@pisell/pisellos 2.3.37 → 2.3.38

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 (90) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  11. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  14. package/dist/modules/OpenData/index.d.ts +2 -0
  15. package/dist/modules/OpenData/index.js +8 -0
  16. package/dist/modules/Order/index.js +21 -14
  17. package/dist/modules/Order/utils.js +2 -1
  18. package/dist/modules/Payment/index.js +1 -1
  19. package/dist/modules/Payment/types.d.ts +73 -4
  20. package/dist/modules/Payment/types.js +18 -3
  21. package/dist/modules/Payment/walletpass.d.ts +25 -1
  22. package/dist/modules/Payment/walletpass.js +707 -157
  23. package/dist/modules/Rules/index.d.ts +1 -0
  24. package/dist/modules/Rules/index.js +75 -49
  25. package/dist/server/index.js +19 -18
  26. package/dist/server/modules/order/index.d.ts +5 -0
  27. package/dist/server/modules/order/index.js +52 -31
  28. package/dist/solution/BaseSales/index.d.ts +77 -11
  29. package/dist/solution/BaseSales/index.js +1322 -297
  30. package/dist/solution/BaseSales/types.d.ts +52 -0
  31. package/dist/solution/BaseSales/types.js +2 -1
  32. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  33. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +7 -3
  36. package/dist/solution/BookingTicket/index.js +130 -48
  37. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  38. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  39. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  40. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  41. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  42. package/dist/solution/ScanOrder/index.js +31 -20
  43. package/dist/solution/VenueBooking/index.js +30 -19
  44. package/dist/types/index.d.ts +1 -0
  45. package/lib/core/index.d.ts +2 -0
  46. package/lib/core/index.js +4 -0
  47. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  48. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  49. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  50. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  51. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  52. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  53. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  54. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  55. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  56. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  57. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  58. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  59. package/lib/modules/OpenData/index.d.ts +2 -0
  60. package/lib/modules/OpenData/index.js +5 -0
  61. package/lib/modules/Order/index.js +10 -4
  62. package/lib/modules/Order/utils.js +6 -1
  63. package/lib/modules/Payment/index.js +1 -1
  64. package/lib/modules/Payment/types.d.ts +73 -4
  65. package/lib/modules/Payment/types.js +4 -3
  66. package/lib/modules/Payment/walletpass.d.ts +25 -1
  67. package/lib/modules/Payment/walletpass.js +470 -21
  68. package/lib/modules/Rules/index.d.ts +1 -0
  69. package/lib/modules/Rules/index.js +30 -7
  70. package/lib/server/index.js +5 -3
  71. package/lib/server/modules/order/index.d.ts +5 -0
  72. package/lib/server/modules/order/index.js +24 -2
  73. package/lib/solution/BaseSales/index.d.ts +77 -11
  74. package/lib/solution/BaseSales/index.js +682 -39
  75. package/lib/solution/BaseSales/types.d.ts +52 -0
  76. package/lib/solution/BaseSales/types.js +2 -1
  77. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  78. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingTicket/index.d.ts +7 -3
  81. package/lib/solution/BookingTicket/index.js +60 -8
  82. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  83. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  84. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  85. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  86. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  87. package/lib/solution/ScanOrder/index.js +8 -0
  88. package/lib/solution/VenueBooking/index.js +8 -0
  89. package/lib/types/index.d.ts +1 -0
  90. package/package.json +2 -2
@@ -46,6 +46,89 @@ import { QuotationModule } from "../../modules/Quotation";
46
46
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
47
47
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
48
48
  var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
49
+ var WALLET_PAYMENT_CODE_BY_TAG = {
50
+ product_voucher: 'PRODUCTVOUCHER',
51
+ gift_card: 'GIFTCARD',
52
+ point_card: 'POINTCARD'
53
+ };
54
+ function getSharedWalletAssetId(asset) {
55
+ var _ref, _asset$id;
56
+ return (_ref = (_asset$id = asset === null || asset === void 0 ? void 0 : asset.id) !== null && _asset$id !== void 0 ? _asset$id : asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _ref !== void 0 ? _ref : asset === null || asset === void 0 ? void 0 : asset.code;
57
+ }
58
+ function getSharedWalletAssetAmount(asset) {
59
+ var _ref2, _ref3, _ref4, _ref5, _asset$edit_current_a;
60
+ var value = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_asset$edit_current_a = asset === null || asset === void 0 ? void 0 : asset.edit_current_amount) !== null && _asset$edit_current_a !== void 0 ? _asset$edit_current_a : asset === null || asset === void 0 ? void 0 : asset._available_max_amount) !== null && _ref5 !== void 0 ? _ref5 : (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' ? asset === null || asset === void 0 ? void 0 : asset.recommended_usage_amount : asset === null || asset === void 0 ? void 0 : asset.available_max_amount) !== null && _ref4 !== void 0 ? _ref4 : asset === null || asset === void 0 ? void 0 : asset.actualDeduction) !== null && _ref3 !== void 0 ? _ref3 : asset === null || asset === void 0 ? void 0 : asset.amount) !== null && _ref2 !== void 0 ? _ref2 : 0;
61
+ var amount = Number(value);
62
+ return Number.isFinite(amount) && amount > 0 ? amount : 0;
63
+ }
64
+ function isRejectedSalesSubmitResult(result) {
65
+ var _result$response, _result$response2;
66
+ var candidates = [result, result === null || result === void 0 ? void 0 : result.data, result === null || result === void 0 || (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.data, result === null || result === void 0 || (_result$response2 = result.response) === null || _result$response2 === void 0 ? void 0 : _result$response2.body];
67
+ return candidates.some(function (candidate) {
68
+ var _candidate$code;
69
+ if (!candidate || _typeof(candidate) !== 'object') return false;
70
+ var responseCode = Number((_candidate$code = candidate.code) !== null && _candidate$code !== void 0 ? _candidate$code : candidate.statusCode);
71
+ if (Number.isFinite(responseCode) && responseCode >= 400) return true;
72
+ if (candidate.status === false || candidate.success === false || candidate.result === false) {
73
+ return true;
74
+ }
75
+ return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
76
+ });
77
+ }
78
+ function getSalesSubmitErrorMessage(result) {
79
+ var _result$data, _result$data2;
80
+ return (result === null || result === void 0 ? void 0 : result.message) || (result === null || result === void 0 ? void 0 : result.msg) || (result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.message) || (result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.msg) || 'Wallet 支付确认失败';
81
+ }
82
+ function toWalletFundValue(value) {
83
+ try {
84
+ return new Decimal(value || 0).toDecimalPlaces(2).toFixed(2);
85
+ } catch (_unused) {
86
+ return '0.00';
87
+ }
88
+ }
89
+ function subtractWalletFundValue(left, right) {
90
+ try {
91
+ return new Decimal(left || 0).minus(right || 0).toDecimalPlaces(2).toFixed(2);
92
+ } catch (_unused2) {
93
+ return '0.00';
94
+ }
95
+ }
96
+ function getSharedWalletPassUseValue(params) {
97
+ var asset = params.asset,
98
+ amount = params.amount,
99
+ paymentMethod = params.paymentMethod;
100
+ var configuredValue = Number(asset === null || asset === void 0 ? void 0 : asset.wallet_pass_use_value);
101
+ if (Number.isFinite(configuredValue) && configuredValue > 0) {
102
+ return configuredValue;
103
+ }
104
+ var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
105
+ var usageUnit = asset === null || asset === void 0 ? void 0 : asset.wallet_pass_usage_unit;
106
+ if (isPointCard && usageUnit !== null && usageUnit !== void 0 && usageUnit.points && usageUnit !== null && usageUnit !== void 0 && usageUnit.price) {
107
+ return new Decimal(amount).div(usageUnit.price).mul(usageUnit.points).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
108
+ }
109
+ return amount;
110
+ }
111
+ function buildSharedWalletFundRecord(params) {
112
+ var _ref6, _ref7, _asset$balance_par_va, _asset$voucher_id;
113
+ var asset = params.asset,
114
+ amount = params.amount,
115
+ paymentMethod = params.paymentMethod;
116
+ var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
117
+ var usingBeforeValue = (_ref6 = (_ref7 = (_asset$balance_par_va = asset === null || asset === void 0 ? void 0 : asset.balance_par_value) !== null && _asset$balance_par_va !== void 0 ? _asset$balance_par_va : asset === null || asset === void 0 ? void 0 : asset.balance) !== null && _ref7 !== void 0 ? _ref7 : asset === null || asset === void 0 ? void 0 : asset.using_before_value) !== null && _ref6 !== void 0 ? _ref6 : 0;
118
+ var walletPassUseValue = getSharedWalletPassUseValue(params);
119
+ var usingValue = isPointCard ? walletPassUseValue : amount;
120
+ var walletPassName = (asset === null || asset === void 0 ? void 0 : asset.wallet_pass_name) || (asset === null || asset === void 0 ? void 0 : asset.format_title) || (asset === null || asset === void 0 ? void 0 : asset.product_name) || (asset === null || asset === void 0 ? void 0 : asset.name) || paymentMethod.name;
121
+ return {
122
+ voucher_id: (_asset$voucher_id = asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _asset$voucher_id !== void 0 ? _asset$voucher_id : asset === null || asset === void 0 ? void 0 : asset.id,
123
+ wallet_pass_name: walletPassName && _typeof(walletPassName) === 'object' ? walletPassName : {
124
+ default: walletPassName || ''
125
+ },
126
+ code: (asset === null || asset === void 0 ? void 0 : asset.code) || (asset === null || asset === void 0 ? void 0 : asset.tag),
127
+ encoded: asset === null || asset === void 0 ? void 0 : asset.encoded,
128
+ using_before_value: toWalletFundValue(usingBeforeValue),
129
+ using_after_value: subtractWalletFundValue(usingBeforeValue, usingValue)
130
+ };
131
+ }
49
132
  function isBaseSalesManualProductDiscountProduct(product) {
50
133
  var _product$metadata, _product$metadata2;
51
134
  return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
@@ -304,6 +387,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
304
387
  });
305
388
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
306
389
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
390
+ /**
391
+ * 由已在初始化阶段解析过设备短号的业务解决方案写入。
392
+ * 未设置时,支付编号仍按原逻辑实时读取设备信息。
393
+ */
394
+ _defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
307
395
  /**
308
396
  * window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
309
397
  * `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
@@ -321,6 +409,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
321
409
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
322
410
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
323
411
  _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
412
+ _defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
324
413
  _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
325
414
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
326
415
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
@@ -513,12 +602,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
513
602
  return _context3.abrupt("return");
514
603
  case 14:
515
604
  this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
516
- var _getTempOrder, _ref2;
605
+ var _getTempOrder, _ref9;
517
606
  var currentTempOrder, record, sales;
518
607
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
519
608
  while (1) switch (_context2.prev = _context2.next) {
520
609
  case 0:
521
- currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
610
+ currentTempOrder = (_getTempOrder = (_ref9 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref9);
522
611
  record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
523
612
  _context2.next = 4;
524
613
  return _this2.store.order.hydrateTempOrderFromRecord(record, {
@@ -587,7 +676,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
587
676
  hydratedSales = null;
588
677
  skippedBeforeHydrate = false;
589
678
  hydrateTask = /*#__PURE__*/function () {
590
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
679
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
591
680
  var sales;
592
681
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
593
682
  while (1) switch (_context4.prev = _context4.next) {
@@ -632,7 +721,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
632
721
  }, _callee4);
633
722
  }));
634
723
  return function hydrateTask() {
635
- return _ref3.apply(this, arguments);
724
+ return _ref10.apply(this, arguments);
636
725
  };
637
726
  }();
638
727
  queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
@@ -726,10 +815,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
726
815
  });
727
816
  }
728
817
  quotation.setScheduleResolver(function (id) {
729
- var _scheduleModule$getSc, _getScheduleByIds, _ref4;
818
+ var _scheduleModule$getSc, _getScheduleByIds, _ref11;
730
819
  var scheduleId = String(id);
731
820
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
732
- var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
821
+ var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref11 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref11, [id])) || [];
733
822
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
734
823
  return schedules[0];
735
824
  });
@@ -916,10 +1005,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
916
1005
  return groups.flatMap(function (group) {
917
1006
  var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
918
1007
  return items.map(function (item) {
919
- var _item$group_id, _ref5, _item$bundle_group_id;
1008
+ var _item$group_id, _ref12, _item$bundle_group_id;
920
1009
  return _objectSpread(_objectSpread({}, item), {}, {
921
1010
  group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
922
- bundle_group_id: (_ref5 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
1011
+ bundle_group_id: (_ref12 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref12 !== void 0 ? _ref12 : group === null || group === void 0 ? void 0 : group.id
923
1012
  });
924
1013
  });
925
1014
  });
@@ -950,21 +1039,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
950
1039
  }, {
951
1040
  key: "getAuthoritativeBundleUnitPrice",
952
1041
  value: function getAuthoritativeBundleUnitPrice(bundle) {
953
- var _ref6, _ref7, _ref8, _bundle$price;
954
- return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
1042
+ var _ref13, _ref14, _ref15, _bundle$price;
1043
+ return (_ref13 = (_ref14 = (_ref15 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.custom_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.product_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.base_price;
955
1044
  }
956
1045
  }, {
957
1046
  key: "mergeProductForPriceQuery",
958
1047
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
959
1048
  var _this5 = this,
960
1049
  _product$id,
961
- _ref9,
1050
+ _ref16,
962
1051
  _product$product_id2,
963
- _ref10,
1052
+ _ref17,
964
1053
  _product$product_vari,
965
- _ref11,
1054
+ _ref18,
966
1055
  _product$num,
967
- _ref12,
1056
+ _ref19,
968
1057
  _product$quantity,
969
1058
  _product$metadata4;
970
1059
  if (!authoritativeProduct) return product;
@@ -984,10 +1073,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
984
1073
  });
985
1074
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
986
1075
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
987
- product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
988
- product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
989
- num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
990
- quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
1076
+ product_id: (_ref16 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref16 !== void 0 ? _ref16 : authoritativeProduct.id,
1077
+ product_variant_id: (_ref17 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0,
1078
+ num: (_ref18 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref18 !== void 0 ? _ref18 : authoritativeProduct.num,
1079
+ quantity: (_ref19 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.quantity,
991
1080
  product_sku: function () {
992
1081
  var authoritativeSku = ensureProductSku(authoritativeProduct);
993
1082
  var productSku = ensureProductSku(product);
@@ -1063,24 +1152,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1063
1152
  value: (function () {
1064
1153
  var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
1065
1154
  var _this6 = this;
1066
- var _ref13,
1067
- _ref13$cover,
1155
+ var _ref20,
1156
+ _ref20$cover,
1068
1157
  cover,
1069
1158
  nextSubModuleOtherParams,
1070
1159
  _args10 = arguments;
1071
1160
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1072
1161
  while (1) switch (_context10.prev = _context10.next) {
1073
1162
  case 0:
1074
- _ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
1163
+ _ref20 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref20$cover = _ref20.cover, cover = _ref20$cover === void 0 ? false : _ref20$cover;
1075
1164
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
1076
1165
  _context10.next = 4;
1077
1166
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1078
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
1079
- var _ref16, moduleName, subModule, targetModule;
1167
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
1168
+ var _ref23, moduleName, subModule, targetModule;
1080
1169
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1081
1170
  while (1) switch (_context9.prev = _context9.next) {
1082
1171
  case 0:
1083
- _ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
1172
+ _ref23 = _slicedToArray(_ref21, 2), moduleName = _ref23[0], subModule = _ref23[1];
1084
1173
  if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1085
1174
  _context9.next = 3;
1086
1175
  break;
@@ -1106,7 +1195,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1106
1195
  }, _callee9);
1107
1196
  }));
1108
1197
  return function (_x9) {
1109
- return _ref15.apply(this, arguments);
1198
+ return _ref22.apply(this, arguments);
1110
1199
  };
1111
1200
  }()));
1112
1201
  case 4:
@@ -1134,7 +1223,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1134
1223
  if (!sessionData) return {};
1135
1224
  var data = JSON.parse(sessionData);
1136
1225
  return data && data[this.cacheId] || {};
1137
- } catch (_unused) {
1226
+ } catch (_unused3) {
1138
1227
  return {};
1139
1228
  }
1140
1229
  }
@@ -1148,6 +1237,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1148
1237
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
1149
1238
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1150
1239
  }
1240
+
1241
+ /**
1242
+ * 复用业务解决方案初始化时已解析的支付设备短号。
1243
+ * 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
1244
+ */
1245
+ }, {
1246
+ key: "setPaymentNumberDevicePrefix",
1247
+ value: function setPaymentNumberDevicePrefix(prefix) {
1248
+ var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
1249
+ this.paymentNumberDevicePrefix = normalized || null;
1250
+ }
1151
1251
  }, {
1152
1252
  key: "getPaymentNumberDevicePrefixSync",
1153
1253
  value: function getPaymentNumberDevicePrefixSync() {
@@ -1162,6 +1262,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1162
1262
  value: function getPaymentNumberDevicePrefixAsync() {
1163
1263
  var _this8 = this;
1164
1264
  if (!this.appPlugin) return Promise.resolve('LOCAL');
1265
+ if (this.paymentNumberDevicePrefix) {
1266
+ return Promise.resolve(this.paymentNumberDevicePrefix);
1267
+ }
1165
1268
  return resolvePaymentNumberDevicePrefix(function (key) {
1166
1269
  return _this8.getAppData(key);
1167
1270
  });
@@ -1222,6 +1325,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1222
1325
  options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1223
1326
  this.core = core;
1224
1327
  this.initializeOptions = options || {};
1328
+ this.paymentNumberDevicePrefix = null;
1225
1329
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1226
1330
  this.otherParams = options.otherParams || {};
1227
1331
  this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
@@ -1232,11 +1336,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1232
1336
  // 获取 logger 实例
1233
1337
  this.appPlugin = core.getPlugin('app');
1234
1338
  if (this.appPlugin) {
1235
- _context11.next = 11;
1339
+ _context11.next = 12;
1236
1340
  break;
1237
1341
  }
1238
1342
  throw new Error('Checkout 解决方案需要 app 插件支持');
1239
- case 11:
1343
+ case 12:
1240
1344
  app = this.appPlugin.getApp();
1241
1345
  this.logger = app.logger;
1242
1346
  targetCacheData = this.readSessionCacheData();
@@ -1263,21 +1367,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1263
1367
  }));
1264
1368
  });
1265
1369
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1266
- _context11.next = 19;
1370
+ _context11.next = 20;
1267
1371
  break;
1268
1372
  }
1269
- _context11.next = 19;
1373
+ _context11.next = 20;
1270
1374
  return this.store.schedule.loadAllSchedule();
1271
- case 19:
1375
+ case 20:
1272
1376
  if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
1273
1377
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1274
1378
  }
1275
- _context11.next = 22;
1379
+ _context11.next = 23;
1276
1380
  return this.getPaymentMethodsAsync();
1277
- case 22:
1381
+ case 23:
1278
1382
  this.registerServerOrderChangeSync();
1279
1383
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1280
- case 24:
1384
+ case 25:
1281
1385
  case "end":
1282
1386
  return _context11.stop();
1283
1387
  }
@@ -1311,13 +1415,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1311
1415
  }
1312
1416
  });
1313
1417
  this.currentSalesDetail = null;
1418
+ this.paymentNumberDevicePrefix = null;
1314
1419
  this.queuedServerOrderChanges = [];
1315
1420
  this.salesDetailLoadSequence += 1;
1316
- _context12.next = 8;
1421
+ this.walletAssetsRefreshSequence += 1;
1422
+ _context12.next = 10;
1317
1423
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1318
- case 8:
1424
+ case 10:
1319
1425
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1320
- case 9:
1426
+ case 11:
1321
1427
  case "end":
1322
1428
  return _context12.stop();
1323
1429
  }
@@ -1339,7 +1445,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1339
1445
  key: "loadSalesDetail",
1340
1446
  value: (function () {
1341
1447
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1342
- var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1448
+ var loadSequence, _ref24, _ref25, _ref26, _ref27, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1343
1449
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1344
1450
  while (1) switch (_context13.prev = _context13.next) {
1345
1451
  case 0:
@@ -1357,7 +1463,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1357
1463
  };
1358
1464
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1359
1465
  preloadedSalesDetail = params.preloadedSalesDetail;
1360
- lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1466
+ lookup = (_ref24 = (_ref25 = (_ref26 = (_ref27 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref27 !== void 0 ? _ref27 : params.orderNumber) !== null && _ref26 !== void 0 ? _ref26 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref25 !== void 0 ? _ref25 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref24 !== void 0 ? _ref24 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1361
1467
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1362
1468
  _context13.next = 11;
1363
1469
  break;
@@ -1698,7 +1804,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1698
1804
  key: "restoreOrder",
1699
1805
  value: function () {
1700
1806
  var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1701
- var tempOrder;
1807
+ var _this$store$payment, tempOrder, wallet;
1702
1808
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1703
1809
  while (1) switch (_context17.prev = _context17.next) {
1704
1810
  case 0:
@@ -1714,29 +1820,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1714
1820
  this.currentSalesDetail = null;
1715
1821
  this.discountConfigCacheKey = null;
1716
1822
  this.hasManualDiscountSelection = false;
1717
- _context17.next = 9;
1823
+ wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
1824
+ if (!wallet) {
1825
+ _context17.next = 13;
1826
+ break;
1827
+ }
1828
+ this.walletAssetsRefreshSequence += 1;
1829
+ wallet.clearAllCache();
1830
+ _context17.next = 13;
1831
+ return this.publishWalletAssetsState(wallet.getWalletAssetsState());
1832
+ case 13:
1833
+ _context17.next = 15;
1718
1834
  return this.effectsEmit('onTempOrderReplaced', {
1719
1835
  tempOrder: tempOrder
1720
1836
  });
1721
- case 9:
1837
+ case 15:
1722
1838
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1723
- _context17.next = 13;
1839
+ _context17.next = 19;
1724
1840
  break;
1725
1841
  }
1726
1842
  this.store.order.persistTempOrder();
1727
- _context17.next = 13;
1843
+ _context17.next = 19;
1728
1844
  return this.store.order.saveDraft();
1729
- case 13:
1845
+ case 19:
1730
1846
  return _context17.abrupt("return", tempOrder);
1731
- case 16:
1732
- _context17.prev = 16;
1847
+ case 22:
1848
+ _context17.prev = 22;
1733
1849
  _context17.t0 = _context17["catch"](0);
1734
1850
  throw _context17.t0;
1735
- case 19:
1851
+ case 25:
1736
1852
  case "end":
1737
1853
  return _context17.stop();
1738
1854
  }
1739
- }, _callee17, this, [[0, 16]]);
1855
+ }, _callee17, this, [[0, 22]]);
1740
1856
  }));
1741
1857
  function restoreOrder() {
1742
1858
  return _restoreOrder.apply(this, arguments);
@@ -2495,10 +2611,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2495
2611
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2496
2612
  if (Array.isArray(product.product_bundle)) {
2497
2613
  product.product_bundle = product.product_bundle.map(function (bundle) {
2498
- var _ref21, _bundle$original_pric;
2614
+ var _ref28, _bundle$original_pric;
2499
2615
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2500
2616
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2501
- var restoredBundlePrice = (_ref21 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2617
+ var restoredBundlePrice = (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2502
2618
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2503
2619
  price: restoredBundlePrice,
2504
2620
  bundle_selling_price: restoredBundlePrice
@@ -2722,7 +2838,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2722
2838
  key: "saveSalesOrderDraft",
2723
2839
  value: function () {
2724
2840
  var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2725
- var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2841
+ var _params$platform, _this$otherParams10, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2726
2842
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2727
2843
  while (1) switch (_context28.prev = _context28.next) {
2728
2844
  case 0:
@@ -2735,7 +2851,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2735
2851
  return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2736
2852
  cacheId: this.cacheId,
2737
2853
  platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2738
- businessCode: (_ref22 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
2854
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2739
2855
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2740
2856
  type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2741
2857
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
@@ -2873,7 +2989,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2873
2989
  if (!amountSnapshot) return undefined;
2874
2990
  try {
2875
2991
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
2876
- } catch (_unused2) {
2992
+ } catch (_unused4) {
2877
2993
  return undefined;
2878
2994
  }
2879
2995
  }
@@ -2881,7 +2997,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2881
2997
  key: "syncPaymentsToOrder",
2882
2998
  value: function () {
2883
2999
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2884
- var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
3000
+ var _ref29, _params$businessCode, _this$otherParams22, _this$otherParams23, _params$channel2;
2885
3001
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2886
3002
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2887
3003
  while (1) switch (_context31.prev = _context31.next) {
@@ -2892,7 +3008,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2892
3008
  }
2893
3009
  throw new Error('order 模块未初始化');
2894
3010
  case 2:
2895
- businessCode = (_ref23 = (_params$businessCode2 = params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref23 !== void 0 ? _ref23 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
3011
+ businessCode = (_ref29 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref29 !== void 0 ? _ref29 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
2896
3012
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2897
3013
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2898
3014
  businessCode: businessCode
@@ -3106,7 +3222,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3106
3222
  return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3107
3223
  }
3108
3224
 
3109
- /** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
3225
+ /**
3226
+ * 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
3227
+ * 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
3228
+ */
3110
3229
  }, {
3111
3230
  key: "addOrderPaymentAsync",
3112
3231
  value: (function () {
@@ -3149,7 +3268,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3149
3268
  var _this$otherParams24,
3150
3269
  _paymentRecord$paymen,
3151
3270
  _paymentRecord$create,
3152
- _ref24,
3271
+ _ref30,
3153
3272
  _paymentRecord$origin,
3154
3273
  _this14 = this;
3155
3274
  if (!this.store.order) throw new Error('order 模块未初始化');
@@ -3171,7 +3290,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3171
3290
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3172
3291
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3173
3292
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3174
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref24 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref24 !== void 0 ? _ref24 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3293
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref30 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref30 !== void 0 ? _ref30 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3175
3294
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3176
3295
  service_fee: calculatedServiceFee
3177
3296
  } : {}), {}, {
@@ -3374,7 +3493,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3374
3493
  key: "confirmPendingVoucherPayments",
3375
3494
  value: function confirmPendingVoucherPayments() {
3376
3495
  if (!this.store.order) throw new Error('order 模块未初始化');
3377
- return this.store.order.confirmPendingVoucherPayments();
3496
+ var payments = this.store.order.confirmPendingVoucherPayments();
3497
+ if (this.store.payment) {
3498
+ var committed = this.getCommittedWalletAssets();
3499
+ var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3500
+ void this.publishWalletAssetsState(state);
3501
+ }
3502
+ return payments;
3378
3503
  }
3379
3504
  }, {
3380
3505
  key: "discardPendingVoucherPayments",
@@ -3443,12 +3568,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3443
3568
  });
3444
3569
  return walletProducts;
3445
3570
  }
3571
+ }, {
3572
+ key: "buildWalletInitBusinessData",
3573
+ value: function buildWalletInitBusinessData(params) {
3574
+ var _this$store$order8, _params$order_wait_pa, _ref31, _tempOrder$is_price_i;
3575
+ var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
3576
+ var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3577
+ var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3578
+ if (!tempOrder || !amount) return null;
3579
+ return _objectSpread({
3580
+ customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
3581
+ holder: tempOrder.holder,
3582
+ amountInfo: {
3583
+ totalAmount: amount.totalAmount,
3584
+ subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
3585
+ depositAmount: amount.depositAmount,
3586
+ isDeposit: tempOrder.is_deposit
3587
+ },
3588
+ products: this.getWalletProductList(),
3589
+ 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),
3590
+ is_price_include_tax: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : 1
3591
+ }, snapshot.identity.orderId ? {
3592
+ payment_order_id: String(snapshot.identity.orderId)
3593
+ } : {});
3594
+ }
3446
3595
  }, {
3447
3596
  key: "initWalletData",
3448
3597
  value: function () {
3449
3598
  var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3450
- var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
3451
- var snapshot, tempOrder, amount, walletBusinessData, result;
3599
+ var _snapshot$identity;
3600
+ var snapshot, walletBusinessData, result;
3452
3601
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3453
3602
  while (1) switch (_context36.prev = _context36.next) {
3454
3603
  case 0:
@@ -3465,10 +3614,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3465
3614
  throw new Error('payment 模块未初始化');
3466
3615
  case 4:
3467
3616
  snapshot = this.store.order.getOrderSnapshot();
3468
- tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3469
- amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3470
- if (!(!tempOrder || !amount)) {
3471
- _context36.next = 9;
3617
+ walletBusinessData = this.buildWalletInitBusinessData(params);
3618
+ if (walletBusinessData) {
3619
+ _context36.next = 8;
3472
3620
  break;
3473
3621
  }
3474
3622
  return _context36.abrupt("return", {
@@ -3478,29 +3626,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3478
3626
  noApplicableVoucher: [],
3479
3627
  products: []
3480
3628
  });
3481
- case 9:
3482
- walletBusinessData = _objectSpread({
3483
- customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
3484
- holder: tempOrder.holder,
3485
- amountInfo: {
3486
- totalAmount: amount.totalAmount,
3487
- subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
3488
- depositAmount: amount.depositAmount,
3489
- isDeposit: tempOrder.is_deposit
3490
- },
3491
- products: this.getWalletProductList(),
3492
- 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),
3493
- is_price_include_tax: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : 1
3494
- }, snapshot.identity.orderId ? {
3495
- payment_order_id: String(snapshot.identity.orderId)
3496
- } : {});
3497
- _context36.next = 12;
3629
+ case 8:
3630
+ _context36.next = 10;
3498
3631
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3499
- case 12:
3632
+ case 10:
3500
3633
  result = _context36.sent;
3501
- _context36.next = 15;
3634
+ _context36.next = 13;
3502
3635
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3503
- orderId: snapshot.identity.orderId,
3636
+ orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
3504
3637
  customerId: walletBusinessData.customer_id,
3505
3638
  walletBusinessData: {
3506
3639
  customer_id: walletBusinessData.customer_id,
@@ -3509,9 +3642,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3509
3642
  },
3510
3643
  timestamp: Date.now()
3511
3644
  });
3512
- case 15:
3645
+ case 13:
3513
3646
  return _context36.abrupt("return", result);
3514
- case 16:
3647
+ case 14:
3515
3648
  case "end":
3516
3649
  return _context36.stop();
3517
3650
  }
@@ -3522,12 +3655,400 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3522
3655
  }
3523
3656
  return initWalletData;
3524
3657
  }()
3658
+ }, {
3659
+ key: "getCommittedWalletAssets",
3660
+ value: function getCommittedWalletAssets() {
3661
+ var _this$store$order9, _this$store$order9$ge;
3662
+ 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)) || [];
3663
+ var committed = payments.filter(function (payment) {
3664
+ var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
3665
+ if (voucherId === undefined || voucherId === null || voucherId === 0) {
3666
+ return false;
3667
+ }
3668
+ return (payment === null || payment === void 0 ? void 0 : payment.status) === 'paid' || (payment === null || payment === void 0 ? void 0 : payment.isSynced) === true || (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== null && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== '';
3669
+ });
3670
+ return {
3671
+ ids: committed.map(function (payment) {
3672
+ return payment.voucher_id;
3673
+ }),
3674
+ assets: committed.map(function (payment) {
3675
+ var _Object$entries$find;
3676
+ var fundRecord = (payment === null || payment === void 0 ? void 0 : payment.fund_record) || {};
3677
+ var walletPassName = fundRecord.wallet_pass_name;
3678
+ var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
3679
+ var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
3680
+ var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref32) {
3681
+ var _ref33 = _slicedToArray(_ref32, 2),
3682
+ paymentCode = _ref33[1];
3683
+ return paymentCode === code;
3684
+ })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
3685
+ return {
3686
+ id: payment.voucher_id,
3687
+ voucher_id: payment.voucher_id,
3688
+ code: fundRecord.code,
3689
+ tag: tag,
3690
+ product_name: title || payment.name,
3691
+ name: title || payment.name,
3692
+ amount: Number(payment.amount || 0),
3693
+ _available_max_amount: Number(payment.amount || 0),
3694
+ unified_available_status: 1,
3695
+ _unified_available_status: 1,
3696
+ _committed_payment: payment
3697
+ };
3698
+ })
3699
+ };
3700
+ }
3701
+ }, {
3702
+ key: "publishWalletAssetsState",
3703
+ value: function () {
3704
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
3705
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3706
+ while (1) switch (_context37.prev = _context37.next) {
3707
+ case 0:
3708
+ _context37.next = 2;
3709
+ return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
3710
+ state: state
3711
+ });
3712
+ case 2:
3713
+ return _context37.abrupt("return", state);
3714
+ case 3:
3715
+ case "end":
3716
+ return _context37.stop();
3717
+ }
3718
+ }, _callee37, this);
3719
+ }));
3720
+ function publishWalletAssetsState(_x32) {
3721
+ return _publishWalletAssetsState.apply(this, arguments);
3722
+ }
3723
+ return publishWalletAssetsState;
3724
+ }()
3725
+ }, {
3726
+ key: "syncSelectedWalletAssets",
3727
+ value: function () {
3728
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
3729
+ var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
3730
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3731
+ while (1) switch (_context38.prev = _context38.next) {
3732
+ case 0:
3733
+ if (!(!this.store.order || !this.store.payment)) {
3734
+ _context38.next = 2;
3735
+ break;
3736
+ }
3737
+ throw new Error('订单或支付模块未初始化');
3738
+ case 2:
3739
+ paymentMethods = this.getPaymentMethods();
3740
+ if (!(!paymentMethods.length && state.selectedItems.length)) {
3741
+ _context38.next = 7;
3742
+ break;
3743
+ }
3744
+ _context38.next = 6;
3745
+ return this.getPaymentMethodsAsync();
3746
+ case 6:
3747
+ paymentMethods = _context38.sent;
3748
+ case 7:
3749
+ methodByCode = new Map(paymentMethods.map(function (method) {
3750
+ return [String(method.code || '').toUpperCase(), method];
3751
+ }));
3752
+ preparePayments = this.store.payment.wallet.formatWalletPassList2PreparePayments(state.selectedItems);
3753
+ selectedAssetById = new Map(state.selectedItems.map(function (asset) {
3754
+ return [String(getSharedWalletAssetId(asset)), asset];
3755
+ }));
3756
+ voucherPayments = preparePayments.flatMap(function (item) {
3757
+ var asset = selectedAssetById.get(String(item.voucher_id));
3758
+ var paymentCode = WALLET_PAYMENT_CODE_BY_TAG[String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '')] || String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '').toUpperCase();
3759
+ var paymentMethod = methodByCode.get(paymentCode);
3760
+ var formattedAmount = Number(item.amount);
3761
+ var amount = Number.isFinite(formattedAmount) && formattedAmount > 0 ? formattedAmount : getSharedWalletAssetAmount(asset);
3762
+ if (!asset || !paymentMethod || !Number.isFinite(amount) || amount <= 0) {
3763
+ return [];
3764
+ }
3765
+ var walletPassUseValue = getSharedWalletPassUseValue({
3766
+ asset: asset,
3767
+ amount: amount,
3768
+ paymentMethod: paymentMethod
3769
+ });
3770
+ return [{
3771
+ amount: amount.toFixed(2),
3772
+ code: paymentMethod.code,
3773
+ custom_payment_id: paymentMethod.id,
3774
+ name: paymentMethod.name,
3775
+ type: paymentMethod.type,
3776
+ voucher_id: item.voucher_id,
3777
+ wallet_pass_usage_unit: item.wallet_pass_usage_unit,
3778
+ wallet_pass_use_value: walletPassUseValue,
3779
+ fund_record: buildSharedWalletFundRecord({
3780
+ asset: asset,
3781
+ amount: amount,
3782
+ paymentMethod: paymentMethod
3783
+ })
3784
+ }];
3785
+ });
3786
+ payments = this.updateVoucherOrderPayments(voucherPayments, {
3787
+ status: 'payment_pending'
3788
+ });
3789
+ _context38.next = 14;
3790
+ return this.store.order.recalculateSummary({
3791
+ createIfMissing: true
3792
+ });
3793
+ case 14:
3794
+ return _context38.abrupt("return", payments);
3795
+ case 15:
3796
+ case "end":
3797
+ return _context38.stop();
3798
+ }
3799
+ }, _callee38, this);
3800
+ }));
3801
+ function syncSelectedWalletAssets(_x33) {
3802
+ return _syncSelectedWalletAssets.apply(this, arguments);
3803
+ }
3804
+ return syncSelectedWalletAssets;
3805
+ }() /** 读取购物车与 Shared Checkout 共用的钱包资产状态。 */
3806
+ }, {
3807
+ key: "getWalletAssetsState",
3808
+ value: function getWalletAssetsState() {
3809
+ if (!this.store.payment) throw new Error('payment 模块未初始化');
3810
+ return this.store.payment.wallet.getWalletAssetsState();
3811
+ }
3812
+
3813
+ /** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
3814
+ }, {
3815
+ key: "exportWalletAssetsSnapshot",
3816
+ value: function exportWalletAssetsSnapshot() {
3817
+ if (!this.store.payment) throw new Error('payment 模块未初始化');
3818
+ return this.store.payment.wallet.exportWalletAssetsSnapshot();
3819
+ }
3820
+
3821
+ /**
3822
+ * 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
3823
+ */
3824
+ }, {
3825
+ key: "importWalletAssetsSnapshot",
3826
+ value: (function () {
3827
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
3828
+ var state;
3829
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3830
+ while (1) switch (_context39.prev = _context39.next) {
3831
+ case 0:
3832
+ if (this.store.payment) {
3833
+ _context39.next = 2;
3834
+ break;
3835
+ }
3836
+ throw new Error('payment 模块未初始化');
3837
+ case 2:
3838
+ state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
3839
+ _context39.next = 5;
3840
+ return this.syncSelectedWalletAssets(state);
3841
+ case 5:
3842
+ return _context39.abrupt("return", this.publishWalletAssetsState(state));
3843
+ case 6:
3844
+ case "end":
3845
+ return _context39.stop();
3846
+ }
3847
+ }, _callee39, this);
3848
+ }));
3849
+ function importWalletAssetsSnapshot(_x34) {
3850
+ return _importWalletAssetsSnapshot.apply(this, arguments);
3851
+ }
3852
+ return importWalletAssetsSnapshot;
3853
+ }()
3854
+ /**
3855
+ * 基于当前订单快照刷新钱包资产。商品变化保留并重验选择;客户变化强制清空。
3856
+ */
3857
+ )
3858
+ }, {
3859
+ key: "refreshWalletAssets",
3860
+ value: (function () {
3861
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3862
+ var _previousState$custom, _businessData$custome;
3863
+ var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
3864
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3865
+ while (1) switch (_context40.prev = _context40.next) {
3866
+ case 0:
3867
+ if (this.store.order) {
3868
+ _context40.next = 2;
3869
+ break;
3870
+ }
3871
+ throw new Error('order 模块未初始化');
3872
+ case 2:
3873
+ if (this.store.payment) {
3874
+ _context40.next = 4;
3875
+ break;
3876
+ }
3877
+ throw new Error('payment 模块未初始化');
3878
+ case 4:
3879
+ refreshSequence = ++this.walletAssetsRefreshSequence;
3880
+ wallet = this.store.payment.wallet;
3881
+ businessData = this.buildWalletInitBusinessData(params);
3882
+ if (businessData) {
3883
+ _context40.next = 12;
3884
+ break;
3885
+ }
3886
+ wallet.clearAllCache();
3887
+ emptyState = wallet.getWalletAssetsState();
3888
+ this.updateVoucherOrderPayments([], {
3889
+ status: 'payment_pending'
3890
+ });
3891
+ return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
3892
+ case 12:
3893
+ previousState = wallet.getWalletAssetsState();
3894
+ hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
3895
+ 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 : '');
3896
+ if (!customerChanged) {
3897
+ _context40.next = 20;
3898
+ break;
3899
+ }
3900
+ clearedState = wallet.clearWalletAssetSelection();
3901
+ this.updateVoucherOrderPayments([], {
3902
+ status: 'payment_pending'
3903
+ });
3904
+ _context40.next = 20;
3905
+ return this.publishWalletAssetsState(clearedState);
3906
+ case 20:
3907
+ refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
3908
+ preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
3909
+ });
3910
+ _context40.next = 23;
3911
+ return this.publishWalletAssetsState(wallet.getWalletAssetsState());
3912
+ case 23:
3913
+ _context40.next = 25;
3914
+ return refreshTask;
3915
+ case 25:
3916
+ state = _context40.sent;
3917
+ if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
3918
+ _context40.next = 28;
3919
+ break;
3920
+ }
3921
+ return _context40.abrupt("return", wallet.getWalletAssetsState());
3922
+ case 28:
3923
+ if (state.status !== 'error') {
3924
+ committed = this.getCommittedWalletAssets();
3925
+ state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3926
+ }
3927
+ _context40.next = 31;
3928
+ return this.syncSelectedWalletAssets(state);
3929
+ case 31:
3930
+ return _context40.abrupt("return", this.publishWalletAssetsState(state));
3931
+ case 32:
3932
+ case "end":
3933
+ return _context40.stop();
3934
+ }
3935
+ }, _callee40, this);
3936
+ }));
3937
+ function refreshWalletAssets(_x35) {
3938
+ return _refreshWalletAssets.apply(this, arguments);
3939
+ }
3940
+ return refreshWalletAssets;
3941
+ }() /** 选择或取消单张钱包资产,并立即同步 pending wallet payments。 */)
3942
+ }, {
3943
+ key: "selectWalletAsset",
3944
+ value: (function () {
3945
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3946
+ var state;
3947
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3948
+ while (1) switch (_context41.prev = _context41.next) {
3949
+ case 0:
3950
+ if (this.store.payment) {
3951
+ _context41.next = 2;
3952
+ break;
3953
+ }
3954
+ throw new Error('payment 模块未初始化');
3955
+ case 2:
3956
+ state = this.store.payment.wallet.selectWalletAsset(params.assetId, {
3957
+ selected: params.selected,
3958
+ source: params.source
3959
+ });
3960
+ _context41.next = 5;
3961
+ return this.syncSelectedWalletAssets(state);
3962
+ case 5:
3963
+ return _context41.abrupt("return", this.publishWalletAssetsState(state));
3964
+ case 6:
3965
+ case "end":
3966
+ return _context41.stop();
3967
+ }
3968
+ }, _callee41, this);
3969
+ }));
3970
+ function selectWalletAsset(_x36) {
3971
+ return _selectWalletAsset.apply(this, arguments);
3972
+ }
3973
+ return selectWalletAsset;
3974
+ }() /** 扫码精确查券;仅可用资产会被自动选中。 */)
3975
+ }, {
3976
+ key: "scanWalletAsset",
3977
+ value: (function () {
3978
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(code) {
3979
+ var result;
3980
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3981
+ while (1) switch (_context42.prev = _context42.next) {
3982
+ case 0:
3983
+ if (this.store.payment) {
3984
+ _context42.next = 2;
3985
+ break;
3986
+ }
3987
+ throw new Error('payment 模块未初始化');
3988
+ case 2:
3989
+ _context42.next = 4;
3990
+ return this.store.payment.wallet.scanWalletAssetAsync(code);
3991
+ case 4:
3992
+ result = _context42.sent;
3993
+ if (!(result.type === 'normalCode')) {
3994
+ _context42.next = 10;
3995
+ break;
3996
+ }
3997
+ _context42.next = 8;
3998
+ return this.syncSelectedWalletAssets(result.state);
3999
+ case 8:
4000
+ _context42.next = 10;
4001
+ return this.publishWalletAssetsState(result.state);
4002
+ case 10:
4003
+ return _context42.abrupt("return", result);
4004
+ case 11:
4005
+ case "end":
4006
+ return _context42.stop();
4007
+ }
4008
+ }, _callee42, this);
4009
+ }));
4010
+ function scanWalletAsset(_x37) {
4011
+ return _scanWalletAsset.apply(this, arguments);
4012
+ }
4013
+ return scanWalletAsset;
4014
+ }() /** 清空全部未确认钱包选择,已支付钱包项由 Order 模块继续保留。 */)
4015
+ }, {
4016
+ key: "clearWalletAssetSelection",
4017
+ value: (function () {
4018
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
4019
+ var state;
4020
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4021
+ while (1) switch (_context43.prev = _context43.next) {
4022
+ case 0:
4023
+ if (this.store.payment) {
4024
+ _context43.next = 2;
4025
+ break;
4026
+ }
4027
+ throw new Error('payment 模块未初始化');
4028
+ case 2:
4029
+ state = this.store.payment.wallet.clearWalletAssetSelection();
4030
+ _context43.next = 5;
4031
+ return this.syncSelectedWalletAssets(state);
4032
+ case 5:
4033
+ return _context43.abrupt("return", this.publishWalletAssetsState(state));
4034
+ case 6:
4035
+ case "end":
4036
+ return _context43.stop();
4037
+ }
4038
+ }, _callee43, this);
4039
+ }));
4040
+ function clearWalletAssetSelection() {
4041
+ return _clearWalletAssetSelection.apply(this, arguments);
4042
+ }
4043
+ return clearWalletAssetSelection;
4044
+ }()
3525
4045
  /**
3526
4046
  * 更新当前订单客户字段。
3527
4047
  *
3528
4048
  * 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
3529
4049
  * 调用方通过 onCustomerChange 回调完成。
3530
4050
  */
4051
+ )
3531
4052
  }, {
3532
4053
  key: "updateOrderCustomer",
3533
4054
  value: function updateOrderCustomer(customer) {
@@ -3544,35 +4065,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3544
4065
  }, {
3545
4066
  key: "getPaymentMethodsAsync",
3546
4067
  value: (function () {
3547
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
4068
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3548
4069
  var response, paymentMethods;
3549
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3550
- while (1) switch (_context37.prev = _context37.next) {
4070
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4071
+ while (1) switch (_context44.prev = _context44.next) {
3551
4072
  case 0:
3552
- _context37.prev = 0;
3553
- _context37.next = 3;
4073
+ _context44.prev = 0;
4074
+ _context44.next = 3;
3554
4075
  return this.request.get('/pay/custom-payment/all', {
3555
4076
  filterPaymentMethods: true
3556
4077
  }, {
3557
4078
  osServer: true
3558
4079
  });
3559
4080
  case 3:
3560
- response = _context37.sent;
4081
+ response = _context44.sent;
3561
4082
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3562
4083
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3563
- return _context37.abrupt("return", this.getPaymentMethods());
4084
+ return _context44.abrupt("return", this.getPaymentMethods());
3564
4085
  case 9:
3565
- _context37.prev = 9;
3566
- _context37.t0 = _context37["catch"](0);
4086
+ _context44.prev = 9;
4087
+ _context44.t0 = _context44["catch"](0);
3567
4088
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3568
- error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
4089
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
3569
4090
  });
3570
- return _context37.abrupt("return", this.getPaymentMethods());
4091
+ return _context44.abrupt("return", this.getPaymentMethods());
3571
4092
  case 13:
3572
4093
  case "end":
3573
- return _context37.stop();
4094
+ return _context44.stop();
3574
4095
  }
3575
- }, _callee37, this, [[0, 9]]);
4096
+ }, _callee44, this, [[0, 9]]);
3576
4097
  }));
3577
4098
  function getPaymentMethodsAsync() {
3578
4099
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3584,85 +4105,589 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3584
4105
  value: function getPaymentMethods() {
3585
4106
  return _toConsumableArray(this.paymentMethodsCache);
3586
4107
  }
4108
+ }, {
4109
+ key: "findCashPaymentMethod",
4110
+ value: function findCashPaymentMethod(paymentMethods) {
4111
+ return paymentMethods.find(function (method) {
4112
+ var identifiers = [method === null || method === void 0 ? void 0 : method.code, method === null || method === void 0 ? void 0 : method.type, method === null || method === void 0 ? void 0 : method.tag].map(function (value) {
4113
+ return String(value || '').toUpperCase();
4114
+ });
4115
+ return identifiers.includes('CASHMANUAL') && (method === null || method === void 0 ? void 0 : method.enabled) !== false && (method === null || method === void 0 ? void 0 : method.enable) !== false;
4116
+ });
4117
+ }
4118
+ }, {
4119
+ key: "getPendingWalletPaymentAmount",
4120
+ value: function getPendingWalletPaymentAmount() {
4121
+ var _this$store$order10, _this$store$order10$g;
4122
+ 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)) || [];
4123
+ return payments.reduce(function (total, payment) {
4124
+ 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) {
4125
+ return total;
4126
+ }
4127
+ try {
4128
+ return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
4129
+ } catch (_unused5) {
4130
+ return total;
4131
+ }
4132
+ }, new Decimal(0));
4133
+ }
3587
4134
 
3588
- /** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
4135
+ /** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
4136
+ }, {
4137
+ key: "getCashPaymentConfig",
4138
+ value: (function () {
4139
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4140
+ var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams25;
4141
+ var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4142
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4143
+ while (1) switch (_context45.prev = _context45.next) {
4144
+ case 0:
4145
+ if (this.store.payment) {
4146
+ _context45.next = 2;
4147
+ break;
4148
+ }
4149
+ throw new Error('payment 模块未初始化');
4150
+ case 2:
4151
+ paymentMethods = this.getPaymentMethods();
4152
+ paymentMethod = this.findCashPaymentMethod(paymentMethods);
4153
+ if (paymentMethod) {
4154
+ _context45.next = 9;
4155
+ break;
4156
+ }
4157
+ _context45.next = 7;
4158
+ return this.getPaymentMethodsAsync();
4159
+ case 7:
4160
+ paymentMethods = _context45.sent;
4161
+ paymentMethod = this.findCashPaymentMethod(paymentMethods);
4162
+ case 9:
4163
+ 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);
4164
+ pendingWalletAmount = this.getPendingWalletPaymentAmount();
4165
+ amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4166
+ 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$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.currency) || 'USD';
4167
+ recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4168
+ return _context45.abrupt("return", {
4169
+ available: Boolean(paymentMethod && amountDue > 0),
4170
+ paymentMethod: paymentMethod,
4171
+ amountDue: amountDue,
4172
+ recommendedAmounts: recommendedAmounts
4173
+ });
4174
+ case 15:
4175
+ case "end":
4176
+ return _context45.stop();
4177
+ }
4178
+ }, _callee45, this);
4179
+ }));
4180
+ function getCashPaymentConfig() {
4181
+ return _getCashPaymentConfig.apply(this, arguments);
4182
+ }
4183
+ return getCashPaymentConfig;
4184
+ }()
4185
+ /**
4186
+ * 确认足额覆盖订单的 pending Wallet 支付并提交订单。
4187
+ *
4188
+ * Order 模块在构造提交参数时将 pending voucher 转为 paid;只有提交成功后
4189
+ * 才同步 Wallet committed 状态。失败时恢复调用前 payments,允许用户重试。
4190
+ */
4191
+ )
4192
+ }, {
4193
+ key: "confirmWalletPayment",
4194
+ value: (function () {
4195
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4196
+ var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4197
+ var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4198
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4199
+ while (1) switch (_context46.prev = _context46.next) {
4200
+ case 0:
4201
+ if (this.store.order) {
4202
+ _context46.next = 2;
4203
+ break;
4204
+ }
4205
+ throw new Error('order 模块未初始化');
4206
+ case 2:
4207
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4208
+ pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
4209
+ if (!pendingWalletAmount.lte(0)) {
4210
+ _context46.next = 6;
4211
+ break;
4212
+ }
4213
+ throw new Error('当前订单没有待确认的 Wallet 支付');
4214
+ case 6:
4215
+ 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);
4216
+ effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4217
+ if (!effectiveAmountDue.gt(0.01)) {
4218
+ _context46.next = 10;
4219
+ break;
4220
+ }
4221
+ throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4222
+ case 10:
4223
+ beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4224
+ _context46.prev = 11;
4225
+ _context46.next = 14;
4226
+ return this.submitSalesOrder({
4227
+ smallTicketDataFlag: 1,
4228
+ confirmPendingVoucherPayments: true
4229
+ });
4230
+ case 14:
4231
+ submitResult = _context46.sent;
4232
+ if (!isRejectedSalesSubmitResult(submitResult)) {
4233
+ _context46.next = 17;
4234
+ break;
4235
+ }
4236
+ throw new Error(getSalesSubmitErrorMessage(submitResult));
4237
+ case 17:
4238
+ _context46.next = 27;
4239
+ break;
4240
+ case 19:
4241
+ _context46.prev = 19;
4242
+ _context46.t0 = _context46["catch"](11);
4243
+ this.store.order.setOrderPayments(beforePayments);
4244
+ restoredTempOrder = this.store.order.getTempOrder();
4245
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4246
+ restoredTempOrder.payment_status = beforePaymentStatus;
4247
+ this.store.order.persistTempOrder();
4248
+ }
4249
+ _context46.next = 26;
4250
+ return this.store.order.recalculateSummary({
4251
+ createIfMissing: true
4252
+ });
4253
+ case 26:
4254
+ throw _context46.t0;
4255
+ case 27:
4256
+ if (!this.store.payment) {
4257
+ _context46.next = 38;
4258
+ break;
4259
+ }
4260
+ _context46.prev = 28;
4261
+ committed = this.getCommittedWalletAssets();
4262
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4263
+ _context46.next = 33;
4264
+ return this.publishWalletAssetsState(walletState);
4265
+ case 33:
4266
+ _context46.next = 38;
4267
+ break;
4268
+ case 35:
4269
+ _context46.prev = 35;
4270
+ _context46.t1 = _context46["catch"](28);
4271
+ this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4272
+ error: _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1)
4273
+ });
4274
+ case 38:
4275
+ 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);
4276
+ return _context46.abrupt("return", {
4277
+ submitResult: submitResult,
4278
+ payments: this.store.order.getOrderPayments(),
4279
+ isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4280
+ });
4281
+ case 40:
4282
+ case "end":
4283
+ return _context46.stop();
4284
+ }
4285
+ }, _callee46, this, [[11, 19], [28, 35]]);
4286
+ }));
4287
+ function confirmWalletPayment() {
4288
+ return _confirmWalletPayment.apply(this, arguments);
4289
+ }
4290
+ return confirmWalletPayment;
4291
+ }()
4292
+ /**
4293
+ * 购物车现金直付:写入现金记录并等待支付同步完成。
4294
+ * 同步失败会恢复调用前 payments(包含 Wallet pending 状态)。
4295
+ */
4296
+ )
4297
+ }, {
4298
+ key: "payCash",
4299
+ value: (function () {
4300
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4301
+ var _this$store$order$get6, _params$actualPaidAmo, _this$window, _this$window$postMess;
4302
+ var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4303
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4304
+ while (1) switch (_context47.prev = _context47.next) {
4305
+ case 0:
4306
+ if (this.store.order) {
4307
+ _context47.next = 2;
4308
+ break;
4309
+ }
4310
+ throw new Error('order 模块未初始化');
4311
+ case 2:
4312
+ amount = Number(params.amount || 0);
4313
+ if (!(!Number.isFinite(amount) || amount <= 0)) {
4314
+ _context47.next = 5;
4315
+ break;
4316
+ }
4317
+ throw new Error('现金支付金额必须大于 0');
4318
+ case 5:
4319
+ _context47.next = 7;
4320
+ return this.getCashPaymentConfig();
4321
+ case 7:
4322
+ config = _context47.sent;
4323
+ paymentMethod = config.paymentMethod;
4324
+ if (paymentMethod) {
4325
+ _context47.next = 11;
4326
+ break;
4327
+ }
4328
+ throw new Error('未找到可用的 CASHMANUAL 支付方式');
4329
+ case 11:
4330
+ if (!(config.amountDue <= 0)) {
4331
+ _context47.next = 13;
4332
+ break;
4333
+ }
4334
+ throw new Error('当前订单没有待支付金额');
4335
+ case 13:
4336
+ roundingAmount = Number(params.roundingAmount || 0);
4337
+ effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4338
+ if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4339
+ _context47.next = 17;
4340
+ break;
4341
+ }
4342
+ throw new Error('现金支付金额超过当前待支付金额');
4343
+ case 17:
4344
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4345
+ beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
4346
+ uniquePaymentNumber = createUuidV4();
4347
+ paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4348
+ actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4349
+ changeAmount = Number(params.changeAmount || 0);
4350
+ if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4351
+ _context47.next = 25;
4352
+ break;
4353
+ }
4354
+ throw new Error('顾客实收现金不能小于支付金额');
4355
+ case 25:
4356
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
4357
+ module: 'till',
4358
+ key: 'open_till',
4359
+ data: {
4360
+ type: 'cash'
4361
+ }
4362
+ });
4363
+ payments = this.store.order.addOrderPayment({
4364
+ amount: amount.toFixed(2),
4365
+ code: paymentMethod.code,
4366
+ custom_payment_id: paymentMethod.id,
4367
+ name: paymentMethod.name,
4368
+ custom_payment_type: paymentMethod.type,
4369
+ voucher_id: 0,
4370
+ rounding_amount: roundingAmount.toFixed(2),
4371
+ metadata: {
4372
+ unique_payment_number: uniquePaymentNumber,
4373
+ actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
4374
+ change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
4375
+ },
4376
+ payment_time: paymentTimestamp,
4377
+ created_at: paymentTimestamp
4378
+ });
4379
+ payment = payments.find(function (item) {
4380
+ var _item$metadata2;
4381
+ return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4382
+ });
4383
+ _context47.prev = 28;
4384
+ _context47.next = 31;
4385
+ return this.syncPaymentsToOrder({
4386
+ payments: payments,
4387
+ submitWhenPaid: true,
4388
+ smallTicketDataFlag: 1,
4389
+ confirmPendingVoucherPayments: true
4390
+ });
4391
+ case 31:
4392
+ syncResult = _context47.sent;
4393
+ if (!this.store.payment) {
4394
+ _context47.next = 37;
4395
+ break;
4396
+ }
4397
+ committed = this.getCommittedWalletAssets();
4398
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4399
+ _context47.next = 37;
4400
+ return this.publishWalletAssetsState(walletState);
4401
+ case 37:
4402
+ return _context47.abrupt("return", {
4403
+ payment: payment || {},
4404
+ payments: this.store.order.getOrderPayments(),
4405
+ syncResult: syncResult,
4406
+ isOrderFullyPaid: syncResult.isOrderFullyPaid
4407
+ });
4408
+ case 40:
4409
+ _context47.prev = 40;
4410
+ _context47.t0 = _context47["catch"](28);
4411
+ this.store.order.setOrderPayments(beforePayments);
4412
+ restoredTempOrder = this.store.order.getTempOrder();
4413
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4414
+ restoredTempOrder.payment_status = beforePaymentStatus;
4415
+ this.store.order.persistTempOrder();
4416
+ }
4417
+ _context47.next = 47;
4418
+ return this.store.order.recalculateSummary({
4419
+ createIfMissing: true
4420
+ });
4421
+ case 47:
4422
+ throw _context47.t0;
4423
+ case 48:
4424
+ case "end":
4425
+ return _context47.stop();
4426
+ }
4427
+ }, _callee47, this, [[28, 40]]);
4428
+ }));
4429
+ function payCash(_x38) {
4430
+ return _payCash.apply(this, arguments);
4431
+ }
4432
+ return payCash;
4433
+ }()
4434
+ /**
4435
+ * 提交一次已由支付设备确认成功的非 Wallet 支付。
4436
+ *
4437
+ * 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
4438
+ * 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
4439
+ * 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
4440
+ */
4441
+ )
4442
+ }, {
4443
+ key: "commitPaymentMethodPayment",
4444
+ value: (function () {
4445
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4446
+ var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
4447
+ var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4448
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4449
+ while (1) switch (_context48.prev = _context48.next) {
4450
+ case 0:
4451
+ if (this.store.order) {
4452
+ _context48.next = 2;
4453
+ break;
4454
+ }
4455
+ throw new Error('order 模块未初始化');
4456
+ case 2:
4457
+ amount = Number(params.amount || 0);
4458
+ if (!(!Number.isFinite(amount) || amount <= 0)) {
4459
+ _context48.next = 5;
4460
+ break;
4461
+ }
4462
+ throw new Error('支付金额必须大于 0');
4463
+ case 5:
4464
+ paymentMethods = this.getPaymentMethods();
4465
+ findPaymentMethod = function findPaymentMethod() {
4466
+ var methodCode = String(params.paymentMethodCode || '').toUpperCase();
4467
+ return paymentMethods.find(function (method) {
4468
+ var idMatched = params.paymentMethodId !== undefined && String(method.id) === String(params.paymentMethodId);
4469
+ var codeMatched = Boolean(methodCode) && String(method.code || '').toUpperCase() === methodCode;
4470
+ return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
4471
+ });
4472
+ };
4473
+ paymentMethod = findPaymentMethod();
4474
+ if (paymentMethod) {
4475
+ _context48.next = 13;
4476
+ break;
4477
+ }
4478
+ _context48.next = 11;
4479
+ return this.getPaymentMethodsAsync();
4480
+ case 11:
4481
+ paymentMethods = _context48.sent;
4482
+ paymentMethod = findPaymentMethod();
4483
+ case 13:
4484
+ if (paymentMethod) {
4485
+ _context48.next = 15;
4486
+ break;
4487
+ }
4488
+ throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
4489
+ case 15:
4490
+ 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);
4491
+ pendingWalletAmount = this.getPendingWalletPaymentAmount();
4492
+ amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4493
+ if (!amountDue.lte(0)) {
4494
+ _context48.next = 20;
4495
+ break;
4496
+ }
4497
+ throw new Error('当前订单没有待支付金额');
4498
+ case 20:
4499
+ if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
4500
+ _context48.next = 22;
4501
+ break;
4502
+ }
4503
+ throw new Error('支付金额超过当前待支付金额');
4504
+ case 22:
4505
+ beforePayments = cloneDeep(this.store.order.getOrderPayments());
4506
+ beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
4507
+ paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4508
+ metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
4509
+ unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
4510
+ });
4511
+ serviceCharge = params.serviceCharge ? {
4512
+ amount: String(params.serviceCharge.amount || 0),
4513
+ percentage: String(params.serviceCharge.percentage || 0)
4514
+ } : undefined;
4515
+ serviceFee = serviceCharge ? new Decimal((_params$originAmount = params.originAmount) !== null && _params$originAmount !== void 0 ? _params$originAmount : amount).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
4516
+ payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params.paymentData || {}), {}, {
4517
+ amount: amount.toFixed(2)
4518
+ }, params.originAmount !== undefined ? {
4519
+ origin_amount: Number(params.originAmount).toFixed(2)
4520
+ } : {}), {}, {
4521
+ code: paymentMethod.code,
4522
+ custom_payment_id: paymentMethod.id,
4523
+ name: paymentMethod.name,
4524
+ custom_payment_type: paymentMethod.type,
4525
+ voucher_id: 0
4526
+ }, serviceCharge ? {
4527
+ service_charge: serviceCharge
4528
+ } : {}), serviceFee !== undefined ? {
4529
+ service_fee: serviceFee
4530
+ } : {}), {}, {
4531
+ metadata: metadata,
4532
+ payment_time: paymentTimestamp,
4533
+ created_at: paymentTimestamp
4534
+ }));
4535
+ payment = payments.find(function (item) {
4536
+ var _item$metadata3;
4537
+ 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;
4538
+ });
4539
+ _context48.prev = 30;
4540
+ _context48.next = 33;
4541
+ return this.syncPaymentsToOrder({
4542
+ payments: payments,
4543
+ submitWhenPaid: true,
4544
+ smallTicketDataFlag: 1,
4545
+ confirmPendingVoucherPayments: true
4546
+ });
4547
+ case 33:
4548
+ syncResult = _context48.sent;
4549
+ if (!this.store.payment) {
4550
+ _context48.next = 39;
4551
+ break;
4552
+ }
4553
+ committed = this.getCommittedWalletAssets();
4554
+ walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4555
+ _context48.next = 39;
4556
+ return this.publishWalletAssetsState(walletState);
4557
+ case 39:
4558
+ return _context48.abrupt("return", {
4559
+ payment: payment || {},
4560
+ payments: this.store.order.getOrderPayments(),
4561
+ syncResult: syncResult,
4562
+ isOrderFullyPaid: syncResult.isOrderFullyPaid
4563
+ });
4564
+ case 42:
4565
+ _context48.prev = 42;
4566
+ _context48.t0 = _context48["catch"](30);
4567
+ this.store.order.setOrderPayments(beforePayments);
4568
+ restoredTempOrder = this.store.order.getTempOrder();
4569
+ if (restoredTempOrder && beforePaymentStatus !== undefined) {
4570
+ restoredTempOrder.payment_status = beforePaymentStatus;
4571
+ this.store.order.persistTempOrder();
4572
+ }
4573
+ _context48.next = 49;
4574
+ return this.store.order.recalculateSummary({
4575
+ createIfMissing: true
4576
+ });
4577
+ case 49:
4578
+ throw _context48.t0;
4579
+ case 50:
4580
+ case "end":
4581
+ return _context48.stop();
4582
+ }
4583
+ }, _callee48, this, [[30, 42]]);
4584
+ }));
4585
+ function commitPaymentMethodPayment(_x39) {
4586
+ return _commitPaymentMethodPayment.apply(this, arguments);
4587
+ }
4588
+ return commitPaymentMethodPayment;
4589
+ }()
4590
+ /**
4591
+ * 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
4592
+ *
4593
+ * 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
4594
+ * otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
4595
+ */
4596
+ )
3589
4597
  }, {
3590
4598
  key: "roundAmount",
3591
- value: function roundAmount(params) {
3592
- var amount = new Decimal(params.amount || 0);
3593
- var interval = new Decimal(params.interval || 0.05);
3594
- var rule = params.rule || 'standard_rounding';
3595
- var quotient = amount.div(interval);
3596
- var roundedQuotient;
3597
- if (rule === 'always_up') {
3598
- roundedQuotient = quotient.ceil();
3599
- } else if (rule === 'always_down') {
3600
- roundedQuotient = quotient.floor();
3601
- } else if (rule === 'standard_down') {
3602
- roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
3603
- } else {
3604
- roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
4599
+ value: (function () {
4600
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4601
+ var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
4602
+ var amount, cashManualPayment;
4603
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4604
+ while (1) switch (_context49.prev = _context49.next) {
4605
+ case 0:
4606
+ amount = params.amount;
4607
+ cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
4608
+ return paymentMethod.code === 'CASHMANUAL';
4609
+ });
4610
+ if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
4611
+ _context49.next = 4;
4612
+ break;
4613
+ }
4614
+ return _context49.abrupt("return", {
4615
+ originalAmount: amount.toString(),
4616
+ roundedAmount: amount.toString(),
4617
+ roundingDifference: '0.00'
4618
+ });
4619
+ case 4:
4620
+ if (this.payment) {
4621
+ _context49.next = 6;
4622
+ break;
4623
+ }
4624
+ throw new Error('payment 模块未初始化');
4625
+ case 6:
4626
+ return _context49.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
4627
+ case 7:
4628
+ case "end":
4629
+ return _context49.stop();
4630
+ }
4631
+ }, _callee49, this);
4632
+ }));
4633
+ function roundAmount(_x40) {
4634
+ return _roundAmount.apply(this, arguments);
3605
4635
  }
3606
- var roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
3607
- return {
3608
- originalAmount: amount.toFixed(2),
3609
- roundedAmount: roundedAmount.toFixed(2),
3610
- roundingDifference: roundedAmount.minus(amount).toFixed(2)
3611
- };
3612
- }
3613
-
4636
+ return roundAmount;
4637
+ }()
3614
4638
  /**
3615
4639
  * 发送支付链接。
3616
4640
  *
3617
4641
  * 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
3618
4642
  * 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
3619
4643
  */
4644
+ )
3620
4645
  }, {
3621
4646
  key: "sendCustomerPayLink",
3622
4647
  value: (function () {
3623
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3624
- var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3625
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3626
- while (1) switch (_context38.prev = _context38.next) {
4648
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4649
+ var orderIds, _ref34, _ref35, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
4650
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4651
+ while (1) switch (_context50.prev = _context50.next) {
3627
4652
  case 0:
3628
4653
  if (this.store.order) {
3629
- _context38.next = 2;
4654
+ _context50.next = 2;
3630
4655
  break;
3631
4656
  }
3632
4657
  throw new Error('order 模块未初始化');
3633
4658
  case 2:
3634
4659
  orderIds = params.order_ids || params.orderIds || [];
3635
4660
  if (!(!orderIds.length || params.submitBeforeSend)) {
3636
- _context38.next = 11;
4661
+ _context50.next = 11;
3637
4662
  break;
3638
4663
  }
3639
- _context38.next = 6;
4664
+ _context50.next = 6;
3640
4665
  return this.submitSalesOrder({
3641
4666
  smallTicketDataFlag: 1
3642
4667
  });
3643
4668
  case 6:
3644
- submitResult = _context38.sent;
3645
- orderId = (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
4669
+ submitResult = _context50.sent;
4670
+ orderId = (_ref34 = (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref34 !== void 0 ? _ref34 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3646
4671
  if (orderId) {
3647
- _context38.next = 10;
4672
+ _context50.next = 10;
3648
4673
  break;
3649
4674
  }
3650
4675
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3651
4676
  case 10:
3652
4677
  orderIds = [orderId];
3653
4678
  case 11:
3654
- return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
4679
+ return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
3655
4680
  emails: params.emails,
3656
4681
  notify_action: params.notify_action,
3657
4682
  order_ids: orderIds
3658
4683
  }));
3659
4684
  case 12:
3660
4685
  case "end":
3661
- return _context38.stop();
4686
+ return _context50.stop();
3662
4687
  }
3663
- }, _callee38, this);
4688
+ }, _callee50, this);
3664
4689
  }));
3665
- function sendCustomerPayLink(_x32) {
4690
+ function sendCustomerPayLink(_x41) {
3666
4691
  return _sendCustomerPayLink.apply(this, arguments);
3667
4692
  }
3668
4693
  return sendCustomerPayLink;
@@ -3675,27 +4700,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3675
4700
  }, {
3676
4701
  key: "calculateProductBookingPrice",
3677
4702
  value: function () {
3678
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
4703
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
3679
4704
  var _params$customer_id;
3680
4705
  var quotation, customerId, authoritativeProduct, product;
3681
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3682
- while (1) switch (_context39.prev = _context39.next) {
4706
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4707
+ while (1) switch (_context51.prev = _context51.next) {
3683
4708
  case 0:
3684
4709
  quotation = this.store.quotation;
3685
4710
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3686
- _context39.next = 4;
4711
+ _context51.next = 4;
3687
4712
  return this.loadProductForPriceQuery(params, customerId);
3688
4713
  case 4:
3689
- authoritativeProduct = _context39.sent;
4714
+ authoritativeProduct = _context51.sent;
3690
4715
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3691
- _context39.next = 8;
4716
+ _context51.next = 8;
3692
4717
  return this.loadQuotationForPriceQuery({
3693
4718
  quotation: quotation,
3694
4719
  customer_id: customerId,
3695
4720
  channel: params.channel
3696
4721
  });
3697
4722
  case 8:
3698
- return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4723
+ return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3699
4724
  product: product,
3700
4725
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3701
4726
  customer_id: customerId,
@@ -3703,11 +4728,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3703
4728
  })));
3704
4729
  case 9:
3705
4730
  case "end":
3706
- return _context39.stop();
4731
+ return _context51.stop();
3707
4732
  }
3708
- }, _callee39, this);
4733
+ }, _callee51, this);
3709
4734
  }));
3710
- function calculateProductBookingPrice(_x33) {
4735
+ function calculateProductBookingPrice(_x42) {
3711
4736
  return _calculateProductBookingPrice.apply(this, arguments);
3712
4737
  }
3713
4738
  return calculateProductBookingPrice;
@@ -3777,20 +4802,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3777
4802
  }, {
3778
4803
  key: "calculateProductBookingPrices",
3779
4804
  value: function () {
3780
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
4805
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
3781
4806
  var _paramsList$0$custome,
3782
4807
  _paramsList$,
3783
4808
  _this16 = this,
3784
4809
  _paramsList$2;
3785
4810
  var quotation, customerId, productMapsByGroup, groups;
3786
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3787
- while (1) switch (_context41.prev = _context41.next) {
4811
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4812
+ while (1) switch (_context53.prev = _context53.next) {
3788
4813
  case 0:
3789
4814
  if (paramsList.length) {
3790
- _context41.next = 2;
4815
+ _context53.next = 2;
3791
4816
  break;
3792
4817
  }
3793
- return _context41.abrupt("return", []);
4818
+ return _context53.abrupt("return", []);
3794
4819
  case 2:
3795
4820
  quotation = this.store.quotation;
3796
4821
  customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
@@ -3812,15 +4837,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3812
4837
  group.ids.add(productId);
3813
4838
  groups.set(groupKey, group);
3814
4839
  });
3815
- _context41.next = 9;
4840
+ _context53.next = 9;
3816
4841
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3817
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3818
- var _ref30, groupKey, group, productsById;
3819
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3820
- while (1) switch (_context40.prev = _context40.next) {
4842
+ var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(_ref36) {
4843
+ var _ref38, groupKey, group, productsById;
4844
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4845
+ while (1) switch (_context52.prev = _context52.next) {
3821
4846
  case 0:
3822
- _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3823
- _context40.next = 3;
4847
+ _ref38 = _slicedToArray(_ref36, 2), groupKey = _ref38[0], group = _ref38[1];
4848
+ _context52.next = 3;
3824
4849
  return _this16.loadProductsForPriceQuery({
3825
4850
  ids: Array.from(group.ids),
3826
4851
  schedule: group.schedule,
@@ -3828,27 +4853,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3828
4853
  channel: group.channel
3829
4854
  });
3830
4855
  case 3:
3831
- productsById = _context40.sent;
4856
+ productsById = _context52.sent;
3832
4857
  productMapsByGroup.set(groupKey, productsById);
3833
4858
  case 5:
3834
4859
  case "end":
3835
- return _context40.stop();
4860
+ return _context52.stop();
3836
4861
  }
3837
- }, _callee40);
4862
+ }, _callee52);
3838
4863
  }));
3839
- return function (_x35) {
3840
- return _ref29.apply(this, arguments);
4864
+ return function (_x44) {
4865
+ return _ref37.apply(this, arguments);
3841
4866
  };
3842
4867
  }()));
3843
4868
  case 9:
3844
- _context41.next = 11;
4869
+ _context53.next = 11;
3845
4870
  return this.loadQuotationForPriceQuery({
3846
4871
  quotation: quotation,
3847
4872
  customer_id: customerId,
3848
4873
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3849
4874
  });
3850
4875
  case 11:
3851
- return _context41.abrupt("return", paramsList.map(function (params) {
4876
+ return _context53.abrupt("return", paramsList.map(function (params) {
3852
4877
  var _this16$otherParams2, _productMapsByGroup$g;
3853
4878
  var productInput = params.product || {};
3854
4879
  var productId = _this16.getPriceQueryProductId(productInput);
@@ -3866,11 +4891,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3866
4891
  }));
3867
4892
  case 12:
3868
4893
  case "end":
3869
- return _context41.stop();
4894
+ return _context53.stop();
3870
4895
  }
3871
- }, _callee41, this);
4896
+ }, _callee53, this);
3872
4897
  }));
3873
- function calculateProductBookingPrices(_x34) {
4898
+ function calculateProductBookingPrices(_x43) {
3874
4899
  return _calculateProductBookingPrices.apply(this, arguments);
3875
4900
  }
3876
4901
  return calculateProductBookingPrices;
@@ -3878,34 +4903,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3878
4903
  }, {
3879
4904
  key: "addProductToOrder",
3880
4905
  value: function () {
3881
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(product, booking) {
4906
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking) {
3882
4907
  var products;
3883
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3884
- while (1) switch (_context42.prev = _context42.next) {
4908
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4909
+ while (1) switch (_context54.prev = _context54.next) {
3885
4910
  case 0:
3886
- _context42.prev = 0;
4911
+ _context54.prev = 0;
3887
4912
  if (this.store.order) {
3888
- _context42.next = 3;
4913
+ _context54.next = 3;
3889
4914
  break;
3890
4915
  }
3891
4916
  throw new Error('order 模块未初始化');
3892
4917
  case 3:
3893
- _context42.next = 5;
4918
+ _context54.next = 5;
3894
4919
  return this.store.order.addProductToOrder(product, booking);
3895
4920
  case 5:
3896
- products = _context42.sent;
3897
- return _context42.abrupt("return", products);
4921
+ products = _context54.sent;
4922
+ return _context54.abrupt("return", products);
3898
4923
  case 9:
3899
- _context42.prev = 9;
3900
- _context42.t0 = _context42["catch"](0);
3901
- throw _context42.t0;
4924
+ _context54.prev = 9;
4925
+ _context54.t0 = _context54["catch"](0);
4926
+ throw _context54.t0;
3902
4927
  case 12:
3903
4928
  case "end":
3904
- return _context42.stop();
4929
+ return _context54.stop();
3905
4930
  }
3906
- }, _callee42, this, [[0, 9]]);
4931
+ }, _callee54, this, [[0, 9]]);
3907
4932
  }));
3908
- function addProductToOrder(_x36, _x37) {
4933
+ function addProductToOrder(_x45, _x46) {
3909
4934
  return _addProductToOrder.apply(this, arguments);
3910
4935
  }
3911
4936
  return addProductToOrder;
@@ -3913,34 +4938,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3913
4938
  }, {
3914
4939
  key: "updateOrderProduct",
3915
4940
  value: function () {
3916
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4941
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
3917
4942
  var products;
3918
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3919
- while (1) switch (_context43.prev = _context43.next) {
4943
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4944
+ while (1) switch (_context55.prev = _context55.next) {
3920
4945
  case 0:
3921
- _context43.prev = 0;
4946
+ _context55.prev = 0;
3922
4947
  if (this.store.order) {
3923
- _context43.next = 3;
4948
+ _context55.next = 3;
3924
4949
  break;
3925
4950
  }
3926
4951
  throw new Error('order 模块未初始化');
3927
4952
  case 3:
3928
- _context43.next = 5;
4953
+ _context55.next = 5;
3929
4954
  return this.store.order.updateOrderProduct(params);
3930
4955
  case 5:
3931
- products = _context43.sent;
3932
- return _context43.abrupt("return", products);
4956
+ products = _context55.sent;
4957
+ return _context55.abrupt("return", products);
3933
4958
  case 9:
3934
- _context43.prev = 9;
3935
- _context43.t0 = _context43["catch"](0);
3936
- throw _context43.t0;
4959
+ _context55.prev = 9;
4960
+ _context55.t0 = _context55["catch"](0);
4961
+ throw _context55.t0;
3937
4962
  case 12:
3938
4963
  case "end":
3939
- return _context43.stop();
4964
+ return _context55.stop();
3940
4965
  }
3941
- }, _callee43, this, [[0, 9]]);
4966
+ }, _callee55, this, [[0, 9]]);
3942
4967
  }));
3943
- function updateOrderProduct(_x38) {
4968
+ function updateOrderProduct(_x47) {
3944
4969
  return _updateOrderProduct.apply(this, arguments);
3945
4970
  }
3946
4971
  return updateOrderProduct;
@@ -3948,34 +4973,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3948
4973
  }, {
3949
4974
  key: "updateOrderProducts",
3950
4975
  value: function () {
3951
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paramsList) {
4976
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
3952
4977
  var products;
3953
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3954
- while (1) switch (_context44.prev = _context44.next) {
4978
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
4979
+ while (1) switch (_context56.prev = _context56.next) {
3955
4980
  case 0:
3956
- _context44.prev = 0;
4981
+ _context56.prev = 0;
3957
4982
  if (this.store.order) {
3958
- _context44.next = 3;
4983
+ _context56.next = 3;
3959
4984
  break;
3960
4985
  }
3961
4986
  throw new Error('order 模块未初始化');
3962
4987
  case 3:
3963
- _context44.next = 5;
4988
+ _context56.next = 5;
3964
4989
  return this.store.order.updateOrderProducts(paramsList);
3965
4990
  case 5:
3966
- products = _context44.sent;
3967
- return _context44.abrupt("return", products);
4991
+ products = _context56.sent;
4992
+ return _context56.abrupt("return", products);
3968
4993
  case 9:
3969
- _context44.prev = 9;
3970
- _context44.t0 = _context44["catch"](0);
3971
- throw _context44.t0;
4994
+ _context56.prev = 9;
4995
+ _context56.t0 = _context56["catch"](0);
4996
+ throw _context56.t0;
3972
4997
  case 12:
3973
4998
  case "end":
3974
- return _context44.stop();
4999
+ return _context56.stop();
3975
5000
  }
3976
- }, _callee44, this, [[0, 9]]);
5001
+ }, _callee56, this, [[0, 9]]);
3977
5002
  }));
3978
- function updateOrderProducts(_x39) {
5003
+ function updateOrderProducts(_x48) {
3979
5004
  return _updateOrderProducts.apply(this, arguments);
3980
5005
  }
3981
5006
  return updateOrderProducts;
@@ -3983,34 +5008,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3983
5008
  }, {
3984
5009
  key: "updateOrderProductQuantity",
3985
5010
  value: function () {
3986
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
5011
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
3987
5012
  var products;
3988
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3989
- while (1) switch (_context45.prev = _context45.next) {
5013
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5014
+ while (1) switch (_context57.prev = _context57.next) {
3990
5015
  case 0:
3991
- _context45.prev = 0;
5016
+ _context57.prev = 0;
3992
5017
  if (this.store.order) {
3993
- _context45.next = 3;
5018
+ _context57.next = 3;
3994
5019
  break;
3995
5020
  }
3996
5021
  throw new Error('order 模块未初始化');
3997
5022
  case 3:
3998
- _context45.next = 5;
5023
+ _context57.next = 5;
3999
5024
  return this.store.order.updateOrderProductQuantity(params);
4000
5025
  case 5:
4001
- products = _context45.sent;
4002
- return _context45.abrupt("return", products);
5026
+ products = _context57.sent;
5027
+ return _context57.abrupt("return", products);
4003
5028
  case 9:
4004
- _context45.prev = 9;
4005
- _context45.t0 = _context45["catch"](0);
4006
- throw _context45.t0;
5029
+ _context57.prev = 9;
5030
+ _context57.t0 = _context57["catch"](0);
5031
+ throw _context57.t0;
4007
5032
  case 12:
4008
5033
  case "end":
4009
- return _context45.stop();
5034
+ return _context57.stop();
4010
5035
  }
4011
- }, _callee45, this, [[0, 9]]);
5036
+ }, _callee57, this, [[0, 9]]);
4012
5037
  }));
4013
- function updateOrderProductQuantity(_x40) {
5038
+ function updateOrderProductQuantity(_x49) {
4014
5039
  return _updateOrderProductQuantity.apply(this, arguments);
4015
5040
  }
4016
5041
  return updateOrderProductQuantity;
@@ -4033,12 +5058,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4033
5058
  }, {
4034
5059
  key: "setOrderProductLineNote",
4035
5060
  value: (function () {
4036
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(identity, note) {
5061
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
4037
5062
  var params, products;
4038
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4039
- while (1) switch (_context46.prev = _context46.next) {
5063
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5064
+ while (1) switch (_context58.prev = _context58.next) {
4040
5065
  case 0:
4041
- _context46.prev = 0;
5066
+ _context58.prev = 0;
4042
5067
  params = {
4043
5068
  product_id: identity.product_id,
4044
5069
  product_variant_id: identity.product_variant_id,
@@ -4053,22 +5078,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4053
5078
  params.product_sku = identity.product_sku;
4054
5079
  }
4055
5080
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
4056
- _context46.next = 7;
5081
+ _context58.next = 7;
4057
5082
  return this.updateOrderProduct(params);
4058
5083
  case 7:
4059
- products = _context46.sent;
4060
- return _context46.abrupt("return", products);
5084
+ products = _context58.sent;
5085
+ return _context58.abrupt("return", products);
4061
5086
  case 11:
4062
- _context46.prev = 11;
4063
- _context46.t0 = _context46["catch"](0);
4064
- throw _context46.t0;
5087
+ _context58.prev = 11;
5088
+ _context58.t0 = _context58["catch"](0);
5089
+ throw _context58.t0;
4065
5090
  case 14:
4066
5091
  case "end":
4067
- return _context46.stop();
5092
+ return _context58.stop();
4068
5093
  }
4069
- }, _callee46, this, [[0, 11]]);
5094
+ }, _callee58, this, [[0, 11]]);
4070
5095
  }));
4071
- function setOrderProductLineNote(_x41, _x42) {
5096
+ function setOrderProductLineNote(_x50, _x51) {
4072
5097
  return _setOrderProductLineNote.apply(this, arguments);
4073
5098
  }
4074
5099
  return setOrderProductLineNote;
@@ -4083,32 +5108,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4083
5108
  }, {
4084
5109
  key: "removeProductsFromOrder",
4085
5110
  value: (function () {
4086
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(identities) {
4087
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4088
- while (1) switch (_context47.prev = _context47.next) {
5111
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identities) {
5112
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5113
+ while (1) switch (_context59.prev = _context59.next) {
4089
5114
  case 0:
4090
- _context47.prev = 0;
5115
+ _context59.prev = 0;
4091
5116
  if (this.store.order) {
4092
- _context47.next = 3;
5117
+ _context59.next = 3;
4093
5118
  break;
4094
5119
  }
4095
5120
  throw new Error('order 模块未初始化');
4096
5121
  case 3:
4097
- _context47.next = 5;
5122
+ _context59.next = 5;
4098
5123
  return this.store.order.removeProductsFromOrder(identities);
4099
5124
  case 5:
4100
- return _context47.abrupt("return", _context47.sent);
5125
+ return _context59.abrupt("return", _context59.sent);
4101
5126
  case 8:
4102
- _context47.prev = 8;
4103
- _context47.t0 = _context47["catch"](0);
4104
- throw _context47.t0;
5127
+ _context59.prev = 8;
5128
+ _context59.t0 = _context59["catch"](0);
5129
+ throw _context59.t0;
4105
5130
  case 11:
4106
5131
  case "end":
4107
- return _context47.stop();
5132
+ return _context59.stop();
4108
5133
  }
4109
- }, _callee47, this, [[0, 8]]);
5134
+ }, _callee59, this, [[0, 8]]);
4110
5135
  }));
4111
- function removeProductsFromOrder(_x43) {
5136
+ function removeProductsFromOrder(_x52) {
4112
5137
  return _removeProductsFromOrder.apply(this, arguments);
4113
5138
  }
4114
5139
  return removeProductsFromOrder;
@@ -4116,18 +5141,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4116
5141
  }, {
4117
5142
  key: "removeProductFromOrder",
4118
5143
  value: function () {
4119
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(identity) {
4120
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4121
- while (1) switch (_context48.prev = _context48.next) {
5144
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity) {
5145
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5146
+ while (1) switch (_context60.prev = _context60.next) {
4122
5147
  case 0:
4123
- return _context48.abrupt("return", this.removeProductsFromOrder([identity]));
5148
+ return _context60.abrupt("return", this.removeProductsFromOrder([identity]));
4124
5149
  case 1:
4125
5150
  case "end":
4126
- return _context48.stop();
5151
+ return _context60.stop();
4127
5152
  }
4128
- }, _callee48, this);
5153
+ }, _callee60, this);
4129
5154
  }));
4130
- function removeProductFromOrder(_x44) {
5155
+ function removeProductFromOrder(_x53) {
4131
5156
  return _removeProductFromOrder.apply(this, arguments);
4132
5157
  }
4133
5158
  return removeProductFromOrder;
@@ -4177,23 +5202,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4177
5202
  }, {
4178
5203
  key: "applyPromotion",
4179
5204
  value: (function () {
4180
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4181
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4182
- while (1) switch (_context49.prev = _context49.next) {
5205
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
5206
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5207
+ while (1) switch (_context61.prev = _context61.next) {
4183
5208
  case 0:
4184
5209
  if (this.store.order) {
4185
- _context49.next = 2;
5210
+ _context61.next = 2;
4186
5211
  break;
4187
5212
  }
4188
5213
  throw new Error('order 模块未初始化');
4189
5214
  case 2:
4190
- _context49.next = 4;
5215
+ _context61.next = 4;
4191
5216
  return this.store.order.applyPromotion();
4192
5217
  case 4:
4193
5218
  case "end":
4194
- return _context49.stop();
5219
+ return _context61.stop();
4195
5220
  }
4196
- }, _callee49, this);
5221
+ }, _callee61, this);
4197
5222
  }));
4198
5223
  function applyPromotion() {
4199
5224
  return _applyPromotion.apply(this, arguments);
@@ -4203,16 +5228,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4203
5228
  }, {
4204
5229
  key: "getUnfulfilledPromotions",
4205
5230
  value: function getUnfulfilledPromotions() {
4206
- var _this$store$order8;
4207
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
5231
+ var _this$store$order16;
5232
+ return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
4208
5233
  }
4209
5234
 
4210
5235
  /** 最近一次促销计算输出的赠品操作 diff。 */
4211
5236
  }, {
4212
5237
  key: "getLastGiftActions",
4213
5238
  value: function getLastGiftActions() {
4214
- var _this$store$order9;
4215
- return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
5239
+ var _this$store$order17;
5240
+ return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
4216
5241
  }
4217
5242
 
4218
5243
  // 获取商品列表
@@ -4220,18 +5245,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4220
5245
  }, {
4221
5246
  key: "getProductList",
4222
5247
  value: function () {
4223
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4224
- var _this$otherParams25;
5248
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
5249
+ var _this$otherParams26;
4225
5250
  var menu_list_ids, _this$store$products, res;
4226
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4227
- while (1) switch (_context50.prev = _context50.next) {
5251
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5252
+ while (1) switch (_context62.prev = _context62.next) {
4228
5253
  case 0:
4229
5254
  // 可以直接通过配置里的 menu 读取
4230
- menu_list_ids = ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 || (_this$otherParams25 = _this$otherParams25.dineInConfig) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25['menu.associated_menus'].map(function (n) {
5255
+ menu_list_ids = ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 || (_this$otherParams26 = _this$otherParams26.dineInConfig) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26['menu.associated_menus'].map(function (n) {
4231
5256
  return Number(n.value);
4232
5257
  })) || [];
4233
- _context50.prev = 1;
4234
- _context50.next = 4;
5258
+ _context62.prev = 1;
5259
+ _context62.next = 4;
4235
5260
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
4236
5261
  menu_list_ids: menu_list_ids,
4237
5262
  cacheId: this.cacheId,
@@ -4239,17 +5264,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4239
5264
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
4240
5265
  });
4241
5266
  case 4:
4242
- res = _context50.sent;
4243
- return _context50.abrupt("return", res);
5267
+ res = _context62.sent;
5268
+ return _context62.abrupt("return", res);
4244
5269
  case 8:
4245
- _context50.prev = 8;
4246
- _context50.t0 = _context50["catch"](1);
4247
- throw _context50.t0;
5270
+ _context62.prev = 8;
5271
+ _context62.t0 = _context62["catch"](1);
5272
+ throw _context62.t0;
4248
5273
  case 11:
4249
5274
  case "end":
4250
- return _context50.stop();
5275
+ return _context62.stop();
4251
5276
  }
4252
- }, _callee50, this, [[1, 8]]);
5277
+ }, _callee62, this, [[1, 8]]);
4253
5278
  }));
4254
5279
  function getProductList() {
4255
5280
  return _getProductList.apply(this, arguments);
@@ -4264,33 +5289,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4264
5289
  }, {
4265
5290
  key: "setOtherParams",
4266
5291
  value: function () {
4267
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4268
- var _this$otherParams26;
4269
- var _ref31,
4270
- _ref31$cover,
5292
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
5293
+ var _this$otherParams27;
5294
+ var _ref39,
5295
+ _ref39$cover,
4271
5296
  cover,
4272
- _args51 = arguments;
4273
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4274
- while (1) switch (_context51.prev = _context51.next) {
5297
+ _args63 = arguments;
5298
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5299
+ while (1) switch (_context63.prev = _context63.next) {
4275
5300
  case 0:
4276
- _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
5301
+ _ref39 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref39$cover = _ref39.cover, cover = _ref39$cover === void 0 ? false : _ref39$cover;
4277
5302
  if (cover) {
4278
5303
  this.otherParams = _objectSpread({}, params);
4279
5304
  } else {
4280
5305
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
4281
5306
  }
4282
- this.cacheId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.cacheId;
4283
- _context51.next = 5;
5307
+ this.cacheId = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.cacheId;
5308
+ _context63.next = 5;
4284
5309
  return this.syncOtherParamsToSubModules(params, {
4285
5310
  cover: cover
4286
5311
  });
4287
5312
  case 5:
4288
5313
  case "end":
4289
- return _context51.stop();
5314
+ return _context63.stop();
4290
5315
  }
4291
- }, _callee51, this);
5316
+ }, _callee63, this);
4292
5317
  }));
4293
- function setOtherParams(_x45) {
5318
+ function setOtherParams(_x54) {
4294
5319
  return _setOtherParams.apply(this, arguments);
4295
5320
  }
4296
5321
  return setOtherParams;