@pisell/pisellos 2.3.192 → 2.3.194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/OpenData/types.d.ts +3 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +5 -2
- package/dist/modules/Rules/index.js +30 -19
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +76 -61
- package/dist/solution/BaseSales/index.d.ts +3 -0
- package/dist/solution/BaseSales/index.js +45 -36
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/index.js +35 -25
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/OpenData/types.d.ts +3 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +5 -2
- package/lib/modules/Rules/index.js +19 -9
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +17 -6
- package/lib/solution/BaseSales/index.d.ts +3 -0
- package/lib/solution/BaseSales/index.js +11 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/index.js +7 -0
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ScheduleItem } from '../Schedule/types';
|
|
2
|
+
import type { PosReceiptAutoPrintPaymentStatus } from '../../utils/pos-receipt-auto-print';
|
|
3
|
+
export type { PosReceiptAutoPrintPaymentStatus } from '../../utils/pos-receipt-auto-print';
|
|
2
4
|
export interface MultiLangObject {
|
|
3
5
|
en?: string;
|
|
4
6
|
ja?: string;
|
|
@@ -126,6 +128,7 @@ export interface OpenDataConfig {
|
|
|
126
128
|
}>;
|
|
127
129
|
'documents.invoice_template'?: string | number;
|
|
128
130
|
'documents.invoice_edit'?: RawInvoiceEditConfig;
|
|
131
|
+
'documents.pos_receipt_auto_print_payment_statuses'?: PosReceiptAutoPrintPaymentStatus[];
|
|
129
132
|
/** @deprecated 仅保留旧调用方的类型兼容,Invoice 读取逻辑不再消费该字段。 */
|
|
130
133
|
'documents.invoice'?: RawInvoiceLayoutConfig;
|
|
131
134
|
/** @deprecated Invoice 读取逻辑只消费扁平的 documents.invoice_* 字段。 */
|
|
@@ -637,7 +637,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
637
637
|
generateIdempotencyToken(): string;
|
|
638
638
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
639
639
|
createOrder(params: CommitOrderParams['query']): {
|
|
640
|
-
type: "
|
|
640
|
+
type: "appointment_booking" | "virtual";
|
|
641
641
|
platform: string;
|
|
642
642
|
sales_channel: string;
|
|
643
643
|
order_sales_channel: string;
|
|
@@ -128,7 +128,9 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
|
|
|
128
128
|
*
|
|
129
129
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
130
130
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
131
|
-
* (`metadata.source_product_price
|
|
131
|
+
* (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
|
|
132
|
+
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
133
|
+
* Rules 内部 `getProductTotalPrice` /
|
|
132
134
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
133
135
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
134
136
|
* total(source + option + bundle)对齐。
|
|
@@ -597,7 +597,9 @@ export function getBundleSellingMagnitude(bundle) {
|
|
|
597
597
|
*
|
|
598
598
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
599
599
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
600
|
-
* (`metadata.source_product_price
|
|
600
|
+
* (`metadata.source_product_price`);买赠行的 `price` 为 0,`original_price` 仍保留 source。
|
|
601
|
+
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
602
|
+
* Rules 内部 `getProductTotalPrice` /
|
|
601
603
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
602
604
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
603
605
|
* total(source + option + bundle)对齐。
|
|
@@ -901,7 +903,8 @@ export function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
901
903
|
_id: (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
|
|
902
904
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
903
905
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
904
|
-
|
|
906
|
+
// 赠品基础价不再参与卡券;source 元数据保留原价,供后续与赠送优惠相抵。
|
|
907
|
+
price: metadataAny._giftInfo ? '0.00' : sourcePrice,
|
|
905
908
|
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
906
909
|
total: new Decimal(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
907
910
|
origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
@@ -1222,10 +1222,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1222
|
|
|
1223
1223
|
// 记录已应用优惠券的商品信息
|
|
1224
1224
|
var appliedDiscountProducts = new Map();
|
|
1225
|
+
var hasPayableOptions = function hasPayableOptions(product) {
|
|
1226
|
+
return (product.options || []).reduce(function (total, option) {
|
|
1227
|
+
var _ref14, _ref15, _ref16, _option$_original_pri, _ref17, _option$num;
|
|
1228
|
+
var unitPrice = Number((_ref14 = (_ref15 = (_ref16 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref16 !== void 0 ? _ref16 : option.price) !== null && _ref15 !== void 0 ? _ref15 : option.add_price) !== null && _ref14 !== void 0 ? _ref14 : 0);
|
|
1229
|
+
var quantity = Number((_ref17 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref17 !== void 0 ? _ref17 : 1);
|
|
1230
|
+
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
1231
|
+
return total;
|
|
1232
|
+
}
|
|
1233
|
+
return total.plus(new Decimal(unitPrice).mul(quantity));
|
|
1234
|
+
}, new Decimal(0)).greaterThan(0);
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// 只排除赠品主项的零可抵扣金额;收费 option 和独立 bundle 保持原有规则。
|
|
1238
|
+
var isGiftWithoutDeductibleAmount = function isGiftWithoutDeductibleAmount(flatItem, discount) {
|
|
1239
|
+
var _flatItem$originProdu, _discount$config4;
|
|
1240
|
+
if (flatItem.type !== 'main' || !((_flatItem$originProdu = flatItem.originProduct) !== null && _flatItem$originProdu !== void 0 && (_flatItem$originProdu = _flatItem$originProdu.metadata) !== null && _flatItem$originProdu !== void 0 && _flatItem$originProdu._giftInfo) || Number(flatItem.price || 0) > 0) return false;
|
|
1241
|
+
return !((_discount$config4 = discount.config) !== null && _discount$config4 !== void 0 && _discount$config4.deductOptionPrice) || !hasPayableOptions(flatItem.product);
|
|
1242
|
+
};
|
|
1225
1243
|
|
|
1226
1244
|
// 可用性和实际应用共用金额判断;零基础价商品可按策略抵扣收费 option。
|
|
1227
1245
|
var isDiscountCardPriceAvailable = function isDiscountCardPriceAvailable(flatItem, discount) {
|
|
1228
|
-
var _product$discount_lis2, _discount$
|
|
1246
|
+
var _product$discount_lis2, _discount$config5;
|
|
1229
1247
|
var product = flatItem.type === 'main' ? flatItem.product : flatItem.bundleItem;
|
|
1230
1248
|
if (!(Number(flatItem.price) <= 0 || !flatItem.price) || (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.some(function (item) {
|
|
1231
1249
|
var _item$discount2;
|
|
@@ -1233,18 +1251,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1233
1251
|
})) {
|
|
1234
1252
|
return true;
|
|
1235
1253
|
}
|
|
1236
|
-
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !((_discount$
|
|
1254
|
+
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !((_discount$config5 = discount.config) !== null && _discount$config5 !== void 0 && _discount$config5.deductOptionPrice) || isOrderLevelFixedAmountDiscount(discount)) {
|
|
1237
1255
|
return false;
|
|
1238
1256
|
}
|
|
1239
|
-
return (product
|
|
1240
|
-
var _ref14, _ref15, _ref16, _option$_original_pri, _ref17, _option$num;
|
|
1241
|
-
var unitPrice = Number((_ref14 = (_ref15 = (_ref16 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref16 !== void 0 ? _ref16 : option.price) !== null && _ref15 !== void 0 ? _ref15 : option.add_price) !== null && _ref14 !== void 0 ? _ref14 : 0);
|
|
1242
|
-
var quantity = Number((_ref17 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref17 !== void 0 ? _ref17 : 1);
|
|
1243
|
-
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
1244
|
-
return total;
|
|
1245
|
-
}
|
|
1246
|
-
return total.plus(new Decimal(unitPrice).mul(quantity));
|
|
1247
|
-
}, new Decimal(0)).greaterThan(0);
|
|
1257
|
+
return hasPayableOptions(product);
|
|
1248
1258
|
};
|
|
1249
1259
|
|
|
1250
1260
|
// 首先遍历所有商品和所有优惠券,确定每个优惠券的适用范围,包括isSelected为false的优惠券
|
|
@@ -1274,7 +1284,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1274
1284
|
}
|
|
1275
1285
|
var isItemRewardProductDiscount = _this5.isItemRewardProductDiscount(product);
|
|
1276
1286
|
addModeDiscount.forEach(function (discount) {
|
|
1277
|
-
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$
|
|
1287
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config6;
|
|
1278
1288
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
1279
1289
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
1280
1290
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
@@ -1305,7 +1315,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1305
1315
|
}
|
|
1306
1316
|
|
|
1307
1317
|
// 判断优惠券是否适用于该商品
|
|
1308
|
-
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$
|
|
1318
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && !isGiftWithoutDeductibleAmount(flatItem, discount) && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config6 = discount.config) !== null && _discount$config6 !== void 0 && _discount$config6.isAvailable && (isFullCoveragePass(discount) || isDiscountCardPriceAvailable(flatItem, discount)) && (!isEntitlementPass(discount) || getRemainingEntitlementUses(discount, 0, 1) > 0)) {
|
|
1309
1319
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5, _discount$metadata6;
|
|
1310
1320
|
// 记录此优惠券适用的商品
|
|
1311
1321
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1456,6 +1466,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1456
1466
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1457
1467
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1458
1468
|
var _product$discount_lis4;
|
|
1469
|
+
if (isGiftWithoutDeductibleAmount(flatItem, discount)) return false;
|
|
1459
1470
|
if (_this5.discountScope && !_this5.discountScope(originProduct, discount)) return false;
|
|
1460
1471
|
if (_this5.isItemRewardProductDiscount(product)) return false;
|
|
1461
1472
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
@@ -1469,9 +1480,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1469
1480
|
if (!discount.isSelected) return false;
|
|
1470
1481
|
}
|
|
1471
1482
|
if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '') && !isReapplyEditModeDiscountForProduct) {
|
|
1472
|
-
var _discount$
|
|
1483
|
+
var _discount$config7;
|
|
1473
1484
|
// 如果策略检查后没有config,说明不可用
|
|
1474
|
-
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$
|
|
1485
|
+
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config7 = discount.config) !== null && _discount$config7 !== void 0 && _discount$config7.isAvailable)) {
|
|
1475
1486
|
return false;
|
|
1476
1487
|
}
|
|
1477
1488
|
}
|
|
@@ -1493,8 +1504,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
1504
|
|
|
1494
1505
|
// 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
|
|
1495
1506
|
if (isFullCoveragePass(discount)) {
|
|
1496
|
-
var _discount$
|
|
1497
|
-
var maxUsagePerOrder = (_discount$
|
|
1507
|
+
var _discount$config8;
|
|
1508
|
+
var maxUsagePerOrder = (_discount$config8 = discount.config) === null || _discount$config8 === void 0 ? void 0 : _discount$config8.maxUsagePerOrder;
|
|
1498
1509
|
if (maxUsagePerOrder && maxUsagePerOrder > 0) {
|
|
1499
1510
|
var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
|
|
1500
1511
|
if (currentUsedCount >= maxUsagePerOrder) {
|
|
@@ -2647,7 +2658,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2647
2658
|
}, {
|
|
2648
2659
|
key: "checkPackageSubItemUsageRules",
|
|
2649
2660
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2650
|
-
var _flatItem$product, _flatItem$
|
|
2661
|
+
var _flatItem$product, _flatItem$originProdu2, _flatItem$parentProdu10;
|
|
2651
2662
|
var limitedData = discount.limited_relation_product_data;
|
|
2652
2663
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2653
2664
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2672,7 +2683,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2672
2683
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2673
2684
|
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2674
2685
|
// 主商品id
|
|
2675
|
-
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$
|
|
2686
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu2 = flatItem.originProduct) === null || _flatItem$originProdu2 === void 0 || (_flatItem$originProdu2 = _flatItem$originProdu2._productOrigin) === null || _flatItem$originProdu2 === void 0 ? void 0 : _flatItem$originProdu2.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
|
|
2676
2687
|
|
|
2677
2688
|
// 主商品直接可用
|
|
2678
2689
|
if (isMainProduct) {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -563,6 +563,8 @@ declare class Server {
|
|
|
563
563
|
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
564
564
|
*/
|
|
565
565
|
private shouldAutoPrintCheckoutReceipt;
|
|
566
|
+
/** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
|
|
567
|
+
private shouldAutoPrintReceiptForPaymentStatus;
|
|
566
568
|
private shouldBuildSmallTicketData;
|
|
567
569
|
private shouldPrintSyncedOrder;
|
|
568
570
|
private hasPaymentStatus;
|
package/dist/server/index.js
CHANGED
|
@@ -49,6 +49,7 @@ import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPending
|
|
|
49
49
|
import { finalizeSalesNotesForCheckout } from "../modules/Order/salesNotes";
|
|
50
50
|
import { normalizeOrderCollections } from "../modules/Order/utils/orderCollectionIdentity";
|
|
51
51
|
import { stripOsPrivatePayloadFields } from "../utils/os-private-payload";
|
|
52
|
+
import { normalizePosReceiptAutoPrintPaymentStatuses, OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD } from "../utils/pos-receipt-auto-print";
|
|
52
53
|
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "../modules/OpenData";
|
|
53
54
|
var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
|
|
54
55
|
var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
|
|
@@ -6592,7 +6593,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6592
6593
|
value: function () {
|
|
6593
6594
|
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
|
|
6594
6595
|
var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
|
|
6595
|
-
var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
6596
|
+
var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
6596
6597
|
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6597
6598
|
while (1) switch (_context66.prev = _context66.next) {
|
|
6598
6599
|
case 0:
|
|
@@ -6629,6 +6630,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6629
6630
|
data = extractedTemplateSettings.data;
|
|
6630
6631
|
invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
|
|
6631
6632
|
invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
|
|
6633
|
+
receiptAutoPrintPaymentStatuses = normalizePosReceiptAutoPrintPaymentStatuses(data === null || data === void 0 ? void 0 : data[OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD]);
|
|
6632
6634
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
6633
6635
|
backendPath: backendPath,
|
|
6634
6636
|
order_id: data === null || data === void 0 ? void 0 : data.order_id,
|
|
@@ -6636,7 +6638,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6636
6638
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6637
6639
|
});
|
|
6638
6640
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
6639
|
-
_context66.next =
|
|
6641
|
+
_context66.next = 19;
|
|
6640
6642
|
break;
|
|
6641
6643
|
}
|
|
6642
6644
|
return _context66.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
@@ -6644,19 +6646,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6644
6646
|
data: data,
|
|
6645
6647
|
title: title,
|
|
6646
6648
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6647
|
-
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6649
|
+
invoiceTemplateSettings: invoiceTemplateSettings,
|
|
6650
|
+
receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
|
|
6648
6651
|
}));
|
|
6649
|
-
case
|
|
6650
|
-
_context66.next =
|
|
6652
|
+
case 19:
|
|
6653
|
+
_context66.next = 21;
|
|
6651
6654
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6652
|
-
case
|
|
6655
|
+
case 21:
|
|
6653
6656
|
normalizedData = _context66.sent;
|
|
6654
|
-
_context66.next =
|
|
6657
|
+
_context66.next = 24;
|
|
6655
6658
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
6656
|
-
case
|
|
6659
|
+
case 24:
|
|
6657
6660
|
numberedData = _context66.sent;
|
|
6658
6661
|
checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
6659
|
-
_context66.next =
|
|
6662
|
+
_context66.next = 28;
|
|
6660
6663
|
return this.handlePendingSyncCheckoutOrder({
|
|
6661
6664
|
backendPath: backendPath,
|
|
6662
6665
|
data: checkoutData,
|
|
@@ -6664,41 +6667,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
6664
6667
|
reason: 'checkout 已转入设备任务同步',
|
|
6665
6668
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6666
6669
|
});
|
|
6667
|
-
case
|
|
6670
|
+
case 28:
|
|
6668
6671
|
pendingResult = _context66.sent;
|
|
6669
6672
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
6670
|
-
_context66.next =
|
|
6673
|
+
_context66.next = 43;
|
|
6671
6674
|
break;
|
|
6672
6675
|
}
|
|
6673
6676
|
pendingOrder = pendingResult.data;
|
|
6674
|
-
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.
|
|
6675
|
-
_context66.next =
|
|
6677
|
+
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6678
|
+
_context66.next = 41;
|
|
6676
6679
|
break;
|
|
6677
6680
|
}
|
|
6678
|
-
_context66.prev =
|
|
6679
|
-
_context66.next =
|
|
6681
|
+
_context66.prev = 32;
|
|
6682
|
+
_context66.next = 35;
|
|
6680
6683
|
return this.dispatchLocalReceiptPrint({
|
|
6681
6684
|
checkoutData: checkoutData,
|
|
6682
6685
|
order: pendingOrder,
|
|
6683
6686
|
response: pendingResult,
|
|
6684
|
-
requireFullyPaid:
|
|
6687
|
+
requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
|
|
6685
6688
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6686
6689
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6687
6690
|
});
|
|
6688
|
-
case
|
|
6689
|
-
_context66.next =
|
|
6691
|
+
case 35:
|
|
6692
|
+
_context66.next = 41;
|
|
6690
6693
|
break;
|
|
6691
|
-
case
|
|
6692
|
-
_context66.prev =
|
|
6693
|
-
_context66.t1 = _context66["catch"](
|
|
6694
|
+
case 37:
|
|
6695
|
+
_context66.prev = 37;
|
|
6696
|
+
_context66.t1 = _context66["catch"](32);
|
|
6694
6697
|
// The sale is already persisted. A failed receipt must not cancel its
|
|
6695
6698
|
// sync task or send an unfiltered fallback to the printer.
|
|
6696
6699
|
pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context66.t1);
|
|
6697
6700
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
|
|
6698
6701
|
error: pendingResult.receipt_print_error
|
|
6699
6702
|
});
|
|
6700
|
-
case
|
|
6701
|
-
_context66.next =
|
|
6703
|
+
case 41:
|
|
6704
|
+
_context66.next = 43;
|
|
6702
6705
|
return this.dispatchCheckoutSyncTask({
|
|
6703
6706
|
backendPath: backendPath,
|
|
6704
6707
|
data: checkoutData,
|
|
@@ -6706,9 +6709,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6706
6709
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6707
6710
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6708
6711
|
});
|
|
6709
|
-
case
|
|
6712
|
+
case 43:
|
|
6710
6713
|
if (pendingResult.data.order_id) {
|
|
6711
|
-
_context66.next =
|
|
6714
|
+
_context66.next = 45;
|
|
6712
6715
|
break;
|
|
6713
6716
|
}
|
|
6714
6717
|
return _context66.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
@@ -6716,13 +6719,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6716
6719
|
order_id: pendingResult.data.external_sale_number
|
|
6717
6720
|
})
|
|
6718
6721
|
}));
|
|
6719
|
-
case 44:
|
|
6720
|
-
return _context66.abrupt("return", pendingResult);
|
|
6721
6722
|
case 45:
|
|
6723
|
+
return _context66.abrupt("return", pendingResult);
|
|
6724
|
+
case 46:
|
|
6722
6725
|
case "end":
|
|
6723
6726
|
return _context66.stop();
|
|
6724
6727
|
}
|
|
6725
|
-
}, _callee66, this, [[
|
|
6728
|
+
}, _callee66, this, [[32, 37]]);
|
|
6726
6729
|
}));
|
|
6727
6730
|
function handleOrderCheckoutSubmit(_x73) {
|
|
6728
6731
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
@@ -6734,11 +6737,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6734
6737
|
value: function () {
|
|
6735
6738
|
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
|
|
6736
6739
|
var _this$app15;
|
|
6737
|
-
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6740
|
+
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6738
6741
|
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6739
6742
|
while (1) switch (_context67.prev = _context67.next) {
|
|
6740
6743
|
case 0:
|
|
6741
|
-
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6744
|
+
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
|
|
6742
6745
|
if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
|
|
6743
6746
|
_context67.next = 4;
|
|
6744
6747
|
break;
|
|
@@ -6776,7 +6779,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6776
6779
|
case 11:
|
|
6777
6780
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
6778
6781
|
syncedOrder = syncResult.syncedOrder;
|
|
6779
|
-
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.
|
|
6782
|
+
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
|
|
6780
6783
|
_context67.next = 23;
|
|
6781
6784
|
break;
|
|
6782
6785
|
}
|
|
@@ -6786,7 +6789,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6786
6789
|
checkoutData: syncResult.checkoutData,
|
|
6787
6790
|
order: syncedOrder,
|
|
6788
6791
|
response: syncResult.normalizedResponse,
|
|
6789
|
-
requireFullyPaid:
|
|
6792
|
+
requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
|
|
6790
6793
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6791
6794
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6792
6795
|
});
|
|
@@ -7101,6 +7104,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
7101
7104
|
if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
|
|
7102
7105
|
return ((_this$app16 = this.app) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.storage) === null || _this$app16 === void 0 || (_this$app16$getStorag = _this$app16.getStorage) === null || _this$app16$getStorag === void 0 ? void 0 : _this$app16$getStorag.call(_this$app16, AUTO_PRINT_STORAGE_KEY)) !== 'false';
|
|
7103
7106
|
}
|
|
7107
|
+
|
|
7108
|
+
/** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
|
|
7109
|
+
}, {
|
|
7110
|
+
key: "shouldAutoPrintReceiptForPaymentStatus",
|
|
7111
|
+
value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
|
|
7112
|
+
var _this19 = this;
|
|
7113
|
+
if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
|
|
7114
|
+
var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
|
|
7115
|
+
return statuses.some(function (status) {
|
|
7116
|
+
return status === 'paid' ? _this19.isSalesOrderFullyPaid(order) : paymentStatus === status;
|
|
7117
|
+
});
|
|
7118
|
+
}
|
|
7104
7119
|
}, {
|
|
7105
7120
|
key: "shouldBuildSmallTicketData",
|
|
7106
7121
|
value: function shouldBuildSmallTicketData(order, invoiceTemplateSettings) {
|
|
@@ -7146,13 +7161,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
7146
7161
|
}, {
|
|
7147
7162
|
key: "sumPaidOrderPayments",
|
|
7148
7163
|
value: function sumPaidOrderPayments(payments) {
|
|
7149
|
-
var
|
|
7164
|
+
var _this20 = this;
|
|
7150
7165
|
if (!Array.isArray(payments)) return 0;
|
|
7151
7166
|
return payments.reduce(function (sum, payment) {
|
|
7152
7167
|
var _payment$amount;
|
|
7153
7168
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
7154
7169
|
if (status !== 'paid') return sum;
|
|
7155
|
-
return sum +
|
|
7170
|
+
return sum + _this20.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
7156
7171
|
}, 0);
|
|
7157
7172
|
}
|
|
7158
7173
|
}, {
|
|
@@ -7168,7 +7183,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7168
7183
|
value: function () {
|
|
7169
7184
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
|
|
7170
7185
|
var _this$products3,
|
|
7171
|
-
|
|
7186
|
+
_this21 = this;
|
|
7172
7187
|
var products, productIdSet, productIds, entries;
|
|
7173
7188
|
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7174
7189
|
while (1) switch (_context72.prev = _context72.next) {
|
|
@@ -7201,20 +7216,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
7201
7216
|
_context72.next = 8;
|
|
7202
7217
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
7203
7218
|
var _ref76 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(id) {
|
|
7204
|
-
var
|
|
7219
|
+
var _this21$products, _this21$products$getP, product;
|
|
7205
7220
|
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7206
7221
|
while (1) switch (_context71.prev = _context71.next) {
|
|
7207
7222
|
case 0:
|
|
7208
7223
|
_context71.prev = 0;
|
|
7209
7224
|
_context71.next = 3;
|
|
7210
|
-
return (
|
|
7225
|
+
return (_this21$products = _this21.products) === null || _this21$products === void 0 || (_this21$products$getP = _this21$products.getProductById) === null || _this21$products$getP === void 0 ? void 0 : _this21$products$getP.call(_this21$products, Number(id));
|
|
7211
7226
|
case 3:
|
|
7212
7227
|
product = _context71.sent;
|
|
7213
7228
|
return _context71.abrupt("return", product ? [String(id), product] : null);
|
|
7214
7229
|
case 7:
|
|
7215
7230
|
_context71.prev = 7;
|
|
7216
7231
|
_context71.t0 = _context71["catch"](0);
|
|
7217
|
-
|
|
7232
|
+
_this21.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
7218
7233
|
product_id: id,
|
|
7219
7234
|
error: _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0)
|
|
7220
7235
|
});
|
|
@@ -7365,7 +7380,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7365
7380
|
key: "withSalesDetailProductSnapshots",
|
|
7366
7381
|
value: function () {
|
|
7367
7382
|
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
|
|
7368
|
-
var
|
|
7383
|
+
var _this22 = this;
|
|
7369
7384
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
7370
7385
|
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7371
7386
|
while (1) switch (_context74.prev = _context74.next) {
|
|
@@ -7389,8 +7404,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7389
7404
|
case 8:
|
|
7390
7405
|
hasChanged = false;
|
|
7391
7406
|
enrichedProducts = products.map(function (product) {
|
|
7392
|
-
var productWithBundleSnapshots =
|
|
7393
|
-
var nextProduct =
|
|
7407
|
+
var productWithBundleSnapshots = _this22.withBundleCatalogSnapshots(product, snapshotMap);
|
|
7408
|
+
var nextProduct = _this22.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
7394
7409
|
if (nextProduct !== product) hasChanged = true;
|
|
7395
7410
|
return nextProduct;
|
|
7396
7411
|
});
|
|
@@ -7418,13 +7433,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
7418
7433
|
}, {
|
|
7419
7434
|
key: "withPendingSyncProductTitles",
|
|
7420
7435
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
7421
|
-
var
|
|
7436
|
+
var _this23 = this;
|
|
7422
7437
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
7423
7438
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
7424
7439
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
7425
7440
|
products: products.map(function (product) {
|
|
7426
7441
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
7427
|
-
product_title:
|
|
7442
|
+
product_title: _this23.buildProductTitleSnapshot(product, productMap)
|
|
7428
7443
|
});
|
|
7429
7444
|
})
|
|
7430
7445
|
});
|
|
@@ -7435,7 +7450,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7435
7450
|
var _product$product_id4,
|
|
7436
7451
|
_product$product,
|
|
7437
7452
|
_fallbackProduct$prod,
|
|
7438
|
-
|
|
7453
|
+
_this24 = this;
|
|
7439
7454
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
7440
7455
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
7441
7456
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -7443,7 +7458,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7443
7458
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
7444
7459
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
7445
7460
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
7446
|
-
snapshot[key] =
|
|
7461
|
+
snapshot[key] = _this24.resolveProductTitleValue(ownTitle, key, currentLocale) || _this24.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
7447
7462
|
return snapshot;
|
|
7448
7463
|
}, {});
|
|
7449
7464
|
}
|
|
@@ -7542,14 +7557,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
7542
7557
|
key: "enrichPaymentNamesByCode",
|
|
7543
7558
|
value: function () {
|
|
7544
7559
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
|
|
7545
|
-
var
|
|
7560
|
+
var _this25 = this;
|
|
7546
7561
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
7547
7562
|
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7548
7563
|
while (1) switch (_context75.prev = _context75.next) {
|
|
7549
7564
|
case 0:
|
|
7550
7565
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
7551
7566
|
hasMissingName = payments.some(function (payment) {
|
|
7552
|
-
return
|
|
7567
|
+
return _this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
7553
7568
|
});
|
|
7554
7569
|
if (hasMissingName) {
|
|
7555
7570
|
_context75.next = 4;
|
|
@@ -7582,9 +7597,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7582
7597
|
}
|
|
7583
7598
|
hasResolvedName = false;
|
|
7584
7599
|
enrichedPayments = payments.map(function (payment) {
|
|
7585
|
-
if (!
|
|
7586
|
-
if (!
|
|
7587
|
-
var name = nameByCode.get(
|
|
7600
|
+
if (!_this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
7601
|
+
if (!_this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
7602
|
+
var name = nameByCode.get(_this25.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
7588
7603
|
if (!name) return payment;
|
|
7589
7604
|
hasResolvedName = true;
|
|
7590
7605
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -8450,10 +8465,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
8450
8465
|
value: function extractBackendErrorResponse(error) {
|
|
8451
8466
|
var _error$response3,
|
|
8452
8467
|
_error$response4,
|
|
8453
|
-
|
|
8468
|
+
_this26 = this;
|
|
8454
8469
|
var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
|
|
8455
8470
|
return candidates.find(function (candidate) {
|
|
8456
|
-
return
|
|
8471
|
+
return _this26.isExplicitBackendErrorResponse(candidate);
|
|
8457
8472
|
}) || null;
|
|
8458
8473
|
}
|
|
8459
8474
|
}, {
|
|
@@ -8815,7 +8830,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8815
8830
|
value: (function () {
|
|
8816
8831
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(context, options) {
|
|
8817
8832
|
var _menu_list_ids$length3,
|
|
8818
|
-
|
|
8833
|
+
_this27 = this;
|
|
8819
8834
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
8820
8835
|
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
|
8821
8836
|
while (1) switch (_context82.prev = _context82.next) {
|
|
@@ -9028,9 +9043,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
9028
9043
|
}
|
|
9029
9044
|
tMenu = performance.now();
|
|
9030
9045
|
getActiveMenus = function getActiveMenus() {
|
|
9031
|
-
return
|
|
9032
|
-
var
|
|
9033
|
-
return ((
|
|
9046
|
+
return _this27.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
9047
|
+
var _this27$schedule;
|
|
9048
|
+
return ((_this27$schedule = _this27.schedule) === null || _this27$schedule === void 0 ? void 0 : _this27$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
9034
9049
|
});
|
|
9035
9050
|
};
|
|
9036
9051
|
activeMenuList = getActiveMenus();
|
|
@@ -9343,7 +9358,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9343
9358
|
}, {
|
|
9344
9359
|
key: "notifySalesSearchSubscribers",
|
|
9345
9360
|
value: function notifySalesSearchSubscribers(payload) {
|
|
9346
|
-
var
|
|
9361
|
+
var _this28 = this;
|
|
9347
9362
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
9348
9363
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
9349
9364
|
if (changedOrders.length === 0) {
|
|
@@ -9361,21 +9376,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
9361
9376
|
subscriber = _step20$value[1];
|
|
9362
9377
|
try {
|
|
9363
9378
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
9364
|
-
var orderId =
|
|
9379
|
+
var orderId = _this28.getSalesSearchOrderId(order);
|
|
9365
9380
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
9366
9381
|
});
|
|
9367
9382
|
if (changedVisibleOrders.length === 0) {
|
|
9368
9383
|
return 1; // continue
|
|
9369
9384
|
}
|
|
9370
|
-
subscriber.callback(
|
|
9371
|
-
|
|
9385
|
+
subscriber.callback(_this28.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
9386
|
+
_this28.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
9372
9387
|
subscriberId: subscriberId,
|
|
9373
9388
|
kind: subscriber.kind,
|
|
9374
9389
|
count: changedVisibleOrders.length
|
|
9375
9390
|
});
|
|
9376
9391
|
} catch (error) {
|
|
9377
9392
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
9378
|
-
|
|
9393
|
+
_this28.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
9379
9394
|
subscriberId: subscriberId,
|
|
9380
9395
|
error: errorMessage
|
|
9381
9396
|
});
|
|
@@ -13,6 +13,7 @@ import type { Discount, VirtualCurrencyAsset } from '../../modules/Discount/type
|
|
|
13
13
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
14
14
|
export * from './types';
|
|
15
15
|
import { ProductList } from '../../modules/ProductList';
|
|
16
|
+
import { type PosReceiptAutoPrintPaymentStatus } from '../../utils/pos-receipt-auto-print';
|
|
16
17
|
import { PaymentModule } from '../../modules/Payment';
|
|
17
18
|
import type { PaymentMethod, RoundingResult, WalletAssetId, WalletAssetsBehaviorOptions, WalletAssetsSnapshot, WalletAssetsState, WalletAssetSelectionSource, ScanWalletAssetResult } from '../../modules/Payment/types';
|
|
18
19
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
@@ -199,6 +200,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
199
200
|
private getFulfillmentRefMode;
|
|
200
201
|
private getCachedInvoiceLayoutConfig;
|
|
201
202
|
private getCachedInvoiceTemplateSettings;
|
|
203
|
+
/** Only solutions with a current POS business configuration opt into this receipt policy. */
|
|
204
|
+
protected getPosReceiptAutoPrintPaymentStatuses(): PosReceiptAutoPrintPaymentStatus[] | undefined;
|
|
202
205
|
private buildSubmitPayloadEnhancerWithOpenDataConfig;
|
|
203
206
|
/**
|
|
204
207
|
* 工厂入口:根据子模块名实例化对应模块。
|