@pisell/pisellos 2.2.267 → 2.2.269

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.
Files changed (121) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
  14. package/dist/modules/OpenData/index.d.ts +2 -0
  15. package/dist/modules/OpenData/index.js +8 -0
  16. package/dist/modules/Order/index.d.ts +33 -13
  17. package/dist/modules/Order/index.js +883 -524
  18. package/dist/modules/Order/payment-utils.d.ts +26 -0
  19. package/dist/modules/Order/payment-utils.js +225 -0
  20. package/dist/modules/Order/types.d.ts +56 -4
  21. package/dist/modules/Order/types.js +11 -0
  22. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  23. package/dist/modules/Order/utils.js +10 -6
  24. package/dist/modules/Payment/index.d.ts +2 -0
  25. package/dist/modules/Payment/index.js +78 -49
  26. package/dist/modules/Payment/types.d.ts +104 -25
  27. package/dist/modules/Payment/types.js +17 -0
  28. package/dist/modules/Payment/walletpass.d.ts +38 -1
  29. package/dist/modules/Payment/walletpass.js +917 -114
  30. package/dist/modules/Rules/index.d.ts +3 -0
  31. package/dist/modules/Rules/index.js +146 -106
  32. package/dist/modules/SalesSummary/utils.js +7 -1
  33. package/dist/server/index.d.ts +16 -0
  34. package/dist/server/index.js +1940 -1043
  35. package/dist/server/modules/index.d.ts +1 -1
  36. package/dist/server/modules/order/index.d.ts +70 -4
  37. package/dist/server/modules/order/index.js +1816 -728
  38. package/dist/server/modules/order/types.d.ts +25 -3
  39. package/dist/server/modules/order/types.js +7 -1
  40. package/dist/solution/BaseSales/index.d.ts +118 -9
  41. package/dist/solution/BaseSales/index.js +1849 -480
  42. package/dist/solution/BaseSales/types.d.ts +55 -1
  43. package/dist/solution/BaseSales/types.js +2 -1
  44. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  45. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  48. package/dist/solution/BookingTicket/index.d.ts +8 -16
  49. package/dist/solution/BookingTicket/index.js +138 -52
  50. package/dist/solution/BookingTicket/types.d.ts +4 -0
  51. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  52. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  53. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  54. package/dist/solution/Sales/index.d.ts +2 -0
  55. package/dist/solution/Sales/index.js +26 -4
  56. package/dist/solution/ScanOrder/index.js +31 -20
  57. package/dist/solution/VenueBooking/index.d.ts +1 -0
  58. package/dist/solution/VenueBooking/index.js +30 -19
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/utils/payment-number.d.ts +9 -0
  61. package/dist/utils/payment-number.js +69 -0
  62. package/lib/core/index.d.ts +2 -0
  63. package/lib/core/index.js +4 -0
  64. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  65. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  66. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  67. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  68. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  69. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  70. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  71. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  72. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  73. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
  74. package/lib/modules/OpenData/index.d.ts +2 -0
  75. package/lib/modules/OpenData/index.js +5 -0
  76. package/lib/modules/Order/index.d.ts +33 -13
  77. package/lib/modules/Order/index.js +306 -79
  78. package/lib/modules/Order/payment-utils.d.ts +26 -0
  79. package/lib/modules/Order/payment-utils.js +224 -0
  80. package/lib/modules/Order/types.d.ts +56 -4
  81. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  82. package/lib/modules/Order/utils.js +11 -4
  83. package/lib/modules/Payment/index.d.ts +2 -0
  84. package/lib/modules/Payment/index.js +33 -12
  85. package/lib/modules/Payment/types.d.ts +104 -25
  86. package/lib/modules/Payment/types.js +1 -0
  87. package/lib/modules/Payment/walletpass.d.ts +38 -1
  88. package/lib/modules/Payment/walletpass.js +730 -21
  89. package/lib/modules/Rules/index.d.ts +3 -0
  90. package/lib/modules/Rules/index.js +54 -21
  91. package/lib/modules/SalesSummary/utils.js +5 -1
  92. package/lib/server/index.d.ts +16 -0
  93. package/lib/server/index.js +670 -18
  94. package/lib/server/modules/index.d.ts +1 -1
  95. package/lib/server/modules/order/index.d.ts +70 -4
  96. package/lib/server/modules/order/index.js +818 -69
  97. package/lib/server/modules/order/types.d.ts +25 -3
  98. package/lib/server/modules/order/types.js +1 -0
  99. package/lib/solution/BaseSales/index.d.ts +118 -9
  100. package/lib/solution/BaseSales/index.js +902 -38
  101. package/lib/solution/BaseSales/types.d.ts +55 -1
  102. package/lib/solution/BaseSales/types.js +2 -1
  103. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  104. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  105. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  106. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  107. package/lib/solution/BookingTicket/index.d.ts +8 -16
  108. package/lib/solution/BookingTicket/index.js +63 -9
  109. package/lib/solution/BookingTicket/types.d.ts +4 -0
  110. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  111. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  112. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  113. package/lib/solution/Sales/index.d.ts +2 -0
  114. package/lib/solution/Sales/index.js +20 -6
  115. package/lib/solution/ScanOrder/index.js +8 -0
  116. package/lib/solution/VenueBooking/index.d.ts +1 -0
  117. package/lib/solution/VenueBooking/index.js +8 -0
  118. package/lib/types/index.d.ts +1 -0
  119. package/lib/utils/payment-number.d.ts +9 -0
  120. package/lib/utils/payment-number.js +64 -0
  121. package/package.json +1 -1
@@ -37,6 +37,8 @@ import Decimal from 'decimal.js';
37
37
  import { cloneDeep, mergeWith } from 'lodash-es';
38
38
  import { createModule } from "../BookingByStep/types";
39
39
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
40
+ import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
41
+ import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
40
42
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
41
43
  import dayjs from 'dayjs';
42
44
  export * from "./types";
@@ -44,6 +46,89 @@ import { QuotationModule } from "../../modules/Quotation";
44
46
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
45
47
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
46
48
  var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
49
+ var WALLET_PAYMENT_CODE_BY_TAG = {
50
+ product_voucher: 'PRODUCTVOUCHER',
51
+ gift_card: 'GIFTCARD',
52
+ point_card: 'POINTCARD'
53
+ };
54
+ function getSharedWalletAssetId(asset) {
55
+ var _ref, _asset$id;
56
+ return (_ref = (_asset$id = asset === null || asset === void 0 ? void 0 : asset.id) !== null && _asset$id !== void 0 ? _asset$id : asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _ref !== void 0 ? _ref : asset === null || asset === void 0 ? void 0 : asset.code;
57
+ }
58
+ function getSharedWalletAssetAmount(asset) {
59
+ var _ref2, _ref3, _ref4, _ref5, _asset$edit_current_a;
60
+ var value = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_asset$edit_current_a = asset === null || asset === void 0 ? void 0 : asset.edit_current_amount) !== null && _asset$edit_current_a !== void 0 ? _asset$edit_current_a : asset === null || asset === void 0 ? void 0 : asset._available_max_amount) !== null && _ref5 !== void 0 ? _ref5 : (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' ? asset === null || asset === void 0 ? void 0 : asset.recommended_usage_amount : asset === null || asset === void 0 ? void 0 : asset.available_max_amount) !== null && _ref4 !== void 0 ? _ref4 : asset === null || asset === void 0 ? void 0 : asset.actualDeduction) !== null && _ref3 !== void 0 ? _ref3 : asset === null || asset === void 0 ? void 0 : asset.amount) !== null && _ref2 !== void 0 ? _ref2 : 0;
61
+ var amount = Number(value);
62
+ return Number.isFinite(amount) && amount > 0 ? amount : 0;
63
+ }
64
+ function isRejectedSalesSubmitResult(result) {
65
+ var _result$response, _result$response2;
66
+ var candidates = [result, result === null || result === void 0 ? void 0 : result.data, result === null || result === void 0 || (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.data, result === null || result === void 0 || (_result$response2 = result.response) === null || _result$response2 === void 0 ? void 0 : _result$response2.body];
67
+ return candidates.some(function (candidate) {
68
+ var _candidate$code;
69
+ if (!candidate || _typeof(candidate) !== 'object') return false;
70
+ var responseCode = Number((_candidate$code = candidate.code) !== null && _candidate$code !== void 0 ? _candidate$code : candidate.statusCode);
71
+ if (Number.isFinite(responseCode) && responseCode >= 400) return true;
72
+ if (candidate.status === false || candidate.success === false || candidate.result === false) {
73
+ return true;
74
+ }
75
+ return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
76
+ });
77
+ }
78
+ function getSalesSubmitErrorMessage(result) {
79
+ var _result$data, _result$data2;
80
+ return (result === null || result === void 0 ? void 0 : result.message) || (result === null || result === void 0 ? void 0 : result.msg) || (result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.message) || (result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.msg) || 'Wallet 支付确认失败';
81
+ }
82
+ function toWalletFundValue(value) {
83
+ try {
84
+ return new Decimal(value || 0).toDecimalPlaces(2).toFixed(2);
85
+ } catch (_unused) {
86
+ return '0.00';
87
+ }
88
+ }
89
+ function subtractWalletFundValue(left, right) {
90
+ try {
91
+ return new Decimal(left || 0).minus(right || 0).toDecimalPlaces(2).toFixed(2);
92
+ } catch (_unused2) {
93
+ return '0.00';
94
+ }
95
+ }
96
+ function getSharedWalletPassUseValue(params) {
97
+ var asset = params.asset,
98
+ amount = params.amount,
99
+ paymentMethod = params.paymentMethod;
100
+ var configuredValue = Number(asset === null || asset === void 0 ? void 0 : asset.wallet_pass_use_value);
101
+ if (Number.isFinite(configuredValue) && configuredValue > 0) {
102
+ return configuredValue;
103
+ }
104
+ var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
105
+ var usageUnit = asset === null || asset === void 0 ? void 0 : asset.wallet_pass_usage_unit;
106
+ if (isPointCard && usageUnit !== null && usageUnit !== void 0 && usageUnit.points && usageUnit !== null && usageUnit !== void 0 && usageUnit.price) {
107
+ return new Decimal(amount).div(usageUnit.price).mul(usageUnit.points).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
108
+ }
109
+ return amount;
110
+ }
111
+ function buildSharedWalletFundRecord(params) {
112
+ var _ref6, _ref7, _asset$balance_par_va, _asset$voucher_id;
113
+ var asset = params.asset,
114
+ amount = params.amount,
115
+ paymentMethod = params.paymentMethod;
116
+ var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
117
+ var usingBeforeValue = (_ref6 = (_ref7 = (_asset$balance_par_va = asset === null || asset === void 0 ? void 0 : asset.balance_par_value) !== null && _asset$balance_par_va !== void 0 ? _asset$balance_par_va : asset === null || asset === void 0 ? void 0 : asset.balance) !== null && _ref7 !== void 0 ? _ref7 : asset === null || asset === void 0 ? void 0 : asset.using_before_value) !== null && _ref6 !== void 0 ? _ref6 : 0;
118
+ var walletPassUseValue = getSharedWalletPassUseValue(params);
119
+ var usingValue = isPointCard ? walletPassUseValue : amount;
120
+ var walletPassName = (asset === null || asset === void 0 ? void 0 : asset.wallet_pass_name) || (asset === null || asset === void 0 ? void 0 : asset.format_title) || (asset === null || asset === void 0 ? void 0 : asset.product_name) || (asset === null || asset === void 0 ? void 0 : asset.name) || paymentMethod.name;
121
+ return {
122
+ voucher_id: (_asset$voucher_id = asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _asset$voucher_id !== void 0 ? _asset$voucher_id : asset === null || asset === void 0 ? void 0 : asset.id,
123
+ wallet_pass_name: walletPassName && _typeof(walletPassName) === 'object' ? walletPassName : {
124
+ default: walletPassName || ''
125
+ },
126
+ code: (asset === null || asset === void 0 ? void 0 : asset.code) || (asset === null || asset === void 0 ? void 0 : asset.tag),
127
+ encoded: asset === null || asset === void 0 ? void 0 : asset.encoded,
128
+ using_before_value: toWalletFundValue(usingBeforeValue),
129
+ using_after_value: subtractWalletFundValue(usingBeforeValue, usingValue)
130
+ };
131
+ }
47
132
  function isBaseSalesManualProductDiscountProduct(product) {
48
133
  var _product$metadata, _product$metadata2;
49
134
  return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
@@ -72,6 +157,10 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
72
157
  function isBaseSalesHistoricalDiscountEntry(discount) {
73
158
  return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
74
159
  }
160
+ function getBaseSalesUniqueArrayMetadataKey(key) {
161
+ if (key === 'products' || key === 'bookings') return 'unique_identification_number';
162
+ return null;
163
+ }
75
164
  var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
76
165
  product: 'order_detail_id',
77
166
  booking: 'schedule_event_id',
@@ -143,6 +232,15 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
143
232
  return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
144
233
  }
145
234
  function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
235
+ if (kind === 'payment') {
236
+ return mergeOrderPaymentListsByIdentity(currentValue, incomingValue, strategy === 'preserve-local' ? {
237
+ preserveUnmatchedExisting: true
238
+ } : {
239
+ preserveUnmatchedExistingWhen: function preserveUnmatchedExistingWhen(payment) {
240
+ return isIdentifiedPendingOrderPayment(payment) || !getOrderCollectionPersistentId('payment', payment);
241
+ }
242
+ });
243
+ }
146
244
  var currentItems = normalizeOrderCollection(kind, currentValue, {
147
245
  ensureUid: false
148
246
  }).items;
@@ -189,6 +287,34 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
189
287
  }
190
288
  return normalizedRecord;
191
289
  }
290
+ function getBaseSalesMetadataUid(item, metadataKey) {
291
+ var _item$metadata$metada, _item$metadata;
292
+ var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
293
+ if (uid === undefined || uid === null || uid === '') return null;
294
+ return String(uid);
295
+ }
296
+ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
297
+ var result = [];
298
+ var indexByUid = new Map();
299
+ var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
300
+ var clonedItem = cloneDeep(item);
301
+ var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
302
+ if (!uid) {
303
+ result.push(clonedItem);
304
+ return;
305
+ }
306
+ var existingIndex = indexByUid.get(uid);
307
+ if (existingIndex !== undefined) {
308
+ result[existingIndex] = clonedItem;
309
+ return;
310
+ }
311
+ indexByUid.set(uid, result.length);
312
+ result.push(clonedItem);
313
+ };
314
+ currentValue.forEach(appendOrReplaceByUid);
315
+ loadedValue.forEach(appendOrReplaceByUid);
316
+ return result;
317
+ }
192
318
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
193
319
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
194
320
  ensureUid: false
@@ -206,6 +332,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
206
332
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
207
333
  }
208
334
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
335
+ if (key === 'payments' || key === 'payment') {
336
+ return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
337
+ preserveUnmatchedExisting: true
338
+ });
339
+ }
340
+ var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
341
+ if (metadataKey) {
342
+ return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
343
+ }
209
344
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
210
345
  }
211
346
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -217,6 +352,22 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
217
352
  delete mergedRecord.request_unique_idempotency_token;
218
353
  return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
219
354
  }
355
+ function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
356
+ if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
357
+ var record = _objectSpread({}, sourceRecord);
358
+ if (Array.isArray(sourceRecord.payments)) {
359
+ record.payments = sourceRecord.payments.filter(function (payment) {
360
+ return !isPendingOrderPayment(payment);
361
+ });
362
+ }
363
+ // 兼容少量历史详情数据使用的单数 payment 字段。
364
+ if (Array.isArray(sourceRecord.payment)) {
365
+ record.payment = sourceRecord.payment.filter(function (payment) {
366
+ return !isPendingOrderPayment(payment);
367
+ });
368
+ }
369
+ return record;
370
+ }
220
371
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
221
372
  _inherits(BaseSalesImpl, _BaseModule);
222
373
  var _super = _createSuper(BaseSalesImpl);
@@ -236,6 +387,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
236
387
  });
237
388
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
238
389
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
390
+ /**
391
+ * 由已在初始化阶段解析过设备短号的业务解决方案写入。
392
+ * 未设置时,支付编号仍按原逻辑实时读取设备信息。
393
+ */
394
+ _defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
239
395
  /**
240
396
  * window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
241
397
  * `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
@@ -253,6 +409,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
253
409
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
254
410
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
255
411
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
412
+ _defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
256
413
  _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
257
414
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
258
415
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
@@ -445,12 +602,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
445
602
  return _context3.abrupt("return");
446
603
  case 14:
447
604
  this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
448
- var _getTempOrder, _ref2;
605
+ var _getTempOrder, _ref9;
449
606
  var currentTempOrder, record, sales;
450
607
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
451
608
  while (1) switch (_context2.prev = _context2.next) {
452
609
  case 0:
453
- currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
610
+ currentTempOrder = (_getTempOrder = (_ref9 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref9);
454
611
  record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
455
612
  _context2.next = 4;
456
613
  return _this2.store.order.hydrateTempOrderFromRecord(record, {
@@ -519,7 +676,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
519
676
  hydratedSales = null;
520
677
  skippedBeforeHydrate = false;
521
678
  hydrateTask = /*#__PURE__*/function () {
522
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
679
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
523
680
  var sales;
524
681
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
525
682
  while (1) switch (_context4.prev = _context4.next) {
@@ -564,7 +721,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
564
721
  }, _callee4);
565
722
  }));
566
723
  return function hydrateTask() {
567
- return _ref3.apply(this, arguments);
724
+ return _ref10.apply(this, arguments);
568
725
  };
569
726
  }();
570
727
  queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
@@ -658,10 +815,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
658
815
  });
659
816
  }
660
817
  quotation.setScheduleResolver(function (id) {
661
- var _scheduleModule$getSc, _getScheduleByIds, _ref4;
818
+ var _scheduleModule$getSc, _getScheduleByIds, _ref11;
662
819
  var scheduleId = String(id);
663
820
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
664
- var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
821
+ var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref11 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref11, [id])) || [];
665
822
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
666
823
  return schedules[0];
667
824
  });
@@ -705,6 +862,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
705
862
  if (!Number.isFinite(productId)) return null;
706
863
  return productId;
707
864
  }
865
+
866
+ /**
867
+ * Change Time / customer reprice 必须沿用商品列表的渠道口径。
868
+ * SalesSdk Provider 通常将渠道存为 platform,因此不能只读取 otherParams.channel。
869
+ */
870
+ }, {
871
+ key: "getPriceQueryChannel",
872
+ value: function getPriceQueryChannel(channel) {
873
+ var _this$otherParams2, _ref12, _ref13, _this$otherParams3, _this$otherParams4;
874
+ var strategyContext = (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
875
+ var value = (_ref12 = (_ref13 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref13 !== void 0 ? _ref13 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel) !== null && _ref12 !== void 0 ? _ref12 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform;
876
+ if (value === undefined || value === null || String(value).trim() === '') {
877
+ return undefined;
878
+ }
879
+ return String(value).trim();
880
+ }
881
+ /**
882
+ * /product/query 的智能定价评估只读取 strategy_context;
883
+ * application_code 仅作为接口兼容字段,不能替代 channel / business_code。
884
+ */
885
+ }, {
886
+ key: "getPriceQueryStrategyContext",
887
+ value: function getPriceQueryStrategyContext(channel) {
888
+ var _this$otherParams5, _ref14, _strategyContext$busi, _this$otherParams6, _this$otherParams7;
889
+ var inherited = (_this$otherParams5 = this.otherParams) !== null && _this$otherParams5 !== void 0 && _this$otherParams5.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
890
+ var strategyContext = _objectSpread({}, inherited);
891
+ var resolvedChannel = this.getPriceQueryChannel(channel);
892
+ var businessCode = (_ref14 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref14 !== void 0 ? _ref14 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code;
893
+ if (resolvedChannel) strategyContext.channel = resolvedChannel;
894
+ if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
895
+ strategyContext.business_code = String(businessCode).trim();
896
+ }
897
+ return strategyContext;
898
+ }
708
899
  }, {
709
900
  key: "getPriceQuerySchedule",
710
901
  value: function getPriceQuerySchedule(params) {
@@ -737,7 +928,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
737
928
  key: "loadProductsForPriceQuery",
738
929
  value: function () {
739
930
  var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
740
- var ids, productsById, _this$otherParams2, _response$data, response, list;
931
+ var ids, productsById, channel, strategyContext, _response$data, response, list;
741
932
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
742
933
  while (1) switch (_context7.prev = _context7.next) {
743
934
  case 0:
@@ -751,9 +942,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
751
942
  }
752
943
  return _context7.abrupt("return", productsById);
753
944
  case 4:
754
- _context7.prev = 4;
755
- _context7.next = 7;
756
- return this.request.post('/product/query', {
945
+ channel = this.getPriceQueryChannel(params.channel);
946
+ strategyContext = this.getPriceQueryStrategyContext(channel);
947
+ _context7.prev = 6;
948
+ _context7.next = 9;
949
+ return this.request.post('/product/query', _objectSpread({
757
950
  ids: ids,
758
951
  open_quotation: 1,
759
952
  open_bundle: 1,
@@ -763,39 +956,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
763
956
  customer_id: params.customerId,
764
957
  schedule_date: params.schedule.schedule_date,
765
958
  schedule_datetime: params.schedule.schedule_datetime,
766
- application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
767
- }, {
959
+ application_code: channel
960
+ }, Object.keys(strategyContext).length ? {
961
+ strategy_context: strategyContext
962
+ } : {}), {
768
963
  osServer: true,
769
964
  customToast: function customToast() {}
770
965
  });
771
- case 7:
966
+ case 9:
772
967
  response = _context7.sent;
773
968
  list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
774
969
  if (Array.isArray(list)) {
775
- _context7.next = 11;
970
+ _context7.next = 13;
776
971
  break;
777
972
  }
778
973
  return _context7.abrupt("return", productsById);
779
- case 11:
974
+ case 13:
780
975
  list.forEach(function (item) {
781
976
  var _item$id;
782
977
  var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
783
978
  if (Number.isFinite(productId)) productsById.set(productId, item);
784
979
  });
785
980
  return _context7.abrupt("return", productsById);
786
- case 15:
787
- _context7.prev = 15;
788
- _context7.t0 = _context7["catch"](4);
981
+ case 17:
982
+ _context7.prev = 17;
983
+ _context7.t0 = _context7["catch"](6);
789
984
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
790
985
  ids: ids,
791
986
  error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
792
987
  });
793
988
  return _context7.abrupt("return", productsById);
794
- case 19:
989
+ case 21:
795
990
  case "end":
796
991
  return _context7.stop();
797
992
  }
798
- }, _callee7, this, [[4, 15]]);
993
+ }, _callee7, this, [[6, 17]]);
799
994
  }));
800
995
  function loadProductsForPriceQuery(_x5) {
801
996
  return _loadProductsForPriceQuery.apply(this, arguments);
@@ -848,10 +1043,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
848
1043
  return groups.flatMap(function (group) {
849
1044
  var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
850
1045
  return items.map(function (item) {
851
- var _item$group_id, _ref5, _item$bundle_group_id;
1046
+ var _item$group_id, _ref15, _item$bundle_group_id;
852
1047
  return _objectSpread(_objectSpread({}, item), {}, {
853
1048
  group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
854
- bundle_group_id: (_ref5 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
1049
+ bundle_group_id: (_ref15 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref15 !== void 0 ? _ref15 : group === null || group === void 0 ? void 0 : group.id
855
1050
  });
856
1051
  });
857
1052
  });
@@ -882,21 +1077,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
882
1077
  }, {
883
1078
  key: "getAuthoritativeBundleUnitPrice",
884
1079
  value: function getAuthoritativeBundleUnitPrice(bundle) {
885
- var _ref6, _ref7, _ref8, _bundle$price;
886
- return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
1080
+ var _ref16, _ref17, _ref18, _bundle$price;
1081
+ return (_ref16 = (_ref17 = (_ref18 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref18 !== void 0 ? _ref18 : bundle.custom_price) !== null && _ref17 !== void 0 ? _ref17 : bundle.product_price) !== null && _ref16 !== void 0 ? _ref16 : bundle.base_price;
887
1082
  }
888
1083
  }, {
889
1084
  key: "mergeProductForPriceQuery",
890
1085
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
891
1086
  var _this5 = this,
892
1087
  _product$id,
893
- _ref9,
1088
+ _ref19,
894
1089
  _product$product_id2,
895
- _ref10,
1090
+ _ref20,
896
1091
  _product$product_vari,
897
- _ref11,
1092
+ _ref21,
898
1093
  _product$num,
899
- _ref12,
1094
+ _ref22,
900
1095
  _product$quantity,
901
1096
  _product$metadata4;
902
1097
  if (!authoritativeProduct) return product;
@@ -916,10 +1111,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
916
1111
  });
917
1112
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
918
1113
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
919
- product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
920
- product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
921
- num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
922
- quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
1114
+ product_id: (_ref19 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.id,
1115
+ product_variant_id: (_ref20 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
1116
+ num: (_ref21 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref21 !== void 0 ? _ref21 : authoritativeProduct.num,
1117
+ quantity: (_ref22 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref22 !== void 0 ? _ref22 : authoritativeProduct.quantity,
923
1118
  product_sku: function () {
924
1119
  var authoritativeSku = ensureProductSku(authoritativeProduct);
925
1120
  var productSku = ensureProductSku(product);
@@ -935,8 +1130,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
935
1130
  }, {
936
1131
  key: "getSubmitOrderSalesChannel",
937
1132
  value: function getSubmitOrderSalesChannel() {
938
- var _this$otherParams3;
939
- return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
1133
+ var _this$otherParams8;
1134
+ return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
940
1135
  }
941
1136
 
942
1137
  /**
@@ -995,24 +1190,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
995
1190
  value: (function () {
996
1191
  var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
997
1192
  var _this6 = this;
998
- var _ref13,
999
- _ref13$cover,
1193
+ var _ref23,
1194
+ _ref23$cover,
1000
1195
  cover,
1001
1196
  nextSubModuleOtherParams,
1002
1197
  _args10 = arguments;
1003
1198
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1004
1199
  while (1) switch (_context10.prev = _context10.next) {
1005
1200
  case 0:
1006
- _ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
1201
+ _ref23 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
1007
1202
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
1008
1203
  _context10.next = 4;
1009
1204
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1010
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
1011
- var _ref16, moduleName, subModule, targetModule;
1205
+ var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref24) {
1206
+ var _ref26, moduleName, subModule, targetModule;
1012
1207
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1013
1208
  while (1) switch (_context9.prev = _context9.next) {
1014
1209
  case 0:
1015
- _ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
1210
+ _ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
1016
1211
  if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1017
1212
  _context9.next = 3;
1018
1213
  break;
@@ -1038,7 +1233,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1038
1233
  }, _callee9);
1039
1234
  }));
1040
1235
  return function (_x9) {
1041
- return _ref15.apply(this, arguments);
1236
+ return _ref25.apply(this, arguments);
1042
1237
  };
1043
1238
  }()));
1044
1239
  case 4:
@@ -1066,7 +1261,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1066
1261
  if (!sessionData) return {};
1067
1262
  var data = JSON.parse(sessionData);
1068
1263
  return data && data[this.cacheId] || {};
1069
- } catch (_unused) {
1264
+ } catch (_unused3) {
1070
1265
  return {};
1071
1266
  }
1072
1267
  }
@@ -1080,6 +1275,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1080
1275
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
1081
1276
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1082
1277
  }
1278
+
1279
+ /**
1280
+ * 复用业务解决方案初始化时已解析的支付设备短号。
1281
+ * 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
1282
+ */
1283
+ }, {
1284
+ key: "setPaymentNumberDevicePrefix",
1285
+ value: function setPaymentNumberDevicePrefix(prefix) {
1286
+ var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
1287
+ this.paymentNumberDevicePrefix = normalized || null;
1288
+ }
1289
+ }, {
1290
+ key: "getPaymentNumberDevicePrefixSync",
1291
+ value: function getPaymentNumberDevicePrefixSync() {
1292
+ var _this7 = this;
1293
+ if (!this.appPlugin) return 'LOCAL';
1294
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1295
+ return _this7.getAppData(key);
1296
+ });
1297
+ }
1298
+ }, {
1299
+ key: "getPaymentNumberDevicePrefixAsync",
1300
+ value: function getPaymentNumberDevicePrefixAsync() {
1301
+ var _this8 = this;
1302
+ if (!this.appPlugin) return Promise.resolve('LOCAL');
1303
+ if (this.paymentNumberDevicePrefix) {
1304
+ return Promise.resolve(this.paymentNumberDevicePrefix);
1305
+ }
1306
+ return resolvePaymentNumberDevicePrefix(function (key) {
1307
+ return _this8.getAppData(key);
1308
+ });
1309
+ }
1083
1310
  }, {
1084
1311
  key: "syncAppDataToTempOrder",
1085
1312
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1122,9 +1349,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1122
1349
  key: "initialize",
1123
1350
  value: function () {
1124
1351
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1125
- var _this$otherParams4,
1126
- _this7 = this,
1127
- _this$otherParams5;
1352
+ var _this$otherParams9,
1353
+ _this9 = this,
1354
+ _this$otherParams10;
1128
1355
  var options,
1129
1356
  app,
1130
1357
  targetCacheData,
@@ -1136,9 +1363,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1136
1363
  options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1137
1364
  this.core = core;
1138
1365
  this.initializeOptions = options || {};
1366
+ this.paymentNumberDevicePrefix = null;
1139
1367
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1140
1368
  this.otherParams = options.otherParams || {};
1141
- this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
1369
+ this.cacheId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.cacheId;
1142
1370
  this.reusedSharedSubModuleNames.clear();
1143
1371
  this.window = core.getPlugin('window');
1144
1372
  this.request = core.getPlugin('request');
@@ -1146,52 +1374,52 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1146
1374
  // 获取 logger 实例
1147
1375
  this.appPlugin = core.getPlugin('app');
1148
1376
  if (this.appPlugin) {
1149
- _context11.next = 11;
1377
+ _context11.next = 12;
1150
1378
  break;
1151
1379
  }
1152
1380
  throw new Error('Checkout 解决方案需要 app 插件支持');
1153
- case 11:
1381
+ case 12:
1154
1382
  app = this.appPlugin.getApp();
1155
1383
  this.logger = app.logger;
1156
1384
  targetCacheData = this.readSessionCacheData();
1157
1385
  moduleNames = this.getRegisteredModuleNames();
1158
1386
  moduleNames.forEach(function (step) {
1159
- var reusedModule = _this7.getReusableSharedSubModule(step);
1387
+ var reusedModule = _this9.getReusableSharedSubModule(step);
1160
1388
  if (reusedModule) {
1161
- _this7.store[step] = reusedModule;
1162
- _this7.reusedSharedSubModuleNames.add(step);
1389
+ _this9.store[step] = reusedModule;
1390
+ _this9.reusedSharedSubModuleNames.add(step);
1163
1391
  return;
1164
1392
  }
1165
- var targetModule = _this7.createSubModule(step);
1393
+ var targetModule = _this9.createSubModule(step);
1166
1394
  if (!targetModule) {
1167
1395
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1168
1396
  }
1169
- var hooks = _this7.getSubModuleHooks(step);
1170
- _this7.store[step] = targetModule;
1171
- _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
1397
+ var hooks = _this9.getSubModuleHooks(step);
1398
+ _this9.store[step] = targetModule;
1399
+ _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1172
1400
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1173
1401
  }, hooks ? {
1174
1402
  hooks: hooks
1175
1403
  } : {}), {}, {
1176
- otherParams: _this7.buildSubModuleOtherParams()
1404
+ otherParams: _this9.buildSubModuleOtherParams()
1177
1405
  }));
1178
1406
  });
1179
1407
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1180
- _context11.next = 19;
1408
+ _context11.next = 20;
1181
1409
  break;
1182
1410
  }
1183
- _context11.next = 19;
1411
+ _context11.next = 20;
1184
1412
  return this.store.schedule.loadAllSchedule();
1185
- case 19:
1186
- if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
1413
+ case 20:
1414
+ if (this.store.order && typeof ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.enableTempOrderPersist) === 'boolean') {
1187
1415
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1188
1416
  }
1189
- _context11.next = 22;
1417
+ _context11.next = 23;
1190
1418
  return this.getPaymentMethodsAsync();
1191
- case 22:
1419
+ case 23:
1192
1420
  this.registerServerOrderChangeSync();
1193
1421
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1194
- case 24:
1422
+ case 25:
1195
1423
  case "end":
1196
1424
  return _context11.stop();
1197
1425
  }
@@ -1207,15 +1435,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1207
1435
  value: function () {
1208
1436
  var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1209
1437
  var _this$serverOrderChan2,
1210
- _this8 = this;
1438
+ _this10 = this;
1211
1439
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1212
1440
  while (1) switch (_context12.prev = _context12.next) {
1213
1441
  case 0:
1214
1442
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1215
1443
  this.serverOrderChangeUnsubscribe = null;
1216
1444
  Object.keys(this.store).forEach(function (key) {
1217
- if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
- var sub = _this8.store[key];
1445
+ if (_this10.reusedSharedSubModuleNames.has(key)) return;
1446
+ var sub = _this10.store[key];
1219
1447
  if (sub && typeof sub.destroy === 'function') {
1220
1448
  try {
1221
1449
  sub.destroy();
@@ -1225,13 +1453,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1225
1453
  }
1226
1454
  });
1227
1455
  this.currentSalesDetail = null;
1456
+ this.paymentNumberDevicePrefix = null;
1228
1457
  this.queuedServerOrderChanges = [];
1229
1458
  this.salesDetailLoadSequence += 1;
1230
- _context12.next = 8;
1459
+ this.walletAssetsRefreshSequence += 1;
1460
+ _context12.next = 10;
1231
1461
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1232
- case 8:
1462
+ case 10:
1233
1463
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1234
- case 9:
1464
+ case 11:
1235
1465
  case "end":
1236
1466
  return _context12.stop();
1237
1467
  }
@@ -1253,7 +1483,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1253
1483
  key: "loadSalesDetail",
1254
1484
  value: (function () {
1255
1485
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1256
- var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1486
+ var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1257
1487
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1258
1488
  while (1) switch (_context13.prev = _context13.next) {
1259
1489
  case 0:
@@ -1271,7 +1501,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1271
1501
  };
1272
1502
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1273
1503
  preloadedSalesDetail = params.preloadedSalesDetail;
1274
- lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1504
+ lookup = (_ref27 = (_ref28 = (_ref29 = (_ref30 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref30 !== void 0 ? _ref30 : params.orderNumber) !== null && _ref29 !== void 0 ? _ref29 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref28 !== void 0 ? _ref28 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref27 !== void 0 ? _ref27 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1275
1505
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1276
1506
  _context13.next = 11;
1277
1507
  break;
@@ -1302,39 +1532,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1302
1532
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1303
1533
  throw new Error(message);
1304
1534
  case 22:
1305
- remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1535
+ remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1306
1536
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1307
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1308
- _context13.next = 27;
1537
+ mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1538
+ record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1539
+ _context13.next = 28;
1309
1540
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1310
- case 27:
1311
- return _context13.abrupt("return", _context13.sent);
1312
1541
  case 28:
1313
- _context13.prev = 28;
1542
+ return _context13.abrupt("return", _context13.sent);
1543
+ case 29:
1544
+ _context13.prev = 29;
1314
1545
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1315
1546
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1316
- _context13.next = 39;
1547
+ _context13.next = 40;
1317
1548
  break;
1318
1549
  }
1319
- _context13.prev = 31;
1320
- _context13.next = 34;
1550
+ _context13.prev = 32;
1551
+ _context13.next = 35;
1321
1552
  return this.drainQueuedServerOrderChanges();
1322
- case 34:
1323
- _context13.next = 39;
1553
+ case 35:
1554
+ _context13.next = 40;
1324
1555
  break;
1325
- case 36:
1326
- _context13.prev = 36;
1327
- _context13.t1 = _context13["catch"](31);
1556
+ case 37:
1557
+ _context13.prev = 37;
1558
+ _context13.t1 = _context13["catch"](32);
1328
1559
  this.logError('drain queued server order changes failed', {
1329
1560
  error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1330
1561
  });
1331
- case 39:
1332
- return _context13.finish(28);
1333
1562
  case 40:
1563
+ return _context13.finish(29);
1564
+ case 41:
1334
1565
  case "end":
1335
1566
  return _context13.stop();
1336
1567
  }
1337
- }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1568
+ }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1338
1569
  }));
1339
1570
  function loadSalesDetail(_x11) {
1340
1571
  return _loadSalesDetail.apply(this, arguments);
@@ -1416,7 +1647,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1416
1647
  }, {
1417
1648
  key: "replaceTempOrder",
1418
1649
  value: function () {
1419
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
1650
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder, options) {
1420
1651
  var nextTempOrder;
1421
1652
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1422
1653
  while (1) switch (_context14.prev = _context14.next) {
@@ -1428,7 +1659,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1428
1659
  throw new Error('order 模块未初始化');
1429
1660
  case 2:
1430
1661
  _context14.next = 4;
1431
- return this.store.order.replaceTempOrder(tempOrder);
1662
+ return this.store.order.replaceTempOrder(tempOrder, options);
1432
1663
  case 4:
1433
1664
  nextTempOrder = _context14.sent;
1434
1665
  _context14.next = 7;
@@ -1443,7 +1674,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1443
1674
  }
1444
1675
  }, _callee14, this);
1445
1676
  }));
1446
- function replaceTempOrder(_x12) {
1677
+ function replaceTempOrder(_x12, _x13) {
1447
1678
  return _replaceTempOrder.apply(this, arguments);
1448
1679
  }
1449
1680
  return replaceTempOrder;
@@ -1611,7 +1842,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1611
1842
  key: "restoreOrder",
1612
1843
  value: function () {
1613
1844
  var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1614
- var tempOrder;
1845
+ var _this$store$payment, tempOrder, wallet;
1615
1846
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1616
1847
  while (1) switch (_context17.prev = _context17.next) {
1617
1848
  case 0:
@@ -1627,29 +1858,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1627
1858
  this.currentSalesDetail = null;
1628
1859
  this.discountConfigCacheKey = null;
1629
1860
  this.hasManualDiscountSelection = false;
1630
- _context17.next = 9;
1861
+ wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
1862
+ if (!wallet) {
1863
+ _context17.next = 13;
1864
+ break;
1865
+ }
1866
+ this.walletAssetsRefreshSequence += 1;
1867
+ wallet.clearAllCache();
1868
+ _context17.next = 13;
1869
+ return this.publishWalletAssetsState(wallet.getWalletAssetsState());
1870
+ case 13:
1871
+ _context17.next = 15;
1631
1872
  return this.effectsEmit('onTempOrderReplaced', {
1632
1873
  tempOrder: tempOrder
1633
1874
  });
1634
- case 9:
1875
+ case 15:
1635
1876
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1636
- _context17.next = 13;
1877
+ _context17.next = 19;
1637
1878
  break;
1638
1879
  }
1639
1880
  this.store.order.persistTempOrder();
1640
- _context17.next = 13;
1881
+ _context17.next = 19;
1641
1882
  return this.store.order.saveDraft();
1642
- case 13:
1883
+ case 19:
1643
1884
  return _context17.abrupt("return", tempOrder);
1644
- case 16:
1645
- _context17.prev = 16;
1885
+ case 22:
1886
+ _context17.prev = 22;
1646
1887
  _context17.t0 = _context17["catch"](0);
1647
1888
  throw _context17.t0;
1648
- case 19:
1889
+ case 25:
1649
1890
  case "end":
1650
1891
  return _context17.stop();
1651
1892
  }
1652
- }, _callee17, this, [[0, 16]]);
1893
+ }, _callee17, this, [[0, 22]]);
1653
1894
  }));
1654
1895
  function restoreOrder() {
1655
1896
  return _restoreOrder.apply(this, arguments);
@@ -1762,10 +2003,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1762
2003
  }, {
1763
2004
  key: "getHistoricalProductDiscountList",
1764
2005
  value: function getHistoricalProductDiscountList(products) {
1765
- var _this9 = this;
2006
+ var _this11 = this;
1766
2007
  var historyDiscountList = [];
1767
2008
  products.forEach(function (item) {
1768
- if (!_this9.isPersistedOrderProduct(item)) return;
2009
+ if (!_this11.isPersistedOrderProduct(item)) return;
1769
2010
  (item.discount_list || []).forEach(function (discount) {
1770
2011
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1771
2012
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1825,11 +2066,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1825
2066
  }, {
1826
2067
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1827
2068
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1828
- var _this10 = this;
2069
+ var _this12 = this;
1829
2070
  if (params.discountAction !== 'edit') return false;
1830
2071
  if (!params.products.length) return false;
1831
2072
  var hasDraftProduct = params.products.some(function (product) {
1832
- return !_this10.isPersistedOrderProduct(product);
2073
+ return !_this12.isPersistedOrderProduct(product);
1833
2074
  });
1834
2075
  if (hasDraftProduct) return false;
1835
2076
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -2073,7 +2314,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2073
2314
  }
2074
2315
  }, _callee20, this, [[46, 65, 68, 71]]);
2075
2316
  }));
2076
- function loadDiscountConfig(_x13) {
2317
+ function loadDiscountConfig(_x14) {
2077
2318
  return _loadDiscountConfig.apply(this, arguments);
2078
2319
  }
2079
2320
  return loadDiscountConfig;
@@ -2171,7 +2412,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2171
2412
  }
2172
2413
  }, _callee21, this);
2173
2414
  }));
2174
- function bestDiscount(_x14) {
2415
+ function bestDiscount(_x15) {
2175
2416
  return _bestDiscount.apply(this, arguments);
2176
2417
  }
2177
2418
  return bestDiscount;
@@ -2234,7 +2475,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2234
2475
  }
2235
2476
  }, _callee22, this);
2236
2477
  }));
2237
- function replaceDiscountStoreLists(_x15) {
2478
+ function replaceDiscountStoreLists(_x16) {
2238
2479
  return _replaceDiscountStoreLists.apply(this, arguments);
2239
2480
  }
2240
2481
  return replaceDiscountStoreLists;
@@ -2277,12 +2518,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2277
2518
  tempOrder: tempOrder
2278
2519
  });
2279
2520
  case 13:
2280
- return _context23.abrupt("return", {
2281
- isAvailable: raw.isAvailable,
2521
+ return _context23.abrupt("return", _objectSpread(_objectSpread({
2522
+ isAvailable: raw.isAvailable
2523
+ }, raw.isAccepted !== undefined ? {
2524
+ isAccepted: raw.isAccepted
2525
+ } : {}), {}, {
2282
2526
  type: raw.type,
2283
2527
  unavailableReason: raw.unavailableReason,
2284
2528
  scannedDiscountList: raw.scannedDiscountList
2285
- });
2529
+ }));
2286
2530
  case 16:
2287
2531
  _context23.prev = 16;
2288
2532
  _context23.t0 = _context23["catch"](0);
@@ -2293,7 +2537,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2293
2537
  }
2294
2538
  }, _callee23, this, [[0, 16]]);
2295
2539
  }));
2296
- function scanPromotionCode(_x16, _x17) {
2540
+ function scanPromotionCode(_x17, _x18) {
2297
2541
  return _scanPromotionCode.apply(this, arguments);
2298
2542
  }
2299
2543
  return scanPromotionCode;
@@ -2408,10 +2652,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2408
2652
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2409
2653
  if (Array.isArray(product.product_bundle)) {
2410
2654
  product.product_bundle = product.product_bundle.map(function (bundle) {
2411
- var _ref21, _bundle$original_pric;
2655
+ var _ref31, _bundle$original_pric;
2412
2656
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2413
2657
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2414
- var restoredBundlePrice = (_ref21 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2658
+ var restoredBundlePrice = (_ref31 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref31 !== void 0 ? _ref31 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2415
2659
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2416
2660
  price: restoredBundlePrice,
2417
2661
  bundle_selling_price: restoredBundlePrice
@@ -2484,7 +2728,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2484
2728
  }
2485
2729
  }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2486
2730
  }));
2487
- function setDiscountSelected(_x18) {
2731
+ function setDiscountSelected(_x19) {
2488
2732
  return _setDiscountSelected.apply(this, arguments);
2489
2733
  }
2490
2734
  return setDiscountSelected;
@@ -2554,7 +2798,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2554
2798
  }
2555
2799
  }, _callee25, this, [[0, 21]]);
2556
2800
  }));
2557
- function applyDiscountCalculationResult(_x19) {
2801
+ function applyDiscountCalculationResult(_x20) {
2558
2802
  return _applyDiscountCalculationResult.apply(this, arguments);
2559
2803
  }
2560
2804
  return applyDiscountCalculationResult;
@@ -2573,7 +2817,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2573
2817
  }
2574
2818
  }, _callee26, this);
2575
2819
  }));
2576
- function submitScanOrder(_x20) {
2820
+ function submitScanOrder(_x21) {
2577
2821
  return _submitScanOrder.apply(this, arguments);
2578
2822
  }
2579
2823
  return submitScanOrder;
@@ -2588,7 +2832,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2588
2832
  key: "submitSalesOrder",
2589
2833
  value: (function () {
2590
2834
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2591
- var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
2835
+ var _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14;
2592
2836
  var inferredPaymentStatus, submitParams;
2593
2837
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2594
2838
  while (1) switch (_context27.prev = _context27.next) {
@@ -2603,10 +2847,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2603
2847
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2604
2848
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2605
2849
  cacheId: this.cacheId,
2606
- platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
2607
- businessCode: ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code),
2850
+ platform: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.platform,
2851
+ businessCode: ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode) || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.business_code),
2608
2852
  channel: this.getSubmitOrderSalesChannel(),
2609
- type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
2853
+ type: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.type,
2610
2854
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
2611
2855
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2612
2856
  payments: params.payments
@@ -2626,17 +2870,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2626
2870
  }
2627
2871
  }, _callee27, this);
2628
2872
  }));
2629
- function submitSalesOrder(_x21) {
2873
+ function submitSalesOrder(_x22) {
2630
2874
  return _submitSalesOrder.apply(this, arguments);
2631
2875
  }
2632
2876
  return submitSalesOrder;
2633
2877
  }())
2634
2878
  }, {
2635
- key: "submitTempOrderAsync",
2879
+ key: "saveSalesOrderDraft",
2636
2880
  value: function () {
2637
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2638
- var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2639
- var inferredPaymentStatus, submitParams;
2881
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2882
+ var _params$platform, _this$otherParams15, _this$otherParams16, _this$otherParams17, _params$channel, _params$type, _this$otherParams18;
2640
2883
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2641
2884
  while (1) switch (_context28.prev = _context28.next) {
2642
2885
  case 0:
@@ -2645,14 +2888,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2645
2888
  break;
2646
2889
  }
2647
2890
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2891
+ case 2:
2892
+ return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2893
+ cacheId: this.cacheId,
2894
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
2895
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
2896
+ channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2897
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type
2898
+ }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2899
+ enhancePayload: params.enhancePayload
2900
+ } : {})));
2901
+ case 3:
2902
+ case "end":
2903
+ return _context28.stop();
2904
+ }
2905
+ }, _callee28, this);
2906
+ }));
2907
+ function saveSalesOrderDraft(_x23) {
2908
+ return _saveSalesOrderDraft.apply(this, arguments);
2909
+ }
2910
+ return saveSalesOrderDraft;
2911
+ }()
2912
+ }, {
2913
+ key: "submitTempOrderAsync",
2914
+ value: function () {
2915
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2916
+ var _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
2917
+ var inferredPaymentStatus, submitParams;
2918
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2919
+ while (1) switch (_context29.prev = _context29.next) {
2920
+ case 0:
2921
+ if (this.store.order) {
2922
+ _context29.next = 2;
2923
+ break;
2924
+ }
2925
+ throw new Error('BaseSales 解决方案需要 order 模块支持');
2648
2926
  case 2:
2649
2927
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2650
2928
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2651
2929
  cacheId: this.cacheId,
2652
- platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2653
- businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2930
+ platform: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform,
2931
+ businessCode: ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode) || ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.business_code),
2654
2932
  channel: this.getSubmitOrderSalesChannel(),
2655
- type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2933
+ type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
2656
2934
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2657
2935
  payments: params.payments
2658
2936
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2664,14 +2942,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2664
2942
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2665
2943
  enhancePayload: params.enhancePayload
2666
2944
  } : {});
2667
- return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2945
+ return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2668
2946
  case 5:
2669
2947
  case "end":
2670
- return _context28.stop();
2948
+ return _context29.stop();
2671
2949
  }
2672
- }, _callee28, this);
2950
+ }, _callee29, this);
2673
2951
  }));
2674
- function submitTempOrderAsync(_x22) {
2952
+ function submitTempOrderAsync(_x24) {
2675
2953
  return _submitTempOrderAsync.apply(this, arguments);
2676
2954
  }
2677
2955
  return submitTempOrderAsync;
@@ -2679,14 +2957,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2679
2957
  }, {
2680
2958
  key: "printLocalOrderReceipt",
2681
2959
  value: function () {
2682
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2683
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2960
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2961
+ var _this$otherParams23, _this$otherParams24, _this$otherParams25, _this$otherParams26;
2684
2962
  var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2685
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2686
- while (1) switch (_context29.prev = _context29.next) {
2963
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2964
+ while (1) switch (_context30.prev = _context30.next) {
2687
2965
  case 0:
2688
2966
  if (this.store.order) {
2689
- _context29.next = 2;
2967
+ _context30.next = 2;
2690
2968
  break;
2691
2969
  }
2692
2970
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2698,10 +2976,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2698
2976
  external_sale_number: lookup
2699
2977
  };
2700
2978
  context = {
2701
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2702
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2979
+ platform: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform,
2980
+ businessCode: ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) || ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.business_code),
2703
2981
  channel: this.getSubmitOrderSalesChannel(),
2704
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2982
+ type: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.type
2705
2983
  };
2706
2984
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2707
2985
  lookup_order_from_db: 1,
@@ -2717,28 +2995,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2717
2995
  channel: context.channel,
2718
2996
  type: context.type
2719
2997
  });
2720
- _context29.next = 8;
2998
+ _context30.next = 8;
2721
2999
  return this.request.post('/local/print-order', payload, {
2722
3000
  osServer: true,
2723
3001
  customToast: function customToast() {}
2724
3002
  });
2725
3003
  case 8:
2726
- response = _context29.sent;
3004
+ response = _context30.sent;
2727
3005
  if (hasLookup) {
2728
- _context29.next = 12;
3006
+ _context30.next = 12;
2729
3007
  break;
2730
3008
  }
2731
- _context29.next = 12;
3009
+ _context30.next = 12;
2732
3010
  return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2733
3011
  case 12:
2734
- return _context29.abrupt("return", response);
3012
+ return _context30.abrupt("return", response);
2735
3013
  case 13:
2736
3014
  case "end":
2737
- return _context29.stop();
3015
+ return _context30.stop();
2738
3016
  }
2739
- }, _callee29, this);
3017
+ }, _callee30, this);
2740
3018
  }));
2741
- function printLocalOrderReceipt(_x23) {
3019
+ function printLocalOrderReceipt(_x25) {
2742
3020
  return _printLocalOrderReceipt.apply(this, arguments);
2743
3021
  }
2744
3022
  return printLocalOrderReceipt;
@@ -2752,27 +3030,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2752
3030
  if (!amountSnapshot) return undefined;
2753
3031
  try {
2754
3032
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
2755
- } catch (_unused2) {
3033
+ } catch (_unused4) {
2756
3034
  return undefined;
2757
3035
  }
2758
3036
  }
2759
3037
  }, {
2760
3038
  key: "syncPaymentsToOrder",
2761
3039
  value: function () {
2762
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
- var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
3040
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3041
+ var _ref32, _params$businessCode, _this$otherParams27, _this$otherParams28, _params$channel2;
2764
3042
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2765
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2766
- while (1) switch (_context30.prev = _context30.next) {
3043
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3044
+ while (1) switch (_context31.prev = _context31.next) {
2767
3045
  case 0:
2768
3046
  if (this.store.order) {
2769
- _context30.next = 2;
3047
+ _context31.next = 2;
2770
3048
  break;
2771
3049
  }
2772
3050
  throw new Error('order 模块未初始化');
2773
3051
  case 2:
2774
- businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2775
- channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
3052
+ businessCode = (_ref32 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.businessCode) !== null && _ref32 !== void 0 ? _ref32 : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.business_code;
3053
+ channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2776
3054
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2777
3055
  businessCode: businessCode
2778
3056
  } : {}), channel !== undefined ? {
@@ -2780,14 +3058,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2780
3058
  } : {});
2781
3059
  syncState = this.store.order.getOrderSyncState();
2782
3060
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2783
- _context30.next = 9;
3061
+ _context31.next = 9;
2784
3062
  break;
2785
3063
  }
2786
3064
  this.queueLatestAutoPaymentSync();
2787
- return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3065
+ return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2788
3066
  case 9:
2789
3067
  payments = params.payments || [];
2790
- _context30.next = 12;
3068
+ _context31.next = 12;
2791
3069
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2792
3070
  payments: payments,
2793
3071
  params: syncParams,
@@ -2795,11 +3073,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2795
3073
  orderSnapshot: this.store.order.getOrderSnapshot()
2796
3074
  });
2797
3075
  case 12:
2798
- _context30.prev = 12;
2799
- _context30.next = 15;
3076
+ _context31.prev = 12;
3077
+ _context31.next = 15;
2800
3078
  return this.store.order.syncPaymentsToOrder(syncParams);
2801
3079
  case 15:
2802
- syncResult = _context30.sent;
3080
+ syncResult = _context31.sent;
2803
3081
  latestPayments = this.store.order.getOrderPayments();
2804
3082
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2805
3083
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2817,25 +3095,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2817
3095
  depositAmount: syncResult.depositAmount,
2818
3096
  orderExpectedAmount: syncResult.orderExpectedAmount
2819
3097
  };
2820
- _context30.next = 22;
3098
+ _context31.next = 22;
2821
3099
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2822
3100
  case 22:
2823
3101
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2824
- _context30.next = 25;
3102
+ _context31.next = 25;
2825
3103
  break;
2826
3104
  }
2827
- _context30.next = 25;
3105
+ _context31.next = 25;
2828
3106
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2829
3107
  case 25:
2830
3108
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2831
- return _context30.abrupt("return", syncResult);
3109
+ return _context31.abrupt("return", syncResult);
2832
3110
  case 29:
2833
- _context30.prev = 29;
2834
- _context30.t0 = _context30["catch"](12);
2835
- _context30.next = 33;
3111
+ _context31.prev = 29;
3112
+ _context31.t0 = _context31["catch"](12);
3113
+ _context31.next = 33;
2836
3114
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2837
3115
  ok: false,
2838
- error: _context30.t0,
3116
+ error: _context31.t0,
2839
3117
  payments: this.store.order.getOrderPayments(),
2840
3118
  params: syncParams,
2841
3119
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2843,14 +3121,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2843
3121
  });
2844
3122
  case 33:
2845
3123
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2846
- throw _context30.t0;
3124
+ throw _context31.t0;
2847
3125
  case 35:
2848
3126
  case "end":
2849
- return _context30.stop();
3127
+ return _context31.stop();
2850
3128
  }
2851
- }, _callee30, this, [[12, 29]]);
3129
+ }, _callee31, this, [[12, 29]]);
2852
3130
  }));
2853
- function syncPaymentsToOrder(_x24) {
3131
+ function syncPaymentsToOrder(_x26) {
2854
3132
  return _syncPaymentsToOrder.apply(this, arguments);
2855
3133
  }
2856
3134
  return syncPaymentsToOrder;
@@ -2887,58 +3165,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2887
3165
  }, {
2888
3166
  key: "scheduleQueuedAutoPaymentSyncFlush",
2889
3167
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2890
- var _this11 = this;
3168
+ var _this13 = this;
2891
3169
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2892
3170
  if (!this.queuedAutoPaymentSync) return;
2893
3171
  if (this.autoPaymentSyncTimer) return;
2894
3172
  this.autoPaymentSyncTimer = setTimeout(function () {
2895
- _this11.autoPaymentSyncTimer = null;
2896
- void _this11.flushQueuedAutoPaymentSync();
3173
+ _this13.autoPaymentSyncTimer = null;
3174
+ void _this13.flushQueuedAutoPaymentSync();
2897
3175
  }, delay);
2898
3176
  }
2899
3177
  }, {
2900
3178
  key: "flushQueuedAutoPaymentSync",
2901
3179
  value: function () {
2902
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
3180
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2903
3181
  var payments;
2904
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
- while (1) switch (_context31.prev = _context31.next) {
3182
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3183
+ while (1) switch (_context32.prev = _context32.next) {
2906
3184
  case 0:
2907
3185
  if (this.store.order) {
2908
- _context31.next = 2;
3186
+ _context32.next = 2;
2909
3187
  break;
2910
3188
  }
2911
- return _context31.abrupt("return");
3189
+ return _context32.abrupt("return");
2912
3190
  case 2:
2913
3191
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2914
- _context31.next = 4;
3192
+ _context32.next = 4;
2915
3193
  break;
2916
3194
  }
2917
- return _context31.abrupt("return");
3195
+ return _context32.abrupt("return");
2918
3196
  case 4:
2919
3197
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2920
- _context31.next = 7;
3198
+ _context32.next = 7;
2921
3199
  break;
2922
3200
  }
2923
3201
  this.scheduleQueuedAutoPaymentSyncFlush();
2924
- return _context31.abrupt("return");
3202
+ return _context32.abrupt("return");
2925
3203
  case 7:
2926
3204
  this.autoPaymentSyncFlushing = true;
2927
- _context31.prev = 8;
3205
+ _context32.prev = 8;
2928
3206
  case 9:
2929
3207
  if (!this.queuedAutoPaymentSync) {
2930
- _context31.next = 18;
3208
+ _context32.next = 18;
2931
3209
  break;
2932
3210
  }
2933
3211
  this.queuedAutoPaymentSync = false;
2934
3212
  payments = this.store.order.getOrderPayments();
2935
3213
  if (payments.length) {
2936
- _context31.next = 14;
3214
+ _context32.next = 14;
2937
3215
  break;
2938
3216
  }
2939
- return _context31.abrupt("continue", 9);
3217
+ return _context32.abrupt("continue", 9);
2940
3218
  case 14:
2941
- _context31.next = 16;
3219
+ _context32.next = 16;
2942
3220
  return this.syncPaymentsToOrder({
2943
3221
  payments: payments,
2944
3222
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2946,44 +3224,94 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2946
3224
  smallTicketDataFlag: 1
2947
3225
  });
2948
3226
  case 16:
2949
- _context31.next = 9;
3227
+ _context32.next = 9;
2950
3228
  break;
2951
3229
  case 18:
2952
- _context31.next = 23;
3230
+ _context32.next = 23;
2953
3231
  break;
2954
3232
  case 20:
2955
- _context31.prev = 20;
2956
- _context31.t0 = _context31["catch"](8);
3233
+ _context32.prev = 20;
3234
+ _context32.t0 = _context32["catch"](8);
2957
3235
  this.logError('queued auto sync payments failed', {
2958
- error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
3236
+ error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2959
3237
  });
2960
3238
  case 23:
2961
- _context31.prev = 23;
3239
+ _context32.prev = 23;
2962
3240
  this.autoPaymentSyncFlushing = false;
2963
3241
  if (this.queuedAutoPaymentSync) {
2964
3242
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2965
3243
  }
2966
- return _context31.finish(23);
3244
+ return _context32.finish(23);
2967
3245
  case 27:
2968
3246
  case "end":
2969
- return _context31.stop();
3247
+ return _context32.stop();
2970
3248
  }
2971
- }, _callee31, this, [[8, 20, 23, 27]]);
3249
+ }, _callee32, this, [[8, 20, 23, 27]]);
2972
3250
  }));
2973
3251
  function flushQueuedAutoPaymentSync() {
2974
3252
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
2975
3253
  }
2976
3254
  return flushQueuedAutoPaymentSync;
2977
- }() /** 追加单个支付项到当前订单。 */
3255
+ }()
3256
+ /**
3257
+ * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3258
+ */
2978
3259
  }, {
2979
3260
  key: "addOrderPayment",
2980
3261
  value: function addOrderPayment(payment) {
2981
- var _this$otherParams20,
3262
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3263
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3264
+ }
3265
+
3266
+ /**
3267
+ * 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
3268
+ * 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
3269
+ */
3270
+ }, {
3271
+ key: "addOrderPaymentAsync",
3272
+ value: (function () {
3273
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3274
+ var paymentRecord, hasPaymentNumber, devicePrefix;
3275
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3276
+ while (1) switch (_context33.prev = _context33.next) {
3277
+ case 0:
3278
+ paymentRecord = payment;
3279
+ hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3280
+ if (!hasPaymentNumber) {
3281
+ _context33.next = 6;
3282
+ break;
3283
+ }
3284
+ _context33.t0 = 'LOCAL';
3285
+ _context33.next = 9;
3286
+ break;
3287
+ case 6:
3288
+ _context33.next = 8;
3289
+ return this.getPaymentNumberDevicePrefixAsync();
3290
+ case 8:
3291
+ _context33.t0 = _context33.sent;
3292
+ case 9:
3293
+ devicePrefix = _context33.t0;
3294
+ return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3295
+ case 11:
3296
+ case "end":
3297
+ return _context33.stop();
3298
+ }
3299
+ }, _callee33, this);
3300
+ }));
3301
+ function addOrderPaymentAsync(_x27) {
3302
+ return _addOrderPaymentAsync.apply(this, arguments);
3303
+ }
3304
+ return addOrderPaymentAsync;
3305
+ }())
3306
+ }, {
3307
+ key: "addOrderPaymentWithDevicePrefix",
3308
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3309
+ var _this$otherParams29,
2982
3310
  _paymentRecord$paymen,
2983
3311
  _paymentRecord$create,
2984
- _ref23,
3312
+ _ref33,
2985
3313
  _paymentRecord$origin,
2986
- _this12 = this;
3314
+ _this14 = this;
2987
3315
  if (!this.store.order) throw new Error('order 模块未初始化');
2988
3316
  var paymentRecord = payment;
2989
3317
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -2994,25 +3322,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2994
3322
  return this.store.order.getOrderPayments();
2995
3323
  }
2996
3324
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2997
- var shopWalletPassId = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.shop_wallet_pass_id;
3325
+ var shopWalletPassId = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.shop_wallet_pass_id;
2998
3326
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
2999
3327
  metadata.shop_wallet_pass_id = shopWalletPassId;
3000
3328
  }
3001
- if (!metadata.unique_payment_number) {
3002
- metadata.unique_payment_number = createUuidV4();
3003
- }
3329
+ var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
3004
3330
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
3005
3331
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3006
3332
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3007
3333
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3008
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3009
- var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
3334
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref33 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref33 !== void 0 ? _ref33 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3335
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3010
3336
  service_fee: calculatedServiceFee
3011
3337
  } : {}), {}, {
3012
3338
  metadata: metadata,
3013
3339
  payment_time: paymentTime,
3014
3340
  created_at: createdAt
3015
3341
  }));
3342
+ if (paymentRecord.status === 'payment_pending') {
3343
+ return payments;
3344
+ }
3016
3345
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
3017
3346
  var syncState = this.store.order.getOrderSyncState();
3018
3347
  if (amountSnapshot) {
@@ -3026,7 +3355,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3026
3355
  submitWhenPaid: true,
3027
3356
  smallTicketDataFlag: 1
3028
3357
  }).catch(function (error) {
3029
- _this12.logError('auto sync payments failed', {
3358
+ _this14.logError('auto sync payments failed', {
3030
3359
  error: error instanceof Error ? error.message : String(error)
3031
3360
  });
3032
3361
  });
@@ -3037,12 +3366,131 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3037
3366
  /** 更新当前订单中的指定支付项。 */
3038
3367
  }, {
3039
3368
  key: "updateOrderPayment",
3040
- value: function updateOrderPayment(paymentIdentity, updates) {
3041
- if (!this.store.order) throw new Error('order 模块未初始化');
3042
- return this.store.order.updateOrderPayment(paymentIdentity, updates);
3043
- }
3044
-
3045
- /** 删除当前订单中的指定支付项。 */
3369
+ value: (function () {
3370
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3371
+ var _result$payment, _result$payment2;
3372
+ var options,
3373
+ matchMode,
3374
+ previousMatch,
3375
+ previousPayment,
3376
+ _this$store$order$get2,
3377
+ currentPayments,
3378
+ _syncResult,
3379
+ _options$smallTicketD,
3380
+ result,
3381
+ draftResult,
3382
+ draftError,
3383
+ becamePaid,
3384
+ shouldSubmit,
3385
+ syncResult,
3386
+ _options$smallTicketD2,
3387
+ _args34 = arguments;
3388
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3389
+ while (1) switch (_context34.prev = _context34.next) {
3390
+ case 0:
3391
+ options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3392
+ if (this.store.order) {
3393
+ _context34.next = 3;
3394
+ break;
3395
+ }
3396
+ throw new Error('order 模块未初始化');
3397
+ case 3:
3398
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3399
+ previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3400
+ previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3401
+ if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3402
+ _context34.next = 13;
3403
+ break;
3404
+ }
3405
+ currentPayments = this.store.order.getOrderPayments();
3406
+ if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3407
+ _context34.next = 12;
3408
+ break;
3409
+ }
3410
+ _context34.next = 11;
3411
+ return this.syncPaymentsToOrder({
3412
+ payments: currentPayments,
3413
+ paymentStatus: this.getPaymentStatusForSync(currentPayments),
3414
+ submitWhenPaid: true,
3415
+ smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3416
+ });
3417
+ case 11:
3418
+ _syncResult = _context34.sent;
3419
+ case 12:
3420
+ return _context34.abrupt("return", _objectSpread({
3421
+ updated: false,
3422
+ payment: previousPayment,
3423
+ payments: currentPayments,
3424
+ summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
3425
+ }, _syncResult !== undefined ? {
3426
+ syncResult: _syncResult
3427
+ } : {}));
3428
+ case 13:
3429
+ _context34.next = 15;
3430
+ return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3431
+ matchBy: matchMode
3432
+ });
3433
+ case 15:
3434
+ result = _context34.sent;
3435
+ if (!(options.persistDraft !== false)) {
3436
+ _context34.next = 29;
3437
+ break;
3438
+ }
3439
+ _context34.prev = 17;
3440
+ _context34.next = 20;
3441
+ return this.saveSalesOrderDraft();
3442
+ case 20:
3443
+ draftResult = _context34.sent;
3444
+ _context34.next = 29;
3445
+ break;
3446
+ case 23:
3447
+ _context34.prev = 23;
3448
+ _context34.t0 = _context34["catch"](17);
3449
+ draftError = _context34.t0;
3450
+ this.logError('updateOrderPayment: 保存支付草稿失败', {
3451
+ paymentIdentity: paymentIdentity,
3452
+ error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3453
+ });
3454
+ if (options.submitWhenPaid) {
3455
+ _context34.next = 29;
3456
+ break;
3457
+ }
3458
+ throw _context34.t0;
3459
+ case 29:
3460
+ becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
3461
+ shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3462
+ if (!shouldSubmit) {
3463
+ _context34.next = 35;
3464
+ break;
3465
+ }
3466
+ _context34.next = 34;
3467
+ return this.syncPaymentsToOrder({
3468
+ payments: result.payments,
3469
+ paymentStatus: this.getPaymentStatusForSync(result.payments),
3470
+ submitWhenPaid: true,
3471
+ smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3472
+ });
3473
+ case 34:
3474
+ syncResult = _context34.sent;
3475
+ case 35:
3476
+ return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3477
+ draftResult: draftResult
3478
+ } : {}), draftError !== undefined ? {
3479
+ draftError: draftError
3480
+ } : {}), syncResult !== undefined ? {
3481
+ syncResult: syncResult
3482
+ } : {}));
3483
+ case 36:
3484
+ case "end":
3485
+ return _context34.stop();
3486
+ }
3487
+ }, _callee34, this, [[17, 23]]);
3488
+ }));
3489
+ function updateOrderPayment(_x28, _x29) {
3490
+ return _updateOrderPayment.apply(this, arguments);
3491
+ }
3492
+ return updateOrderPayment;
3493
+ }() /** 删除当前订单中的指定支付项。 */)
3046
3494
  }, {
3047
3495
  key: "deleteOrderPayment",
3048
3496
  value: function deleteOrderPayment(paymentIdentity) {
@@ -3058,18 +3506,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3058
3506
  return this.store.order.updateVoucherOrderPayments(payments, options);
3059
3507
  }
3060
3508
  }, {
3061
- key: "confirmPendingVoucherPayments",
3062
- value: function confirmPendingVoucherPayments() {
3063
- if (!this.store.order) throw new Error('order 模块未初始化');
3064
- return this.store.order.confirmPendingVoucherPayments();
3065
- }
3066
- }, {
3067
- key: "discardPendingVoucherPayments",
3068
- value: function discardPendingVoucherPayments() {
3069
- if (!this.store.order) throw new Error('order 模块未初始化');
3070
- return this.store.order.discardPendingVoucherPayments();
3071
- }
3072
- }, {
3509
+ key: "updateVoucherOrderPaymentsAsync",
3510
+ value: function () {
3511
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3512
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3513
+ while (1) switch (_context35.prev = _context35.next) {
3514
+ case 0:
3515
+ if (this.store.order) {
3516
+ _context35.next = 2;
3517
+ break;
3518
+ }
3519
+ throw new Error('order 模块未初始化');
3520
+ case 2:
3521
+ return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3522
+ case 3:
3523
+ case "end":
3524
+ return _context35.stop();
3525
+ }
3526
+ }, _callee35, this);
3527
+ }));
3528
+ function updateVoucherOrderPaymentsAsync(_x30, _x31) {
3529
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3530
+ }
3531
+ return updateVoucherOrderPaymentsAsync;
3532
+ }()
3533
+ }, {
3534
+ key: "confirmPendingVoucherPayments",
3535
+ value: function confirmPendingVoucherPayments() {
3536
+ if (!this.store.order) throw new Error('order 模块未初始化');
3537
+ var payments = this.store.order.confirmPendingVoucherPayments();
3538
+ if (this.store.payment) {
3539
+ var committed = this.getCommittedWalletAssets();
3540
+ var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3541
+ void this.publishWalletAssetsState(state);
3542
+ }
3543
+ return payments;
3544
+ }
3545
+ }, {
3546
+ key: "discardPendingVoucherPayments",
3547
+ value: function discardPendingVoucherPayments() {
3548
+ if (!this.store.order) throw new Error('order 模块未初始化');
3549
+ return this.store.order.discardPendingVoucherPayments();
3550
+ }
3551
+ }, {
3073
3552
  key: "getWalletProductList",
3074
3553
  value: function getWalletProductList() {
3075
3554
  var _this$store$order7, _tempOrder$products;
@@ -3130,64 +3609,72 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3130
3609
  });
3131
3610
  return walletProducts;
3132
3611
  }
3612
+ }, {
3613
+ key: "buildWalletInitBusinessData",
3614
+ value: function buildWalletInitBusinessData(params) {
3615
+ var _this$store$order8, _params$order_wait_pa, _ref34, _tempOrder$is_price_i;
3616
+ var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
3617
+ var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3618
+ var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3619
+ if (!tempOrder || !amount) return null;
3620
+ return _objectSpread({
3621
+ customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
3622
+ holder: tempOrder.holder,
3623
+ amountInfo: {
3624
+ totalAmount: amount.totalAmount,
3625
+ subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
3626
+ depositAmount: amount.depositAmount,
3627
+ isDeposit: tempOrder.is_deposit
3628
+ },
3629
+ products: this.getWalletProductList(),
3630
+ order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
3631
+ is_price_include_tax: (_ref34 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref34 !== void 0 ? _ref34 : 1
3632
+ }, snapshot.identity.orderId ? {
3633
+ payment_order_id: String(snapshot.identity.orderId)
3634
+ } : {});
3635
+ }
3133
3636
  }, {
3134
3637
  key: "initWalletData",
3135
3638
  value: function () {
3136
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
- var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
3138
- var snapshot, tempOrder, amount, walletBusinessData, result;
3139
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
- while (1) switch (_context32.prev = _context32.next) {
3639
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3640
+ var _snapshot$identity;
3641
+ var snapshot, walletBusinessData, result;
3642
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3643
+ while (1) switch (_context36.prev = _context36.next) {
3141
3644
  case 0:
3142
3645
  if (this.store.order) {
3143
- _context32.next = 2;
3646
+ _context36.next = 2;
3144
3647
  break;
3145
3648
  }
3146
3649
  throw new Error('order 模块未初始化');
3147
3650
  case 2:
3148
3651
  if (this.store.payment) {
3149
- _context32.next = 4;
3652
+ _context36.next = 4;
3150
3653
  break;
3151
3654
  }
3152
3655
  throw new Error('payment 模块未初始化');
3153
3656
  case 4:
3154
3657
  snapshot = this.store.order.getOrderSnapshot();
3155
- tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3156
- amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3157
- if (!(!tempOrder || !amount)) {
3158
- _context32.next = 9;
3658
+ walletBusinessData = this.buildWalletInitBusinessData(params);
3659
+ if (walletBusinessData) {
3660
+ _context36.next = 8;
3159
3661
  break;
3160
3662
  }
3161
- return _context32.abrupt("return", {
3663
+ return _context36.abrupt("return", {
3162
3664
  walletRecommendList: [],
3163
3665
  userIdentificationCodes: [],
3164
3666
  transformList: [],
3165
3667
  noApplicableVoucher: [],
3166
3668
  products: []
3167
3669
  });
3168
- case 9:
3169
- walletBusinessData = _objectSpread({
3170
- customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
3171
- holder: tempOrder.holder,
3172
- amountInfo: {
3173
- totalAmount: amount.totalAmount,
3174
- subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
3175
- depositAmount: amount.depositAmount,
3176
- isDeposit: tempOrder.is_deposit
3177
- },
3178
- products: this.getWalletProductList(),
3179
- order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
3180
- is_price_include_tax: (_ref24 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref24 !== void 0 ? _ref24 : 1
3181
- }, snapshot.identity.orderId ? {
3182
- payment_order_id: String(snapshot.identity.orderId)
3183
- } : {});
3184
- _context32.next = 12;
3670
+ case 8:
3671
+ _context36.next = 10;
3185
3672
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3186
- case 12:
3187
- result = _context32.sent;
3188
- _context32.next = 15;
3673
+ case 10:
3674
+ result = _context36.sent;
3675
+ _context36.next = 13;
3189
3676
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3190
- orderId: snapshot.identity.orderId,
3677
+ orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
3191
3678
  customerId: walletBusinessData.customer_id,
3192
3679
  walletBusinessData: {
3193
3680
  customer_id: walletBusinessData.customer_id,
@@ -3196,25 +3683,421 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3196
3683
  },
3197
3684
  timestamp: Date.now()
3198
3685
  });
3199
- case 15:
3200
- return _context32.abrupt("return", result);
3201
- case 16:
3686
+ case 13:
3687
+ return _context36.abrupt("return", result);
3688
+ case 14:
3202
3689
  case "end":
3203
- return _context32.stop();
3690
+ return _context36.stop();
3204
3691
  }
3205
- }, _callee32, this);
3692
+ }, _callee36, this);
3206
3693
  }));
3207
- function initWalletData(_x25) {
3694
+ function initWalletData(_x32) {
3208
3695
  return _initWalletData.apply(this, arguments);
3209
3696
  }
3210
3697
  return initWalletData;
3211
3698
  }()
3699
+ }, {
3700
+ key: "getCommittedWalletAssets",
3701
+ value: function getCommittedWalletAssets() {
3702
+ var _this$store$order9, _this$store$order9$ge;
3703
+ var payments = ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$ge = _this$store$order9.getOrderPayments) === null || _this$store$order9$ge === void 0 ? void 0 : _this$store$order9$ge.call(_this$store$order9)) || [];
3704
+ var committed = payments.filter(function (payment) {
3705
+ var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
3706
+ if (voucherId === undefined || voucherId === null || voucherId === 0) {
3707
+ return false;
3708
+ }
3709
+ return (payment === null || payment === void 0 ? void 0 : payment.status) === 'paid' || (payment === null || payment === void 0 ? void 0 : payment.isSynced) === true || (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== null && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== '';
3710
+ });
3711
+ return {
3712
+ ids: committed.map(function (payment) {
3713
+ return payment.voucher_id;
3714
+ }),
3715
+ assets: committed.map(function (payment) {
3716
+ var _Object$entries$find;
3717
+ var fundRecord = (payment === null || payment === void 0 ? void 0 : payment.fund_record) || {};
3718
+ var walletPassName = fundRecord.wallet_pass_name;
3719
+ var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
3720
+ var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
3721
+ var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref35) {
3722
+ var _ref36 = _slicedToArray(_ref35, 2),
3723
+ paymentCode = _ref36[1];
3724
+ return paymentCode === code;
3725
+ })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
3726
+ return {
3727
+ id: payment.voucher_id,
3728
+ voucher_id: payment.voucher_id,
3729
+ code: fundRecord.code,
3730
+ tag: tag,
3731
+ product_name: title || payment.name,
3732
+ name: title || payment.name,
3733
+ amount: Number(payment.amount || 0),
3734
+ _available_max_amount: Number(payment.amount || 0),
3735
+ unified_available_status: 1,
3736
+ _unified_available_status: 1,
3737
+ _committed_payment: payment
3738
+ };
3739
+ })
3740
+ };
3741
+ }
3742
+ }, {
3743
+ key: "publishWalletAssetsState",
3744
+ value: function () {
3745
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
3746
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3747
+ while (1) switch (_context37.prev = _context37.next) {
3748
+ case 0:
3749
+ _context37.next = 2;
3750
+ return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
3751
+ state: state
3752
+ });
3753
+ case 2:
3754
+ return _context37.abrupt("return", state);
3755
+ case 3:
3756
+ case "end":
3757
+ return _context37.stop();
3758
+ }
3759
+ }, _callee37, this);
3760
+ }));
3761
+ function publishWalletAssetsState(_x33) {
3762
+ return _publishWalletAssetsState.apply(this, arguments);
3763
+ }
3764
+ return publishWalletAssetsState;
3765
+ }()
3766
+ }, {
3767
+ key: "syncSelectedWalletAssets",
3768
+ value: function () {
3769
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
3770
+ var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
3771
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3772
+ while (1) switch (_context38.prev = _context38.next) {
3773
+ case 0:
3774
+ if (!(!this.store.order || !this.store.payment)) {
3775
+ _context38.next = 2;
3776
+ break;
3777
+ }
3778
+ throw new Error('订单或支付模块未初始化');
3779
+ case 2:
3780
+ paymentMethods = this.getPaymentMethods();
3781
+ if (!(!paymentMethods.length && state.selectedItems.length)) {
3782
+ _context38.next = 7;
3783
+ break;
3784
+ }
3785
+ _context38.next = 6;
3786
+ return this.getPaymentMethodsAsync();
3787
+ case 6:
3788
+ paymentMethods = _context38.sent;
3789
+ case 7:
3790
+ methodByCode = new Map(paymentMethods.map(function (method) {
3791
+ return [String(method.code || '').toUpperCase(), method];
3792
+ }));
3793
+ preparePayments = this.store.payment.wallet.formatWalletPassList2PreparePayments(state.selectedItems);
3794
+ selectedAssetById = new Map(state.selectedItems.map(function (asset) {
3795
+ return [String(getSharedWalletAssetId(asset)), asset];
3796
+ }));
3797
+ voucherPayments = preparePayments.flatMap(function (item) {
3798
+ var asset = selectedAssetById.get(String(item.voucher_id));
3799
+ var paymentCode = WALLET_PAYMENT_CODE_BY_TAG[String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '')] || String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '').toUpperCase();
3800
+ var paymentMethod = methodByCode.get(paymentCode);
3801
+ var formattedAmount = Number(item.amount);
3802
+ var amount = Number.isFinite(formattedAmount) && formattedAmount > 0 ? formattedAmount : getSharedWalletAssetAmount(asset);
3803
+ if (!asset || !paymentMethod || !Number.isFinite(amount) || amount <= 0) {
3804
+ return [];
3805
+ }
3806
+ var walletPassUseValue = getSharedWalletPassUseValue({
3807
+ asset: asset,
3808
+ amount: amount,
3809
+ paymentMethod: paymentMethod
3810
+ });
3811
+ return [{
3812
+ amount: amount.toFixed(2),
3813
+ code: paymentMethod.code,
3814
+ custom_payment_id: paymentMethod.id,
3815
+ name: paymentMethod.name,
3816
+ type: paymentMethod.type,
3817
+ voucher_id: item.voucher_id,
3818
+ wallet_pass_usage_unit: item.wallet_pass_usage_unit,
3819
+ wallet_pass_use_value: walletPassUseValue,
3820
+ fund_record: buildSharedWalletFundRecord({
3821
+ asset: asset,
3822
+ amount: amount,
3823
+ paymentMethod: paymentMethod
3824
+ })
3825
+ }];
3826
+ });
3827
+ payments = this.updateVoucherOrderPayments(voucherPayments, {
3828
+ status: 'payment_pending'
3829
+ });
3830
+ _context38.next = 14;
3831
+ return this.store.order.recalculateSummary({
3832
+ createIfMissing: true
3833
+ });
3834
+ case 14:
3835
+ return _context38.abrupt("return", payments);
3836
+ case 15:
3837
+ case "end":
3838
+ return _context38.stop();
3839
+ }
3840
+ }, _callee38, this);
3841
+ }));
3842
+ function syncSelectedWalletAssets(_x34) {
3843
+ return _syncSelectedWalletAssets.apply(this, arguments);
3844
+ }
3845
+ return syncSelectedWalletAssets;
3846
+ }() /** 读取购物车与 Shared Checkout 共用的钱包资产状态。 */
3847
+ }, {
3848
+ key: "getWalletAssetsState",
3849
+ value: function getWalletAssetsState() {
3850
+ if (!this.store.payment) throw new Error('payment 模块未初始化');
3851
+ return this.store.payment.wallet.getWalletAssetsState();
3852
+ }
3853
+
3854
+ /** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
3855
+ }, {
3856
+ key: "exportWalletAssetsSnapshot",
3857
+ value: function exportWalletAssetsSnapshot() {
3858
+ if (!this.store.payment) throw new Error('payment 模块未初始化');
3859
+ return this.store.payment.wallet.exportWalletAssetsSnapshot();
3860
+ }
3861
+
3862
+ /** 配置仅影响 Wallet Assets,不改变 Promotion/Voucher 选择流程。 */
3863
+ }, {
3864
+ key: "configureWalletAssetsBehavior",
3865
+ value: function configureWalletAssetsBehavior(options) {
3866
+ if (!this.store.payment) throw new Error('payment 模块未初始化');
3867
+ this.store.payment.wallet.configureWalletAssetsBehavior(options);
3868
+ }
3869
+
3870
+ /**
3871
+ * 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
3872
+ */
3873
+ }, {
3874
+ key: "importWalletAssetsSnapshot",
3875
+ value: (function () {
3876
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
3877
+ var state;
3878
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3879
+ while (1) switch (_context39.prev = _context39.next) {
3880
+ case 0:
3881
+ if (this.store.payment) {
3882
+ _context39.next = 2;
3883
+ break;
3884
+ }
3885
+ throw new Error('payment 模块未初始化');
3886
+ case 2:
3887
+ state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
3888
+ _context39.next = 5;
3889
+ return this.syncSelectedWalletAssets(state);
3890
+ case 5:
3891
+ return _context39.abrupt("return", this.publishWalletAssetsState(state));
3892
+ case 6:
3893
+ case "end":
3894
+ return _context39.stop();
3895
+ }
3896
+ }, _callee39, this);
3897
+ }));
3898
+ function importWalletAssetsSnapshot(_x35) {
3899
+ return _importWalletAssetsSnapshot.apply(this, arguments);
3900
+ }
3901
+ return importWalletAssetsSnapshot;
3902
+ }()
3903
+ /**
3904
+ * 基于当前订单快照刷新钱包资产。商品变化保留并重验选择;客户变化强制清空。
3905
+ */
3906
+ )
3907
+ }, {
3908
+ key: "refreshWalletAssets",
3909
+ value: (function () {
3910
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3911
+ var _previousState$custom, _businessData$custome;
3912
+ var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
3913
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3914
+ while (1) switch (_context40.prev = _context40.next) {
3915
+ case 0:
3916
+ if (this.store.order) {
3917
+ _context40.next = 2;
3918
+ break;
3919
+ }
3920
+ throw new Error('order 模块未初始化');
3921
+ case 2:
3922
+ if (this.store.payment) {
3923
+ _context40.next = 4;
3924
+ break;
3925
+ }
3926
+ throw new Error('payment 模块未初始化');
3927
+ case 4:
3928
+ refreshSequence = ++this.walletAssetsRefreshSequence;
3929
+ wallet = this.store.payment.wallet;
3930
+ businessData = this.buildWalletInitBusinessData(params);
3931
+ if (businessData) {
3932
+ _context40.next = 12;
3933
+ break;
3934
+ }
3935
+ wallet.clearAllCache();
3936
+ emptyState = wallet.getWalletAssetsState();
3937
+ this.updateVoucherOrderPayments([], {
3938
+ status: 'payment_pending'
3939
+ });
3940
+ return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
3941
+ case 12:
3942
+ previousState = wallet.getWalletAssetsState();
3943
+ hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
3944
+ customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
3945
+ if (!customerChanged) {
3946
+ _context40.next = 20;
3947
+ break;
3948
+ }
3949
+ clearedState = wallet.clearWalletAssetSelection();
3950
+ this.updateVoucherOrderPayments([], {
3951
+ status: 'payment_pending'
3952
+ });
3953
+ _context40.next = 20;
3954
+ return this.publishWalletAssetsState(clearedState);
3955
+ case 20:
3956
+ refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
3957
+ preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
3958
+ });
3959
+ _context40.next = 23;
3960
+ return this.publishWalletAssetsState(wallet.getWalletAssetsState());
3961
+ case 23:
3962
+ _context40.next = 25;
3963
+ return refreshTask;
3964
+ case 25:
3965
+ state = _context40.sent;
3966
+ if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
3967
+ _context40.next = 28;
3968
+ break;
3969
+ }
3970
+ return _context40.abrupt("return", wallet.getWalletAssetsState());
3971
+ case 28:
3972
+ if (state.status !== 'error') {
3973
+ committed = this.getCommittedWalletAssets();
3974
+ state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3975
+ }
3976
+ _context40.next = 31;
3977
+ return this.syncSelectedWalletAssets(state);
3978
+ case 31:
3979
+ return _context40.abrupt("return", this.publishWalletAssetsState(state));
3980
+ case 32:
3981
+ case "end":
3982
+ return _context40.stop();
3983
+ }
3984
+ }, _callee40, this);
3985
+ }));
3986
+ function refreshWalletAssets(_x36) {
3987
+ return _refreshWalletAssets.apply(this, arguments);
3988
+ }
3989
+ return refreshWalletAssets;
3990
+ }() /** 选择或取消单张钱包资产,并立即同步 pending wallet payments。 */)
3991
+ }, {
3992
+ key: "selectWalletAsset",
3993
+ value: (function () {
3994
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3995
+ var state;
3996
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3997
+ while (1) switch (_context41.prev = _context41.next) {
3998
+ case 0:
3999
+ if (this.store.payment) {
4000
+ _context41.next = 2;
4001
+ break;
4002
+ }
4003
+ throw new Error('payment 模块未初始化');
4004
+ case 2:
4005
+ state = this.store.payment.wallet.selectWalletAsset(params.assetId, {
4006
+ selected: params.selected,
4007
+ source: params.source
4008
+ });
4009
+ _context41.next = 5;
4010
+ return this.syncSelectedWalletAssets(state);
4011
+ case 5:
4012
+ return _context41.abrupt("return", this.publishWalletAssetsState(state));
4013
+ case 6:
4014
+ case "end":
4015
+ return _context41.stop();
4016
+ }
4017
+ }, _callee41, this);
4018
+ }));
4019
+ function selectWalletAsset(_x37) {
4020
+ return _selectWalletAsset.apply(this, arguments);
4021
+ }
4022
+ return selectWalletAsset;
4023
+ }() /** 扫码精确查券;仅可用资产会被自动选中。 */)
4024
+ }, {
4025
+ key: "scanWalletAsset",
4026
+ value: (function () {
4027
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(code) {
4028
+ var result;
4029
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4030
+ while (1) switch (_context42.prev = _context42.next) {
4031
+ case 0:
4032
+ if (this.store.payment) {
4033
+ _context42.next = 2;
4034
+ break;
4035
+ }
4036
+ throw new Error('payment 模块未初始化');
4037
+ case 2:
4038
+ _context42.next = 4;
4039
+ return this.store.payment.wallet.scanWalletAssetAsync(code);
4040
+ case 4:
4041
+ result = _context42.sent;
4042
+ if (!(result.type === 'normalCode')) {
4043
+ _context42.next = 10;
4044
+ break;
4045
+ }
4046
+ _context42.next = 8;
4047
+ return this.syncSelectedWalletAssets(result.state);
4048
+ case 8:
4049
+ _context42.next = 10;
4050
+ return this.publishWalletAssetsState(result.state);
4051
+ case 10:
4052
+ return _context42.abrupt("return", result);
4053
+ case 11:
4054
+ case "end":
4055
+ return _context42.stop();
4056
+ }
4057
+ }, _callee42, this);
4058
+ }));
4059
+ function scanWalletAsset(_x38) {
4060
+ return _scanWalletAsset.apply(this, arguments);
4061
+ }
4062
+ return scanWalletAsset;
4063
+ }() /** 清空全部未确认钱包选择,已支付钱包项由 Order 模块继续保留。 */)
4064
+ }, {
4065
+ key: "clearWalletAssetSelection",
4066
+ value: (function () {
4067
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
4068
+ var state;
4069
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4070
+ while (1) switch (_context43.prev = _context43.next) {
4071
+ case 0:
4072
+ if (this.store.payment) {
4073
+ _context43.next = 2;
4074
+ break;
4075
+ }
4076
+ throw new Error('payment 模块未初始化');
4077
+ case 2:
4078
+ state = this.store.payment.wallet.clearWalletAssetSelection();
4079
+ _context43.next = 5;
4080
+ return this.syncSelectedWalletAssets(state);
4081
+ case 5:
4082
+ return _context43.abrupt("return", this.publishWalletAssetsState(state));
4083
+ case 6:
4084
+ case "end":
4085
+ return _context43.stop();
4086
+ }
4087
+ }, _callee43, this);
4088
+ }));
4089
+ function clearWalletAssetSelection() {
4090
+ return _clearWalletAssetSelection.apply(this, arguments);
4091
+ }
4092
+ return clearWalletAssetSelection;
4093
+ }()
3212
4094
  /**
3213
4095
  * 更新当前订单客户字段。
3214
4096
  *
3215
4097
  * 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
3216
4098
  * 调用方通过 onCustomerChange 回调完成。
3217
4099
  */
4100
+ )
3218
4101
  }, {
3219
4102
  key: "updateOrderCustomer",
3220
4103
  value: function updateOrderCustomer(customer) {
@@ -3231,35 +4114,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3231
4114
  }, {
3232
4115
  key: "getPaymentMethodsAsync",
3233
4116
  value: (function () {
3234
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
4117
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3235
4118
  var response, paymentMethods;
3236
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
- while (1) switch (_context33.prev = _context33.next) {
4119
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4120
+ while (1) switch (_context44.prev = _context44.next) {
3238
4121
  case 0:
3239
- _context33.prev = 0;
3240
- _context33.next = 3;
4122
+ _context44.prev = 0;
4123
+ _context44.next = 3;
3241
4124
  return this.request.get('/pay/custom-payment/all', {
3242
4125
  filterPaymentMethods: true
3243
4126
  }, {
3244
4127
  osServer: true
3245
4128
  });
3246
4129
  case 3:
3247
- response = _context33.sent;
4130
+ response = _context44.sent;
3248
4131
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3249
4132
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3250
- return _context33.abrupt("return", this.getPaymentMethods());
4133
+ return _context44.abrupt("return", this.getPaymentMethods());
3251
4134
  case 9:
3252
- _context33.prev = 9;
3253
- _context33.t0 = _context33["catch"](0);
4135
+ _context44.prev = 9;
4136
+ _context44.t0 = _context44["catch"](0);
3254
4137
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3255
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
4138
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
3256
4139
  });
3257
- return _context33.abrupt("return", this.getPaymentMethods());
4140
+ return _context44.abrupt("return", this.getPaymentMethods());
3258
4141
  case 13:
3259
4142
  case "end":
3260
- return _context33.stop();
4143
+ return _context44.stop();
3261
4144
  }
3262
- }, _callee33, this, [[0, 9]]);
4145
+ }, _callee44, this, [[0, 9]]);
3263
4146
  }));
3264
4147
  function getPaymentMethodsAsync() {
3265
4148
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3271,50 +4154,536 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3271
4154
  value: function getPaymentMethods() {
3272
4155
  return _toConsumableArray(this.paymentMethodsCache);
3273
4156
  }
4157
+ }, {
4158
+ key: "findCashPaymentMethod",
4159
+ value: function findCashPaymentMethod(paymentMethods) {
4160
+ return paymentMethods.find(function (method) {
4161
+ var identifiers = [method === null || method === void 0 ? void 0 : method.code, method === null || method === void 0 ? void 0 : method.type, method === null || method === void 0 ? void 0 : method.tag].map(function (value) {
4162
+ return String(value || '').toUpperCase();
4163
+ });
4164
+ return identifiers.includes('CASHMANUAL') && (method === null || method === void 0 ? void 0 : method.enabled) !== false && (method === null || method === void 0 ? void 0 : method.enable) !== false;
4165
+ });
4166
+ }
4167
+ }, {
4168
+ key: "getPendingWalletPaymentAmount",
4169
+ value: function getPendingWalletPaymentAmount() {
4170
+ var _this$store$order10, _this$store$order10$g;
4171
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
4172
+ return payments.reduce(function (total, payment) {
4173
+ if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
4174
+ return total;
4175
+ }
4176
+ try {
4177
+ return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
4178
+ } catch (_unused5) {
4179
+ return total;
4180
+ }
4181
+ }, new Decimal(0));
4182
+ }
3274
4183
 
4184
+ /** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
4185
+ }, {
4186
+ key: "getCashPaymentConfig",
4187
+ value: (function () {
4188
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4189
+ var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams30;
4190
+ var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4191
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4192
+ while (1) switch (_context45.prev = _context45.next) {
4193
+ case 0:
4194
+ if (this.store.payment) {
4195
+ _context45.next = 2;
4196
+ break;
4197
+ }
4198
+ throw new Error('payment 模块未初始化');
4199
+ case 2:
4200
+ paymentMethods = this.getPaymentMethods();
4201
+ paymentMethod = this.findCashPaymentMethod(paymentMethods);
4202
+ if (paymentMethod) {
4203
+ _context45.next = 9;
4204
+ break;
4205
+ }
4206
+ _context45.next = 7;
4207
+ return this.getPaymentMethodsAsync();
4208
+ case 7:
4209
+ paymentMethods = _context45.sent;
4210
+ paymentMethod = this.findCashPaymentMethod(paymentMethods);
4211
+ case 9:
4212
+ amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
4213
+ pendingWalletAmount = this.getPendingWalletPaymentAmount();
4214
+ amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4215
+ currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.currency) || 'USD';
4216
+ recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4217
+ return _context45.abrupt("return", {
4218
+ available: Boolean(paymentMethod && amountDue > 0),
4219
+ paymentMethod: paymentMethod,
4220
+ amountDue: amountDue,
4221
+ recommendedAmounts: recommendedAmounts
4222
+ });
4223
+ case 15:
4224
+ case "end":
4225
+ return _context45.stop();
4226
+ }
4227
+ }, _callee45, this);
4228
+ }));
4229
+ function getCashPaymentConfig() {
4230
+ return _getCashPaymentConfig.apply(this, arguments);
4231
+ }
4232
+ return getCashPaymentConfig;
4233
+ }()
4234
+ /**
4235
+ * 确认足额覆盖订单的 pending Wallet 支付并提交订单。
4236
+ *
4237
+ * Order 模块在构造提交参数时将 pending voucher 转为 paid;只有提交成功后
4238
+ * 才同步 Wallet committed 状态。失败时恢复调用前 payments,允许用户重试。
4239
+ */
4240
+ )
4241
+ }, {
4242
+ key: "confirmWalletPayment",
4243
+ value: (function () {
4244
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4245
+ var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4246
+ var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4247
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4248
+ while (1) switch (_context46.prev = _context46.next) {
4249
+ case 0:
4250
+ if (this.store.order) {
4251
+ _context46.next = 2;
4252
+ break;
4253
+ }
4254
+ throw new Error('order 模块未初始化');
4255
+ case 2:
4256
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4257
+ pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
4258
+ if (!pendingWalletAmount.lte(0)) {
4259
+ _context46.next = 6;
4260
+ break;
4261
+ }
4262
+ throw new Error('当前订单没有待确认的 Wallet 支付');
4263
+ case 6:
4264
+ amountSnapshot = (_this$store$order$get3 = (_this$store$order13 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order13);
4265
+ effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4266
+ if (!effectiveAmountDue.gt(0.01)) {
4267
+ _context46.next = 10;
4268
+ break;
4269
+ }
4270
+ throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4271
+ case 10:
4272
+ beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4273
+ _context46.prev = 11;
4274
+ _context46.next = 14;
4275
+ return this.submitSalesOrder({
4276
+ smallTicketDataFlag: 1,
4277
+ confirmPendingVoucherPayments: true
4278
+ });
4279
+ case 14:
4280
+ submitResult = _context46.sent;
4281
+ if (!isRejectedSalesSubmitResult(submitResult)) {
4282
+ _context46.next = 17;
4283
+ break;
4284
+ }
4285
+ throw new Error(getSalesSubmitErrorMessage(submitResult));
4286
+ case 17:
4287
+ _context46.next = 27;
4288
+ break;
4289
+ case 19:
4290
+ _context46.prev = 19;
4291
+ _context46.t0 = _context46["catch"](11);
4292
+ this.store.order.setOrderPayments(beforePayments);
4293
+ restoredTempOrder = this.store.order.getTempOrder();
4294
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4295
+ restoredTempOrder.payment_status = beforePaymentStatus;
4296
+ this.store.order.persistTempOrder();
4297
+ }
4298
+ _context46.next = 26;
4299
+ return this.store.order.recalculateSummary({
4300
+ createIfMissing: true
4301
+ });
4302
+ case 26:
4303
+ throw _context46.t0;
4304
+ case 27:
4305
+ if (!this.store.payment) {
4306
+ _context46.next = 38;
4307
+ break;
4308
+ }
4309
+ _context46.prev = 28;
4310
+ committed = this.getCommittedWalletAssets();
4311
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4312
+ _context46.next = 33;
4313
+ return this.publishWalletAssetsState(walletState);
4314
+ case 33:
4315
+ _context46.next = 38;
4316
+ break;
4317
+ case 35:
4318
+ _context46.prev = 35;
4319
+ _context46.t1 = _context46["catch"](28);
4320
+ this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4321
+ error: _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1)
4322
+ });
4323
+ case 38:
4324
+ latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order14);
4325
+ return _context46.abrupt("return", {
4326
+ submitResult: submitResult,
4327
+ payments: this.store.order.getOrderPayments(),
4328
+ isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4329
+ });
4330
+ case 40:
4331
+ case "end":
4332
+ return _context46.stop();
4333
+ }
4334
+ }, _callee46, this, [[11, 19], [28, 35]]);
4335
+ }));
4336
+ function confirmWalletPayment() {
4337
+ return _confirmWalletPayment.apply(this, arguments);
4338
+ }
4339
+ return confirmWalletPayment;
4340
+ }()
4341
+ /**
4342
+ * 购物车现金直付:写入现金记录并等待支付同步完成。
4343
+ * 同步失败会恢复调用前 payments(包含 Wallet pending 状态)。
4344
+ */
4345
+ )
4346
+ }, {
4347
+ key: "payCash",
4348
+ value: (function () {
4349
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4350
+ var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams31, _this$window, _this$window$postMess;
4351
+ var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4352
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4353
+ while (1) switch (_context47.prev = _context47.next) {
4354
+ case 0:
4355
+ if (this.store.order) {
4356
+ _context47.next = 2;
4357
+ break;
4358
+ }
4359
+ throw new Error('order 模块未初始化');
4360
+ case 2:
4361
+ amount = Number(params.amount || 0);
4362
+ if (!(!Number.isFinite(amount) || amount <= 0)) {
4363
+ _context47.next = 5;
4364
+ break;
4365
+ }
4366
+ throw new Error('现金支付金额必须大于 0');
4367
+ case 5:
4368
+ _context47.next = 7;
4369
+ return this.getCashPaymentConfig();
4370
+ case 7:
4371
+ config = _context47.sent;
4372
+ paymentMethod = config.paymentMethod;
4373
+ if (paymentMethod) {
4374
+ _context47.next = 11;
4375
+ break;
4376
+ }
4377
+ throw new Error('未找到可用的 CASHMANUAL 支付方式');
4378
+ case 11:
4379
+ if (!(config.amountDue <= 0)) {
4380
+ _context47.next = 13;
4381
+ break;
4382
+ }
4383
+ throw new Error('当前订单没有待支付金额');
4384
+ case 13:
4385
+ roundingAmount = Number(params.roundingAmount || 0);
4386
+ effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4387
+ if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4388
+ _context47.next = 17;
4389
+ break;
4390
+ }
4391
+ throw new Error('现金支付金额超过当前待支付金额');
4392
+ case 17:
4393
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4394
+ beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
4395
+ uniquePaymentNumber = createUuidV4();
4396
+ paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4397
+ actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4398
+ changeAmount = Number(params.changeAmount || 0);
4399
+ shopWalletPassId = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.shop_wallet_pass_id;
4400
+ if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4401
+ _context47.next = 26;
4402
+ break;
4403
+ }
4404
+ throw new Error('顾客实收现金不能小于支付金额');
4405
+ case 26:
4406
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
4407
+ module: 'till',
4408
+ key: 'open_till',
4409
+ data: {
4410
+ type: 'cash'
4411
+ }
4412
+ });
4413
+ payments = this.store.order.addOrderPayment({
4414
+ amount: amount.toFixed(2),
4415
+ code: paymentMethod.code,
4416
+ custom_payment_id: paymentMethod.id,
4417
+ name: paymentMethod.name,
4418
+ custom_payment_type: paymentMethod.type,
4419
+ voucher_id: 0,
4420
+ rounding_amount: roundingAmount.toFixed(2),
4421
+ metadata: _objectSpread(_objectSpread({
4422
+ unique_payment_number: uniquePaymentNumber
4423
+ }, shopWalletPassId !== undefined && shopWalletPassId !== null ? {
4424
+ shop_wallet_pass_id: shopWalletPassId
4425
+ } : {}), {}, {
4426
+ actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
4427
+ change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
4428
+ }),
4429
+ payment_time: paymentTimestamp,
4430
+ created_at: paymentTimestamp
4431
+ });
4432
+ payment = payments.find(function (item) {
4433
+ var _item$metadata2;
4434
+ return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4435
+ });
4436
+ _context47.prev = 29;
4437
+ _context47.next = 32;
4438
+ return this.syncPaymentsToOrder({
4439
+ payments: payments,
4440
+ submitWhenPaid: true,
4441
+ smallTicketDataFlag: 1,
4442
+ confirmPendingVoucherPayments: true
4443
+ });
4444
+ case 32:
4445
+ syncResult = _context47.sent;
4446
+ if (!this.store.payment) {
4447
+ _context47.next = 38;
4448
+ break;
4449
+ }
4450
+ committed = this.getCommittedWalletAssets();
4451
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4452
+ _context47.next = 38;
4453
+ return this.publishWalletAssetsState(walletState);
4454
+ case 38:
4455
+ return _context47.abrupt("return", {
4456
+ payment: payment || {},
4457
+ payments: this.store.order.getOrderPayments(),
4458
+ syncResult: syncResult,
4459
+ isOrderFullyPaid: syncResult.isOrderFullyPaid
4460
+ });
4461
+ case 41:
4462
+ _context47.prev = 41;
4463
+ _context47.t0 = _context47["catch"](29);
4464
+ this.store.order.setOrderPayments(beforePayments);
4465
+ restoredTempOrder = this.store.order.getTempOrder();
4466
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4467
+ restoredTempOrder.payment_status = beforePaymentStatus;
4468
+ this.store.order.persistTempOrder();
4469
+ }
4470
+ _context47.next = 48;
4471
+ return this.store.order.recalculateSummary({
4472
+ createIfMissing: true
4473
+ });
4474
+ case 48:
4475
+ throw _context47.t0;
4476
+ case 49:
4477
+ case "end":
4478
+ return _context47.stop();
4479
+ }
4480
+ }, _callee47, this, [[29, 41]]);
4481
+ }));
4482
+ function payCash(_x39) {
4483
+ return _payCash.apply(this, arguments);
4484
+ }
4485
+ return payCash;
4486
+ }()
4487
+ /**
4488
+ * 提交一次已由支付设备确认成功的非 Wallet 支付。
4489
+ *
4490
+ * 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
4491
+ * 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
4492
+ * 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
4493
+ */
4494
+ )
4495
+ }, {
4496
+ key: "commitPaymentMethodPayment",
4497
+ value: (function () {
4498
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4499
+ var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
4500
+ var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4501
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4502
+ while (1) switch (_context48.prev = _context48.next) {
4503
+ case 0:
4504
+ if (this.store.order) {
4505
+ _context48.next = 2;
4506
+ break;
4507
+ }
4508
+ throw new Error('order 模块未初始化');
4509
+ case 2:
4510
+ amount = Number(params.amount || 0);
4511
+ if (!(!Number.isFinite(amount) || amount <= 0)) {
4512
+ _context48.next = 5;
4513
+ break;
4514
+ }
4515
+ throw new Error('支付金额必须大于 0');
4516
+ case 5:
4517
+ paymentMethods = this.getPaymentMethods();
4518
+ findPaymentMethod = function findPaymentMethod() {
4519
+ var methodCode = String(params.paymentMethodCode || '').toUpperCase();
4520
+ return paymentMethods.find(function (method) {
4521
+ var idMatched = params.paymentMethodId !== undefined && String(method.id) === String(params.paymentMethodId);
4522
+ var codeMatched = Boolean(methodCode) && String(method.code || '').toUpperCase() === methodCode;
4523
+ return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
4524
+ });
4525
+ };
4526
+ paymentMethod = findPaymentMethod();
4527
+ if (paymentMethod) {
4528
+ _context48.next = 13;
4529
+ break;
4530
+ }
4531
+ _context48.next = 11;
4532
+ return this.getPaymentMethodsAsync();
4533
+ case 11:
4534
+ paymentMethods = _context48.sent;
4535
+ paymentMethod = findPaymentMethod();
4536
+ case 13:
4537
+ if (paymentMethod) {
4538
+ _context48.next = 15;
4539
+ break;
4540
+ }
4541
+ throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
4542
+ case 15:
4543
+ amountSnapshot = (_this$store$order$get7 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order15);
4544
+ pendingWalletAmount = this.getPendingWalletPaymentAmount();
4545
+ amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4546
+ if (!amountDue.lte(0)) {
4547
+ _context48.next = 20;
4548
+ break;
4549
+ }
4550
+ throw new Error('当前订单没有待支付金额');
4551
+ case 20:
4552
+ if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
4553
+ _context48.next = 22;
4554
+ break;
4555
+ }
4556
+ throw new Error('支付金额超过当前待支付金额');
4557
+ case 22:
4558
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4559
+ beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
4560
+ paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4561
+ metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
4562
+ unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
4563
+ });
4564
+ serviceCharge = params.serviceCharge ? {
4565
+ amount: String(params.serviceCharge.amount || 0),
4566
+ percentage: String(params.serviceCharge.percentage || 0)
4567
+ } : undefined;
4568
+ serviceFee = serviceCharge ? new Decimal((_params$originAmount = params.originAmount) !== null && _params$originAmount !== void 0 ? _params$originAmount : amount).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
4569
+ payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params.paymentData || {}), {}, {
4570
+ amount: amount.toFixed(2)
4571
+ }, params.originAmount !== undefined ? {
4572
+ origin_amount: Number(params.originAmount).toFixed(2)
4573
+ } : {}), {}, {
4574
+ code: paymentMethod.code,
4575
+ custom_payment_id: paymentMethod.id,
4576
+ name: paymentMethod.name,
4577
+ custom_payment_type: paymentMethod.type,
4578
+ voucher_id: 0
4579
+ }, serviceCharge ? {
4580
+ service_charge: serviceCharge
4581
+ } : {}), serviceFee !== undefined ? {
4582
+ service_fee: serviceFee
4583
+ } : {}), {}, {
4584
+ metadata: metadata,
4585
+ payment_time: paymentTimestamp,
4586
+ created_at: paymentTimestamp
4587
+ }));
4588
+ payment = payments.find(function (item) {
4589
+ var _item$metadata3;
4590
+ return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
4591
+ });
4592
+ _context48.prev = 30;
4593
+ _context48.next = 33;
4594
+ return this.syncPaymentsToOrder({
4595
+ payments: payments,
4596
+ submitWhenPaid: true,
4597
+ smallTicketDataFlag: 1,
4598
+ confirmPendingVoucherPayments: true
4599
+ });
4600
+ case 33:
4601
+ syncResult = _context48.sent;
4602
+ if (!this.store.payment) {
4603
+ _context48.next = 39;
4604
+ break;
4605
+ }
4606
+ committed = this.getCommittedWalletAssets();
4607
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4608
+ _context48.next = 39;
4609
+ return this.publishWalletAssetsState(walletState);
4610
+ case 39:
4611
+ return _context48.abrupt("return", {
4612
+ payment: payment || {},
4613
+ payments: this.store.order.getOrderPayments(),
4614
+ syncResult: syncResult,
4615
+ isOrderFullyPaid: syncResult.isOrderFullyPaid
4616
+ });
4617
+ case 42:
4618
+ _context48.prev = 42;
4619
+ _context48.t0 = _context48["catch"](30);
4620
+ this.store.order.setOrderPayments(beforePayments);
4621
+ restoredTempOrder = this.store.order.getTempOrder();
4622
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4623
+ restoredTempOrder.payment_status = beforePaymentStatus;
4624
+ this.store.order.persistTempOrder();
4625
+ }
4626
+ _context48.next = 49;
4627
+ return this.store.order.recalculateSummary({
4628
+ createIfMissing: true
4629
+ });
4630
+ case 49:
4631
+ throw _context48.t0;
4632
+ case 50:
4633
+ case "end":
4634
+ return _context48.stop();
4635
+ }
4636
+ }, _callee48, this, [[30, 42]]);
4637
+ }));
4638
+ function commitPaymentMethodPayment(_x40) {
4639
+ return _commitPaymentMethodPayment.apply(this, arguments);
4640
+ }
4641
+ return commitPaymentMethodPayment;
4642
+ }()
3275
4643
  /**
3276
4644
  * 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
3277
4645
  *
3278
4646
  * 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
3279
4647
  * otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
3280
4648
  */
4649
+ )
3281
4650
  }, {
3282
4651
  key: "roundAmount",
3283
4652
  value: (function () {
3284
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4653
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
3285
4654
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
3286
4655
  var amount, cashManualPayment;
3287
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3288
- while (1) switch (_context34.prev = _context34.next) {
4656
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4657
+ while (1) switch (_context49.prev = _context49.next) {
3289
4658
  case 0:
3290
4659
  amount = params.amount;
3291
4660
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
3292
4661
  return paymentMethod.code === 'CASHMANUAL';
3293
4662
  });
3294
4663
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
3295
- _context34.next = 4;
4664
+ _context49.next = 4;
3296
4665
  break;
3297
4666
  }
3298
- return _context34.abrupt("return", {
4667
+ return _context49.abrupt("return", {
3299
4668
  originalAmount: amount.toString(),
3300
4669
  roundedAmount: amount.toString(),
3301
4670
  roundingDifference: '0.00'
3302
4671
  });
3303
4672
  case 4:
3304
4673
  if (this.payment) {
3305
- _context34.next = 6;
4674
+ _context49.next = 6;
3306
4675
  break;
3307
4676
  }
3308
4677
  throw new Error('payment 模块未初始化');
3309
4678
  case 6:
3310
- return _context34.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
4679
+ return _context49.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
3311
4680
  case 7:
3312
4681
  case "end":
3313
- return _context34.stop();
4682
+ return _context49.stop();
3314
4683
  }
3315
- }, _callee34, this);
4684
+ }, _callee49, this);
3316
4685
  }));
3317
- function roundAmount(_x26) {
4686
+ function roundAmount(_x41) {
3318
4687
  return _roundAmount.apply(this, arguments);
3319
4688
  }
3320
4689
  return roundAmount;
@@ -3329,49 +4698,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3329
4698
  }, {
3330
4699
  key: "sendCustomerPayLink",
3331
4700
  value: (function () {
3332
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3333
- var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3334
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3335
- while (1) switch (_context35.prev = _context35.next) {
4701
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4702
+ var orderIds, _ref37, _ref38, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
4703
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4704
+ while (1) switch (_context50.prev = _context50.next) {
3336
4705
  case 0:
3337
4706
  if (this.store.order) {
3338
- _context35.next = 2;
4707
+ _context50.next = 2;
3339
4708
  break;
3340
4709
  }
3341
4710
  throw new Error('order 模块未初始化');
3342
4711
  case 2:
3343
4712
  orderIds = params.order_ids || params.orderIds || [];
3344
4713
  if (!(!orderIds.length || params.submitBeforeSend)) {
3345
- _context35.next = 11;
4714
+ _context50.next = 11;
3346
4715
  break;
3347
4716
  }
3348
- _context35.next = 6;
4717
+ _context50.next = 6;
3349
4718
  return this.submitSalesOrder({
3350
4719
  smallTicketDataFlag: 1
3351
4720
  });
3352
4721
  case 6:
3353
- submitResult = _context35.sent;
3354
- orderId = (_ref25 = (_ref26 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
4722
+ submitResult = _context50.sent;
4723
+ orderId = (_ref37 = (_ref38 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref38 !== void 0 ? _ref38 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref37 !== void 0 ? _ref37 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3355
4724
  if (orderId) {
3356
- _context35.next = 10;
4725
+ _context50.next = 10;
3357
4726
  break;
3358
4727
  }
3359
4728
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3360
4729
  case 10:
3361
4730
  orderIds = [orderId];
3362
4731
  case 11:
3363
- return _context35.abrupt("return", this.store.order.sendCustomerPayLink({
4732
+ return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
3364
4733
  emails: params.emails,
3365
4734
  notify_action: params.notify_action,
3366
4735
  order_ids: orderIds
3367
4736
  }));
3368
4737
  case 12:
3369
4738
  case "end":
3370
- return _context35.stop();
4739
+ return _context50.stop();
3371
4740
  }
3372
- }, _callee35, this);
4741
+ }, _callee50, this);
3373
4742
  }));
3374
- function sendCustomerPayLink(_x27) {
4743
+ function sendCustomerPayLink(_x42) {
3375
4744
  return _sendCustomerPayLink.apply(this, arguments);
3376
4745
  }
3377
4746
  return sendCustomerPayLink;
@@ -3384,27 +4753,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3384
4753
  }, {
3385
4754
  key: "calculateProductBookingPrice",
3386
4755
  value: function () {
3387
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4756
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
3388
4757
  var _params$customer_id;
3389
4758
  var quotation, customerId, authoritativeProduct, product;
3390
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3391
- while (1) switch (_context36.prev = _context36.next) {
4759
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4760
+ while (1) switch (_context51.prev = _context51.next) {
3392
4761
  case 0:
3393
4762
  quotation = this.store.quotation;
3394
4763
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3395
- _context36.next = 4;
4764
+ _context51.next = 4;
3396
4765
  return this.loadProductForPriceQuery(params, customerId);
3397
4766
  case 4:
3398
- authoritativeProduct = _context36.sent;
4767
+ authoritativeProduct = _context51.sent;
3399
4768
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3400
- _context36.next = 8;
4769
+ _context51.next = 8;
3401
4770
  return this.loadQuotationForPriceQuery({
3402
4771
  quotation: quotation,
3403
4772
  customer_id: customerId,
3404
4773
  channel: params.channel
3405
4774
  });
3406
4775
  case 8:
3407
- return _context36.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4776
+ return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3408
4777
  product: product,
3409
4778
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3410
4779
  customer_id: customerId,
@@ -3412,11 +4781,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3412
4781
  })));
3413
4782
  case 9:
3414
4783
  case "end":
3415
- return _context36.stop();
4784
+ return _context51.stop();
3416
4785
  }
3417
- }, _callee36, this);
4786
+ }, _callee51, this);
3418
4787
  }));
3419
- function calculateProductBookingPrice(_x28) {
4788
+ function calculateProductBookingPrice(_x43) {
3420
4789
  return _calculateProductBookingPrice.apply(this, arguments);
3421
4790
  }
3422
4791
  return calculateProductBookingPrice;
@@ -3424,7 +4793,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3424
4793
  }, {
3425
4794
  key: "getQuotationCustomerScopeInfo",
3426
4795
  value: function getQuotationCustomerScopeInfo() {
3427
- var _this13 = this;
4796
+ var _this15 = this;
3428
4797
  var quotation = this.store.quotation;
3429
4798
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3430
4799
  return quotation.getQuotationCustomerScopeInfo();
@@ -3436,7 +4805,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3436
4805
  }).map(function (item) {
3437
4806
  var localSeen = new Set();
3438
4807
  var customers = item.customer.filter(function (customer) {
3439
- var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
4808
+ var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3440
4809
  if (!customerId || localSeen.has(customerId)) return false;
3441
4810
  localSeen.add(customerId);
3442
4811
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3486,32 +4855,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3486
4855
  }, {
3487
4856
  key: "calculateProductBookingPrices",
3488
4857
  value: function () {
3489
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paramsList) {
4858
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
3490
4859
  var _paramsList$0$custome,
3491
4860
  _paramsList$,
3492
- _this14 = this,
4861
+ _this16 = this,
3493
4862
  _paramsList$2;
3494
4863
  var quotation, customerId, productMapsByGroup, groups;
3495
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3496
- while (1) switch (_context38.prev = _context38.next) {
4864
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4865
+ while (1) switch (_context53.prev = _context53.next) {
3497
4866
  case 0:
3498
4867
  if (paramsList.length) {
3499
- _context38.next = 2;
4868
+ _context53.next = 2;
3500
4869
  break;
3501
4870
  }
3502
- return _context38.abrupt("return", []);
4871
+ return _context53.abrupt("return", []);
3503
4872
  case 2:
3504
4873
  quotation = this.store.quotation;
3505
4874
  customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
3506
4875
  productMapsByGroup = new Map();
3507
4876
  groups = new Map();
3508
4877
  paramsList.forEach(function (params) {
3509
- var _this14$otherParams;
4878
+ var _this16$otherParams;
3510
4879
  var product = params.product || {};
3511
- var productId = _this14.getPriceQueryProductId(product);
4880
+ var productId = _this16.getPriceQueryProductId(product);
3512
4881
  if (productId === null) return;
3513
- var schedule = _this14.getPriceQuerySchedule(params);
3514
- var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
4882
+ var schedule = _this16.getPriceQuerySchedule(params);
4883
+ var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
3515
4884
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3516
4885
  var group = groups.get(groupKey) || {
3517
4886
  ids: new Set(),
@@ -3521,51 +4890,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3521
4890
  group.ids.add(productId);
3522
4891
  groups.set(groupKey, group);
3523
4892
  });
3524
- _context38.next = 9;
4893
+ _context53.next = 9;
3525
4894
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3526
- var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(_ref27) {
3527
- var _ref29, groupKey, group, productsById;
3528
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3529
- while (1) switch (_context37.prev = _context37.next) {
4895
+ var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(_ref39) {
4896
+ var _ref41, groupKey, group, productsById;
4897
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4898
+ while (1) switch (_context52.prev = _context52.next) {
3530
4899
  case 0:
3531
- _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3532
- _context37.next = 3;
3533
- return _this14.loadProductsForPriceQuery({
4900
+ _ref41 = _slicedToArray(_ref39, 2), groupKey = _ref41[0], group = _ref41[1];
4901
+ _context52.next = 3;
4902
+ return _this16.loadProductsForPriceQuery({
3534
4903
  ids: Array.from(group.ids),
3535
4904
  schedule: group.schedule,
3536
4905
  customerId: customerId,
3537
4906
  channel: group.channel
3538
4907
  });
3539
4908
  case 3:
3540
- productsById = _context37.sent;
4909
+ productsById = _context52.sent;
3541
4910
  productMapsByGroup.set(groupKey, productsById);
3542
4911
  case 5:
3543
4912
  case "end":
3544
- return _context37.stop();
4913
+ return _context52.stop();
3545
4914
  }
3546
- }, _callee37);
4915
+ }, _callee52);
3547
4916
  }));
3548
- return function (_x30) {
3549
- return _ref28.apply(this, arguments);
4917
+ return function (_x45) {
4918
+ return _ref40.apply(this, arguments);
3550
4919
  };
3551
4920
  }()));
3552
4921
  case 9:
3553
- _context38.next = 11;
4922
+ _context53.next = 11;
3554
4923
  return this.loadQuotationForPriceQuery({
3555
4924
  quotation: quotation,
3556
4925
  customer_id: customerId,
3557
4926
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3558
4927
  });
3559
4928
  case 11:
3560
- return _context38.abrupt("return", paramsList.map(function (params) {
3561
- var _this14$otherParams2, _productMapsByGroup$g;
4929
+ return _context53.abrupt("return", paramsList.map(function (params) {
4930
+ var _this16$otherParams2, _productMapsByGroup$g;
3562
4931
  var productInput = params.product || {};
3563
- var productId = _this14.getPriceQueryProductId(productInput);
3564
- var schedule = _this14.getPriceQuerySchedule(params);
3565
- var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
4932
+ var productId = _this16.getPriceQueryProductId(productInput);
4933
+ var schedule = _this16.getPriceQuerySchedule(params);
4934
+ var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
3566
4935
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3567
4936
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3568
- var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
4937
+ var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3569
4938
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3570
4939
  product: product,
3571
4940
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3575,11 +4944,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3575
4944
  }));
3576
4945
  case 12:
3577
4946
  case "end":
3578
- return _context38.stop();
4947
+ return _context53.stop();
3579
4948
  }
3580
- }, _callee38, this);
4949
+ }, _callee53, this);
3581
4950
  }));
3582
- function calculateProductBookingPrices(_x29) {
4951
+ function calculateProductBookingPrices(_x44) {
3583
4952
  return _calculateProductBookingPrices.apply(this, arguments);
3584
4953
  }
3585
4954
  return calculateProductBookingPrices;
@@ -3587,34 +4956,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3587
4956
  }, {
3588
4957
  key: "addProductToOrder",
3589
4958
  value: function () {
3590
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(product, booking) {
4959
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking, options) {
3591
4960
  var products;
3592
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3593
- while (1) switch (_context39.prev = _context39.next) {
4961
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4962
+ while (1) switch (_context54.prev = _context54.next) {
3594
4963
  case 0:
3595
- _context39.prev = 0;
4964
+ _context54.prev = 0;
3596
4965
  if (this.store.order) {
3597
- _context39.next = 3;
4966
+ _context54.next = 3;
3598
4967
  break;
3599
4968
  }
3600
4969
  throw new Error('order 模块未初始化');
3601
4970
  case 3:
3602
- _context39.next = 5;
3603
- return this.store.order.addProductToOrder(product, booking);
4971
+ _context54.next = 5;
4972
+ return this.store.order.addProductToOrder(product, booking, options);
3604
4973
  case 5:
3605
- products = _context39.sent;
3606
- return _context39.abrupt("return", products);
4974
+ products = _context54.sent;
4975
+ return _context54.abrupt("return", products);
3607
4976
  case 9:
3608
- _context39.prev = 9;
3609
- _context39.t0 = _context39["catch"](0);
3610
- throw _context39.t0;
4977
+ _context54.prev = 9;
4978
+ _context54.t0 = _context54["catch"](0);
4979
+ throw _context54.t0;
3611
4980
  case 12:
3612
4981
  case "end":
3613
- return _context39.stop();
4982
+ return _context54.stop();
3614
4983
  }
3615
- }, _callee39, this, [[0, 9]]);
4984
+ }, _callee54, this, [[0, 9]]);
3616
4985
  }));
3617
- function addProductToOrder(_x31, _x32) {
4986
+ function addProductToOrder(_x46, _x47, _x48) {
3618
4987
  return _addProductToOrder.apply(this, arguments);
3619
4988
  }
3620
4989
  return addProductToOrder;
@@ -3622,34 +4991,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3622
4991
  }, {
3623
4992
  key: "updateOrderProduct",
3624
4993
  value: function () {
3625
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
4994
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
3626
4995
  var products;
3627
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3628
- while (1) switch (_context40.prev = _context40.next) {
4996
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4997
+ while (1) switch (_context55.prev = _context55.next) {
3629
4998
  case 0:
3630
- _context40.prev = 0;
4999
+ _context55.prev = 0;
3631
5000
  if (this.store.order) {
3632
- _context40.next = 3;
5001
+ _context55.next = 3;
3633
5002
  break;
3634
5003
  }
3635
5004
  throw new Error('order 模块未初始化');
3636
5005
  case 3:
3637
- _context40.next = 5;
5006
+ _context55.next = 5;
3638
5007
  return this.store.order.updateOrderProduct(params);
3639
5008
  case 5:
3640
- products = _context40.sent;
3641
- return _context40.abrupt("return", products);
5009
+ products = _context55.sent;
5010
+ return _context55.abrupt("return", products);
3642
5011
  case 9:
3643
- _context40.prev = 9;
3644
- _context40.t0 = _context40["catch"](0);
3645
- throw _context40.t0;
5012
+ _context55.prev = 9;
5013
+ _context55.t0 = _context55["catch"](0);
5014
+ throw _context55.t0;
3646
5015
  case 12:
3647
5016
  case "end":
3648
- return _context40.stop();
5017
+ return _context55.stop();
3649
5018
  }
3650
- }, _callee40, this, [[0, 9]]);
5019
+ }, _callee55, this, [[0, 9]]);
3651
5020
  }));
3652
- function updateOrderProduct(_x33) {
5021
+ function updateOrderProduct(_x49) {
3653
5022
  return _updateOrderProduct.apply(this, arguments);
3654
5023
  }
3655
5024
  return updateOrderProduct;
@@ -3657,34 +5026,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3657
5026
  }, {
3658
5027
  key: "updateOrderProducts",
3659
5028
  value: function () {
3660
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
5029
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
3661
5030
  var products;
3662
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3663
- while (1) switch (_context41.prev = _context41.next) {
5031
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5032
+ while (1) switch (_context56.prev = _context56.next) {
3664
5033
  case 0:
3665
- _context41.prev = 0;
5034
+ _context56.prev = 0;
3666
5035
  if (this.store.order) {
3667
- _context41.next = 3;
5036
+ _context56.next = 3;
3668
5037
  break;
3669
5038
  }
3670
5039
  throw new Error('order 模块未初始化');
3671
5040
  case 3:
3672
- _context41.next = 5;
5041
+ _context56.next = 5;
3673
5042
  return this.store.order.updateOrderProducts(paramsList);
3674
5043
  case 5:
3675
- products = _context41.sent;
3676
- return _context41.abrupt("return", products);
5044
+ products = _context56.sent;
5045
+ return _context56.abrupt("return", products);
3677
5046
  case 9:
3678
- _context41.prev = 9;
3679
- _context41.t0 = _context41["catch"](0);
3680
- throw _context41.t0;
5047
+ _context56.prev = 9;
5048
+ _context56.t0 = _context56["catch"](0);
5049
+ throw _context56.t0;
3681
5050
  case 12:
3682
5051
  case "end":
3683
- return _context41.stop();
5052
+ return _context56.stop();
3684
5053
  }
3685
- }, _callee41, this, [[0, 9]]);
5054
+ }, _callee56, this, [[0, 9]]);
3686
5055
  }));
3687
- function updateOrderProducts(_x34) {
5056
+ function updateOrderProducts(_x50) {
3688
5057
  return _updateOrderProducts.apply(this, arguments);
3689
5058
  }
3690
5059
  return updateOrderProducts;
@@ -3692,34 +5061,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3692
5061
  }, {
3693
5062
  key: "updateOrderProductQuantity",
3694
5063
  value: function () {
3695
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5064
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
3696
5065
  var products;
3697
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3698
- while (1) switch (_context42.prev = _context42.next) {
5066
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5067
+ while (1) switch (_context57.prev = _context57.next) {
3699
5068
  case 0:
3700
- _context42.prev = 0;
5069
+ _context57.prev = 0;
3701
5070
  if (this.store.order) {
3702
- _context42.next = 3;
5071
+ _context57.next = 3;
3703
5072
  break;
3704
5073
  }
3705
5074
  throw new Error('order 模块未初始化');
3706
5075
  case 3:
3707
- _context42.next = 5;
5076
+ _context57.next = 5;
3708
5077
  return this.store.order.updateOrderProductQuantity(params);
3709
5078
  case 5:
3710
- products = _context42.sent;
3711
- return _context42.abrupt("return", products);
5079
+ products = _context57.sent;
5080
+ return _context57.abrupt("return", products);
3712
5081
  case 9:
3713
- _context42.prev = 9;
3714
- _context42.t0 = _context42["catch"](0);
3715
- throw _context42.t0;
5082
+ _context57.prev = 9;
5083
+ _context57.t0 = _context57["catch"](0);
5084
+ throw _context57.t0;
3716
5085
  case 12:
3717
5086
  case "end":
3718
- return _context42.stop();
5087
+ return _context57.stop();
3719
5088
  }
3720
- }, _callee42, this, [[0, 9]]);
5089
+ }, _callee57, this, [[0, 9]]);
3721
5090
  }));
3722
- function updateOrderProductQuantity(_x35) {
5091
+ function updateOrderProductQuantity(_x51) {
3723
5092
  return _updateOrderProductQuantity.apply(this, arguments);
3724
5093
  }
3725
5094
  return updateOrderProductQuantity;
@@ -3742,12 +5111,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3742
5111
  }, {
3743
5112
  key: "setOrderProductLineNote",
3744
5113
  value: (function () {
3745
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identity, note) {
5114
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
3746
5115
  var params, products;
3747
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3748
- while (1) switch (_context43.prev = _context43.next) {
5116
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5117
+ while (1) switch (_context58.prev = _context58.next) {
3749
5118
  case 0:
3750
- _context43.prev = 0;
5119
+ _context58.prev = 0;
3751
5120
  params = {
3752
5121
  product_id: identity.product_id,
3753
5122
  product_variant_id: identity.product_variant_id,
@@ -3762,22 +5131,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3762
5131
  params.product_sku = identity.product_sku;
3763
5132
  }
3764
5133
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3765
- _context43.next = 7;
5134
+ _context58.next = 7;
3766
5135
  return this.updateOrderProduct(params);
3767
5136
  case 7:
3768
- products = _context43.sent;
3769
- return _context43.abrupt("return", products);
5137
+ products = _context58.sent;
5138
+ return _context58.abrupt("return", products);
3770
5139
  case 11:
3771
- _context43.prev = 11;
3772
- _context43.t0 = _context43["catch"](0);
3773
- throw _context43.t0;
5140
+ _context58.prev = 11;
5141
+ _context58.t0 = _context58["catch"](0);
5142
+ throw _context58.t0;
3774
5143
  case 14:
3775
5144
  case "end":
3776
- return _context43.stop();
5145
+ return _context58.stop();
3777
5146
  }
3778
- }, _callee43, this, [[0, 11]]);
5147
+ }, _callee58, this, [[0, 11]]);
3779
5148
  }));
3780
- function setOrderProductLineNote(_x36, _x37) {
5149
+ function setOrderProductLineNote(_x52, _x53) {
3781
5150
  return _setOrderProductLineNote.apply(this, arguments);
3782
5151
  }
3783
5152
  return setOrderProductLineNote;
@@ -3792,32 +5161,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3792
5161
  }, {
3793
5162
  key: "removeProductsFromOrder",
3794
5163
  value: (function () {
3795
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identities) {
3796
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3797
- while (1) switch (_context44.prev = _context44.next) {
5164
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identities, options) {
5165
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5166
+ while (1) switch (_context59.prev = _context59.next) {
3798
5167
  case 0:
3799
- _context44.prev = 0;
5168
+ _context59.prev = 0;
3800
5169
  if (this.store.order) {
3801
- _context44.next = 3;
5170
+ _context59.next = 3;
3802
5171
  break;
3803
5172
  }
3804
5173
  throw new Error('order 模块未初始化');
3805
5174
  case 3:
3806
- _context44.next = 5;
3807
- return this.store.order.removeProductsFromOrder(identities);
5175
+ _context59.next = 5;
5176
+ return this.store.order.removeProductsFromOrder(identities, options);
3808
5177
  case 5:
3809
- return _context44.abrupt("return", _context44.sent);
5178
+ return _context59.abrupt("return", _context59.sent);
3810
5179
  case 8:
3811
- _context44.prev = 8;
3812
- _context44.t0 = _context44["catch"](0);
3813
- throw _context44.t0;
5180
+ _context59.prev = 8;
5181
+ _context59.t0 = _context59["catch"](0);
5182
+ throw _context59.t0;
3814
5183
  case 11:
3815
5184
  case "end":
3816
- return _context44.stop();
5185
+ return _context59.stop();
3817
5186
  }
3818
- }, _callee44, this, [[0, 8]]);
5187
+ }, _callee59, this, [[0, 8]]);
3819
5188
  }));
3820
- function removeProductsFromOrder(_x38) {
5189
+ function removeProductsFromOrder(_x54, _x55) {
3821
5190
  return _removeProductsFromOrder.apply(this, arguments);
3822
5191
  }
3823
5192
  return removeProductsFromOrder;
@@ -3825,18 +5194,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3825
5194
  }, {
3826
5195
  key: "removeProductFromOrder",
3827
5196
  value: function () {
3828
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(identity) {
3829
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3830
- while (1) switch (_context45.prev = _context45.next) {
5197
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity, options) {
5198
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5199
+ while (1) switch (_context60.prev = _context60.next) {
3831
5200
  case 0:
3832
- return _context45.abrupt("return", this.removeProductsFromOrder([identity]));
5201
+ return _context60.abrupt("return", this.removeProductsFromOrder([identity], options));
3833
5202
  case 1:
3834
5203
  case "end":
3835
- return _context45.stop();
5204
+ return _context60.stop();
3836
5205
  }
3837
- }, _callee45, this);
5206
+ }, _callee60, this);
3838
5207
  }));
3839
- function removeProductFromOrder(_x39) {
5208
+ function removeProductFromOrder(_x56, _x57) {
3840
5209
  return _removeProductFromOrder.apply(this, arguments);
3841
5210
  }
3842
5211
  return removeProductFromOrder;
@@ -3886,23 +5255,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3886
5255
  }, {
3887
5256
  key: "applyPromotion",
3888
5257
  value: (function () {
3889
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3890
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3891
- while (1) switch (_context46.prev = _context46.next) {
5258
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
5259
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5260
+ while (1) switch (_context61.prev = _context61.next) {
3892
5261
  case 0:
3893
5262
  if (this.store.order) {
3894
- _context46.next = 2;
5263
+ _context61.next = 2;
3895
5264
  break;
3896
5265
  }
3897
5266
  throw new Error('order 模块未初始化');
3898
5267
  case 2:
3899
- _context46.next = 4;
5268
+ _context61.next = 4;
3900
5269
  return this.store.order.applyPromotion();
3901
5270
  case 4:
3902
5271
  case "end":
3903
- return _context46.stop();
5272
+ return _context61.stop();
3904
5273
  }
3905
- }, _callee46, this);
5274
+ }, _callee61, this);
3906
5275
  }));
3907
5276
  function applyPromotion() {
3908
5277
  return _applyPromotion.apply(this, arguments);
@@ -3912,16 +5281,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3912
5281
  }, {
3913
5282
  key: "getUnfulfilledPromotions",
3914
5283
  value: function getUnfulfilledPromotions() {
3915
- var _this$store$order8;
3916
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
5284
+ var _this$store$order16;
5285
+ return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
3917
5286
  }
3918
5287
 
3919
5288
  /** 最近一次促销计算输出的赠品操作 diff。 */
3920
5289
  }, {
3921
5290
  key: "getLastGiftActions",
3922
5291
  value: function getLastGiftActions() {
3923
- var _this$store$order9;
3924
- return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
5292
+ var _this$store$order17;
5293
+ return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
3925
5294
  }
3926
5295
 
3927
5296
  // 获取商品列表
@@ -3929,18 +5298,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3929
5298
  }, {
3930
5299
  key: "getProductList",
3931
5300
  value: function () {
3932
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3933
- var _this$otherParams21;
5301
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
5302
+ var _this$otherParams32;
3934
5303
  var menu_list_ids, _this$store$products, res;
3935
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3936
- while (1) switch (_context47.prev = _context47.next) {
5304
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5305
+ while (1) switch (_context62.prev = _context62.next) {
3937
5306
  case 0:
3938
5307
  // 可以直接通过配置里的 menu 读取
3939
- menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
5308
+ menu_list_ids = ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 || (_this$otherParams32 = _this$otherParams32.dineInConfig) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32['menu.associated_menus'].map(function (n) {
3940
5309
  return Number(n.value);
3941
5310
  })) || [];
3942
- _context47.prev = 1;
3943
- _context47.next = 4;
5311
+ _context62.prev = 1;
5312
+ _context62.next = 4;
3944
5313
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3945
5314
  menu_list_ids: menu_list_ids,
3946
5315
  cacheId: this.cacheId,
@@ -3948,17 +5317,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3948
5317
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3949
5318
  });
3950
5319
  case 4:
3951
- res = _context47.sent;
3952
- return _context47.abrupt("return", res);
5320
+ res = _context62.sent;
5321
+ return _context62.abrupt("return", res);
3953
5322
  case 8:
3954
- _context47.prev = 8;
3955
- _context47.t0 = _context47["catch"](1);
3956
- throw _context47.t0;
5323
+ _context62.prev = 8;
5324
+ _context62.t0 = _context62["catch"](1);
5325
+ throw _context62.t0;
3957
5326
  case 11:
3958
5327
  case "end":
3959
- return _context47.stop();
5328
+ return _context62.stop();
3960
5329
  }
3961
- }, _callee47, this, [[1, 8]]);
5330
+ }, _callee62, this, [[1, 8]]);
3962
5331
  }));
3963
5332
  function getProductList() {
3964
5333
  return _getProductList.apply(this, arguments);
@@ -3973,33 +5342,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3973
5342
  }, {
3974
5343
  key: "setOtherParams",
3975
5344
  value: function () {
3976
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
3977
- var _this$otherParams22;
3978
- var _ref30,
3979
- _ref30$cover,
5345
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
5346
+ var _this$otherParams33;
5347
+ var _ref42,
5348
+ _ref42$cover,
3980
5349
  cover,
3981
- _args48 = arguments;
3982
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3983
- while (1) switch (_context48.prev = _context48.next) {
5350
+ _args63 = arguments;
5351
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5352
+ while (1) switch (_context63.prev = _context63.next) {
3984
5353
  case 0:
3985
- _ref30 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
5354
+ _ref42 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref42$cover = _ref42.cover, cover = _ref42$cover === void 0 ? false : _ref42$cover;
3986
5355
  if (cover) {
3987
5356
  this.otherParams = _objectSpread({}, params);
3988
5357
  } else {
3989
5358
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3990
5359
  }
3991
- this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3992
- _context48.next = 5;
5360
+ this.cacheId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.cacheId;
5361
+ _context63.next = 5;
3993
5362
  return this.syncOtherParamsToSubModules(params, {
3994
5363
  cover: cover
3995
5364
  });
3996
5365
  case 5:
3997
5366
  case "end":
3998
- return _context48.stop();
5367
+ return _context63.stop();
3999
5368
  }
4000
- }, _callee48, this);
5369
+ }, _callee63, this);
4001
5370
  }));
4002
- function setOtherParams(_x40) {
5371
+ function setOtherParams(_x58) {
4003
5372
  return _setOtherParams.apply(this, arguments);
4004
5373
  }
4005
5374
  return setOtherParams;