@pisell/pisellos 2.2.276 → 2.2.800

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 (119) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  12. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  13. package/dist/modules/OpenData/index.d.ts +0 -2
  14. package/dist/modules/OpenData/index.js +0 -8
  15. package/dist/modules/Order/index.d.ts +8 -28
  16. package/dist/modules/Order/index.js +496 -808
  17. package/dist/modules/Order/types.d.ts +1 -35
  18. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  19. package/dist/modules/Order/utils.js +6 -10
  20. package/dist/modules/Payment/index.d.ts +0 -2
  21. package/dist/modules/Payment/index.js +49 -78
  22. package/dist/modules/Payment/types.d.ts +25 -104
  23. package/dist/modules/Payment/types.js +0 -17
  24. package/dist/modules/Payment/walletpass.d.ts +1 -38
  25. package/dist/modules/Payment/walletpass.js +114 -917
  26. package/dist/modules/Rules/index.d.ts +0 -3
  27. package/dist/modules/Rules/index.js +70 -100
  28. package/dist/server/index.d.ts +0 -25
  29. package/dist/server/index.js +1069 -2001
  30. package/dist/server/modules/index.d.ts +1 -1
  31. package/dist/server/modules/order/index.d.ts +4 -70
  32. package/dist/server/modules/order/index.js +728 -1816
  33. package/dist/server/modules/order/types.d.ts +3 -25
  34. package/dist/server/modules/order/types.js +1 -7
  35. package/dist/server/utils/small-ticket.js +2 -1
  36. package/dist/solution/BaseSales/index.d.ts +5 -104
  37. package/dist/solution/BaseSales/index.js +436 -1767
  38. package/dist/solution/BaseSales/types.d.ts +1 -55
  39. package/dist/solution/BaseSales/types.js +1 -2
  40. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  41. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  42. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  43. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
  44. package/dist/solution/BookingByStep/index.d.ts +1 -1
  45. package/dist/solution/BookingTicket/index.d.ts +5 -21
  46. package/dist/solution/BookingTicket/index.js +56 -139
  47. package/dist/solution/BookingTicket/types.d.ts +0 -1
  48. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
  50. package/dist/solution/Sales/index.d.ts +0 -2
  51. package/dist/solution/Sales/index.js +4 -26
  52. package/dist/solution/ScanOrder/index.js +20 -31
  53. package/dist/solution/VenueBooking/index.d.ts +0 -1
  54. package/dist/solution/VenueBooking/index.js +19 -30
  55. package/dist/types/index.d.ts +0 -1
  56. package/lib/core/index.d.ts +0 -2
  57. package/lib/core/index.js +0 -4
  58. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  59. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  60. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  61. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  62. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  63. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  64. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  65. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  66. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  67. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  68. package/lib/modules/OpenData/index.d.ts +0 -2
  69. package/lib/modules/OpenData/index.js +0 -5
  70. package/lib/modules/Order/index.d.ts +8 -28
  71. package/lib/modules/Order/index.js +69 -231
  72. package/lib/modules/Order/types.d.ts +1 -35
  73. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  74. package/lib/modules/Order/utils.js +4 -11
  75. package/lib/modules/Payment/index.d.ts +0 -2
  76. package/lib/modules/Payment/index.js +12 -33
  77. package/lib/modules/Payment/types.d.ts +25 -104
  78. package/lib/modules/Payment/types.js +0 -1
  79. package/lib/modules/Payment/walletpass.d.ts +1 -38
  80. package/lib/modules/Payment/walletpass.js +21 -730
  81. package/lib/modules/Rules/index.d.ts +0 -3
  82. package/lib/modules/Rules/index.js +9 -38
  83. package/lib/server/index.d.ts +0 -25
  84. package/lib/server/index.js +31 -726
  85. package/lib/server/modules/index.d.ts +1 -1
  86. package/lib/server/modules/order/index.d.ts +4 -70
  87. package/lib/server/modules/order/index.js +69 -818
  88. package/lib/server/modules/order/types.d.ts +3 -25
  89. package/lib/server/modules/order/types.js +0 -1
  90. package/lib/server/utils/small-ticket.js +1 -1
  91. package/lib/solution/BaseSales/index.d.ts +5 -104
  92. package/lib/solution/BaseSales/index.js +27 -858
  93. package/lib/solution/BaseSales/types.d.ts +1 -55
  94. package/lib/solution/BaseSales/types.js +1 -2
  95. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  96. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  97. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  98. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
  99. package/lib/solution/BookingByStep/index.d.ts +1 -1
  100. package/lib/solution/BookingTicket/index.d.ts +5 -21
  101. package/lib/solution/BookingTicket/index.js +13 -64
  102. package/lib/solution/BookingTicket/types.d.ts +0 -1
  103. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  104. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
  105. package/lib/solution/Sales/index.d.ts +0 -2
  106. package/lib/solution/Sales/index.js +6 -20
  107. package/lib/solution/ScanOrder/index.js +0 -8
  108. package/lib/solution/VenueBooking/index.d.ts +0 -1
  109. package/lib/solution/VenueBooking/index.js +0 -8
  110. package/lib/types/index.d.ts +0 -1
  111. package/package.json +1 -1
  112. package/dist/modules/Order/payment-utils.d.ts +0 -26
  113. package/dist/modules/Order/payment-utils.js +0 -225
  114. package/dist/utils/payment-number.d.ts +0 -9
  115. package/dist/utils/payment-number.js +0 -69
  116. package/lib/modules/Order/payment-utils.d.ts +0 -26
  117. package/lib/modules/Order/payment-utils.js +0 -224
  118. package/lib/utils/payment-number.d.ts +0 -9
  119. package/lib/utils/payment-number.js +0 -64
@@ -37,8 +37,6 @@ 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";
42
40
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
43
41
  import dayjs from 'dayjs';
44
42
  export * from "./types";
@@ -46,89 +44,6 @@ import { QuotationModule } from "../../modules/Quotation";
46
44
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
47
45
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
48
46
  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
- }
132
47
  function isBaseSalesManualProductDiscountProduct(product) {
133
48
  var _product$metadata, _product$metadata2;
134
49
  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) {
@@ -157,10 +72,6 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
157
72
  function isBaseSalesHistoricalDiscountEntry(discount) {
158
73
  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);
159
74
  }
160
- function getBaseSalesUniqueArrayMetadataKey(key) {
161
- if (key === 'products' || key === 'bookings') return 'unique_identification_number';
162
- return null;
163
- }
164
75
  var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
165
76
  product: 'order_detail_id',
166
77
  booking: 'schedule_event_id',
@@ -232,15 +143,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
232
143
  return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
233
144
  }
234
145
  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
- }
244
146
  var currentItems = normalizeOrderCollection(kind, currentValue, {
245
147
  ensureUid: false
246
148
  }).items;
@@ -287,34 +189,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
287
189
  }
288
190
  return normalizedRecord;
289
191
  }
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
- }
318
192
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
319
193
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
320
194
  ensureUid: false
@@ -332,15 +206,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
332
206
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
333
207
  }
334
208
  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
- }
344
209
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
345
210
  }
346
211
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -352,22 +217,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
352
217
  delete mergedRecord.request_unique_idempotency_token;
353
218
  return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
354
219
  }
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
- }
371
220
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
372
221
  _inherits(BaseSalesImpl, _BaseModule);
373
222
  var _super = _createSuper(BaseSalesImpl);
@@ -387,11 +236,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
387
236
  });
388
237
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
389
238
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
390
- /**
391
- * 由已在初始化阶段解析过设备短号的业务解决方案写入。
392
- * 未设置时,支付编号仍按原逻辑实时读取设备信息。
393
- */
394
- _defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
395
239
  /**
396
240
  * window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
397
241
  * `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
@@ -409,7 +253,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
409
253
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
410
254
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
411
255
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
412
- _defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
413
256
  _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
414
257
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
415
258
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
@@ -602,12 +445,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
602
445
  return _context3.abrupt("return");
603
446
  case 14:
604
447
  this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
605
- var _getTempOrder, _ref9;
448
+ var _getTempOrder, _ref2;
606
449
  var currentTempOrder, record, sales;
607
450
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
608
451
  while (1) switch (_context2.prev = _context2.next) {
609
452
  case 0:
610
- currentTempOrder = (_getTempOrder = (_ref9 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref9);
453
+ currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
611
454
  record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
612
455
  _context2.next = 4;
613
456
  return _this2.store.order.hydrateTempOrderFromRecord(record, {
@@ -676,7 +519,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
676
519
  hydratedSales = null;
677
520
  skippedBeforeHydrate = false;
678
521
  hydrateTask = /*#__PURE__*/function () {
679
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
522
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
680
523
  var sales;
681
524
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
682
525
  while (1) switch (_context4.prev = _context4.next) {
@@ -721,7 +564,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
721
564
  }, _callee4);
722
565
  }));
723
566
  return function hydrateTask() {
724
- return _ref10.apply(this, arguments);
567
+ return _ref3.apply(this, arguments);
725
568
  };
726
569
  }();
727
570
  queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
@@ -815,10 +658,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
815
658
  });
816
659
  }
817
660
  quotation.setScheduleResolver(function (id) {
818
- var _scheduleModule$getSc, _getScheduleByIds, _ref11;
661
+ var _scheduleModule$getSc, _getScheduleByIds, _ref4;
819
662
  var scheduleId = String(id);
820
663
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
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])) || [];
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])) || [];
822
665
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
823
666
  return schedules[0];
824
667
  });
@@ -870,9 +713,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
870
713
  }, {
871
714
  key: "getPriceQueryChannel",
872
715
  value: function getPriceQueryChannel(channel) {
873
- var _this$otherParams2, _ref12, _ref13, _this$otherParams3, _this$otherParams4;
716
+ var _this$otherParams2, _ref5, _ref6, _this$otherParams3, _this$otherParams4;
874
717
  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;
718
+ var value = (_ref5 = (_ref6 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref6 !== void 0 ? _ref6 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel) !== null && _ref5 !== void 0 ? _ref5 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform;
876
719
  if (value === undefined || value === null || String(value).trim() === '') {
877
720
  return undefined;
878
721
  }
@@ -885,11 +728,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
885
728
  }, {
886
729
  key: "getPriceQueryStrategyContext",
887
730
  value: function getPriceQueryStrategyContext(channel) {
888
- var _this$otherParams5, _ref14, _strategyContext$busi, _this$otherParams6, _this$otherParams7;
731
+ var _this$otherParams5, _ref7, _strategyContext$busi, _this$otherParams6, _this$otherParams7;
889
732
  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
733
  var strategyContext = _objectSpread({}, inherited);
891
734
  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;
735
+ var businessCode = (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code;
893
736
  if (resolvedChannel) strategyContext.channel = resolvedChannel;
894
737
  if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
895
738
  strategyContext.business_code = String(businessCode).trim();
@@ -1043,10 +886,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1043
886
  return groups.flatMap(function (group) {
1044
887
  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 : [];
1045
888
  return items.map(function (item) {
1046
- var _item$group_id, _ref15, _item$bundle_group_id;
889
+ var _item$group_id, _ref8, _item$bundle_group_id;
1047
890
  return _objectSpread(_objectSpread({}, item), {}, {
1048
891
  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,
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
892
+ bundle_group_id: (_ref8 = (_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 && _ref8 !== void 0 ? _ref8 : group === null || group === void 0 ? void 0 : group.id
1050
893
  });
1051
894
  });
1052
895
  });
@@ -1077,21 +920,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1077
920
  }, {
1078
921
  key: "getAuthoritativeBundleUnitPrice",
1079
922
  value: function getAuthoritativeBundleUnitPrice(bundle) {
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;
923
+ var _ref9, _ref10, _ref11, _bundle$price;
924
+ return (_ref9 = (_ref10 = (_ref11 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.custom_price) !== null && _ref10 !== void 0 ? _ref10 : bundle.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundle.base_price;
1082
925
  }
1083
926
  }, {
1084
927
  key: "mergeProductForPriceQuery",
1085
928
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
1086
929
  var _this5 = this,
1087
930
  _product$id,
1088
- _ref19,
931
+ _ref12,
1089
932
  _product$product_id2,
1090
- _ref20,
933
+ _ref13,
1091
934
  _product$product_vari,
1092
- _ref21,
935
+ _ref14,
1093
936
  _product$num,
1094
- _ref22,
937
+ _ref15,
1095
938
  _product$quantity,
1096
939
  _product$metadata4;
1097
940
  if (!authoritativeProduct) return product;
@@ -1111,10 +954,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1111
954
  });
1112
955
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
1113
956
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
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,
957
+ product_id: (_ref12 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.id,
958
+ product_variant_id: (_ref13 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref13 !== void 0 ? _ref13 : 0,
959
+ num: (_ref14 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref14 !== void 0 ? _ref14 : authoritativeProduct.num,
960
+ quantity: (_ref15 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref15 !== void 0 ? _ref15 : authoritativeProduct.quantity,
1118
961
  product_sku: function () {
1119
962
  var authoritativeSku = ensureProductSku(authoritativeProduct);
1120
963
  var productSku = ensureProductSku(product);
@@ -1190,24 +1033,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1190
1033
  value: (function () {
1191
1034
  var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
1192
1035
  var _this6 = this;
1193
- var _ref23,
1194
- _ref23$cover,
1036
+ var _ref16,
1037
+ _ref16$cover,
1195
1038
  cover,
1196
1039
  nextSubModuleOtherParams,
1197
1040
  _args10 = arguments;
1198
1041
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1199
1042
  while (1) switch (_context10.prev = _context10.next) {
1200
1043
  case 0:
1201
- _ref23 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
1044
+ _ref16 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref16$cover = _ref16.cover, cover = _ref16$cover === void 0 ? false : _ref16$cover;
1202
1045
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
1203
1046
  _context10.next = 4;
1204
1047
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1205
- var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref24) {
1206
- var _ref26, moduleName, subModule, targetModule;
1048
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref17) {
1049
+ var _ref19, moduleName, subModule, targetModule;
1207
1050
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1208
1051
  while (1) switch (_context9.prev = _context9.next) {
1209
1052
  case 0:
1210
- _ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
1053
+ _ref19 = _slicedToArray(_ref17, 2), moduleName = _ref19[0], subModule = _ref19[1];
1211
1054
  if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1212
1055
  _context9.next = 3;
1213
1056
  break;
@@ -1233,7 +1076,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1233
1076
  }, _callee9);
1234
1077
  }));
1235
1078
  return function (_x9) {
1236
- return _ref25.apply(this, arguments);
1079
+ return _ref18.apply(this, arguments);
1237
1080
  };
1238
1081
  }()));
1239
1082
  case 4:
@@ -1261,7 +1104,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1261
1104
  if (!sessionData) return {};
1262
1105
  var data = JSON.parse(sessionData);
1263
1106
  return data && data[this.cacheId] || {};
1264
- } catch (_unused3) {
1107
+ } catch (_unused) {
1265
1108
  return {};
1266
1109
  }
1267
1110
  }
@@ -1275,38 +1118,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1275
1118
  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');
1276
1119
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1277
1120
  }
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
- }
1310
1121
  }, {
1311
1122
  key: "syncAppDataToTempOrder",
1312
1123
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1350,7 +1161,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1350
1161
  value: function () {
1351
1162
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1352
1163
  var _this$otherParams9,
1353
- _this9 = this,
1164
+ _this7 = this,
1354
1165
  _this$otherParams10;
1355
1166
  var options,
1356
1167
  app,
@@ -1363,7 +1174,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1363
1174
  options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1364
1175
  this.core = core;
1365
1176
  this.initializeOptions = options || {};
1366
- this.paymentNumberDevicePrefix = null;
1367
1177
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1368
1178
  this.otherParams = options.otherParams || {};
1369
1179
  this.cacheId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.cacheId;
@@ -1374,52 +1184,52 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1374
1184
  // 获取 logger 实例
1375
1185
  this.appPlugin = core.getPlugin('app');
1376
1186
  if (this.appPlugin) {
1377
- _context11.next = 12;
1187
+ _context11.next = 11;
1378
1188
  break;
1379
1189
  }
1380
1190
  throw new Error('Checkout 解决方案需要 app 插件支持');
1381
- case 12:
1191
+ case 11:
1382
1192
  app = this.appPlugin.getApp();
1383
1193
  this.logger = app.logger;
1384
1194
  targetCacheData = this.readSessionCacheData();
1385
1195
  moduleNames = this.getRegisteredModuleNames();
1386
1196
  moduleNames.forEach(function (step) {
1387
- var reusedModule = _this9.getReusableSharedSubModule(step);
1197
+ var reusedModule = _this7.getReusableSharedSubModule(step);
1388
1198
  if (reusedModule) {
1389
- _this9.store[step] = reusedModule;
1390
- _this9.reusedSharedSubModuleNames.add(step);
1199
+ _this7.store[step] = reusedModule;
1200
+ _this7.reusedSharedSubModuleNames.add(step);
1391
1201
  return;
1392
1202
  }
1393
- var targetModule = _this9.createSubModule(step);
1203
+ var targetModule = _this7.createSubModule(step);
1394
1204
  if (!targetModule) {
1395
1205
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1396
1206
  }
1397
- var hooks = _this9.getSubModuleHooks(step);
1398
- _this9.store[step] = targetModule;
1399
- _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1207
+ var hooks = _this7.getSubModuleHooks(step);
1208
+ _this7.store[step] = targetModule;
1209
+ _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
1400
1210
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1401
1211
  }, hooks ? {
1402
1212
  hooks: hooks
1403
1213
  } : {}), {}, {
1404
- otherParams: _this9.buildSubModuleOtherParams()
1214
+ otherParams: _this7.buildSubModuleOtherParams()
1405
1215
  }));
1406
1216
  });
1407
1217
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1408
- _context11.next = 20;
1218
+ _context11.next = 19;
1409
1219
  break;
1410
1220
  }
1411
- _context11.next = 20;
1221
+ _context11.next = 19;
1412
1222
  return this.store.schedule.loadAllSchedule();
1413
- case 20:
1223
+ case 19:
1414
1224
  if (this.store.order && typeof ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.enableTempOrderPersist) === 'boolean') {
1415
1225
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1416
1226
  }
1417
- _context11.next = 23;
1227
+ _context11.next = 22;
1418
1228
  return this.getPaymentMethodsAsync();
1419
- case 23:
1229
+ case 22:
1420
1230
  this.registerServerOrderChangeSync();
1421
1231
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1422
- case 25:
1232
+ case 24:
1423
1233
  case "end":
1424
1234
  return _context11.stop();
1425
1235
  }
@@ -1435,15 +1245,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1435
1245
  value: function () {
1436
1246
  var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1437
1247
  var _this$serverOrderChan2,
1438
- _this10 = this;
1248
+ _this8 = this;
1439
1249
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1440
1250
  while (1) switch (_context12.prev = _context12.next) {
1441
1251
  case 0:
1442
1252
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1443
1253
  this.serverOrderChangeUnsubscribe = null;
1444
1254
  Object.keys(this.store).forEach(function (key) {
1445
- if (_this10.reusedSharedSubModuleNames.has(key)) return;
1446
- var sub = _this10.store[key];
1255
+ if (_this8.reusedSharedSubModuleNames.has(key)) return;
1256
+ var sub = _this8.store[key];
1447
1257
  if (sub && typeof sub.destroy === 'function') {
1448
1258
  try {
1449
1259
  sub.destroy();
@@ -1453,15 +1263,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1453
1263
  }
1454
1264
  });
1455
1265
  this.currentSalesDetail = null;
1456
- this.paymentNumberDevicePrefix = null;
1457
1266
  this.queuedServerOrderChanges = [];
1458
1267
  this.salesDetailLoadSequence += 1;
1459
- this.walletAssetsRefreshSequence += 1;
1460
- _context12.next = 10;
1268
+ _context12.next = 8;
1461
1269
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1462
- case 10:
1270
+ case 8:
1463
1271
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1464
- case 11:
1272
+ case 9:
1465
1273
  case "end":
1466
1274
  return _context12.stop();
1467
1275
  }
@@ -1483,7 +1291,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1483
1291
  key: "loadSalesDetail",
1484
1292
  value: (function () {
1485
1293
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1486
- var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1294
+ var loadSequence, _ref20, _ref21, _ref22, _ref23, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1487
1295
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1488
1296
  while (1) switch (_context13.prev = _context13.next) {
1489
1297
  case 0:
@@ -1501,7 +1309,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1501
1309
  };
1502
1310
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1503
1311
  preloadedSalesDetail = params.preloadedSalesDetail;
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;
1312
+ lookup = (_ref20 = (_ref21 = (_ref22 = (_ref23 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref23 !== void 0 ? _ref23 : params.orderNumber) !== null && _ref22 !== void 0 ? _ref22 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref21 !== void 0 ? _ref21 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref20 !== void 0 ? _ref20 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1505
1313
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1506
1314
  _context13.next = 11;
1507
1315
  break;
@@ -1532,40 +1340,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1532
1340
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1533
1341
  throw new Error(message);
1534
1342
  case 22:
1535
- remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1343
+ remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1536
1344
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1537
- mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1538
- record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1539
- _context13.next = 28;
1345
+ record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1346
+ _context13.next = 27;
1540
1347
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1541
- case 28:
1348
+ case 27:
1542
1349
  return _context13.abrupt("return", _context13.sent);
1543
- case 29:
1544
- _context13.prev = 29;
1350
+ case 28:
1351
+ _context13.prev = 28;
1545
1352
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1546
1353
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1547
- _context13.next = 40;
1354
+ _context13.next = 39;
1548
1355
  break;
1549
1356
  }
1550
- _context13.prev = 32;
1551
- _context13.next = 35;
1357
+ _context13.prev = 31;
1358
+ _context13.next = 34;
1552
1359
  return this.drainQueuedServerOrderChanges();
1553
- case 35:
1554
- _context13.next = 40;
1360
+ case 34:
1361
+ _context13.next = 39;
1555
1362
  break;
1556
- case 37:
1557
- _context13.prev = 37;
1558
- _context13.t1 = _context13["catch"](32);
1363
+ case 36:
1364
+ _context13.prev = 36;
1365
+ _context13.t1 = _context13["catch"](31);
1559
1366
  this.logError('drain queued server order changes failed', {
1560
1367
  error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1561
1368
  });
1369
+ case 39:
1370
+ return _context13.finish(28);
1562
1371
  case 40:
1563
- return _context13.finish(29);
1564
- case 41:
1565
1372
  case "end":
1566
1373
  return _context13.stop();
1567
1374
  }
1568
- }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1375
+ }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1569
1376
  }));
1570
1377
  function loadSalesDetail(_x11) {
1571
1378
  return _loadSalesDetail.apply(this, arguments);
@@ -1842,7 +1649,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1842
1649
  key: "restoreOrder",
1843
1650
  value: function () {
1844
1651
  var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1845
- var _this$store$payment, tempOrder, wallet;
1652
+ var tempOrder;
1846
1653
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1847
1654
  while (1) switch (_context17.prev = _context17.next) {
1848
1655
  case 0:
@@ -1858,39 +1665,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1858
1665
  this.currentSalesDetail = null;
1859
1666
  this.discountConfigCacheKey = null;
1860
1667
  this.hasManualDiscountSelection = false;
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;
1668
+ _context17.next = 9;
1872
1669
  return this.effectsEmit('onTempOrderReplaced', {
1873
1670
  tempOrder: tempOrder
1874
1671
  });
1875
- case 15:
1672
+ case 9:
1876
1673
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1877
- _context17.next = 19;
1674
+ _context17.next = 13;
1878
1675
  break;
1879
1676
  }
1880
1677
  this.store.order.persistTempOrder();
1881
- _context17.next = 19;
1678
+ _context17.next = 13;
1882
1679
  return this.store.order.saveDraft();
1883
- case 19:
1680
+ case 13:
1884
1681
  return _context17.abrupt("return", tempOrder);
1885
- case 22:
1886
- _context17.prev = 22;
1682
+ case 16:
1683
+ _context17.prev = 16;
1887
1684
  _context17.t0 = _context17["catch"](0);
1888
1685
  throw _context17.t0;
1889
- case 25:
1686
+ case 19:
1890
1687
  case "end":
1891
1688
  return _context17.stop();
1892
1689
  }
1893
- }, _callee17, this, [[0, 22]]);
1690
+ }, _callee17, this, [[0, 16]]);
1894
1691
  }));
1895
1692
  function restoreOrder() {
1896
1693
  return _restoreOrder.apply(this, arguments);
@@ -2003,10 +1800,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2003
1800
  }, {
2004
1801
  key: "getHistoricalProductDiscountList",
2005
1802
  value: function getHistoricalProductDiscountList(products) {
2006
- var _this11 = this;
1803
+ var _this9 = this;
2007
1804
  var historyDiscountList = [];
2008
1805
  products.forEach(function (item) {
2009
- if (!_this11.isPersistedOrderProduct(item)) return;
1806
+ if (!_this9.isPersistedOrderProduct(item)) return;
2010
1807
  (item.discount_list || []).forEach(function (discount) {
2011
1808
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
2012
1809
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -2066,11 +1863,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2066
1863
  }, {
2067
1864
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
2068
1865
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
2069
- var _this12 = this;
1866
+ var _this10 = this;
2070
1867
  if (params.discountAction !== 'edit') return false;
2071
1868
  if (!params.products.length) return false;
2072
1869
  var hasDraftProduct = params.products.some(function (product) {
2073
- return !_this12.isPersistedOrderProduct(product);
1870
+ return !_this10.isPersistedOrderProduct(product);
2074
1871
  });
2075
1872
  if (hasDraftProduct) return false;
2076
1873
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -2518,15 +2315,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2518
2315
  tempOrder: tempOrder
2519
2316
  });
2520
2317
  case 13:
2521
- return _context23.abrupt("return", _objectSpread(_objectSpread({
2522
- isAvailable: raw.isAvailable
2523
- }, raw.isAccepted !== undefined ? {
2524
- isAccepted: raw.isAccepted
2525
- } : {}), {}, {
2318
+ return _context23.abrupt("return", {
2319
+ isAvailable: raw.isAvailable,
2526
2320
  type: raw.type,
2527
2321
  unavailableReason: raw.unavailableReason,
2528
2322
  scannedDiscountList: raw.scannedDiscountList
2529
- }));
2323
+ });
2530
2324
  case 16:
2531
2325
  _context23.prev = 16;
2532
2326
  _context23.t0 = _context23["catch"](0);
@@ -2652,10 +2446,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2652
2446
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2653
2447
  if (Array.isArray(product.product_bundle)) {
2654
2448
  product.product_bundle = product.product_bundle.map(function (bundle) {
2655
- var _ref31, _bundle$original_pric;
2449
+ var _ref24, _bundle$original_pric;
2656
2450
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2657
2451
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
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;
2452
+ var restoredBundlePrice = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2659
2453
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2660
2454
  price: restoredBundlePrice,
2661
2455
  bundle_selling_price: restoredBundlePrice
@@ -2876,10 +2670,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2876
2670
  return submitSalesOrder;
2877
2671
  }())
2878
2672
  }, {
2879
- key: "saveSalesOrderDraft",
2673
+ key: "submitTempOrderAsync",
2880
2674
  value: function () {
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;
2675
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2676
+ var _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18;
2677
+ var inferredPaymentStatus, submitParams;
2883
2678
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2884
2679
  while (1) switch (_context28.prev = _context28.next) {
2885
2680
  case 0:
@@ -2888,49 +2683,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2888
2683
  break;
2889
2684
  }
2890
2685
  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 模块支持');
2926
2686
  case 2:
2927
2687
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2928
2688
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2929
2689
  cacheId: this.cacheId,
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),
2690
+ platform: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
2691
+ 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),
2932
2692
  channel: this.getSubmitOrderSalesChannel(),
2933
- type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
2693
+ type: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type
2934
2694
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2935
2695
  payments: params.payments
2936
2696
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2942,14 +2702,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2942
2702
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2943
2703
  enhancePayload: params.enhancePayload
2944
2704
  } : {});
2945
- return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2705
+ return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2946
2706
  case 5:
2947
2707
  case "end":
2948
- return _context29.stop();
2708
+ return _context28.stop();
2949
2709
  }
2950
- }, _callee29, this);
2710
+ }, _callee28, this);
2951
2711
  }));
2952
- function submitTempOrderAsync(_x24) {
2712
+ function submitTempOrderAsync(_x23) {
2953
2713
  return _submitTempOrderAsync.apply(this, arguments);
2954
2714
  }
2955
2715
  return submitTempOrderAsync;
@@ -2957,14 +2717,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2957
2717
  }, {
2958
2718
  key: "printLocalOrderReceipt",
2959
2719
  value: function () {
2960
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2961
- var _this$otherParams23, _this$otherParams24, _this$otherParams25, _this$otherParams26;
2720
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2721
+ var _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
2962
2722
  var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2963
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2964
- while (1) switch (_context30.prev = _context30.next) {
2723
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2724
+ while (1) switch (_context29.prev = _context29.next) {
2965
2725
  case 0:
2966
2726
  if (this.store.order) {
2967
- _context30.next = 2;
2727
+ _context29.next = 2;
2968
2728
  break;
2969
2729
  }
2970
2730
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2976,10 +2736,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2976
2736
  external_sale_number: lookup
2977
2737
  };
2978
2738
  context = {
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),
2739
+ platform: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform,
2740
+ 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),
2981
2741
  channel: this.getSubmitOrderSalesChannel(),
2982
- type: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.type
2742
+ type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
2983
2743
  };
2984
2744
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2985
2745
  lookup_order_from_db: 1,
@@ -2995,28 +2755,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2995
2755
  channel: context.channel,
2996
2756
  type: context.type
2997
2757
  });
2998
- _context30.next = 8;
2758
+ _context29.next = 8;
2999
2759
  return this.request.post('/local/print-order', payload, {
3000
2760
  osServer: true,
3001
2761
  customToast: function customToast() {}
3002
2762
  });
3003
2763
  case 8:
3004
- response = _context30.sent;
2764
+ response = _context29.sent;
3005
2765
  if (hasLookup) {
3006
- _context30.next = 12;
2766
+ _context29.next = 12;
3007
2767
  break;
3008
2768
  }
3009
- _context30.next = 12;
2769
+ _context29.next = 12;
3010
2770
  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);
3011
2771
  case 12:
3012
- return _context30.abrupt("return", response);
2772
+ return _context29.abrupt("return", response);
3013
2773
  case 13:
3014
2774
  case "end":
3015
- return _context30.stop();
2775
+ return _context29.stop();
3016
2776
  }
3017
- }, _callee30, this);
2777
+ }, _callee29, this);
3018
2778
  }));
3019
- function printLocalOrderReceipt(_x25) {
2779
+ function printLocalOrderReceipt(_x24) {
3020
2780
  return _printLocalOrderReceipt.apply(this, arguments);
3021
2781
  }
3022
2782
  return printLocalOrderReceipt;
@@ -3030,27 +2790,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3030
2790
  if (!amountSnapshot) return undefined;
3031
2791
  try {
3032
2792
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
3033
- } catch (_unused4) {
2793
+ } catch (_unused2) {
3034
2794
  return undefined;
3035
2795
  }
3036
2796
  }
3037
2797
  }, {
3038
2798
  key: "syncPaymentsToOrder",
3039
2799
  value: function () {
3040
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3041
- var _ref32, _params$businessCode, _this$otherParams27, _this$otherParams28, _params$channel2;
2800
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2801
+ var _ref25, _params$businessCode, _this$otherParams23, _this$otherParams24, _params$channel;
3042
2802
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
3043
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3044
- while (1) switch (_context31.prev = _context31.next) {
2803
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2804
+ while (1) switch (_context30.prev = _context30.next) {
3045
2805
  case 0:
3046
2806
  if (this.store.order) {
3047
- _context31.next = 2;
2807
+ _context30.next = 2;
3048
2808
  break;
3049
2809
  }
3050
2810
  throw new Error('order 模块未初始化');
3051
2811
  case 2:
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();
2812
+ businessCode = (_ref25 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) !== null && _ref25 !== void 0 ? _ref25 : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code;
2813
+ channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
3054
2814
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
3055
2815
  businessCode: businessCode
3056
2816
  } : {}), channel !== undefined ? {
@@ -3058,14 +2818,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3058
2818
  } : {});
3059
2819
  syncState = this.store.order.getOrderSyncState();
3060
2820
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
3061
- _context31.next = 9;
2821
+ _context30.next = 9;
3062
2822
  break;
3063
2823
  }
3064
2824
  this.queueLatestAutoPaymentSync();
3065
- return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2825
+ return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3066
2826
  case 9:
3067
2827
  payments = params.payments || [];
3068
- _context31.next = 12;
2828
+ _context30.next = 12;
3069
2829
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
3070
2830
  payments: payments,
3071
2831
  params: syncParams,
@@ -3073,11 +2833,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3073
2833
  orderSnapshot: this.store.order.getOrderSnapshot()
3074
2834
  });
3075
2835
  case 12:
3076
- _context31.prev = 12;
3077
- _context31.next = 15;
2836
+ _context30.prev = 12;
2837
+ _context30.next = 15;
3078
2838
  return this.store.order.syncPaymentsToOrder(syncParams);
3079
2839
  case 15:
3080
- syncResult = _context31.sent;
2840
+ syncResult = _context30.sent;
3081
2841
  latestPayments = this.store.order.getOrderPayments();
3082
2842
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
3083
2843
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -3095,25 +2855,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3095
2855
  depositAmount: syncResult.depositAmount,
3096
2856
  orderExpectedAmount: syncResult.orderExpectedAmount
3097
2857
  };
3098
- _context31.next = 22;
2858
+ _context30.next = 22;
3099
2859
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
3100
2860
  case 22:
3101
2861
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
3102
- _context31.next = 25;
2862
+ _context30.next = 25;
3103
2863
  break;
3104
2864
  }
3105
- _context31.next = 25;
2865
+ _context30.next = 25;
3106
2866
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
3107
2867
  case 25:
3108
2868
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3109
- return _context31.abrupt("return", syncResult);
2869
+ return _context30.abrupt("return", syncResult);
3110
2870
  case 29:
3111
- _context31.prev = 29;
3112
- _context31.t0 = _context31["catch"](12);
3113
- _context31.next = 33;
2871
+ _context30.prev = 29;
2872
+ _context30.t0 = _context30["catch"](12);
2873
+ _context30.next = 33;
3114
2874
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
3115
2875
  ok: false,
3116
- error: _context31.t0,
2876
+ error: _context30.t0,
3117
2877
  payments: this.store.order.getOrderPayments(),
3118
2878
  params: syncParams,
3119
2879
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -3121,14 +2881,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3121
2881
  });
3122
2882
  case 33:
3123
2883
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3124
- throw _context31.t0;
2884
+ throw _context30.t0;
3125
2885
  case 35:
3126
2886
  case "end":
3127
- return _context31.stop();
2887
+ return _context30.stop();
3128
2888
  }
3129
- }, _callee31, this, [[12, 29]]);
2889
+ }, _callee30, this, [[12, 29]]);
3130
2890
  }));
3131
- function syncPaymentsToOrder(_x26) {
2891
+ function syncPaymentsToOrder(_x25) {
3132
2892
  return _syncPaymentsToOrder.apply(this, arguments);
3133
2893
  }
3134
2894
  return syncPaymentsToOrder;
@@ -3165,58 +2925,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3165
2925
  }, {
3166
2926
  key: "scheduleQueuedAutoPaymentSyncFlush",
3167
2927
  value: function scheduleQueuedAutoPaymentSyncFlush() {
3168
- var _this13 = this;
2928
+ var _this11 = this;
3169
2929
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
3170
2930
  if (!this.queuedAutoPaymentSync) return;
3171
2931
  if (this.autoPaymentSyncTimer) return;
3172
2932
  this.autoPaymentSyncTimer = setTimeout(function () {
3173
- _this13.autoPaymentSyncTimer = null;
3174
- void _this13.flushQueuedAutoPaymentSync();
2933
+ _this11.autoPaymentSyncTimer = null;
2934
+ void _this11.flushQueuedAutoPaymentSync();
3175
2935
  }, delay);
3176
2936
  }
3177
2937
  }, {
3178
2938
  key: "flushQueuedAutoPaymentSync",
3179
2939
  value: function () {
3180
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2940
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
3181
2941
  var payments;
3182
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3183
- while (1) switch (_context32.prev = _context32.next) {
2942
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2943
+ while (1) switch (_context31.prev = _context31.next) {
3184
2944
  case 0:
3185
2945
  if (this.store.order) {
3186
- _context32.next = 2;
2946
+ _context31.next = 2;
3187
2947
  break;
3188
2948
  }
3189
- return _context32.abrupt("return");
2949
+ return _context31.abrupt("return");
3190
2950
  case 2:
3191
2951
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3192
- _context32.next = 4;
2952
+ _context31.next = 4;
3193
2953
  break;
3194
2954
  }
3195
- return _context32.abrupt("return");
2955
+ return _context31.abrupt("return");
3196
2956
  case 4:
3197
2957
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3198
- _context32.next = 7;
2958
+ _context31.next = 7;
3199
2959
  break;
3200
2960
  }
3201
2961
  this.scheduleQueuedAutoPaymentSyncFlush();
3202
- return _context32.abrupt("return");
2962
+ return _context31.abrupt("return");
3203
2963
  case 7:
3204
2964
  this.autoPaymentSyncFlushing = true;
3205
- _context32.prev = 8;
2965
+ _context31.prev = 8;
3206
2966
  case 9:
3207
2967
  if (!this.queuedAutoPaymentSync) {
3208
- _context32.next = 18;
2968
+ _context31.next = 18;
3209
2969
  break;
3210
2970
  }
3211
2971
  this.queuedAutoPaymentSync = false;
3212
2972
  payments = this.store.order.getOrderPayments();
3213
2973
  if (payments.length) {
3214
- _context32.next = 14;
2974
+ _context31.next = 14;
3215
2975
  break;
3216
2976
  }
3217
- return _context32.abrupt("continue", 9);
2977
+ return _context31.abrupt("continue", 9);
3218
2978
  case 14:
3219
- _context32.next = 16;
2979
+ _context31.next = 16;
3220
2980
  return this.syncPaymentsToOrder({
3221
2981
  payments: payments,
3222
2982
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3224,94 +2984,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3224
2984
  smallTicketDataFlag: 1
3225
2985
  });
3226
2986
  case 16:
3227
- _context32.next = 9;
2987
+ _context31.next = 9;
3228
2988
  break;
3229
2989
  case 18:
3230
- _context32.next = 23;
2990
+ _context31.next = 23;
3231
2991
  break;
3232
2992
  case 20:
3233
- _context32.prev = 20;
3234
- _context32.t0 = _context32["catch"](8);
2993
+ _context31.prev = 20;
2994
+ _context31.t0 = _context31["catch"](8);
3235
2995
  this.logError('queued auto sync payments failed', {
3236
- error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2996
+ error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
3237
2997
  });
3238
2998
  case 23:
3239
- _context32.prev = 23;
2999
+ _context31.prev = 23;
3240
3000
  this.autoPaymentSyncFlushing = false;
3241
3001
  if (this.queuedAutoPaymentSync) {
3242
3002
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3243
3003
  }
3244
- return _context32.finish(23);
3004
+ return _context31.finish(23);
3245
3005
  case 27:
3246
3006
  case "end":
3247
- return _context32.stop();
3007
+ return _context31.stop();
3248
3008
  }
3249
- }, _callee32, this, [[8, 20, 23, 27]]);
3009
+ }, _callee31, this, [[8, 20, 23, 27]]);
3250
3010
  }));
3251
3011
  function flushQueuedAutoPaymentSync() {
3252
3012
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
3253
3013
  }
3254
3014
  return flushQueuedAutoPaymentSync;
3255
- }()
3256
- /**
3257
- * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3258
- */
3015
+ }() /** 追加单个支付项到当前订单。 */
3259
3016
  }, {
3260
3017
  key: "addOrderPayment",
3261
3018
  value: function addOrderPayment(payment) {
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,
3019
+ var _this$otherParams25,
3310
3020
  _paymentRecord$paymen,
3311
3021
  _paymentRecord$create,
3312
- _ref33,
3022
+ _ref26,
3313
3023
  _paymentRecord$origin,
3314
- _this14 = this;
3024
+ _this12 = this;
3315
3025
  if (!this.store.order) throw new Error('order 模块未初始化');
3316
3026
  var paymentRecord = payment;
3317
3027
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -3322,26 +3032,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3322
3032
  return this.store.order.getOrderPayments();
3323
3033
  }
3324
3034
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3325
- var shopWalletPassId = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.shop_wallet_pass_id;
3035
+ var shopWalletPassId = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.shop_wallet_pass_id;
3326
3036
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3327
3037
  metadata.shop_wallet_pass_id = shopWalletPassId;
3328
3038
  }
3329
- var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
3039
+ if (!metadata.unique_payment_number) {
3040
+ metadata.unique_payment_number = createUuidV4();
3041
+ }
3330
3042
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
3331
3043
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3332
3044
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3333
3045
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
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 ? {
3046
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref26 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref26 !== void 0 ? _ref26 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3047
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
3336
3048
  service_fee: calculatedServiceFee
3337
3049
  } : {}), {}, {
3338
3050
  metadata: metadata,
3339
3051
  payment_time: paymentTime,
3340
3052
  created_at: createdAt
3341
3053
  }));
3342
- if (paymentRecord.status === 'payment_pending') {
3343
- return payments;
3344
- }
3345
3054
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
3346
3055
  var syncState = this.store.order.getOrderSyncState();
3347
3056
  if (amountSnapshot) {
@@ -3355,7 +3064,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3355
3064
  submitWhenPaid: true,
3356
3065
  smallTicketDataFlag: 1
3357
3066
  }).catch(function (error) {
3358
- _this14.logError('auto sync payments failed', {
3067
+ _this12.logError('auto sync payments failed', {
3359
3068
  error: error instanceof Error ? error.message : String(error)
3360
3069
  });
3361
3070
  });
@@ -3366,131 +3075,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3366
3075
  /** 更新当前订单中的指定支付项。 */
3367
3076
  }, {
3368
3077
  key: "updateOrderPayment",
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
- }() /** 删除当前订单中的指定支付项。 */)
3078
+ value: function updateOrderPayment(paymentIdentity, updates) {
3079
+ if (!this.store.order) throw new Error('order 模块未初始化');
3080
+ return this.store.order.updateOrderPayment(paymentIdentity, updates);
3081
+ }
3082
+
3083
+ /** 删除当前订单中的指定支付项。 */
3494
3084
  }, {
3495
3085
  key: "deleteOrderPayment",
3496
3086
  value: function deleteOrderPayment(paymentIdentity) {
@@ -3505,42 +3095,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3505
3095
  if (!this.store.order) throw new Error('order 模块未初始化');
3506
3096
  return this.store.order.updateVoucherOrderPayments(payments, options);
3507
3097
  }
3508
- }, {
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
3098
  }, {
3534
3099
  key: "confirmPendingVoucherPayments",
3535
3100
  value: function confirmPendingVoucherPayments() {
3536
3101
  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;
3102
+ return this.store.order.confirmPendingVoucherPayments();
3544
3103
  }
3545
3104
  }, {
3546
3105
  key: "discardPendingVoucherPayments",
@@ -3609,72 +3168,64 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3609
3168
  });
3610
3169
  return walletProducts;
3611
3170
  }
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
- }
3636
3171
  }, {
3637
3172
  key: "initWalletData",
3638
3173
  value: function () {
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) {
3174
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3175
+ var _params$order_wait_pa, _ref27, _tempOrder$is_price_i;
3176
+ var snapshot, tempOrder, amount, walletBusinessData, result;
3177
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3178
+ while (1) switch (_context32.prev = _context32.next) {
3644
3179
  case 0:
3645
3180
  if (this.store.order) {
3646
- _context36.next = 2;
3181
+ _context32.next = 2;
3647
3182
  break;
3648
3183
  }
3649
3184
  throw new Error('order 模块未初始化');
3650
3185
  case 2:
3651
3186
  if (this.store.payment) {
3652
- _context36.next = 4;
3187
+ _context32.next = 4;
3653
3188
  break;
3654
3189
  }
3655
3190
  throw new Error('payment 模块未初始化');
3656
3191
  case 4:
3657
3192
  snapshot = this.store.order.getOrderSnapshot();
3658
- walletBusinessData = this.buildWalletInitBusinessData(params);
3659
- if (walletBusinessData) {
3660
- _context36.next = 8;
3193
+ tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3194
+ amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3195
+ if (!(!tempOrder || !amount)) {
3196
+ _context32.next = 9;
3661
3197
  break;
3662
3198
  }
3663
- return _context36.abrupt("return", {
3199
+ return _context32.abrupt("return", {
3664
3200
  walletRecommendList: [],
3665
3201
  userIdentificationCodes: [],
3666
3202
  transformList: [],
3667
3203
  noApplicableVoucher: [],
3668
3204
  products: []
3669
3205
  });
3670
- case 8:
3671
- _context36.next = 10;
3206
+ case 9:
3207
+ walletBusinessData = _objectSpread({
3208
+ customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
3209
+ holder: tempOrder.holder,
3210
+ amountInfo: {
3211
+ totalAmount: amount.totalAmount,
3212
+ subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
3213
+ depositAmount: amount.depositAmount,
3214
+ isDeposit: tempOrder.is_deposit
3215
+ },
3216
+ products: this.getWalletProductList(),
3217
+ 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),
3218
+ is_price_include_tax: (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : 1
3219
+ }, snapshot.identity.orderId ? {
3220
+ payment_order_id: String(snapshot.identity.orderId)
3221
+ } : {});
3222
+ _context32.next = 12;
3672
3223
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3673
- case 10:
3674
- result = _context36.sent;
3675
- _context36.next = 13;
3224
+ case 12:
3225
+ result = _context32.sent;
3226
+ _context32.next = 15;
3676
3227
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3677
- orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
3228
+ orderId: snapshot.identity.orderId,
3678
3229
  customerId: walletBusinessData.customer_id,
3679
3230
  walletBusinessData: {
3680
3231
  customer_id: walletBusinessData.customer_id,
@@ -3683,421 +3234,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3683
3234
  },
3684
3235
  timestamp: Date.now()
3685
3236
  });
3686
- case 13:
3687
- return _context36.abrupt("return", result);
3688
- case 14:
3237
+ case 15:
3238
+ return _context32.abrupt("return", result);
3239
+ case 16:
3689
3240
  case "end":
3690
- return _context36.stop();
3241
+ return _context32.stop();
3691
3242
  }
3692
- }, _callee36, this);
3243
+ }, _callee32, this);
3693
3244
  }));
3694
- function initWalletData(_x32) {
3245
+ function initWalletData(_x26) {
3695
3246
  return _initWalletData.apply(this, arguments);
3696
3247
  }
3697
3248
  return initWalletData;
3698
3249
  }()
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
- }()
4094
3250
  /**
4095
3251
  * 更新当前订单客户字段。
4096
3252
  *
4097
3253
  * 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
4098
3254
  * 调用方通过 onCustomerChange 回调完成。
4099
3255
  */
4100
- )
4101
3256
  }, {
4102
3257
  key: "updateOrderCustomer",
4103
3258
  value: function updateOrderCustomer(customer) {
@@ -4114,35 +3269,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4114
3269
  }, {
4115
3270
  key: "getPaymentMethodsAsync",
4116
3271
  value: (function () {
4117
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3272
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
4118
3273
  var response, paymentMethods;
4119
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4120
- while (1) switch (_context44.prev = _context44.next) {
3274
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3275
+ while (1) switch (_context33.prev = _context33.next) {
4121
3276
  case 0:
4122
- _context44.prev = 0;
4123
- _context44.next = 3;
3277
+ _context33.prev = 0;
3278
+ _context33.next = 3;
4124
3279
  return this.request.get('/pay/custom-payment/all', {
4125
3280
  filterPaymentMethods: true
4126
3281
  }, {
4127
3282
  osServer: true
4128
3283
  });
4129
3284
  case 3:
4130
- response = _context44.sent;
3285
+ response = _context33.sent;
4131
3286
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
4132
3287
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
4133
- return _context44.abrupt("return", this.getPaymentMethods());
3288
+ return _context33.abrupt("return", this.getPaymentMethods());
4134
3289
  case 9:
4135
- _context44.prev = 9;
4136
- _context44.t0 = _context44["catch"](0);
3290
+ _context33.prev = 9;
3291
+ _context33.t0 = _context33["catch"](0);
4137
3292
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
4138
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
3293
+ error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
4139
3294
  });
4140
- return _context44.abrupt("return", this.getPaymentMethods());
3295
+ return _context33.abrupt("return", this.getPaymentMethods());
4141
3296
  case 13:
4142
3297
  case "end":
4143
- return _context44.stop();
3298
+ return _context33.stop();
4144
3299
  }
4145
- }, _callee44, this, [[0, 9]]);
3300
+ }, _callee33, this, [[0, 9]]);
4146
3301
  }));
4147
3302
  function getPaymentMethodsAsync() {
4148
3303
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -4154,536 +3309,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4154
3309
  value: function getPaymentMethods() {
4155
3310
  return _toConsumableArray(this.paymentMethodsCache);
4156
3311
  }
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
- }
4183
3312
 
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
- }()
4643
3313
  /**
4644
3314
  * 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
4645
3315
  *
4646
3316
  * 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
4647
3317
  * otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
4648
3318
  */
4649
- )
4650
3319
  }, {
4651
3320
  key: "roundAmount",
4652
3321
  value: (function () {
4653
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
3322
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4654
3323
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
4655
3324
  var amount, cashManualPayment;
4656
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4657
- while (1) switch (_context49.prev = _context49.next) {
3325
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3326
+ while (1) switch (_context34.prev = _context34.next) {
4658
3327
  case 0:
4659
3328
  amount = params.amount;
4660
3329
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
4661
3330
  return paymentMethod.code === 'CASHMANUAL';
4662
3331
  });
4663
3332
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
4664
- _context49.next = 4;
3333
+ _context34.next = 4;
4665
3334
  break;
4666
3335
  }
4667
- return _context49.abrupt("return", {
3336
+ return _context34.abrupt("return", {
4668
3337
  originalAmount: amount.toString(),
4669
3338
  roundedAmount: amount.toString(),
4670
3339
  roundingDifference: '0.00'
4671
3340
  });
4672
3341
  case 4:
4673
3342
  if (this.payment) {
4674
- _context49.next = 6;
3343
+ _context34.next = 6;
4675
3344
  break;
4676
3345
  }
4677
3346
  throw new Error('payment 模块未初始化');
4678
3347
  case 6:
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));
3348
+ 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));
4680
3349
  case 7:
4681
3350
  case "end":
4682
- return _context49.stop();
3351
+ return _context34.stop();
4683
3352
  }
4684
- }, _callee49, this);
3353
+ }, _callee34, this);
4685
3354
  }));
4686
- function roundAmount(_x41) {
3355
+ function roundAmount(_x27) {
4687
3356
  return _roundAmount.apply(this, arguments);
4688
3357
  }
4689
3358
  return roundAmount;
@@ -4698,49 +3367,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4698
3367
  }, {
4699
3368
  key: "sendCustomerPayLink",
4700
3369
  value: (function () {
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) {
3370
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3371
+ var orderIds, _ref28, _ref29, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3372
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3373
+ while (1) switch (_context35.prev = _context35.next) {
4705
3374
  case 0:
4706
3375
  if (this.store.order) {
4707
- _context50.next = 2;
3376
+ _context35.next = 2;
4708
3377
  break;
4709
3378
  }
4710
3379
  throw new Error('order 模块未初始化');
4711
3380
  case 2:
4712
3381
  orderIds = params.order_ids || params.orderIds || [];
4713
3382
  if (!(!orderIds.length || params.submitBeforeSend)) {
4714
- _context50.next = 11;
3383
+ _context35.next = 11;
4715
3384
  break;
4716
3385
  }
4717
- _context50.next = 6;
3386
+ _context35.next = 6;
4718
3387
  return this.submitSalesOrder({
4719
3388
  smallTicketDataFlag: 1
4720
3389
  });
4721
3390
  case 6:
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;
3391
+ submitResult = _context35.sent;
3392
+ orderId = (_ref28 = (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref28 !== void 0 ? _ref28 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
4724
3393
  if (orderId) {
4725
- _context50.next = 10;
3394
+ _context35.next = 10;
4726
3395
  break;
4727
3396
  }
4728
3397
  throw new Error('本地订单提交云端失败,无法发送支付链接');
4729
3398
  case 10:
4730
3399
  orderIds = [orderId];
4731
3400
  case 11:
4732
- return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
3401
+ return _context35.abrupt("return", this.store.order.sendCustomerPayLink({
4733
3402
  emails: params.emails,
4734
3403
  notify_action: params.notify_action,
4735
3404
  order_ids: orderIds
4736
3405
  }));
4737
3406
  case 12:
4738
3407
  case "end":
4739
- return _context50.stop();
3408
+ return _context35.stop();
4740
3409
  }
4741
- }, _callee50, this);
3410
+ }, _callee35, this);
4742
3411
  }));
4743
- function sendCustomerPayLink(_x42) {
3412
+ function sendCustomerPayLink(_x28) {
4744
3413
  return _sendCustomerPayLink.apply(this, arguments);
4745
3414
  }
4746
3415
  return sendCustomerPayLink;
@@ -4753,27 +3422,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4753
3422
  }, {
4754
3423
  key: "calculateProductBookingPrice",
4755
3424
  value: function () {
4756
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
3425
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4757
3426
  var _params$customer_id;
4758
3427
  var quotation, customerId, authoritativeProduct, product;
4759
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4760
- while (1) switch (_context51.prev = _context51.next) {
3428
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3429
+ while (1) switch (_context36.prev = _context36.next) {
4761
3430
  case 0:
4762
3431
  quotation = this.store.quotation;
4763
3432
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
4764
- _context51.next = 4;
3433
+ _context36.next = 4;
4765
3434
  return this.loadProductForPriceQuery(params, customerId);
4766
3435
  case 4:
4767
- authoritativeProduct = _context51.sent;
3436
+ authoritativeProduct = _context36.sent;
4768
3437
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
4769
- _context51.next = 8;
3438
+ _context36.next = 8;
4770
3439
  return this.loadQuotationForPriceQuery({
4771
3440
  quotation: quotation,
4772
3441
  customer_id: customerId,
4773
3442
  channel: params.channel
4774
3443
  });
4775
3444
  case 8:
4776
- return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3445
+ return _context36.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4777
3446
  product: product,
4778
3447
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
4779
3448
  customer_id: customerId,
@@ -4781,11 +3450,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4781
3450
  })));
4782
3451
  case 9:
4783
3452
  case "end":
4784
- return _context51.stop();
3453
+ return _context36.stop();
4785
3454
  }
4786
- }, _callee51, this);
3455
+ }, _callee36, this);
4787
3456
  }));
4788
- function calculateProductBookingPrice(_x43) {
3457
+ function calculateProductBookingPrice(_x29) {
4789
3458
  return _calculateProductBookingPrice.apply(this, arguments);
4790
3459
  }
4791
3460
  return calculateProductBookingPrice;
@@ -4793,7 +3462,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4793
3462
  }, {
4794
3463
  key: "getQuotationCustomerScopeInfo",
4795
3464
  value: function getQuotationCustomerScopeInfo() {
4796
- var _this15 = this;
3465
+ var _this13 = this;
4797
3466
  var quotation = this.store.quotation;
4798
3467
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
4799
3468
  return quotation.getQuotationCustomerScopeInfo();
@@ -4805,7 +3474,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4805
3474
  }).map(function (item) {
4806
3475
  var localSeen = new Set();
4807
3476
  var customers = item.customer.filter(function (customer) {
4808
- var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3477
+ var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
4809
3478
  if (!customerId || localSeen.has(customerId)) return false;
4810
3479
  localSeen.add(customerId);
4811
3480
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -4855,32 +3524,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4855
3524
  }, {
4856
3525
  key: "calculateProductBookingPrices",
4857
3526
  value: function () {
4858
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
3527
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paramsList) {
4859
3528
  var _paramsList$0$custome,
4860
3529
  _paramsList$,
4861
- _this16 = this,
3530
+ _this14 = this,
4862
3531
  _paramsList$2;
4863
3532
  var quotation, customerId, productMapsByGroup, groups;
4864
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4865
- while (1) switch (_context53.prev = _context53.next) {
3533
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3534
+ while (1) switch (_context38.prev = _context38.next) {
4866
3535
  case 0:
4867
3536
  if (paramsList.length) {
4868
- _context53.next = 2;
3537
+ _context38.next = 2;
4869
3538
  break;
4870
3539
  }
4871
- return _context53.abrupt("return", []);
3540
+ return _context38.abrupt("return", []);
4872
3541
  case 2:
4873
3542
  quotation = this.store.quotation;
4874
3543
  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();
4875
3544
  productMapsByGroup = new Map();
4876
3545
  groups = new Map();
4877
3546
  paramsList.forEach(function (params) {
4878
- var _this16$otherParams;
3547
+ var _this14$otherParams;
4879
3548
  var product = params.product || {};
4880
- var productId = _this16.getPriceQueryProductId(product);
3549
+ var productId = _this14.getPriceQueryProductId(product);
4881
3550
  if (productId === null) return;
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);
3551
+ var schedule = _this14.getPriceQuerySchedule(params);
3552
+ var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
4884
3553
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
4885
3554
  var group = groups.get(groupKey) || {
4886
3555
  ids: new Set(),
@@ -4890,51 +3559,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4890
3559
  group.ids.add(productId);
4891
3560
  groups.set(groupKey, group);
4892
3561
  });
4893
- _context53.next = 9;
3562
+ _context38.next = 9;
4894
3563
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
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) {
3564
+ var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(_ref30) {
3565
+ var _ref32, groupKey, group, productsById;
3566
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3567
+ while (1) switch (_context37.prev = _context37.next) {
4899
3568
  case 0:
4900
- _ref41 = _slicedToArray(_ref39, 2), groupKey = _ref41[0], group = _ref41[1];
4901
- _context52.next = 3;
4902
- return _this16.loadProductsForPriceQuery({
3569
+ _ref32 = _slicedToArray(_ref30, 2), groupKey = _ref32[0], group = _ref32[1];
3570
+ _context37.next = 3;
3571
+ return _this14.loadProductsForPriceQuery({
4903
3572
  ids: Array.from(group.ids),
4904
3573
  schedule: group.schedule,
4905
3574
  customerId: customerId,
4906
3575
  channel: group.channel
4907
3576
  });
4908
3577
  case 3:
4909
- productsById = _context52.sent;
3578
+ productsById = _context37.sent;
4910
3579
  productMapsByGroup.set(groupKey, productsById);
4911
3580
  case 5:
4912
3581
  case "end":
4913
- return _context52.stop();
3582
+ return _context37.stop();
4914
3583
  }
4915
- }, _callee52);
3584
+ }, _callee37);
4916
3585
  }));
4917
- return function (_x45) {
4918
- return _ref40.apply(this, arguments);
3586
+ return function (_x31) {
3587
+ return _ref31.apply(this, arguments);
4919
3588
  };
4920
3589
  }()));
4921
3590
  case 9:
4922
- _context53.next = 11;
3591
+ _context38.next = 11;
4923
3592
  return this.loadQuotationForPriceQuery({
4924
3593
  quotation: quotation,
4925
3594
  customer_id: customerId,
4926
3595
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
4927
3596
  });
4928
3597
  case 11:
4929
- return _context53.abrupt("return", paramsList.map(function (params) {
4930
- var _this16$otherParams2, _productMapsByGroup$g;
3598
+ return _context38.abrupt("return", paramsList.map(function (params) {
3599
+ var _this14$otherParams2, _productMapsByGroup$g;
4931
3600
  var productInput = params.product || {};
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);
3601
+ var productId = _this14.getPriceQueryProductId(productInput);
3602
+ var schedule = _this14.getPriceQuerySchedule(params);
3603
+ var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
4935
3604
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
4936
3605
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
4937
- var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3606
+ var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
4938
3607
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4939
3608
  product: product,
4940
3609
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -4944,11 +3613,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4944
3613
  }));
4945
3614
  case 12:
4946
3615
  case "end":
4947
- return _context53.stop();
3616
+ return _context38.stop();
4948
3617
  }
4949
- }, _callee53, this);
3618
+ }, _callee38, this);
4950
3619
  }));
4951
- function calculateProductBookingPrices(_x44) {
3620
+ function calculateProductBookingPrices(_x30) {
4952
3621
  return _calculateProductBookingPrices.apply(this, arguments);
4953
3622
  }
4954
3623
  return calculateProductBookingPrices;
@@ -4956,34 +3625,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4956
3625
  }, {
4957
3626
  key: "addProductToOrder",
4958
3627
  value: function () {
4959
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking, options) {
3628
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(product, booking, options) {
4960
3629
  var products;
4961
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4962
- while (1) switch (_context54.prev = _context54.next) {
3630
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3631
+ while (1) switch (_context39.prev = _context39.next) {
4963
3632
  case 0:
4964
- _context54.prev = 0;
3633
+ _context39.prev = 0;
4965
3634
  if (this.store.order) {
4966
- _context54.next = 3;
3635
+ _context39.next = 3;
4967
3636
  break;
4968
3637
  }
4969
3638
  throw new Error('order 模块未初始化');
4970
3639
  case 3:
4971
- _context54.next = 5;
3640
+ _context39.next = 5;
4972
3641
  return this.store.order.addProductToOrder(product, booking, options);
4973
3642
  case 5:
4974
- products = _context54.sent;
4975
- return _context54.abrupt("return", products);
3643
+ products = _context39.sent;
3644
+ return _context39.abrupt("return", products);
4976
3645
  case 9:
4977
- _context54.prev = 9;
4978
- _context54.t0 = _context54["catch"](0);
4979
- throw _context54.t0;
3646
+ _context39.prev = 9;
3647
+ _context39.t0 = _context39["catch"](0);
3648
+ throw _context39.t0;
4980
3649
  case 12:
4981
3650
  case "end":
4982
- return _context54.stop();
3651
+ return _context39.stop();
4983
3652
  }
4984
- }, _callee54, this, [[0, 9]]);
3653
+ }, _callee39, this, [[0, 9]]);
4985
3654
  }));
4986
- function addProductToOrder(_x46, _x47, _x48) {
3655
+ function addProductToOrder(_x32, _x33, _x34) {
4987
3656
  return _addProductToOrder.apply(this, arguments);
4988
3657
  }
4989
3658
  return addProductToOrder;
@@ -4991,34 +3660,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4991
3660
  }, {
4992
3661
  key: "updateOrderProduct",
4993
3662
  value: function () {
4994
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
3663
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
4995
3664
  var products;
4996
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4997
- while (1) switch (_context55.prev = _context55.next) {
3665
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3666
+ while (1) switch (_context40.prev = _context40.next) {
4998
3667
  case 0:
4999
- _context55.prev = 0;
3668
+ _context40.prev = 0;
5000
3669
  if (this.store.order) {
5001
- _context55.next = 3;
3670
+ _context40.next = 3;
5002
3671
  break;
5003
3672
  }
5004
3673
  throw new Error('order 模块未初始化');
5005
3674
  case 3:
5006
- _context55.next = 5;
3675
+ _context40.next = 5;
5007
3676
  return this.store.order.updateOrderProduct(params);
5008
3677
  case 5:
5009
- products = _context55.sent;
5010
- return _context55.abrupt("return", products);
3678
+ products = _context40.sent;
3679
+ return _context40.abrupt("return", products);
5011
3680
  case 9:
5012
- _context55.prev = 9;
5013
- _context55.t0 = _context55["catch"](0);
5014
- throw _context55.t0;
3681
+ _context40.prev = 9;
3682
+ _context40.t0 = _context40["catch"](0);
3683
+ throw _context40.t0;
5015
3684
  case 12:
5016
3685
  case "end":
5017
- return _context55.stop();
3686
+ return _context40.stop();
5018
3687
  }
5019
- }, _callee55, this, [[0, 9]]);
3688
+ }, _callee40, this, [[0, 9]]);
5020
3689
  }));
5021
- function updateOrderProduct(_x49) {
3690
+ function updateOrderProduct(_x35) {
5022
3691
  return _updateOrderProduct.apply(this, arguments);
5023
3692
  }
5024
3693
  return updateOrderProduct;
@@ -5026,34 +3695,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5026
3695
  }, {
5027
3696
  key: "updateOrderProducts",
5028
3697
  value: function () {
5029
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
3698
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
5030
3699
  var products;
5031
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5032
- while (1) switch (_context56.prev = _context56.next) {
3700
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3701
+ while (1) switch (_context41.prev = _context41.next) {
5033
3702
  case 0:
5034
- _context56.prev = 0;
3703
+ _context41.prev = 0;
5035
3704
  if (this.store.order) {
5036
- _context56.next = 3;
3705
+ _context41.next = 3;
5037
3706
  break;
5038
3707
  }
5039
3708
  throw new Error('order 模块未初始化');
5040
3709
  case 3:
5041
- _context56.next = 5;
3710
+ _context41.next = 5;
5042
3711
  return this.store.order.updateOrderProducts(paramsList);
5043
3712
  case 5:
5044
- products = _context56.sent;
5045
- return _context56.abrupt("return", products);
3713
+ products = _context41.sent;
3714
+ return _context41.abrupt("return", products);
5046
3715
  case 9:
5047
- _context56.prev = 9;
5048
- _context56.t0 = _context56["catch"](0);
5049
- throw _context56.t0;
3716
+ _context41.prev = 9;
3717
+ _context41.t0 = _context41["catch"](0);
3718
+ throw _context41.t0;
5050
3719
  case 12:
5051
3720
  case "end":
5052
- return _context56.stop();
3721
+ return _context41.stop();
5053
3722
  }
5054
- }, _callee56, this, [[0, 9]]);
3723
+ }, _callee41, this, [[0, 9]]);
5055
3724
  }));
5056
- function updateOrderProducts(_x50) {
3725
+ function updateOrderProducts(_x36) {
5057
3726
  return _updateOrderProducts.apply(this, arguments);
5058
3727
  }
5059
3728
  return updateOrderProducts;
@@ -5061,34 +3730,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5061
3730
  }, {
5062
3731
  key: "updateOrderProductQuantity",
5063
3732
  value: function () {
5064
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
3733
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5065
3734
  var products;
5066
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5067
- while (1) switch (_context57.prev = _context57.next) {
3735
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3736
+ while (1) switch (_context42.prev = _context42.next) {
5068
3737
  case 0:
5069
- _context57.prev = 0;
3738
+ _context42.prev = 0;
5070
3739
  if (this.store.order) {
5071
- _context57.next = 3;
3740
+ _context42.next = 3;
5072
3741
  break;
5073
3742
  }
5074
3743
  throw new Error('order 模块未初始化');
5075
3744
  case 3:
5076
- _context57.next = 5;
3745
+ _context42.next = 5;
5077
3746
  return this.store.order.updateOrderProductQuantity(params);
5078
3747
  case 5:
5079
- products = _context57.sent;
5080
- return _context57.abrupt("return", products);
3748
+ products = _context42.sent;
3749
+ return _context42.abrupt("return", products);
5081
3750
  case 9:
5082
- _context57.prev = 9;
5083
- _context57.t0 = _context57["catch"](0);
5084
- throw _context57.t0;
3751
+ _context42.prev = 9;
3752
+ _context42.t0 = _context42["catch"](0);
3753
+ throw _context42.t0;
5085
3754
  case 12:
5086
3755
  case "end":
5087
- return _context57.stop();
3756
+ return _context42.stop();
5088
3757
  }
5089
- }, _callee57, this, [[0, 9]]);
3758
+ }, _callee42, this, [[0, 9]]);
5090
3759
  }));
5091
- function updateOrderProductQuantity(_x51) {
3760
+ function updateOrderProductQuantity(_x37) {
5092
3761
  return _updateOrderProductQuantity.apply(this, arguments);
5093
3762
  }
5094
3763
  return updateOrderProductQuantity;
@@ -5111,12 +3780,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5111
3780
  }, {
5112
3781
  key: "setOrderProductLineNote",
5113
3782
  value: (function () {
5114
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
3783
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identity, note) {
5115
3784
  var params, products;
5116
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5117
- while (1) switch (_context58.prev = _context58.next) {
3785
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3786
+ while (1) switch (_context43.prev = _context43.next) {
5118
3787
  case 0:
5119
- _context58.prev = 0;
3788
+ _context43.prev = 0;
5120
3789
  params = {
5121
3790
  product_id: identity.product_id,
5122
3791
  product_variant_id: identity.product_variant_id,
@@ -5131,22 +3800,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5131
3800
  params.product_sku = identity.product_sku;
5132
3801
  }
5133
3802
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
5134
- _context58.next = 7;
3803
+ _context43.next = 7;
5135
3804
  return this.updateOrderProduct(params);
5136
3805
  case 7:
5137
- products = _context58.sent;
5138
- return _context58.abrupt("return", products);
3806
+ products = _context43.sent;
3807
+ return _context43.abrupt("return", products);
5139
3808
  case 11:
5140
- _context58.prev = 11;
5141
- _context58.t0 = _context58["catch"](0);
5142
- throw _context58.t0;
3809
+ _context43.prev = 11;
3810
+ _context43.t0 = _context43["catch"](0);
3811
+ throw _context43.t0;
5143
3812
  case 14:
5144
3813
  case "end":
5145
- return _context58.stop();
3814
+ return _context43.stop();
5146
3815
  }
5147
- }, _callee58, this, [[0, 11]]);
3816
+ }, _callee43, this, [[0, 11]]);
5148
3817
  }));
5149
- function setOrderProductLineNote(_x52, _x53) {
3818
+ function setOrderProductLineNote(_x38, _x39) {
5150
3819
  return _setOrderProductLineNote.apply(this, arguments);
5151
3820
  }
5152
3821
  return setOrderProductLineNote;
@@ -5161,32 +3830,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5161
3830
  }, {
5162
3831
  key: "removeProductsFromOrder",
5163
3832
  value: (function () {
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) {
3833
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identities, options) {
3834
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3835
+ while (1) switch (_context44.prev = _context44.next) {
5167
3836
  case 0:
5168
- _context59.prev = 0;
3837
+ _context44.prev = 0;
5169
3838
  if (this.store.order) {
5170
- _context59.next = 3;
3839
+ _context44.next = 3;
5171
3840
  break;
5172
3841
  }
5173
3842
  throw new Error('order 模块未初始化');
5174
3843
  case 3:
5175
- _context59.next = 5;
3844
+ _context44.next = 5;
5176
3845
  return this.store.order.removeProductsFromOrder(identities, options);
5177
3846
  case 5:
5178
- return _context59.abrupt("return", _context59.sent);
3847
+ return _context44.abrupt("return", _context44.sent);
5179
3848
  case 8:
5180
- _context59.prev = 8;
5181
- _context59.t0 = _context59["catch"](0);
5182
- throw _context59.t0;
3849
+ _context44.prev = 8;
3850
+ _context44.t0 = _context44["catch"](0);
3851
+ throw _context44.t0;
5183
3852
  case 11:
5184
3853
  case "end":
5185
- return _context59.stop();
3854
+ return _context44.stop();
5186
3855
  }
5187
- }, _callee59, this, [[0, 8]]);
3856
+ }, _callee44, this, [[0, 8]]);
5188
3857
  }));
5189
- function removeProductsFromOrder(_x54, _x55) {
3858
+ function removeProductsFromOrder(_x40, _x41) {
5190
3859
  return _removeProductsFromOrder.apply(this, arguments);
5191
3860
  }
5192
3861
  return removeProductsFromOrder;
@@ -5194,18 +3863,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5194
3863
  }, {
5195
3864
  key: "removeProductFromOrder",
5196
3865
  value: function () {
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) {
3866
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(identity, options) {
3867
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3868
+ while (1) switch (_context45.prev = _context45.next) {
5200
3869
  case 0:
5201
- return _context60.abrupt("return", this.removeProductsFromOrder([identity], options));
3870
+ return _context45.abrupt("return", this.removeProductsFromOrder([identity], options));
5202
3871
  case 1:
5203
3872
  case "end":
5204
- return _context60.stop();
3873
+ return _context45.stop();
5205
3874
  }
5206
- }, _callee60, this);
3875
+ }, _callee45, this);
5207
3876
  }));
5208
- function removeProductFromOrder(_x56, _x57) {
3877
+ function removeProductFromOrder(_x42, _x43) {
5209
3878
  return _removeProductFromOrder.apply(this, arguments);
5210
3879
  }
5211
3880
  return removeProductFromOrder;
@@ -5255,23 +3924,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5255
3924
  }, {
5256
3925
  key: "applyPromotion",
5257
3926
  value: (function () {
5258
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
5259
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5260
- while (1) switch (_context61.prev = _context61.next) {
3927
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3928
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3929
+ while (1) switch (_context46.prev = _context46.next) {
5261
3930
  case 0:
5262
3931
  if (this.store.order) {
5263
- _context61.next = 2;
3932
+ _context46.next = 2;
5264
3933
  break;
5265
3934
  }
5266
3935
  throw new Error('order 模块未初始化');
5267
3936
  case 2:
5268
- _context61.next = 4;
3937
+ _context46.next = 4;
5269
3938
  return this.store.order.applyPromotion();
5270
3939
  case 4:
5271
3940
  case "end":
5272
- return _context61.stop();
3941
+ return _context46.stop();
5273
3942
  }
5274
- }, _callee61, this);
3943
+ }, _callee46, this);
5275
3944
  }));
5276
3945
  function applyPromotion() {
5277
3946
  return _applyPromotion.apply(this, arguments);
@@ -5281,16 +3950,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5281
3950
  }, {
5282
3951
  key: "getUnfulfilledPromotions",
5283
3952
  value: function 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()) || [];
3953
+ var _this$store$order8;
3954
+ return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
5286
3955
  }
5287
3956
 
5288
3957
  /** 最近一次促销计算输出的赠品操作 diff。 */
5289
3958
  }, {
5290
3959
  key: "getLastGiftActions",
5291
3960
  value: function getLastGiftActions() {
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;
3961
+ var _this$store$order9;
3962
+ return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
5294
3963
  }
5295
3964
 
5296
3965
  // 获取商品列表
@@ -5298,18 +3967,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5298
3967
  }, {
5299
3968
  key: "getProductList",
5300
3969
  value: function () {
5301
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
5302
- var _this$otherParams32;
3970
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3971
+ var _this$otherParams26;
5303
3972
  var menu_list_ids, _this$store$products, res;
5304
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5305
- while (1) switch (_context62.prev = _context62.next) {
3973
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3974
+ while (1) switch (_context47.prev = _context47.next) {
5306
3975
  case 0:
5307
3976
  // 可以直接通过配置里的 menu 读取
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) {
3977
+ menu_list_ids = ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 || (_this$otherParams26 = _this$otherParams26.dineInConfig) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26['menu.associated_menus'].map(function (n) {
5309
3978
  return Number(n.value);
5310
3979
  })) || [];
5311
- _context62.prev = 1;
5312
- _context62.next = 4;
3980
+ _context47.prev = 1;
3981
+ _context47.next = 4;
5313
3982
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
5314
3983
  menu_list_ids: menu_list_ids,
5315
3984
  cacheId: this.cacheId,
@@ -5317,17 +3986,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5317
3986
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
5318
3987
  });
5319
3988
  case 4:
5320
- res = _context62.sent;
5321
- return _context62.abrupt("return", res);
3989
+ res = _context47.sent;
3990
+ return _context47.abrupt("return", res);
5322
3991
  case 8:
5323
- _context62.prev = 8;
5324
- _context62.t0 = _context62["catch"](1);
5325
- throw _context62.t0;
3992
+ _context47.prev = 8;
3993
+ _context47.t0 = _context47["catch"](1);
3994
+ throw _context47.t0;
5326
3995
  case 11:
5327
3996
  case "end":
5328
- return _context62.stop();
3997
+ return _context47.stop();
5329
3998
  }
5330
- }, _callee62, this, [[1, 8]]);
3999
+ }, _callee47, this, [[1, 8]]);
5331
4000
  }));
5332
4001
  function getProductList() {
5333
4002
  return _getProductList.apply(this, arguments);
@@ -5342,33 +4011,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5342
4011
  }, {
5343
4012
  key: "setOtherParams",
5344
4013
  value: function () {
5345
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
5346
- var _this$otherParams33;
5347
- var _ref42,
5348
- _ref42$cover,
4014
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4015
+ var _this$otherParams27;
4016
+ var _ref33,
4017
+ _ref33$cover,
5349
4018
  cover,
5350
- _args63 = arguments;
5351
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5352
- while (1) switch (_context63.prev = _context63.next) {
4019
+ _args48 = arguments;
4020
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4021
+ while (1) switch (_context48.prev = _context48.next) {
5353
4022
  case 0:
5354
- _ref42 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref42$cover = _ref42.cover, cover = _ref42$cover === void 0 ? false : _ref42$cover;
4023
+ _ref33 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref33$cover = _ref33.cover, cover = _ref33$cover === void 0 ? false : _ref33$cover;
5355
4024
  if (cover) {
5356
4025
  this.otherParams = _objectSpread({}, params);
5357
4026
  } else {
5358
4027
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
5359
4028
  }
5360
- this.cacheId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.cacheId;
5361
- _context63.next = 5;
4029
+ this.cacheId = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.cacheId;
4030
+ _context48.next = 5;
5362
4031
  return this.syncOtherParamsToSubModules(params, {
5363
4032
  cover: cover
5364
4033
  });
5365
4034
  case 5:
5366
4035
  case "end":
5367
- return _context63.stop();
4036
+ return _context48.stop();
5368
4037
  }
5369
- }, _callee63, this);
4038
+ }, _callee48, this);
5370
4039
  }));
5371
- function setOtherParams(_x58) {
4040
+ function setOtherParams(_x44) {
5372
4041
  return _setOtherParams.apply(this, arguments);
5373
4042
  }
5374
4043
  return setOtherParams;