@pisell/pisellos 2.2.302 → 2.2.304

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 (157) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  3. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  4. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  5. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  6. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  7. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  8. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  9. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
  12. package/dist/modules/Discount/index.d.ts +2 -0
  13. package/dist/modules/Discount/index.js +41 -5
  14. package/dist/modules/Discount/types.d.ts +21 -0
  15. package/dist/modules/OpenData/index.d.ts +15 -2
  16. package/dist/modules/OpenData/index.js +307 -19
  17. package/dist/modules/OpenData/types.d.ts +55 -0
  18. package/dist/modules/OpenData/types.js +7 -1
  19. package/dist/modules/OpenData/utils.d.ts +21 -1
  20. package/dist/modules/OpenData/utils.js +138 -0
  21. package/dist/modules/Order/index.d.ts +50 -7
  22. package/dist/modules/Order/index.js +1690 -815
  23. package/dist/modules/Order/salesNotes.d.ts +31 -0
  24. package/dist/modules/Order/salesNotes.js +492 -0
  25. package/dist/modules/Order/types.d.ts +117 -10
  26. package/dist/modules/Order/types.js +6 -1
  27. package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
  28. package/dist/modules/Order/utils/virtualSettlement.js +284 -0
  29. package/dist/modules/Order/utils.d.ts +5 -1
  30. package/dist/modules/Order/utils.js +138 -33
  31. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  32. package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
  33. package/dist/modules/Payment/walletpass.js +20 -21
  34. package/dist/modules/Product/types.d.ts +23 -0
  35. package/dist/modules/ProductList/index.d.ts +2 -1
  36. package/dist/modules/ProductList/index.js +100 -20
  37. package/dist/modules/ProductList/types.d.ts +10 -0
  38. package/dist/modules/Rules/index.d.ts +5 -0
  39. package/dist/modules/Rules/index.js +30 -14
  40. package/dist/modules/SalesSummary/index.d.ts +1 -0
  41. package/dist/modules/SalesSummary/index.js +4 -3
  42. package/dist/modules/SalesSummary/types.d.ts +1 -0
  43. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  44. package/dist/modules/SalesSummary/utils.js +21 -1
  45. package/dist/plugins/request.d.ts +2 -1
  46. package/dist/plugins/request.js +4 -2
  47. package/dist/server/index.d.ts +21 -0
  48. package/dist/server/index.js +1774 -1285
  49. package/dist/server/modules/order/types.d.ts +50 -0
  50. package/dist/server/modules/order/types.js +2 -0
  51. package/dist/server/utils/small-ticket.d.ts +4 -1
  52. package/dist/server/utils/small-ticket.js +461 -96
  53. package/dist/solution/BaseSales/index.d.ts +24 -3
  54. package/dist/solution/BaseSales/index.js +1484 -873
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  56. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  58. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
  59. package/dist/solution/BookingByStep/index.d.ts +1 -1
  60. package/dist/solution/BookingTicket/index.d.ts +22 -5
  61. package/dist/solution/BookingTicket/index.js +558 -443
  62. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  63. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  64. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  65. package/dist/solution/RegisterAndLogin/config.js +95 -40
  66. package/dist/solution/RegisterAndLogin/index.js +4 -1
  67. package/dist/solution/Sales/index.d.ts +16 -1
  68. package/dist/solution/Sales/index.js +338 -63
  69. package/dist/solution/Sales/types.d.ts +10 -0
  70. package/dist/solution/ScanOrder/index.d.ts +1 -0
  71. package/dist/solution/ScanOrder/index.js +31 -27
  72. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  73. package/dist/solution/ScanOrder/utils.js +2 -0
  74. package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
  75. package/dist/solution/UnifiedBookingSales/index.js +874 -527
  76. package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
  77. package/dist/solution/VenueBooking/index.d.ts +1 -0
  78. package/dist/solution/VenueBooking/index.js +8 -4
  79. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  80. package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
  81. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  82. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  83. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  84. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  85. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  86. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  87. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  88. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  89. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
  90. package/lib/modules/Discount/index.d.ts +2 -0
  91. package/lib/modules/Discount/index.js +34 -2
  92. package/lib/modules/Discount/types.d.ts +21 -0
  93. package/lib/modules/OpenData/index.d.ts +15 -2
  94. package/lib/modules/OpenData/index.js +230 -3
  95. package/lib/modules/OpenData/types.d.ts +55 -0
  96. package/lib/modules/OpenData/types.js +9 -1
  97. package/lib/modules/OpenData/utils.d.ts +21 -1
  98. package/lib/modules/OpenData/utils.js +126 -0
  99. package/lib/modules/Order/index.d.ts +50 -7
  100. package/lib/modules/Order/index.js +704 -64
  101. package/lib/modules/Order/salesNotes.d.ts +31 -0
  102. package/lib/modules/Order/salesNotes.js +382 -0
  103. package/lib/modules/Order/types.d.ts +117 -10
  104. package/lib/modules/Order/types.js +5 -1
  105. package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
  106. package/lib/modules/Order/utils/virtualSettlement.js +262 -0
  107. package/lib/modules/Order/utils.d.ts +5 -1
  108. package/lib/modules/Order/utils.js +127 -21
  109. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  110. package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
  111. package/lib/modules/Payment/walletpass.js +14 -11
  112. package/lib/modules/Product/types.d.ts +23 -0
  113. package/lib/modules/ProductList/index.d.ts +2 -1
  114. package/lib/modules/ProductList/index.js +47 -2
  115. package/lib/modules/ProductList/types.d.ts +10 -0
  116. package/lib/modules/Rules/index.d.ts +5 -0
  117. package/lib/modules/Rules/index.js +22 -12
  118. package/lib/modules/SalesSummary/index.d.ts +1 -0
  119. package/lib/modules/SalesSummary/index.js +4 -2
  120. package/lib/modules/SalesSummary/types.d.ts +1 -0
  121. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  122. package/lib/modules/SalesSummary/utils.js +17 -1
  123. package/lib/plugins/request.d.ts +2 -1
  124. package/lib/plugins/request.js +3 -2
  125. package/lib/server/index.d.ts +21 -0
  126. package/lib/server/index.js +492 -108
  127. package/lib/server/modules/order/types.d.ts +50 -0
  128. package/lib/server/modules/order/types.js +1 -0
  129. package/lib/server/utils/small-ticket.d.ts +4 -1
  130. package/lib/server/utils/small-ticket.js +427 -72
  131. package/lib/solution/BaseSales/index.d.ts +24 -3
  132. package/lib/solution/BaseSales/index.js +433 -30
  133. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  134. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  135. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  136. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
  137. package/lib/solution/BookingByStep/index.d.ts +1 -1
  138. package/lib/solution/BookingTicket/index.d.ts +22 -5
  139. package/lib/solution/BookingTicket/index.js +60 -15
  140. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
  141. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  142. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  143. package/lib/solution/RegisterAndLogin/config.js +49 -8
  144. package/lib/solution/RegisterAndLogin/index.js +4 -1
  145. package/lib/solution/Sales/index.d.ts +16 -1
  146. package/lib/solution/Sales/index.js +168 -1
  147. package/lib/solution/Sales/types.d.ts +10 -0
  148. package/lib/solution/ScanOrder/index.d.ts +1 -0
  149. package/lib/solution/ScanOrder/index.js +5 -1
  150. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  151. package/lib/solution/ScanOrder/utils.js +1 -0
  152. package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
  153. package/lib/solution/UnifiedBookingSales/index.js +169 -16
  154. package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
  155. package/lib/solution/VenueBooking/index.d.ts +1 -0
  156. package/lib/solution/VenueBooking/index.js +5 -1
  157. package/package.json +1 -1
@@ -34,9 +34,10 @@ import { BaseModule } from "../../modules/BaseModule";
34
34
  import { BaseSalesHookNames } from "./types";
35
35
  import { OrderModule } from "../../modules/Order";
36
36
  import Decimal from 'decimal.js';
37
- import { cloneDeep, mergeWith } from 'lodash-es';
37
+ import { cloneDeep, isEqual, 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 { buildCurrencyDisplaySnapshot, getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
40
41
  import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
41
42
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
42
43
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
@@ -49,6 +50,8 @@ import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProdu
49
50
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
50
51
  var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
51
52
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
53
+ var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
54
+ var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
52
55
  var WALLET_PAYMENT_CODE_BY_TAG = {
53
56
  product_voucher: 'PRODUCTVOUCHER',
54
57
  gift_card: 'GIFTCARD',
@@ -292,6 +295,24 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
292
295
  }
293
296
  return normalizedRecord;
294
297
  }
298
+ function isValidBaseSalesSmallTicketDataSnapshot(value) {
299
+ if (!value || _typeof(value) !== 'object' || Array.isArray(value)) return false;
300
+ var localeSnapshots = Object.values(value);
301
+ return localeSnapshots.length > 0 && localeSnapshots.some(function (localeSnapshot) {
302
+ return localeSnapshot !== null && _typeof(localeSnapshot) === 'object' && !Array.isArray(localeSnapshot);
303
+ });
304
+ }
305
+ function mergeBaseSalesSmallTicketDataSnapshot(currentValue, loadedValue) {
306
+ if (isValidBaseSalesSmallTicketDataSnapshot(loadedValue)) {
307
+ return cloneDeep(loadedValue);
308
+ }
309
+ if (isValidBaseSalesSmallTicketDataSnapshot(currentValue)) {
310
+ return cloneDeep(currentValue);
311
+ }
312
+ if (loadedValue !== undefined) return cloneDeep(loadedValue);
313
+ if (currentValue !== undefined) return cloneDeep(currentValue);
314
+ return undefined;
315
+ }
295
316
  function getBaseSalesMetadataUid(item, metadataKey) {
296
317
  var _item$metadata$metada, _item$metadata;
297
318
  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];
@@ -320,7 +341,66 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
320
341
  loadedValue.forEach(appendOrReplaceByUid);
321
342
  return result;
322
343
  }
344
+
345
+ // checkout / realtime snapshots may reorder protocol arrays or append persistence fields.
346
+ // Compare only the Sales Note protocol fields so a matching remote echo can acknowledge dirty state.
347
+ function normalizeBaseSalesNotesForComparison(value, options) {
348
+ var _options$unresolvedOr;
349
+ if (!Array.isArray(value)) return null;
350
+ var unresolvedOrderTargetUuid = String((_options$unresolvedOr = options === null || options === void 0 ? void 0 : options.unresolvedOrderTargetUuid) !== null && _options$unresolvedOr !== void 0 ? _options$unresolvedOr : '').trim();
351
+ return value.map(function (note) {
352
+ var _noteRecord$content;
353
+ if (!note || _typeof(note) !== 'object' || Array.isArray(note)) {
354
+ return cloneDeep(note);
355
+ }
356
+ var noteRecord = note;
357
+ var relations = Array.isArray(noteRecord.note_relations) ? noteRecord.note_relations.map(function (relation) {
358
+ var _relation$target_uuid;
359
+ if (!relation || _typeof(relation) !== 'object' || Array.isArray(relation)) {
360
+ return cloneDeep(relation);
361
+ }
362
+ var shouldResolveOrderTarget = relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && String((_relation$target_uuid = relation.target_uuid) !== null && _relation$target_uuid !== void 0 ? _relation$target_uuid : '').trim() === '' && unresolvedOrderTargetUuid.length > 0;
363
+ return {
364
+ uuid: relation.uuid,
365
+ relation_type: relation.relation_type,
366
+ target_type: relation.target_type,
367
+ target_uuid: shouldResolveOrderTarget ? unresolvedOrderTargetUuid : relation.target_uuid,
368
+ is_primary: relation.is_primary
369
+ };
370
+ }).sort(function (left, right) {
371
+ var _left$uuid, _right$uuid;
372
+ return String((_left$uuid = left === null || left === void 0 ? void 0 : left.uuid) !== null && _left$uuid !== void 0 ? _left$uuid : '').localeCompare(String((_right$uuid = right === null || right === void 0 ? void 0 : right.uuid) !== null && _right$uuid !== void 0 ? _right$uuid : ''));
373
+ }) : cloneDeep(noteRecord.note_relations);
374
+ return {
375
+ uuid: noteRecord.uuid,
376
+ note_type: noteRecord.note_type,
377
+ content: {
378
+ text: cloneDeep((_noteRecord$content = noteRecord.content) === null || _noteRecord$content === void 0 ? void 0 : _noteRecord$content.text)
379
+ },
380
+ importance: noteRecord.importance,
381
+ note_relations: relations
382
+ };
383
+ }).sort(function (left, right) {
384
+ var _left$uuid2, _right$uuid2;
385
+ return String((_left$uuid2 = left === null || left === void 0 ? void 0 : left.uuid) !== null && _left$uuid2 !== void 0 ? _left$uuid2 : '').localeCompare(String((_right$uuid2 = right === null || right === void 0 ? void 0 : right.uuid) !== null && _right$uuid2 !== void 0 ? _right$uuid2 : ''));
386
+ });
387
+ }
388
+ function areBaseSalesNotesEquivalent(currentValue, loadedValue, options) {
389
+ var currentNotes = normalizeBaseSalesNotesForComparison(currentValue, {
390
+ unresolvedOrderTargetUuid: options === null || options === void 0 ? void 0 : options.currentOrderTargetUuid
391
+ });
392
+ var loadedNotes = normalizeBaseSalesNotesForComparison(loadedValue);
393
+ return currentNotes !== null && loadedNotes !== null && isEqual(currentNotes, loadedNotes);
394
+ }
323
395
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
396
+ var _currentTempOrder$_ex, _normalizedLoadedReco;
397
+ var loadedHasSalesNotes = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'notes');
398
+ var hasDirtyLocalSalesNotes = (currentTempOrder === null || currentTempOrder === void 0 || (_currentTempOrder$_ex = currentTempOrder._extend) === null || _currentTempOrder$_ex === void 0 || (_currentTempOrder$_ex = _currentTempOrder$_ex.salesNotesState) === null || _currentTempOrder$_ex === void 0 ? void 0 : _currentTempOrder$_ex.dirty) === true;
399
+ var incomingSalesNotesMatchLocal = loadedHasSalesNotes && areBaseSalesNotesEquivalent(currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.notes, loadedRecord.notes, {
400
+ currentOrderTargetUuid: (loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.shop_order_number) || (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.shop_order_number)
401
+ });
402
+ var shouldAwaitAuthoritativeSalesNotes = strategy === 'authoritative-incoming' && hasDirtyLocalSalesNotes && (Number(loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.need_sync) === 1 || !incomingSalesNotesMatchLocal);
403
+ var preserveDirtyLocalSalesNotes = hasDirtyLocalSalesNotes && (strategy === 'preserve-local' || shouldAwaitAuthoritativeSalesNotes);
324
404
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
325
405
  ensureUid: false
326
406
  });
@@ -332,6 +412,17 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
332
412
  });
333
413
  var uidRemaps = [];
334
414
  var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
415
+ if (key === 'notes') {
416
+ if (preserveDirtyLocalSalesNotes && Array.isArray(currentValue)) {
417
+ return cloneDeep(currentValue);
418
+ }
419
+ if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
420
+ }
421
+ // small_ticket_data 是由 Server 一次性生成的完整展示快照,不能递归进入
422
+ // locale 内部继续套用订单集合或普通数组的合并规则。
423
+ if (key === 'small_ticket_data') {
424
+ return mergeBaseSalesSmallTicketDataSnapshot(currentValue, loadedValue);
425
+ }
335
426
  var collectionKind = getBaseSalesOrderCollectionKind(key);
336
427
  if (collectionKind && Array.isArray(loadedValue)) {
337
428
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
@@ -355,7 +446,23 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
355
446
  return undefined;
356
447
  });
357
448
  delete mergedRecord.request_unique_idempotency_token;
358
- return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
449
+ var normalizedMergedRecord = normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
450
+ normalizedMergedRecord._extend = _objectSpread(_objectSpread({}, normalizedMergedRecord._extend || {}), {}, {
451
+ salesNotesState: preserveDirtyLocalSalesNotes ? {
452
+ loaded: true,
453
+ dirty: true
454
+ } : loadedHasSalesNotes ? {
455
+ loaded: true,
456
+ dirty: ((_normalizedLoadedReco = normalizedLoadedRecord._extend) === null || _normalizedLoadedReco === void 0 || (_normalizedLoadedReco = _normalizedLoadedReco.salesNotesState) === null || _normalizedLoadedReco === void 0 ? void 0 : _normalizedLoadedReco.dirty) === true
457
+ } : {
458
+ loaded: false,
459
+ dirty: false
460
+ }
461
+ });
462
+ if (!loadedHasSalesNotes && !preserveDirtyLocalSalesNotes) {
463
+ delete normalizedMergedRecord.notes;
464
+ }
465
+ return normalizedMergedRecord;
359
466
  }
360
467
  function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
361
468
  if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
@@ -1457,6 +1564,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1457
1564
  var _this$otherParams8;
1458
1565
  return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
1459
1566
  }
1567
+
1568
+ /** Subclasses with target-scoped OpenData override this guard before reusing the cache. */
1569
+ }, {
1570
+ key: "isInvoiceOpenDataCacheCurrent",
1571
+ value: function isInvoiceOpenDataCacheCurrent() {
1572
+ return true;
1573
+ }
1460
1574
  }, {
1461
1575
  key: "getFulfillmentRefModeConfigs",
1462
1576
  value: function getFulfillmentRefModeConfigs() {
@@ -1487,13 +1601,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1487
1601
  return undefined;
1488
1602
  }
1489
1603
  }, {
1490
- key: "buildSubmitPayloadEnhancerWithFulfillmentRefMode",
1491
- value: function buildSubmitPayloadEnhancerWithFulfillmentRefMode(enhancePayload) {
1604
+ key: "getCachedInvoiceLayoutConfig",
1605
+ value: function getCachedInvoiceLayoutConfig() {
1606
+ var _this$store2;
1607
+ var openDataModule = (_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : _this$store2.openData;
1608
+ if (typeof (openDataModule === null || openDataModule === void 0 ? void 0 : openDataModule.getInvoiceLayoutConfig) !== 'function') return undefined;
1609
+ if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
1610
+ try {
1611
+ return openDataModule.getInvoiceLayoutConfig();
1612
+ } catch (error) {
1613
+ this.logWarning('读取 Invoice OpenData 布局失败,提交时不注入布局配置', {
1614
+ error: error instanceof Error ? error.message : String(error)
1615
+ });
1616
+ return undefined;
1617
+ }
1618
+ }
1619
+ }, {
1620
+ key: "getCachedInvoiceTemplateSettings",
1621
+ value: function getCachedInvoiceTemplateSettings() {
1622
+ var _this$store3;
1623
+ var openDataModule = (_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : _this$store3.openData;
1624
+ if (typeof (openDataModule === null || openDataModule === void 0 ? void 0 : openDataModule.getInvoiceTemplateSettings) !== 'function') return undefined;
1625
+ if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
1626
+ try {
1627
+ return openDataModule.getInvoiceTemplateSettings();
1628
+ } catch (error) {
1629
+ this.logWarning('读取 Invoice OpenData 模板配置失败,提交时不注入模板配置', {
1630
+ error: error instanceof Error ? error.message : String(error)
1631
+ });
1632
+ return undefined;
1633
+ }
1634
+ }
1635
+ }, {
1636
+ key: "buildSubmitPayloadEnhancerWithOpenDataConfig",
1637
+ value: function buildSubmitPayloadEnhancerWithOpenDataConfig(enhancePayload) {
1492
1638
  var fulfillmentRefMode = this.getFulfillmentRefMode();
1493
- if (!fulfillmentRefMode) return enhancePayload;
1639
+ var invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
1640
+ var invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
1641
+ if (!fulfillmentRefMode && !invoiceLayoutConfig && !invoiceTemplateSettings) {
1642
+ return enhancePayload;
1643
+ }
1494
1644
  return function (payload, ctx) {
1495
1645
  var enhancedPayload = enhancePayload ? enhancePayload(payload, ctx) : payload;
1496
- return _objectSpread(_objectSpread({}, enhancedPayload), {}, _defineProperty({}, OS_FULFILLMENT_REF_MODE_FIELD, fulfillmentRefMode));
1646
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, enhancedPayload), fulfillmentRefMode ? _defineProperty({}, OS_FULFILLMENT_REF_MODE_FIELD, fulfillmentRefMode) : {}), invoiceLayoutConfig ? _defineProperty({}, OS_INVOICE_LAYOUT_CONFIG_FIELD, cloneDeep(invoiceLayoutConfig)) : {}), invoiceTemplateSettings ? _defineProperty({}, OS_INVOICE_TEMPLATE_SETTINGS_FIELD, cloneDeep(invoiceTemplateSettings)) : {});
1497
1647
  };
1498
1648
  }
1499
1649
 
@@ -1563,22 +1713,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1563
1713
  value: (function () {
1564
1714
  var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
1565
1715
  var _this8 = this;
1566
- var _ref27,
1567
- _ref27$cover,
1716
+ var _ref30,
1717
+ _ref30$cover,
1568
1718
  cover,
1569
1719
  _args11 = arguments;
1570
1720
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1571
1721
  while (1) switch (_context11.prev = _context11.next) {
1572
1722
  case 0:
1573
- _ref27 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref27$cover = _ref27.cover, cover = _ref27$cover === void 0 ? false : _ref27$cover;
1723
+ _ref30 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
1574
1724
  _context11.next = 3;
1575
1725
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1576
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref28) {
1577
- var _ref30, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1726
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref31) {
1727
+ var _ref33, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1578
1728
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1579
1729
  while (1) switch (_context10.prev = _context10.next) {
1580
1730
  case 0:
1581
- _ref30 = _slicedToArray(_ref28, 2), moduleName = _ref30[0], subModule = _ref30[1];
1731
+ _ref33 = _slicedToArray(_ref31, 2), moduleName = _ref33[0], subModule = _ref33[1];
1582
1732
  if (!_this8.reusedSharedSubModuleNames.has(moduleName)) {
1583
1733
  _context10.next = 3;
1584
1734
  break;
@@ -1605,7 +1755,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1605
1755
  }, _callee10);
1606
1756
  }));
1607
1757
  return function (_x10) {
1608
- return _ref29.apply(this, arguments);
1758
+ return _ref32.apply(this, arguments);
1609
1759
  };
1610
1760
  }()));
1611
1761
  case 3:
@@ -1682,6 +1832,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1682
1832
  return _this10.getAppData(key);
1683
1833
  });
1684
1834
  }
1835
+ }, {
1836
+ key: "isMultiCurrencySettlementEnabled",
1837
+ value: function isMultiCurrencySettlementEnabled() {
1838
+ var _this$otherParams11;
1839
+ return ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableMultiCurrencySettlement) === true;
1840
+ }
1841
+ }, {
1842
+ key: "isActiveVirtualSettlementOrder",
1843
+ value: function isActiveVirtualSettlementOrder(tempOrder) {
1844
+ return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
1845
+ }
1846
+ }, {
1847
+ key: "isHistoricalVirtualSettlementOrder",
1848
+ value: function isHistoricalVirtualSettlementOrder(tempOrder) {
1849
+ var _tempOrder$metadata;
1850
+ return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
1851
+ }
1685
1852
  }, {
1686
1853
  key: "syncAppDataToTempOrder",
1687
1854
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1689,6 +1856,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1689
1856
  var taxCountryCode = this.getAppData('tax_country_code');
1690
1857
  var currencyCode = this.getAppData('shop_currency_code');
1691
1858
  var currencySymbol = this.getAppData('shop_symbol');
1859
+ // 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
1860
+ var isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
1861
+ var isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
1862
+ var shouldManageLegalCurrencySnapshot = this.isMultiCurrencySettlementEnabled() || isHistoricalVirtualSettlement;
1692
1863
  var isChanged = false;
1693
1864
  if (isPriceIncludeTax !== undefined) {
1694
1865
  var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
@@ -1704,14 +1875,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1704
1875
  isChanged = true;
1705
1876
  }
1706
1877
  }
1707
- if (currencyCode !== undefined) {
1878
+ tempOrder.metadata = tempOrder.metadata || {};
1879
+ if (shouldManageLegalCurrencySnapshot) {
1880
+ var _ref34, _ref35, _tempOrder$metadata$l, _ref36, _ref37, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
1881
+ var legalCurrencySnapshot = {
1882
+ currency_code: String((_ref34 = (_ref35 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref35 !== void 0 ? _ref35 : tempOrder.currency_code) !== null && _ref34 !== void 0 ? _ref34 : ''),
1883
+ currency_symbol: String((_ref36 = (_ref37 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref37 !== void 0 ? _ref37 : tempOrder.currency_symbol) !== null && _ref36 !== void 0 ? _ref36 : ''),
1884
+ currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
1885
+ };
1886
+ if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
1887
+ tempOrder.metadata.legal_currency_snapshot = legalCurrencySnapshot;
1888
+ isChanged = true;
1889
+ }
1890
+ }
1891
+ if (!isVirtualSettlement && currencyCode !== undefined) {
1708
1892
  var nextCurrencyCode = String(currencyCode || '');
1709
1893
  if (tempOrder.currency_code !== nextCurrencyCode) {
1710
1894
  tempOrder.currency_code = nextCurrencyCode;
1711
1895
  isChanged = true;
1712
1896
  }
1713
1897
  }
1714
- if (currencySymbol !== undefined) {
1898
+ if (!isVirtualSettlement && currencySymbol !== undefined) {
1715
1899
  var nextCurrencySymbol = String(currencySymbol || '');
1716
1900
  if (tempOrder.currency_symbol !== nextCurrencySymbol) {
1717
1901
  tempOrder.currency_symbol = nextCurrencySymbol;
@@ -1724,11 +1908,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1724
1908
  key: "initialize",
1725
1909
  value: function () {
1726
1910
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
1727
- var _this$otherParams11,
1911
+ var _this$otherParams12,
1728
1912
  _this$appPlugin2,
1729
1913
  _this$appPlugin2$getA,
1730
1914
  _this11 = this,
1731
- _this$otherParams12;
1915
+ _this$otherParams13;
1732
1916
  var options,
1733
1917
  app,
1734
1918
  targetCacheData,
@@ -1743,7 +1927,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1743
1927
  this.paymentNumberDevicePrefix = null;
1744
1928
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1745
1929
  this.otherParams = options.otherParams || {};
1746
- this.cacheId = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.cacheId;
1930
+ this.cacheId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.cacheId;
1747
1931
  this.reusedSharedSubModuleNames.clear();
1748
1932
  this.window = core.getPlugin('window');
1749
1933
  this.request = core.getPlugin('request');
@@ -1785,7 +1969,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1785
1969
  _context12.next = 19;
1786
1970
  return this.store.schedule.loadAllSchedule();
1787
1971
  case 19:
1788
- if (this.store.order && typeof ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.enableTempOrderPersist) === 'boolean') {
1972
+ if (this.store.order && typeof ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableTempOrderPersist) === 'boolean') {
1789
1973
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1790
1974
  }
1791
1975
  _context12.next = 22;
@@ -1857,7 +2041,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1857
2041
  key: "loadSalesDetail",
1858
2042
  value: (function () {
1859
2043
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
1860
- var loadSequence, _ref31, _ref32, _ref33, _ref34, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
2044
+ var loadSequence, _ref38, _ref39, _ref40, _ref41, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
1861
2045
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1862
2046
  while (1) switch (_context14.prev = _context14.next) {
1863
2047
  case 0:
@@ -1875,7 +2059,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1875
2059
  };
1876
2060
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1877
2061
  preloadedSalesDetail = params.preloadedSalesDetail;
1878
- lookup = (_ref31 = (_ref32 = (_ref33 = (_ref34 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref34 !== void 0 ? _ref34 : params.orderNumber) !== null && _ref33 !== void 0 ? _ref33 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref32 !== void 0 ? _ref32 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref31 !== void 0 ? _ref31 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
2062
+ lookup = (_ref38 = (_ref39 = (_ref40 = (_ref41 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref41 !== void 0 ? _ref41 : params.orderNumber) !== null && _ref40 !== void 0 ? _ref40 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref39 !== void 0 ? _ref39 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref38 !== void 0 ? _ref38 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1879
2063
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1880
2064
  _context14.next = 11;
1881
2065
  break;
@@ -2089,6 +2273,101 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2089
2273
  if (!this.store.order) return '';
2090
2274
  return this.store.order.getTempOrderNote();
2091
2275
  }
2276
+ }, {
2277
+ key: "getSalesNotes",
2278
+ value: function getSalesNotes() {
2279
+ if (!this.store.order) return [];
2280
+ return this.store.order.getSalesNotes();
2281
+ }
2282
+ }, {
2283
+ key: "createSalesNotesMutationSnapshot",
2284
+ value: function createSalesNotesMutationSnapshot() {
2285
+ if (!this.store.order) throw new Error('order 模块未初始化');
2286
+ return this.store.order.createSalesNotesMutationSnapshot();
2287
+ }
2288
+ }, {
2289
+ key: "restoreSalesNotesMutationSnapshot",
2290
+ value: function restoreSalesNotesMutationSnapshot(snapshot) {
2291
+ if (!this.store.order) throw new Error('order 模块未初始化');
2292
+ this.store.order.restoreSalesNotesMutationSnapshot(snapshot);
2293
+ }
2294
+ }, {
2295
+ key: "setSalesNote",
2296
+ value: function () {
2297
+ var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
2298
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2299
+ while (1) switch (_context16.prev = _context16.next) {
2300
+ case 0:
2301
+ if (this.store.order) {
2302
+ _context16.next = 2;
2303
+ break;
2304
+ }
2305
+ throw new Error('order 模块未初始化');
2306
+ case 2:
2307
+ return _context16.abrupt("return", this.store.order.setSalesNote(input));
2308
+ case 3:
2309
+ case "end":
2310
+ return _context16.stop();
2311
+ }
2312
+ }, _callee16, this);
2313
+ }));
2314
+ function setSalesNote(_x15) {
2315
+ return _setSalesNote.apply(this, arguments);
2316
+ }
2317
+ return setSalesNote;
2318
+ }()
2319
+ }, {
2320
+ key: "removeSalesNote",
2321
+ value: function () {
2322
+ var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
2323
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2324
+ while (1) switch (_context17.prev = _context17.next) {
2325
+ case 0:
2326
+ if (this.store.order) {
2327
+ _context17.next = 2;
2328
+ break;
2329
+ }
2330
+ throw new Error('order 模块未初始化');
2331
+ case 2:
2332
+ _context17.next = 4;
2333
+ return this.store.order.removeSalesNote(uuid);
2334
+ case 4:
2335
+ case "end":
2336
+ return _context17.stop();
2337
+ }
2338
+ }, _callee17, this);
2339
+ }));
2340
+ function removeSalesNote(_x16) {
2341
+ return _removeSalesNote.apply(this, arguments);
2342
+ }
2343
+ return removeSalesNote;
2344
+ }()
2345
+ }, {
2346
+ key: "clearSalesNotes",
2347
+ value: function () {
2348
+ var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2349
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2350
+ while (1) switch (_context18.prev = _context18.next) {
2351
+ case 0:
2352
+ if (this.store.order) {
2353
+ _context18.next = 2;
2354
+ break;
2355
+ }
2356
+ throw new Error('order 模块未初始化');
2357
+ case 2:
2358
+ _context18.next = 4;
2359
+ return this.store.order.clearSalesNotes();
2360
+ case 4:
2361
+ case "end":
2362
+ return _context18.stop();
2363
+ }
2364
+ }, _callee18, this);
2365
+ }));
2366
+ function clearSalesNotes() {
2367
+ return _clearSalesNotes.apply(this, arguments);
2368
+ }
2369
+ return clearSalesNotes;
2370
+ }()
2092
2371
  }, {
2093
2372
  key: "updateTempOrderNote",
2094
2373
  value: function updateTempOrderNote(note) {
@@ -2127,6 +2406,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2127
2406
  if (!this.store.order) throw new Error('order 模块未初始化');
2128
2407
  return this.store.order.updateTempOrderDepositAmount(amount);
2129
2408
  }
2409
+ }, {
2410
+ key: "setPickupReferenceMode",
2411
+ value: function setPickupReferenceMode(mode) {
2412
+ if (!this.store.order) throw new Error('order 模块未初始化');
2413
+ return this.store.order.updateTempOrderPickupReferenceMode(mode);
2414
+ }
2415
+ }, {
2416
+ key: "setServiceType",
2417
+ value: function setServiceType(serviceType) {
2418
+ if (!this.store.order) throw new Error('order 模块未初始化');
2419
+ return this.store.order.updateTempOrderServiceType(serviceType);
2420
+ }
2130
2421
  }, {
2131
2422
  key: "updateTempOrderContactsInfo",
2132
2423
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -2160,40 +2451,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2160
2451
  }, {
2161
2452
  key: "addNewOrder",
2162
2453
  value: function () {
2163
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
2454
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2164
2455
  var tempOrder;
2165
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2166
- while (1) switch (_context16.prev = _context16.next) {
2456
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2457
+ while (1) switch (_context19.prev = _context19.next) {
2167
2458
  case 0:
2168
- _context16.prev = 0;
2459
+ _context19.prev = 0;
2169
2460
  if (this.store.order) {
2170
- _context16.next = 3;
2461
+ _context19.next = 3;
2171
2462
  break;
2172
2463
  }
2173
2464
  throw new Error('order 模块未初始化');
2174
2465
  case 3:
2175
- _context16.next = 5;
2466
+ _context19.next = 5;
2176
2467
  return this.store.order.addNewOrder();
2177
2468
  case 5:
2178
- tempOrder = _context16.sent;
2469
+ tempOrder = _context19.sent;
2179
2470
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2180
- _context16.next = 10;
2471
+ _context19.next = 10;
2181
2472
  break;
2182
2473
  }
2183
2474
  this.store.order.persistTempOrder();
2184
- _context16.next = 10;
2475
+ _context19.next = 10;
2185
2476
  return this.store.order.saveDraft();
2186
2477
  case 10:
2187
- return _context16.abrupt("return", tempOrder);
2478
+ return _context19.abrupt("return", tempOrder);
2188
2479
  case 13:
2189
- _context16.prev = 13;
2190
- _context16.t0 = _context16["catch"](0);
2191
- throw _context16.t0;
2480
+ _context19.prev = 13;
2481
+ _context19.t0 = _context19["catch"](0);
2482
+ throw _context19.t0;
2192
2483
  case 16:
2193
2484
  case "end":
2194
- return _context16.stop();
2485
+ return _context19.stop();
2195
2486
  }
2196
- }, _callee16, this, [[0, 13]]);
2487
+ }, _callee19, this, [[0, 13]]);
2197
2488
  }));
2198
2489
  function addNewOrder() {
2199
2490
  return _addNewOrder.apply(this, arguments);
@@ -2203,22 +2494,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2203
2494
  }, {
2204
2495
  key: "saveDraft",
2205
2496
  value: function () {
2206
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2207
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2208
- while (1) switch (_context17.prev = _context17.next) {
2497
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2498
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2499
+ while (1) switch (_context20.prev = _context20.next) {
2209
2500
  case 0:
2210
2501
  if (this.store.order) {
2211
- _context17.next = 2;
2502
+ _context20.next = 2;
2212
2503
  break;
2213
2504
  }
2214
2505
  throw new Error('order 模块未初始化');
2215
2506
  case 2:
2216
- return _context17.abrupt("return", this.store.order.saveDraft());
2507
+ return _context20.abrupt("return", this.store.order.saveDraft());
2217
2508
  case 3:
2218
2509
  case "end":
2219
- return _context17.stop();
2510
+ return _context20.stop();
2220
2511
  }
2221
- }, _callee17, this);
2512
+ }, _callee20, this);
2222
2513
  }));
2223
2514
  function saveDraft() {
2224
2515
  return _saveDraft.apply(this, arguments);
@@ -2229,14 +2520,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2229
2520
  }, {
2230
2521
  key: "restoreOrder",
2231
2522
  value: function () {
2232
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2523
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2233
2524
  var _this$store$payment, tempOrder, appDataChanged, wallet;
2234
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2235
- while (1) switch (_context18.prev = _context18.next) {
2525
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2526
+ while (1) switch (_context21.prev = _context21.next) {
2236
2527
  case 0:
2237
- _context18.prev = 0;
2528
+ _context21.prev = 0;
2238
2529
  if (this.store.order) {
2239
- _context18.next = 3;
2530
+ _context21.next = 3;
2240
2531
  break;
2241
2532
  }
2242
2533
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -2249,37 +2540,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2249
2540
  this.hasManualDiscountSelection = false;
2250
2541
  wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
2251
2542
  if (!wallet) {
2252
- _context18.next = 14;
2543
+ _context21.next = 14;
2253
2544
  break;
2254
2545
  }
2255
2546
  this.walletAssetsRefreshSequence += 1;
2256
2547
  wallet.clearAllCache();
2257
- _context18.next = 14;
2548
+ _context21.next = 14;
2258
2549
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
2259
2550
  case 14:
2260
- _context18.next = 16;
2551
+ _context21.next = 16;
2261
2552
  return this.effectsEmit('onTempOrderReplaced', {
2262
2553
  tempOrder: tempOrder
2263
2554
  });
2264
2555
  case 16:
2265
2556
  if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
2266
- _context18.next = 20;
2557
+ _context21.next = 20;
2267
2558
  break;
2268
2559
  }
2269
2560
  this.store.order.persistTempOrder();
2270
- _context18.next = 20;
2561
+ _context21.next = 20;
2271
2562
  return this.store.order.saveDraft();
2272
2563
  case 20:
2273
- return _context18.abrupt("return", tempOrder);
2564
+ return _context21.abrupt("return", tempOrder);
2274
2565
  case 23:
2275
- _context18.prev = 23;
2276
- _context18.t0 = _context18["catch"](0);
2277
- throw _context18.t0;
2566
+ _context21.prev = 23;
2567
+ _context21.t0 = _context21["catch"](0);
2568
+ throw _context21.t0;
2278
2569
  case 26:
2279
2570
  case "end":
2280
- return _context18.stop();
2571
+ return _context21.stop();
2281
2572
  }
2282
- }, _callee18, this, [[0, 23]]);
2573
+ }, _callee21, this, [[0, 23]]);
2283
2574
  }));
2284
2575
  function restoreOrder() {
2285
2576
  return _restoreOrder.apply(this, arguments);
@@ -2293,22 +2584,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2293
2584
  }, {
2294
2585
  key: "clearOrderCartLines",
2295
2586
  value: (function () {
2296
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2587
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2297
2588
  var tempOrder;
2298
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2299
- while (1) switch (_context19.prev = _context19.next) {
2589
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2590
+ while (1) switch (_context22.prev = _context22.next) {
2300
2591
  case 0:
2301
- _context19.prev = 0;
2592
+ _context22.prev = 0;
2302
2593
  if (this.store.order) {
2303
- _context19.next = 3;
2594
+ _context22.next = 3;
2304
2595
  break;
2305
2596
  }
2306
2597
  throw new Error('order 模块未初始化');
2307
2598
  case 3:
2308
- _context19.next = 5;
2599
+ _context22.next = 5;
2309
2600
  return this.store.order.clearOrderCartLines();
2310
2601
  case 5:
2311
- tempOrder = _context19.sent;
2602
+ tempOrder = _context22.sent;
2312
2603
  if (this.currentSalesDetail) {
2313
2604
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2314
2605
  products: [],
@@ -2318,34 +2609,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2318
2609
  discount_list: []
2319
2610
  });
2320
2611
  }
2321
- _context19.next = 9;
2612
+ _context22.next = 9;
2322
2613
  return this.effectsEmit('onTempOrderReplaced', {
2323
2614
  tempOrder: tempOrder
2324
2615
  });
2325
2616
  case 9:
2326
2617
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2327
- _context19.next = 13;
2618
+ _context22.next = 13;
2328
2619
  break;
2329
2620
  }
2330
2621
  this.store.order.persistTempOrder();
2331
- _context19.next = 13;
2622
+ _context22.next = 13;
2332
2623
  return this.store.order.saveDraft();
2333
2624
  case 13:
2334
- return _context19.abrupt("return", tempOrder);
2625
+ return _context22.abrupt("return", tempOrder);
2335
2626
  case 16:
2336
- _context19.prev = 16;
2337
- _context19.t0 = _context19["catch"](0);
2338
- throw _context19.t0;
2627
+ _context22.prev = 16;
2628
+ _context22.t0 = _context22["catch"](0);
2629
+ throw _context22.t0;
2339
2630
  case 19:
2340
2631
  case "end":
2341
- return _context19.stop();
2632
+ return _context22.stop();
2342
2633
  }
2343
- }, _callee19, this, [[0, 16]]);
2634
+ }, _callee22, this, [[0, 16]]);
2344
2635
  }));
2345
2636
  function clearOrderCartLines() {
2346
2637
  return _clearOrderCartLines.apply(this, arguments);
2347
2638
  }
2348
2639
  return clearOrderCartLines;
2640
+ }() /** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */)
2641
+ }, {
2642
+ key: "clearOrderForSettlementSwitch",
2643
+ value: (function () {
2644
+ var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2645
+ var tempOrder;
2646
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2647
+ while (1) switch (_context23.prev = _context23.next) {
2648
+ case 0:
2649
+ if (this.store.order) {
2650
+ _context23.next = 2;
2651
+ break;
2652
+ }
2653
+ throw new Error('order 模块未初始化');
2654
+ case 2:
2655
+ _context23.next = 4;
2656
+ return this.store.order.clearOrderForSettlementSwitch();
2657
+ case 4:
2658
+ tempOrder = _context23.sent;
2659
+ if (this.currentSalesDetail) {
2660
+ this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2661
+ products: [],
2662
+ bookings: [],
2663
+ rootBooking: null,
2664
+ bookingsByProductUid: {},
2665
+ discount_list: [],
2666
+ payments: []
2667
+ });
2668
+ }
2669
+ return _context23.abrupt("return", tempOrder);
2670
+ case 7:
2671
+ case "end":
2672
+ return _context23.stop();
2673
+ }
2674
+ }, _callee23, this);
2675
+ }));
2676
+ function clearOrderForSettlementSwitch() {
2677
+ return _clearOrderForSettlementSwitch.apply(this, arguments);
2678
+ }
2679
+ return clearOrderForSettlementSwitch;
2349
2680
  }())
2350
2681
  }, {
2351
2682
  key: "getOrderProducts",
@@ -2357,32 +2688,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2357
2688
  }, {
2358
2689
  key: "getSummary",
2359
2690
  value: function () {
2360
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2691
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2361
2692
  var summary;
2362
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2363
- while (1) switch (_context20.prev = _context20.next) {
2693
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2694
+ while (1) switch (_context24.prev = _context24.next) {
2364
2695
  case 0:
2365
- _context20.prev = 0;
2696
+ _context24.prev = 0;
2366
2697
  if (this.store.order) {
2367
- _context20.next = 3;
2698
+ _context24.next = 3;
2368
2699
  break;
2369
2700
  }
2370
2701
  throw new Error('order 模块未初始化');
2371
2702
  case 3:
2372
- _context20.next = 5;
2703
+ _context24.next = 5;
2373
2704
  return this.store.order.getOrderSummary();
2374
2705
  case 5:
2375
- summary = _context20.sent;
2376
- return _context20.abrupt("return", summary);
2706
+ summary = _context24.sent;
2707
+ return _context24.abrupt("return", summary);
2377
2708
  case 9:
2378
- _context20.prev = 9;
2379
- _context20.t0 = _context20["catch"](0);
2380
- throw _context20.t0;
2709
+ _context24.prev = 9;
2710
+ _context24.t0 = _context24["catch"](0);
2711
+ throw _context24.t0;
2381
2712
  case 12:
2382
2713
  case "end":
2383
- return _context20.stop();
2714
+ return _context24.stop();
2384
2715
  }
2385
- }, _callee20, this, [[0, 9]]);
2716
+ }, _callee24, this, [[0, 9]]);
2386
2717
  }));
2387
2718
  function getSummary() {
2388
2719
  return _getSummary.apply(this, arguments);
@@ -2510,14 +2841,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2510
2841
  }, {
2511
2842
  key: "loadDiscountConfig",
2512
2843
  value: function () {
2513
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2844
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2514
2845
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
2515
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
2516
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2517
- while (1) switch (_context21.prev = _context21.next) {
2846
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
2847
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2848
+ while (1) switch (_context25.prev = _context25.next) {
2518
2849
  case 0:
2519
2850
  if (this.store.order) {
2520
- _context21.next = 2;
2851
+ _context25.next = 2;
2521
2852
  break;
2522
2853
  }
2523
2854
  throw new Error('order 模块未初始化');
@@ -2534,48 +2865,77 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2534
2865
  return discount.isManualSelect;
2535
2866
  });
2536
2867
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
2537
- discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
2538
- preparedDiscountList = [];
2868
+ discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':'); // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
2869
+ // current 优先于 original,保留搜索后的最新选择与可用状态。
2870
+ searchedDiscountList = currentDiscountList.filter(function (discount) {
2871
+ return discount.isScan;
2872
+ });
2873
+ searchedDiscountIds = new Set(searchedDiscountList.map(function (discount) {
2874
+ return String(discount.id);
2875
+ }));
2876
+ preparedDiscountList = [].concat(_toConsumableArray(searchedDiscountList), _toConsumableArray(originalDiscountList.filter(function (discount) {
2877
+ return !searchedDiscountIds.has(String(discount.id));
2878
+ })));
2539
2879
  if (!(customerId && customerId !== 1)) {
2540
- _context21.next = 25;
2880
+ _context25.next = 27;
2541
2881
  break;
2542
2882
  }
2543
- if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
2544
- _context21.next = 19;
2883
+ if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
2884
+ _context25.next = 21;
2545
2885
  break;
2546
2886
  }
2547
2887
  preparedDiscountList = originalDiscountList;
2548
- _context21.next = 25;
2888
+ _context25.next = 27;
2549
2889
  break;
2550
- case 19:
2551
- _context21.next = 21;
2890
+ case 21:
2891
+ _context25.next = 23;
2552
2892
  return this.store.order.loadDiscountConfig({
2553
2893
  customerId: customerId,
2554
2894
  action: discountAction,
2555
2895
  orderId: Number(orderId) || undefined,
2556
2896
  apply: false
2557
2897
  });
2558
- case 21:
2559
- preparedDiscountList = _context21.sent;
2898
+ case 23:
2899
+ preparedDiscountList = _context25.sent;
2560
2900
  this.discountConfigCacheKey = discountConfigCacheKey;
2561
- _context21.next = 25;
2901
+ _context25.next = 27;
2562
2902
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2563
- case 25:
2903
+ case 27:
2904
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
2905
+ _context25.next = 35;
2906
+ break;
2907
+ }
2908
+ _context25.next = 30;
2909
+ return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
2910
+ case 30:
2911
+ _context25.next = 32;
2912
+ return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
2913
+ case 32:
2914
+ tempOrder.discount_list = [];
2915
+ tempOrder.shop_discount = '0.00';
2916
+ return _context25.abrupt("return", {
2917
+ productList: tempOrder.products || [],
2918
+ discountList: [],
2919
+ availableWalletIds: this.getAvailableWalletIds(),
2920
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2921
+ });
2922
+ case 35:
2564
2923
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
2565
- _context21.next = 27;
2924
+ _context25.next = 37;
2566
2925
  break;
2567
2926
  }
2568
- return _context21.abrupt("return", {
2927
+ return _context25.abrupt("return", {
2569
2928
  productList: tempOrder.products || [],
2570
2929
  discountList: currentDiscountList,
2571
- availableWalletIds: this.getAvailableWalletIds()
2930
+ availableWalletIds: this.getAvailableWalletIds(),
2931
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2572
2932
  });
2573
- case 27:
2933
+ case 37:
2574
2934
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
2575
2935
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2576
- _context21.next = 31;
2936
+ _context25.next = 41;
2577
2937
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2578
- case 31:
2938
+ case 41:
2579
2939
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
2580
2940
  discountAction: discountAction,
2581
2941
  products: tempOrder.products || [],
@@ -2583,32 +2943,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2583
2943
  nextDiscountList: nextDiscountList
2584
2944
  });
2585
2945
  if (!shouldSkipAutoApplyFetchedDiscounts) {
2586
- _context21.next = 40;
2946
+ _context25.next = 50;
2587
2947
  break;
2588
2948
  }
2589
- _context21.next = 35;
2949
+ _context25.next = 45;
2590
2950
  return this.store.order.recalculateSummary({
2591
2951
  createIfMissing: true
2592
2952
  });
2593
- case 35:
2594
- _summary = _context21.sent;
2953
+ case 45:
2954
+ _summary = _context25.sent;
2595
2955
  this.store.order.persistTempOrder();
2596
- _context21.next = 39;
2956
+ _context25.next = 49;
2597
2957
  return this.effectsEmit('onDiscountApplied', {
2598
2958
  productList: tempOrder.products || [],
2599
2959
  discountList: nextDiscountList,
2600
2960
  selectedDiscountList: tempOrder.discount_list || [],
2601
2961
  tempOrder: tempOrder
2602
2962
  });
2603
- case 39:
2604
- return _context21.abrupt("return", {
2963
+ case 49:
2964
+ return _context25.abrupt("return", {
2605
2965
  productList: tempOrder.products || [],
2606
2966
  discountList: nextDiscountList,
2607
- availableWalletIds: this.getAvailableWalletIds()
2967
+ availableWalletIds: this.getAvailableWalletIds(),
2968
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2608
2969
  });
2609
- case 40:
2970
+ case 50:
2610
2971
  if (!rulesModule) {
2611
- _context21.next = 76;
2972
+ _context25.next = 86;
2612
2973
  break;
2613
2974
  }
2614
2975
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
@@ -2628,22 +2989,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2628
2989
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2629
2990
  }
2630
2991
  _iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
2631
- _context21.prev = 45;
2992
+ _context25.prev = 55;
2632
2993
  _iterator3.s();
2633
- case 47:
2994
+ case 57:
2634
2995
  if ((_step3 = _iterator3.n()).done) {
2635
- _context21.next = 62;
2996
+ _context25.next = 72;
2636
2997
  break;
2637
2998
  }
2638
2999
  product = _step3.value;
2639
3000
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2640
3001
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
2641
3002
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2642
- _context21.next = 53;
3003
+ _context25.next = 63;
2643
3004
  break;
2644
3005
  }
2645
- return _context21.abrupt("continue", 60);
2646
- case 53:
3006
+ return _context25.abrupt("continue", 70);
3007
+ case 63:
2647
3008
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2648
3009
  return sum + Number(pd.amount || 0);
2649
3010
  }, 0);
@@ -2659,61 +3020,62 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2659
3020
  mainPrice: newMainSellingPrice,
2660
3021
  bundle: product.product_bundle
2661
3022
  });
2662
- case 60:
2663
- _context21.next = 47;
3023
+ case 70:
3024
+ _context25.next = 57;
2664
3025
  break;
2665
- case 62:
2666
- _context21.next = 67;
3026
+ case 72:
3027
+ _context25.next = 77;
2667
3028
  break;
2668
- case 64:
2669
- _context21.prev = 64;
2670
- _context21.t0 = _context21["catch"](45);
2671
- _iterator3.e(_context21.t0);
2672
- case 67:
2673
- _context21.prev = 67;
3029
+ case 74:
3030
+ _context25.prev = 74;
3031
+ _context25.t0 = _context25["catch"](55);
3032
+ _iterator3.e(_context25.t0);
3033
+ case 77:
3034
+ _context25.prev = 77;
2674
3035
  _iterator3.f();
2675
- return _context21.finish(67);
2676
- case 70:
3036
+ return _context25.finish(77);
3037
+ case 80:
2677
3038
  if (!result.discountList) {
2678
- _context21.next = 76;
3039
+ _context25.next = 86;
2679
3040
  break;
2680
3041
  }
2681
3042
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2682
3043
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2683
- _context21.next = 75;
3044
+ _context25.next = 85;
2684
3045
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2685
- case 75:
3046
+ case 85:
2686
3047
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2687
3048
  return discount.isSelected;
2688
3049
  });
2689
- case 76:
2690
- _context21.next = 78;
3050
+ case 86:
3051
+ _context25.next = 88;
2691
3052
  return this.store.order.recalculateSummary({
2692
3053
  createIfMissing: true
2693
3054
  });
2694
- case 78:
2695
- summary = _context21.sent;
3055
+ case 88:
3056
+ summary = _context25.sent;
2696
3057
  this.store.order.persistTempOrder();
2697
- _context21.next = 82;
3058
+ _context25.next = 92;
2698
3059
  return this.effectsEmit('onDiscountApplied', {
2699
3060
  productList: tempOrder.products || [],
2700
3061
  discountList: nextDiscountList,
2701
3062
  selectedDiscountList: tempOrder.discount_list || [],
2702
3063
  tempOrder: tempOrder
2703
3064
  });
2704
- case 82:
2705
- return _context21.abrupt("return", {
3065
+ case 92:
3066
+ return _context25.abrupt("return", {
2706
3067
  productList: tempOrder.products || [],
2707
3068
  discountList: nextDiscountList,
2708
- availableWalletIds: this.getAvailableWalletIds()
3069
+ availableWalletIds: this.getAvailableWalletIds(),
3070
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2709
3071
  });
2710
- case 83:
3072
+ case 93:
2711
3073
  case "end":
2712
- return _context21.stop();
3074
+ return _context25.stop();
2713
3075
  }
2714
- }, _callee21, this, [[45, 64, 67, 70]]);
3076
+ }, _callee25, this, [[55, 74, 77, 80]]);
2715
3077
  }));
2716
- function loadDiscountConfig(_x15) {
3078
+ function loadDiscountConfig(_x17) {
2717
3079
  return _loadDiscountConfig.apply(this, arguments);
2718
3080
  }
2719
3081
  return loadDiscountConfig;
@@ -2725,22 +3087,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2725
3087
  if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2726
3088
  return this.store.order.getAvailableWalletIds();
2727
3089
  }
3090
+ }, {
3091
+ key: "getVirtualCurrencyList",
3092
+ value: function getVirtualCurrencyList() {
3093
+ var _this$store$order5;
3094
+ if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && _this$store$order5.getVirtualCurrencyList)) return [];
3095
+ return this.store.order.getVirtualCurrencyList();
3096
+ }
2728
3097
  }, {
2729
3098
  key: "bestDiscount",
2730
3099
  value: function () {
2731
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cb) {
3100
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(cb) {
2732
3101
  var _discountModule$getOr2, _discountModule$getDi3;
2733
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2734
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2735
- while (1) switch (_context22.prev = _context22.next) {
3102
+ var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
3103
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3104
+ while (1) switch (_context26.prev = _context26.next) {
2736
3105
  case 0:
2737
3106
  if (this.store.order) {
2738
- _context22.next = 2;
3107
+ _context26.next = 2;
2739
3108
  break;
2740
3109
  }
2741
3110
  throw new Error('order 模块未初始化');
2742
3111
  case 2:
2743
3112
  tempOrder = this.store.order.ensureTempOrder();
3113
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
3114
+ _context26.next = 7;
3115
+ break;
3116
+ }
3117
+ _result2 = {
3118
+ productList: tempOrder.products || [],
3119
+ discountList: []
3120
+ };
3121
+ cb === null || cb === void 0 || cb(_result2);
3122
+ return _context26.abrupt("return", _result2);
3123
+ case 7:
2744
3124
  orderStore = this.store.order.store || {};
2745
3125
  discountModule = orderStore.discount;
2746
3126
  rulesModule = orderStore.rules;
@@ -2751,11 +3131,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2751
3131
  productList: tempOrder.products || [],
2752
3132
  discountList: nextDiscountList
2753
3133
  };
2754
- _context22.next = 12;
3134
+ _context26.next = 16;
2755
3135
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2756
- case 12:
3136
+ case 16:
2757
3137
  if (!rulesModule) {
2758
- _context22.next = 23;
3138
+ _context26.next = 27;
2759
3139
  break;
2760
3140
  }
2761
3141
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -2772,14 +3152,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2772
3152
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2773
3153
  }
2774
3154
  if (!result.discountList) {
2775
- _context22.next = 23;
3155
+ _context26.next = 27;
2776
3156
  break;
2777
3157
  }
2778
3158
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2779
3159
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2780
- _context22.next = 21;
3160
+ _context26.next = 25;
2781
3161
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2782
- case 21:
3162
+ case 25:
2783
3163
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2784
3164
  return discount.isSelected;
2785
3165
  });
@@ -2787,30 +3167,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2787
3167
  productList: tempOrder.products,
2788
3168
  discountList: nextDiscountList
2789
3169
  };
2790
- case 23:
2791
- _context22.next = 25;
3170
+ case 27:
3171
+ _context26.next = 29;
2792
3172
  return this.store.order.recalculateSummary({
2793
3173
  createIfMissing: true
2794
3174
  });
2795
- case 25:
3175
+ case 29:
2796
3176
  this.store.order.persistTempOrder();
2797
- _context22.next = 28;
3177
+ _context26.next = 32;
2798
3178
  return this.effectsEmit('onDiscountApplied', {
2799
3179
  productList: tempOrder.products || [],
2800
3180
  discountList: nextDiscountList,
2801
3181
  selectedDiscountList: tempOrder.discount_list || [],
2802
3182
  tempOrder: tempOrder
2803
3183
  });
2804
- case 28:
3184
+ case 32:
2805
3185
  cb === null || cb === void 0 || cb(result);
2806
- return _context22.abrupt("return", result);
2807
- case 30:
3186
+ return _context26.abrupt("return", result);
3187
+ case 34:
2808
3188
  case "end":
2809
- return _context22.stop();
3189
+ return _context26.stop();
2810
3190
  }
2811
- }, _callee22, this);
3191
+ }, _callee26, this);
2812
3192
  }));
2813
- function bestDiscount(_x16) {
3193
+ function bestDiscount(_x18) {
2814
3194
  return _bestDiscount.apply(this, arguments);
2815
3195
  }
2816
3196
  return bestDiscount;
@@ -2839,41 +3219,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2839
3219
  }, {
2840
3220
  key: "replaceDiscountStoreLists",
2841
3221
  value: (function () {
2842
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
3222
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2843
3223
  var _store2;
2844
3224
  var discountModule;
2845
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2846
- while (1) switch (_context23.prev = _context23.next) {
3225
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3226
+ while (1) switch (_context27.prev = _context27.next) {
2847
3227
  case 0:
2848
3228
  if (this.store.order) {
2849
- _context23.next = 2;
3229
+ _context27.next = 2;
2850
3230
  break;
2851
3231
  }
2852
3232
  throw new Error('order 模块未初始化');
2853
3233
  case 2:
2854
3234
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2855
3235
  if (discountModule) {
2856
- _context23.next = 5;
3236
+ _context27.next = 5;
2857
3237
  break;
2858
3238
  }
2859
- return _context23.abrupt("return");
3239
+ return _context27.abrupt("return");
2860
3240
  case 5:
2861
3241
  if (!params.originalDiscountList) {
2862
- _context23.next = 8;
3242
+ _context27.next = 8;
2863
3243
  break;
2864
3244
  }
2865
- _context23.next = 8;
3245
+ _context27.next = 8;
2866
3246
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
2867
3247
  case 8:
2868
- _context23.next = 10;
3248
+ _context27.next = 10;
2869
3249
  return discountModule.setDiscountList(params.discountList);
2870
3250
  case 10:
2871
3251
  case "end":
2872
- return _context23.stop();
3252
+ return _context27.stop();
2873
3253
  }
2874
- }, _callee23, this);
3254
+ }, _callee27, this);
2875
3255
  }));
2876
- function replaceDiscountStoreLists(_x17) {
3256
+ function replaceDiscountStoreLists(_x19) {
2877
3257
  return _replaceDiscountStoreLists.apply(this, arguments);
2878
3258
  }
2879
3259
  return replaceDiscountStoreLists;
@@ -2881,34 +3261,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2881
3261
  }, {
2882
3262
  key: "scanPromotionCode",
2883
3263
  value: function () {
2884
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(code, customerId) {
3264
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, customerId) {
2885
3265
  var raw, tempOrder;
2886
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2887
- while (1) switch (_context24.prev = _context24.next) {
3266
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3267
+ while (1) switch (_context28.prev = _context28.next) {
2888
3268
  case 0:
2889
- _context24.prev = 0;
3269
+ _context28.prev = 0;
2890
3270
  if (this.store.order) {
2891
- _context24.next = 3;
3271
+ _context28.next = 3;
2892
3272
  break;
2893
3273
  }
2894
3274
  throw new Error('order 模块未初始化');
2895
3275
  case 3:
2896
- _context24.next = 5;
3276
+ _context28.next = 5;
2897
3277
  return this.store.order.scanCode(code, customerId);
2898
3278
  case 5:
2899
- raw = _context24.sent;
3279
+ raw = _context28.sent;
2900
3280
  if (!raw.isAvailable) {
2901
- _context24.next = 13;
3281
+ _context28.next = 13;
2902
3282
  break;
2903
3283
  }
2904
- _context24.next = 9;
3284
+ _context28.next = 9;
2905
3285
  return this.store.order.recalculateSummary({
2906
3286
  createIfMissing: true
2907
3287
  });
2908
3288
  case 9:
2909
3289
  this.store.order.persistTempOrder();
2910
3290
  tempOrder = this.store.order.ensureTempOrder();
2911
- _context24.next = 13;
3291
+ _context28.next = 13;
2912
3292
  return this.effectsEmit('onDiscountApplied', {
2913
3293
  productList: tempOrder.products || [],
2914
3294
  discountList: this.store.order.getDiscountList(),
@@ -2916,7 +3296,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2916
3296
  tempOrder: tempOrder
2917
3297
  });
2918
3298
  case 13:
2919
- return _context24.abrupt("return", _objectSpread(_objectSpread({
3299
+ return _context28.abrupt("return", _objectSpread(_objectSpread({
2920
3300
  isAvailable: raw.isAvailable
2921
3301
  }, raw.isAccepted !== undefined ? {
2922
3302
  isAccepted: raw.isAccepted
@@ -2926,16 +3306,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2926
3306
  scannedDiscountList: raw.scannedDiscountList
2927
3307
  }));
2928
3308
  case 16:
2929
- _context24.prev = 16;
2930
- _context24.t0 = _context24["catch"](0);
2931
- throw _context24.t0;
3309
+ _context28.prev = 16;
3310
+ _context28.t0 = _context28["catch"](0);
3311
+ throw _context28.t0;
2932
3312
  case 19:
2933
3313
  case "end":
2934
- return _context24.stop();
3314
+ return _context28.stop();
2935
3315
  }
2936
- }, _callee24, this, [[0, 16]]);
3316
+ }, _callee28, this, [[0, 16]]);
2937
3317
  }));
2938
- function scanPromotionCode(_x18, _x19) {
3318
+ function scanPromotionCode(_x20, _x21) {
2939
3319
  return _scanPromotionCode.apply(this, arguments);
2940
3320
  }
2941
3321
  return scanPromotionCode;
@@ -2943,18 +3323,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2943
3323
  }, {
2944
3324
  key: "setDiscountSelected",
2945
3325
  value: function () {
2946
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2947
- var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2948
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2949
- while (1) switch (_context25.prev = _context25.next) {
3326
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3327
+ var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3328
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3329
+ while (1) switch (_context29.prev = _context29.next) {
2950
3330
  case 0:
2951
- _context25.prev = 0;
3331
+ _context29.prev = 0;
2952
3332
  if (this.store.order) {
2953
- _context25.next = 3;
3333
+ _context29.next = 3;
2954
3334
  break;
2955
3335
  }
2956
3336
  throw new Error('order 模块未初始化');
2957
3337
  case 3:
3338
+ currentOrder = this.store.order.ensureTempOrder();
3339
+ if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
3340
+ _context29.next = 13;
3341
+ break;
3342
+ }
3343
+ currentOrder.discount_list = [];
3344
+ currentOrder.shop_discount = '0.00';
3345
+ _context29.next = 9;
3346
+ return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
3347
+ case 9:
3348
+ _context29.next = 11;
3349
+ return this.store.order.recalculateSummary({
3350
+ createIfMissing: true
3351
+ });
3352
+ case 11:
3353
+ this.store.order.persistTempOrder();
3354
+ return _context29.abrupt("return");
3355
+ case 13:
2958
3356
  list = this.store.order.getDiscountList();
2959
3357
  updated = list.map(function (d) {
2960
3358
  return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
@@ -2968,9 +3366,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2968
3366
  discountModule = orderStore.discount;
2969
3367
  rulesModule = orderStore.rules;
2970
3368
  nextDiscountList = updated;
2971
- _context25.next = 13;
3369
+ _context29.next = 23;
2972
3370
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2973
- case 13:
3371
+ case 23:
2974
3372
  if (rulesModule) {
2975
3373
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
2976
3374
  result = rulesModule.calcDiscount({
@@ -3030,29 +3428,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3030
3428
  });
3031
3429
  };
3032
3430
  _iterator5 = _createForOfIteratorHelper(tempOrder.products);
3033
- _context25.prev = 17;
3431
+ _context29.prev = 27;
3034
3432
  _iterator5.s();
3035
- case 19:
3433
+ case 29:
3036
3434
  if ((_step5 = _iterator5.n()).done) {
3037
- _context25.next = 36;
3435
+ _context29.next = 46;
3038
3436
  break;
3039
3437
  }
3040
3438
  product = _step5.value;
3041
3439
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
3042
3440
  runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
3043
3441
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3044
- _context25.next = 25;
3442
+ _context29.next = 35;
3045
3443
  break;
3046
3444
  }
3047
- return _context25.abrupt("continue", 34);
3048
- case 25:
3445
+ return _context29.abrupt("continue", 44);
3446
+ case 35:
3049
3447
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
3050
3448
  if (Array.isArray(product.product_bundle)) {
3051
3449
  product.product_bundle = product.product_bundle.map(function (bundle) {
3052
- var _ref35, _bundle$original_pric;
3450
+ var _ref42, _bundle$original_pric;
3053
3451
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
3054
3452
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
3055
- var restoredBundlePrice = (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
3453
+ var restoredBundlePrice = (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
3056
3454
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
3057
3455
  price: restoredBundlePrice,
3058
3456
  bundle_selling_price: restoredBundlePrice
@@ -3079,33 +3477,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3079
3477
  mainPrice: newMainSellingPrice,
3080
3478
  bundle: product.product_bundle
3081
3479
  });
3082
- case 34:
3083
- _context25.next = 19;
3480
+ case 44:
3481
+ _context29.next = 29;
3084
3482
  break;
3085
- case 36:
3086
- _context25.next = 41;
3483
+ case 46:
3484
+ _context29.next = 51;
3087
3485
  break;
3088
- case 38:
3089
- _context25.prev = 38;
3090
- _context25.t0 = _context25["catch"](17);
3091
- _iterator5.e(_context25.t0);
3092
- case 41:
3093
- _context25.prev = 41;
3486
+ case 48:
3487
+ _context29.prev = 48;
3488
+ _context29.t0 = _context29["catch"](27);
3489
+ _iterator5.e(_context29.t0);
3490
+ case 51:
3491
+ _context29.prev = 51;
3094
3492
  _iterator5.f();
3095
- return _context25.finish(41);
3096
- case 44:
3493
+ return _context29.finish(51);
3494
+ case 54:
3097
3495
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3098
- _context25.next = 47;
3496
+ _context29.next = 57;
3099
3497
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3100
- case 47:
3498
+ case 57:
3101
3499
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
3102
3500
  return d.isSelected;
3103
3501
  });
3104
- _context25.next = 50;
3502
+ _context29.next = 60;
3105
3503
  return this.store.order.recalculateSummary({
3106
3504
  createIfMissing: true
3107
3505
  });
3108
- case 50:
3506
+ case 60:
3109
3507
  this.store.order.persistTempOrder();
3110
3508
  this.effectsEmit('onDiscountApplied', {
3111
3509
  productList: tempOrder.products,
@@ -3113,19 +3511,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3113
3511
  selectedDiscountList: tempOrder.discount_list,
3114
3512
  tempOrder: tempOrder
3115
3513
  });
3116
- _context25.next = 57;
3514
+ _context29.next = 67;
3117
3515
  break;
3118
- case 54:
3119
- _context25.prev = 54;
3120
- _context25.t1 = _context25["catch"](0);
3121
- throw _context25.t1;
3122
- case 57:
3516
+ case 64:
3517
+ _context29.prev = 64;
3518
+ _context29.t1 = _context29["catch"](0);
3519
+ throw _context29.t1;
3520
+ case 67:
3123
3521
  case "end":
3124
- return _context25.stop();
3522
+ return _context29.stop();
3125
3523
  }
3126
- }, _callee25, this, [[0, 54], [17, 38, 41, 44]]);
3524
+ }, _callee29, this, [[0, 64], [27, 48, 51, 54]]);
3127
3525
  }));
3128
- function setDiscountSelected(_x20) {
3526
+ function setDiscountSelected(_x22) {
3129
3527
  return _setDiscountSelected.apply(this, arguments);
3130
3528
  }
3131
3529
  return setDiscountSelected;
@@ -3133,23 +3531,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3133
3531
  }, {
3134
3532
  key: "applyDiscountCalculationResult",
3135
3533
  value: function () {
3136
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(result) {
3534
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(result) {
3137
3535
  var tempOrder, orderStore, discountModule;
3138
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3139
- while (1) switch (_context26.prev = _context26.next) {
3536
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3537
+ while (1) switch (_context30.prev = _context30.next) {
3140
3538
  case 0:
3141
- _context26.prev = 0;
3539
+ _context30.prev = 0;
3142
3540
  if (this.store.order) {
3143
- _context26.next = 3;
3541
+ _context30.next = 3;
3144
3542
  break;
3145
3543
  }
3146
3544
  throw new Error('order 模块未初始化');
3147
3545
  case 3:
3148
3546
  if (result) {
3149
- _context26.next = 5;
3547
+ _context30.next = 5;
3150
3548
  break;
3151
3549
  }
3152
- return _context26.abrupt("return");
3550
+ return _context30.abrupt("return");
3153
3551
  case 5:
3154
3552
  tempOrder = this.store.order.ensureTempOrder();
3155
3553
  orderStore = this.store.order.store || {};
@@ -3158,24 +3556,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3158
3556
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3159
3557
  }
3160
3558
  if (!result.discountList) {
3161
- _context26.next = 14;
3559
+ _context30.next = 14;
3162
3560
  break;
3163
3561
  }
3164
3562
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
3165
- _context26.next = 13;
3563
+ _context30.next = 13;
3166
3564
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
3167
3565
  case 13:
3168
3566
  tempOrder.discount_list = result.discountList.filter(function (discount) {
3169
3567
  return discount.isSelected;
3170
3568
  });
3171
3569
  case 14:
3172
- _context26.next = 16;
3570
+ _context30.next = 16;
3173
3571
  return this.store.order.recalculateSummary({
3174
3572
  createIfMissing: true
3175
3573
  });
3176
3574
  case 16:
3177
3575
  this.store.order.persistTempOrder();
3178
- _context26.next = 19;
3576
+ _context30.next = 19;
3179
3577
  return this.effectsEmit('onDiscountApplied', {
3180
3578
  productList: tempOrder.products || [],
3181
3579
  discountList: result.discountList || [],
@@ -3183,19 +3581,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3183
3581
  tempOrder: tempOrder
3184
3582
  });
3185
3583
  case 19:
3186
- _context26.next = 24;
3584
+ _context30.next = 24;
3187
3585
  break;
3188
3586
  case 21:
3189
- _context26.prev = 21;
3190
- _context26.t0 = _context26["catch"](0);
3191
- throw _context26.t0;
3587
+ _context30.prev = 21;
3588
+ _context30.t0 = _context30["catch"](0);
3589
+ throw _context30.t0;
3192
3590
  case 24:
3193
3591
  case "end":
3194
- return _context26.stop();
3592
+ return _context30.stop();
3195
3593
  }
3196
- }, _callee26, this, [[0, 21]]);
3594
+ }, _callee30, this, [[0, 21]]);
3197
3595
  }));
3198
- function applyDiscountCalculationResult(_x21) {
3596
+ function applyDiscountCalculationResult(_x23) {
3199
3597
  return _applyDiscountCalculationResult.apply(this, arguments);
3200
3598
  }
3201
3599
  return applyDiscountCalculationResult;
@@ -3203,22 +3601,178 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3203
3601
  }, {
3204
3602
  key: "submitScanOrder",
3205
3603
  value: function () {
3206
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3207
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3208
- while (1) switch (_context27.prev = _context27.next) {
3604
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3605
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3606
+ while (1) switch (_context31.prev = _context31.next) {
3209
3607
  case 0:
3210
- return _context27.abrupt("return", this.submitSalesOrder(params));
3608
+ return _context31.abrupt("return", this.submitSalesOrder(params));
3211
3609
  case 1:
3212
3610
  case "end":
3213
- return _context27.stop();
3611
+ return _context31.stop();
3214
3612
  }
3215
- }, _callee27, this);
3613
+ }, _callee31, this);
3216
3614
  }));
3217
- function submitScanOrder(_x22) {
3615
+ function submitScanOrder(_x24) {
3218
3616
  return _submitScanOrder.apply(this, arguments);
3219
3617
  }
3220
3618
  return submitScanOrder;
3221
3619
  }()
3620
+ }, {
3621
+ key: "buildVirtualSettlementSubmitData",
3622
+ value: function () {
3623
+ var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
3624
+ var _tempOrder$metadata$c, _tempOrder$metadata2;
3625
+ var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
3626
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3627
+ while (1) switch (_context32.prev = _context32.next) {
3628
+ case 0:
3629
+ if (this.store.order) {
3630
+ _context32.next = 2;
3631
+ break;
3632
+ }
3633
+ return _context32.abrupt("return", null);
3634
+ case 2:
3635
+ tempOrder = this.store.order.getTempOrder();
3636
+ if (this.isActiveVirtualSettlementOrder(tempOrder)) {
3637
+ _context32.next = 5;
3638
+ break;
3639
+ }
3640
+ return _context32.abrupt("return", null);
3641
+ case 5:
3642
+ snapshot = getTempOrderSettlementSnapshot(tempOrder);
3643
+ currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
3644
+ if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
3645
+ _context32.next = 9;
3646
+ break;
3647
+ }
3648
+ throw new Error('Virtual currency settlement configuration is invalid.');
3649
+ case 9:
3650
+ _context32.next = 11;
3651
+ return this.store.order.recalculateSummary({
3652
+ createIfMissing: true
3653
+ });
3654
+ case 11:
3655
+ summary = _context32.sent;
3656
+ amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
3657
+ customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
3658
+ if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
3659
+ _context32.next = 17;
3660
+ break;
3661
+ }
3662
+ _context32.next = 17;
3663
+ return this.store.order.loadDiscountConfig({
3664
+ customerId: customerId,
3665
+ action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
3666
+ orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
3667
+ apply: false
3668
+ });
3669
+ case 17:
3670
+ asset = this.store.order.getVirtualCurrencyList().find(function (item) {
3671
+ return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
3672
+ });
3673
+ currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
3674
+ currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
3675
+ currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
3676
+ if (!amount.lte(0)) {
3677
+ _context32.next = 23;
3678
+ break;
3679
+ }
3680
+ return _context32.abrupt("return", {
3681
+ payments: [],
3682
+ snapshot: snapshot,
3683
+ currencyProductId: currencyProductId,
3684
+ currencyCode: currencyCode,
3685
+ currencySymbol: currencySymbol,
3686
+ currencyFormat: currencyFormat
3687
+ });
3688
+ case 23:
3689
+ if (asset) {
3690
+ _context32.next = 25;
3691
+ break;
3692
+ }
3693
+ throw new Error('No matching virtual currency card is available.');
3694
+ case 25:
3695
+ balance = new Decimal(asset.balance || 0);
3696
+ if (!balance.lt(amount)) {
3697
+ _context32.next = 28;
3698
+ break;
3699
+ }
3700
+ throw new Error('Insufficient virtual currency balance.');
3701
+ case 28:
3702
+ amountText = amount.toFixed(2);
3703
+ paymentNumber = "LOCAL_".concat(createUuidV4());
3704
+ if (!this.store.order.isOnlineStorePlatform()) {
3705
+ _context32.next = 34;
3706
+ break;
3707
+ }
3708
+ payment = {
3709
+ payment_number: paymentNumber,
3710
+ amount: amount.toNumber(),
3711
+ metadata: {
3712
+ unique_payment_number: createUuidV4()
3713
+ },
3714
+ tag: asset.tag,
3715
+ voucher_id: asset.id,
3716
+ wallet_pass_usage_unit: {
3717
+ price: 1,
3718
+ points: 1
3719
+ },
3720
+ wallet_pass_use_value: amountText
3721
+ };
3722
+ _context32.next = 41;
3723
+ break;
3724
+ case 34:
3725
+ _context32.next = 36;
3726
+ return this.getPaymentMethodsAsync();
3727
+ case 36:
3728
+ paymentMethods = _context32.sent;
3729
+ paymentMethod = paymentMethods.find(function (method) {
3730
+ return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
3731
+ });
3732
+ if (paymentMethod) {
3733
+ _context32.next = 40;
3734
+ break;
3735
+ }
3736
+ throw new Error('PRODUCTVOUCHER payment method is unavailable.');
3737
+ case 40:
3738
+ payment = {
3739
+ payment_number: paymentNumber,
3740
+ amount: amountText,
3741
+ origin_amount: amountText,
3742
+ code: paymentMethod.code,
3743
+ custom_payment_id: paymentMethod.id,
3744
+ custom_payment_type: (_paymentMethod$custom = paymentMethod.custom_payment_type) !== null && _paymentMethod$custom !== void 0 ? _paymentMethod$custom : paymentMethod.type,
3745
+ name: paymentMethod.name,
3746
+ type: 'normal',
3747
+ voucher_id: asset.id,
3748
+ order_payment_type: 'normal',
3749
+ wallet_pass_usage_unit: {
3750
+ price: 1,
3751
+ points: 1
3752
+ },
3753
+ wallet_pass_use_value: amountText,
3754
+ metadata: {}
3755
+ };
3756
+ case 41:
3757
+ return _context32.abrupt("return", {
3758
+ payments: [payment],
3759
+ snapshot: snapshot,
3760
+ currencyProductId: currencyProductId,
3761
+ currencyCode: currencyCode,
3762
+ currencySymbol: currencySymbol,
3763
+ currencyFormat: currencyFormat
3764
+ });
3765
+ case 42:
3766
+ case "end":
3767
+ return _context32.stop();
3768
+ }
3769
+ }, _callee32, this);
3770
+ }));
3771
+ function buildVirtualSettlementSubmitData() {
3772
+ return _buildVirtualSettlementSubmitData.apply(this, arguments);
3773
+ }
3774
+ return buildVirtualSettlementSubmitData;
3775
+ }()
3222
3776
  /**
3223
3777
  * 提交当前 Sales 订单。
3224
3778
  *
@@ -3228,48 +3782,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3228
3782
  }, {
3229
3783
  key: "submitSalesOrder",
3230
3784
  value: (function () {
3231
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3232
- var _params$smallTicketDa, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
3233
- var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
3234
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3235
- while (1) switch (_context28.prev = _context28.next) {
3785
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
3786
+ var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
3787
+ var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, _enhancePayload, submitParams;
3788
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3789
+ while (1) switch (_context33.prev = _context33.next) {
3236
3790
  case 0:
3237
3791
  if (this.store.order) {
3238
- _context28.next = 2;
3792
+ _context33.next = 2;
3239
3793
  break;
3240
3794
  }
3241
3795
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3242
3796
  case 2:
3797
+ _context33.next = 4;
3798
+ return this.buildVirtualSettlementSubmitData();
3799
+ case 4:
3800
+ virtualSettlement = _context33.sent;
3243
3801
  // this.store.order.persistTempOrder();
3244
3802
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
3245
3803
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
3246
- enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params === null || params === void 0 ? void 0 : params.enhancePayload);
3804
+ _enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
3247
3805
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
3248
3806
  cacheId: this.cacheId,
3249
- platform: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.platform,
3250
- businessCode: ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode) || ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.business_code),
3807
+ platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
3808
+ businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
3251
3809
  channel: this.getSubmitOrderSalesChannel(),
3252
- type: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.type,
3810
+ type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type,
3253
3811
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
3254
- }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
3812
+ }, virtualSettlement ? {
3813
+ payments: virtualSettlement.payments
3814
+ } : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
3255
3815
  payments: params.payments
3256
3816
  } : {}), inferredPaymentStatus !== undefined ? {
3257
3817
  paymentStatus: inferredPaymentStatus
3258
3818
  } : {}), smallTicketDataFlag !== undefined ? {
3259
3819
  smallTicketDataFlag: smallTicketDataFlag
3260
- } : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
3820
+ } : {}), virtualSettlement ? {
3821
+ confirmPendingVoucherPayments: false
3822
+ } : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
3261
3823
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
3262
- } : {}), enhancePayload !== undefined ? {
3263
- enhancePayload: enhancePayload
3824
+ } : {}), virtualSettlement ? {
3825
+ enhancePayload: function enhancePayload(payload, ctx) {
3826
+ var _callerPayload$metada, _currencySettlementCo;
3827
+ var callerPayload = _enhancePayload ? _enhancePayload(payload, ctx) : payload;
3828
+ var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
3829
+ return _objectSpread(_objectSpread({}, callerPayload), {}, {
3830
+ metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
3831
+ currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
3832
+ settlement_type: 'virtual_currency',
3833
+ settlement_ids: [virtualSettlement.currencyProductId],
3834
+ currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
3835
+ })
3836
+ }),
3837
+ currency_code: virtualSettlement.currencyCode,
3838
+ currency_symbol: virtualSettlement.currencySymbol,
3839
+ currency_format: virtualSettlement.currencyFormat
3840
+ });
3841
+ }
3842
+ } : _enhancePayload !== undefined ? {
3843
+ enhancePayload: _enhancePayload
3264
3844
  } : {});
3265
- return _context28.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
3266
- case 7:
3845
+ return _context33.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
3846
+ case 10:
3267
3847
  case "end":
3268
- return _context28.stop();
3848
+ return _context33.stop();
3269
3849
  }
3270
- }, _callee28, this);
3850
+ }, _callee33, this);
3271
3851
  }));
3272
- function submitSalesOrder(_x23) {
3852
+ function submitSalesOrder(_x25) {
3273
3853
  return _submitSalesOrder.apply(this, arguments);
3274
3854
  }
3275
3855
  return submitSalesOrder;
@@ -3277,33 +3857,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3277
3857
  }, {
3278
3858
  key: "saveSalesOrderDraft",
3279
3859
  value: function () {
3280
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3281
- var _params$platform, _this$otherParams17, _this$otherParams18, _this$otherParams19, _params$channel, _params$type, _this$otherParams20;
3282
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3283
- while (1) switch (_context29.prev = _context29.next) {
3860
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3861
+ var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
3862
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3863
+ while (1) switch (_context34.prev = _context34.next) {
3284
3864
  case 0:
3285
3865
  if (this.store.order) {
3286
- _context29.next = 2;
3866
+ _context34.next = 2;
3287
3867
  break;
3288
3868
  }
3289
3869
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3290
3870
  case 2:
3291
- return _context29.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
3871
+ return _context34.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
3292
3872
  cacheId: this.cacheId,
3293
- platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform,
3294
- businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code),
3873
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
3874
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
3295
3875
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
3296
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.type
3876
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
3297
3877
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
3298
3878
  enhancePayload: params.enhancePayload
3299
3879
  } : {})));
3300
3880
  case 3:
3301
3881
  case "end":
3302
- return _context29.stop();
3882
+ return _context34.stop();
3303
3883
  }
3304
- }, _callee29, this);
3884
+ }, _callee34, this);
3305
3885
  }));
3306
- function saveSalesOrderDraft(_x24) {
3886
+ function saveSalesOrderDraft(_x26) {
3307
3887
  return _saveSalesOrderDraft.apply(this, arguments);
3308
3888
  }
3309
3889
  return saveSalesOrderDraft;
@@ -3311,27 +3891,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3311
3891
  }, {
3312
3892
  key: "submitTempOrderAsync",
3313
3893
  value: function () {
3314
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3315
- var _params$smallTicketDa2, _this$otherParams21, _this$otherParams22, _this$otherParams23, _this$otherParams24;
3894
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3895
+ var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
3316
3896
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
3317
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3318
- while (1) switch (_context30.prev = _context30.next) {
3897
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3898
+ while (1) switch (_context35.prev = _context35.next) {
3319
3899
  case 0:
3320
3900
  if (this.store.order) {
3321
- _context30.next = 2;
3901
+ _context35.next = 2;
3322
3902
  break;
3323
3903
  }
3324
3904
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3325
3905
  case 2:
3326
3906
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
3327
3907
  smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
3328
- enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params === null || params === void 0 ? void 0 : params.enhancePayload);
3908
+ enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
3329
3909
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
3330
3910
  cacheId: this.cacheId,
3331
- platform: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform,
3332
- businessCode: ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) || ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code),
3911
+ platform: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform,
3912
+ businessCode: ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) || ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code),
3333
3913
  channel: this.getSubmitOrderSalesChannel(),
3334
- type: (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.type,
3914
+ type: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.type,
3335
3915
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
3336
3916
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
3337
3917
  payments: params.payments
@@ -3344,14 +3924,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3344
3924
  } : {}), enhancePayload !== undefined ? {
3345
3925
  enhancePayload: enhancePayload
3346
3926
  } : {});
3347
- return _context30.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3927
+ return _context35.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3348
3928
  case 7:
3349
3929
  case "end":
3350
- return _context30.stop();
3930
+ return _context35.stop();
3351
3931
  }
3352
- }, _callee30, this);
3932
+ }, _callee35, this);
3353
3933
  }));
3354
- function submitTempOrderAsync(_x25) {
3934
+ function submitTempOrderAsync(_x27) {
3355
3935
  return _submitTempOrderAsync.apply(this, arguments);
3356
3936
  }
3357
3937
  return submitTempOrderAsync;
@@ -3363,8 +3943,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3363
3943
  }, {
3364
3944
  key: "shouldUseCheckoutSyncTask",
3365
3945
  value: function shouldUseCheckoutSyncTask() {
3366
- var _this$otherParams25;
3367
- var configured = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.checkoutSyncTaskEnabled;
3946
+ var _this$otherParams26;
3947
+ var configured = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.checkoutSyncTaskEnabled;
3368
3948
  return typeof configured === 'boolean' ? configured : true;
3369
3949
  }
3370
3950
 
@@ -3377,14 +3957,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3377
3957
  }, {
3378
3958
  key: "printLocalOrderReceipt",
3379
3959
  value: function () {
3380
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(lookup) {
3381
- var _this$otherParams26, _this$otherParams27, _this$otherParams28, _this$otherParams29;
3382
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
3383
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3384
- while (1) switch (_context31.prev = _context31.next) {
3960
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(lookup) {
3961
+ var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
3962
+ var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order6, _data;
3963
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3964
+ while (1) switch (_context36.prev = _context36.next) {
3385
3965
  case 0:
3386
3966
  if (this.store.order) {
3387
- _context31.next = 2;
3967
+ _context36.next = 2;
3388
3968
  break;
3389
3969
  }
3390
3970
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -3396,10 +3976,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3396
3976
  external_sale_number: lookup
3397
3977
  };
3398
3978
  context = {
3399
- platform: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform,
3400
- businessCode: ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.businessCode) || ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.business_code),
3979
+ platform: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform,
3980
+ businessCode: ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) || ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.business_code),
3401
3981
  channel: this.getSubmitOrderSalesChannel(),
3402
- type: (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.type
3982
+ type: (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.type
3403
3983
  };
3404
3984
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
3405
3985
  lookup_order_from_db: 1,
@@ -3415,28 +3995,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3415
3995
  channel: context.channel,
3416
3996
  type: context.type
3417
3997
  });
3418
- _context31.next = 8;
3419
- return this.request.post('/local/print-order', payload, {
3998
+ invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
3999
+ invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
4000
+ printPayload = _objectSpread(_objectSpread(_objectSpread({}, payload), invoiceLayoutConfig ? {
4001
+ invoice: cloneDeep(invoiceLayoutConfig)
4002
+ } : {}), invoiceTemplateSettings ? {
4003
+ template_settings: cloneDeep(invoiceTemplateSettings)
4004
+ } : {});
4005
+ _context36.next = 11;
4006
+ return this.request.post('/local/print-order', printPayload, {
3420
4007
  osServer: true,
3421
4008
  customToast: function customToast() {}
3422
4009
  });
3423
- case 8:
3424
- response = _context31.sent;
4010
+ case 11:
4011
+ response = _context36.sent;
3425
4012
  if (hasLookup) {
3426
- _context31.next = 12;
4013
+ _context36.next = 15;
3427
4014
  break;
3428
4015
  }
3429
- _context31.next = 12;
3430
- 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);
3431
- case 12:
3432
- return _context31.abrupt("return", response);
3433
- case 13:
4016
+ _context36.next = 15;
4017
+ return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4018
+ case 15:
4019
+ return _context36.abrupt("return", response);
4020
+ case 16:
3434
4021
  case "end":
3435
- return _context31.stop();
4022
+ return _context36.stop();
3436
4023
  }
3437
- }, _callee31, this);
4024
+ }, _callee36, this);
3438
4025
  }));
3439
- function printLocalOrderReceipt(_x26) {
4026
+ function printLocalOrderReceipt(_x28) {
3440
4027
  return _printLocalOrderReceipt.apply(this, arguments);
3441
4028
  }
3442
4029
  return printLocalOrderReceipt;
@@ -3444,9 +4031,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3444
4031
  }, {
3445
4032
  key: "getSubmitPaymentStatus",
3446
4033
  value: function getSubmitPaymentStatus(paymentStatus) {
3447
- var _this$store$order6, _this$store$order6$ge;
4034
+ var _this$store$order7, _this$store$order7$ge;
3448
4035
  if (paymentStatus !== undefined) return paymentStatus;
3449
- var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
4036
+ var amountSnapshot = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderAmountSnapshot) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
3450
4037
  if (!amountSnapshot) return undefined;
3451
4038
  try {
3452
4039
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -3457,21 +4044,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3457
4044
  }, {
3458
4045
  key: "syncPaymentsToOrder",
3459
4046
  value: function () {
3460
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3461
- var _ref36, _params$businessCode, _this$otherParams30, _this$otherParams31, _params$channel2;
4047
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4048
+ var _ref43, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
3462
4049
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
3463
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3464
- while (1) switch (_context32.prev = _context32.next) {
4050
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4051
+ while (1) switch (_context37.prev = _context37.next) {
3465
4052
  case 0:
3466
4053
  if (this.store.order) {
3467
- _context32.next = 2;
4054
+ _context37.next = 2;
3468
4055
  break;
3469
4056
  }
3470
4057
  throw new Error('order 模块未初始化');
3471
4058
  case 2:
3472
- businessCode = (_ref36 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.businessCode) !== null && _ref36 !== void 0 ? _ref36 : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.business_code;
4059
+ businessCode = (_ref43 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref43 !== void 0 ? _ref43 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
3473
4060
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
3474
- enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params.enhancePayload);
4061
+ enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
3475
4062
  syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
3476
4063
  checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
3477
4064
  }, businessCode !== undefined ? {
@@ -3483,14 +4070,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3483
4070
  } : {});
3484
4071
  syncState = this.store.order.getOrderSyncState();
3485
4072
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
3486
- _context32.next = 10;
4073
+ _context37.next = 10;
3487
4074
  break;
3488
4075
  }
3489
4076
  this.queueLatestAutoPaymentSync();
3490
- return _context32.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4077
+ return _context37.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3491
4078
  case 10:
3492
4079
  payments = params.payments || [];
3493
- _context32.next = 13;
4080
+ _context37.next = 13;
3494
4081
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
3495
4082
  payments: payments,
3496
4083
  params: syncParams,
@@ -3498,11 +4085,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3498
4085
  orderSnapshot: this.store.order.getOrderSnapshot()
3499
4086
  });
3500
4087
  case 13:
3501
- _context32.prev = 13;
3502
- _context32.next = 16;
4088
+ _context37.prev = 13;
4089
+ _context37.next = 16;
3503
4090
  return this.store.order.syncPaymentsToOrder(syncParams);
3504
4091
  case 16:
3505
- syncResult = _context32.sent;
4092
+ syncResult = _context37.sent;
3506
4093
  latestPayments = this.store.order.getOrderPayments();
3507
4094
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
3508
4095
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -3520,25 +4107,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3520
4107
  depositAmount: syncResult.depositAmount,
3521
4108
  orderExpectedAmount: syncResult.orderExpectedAmount
3522
4109
  };
3523
- _context32.next = 23;
4110
+ _context37.next = 23;
3524
4111
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
3525
4112
  case 23:
3526
4113
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
3527
- _context32.next = 26;
4114
+ _context37.next = 26;
3528
4115
  break;
3529
4116
  }
3530
- _context32.next = 26;
4117
+ _context37.next = 26;
3531
4118
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
3532
4119
  case 26:
3533
4120
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3534
- return _context32.abrupt("return", syncResult);
4121
+ return _context37.abrupt("return", syncResult);
3535
4122
  case 30:
3536
- _context32.prev = 30;
3537
- _context32.t0 = _context32["catch"](13);
3538
- _context32.next = 34;
4123
+ _context37.prev = 30;
4124
+ _context37.t0 = _context37["catch"](13);
4125
+ _context37.next = 34;
3539
4126
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
3540
4127
  ok: false,
3541
- error: _context32.t0,
4128
+ error: _context37.t0,
3542
4129
  payments: this.store.order.getOrderPayments(),
3543
4130
  params: syncParams,
3544
4131
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -3546,14 +4133,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3546
4133
  });
3547
4134
  case 34:
3548
4135
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3549
- throw _context32.t0;
4136
+ throw _context37.t0;
3550
4137
  case 36:
3551
4138
  case "end":
3552
- return _context32.stop();
4139
+ return _context37.stop();
3553
4140
  }
3554
- }, _callee32, this, [[13, 30]]);
4141
+ }, _callee37, this, [[13, 30]]);
3555
4142
  }));
3556
- function syncPaymentsToOrder(_x27) {
4143
+ function syncPaymentsToOrder(_x29) {
3557
4144
  return _syncPaymentsToOrder.apply(this, arguments);
3558
4145
  }
3559
4146
  return syncPaymentsToOrder;
@@ -3602,46 +4189,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3602
4189
  }, {
3603
4190
  key: "flushQueuedAutoPaymentSync",
3604
4191
  value: function () {
3605
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
4192
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3606
4193
  var payments;
3607
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3608
- while (1) switch (_context33.prev = _context33.next) {
4194
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4195
+ while (1) switch (_context38.prev = _context38.next) {
3609
4196
  case 0:
3610
4197
  if (this.store.order) {
3611
- _context33.next = 2;
4198
+ _context38.next = 2;
3612
4199
  break;
3613
4200
  }
3614
- return _context33.abrupt("return");
4201
+ return _context38.abrupt("return");
3615
4202
  case 2:
3616
4203
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3617
- _context33.next = 4;
4204
+ _context38.next = 4;
3618
4205
  break;
3619
4206
  }
3620
- return _context33.abrupt("return");
4207
+ return _context38.abrupt("return");
3621
4208
  case 4:
3622
4209
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3623
- _context33.next = 7;
4210
+ _context38.next = 7;
3624
4211
  break;
3625
4212
  }
3626
4213
  this.scheduleQueuedAutoPaymentSyncFlush();
3627
- return _context33.abrupt("return");
4214
+ return _context38.abrupt("return");
3628
4215
  case 7:
3629
4216
  this.autoPaymentSyncFlushing = true;
3630
- _context33.prev = 8;
4217
+ _context38.prev = 8;
3631
4218
  case 9:
3632
4219
  if (!this.queuedAutoPaymentSync) {
3633
- _context33.next = 18;
4220
+ _context38.next = 18;
3634
4221
  break;
3635
4222
  }
3636
4223
  this.queuedAutoPaymentSync = false;
3637
4224
  payments = this.store.order.getOrderPayments();
3638
4225
  if (payments.length) {
3639
- _context33.next = 14;
4226
+ _context38.next = 14;
3640
4227
  break;
3641
4228
  }
3642
- return _context33.abrupt("continue", 9);
4229
+ return _context38.abrupt("continue", 9);
3643
4230
  case 14:
3644
- _context33.next = 16;
4231
+ _context38.next = 16;
3645
4232
  return this.syncPaymentsToOrder({
3646
4233
  payments: payments,
3647
4234
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3649,29 +4236,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3649
4236
  smallTicketDataFlag: 1
3650
4237
  });
3651
4238
  case 16:
3652
- _context33.next = 9;
4239
+ _context38.next = 9;
3653
4240
  break;
3654
4241
  case 18:
3655
- _context33.next = 23;
4242
+ _context38.next = 23;
3656
4243
  break;
3657
4244
  case 20:
3658
- _context33.prev = 20;
3659
- _context33.t0 = _context33["catch"](8);
4245
+ _context38.prev = 20;
4246
+ _context38.t0 = _context38["catch"](8);
3660
4247
  this.logError('queued auto sync payments failed', {
3661
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
4248
+ error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
3662
4249
  });
3663
4250
  case 23:
3664
- _context33.prev = 23;
4251
+ _context38.prev = 23;
3665
4252
  this.autoPaymentSyncFlushing = false;
3666
4253
  if (this.queuedAutoPaymentSync) {
3667
4254
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3668
4255
  }
3669
- return _context33.finish(23);
4256
+ return _context38.finish(23);
3670
4257
  case 27:
3671
4258
  case "end":
3672
- return _context33.stop();
4259
+ return _context38.stop();
3673
4260
  }
3674
- }, _callee33, this, [[8, 20, 23, 27]]);
4261
+ }, _callee38, this, [[8, 20, 23, 27]]);
3675
4262
  }));
3676
4263
  function flushQueuedAutoPaymentSync() {
3677
4264
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -3695,35 +4282,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3695
4282
  }, {
3696
4283
  key: "addOrderPaymentAsync",
3697
4284
  value: (function () {
3698
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(payment) {
4285
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payment) {
3699
4286
  var paymentRecord, hasPaymentNumber, devicePrefix;
3700
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3701
- while (1) switch (_context34.prev = _context34.next) {
4287
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4288
+ while (1) switch (_context39.prev = _context39.next) {
3702
4289
  case 0:
3703
4290
  paymentRecord = payment;
3704
4291
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3705
4292
  if (!hasPaymentNumber) {
3706
- _context34.next = 6;
4293
+ _context39.next = 6;
3707
4294
  break;
3708
4295
  }
3709
- _context34.t0 = 'LOCAL';
3710
- _context34.next = 9;
4296
+ _context39.t0 = 'LOCAL';
4297
+ _context39.next = 9;
3711
4298
  break;
3712
4299
  case 6:
3713
- _context34.next = 8;
4300
+ _context39.next = 8;
3714
4301
  return this.getPaymentNumberDevicePrefixAsync();
3715
4302
  case 8:
3716
- _context34.t0 = _context34.sent;
4303
+ _context39.t0 = _context39.sent;
3717
4304
  case 9:
3718
- devicePrefix = _context34.t0;
3719
- return _context34.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4305
+ devicePrefix = _context39.t0;
4306
+ return _context39.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3720
4307
  case 11:
3721
4308
  case "end":
3722
- return _context34.stop();
4309
+ return _context39.stop();
3723
4310
  }
3724
- }, _callee34, this);
4311
+ }, _callee39, this);
3725
4312
  }));
3726
- function addOrderPaymentAsync(_x28) {
4313
+ function addOrderPaymentAsync(_x30) {
3727
4314
  return _addOrderPaymentAsync.apply(this, arguments);
3728
4315
  }
3729
4316
  return addOrderPaymentAsync;
@@ -3731,10 +4318,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3731
4318
  }, {
3732
4319
  key: "addOrderPaymentWithDevicePrefix",
3733
4320
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3734
- var _this$otherParams32,
4321
+ var _this$otherParams33,
3735
4322
  _paymentRecord$paymen,
3736
4323
  _paymentRecord$create,
3737
- _ref37,
4324
+ _ref44,
3738
4325
  _paymentRecord$origin,
3739
4326
  _this16 = this;
3740
4327
  if (!this.store.order) throw new Error('order 模块未初始化');
@@ -3747,7 +4334,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3747
4334
  return this.store.order.getOrderPayments();
3748
4335
  }
3749
4336
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3750
- var shopWalletPassId = (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.shop_wallet_pass_id;
4337
+ var shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
3751
4338
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3752
4339
  metadata.shop_wallet_pass_id = shopWalletPassId;
3753
4340
  }
@@ -3756,7 +4343,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3756
4343
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3757
4344
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3758
4345
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3759
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref37 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref37 !== void 0 ? _ref37 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
4346
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref44 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref44 !== void 0 ? _ref44 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3760
4347
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3761
4348
  service_fee: calculatedServiceFee
3762
4349
  } : {}), {}, {
@@ -3792,7 +4379,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3792
4379
  }, {
3793
4380
  key: "updateOrderPayment",
3794
4381
  value: (function () {
3795
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paymentIdentity, updates) {
4382
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paymentIdentity, updates) {
3796
4383
  var _result$payment, _result$payment2;
3797
4384
  var options,
3798
4385
  matchMode,
@@ -3809,13 +4396,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3809
4396
  shouldSubmit,
3810
4397
  syncResult,
3811
4398
  _options$smallTicketD2,
3812
- _args35 = arguments;
3813
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3814
- while (1) switch (_context35.prev = _context35.next) {
4399
+ _args40 = arguments;
4400
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4401
+ while (1) switch (_context40.prev = _context40.next) {
3815
4402
  case 0:
3816
- options = _args35.length > 2 && _args35[2] !== undefined ? _args35[2] : {};
4403
+ options = _args40.length > 2 && _args40[2] !== undefined ? _args40[2] : {};
3817
4404
  if (this.store.order) {
3818
- _context35.next = 3;
4405
+ _context40.next = 3;
3819
4406
  break;
3820
4407
  }
3821
4408
  throw new Error('order 模块未初始化');
@@ -3824,15 +4411,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3824
4411
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3825
4412
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3826
4413
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3827
- _context35.next = 13;
4414
+ _context40.next = 13;
3828
4415
  break;
3829
4416
  }
3830
4417
  currentPayments = this.store.order.getOrderPayments();
3831
4418
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3832
- _context35.next = 12;
4419
+ _context40.next = 12;
3833
4420
  break;
3834
4421
  }
3835
- _context35.next = 11;
4422
+ _context40.next = 11;
3836
4423
  return this.syncPaymentsToOrder({
3837
4424
  payments: currentPayments,
3838
4425
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -3840,9 +4427,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3840
4427
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3841
4428
  });
3842
4429
  case 11:
3843
- _syncResult = _context35.sent;
4430
+ _syncResult = _context40.sent;
3844
4431
  case 12:
3845
- return _context35.abrupt("return", _objectSpread({
4432
+ return _context40.abrupt("return", _objectSpread({
3846
4433
  updated: false,
3847
4434
  payment: previousPayment,
3848
4435
  payments: currentPayments,
@@ -3851,44 +4438,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3851
4438
  syncResult: _syncResult
3852
4439
  } : {}));
3853
4440
  case 13:
3854
- _context35.next = 15;
4441
+ _context40.next = 15;
3855
4442
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3856
4443
  matchBy: matchMode
3857
4444
  });
3858
4445
  case 15:
3859
- result = _context35.sent;
4446
+ result = _context40.sent;
3860
4447
  if (!(options.persistDraft !== false)) {
3861
- _context35.next = 29;
4448
+ _context40.next = 29;
3862
4449
  break;
3863
4450
  }
3864
- _context35.prev = 17;
3865
- _context35.next = 20;
4451
+ _context40.prev = 17;
4452
+ _context40.next = 20;
3866
4453
  return this.saveSalesOrderDraft();
3867
4454
  case 20:
3868
- draftResult = _context35.sent;
3869
- _context35.next = 29;
4455
+ draftResult = _context40.sent;
4456
+ _context40.next = 29;
3870
4457
  break;
3871
4458
  case 23:
3872
- _context35.prev = 23;
3873
- _context35.t0 = _context35["catch"](17);
3874
- draftError = _context35.t0;
4459
+ _context40.prev = 23;
4460
+ _context40.t0 = _context40["catch"](17);
4461
+ draftError = _context40.t0;
3875
4462
  this.logError('updateOrderPayment: 保存支付草稿失败', {
3876
4463
  paymentIdentity: paymentIdentity,
3877
- error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
4464
+ error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3878
4465
  });
3879
4466
  if (options.submitWhenPaid) {
3880
- _context35.next = 29;
4467
+ _context40.next = 29;
3881
4468
  break;
3882
4469
  }
3883
- throw _context35.t0;
4470
+ throw _context40.t0;
3884
4471
  case 29:
3885
4472
  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';
3886
4473
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3887
4474
  if (!shouldSubmit) {
3888
- _context35.next = 35;
4475
+ _context40.next = 35;
3889
4476
  break;
3890
4477
  }
3891
- _context35.next = 34;
4478
+ _context40.next = 34;
3892
4479
  return this.syncPaymentsToOrder({
3893
4480
  payments: result.payments,
3894
4481
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -3896,9 +4483,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3896
4483
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3897
4484
  });
3898
4485
  case 34:
3899
- syncResult = _context35.sent;
4486
+ syncResult = _context40.sent;
3900
4487
  case 35:
3901
- return _context35.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
4488
+ return _context40.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3902
4489
  draftResult: draftResult
3903
4490
  } : {}), draftError !== undefined ? {
3904
4491
  draftError: draftError
@@ -3907,11 +4494,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3907
4494
  } : {}));
3908
4495
  case 36:
3909
4496
  case "end":
3910
- return _context35.stop();
4497
+ return _context40.stop();
3911
4498
  }
3912
- }, _callee35, this, [[17, 23]]);
4499
+ }, _callee40, this, [[17, 23]]);
3913
4500
  }));
3914
- function updateOrderPayment(_x29, _x30) {
4501
+ function updateOrderPayment(_x31, _x32) {
3915
4502
  return _updateOrderPayment.apply(this, arguments);
3916
4503
  }
3917
4504
  return updateOrderPayment;
@@ -3933,24 +4520,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3933
4520
  }, {
3934
4521
  key: "updateVoucherOrderPaymentsAsync",
3935
4522
  value: function () {
3936
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payments, options) {
3937
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3938
- while (1) switch (_context36.prev = _context36.next) {
4523
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(payments, options) {
4524
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4525
+ while (1) switch (_context41.prev = _context41.next) {
3939
4526
  case 0:
3940
4527
  if (this.store.order) {
3941
- _context36.next = 2;
4528
+ _context41.next = 2;
3942
4529
  break;
3943
4530
  }
3944
4531
  throw new Error('order 模块未初始化');
3945
4532
  case 2:
3946
- return _context36.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
4533
+ return _context41.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3947
4534
  case 3:
3948
4535
  case "end":
3949
- return _context36.stop();
4536
+ return _context41.stop();
3950
4537
  }
3951
- }, _callee36, this);
4538
+ }, _callee41, this);
3952
4539
  }));
3953
- function updateVoucherOrderPaymentsAsync(_x31, _x32) {
4540
+ function updateVoucherOrderPaymentsAsync(_x33, _x34) {
3954
4541
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3955
4542
  }
3956
4543
  return updateVoucherOrderPaymentsAsync;
@@ -3963,7 +4550,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3963
4550
  if (this.store.payment) {
3964
4551
  var committed = this.getCommittedWalletAssets();
3965
4552
  var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3966
- void this.publishWalletAssetsState(state);
4553
+ void this.publishWalletAssetsState(state, 'local');
3967
4554
  }
3968
4555
  return payments;
3969
4556
  }
@@ -3976,8 +4563,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3976
4563
  }, {
3977
4564
  key: "getWalletProductList",
3978
4565
  value: function getWalletProductList() {
3979
- var _this$store$order7, _tempOrder$products;
3980
- var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
4566
+ var _this$store$order8, _tempOrder$products;
4567
+ var tempOrder = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder();
3981
4568
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
3982
4569
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
3983
4570
  // debugger
@@ -4037,8 +4624,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4037
4624
  }, {
4038
4625
  key: "buildWalletInitBusinessData",
4039
4626
  value: function buildWalletInitBusinessData(params) {
4040
- var _this$store$order8, _params$order_wait_pa, _ref38, _tempOrder$is_price_i;
4041
- var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
4627
+ var _this$store$order9, _params$order_wait_pa, _ref45, _tempOrder$is_price_i;
4628
+ var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
4042
4629
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
4043
4630
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
4044
4631
  if (!tempOrder || !amount) return null;
@@ -4053,7 +4640,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4053
4640
  },
4054
4641
  products: this.getWalletProductList(),
4055
4642
  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),
4056
- is_price_include_tax: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : 1
4643
+ is_price_include_tax: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : 1
4057
4644
  }, snapshot.identity.orderId ? {
4058
4645
  payment_order_id: String(snapshot.identity.orderId)
4059
4646
  } : {});
@@ -4061,20 +4648,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4061
4648
  }, {
4062
4649
  key: "initWalletData",
4063
4650
  value: function () {
4064
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4651
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4065
4652
  var _snapshot$identity;
4066
4653
  var snapshot, walletBusinessData, result;
4067
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4068
- while (1) switch (_context37.prev = _context37.next) {
4654
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4655
+ while (1) switch (_context42.prev = _context42.next) {
4069
4656
  case 0:
4070
4657
  if (this.store.order) {
4071
- _context37.next = 2;
4658
+ _context42.next = 2;
4072
4659
  break;
4073
4660
  }
4074
4661
  throw new Error('order 模块未初始化');
4075
4662
  case 2:
4076
4663
  if (this.store.payment) {
4077
- _context37.next = 4;
4664
+ _context42.next = 4;
4078
4665
  break;
4079
4666
  }
4080
4667
  throw new Error('payment 模块未初始化');
@@ -4082,10 +4669,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4082
4669
  snapshot = this.store.order.getOrderSnapshot();
4083
4670
  walletBusinessData = this.buildWalletInitBusinessData(params);
4084
4671
  if (walletBusinessData) {
4085
- _context37.next = 8;
4672
+ _context42.next = 8;
4086
4673
  break;
4087
4674
  }
4088
- return _context37.abrupt("return", {
4675
+ return _context42.abrupt("return", {
4089
4676
  walletRecommendList: [],
4090
4677
  userIdentificationCodes: [],
4091
4678
  transformList: [],
@@ -4093,11 +4680,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4093
4680
  products: []
4094
4681
  });
4095
4682
  case 8:
4096
- _context37.next = 10;
4683
+ _context42.next = 10;
4097
4684
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
4098
4685
  case 10:
4099
- result = _context37.sent;
4100
- _context37.next = 13;
4686
+ result = _context42.sent;
4687
+ _context42.next = 13;
4101
4688
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
4102
4689
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
4103
4690
  customerId: walletBusinessData.customer_id,
@@ -4109,14 +4696,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4109
4696
  timestamp: Date.now()
4110
4697
  });
4111
4698
  case 13:
4112
- return _context37.abrupt("return", result);
4699
+ return _context42.abrupt("return", result);
4113
4700
  case 14:
4114
4701
  case "end":
4115
- return _context37.stop();
4702
+ return _context42.stop();
4116
4703
  }
4117
- }, _callee37, this);
4704
+ }, _callee42, this);
4118
4705
  }));
4119
- function initWalletData(_x33) {
4706
+ function initWalletData(_x35) {
4120
4707
  return _initWalletData.apply(this, arguments);
4121
4708
  }
4122
4709
  return initWalletData;
@@ -4124,8 +4711,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4124
4711
  }, {
4125
4712
  key: "getCommittedWalletAssets",
4126
4713
  value: function getCommittedWalletAssets() {
4127
- var _this$store$order9, _this$store$order9$ge;
4128
- 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)) || [];
4714
+ var _this$store$order10, _this$store$order10$g;
4715
+ var payments = ((_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)) || [];
4129
4716
  var committed = payments.filter(function (payment) {
4130
4717
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
4131
4718
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -4143,9 +4730,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4143
4730
  var walletPassName = fundRecord.wallet_pass_name;
4144
4731
  var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
4145
4732
  var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
4146
- var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref39) {
4147
- var _ref40 = _slicedToArray(_ref39, 2),
4148
- paymentCode = _ref40[1];
4733
+ var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref46) {
4734
+ var _ref47 = _slicedToArray(_ref46, 2),
4735
+ paymentCode = _ref47[1];
4149
4736
  return paymentCode === code;
4150
4737
  })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
4151
4738
  return {
@@ -4167,23 +4754,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4167
4754
  }, {
4168
4755
  key: "publishWalletAssetsState",
4169
4756
  value: function () {
4170
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
4171
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4172
- while (1) switch (_context38.prev = _context38.next) {
4757
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(state) {
4758
+ var changeSource,
4759
+ _args43 = arguments;
4760
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4761
+ while (1) switch (_context43.prev = _context43.next) {
4173
4762
  case 0:
4174
- _context38.next = 2;
4763
+ changeSource = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : 'derived';
4764
+ _context43.next = 3;
4175
4765
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
4176
- state: state
4766
+ state: state,
4767
+ changeSource: changeSource
4177
4768
  });
4178
- case 2:
4179
- return _context38.abrupt("return", state);
4180
4769
  case 3:
4770
+ return _context43.abrupt("return", state);
4771
+ case 4:
4181
4772
  case "end":
4182
- return _context38.stop();
4773
+ return _context43.stop();
4183
4774
  }
4184
- }, _callee38, this);
4775
+ }, _callee43, this);
4185
4776
  }));
4186
- function publishWalletAssetsState(_x34) {
4777
+ function publishWalletAssetsState(_x36) {
4187
4778
  return _publishWalletAssetsState.apply(this, arguments);
4188
4779
  }
4189
4780
  return publishWalletAssetsState;
@@ -4191,26 +4782,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4191
4782
  }, {
4192
4783
  key: "syncSelectedWalletAssets",
4193
4784
  value: function () {
4194
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(state) {
4785
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
4195
4786
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
4196
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4197
- while (1) switch (_context39.prev = _context39.next) {
4787
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4788
+ while (1) switch (_context44.prev = _context44.next) {
4198
4789
  case 0:
4199
4790
  if (!(!this.store.order || !this.store.payment)) {
4200
- _context39.next = 2;
4791
+ _context44.next = 2;
4201
4792
  break;
4202
4793
  }
4203
4794
  throw new Error('订单或支付模块未初始化');
4204
4795
  case 2:
4205
4796
  paymentMethods = this.getPaymentMethods();
4206
4797
  if (!(!paymentMethods.length && state.selectedItems.length)) {
4207
- _context39.next = 7;
4798
+ _context44.next = 7;
4208
4799
  break;
4209
4800
  }
4210
- _context39.next = 6;
4801
+ _context44.next = 6;
4211
4802
  return this.getPaymentMethodsAsync();
4212
4803
  case 6:
4213
- paymentMethods = _context39.sent;
4804
+ paymentMethods = _context44.sent;
4214
4805
  case 7:
4215
4806
  methodByCode = new Map(paymentMethods.map(function (method) {
4216
4807
  return [String(method.code || '').toUpperCase(), method];
@@ -4252,19 +4843,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4252
4843
  payments = this.updateVoucherOrderPayments(voucherPayments, {
4253
4844
  status: 'payment_pending'
4254
4845
  });
4255
- _context39.next = 14;
4846
+ _context44.next = 14;
4256
4847
  return this.store.order.recalculateSummary({
4257
4848
  createIfMissing: true
4258
4849
  });
4259
4850
  case 14:
4260
- return _context39.abrupt("return", payments);
4851
+ return _context44.abrupt("return", payments);
4261
4852
  case 15:
4262
4853
  case "end":
4263
- return _context39.stop();
4854
+ return _context44.stop();
4264
4855
  }
4265
- }, _callee39, this);
4856
+ }, _callee44, this);
4266
4857
  }));
4267
- function syncSelectedWalletAssets(_x35) {
4858
+ function syncSelectedWalletAssets(_x37) {
4268
4859
  return _syncSelectedWalletAssets.apply(this, arguments);
4269
4860
  }
4270
4861
  return syncSelectedWalletAssets;
@@ -4298,29 +4889,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4298
4889
  }, {
4299
4890
  key: "importWalletAssetsSnapshot",
4300
4891
  value: (function () {
4301
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(snapshot) {
4892
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(snapshot) {
4302
4893
  var state;
4303
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4304
- while (1) switch (_context40.prev = _context40.next) {
4894
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4895
+ while (1) switch (_context45.prev = _context45.next) {
4305
4896
  case 0:
4306
4897
  if (this.store.payment) {
4307
- _context40.next = 2;
4898
+ _context45.next = 2;
4308
4899
  break;
4309
4900
  }
4310
4901
  throw new Error('payment 模块未初始化');
4311
4902
  case 2:
4312
4903
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
4313
- _context40.next = 5;
4904
+ _context45.next = 5;
4314
4905
  return this.syncSelectedWalletAssets(state);
4315
4906
  case 5:
4316
- return _context40.abrupt("return", this.publishWalletAssetsState(state));
4907
+ return _context45.abrupt("return", this.publishWalletAssetsState(state));
4317
4908
  case 6:
4318
4909
  case "end":
4319
- return _context40.stop();
4910
+ return _context45.stop();
4320
4911
  }
4321
- }, _callee40, this);
4912
+ }, _callee45, this);
4322
4913
  }));
4323
- function importWalletAssetsSnapshot(_x36) {
4914
+ function importWalletAssetsSnapshot(_x38) {
4324
4915
  return _importWalletAssetsSnapshot.apply(this, arguments);
4325
4916
  }
4326
4917
  return importWalletAssetsSnapshot;
@@ -4332,20 +4923,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4332
4923
  }, {
4333
4924
  key: "refreshWalletAssets",
4334
4925
  value: (function () {
4335
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4926
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
4336
4927
  var _previousState$custom, _businessData$custome;
4337
4928
  var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
4338
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4339
- while (1) switch (_context41.prev = _context41.next) {
4929
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4930
+ while (1) switch (_context46.prev = _context46.next) {
4340
4931
  case 0:
4341
4932
  if (this.store.order) {
4342
- _context41.next = 2;
4933
+ _context46.next = 2;
4343
4934
  break;
4344
4935
  }
4345
4936
  throw new Error('order 模块未初始化');
4346
4937
  case 2:
4347
4938
  if (this.store.payment) {
4348
- _context41.next = 4;
4939
+ _context46.next = 4;
4349
4940
  break;
4350
4941
  }
4351
4942
  throw new Error('payment 模块未初始化');
@@ -4354,7 +4945,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4354
4945
  wallet = this.store.payment.wallet;
4355
4946
  businessData = this.buildWalletInitBusinessData(params);
4356
4947
  if (businessData) {
4357
- _context41.next = 12;
4948
+ _context46.next = 12;
4358
4949
  break;
4359
4950
  }
4360
4951
  wallet.clearAllCache();
@@ -4362,53 +4953,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4362
4953
  this.updateVoucherOrderPayments([], {
4363
4954
  status: 'payment_pending'
4364
4955
  });
4365
- return _context41.abrupt("return", this.publishWalletAssetsState(emptyState));
4956
+ return _context46.abrupt("return", this.publishWalletAssetsState(emptyState));
4366
4957
  case 12:
4367
4958
  previousState = wallet.getWalletAssetsState();
4368
4959
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
4369
4960
  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 : '');
4370
4961
  if (!customerChanged) {
4371
- _context41.next = 20;
4962
+ _context46.next = 20;
4372
4963
  break;
4373
4964
  }
4374
4965
  clearedState = wallet.clearWalletAssetSelection();
4375
4966
  this.updateVoucherOrderPayments([], {
4376
4967
  status: 'payment_pending'
4377
4968
  });
4378
- _context41.next = 20;
4969
+ _context46.next = 20;
4379
4970
  return this.publishWalletAssetsState(clearedState);
4380
4971
  case 20:
4381
4972
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
4382
4973
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
4383
4974
  });
4384
- _context41.next = 23;
4975
+ _context46.next = 23;
4385
4976
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
4386
4977
  case 23:
4387
- _context41.next = 25;
4978
+ _context46.next = 25;
4388
4979
  return refreshTask;
4389
4980
  case 25:
4390
- state = _context41.sent;
4981
+ state = _context46.sent;
4391
4982
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
4392
- _context41.next = 28;
4983
+ _context46.next = 28;
4393
4984
  break;
4394
4985
  }
4395
- return _context41.abrupt("return", wallet.getWalletAssetsState());
4986
+ return _context46.abrupt("return", wallet.getWalletAssetsState());
4396
4987
  case 28:
4397
4988
  if (state.status !== 'error') {
4398
4989
  committed = this.getCommittedWalletAssets();
4399
4990
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4400
4991
  }
4401
- _context41.next = 31;
4992
+ _context46.next = 31;
4402
4993
  return this.syncSelectedWalletAssets(state);
4403
4994
  case 31:
4404
- return _context41.abrupt("return", this.publishWalletAssetsState(state));
4995
+ return _context46.abrupt("return", this.publishWalletAssetsState(state));
4405
4996
  case 32:
4406
4997
  case "end":
4407
- return _context41.stop();
4998
+ return _context46.stop();
4408
4999
  }
4409
- }, _callee41, this);
5000
+ }, _callee46, this);
4410
5001
  }));
4411
- function refreshWalletAssets(_x37) {
5002
+ function refreshWalletAssets(_x39) {
4412
5003
  return _refreshWalletAssets.apply(this, arguments);
4413
5004
  }
4414
5005
  return refreshWalletAssets;
@@ -4416,13 +5007,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4416
5007
  }, {
4417
5008
  key: "selectWalletAsset",
4418
5009
  value: (function () {
4419
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5010
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4420
5011
  var state;
4421
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4422
- while (1) switch (_context42.prev = _context42.next) {
5012
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5013
+ while (1) switch (_context47.prev = _context47.next) {
4423
5014
  case 0:
4424
5015
  if (this.store.payment) {
4425
- _context42.next = 2;
5016
+ _context47.next = 2;
4426
5017
  break;
4427
5018
  }
4428
5019
  throw new Error('payment 模块未初始化');
@@ -4431,17 +5022,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4431
5022
  selected: params.selected,
4432
5023
  source: params.source
4433
5024
  });
4434
- _context42.next = 5;
5025
+ _context47.next = 5;
4435
5026
  return this.syncSelectedWalletAssets(state);
4436
5027
  case 5:
4437
- return _context42.abrupt("return", this.publishWalletAssetsState(state));
5028
+ return _context47.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4438
5029
  case 6:
4439
5030
  case "end":
4440
- return _context42.stop();
5031
+ return _context47.stop();
4441
5032
  }
4442
- }, _callee42, this);
5033
+ }, _callee47, this);
4443
5034
  }));
4444
- function selectWalletAsset(_x38) {
5035
+ function selectWalletAsset(_x40) {
4445
5036
  return _selectWalletAsset.apply(this, arguments);
4446
5037
  }
4447
5038
  return selectWalletAsset;
@@ -4449,29 +5040,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4449
5040
  }, {
4450
5041
  key: "updateWalletAssetAmount",
4451
5042
  value: (function () {
4452
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5043
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4453
5044
  var state;
4454
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4455
- while (1) switch (_context43.prev = _context43.next) {
5045
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5046
+ while (1) switch (_context48.prev = _context48.next) {
4456
5047
  case 0:
4457
5048
  if (this.store.payment) {
4458
- _context43.next = 2;
5049
+ _context48.next = 2;
4459
5050
  break;
4460
5051
  }
4461
5052
  throw new Error('payment 模块未初始化');
4462
5053
  case 2:
4463
5054
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
4464
- _context43.next = 5;
5055
+ _context48.next = 5;
4465
5056
  return this.syncSelectedWalletAssets(state);
4466
5057
  case 5:
4467
- return _context43.abrupt("return", this.publishWalletAssetsState(state));
5058
+ return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4468
5059
  case 6:
4469
5060
  case "end":
4470
- return _context43.stop();
5061
+ return _context48.stop();
4471
5062
  }
4472
- }, _callee43, this);
5063
+ }, _callee48, this);
4473
5064
  }));
4474
- function updateWalletAssetAmount(_x39) {
5065
+ function updateWalletAssetAmount(_x41) {
4475
5066
  return _updateWalletAssetAmount.apply(this, arguments);
4476
5067
  }
4477
5068
  return updateWalletAssetAmount;
@@ -4479,13 +5070,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4479
5070
  }, {
4480
5071
  key: "scanWalletAsset",
4481
5072
  value: (function () {
4482
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(code) {
5073
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(code) {
4483
5074
  var wallet, businessData, result;
4484
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4485
- while (1) switch (_context44.prev = _context44.next) {
5075
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5076
+ while (1) switch (_context49.prev = _context49.next) {
4486
5077
  case 0:
4487
5078
  if (this.store.payment) {
4488
- _context44.next = 2;
5079
+ _context49.next = 2;
4489
5080
  break;
4490
5081
  }
4491
5082
  throw new Error('payment 模块未初始化');
@@ -4495,28 +5086,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4495
5086
  if (businessData) {
4496
5087
  wallet.generateWalletParams(businessData);
4497
5088
  }
4498
- _context44.next = 7;
5089
+ _context49.next = 7;
4499
5090
  return wallet.scanWalletAssetAsync(code);
4500
5091
  case 7:
4501
- result = _context44.sent;
5092
+ result = _context49.sent;
4502
5093
  if (!(result.type === 'normalCode')) {
4503
- _context44.next = 13;
5094
+ _context49.next = 13;
4504
5095
  break;
4505
5096
  }
4506
- _context44.next = 11;
5097
+ _context49.next = 11;
4507
5098
  return this.syncSelectedWalletAssets(result.state);
4508
5099
  case 11:
4509
- _context44.next = 13;
4510
- return this.publishWalletAssetsState(result.state);
5100
+ _context49.next = 13;
5101
+ return this.publishWalletAssetsState(result.state, 'local');
4511
5102
  case 13:
4512
- return _context44.abrupt("return", result);
5103
+ return _context49.abrupt("return", result);
4513
5104
  case 14:
4514
5105
  case "end":
4515
- return _context44.stop();
5106
+ return _context49.stop();
4516
5107
  }
4517
- }, _callee44, this);
5108
+ }, _callee49, this);
4518
5109
  }));
4519
- function scanWalletAsset(_x40) {
5110
+ function scanWalletAsset(_x42) {
4520
5111
  return _scanWalletAsset.apply(this, arguments);
4521
5112
  }
4522
5113
  return scanWalletAsset;
@@ -4524,27 +5115,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4524
5115
  }, {
4525
5116
  key: "clearWalletAssetSelection",
4526
5117
  value: (function () {
4527
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
5118
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4528
5119
  var state;
4529
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4530
- while (1) switch (_context45.prev = _context45.next) {
5120
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5121
+ while (1) switch (_context50.prev = _context50.next) {
4531
5122
  case 0:
4532
5123
  if (this.store.payment) {
4533
- _context45.next = 2;
5124
+ _context50.next = 2;
4534
5125
  break;
4535
5126
  }
4536
5127
  throw new Error('payment 模块未初始化');
4537
5128
  case 2:
4538
5129
  state = this.store.payment.wallet.clearWalletAssetSelection();
4539
- _context45.next = 5;
5130
+ _context50.next = 5;
4540
5131
  return this.syncSelectedWalletAssets(state);
4541
5132
  case 5:
4542
- return _context45.abrupt("return", this.publishWalletAssetsState(state));
5133
+ return _context50.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4543
5134
  case 6:
4544
5135
  case "end":
4545
- return _context45.stop();
5136
+ return _context50.stop();
4546
5137
  }
4547
- }, _callee45, this);
5138
+ }, _callee50, this);
4548
5139
  }));
4549
5140
  function clearWalletAssetSelection() {
4550
5141
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -4574,35 +5165,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4574
5165
  }, {
4575
5166
  key: "getPaymentMethodsAsync",
4576
5167
  value: (function () {
4577
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
5168
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
4578
5169
  var response, paymentMethods;
4579
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4580
- while (1) switch (_context46.prev = _context46.next) {
5170
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5171
+ while (1) switch (_context51.prev = _context51.next) {
4581
5172
  case 0:
4582
- _context46.prev = 0;
4583
- _context46.next = 3;
5173
+ _context51.prev = 0;
5174
+ _context51.next = 3;
4584
5175
  return this.request.get('/pay/custom-payment/all', {
4585
5176
  filterPaymentMethods: true
4586
5177
  }, {
4587
5178
  osServer: true
4588
5179
  });
4589
5180
  case 3:
4590
- response = _context46.sent;
5181
+ response = _context51.sent;
4591
5182
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
4592
5183
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
4593
- return _context46.abrupt("return", this.getPaymentMethods());
5184
+ return _context51.abrupt("return", this.getPaymentMethods());
4594
5185
  case 9:
4595
- _context46.prev = 9;
4596
- _context46.t0 = _context46["catch"](0);
5186
+ _context51.prev = 9;
5187
+ _context51.t0 = _context51["catch"](0);
4597
5188
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
4598
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
5189
+ error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
4599
5190
  });
4600
- return _context46.abrupt("return", this.getPaymentMethods());
5191
+ return _context51.abrupt("return", this.getPaymentMethods());
4601
5192
  case 13:
4602
5193
  case "end":
4603
- return _context46.stop();
5194
+ return _context51.stop();
4604
5195
  }
4605
- }, _callee46, this, [[0, 9]]);
5196
+ }, _callee51, this, [[0, 9]]);
4606
5197
  }));
4607
5198
  function getPaymentMethodsAsync() {
4608
5199
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -4627,8 +5218,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4627
5218
  }, {
4628
5219
  key: "getPendingWalletPaymentAmount",
4629
5220
  value: function getPendingWalletPaymentAmount() {
4630
- var _this$store$order10, _this$store$order10$g;
4631
- 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)) || [];
5221
+ var _this$store$order11, _this$store$order11$g;
5222
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderPayments) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11)) || [];
4632
5223
  return payments.reduce(function (total, payment) {
4633
5224
  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) {
4634
5225
  return total;
@@ -4645,14 +5236,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4645
5236
  }, {
4646
5237
  key: "getCashPaymentConfig",
4647
5238
  value: (function () {
4648
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4649
- var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams33;
5239
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5240
+ var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams34;
4650
5241
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4651
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4652
- while (1) switch (_context47.prev = _context47.next) {
5242
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5243
+ while (1) switch (_context52.prev = _context52.next) {
4653
5244
  case 0:
4654
5245
  if (this.store.payment) {
4655
- _context47.next = 2;
5246
+ _context52.next = 2;
4656
5247
  break;
4657
5248
  }
4658
5249
  throw new Error('payment 模块未初始化');
@@ -4660,21 +5251,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4660
5251
  paymentMethods = this.getPaymentMethods();
4661
5252
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4662
5253
  if (paymentMethod) {
4663
- _context47.next = 9;
5254
+ _context52.next = 9;
4664
5255
  break;
4665
5256
  }
4666
- _context47.next = 7;
5257
+ _context52.next = 7;
4667
5258
  return this.getPaymentMethodsAsync();
4668
5259
  case 7:
4669
- paymentMethods = _context47.sent;
5260
+ paymentMethods = _context52.sent;
4670
5261
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4671
5262
  case 9:
4672
- 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);
5263
+ amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
4673
5264
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4674
5265
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4675
- 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$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.currency) || 'USD';
5266
+ currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
4676
5267
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4677
- return _context47.abrupt("return", {
5268
+ return _context52.abrupt("return", {
4678
5269
  available: Boolean(paymentMethod && amountDue > 0),
4679
5270
  paymentMethod: paymentMethod,
4680
5271
  amountDue: amountDue,
@@ -4682,9 +5273,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4682
5273
  });
4683
5274
  case 15:
4684
5275
  case "end":
4685
- return _context47.stop();
5276
+ return _context52.stop();
4686
5277
  }
4687
- }, _callee47, this);
5278
+ }, _callee52, this);
4688
5279
  }));
4689
5280
  function getCashPaymentConfig() {
4690
5281
  return _getCashPaymentConfig.apply(this, arguments);
@@ -4701,97 +5292,117 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4701
5292
  }, {
4702
5293
  key: "confirmWalletPayment",
4703
5294
  value: (function () {
4704
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4705
- var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4706
- var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4707
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4708
- while (1) switch (_context48.prev = _context48.next) {
5295
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5296
+ var _this$store$order$get3, _this$store$order14, _this$store$order$get5, _this$store$order$get6, _this$store$order16;
5297
+ var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get4, _this$store$order15, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5298
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5299
+ while (1) switch (_context53.prev = _context53.next) {
4709
5300
  case 0:
4710
5301
  if (this.store.order) {
4711
- _context48.next = 2;
5302
+ _context53.next = 2;
4712
5303
  break;
4713
5304
  }
4714
5305
  throw new Error('order 模块未初始化');
4715
5306
  case 2:
4716
5307
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4717
5308
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5309
+ amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
4718
5310
  if (!pendingWalletAmount.lte(0)) {
4719
- _context48.next = 6;
5311
+ _context53.next = 14;
4720
5312
  break;
4721
5313
  }
4722
- throw new Error('当前订单没有待确认的 Wallet 支付');
4723
- case 6:
4724
- 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);
5314
+ this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
5315
+ amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
5316
+ });
5317
+ _context53.next = 9;
5318
+ return this.submitSalesOrder({
5319
+ smallTicketDataFlag: 1
5320
+ });
5321
+ case 9:
5322
+ _submitResult = _context53.sent;
5323
+ if (!isRejectedSalesSubmitResult(_submitResult)) {
5324
+ _context53.next = 12;
5325
+ break;
5326
+ }
5327
+ throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5328
+ case 12:
5329
+ _latestAmountSnapshot = (_this$store$order$get4 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order15);
5330
+ return _context53.abrupt("return", {
5331
+ submitResult: _submitResult,
5332
+ payments: this.store.order.getOrderPayments(),
5333
+ isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
5334
+ });
5335
+ case 14:
4725
5336
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4726
5337
  if (!effectiveAmountDue.gt(0.01)) {
4727
- _context48.next = 10;
5338
+ _context53.next = 17;
4728
5339
  break;
4729
5340
  }
4730
5341
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4731
- case 10:
4732
- beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4733
- _context48.prev = 11;
4734
- _context48.next = 14;
5342
+ case 17:
5343
+ beforePaymentStatus = (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.payment_status;
5344
+ _context53.prev = 18;
5345
+ _context53.next = 21;
4735
5346
  return this.submitSalesOrder({
4736
5347
  smallTicketDataFlag: 1,
4737
5348
  confirmPendingVoucherPayments: true
4738
5349
  });
4739
- case 14:
4740
- submitResult = _context48.sent;
5350
+ case 21:
5351
+ submitResult = _context53.sent;
4741
5352
  if (!isRejectedSalesSubmitResult(submitResult)) {
4742
- _context48.next = 17;
5353
+ _context53.next = 24;
4743
5354
  break;
4744
5355
  }
4745
5356
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
4746
- case 17:
4747
- _context48.next = 27;
5357
+ case 24:
5358
+ _context53.next = 34;
4748
5359
  break;
4749
- case 19:
4750
- _context48.prev = 19;
4751
- _context48.t0 = _context48["catch"](11);
5360
+ case 26:
5361
+ _context53.prev = 26;
5362
+ _context53.t0 = _context53["catch"](18);
4752
5363
  this.store.order.setOrderPayments(beforePayments);
4753
5364
  restoredTempOrder = this.store.order.getTempOrder();
4754
5365
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4755
5366
  restoredTempOrder.payment_status = beforePaymentStatus;
4756
5367
  this.store.order.persistTempOrder();
4757
5368
  }
4758
- _context48.next = 26;
5369
+ _context53.next = 33;
4759
5370
  return this.store.order.recalculateSummary({
4760
5371
  createIfMissing: true
4761
5372
  });
4762
- case 26:
4763
- throw _context48.t0;
4764
- case 27:
5373
+ case 33:
5374
+ throw _context53.t0;
5375
+ case 34:
4765
5376
  if (!this.store.payment) {
4766
- _context48.next = 38;
5377
+ _context53.next = 45;
4767
5378
  break;
4768
5379
  }
4769
- _context48.prev = 28;
5380
+ _context53.prev = 35;
4770
5381
  committed = this.getCommittedWalletAssets();
4771
5382
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4772
- _context48.next = 33;
4773
- return this.publishWalletAssetsState(walletState);
4774
- case 33:
4775
- _context48.next = 38;
5383
+ _context53.next = 40;
5384
+ return this.publishWalletAssetsState(walletState, 'local');
5385
+ case 40:
5386
+ _context53.next = 45;
4776
5387
  break;
4777
- case 35:
4778
- _context48.prev = 35;
4779
- _context48.t1 = _context48["catch"](28);
5388
+ case 42:
5389
+ _context53.prev = 42;
5390
+ _context53.t1 = _context53["catch"](35);
4780
5391
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4781
- error: _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1)
5392
+ error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
4782
5393
  });
4783
- case 38:
4784
- 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);
4785
- return _context48.abrupt("return", {
5394
+ case 45:
5395
+ latestAmountSnapshot = (_this$store$order$get6 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16);
5396
+ return _context53.abrupt("return", {
4786
5397
  submitResult: submitResult,
4787
5398
  payments: this.store.order.getOrderPayments(),
4788
5399
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4789
5400
  });
4790
- case 40:
5401
+ case 47:
4791
5402
  case "end":
4792
- return _context48.stop();
5403
+ return _context53.stop();
4793
5404
  }
4794
- }, _callee48, this, [[11, 19], [28, 35]]);
5405
+ }, _callee53, this, [[18, 26], [35, 42]]);
4795
5406
  }));
4796
5407
  function confirmWalletPayment() {
4797
5408
  return _confirmWalletPayment.apply(this, arguments);
@@ -4806,38 +5417,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4806
5417
  }, {
4807
5418
  key: "payCash",
4808
5419
  value: (function () {
4809
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4810
- var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams34, _this$window, _this$window$postMess;
5420
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5421
+ var _this$store$order$get7, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
4811
5422
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4812
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4813
- while (1) switch (_context49.prev = _context49.next) {
5423
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5424
+ while (1) switch (_context54.prev = _context54.next) {
4814
5425
  case 0:
4815
5426
  if (this.store.order) {
4816
- _context49.next = 2;
5427
+ _context54.next = 2;
4817
5428
  break;
4818
5429
  }
4819
5430
  throw new Error('order 模块未初始化');
4820
5431
  case 2:
4821
5432
  amount = Number(params.amount || 0);
4822
5433
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4823
- _context49.next = 5;
5434
+ _context54.next = 5;
4824
5435
  break;
4825
5436
  }
4826
5437
  throw new Error('现金支付金额必须大于 0');
4827
5438
  case 5:
4828
- _context49.next = 7;
5439
+ _context54.next = 7;
4829
5440
  return this.getCashPaymentConfig();
4830
5441
  case 7:
4831
- config = _context49.sent;
5442
+ config = _context54.sent;
4832
5443
  paymentMethod = config.paymentMethod;
4833
5444
  if (paymentMethod) {
4834
- _context49.next = 11;
5445
+ _context54.next = 11;
4835
5446
  break;
4836
5447
  }
4837
5448
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
4838
5449
  case 11:
4839
5450
  if (!(config.amountDue <= 0)) {
4840
- _context49.next = 13;
5451
+ _context54.next = 13;
4841
5452
  break;
4842
5453
  }
4843
5454
  throw new Error('当前订单没有待支付金额');
@@ -4845,20 +5456,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4845
5456
  roundingAmount = Number(params.roundingAmount || 0);
4846
5457
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4847
5458
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4848
- _context49.next = 17;
5459
+ _context54.next = 17;
4849
5460
  break;
4850
5461
  }
4851
5462
  throw new Error('现金支付金额超过当前待支付金额');
4852
5463
  case 17:
4853
5464
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4854
- beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
5465
+ beforePaymentStatus = (_this$store$order$get7 = this.store.order.getTempOrder()) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.payment_status;
4855
5466
  uniquePaymentNumber = createUuidV4();
4856
5467
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4857
5468
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4858
5469
  changeAmount = Number(params.changeAmount || 0);
4859
- shopWalletPassId = (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.shop_wallet_pass_id;
5470
+ shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
4860
5471
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4861
- _context49.next = 26;
5472
+ _context54.next = 26;
4862
5473
  break;
4863
5474
  }
4864
5475
  throw new Error('顾客实收现金不能小于支付金额');
@@ -4893,8 +5504,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4893
5504
  var _item$metadata2;
4894
5505
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4895
5506
  });
4896
- _context49.prev = 29;
4897
- _context49.next = 32;
5507
+ _context54.prev = 29;
5508
+ _context54.next = 32;
4898
5509
  return this.syncPaymentsToOrder({
4899
5510
  payments: payments,
4900
5511
  submitWhenPaid: true,
@@ -4902,50 +5513,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4902
5513
  confirmPendingVoucherPayments: true
4903
5514
  });
4904
5515
  case 32:
4905
- syncResult = _context49.sent;
5516
+ syncResult = _context54.sent;
4906
5517
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
4907
- _context49.next = 35;
5518
+ _context54.next = 35;
4908
5519
  break;
4909
5520
  }
4910
5521
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
4911
5522
  case 35:
4912
5523
  if (!this.store.payment) {
4913
- _context49.next = 40;
5524
+ _context54.next = 40;
4914
5525
  break;
4915
5526
  }
4916
5527
  committed = this.getCommittedWalletAssets();
4917
5528
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4918
- _context49.next = 40;
4919
- return this.publishWalletAssetsState(walletState);
5529
+ _context54.next = 40;
5530
+ return this.publishWalletAssetsState(walletState, 'local');
4920
5531
  case 40:
4921
- return _context49.abrupt("return", {
5532
+ return _context54.abrupt("return", {
4922
5533
  payment: payment || {},
4923
5534
  payments: this.store.order.getOrderPayments(),
4924
5535
  syncResult: syncResult,
4925
5536
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4926
5537
  });
4927
5538
  case 43:
4928
- _context49.prev = 43;
4929
- _context49.t0 = _context49["catch"](29);
5539
+ _context54.prev = 43;
5540
+ _context54.t0 = _context54["catch"](29);
4930
5541
  this.store.order.setOrderPayments(beforePayments);
4931
5542
  restoredTempOrder = this.store.order.getTempOrder();
4932
5543
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4933
5544
  restoredTempOrder.payment_status = beforePaymentStatus;
4934
5545
  this.store.order.persistTempOrder();
4935
5546
  }
4936
- _context49.next = 50;
5547
+ _context54.next = 50;
4937
5548
  return this.store.order.recalculateSummary({
4938
5549
  createIfMissing: true
4939
5550
  });
4940
5551
  case 50:
4941
- throw _context49.t0;
5552
+ throw _context54.t0;
4942
5553
  case 51:
4943
5554
  case "end":
4944
- return _context49.stop();
5555
+ return _context54.stop();
4945
5556
  }
4946
- }, _callee49, this, [[29, 43]]);
5557
+ }, _callee54, this, [[29, 43]]);
4947
5558
  }));
4948
- function payCash(_x41) {
5559
+ function payCash(_x43) {
4949
5560
  return _payCash.apply(this, arguments);
4950
5561
  }
4951
5562
  return payCash;
@@ -4961,21 +5572,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4961
5572
  }, {
4962
5573
  key: "commitPaymentMethodPayment",
4963
5574
  value: (function () {
4964
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4965
- var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
5575
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5576
+ var _this$store$order$get8, _this$store$order17, _this$store$order$get9, _params$metadata, _params$originAmount;
4966
5577
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4967
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4968
- while (1) switch (_context50.prev = _context50.next) {
5578
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5579
+ while (1) switch (_context55.prev = _context55.next) {
4969
5580
  case 0:
4970
5581
  if (this.store.order) {
4971
- _context50.next = 2;
5582
+ _context55.next = 2;
4972
5583
  break;
4973
5584
  }
4974
5585
  throw new Error('order 模块未初始化');
4975
5586
  case 2:
4976
5587
  amount = Number(params.amount || 0);
4977
5588
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4978
- _context50.next = 5;
5589
+ _context55.next = 5;
4979
5590
  break;
4980
5591
  }
4981
5592
  throw new Error('支付金额必须大于 0');
@@ -4991,38 +5602,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4991
5602
  };
4992
5603
  paymentMethod = findPaymentMethod();
4993
5604
  if (paymentMethod) {
4994
- _context50.next = 13;
5605
+ _context55.next = 13;
4995
5606
  break;
4996
5607
  }
4997
- _context50.next = 11;
5608
+ _context55.next = 11;
4998
5609
  return this.getPaymentMethodsAsync();
4999
5610
  case 11:
5000
- paymentMethods = _context50.sent;
5611
+ paymentMethods = _context55.sent;
5001
5612
  paymentMethod = findPaymentMethod();
5002
5613
  case 13:
5003
5614
  if (paymentMethod) {
5004
- _context50.next = 15;
5615
+ _context55.next = 15;
5005
5616
  break;
5006
5617
  }
5007
5618
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
5008
5619
  case 15:
5009
- 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);
5620
+ amountSnapshot = (_this$store$order$get8 = (_this$store$order17 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order17);
5010
5621
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5011
5622
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5012
5623
  if (!amountDue.lte(0)) {
5013
- _context50.next = 20;
5624
+ _context55.next = 20;
5014
5625
  break;
5015
5626
  }
5016
5627
  throw new Error('当前订单没有待支付金额');
5017
5628
  case 20:
5018
5629
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
5019
- _context50.next = 22;
5630
+ _context55.next = 22;
5020
5631
  break;
5021
5632
  }
5022
5633
  throw new Error('支付金额超过当前待支付金额');
5023
5634
  case 22:
5024
5635
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5025
- beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
5636
+ beforePaymentStatus = (_this$store$order$get9 = this.store.order.getTempOrder()) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.payment_status;
5026
5637
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5027
5638
  metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
5028
5639
  unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
@@ -5055,8 +5666,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5055
5666
  var _item$metadata3;
5056
5667
  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;
5057
5668
  });
5058
- _context50.prev = 30;
5059
- _context50.next = 33;
5669
+ _context55.prev = 30;
5670
+ _context55.next = 33;
5060
5671
  return this.syncPaymentsToOrder({
5061
5672
  payments: payments,
5062
5673
  submitWhenPaid: true,
@@ -5064,50 +5675,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5064
5675
  confirmPendingVoucherPayments: true
5065
5676
  });
5066
5677
  case 33:
5067
- syncResult = _context50.sent;
5678
+ syncResult = _context55.sent;
5068
5679
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5069
- _context50.next = 36;
5680
+ _context55.next = 36;
5070
5681
  break;
5071
5682
  }
5072
5683
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5073
5684
  case 36:
5074
5685
  if (!this.store.payment) {
5075
- _context50.next = 41;
5686
+ _context55.next = 41;
5076
5687
  break;
5077
5688
  }
5078
5689
  committed = this.getCommittedWalletAssets();
5079
5690
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5080
- _context50.next = 41;
5081
- return this.publishWalletAssetsState(walletState);
5691
+ _context55.next = 41;
5692
+ return this.publishWalletAssetsState(walletState, 'local');
5082
5693
  case 41:
5083
- return _context50.abrupt("return", {
5694
+ return _context55.abrupt("return", {
5084
5695
  payment: payment || {},
5085
5696
  payments: this.store.order.getOrderPayments(),
5086
5697
  syncResult: syncResult,
5087
5698
  isOrderFullyPaid: syncResult.isOrderFullyPaid
5088
5699
  });
5089
5700
  case 44:
5090
- _context50.prev = 44;
5091
- _context50.t0 = _context50["catch"](30);
5701
+ _context55.prev = 44;
5702
+ _context55.t0 = _context55["catch"](30);
5092
5703
  this.store.order.setOrderPayments(beforePayments);
5093
5704
  restoredTempOrder = this.store.order.getTempOrder();
5094
5705
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5095
5706
  restoredTempOrder.payment_status = beforePaymentStatus;
5096
5707
  this.store.order.persistTempOrder();
5097
5708
  }
5098
- _context50.next = 51;
5709
+ _context55.next = 51;
5099
5710
  return this.store.order.recalculateSummary({
5100
5711
  createIfMissing: true
5101
5712
  });
5102
5713
  case 51:
5103
- throw _context50.t0;
5714
+ throw _context55.t0;
5104
5715
  case 52:
5105
5716
  case "end":
5106
- return _context50.stop();
5717
+ return _context55.stop();
5107
5718
  }
5108
- }, _callee50, this, [[30, 44]]);
5719
+ }, _callee55, this, [[30, 44]]);
5109
5720
  }));
5110
- function commitPaymentMethodPayment(_x42) {
5721
+ function commitPaymentMethodPayment(_x44) {
5111
5722
  return _commitPaymentMethodPayment.apply(this, arguments);
5112
5723
  }
5113
5724
  return commitPaymentMethodPayment;
@@ -5122,40 +5733,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5122
5733
  }, {
5123
5734
  key: "roundAmount",
5124
5735
  value: (function () {
5125
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5736
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5126
5737
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
5127
5738
  var amount, cashManualPayment;
5128
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5129
- while (1) switch (_context51.prev = _context51.next) {
5739
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5740
+ while (1) switch (_context56.prev = _context56.next) {
5130
5741
  case 0:
5131
5742
  amount = params.amount;
5132
5743
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
5133
5744
  return paymentMethod.code === 'CASHMANUAL';
5134
5745
  });
5135
5746
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
5136
- _context51.next = 4;
5747
+ _context56.next = 4;
5137
5748
  break;
5138
5749
  }
5139
- return _context51.abrupt("return", {
5750
+ return _context56.abrupt("return", {
5140
5751
  originalAmount: amount.toString(),
5141
5752
  roundedAmount: amount.toString(),
5142
5753
  roundingDifference: '0.00'
5143
5754
  });
5144
5755
  case 4:
5145
5756
  if (this.payment) {
5146
- _context51.next = 6;
5757
+ _context56.next = 6;
5147
5758
  break;
5148
5759
  }
5149
5760
  throw new Error('payment 模块未初始化');
5150
5761
  case 6:
5151
- return _context51.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));
5762
+ return _context56.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));
5152
5763
  case 7:
5153
5764
  case "end":
5154
- return _context51.stop();
5765
+ return _context56.stop();
5155
5766
  }
5156
- }, _callee51, this);
5767
+ }, _callee56, this);
5157
5768
  }));
5158
- function roundAmount(_x43) {
5769
+ function roundAmount(_x45) {
5159
5770
  return _roundAmount.apply(this, arguments);
5160
5771
  }
5161
5772
  return roundAmount;
@@ -5170,49 +5781,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5170
5781
  }, {
5171
5782
  key: "sendCustomerPayLink",
5172
5783
  value: (function () {
5173
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5174
- var orderIds, _ref41, _ref42, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5175
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5176
- while (1) switch (_context52.prev = _context52.next) {
5784
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5785
+ var orderIds, _ref48, _ref49, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5786
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5787
+ while (1) switch (_context57.prev = _context57.next) {
5177
5788
  case 0:
5178
5789
  if (this.store.order) {
5179
- _context52.next = 2;
5790
+ _context57.next = 2;
5180
5791
  break;
5181
5792
  }
5182
5793
  throw new Error('order 模块未初始化');
5183
5794
  case 2:
5184
5795
  orderIds = params.order_ids || params.orderIds || [];
5185
5796
  if (!(!orderIds.length || params.submitBeforeSend)) {
5186
- _context52.next = 11;
5797
+ _context57.next = 11;
5187
5798
  break;
5188
5799
  }
5189
- _context52.next = 6;
5800
+ _context57.next = 6;
5190
5801
  return this.submitSalesOrder({
5191
5802
  smallTicketDataFlag: 1
5192
5803
  });
5193
5804
  case 6:
5194
- submitResult = _context52.sent;
5195
- orderId = (_ref41 = (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref41 !== void 0 ? _ref41 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
5805
+ submitResult = _context57.sent;
5806
+ orderId = (_ref48 = (_ref49 = (_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 && _ref49 !== void 0 ? _ref49 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref48 !== void 0 ? _ref48 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
5196
5807
  if (orderId) {
5197
- _context52.next = 10;
5808
+ _context57.next = 10;
5198
5809
  break;
5199
5810
  }
5200
5811
  throw new Error('本地订单提交云端失败,无法发送支付链接');
5201
5812
  case 10:
5202
5813
  orderIds = [orderId];
5203
5814
  case 11:
5204
- return _context52.abrupt("return", this.store.order.sendCustomerPayLink({
5815
+ return _context57.abrupt("return", this.store.order.sendCustomerPayLink({
5205
5816
  emails: params.emails,
5206
5817
  notify_action: params.notify_action,
5207
5818
  order_ids: orderIds
5208
5819
  }));
5209
5820
  case 12:
5210
5821
  case "end":
5211
- return _context52.stop();
5822
+ return _context57.stop();
5212
5823
  }
5213
- }, _callee52, this);
5824
+ }, _callee57, this);
5214
5825
  }));
5215
- function sendCustomerPayLink(_x44) {
5826
+ function sendCustomerPayLink(_x46) {
5216
5827
  return _sendCustomerPayLink.apply(this, arguments);
5217
5828
  }
5218
5829
  return sendCustomerPayLink;
@@ -5225,20 +5836,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5225
5836
  }, {
5226
5837
  key: "calculateProductBookingPrice",
5227
5838
  value: function () {
5228
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5839
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5229
5840
  var _params$customer_id;
5230
5841
  var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
5231
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5232
- while (1) switch (_context53.prev = _context53.next) {
5842
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5843
+ while (1) switch (_context58.prev = _context58.next) {
5233
5844
  case 0:
5234
5845
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
5235
5846
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
5236
5847
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
5237
- _context53.next = 5;
5848
+ _context58.next = 5;
5238
5849
  return this.prepareProductPriceQueryContext(customerId);
5239
5850
  case 5:
5240
5851
  channel = this.getPriceQueryChannel(params.channel);
5241
- _context53.next = 8;
5852
+ _context58.next = 8;
5242
5853
  return this.resolveProductsForPriceQuery({
5243
5854
  priceQueries: [params],
5244
5855
  schedule: this.getPriceQuerySchedule(params),
@@ -5246,22 +5857,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5246
5857
  channel: channel
5247
5858
  });
5248
5859
  case 8:
5249
- _yield$this$resolvePr = _context53.sent;
5860
+ _yield$this$resolvePr = _context58.sent;
5250
5861
  _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
5251
5862
  authoritativeProduct = _yield$this$resolvePr2[0];
5252
5863
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
5253
5864
  if (useCustomerUserPricing) {
5254
- _context53.next = 15;
5865
+ _context58.next = 15;
5255
5866
  break;
5256
5867
  }
5257
- _context53.next = 15;
5868
+ _context58.next = 15;
5258
5869
  return this.loadQuotationForPriceQuery({
5259
5870
  quotation: quotation,
5260
5871
  customer_id: customerId,
5261
5872
  channel: channel
5262
5873
  });
5263
5874
  case 15:
5264
- return _context53.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
5875
+ return _context58.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
5265
5876
  channel: channel,
5266
5877
  product: product,
5267
5878
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -5270,11 +5881,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5270
5881
  })));
5271
5882
  case 16:
5272
5883
  case "end":
5273
- return _context53.stop();
5884
+ return _context58.stop();
5274
5885
  }
5275
- }, _callee53, this);
5886
+ }, _callee58, this);
5276
5887
  }));
5277
- function calculateProductBookingPrice(_x45) {
5888
+ function calculateProductBookingPrice(_x47) {
5278
5889
  return _calculateProductBookingPrice.apply(this, arguments);
5279
5890
  }
5280
5891
  return calculateProductBookingPrice;
@@ -5358,17 +5969,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5358
5969
  }, {
5359
5970
  key: "calculateProductBookingPrices",
5360
5971
  value: function () {
5361
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(paramsList) {
5972
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
5362
5973
  var _this18 = this;
5363
5974
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
5364
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5365
- while (1) switch (_context55.prev = _context55.next) {
5975
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5976
+ while (1) switch (_context60.prev = _context60.next) {
5366
5977
  case 0:
5367
5978
  if (paramsList.length) {
5368
- _context55.next = 2;
5979
+ _context60.next = 2;
5369
5980
  break;
5370
5981
  }
5371
- return _context55.abrupt("return", []);
5982
+ return _context60.abrupt("return", []);
5372
5983
  case 2:
5373
5984
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
5374
5985
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
@@ -5395,20 +6006,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5395
6006
  group.indices.push(index);
5396
6007
  groups.set(groupKey, group);
5397
6008
  });
5398
- _context55.next = 11;
6009
+ _context60.next = 11;
5399
6010
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
5400
- var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(group) {
6011
+ var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(group) {
5401
6012
  var priceQueries, resolvedProducts;
5402
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5403
- while (1) switch (_context54.prev = _context54.next) {
6013
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6014
+ while (1) switch (_context59.prev = _context59.next) {
5404
6015
  case 0:
5405
- _context54.next = 2;
6016
+ _context59.next = 2;
5406
6017
  return _this18.prepareProductPriceQueryContext(group.customerId);
5407
6018
  case 2:
5408
6019
  priceQueries = group.indices.map(function (index) {
5409
6020
  return paramsList[index];
5410
6021
  });
5411
- _context54.next = 5;
6022
+ _context59.next = 5;
5412
6023
  return _this18.resolveProductsForPriceQuery({
5413
6024
  priceQueries: priceQueries,
5414
6025
  schedule: group.schedule,
@@ -5416,23 +6027,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5416
6027
  channel: group.channel
5417
6028
  });
5418
6029
  case 5:
5419
- resolvedProducts = _context54.sent;
6030
+ resolvedProducts = _context59.sent;
5420
6031
  group.indices.forEach(function (originalIndex, groupIndex) {
5421
6032
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
5422
6033
  });
5423
6034
  case 7:
5424
6035
  case "end":
5425
- return _context54.stop();
6036
+ return _context59.stop();
5426
6037
  }
5427
- }, _callee54);
6038
+ }, _callee59);
5428
6039
  }));
5429
- return function (_x47) {
5430
- return _ref43.apply(this, arguments);
6040
+ return function (_x49) {
6041
+ return _ref50.apply(this, arguments);
5431
6042
  };
5432
6043
  }()));
5433
6044
  case 11:
5434
6045
  if (useCustomerUserPricing) {
5435
- _context55.next = 16;
6046
+ _context60.next = 16;
5436
6047
  break;
5437
6048
  }
5438
6049
  quotationContexts = new Map();
@@ -5446,14 +6057,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5446
6057
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
5447
6058
  });
5448
6059
  });
5449
- _context55.next = 16;
6060
+ _context60.next = 16;
5450
6061
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
5451
6062
  return _this18.loadQuotationForPriceQuery(_objectSpread({
5452
6063
  quotation: quotation
5453
6064
  }, context));
5454
6065
  }));
5455
6066
  case 16:
5456
- return _context55.abrupt("return", paramsList.map(function (params, index) {
6067
+ return _context60.abrupt("return", paramsList.map(function (params, index) {
5457
6068
  var _params$customer_id4;
5458
6069
  var productInput = params.product || {};
5459
6070
  var authoritativeProduct = authoritativeProducts[index];
@@ -5470,11 +6081,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5470
6081
  }));
5471
6082
  case 17:
5472
6083
  case "end":
5473
- return _context55.stop();
6084
+ return _context60.stop();
5474
6085
  }
5475
- }, _callee55, this);
6086
+ }, _callee60, this);
5476
6087
  }));
5477
- function calculateProductBookingPrices(_x46) {
6088
+ function calculateProductBookingPrices(_x48) {
5478
6089
  return _calculateProductBookingPrices.apply(this, arguments);
5479
6090
  }
5480
6091
  return calculateProductBookingPrices;
@@ -5482,34 +6093,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5482
6093
  }, {
5483
6094
  key: "addProductToOrder",
5484
6095
  value: function () {
5485
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(product, booking, options) {
6096
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(product, booking, options) {
5486
6097
  var products;
5487
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5488
- while (1) switch (_context56.prev = _context56.next) {
6098
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6099
+ while (1) switch (_context61.prev = _context61.next) {
5489
6100
  case 0:
5490
- _context56.prev = 0;
6101
+ _context61.prev = 0;
5491
6102
  if (this.store.order) {
5492
- _context56.next = 3;
6103
+ _context61.next = 3;
5493
6104
  break;
5494
6105
  }
5495
6106
  throw new Error('order 模块未初始化');
5496
6107
  case 3:
5497
- _context56.next = 5;
6108
+ _context61.next = 5;
5498
6109
  return this.store.order.addProductToOrder(product, booking, options);
5499
6110
  case 5:
5500
- products = _context56.sent;
5501
- return _context56.abrupt("return", products);
6111
+ products = _context61.sent;
6112
+ return _context61.abrupt("return", products);
5502
6113
  case 9:
5503
- _context56.prev = 9;
5504
- _context56.t0 = _context56["catch"](0);
5505
- throw _context56.t0;
6114
+ _context61.prev = 9;
6115
+ _context61.t0 = _context61["catch"](0);
6116
+ throw _context61.t0;
5506
6117
  case 12:
5507
6118
  case "end":
5508
- return _context56.stop();
6119
+ return _context61.stop();
5509
6120
  }
5510
- }, _callee56, this, [[0, 9]]);
6121
+ }, _callee61, this, [[0, 9]]);
5511
6122
  }));
5512
- function addProductToOrder(_x48, _x49, _x50) {
6123
+ function addProductToOrder(_x50, _x51, _x52) {
5513
6124
  return _addProductToOrder.apply(this, arguments);
5514
6125
  }
5515
6126
  return addProductToOrder;
@@ -5517,34 +6128,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5517
6128
  }, {
5518
6129
  key: "updateOrderProduct",
5519
6130
  value: function () {
5520
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
6131
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
5521
6132
  var products;
5522
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5523
- while (1) switch (_context57.prev = _context57.next) {
6133
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6134
+ while (1) switch (_context62.prev = _context62.next) {
5524
6135
  case 0:
5525
- _context57.prev = 0;
6136
+ _context62.prev = 0;
5526
6137
  if (this.store.order) {
5527
- _context57.next = 3;
6138
+ _context62.next = 3;
5528
6139
  break;
5529
6140
  }
5530
6141
  throw new Error('order 模块未初始化');
5531
6142
  case 3:
5532
- _context57.next = 5;
6143
+ _context62.next = 5;
5533
6144
  return this.store.order.updateOrderProduct(params);
5534
6145
  case 5:
5535
- products = _context57.sent;
5536
- return _context57.abrupt("return", products);
6146
+ products = _context62.sent;
6147
+ return _context62.abrupt("return", products);
5537
6148
  case 9:
5538
- _context57.prev = 9;
5539
- _context57.t0 = _context57["catch"](0);
5540
- throw _context57.t0;
6149
+ _context62.prev = 9;
6150
+ _context62.t0 = _context62["catch"](0);
6151
+ throw _context62.t0;
5541
6152
  case 12:
5542
6153
  case "end":
5543
- return _context57.stop();
6154
+ return _context62.stop();
5544
6155
  }
5545
- }, _callee57, this, [[0, 9]]);
6156
+ }, _callee62, this, [[0, 9]]);
5546
6157
  }));
5547
- function updateOrderProduct(_x51) {
6158
+ function updateOrderProduct(_x53) {
5548
6159
  return _updateOrderProduct.apply(this, arguments);
5549
6160
  }
5550
6161
  return updateOrderProduct;
@@ -5552,34 +6163,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5552
6163
  }, {
5553
6164
  key: "updateOrderProducts",
5554
6165
  value: function () {
5555
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(paramsList) {
6166
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(paramsList) {
5556
6167
  var products;
5557
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5558
- while (1) switch (_context58.prev = _context58.next) {
6168
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6169
+ while (1) switch (_context63.prev = _context63.next) {
5559
6170
  case 0:
5560
- _context58.prev = 0;
6171
+ _context63.prev = 0;
5561
6172
  if (this.store.order) {
5562
- _context58.next = 3;
6173
+ _context63.next = 3;
5563
6174
  break;
5564
6175
  }
5565
6176
  throw new Error('order 模块未初始化');
5566
6177
  case 3:
5567
- _context58.next = 5;
6178
+ _context63.next = 5;
5568
6179
  return this.store.order.updateOrderProducts(paramsList);
5569
6180
  case 5:
5570
- products = _context58.sent;
5571
- return _context58.abrupt("return", products);
6181
+ products = _context63.sent;
6182
+ return _context63.abrupt("return", products);
5572
6183
  case 9:
5573
- _context58.prev = 9;
5574
- _context58.t0 = _context58["catch"](0);
5575
- throw _context58.t0;
6184
+ _context63.prev = 9;
6185
+ _context63.t0 = _context63["catch"](0);
6186
+ throw _context63.t0;
5576
6187
  case 12:
5577
6188
  case "end":
5578
- return _context58.stop();
6189
+ return _context63.stop();
5579
6190
  }
5580
- }, _callee58, this, [[0, 9]]);
6191
+ }, _callee63, this, [[0, 9]]);
5581
6192
  }));
5582
- function updateOrderProducts(_x52) {
6193
+ function updateOrderProducts(_x54) {
5583
6194
  return _updateOrderProducts.apply(this, arguments);
5584
6195
  }
5585
6196
  return updateOrderProducts;
@@ -5587,34 +6198,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5587
6198
  }, {
5588
6199
  key: "updateOrderProductQuantity",
5589
6200
  value: function () {
5590
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
6201
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
5591
6202
  var products;
5592
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5593
- while (1) switch (_context59.prev = _context59.next) {
6203
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6204
+ while (1) switch (_context64.prev = _context64.next) {
5594
6205
  case 0:
5595
- _context59.prev = 0;
6206
+ _context64.prev = 0;
5596
6207
  if (this.store.order) {
5597
- _context59.next = 3;
6208
+ _context64.next = 3;
5598
6209
  break;
5599
6210
  }
5600
6211
  throw new Error('order 模块未初始化');
5601
6212
  case 3:
5602
- _context59.next = 5;
6213
+ _context64.next = 5;
5603
6214
  return this.store.order.updateOrderProductQuantity(params);
5604
6215
  case 5:
5605
- products = _context59.sent;
5606
- return _context59.abrupt("return", products);
6216
+ products = _context64.sent;
6217
+ return _context64.abrupt("return", products);
5607
6218
  case 9:
5608
- _context59.prev = 9;
5609
- _context59.t0 = _context59["catch"](0);
5610
- throw _context59.t0;
6219
+ _context64.prev = 9;
6220
+ _context64.t0 = _context64["catch"](0);
6221
+ throw _context64.t0;
5611
6222
  case 12:
5612
6223
  case "end":
5613
- return _context59.stop();
6224
+ return _context64.stop();
5614
6225
  }
5615
- }, _callee59, this, [[0, 9]]);
6226
+ }, _callee64, this, [[0, 9]]);
5616
6227
  }));
5617
- function updateOrderProductQuantity(_x53) {
6228
+ function updateOrderProductQuantity(_x55) {
5618
6229
  return _updateOrderProductQuantity.apply(this, arguments);
5619
6230
  }
5620
6231
  return updateOrderProductQuantity;
@@ -5637,12 +6248,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5637
6248
  }, {
5638
6249
  key: "setOrderProductLineNote",
5639
6250
  value: (function () {
5640
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity, note) {
6251
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, note) {
5641
6252
  var params, products;
5642
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5643
- while (1) switch (_context60.prev = _context60.next) {
6253
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6254
+ while (1) switch (_context65.prev = _context65.next) {
5644
6255
  case 0:
5645
- _context60.prev = 0;
6256
+ _context65.prev = 0;
5646
6257
  params = {
5647
6258
  product_id: identity.product_id,
5648
6259
  product_variant_id: identity.product_variant_id,
@@ -5657,22 +6268,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5657
6268
  params.product_sku = identity.product_sku;
5658
6269
  }
5659
6270
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
5660
- _context60.next = 7;
6271
+ _context65.next = 7;
5661
6272
  return this.updateOrderProduct(params);
5662
6273
  case 7:
5663
- products = _context60.sent;
5664
- return _context60.abrupt("return", products);
6274
+ products = _context65.sent;
6275
+ return _context65.abrupt("return", products);
5665
6276
  case 11:
5666
- _context60.prev = 11;
5667
- _context60.t0 = _context60["catch"](0);
5668
- throw _context60.t0;
6277
+ _context65.prev = 11;
6278
+ _context65.t0 = _context65["catch"](0);
6279
+ throw _context65.t0;
5669
6280
  case 14:
5670
6281
  case "end":
5671
- return _context60.stop();
6282
+ return _context65.stop();
5672
6283
  }
5673
- }, _callee60, this, [[0, 11]]);
6284
+ }, _callee65, this, [[0, 11]]);
5674
6285
  }));
5675
- function setOrderProductLineNote(_x54, _x55) {
6286
+ function setOrderProductLineNote(_x56, _x57) {
5676
6287
  return _setOrderProductLineNote.apply(this, arguments);
5677
6288
  }
5678
6289
  return setOrderProductLineNote;
@@ -5687,32 +6298,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5687
6298
  }, {
5688
6299
  key: "removeProductsFromOrder",
5689
6300
  value: (function () {
5690
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(identities, options) {
5691
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5692
- while (1) switch (_context61.prev = _context61.next) {
6301
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identities, options) {
6302
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6303
+ while (1) switch (_context66.prev = _context66.next) {
5693
6304
  case 0:
5694
- _context61.prev = 0;
6305
+ _context66.prev = 0;
5695
6306
  if (this.store.order) {
5696
- _context61.next = 3;
6307
+ _context66.next = 3;
5697
6308
  break;
5698
6309
  }
5699
6310
  throw new Error('order 模块未初始化');
5700
6311
  case 3:
5701
- _context61.next = 5;
6312
+ _context66.next = 5;
5702
6313
  return this.store.order.removeProductsFromOrder(identities, options);
5703
6314
  case 5:
5704
- return _context61.abrupt("return", _context61.sent);
6315
+ return _context66.abrupt("return", _context66.sent);
5705
6316
  case 8:
5706
- _context61.prev = 8;
5707
- _context61.t0 = _context61["catch"](0);
5708
- throw _context61.t0;
6317
+ _context66.prev = 8;
6318
+ _context66.t0 = _context66["catch"](0);
6319
+ throw _context66.t0;
5709
6320
  case 11:
5710
6321
  case "end":
5711
- return _context61.stop();
6322
+ return _context66.stop();
5712
6323
  }
5713
- }, _callee61, this, [[0, 8]]);
6324
+ }, _callee66, this, [[0, 8]]);
5714
6325
  }));
5715
- function removeProductsFromOrder(_x56, _x57) {
6326
+ function removeProductsFromOrder(_x58, _x59) {
5716
6327
  return _removeProductsFromOrder.apply(this, arguments);
5717
6328
  }
5718
6329
  return removeProductsFromOrder;
@@ -5720,18 +6331,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5720
6331
  }, {
5721
6332
  key: "removeProductFromOrder",
5722
6333
  value: function () {
5723
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, options) {
5724
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5725
- while (1) switch (_context62.prev = _context62.next) {
6334
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identity, options) {
6335
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6336
+ while (1) switch (_context67.prev = _context67.next) {
5726
6337
  case 0:
5727
- return _context62.abrupt("return", this.removeProductsFromOrder([identity], options));
6338
+ return _context67.abrupt("return", this.removeProductsFromOrder([identity], options));
5728
6339
  case 1:
5729
6340
  case "end":
5730
- return _context62.stop();
6341
+ return _context67.stop();
5731
6342
  }
5732
- }, _callee62, this);
6343
+ }, _callee67, this);
5733
6344
  }));
5734
- function removeProductFromOrder(_x58, _x59) {
6345
+ function removeProductFromOrder(_x60, _x61) {
5735
6346
  return _removeProductFromOrder.apply(this, arguments);
5736
6347
  }
5737
6348
  return removeProductFromOrder;
@@ -5781,23 +6392,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5781
6392
  }, {
5782
6393
  key: "applyPromotion",
5783
6394
  value: (function () {
5784
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
5785
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5786
- while (1) switch (_context63.prev = _context63.next) {
6395
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
6396
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6397
+ while (1) switch (_context68.prev = _context68.next) {
5787
6398
  case 0:
5788
6399
  if (this.store.order) {
5789
- _context63.next = 2;
6400
+ _context68.next = 2;
5790
6401
  break;
5791
6402
  }
5792
6403
  throw new Error('order 模块未初始化');
5793
6404
  case 2:
5794
- _context63.next = 4;
6405
+ _context68.next = 4;
5795
6406
  return this.store.order.applyPromotion();
5796
6407
  case 4:
5797
6408
  case "end":
5798
- return _context63.stop();
6409
+ return _context68.stop();
5799
6410
  }
5800
- }, _callee63, this);
6411
+ }, _callee68, this);
5801
6412
  }));
5802
6413
  function applyPromotion() {
5803
6414
  return _applyPromotion.apply(this, arguments);
@@ -5807,16 +6418,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5807
6418
  }, {
5808
6419
  key: "getUnfulfilledPromotions",
5809
6420
  value: function getUnfulfilledPromotions() {
5810
- var _this$store$order16;
5811
- return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
6421
+ var _this$store$order18;
6422
+ return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getUnfulfilledPromotions()) || [];
5812
6423
  }
5813
6424
 
5814
6425
  /** 最近一次促销计算输出的赠品操作 diff。 */
5815
6426
  }, {
5816
6427
  key: "getLastGiftActions",
5817
6428
  value: function getLastGiftActions() {
5818
- var _this$store$order17;
5819
- return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
6429
+ var _this$store$order19;
6430
+ return ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 ? void 0 : _this$store$order19.getLastGiftActions()) || null;
5820
6431
  }
5821
6432
 
5822
6433
  // 获取商品列表
@@ -5824,18 +6435,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5824
6435
  }, {
5825
6436
  key: "getProductList",
5826
6437
  value: function () {
5827
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
5828
- var _this$otherParams35;
6438
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
6439
+ var _this$otherParams36;
5829
6440
  var menu_list_ids, _this$store$products, res;
5830
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
5831
- while (1) switch (_context64.prev = _context64.next) {
6441
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6442
+ while (1) switch (_context69.prev = _context69.next) {
5832
6443
  case 0:
5833
6444
  // 可以直接通过配置里的 menu 读取
5834
- menu_list_ids = ((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 || (_this$otherParams35 = _this$otherParams35.dineInConfig) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35['menu.associated_menus'].map(function (n) {
6445
+ menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
5835
6446
  return Number(n.value);
5836
6447
  })) || [];
5837
- _context64.prev = 1;
5838
- _context64.next = 4;
6448
+ _context69.prev = 1;
6449
+ _context69.next = 4;
5839
6450
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
5840
6451
  menu_list_ids: menu_list_ids,
5841
6452
  cacheId: this.cacheId,
@@ -5843,17 +6454,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5843
6454
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
5844
6455
  });
5845
6456
  case 4:
5846
- res = _context64.sent;
5847
- return _context64.abrupt("return", res);
6457
+ res = _context69.sent;
6458
+ return _context69.abrupt("return", res);
5848
6459
  case 8:
5849
- _context64.prev = 8;
5850
- _context64.t0 = _context64["catch"](1);
5851
- throw _context64.t0;
6460
+ _context69.prev = 8;
6461
+ _context69.t0 = _context69["catch"](1);
6462
+ throw _context69.t0;
5852
6463
  case 11:
5853
6464
  case "end":
5854
- return _context64.stop();
6465
+ return _context69.stop();
5855
6466
  }
5856
- }, _callee64, this, [[1, 8]]);
6467
+ }, _callee69, this, [[1, 8]]);
5857
6468
  }));
5858
6469
  function getProductList() {
5859
6470
  return _getProductList.apply(this, arguments);
@@ -5868,33 +6479,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5868
6479
  }, {
5869
6480
  key: "setOtherParams",
5870
6481
  value: function () {
5871
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
5872
- var _this$otherParams36;
5873
- var _ref44,
5874
- _ref44$cover,
6482
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6483
+ var _this$otherParams37;
6484
+ var _ref51,
6485
+ _ref51$cover,
5875
6486
  cover,
5876
- _args65 = arguments;
5877
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
5878
- while (1) switch (_context65.prev = _context65.next) {
6487
+ _args70 = arguments;
6488
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6489
+ while (1) switch (_context70.prev = _context70.next) {
5879
6490
  case 0:
5880
- _ref44 = _args65.length > 1 && _args65[1] !== undefined ? _args65[1] : {}, _ref44$cover = _ref44.cover, cover = _ref44$cover === void 0 ? false : _ref44$cover;
6491
+ _ref51 = _args70.length > 1 && _args70[1] !== undefined ? _args70[1] : {}, _ref51$cover = _ref51.cover, cover = _ref51$cover === void 0 ? false : _ref51$cover;
5881
6492
  if (cover) {
5882
6493
  this.otherParams = _objectSpread({}, params);
5883
6494
  } else {
5884
6495
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
5885
6496
  }
5886
- this.cacheId = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.cacheId;
5887
- _context65.next = 5;
6497
+ this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
6498
+ _context70.next = 5;
5888
6499
  return this.syncOtherParamsToSubModules(params, {
5889
6500
  cover: cover
5890
6501
  });
5891
6502
  case 5:
5892
6503
  case "end":
5893
- return _context65.stop();
6504
+ return _context70.stop();
5894
6505
  }
5895
- }, _callee65, this);
6506
+ }, _callee70, this);
5896
6507
  }));
5897
- function setOtherParams(_x60) {
6508
+ function setOtherParams(_x62) {
5898
6509
  return _setOtherParams.apply(this, arguments);
5899
6510
  }
5900
6511
  return setOtherParams;