@pisell/pisellos 2.2.301 → 2.2.303

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 (152) 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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
  11. package/dist/modules/Discount/index.d.ts +2 -0
  12. package/dist/modules/Discount/index.js +41 -5
  13. package/dist/modules/Discount/types.d.ts +21 -0
  14. package/dist/modules/OpenData/index.d.ts +15 -2
  15. package/dist/modules/OpenData/index.js +307 -19
  16. package/dist/modules/OpenData/types.d.ts +55 -0
  17. package/dist/modules/OpenData/types.js +7 -1
  18. package/dist/modules/OpenData/utils.d.ts +21 -1
  19. package/dist/modules/OpenData/utils.js +138 -0
  20. package/dist/modules/Order/index.d.ts +50 -7
  21. package/dist/modules/Order/index.js +1690 -815
  22. package/dist/modules/Order/salesNotes.d.ts +31 -0
  23. package/dist/modules/Order/salesNotes.js +492 -0
  24. package/dist/modules/Order/types.d.ts +117 -10
  25. package/dist/modules/Order/types.js +6 -1
  26. package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
  27. package/dist/modules/Order/utils/virtualSettlement.js +284 -0
  28. package/dist/modules/Order/utils.d.ts +5 -1
  29. package/dist/modules/Order/utils.js +138 -33
  30. package/dist/modules/Payment/walletpass.js +20 -21
  31. package/dist/modules/Product/types.d.ts +23 -0
  32. package/dist/modules/ProductList/index.d.ts +2 -1
  33. package/dist/modules/ProductList/index.js +100 -20
  34. package/dist/modules/ProductList/types.d.ts +10 -0
  35. package/dist/modules/Rules/index.d.ts +5 -0
  36. package/dist/modules/Rules/index.js +30 -14
  37. package/dist/modules/SalesSummary/index.d.ts +1 -0
  38. package/dist/modules/SalesSummary/index.js +4 -3
  39. package/dist/modules/SalesSummary/types.d.ts +1 -0
  40. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  41. package/dist/modules/SalesSummary/utils.js +21 -1
  42. package/dist/plugins/request.d.ts +2 -1
  43. package/dist/plugins/request.js +4 -2
  44. package/dist/server/index.d.ts +21 -0
  45. package/dist/server/index.js +1774 -1285
  46. package/dist/server/modules/order/types.d.ts +50 -0
  47. package/dist/server/modules/order/types.js +2 -0
  48. package/dist/server/utils/small-ticket.d.ts +4 -1
  49. package/dist/server/utils/small-ticket.js +461 -96
  50. package/dist/solution/BaseSales/index.d.ts +26 -3
  51. package/dist/solution/BaseSales/index.js +1492 -873
  52. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  53. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  54. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  55. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
  56. package/dist/solution/BookingByStep/index.d.ts +1 -1
  57. package/dist/solution/BookingTicket/index.d.ts +8 -3
  58. package/dist/solution/BookingTicket/index.js +558 -443
  59. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  60. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  61. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  62. package/dist/solution/RegisterAndLogin/config.js +95 -40
  63. package/dist/solution/RegisterAndLogin/index.js +4 -1
  64. package/dist/solution/Sales/index.d.ts +16 -1
  65. package/dist/solution/Sales/index.js +338 -63
  66. package/dist/solution/Sales/types.d.ts +10 -0
  67. package/dist/solution/ScanOrder/index.d.ts +1 -0
  68. package/dist/solution/ScanOrder/index.js +31 -27
  69. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  70. package/dist/solution/ScanOrder/utils.js +2 -0
  71. package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
  72. package/dist/solution/UnifiedBookingSales/index.js +874 -527
  73. package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
  74. package/dist/solution/VenueBooking/index.d.ts +1 -0
  75. package/dist/solution/VenueBooking/index.js +8 -4
  76. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  77. package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
  78. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  79. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  80. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  81. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  82. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  83. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  84. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  85. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  86. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
  87. package/lib/modules/Discount/index.d.ts +2 -0
  88. package/lib/modules/Discount/index.js +34 -2
  89. package/lib/modules/Discount/types.d.ts +21 -0
  90. package/lib/modules/OpenData/index.d.ts +15 -2
  91. package/lib/modules/OpenData/index.js +230 -3
  92. package/lib/modules/OpenData/types.d.ts +55 -0
  93. package/lib/modules/OpenData/types.js +9 -1
  94. package/lib/modules/OpenData/utils.d.ts +21 -1
  95. package/lib/modules/OpenData/utils.js +126 -0
  96. package/lib/modules/Order/index.d.ts +50 -7
  97. package/lib/modules/Order/index.js +704 -64
  98. package/lib/modules/Order/salesNotes.d.ts +31 -0
  99. package/lib/modules/Order/salesNotes.js +382 -0
  100. package/lib/modules/Order/types.d.ts +117 -10
  101. package/lib/modules/Order/types.js +5 -1
  102. package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
  103. package/lib/modules/Order/utils/virtualSettlement.js +262 -0
  104. package/lib/modules/Order/utils.d.ts +5 -1
  105. package/lib/modules/Order/utils.js +127 -21
  106. package/lib/modules/Payment/walletpass.js +14 -11
  107. package/lib/modules/Product/types.d.ts +23 -0
  108. package/lib/modules/ProductList/index.d.ts +2 -1
  109. package/lib/modules/ProductList/index.js +47 -2
  110. package/lib/modules/ProductList/types.d.ts +10 -0
  111. package/lib/modules/Rules/index.d.ts +5 -0
  112. package/lib/modules/Rules/index.js +22 -12
  113. package/lib/modules/SalesSummary/index.d.ts +1 -0
  114. package/lib/modules/SalesSummary/index.js +4 -2
  115. package/lib/modules/SalesSummary/types.d.ts +1 -0
  116. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  117. package/lib/modules/SalesSummary/utils.js +17 -1
  118. package/lib/plugins/request.d.ts +2 -1
  119. package/lib/plugins/request.js +3 -2
  120. package/lib/server/index.d.ts +21 -0
  121. package/lib/server/index.js +492 -108
  122. package/lib/server/modules/order/types.d.ts +50 -0
  123. package/lib/server/modules/order/types.js +1 -0
  124. package/lib/server/utils/small-ticket.d.ts +4 -1
  125. package/lib/server/utils/small-ticket.js +427 -72
  126. package/lib/solution/BaseSales/index.d.ts +26 -3
  127. package/lib/solution/BaseSales/index.js +439 -30
  128. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  129. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  130. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  131. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
  132. package/lib/solution/BookingByStep/index.d.ts +1 -1
  133. package/lib/solution/BookingTicket/index.d.ts +8 -3
  134. package/lib/solution/BookingTicket/index.js +60 -15
  135. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
  136. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  137. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  138. package/lib/solution/RegisterAndLogin/config.js +49 -8
  139. package/lib/solution/RegisterAndLogin/index.js +4 -1
  140. package/lib/solution/Sales/index.d.ts +16 -1
  141. package/lib/solution/Sales/index.js +168 -1
  142. package/lib/solution/Sales/types.d.ts +10 -0
  143. package/lib/solution/ScanOrder/index.d.ts +1 -0
  144. package/lib/solution/ScanOrder/index.js +5 -1
  145. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  146. package/lib/solution/ScanOrder/utils.js +1 -0
  147. package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
  148. package/lib/solution/UnifiedBookingSales/index.js +169 -16
  149. package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
  150. package/lib/solution/VenueBooking/index.d.ts +1 -0
  151. package/lib/solution/VenueBooking/index.js +5 -1
  152. 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) {
@@ -2107,6 +2386,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2107
2386
  if (!this.store.order) throw new Error('order 模块未初始化');
2108
2387
  this.store.order.syncTempOrderNoteToRemote(orderId, note);
2109
2388
  }
2389
+
2390
+ /** 存储用户自定义取餐标识到当前 tempOrder.buzzer。 */
2391
+ }, {
2392
+ key: "setPickupRef",
2393
+ value: function setPickupRef(buzzer) {
2394
+ if (!this.store.order) throw new Error('order 模块未初始化');
2395
+ return this.store.order.updateTempOrderBuzzer(buzzer);
2396
+ }
2110
2397
  }, {
2111
2398
  key: "updateTempOrderShopDiscount",
2112
2399
  value: function updateTempOrderShopDiscount(amount) {
@@ -2119,6 +2406,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2119
2406
  if (!this.store.order) throw new Error('order 模块未初始化');
2120
2407
  return this.store.order.updateTempOrderDepositAmount(amount);
2121
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
+ }
2122
2421
  }, {
2123
2422
  key: "updateTempOrderContactsInfo",
2124
2423
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -2152,40 +2451,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2152
2451
  }, {
2153
2452
  key: "addNewOrder",
2154
2453
  value: function () {
2155
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
2454
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2156
2455
  var tempOrder;
2157
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2158
- while (1) switch (_context16.prev = _context16.next) {
2456
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2457
+ while (1) switch (_context19.prev = _context19.next) {
2159
2458
  case 0:
2160
- _context16.prev = 0;
2459
+ _context19.prev = 0;
2161
2460
  if (this.store.order) {
2162
- _context16.next = 3;
2461
+ _context19.next = 3;
2163
2462
  break;
2164
2463
  }
2165
2464
  throw new Error('order 模块未初始化');
2166
2465
  case 3:
2167
- _context16.next = 5;
2466
+ _context19.next = 5;
2168
2467
  return this.store.order.addNewOrder();
2169
2468
  case 5:
2170
- tempOrder = _context16.sent;
2469
+ tempOrder = _context19.sent;
2171
2470
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2172
- _context16.next = 10;
2471
+ _context19.next = 10;
2173
2472
  break;
2174
2473
  }
2175
2474
  this.store.order.persistTempOrder();
2176
- _context16.next = 10;
2475
+ _context19.next = 10;
2177
2476
  return this.store.order.saveDraft();
2178
2477
  case 10:
2179
- return _context16.abrupt("return", tempOrder);
2478
+ return _context19.abrupt("return", tempOrder);
2180
2479
  case 13:
2181
- _context16.prev = 13;
2182
- _context16.t0 = _context16["catch"](0);
2183
- throw _context16.t0;
2480
+ _context19.prev = 13;
2481
+ _context19.t0 = _context19["catch"](0);
2482
+ throw _context19.t0;
2184
2483
  case 16:
2185
2484
  case "end":
2186
- return _context16.stop();
2485
+ return _context19.stop();
2187
2486
  }
2188
- }, _callee16, this, [[0, 13]]);
2487
+ }, _callee19, this, [[0, 13]]);
2189
2488
  }));
2190
2489
  function addNewOrder() {
2191
2490
  return _addNewOrder.apply(this, arguments);
@@ -2195,22 +2494,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2195
2494
  }, {
2196
2495
  key: "saveDraft",
2197
2496
  value: function () {
2198
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2199
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2200
- 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) {
2201
2500
  case 0:
2202
2501
  if (this.store.order) {
2203
- _context17.next = 2;
2502
+ _context20.next = 2;
2204
2503
  break;
2205
2504
  }
2206
2505
  throw new Error('order 模块未初始化');
2207
2506
  case 2:
2208
- return _context17.abrupt("return", this.store.order.saveDraft());
2507
+ return _context20.abrupt("return", this.store.order.saveDraft());
2209
2508
  case 3:
2210
2509
  case "end":
2211
- return _context17.stop();
2510
+ return _context20.stop();
2212
2511
  }
2213
- }, _callee17, this);
2512
+ }, _callee20, this);
2214
2513
  }));
2215
2514
  function saveDraft() {
2216
2515
  return _saveDraft.apply(this, arguments);
@@ -2221,14 +2520,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2221
2520
  }, {
2222
2521
  key: "restoreOrder",
2223
2522
  value: function () {
2224
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2523
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2225
2524
  var _this$store$payment, tempOrder, appDataChanged, wallet;
2226
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2227
- while (1) switch (_context18.prev = _context18.next) {
2525
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2526
+ while (1) switch (_context21.prev = _context21.next) {
2228
2527
  case 0:
2229
- _context18.prev = 0;
2528
+ _context21.prev = 0;
2230
2529
  if (this.store.order) {
2231
- _context18.next = 3;
2530
+ _context21.next = 3;
2232
2531
  break;
2233
2532
  }
2234
2533
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -2241,37 +2540,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2241
2540
  this.hasManualDiscountSelection = false;
2242
2541
  wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
2243
2542
  if (!wallet) {
2244
- _context18.next = 14;
2543
+ _context21.next = 14;
2245
2544
  break;
2246
2545
  }
2247
2546
  this.walletAssetsRefreshSequence += 1;
2248
2547
  wallet.clearAllCache();
2249
- _context18.next = 14;
2548
+ _context21.next = 14;
2250
2549
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
2251
2550
  case 14:
2252
- _context18.next = 16;
2551
+ _context21.next = 16;
2253
2552
  return this.effectsEmit('onTempOrderReplaced', {
2254
2553
  tempOrder: tempOrder
2255
2554
  });
2256
2555
  case 16:
2257
2556
  if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
2258
- _context18.next = 20;
2557
+ _context21.next = 20;
2259
2558
  break;
2260
2559
  }
2261
2560
  this.store.order.persistTempOrder();
2262
- _context18.next = 20;
2561
+ _context21.next = 20;
2263
2562
  return this.store.order.saveDraft();
2264
2563
  case 20:
2265
- return _context18.abrupt("return", tempOrder);
2564
+ return _context21.abrupt("return", tempOrder);
2266
2565
  case 23:
2267
- _context18.prev = 23;
2268
- _context18.t0 = _context18["catch"](0);
2269
- throw _context18.t0;
2566
+ _context21.prev = 23;
2567
+ _context21.t0 = _context21["catch"](0);
2568
+ throw _context21.t0;
2270
2569
  case 26:
2271
2570
  case "end":
2272
- return _context18.stop();
2571
+ return _context21.stop();
2273
2572
  }
2274
- }, _callee18, this, [[0, 23]]);
2573
+ }, _callee21, this, [[0, 23]]);
2275
2574
  }));
2276
2575
  function restoreOrder() {
2277
2576
  return _restoreOrder.apply(this, arguments);
@@ -2285,22 +2584,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2285
2584
  }, {
2286
2585
  key: "clearOrderCartLines",
2287
2586
  value: (function () {
2288
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2587
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2289
2588
  var tempOrder;
2290
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2291
- while (1) switch (_context19.prev = _context19.next) {
2589
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2590
+ while (1) switch (_context22.prev = _context22.next) {
2292
2591
  case 0:
2293
- _context19.prev = 0;
2592
+ _context22.prev = 0;
2294
2593
  if (this.store.order) {
2295
- _context19.next = 3;
2594
+ _context22.next = 3;
2296
2595
  break;
2297
2596
  }
2298
2597
  throw new Error('order 模块未初始化');
2299
2598
  case 3:
2300
- _context19.next = 5;
2599
+ _context22.next = 5;
2301
2600
  return this.store.order.clearOrderCartLines();
2302
2601
  case 5:
2303
- tempOrder = _context19.sent;
2602
+ tempOrder = _context22.sent;
2304
2603
  if (this.currentSalesDetail) {
2305
2604
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2306
2605
  products: [],
@@ -2310,34 +2609,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2310
2609
  discount_list: []
2311
2610
  });
2312
2611
  }
2313
- _context19.next = 9;
2612
+ _context22.next = 9;
2314
2613
  return this.effectsEmit('onTempOrderReplaced', {
2315
2614
  tempOrder: tempOrder
2316
2615
  });
2317
2616
  case 9:
2318
2617
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2319
- _context19.next = 13;
2618
+ _context22.next = 13;
2320
2619
  break;
2321
2620
  }
2322
2621
  this.store.order.persistTempOrder();
2323
- _context19.next = 13;
2622
+ _context22.next = 13;
2324
2623
  return this.store.order.saveDraft();
2325
2624
  case 13:
2326
- return _context19.abrupt("return", tempOrder);
2625
+ return _context22.abrupt("return", tempOrder);
2327
2626
  case 16:
2328
- _context19.prev = 16;
2329
- _context19.t0 = _context19["catch"](0);
2330
- throw _context19.t0;
2627
+ _context22.prev = 16;
2628
+ _context22.t0 = _context22["catch"](0);
2629
+ throw _context22.t0;
2331
2630
  case 19:
2332
2631
  case "end":
2333
- return _context19.stop();
2632
+ return _context22.stop();
2334
2633
  }
2335
- }, _callee19, this, [[0, 16]]);
2634
+ }, _callee22, this, [[0, 16]]);
2336
2635
  }));
2337
2636
  function clearOrderCartLines() {
2338
2637
  return _clearOrderCartLines.apply(this, arguments);
2339
2638
  }
2340
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;
2341
2680
  }())
2342
2681
  }, {
2343
2682
  key: "getOrderProducts",
@@ -2349,32 +2688,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2349
2688
  }, {
2350
2689
  key: "getSummary",
2351
2690
  value: function () {
2352
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2691
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2353
2692
  var summary;
2354
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2355
- while (1) switch (_context20.prev = _context20.next) {
2693
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2694
+ while (1) switch (_context24.prev = _context24.next) {
2356
2695
  case 0:
2357
- _context20.prev = 0;
2696
+ _context24.prev = 0;
2358
2697
  if (this.store.order) {
2359
- _context20.next = 3;
2698
+ _context24.next = 3;
2360
2699
  break;
2361
2700
  }
2362
2701
  throw new Error('order 模块未初始化');
2363
2702
  case 3:
2364
- _context20.next = 5;
2703
+ _context24.next = 5;
2365
2704
  return this.store.order.getOrderSummary();
2366
2705
  case 5:
2367
- summary = _context20.sent;
2368
- return _context20.abrupt("return", summary);
2706
+ summary = _context24.sent;
2707
+ return _context24.abrupt("return", summary);
2369
2708
  case 9:
2370
- _context20.prev = 9;
2371
- _context20.t0 = _context20["catch"](0);
2372
- throw _context20.t0;
2709
+ _context24.prev = 9;
2710
+ _context24.t0 = _context24["catch"](0);
2711
+ throw _context24.t0;
2373
2712
  case 12:
2374
2713
  case "end":
2375
- return _context20.stop();
2714
+ return _context24.stop();
2376
2715
  }
2377
- }, _callee20, this, [[0, 9]]);
2716
+ }, _callee24, this, [[0, 9]]);
2378
2717
  }));
2379
2718
  function getSummary() {
2380
2719
  return _getSummary.apply(this, arguments);
@@ -2502,14 +2841,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2502
2841
  }, {
2503
2842
  key: "loadDiscountConfig",
2504
2843
  value: function () {
2505
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2844
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2506
2845
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
2507
- 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;
2508
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2509
- 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) {
2510
2849
  case 0:
2511
2850
  if (this.store.order) {
2512
- _context21.next = 2;
2851
+ _context25.next = 2;
2513
2852
  break;
2514
2853
  }
2515
2854
  throw new Error('order 模块未初始化');
@@ -2526,48 +2865,77 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2526
2865
  return discount.isManualSelect;
2527
2866
  });
2528
2867
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
2529
- discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
2530
- 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
+ })));
2531
2879
  if (!(customerId && customerId !== 1)) {
2532
- _context21.next = 25;
2880
+ _context25.next = 27;
2533
2881
  break;
2534
2882
  }
2535
- if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
2536
- _context21.next = 19;
2883
+ if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
2884
+ _context25.next = 21;
2537
2885
  break;
2538
2886
  }
2539
2887
  preparedDiscountList = originalDiscountList;
2540
- _context21.next = 25;
2888
+ _context25.next = 27;
2541
2889
  break;
2542
- case 19:
2543
- _context21.next = 21;
2890
+ case 21:
2891
+ _context25.next = 23;
2544
2892
  return this.store.order.loadDiscountConfig({
2545
2893
  customerId: customerId,
2546
2894
  action: discountAction,
2547
2895
  orderId: Number(orderId) || undefined,
2548
2896
  apply: false
2549
2897
  });
2550
- case 21:
2551
- preparedDiscountList = _context21.sent;
2898
+ case 23:
2899
+ preparedDiscountList = _context25.sent;
2552
2900
  this.discountConfigCacheKey = discountConfigCacheKey;
2553
- _context21.next = 25;
2901
+ _context25.next = 27;
2554
2902
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2555
- 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:
2556
2923
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
2557
- _context21.next = 27;
2924
+ _context25.next = 37;
2558
2925
  break;
2559
2926
  }
2560
- return _context21.abrupt("return", {
2927
+ return _context25.abrupt("return", {
2561
2928
  productList: tempOrder.products || [],
2562
2929
  discountList: currentDiscountList,
2563
- availableWalletIds: this.getAvailableWalletIds()
2930
+ availableWalletIds: this.getAvailableWalletIds(),
2931
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2564
2932
  });
2565
- case 27:
2933
+ case 37:
2566
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 || []);
2567
2935
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2568
- _context21.next = 31;
2936
+ _context25.next = 41;
2569
2937
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2570
- case 31:
2938
+ case 41:
2571
2939
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
2572
2940
  discountAction: discountAction,
2573
2941
  products: tempOrder.products || [],
@@ -2575,32 +2943,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2575
2943
  nextDiscountList: nextDiscountList
2576
2944
  });
2577
2945
  if (!shouldSkipAutoApplyFetchedDiscounts) {
2578
- _context21.next = 40;
2946
+ _context25.next = 50;
2579
2947
  break;
2580
2948
  }
2581
- _context21.next = 35;
2949
+ _context25.next = 45;
2582
2950
  return this.store.order.recalculateSummary({
2583
2951
  createIfMissing: true
2584
2952
  });
2585
- case 35:
2586
- _summary = _context21.sent;
2953
+ case 45:
2954
+ _summary = _context25.sent;
2587
2955
  this.store.order.persistTempOrder();
2588
- _context21.next = 39;
2956
+ _context25.next = 49;
2589
2957
  return this.effectsEmit('onDiscountApplied', {
2590
2958
  productList: tempOrder.products || [],
2591
2959
  discountList: nextDiscountList,
2592
2960
  selectedDiscountList: tempOrder.discount_list || [],
2593
2961
  tempOrder: tempOrder
2594
2962
  });
2595
- case 39:
2596
- return _context21.abrupt("return", {
2963
+ case 49:
2964
+ return _context25.abrupt("return", {
2597
2965
  productList: tempOrder.products || [],
2598
2966
  discountList: nextDiscountList,
2599
- availableWalletIds: this.getAvailableWalletIds()
2967
+ availableWalletIds: this.getAvailableWalletIds(),
2968
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2600
2969
  });
2601
- case 40:
2970
+ case 50:
2602
2971
  if (!rulesModule) {
2603
- _context21.next = 76;
2972
+ _context25.next = 86;
2604
2973
  break;
2605
2974
  }
2606
2975
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
@@ -2620,22 +2989,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2620
2989
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2621
2990
  }
2622
2991
  _iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
2623
- _context21.prev = 45;
2992
+ _context25.prev = 55;
2624
2993
  _iterator3.s();
2625
- case 47:
2994
+ case 57:
2626
2995
  if ((_step3 = _iterator3.n()).done) {
2627
- _context21.next = 62;
2996
+ _context25.next = 72;
2628
2997
  break;
2629
2998
  }
2630
2999
  product = _step3.value;
2631
3000
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2632
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;
2633
3002
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2634
- _context21.next = 53;
3003
+ _context25.next = 63;
2635
3004
  break;
2636
3005
  }
2637
- return _context21.abrupt("continue", 60);
2638
- case 53:
3006
+ return _context25.abrupt("continue", 70);
3007
+ case 63:
2639
3008
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2640
3009
  return sum + Number(pd.amount || 0);
2641
3010
  }, 0);
@@ -2651,61 +3020,62 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2651
3020
  mainPrice: newMainSellingPrice,
2652
3021
  bundle: product.product_bundle
2653
3022
  });
2654
- case 60:
2655
- _context21.next = 47;
3023
+ case 70:
3024
+ _context25.next = 57;
2656
3025
  break;
2657
- case 62:
2658
- _context21.next = 67;
3026
+ case 72:
3027
+ _context25.next = 77;
2659
3028
  break;
2660
- case 64:
2661
- _context21.prev = 64;
2662
- _context21.t0 = _context21["catch"](45);
2663
- _iterator3.e(_context21.t0);
2664
- case 67:
2665
- _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;
2666
3035
  _iterator3.f();
2667
- return _context21.finish(67);
2668
- case 70:
3036
+ return _context25.finish(77);
3037
+ case 80:
2669
3038
  if (!result.discountList) {
2670
- _context21.next = 76;
3039
+ _context25.next = 86;
2671
3040
  break;
2672
3041
  }
2673
3042
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2674
3043
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2675
- _context21.next = 75;
3044
+ _context25.next = 85;
2676
3045
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2677
- case 75:
3046
+ case 85:
2678
3047
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2679
3048
  return discount.isSelected;
2680
3049
  });
2681
- case 76:
2682
- _context21.next = 78;
3050
+ case 86:
3051
+ _context25.next = 88;
2683
3052
  return this.store.order.recalculateSummary({
2684
3053
  createIfMissing: true
2685
3054
  });
2686
- case 78:
2687
- summary = _context21.sent;
3055
+ case 88:
3056
+ summary = _context25.sent;
2688
3057
  this.store.order.persistTempOrder();
2689
- _context21.next = 82;
3058
+ _context25.next = 92;
2690
3059
  return this.effectsEmit('onDiscountApplied', {
2691
3060
  productList: tempOrder.products || [],
2692
3061
  discountList: nextDiscountList,
2693
3062
  selectedDiscountList: tempOrder.discount_list || [],
2694
3063
  tempOrder: tempOrder
2695
3064
  });
2696
- case 82:
2697
- return _context21.abrupt("return", {
3065
+ case 92:
3066
+ return _context25.abrupt("return", {
2698
3067
  productList: tempOrder.products || [],
2699
3068
  discountList: nextDiscountList,
2700
- availableWalletIds: this.getAvailableWalletIds()
3069
+ availableWalletIds: this.getAvailableWalletIds(),
3070
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2701
3071
  });
2702
- case 83:
3072
+ case 93:
2703
3073
  case "end":
2704
- return _context21.stop();
3074
+ return _context25.stop();
2705
3075
  }
2706
- }, _callee21, this, [[45, 64, 67, 70]]);
3076
+ }, _callee25, this, [[55, 74, 77, 80]]);
2707
3077
  }));
2708
- function loadDiscountConfig(_x15) {
3078
+ function loadDiscountConfig(_x17) {
2709
3079
  return _loadDiscountConfig.apply(this, arguments);
2710
3080
  }
2711
3081
  return loadDiscountConfig;
@@ -2717,22 +3087,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2717
3087
  if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2718
3088
  return this.store.order.getAvailableWalletIds();
2719
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
+ }
2720
3097
  }, {
2721
3098
  key: "bestDiscount",
2722
3099
  value: function () {
2723
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cb) {
3100
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(cb) {
2724
3101
  var _discountModule$getOr2, _discountModule$getDi3;
2725
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2726
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2727
- 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) {
2728
3105
  case 0:
2729
3106
  if (this.store.order) {
2730
- _context22.next = 2;
3107
+ _context26.next = 2;
2731
3108
  break;
2732
3109
  }
2733
3110
  throw new Error('order 模块未初始化');
2734
3111
  case 2:
2735
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:
2736
3124
  orderStore = this.store.order.store || {};
2737
3125
  discountModule = orderStore.discount;
2738
3126
  rulesModule = orderStore.rules;
@@ -2743,11 +3131,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2743
3131
  productList: tempOrder.products || [],
2744
3132
  discountList: nextDiscountList
2745
3133
  };
2746
- _context22.next = 12;
3134
+ _context26.next = 16;
2747
3135
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2748
- case 12:
3136
+ case 16:
2749
3137
  if (!rulesModule) {
2750
- _context22.next = 23;
3138
+ _context26.next = 27;
2751
3139
  break;
2752
3140
  }
2753
3141
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -2764,14 +3152,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2764
3152
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2765
3153
  }
2766
3154
  if (!result.discountList) {
2767
- _context22.next = 23;
3155
+ _context26.next = 27;
2768
3156
  break;
2769
3157
  }
2770
3158
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2771
3159
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2772
- _context22.next = 21;
3160
+ _context26.next = 25;
2773
3161
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2774
- case 21:
3162
+ case 25:
2775
3163
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2776
3164
  return discount.isSelected;
2777
3165
  });
@@ -2779,30 +3167,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2779
3167
  productList: tempOrder.products,
2780
3168
  discountList: nextDiscountList
2781
3169
  };
2782
- case 23:
2783
- _context22.next = 25;
3170
+ case 27:
3171
+ _context26.next = 29;
2784
3172
  return this.store.order.recalculateSummary({
2785
3173
  createIfMissing: true
2786
3174
  });
2787
- case 25:
3175
+ case 29:
2788
3176
  this.store.order.persistTempOrder();
2789
- _context22.next = 28;
3177
+ _context26.next = 32;
2790
3178
  return this.effectsEmit('onDiscountApplied', {
2791
3179
  productList: tempOrder.products || [],
2792
3180
  discountList: nextDiscountList,
2793
3181
  selectedDiscountList: tempOrder.discount_list || [],
2794
3182
  tempOrder: tempOrder
2795
3183
  });
2796
- case 28:
3184
+ case 32:
2797
3185
  cb === null || cb === void 0 || cb(result);
2798
- return _context22.abrupt("return", result);
2799
- case 30:
3186
+ return _context26.abrupt("return", result);
3187
+ case 34:
2800
3188
  case "end":
2801
- return _context22.stop();
3189
+ return _context26.stop();
2802
3190
  }
2803
- }, _callee22, this);
3191
+ }, _callee26, this);
2804
3192
  }));
2805
- function bestDiscount(_x16) {
3193
+ function bestDiscount(_x18) {
2806
3194
  return _bestDiscount.apply(this, arguments);
2807
3195
  }
2808
3196
  return bestDiscount;
@@ -2831,41 +3219,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2831
3219
  }, {
2832
3220
  key: "replaceDiscountStoreLists",
2833
3221
  value: (function () {
2834
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
3222
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2835
3223
  var _store2;
2836
3224
  var discountModule;
2837
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2838
- while (1) switch (_context23.prev = _context23.next) {
3225
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3226
+ while (1) switch (_context27.prev = _context27.next) {
2839
3227
  case 0:
2840
3228
  if (this.store.order) {
2841
- _context23.next = 2;
3229
+ _context27.next = 2;
2842
3230
  break;
2843
3231
  }
2844
3232
  throw new Error('order 模块未初始化');
2845
3233
  case 2:
2846
3234
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2847
3235
  if (discountModule) {
2848
- _context23.next = 5;
3236
+ _context27.next = 5;
2849
3237
  break;
2850
3238
  }
2851
- return _context23.abrupt("return");
3239
+ return _context27.abrupt("return");
2852
3240
  case 5:
2853
3241
  if (!params.originalDiscountList) {
2854
- _context23.next = 8;
3242
+ _context27.next = 8;
2855
3243
  break;
2856
3244
  }
2857
- _context23.next = 8;
3245
+ _context27.next = 8;
2858
3246
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
2859
3247
  case 8:
2860
- _context23.next = 10;
3248
+ _context27.next = 10;
2861
3249
  return discountModule.setDiscountList(params.discountList);
2862
3250
  case 10:
2863
3251
  case "end":
2864
- return _context23.stop();
3252
+ return _context27.stop();
2865
3253
  }
2866
- }, _callee23, this);
3254
+ }, _callee27, this);
2867
3255
  }));
2868
- function replaceDiscountStoreLists(_x17) {
3256
+ function replaceDiscountStoreLists(_x19) {
2869
3257
  return _replaceDiscountStoreLists.apply(this, arguments);
2870
3258
  }
2871
3259
  return replaceDiscountStoreLists;
@@ -2873,34 +3261,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2873
3261
  }, {
2874
3262
  key: "scanPromotionCode",
2875
3263
  value: function () {
2876
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(code, customerId) {
3264
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, customerId) {
2877
3265
  var raw, tempOrder;
2878
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2879
- while (1) switch (_context24.prev = _context24.next) {
3266
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3267
+ while (1) switch (_context28.prev = _context28.next) {
2880
3268
  case 0:
2881
- _context24.prev = 0;
3269
+ _context28.prev = 0;
2882
3270
  if (this.store.order) {
2883
- _context24.next = 3;
3271
+ _context28.next = 3;
2884
3272
  break;
2885
3273
  }
2886
3274
  throw new Error('order 模块未初始化');
2887
3275
  case 3:
2888
- _context24.next = 5;
3276
+ _context28.next = 5;
2889
3277
  return this.store.order.scanCode(code, customerId);
2890
3278
  case 5:
2891
- raw = _context24.sent;
3279
+ raw = _context28.sent;
2892
3280
  if (!raw.isAvailable) {
2893
- _context24.next = 13;
3281
+ _context28.next = 13;
2894
3282
  break;
2895
3283
  }
2896
- _context24.next = 9;
3284
+ _context28.next = 9;
2897
3285
  return this.store.order.recalculateSummary({
2898
3286
  createIfMissing: true
2899
3287
  });
2900
3288
  case 9:
2901
3289
  this.store.order.persistTempOrder();
2902
3290
  tempOrder = this.store.order.ensureTempOrder();
2903
- _context24.next = 13;
3291
+ _context28.next = 13;
2904
3292
  return this.effectsEmit('onDiscountApplied', {
2905
3293
  productList: tempOrder.products || [],
2906
3294
  discountList: this.store.order.getDiscountList(),
@@ -2908,7 +3296,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2908
3296
  tempOrder: tempOrder
2909
3297
  });
2910
3298
  case 13:
2911
- return _context24.abrupt("return", _objectSpread(_objectSpread({
3299
+ return _context28.abrupt("return", _objectSpread(_objectSpread({
2912
3300
  isAvailable: raw.isAvailable
2913
3301
  }, raw.isAccepted !== undefined ? {
2914
3302
  isAccepted: raw.isAccepted
@@ -2918,16 +3306,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2918
3306
  scannedDiscountList: raw.scannedDiscountList
2919
3307
  }));
2920
3308
  case 16:
2921
- _context24.prev = 16;
2922
- _context24.t0 = _context24["catch"](0);
2923
- throw _context24.t0;
3309
+ _context28.prev = 16;
3310
+ _context28.t0 = _context28["catch"](0);
3311
+ throw _context28.t0;
2924
3312
  case 19:
2925
3313
  case "end":
2926
- return _context24.stop();
3314
+ return _context28.stop();
2927
3315
  }
2928
- }, _callee24, this, [[0, 16]]);
3316
+ }, _callee28, this, [[0, 16]]);
2929
3317
  }));
2930
- function scanPromotionCode(_x18, _x19) {
3318
+ function scanPromotionCode(_x20, _x21) {
2931
3319
  return _scanPromotionCode.apply(this, arguments);
2932
3320
  }
2933
3321
  return scanPromotionCode;
@@ -2935,18 +3323,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2935
3323
  }, {
2936
3324
  key: "setDiscountSelected",
2937
3325
  value: function () {
2938
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2939
- 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;
2940
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2941
- 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) {
2942
3330
  case 0:
2943
- _context25.prev = 0;
3331
+ _context29.prev = 0;
2944
3332
  if (this.store.order) {
2945
- _context25.next = 3;
3333
+ _context29.next = 3;
2946
3334
  break;
2947
3335
  }
2948
3336
  throw new Error('order 模块未初始化');
2949
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:
2950
3356
  list = this.store.order.getDiscountList();
2951
3357
  updated = list.map(function (d) {
2952
3358
  return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
@@ -2960,9 +3366,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2960
3366
  discountModule = orderStore.discount;
2961
3367
  rulesModule = orderStore.rules;
2962
3368
  nextDiscountList = updated;
2963
- _context25.next = 13;
3369
+ _context29.next = 23;
2964
3370
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2965
- case 13:
3371
+ case 23:
2966
3372
  if (rulesModule) {
2967
3373
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
2968
3374
  result = rulesModule.calcDiscount({
@@ -3022,29 +3428,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3022
3428
  });
3023
3429
  };
3024
3430
  _iterator5 = _createForOfIteratorHelper(tempOrder.products);
3025
- _context25.prev = 17;
3431
+ _context29.prev = 27;
3026
3432
  _iterator5.s();
3027
- case 19:
3433
+ case 29:
3028
3434
  if ((_step5 = _iterator5.n()).done) {
3029
- _context25.next = 36;
3435
+ _context29.next = 46;
3030
3436
  break;
3031
3437
  }
3032
3438
  product = _step5.value;
3033
3439
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
3034
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;
3035
3441
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3036
- _context25.next = 25;
3442
+ _context29.next = 35;
3037
3443
  break;
3038
3444
  }
3039
- return _context25.abrupt("continue", 34);
3040
- case 25:
3445
+ return _context29.abrupt("continue", 44);
3446
+ case 35:
3041
3447
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
3042
3448
  if (Array.isArray(product.product_bundle)) {
3043
3449
  product.product_bundle = product.product_bundle.map(function (bundle) {
3044
- var _ref35, _bundle$original_pric;
3450
+ var _ref42, _bundle$original_pric;
3045
3451
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
3046
3452
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
3047
- 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;
3048
3454
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
3049
3455
  price: restoredBundlePrice,
3050
3456
  bundle_selling_price: restoredBundlePrice
@@ -3071,33 +3477,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3071
3477
  mainPrice: newMainSellingPrice,
3072
3478
  bundle: product.product_bundle
3073
3479
  });
3074
- case 34:
3075
- _context25.next = 19;
3480
+ case 44:
3481
+ _context29.next = 29;
3076
3482
  break;
3077
- case 36:
3078
- _context25.next = 41;
3483
+ case 46:
3484
+ _context29.next = 51;
3079
3485
  break;
3080
- case 38:
3081
- _context25.prev = 38;
3082
- _context25.t0 = _context25["catch"](17);
3083
- _iterator5.e(_context25.t0);
3084
- case 41:
3085
- _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;
3086
3492
  _iterator5.f();
3087
- return _context25.finish(41);
3088
- case 44:
3493
+ return _context29.finish(51);
3494
+ case 54:
3089
3495
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3090
- _context25.next = 47;
3496
+ _context29.next = 57;
3091
3497
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3092
- case 47:
3498
+ case 57:
3093
3499
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
3094
3500
  return d.isSelected;
3095
3501
  });
3096
- _context25.next = 50;
3502
+ _context29.next = 60;
3097
3503
  return this.store.order.recalculateSummary({
3098
3504
  createIfMissing: true
3099
3505
  });
3100
- case 50:
3506
+ case 60:
3101
3507
  this.store.order.persistTempOrder();
3102
3508
  this.effectsEmit('onDiscountApplied', {
3103
3509
  productList: tempOrder.products,
@@ -3105,19 +3511,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3105
3511
  selectedDiscountList: tempOrder.discount_list,
3106
3512
  tempOrder: tempOrder
3107
3513
  });
3108
- _context25.next = 57;
3514
+ _context29.next = 67;
3109
3515
  break;
3110
- case 54:
3111
- _context25.prev = 54;
3112
- _context25.t1 = _context25["catch"](0);
3113
- throw _context25.t1;
3114
- case 57:
3516
+ case 64:
3517
+ _context29.prev = 64;
3518
+ _context29.t1 = _context29["catch"](0);
3519
+ throw _context29.t1;
3520
+ case 67:
3115
3521
  case "end":
3116
- return _context25.stop();
3522
+ return _context29.stop();
3117
3523
  }
3118
- }, _callee25, this, [[0, 54], [17, 38, 41, 44]]);
3524
+ }, _callee29, this, [[0, 64], [27, 48, 51, 54]]);
3119
3525
  }));
3120
- function setDiscountSelected(_x20) {
3526
+ function setDiscountSelected(_x22) {
3121
3527
  return _setDiscountSelected.apply(this, arguments);
3122
3528
  }
3123
3529
  return setDiscountSelected;
@@ -3125,23 +3531,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3125
3531
  }, {
3126
3532
  key: "applyDiscountCalculationResult",
3127
3533
  value: function () {
3128
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(result) {
3534
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(result) {
3129
3535
  var tempOrder, orderStore, discountModule;
3130
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3131
- while (1) switch (_context26.prev = _context26.next) {
3536
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3537
+ while (1) switch (_context30.prev = _context30.next) {
3132
3538
  case 0:
3133
- _context26.prev = 0;
3539
+ _context30.prev = 0;
3134
3540
  if (this.store.order) {
3135
- _context26.next = 3;
3541
+ _context30.next = 3;
3136
3542
  break;
3137
3543
  }
3138
3544
  throw new Error('order 模块未初始化');
3139
3545
  case 3:
3140
3546
  if (result) {
3141
- _context26.next = 5;
3547
+ _context30.next = 5;
3142
3548
  break;
3143
3549
  }
3144
- return _context26.abrupt("return");
3550
+ return _context30.abrupt("return");
3145
3551
  case 5:
3146
3552
  tempOrder = this.store.order.ensureTempOrder();
3147
3553
  orderStore = this.store.order.store || {};
@@ -3150,24 +3556,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3150
3556
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3151
3557
  }
3152
3558
  if (!result.discountList) {
3153
- _context26.next = 14;
3559
+ _context30.next = 14;
3154
3560
  break;
3155
3561
  }
3156
3562
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
3157
- _context26.next = 13;
3563
+ _context30.next = 13;
3158
3564
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
3159
3565
  case 13:
3160
3566
  tempOrder.discount_list = result.discountList.filter(function (discount) {
3161
3567
  return discount.isSelected;
3162
3568
  });
3163
3569
  case 14:
3164
- _context26.next = 16;
3570
+ _context30.next = 16;
3165
3571
  return this.store.order.recalculateSummary({
3166
3572
  createIfMissing: true
3167
3573
  });
3168
3574
  case 16:
3169
3575
  this.store.order.persistTempOrder();
3170
- _context26.next = 19;
3576
+ _context30.next = 19;
3171
3577
  return this.effectsEmit('onDiscountApplied', {
3172
3578
  productList: tempOrder.products || [],
3173
3579
  discountList: result.discountList || [],
@@ -3175,19 +3581,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3175
3581
  tempOrder: tempOrder
3176
3582
  });
3177
3583
  case 19:
3178
- _context26.next = 24;
3584
+ _context30.next = 24;
3179
3585
  break;
3180
3586
  case 21:
3181
- _context26.prev = 21;
3182
- _context26.t0 = _context26["catch"](0);
3183
- throw _context26.t0;
3587
+ _context30.prev = 21;
3588
+ _context30.t0 = _context30["catch"](0);
3589
+ throw _context30.t0;
3184
3590
  case 24:
3185
3591
  case "end":
3186
- return _context26.stop();
3592
+ return _context30.stop();
3187
3593
  }
3188
- }, _callee26, this, [[0, 21]]);
3594
+ }, _callee30, this, [[0, 21]]);
3189
3595
  }));
3190
- function applyDiscountCalculationResult(_x21) {
3596
+ function applyDiscountCalculationResult(_x23) {
3191
3597
  return _applyDiscountCalculationResult.apply(this, arguments);
3192
3598
  }
3193
3599
  return applyDiscountCalculationResult;
@@ -3195,22 +3601,178 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3195
3601
  }, {
3196
3602
  key: "submitScanOrder",
3197
3603
  value: function () {
3198
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3199
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3200
- 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) {
3201
3607
  case 0:
3202
- return _context27.abrupt("return", this.submitSalesOrder(params));
3608
+ return _context31.abrupt("return", this.submitSalesOrder(params));
3203
3609
  case 1:
3204
3610
  case "end":
3205
- return _context27.stop();
3611
+ return _context31.stop();
3206
3612
  }
3207
- }, _callee27, this);
3613
+ }, _callee31, this);
3208
3614
  }));
3209
- function submitScanOrder(_x22) {
3615
+ function submitScanOrder(_x24) {
3210
3616
  return _submitScanOrder.apply(this, arguments);
3211
3617
  }
3212
3618
  return submitScanOrder;
3213
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
+ }()
3214
3776
  /**
3215
3777
  * 提交当前 Sales 订单。
3216
3778
  *
@@ -3220,48 +3782,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3220
3782
  }, {
3221
3783
  key: "submitSalesOrder",
3222
3784
  value: (function () {
3223
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3224
- var _params$smallTicketDa, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
3225
- var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
3226
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3227
- 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) {
3228
3790
  case 0:
3229
3791
  if (this.store.order) {
3230
- _context28.next = 2;
3792
+ _context33.next = 2;
3231
3793
  break;
3232
3794
  }
3233
3795
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3234
3796
  case 2:
3797
+ _context33.next = 4;
3798
+ return this.buildVirtualSettlementSubmitData();
3799
+ case 4:
3800
+ virtualSettlement = _context33.sent;
3235
3801
  // this.store.order.persistTempOrder();
3236
3802
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
3237
3803
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
3238
- 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);
3239
3805
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
3240
3806
  cacheId: this.cacheId,
3241
- platform: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.platform,
3242
- 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),
3243
3809
  channel: this.getSubmitOrderSalesChannel(),
3244
- 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,
3245
3811
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
3246
- }, (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 ? {
3247
3815
  payments: params.payments
3248
3816
  } : {}), inferredPaymentStatus !== undefined ? {
3249
3817
  paymentStatus: inferredPaymentStatus
3250
3818
  } : {}), smallTicketDataFlag !== undefined ? {
3251
3819
  smallTicketDataFlag: smallTicketDataFlag
3252
- } : {}), (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 ? {
3253
3823
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
3254
- } : {}), enhancePayload !== undefined ? {
3255
- 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
3256
3844
  } : {});
3257
- return _context28.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
3258
- case 7:
3845
+ return _context33.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
3846
+ case 10:
3259
3847
  case "end":
3260
- return _context28.stop();
3848
+ return _context33.stop();
3261
3849
  }
3262
- }, _callee28, this);
3850
+ }, _callee33, this);
3263
3851
  }));
3264
- function submitSalesOrder(_x23) {
3852
+ function submitSalesOrder(_x25) {
3265
3853
  return _submitSalesOrder.apply(this, arguments);
3266
3854
  }
3267
3855
  return submitSalesOrder;
@@ -3269,33 +3857,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3269
3857
  }, {
3270
3858
  key: "saveSalesOrderDraft",
3271
3859
  value: function () {
3272
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3273
- var _params$platform, _this$otherParams17, _this$otherParams18, _this$otherParams19, _params$channel, _params$type, _this$otherParams20;
3274
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3275
- 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) {
3276
3864
  case 0:
3277
3865
  if (this.store.order) {
3278
- _context29.next = 2;
3866
+ _context34.next = 2;
3279
3867
  break;
3280
3868
  }
3281
3869
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3282
3870
  case 2:
3283
- return _context29.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
3871
+ return _context34.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
3284
3872
  cacheId: this.cacheId,
3285
- 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,
3286
- 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),
3287
3875
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
3288
- 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
3289
3877
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
3290
3878
  enhancePayload: params.enhancePayload
3291
3879
  } : {})));
3292
3880
  case 3:
3293
3881
  case "end":
3294
- return _context29.stop();
3882
+ return _context34.stop();
3295
3883
  }
3296
- }, _callee29, this);
3884
+ }, _callee34, this);
3297
3885
  }));
3298
- function saveSalesOrderDraft(_x24) {
3886
+ function saveSalesOrderDraft(_x26) {
3299
3887
  return _saveSalesOrderDraft.apply(this, arguments);
3300
3888
  }
3301
3889
  return saveSalesOrderDraft;
@@ -3303,27 +3891,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3303
3891
  }, {
3304
3892
  key: "submitTempOrderAsync",
3305
3893
  value: function () {
3306
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3307
- 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;
3308
3896
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
3309
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3310
- while (1) switch (_context30.prev = _context30.next) {
3897
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3898
+ while (1) switch (_context35.prev = _context35.next) {
3311
3899
  case 0:
3312
3900
  if (this.store.order) {
3313
- _context30.next = 2;
3901
+ _context35.next = 2;
3314
3902
  break;
3315
3903
  }
3316
3904
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3317
3905
  case 2:
3318
3906
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
3319
3907
  smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
3320
- 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);
3321
3909
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
3322
3910
  cacheId: this.cacheId,
3323
- platform: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform,
3324
- 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),
3325
3913
  channel: this.getSubmitOrderSalesChannel(),
3326
- 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,
3327
3915
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
3328
3916
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
3329
3917
  payments: params.payments
@@ -3336,14 +3924,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3336
3924
  } : {}), enhancePayload !== undefined ? {
3337
3925
  enhancePayload: enhancePayload
3338
3926
  } : {});
3339
- return _context30.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3927
+ return _context35.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3340
3928
  case 7:
3341
3929
  case "end":
3342
- return _context30.stop();
3930
+ return _context35.stop();
3343
3931
  }
3344
- }, _callee30, this);
3932
+ }, _callee35, this);
3345
3933
  }));
3346
- function submitTempOrderAsync(_x25) {
3934
+ function submitTempOrderAsync(_x27) {
3347
3935
  return _submitTempOrderAsync.apply(this, arguments);
3348
3936
  }
3349
3937
  return submitTempOrderAsync;
@@ -3355,8 +3943,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3355
3943
  }, {
3356
3944
  key: "shouldUseCheckoutSyncTask",
3357
3945
  value: function shouldUseCheckoutSyncTask() {
3358
- var _this$otherParams25;
3359
- 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;
3360
3948
  return typeof configured === 'boolean' ? configured : true;
3361
3949
  }
3362
3950
 
@@ -3369,14 +3957,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3369
3957
  }, {
3370
3958
  key: "printLocalOrderReceipt",
3371
3959
  value: function () {
3372
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(lookup) {
3373
- var _this$otherParams26, _this$otherParams27, _this$otherParams28, _this$otherParams29;
3374
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
3375
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3376
- 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) {
3377
3965
  case 0:
3378
3966
  if (this.store.order) {
3379
- _context31.next = 2;
3967
+ _context36.next = 2;
3380
3968
  break;
3381
3969
  }
3382
3970
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -3388,10 +3976,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3388
3976
  external_sale_number: lookup
3389
3977
  };
3390
3978
  context = {
3391
- platform: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform,
3392
- 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),
3393
3981
  channel: this.getSubmitOrderSalesChannel(),
3394
- 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
3395
3983
  };
3396
3984
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
3397
3985
  lookup_order_from_db: 1,
@@ -3407,28 +3995,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3407
3995
  channel: context.channel,
3408
3996
  type: context.type
3409
3997
  });
3410
- _context31.next = 8;
3411
- 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, {
3412
4007
  osServer: true,
3413
4008
  customToast: function customToast() {}
3414
4009
  });
3415
- case 8:
3416
- response = _context31.sent;
4010
+ case 11:
4011
+ response = _context36.sent;
3417
4012
  if (hasLookup) {
3418
- _context31.next = 12;
4013
+ _context36.next = 15;
3419
4014
  break;
3420
4015
  }
3421
- _context31.next = 12;
3422
- 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);
3423
- case 12:
3424
- return _context31.abrupt("return", response);
3425
- 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:
3426
4021
  case "end":
3427
- return _context31.stop();
4022
+ return _context36.stop();
3428
4023
  }
3429
- }, _callee31, this);
4024
+ }, _callee36, this);
3430
4025
  }));
3431
- function printLocalOrderReceipt(_x26) {
4026
+ function printLocalOrderReceipt(_x28) {
3432
4027
  return _printLocalOrderReceipt.apply(this, arguments);
3433
4028
  }
3434
4029
  return printLocalOrderReceipt;
@@ -3436,9 +4031,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3436
4031
  }, {
3437
4032
  key: "getSubmitPaymentStatus",
3438
4033
  value: function getSubmitPaymentStatus(paymentStatus) {
3439
- var _this$store$order6, _this$store$order6$ge;
4034
+ var _this$store$order7, _this$store$order7$ge;
3440
4035
  if (paymentStatus !== undefined) return paymentStatus;
3441
- 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);
3442
4037
  if (!amountSnapshot) return undefined;
3443
4038
  try {
3444
4039
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -3449,21 +4044,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3449
4044
  }, {
3450
4045
  key: "syncPaymentsToOrder",
3451
4046
  value: function () {
3452
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3453
- 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;
3454
4049
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
3455
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3456
- while (1) switch (_context32.prev = _context32.next) {
4050
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4051
+ while (1) switch (_context37.prev = _context37.next) {
3457
4052
  case 0:
3458
4053
  if (this.store.order) {
3459
- _context32.next = 2;
4054
+ _context37.next = 2;
3460
4055
  break;
3461
4056
  }
3462
4057
  throw new Error('order 模块未初始化');
3463
4058
  case 2:
3464
- 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;
3465
4060
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
3466
- enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params.enhancePayload);
4061
+ enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
3467
4062
  syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
3468
4063
  checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
3469
4064
  }, businessCode !== undefined ? {
@@ -3475,14 +4070,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3475
4070
  } : {});
3476
4071
  syncState = this.store.order.getOrderSyncState();
3477
4072
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
3478
- _context32.next = 10;
4073
+ _context37.next = 10;
3479
4074
  break;
3480
4075
  }
3481
4076
  this.queueLatestAutoPaymentSync();
3482
- return _context32.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4077
+ return _context37.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3483
4078
  case 10:
3484
4079
  payments = params.payments || [];
3485
- _context32.next = 13;
4080
+ _context37.next = 13;
3486
4081
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
3487
4082
  payments: payments,
3488
4083
  params: syncParams,
@@ -3490,11 +4085,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3490
4085
  orderSnapshot: this.store.order.getOrderSnapshot()
3491
4086
  });
3492
4087
  case 13:
3493
- _context32.prev = 13;
3494
- _context32.next = 16;
4088
+ _context37.prev = 13;
4089
+ _context37.next = 16;
3495
4090
  return this.store.order.syncPaymentsToOrder(syncParams);
3496
4091
  case 16:
3497
- syncResult = _context32.sent;
4092
+ syncResult = _context37.sent;
3498
4093
  latestPayments = this.store.order.getOrderPayments();
3499
4094
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
3500
4095
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -3512,25 +4107,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3512
4107
  depositAmount: syncResult.depositAmount,
3513
4108
  orderExpectedAmount: syncResult.orderExpectedAmount
3514
4109
  };
3515
- _context32.next = 23;
4110
+ _context37.next = 23;
3516
4111
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
3517
4112
  case 23:
3518
4113
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
3519
- _context32.next = 26;
4114
+ _context37.next = 26;
3520
4115
  break;
3521
4116
  }
3522
- _context32.next = 26;
4117
+ _context37.next = 26;
3523
4118
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
3524
4119
  case 26:
3525
4120
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3526
- return _context32.abrupt("return", syncResult);
4121
+ return _context37.abrupt("return", syncResult);
3527
4122
  case 30:
3528
- _context32.prev = 30;
3529
- _context32.t0 = _context32["catch"](13);
3530
- _context32.next = 34;
4123
+ _context37.prev = 30;
4124
+ _context37.t0 = _context37["catch"](13);
4125
+ _context37.next = 34;
3531
4126
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
3532
4127
  ok: false,
3533
- error: _context32.t0,
4128
+ error: _context37.t0,
3534
4129
  payments: this.store.order.getOrderPayments(),
3535
4130
  params: syncParams,
3536
4131
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -3538,14 +4133,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3538
4133
  });
3539
4134
  case 34:
3540
4135
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3541
- throw _context32.t0;
4136
+ throw _context37.t0;
3542
4137
  case 36:
3543
4138
  case "end":
3544
- return _context32.stop();
4139
+ return _context37.stop();
3545
4140
  }
3546
- }, _callee32, this, [[13, 30]]);
4141
+ }, _callee37, this, [[13, 30]]);
3547
4142
  }));
3548
- function syncPaymentsToOrder(_x27) {
4143
+ function syncPaymentsToOrder(_x29) {
3549
4144
  return _syncPaymentsToOrder.apply(this, arguments);
3550
4145
  }
3551
4146
  return syncPaymentsToOrder;
@@ -3594,46 +4189,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3594
4189
  }, {
3595
4190
  key: "flushQueuedAutoPaymentSync",
3596
4191
  value: function () {
3597
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
4192
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3598
4193
  var payments;
3599
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3600
- while (1) switch (_context33.prev = _context33.next) {
4194
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4195
+ while (1) switch (_context38.prev = _context38.next) {
3601
4196
  case 0:
3602
4197
  if (this.store.order) {
3603
- _context33.next = 2;
4198
+ _context38.next = 2;
3604
4199
  break;
3605
4200
  }
3606
- return _context33.abrupt("return");
4201
+ return _context38.abrupt("return");
3607
4202
  case 2:
3608
4203
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3609
- _context33.next = 4;
4204
+ _context38.next = 4;
3610
4205
  break;
3611
4206
  }
3612
- return _context33.abrupt("return");
4207
+ return _context38.abrupt("return");
3613
4208
  case 4:
3614
4209
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3615
- _context33.next = 7;
4210
+ _context38.next = 7;
3616
4211
  break;
3617
4212
  }
3618
4213
  this.scheduleQueuedAutoPaymentSyncFlush();
3619
- return _context33.abrupt("return");
4214
+ return _context38.abrupt("return");
3620
4215
  case 7:
3621
4216
  this.autoPaymentSyncFlushing = true;
3622
- _context33.prev = 8;
4217
+ _context38.prev = 8;
3623
4218
  case 9:
3624
4219
  if (!this.queuedAutoPaymentSync) {
3625
- _context33.next = 18;
4220
+ _context38.next = 18;
3626
4221
  break;
3627
4222
  }
3628
4223
  this.queuedAutoPaymentSync = false;
3629
4224
  payments = this.store.order.getOrderPayments();
3630
4225
  if (payments.length) {
3631
- _context33.next = 14;
4226
+ _context38.next = 14;
3632
4227
  break;
3633
4228
  }
3634
- return _context33.abrupt("continue", 9);
4229
+ return _context38.abrupt("continue", 9);
3635
4230
  case 14:
3636
- _context33.next = 16;
4231
+ _context38.next = 16;
3637
4232
  return this.syncPaymentsToOrder({
3638
4233
  payments: payments,
3639
4234
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3641,29 +4236,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3641
4236
  smallTicketDataFlag: 1
3642
4237
  });
3643
4238
  case 16:
3644
- _context33.next = 9;
4239
+ _context38.next = 9;
3645
4240
  break;
3646
4241
  case 18:
3647
- _context33.next = 23;
4242
+ _context38.next = 23;
3648
4243
  break;
3649
4244
  case 20:
3650
- _context33.prev = 20;
3651
- _context33.t0 = _context33["catch"](8);
4245
+ _context38.prev = 20;
4246
+ _context38.t0 = _context38["catch"](8);
3652
4247
  this.logError('queued auto sync payments failed', {
3653
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
4248
+ error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
3654
4249
  });
3655
4250
  case 23:
3656
- _context33.prev = 23;
4251
+ _context38.prev = 23;
3657
4252
  this.autoPaymentSyncFlushing = false;
3658
4253
  if (this.queuedAutoPaymentSync) {
3659
4254
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3660
4255
  }
3661
- return _context33.finish(23);
4256
+ return _context38.finish(23);
3662
4257
  case 27:
3663
4258
  case "end":
3664
- return _context33.stop();
4259
+ return _context38.stop();
3665
4260
  }
3666
- }, _callee33, this, [[8, 20, 23, 27]]);
4261
+ }, _callee38, this, [[8, 20, 23, 27]]);
3667
4262
  }));
3668
4263
  function flushQueuedAutoPaymentSync() {
3669
4264
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -3687,35 +4282,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3687
4282
  }, {
3688
4283
  key: "addOrderPaymentAsync",
3689
4284
  value: (function () {
3690
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(payment) {
4285
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payment) {
3691
4286
  var paymentRecord, hasPaymentNumber, devicePrefix;
3692
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3693
- while (1) switch (_context34.prev = _context34.next) {
4287
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4288
+ while (1) switch (_context39.prev = _context39.next) {
3694
4289
  case 0:
3695
4290
  paymentRecord = payment;
3696
4291
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3697
4292
  if (!hasPaymentNumber) {
3698
- _context34.next = 6;
4293
+ _context39.next = 6;
3699
4294
  break;
3700
4295
  }
3701
- _context34.t0 = 'LOCAL';
3702
- _context34.next = 9;
4296
+ _context39.t0 = 'LOCAL';
4297
+ _context39.next = 9;
3703
4298
  break;
3704
4299
  case 6:
3705
- _context34.next = 8;
4300
+ _context39.next = 8;
3706
4301
  return this.getPaymentNumberDevicePrefixAsync();
3707
4302
  case 8:
3708
- _context34.t0 = _context34.sent;
4303
+ _context39.t0 = _context39.sent;
3709
4304
  case 9:
3710
- devicePrefix = _context34.t0;
3711
- return _context34.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4305
+ devicePrefix = _context39.t0;
4306
+ return _context39.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3712
4307
  case 11:
3713
4308
  case "end":
3714
- return _context34.stop();
4309
+ return _context39.stop();
3715
4310
  }
3716
- }, _callee34, this);
4311
+ }, _callee39, this);
3717
4312
  }));
3718
- function addOrderPaymentAsync(_x28) {
4313
+ function addOrderPaymentAsync(_x30) {
3719
4314
  return _addOrderPaymentAsync.apply(this, arguments);
3720
4315
  }
3721
4316
  return addOrderPaymentAsync;
@@ -3723,10 +4318,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3723
4318
  }, {
3724
4319
  key: "addOrderPaymentWithDevicePrefix",
3725
4320
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3726
- var _this$otherParams32,
4321
+ var _this$otherParams33,
3727
4322
  _paymentRecord$paymen,
3728
4323
  _paymentRecord$create,
3729
- _ref37,
4324
+ _ref44,
3730
4325
  _paymentRecord$origin,
3731
4326
  _this16 = this;
3732
4327
  if (!this.store.order) throw new Error('order 模块未初始化');
@@ -3739,7 +4334,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3739
4334
  return this.store.order.getOrderPayments();
3740
4335
  }
3741
4336
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3742
- 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;
3743
4338
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3744
4339
  metadata.shop_wallet_pass_id = shopWalletPassId;
3745
4340
  }
@@ -3748,7 +4343,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3748
4343
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3749
4344
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3750
4345
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3751
- 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;
3752
4347
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3753
4348
  service_fee: calculatedServiceFee
3754
4349
  } : {}), {}, {
@@ -3784,7 +4379,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3784
4379
  }, {
3785
4380
  key: "updateOrderPayment",
3786
4381
  value: (function () {
3787
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paymentIdentity, updates) {
4382
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paymentIdentity, updates) {
3788
4383
  var _result$payment, _result$payment2;
3789
4384
  var options,
3790
4385
  matchMode,
@@ -3801,13 +4396,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3801
4396
  shouldSubmit,
3802
4397
  syncResult,
3803
4398
  _options$smallTicketD2,
3804
- _args35 = arguments;
3805
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3806
- 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) {
3807
4402
  case 0:
3808
- options = _args35.length > 2 && _args35[2] !== undefined ? _args35[2] : {};
4403
+ options = _args40.length > 2 && _args40[2] !== undefined ? _args40[2] : {};
3809
4404
  if (this.store.order) {
3810
- _context35.next = 3;
4405
+ _context40.next = 3;
3811
4406
  break;
3812
4407
  }
3813
4408
  throw new Error('order 模块未初始化');
@@ -3816,15 +4411,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3816
4411
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3817
4412
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3818
4413
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3819
- _context35.next = 13;
4414
+ _context40.next = 13;
3820
4415
  break;
3821
4416
  }
3822
4417
  currentPayments = this.store.order.getOrderPayments();
3823
4418
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3824
- _context35.next = 12;
4419
+ _context40.next = 12;
3825
4420
  break;
3826
4421
  }
3827
- _context35.next = 11;
4422
+ _context40.next = 11;
3828
4423
  return this.syncPaymentsToOrder({
3829
4424
  payments: currentPayments,
3830
4425
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -3832,9 +4427,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3832
4427
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3833
4428
  });
3834
4429
  case 11:
3835
- _syncResult = _context35.sent;
4430
+ _syncResult = _context40.sent;
3836
4431
  case 12:
3837
- return _context35.abrupt("return", _objectSpread({
4432
+ return _context40.abrupt("return", _objectSpread({
3838
4433
  updated: false,
3839
4434
  payment: previousPayment,
3840
4435
  payments: currentPayments,
@@ -3843,44 +4438,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3843
4438
  syncResult: _syncResult
3844
4439
  } : {}));
3845
4440
  case 13:
3846
- _context35.next = 15;
4441
+ _context40.next = 15;
3847
4442
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3848
4443
  matchBy: matchMode
3849
4444
  });
3850
4445
  case 15:
3851
- result = _context35.sent;
4446
+ result = _context40.sent;
3852
4447
  if (!(options.persistDraft !== false)) {
3853
- _context35.next = 29;
4448
+ _context40.next = 29;
3854
4449
  break;
3855
4450
  }
3856
- _context35.prev = 17;
3857
- _context35.next = 20;
4451
+ _context40.prev = 17;
4452
+ _context40.next = 20;
3858
4453
  return this.saveSalesOrderDraft();
3859
4454
  case 20:
3860
- draftResult = _context35.sent;
3861
- _context35.next = 29;
4455
+ draftResult = _context40.sent;
4456
+ _context40.next = 29;
3862
4457
  break;
3863
4458
  case 23:
3864
- _context35.prev = 23;
3865
- _context35.t0 = _context35["catch"](17);
3866
- draftError = _context35.t0;
4459
+ _context40.prev = 23;
4460
+ _context40.t0 = _context40["catch"](17);
4461
+ draftError = _context40.t0;
3867
4462
  this.logError('updateOrderPayment: 保存支付草稿失败', {
3868
4463
  paymentIdentity: paymentIdentity,
3869
- error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
4464
+ error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3870
4465
  });
3871
4466
  if (options.submitWhenPaid) {
3872
- _context35.next = 29;
4467
+ _context40.next = 29;
3873
4468
  break;
3874
4469
  }
3875
- throw _context35.t0;
4470
+ throw _context40.t0;
3876
4471
  case 29:
3877
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';
3878
4473
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3879
4474
  if (!shouldSubmit) {
3880
- _context35.next = 35;
4475
+ _context40.next = 35;
3881
4476
  break;
3882
4477
  }
3883
- _context35.next = 34;
4478
+ _context40.next = 34;
3884
4479
  return this.syncPaymentsToOrder({
3885
4480
  payments: result.payments,
3886
4481
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -3888,9 +4483,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3888
4483
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3889
4484
  });
3890
4485
  case 34:
3891
- syncResult = _context35.sent;
4486
+ syncResult = _context40.sent;
3892
4487
  case 35:
3893
- return _context35.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
4488
+ return _context40.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3894
4489
  draftResult: draftResult
3895
4490
  } : {}), draftError !== undefined ? {
3896
4491
  draftError: draftError
@@ -3899,11 +4494,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3899
4494
  } : {}));
3900
4495
  case 36:
3901
4496
  case "end":
3902
- return _context35.stop();
4497
+ return _context40.stop();
3903
4498
  }
3904
- }, _callee35, this, [[17, 23]]);
4499
+ }, _callee40, this, [[17, 23]]);
3905
4500
  }));
3906
- function updateOrderPayment(_x29, _x30) {
4501
+ function updateOrderPayment(_x31, _x32) {
3907
4502
  return _updateOrderPayment.apply(this, arguments);
3908
4503
  }
3909
4504
  return updateOrderPayment;
@@ -3925,24 +4520,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3925
4520
  }, {
3926
4521
  key: "updateVoucherOrderPaymentsAsync",
3927
4522
  value: function () {
3928
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payments, options) {
3929
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3930
- 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) {
3931
4526
  case 0:
3932
4527
  if (this.store.order) {
3933
- _context36.next = 2;
4528
+ _context41.next = 2;
3934
4529
  break;
3935
4530
  }
3936
4531
  throw new Error('order 模块未初始化');
3937
4532
  case 2:
3938
- return _context36.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
4533
+ return _context41.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3939
4534
  case 3:
3940
4535
  case "end":
3941
- return _context36.stop();
4536
+ return _context41.stop();
3942
4537
  }
3943
- }, _callee36, this);
4538
+ }, _callee41, this);
3944
4539
  }));
3945
- function updateVoucherOrderPaymentsAsync(_x31, _x32) {
4540
+ function updateVoucherOrderPaymentsAsync(_x33, _x34) {
3946
4541
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3947
4542
  }
3948
4543
  return updateVoucherOrderPaymentsAsync;
@@ -3955,7 +4550,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3955
4550
  if (this.store.payment) {
3956
4551
  var committed = this.getCommittedWalletAssets();
3957
4552
  var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3958
- void this.publishWalletAssetsState(state);
4553
+ void this.publishWalletAssetsState(state, 'local');
3959
4554
  }
3960
4555
  return payments;
3961
4556
  }
@@ -3968,8 +4563,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3968
4563
  }, {
3969
4564
  key: "getWalletProductList",
3970
4565
  value: function getWalletProductList() {
3971
- var _this$store$order7, _tempOrder$products;
3972
- 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();
3973
4568
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
3974
4569
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
3975
4570
  // debugger
@@ -4029,8 +4624,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4029
4624
  }, {
4030
4625
  key: "buildWalletInitBusinessData",
4031
4626
  value: function buildWalletInitBusinessData(params) {
4032
- var _this$store$order8, _params$order_wait_pa, _ref38, _tempOrder$is_price_i;
4033
- 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();
4034
4629
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
4035
4630
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
4036
4631
  if (!tempOrder || !amount) return null;
@@ -4045,7 +4640,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4045
4640
  },
4046
4641
  products: this.getWalletProductList(),
4047
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),
4048
- 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
4049
4644
  }, snapshot.identity.orderId ? {
4050
4645
  payment_order_id: String(snapshot.identity.orderId)
4051
4646
  } : {});
@@ -4053,20 +4648,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4053
4648
  }, {
4054
4649
  key: "initWalletData",
4055
4650
  value: function () {
4056
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4651
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4057
4652
  var _snapshot$identity;
4058
4653
  var snapshot, walletBusinessData, result;
4059
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4060
- while (1) switch (_context37.prev = _context37.next) {
4654
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4655
+ while (1) switch (_context42.prev = _context42.next) {
4061
4656
  case 0:
4062
4657
  if (this.store.order) {
4063
- _context37.next = 2;
4658
+ _context42.next = 2;
4064
4659
  break;
4065
4660
  }
4066
4661
  throw new Error('order 模块未初始化');
4067
4662
  case 2:
4068
4663
  if (this.store.payment) {
4069
- _context37.next = 4;
4664
+ _context42.next = 4;
4070
4665
  break;
4071
4666
  }
4072
4667
  throw new Error('payment 模块未初始化');
@@ -4074,10 +4669,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4074
4669
  snapshot = this.store.order.getOrderSnapshot();
4075
4670
  walletBusinessData = this.buildWalletInitBusinessData(params);
4076
4671
  if (walletBusinessData) {
4077
- _context37.next = 8;
4672
+ _context42.next = 8;
4078
4673
  break;
4079
4674
  }
4080
- return _context37.abrupt("return", {
4675
+ return _context42.abrupt("return", {
4081
4676
  walletRecommendList: [],
4082
4677
  userIdentificationCodes: [],
4083
4678
  transformList: [],
@@ -4085,11 +4680,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4085
4680
  products: []
4086
4681
  });
4087
4682
  case 8:
4088
- _context37.next = 10;
4683
+ _context42.next = 10;
4089
4684
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
4090
4685
  case 10:
4091
- result = _context37.sent;
4092
- _context37.next = 13;
4686
+ result = _context42.sent;
4687
+ _context42.next = 13;
4093
4688
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
4094
4689
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
4095
4690
  customerId: walletBusinessData.customer_id,
@@ -4101,14 +4696,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4101
4696
  timestamp: Date.now()
4102
4697
  });
4103
4698
  case 13:
4104
- return _context37.abrupt("return", result);
4699
+ return _context42.abrupt("return", result);
4105
4700
  case 14:
4106
4701
  case "end":
4107
- return _context37.stop();
4702
+ return _context42.stop();
4108
4703
  }
4109
- }, _callee37, this);
4704
+ }, _callee42, this);
4110
4705
  }));
4111
- function initWalletData(_x33) {
4706
+ function initWalletData(_x35) {
4112
4707
  return _initWalletData.apply(this, arguments);
4113
4708
  }
4114
4709
  return initWalletData;
@@ -4116,8 +4711,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4116
4711
  }, {
4117
4712
  key: "getCommittedWalletAssets",
4118
4713
  value: function getCommittedWalletAssets() {
4119
- var _this$store$order9, _this$store$order9$ge;
4120
- 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)) || [];
4121
4716
  var committed = payments.filter(function (payment) {
4122
4717
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
4123
4718
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -4135,9 +4730,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4135
4730
  var walletPassName = fundRecord.wallet_pass_name;
4136
4731
  var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
4137
4732
  var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
4138
- var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref39) {
4139
- var _ref40 = _slicedToArray(_ref39, 2),
4140
- 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];
4141
4736
  return paymentCode === code;
4142
4737
  })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
4143
4738
  return {
@@ -4159,23 +4754,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4159
4754
  }, {
4160
4755
  key: "publishWalletAssetsState",
4161
4756
  value: function () {
4162
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
4163
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4164
- 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) {
4165
4762
  case 0:
4166
- _context38.next = 2;
4763
+ changeSource = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : 'derived';
4764
+ _context43.next = 3;
4167
4765
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
4168
- state: state
4766
+ state: state,
4767
+ changeSource: changeSource
4169
4768
  });
4170
- case 2:
4171
- return _context38.abrupt("return", state);
4172
4769
  case 3:
4770
+ return _context43.abrupt("return", state);
4771
+ case 4:
4173
4772
  case "end":
4174
- return _context38.stop();
4773
+ return _context43.stop();
4175
4774
  }
4176
- }, _callee38, this);
4775
+ }, _callee43, this);
4177
4776
  }));
4178
- function publishWalletAssetsState(_x34) {
4777
+ function publishWalletAssetsState(_x36) {
4179
4778
  return _publishWalletAssetsState.apply(this, arguments);
4180
4779
  }
4181
4780
  return publishWalletAssetsState;
@@ -4183,26 +4782,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4183
4782
  }, {
4184
4783
  key: "syncSelectedWalletAssets",
4185
4784
  value: function () {
4186
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(state) {
4785
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
4187
4786
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
4188
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4189
- while (1) switch (_context39.prev = _context39.next) {
4787
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4788
+ while (1) switch (_context44.prev = _context44.next) {
4190
4789
  case 0:
4191
4790
  if (!(!this.store.order || !this.store.payment)) {
4192
- _context39.next = 2;
4791
+ _context44.next = 2;
4193
4792
  break;
4194
4793
  }
4195
4794
  throw new Error('订单或支付模块未初始化');
4196
4795
  case 2:
4197
4796
  paymentMethods = this.getPaymentMethods();
4198
4797
  if (!(!paymentMethods.length && state.selectedItems.length)) {
4199
- _context39.next = 7;
4798
+ _context44.next = 7;
4200
4799
  break;
4201
4800
  }
4202
- _context39.next = 6;
4801
+ _context44.next = 6;
4203
4802
  return this.getPaymentMethodsAsync();
4204
4803
  case 6:
4205
- paymentMethods = _context39.sent;
4804
+ paymentMethods = _context44.sent;
4206
4805
  case 7:
4207
4806
  methodByCode = new Map(paymentMethods.map(function (method) {
4208
4807
  return [String(method.code || '').toUpperCase(), method];
@@ -4244,19 +4843,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4244
4843
  payments = this.updateVoucherOrderPayments(voucherPayments, {
4245
4844
  status: 'payment_pending'
4246
4845
  });
4247
- _context39.next = 14;
4846
+ _context44.next = 14;
4248
4847
  return this.store.order.recalculateSummary({
4249
4848
  createIfMissing: true
4250
4849
  });
4251
4850
  case 14:
4252
- return _context39.abrupt("return", payments);
4851
+ return _context44.abrupt("return", payments);
4253
4852
  case 15:
4254
4853
  case "end":
4255
- return _context39.stop();
4854
+ return _context44.stop();
4256
4855
  }
4257
- }, _callee39, this);
4856
+ }, _callee44, this);
4258
4857
  }));
4259
- function syncSelectedWalletAssets(_x35) {
4858
+ function syncSelectedWalletAssets(_x37) {
4260
4859
  return _syncSelectedWalletAssets.apply(this, arguments);
4261
4860
  }
4262
4861
  return syncSelectedWalletAssets;
@@ -4290,29 +4889,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4290
4889
  }, {
4291
4890
  key: "importWalletAssetsSnapshot",
4292
4891
  value: (function () {
4293
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(snapshot) {
4892
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(snapshot) {
4294
4893
  var state;
4295
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4296
- while (1) switch (_context40.prev = _context40.next) {
4894
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4895
+ while (1) switch (_context45.prev = _context45.next) {
4297
4896
  case 0:
4298
4897
  if (this.store.payment) {
4299
- _context40.next = 2;
4898
+ _context45.next = 2;
4300
4899
  break;
4301
4900
  }
4302
4901
  throw new Error('payment 模块未初始化');
4303
4902
  case 2:
4304
4903
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
4305
- _context40.next = 5;
4904
+ _context45.next = 5;
4306
4905
  return this.syncSelectedWalletAssets(state);
4307
4906
  case 5:
4308
- return _context40.abrupt("return", this.publishWalletAssetsState(state));
4907
+ return _context45.abrupt("return", this.publishWalletAssetsState(state));
4309
4908
  case 6:
4310
4909
  case "end":
4311
- return _context40.stop();
4910
+ return _context45.stop();
4312
4911
  }
4313
- }, _callee40, this);
4912
+ }, _callee45, this);
4314
4913
  }));
4315
- function importWalletAssetsSnapshot(_x36) {
4914
+ function importWalletAssetsSnapshot(_x38) {
4316
4915
  return _importWalletAssetsSnapshot.apply(this, arguments);
4317
4916
  }
4318
4917
  return importWalletAssetsSnapshot;
@@ -4324,20 +4923,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4324
4923
  }, {
4325
4924
  key: "refreshWalletAssets",
4326
4925
  value: (function () {
4327
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4926
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
4328
4927
  var _previousState$custom, _businessData$custome;
4329
4928
  var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
4330
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4331
- while (1) switch (_context41.prev = _context41.next) {
4929
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4930
+ while (1) switch (_context46.prev = _context46.next) {
4332
4931
  case 0:
4333
4932
  if (this.store.order) {
4334
- _context41.next = 2;
4933
+ _context46.next = 2;
4335
4934
  break;
4336
4935
  }
4337
4936
  throw new Error('order 模块未初始化');
4338
4937
  case 2:
4339
4938
  if (this.store.payment) {
4340
- _context41.next = 4;
4939
+ _context46.next = 4;
4341
4940
  break;
4342
4941
  }
4343
4942
  throw new Error('payment 模块未初始化');
@@ -4346,7 +4945,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4346
4945
  wallet = this.store.payment.wallet;
4347
4946
  businessData = this.buildWalletInitBusinessData(params);
4348
4947
  if (businessData) {
4349
- _context41.next = 12;
4948
+ _context46.next = 12;
4350
4949
  break;
4351
4950
  }
4352
4951
  wallet.clearAllCache();
@@ -4354,53 +4953,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4354
4953
  this.updateVoucherOrderPayments([], {
4355
4954
  status: 'payment_pending'
4356
4955
  });
4357
- return _context41.abrupt("return", this.publishWalletAssetsState(emptyState));
4956
+ return _context46.abrupt("return", this.publishWalletAssetsState(emptyState));
4358
4957
  case 12:
4359
4958
  previousState = wallet.getWalletAssetsState();
4360
4959
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
4361
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 : '');
4362
4961
  if (!customerChanged) {
4363
- _context41.next = 20;
4962
+ _context46.next = 20;
4364
4963
  break;
4365
4964
  }
4366
4965
  clearedState = wallet.clearWalletAssetSelection();
4367
4966
  this.updateVoucherOrderPayments([], {
4368
4967
  status: 'payment_pending'
4369
4968
  });
4370
- _context41.next = 20;
4969
+ _context46.next = 20;
4371
4970
  return this.publishWalletAssetsState(clearedState);
4372
4971
  case 20:
4373
4972
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
4374
4973
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
4375
4974
  });
4376
- _context41.next = 23;
4975
+ _context46.next = 23;
4377
4976
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
4378
4977
  case 23:
4379
- _context41.next = 25;
4978
+ _context46.next = 25;
4380
4979
  return refreshTask;
4381
4980
  case 25:
4382
- state = _context41.sent;
4981
+ state = _context46.sent;
4383
4982
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
4384
- _context41.next = 28;
4983
+ _context46.next = 28;
4385
4984
  break;
4386
4985
  }
4387
- return _context41.abrupt("return", wallet.getWalletAssetsState());
4986
+ return _context46.abrupt("return", wallet.getWalletAssetsState());
4388
4987
  case 28:
4389
4988
  if (state.status !== 'error') {
4390
4989
  committed = this.getCommittedWalletAssets();
4391
4990
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4392
4991
  }
4393
- _context41.next = 31;
4992
+ _context46.next = 31;
4394
4993
  return this.syncSelectedWalletAssets(state);
4395
4994
  case 31:
4396
- return _context41.abrupt("return", this.publishWalletAssetsState(state));
4995
+ return _context46.abrupt("return", this.publishWalletAssetsState(state));
4397
4996
  case 32:
4398
4997
  case "end":
4399
- return _context41.stop();
4998
+ return _context46.stop();
4400
4999
  }
4401
- }, _callee41, this);
5000
+ }, _callee46, this);
4402
5001
  }));
4403
- function refreshWalletAssets(_x37) {
5002
+ function refreshWalletAssets(_x39) {
4404
5003
  return _refreshWalletAssets.apply(this, arguments);
4405
5004
  }
4406
5005
  return refreshWalletAssets;
@@ -4408,13 +5007,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4408
5007
  }, {
4409
5008
  key: "selectWalletAsset",
4410
5009
  value: (function () {
4411
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5010
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4412
5011
  var state;
4413
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4414
- while (1) switch (_context42.prev = _context42.next) {
5012
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5013
+ while (1) switch (_context47.prev = _context47.next) {
4415
5014
  case 0:
4416
5015
  if (this.store.payment) {
4417
- _context42.next = 2;
5016
+ _context47.next = 2;
4418
5017
  break;
4419
5018
  }
4420
5019
  throw new Error('payment 模块未初始化');
@@ -4423,17 +5022,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4423
5022
  selected: params.selected,
4424
5023
  source: params.source
4425
5024
  });
4426
- _context42.next = 5;
5025
+ _context47.next = 5;
4427
5026
  return this.syncSelectedWalletAssets(state);
4428
5027
  case 5:
4429
- return _context42.abrupt("return", this.publishWalletAssetsState(state));
5028
+ return _context47.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4430
5029
  case 6:
4431
5030
  case "end":
4432
- return _context42.stop();
5031
+ return _context47.stop();
4433
5032
  }
4434
- }, _callee42, this);
5033
+ }, _callee47, this);
4435
5034
  }));
4436
- function selectWalletAsset(_x38) {
5035
+ function selectWalletAsset(_x40) {
4437
5036
  return _selectWalletAsset.apply(this, arguments);
4438
5037
  }
4439
5038
  return selectWalletAsset;
@@ -4441,29 +5040,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4441
5040
  }, {
4442
5041
  key: "updateWalletAssetAmount",
4443
5042
  value: (function () {
4444
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5043
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4445
5044
  var state;
4446
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4447
- while (1) switch (_context43.prev = _context43.next) {
5045
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5046
+ while (1) switch (_context48.prev = _context48.next) {
4448
5047
  case 0:
4449
5048
  if (this.store.payment) {
4450
- _context43.next = 2;
5049
+ _context48.next = 2;
4451
5050
  break;
4452
5051
  }
4453
5052
  throw new Error('payment 模块未初始化');
4454
5053
  case 2:
4455
5054
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
4456
- _context43.next = 5;
5055
+ _context48.next = 5;
4457
5056
  return this.syncSelectedWalletAssets(state);
4458
5057
  case 5:
4459
- return _context43.abrupt("return", this.publishWalletAssetsState(state));
5058
+ return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4460
5059
  case 6:
4461
5060
  case "end":
4462
- return _context43.stop();
5061
+ return _context48.stop();
4463
5062
  }
4464
- }, _callee43, this);
5063
+ }, _callee48, this);
4465
5064
  }));
4466
- function updateWalletAssetAmount(_x39) {
5065
+ function updateWalletAssetAmount(_x41) {
4467
5066
  return _updateWalletAssetAmount.apply(this, arguments);
4468
5067
  }
4469
5068
  return updateWalletAssetAmount;
@@ -4471,13 +5070,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4471
5070
  }, {
4472
5071
  key: "scanWalletAsset",
4473
5072
  value: (function () {
4474
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(code) {
5073
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(code) {
4475
5074
  var wallet, businessData, result;
4476
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4477
- while (1) switch (_context44.prev = _context44.next) {
5075
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5076
+ while (1) switch (_context49.prev = _context49.next) {
4478
5077
  case 0:
4479
5078
  if (this.store.payment) {
4480
- _context44.next = 2;
5079
+ _context49.next = 2;
4481
5080
  break;
4482
5081
  }
4483
5082
  throw new Error('payment 模块未初始化');
@@ -4487,28 +5086,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4487
5086
  if (businessData) {
4488
5087
  wallet.generateWalletParams(businessData);
4489
5088
  }
4490
- _context44.next = 7;
5089
+ _context49.next = 7;
4491
5090
  return wallet.scanWalletAssetAsync(code);
4492
5091
  case 7:
4493
- result = _context44.sent;
5092
+ result = _context49.sent;
4494
5093
  if (!(result.type === 'normalCode')) {
4495
- _context44.next = 13;
5094
+ _context49.next = 13;
4496
5095
  break;
4497
5096
  }
4498
- _context44.next = 11;
5097
+ _context49.next = 11;
4499
5098
  return this.syncSelectedWalletAssets(result.state);
4500
5099
  case 11:
4501
- _context44.next = 13;
4502
- return this.publishWalletAssetsState(result.state);
5100
+ _context49.next = 13;
5101
+ return this.publishWalletAssetsState(result.state, 'local');
4503
5102
  case 13:
4504
- return _context44.abrupt("return", result);
5103
+ return _context49.abrupt("return", result);
4505
5104
  case 14:
4506
5105
  case "end":
4507
- return _context44.stop();
5106
+ return _context49.stop();
4508
5107
  }
4509
- }, _callee44, this);
5108
+ }, _callee49, this);
4510
5109
  }));
4511
- function scanWalletAsset(_x40) {
5110
+ function scanWalletAsset(_x42) {
4512
5111
  return _scanWalletAsset.apply(this, arguments);
4513
5112
  }
4514
5113
  return scanWalletAsset;
@@ -4516,27 +5115,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4516
5115
  }, {
4517
5116
  key: "clearWalletAssetSelection",
4518
5117
  value: (function () {
4519
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
5118
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4520
5119
  var state;
4521
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4522
- while (1) switch (_context45.prev = _context45.next) {
5120
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5121
+ while (1) switch (_context50.prev = _context50.next) {
4523
5122
  case 0:
4524
5123
  if (this.store.payment) {
4525
- _context45.next = 2;
5124
+ _context50.next = 2;
4526
5125
  break;
4527
5126
  }
4528
5127
  throw new Error('payment 模块未初始化');
4529
5128
  case 2:
4530
5129
  state = this.store.payment.wallet.clearWalletAssetSelection();
4531
- _context45.next = 5;
5130
+ _context50.next = 5;
4532
5131
  return this.syncSelectedWalletAssets(state);
4533
5132
  case 5:
4534
- return _context45.abrupt("return", this.publishWalletAssetsState(state));
5133
+ return _context50.abrupt("return", this.publishWalletAssetsState(state, 'local'));
4535
5134
  case 6:
4536
5135
  case "end":
4537
- return _context45.stop();
5136
+ return _context50.stop();
4538
5137
  }
4539
- }, _callee45, this);
5138
+ }, _callee50, this);
4540
5139
  }));
4541
5140
  function clearWalletAssetSelection() {
4542
5141
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -4566,35 +5165,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4566
5165
  }, {
4567
5166
  key: "getPaymentMethodsAsync",
4568
5167
  value: (function () {
4569
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
5168
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
4570
5169
  var response, paymentMethods;
4571
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4572
- while (1) switch (_context46.prev = _context46.next) {
5170
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5171
+ while (1) switch (_context51.prev = _context51.next) {
4573
5172
  case 0:
4574
- _context46.prev = 0;
4575
- _context46.next = 3;
5173
+ _context51.prev = 0;
5174
+ _context51.next = 3;
4576
5175
  return this.request.get('/pay/custom-payment/all', {
4577
5176
  filterPaymentMethods: true
4578
5177
  }, {
4579
5178
  osServer: true
4580
5179
  });
4581
5180
  case 3:
4582
- response = _context46.sent;
5181
+ response = _context51.sent;
4583
5182
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
4584
5183
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
4585
- return _context46.abrupt("return", this.getPaymentMethods());
5184
+ return _context51.abrupt("return", this.getPaymentMethods());
4586
5185
  case 9:
4587
- _context46.prev = 9;
4588
- _context46.t0 = _context46["catch"](0);
5186
+ _context51.prev = 9;
5187
+ _context51.t0 = _context51["catch"](0);
4589
5188
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
4590
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
5189
+ error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
4591
5190
  });
4592
- return _context46.abrupt("return", this.getPaymentMethods());
5191
+ return _context51.abrupt("return", this.getPaymentMethods());
4593
5192
  case 13:
4594
5193
  case "end":
4595
- return _context46.stop();
5194
+ return _context51.stop();
4596
5195
  }
4597
- }, _callee46, this, [[0, 9]]);
5196
+ }, _callee51, this, [[0, 9]]);
4598
5197
  }));
4599
5198
  function getPaymentMethodsAsync() {
4600
5199
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -4619,8 +5218,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4619
5218
  }, {
4620
5219
  key: "getPendingWalletPaymentAmount",
4621
5220
  value: function getPendingWalletPaymentAmount() {
4622
- var _this$store$order10, _this$store$order10$g;
4623
- 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)) || [];
4624
5223
  return payments.reduce(function (total, payment) {
4625
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) {
4626
5225
  return total;
@@ -4637,14 +5236,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4637
5236
  }, {
4638
5237
  key: "getCashPaymentConfig",
4639
5238
  value: (function () {
4640
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4641
- 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;
4642
5241
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4643
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4644
- while (1) switch (_context47.prev = _context47.next) {
5242
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5243
+ while (1) switch (_context52.prev = _context52.next) {
4645
5244
  case 0:
4646
5245
  if (this.store.payment) {
4647
- _context47.next = 2;
5246
+ _context52.next = 2;
4648
5247
  break;
4649
5248
  }
4650
5249
  throw new Error('payment 模块未初始化');
@@ -4652,21 +5251,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4652
5251
  paymentMethods = this.getPaymentMethods();
4653
5252
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4654
5253
  if (paymentMethod) {
4655
- _context47.next = 9;
5254
+ _context52.next = 9;
4656
5255
  break;
4657
5256
  }
4658
- _context47.next = 7;
5257
+ _context52.next = 7;
4659
5258
  return this.getPaymentMethodsAsync();
4660
5259
  case 7:
4661
- paymentMethods = _context47.sent;
5260
+ paymentMethods = _context52.sent;
4662
5261
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4663
5262
  case 9:
4664
- 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);
4665
5264
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4666
5265
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4667
- 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';
4668
5267
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4669
- return _context47.abrupt("return", {
5268
+ return _context52.abrupt("return", {
4670
5269
  available: Boolean(paymentMethod && amountDue > 0),
4671
5270
  paymentMethod: paymentMethod,
4672
5271
  amountDue: amountDue,
@@ -4674,9 +5273,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4674
5273
  });
4675
5274
  case 15:
4676
5275
  case "end":
4677
- return _context47.stop();
5276
+ return _context52.stop();
4678
5277
  }
4679
- }, _callee47, this);
5278
+ }, _callee52, this);
4680
5279
  }));
4681
5280
  function getCashPaymentConfig() {
4682
5281
  return _getCashPaymentConfig.apply(this, arguments);
@@ -4693,97 +5292,117 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4693
5292
  }, {
4694
5293
  key: "confirmWalletPayment",
4695
5294
  value: (function () {
4696
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4697
- var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4698
- var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4699
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4700
- 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) {
4701
5300
  case 0:
4702
5301
  if (this.store.order) {
4703
- _context48.next = 2;
5302
+ _context53.next = 2;
4704
5303
  break;
4705
5304
  }
4706
5305
  throw new Error('order 模块未初始化');
4707
5306
  case 2:
4708
5307
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4709
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);
4710
5310
  if (!pendingWalletAmount.lte(0)) {
4711
- _context48.next = 6;
5311
+ _context53.next = 14;
4712
5312
  break;
4713
5313
  }
4714
- throw new Error('当前订单没有待确认的 Wallet 支付');
4715
- case 6:
4716
- 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:
4717
5336
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4718
5337
  if (!effectiveAmountDue.gt(0.01)) {
4719
- _context48.next = 10;
5338
+ _context53.next = 17;
4720
5339
  break;
4721
5340
  }
4722
5341
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4723
- case 10:
4724
- beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4725
- _context48.prev = 11;
4726
- _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;
4727
5346
  return this.submitSalesOrder({
4728
5347
  smallTicketDataFlag: 1,
4729
5348
  confirmPendingVoucherPayments: true
4730
5349
  });
4731
- case 14:
4732
- submitResult = _context48.sent;
5350
+ case 21:
5351
+ submitResult = _context53.sent;
4733
5352
  if (!isRejectedSalesSubmitResult(submitResult)) {
4734
- _context48.next = 17;
5353
+ _context53.next = 24;
4735
5354
  break;
4736
5355
  }
4737
5356
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
4738
- case 17:
4739
- _context48.next = 27;
5357
+ case 24:
5358
+ _context53.next = 34;
4740
5359
  break;
4741
- case 19:
4742
- _context48.prev = 19;
4743
- _context48.t0 = _context48["catch"](11);
5360
+ case 26:
5361
+ _context53.prev = 26;
5362
+ _context53.t0 = _context53["catch"](18);
4744
5363
  this.store.order.setOrderPayments(beforePayments);
4745
5364
  restoredTempOrder = this.store.order.getTempOrder();
4746
5365
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4747
5366
  restoredTempOrder.payment_status = beforePaymentStatus;
4748
5367
  this.store.order.persistTempOrder();
4749
5368
  }
4750
- _context48.next = 26;
5369
+ _context53.next = 33;
4751
5370
  return this.store.order.recalculateSummary({
4752
5371
  createIfMissing: true
4753
5372
  });
4754
- case 26:
4755
- throw _context48.t0;
4756
- case 27:
5373
+ case 33:
5374
+ throw _context53.t0;
5375
+ case 34:
4757
5376
  if (!this.store.payment) {
4758
- _context48.next = 38;
5377
+ _context53.next = 45;
4759
5378
  break;
4760
5379
  }
4761
- _context48.prev = 28;
5380
+ _context53.prev = 35;
4762
5381
  committed = this.getCommittedWalletAssets();
4763
5382
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4764
- _context48.next = 33;
4765
- return this.publishWalletAssetsState(walletState);
4766
- case 33:
4767
- _context48.next = 38;
5383
+ _context53.next = 40;
5384
+ return this.publishWalletAssetsState(walletState, 'local');
5385
+ case 40:
5386
+ _context53.next = 45;
4768
5387
  break;
4769
- case 35:
4770
- _context48.prev = 35;
4771
- _context48.t1 = _context48["catch"](28);
5388
+ case 42:
5389
+ _context53.prev = 42;
5390
+ _context53.t1 = _context53["catch"](35);
4772
5391
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4773
- error: _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1)
5392
+ error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
4774
5393
  });
4775
- case 38:
4776
- 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);
4777
- 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", {
4778
5397
  submitResult: submitResult,
4779
5398
  payments: this.store.order.getOrderPayments(),
4780
5399
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4781
5400
  });
4782
- case 40:
5401
+ case 47:
4783
5402
  case "end":
4784
- return _context48.stop();
5403
+ return _context53.stop();
4785
5404
  }
4786
- }, _callee48, this, [[11, 19], [28, 35]]);
5405
+ }, _callee53, this, [[18, 26], [35, 42]]);
4787
5406
  }));
4788
5407
  function confirmWalletPayment() {
4789
5408
  return _confirmWalletPayment.apply(this, arguments);
@@ -4798,38 +5417,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4798
5417
  }, {
4799
5418
  key: "payCash",
4800
5419
  value: (function () {
4801
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4802
- 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;
4803
5422
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4804
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4805
- while (1) switch (_context49.prev = _context49.next) {
5423
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5424
+ while (1) switch (_context54.prev = _context54.next) {
4806
5425
  case 0:
4807
5426
  if (this.store.order) {
4808
- _context49.next = 2;
5427
+ _context54.next = 2;
4809
5428
  break;
4810
5429
  }
4811
5430
  throw new Error('order 模块未初始化');
4812
5431
  case 2:
4813
5432
  amount = Number(params.amount || 0);
4814
5433
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4815
- _context49.next = 5;
5434
+ _context54.next = 5;
4816
5435
  break;
4817
5436
  }
4818
5437
  throw new Error('现金支付金额必须大于 0');
4819
5438
  case 5:
4820
- _context49.next = 7;
5439
+ _context54.next = 7;
4821
5440
  return this.getCashPaymentConfig();
4822
5441
  case 7:
4823
- config = _context49.sent;
5442
+ config = _context54.sent;
4824
5443
  paymentMethod = config.paymentMethod;
4825
5444
  if (paymentMethod) {
4826
- _context49.next = 11;
5445
+ _context54.next = 11;
4827
5446
  break;
4828
5447
  }
4829
5448
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
4830
5449
  case 11:
4831
5450
  if (!(config.amountDue <= 0)) {
4832
- _context49.next = 13;
5451
+ _context54.next = 13;
4833
5452
  break;
4834
5453
  }
4835
5454
  throw new Error('当前订单没有待支付金额');
@@ -4837,20 +5456,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4837
5456
  roundingAmount = Number(params.roundingAmount || 0);
4838
5457
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4839
5458
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4840
- _context49.next = 17;
5459
+ _context54.next = 17;
4841
5460
  break;
4842
5461
  }
4843
5462
  throw new Error('现金支付金额超过当前待支付金额');
4844
5463
  case 17:
4845
5464
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4846
- 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;
4847
5466
  uniquePaymentNumber = createUuidV4();
4848
5467
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4849
5468
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4850
5469
  changeAmount = Number(params.changeAmount || 0);
4851
- 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;
4852
5471
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4853
- _context49.next = 26;
5472
+ _context54.next = 26;
4854
5473
  break;
4855
5474
  }
4856
5475
  throw new Error('顾客实收现金不能小于支付金额');
@@ -4885,8 +5504,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4885
5504
  var _item$metadata2;
4886
5505
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4887
5506
  });
4888
- _context49.prev = 29;
4889
- _context49.next = 32;
5507
+ _context54.prev = 29;
5508
+ _context54.next = 32;
4890
5509
  return this.syncPaymentsToOrder({
4891
5510
  payments: payments,
4892
5511
  submitWhenPaid: true,
@@ -4894,50 +5513,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4894
5513
  confirmPendingVoucherPayments: true
4895
5514
  });
4896
5515
  case 32:
4897
- syncResult = _context49.sent;
5516
+ syncResult = _context54.sent;
4898
5517
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
4899
- _context49.next = 35;
5518
+ _context54.next = 35;
4900
5519
  break;
4901
5520
  }
4902
5521
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
4903
5522
  case 35:
4904
5523
  if (!this.store.payment) {
4905
- _context49.next = 40;
5524
+ _context54.next = 40;
4906
5525
  break;
4907
5526
  }
4908
5527
  committed = this.getCommittedWalletAssets();
4909
5528
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4910
- _context49.next = 40;
4911
- return this.publishWalletAssetsState(walletState);
5529
+ _context54.next = 40;
5530
+ return this.publishWalletAssetsState(walletState, 'local');
4912
5531
  case 40:
4913
- return _context49.abrupt("return", {
5532
+ return _context54.abrupt("return", {
4914
5533
  payment: payment || {},
4915
5534
  payments: this.store.order.getOrderPayments(),
4916
5535
  syncResult: syncResult,
4917
5536
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4918
5537
  });
4919
5538
  case 43:
4920
- _context49.prev = 43;
4921
- _context49.t0 = _context49["catch"](29);
5539
+ _context54.prev = 43;
5540
+ _context54.t0 = _context54["catch"](29);
4922
5541
  this.store.order.setOrderPayments(beforePayments);
4923
5542
  restoredTempOrder = this.store.order.getTempOrder();
4924
5543
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4925
5544
  restoredTempOrder.payment_status = beforePaymentStatus;
4926
5545
  this.store.order.persistTempOrder();
4927
5546
  }
4928
- _context49.next = 50;
5547
+ _context54.next = 50;
4929
5548
  return this.store.order.recalculateSummary({
4930
5549
  createIfMissing: true
4931
5550
  });
4932
5551
  case 50:
4933
- throw _context49.t0;
5552
+ throw _context54.t0;
4934
5553
  case 51:
4935
5554
  case "end":
4936
- return _context49.stop();
5555
+ return _context54.stop();
4937
5556
  }
4938
- }, _callee49, this, [[29, 43]]);
5557
+ }, _callee54, this, [[29, 43]]);
4939
5558
  }));
4940
- function payCash(_x41) {
5559
+ function payCash(_x43) {
4941
5560
  return _payCash.apply(this, arguments);
4942
5561
  }
4943
5562
  return payCash;
@@ -4953,21 +5572,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4953
5572
  }, {
4954
5573
  key: "commitPaymentMethodPayment",
4955
5574
  value: (function () {
4956
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4957
- 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;
4958
5577
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4959
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4960
- while (1) switch (_context50.prev = _context50.next) {
5578
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5579
+ while (1) switch (_context55.prev = _context55.next) {
4961
5580
  case 0:
4962
5581
  if (this.store.order) {
4963
- _context50.next = 2;
5582
+ _context55.next = 2;
4964
5583
  break;
4965
5584
  }
4966
5585
  throw new Error('order 模块未初始化');
4967
5586
  case 2:
4968
5587
  amount = Number(params.amount || 0);
4969
5588
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4970
- _context50.next = 5;
5589
+ _context55.next = 5;
4971
5590
  break;
4972
5591
  }
4973
5592
  throw new Error('支付金额必须大于 0');
@@ -4983,38 +5602,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4983
5602
  };
4984
5603
  paymentMethod = findPaymentMethod();
4985
5604
  if (paymentMethod) {
4986
- _context50.next = 13;
5605
+ _context55.next = 13;
4987
5606
  break;
4988
5607
  }
4989
- _context50.next = 11;
5608
+ _context55.next = 11;
4990
5609
  return this.getPaymentMethodsAsync();
4991
5610
  case 11:
4992
- paymentMethods = _context50.sent;
5611
+ paymentMethods = _context55.sent;
4993
5612
  paymentMethod = findPaymentMethod();
4994
5613
  case 13:
4995
5614
  if (paymentMethod) {
4996
- _context50.next = 15;
5615
+ _context55.next = 15;
4997
5616
  break;
4998
5617
  }
4999
5618
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
5000
5619
  case 15:
5001
- 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);
5002
5621
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5003
5622
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5004
5623
  if (!amountDue.lte(0)) {
5005
- _context50.next = 20;
5624
+ _context55.next = 20;
5006
5625
  break;
5007
5626
  }
5008
5627
  throw new Error('当前订单没有待支付金额');
5009
5628
  case 20:
5010
5629
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
5011
- _context50.next = 22;
5630
+ _context55.next = 22;
5012
5631
  break;
5013
5632
  }
5014
5633
  throw new Error('支付金额超过当前待支付金额');
5015
5634
  case 22:
5016
5635
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5017
- 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;
5018
5637
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5019
5638
  metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
5020
5639
  unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
@@ -5047,8 +5666,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5047
5666
  var _item$metadata3;
5048
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;
5049
5668
  });
5050
- _context50.prev = 30;
5051
- _context50.next = 33;
5669
+ _context55.prev = 30;
5670
+ _context55.next = 33;
5052
5671
  return this.syncPaymentsToOrder({
5053
5672
  payments: payments,
5054
5673
  submitWhenPaid: true,
@@ -5056,50 +5675,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5056
5675
  confirmPendingVoucherPayments: true
5057
5676
  });
5058
5677
  case 33:
5059
- syncResult = _context50.sent;
5678
+ syncResult = _context55.sent;
5060
5679
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5061
- _context50.next = 36;
5680
+ _context55.next = 36;
5062
5681
  break;
5063
5682
  }
5064
5683
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5065
5684
  case 36:
5066
5685
  if (!this.store.payment) {
5067
- _context50.next = 41;
5686
+ _context55.next = 41;
5068
5687
  break;
5069
5688
  }
5070
5689
  committed = this.getCommittedWalletAssets();
5071
5690
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5072
- _context50.next = 41;
5073
- return this.publishWalletAssetsState(walletState);
5691
+ _context55.next = 41;
5692
+ return this.publishWalletAssetsState(walletState, 'local');
5074
5693
  case 41:
5075
- return _context50.abrupt("return", {
5694
+ return _context55.abrupt("return", {
5076
5695
  payment: payment || {},
5077
5696
  payments: this.store.order.getOrderPayments(),
5078
5697
  syncResult: syncResult,
5079
5698
  isOrderFullyPaid: syncResult.isOrderFullyPaid
5080
5699
  });
5081
5700
  case 44:
5082
- _context50.prev = 44;
5083
- _context50.t0 = _context50["catch"](30);
5701
+ _context55.prev = 44;
5702
+ _context55.t0 = _context55["catch"](30);
5084
5703
  this.store.order.setOrderPayments(beforePayments);
5085
5704
  restoredTempOrder = this.store.order.getTempOrder();
5086
5705
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5087
5706
  restoredTempOrder.payment_status = beforePaymentStatus;
5088
5707
  this.store.order.persistTempOrder();
5089
5708
  }
5090
- _context50.next = 51;
5709
+ _context55.next = 51;
5091
5710
  return this.store.order.recalculateSummary({
5092
5711
  createIfMissing: true
5093
5712
  });
5094
5713
  case 51:
5095
- throw _context50.t0;
5714
+ throw _context55.t0;
5096
5715
  case 52:
5097
5716
  case "end":
5098
- return _context50.stop();
5717
+ return _context55.stop();
5099
5718
  }
5100
- }, _callee50, this, [[30, 44]]);
5719
+ }, _callee55, this, [[30, 44]]);
5101
5720
  }));
5102
- function commitPaymentMethodPayment(_x42) {
5721
+ function commitPaymentMethodPayment(_x44) {
5103
5722
  return _commitPaymentMethodPayment.apply(this, arguments);
5104
5723
  }
5105
5724
  return commitPaymentMethodPayment;
@@ -5114,40 +5733,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5114
5733
  }, {
5115
5734
  key: "roundAmount",
5116
5735
  value: (function () {
5117
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5736
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5118
5737
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
5119
5738
  var amount, cashManualPayment;
5120
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5121
- while (1) switch (_context51.prev = _context51.next) {
5739
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5740
+ while (1) switch (_context56.prev = _context56.next) {
5122
5741
  case 0:
5123
5742
  amount = params.amount;
5124
5743
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
5125
5744
  return paymentMethod.code === 'CASHMANUAL';
5126
5745
  });
5127
5746
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
5128
- _context51.next = 4;
5747
+ _context56.next = 4;
5129
5748
  break;
5130
5749
  }
5131
- return _context51.abrupt("return", {
5750
+ return _context56.abrupt("return", {
5132
5751
  originalAmount: amount.toString(),
5133
5752
  roundedAmount: amount.toString(),
5134
5753
  roundingDifference: '0.00'
5135
5754
  });
5136
5755
  case 4:
5137
5756
  if (this.payment) {
5138
- _context51.next = 6;
5757
+ _context56.next = 6;
5139
5758
  break;
5140
5759
  }
5141
5760
  throw new Error('payment 模块未初始化');
5142
5761
  case 6:
5143
- 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));
5144
5763
  case 7:
5145
5764
  case "end":
5146
- return _context51.stop();
5765
+ return _context56.stop();
5147
5766
  }
5148
- }, _callee51, this);
5767
+ }, _callee56, this);
5149
5768
  }));
5150
- function roundAmount(_x43) {
5769
+ function roundAmount(_x45) {
5151
5770
  return _roundAmount.apply(this, arguments);
5152
5771
  }
5153
5772
  return roundAmount;
@@ -5162,49 +5781,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5162
5781
  }, {
5163
5782
  key: "sendCustomerPayLink",
5164
5783
  value: (function () {
5165
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5166
- var orderIds, _ref41, _ref42, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5167
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5168
- 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) {
5169
5788
  case 0:
5170
5789
  if (this.store.order) {
5171
- _context52.next = 2;
5790
+ _context57.next = 2;
5172
5791
  break;
5173
5792
  }
5174
5793
  throw new Error('order 模块未初始化');
5175
5794
  case 2:
5176
5795
  orderIds = params.order_ids || params.orderIds || [];
5177
5796
  if (!(!orderIds.length || params.submitBeforeSend)) {
5178
- _context52.next = 11;
5797
+ _context57.next = 11;
5179
5798
  break;
5180
5799
  }
5181
- _context52.next = 6;
5800
+ _context57.next = 6;
5182
5801
  return this.submitSalesOrder({
5183
5802
  smallTicketDataFlag: 1
5184
5803
  });
5185
5804
  case 6:
5186
- submitResult = _context52.sent;
5187
- 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;
5188
5807
  if (orderId) {
5189
- _context52.next = 10;
5808
+ _context57.next = 10;
5190
5809
  break;
5191
5810
  }
5192
5811
  throw new Error('本地订单提交云端失败,无法发送支付链接');
5193
5812
  case 10:
5194
5813
  orderIds = [orderId];
5195
5814
  case 11:
5196
- return _context52.abrupt("return", this.store.order.sendCustomerPayLink({
5815
+ return _context57.abrupt("return", this.store.order.sendCustomerPayLink({
5197
5816
  emails: params.emails,
5198
5817
  notify_action: params.notify_action,
5199
5818
  order_ids: orderIds
5200
5819
  }));
5201
5820
  case 12:
5202
5821
  case "end":
5203
- return _context52.stop();
5822
+ return _context57.stop();
5204
5823
  }
5205
- }, _callee52, this);
5824
+ }, _callee57, this);
5206
5825
  }));
5207
- function sendCustomerPayLink(_x44) {
5826
+ function sendCustomerPayLink(_x46) {
5208
5827
  return _sendCustomerPayLink.apply(this, arguments);
5209
5828
  }
5210
5829
  return sendCustomerPayLink;
@@ -5217,20 +5836,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5217
5836
  }, {
5218
5837
  key: "calculateProductBookingPrice",
5219
5838
  value: function () {
5220
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5839
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5221
5840
  var _params$customer_id;
5222
5841
  var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
5223
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5224
- while (1) switch (_context53.prev = _context53.next) {
5842
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5843
+ while (1) switch (_context58.prev = _context58.next) {
5225
5844
  case 0:
5226
5845
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
5227
5846
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
5228
5847
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
5229
- _context53.next = 5;
5848
+ _context58.next = 5;
5230
5849
  return this.prepareProductPriceQueryContext(customerId);
5231
5850
  case 5:
5232
5851
  channel = this.getPriceQueryChannel(params.channel);
5233
- _context53.next = 8;
5852
+ _context58.next = 8;
5234
5853
  return this.resolveProductsForPriceQuery({
5235
5854
  priceQueries: [params],
5236
5855
  schedule: this.getPriceQuerySchedule(params),
@@ -5238,22 +5857,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5238
5857
  channel: channel
5239
5858
  });
5240
5859
  case 8:
5241
- _yield$this$resolvePr = _context53.sent;
5860
+ _yield$this$resolvePr = _context58.sent;
5242
5861
  _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
5243
5862
  authoritativeProduct = _yield$this$resolvePr2[0];
5244
5863
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
5245
5864
  if (useCustomerUserPricing) {
5246
- _context53.next = 15;
5865
+ _context58.next = 15;
5247
5866
  break;
5248
5867
  }
5249
- _context53.next = 15;
5868
+ _context58.next = 15;
5250
5869
  return this.loadQuotationForPriceQuery({
5251
5870
  quotation: quotation,
5252
5871
  customer_id: customerId,
5253
5872
  channel: channel
5254
5873
  });
5255
5874
  case 15:
5256
- return _context53.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
5875
+ return _context58.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
5257
5876
  channel: channel,
5258
5877
  product: product,
5259
5878
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -5262,11 +5881,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5262
5881
  })));
5263
5882
  case 16:
5264
5883
  case "end":
5265
- return _context53.stop();
5884
+ return _context58.stop();
5266
5885
  }
5267
- }, _callee53, this);
5886
+ }, _callee58, this);
5268
5887
  }));
5269
- function calculateProductBookingPrice(_x45) {
5888
+ function calculateProductBookingPrice(_x47) {
5270
5889
  return _calculateProductBookingPrice.apply(this, arguments);
5271
5890
  }
5272
5891
  return calculateProductBookingPrice;
@@ -5350,17 +5969,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5350
5969
  }, {
5351
5970
  key: "calculateProductBookingPrices",
5352
5971
  value: function () {
5353
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(paramsList) {
5972
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
5354
5973
  var _this18 = this;
5355
5974
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
5356
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5357
- while (1) switch (_context55.prev = _context55.next) {
5975
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5976
+ while (1) switch (_context60.prev = _context60.next) {
5358
5977
  case 0:
5359
5978
  if (paramsList.length) {
5360
- _context55.next = 2;
5979
+ _context60.next = 2;
5361
5980
  break;
5362
5981
  }
5363
- return _context55.abrupt("return", []);
5982
+ return _context60.abrupt("return", []);
5364
5983
  case 2:
5365
5984
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
5366
5985
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
@@ -5387,20 +6006,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5387
6006
  group.indices.push(index);
5388
6007
  groups.set(groupKey, group);
5389
6008
  });
5390
- _context55.next = 11;
6009
+ _context60.next = 11;
5391
6010
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
5392
- var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(group) {
6011
+ var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(group) {
5393
6012
  var priceQueries, resolvedProducts;
5394
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5395
- while (1) switch (_context54.prev = _context54.next) {
6013
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6014
+ while (1) switch (_context59.prev = _context59.next) {
5396
6015
  case 0:
5397
- _context54.next = 2;
6016
+ _context59.next = 2;
5398
6017
  return _this18.prepareProductPriceQueryContext(group.customerId);
5399
6018
  case 2:
5400
6019
  priceQueries = group.indices.map(function (index) {
5401
6020
  return paramsList[index];
5402
6021
  });
5403
- _context54.next = 5;
6022
+ _context59.next = 5;
5404
6023
  return _this18.resolveProductsForPriceQuery({
5405
6024
  priceQueries: priceQueries,
5406
6025
  schedule: group.schedule,
@@ -5408,23 +6027,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5408
6027
  channel: group.channel
5409
6028
  });
5410
6029
  case 5:
5411
- resolvedProducts = _context54.sent;
6030
+ resolvedProducts = _context59.sent;
5412
6031
  group.indices.forEach(function (originalIndex, groupIndex) {
5413
6032
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
5414
6033
  });
5415
6034
  case 7:
5416
6035
  case "end":
5417
- return _context54.stop();
6036
+ return _context59.stop();
5418
6037
  }
5419
- }, _callee54);
6038
+ }, _callee59);
5420
6039
  }));
5421
- return function (_x47) {
5422
- return _ref43.apply(this, arguments);
6040
+ return function (_x49) {
6041
+ return _ref50.apply(this, arguments);
5423
6042
  };
5424
6043
  }()));
5425
6044
  case 11:
5426
6045
  if (useCustomerUserPricing) {
5427
- _context55.next = 16;
6046
+ _context60.next = 16;
5428
6047
  break;
5429
6048
  }
5430
6049
  quotationContexts = new Map();
@@ -5438,14 +6057,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5438
6057
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
5439
6058
  });
5440
6059
  });
5441
- _context55.next = 16;
6060
+ _context60.next = 16;
5442
6061
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
5443
6062
  return _this18.loadQuotationForPriceQuery(_objectSpread({
5444
6063
  quotation: quotation
5445
6064
  }, context));
5446
6065
  }));
5447
6066
  case 16:
5448
- return _context55.abrupt("return", paramsList.map(function (params, index) {
6067
+ return _context60.abrupt("return", paramsList.map(function (params, index) {
5449
6068
  var _params$customer_id4;
5450
6069
  var productInput = params.product || {};
5451
6070
  var authoritativeProduct = authoritativeProducts[index];
@@ -5462,11 +6081,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5462
6081
  }));
5463
6082
  case 17:
5464
6083
  case "end":
5465
- return _context55.stop();
6084
+ return _context60.stop();
5466
6085
  }
5467
- }, _callee55, this);
6086
+ }, _callee60, this);
5468
6087
  }));
5469
- function calculateProductBookingPrices(_x46) {
6088
+ function calculateProductBookingPrices(_x48) {
5470
6089
  return _calculateProductBookingPrices.apply(this, arguments);
5471
6090
  }
5472
6091
  return calculateProductBookingPrices;
@@ -5474,34 +6093,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5474
6093
  }, {
5475
6094
  key: "addProductToOrder",
5476
6095
  value: function () {
5477
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(product, booking, options) {
6096
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(product, booking, options) {
5478
6097
  var products;
5479
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5480
- while (1) switch (_context56.prev = _context56.next) {
6098
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6099
+ while (1) switch (_context61.prev = _context61.next) {
5481
6100
  case 0:
5482
- _context56.prev = 0;
6101
+ _context61.prev = 0;
5483
6102
  if (this.store.order) {
5484
- _context56.next = 3;
6103
+ _context61.next = 3;
5485
6104
  break;
5486
6105
  }
5487
6106
  throw new Error('order 模块未初始化');
5488
6107
  case 3:
5489
- _context56.next = 5;
6108
+ _context61.next = 5;
5490
6109
  return this.store.order.addProductToOrder(product, booking, options);
5491
6110
  case 5:
5492
- products = _context56.sent;
5493
- return _context56.abrupt("return", products);
6111
+ products = _context61.sent;
6112
+ return _context61.abrupt("return", products);
5494
6113
  case 9:
5495
- _context56.prev = 9;
5496
- _context56.t0 = _context56["catch"](0);
5497
- throw _context56.t0;
6114
+ _context61.prev = 9;
6115
+ _context61.t0 = _context61["catch"](0);
6116
+ throw _context61.t0;
5498
6117
  case 12:
5499
6118
  case "end":
5500
- return _context56.stop();
6119
+ return _context61.stop();
5501
6120
  }
5502
- }, _callee56, this, [[0, 9]]);
6121
+ }, _callee61, this, [[0, 9]]);
5503
6122
  }));
5504
- function addProductToOrder(_x48, _x49, _x50) {
6123
+ function addProductToOrder(_x50, _x51, _x52) {
5505
6124
  return _addProductToOrder.apply(this, arguments);
5506
6125
  }
5507
6126
  return addProductToOrder;
@@ -5509,34 +6128,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5509
6128
  }, {
5510
6129
  key: "updateOrderProduct",
5511
6130
  value: function () {
5512
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
6131
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
5513
6132
  var products;
5514
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5515
- while (1) switch (_context57.prev = _context57.next) {
6133
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6134
+ while (1) switch (_context62.prev = _context62.next) {
5516
6135
  case 0:
5517
- _context57.prev = 0;
6136
+ _context62.prev = 0;
5518
6137
  if (this.store.order) {
5519
- _context57.next = 3;
6138
+ _context62.next = 3;
5520
6139
  break;
5521
6140
  }
5522
6141
  throw new Error('order 模块未初始化');
5523
6142
  case 3:
5524
- _context57.next = 5;
6143
+ _context62.next = 5;
5525
6144
  return this.store.order.updateOrderProduct(params);
5526
6145
  case 5:
5527
- products = _context57.sent;
5528
- return _context57.abrupt("return", products);
6146
+ products = _context62.sent;
6147
+ return _context62.abrupt("return", products);
5529
6148
  case 9:
5530
- _context57.prev = 9;
5531
- _context57.t0 = _context57["catch"](0);
5532
- throw _context57.t0;
6149
+ _context62.prev = 9;
6150
+ _context62.t0 = _context62["catch"](0);
6151
+ throw _context62.t0;
5533
6152
  case 12:
5534
6153
  case "end":
5535
- return _context57.stop();
6154
+ return _context62.stop();
5536
6155
  }
5537
- }, _callee57, this, [[0, 9]]);
6156
+ }, _callee62, this, [[0, 9]]);
5538
6157
  }));
5539
- function updateOrderProduct(_x51) {
6158
+ function updateOrderProduct(_x53) {
5540
6159
  return _updateOrderProduct.apply(this, arguments);
5541
6160
  }
5542
6161
  return updateOrderProduct;
@@ -5544,34 +6163,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5544
6163
  }, {
5545
6164
  key: "updateOrderProducts",
5546
6165
  value: function () {
5547
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(paramsList) {
6166
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(paramsList) {
5548
6167
  var products;
5549
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5550
- while (1) switch (_context58.prev = _context58.next) {
6168
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6169
+ while (1) switch (_context63.prev = _context63.next) {
5551
6170
  case 0:
5552
- _context58.prev = 0;
6171
+ _context63.prev = 0;
5553
6172
  if (this.store.order) {
5554
- _context58.next = 3;
6173
+ _context63.next = 3;
5555
6174
  break;
5556
6175
  }
5557
6176
  throw new Error('order 模块未初始化');
5558
6177
  case 3:
5559
- _context58.next = 5;
6178
+ _context63.next = 5;
5560
6179
  return this.store.order.updateOrderProducts(paramsList);
5561
6180
  case 5:
5562
- products = _context58.sent;
5563
- return _context58.abrupt("return", products);
6181
+ products = _context63.sent;
6182
+ return _context63.abrupt("return", products);
5564
6183
  case 9:
5565
- _context58.prev = 9;
5566
- _context58.t0 = _context58["catch"](0);
5567
- throw _context58.t0;
6184
+ _context63.prev = 9;
6185
+ _context63.t0 = _context63["catch"](0);
6186
+ throw _context63.t0;
5568
6187
  case 12:
5569
6188
  case "end":
5570
- return _context58.stop();
6189
+ return _context63.stop();
5571
6190
  }
5572
- }, _callee58, this, [[0, 9]]);
6191
+ }, _callee63, this, [[0, 9]]);
5573
6192
  }));
5574
- function updateOrderProducts(_x52) {
6193
+ function updateOrderProducts(_x54) {
5575
6194
  return _updateOrderProducts.apply(this, arguments);
5576
6195
  }
5577
6196
  return updateOrderProducts;
@@ -5579,34 +6198,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5579
6198
  }, {
5580
6199
  key: "updateOrderProductQuantity",
5581
6200
  value: function () {
5582
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
6201
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
5583
6202
  var products;
5584
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5585
- while (1) switch (_context59.prev = _context59.next) {
6203
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6204
+ while (1) switch (_context64.prev = _context64.next) {
5586
6205
  case 0:
5587
- _context59.prev = 0;
6206
+ _context64.prev = 0;
5588
6207
  if (this.store.order) {
5589
- _context59.next = 3;
6208
+ _context64.next = 3;
5590
6209
  break;
5591
6210
  }
5592
6211
  throw new Error('order 模块未初始化');
5593
6212
  case 3:
5594
- _context59.next = 5;
6213
+ _context64.next = 5;
5595
6214
  return this.store.order.updateOrderProductQuantity(params);
5596
6215
  case 5:
5597
- products = _context59.sent;
5598
- return _context59.abrupt("return", products);
6216
+ products = _context64.sent;
6217
+ return _context64.abrupt("return", products);
5599
6218
  case 9:
5600
- _context59.prev = 9;
5601
- _context59.t0 = _context59["catch"](0);
5602
- throw _context59.t0;
6219
+ _context64.prev = 9;
6220
+ _context64.t0 = _context64["catch"](0);
6221
+ throw _context64.t0;
5603
6222
  case 12:
5604
6223
  case "end":
5605
- return _context59.stop();
6224
+ return _context64.stop();
5606
6225
  }
5607
- }, _callee59, this, [[0, 9]]);
6226
+ }, _callee64, this, [[0, 9]]);
5608
6227
  }));
5609
- function updateOrderProductQuantity(_x53) {
6228
+ function updateOrderProductQuantity(_x55) {
5610
6229
  return _updateOrderProductQuantity.apply(this, arguments);
5611
6230
  }
5612
6231
  return updateOrderProductQuantity;
@@ -5629,12 +6248,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5629
6248
  }, {
5630
6249
  key: "setOrderProductLineNote",
5631
6250
  value: (function () {
5632
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity, note) {
6251
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, note) {
5633
6252
  var params, products;
5634
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5635
- while (1) switch (_context60.prev = _context60.next) {
6253
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6254
+ while (1) switch (_context65.prev = _context65.next) {
5636
6255
  case 0:
5637
- _context60.prev = 0;
6256
+ _context65.prev = 0;
5638
6257
  params = {
5639
6258
  product_id: identity.product_id,
5640
6259
  product_variant_id: identity.product_variant_id,
@@ -5649,22 +6268,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5649
6268
  params.product_sku = identity.product_sku;
5650
6269
  }
5651
6270
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
5652
- _context60.next = 7;
6271
+ _context65.next = 7;
5653
6272
  return this.updateOrderProduct(params);
5654
6273
  case 7:
5655
- products = _context60.sent;
5656
- return _context60.abrupt("return", products);
6274
+ products = _context65.sent;
6275
+ return _context65.abrupt("return", products);
5657
6276
  case 11:
5658
- _context60.prev = 11;
5659
- _context60.t0 = _context60["catch"](0);
5660
- throw _context60.t0;
6277
+ _context65.prev = 11;
6278
+ _context65.t0 = _context65["catch"](0);
6279
+ throw _context65.t0;
5661
6280
  case 14:
5662
6281
  case "end":
5663
- return _context60.stop();
6282
+ return _context65.stop();
5664
6283
  }
5665
- }, _callee60, this, [[0, 11]]);
6284
+ }, _callee65, this, [[0, 11]]);
5666
6285
  }));
5667
- function setOrderProductLineNote(_x54, _x55) {
6286
+ function setOrderProductLineNote(_x56, _x57) {
5668
6287
  return _setOrderProductLineNote.apply(this, arguments);
5669
6288
  }
5670
6289
  return setOrderProductLineNote;
@@ -5679,32 +6298,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5679
6298
  }, {
5680
6299
  key: "removeProductsFromOrder",
5681
6300
  value: (function () {
5682
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(identities, options) {
5683
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5684
- 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) {
5685
6304
  case 0:
5686
- _context61.prev = 0;
6305
+ _context66.prev = 0;
5687
6306
  if (this.store.order) {
5688
- _context61.next = 3;
6307
+ _context66.next = 3;
5689
6308
  break;
5690
6309
  }
5691
6310
  throw new Error('order 模块未初始化');
5692
6311
  case 3:
5693
- _context61.next = 5;
6312
+ _context66.next = 5;
5694
6313
  return this.store.order.removeProductsFromOrder(identities, options);
5695
6314
  case 5:
5696
- return _context61.abrupt("return", _context61.sent);
6315
+ return _context66.abrupt("return", _context66.sent);
5697
6316
  case 8:
5698
- _context61.prev = 8;
5699
- _context61.t0 = _context61["catch"](0);
5700
- throw _context61.t0;
6317
+ _context66.prev = 8;
6318
+ _context66.t0 = _context66["catch"](0);
6319
+ throw _context66.t0;
5701
6320
  case 11:
5702
6321
  case "end":
5703
- return _context61.stop();
6322
+ return _context66.stop();
5704
6323
  }
5705
- }, _callee61, this, [[0, 8]]);
6324
+ }, _callee66, this, [[0, 8]]);
5706
6325
  }));
5707
- function removeProductsFromOrder(_x56, _x57) {
6326
+ function removeProductsFromOrder(_x58, _x59) {
5708
6327
  return _removeProductsFromOrder.apply(this, arguments);
5709
6328
  }
5710
6329
  return removeProductsFromOrder;
@@ -5712,18 +6331,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5712
6331
  }, {
5713
6332
  key: "removeProductFromOrder",
5714
6333
  value: function () {
5715
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, options) {
5716
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5717
- 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) {
5718
6337
  case 0:
5719
- return _context62.abrupt("return", this.removeProductsFromOrder([identity], options));
6338
+ return _context67.abrupt("return", this.removeProductsFromOrder([identity], options));
5720
6339
  case 1:
5721
6340
  case "end":
5722
- return _context62.stop();
6341
+ return _context67.stop();
5723
6342
  }
5724
- }, _callee62, this);
6343
+ }, _callee67, this);
5725
6344
  }));
5726
- function removeProductFromOrder(_x58, _x59) {
6345
+ function removeProductFromOrder(_x60, _x61) {
5727
6346
  return _removeProductFromOrder.apply(this, arguments);
5728
6347
  }
5729
6348
  return removeProductFromOrder;
@@ -5773,23 +6392,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5773
6392
  }, {
5774
6393
  key: "applyPromotion",
5775
6394
  value: (function () {
5776
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
5777
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5778
- 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) {
5779
6398
  case 0:
5780
6399
  if (this.store.order) {
5781
- _context63.next = 2;
6400
+ _context68.next = 2;
5782
6401
  break;
5783
6402
  }
5784
6403
  throw new Error('order 模块未初始化');
5785
6404
  case 2:
5786
- _context63.next = 4;
6405
+ _context68.next = 4;
5787
6406
  return this.store.order.applyPromotion();
5788
6407
  case 4:
5789
6408
  case "end":
5790
- return _context63.stop();
6409
+ return _context68.stop();
5791
6410
  }
5792
- }, _callee63, this);
6411
+ }, _callee68, this);
5793
6412
  }));
5794
6413
  function applyPromotion() {
5795
6414
  return _applyPromotion.apply(this, arguments);
@@ -5799,16 +6418,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5799
6418
  }, {
5800
6419
  key: "getUnfulfilledPromotions",
5801
6420
  value: function getUnfulfilledPromotions() {
5802
- var _this$store$order16;
5803
- 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()) || [];
5804
6423
  }
5805
6424
 
5806
6425
  /** 最近一次促销计算输出的赠品操作 diff。 */
5807
6426
  }, {
5808
6427
  key: "getLastGiftActions",
5809
6428
  value: function getLastGiftActions() {
5810
- var _this$store$order17;
5811
- 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;
5812
6431
  }
5813
6432
 
5814
6433
  // 获取商品列表
@@ -5816,18 +6435,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5816
6435
  }, {
5817
6436
  key: "getProductList",
5818
6437
  value: function () {
5819
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
5820
- var _this$otherParams35;
6438
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
6439
+ var _this$otherParams36;
5821
6440
  var menu_list_ids, _this$store$products, res;
5822
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
5823
- while (1) switch (_context64.prev = _context64.next) {
6441
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6442
+ while (1) switch (_context69.prev = _context69.next) {
5824
6443
  case 0:
5825
6444
  // 可以直接通过配置里的 menu 读取
5826
- 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) {
5827
6446
  return Number(n.value);
5828
6447
  })) || [];
5829
- _context64.prev = 1;
5830
- _context64.next = 4;
6448
+ _context69.prev = 1;
6449
+ _context69.next = 4;
5831
6450
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
5832
6451
  menu_list_ids: menu_list_ids,
5833
6452
  cacheId: this.cacheId,
@@ -5835,17 +6454,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5835
6454
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
5836
6455
  });
5837
6456
  case 4:
5838
- res = _context64.sent;
5839
- return _context64.abrupt("return", res);
6457
+ res = _context69.sent;
6458
+ return _context69.abrupt("return", res);
5840
6459
  case 8:
5841
- _context64.prev = 8;
5842
- _context64.t0 = _context64["catch"](1);
5843
- throw _context64.t0;
6460
+ _context69.prev = 8;
6461
+ _context69.t0 = _context69["catch"](1);
6462
+ throw _context69.t0;
5844
6463
  case 11:
5845
6464
  case "end":
5846
- return _context64.stop();
6465
+ return _context69.stop();
5847
6466
  }
5848
- }, _callee64, this, [[1, 8]]);
6467
+ }, _callee69, this, [[1, 8]]);
5849
6468
  }));
5850
6469
  function getProductList() {
5851
6470
  return _getProductList.apply(this, arguments);
@@ -5860,33 +6479,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5860
6479
  }, {
5861
6480
  key: "setOtherParams",
5862
6481
  value: function () {
5863
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
5864
- var _this$otherParams36;
5865
- var _ref44,
5866
- _ref44$cover,
6482
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6483
+ var _this$otherParams37;
6484
+ var _ref51,
6485
+ _ref51$cover,
5867
6486
  cover,
5868
- _args65 = arguments;
5869
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
5870
- 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) {
5871
6490
  case 0:
5872
- _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;
5873
6492
  if (cover) {
5874
6493
  this.otherParams = _objectSpread({}, params);
5875
6494
  } else {
5876
6495
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
5877
6496
  }
5878
- this.cacheId = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.cacheId;
5879
- _context65.next = 5;
6497
+ this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
6498
+ _context70.next = 5;
5880
6499
  return this.syncOtherParamsToSubModules(params, {
5881
6500
  cover: cover
5882
6501
  });
5883
6502
  case 5:
5884
6503
  case "end":
5885
- return _context65.stop();
6504
+ return _context70.stop();
5886
6505
  }
5887
- }, _callee65, this);
6506
+ }, _callee70, this);
5888
6507
  }));
5889
- function setOtherParams(_x60) {
6508
+ function setOtherParams(_x62) {
5890
6509
  return _setOtherParams.apply(this, arguments);
5891
6510
  }
5892
6511
  return setOtherParams;