@pisell/pisellos 2.2.278 → 2.2.280

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 (188) hide show
  1. package/dist/modules/BaseModule.d.ts +1 -0
  2. package/dist/modules/BaseModule.js +24 -28
  3. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
  4. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  5. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  6. package/dist/modules/Customer/index.d.ts +4 -0
  7. package/dist/modules/Customer/index.js +91 -59
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/index.d.ts +1 -0
  10. package/dist/modules/Discount/index.js +40 -11
  11. package/dist/modules/Discount/types.d.ts +1 -0
  12. package/dist/modules/Holder/index.d.ts +48 -0
  13. package/dist/modules/Holder/index.js +640 -0
  14. package/dist/modules/Holder/types.d.ts +123 -0
  15. package/dist/modules/Holder/types.js +1 -0
  16. package/dist/modules/Holder/utils.d.ts +13 -0
  17. package/dist/modules/Holder/utils.js +34 -0
  18. package/dist/modules/OpenData/index.js +2 -2
  19. package/dist/modules/Order/index.d.ts +32 -4
  20. package/dist/modules/Order/index.js +868 -675
  21. package/dist/modules/Order/types.d.ts +22 -1
  22. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  23. package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
  24. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  26. package/dist/modules/Order/utils.d.ts +10 -0
  27. package/dist/modules/Order/utils.js +71 -34
  28. package/dist/modules/Payment/index.d.ts +4 -0
  29. package/dist/modules/Payment/index.js +14 -4
  30. package/dist/modules/Payment/walletpass.js +21 -7
  31. package/dist/modules/Product/types.d.ts +1 -0
  32. package/dist/modules/ProductList/index.js +33 -13
  33. package/dist/modules/Quotation/index.d.ts +1 -1
  34. package/dist/modules/Quotation/index.js +2 -2
  35. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  36. package/dist/modules/ResourcePlanner/index.js +181 -0
  37. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  38. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  39. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  40. package/dist/modules/ResourcePlanner/types.js +1 -0
  41. package/dist/modules/Rules/index.js +153 -56
  42. package/dist/modules/SalesSummary/index.js +12 -13
  43. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  44. package/dist/modules/ScanOrderLogger/index.js +15 -2
  45. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  46. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  47. package/dist/modules/Schedule/index.d.ts +3 -1
  48. package/dist/modules/Schedule/index.js +21 -16
  49. package/dist/modules/Summary/utils.js +38 -13
  50. package/dist/modules/index.d.ts +2 -0
  51. package/dist/modules/index.js +3 -1
  52. package/dist/plugins/window.d.ts +1 -0
  53. package/dist/server/index.d.ts +20 -0
  54. package/dist/server/index.js +1101 -909
  55. package/dist/server/modules/order/index.d.ts +2 -0
  56. package/dist/server/modules/order/index.js +261 -96
  57. package/dist/server/modules/order/types.d.ts +1 -1
  58. package/dist/solution/BaseSales/index.d.ts +20 -1
  59. package/dist/solution/BaseSales/index.js +989 -881
  60. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
  61. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  62. package/dist/solution/BaseSales/utils.js +31 -20
  63. package/dist/solution/BookingByStep/index.d.ts +17 -2
  64. package/dist/solution/BookingByStep/index.js +294 -215
  65. package/dist/solution/BookingByStep/types.d.ts +2 -1
  66. package/dist/solution/BookingByStep/types.js +3 -1
  67. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  68. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  69. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  70. package/dist/solution/BookingTicket/index.d.ts +21 -3
  71. package/dist/solution/BookingTicket/index.js +312 -226
  72. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  73. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  74. package/dist/solution/ScanOrder/index.d.ts +26 -14
  75. package/dist/solution/ScanOrder/index.js +1142 -739
  76. package/dist/solution/ScanOrder/types.d.ts +21 -1
  77. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  78. package/dist/solution/ScanOrder/utils.js +97 -45
  79. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  80. package/dist/solution/ShopDiscount/index.js +125 -87
  81. package/dist/solution/UnifiedBookingSales/index.d.ts +204 -0
  82. package/dist/solution/UnifiedBookingSales/index.js +2211 -0
  83. package/dist/solution/UnifiedBookingSales/types.d.ts +150 -0
  84. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  85. package/dist/solution/VenueBooking/index.d.ts +39 -11
  86. package/dist/solution/VenueBooking/index.js +1167 -841
  87. package/dist/solution/VenueBooking/types.d.ts +3 -0
  88. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  89. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  90. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  91. package/dist/solution/index.d.ts +1 -0
  92. package/dist/solution/index.js +2 -1
  93. package/dist/types/index.d.ts +1 -0
  94. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  95. package/lib/modules/BaseModule.d.ts +1 -0
  96. package/lib/modules/BaseModule.js +24 -37
  97. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
  98. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  99. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  100. package/lib/modules/Customer/index.d.ts +4 -0
  101. package/lib/modules/Customer/index.js +11 -0
  102. package/lib/modules/Customer/types.d.ts +2 -0
  103. package/lib/modules/Discount/index.d.ts +1 -0
  104. package/lib/modules/Discount/index.js +9 -0
  105. package/lib/modules/Discount/types.d.ts +1 -0
  106. package/lib/modules/Holder/index.d.ts +48 -0
  107. package/lib/modules/Holder/index.js +402 -0
  108. package/lib/modules/Holder/types.d.ts +123 -0
  109. package/lib/modules/Holder/types.js +17 -0
  110. package/lib/modules/Holder/utils.d.ts +13 -0
  111. package/lib/modules/Holder/utils.js +71 -0
  112. package/lib/modules/OpenData/index.js +1 -1
  113. package/lib/modules/Order/index.d.ts +32 -4
  114. package/lib/modules/Order/index.js +372 -156
  115. package/lib/modules/Order/types.d.ts +22 -1
  116. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  117. package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
  118. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  119. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  120. package/lib/modules/Order/utils.d.ts +10 -0
  121. package/lib/modules/Order/utils.js +39 -6
  122. package/lib/modules/Payment/index.d.ts +4 -0
  123. package/lib/modules/Payment/index.js +7 -0
  124. package/lib/modules/Payment/walletpass.js +12 -0
  125. package/lib/modules/Product/types.d.ts +1 -0
  126. package/lib/modules/ProductList/index.js +49 -31
  127. package/lib/modules/Quotation/index.d.ts +1 -1
  128. package/lib/modules/Quotation/index.js +2 -2
  129. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  130. package/lib/modules/ResourcePlanner/index.js +148 -0
  131. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  132. package/lib/modules/ResourcePlanner/planner.js +933 -0
  133. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  134. package/lib/modules/ResourcePlanner/types.js +17 -0
  135. package/lib/modules/Rules/index.js +117 -25
  136. package/lib/modules/SalesSummary/index.js +6 -7
  137. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  138. package/lib/modules/ScanOrderLogger/index.js +13 -1
  139. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  140. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  141. package/lib/modules/Schedule/index.d.ts +3 -1
  142. package/lib/modules/Schedule/index.js +10 -8
  143. package/lib/modules/Summary/utils.js +21 -1
  144. package/lib/modules/index.d.ts +2 -0
  145. package/lib/modules/index.js +5 -1
  146. package/lib/plugins/window.d.ts +1 -0
  147. package/lib/server/index.d.ts +20 -0
  148. package/lib/server/index.js +124 -19
  149. package/lib/server/modules/order/index.d.ts +2 -0
  150. package/lib/server/modules/order/index.js +75 -5
  151. package/lib/server/modules/order/types.d.ts +1 -1
  152. package/lib/solution/BaseSales/index.d.ts +20 -1
  153. package/lib/solution/BaseSales/index.js +105 -31
  154. package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
  156. package/lib/solution/BaseSales/utils.js +29 -18
  157. package/lib/solution/BookingByStep/index.d.ts +17 -2
  158. package/lib/solution/BookingByStep/index.js +60 -18
  159. package/lib/solution/BookingByStep/types.d.ts +2 -1
  160. package/lib/solution/BookingByStep/types.js +5 -0
  161. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  162. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  163. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  164. package/lib/solution/BookingTicket/index.d.ts +21 -3
  165. package/lib/solution/BookingTicket/index.js +75 -16
  166. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  167. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  168. package/lib/solution/ScanOrder/index.d.ts +26 -14
  169. package/lib/solution/ScanOrder/index.js +449 -182
  170. package/lib/solution/ScanOrder/types.d.ts +21 -1
  171. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  172. package/lib/solution/ScanOrder/utils.js +60 -18
  173. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  174. package/lib/solution/ShopDiscount/index.js +14 -0
  175. package/lib/solution/UnifiedBookingSales/index.d.ts +204 -0
  176. package/lib/solution/UnifiedBookingSales/index.js +1273 -0
  177. package/lib/solution/UnifiedBookingSales/types.d.ts +150 -0
  178. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  179. package/lib/solution/VenueBooking/index.d.ts +39 -11
  180. package/lib/solution/VenueBooking/index.js +322 -110
  181. package/lib/solution/VenueBooking/types.d.ts +3 -0
  182. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  183. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  184. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  185. package/lib/solution/index.d.ts +1 -0
  186. package/lib/solution/index.js +3 -1
  187. package/lib/types/index.d.ts +1 -0
  188. package/package.json +1 -1
@@ -65,19 +65,21 @@ function isRejectedSalesSubmitResult(result) {
65
65
  var _result$response, _result$response2;
66
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
67
  return candidates.some(function (candidate) {
68
- var _candidate$code;
69
68
  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;
69
+ if (candidate.code !== undefined && candidate.code !== 200 && candidate.code !== '200') {
70
+ return true;
71
+ }
72
+ var statusCode = Number(candidate.statusCode);
73
+ if (Number.isFinite(statusCode) && statusCode >= 400) return true;
72
74
  if (candidate.status === false || candidate.success === false || candidate.result === false) {
73
75
  return true;
74
76
  }
75
77
  return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
76
78
  });
77
79
  }
78
- function getSalesSubmitErrorMessage(result) {
80
+ function getSalesSubmitErrorMessage(result, fallbackMessage) {
79
81
  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 支付确认失败';
82
+ 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) || fallbackMessage;
81
83
  }
82
84
  function toWalletFundValue(value) {
83
85
  try {
@@ -667,7 +669,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
667
669
  }, {
668
670
  key: "hydrateLatestLoadedSalesDetail",
669
671
  value: function () {
670
- var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
672
+ var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence, hydrateSource) {
671
673
  var _this4 = this;
672
674
  var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
673
675
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -695,7 +697,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
695
697
  throw new Error('order 模块未初始化');
696
698
  case 5:
697
699
  _context4.next = 7;
698
- return _this4.store.order.hydrateTempOrderFromRecord(record, {
700
+ return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateSource === 'sessionStorage' ? {
701
+ recalcOnHydrate: true,
702
+ source: 'sessionStorage'
703
+ } : {
699
704
  recalcOnHydrate: false
700
705
  });
701
706
  case 7:
@@ -746,7 +751,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
746
751
  }
747
752
  }, _callee5, this);
748
753
  }));
749
- function hydrateLatestLoadedSalesDetail(_x2, _x3) {
754
+ function hydrateLatestLoadedSalesDetail(_x2, _x3, _x4) {
750
755
  return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
751
756
  }
752
757
  return hydrateLatestLoadedSalesDetail;
@@ -849,7 +854,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
849
854
  }
850
855
  }, _callee6, this);
851
856
  }));
852
- function loadQuotationForPriceQuery(_x4) {
857
+ function loadQuotationForPriceQuery(_x5) {
853
858
  return _loadQuotationForPriceQuery.apply(this, arguments);
854
859
  }
855
860
  return loadQuotationForPriceQuery;
@@ -894,8 +899,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
894
899
  if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
895
900
  strategyContext.business_code = String(businessCode).trim();
896
901
  }
902
+ var availableWalletIds = this.getAvailableWalletIds();
903
+ if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
904
+ strategyContext.available_wallet_ids = availableWalletIds;
905
+ }
897
906
  return strategyContext;
898
907
  }
908
+
909
+ /**
910
+ * 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
911
+ */
912
+ }, {
913
+ key: "prepareProductPriceQueryContext",
914
+ value: (function () {
915
+ var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_customerId) {
916
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
917
+ while (1) switch (_context7.prev = _context7.next) {
918
+ case 0:
919
+ case "end":
920
+ return _context7.stop();
921
+ }
922
+ }, _callee7);
923
+ }));
924
+ function prepareProductPriceQueryContext(_x6) {
925
+ return _prepareProductPriceQueryContext.apply(this, arguments);
926
+ }
927
+ return prepareProductPriceQueryContext;
928
+ }()
929
+ /**
930
+ * 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
931
+ * 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
932
+ */
933
+ )
934
+ }, {
935
+ key: "preferAuthoritativeProductQueryPrice",
936
+ value: function preferAuthoritativeProductQueryPrice() {
937
+ return false;
938
+ }
899
939
  }, {
900
940
  key: "getPriceQuerySchedule",
901
941
  value: function getPriceQuerySchedule(params) {
@@ -927,25 +967,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
927
967
  }, {
928
968
  key: "loadProductsForPriceQuery",
929
969
  value: function () {
930
- var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
970
+ var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
931
971
  var ids, productsById, channel, strategyContext, _response$data, response, list;
932
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
933
- while (1) switch (_context7.prev = _context7.next) {
972
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
973
+ while (1) switch (_context8.prev = _context8.next) {
934
974
  case 0:
935
975
  ids = Array.from(new Set(params.ids.filter(function (id) {
936
976
  return Number.isFinite(id);
937
977
  })));
938
978
  productsById = new Map();
939
979
  if (!(!ids.length || !this.request)) {
940
- _context7.next = 4;
980
+ _context8.next = 4;
941
981
  break;
942
982
  }
943
- return _context7.abrupt("return", productsById);
983
+ return _context8.abrupt("return", productsById);
944
984
  case 4:
945
985
  channel = this.getPriceQueryChannel(params.channel);
946
986
  strategyContext = this.getPriceQueryStrategyContext(channel);
947
- _context7.prev = 6;
948
- _context7.next = 9;
987
+ _context8.prev = 6;
988
+ _context8.next = 9;
949
989
  return this.request.post('/product/query', _objectSpread({
950
990
  ids: ids,
951
991
  open_quotation: 1,
@@ -964,35 +1004,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
964
1004
  customToast: function customToast() {}
965
1005
  });
966
1006
  case 9:
967
- response = _context7.sent;
1007
+ response = _context8.sent;
968
1008
  list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
969
1009
  if (Array.isArray(list)) {
970
- _context7.next = 13;
1010
+ _context8.next = 13;
971
1011
  break;
972
1012
  }
973
- return _context7.abrupt("return", productsById);
1013
+ return _context8.abrupt("return", productsById);
974
1014
  case 13:
975
1015
  list.forEach(function (item) {
976
1016
  var _item$id;
977
1017
  var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
978
1018
  if (Number.isFinite(productId)) productsById.set(productId, item);
979
1019
  });
980
- return _context7.abrupt("return", productsById);
1020
+ return _context8.abrupt("return", productsById);
981
1021
  case 17:
982
- _context7.prev = 17;
983
- _context7.t0 = _context7["catch"](6);
1022
+ _context8.prev = 17;
1023
+ _context8.t0 = _context8["catch"](6);
984
1024
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
985
1025
  ids: ids,
986
- error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
1026
+ error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
987
1027
  });
988
- return _context7.abrupt("return", productsById);
1028
+ return _context8.abrupt("return", productsById);
989
1029
  case 21:
990
1030
  case "end":
991
- return _context7.stop();
1031
+ return _context8.stop();
992
1032
  }
993
- }, _callee7, this, [[6, 17]]);
1033
+ }, _callee8, this, [[6, 17]]);
994
1034
  }));
995
- function loadProductsForPriceQuery(_x5) {
1035
+ function loadProductsForPriceQuery(_x7) {
996
1036
  return _loadProductsForPriceQuery.apply(this, arguments);
997
1037
  }
998
1038
  return loadProductsForPriceQuery;
@@ -1000,21 +1040,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1000
1040
  }, {
1001
1041
  key: "loadProductForPriceQuery",
1002
1042
  value: function () {
1003
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
1043
+ var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, customerId) {
1004
1044
  var product, productId, schedule, productsById;
1005
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1006
- while (1) switch (_context8.prev = _context8.next) {
1045
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1046
+ while (1) switch (_context9.prev = _context9.next) {
1007
1047
  case 0:
1008
1048
  product = params.product || {};
1009
1049
  productId = this.getPriceQueryProductId(product);
1010
1050
  if (!(productId === null || !this.request)) {
1011
- _context8.next = 4;
1051
+ _context9.next = 4;
1012
1052
  break;
1013
1053
  }
1014
- return _context8.abrupt("return", null);
1054
+ return _context9.abrupt("return", null);
1015
1055
  case 4:
1016
1056
  schedule = this.getPriceQuerySchedule(params);
1017
- _context8.next = 7;
1057
+ _context9.next = 7;
1018
1058
  return this.loadProductsForPriceQuery({
1019
1059
  ids: [productId],
1020
1060
  schedule: schedule,
@@ -1022,15 +1062,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1022
1062
  channel: params.channel
1023
1063
  });
1024
1064
  case 7:
1025
- productsById = _context8.sent;
1026
- return _context8.abrupt("return", productsById.get(productId) || null);
1065
+ productsById = _context9.sent;
1066
+ return _context9.abrupt("return", productsById.get(productId) || null);
1027
1067
  case 9:
1028
1068
  case "end":
1029
- return _context8.stop();
1069
+ return _context9.stop();
1030
1070
  }
1031
- }, _callee8, this);
1071
+ }, _callee9, this);
1032
1072
  }));
1033
- function loadProductForPriceQuery(_x6, _x7) {
1073
+ function loadProductForPriceQuery(_x8, _x9) {
1034
1074
  return _loadProductForPriceQuery.apply(this, arguments);
1035
1075
  }
1036
1076
  return loadProductForPriceQuery;
@@ -1168,13 +1208,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1168
1208
  * const params = this.buildSubModuleOtherParams();
1169
1209
  * this.core.registerModule(orderModule, { otherParams: params });
1170
1210
  */
1211
+ }, {
1212
+ key: "isSessionStoragePersistEnabled",
1213
+ value: function isSessionStoragePersistEnabled() {
1214
+ return Boolean(this.cacheId);
1215
+ }
1216
+ }, {
1217
+ key: "shouldUseSessionStorageForSubModule",
1218
+ value: function shouldUseSessionStorageForSubModule(_moduleName) {
1219
+ return this.isSessionStoragePersistEnabled();
1220
+ }
1171
1221
  }, {
1172
1222
  key: "buildSubModuleOtherParams",
1173
- value: function buildSubModuleOtherParams() {
1223
+ value: function buildSubModuleOtherParams(moduleName) {
1174
1224
  return _objectSpread(_objectSpread({}, this.otherParams), {}, {
1175
1225
  salesSummaryModuleName: "".concat(this.name, "_salesSummary"),
1176
1226
  fatherModule: this.name,
1177
- openCache: this.cacheId ? true : false,
1227
+ openCache: this.shouldUseSessionStorageForSubModule(moduleName),
1178
1228
  cacheId: this.cacheId
1179
1229
  });
1180
1230
  }
@@ -1188,61 +1238,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1188
1238
  }, {
1189
1239
  key: "syncOtherParamsToSubModules",
1190
1240
  value: (function () {
1191
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
1241
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
1192
1242
  var _this6 = this;
1193
1243
  var _ref23,
1194
1244
  _ref23$cover,
1195
1245
  cover,
1196
- nextSubModuleOtherParams,
1197
- _args10 = arguments;
1198
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1199
- while (1) switch (_context10.prev = _context10.next) {
1246
+ _args11 = arguments;
1247
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1248
+ while (1) switch (_context11.prev = _context11.next) {
1200
1249
  case 0:
1201
- _ref23 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
1202
- nextSubModuleOtherParams = this.buildSubModuleOtherParams();
1203
- _context10.next = 4;
1250
+ _ref23 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
1251
+ _context11.next = 3;
1204
1252
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1205
- var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref24) {
1206
- var _ref26, moduleName, subModule, targetModule;
1207
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1208
- while (1) switch (_context9.prev = _context9.next) {
1253
+ var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref24) {
1254
+ var _ref26, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1255
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1256
+ while (1) switch (_context10.prev = _context10.next) {
1209
1257
  case 0:
1210
1258
  _ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
1211
1259
  if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1212
- _context9.next = 3;
1260
+ _context10.next = 3;
1213
1261
  break;
1214
1262
  }
1215
- return _context9.abrupt("return");
1263
+ return _context10.abrupt("return");
1216
1264
  case 3:
1217
1265
  targetModule = subModule;
1218
1266
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
1219
- _context9.next = 6;
1267
+ _context10.next = 6;
1220
1268
  break;
1221
1269
  }
1222
- return _context9.abrupt("return");
1270
+ return _context10.abrupt("return");
1223
1271
  case 6:
1224
- _context9.next = 8;
1272
+ nextSubModuleOtherParams = _this6.buildSubModuleOtherParams(moduleName);
1273
+ _context10.next = 9;
1225
1274
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
1226
1275
  changedParams: changedParams,
1227
1276
  cover: cover
1228
1277
  });
1229
- case 8:
1278
+ case 9:
1230
1279
  case "end":
1231
- return _context9.stop();
1280
+ return _context10.stop();
1232
1281
  }
1233
- }, _callee9);
1282
+ }, _callee10);
1234
1283
  }));
1235
- return function (_x9) {
1284
+ return function (_x11) {
1236
1285
  return _ref25.apply(this, arguments);
1237
1286
  };
1238
1287
  }()));
1239
- case 4:
1288
+ case 3:
1240
1289
  case "end":
1241
- return _context10.stop();
1290
+ return _context11.stop();
1242
1291
  }
1243
- }, _callee10, this);
1292
+ }, _callee11, this);
1244
1293
  }));
1245
- function syncOtherParamsToSubModules(_x8) {
1294
+ function syncOtherParamsToSubModules(_x10) {
1246
1295
  return _syncOtherParamsToSubModules.apply(this, arguments);
1247
1296
  }
1248
1297
  return syncOtherParamsToSubModules;
@@ -1255,12 +1304,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1255
1304
  }, {
1256
1305
  key: "readSessionCacheData",
1257
1306
  value: function readSessionCacheData() {
1258
- if (!this.cacheId || !this.window) return {};
1307
+ var cacheId = this.cacheId;
1308
+ if (!cacheId || !this.isSessionStoragePersistEnabled() || !this.window) {
1309
+ return {};
1310
+ }
1259
1311
  try {
1260
1312
  var sessionData = this.window.sessionStorage.getItem(this.name);
1261
1313
  if (!sessionData) return {};
1262
1314
  var data = JSON.parse(sessionData);
1263
- return data && data[this.cacheId] || {};
1315
+ return data && data[cacheId] || {};
1264
1316
  } catch (_unused3) {
1265
1317
  return {};
1266
1318
  }
@@ -1348,19 +1400,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1348
1400
  }, {
1349
1401
  key: "initialize",
1350
1402
  value: function () {
1351
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1403
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
1352
1404
  var _this$otherParams9,
1405
+ _this$appPlugin2,
1406
+ _this$appPlugin2$getA,
1353
1407
  _this9 = this,
1354
1408
  _this$otherParams10;
1355
1409
  var options,
1356
1410
  app,
1357
1411
  targetCacheData,
1358
1412
  moduleNames,
1359
- _args11 = arguments;
1360
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1361
- while (1) switch (_context11.prev = _context11.next) {
1413
+ _args12 = arguments;
1414
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1415
+ while (1) switch (_context12.prev = _context12.next) {
1362
1416
  case 0:
1363
- options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1417
+ options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
1364
1418
  this.core = core;
1365
1419
  this.initializeOptions = options || {};
1366
1420
  this.paymentNumberDevicePrefix = null;
@@ -1373,14 +1427,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1373
1427
 
1374
1428
  // 获取 logger 实例
1375
1429
  this.appPlugin = core.getPlugin('app');
1376
- if (this.appPlugin) {
1377
- _context11.next = 12;
1378
- break;
1430
+ if (!this.appPlugin) {
1431
+ // throw new Error('Checkout 解决方案需要 app 插件支持');
1379
1432
  }
1380
- throw new Error('Checkout 解决方案需要 app 插件支持');
1381
- case 12:
1382
- app = this.appPlugin.getApp();
1383
- this.logger = app.logger;
1433
+ app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
1434
+ this.logger = app === null || app === void 0 ? void 0 : app.logger;
1384
1435
  targetCacheData = this.readSessionCacheData();
1385
1436
  moduleNames = this.getRegisteredModuleNames();
1386
1437
  moduleNames.forEach(function (step) {
@@ -1397,35 +1448,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1397
1448
  var hooks = _this9.getSubModuleHooks(step);
1398
1449
  _this9.store[step] = targetModule;
1399
1450
  _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1400
- initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1451
+ initialState: _this9.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
1401
1452
  }, hooks ? {
1402
1453
  hooks: hooks
1403
1454
  } : {}), {}, {
1404
- otherParams: _this9.buildSubModuleOtherParams()
1455
+ otherParams: _this9.buildSubModuleOtherParams(step)
1405
1456
  }));
1406
1457
  });
1407
1458
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1408
- _context11.next = 20;
1459
+ _context12.next = 19;
1409
1460
  break;
1410
1461
  }
1411
- _context11.next = 20;
1462
+ _context12.next = 19;
1412
1463
  return this.store.schedule.loadAllSchedule();
1413
- case 20:
1464
+ case 19:
1414
1465
  if (this.store.order && typeof ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.enableTempOrderPersist) === 'boolean') {
1415
1466
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1416
1467
  }
1417
- _context11.next = 23;
1468
+ _context12.next = 22;
1418
1469
  return this.getPaymentMethodsAsync();
1419
- case 23:
1470
+ case 22:
1420
1471
  this.registerServerOrderChangeSync();
1421
1472
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1422
- case 25:
1473
+ case 24:
1423
1474
  case "end":
1424
- return _context11.stop();
1475
+ return _context12.stop();
1425
1476
  }
1426
- }, _callee11, this);
1477
+ }, _callee12, this);
1427
1478
  }));
1428
- function initialize(_x10) {
1479
+ function initialize(_x12) {
1429
1480
  return _initialize.apply(this, arguments);
1430
1481
  }
1431
1482
  return initialize;
@@ -1433,11 +1484,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1433
1484
  }, {
1434
1485
  key: "destroy",
1435
1486
  value: function () {
1436
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1487
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1437
1488
  var _this$serverOrderChan2,
1438
1489
  _this10 = this;
1439
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1440
- while (1) switch (_context12.prev = _context12.next) {
1490
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1491
+ while (1) switch (_context13.prev = _context13.next) {
1441
1492
  case 0:
1442
1493
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1443
1494
  this.serverOrderChangeUnsubscribe = null;
@@ -1457,15 +1508,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1457
1508
  this.queuedServerOrderChanges = [];
1458
1509
  this.salesDetailLoadSequence += 1;
1459
1510
  this.walletAssetsRefreshSequence += 1;
1460
- _context12.next = 10;
1511
+ _context13.next = 10;
1461
1512
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1462
1513
  case 10:
1463
1514
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1464
1515
  case 11:
1465
1516
  case "end":
1466
- return _context12.stop();
1517
+ return _context13.stop();
1467
1518
  }
1468
- }, _callee12, this);
1519
+ }, _callee13, this);
1469
1520
  }));
1470
1521
  function destroy() {
1471
1522
  return _destroy.apply(this, arguments);
@@ -1482,20 +1533,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1482
1533
  }, {
1483
1534
  key: "loadSalesDetail",
1484
1535
  value: (function () {
1485
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1486
- var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1487
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1488
- while (1) switch (_context13.prev = _context13.next) {
1536
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
1537
+ var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
1538
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1539
+ while (1) switch (_context14.prev = _context14.next) {
1489
1540
  case 0:
1490
1541
  if (this.store.order) {
1491
- _context13.next = 2;
1542
+ _context14.next = 2;
1492
1543
  break;
1493
1544
  }
1494
1545
  throw new Error('order 模块未初始化');
1495
1546
  case 2:
1496
1547
  loadSequence = ++this.salesDetailLoadSequence;
1497
1548
  this.salesDetailLoadInFlightCount += 1;
1498
- _context13.prev = 4;
1549
+ _context14.prev = 4;
1499
1550
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
1500
1551
  orderId: orderIdOrParams
1501
1552
  };
@@ -1503,71 +1554,73 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1503
1554
  preloadedSalesDetail = params.preloadedSalesDetail;
1504
1555
  lookup = (_ref27 = (_ref28 = (_ref29 = (_ref30 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref30 !== void 0 ? _ref30 : params.orderNumber) !== null && _ref29 !== void 0 ? _ref29 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref28 !== void 0 ? _ref28 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref27 !== void 0 ? _ref27 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1505
1556
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1506
- _context13.next = 11;
1557
+ _context14.next = 11;
1507
1558
  break;
1508
1559
  }
1509
1560
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
1510
1561
  case 11:
1511
1562
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
1512
- _context13.next = 15;
1563
+ _context14.next = 15;
1513
1564
  break;
1514
1565
  }
1515
- _context13.t0 = preloadedSalesDetail;
1516
- _context13.next = 18;
1566
+ _context14.t0 = preloadedSalesDetail;
1567
+ _context14.next = 18;
1517
1568
  break;
1518
1569
  case 15:
1519
- _context13.next = 17;
1570
+ _context14.next = 17;
1520
1571
  return this.store.order.getSalesOrderByLookup({
1521
1572
  lookup: lookup,
1522
1573
  forceRemote: params.forceRemote
1523
1574
  });
1524
1575
  case 17:
1525
- _context13.t0 = _context13.sent;
1576
+ _context14.t0 = _context14.sent;
1526
1577
  case 18:
1527
- loadedRecord = _context13.t0;
1578
+ loadedRecord = _context14.t0;
1528
1579
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
1529
- _context13.next = 22;
1580
+ _context14.next = 22;
1530
1581
  break;
1531
1582
  }
1532
1583
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1533
1584
  throw new Error(message);
1534
1585
  case 22:
1535
- remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1586
+ loadedSalesDetail = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data; // payment_pending 只存在于本地;远端详情需过滤,但会话快照必须完整恢复。
1587
+ shouldFilterPendingPayments = params.hydrateSource !== 'sessionStorage';
1588
+ remoteRecord = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(loadedSalesDetail) : loadedSalesDetail;
1536
1589
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1537
1590
  mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1538
- record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1539
- _context13.next = 28;
1540
- return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1541
- case 28:
1542
- return _context13.abrupt("return", _context13.sent);
1543
- case 29:
1544
- _context13.prev = 29;
1591
+ record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
1592
+ _context14.next = 30;
1593
+ return this.hydrateLatestLoadedSalesDetail(record, loadSequence, params.hydrateSource);
1594
+ case 30:
1595
+ return _context14.abrupt("return", _context14.sent);
1596
+ case 31:
1597
+ _context14.prev = 31;
1545
1598
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1546
1599
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1547
- _context13.next = 40;
1600
+ _context14.next = 42;
1548
1601
  break;
1549
1602
  }
1550
- _context13.prev = 32;
1551
- _context13.next = 35;
1603
+ _context14.prev = 34;
1604
+ _context14.next = 37;
1552
1605
  return this.drainQueuedServerOrderChanges();
1553
- case 35:
1554
- _context13.next = 40;
1555
- break;
1556
1606
  case 37:
1557
- _context13.prev = 37;
1558
- _context13.t1 = _context13["catch"](32);
1607
+ _context14.next = 42;
1608
+ break;
1609
+ case 39:
1610
+ _context14.prev = 39;
1611
+ _context14.t1 = _context14["catch"](34);
1559
1612
  this.logError('drain queued server order changes failed', {
1560
- error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1613
+ error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
1561
1614
  });
1562
- case 40:
1563
- return _context13.finish(29);
1564
- case 41:
1615
+ case 42:
1616
+ return _context14.finish(31);
1617
+ case 43:
1565
1618
  case "end":
1566
- return _context13.stop();
1619
+ return _context14.stop();
1567
1620
  }
1568
- }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1621
+ }, _callee14, this, [[4,, 31, 43], [34, 39]]);
1569
1622
  }));
1570
- function loadSalesDetail(_x11) {
1623
+ function loadSalesDetail(_x13) {
1571
1624
  return _loadSalesDetail.apply(this, arguments);
1572
1625
  }
1573
1626
  return loadSalesDetail;
@@ -1647,34 +1700,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1647
1700
  }, {
1648
1701
  key: "replaceTempOrder",
1649
1702
  value: function () {
1650
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder, options) {
1703
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
1651
1704
  var nextTempOrder;
1652
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1653
- while (1) switch (_context14.prev = _context14.next) {
1705
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1706
+ while (1) switch (_context15.prev = _context15.next) {
1654
1707
  case 0:
1655
1708
  if (this.store.order) {
1656
- _context14.next = 2;
1709
+ _context15.next = 2;
1657
1710
  break;
1658
1711
  }
1659
1712
  throw new Error('order 模块未初始化');
1660
1713
  case 2:
1661
- _context14.next = 4;
1714
+ _context15.next = 4;
1662
1715
  return this.store.order.replaceTempOrder(tempOrder, options);
1663
1716
  case 4:
1664
- nextTempOrder = _context14.sent;
1665
- _context14.next = 7;
1717
+ nextTempOrder = _context15.sent;
1718
+ _context15.next = 7;
1666
1719
  return this.effectsEmit('onTempOrderReplaced', {
1667
1720
  tempOrder: nextTempOrder
1668
1721
  });
1669
1722
  case 7:
1670
- return _context14.abrupt("return", nextTempOrder);
1723
+ return _context15.abrupt("return", nextTempOrder);
1671
1724
  case 8:
1672
1725
  case "end":
1673
- return _context14.stop();
1726
+ return _context15.stop();
1674
1727
  }
1675
- }, _callee14, this);
1728
+ }, _callee15, this);
1676
1729
  }));
1677
- function replaceTempOrder(_x12, _x13) {
1730
+ function replaceTempOrder(_x14, _x15) {
1678
1731
  return _replaceTempOrder.apply(this, arguments);
1679
1732
  }
1680
1733
  return replaceTempOrder;
@@ -1772,40 +1825,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1772
1825
  }, {
1773
1826
  key: "addNewOrder",
1774
1827
  value: function () {
1775
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1828
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1776
1829
  var tempOrder;
1777
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1778
- while (1) switch (_context15.prev = _context15.next) {
1830
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1831
+ while (1) switch (_context16.prev = _context16.next) {
1779
1832
  case 0:
1780
- _context15.prev = 0;
1833
+ _context16.prev = 0;
1781
1834
  if (this.store.order) {
1782
- _context15.next = 3;
1835
+ _context16.next = 3;
1783
1836
  break;
1784
1837
  }
1785
1838
  throw new Error('order 模块未初始化');
1786
1839
  case 3:
1787
- _context15.next = 5;
1840
+ _context16.next = 5;
1788
1841
  return this.store.order.addNewOrder();
1789
1842
  case 5:
1790
- tempOrder = _context15.sent;
1843
+ tempOrder = _context16.sent;
1791
1844
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1792
- _context15.next = 10;
1845
+ _context16.next = 10;
1793
1846
  break;
1794
1847
  }
1795
1848
  this.store.order.persistTempOrder();
1796
- _context15.next = 10;
1849
+ _context16.next = 10;
1797
1850
  return this.store.order.saveDraft();
1798
1851
  case 10:
1799
- return _context15.abrupt("return", tempOrder);
1852
+ return _context16.abrupt("return", tempOrder);
1800
1853
  case 13:
1801
- _context15.prev = 13;
1802
- _context15.t0 = _context15["catch"](0);
1803
- throw _context15.t0;
1854
+ _context16.prev = 13;
1855
+ _context16.t0 = _context16["catch"](0);
1856
+ throw _context16.t0;
1804
1857
  case 16:
1805
1858
  case "end":
1806
- return _context15.stop();
1859
+ return _context16.stop();
1807
1860
  }
1808
- }, _callee15, this, [[0, 13]]);
1861
+ }, _callee16, this, [[0, 13]]);
1809
1862
  }));
1810
1863
  function addNewOrder() {
1811
1864
  return _addNewOrder.apply(this, arguments);
@@ -1815,22 +1868,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1815
1868
  }, {
1816
1869
  key: "saveDraft",
1817
1870
  value: function () {
1818
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1819
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1820
- while (1) switch (_context16.prev = _context16.next) {
1871
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1872
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1873
+ while (1) switch (_context17.prev = _context17.next) {
1821
1874
  case 0:
1822
1875
  if (this.store.order) {
1823
- _context16.next = 2;
1876
+ _context17.next = 2;
1824
1877
  break;
1825
1878
  }
1826
1879
  throw new Error('order 模块未初始化');
1827
1880
  case 2:
1828
- return _context16.abrupt("return", this.store.order.saveDraft());
1881
+ return _context17.abrupt("return", this.store.order.saveDraft());
1829
1882
  case 3:
1830
1883
  case "end":
1831
- return _context16.stop();
1884
+ return _context17.stop();
1832
1885
  }
1833
- }, _callee16, this);
1886
+ }, _callee17, this);
1834
1887
  }));
1835
1888
  function saveDraft() {
1836
1889
  return _saveDraft.apply(this, arguments);
@@ -1841,14 +1894,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1841
1894
  }, {
1842
1895
  key: "restoreOrder",
1843
1896
  value: function () {
1844
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1897
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1845
1898
  var _this$store$payment, tempOrder, wallet;
1846
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1847
- while (1) switch (_context17.prev = _context17.next) {
1899
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1900
+ while (1) switch (_context18.prev = _context18.next) {
1848
1901
  case 0:
1849
- _context17.prev = 0;
1902
+ _context18.prev = 0;
1850
1903
  if (this.store.order) {
1851
- _context17.next = 3;
1904
+ _context18.next = 3;
1852
1905
  break;
1853
1906
  }
1854
1907
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -1860,37 +1913,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1860
1913
  this.hasManualDiscountSelection = false;
1861
1914
  wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
1862
1915
  if (!wallet) {
1863
- _context17.next = 13;
1916
+ _context18.next = 13;
1864
1917
  break;
1865
1918
  }
1866
1919
  this.walletAssetsRefreshSequence += 1;
1867
1920
  wallet.clearAllCache();
1868
- _context17.next = 13;
1921
+ _context18.next = 13;
1869
1922
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
1870
1923
  case 13:
1871
- _context17.next = 15;
1924
+ _context18.next = 15;
1872
1925
  return this.effectsEmit('onTempOrderReplaced', {
1873
1926
  tempOrder: tempOrder
1874
1927
  });
1875
1928
  case 15:
1876
1929
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1877
- _context17.next = 19;
1930
+ _context18.next = 19;
1878
1931
  break;
1879
1932
  }
1880
1933
  this.store.order.persistTempOrder();
1881
- _context17.next = 19;
1934
+ _context18.next = 19;
1882
1935
  return this.store.order.saveDraft();
1883
1936
  case 19:
1884
- return _context17.abrupt("return", tempOrder);
1937
+ return _context18.abrupt("return", tempOrder);
1885
1938
  case 22:
1886
- _context17.prev = 22;
1887
- _context17.t0 = _context17["catch"](0);
1888
- throw _context17.t0;
1939
+ _context18.prev = 22;
1940
+ _context18.t0 = _context18["catch"](0);
1941
+ throw _context18.t0;
1889
1942
  case 25:
1890
1943
  case "end":
1891
- return _context17.stop();
1944
+ return _context18.stop();
1892
1945
  }
1893
- }, _callee17, this, [[0, 22]]);
1946
+ }, _callee18, this, [[0, 22]]);
1894
1947
  }));
1895
1948
  function restoreOrder() {
1896
1949
  return _restoreOrder.apply(this, arguments);
@@ -1904,22 +1957,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1904
1957
  }, {
1905
1958
  key: "clearOrderCartLines",
1906
1959
  value: (function () {
1907
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1960
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1908
1961
  var tempOrder;
1909
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1910
- while (1) switch (_context18.prev = _context18.next) {
1962
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1963
+ while (1) switch (_context19.prev = _context19.next) {
1911
1964
  case 0:
1912
- _context18.prev = 0;
1965
+ _context19.prev = 0;
1913
1966
  if (this.store.order) {
1914
- _context18.next = 3;
1967
+ _context19.next = 3;
1915
1968
  break;
1916
1969
  }
1917
1970
  throw new Error('order 模块未初始化');
1918
1971
  case 3:
1919
- _context18.next = 5;
1972
+ _context19.next = 5;
1920
1973
  return this.store.order.clearOrderCartLines();
1921
1974
  case 5:
1922
- tempOrder = _context18.sent;
1975
+ tempOrder = _context19.sent;
1923
1976
  if (this.currentSalesDetail) {
1924
1977
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1925
1978
  products: [],
@@ -1929,29 +1982,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1929
1982
  discount_list: []
1930
1983
  });
1931
1984
  }
1932
- _context18.next = 9;
1985
+ _context19.next = 9;
1933
1986
  return this.effectsEmit('onTempOrderReplaced', {
1934
1987
  tempOrder: tempOrder
1935
1988
  });
1936
1989
  case 9:
1937
1990
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1938
- _context18.next = 13;
1991
+ _context19.next = 13;
1939
1992
  break;
1940
1993
  }
1941
1994
  this.store.order.persistTempOrder();
1942
- _context18.next = 13;
1995
+ _context19.next = 13;
1943
1996
  return this.store.order.saveDraft();
1944
1997
  case 13:
1945
- return _context18.abrupt("return", tempOrder);
1998
+ return _context19.abrupt("return", tempOrder);
1946
1999
  case 16:
1947
- _context18.prev = 16;
1948
- _context18.t0 = _context18["catch"](0);
1949
- throw _context18.t0;
2000
+ _context19.prev = 16;
2001
+ _context19.t0 = _context19["catch"](0);
2002
+ throw _context19.t0;
1950
2003
  case 19:
1951
2004
  case "end":
1952
- return _context18.stop();
2005
+ return _context19.stop();
1953
2006
  }
1954
- }, _callee18, this, [[0, 16]]);
2007
+ }, _callee19, this, [[0, 16]]);
1955
2008
  }));
1956
2009
  function clearOrderCartLines() {
1957
2010
  return _clearOrderCartLines.apply(this, arguments);
@@ -1968,32 +2021,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1968
2021
  }, {
1969
2022
  key: "getSummary",
1970
2023
  value: function () {
1971
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2024
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1972
2025
  var summary;
1973
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1974
- while (1) switch (_context19.prev = _context19.next) {
2026
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2027
+ while (1) switch (_context20.prev = _context20.next) {
1975
2028
  case 0:
1976
- _context19.prev = 0;
2029
+ _context20.prev = 0;
1977
2030
  if (this.store.order) {
1978
- _context19.next = 3;
2031
+ _context20.next = 3;
1979
2032
  break;
1980
2033
  }
1981
2034
  throw new Error('order 模块未初始化');
1982
2035
  case 3:
1983
- _context19.next = 5;
2036
+ _context20.next = 5;
1984
2037
  return this.store.order.getOrderSummary();
1985
2038
  case 5:
1986
- summary = _context19.sent;
1987
- return _context19.abrupt("return", summary);
2039
+ summary = _context20.sent;
2040
+ return _context20.abrupt("return", summary);
1988
2041
  case 9:
1989
- _context19.prev = 9;
1990
- _context19.t0 = _context19["catch"](0);
1991
- throw _context19.t0;
2042
+ _context20.prev = 9;
2043
+ _context20.t0 = _context20["catch"](0);
2044
+ throw _context20.t0;
1992
2045
  case 12:
1993
2046
  case "end":
1994
- return _context19.stop();
2047
+ return _context20.stop();
1995
2048
  }
1996
- }, _callee19, this, [[0, 9]]);
2049
+ }, _callee20, this, [[0, 9]]);
1997
2050
  }));
1998
2051
  function getSummary() {
1999
2052
  return _getSummary.apply(this, arguments);
@@ -2110,14 +2163,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2110
2163
  }, {
2111
2164
  key: "loadDiscountConfig",
2112
2165
  value: function () {
2113
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2166
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2114
2167
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
2115
2168
  var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator2, _step2, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
2116
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2117
- while (1) switch (_context20.prev = _context20.next) {
2169
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2170
+ while (1) switch (_context21.prev = _context21.next) {
2118
2171
  case 0:
2119
2172
  if (this.store.order) {
2120
- _context20.next = 2;
2173
+ _context21.next = 2;
2121
2174
  break;
2122
2175
  }
2123
2176
  throw new Error('order 模块未初始化');
@@ -2137,18 +2190,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2137
2190
  discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
2138
2191
  preparedDiscountList = [];
2139
2192
  if (!(customerId && customerId !== 1)) {
2140
- _context20.next = 25;
2193
+ _context21.next = 25;
2141
2194
  break;
2142
2195
  }
2143
2196
  if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
2144
- _context20.next = 19;
2197
+ _context21.next = 19;
2145
2198
  break;
2146
2199
  }
2147
2200
  preparedDiscountList = originalDiscountList;
2148
- _context20.next = 25;
2201
+ _context21.next = 25;
2149
2202
  break;
2150
2203
  case 19:
2151
- _context20.next = 21;
2204
+ _context21.next = 21;
2152
2205
  return this.store.order.loadDiscountConfig({
2153
2206
  customerId: customerId,
2154
2207
  action: discountAction,
@@ -2156,16 +2209,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2156
2209
  apply: false
2157
2210
  });
2158
2211
  case 21:
2159
- preparedDiscountList = _context20.sent;
2212
+ preparedDiscountList = _context21.sent;
2160
2213
  this.discountConfigCacheKey = discountConfigCacheKey;
2161
- _context20.next = 25;
2214
+ _context21.next = 25;
2162
2215
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2163
2216
  case 25:
2164
2217
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
2165
- _context20.next = 27;
2218
+ _context21.next = 27;
2166
2219
  break;
2167
2220
  }
2168
- return _context20.abrupt("return", {
2221
+ return _context21.abrupt("return", {
2169
2222
  productList: tempOrder.products || [],
2170
2223
  discountList: currentDiscountList,
2171
2224
  availableWalletIds: this.getAvailableWalletIds()
@@ -2173,7 +2226,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2173
2226
  case 27:
2174
2227
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
2175
2228
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2176
- _context20.next = 31;
2229
+ _context21.next = 31;
2177
2230
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2178
2231
  case 31:
2179
2232
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
@@ -2183,17 +2236,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2183
2236
  nextDiscountList: nextDiscountList
2184
2237
  });
2185
2238
  if (!shouldSkipAutoApplyFetchedDiscounts) {
2186
- _context20.next = 40;
2239
+ _context21.next = 40;
2187
2240
  break;
2188
2241
  }
2189
- _context20.next = 35;
2242
+ _context21.next = 35;
2190
2243
  return this.store.order.recalculateSummary({
2191
2244
  createIfMissing: true
2192
2245
  });
2193
2246
  case 35:
2194
- _summary = _context20.sent;
2247
+ _summary = _context21.sent;
2195
2248
  this.store.order.persistTempOrder();
2196
- _context20.next = 39;
2249
+ _context21.next = 39;
2197
2250
  return this.effectsEmit('onDiscountApplied', {
2198
2251
  productList: tempOrder.products || [],
2199
2252
  discountList: nextDiscountList,
@@ -2201,14 +2254,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2201
2254
  tempOrder: tempOrder
2202
2255
  });
2203
2256
  case 39:
2204
- return _context20.abrupt("return", {
2257
+ return _context21.abrupt("return", {
2205
2258
  productList: tempOrder.products || [],
2206
2259
  discountList: nextDiscountList,
2207
2260
  availableWalletIds: this.getAvailableWalletIds()
2208
2261
  });
2209
2262
  case 40:
2210
2263
  if (!rulesModule) {
2211
- _context20.next = 77;
2264
+ _context21.next = 77;
2212
2265
  break;
2213
2266
  }
2214
2267
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
@@ -2229,21 +2282,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2229
2282
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2230
2283
  }
2231
2284
  _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
2232
- _context20.prev = 46;
2285
+ _context21.prev = 46;
2233
2286
  _iterator2.s();
2234
2287
  case 48:
2235
2288
  if ((_step2 = _iterator2.n()).done) {
2236
- _context20.next = 63;
2289
+ _context21.next = 63;
2237
2290
  break;
2238
2291
  }
2239
2292
  product = _step2.value;
2240
2293
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2241
2294
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
2242
2295
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2243
- _context20.next = 54;
2296
+ _context21.next = 54;
2244
2297
  break;
2245
2298
  }
2246
- return _context20.abrupt("continue", 61);
2299
+ return _context21.abrupt("continue", 61);
2247
2300
  case 54:
2248
2301
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2249
2302
  return sum + Number(pd.amount || 0);
@@ -2261,41 +2314,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2261
2314
  bundle: product.product_bundle
2262
2315
  });
2263
2316
  case 61:
2264
- _context20.next = 48;
2317
+ _context21.next = 48;
2265
2318
  break;
2266
2319
  case 63:
2267
- _context20.next = 68;
2320
+ _context21.next = 68;
2268
2321
  break;
2269
2322
  case 65:
2270
- _context20.prev = 65;
2271
- _context20.t0 = _context20["catch"](46);
2272
- _iterator2.e(_context20.t0);
2323
+ _context21.prev = 65;
2324
+ _context21.t0 = _context21["catch"](46);
2325
+ _iterator2.e(_context21.t0);
2273
2326
  case 68:
2274
- _context20.prev = 68;
2327
+ _context21.prev = 68;
2275
2328
  _iterator2.f();
2276
- return _context20.finish(68);
2329
+ return _context21.finish(68);
2277
2330
  case 71:
2278
2331
  if (!result.discountList) {
2279
- _context20.next = 77;
2332
+ _context21.next = 77;
2280
2333
  break;
2281
2334
  }
2282
2335
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2283
2336
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2284
- _context20.next = 76;
2337
+ _context21.next = 76;
2285
2338
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2286
2339
  case 76:
2287
2340
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2288
2341
  return discount.isSelected;
2289
2342
  });
2290
2343
  case 77:
2291
- _context20.next = 79;
2344
+ _context21.next = 79;
2292
2345
  return this.store.order.recalculateSummary({
2293
2346
  createIfMissing: true
2294
2347
  });
2295
2348
  case 79:
2296
- summary = _context20.sent;
2349
+ summary = _context21.sent;
2297
2350
  this.store.order.persistTempOrder();
2298
- _context20.next = 83;
2351
+ _context21.next = 83;
2299
2352
  return this.effectsEmit('onDiscountApplied', {
2300
2353
  productList: tempOrder.products || [],
2301
2354
  discountList: nextDiscountList,
@@ -2303,18 +2356,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2303
2356
  tempOrder: tempOrder
2304
2357
  });
2305
2358
  case 83:
2306
- return _context20.abrupt("return", {
2359
+ return _context21.abrupt("return", {
2307
2360
  productList: tempOrder.products || [],
2308
2361
  discountList: nextDiscountList,
2309
2362
  availableWalletIds: this.getAvailableWalletIds()
2310
2363
  });
2311
2364
  case 84:
2312
2365
  case "end":
2313
- return _context20.stop();
2366
+ return _context21.stop();
2314
2367
  }
2315
- }, _callee20, this, [[46, 65, 68, 71]]);
2368
+ }, _callee21, this, [[46, 65, 68, 71]]);
2316
2369
  }));
2317
- function loadDiscountConfig(_x14) {
2370
+ function loadDiscountConfig(_x16) {
2318
2371
  return _loadDiscountConfig.apply(this, arguments);
2319
2372
  }
2320
2373
  return loadDiscountConfig;
@@ -2329,14 +2382,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2329
2382
  }, {
2330
2383
  key: "bestDiscount",
2331
2384
  value: function () {
2332
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
2385
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cb) {
2333
2386
  var _discountModule$getOr2, _discountModule$getDi3;
2334
2387
  var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2335
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2336
- while (1) switch (_context21.prev = _context21.next) {
2388
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2389
+ while (1) switch (_context22.prev = _context22.next) {
2337
2390
  case 0:
2338
2391
  if (this.store.order) {
2339
- _context21.next = 2;
2392
+ _context22.next = 2;
2340
2393
  break;
2341
2394
  }
2342
2395
  throw new Error('order 模块未初始化');
@@ -2352,11 +2405,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2352
2405
  productList: tempOrder.products || [],
2353
2406
  discountList: nextDiscountList
2354
2407
  };
2355
- _context21.next = 12;
2408
+ _context22.next = 12;
2356
2409
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2357
2410
  case 12:
2358
2411
  if (!rulesModule) {
2359
- _context21.next = 24;
2412
+ _context22.next = 24;
2360
2413
  break;
2361
2414
  }
2362
2415
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -2374,12 +2427,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2374
2427
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2375
2428
  }
2376
2429
  if (!result.discountList) {
2377
- _context21.next = 24;
2430
+ _context22.next = 24;
2378
2431
  break;
2379
2432
  }
2380
2433
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2381
2434
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2382
- _context21.next = 22;
2435
+ _context22.next = 22;
2383
2436
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2384
2437
  case 22:
2385
2438
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
@@ -2390,13 +2443,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2390
2443
  discountList: nextDiscountList
2391
2444
  };
2392
2445
  case 24:
2393
- _context21.next = 26;
2446
+ _context22.next = 26;
2394
2447
  return this.store.order.recalculateSummary({
2395
2448
  createIfMissing: true
2396
2449
  });
2397
2450
  case 26:
2398
2451
  this.store.order.persistTempOrder();
2399
- _context21.next = 29;
2452
+ _context22.next = 29;
2400
2453
  return this.effectsEmit('onDiscountApplied', {
2401
2454
  productList: tempOrder.products || [],
2402
2455
  discountList: nextDiscountList,
@@ -2405,14 +2458,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2405
2458
  });
2406
2459
  case 29:
2407
2460
  cb === null || cb === void 0 || cb(result);
2408
- return _context21.abrupt("return", result);
2461
+ return _context22.abrupt("return", result);
2409
2462
  case 31:
2410
2463
  case "end":
2411
- return _context21.stop();
2464
+ return _context22.stop();
2412
2465
  }
2413
- }, _callee21, this);
2466
+ }, _callee22, this);
2414
2467
  }));
2415
- function bestDiscount(_x15) {
2468
+ function bestDiscount(_x17) {
2416
2469
  return _bestDiscount.apply(this, arguments);
2417
2470
  }
2418
2471
  return bestDiscount;
@@ -2441,41 +2494,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2441
2494
  }, {
2442
2495
  key: "replaceDiscountStoreLists",
2443
2496
  value: (function () {
2444
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2497
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2445
2498
  var _store2;
2446
2499
  var discountModule;
2447
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2448
- while (1) switch (_context22.prev = _context22.next) {
2500
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2501
+ while (1) switch (_context23.prev = _context23.next) {
2449
2502
  case 0:
2450
2503
  if (this.store.order) {
2451
- _context22.next = 2;
2504
+ _context23.next = 2;
2452
2505
  break;
2453
2506
  }
2454
2507
  throw new Error('order 模块未初始化');
2455
2508
  case 2:
2456
2509
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2457
2510
  if (discountModule) {
2458
- _context22.next = 5;
2511
+ _context23.next = 5;
2459
2512
  break;
2460
2513
  }
2461
- return _context22.abrupt("return");
2514
+ return _context23.abrupt("return");
2462
2515
  case 5:
2463
2516
  if (!params.originalDiscountList) {
2464
- _context22.next = 8;
2517
+ _context23.next = 8;
2465
2518
  break;
2466
2519
  }
2467
- _context22.next = 8;
2520
+ _context23.next = 8;
2468
2521
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
2469
2522
  case 8:
2470
- _context22.next = 10;
2523
+ _context23.next = 10;
2471
2524
  return discountModule.setDiscountList(params.discountList);
2472
2525
  case 10:
2473
2526
  case "end":
2474
- return _context22.stop();
2527
+ return _context23.stop();
2475
2528
  }
2476
- }, _callee22, this);
2529
+ }, _callee23, this);
2477
2530
  }));
2478
- function replaceDiscountStoreLists(_x16) {
2531
+ function replaceDiscountStoreLists(_x18) {
2479
2532
  return _replaceDiscountStoreLists.apply(this, arguments);
2480
2533
  }
2481
2534
  return replaceDiscountStoreLists;
@@ -2483,34 +2536,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2483
2536
  }, {
2484
2537
  key: "scanPromotionCode",
2485
2538
  value: function () {
2486
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
2539
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(code, customerId) {
2487
2540
  var raw, tempOrder;
2488
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2489
- while (1) switch (_context23.prev = _context23.next) {
2541
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2542
+ while (1) switch (_context24.prev = _context24.next) {
2490
2543
  case 0:
2491
- _context23.prev = 0;
2544
+ _context24.prev = 0;
2492
2545
  if (this.store.order) {
2493
- _context23.next = 3;
2546
+ _context24.next = 3;
2494
2547
  break;
2495
2548
  }
2496
2549
  throw new Error('order 模块未初始化');
2497
2550
  case 3:
2498
- _context23.next = 5;
2551
+ _context24.next = 5;
2499
2552
  return this.store.order.scanCode(code, customerId);
2500
2553
  case 5:
2501
- raw = _context23.sent;
2554
+ raw = _context24.sent;
2502
2555
  if (!raw.isAvailable) {
2503
- _context23.next = 13;
2556
+ _context24.next = 13;
2504
2557
  break;
2505
2558
  }
2506
- _context23.next = 9;
2559
+ _context24.next = 9;
2507
2560
  return this.store.order.recalculateSummary({
2508
2561
  createIfMissing: true
2509
2562
  });
2510
2563
  case 9:
2511
2564
  this.store.order.persistTempOrder();
2512
2565
  tempOrder = this.store.order.ensureTempOrder();
2513
- _context23.next = 13;
2566
+ _context24.next = 13;
2514
2567
  return this.effectsEmit('onDiscountApplied', {
2515
2568
  productList: tempOrder.products || [],
2516
2569
  discountList: this.store.order.getDiscountList(),
@@ -2518,7 +2571,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2518
2571
  tempOrder: tempOrder
2519
2572
  });
2520
2573
  case 13:
2521
- return _context23.abrupt("return", _objectSpread(_objectSpread({
2574
+ return _context24.abrupt("return", _objectSpread(_objectSpread({
2522
2575
  isAvailable: raw.isAvailable
2523
2576
  }, raw.isAccepted !== undefined ? {
2524
2577
  isAccepted: raw.isAccepted
@@ -2528,16 +2581,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2528
2581
  scannedDiscountList: raw.scannedDiscountList
2529
2582
  }));
2530
2583
  case 16:
2531
- _context23.prev = 16;
2532
- _context23.t0 = _context23["catch"](0);
2533
- throw _context23.t0;
2584
+ _context24.prev = 16;
2585
+ _context24.t0 = _context24["catch"](0);
2586
+ throw _context24.t0;
2534
2587
  case 19:
2535
2588
  case "end":
2536
- return _context23.stop();
2589
+ return _context24.stop();
2537
2590
  }
2538
- }, _callee23, this, [[0, 16]]);
2591
+ }, _callee24, this, [[0, 16]]);
2539
2592
  }));
2540
- function scanPromotionCode(_x17, _x18) {
2593
+ function scanPromotionCode(_x19, _x20) {
2541
2594
  return _scanPromotionCode.apply(this, arguments);
2542
2595
  }
2543
2596
  return scanPromotionCode;
@@ -2545,14 +2598,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2545
2598
  }, {
2546
2599
  key: "setDiscountSelected",
2547
2600
  value: function () {
2548
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2601
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2549
2602
  var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator3, _step3, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator4, _step4, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2550
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2551
- while (1) switch (_context24.prev = _context24.next) {
2603
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2604
+ while (1) switch (_context25.prev = _context25.next) {
2552
2605
  case 0:
2553
- _context24.prev = 0;
2606
+ _context25.prev = 0;
2554
2607
  if (this.store.order) {
2555
- _context24.next = 3;
2608
+ _context25.next = 3;
2556
2609
  break;
2557
2610
  }
2558
2611
  throw new Error('order 模块未初始化');
@@ -2570,7 +2623,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2570
2623
  discountModule = orderStore.discount;
2571
2624
  rulesModule = orderStore.rules;
2572
2625
  nextDiscountList = updated;
2573
- _context24.next = 13;
2626
+ _context25.next = 13;
2574
2627
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2575
2628
  case 13:
2576
2629
  if (rulesModule) {
@@ -2633,21 +2686,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2633
2686
  });
2634
2687
  };
2635
2688
  _iterator4 = _createForOfIteratorHelper(tempOrder.products);
2636
- _context24.prev = 17;
2689
+ _context25.prev = 17;
2637
2690
  _iterator4.s();
2638
2691
  case 19:
2639
2692
  if ((_step4 = _iterator4.n()).done) {
2640
- _context24.next = 36;
2693
+ _context25.next = 36;
2641
2694
  break;
2642
2695
  }
2643
2696
  product = _step4.value;
2644
2697
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
2645
2698
  runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
2646
2699
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2647
- _context24.next = 25;
2700
+ _context25.next = 25;
2648
2701
  break;
2649
2702
  }
2650
- return _context24.abrupt("continue", 34);
2703
+ return _context25.abrupt("continue", 34);
2651
2704
  case 25:
2652
2705
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2653
2706
  if (Array.isArray(product.product_bundle)) {
@@ -2683,28 +2736,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2683
2736
  bundle: product.product_bundle
2684
2737
  });
2685
2738
  case 34:
2686
- _context24.next = 19;
2739
+ _context25.next = 19;
2687
2740
  break;
2688
2741
  case 36:
2689
- _context24.next = 41;
2742
+ _context25.next = 41;
2690
2743
  break;
2691
2744
  case 38:
2692
- _context24.prev = 38;
2693
- _context24.t0 = _context24["catch"](17);
2694
- _iterator4.e(_context24.t0);
2745
+ _context25.prev = 38;
2746
+ _context25.t0 = _context25["catch"](17);
2747
+ _iterator4.e(_context25.t0);
2695
2748
  case 41:
2696
- _context24.prev = 41;
2749
+ _context25.prev = 41;
2697
2750
  _iterator4.f();
2698
- return _context24.finish(41);
2751
+ return _context25.finish(41);
2699
2752
  case 44:
2700
2753
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2701
- _context24.next = 47;
2754
+ _context25.next = 47;
2702
2755
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2703
2756
  case 47:
2704
2757
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2705
2758
  return d.isSelected;
2706
2759
  });
2707
- _context24.next = 50;
2760
+ _context25.next = 50;
2708
2761
  return this.store.order.recalculateSummary({
2709
2762
  createIfMissing: true
2710
2763
  });
@@ -2716,19 +2769,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2716
2769
  selectedDiscountList: tempOrder.discount_list,
2717
2770
  tempOrder: tempOrder
2718
2771
  });
2719
- _context24.next = 57;
2772
+ _context25.next = 57;
2720
2773
  break;
2721
2774
  case 54:
2722
- _context24.prev = 54;
2723
- _context24.t1 = _context24["catch"](0);
2724
- throw _context24.t1;
2775
+ _context25.prev = 54;
2776
+ _context25.t1 = _context25["catch"](0);
2777
+ throw _context25.t1;
2725
2778
  case 57:
2726
2779
  case "end":
2727
- return _context24.stop();
2780
+ return _context25.stop();
2728
2781
  }
2729
- }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2782
+ }, _callee25, this, [[0, 54], [17, 38, 41, 44]]);
2730
2783
  }));
2731
- function setDiscountSelected(_x19) {
2784
+ function setDiscountSelected(_x21) {
2732
2785
  return _setDiscountSelected.apply(this, arguments);
2733
2786
  }
2734
2787
  return setDiscountSelected;
@@ -2736,23 +2789,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2736
2789
  }, {
2737
2790
  key: "applyDiscountCalculationResult",
2738
2791
  value: function () {
2739
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
2792
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(result) {
2740
2793
  var tempOrder, orderStore, discountModule;
2741
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2742
- while (1) switch (_context25.prev = _context25.next) {
2794
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2795
+ while (1) switch (_context26.prev = _context26.next) {
2743
2796
  case 0:
2744
- _context25.prev = 0;
2797
+ _context26.prev = 0;
2745
2798
  if (this.store.order) {
2746
- _context25.next = 3;
2799
+ _context26.next = 3;
2747
2800
  break;
2748
2801
  }
2749
2802
  throw new Error('order 模块未初始化');
2750
2803
  case 3:
2751
2804
  if (result) {
2752
- _context25.next = 5;
2805
+ _context26.next = 5;
2753
2806
  break;
2754
2807
  }
2755
- return _context25.abrupt("return");
2808
+ return _context26.abrupt("return");
2756
2809
  case 5:
2757
2810
  tempOrder = this.store.order.ensureTempOrder();
2758
2811
  orderStore = this.store.order.store || {};
@@ -2761,24 +2814,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2761
2814
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2762
2815
  }
2763
2816
  if (!result.discountList) {
2764
- _context25.next = 14;
2817
+ _context26.next = 14;
2765
2818
  break;
2766
2819
  }
2767
2820
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
2768
- _context25.next = 13;
2821
+ _context26.next = 13;
2769
2822
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
2770
2823
  case 13:
2771
2824
  tempOrder.discount_list = result.discountList.filter(function (discount) {
2772
2825
  return discount.isSelected;
2773
2826
  });
2774
2827
  case 14:
2775
- _context25.next = 16;
2828
+ _context26.next = 16;
2776
2829
  return this.store.order.recalculateSummary({
2777
2830
  createIfMissing: true
2778
2831
  });
2779
2832
  case 16:
2780
2833
  this.store.order.persistTempOrder();
2781
- _context25.next = 19;
2834
+ _context26.next = 19;
2782
2835
  return this.effectsEmit('onDiscountApplied', {
2783
2836
  productList: tempOrder.products || [],
2784
2837
  discountList: result.discountList || [],
@@ -2786,19 +2839,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2786
2839
  tempOrder: tempOrder
2787
2840
  });
2788
2841
  case 19:
2789
- _context25.next = 24;
2842
+ _context26.next = 24;
2790
2843
  break;
2791
2844
  case 21:
2792
- _context25.prev = 21;
2793
- _context25.t0 = _context25["catch"](0);
2794
- throw _context25.t0;
2845
+ _context26.prev = 21;
2846
+ _context26.t0 = _context26["catch"](0);
2847
+ throw _context26.t0;
2795
2848
  case 24:
2796
2849
  case "end":
2797
- return _context25.stop();
2850
+ return _context26.stop();
2798
2851
  }
2799
- }, _callee25, this, [[0, 21]]);
2852
+ }, _callee26, this, [[0, 21]]);
2800
2853
  }));
2801
- function applyDiscountCalculationResult(_x20) {
2854
+ function applyDiscountCalculationResult(_x22) {
2802
2855
  return _applyDiscountCalculationResult.apply(this, arguments);
2803
2856
  }
2804
2857
  return applyDiscountCalculationResult;
@@ -2806,18 +2859,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2806
2859
  }, {
2807
2860
  key: "submitScanOrder",
2808
2861
  value: function () {
2809
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2810
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2811
- while (1) switch (_context26.prev = _context26.next) {
2862
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2863
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2864
+ while (1) switch (_context27.prev = _context27.next) {
2812
2865
  case 0:
2813
- return _context26.abrupt("return", this.submitSalesOrder(params));
2866
+ return _context27.abrupt("return", this.submitSalesOrder(params));
2814
2867
  case 1:
2815
2868
  case "end":
2816
- return _context26.stop();
2869
+ return _context27.stop();
2817
2870
  }
2818
- }, _callee26, this);
2871
+ }, _callee27, this);
2819
2872
  }));
2820
- function submitScanOrder(_x21) {
2873
+ function submitScanOrder(_x23) {
2821
2874
  return _submitScanOrder.apply(this, arguments);
2822
2875
  }
2823
2876
  return submitScanOrder;
@@ -2831,20 +2884,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2831
2884
  }, {
2832
2885
  key: "submitSalesOrder",
2833
2886
  value: (function () {
2834
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2835
- var _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14;
2836
- var inferredPaymentStatus, submitParams;
2837
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2838
- while (1) switch (_context27.prev = _context27.next) {
2887
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2888
+ var _params$smallTicketDa, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14;
2889
+ var inferredPaymentStatus, smallTicketDataFlag, submitParams;
2890
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2891
+ while (1) switch (_context28.prev = _context28.next) {
2839
2892
  case 0:
2840
2893
  if (this.store.order) {
2841
- _context27.next = 2;
2894
+ _context28.next = 2;
2842
2895
  break;
2843
2896
  }
2844
2897
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2845
2898
  case 2:
2846
2899
  // this.store.order.persistTempOrder();
2847
2900
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2901
+ smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
2848
2902
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2849
2903
  cacheId: this.cacheId,
2850
2904
  platform: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.platform,
@@ -2856,21 +2910,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2856
2910
  payments: params.payments
2857
2911
  } : {}), inferredPaymentStatus !== undefined ? {
2858
2912
  paymentStatus: inferredPaymentStatus
2859
- } : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
2860
- smallTicketDataFlag: params.smallTicketDataFlag
2913
+ } : {}), smallTicketDataFlag !== undefined ? {
2914
+ smallTicketDataFlag: smallTicketDataFlag
2861
2915
  } : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
2862
2916
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
2863
2917
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2864
2918
  enhancePayload: params.enhancePayload
2865
2919
  } : {});
2866
- return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
2867
- case 5:
2920
+ return _context28.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
2921
+ case 6:
2868
2922
  case "end":
2869
- return _context27.stop();
2923
+ return _context28.stop();
2870
2924
  }
2871
- }, _callee27, this);
2925
+ }, _callee28, this);
2872
2926
  }));
2873
- function submitSalesOrder(_x22) {
2927
+ function submitSalesOrder(_x24) {
2874
2928
  return _submitSalesOrder.apply(this, arguments);
2875
2929
  }
2876
2930
  return submitSalesOrder;
@@ -2878,18 +2932,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2878
2932
  }, {
2879
2933
  key: "saveSalesOrderDraft",
2880
2934
  value: function () {
2881
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2935
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2882
2936
  var _params$platform, _this$otherParams15, _this$otherParams16, _this$otherParams17, _params$channel, _params$type, _this$otherParams18;
2883
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2884
- while (1) switch (_context28.prev = _context28.next) {
2937
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2938
+ while (1) switch (_context29.prev = _context29.next) {
2885
2939
  case 0:
2886
2940
  if (this.store.order) {
2887
- _context28.next = 2;
2941
+ _context29.next = 2;
2888
2942
  break;
2889
2943
  }
2890
2944
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2891
2945
  case 2:
2892
- return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2946
+ return _context29.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2893
2947
  cacheId: this.cacheId,
2894
2948
  platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
2895
2949
  businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
@@ -2900,11 +2954,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2900
2954
  } : {})));
2901
2955
  case 3:
2902
2956
  case "end":
2903
- return _context28.stop();
2957
+ return _context29.stop();
2904
2958
  }
2905
- }, _callee28, this);
2959
+ }, _callee29, this);
2906
2960
  }));
2907
- function saveSalesOrderDraft(_x23) {
2961
+ function saveSalesOrderDraft(_x25) {
2908
2962
  return _saveSalesOrderDraft.apply(this, arguments);
2909
2963
  }
2910
2964
  return saveSalesOrderDraft;
@@ -2912,59 +2966,79 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2912
2966
  }, {
2913
2967
  key: "submitTempOrderAsync",
2914
2968
  value: function () {
2915
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2916
- var _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
2917
- var inferredPaymentStatus, submitParams;
2918
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2919
- while (1) switch (_context29.prev = _context29.next) {
2969
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2970
+ var _params$smallTicketDa2, _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
2971
+ var inferredPaymentStatus, smallTicketDataFlag, submitParams;
2972
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2973
+ while (1) switch (_context30.prev = _context30.next) {
2920
2974
  case 0:
2921
2975
  if (this.store.order) {
2922
- _context29.next = 2;
2976
+ _context30.next = 2;
2923
2977
  break;
2924
2978
  }
2925
2979
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2926
2980
  case 2:
2927
2981
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2982
+ smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
2928
2983
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2929
2984
  cacheId: this.cacheId,
2930
2985
  platform: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform,
2931
2986
  businessCode: ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode) || ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.business_code),
2932
2987
  channel: this.getSubmitOrderSalesChannel(),
2933
- type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
2988
+ type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type,
2989
+ request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
2934
2990
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2935
2991
  payments: params.payments
2936
2992
  } : {}), inferredPaymentStatus !== undefined ? {
2937
2993
  paymentStatus: inferredPaymentStatus
2938
- } : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
2939
- smallTicketDataFlag: params.smallTicketDataFlag
2994
+ } : {}), smallTicketDataFlag !== undefined ? {
2995
+ smallTicketDataFlag: smallTicketDataFlag
2940
2996
  } : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
2941
2997
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
2942
2998
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2943
2999
  enhancePayload: params.enhancePayload
2944
3000
  } : {});
2945
- return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2946
- case 5:
3001
+ return _context30.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3002
+ case 6:
2947
3003
  case "end":
2948
- return _context29.stop();
3004
+ return _context30.stop();
2949
3005
  }
2950
- }, _callee29, this);
3006
+ }, _callee30, this);
2951
3007
  }));
2952
- function submitTempOrderAsync(_x24) {
3008
+ function submitTempOrderAsync(_x26) {
2953
3009
  return _submitTempOrderAsync.apply(this, arguments);
2954
3010
  }
2955
3011
  return submitTempOrderAsync;
2956
3012
  }()
3013
+ /**
3014
+ * 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
3015
+ * otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
3016
+ */
3017
+ }, {
3018
+ key: "shouldUseCheckoutSyncTask",
3019
+ value: function shouldUseCheckoutSyncTask() {
3020
+ var _this$otherParams23;
3021
+ var configured = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.checkoutSyncTaskEnabled;
3022
+ return typeof configured === 'boolean' ? configured : true;
3023
+ }
3024
+
3025
+ /** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
3026
+ }, {
3027
+ key: "getDefaultCheckoutSmallTicketDataFlag",
3028
+ value: function getDefaultCheckoutSmallTicketDataFlag() {
3029
+ return undefined;
3030
+ }
2957
3031
  }, {
2958
3032
  key: "printLocalOrderReceipt",
2959
3033
  value: function () {
2960
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2961
- var _this$otherParams23, _this$otherParams24, _this$otherParams25, _this$otherParams26;
3034
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(lookup) {
3035
+ var _this$otherParams24, _this$otherParams25, _this$otherParams26, _this$otherParams27;
2962
3036
  var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2963
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2964
- while (1) switch (_context30.prev = _context30.next) {
3037
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3038
+ while (1) switch (_context31.prev = _context31.next) {
2965
3039
  case 0:
2966
3040
  if (this.store.order) {
2967
- _context30.next = 2;
3041
+ _context31.next = 2;
2968
3042
  break;
2969
3043
  }
2970
3044
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2976,10 +3050,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2976
3050
  external_sale_number: lookup
2977
3051
  };
2978
3052
  context = {
2979
- platform: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform,
2980
- businessCode: ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) || ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.business_code),
3053
+ platform: (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform,
3054
+ businessCode: ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.businessCode) || ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.business_code),
2981
3055
  channel: this.getSubmitOrderSalesChannel(),
2982
- type: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.type
3056
+ type: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.type
2983
3057
  };
2984
3058
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2985
3059
  lookup_order_from_db: 1,
@@ -2995,28 +3069,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2995
3069
  channel: context.channel,
2996
3070
  type: context.type
2997
3071
  });
2998
- _context30.next = 8;
3072
+ _context31.next = 8;
2999
3073
  return this.request.post('/local/print-order', payload, {
3000
3074
  osServer: true,
3001
3075
  customToast: function customToast() {}
3002
3076
  });
3003
3077
  case 8:
3004
- response = _context30.sent;
3078
+ response = _context31.sent;
3005
3079
  if (hasLookup) {
3006
- _context30.next = 12;
3080
+ _context31.next = 12;
3007
3081
  break;
3008
3082
  }
3009
- _context30.next = 12;
3083
+ _context31.next = 12;
3010
3084
  return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
3011
3085
  case 12:
3012
- return _context30.abrupt("return", response);
3086
+ return _context31.abrupt("return", response);
3013
3087
  case 13:
3014
3088
  case "end":
3015
- return _context30.stop();
3089
+ return _context31.stop();
3016
3090
  }
3017
- }, _callee30, this);
3091
+ }, _callee31, this);
3018
3092
  }));
3019
- function printLocalOrderReceipt(_x25) {
3093
+ function printLocalOrderReceipt(_x27) {
3020
3094
  return _printLocalOrderReceipt.apply(this, arguments);
3021
3095
  }
3022
3096
  return printLocalOrderReceipt;
@@ -3037,35 +3111,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3037
3111
  }, {
3038
3112
  key: "syncPaymentsToOrder",
3039
3113
  value: function () {
3040
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3041
- var _ref32, _params$businessCode, _this$otherParams27, _this$otherParams28, _params$channel2;
3114
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3115
+ var _ref32, _params$businessCode, _this$otherParams28, _this$otherParams29, _params$channel2;
3042
3116
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
3043
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3044
- while (1) switch (_context31.prev = _context31.next) {
3117
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3118
+ while (1) switch (_context32.prev = _context32.next) {
3045
3119
  case 0:
3046
3120
  if (this.store.order) {
3047
- _context31.next = 2;
3121
+ _context32.next = 2;
3048
3122
  break;
3049
3123
  }
3050
3124
  throw new Error('order 模块未初始化');
3051
3125
  case 2:
3052
- businessCode = (_ref32 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.businessCode) !== null && _ref32 !== void 0 ? _ref32 : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.business_code;
3126
+ businessCode = (_ref32 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) !== null && _ref32 !== void 0 ? _ref32 : (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.business_code;
3053
3127
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
3054
- syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
3128
+ syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
3129
+ checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
3130
+ }, businessCode !== undefined ? {
3055
3131
  businessCode: businessCode
3056
3132
  } : {}), channel !== undefined ? {
3057
3133
  channel: channel
3058
3134
  } : {});
3059
3135
  syncState = this.store.order.getOrderSyncState();
3060
3136
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
3061
- _context31.next = 9;
3137
+ _context32.next = 9;
3062
3138
  break;
3063
3139
  }
3064
3140
  this.queueLatestAutoPaymentSync();
3065
- return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3141
+ return _context32.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3066
3142
  case 9:
3067
3143
  payments = params.payments || [];
3068
- _context31.next = 12;
3144
+ _context32.next = 12;
3069
3145
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
3070
3146
  payments: payments,
3071
3147
  params: syncParams,
@@ -3073,11 +3149,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3073
3149
  orderSnapshot: this.store.order.getOrderSnapshot()
3074
3150
  });
3075
3151
  case 12:
3076
- _context31.prev = 12;
3077
- _context31.next = 15;
3152
+ _context32.prev = 12;
3153
+ _context32.next = 15;
3078
3154
  return this.store.order.syncPaymentsToOrder(syncParams);
3079
3155
  case 15:
3080
- syncResult = _context31.sent;
3156
+ syncResult = _context32.sent;
3081
3157
  latestPayments = this.store.order.getOrderPayments();
3082
3158
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
3083
3159
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -3095,25 +3171,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3095
3171
  depositAmount: syncResult.depositAmount,
3096
3172
  orderExpectedAmount: syncResult.orderExpectedAmount
3097
3173
  };
3098
- _context31.next = 22;
3174
+ _context32.next = 22;
3099
3175
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
3100
3176
  case 22:
3101
3177
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
3102
- _context31.next = 25;
3178
+ _context32.next = 25;
3103
3179
  break;
3104
3180
  }
3105
- _context31.next = 25;
3181
+ _context32.next = 25;
3106
3182
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
3107
3183
  case 25:
3108
3184
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3109
- return _context31.abrupt("return", syncResult);
3185
+ return _context32.abrupt("return", syncResult);
3110
3186
  case 29:
3111
- _context31.prev = 29;
3112
- _context31.t0 = _context31["catch"](12);
3113
- _context31.next = 33;
3187
+ _context32.prev = 29;
3188
+ _context32.t0 = _context32["catch"](12);
3189
+ _context32.next = 33;
3114
3190
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
3115
3191
  ok: false,
3116
- error: _context31.t0,
3192
+ error: _context32.t0,
3117
3193
  payments: this.store.order.getOrderPayments(),
3118
3194
  params: syncParams,
3119
3195
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -3121,14 +3197,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3121
3197
  });
3122
3198
  case 33:
3123
3199
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3124
- throw _context31.t0;
3200
+ throw _context32.t0;
3125
3201
  case 35:
3126
3202
  case "end":
3127
- return _context31.stop();
3203
+ return _context32.stop();
3128
3204
  }
3129
- }, _callee31, this, [[12, 29]]);
3205
+ }, _callee32, this, [[12, 29]]);
3130
3206
  }));
3131
- function syncPaymentsToOrder(_x26) {
3207
+ function syncPaymentsToOrder(_x28) {
3132
3208
  return _syncPaymentsToOrder.apply(this, arguments);
3133
3209
  }
3134
3210
  return syncPaymentsToOrder;
@@ -3177,46 +3253,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3177
3253
  }, {
3178
3254
  key: "flushQueuedAutoPaymentSync",
3179
3255
  value: function () {
3180
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
3256
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
3181
3257
  var payments;
3182
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3183
- while (1) switch (_context32.prev = _context32.next) {
3258
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3259
+ while (1) switch (_context33.prev = _context33.next) {
3184
3260
  case 0:
3185
3261
  if (this.store.order) {
3186
- _context32.next = 2;
3262
+ _context33.next = 2;
3187
3263
  break;
3188
3264
  }
3189
- return _context32.abrupt("return");
3265
+ return _context33.abrupt("return");
3190
3266
  case 2:
3191
3267
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3192
- _context32.next = 4;
3268
+ _context33.next = 4;
3193
3269
  break;
3194
3270
  }
3195
- return _context32.abrupt("return");
3271
+ return _context33.abrupt("return");
3196
3272
  case 4:
3197
3273
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3198
- _context32.next = 7;
3274
+ _context33.next = 7;
3199
3275
  break;
3200
3276
  }
3201
3277
  this.scheduleQueuedAutoPaymentSyncFlush();
3202
- return _context32.abrupt("return");
3278
+ return _context33.abrupt("return");
3203
3279
  case 7:
3204
3280
  this.autoPaymentSyncFlushing = true;
3205
- _context32.prev = 8;
3281
+ _context33.prev = 8;
3206
3282
  case 9:
3207
3283
  if (!this.queuedAutoPaymentSync) {
3208
- _context32.next = 18;
3284
+ _context33.next = 18;
3209
3285
  break;
3210
3286
  }
3211
3287
  this.queuedAutoPaymentSync = false;
3212
3288
  payments = this.store.order.getOrderPayments();
3213
3289
  if (payments.length) {
3214
- _context32.next = 14;
3290
+ _context33.next = 14;
3215
3291
  break;
3216
3292
  }
3217
- return _context32.abrupt("continue", 9);
3293
+ return _context33.abrupt("continue", 9);
3218
3294
  case 14:
3219
- _context32.next = 16;
3295
+ _context33.next = 16;
3220
3296
  return this.syncPaymentsToOrder({
3221
3297
  payments: payments,
3222
3298
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3224,29 +3300,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3224
3300
  smallTicketDataFlag: 1
3225
3301
  });
3226
3302
  case 16:
3227
- _context32.next = 9;
3303
+ _context33.next = 9;
3228
3304
  break;
3229
3305
  case 18:
3230
- _context32.next = 23;
3306
+ _context33.next = 23;
3231
3307
  break;
3232
3308
  case 20:
3233
- _context32.prev = 20;
3234
- _context32.t0 = _context32["catch"](8);
3309
+ _context33.prev = 20;
3310
+ _context33.t0 = _context33["catch"](8);
3235
3311
  this.logError('queued auto sync payments failed', {
3236
- error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
3312
+ error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
3237
3313
  });
3238
3314
  case 23:
3239
- _context32.prev = 23;
3315
+ _context33.prev = 23;
3240
3316
  this.autoPaymentSyncFlushing = false;
3241
3317
  if (this.queuedAutoPaymentSync) {
3242
3318
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3243
3319
  }
3244
- return _context32.finish(23);
3320
+ return _context33.finish(23);
3245
3321
  case 27:
3246
3322
  case "end":
3247
- return _context32.stop();
3323
+ return _context33.stop();
3248
3324
  }
3249
- }, _callee32, this, [[8, 20, 23, 27]]);
3325
+ }, _callee33, this, [[8, 20, 23, 27]]);
3250
3326
  }));
3251
3327
  function flushQueuedAutoPaymentSync() {
3252
3328
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -3270,35 +3346,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3270
3346
  }, {
3271
3347
  key: "addOrderPaymentAsync",
3272
3348
  value: (function () {
3273
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3349
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(payment) {
3274
3350
  var paymentRecord, hasPaymentNumber, devicePrefix;
3275
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3276
- while (1) switch (_context33.prev = _context33.next) {
3351
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3352
+ while (1) switch (_context34.prev = _context34.next) {
3277
3353
  case 0:
3278
3354
  paymentRecord = payment;
3279
3355
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3280
3356
  if (!hasPaymentNumber) {
3281
- _context33.next = 6;
3357
+ _context34.next = 6;
3282
3358
  break;
3283
3359
  }
3284
- _context33.t0 = 'LOCAL';
3285
- _context33.next = 9;
3360
+ _context34.t0 = 'LOCAL';
3361
+ _context34.next = 9;
3286
3362
  break;
3287
3363
  case 6:
3288
- _context33.next = 8;
3364
+ _context34.next = 8;
3289
3365
  return this.getPaymentNumberDevicePrefixAsync();
3290
3366
  case 8:
3291
- _context33.t0 = _context33.sent;
3367
+ _context34.t0 = _context34.sent;
3292
3368
  case 9:
3293
- devicePrefix = _context33.t0;
3294
- return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3369
+ devicePrefix = _context34.t0;
3370
+ return _context34.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3295
3371
  case 11:
3296
3372
  case "end":
3297
- return _context33.stop();
3373
+ return _context34.stop();
3298
3374
  }
3299
- }, _callee33, this);
3375
+ }, _callee34, this);
3300
3376
  }));
3301
- function addOrderPaymentAsync(_x27) {
3377
+ function addOrderPaymentAsync(_x29) {
3302
3378
  return _addOrderPaymentAsync.apply(this, arguments);
3303
3379
  }
3304
3380
  return addOrderPaymentAsync;
@@ -3306,7 +3382,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3306
3382
  }, {
3307
3383
  key: "addOrderPaymentWithDevicePrefix",
3308
3384
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3309
- var _this$otherParams29,
3385
+ var _this$otherParams30,
3310
3386
  _paymentRecord$paymen,
3311
3387
  _paymentRecord$create,
3312
3388
  _ref33,
@@ -3322,7 +3398,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3322
3398
  return this.store.order.getOrderPayments();
3323
3399
  }
3324
3400
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3325
- var shopWalletPassId = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.shop_wallet_pass_id;
3401
+ var shopWalletPassId = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.shop_wallet_pass_id;
3326
3402
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3327
3403
  metadata.shop_wallet_pass_id = shopWalletPassId;
3328
3404
  }
@@ -3367,7 +3443,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3367
3443
  }, {
3368
3444
  key: "updateOrderPayment",
3369
3445
  value: (function () {
3370
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3446
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paymentIdentity, updates) {
3371
3447
  var _result$payment, _result$payment2;
3372
3448
  var options,
3373
3449
  matchMode,
@@ -3384,13 +3460,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3384
3460
  shouldSubmit,
3385
3461
  syncResult,
3386
3462
  _options$smallTicketD2,
3387
- _args34 = arguments;
3388
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3389
- while (1) switch (_context34.prev = _context34.next) {
3463
+ _args35 = arguments;
3464
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3465
+ while (1) switch (_context35.prev = _context35.next) {
3390
3466
  case 0:
3391
- options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3467
+ options = _args35.length > 2 && _args35[2] !== undefined ? _args35[2] : {};
3392
3468
  if (this.store.order) {
3393
- _context34.next = 3;
3469
+ _context35.next = 3;
3394
3470
  break;
3395
3471
  }
3396
3472
  throw new Error('order 模块未初始化');
@@ -3399,15 +3475,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3399
3475
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3400
3476
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3401
3477
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3402
- _context34.next = 13;
3478
+ _context35.next = 13;
3403
3479
  break;
3404
3480
  }
3405
3481
  currentPayments = this.store.order.getOrderPayments();
3406
3482
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3407
- _context34.next = 12;
3483
+ _context35.next = 12;
3408
3484
  break;
3409
3485
  }
3410
- _context34.next = 11;
3486
+ _context35.next = 11;
3411
3487
  return this.syncPaymentsToOrder({
3412
3488
  payments: currentPayments,
3413
3489
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -3415,9 +3491,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3415
3491
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3416
3492
  });
3417
3493
  case 11:
3418
- _syncResult = _context34.sent;
3494
+ _syncResult = _context35.sent;
3419
3495
  case 12:
3420
- return _context34.abrupt("return", _objectSpread({
3496
+ return _context35.abrupt("return", _objectSpread({
3421
3497
  updated: false,
3422
3498
  payment: previousPayment,
3423
3499
  payments: currentPayments,
@@ -3426,44 +3502,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3426
3502
  syncResult: _syncResult
3427
3503
  } : {}));
3428
3504
  case 13:
3429
- _context34.next = 15;
3505
+ _context35.next = 15;
3430
3506
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3431
3507
  matchBy: matchMode
3432
3508
  });
3433
3509
  case 15:
3434
- result = _context34.sent;
3510
+ result = _context35.sent;
3435
3511
  if (!(options.persistDraft !== false)) {
3436
- _context34.next = 29;
3512
+ _context35.next = 29;
3437
3513
  break;
3438
3514
  }
3439
- _context34.prev = 17;
3440
- _context34.next = 20;
3515
+ _context35.prev = 17;
3516
+ _context35.next = 20;
3441
3517
  return this.saveSalesOrderDraft();
3442
3518
  case 20:
3443
- draftResult = _context34.sent;
3444
- _context34.next = 29;
3519
+ draftResult = _context35.sent;
3520
+ _context35.next = 29;
3445
3521
  break;
3446
3522
  case 23:
3447
- _context34.prev = 23;
3448
- _context34.t0 = _context34["catch"](17);
3449
- draftError = _context34.t0;
3523
+ _context35.prev = 23;
3524
+ _context35.t0 = _context35["catch"](17);
3525
+ draftError = _context35.t0;
3450
3526
  this.logError('updateOrderPayment: 保存支付草稿失败', {
3451
3527
  paymentIdentity: paymentIdentity,
3452
- error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3528
+ error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
3453
3529
  });
3454
3530
  if (options.submitWhenPaid) {
3455
- _context34.next = 29;
3531
+ _context35.next = 29;
3456
3532
  break;
3457
3533
  }
3458
- throw _context34.t0;
3534
+ throw _context35.t0;
3459
3535
  case 29:
3460
3536
  becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
3461
3537
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3462
3538
  if (!shouldSubmit) {
3463
- _context34.next = 35;
3539
+ _context35.next = 35;
3464
3540
  break;
3465
3541
  }
3466
- _context34.next = 34;
3542
+ _context35.next = 34;
3467
3543
  return this.syncPaymentsToOrder({
3468
3544
  payments: result.payments,
3469
3545
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -3471,9 +3547,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3471
3547
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3472
3548
  });
3473
3549
  case 34:
3474
- syncResult = _context34.sent;
3550
+ syncResult = _context35.sent;
3475
3551
  case 35:
3476
- return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3552
+ return _context35.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3477
3553
  draftResult: draftResult
3478
3554
  } : {}), draftError !== undefined ? {
3479
3555
  draftError: draftError
@@ -3482,11 +3558,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3482
3558
  } : {}));
3483
3559
  case 36:
3484
3560
  case "end":
3485
- return _context34.stop();
3561
+ return _context35.stop();
3486
3562
  }
3487
- }, _callee34, this, [[17, 23]]);
3563
+ }, _callee35, this, [[17, 23]]);
3488
3564
  }));
3489
- function updateOrderPayment(_x28, _x29) {
3565
+ function updateOrderPayment(_x30, _x31) {
3490
3566
  return _updateOrderPayment.apply(this, arguments);
3491
3567
  }
3492
3568
  return updateOrderPayment;
@@ -3508,24 +3584,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3508
3584
  }, {
3509
3585
  key: "updateVoucherOrderPaymentsAsync",
3510
3586
  value: function () {
3511
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3512
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3513
- while (1) switch (_context35.prev = _context35.next) {
3587
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payments, options) {
3588
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3589
+ while (1) switch (_context36.prev = _context36.next) {
3514
3590
  case 0:
3515
3591
  if (this.store.order) {
3516
- _context35.next = 2;
3592
+ _context36.next = 2;
3517
3593
  break;
3518
3594
  }
3519
3595
  throw new Error('order 模块未初始化');
3520
3596
  case 2:
3521
- return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3597
+ return _context36.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3522
3598
  case 3:
3523
3599
  case "end":
3524
- return _context35.stop();
3600
+ return _context36.stop();
3525
3601
  }
3526
- }, _callee35, this);
3602
+ }, _callee36, this);
3527
3603
  }));
3528
- function updateVoucherOrderPaymentsAsync(_x30, _x31) {
3604
+ function updateVoucherOrderPaymentsAsync(_x32, _x33) {
3529
3605
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3530
3606
  }
3531
3607
  return updateVoucherOrderPaymentsAsync;
@@ -3636,20 +3712,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3636
3712
  }, {
3637
3713
  key: "initWalletData",
3638
3714
  value: function () {
3639
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3715
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
3640
3716
  var _snapshot$identity;
3641
3717
  var snapshot, walletBusinessData, result;
3642
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3643
- while (1) switch (_context36.prev = _context36.next) {
3718
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3719
+ while (1) switch (_context37.prev = _context37.next) {
3644
3720
  case 0:
3645
3721
  if (this.store.order) {
3646
- _context36.next = 2;
3722
+ _context37.next = 2;
3647
3723
  break;
3648
3724
  }
3649
3725
  throw new Error('order 模块未初始化');
3650
3726
  case 2:
3651
3727
  if (this.store.payment) {
3652
- _context36.next = 4;
3728
+ _context37.next = 4;
3653
3729
  break;
3654
3730
  }
3655
3731
  throw new Error('payment 模块未初始化');
@@ -3657,10 +3733,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3657
3733
  snapshot = this.store.order.getOrderSnapshot();
3658
3734
  walletBusinessData = this.buildWalletInitBusinessData(params);
3659
3735
  if (walletBusinessData) {
3660
- _context36.next = 8;
3736
+ _context37.next = 8;
3661
3737
  break;
3662
3738
  }
3663
- return _context36.abrupt("return", {
3739
+ return _context37.abrupt("return", {
3664
3740
  walletRecommendList: [],
3665
3741
  userIdentificationCodes: [],
3666
3742
  transformList: [],
@@ -3668,11 +3744,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3668
3744
  products: []
3669
3745
  });
3670
3746
  case 8:
3671
- _context36.next = 10;
3747
+ _context37.next = 10;
3672
3748
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3673
3749
  case 10:
3674
- result = _context36.sent;
3675
- _context36.next = 13;
3750
+ result = _context37.sent;
3751
+ _context37.next = 13;
3676
3752
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3677
3753
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
3678
3754
  customerId: walletBusinessData.customer_id,
@@ -3684,14 +3760,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3684
3760
  timestamp: Date.now()
3685
3761
  });
3686
3762
  case 13:
3687
- return _context36.abrupt("return", result);
3763
+ return _context37.abrupt("return", result);
3688
3764
  case 14:
3689
3765
  case "end":
3690
- return _context36.stop();
3766
+ return _context37.stop();
3691
3767
  }
3692
- }, _callee36, this);
3768
+ }, _callee37, this);
3693
3769
  }));
3694
- function initWalletData(_x32) {
3770
+ function initWalletData(_x34) {
3695
3771
  return _initWalletData.apply(this, arguments);
3696
3772
  }
3697
3773
  return initWalletData;
@@ -3742,23 +3818,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3742
3818
  }, {
3743
3819
  key: "publishWalletAssetsState",
3744
3820
  value: function () {
3745
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
3746
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3747
- while (1) switch (_context37.prev = _context37.next) {
3821
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
3822
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3823
+ while (1) switch (_context38.prev = _context38.next) {
3748
3824
  case 0:
3749
- _context37.next = 2;
3825
+ _context38.next = 2;
3750
3826
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
3751
3827
  state: state
3752
3828
  });
3753
3829
  case 2:
3754
- return _context37.abrupt("return", state);
3830
+ return _context38.abrupt("return", state);
3755
3831
  case 3:
3756
3832
  case "end":
3757
- return _context37.stop();
3833
+ return _context38.stop();
3758
3834
  }
3759
- }, _callee37, this);
3835
+ }, _callee38, this);
3760
3836
  }));
3761
- function publishWalletAssetsState(_x33) {
3837
+ function publishWalletAssetsState(_x35) {
3762
3838
  return _publishWalletAssetsState.apply(this, arguments);
3763
3839
  }
3764
3840
  return publishWalletAssetsState;
@@ -3766,26 +3842,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3766
3842
  }, {
3767
3843
  key: "syncSelectedWalletAssets",
3768
3844
  value: function () {
3769
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
3845
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(state) {
3770
3846
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
3771
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3772
- while (1) switch (_context38.prev = _context38.next) {
3847
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3848
+ while (1) switch (_context39.prev = _context39.next) {
3773
3849
  case 0:
3774
3850
  if (!(!this.store.order || !this.store.payment)) {
3775
- _context38.next = 2;
3851
+ _context39.next = 2;
3776
3852
  break;
3777
3853
  }
3778
3854
  throw new Error('订单或支付模块未初始化');
3779
3855
  case 2:
3780
3856
  paymentMethods = this.getPaymentMethods();
3781
3857
  if (!(!paymentMethods.length && state.selectedItems.length)) {
3782
- _context38.next = 7;
3858
+ _context39.next = 7;
3783
3859
  break;
3784
3860
  }
3785
- _context38.next = 6;
3861
+ _context39.next = 6;
3786
3862
  return this.getPaymentMethodsAsync();
3787
3863
  case 6:
3788
- paymentMethods = _context38.sent;
3864
+ paymentMethods = _context39.sent;
3789
3865
  case 7:
3790
3866
  methodByCode = new Map(paymentMethods.map(function (method) {
3791
3867
  return [String(method.code || '').toUpperCase(), method];
@@ -3827,19 +3903,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3827
3903
  payments = this.updateVoucherOrderPayments(voucherPayments, {
3828
3904
  status: 'payment_pending'
3829
3905
  });
3830
- _context38.next = 14;
3906
+ _context39.next = 14;
3831
3907
  return this.store.order.recalculateSummary({
3832
3908
  createIfMissing: true
3833
3909
  });
3834
3910
  case 14:
3835
- return _context38.abrupt("return", payments);
3911
+ return _context39.abrupt("return", payments);
3836
3912
  case 15:
3837
3913
  case "end":
3838
- return _context38.stop();
3914
+ return _context39.stop();
3839
3915
  }
3840
- }, _callee38, this);
3916
+ }, _callee39, this);
3841
3917
  }));
3842
- function syncSelectedWalletAssets(_x34) {
3918
+ function syncSelectedWalletAssets(_x36) {
3843
3919
  return _syncSelectedWalletAssets.apply(this, arguments);
3844
3920
  }
3845
3921
  return syncSelectedWalletAssets;
@@ -3873,29 +3949,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3873
3949
  }, {
3874
3950
  key: "importWalletAssetsSnapshot",
3875
3951
  value: (function () {
3876
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
3952
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(snapshot) {
3877
3953
  var state;
3878
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3879
- while (1) switch (_context39.prev = _context39.next) {
3954
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3955
+ while (1) switch (_context40.prev = _context40.next) {
3880
3956
  case 0:
3881
3957
  if (this.store.payment) {
3882
- _context39.next = 2;
3958
+ _context40.next = 2;
3883
3959
  break;
3884
3960
  }
3885
3961
  throw new Error('payment 模块未初始化');
3886
3962
  case 2:
3887
3963
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
3888
- _context39.next = 5;
3964
+ _context40.next = 5;
3889
3965
  return this.syncSelectedWalletAssets(state);
3890
3966
  case 5:
3891
- return _context39.abrupt("return", this.publishWalletAssetsState(state));
3967
+ return _context40.abrupt("return", this.publishWalletAssetsState(state));
3892
3968
  case 6:
3893
3969
  case "end":
3894
- return _context39.stop();
3970
+ return _context40.stop();
3895
3971
  }
3896
- }, _callee39, this);
3972
+ }, _callee40, this);
3897
3973
  }));
3898
- function importWalletAssetsSnapshot(_x35) {
3974
+ function importWalletAssetsSnapshot(_x37) {
3899
3975
  return _importWalletAssetsSnapshot.apply(this, arguments);
3900
3976
  }
3901
3977
  return importWalletAssetsSnapshot;
@@ -3907,20 +3983,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3907
3983
  }, {
3908
3984
  key: "refreshWalletAssets",
3909
3985
  value: (function () {
3910
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3986
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3911
3987
  var _previousState$custom, _businessData$custome;
3912
3988
  var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
3913
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3914
- while (1) switch (_context40.prev = _context40.next) {
3989
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3990
+ while (1) switch (_context41.prev = _context41.next) {
3915
3991
  case 0:
3916
3992
  if (this.store.order) {
3917
- _context40.next = 2;
3993
+ _context41.next = 2;
3918
3994
  break;
3919
3995
  }
3920
3996
  throw new Error('order 模块未初始化');
3921
3997
  case 2:
3922
3998
  if (this.store.payment) {
3923
- _context40.next = 4;
3999
+ _context41.next = 4;
3924
4000
  break;
3925
4001
  }
3926
4002
  throw new Error('payment 模块未初始化');
@@ -3929,7 +4005,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3929
4005
  wallet = this.store.payment.wallet;
3930
4006
  businessData = this.buildWalletInitBusinessData(params);
3931
4007
  if (businessData) {
3932
- _context40.next = 12;
4008
+ _context41.next = 12;
3933
4009
  break;
3934
4010
  }
3935
4011
  wallet.clearAllCache();
@@ -3937,53 +4013,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3937
4013
  this.updateVoucherOrderPayments([], {
3938
4014
  status: 'payment_pending'
3939
4015
  });
3940
- return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
4016
+ return _context41.abrupt("return", this.publishWalletAssetsState(emptyState));
3941
4017
  case 12:
3942
4018
  previousState = wallet.getWalletAssetsState();
3943
4019
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
3944
4020
  customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
3945
4021
  if (!customerChanged) {
3946
- _context40.next = 20;
4022
+ _context41.next = 20;
3947
4023
  break;
3948
4024
  }
3949
4025
  clearedState = wallet.clearWalletAssetSelection();
3950
4026
  this.updateVoucherOrderPayments([], {
3951
4027
  status: 'payment_pending'
3952
4028
  });
3953
- _context40.next = 20;
4029
+ _context41.next = 20;
3954
4030
  return this.publishWalletAssetsState(clearedState);
3955
4031
  case 20:
3956
4032
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
3957
4033
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
3958
4034
  });
3959
- _context40.next = 23;
4035
+ _context41.next = 23;
3960
4036
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
3961
4037
  case 23:
3962
- _context40.next = 25;
4038
+ _context41.next = 25;
3963
4039
  return refreshTask;
3964
4040
  case 25:
3965
- state = _context40.sent;
4041
+ state = _context41.sent;
3966
4042
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
3967
- _context40.next = 28;
4043
+ _context41.next = 28;
3968
4044
  break;
3969
4045
  }
3970
- return _context40.abrupt("return", wallet.getWalletAssetsState());
4046
+ return _context41.abrupt("return", wallet.getWalletAssetsState());
3971
4047
  case 28:
3972
4048
  if (state.status !== 'error') {
3973
4049
  committed = this.getCommittedWalletAssets();
3974
4050
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3975
4051
  }
3976
- _context40.next = 31;
4052
+ _context41.next = 31;
3977
4053
  return this.syncSelectedWalletAssets(state);
3978
4054
  case 31:
3979
- return _context40.abrupt("return", this.publishWalletAssetsState(state));
4055
+ return _context41.abrupt("return", this.publishWalletAssetsState(state));
3980
4056
  case 32:
3981
4057
  case "end":
3982
- return _context40.stop();
4058
+ return _context41.stop();
3983
4059
  }
3984
- }, _callee40, this);
4060
+ }, _callee41, this);
3985
4061
  }));
3986
- function refreshWalletAssets(_x36) {
4062
+ function refreshWalletAssets(_x38) {
3987
4063
  return _refreshWalletAssets.apply(this, arguments);
3988
4064
  }
3989
4065
  return refreshWalletAssets;
@@ -3991,13 +4067,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3991
4067
  }, {
3992
4068
  key: "selectWalletAsset",
3993
4069
  value: (function () {
3994
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4070
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3995
4071
  var state;
3996
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3997
- while (1) switch (_context41.prev = _context41.next) {
4072
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4073
+ while (1) switch (_context42.prev = _context42.next) {
3998
4074
  case 0:
3999
4075
  if (this.store.payment) {
4000
- _context41.next = 2;
4076
+ _context42.next = 2;
4001
4077
  break;
4002
4078
  }
4003
4079
  throw new Error('payment 模块未初始化');
@@ -4006,17 +4082,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4006
4082
  selected: params.selected,
4007
4083
  source: params.source
4008
4084
  });
4009
- _context41.next = 5;
4085
+ _context42.next = 5;
4010
4086
  return this.syncSelectedWalletAssets(state);
4011
4087
  case 5:
4012
- return _context41.abrupt("return", this.publishWalletAssetsState(state));
4088
+ return _context42.abrupt("return", this.publishWalletAssetsState(state));
4013
4089
  case 6:
4014
4090
  case "end":
4015
- return _context41.stop();
4091
+ return _context42.stop();
4016
4092
  }
4017
- }, _callee41, this);
4093
+ }, _callee42, this);
4018
4094
  }));
4019
- function selectWalletAsset(_x37) {
4095
+ function selectWalletAsset(_x39) {
4020
4096
  return _selectWalletAsset.apply(this, arguments);
4021
4097
  }
4022
4098
  return selectWalletAsset;
@@ -4024,29 +4100,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4024
4100
  }, {
4025
4101
  key: "updateWalletAssetAmount",
4026
4102
  value: (function () {
4027
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4103
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4028
4104
  var state;
4029
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4030
- while (1) switch (_context42.prev = _context42.next) {
4105
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4106
+ while (1) switch (_context43.prev = _context43.next) {
4031
4107
  case 0:
4032
4108
  if (this.store.payment) {
4033
- _context42.next = 2;
4109
+ _context43.next = 2;
4034
4110
  break;
4035
4111
  }
4036
4112
  throw new Error('payment 模块未初始化');
4037
4113
  case 2:
4038
4114
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
4039
- _context42.next = 5;
4115
+ _context43.next = 5;
4040
4116
  return this.syncSelectedWalletAssets(state);
4041
4117
  case 5:
4042
- return _context42.abrupt("return", this.publishWalletAssetsState(state));
4118
+ return _context43.abrupt("return", this.publishWalletAssetsState(state));
4043
4119
  case 6:
4044
4120
  case "end":
4045
- return _context42.stop();
4121
+ return _context43.stop();
4046
4122
  }
4047
- }, _callee42, this);
4123
+ }, _callee43, this);
4048
4124
  }));
4049
- function updateWalletAssetAmount(_x38) {
4125
+ function updateWalletAssetAmount(_x40) {
4050
4126
  return _updateWalletAssetAmount.apply(this, arguments);
4051
4127
  }
4052
4128
  return updateWalletAssetAmount;
@@ -4054,13 +4130,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4054
4130
  }, {
4055
4131
  key: "scanWalletAsset",
4056
4132
  value: (function () {
4057
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(code) {
4133
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(code) {
4058
4134
  var wallet, businessData, result;
4059
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4060
- while (1) switch (_context43.prev = _context43.next) {
4135
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4136
+ while (1) switch (_context44.prev = _context44.next) {
4061
4137
  case 0:
4062
4138
  if (this.store.payment) {
4063
- _context43.next = 2;
4139
+ _context44.next = 2;
4064
4140
  break;
4065
4141
  }
4066
4142
  throw new Error('payment 模块未初始化');
@@ -4070,28 +4146,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4070
4146
  if (businessData) {
4071
4147
  wallet.generateWalletParams(businessData);
4072
4148
  }
4073
- _context43.next = 7;
4149
+ _context44.next = 7;
4074
4150
  return wallet.scanWalletAssetAsync(code);
4075
4151
  case 7:
4076
- result = _context43.sent;
4152
+ result = _context44.sent;
4077
4153
  if (!(result.type === 'normalCode')) {
4078
- _context43.next = 13;
4154
+ _context44.next = 13;
4079
4155
  break;
4080
4156
  }
4081
- _context43.next = 11;
4157
+ _context44.next = 11;
4082
4158
  return this.syncSelectedWalletAssets(result.state);
4083
4159
  case 11:
4084
- _context43.next = 13;
4160
+ _context44.next = 13;
4085
4161
  return this.publishWalletAssetsState(result.state);
4086
4162
  case 13:
4087
- return _context43.abrupt("return", result);
4163
+ return _context44.abrupt("return", result);
4088
4164
  case 14:
4089
4165
  case "end":
4090
- return _context43.stop();
4166
+ return _context44.stop();
4091
4167
  }
4092
- }, _callee43, this);
4168
+ }, _callee44, this);
4093
4169
  }));
4094
- function scanWalletAsset(_x39) {
4170
+ function scanWalletAsset(_x41) {
4095
4171
  return _scanWalletAsset.apply(this, arguments);
4096
4172
  }
4097
4173
  return scanWalletAsset;
@@ -4099,27 +4175,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4099
4175
  }, {
4100
4176
  key: "clearWalletAssetSelection",
4101
4177
  value: (function () {
4102
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4178
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4103
4179
  var state;
4104
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4105
- while (1) switch (_context44.prev = _context44.next) {
4180
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4181
+ while (1) switch (_context45.prev = _context45.next) {
4106
4182
  case 0:
4107
4183
  if (this.store.payment) {
4108
- _context44.next = 2;
4184
+ _context45.next = 2;
4109
4185
  break;
4110
4186
  }
4111
4187
  throw new Error('payment 模块未初始化');
4112
4188
  case 2:
4113
4189
  state = this.store.payment.wallet.clearWalletAssetSelection();
4114
- _context44.next = 5;
4190
+ _context45.next = 5;
4115
4191
  return this.syncSelectedWalletAssets(state);
4116
4192
  case 5:
4117
- return _context44.abrupt("return", this.publishWalletAssetsState(state));
4193
+ return _context45.abrupt("return", this.publishWalletAssetsState(state));
4118
4194
  case 6:
4119
4195
  case "end":
4120
- return _context44.stop();
4196
+ return _context45.stop();
4121
4197
  }
4122
- }, _callee44, this);
4198
+ }, _callee45, this);
4123
4199
  }));
4124
4200
  function clearWalletAssetSelection() {
4125
4201
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -4149,35 +4225,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4149
4225
  }, {
4150
4226
  key: "getPaymentMethodsAsync",
4151
4227
  value: (function () {
4152
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4228
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4153
4229
  var response, paymentMethods;
4154
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4155
- while (1) switch (_context45.prev = _context45.next) {
4230
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4231
+ while (1) switch (_context46.prev = _context46.next) {
4156
4232
  case 0:
4157
- _context45.prev = 0;
4158
- _context45.next = 3;
4233
+ _context46.prev = 0;
4234
+ _context46.next = 3;
4159
4235
  return this.request.get('/pay/custom-payment/all', {
4160
4236
  filterPaymentMethods: true
4161
4237
  }, {
4162
4238
  osServer: true
4163
4239
  });
4164
4240
  case 3:
4165
- response = _context45.sent;
4241
+ response = _context46.sent;
4166
4242
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
4167
4243
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
4168
- return _context45.abrupt("return", this.getPaymentMethods());
4244
+ return _context46.abrupt("return", this.getPaymentMethods());
4169
4245
  case 9:
4170
- _context45.prev = 9;
4171
- _context45.t0 = _context45["catch"](0);
4246
+ _context46.prev = 9;
4247
+ _context46.t0 = _context46["catch"](0);
4172
4248
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
4173
- error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4249
+ error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4174
4250
  });
4175
- return _context45.abrupt("return", this.getPaymentMethods());
4251
+ return _context46.abrupt("return", this.getPaymentMethods());
4176
4252
  case 13:
4177
4253
  case "end":
4178
- return _context45.stop();
4254
+ return _context46.stop();
4179
4255
  }
4180
- }, _callee45, this, [[0, 9]]);
4256
+ }, _callee46, this, [[0, 9]]);
4181
4257
  }));
4182
4258
  function getPaymentMethodsAsync() {
4183
4259
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -4220,14 +4296,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4220
4296
  }, {
4221
4297
  key: "getCashPaymentConfig",
4222
4298
  value: (function () {
4223
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4224
- var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams30;
4299
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4300
+ var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams31;
4225
4301
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4226
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4227
- while (1) switch (_context46.prev = _context46.next) {
4302
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4303
+ while (1) switch (_context47.prev = _context47.next) {
4228
4304
  case 0:
4229
4305
  if (this.store.payment) {
4230
- _context46.next = 2;
4306
+ _context47.next = 2;
4231
4307
  break;
4232
4308
  }
4233
4309
  throw new Error('payment 模块未初始化');
@@ -4235,21 +4311,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4235
4311
  paymentMethods = this.getPaymentMethods();
4236
4312
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4237
4313
  if (paymentMethod) {
4238
- _context46.next = 9;
4314
+ _context47.next = 9;
4239
4315
  break;
4240
4316
  }
4241
- _context46.next = 7;
4317
+ _context47.next = 7;
4242
4318
  return this.getPaymentMethodsAsync();
4243
4319
  case 7:
4244
- paymentMethods = _context46.sent;
4320
+ paymentMethods = _context47.sent;
4245
4321
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4246
4322
  case 9:
4247
4323
  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);
4248
4324
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4249
4325
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4250
- currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.currency) || 'USD';
4326
+ 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$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.currency) || 'USD';
4251
4327
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4252
- return _context46.abrupt("return", {
4328
+ return _context47.abrupt("return", {
4253
4329
  available: Boolean(paymentMethod && amountDue > 0),
4254
4330
  paymentMethod: paymentMethod,
4255
4331
  amountDue: amountDue,
@@ -4257,9 +4333,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4257
4333
  });
4258
4334
  case 15:
4259
4335
  case "end":
4260
- return _context46.stop();
4336
+ return _context47.stop();
4261
4337
  }
4262
- }, _callee46, this);
4338
+ }, _callee47, this);
4263
4339
  }));
4264
4340
  function getCashPaymentConfig() {
4265
4341
  return _getCashPaymentConfig.apply(this, arguments);
@@ -4276,14 +4352,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4276
4352
  }, {
4277
4353
  key: "confirmWalletPayment",
4278
4354
  value: (function () {
4279
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4355
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4280
4356
  var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4281
4357
  var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4282
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4283
- while (1) switch (_context47.prev = _context47.next) {
4358
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4359
+ while (1) switch (_context48.prev = _context48.next) {
4284
4360
  case 0:
4285
4361
  if (this.store.order) {
4286
- _context47.next = 2;
4362
+ _context48.next = 2;
4287
4363
  break;
4288
4364
  }
4289
4365
  throw new Error('order 模块未初始化');
@@ -4291,7 +4367,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4291
4367
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4292
4368
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
4293
4369
  if (!pendingWalletAmount.lte(0)) {
4294
- _context47.next = 6;
4370
+ _context48.next = 6;
4295
4371
  break;
4296
4372
  }
4297
4373
  throw new Error('当前订单没有待确认的 Wallet 支付');
@@ -4299,74 +4375,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4299
4375
  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);
4300
4376
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4301
4377
  if (!effectiveAmountDue.gt(0.01)) {
4302
- _context47.next = 10;
4378
+ _context48.next = 10;
4303
4379
  break;
4304
4380
  }
4305
4381
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4306
4382
  case 10:
4307
4383
  beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4308
- _context47.prev = 11;
4309
- _context47.next = 14;
4384
+ _context48.prev = 11;
4385
+ _context48.next = 14;
4310
4386
  return this.submitSalesOrder({
4311
4387
  smallTicketDataFlag: 1,
4312
4388
  confirmPendingVoucherPayments: true
4313
4389
  });
4314
4390
  case 14:
4315
- submitResult = _context47.sent;
4391
+ submitResult = _context48.sent;
4316
4392
  if (!isRejectedSalesSubmitResult(submitResult)) {
4317
- _context47.next = 17;
4393
+ _context48.next = 17;
4318
4394
  break;
4319
4395
  }
4320
- throw new Error(getSalesSubmitErrorMessage(submitResult));
4396
+ throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
4321
4397
  case 17:
4322
- _context47.next = 27;
4398
+ _context48.next = 27;
4323
4399
  break;
4324
4400
  case 19:
4325
- _context47.prev = 19;
4326
- _context47.t0 = _context47["catch"](11);
4401
+ _context48.prev = 19;
4402
+ _context48.t0 = _context48["catch"](11);
4327
4403
  this.store.order.setOrderPayments(beforePayments);
4328
4404
  restoredTempOrder = this.store.order.getTempOrder();
4329
4405
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4330
4406
  restoredTempOrder.payment_status = beforePaymentStatus;
4331
4407
  this.store.order.persistTempOrder();
4332
4408
  }
4333
- _context47.next = 26;
4409
+ _context48.next = 26;
4334
4410
  return this.store.order.recalculateSummary({
4335
4411
  createIfMissing: true
4336
4412
  });
4337
4413
  case 26:
4338
- throw _context47.t0;
4414
+ throw _context48.t0;
4339
4415
  case 27:
4340
4416
  if (!this.store.payment) {
4341
- _context47.next = 38;
4417
+ _context48.next = 38;
4342
4418
  break;
4343
4419
  }
4344
- _context47.prev = 28;
4420
+ _context48.prev = 28;
4345
4421
  committed = this.getCommittedWalletAssets();
4346
4422
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4347
- _context47.next = 33;
4423
+ _context48.next = 33;
4348
4424
  return this.publishWalletAssetsState(walletState);
4349
4425
  case 33:
4350
- _context47.next = 38;
4426
+ _context48.next = 38;
4351
4427
  break;
4352
4428
  case 35:
4353
- _context47.prev = 35;
4354
- _context47.t1 = _context47["catch"](28);
4429
+ _context48.prev = 35;
4430
+ _context48.t1 = _context48["catch"](28);
4355
4431
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4356
- error: _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1)
4432
+ error: _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1)
4357
4433
  });
4358
4434
  case 38:
4359
4435
  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);
4360
- return _context47.abrupt("return", {
4436
+ return _context48.abrupt("return", {
4361
4437
  submitResult: submitResult,
4362
4438
  payments: this.store.order.getOrderPayments(),
4363
4439
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4364
4440
  });
4365
4441
  case 40:
4366
4442
  case "end":
4367
- return _context47.stop();
4443
+ return _context48.stop();
4368
4444
  }
4369
- }, _callee47, this, [[11, 19], [28, 35]]);
4445
+ }, _callee48, this, [[11, 19], [28, 35]]);
4370
4446
  }));
4371
4447
  function confirmWalletPayment() {
4372
4448
  return _confirmWalletPayment.apply(this, arguments);
@@ -4381,38 +4457,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4381
4457
  }, {
4382
4458
  key: "payCash",
4383
4459
  value: (function () {
4384
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4385
- var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams31, _this$window, _this$window$postMess;
4460
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4461
+ var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams32, _this$window, _this$window$postMess;
4386
4462
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4387
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4388
- while (1) switch (_context48.prev = _context48.next) {
4463
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4464
+ while (1) switch (_context49.prev = _context49.next) {
4389
4465
  case 0:
4390
4466
  if (this.store.order) {
4391
- _context48.next = 2;
4467
+ _context49.next = 2;
4392
4468
  break;
4393
4469
  }
4394
4470
  throw new Error('order 模块未初始化');
4395
4471
  case 2:
4396
4472
  amount = Number(params.amount || 0);
4397
4473
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4398
- _context48.next = 5;
4474
+ _context49.next = 5;
4399
4475
  break;
4400
4476
  }
4401
4477
  throw new Error('现金支付金额必须大于 0');
4402
4478
  case 5:
4403
- _context48.next = 7;
4479
+ _context49.next = 7;
4404
4480
  return this.getCashPaymentConfig();
4405
4481
  case 7:
4406
- config = _context48.sent;
4482
+ config = _context49.sent;
4407
4483
  paymentMethod = config.paymentMethod;
4408
4484
  if (paymentMethod) {
4409
- _context48.next = 11;
4485
+ _context49.next = 11;
4410
4486
  break;
4411
4487
  }
4412
4488
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
4413
4489
  case 11:
4414
4490
  if (!(config.amountDue <= 0)) {
4415
- _context48.next = 13;
4491
+ _context49.next = 13;
4416
4492
  break;
4417
4493
  }
4418
4494
  throw new Error('当前订单没有待支付金额');
@@ -4420,7 +4496,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4420
4496
  roundingAmount = Number(params.roundingAmount || 0);
4421
4497
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4422
4498
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4423
- _context48.next = 17;
4499
+ _context49.next = 17;
4424
4500
  break;
4425
4501
  }
4426
4502
  throw new Error('现金支付金额超过当前待支付金额');
@@ -4431,9 +4507,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4431
4507
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4432
4508
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4433
4509
  changeAmount = Number(params.changeAmount || 0);
4434
- shopWalletPassId = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.shop_wallet_pass_id;
4510
+ shopWalletPassId = (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.shop_wallet_pass_id;
4435
4511
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4436
- _context48.next = 26;
4512
+ _context49.next = 26;
4437
4513
  break;
4438
4514
  }
4439
4515
  throw new Error('顾客实收现金不能小于支付金额');
@@ -4468,8 +4544,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4468
4544
  var _item$metadata2;
4469
4545
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4470
4546
  });
4471
- _context48.prev = 29;
4472
- _context48.next = 32;
4547
+ _context49.prev = 29;
4548
+ _context49.next = 32;
4473
4549
  return this.syncPaymentsToOrder({
4474
4550
  payments: payments,
4475
4551
  submitWhenPaid: true,
@@ -4477,44 +4553,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4477
4553
  confirmPendingVoucherPayments: true
4478
4554
  });
4479
4555
  case 32:
4480
- syncResult = _context48.sent;
4556
+ syncResult = _context49.sent;
4557
+ if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
4558
+ _context49.next = 35;
4559
+ break;
4560
+ }
4561
+ throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
4562
+ case 35:
4481
4563
  if (!this.store.payment) {
4482
- _context48.next = 38;
4564
+ _context49.next = 40;
4483
4565
  break;
4484
4566
  }
4485
4567
  committed = this.getCommittedWalletAssets();
4486
4568
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4487
- _context48.next = 38;
4569
+ _context49.next = 40;
4488
4570
  return this.publishWalletAssetsState(walletState);
4489
- case 38:
4490
- return _context48.abrupt("return", {
4571
+ case 40:
4572
+ return _context49.abrupt("return", {
4491
4573
  payment: payment || {},
4492
4574
  payments: this.store.order.getOrderPayments(),
4493
4575
  syncResult: syncResult,
4494
4576
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4495
4577
  });
4496
- case 41:
4497
- _context48.prev = 41;
4498
- _context48.t0 = _context48["catch"](29);
4578
+ case 43:
4579
+ _context49.prev = 43;
4580
+ _context49.t0 = _context49["catch"](29);
4499
4581
  this.store.order.setOrderPayments(beforePayments);
4500
4582
  restoredTempOrder = this.store.order.getTempOrder();
4501
4583
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4502
4584
  restoredTempOrder.payment_status = beforePaymentStatus;
4503
4585
  this.store.order.persistTempOrder();
4504
4586
  }
4505
- _context48.next = 48;
4587
+ _context49.next = 50;
4506
4588
  return this.store.order.recalculateSummary({
4507
4589
  createIfMissing: true
4508
4590
  });
4509
- case 48:
4510
- throw _context48.t0;
4511
- case 49:
4591
+ case 50:
4592
+ throw _context49.t0;
4593
+ case 51:
4512
4594
  case "end":
4513
- return _context48.stop();
4595
+ return _context49.stop();
4514
4596
  }
4515
- }, _callee48, this, [[29, 41]]);
4597
+ }, _callee49, this, [[29, 43]]);
4516
4598
  }));
4517
- function payCash(_x40) {
4599
+ function payCash(_x42) {
4518
4600
  return _payCash.apply(this, arguments);
4519
4601
  }
4520
4602
  return payCash;
@@ -4530,21 +4612,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4530
4612
  }, {
4531
4613
  key: "commitPaymentMethodPayment",
4532
4614
  value: (function () {
4533
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4615
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4534
4616
  var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
4535
4617
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4536
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4537
- while (1) switch (_context49.prev = _context49.next) {
4618
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4619
+ while (1) switch (_context50.prev = _context50.next) {
4538
4620
  case 0:
4539
4621
  if (this.store.order) {
4540
- _context49.next = 2;
4622
+ _context50.next = 2;
4541
4623
  break;
4542
4624
  }
4543
4625
  throw new Error('order 模块未初始化');
4544
4626
  case 2:
4545
4627
  amount = Number(params.amount || 0);
4546
4628
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4547
- _context49.next = 5;
4629
+ _context50.next = 5;
4548
4630
  break;
4549
4631
  }
4550
4632
  throw new Error('支付金额必须大于 0');
@@ -4560,17 +4642,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4560
4642
  };
4561
4643
  paymentMethod = findPaymentMethod();
4562
4644
  if (paymentMethod) {
4563
- _context49.next = 13;
4645
+ _context50.next = 13;
4564
4646
  break;
4565
4647
  }
4566
- _context49.next = 11;
4648
+ _context50.next = 11;
4567
4649
  return this.getPaymentMethodsAsync();
4568
4650
  case 11:
4569
- paymentMethods = _context49.sent;
4651
+ paymentMethods = _context50.sent;
4570
4652
  paymentMethod = findPaymentMethod();
4571
4653
  case 13:
4572
4654
  if (paymentMethod) {
4573
- _context49.next = 15;
4655
+ _context50.next = 15;
4574
4656
  break;
4575
4657
  }
4576
4658
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
@@ -4579,13 +4661,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4579
4661
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4580
4662
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4581
4663
  if (!amountDue.lte(0)) {
4582
- _context49.next = 20;
4664
+ _context50.next = 20;
4583
4665
  break;
4584
4666
  }
4585
4667
  throw new Error('当前订单没有待支付金额');
4586
4668
  case 20:
4587
4669
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
4588
- _context49.next = 22;
4670
+ _context50.next = 22;
4589
4671
  break;
4590
4672
  }
4591
4673
  throw new Error('支付金额超过当前待支付金额');
@@ -4624,8 +4706,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4624
4706
  var _item$metadata3;
4625
4707
  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;
4626
4708
  });
4627
- _context49.prev = 30;
4628
- _context49.next = 33;
4709
+ _context50.prev = 30;
4710
+ _context50.next = 33;
4629
4711
  return this.syncPaymentsToOrder({
4630
4712
  payments: payments,
4631
4713
  submitWhenPaid: true,
@@ -4633,44 +4715,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4633
4715
  confirmPendingVoucherPayments: true
4634
4716
  });
4635
4717
  case 33:
4636
- syncResult = _context49.sent;
4718
+ syncResult = _context50.sent;
4719
+ if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
4720
+ _context50.next = 36;
4721
+ break;
4722
+ }
4723
+ throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
4724
+ case 36:
4637
4725
  if (!this.store.payment) {
4638
- _context49.next = 39;
4726
+ _context50.next = 41;
4639
4727
  break;
4640
4728
  }
4641
4729
  committed = this.getCommittedWalletAssets();
4642
4730
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4643
- _context49.next = 39;
4731
+ _context50.next = 41;
4644
4732
  return this.publishWalletAssetsState(walletState);
4645
- case 39:
4646
- return _context49.abrupt("return", {
4733
+ case 41:
4734
+ return _context50.abrupt("return", {
4647
4735
  payment: payment || {},
4648
4736
  payments: this.store.order.getOrderPayments(),
4649
4737
  syncResult: syncResult,
4650
4738
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4651
4739
  });
4652
- case 42:
4653
- _context49.prev = 42;
4654
- _context49.t0 = _context49["catch"](30);
4740
+ case 44:
4741
+ _context50.prev = 44;
4742
+ _context50.t0 = _context50["catch"](30);
4655
4743
  this.store.order.setOrderPayments(beforePayments);
4656
4744
  restoredTempOrder = this.store.order.getTempOrder();
4657
4745
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4658
4746
  restoredTempOrder.payment_status = beforePaymentStatus;
4659
4747
  this.store.order.persistTempOrder();
4660
4748
  }
4661
- _context49.next = 49;
4749
+ _context50.next = 51;
4662
4750
  return this.store.order.recalculateSummary({
4663
4751
  createIfMissing: true
4664
4752
  });
4665
- case 49:
4666
- throw _context49.t0;
4667
- case 50:
4753
+ case 51:
4754
+ throw _context50.t0;
4755
+ case 52:
4668
4756
  case "end":
4669
- return _context49.stop();
4757
+ return _context50.stop();
4670
4758
  }
4671
- }, _callee49, this, [[30, 42]]);
4759
+ }, _callee50, this, [[30, 44]]);
4672
4760
  }));
4673
- function commitPaymentMethodPayment(_x41) {
4761
+ function commitPaymentMethodPayment(_x43) {
4674
4762
  return _commitPaymentMethodPayment.apply(this, arguments);
4675
4763
  }
4676
4764
  return commitPaymentMethodPayment;
@@ -4685,40 +4773,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4685
4773
  }, {
4686
4774
  key: "roundAmount",
4687
4775
  value: (function () {
4688
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4776
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4689
4777
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
4690
4778
  var amount, cashManualPayment;
4691
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4692
- while (1) switch (_context50.prev = _context50.next) {
4779
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4780
+ while (1) switch (_context51.prev = _context51.next) {
4693
4781
  case 0:
4694
4782
  amount = params.amount;
4695
4783
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
4696
4784
  return paymentMethod.code === 'CASHMANUAL';
4697
4785
  });
4698
4786
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
4699
- _context50.next = 4;
4787
+ _context51.next = 4;
4700
4788
  break;
4701
4789
  }
4702
- return _context50.abrupt("return", {
4790
+ return _context51.abrupt("return", {
4703
4791
  originalAmount: amount.toString(),
4704
4792
  roundedAmount: amount.toString(),
4705
4793
  roundingDifference: '0.00'
4706
4794
  });
4707
4795
  case 4:
4708
4796
  if (this.payment) {
4709
- _context50.next = 6;
4797
+ _context51.next = 6;
4710
4798
  break;
4711
4799
  }
4712
4800
  throw new Error('payment 模块未初始化');
4713
4801
  case 6:
4714
- return _context50.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));
4802
+ return _context51.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
4715
4803
  case 7:
4716
4804
  case "end":
4717
- return _context50.stop();
4805
+ return _context51.stop();
4718
4806
  }
4719
- }, _callee50, this);
4807
+ }, _callee51, this);
4720
4808
  }));
4721
- function roundAmount(_x42) {
4809
+ function roundAmount(_x44) {
4722
4810
  return _roundAmount.apply(this, arguments);
4723
4811
  }
4724
4812
  return roundAmount;
@@ -4733,49 +4821,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4733
4821
  }, {
4734
4822
  key: "sendCustomerPayLink",
4735
4823
  value: (function () {
4736
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4824
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4737
4825
  var orderIds, _ref37, _ref38, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
4738
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4739
- while (1) switch (_context51.prev = _context51.next) {
4826
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4827
+ while (1) switch (_context52.prev = _context52.next) {
4740
4828
  case 0:
4741
4829
  if (this.store.order) {
4742
- _context51.next = 2;
4830
+ _context52.next = 2;
4743
4831
  break;
4744
4832
  }
4745
4833
  throw new Error('order 模块未初始化');
4746
4834
  case 2:
4747
4835
  orderIds = params.order_ids || params.orderIds || [];
4748
4836
  if (!(!orderIds.length || params.submitBeforeSend)) {
4749
- _context51.next = 11;
4837
+ _context52.next = 11;
4750
4838
  break;
4751
4839
  }
4752
- _context51.next = 6;
4840
+ _context52.next = 6;
4753
4841
  return this.submitSalesOrder({
4754
4842
  smallTicketDataFlag: 1
4755
4843
  });
4756
4844
  case 6:
4757
- submitResult = _context51.sent;
4845
+ submitResult = _context52.sent;
4758
4846
  orderId = (_ref37 = (_ref38 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref38 !== void 0 ? _ref38 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref37 !== void 0 ? _ref37 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
4759
4847
  if (orderId) {
4760
- _context51.next = 10;
4848
+ _context52.next = 10;
4761
4849
  break;
4762
4850
  }
4763
4851
  throw new Error('本地订单提交云端失败,无法发送支付链接');
4764
4852
  case 10:
4765
4853
  orderIds = [orderId];
4766
4854
  case 11:
4767
- return _context51.abrupt("return", this.store.order.sendCustomerPayLink({
4855
+ return _context52.abrupt("return", this.store.order.sendCustomerPayLink({
4768
4856
  emails: params.emails,
4769
4857
  notify_action: params.notify_action,
4770
4858
  order_ids: orderIds
4771
4859
  }));
4772
4860
  case 12:
4773
4861
  case "end":
4774
- return _context51.stop();
4862
+ return _context52.stop();
4775
4863
  }
4776
- }, _callee51, this);
4864
+ }, _callee52, this);
4777
4865
  }));
4778
- function sendCustomerPayLink(_x43) {
4866
+ function sendCustomerPayLink(_x45) {
4779
4867
  return _sendCustomerPayLink.apply(this, arguments);
4780
4868
  }
4781
4869
  return sendCustomerPayLink;
@@ -4788,39 +4876,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4788
4876
  }, {
4789
4877
  key: "calculateProductBookingPrice",
4790
4878
  value: function () {
4791
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4879
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
4792
4880
  var _params$customer_id;
4793
4881
  var quotation, customerId, authoritativeProduct, product;
4794
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4795
- while (1) switch (_context52.prev = _context52.next) {
4882
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4883
+ while (1) switch (_context53.prev = _context53.next) {
4796
4884
  case 0:
4797
4885
  quotation = this.store.quotation;
4798
4886
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
4799
- _context52.next = 4;
4800
- return this.loadProductForPriceQuery(params, customerId);
4887
+ _context53.next = 4;
4888
+ return this.prepareProductPriceQueryContext(customerId);
4801
4889
  case 4:
4802
- authoritativeProduct = _context52.sent;
4890
+ _context53.next = 6;
4891
+ return this.loadProductForPriceQuery(params, customerId);
4892
+ case 6:
4893
+ authoritativeProduct = _context53.sent;
4803
4894
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
4804
- _context52.next = 8;
4895
+ _context53.next = 10;
4805
4896
  return this.loadQuotationForPriceQuery({
4806
4897
  quotation: quotation,
4807
4898
  customer_id: customerId,
4808
4899
  channel: params.channel
4809
4900
  });
4810
- case 8:
4811
- return _context52.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4901
+ case 10:
4902
+ return _context53.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4812
4903
  product: product,
4813
4904
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
4814
4905
  customer_id: customerId,
4815
- quotation: quotation
4906
+ quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
4816
4907
  })));
4817
- case 9:
4908
+ case 11:
4818
4909
  case "end":
4819
- return _context52.stop();
4910
+ return _context53.stop();
4820
4911
  }
4821
- }, _callee52, this);
4912
+ }, _callee53, this);
4822
4913
  }));
4823
- function calculateProductBookingPrice(_x44) {
4914
+ function calculateProductBookingPrice(_x46) {
4824
4915
  return _calculateProductBookingPrice.apply(this, arguments);
4825
4916
  }
4826
4917
  return calculateProductBookingPrice;
@@ -4864,6 +4955,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4864
4955
  quotationScopes: quotationScopes
4865
4956
  };
4866
4957
  }
4958
+ }, {
4959
+ key: "hasSmartPricingStrategies",
4960
+ value: function hasSmartPricingStrategies() {
4961
+ var _this$core3;
4962
+ var evaluator = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.dataVariantEvaluator;
4963
+ if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
4964
+ return false;
4965
+ }
4966
+ var configs = evaluator.getStrategyConfigs();
4967
+ return Array.isArray(configs) && configs.length > 0;
4968
+ }
4867
4969
  }, {
4868
4970
  key: "shouldRecalculateProductBookingPricesForContextChange",
4869
4971
  value: function shouldRecalculateProductBookingPricesForContextChange(params) {
@@ -4873,6 +4975,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4873
4975
  }));
4874
4976
  var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
4875
4977
  var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
4978
+ if (this.hasSmartPricingStrategies()) {
4979
+ return previousCustomerId !== nextCustomerId;
4980
+ }
4876
4981
  var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
4877
4982
  var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
4878
4983
  var shouldRecalculate = false;
@@ -4890,23 +4995,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4890
4995
  }, {
4891
4996
  key: "calculateProductBookingPrices",
4892
4997
  value: function () {
4893
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(paramsList) {
4998
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(paramsList) {
4894
4999
  var _paramsList$0$custome,
4895
5000
  _paramsList$,
4896
5001
  _this16 = this,
4897
5002
  _paramsList$2;
4898
5003
  var quotation, customerId, productMapsByGroup, groups;
4899
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4900
- while (1) switch (_context54.prev = _context54.next) {
5004
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5005
+ while (1) switch (_context55.prev = _context55.next) {
4901
5006
  case 0:
4902
5007
  if (paramsList.length) {
4903
- _context54.next = 2;
5008
+ _context55.next = 2;
4904
5009
  break;
4905
5010
  }
4906
- return _context54.abrupt("return", []);
5011
+ return _context55.abrupt("return", []);
4907
5012
  case 2:
4908
5013
  quotation = this.store.quotation;
4909
5014
  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();
5015
+ _context55.next = 6;
5016
+ return this.prepareProductPriceQueryContext(customerId);
5017
+ case 6:
4910
5018
  productMapsByGroup = new Map();
4911
5019
  groups = new Map();
4912
5020
  paramsList.forEach(function (params) {
@@ -4925,15 +5033,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4925
5033
  group.ids.add(productId);
4926
5034
  groups.set(groupKey, group);
4927
5035
  });
4928
- _context54.next = 9;
5036
+ _context55.next = 11;
4929
5037
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
4930
- var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(_ref39) {
5038
+ var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(_ref39) {
4931
5039
  var _ref41, groupKey, group, productsById;
4932
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4933
- while (1) switch (_context53.prev = _context53.next) {
5040
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5041
+ while (1) switch (_context54.prev = _context54.next) {
4934
5042
  case 0:
4935
5043
  _ref41 = _slicedToArray(_ref39, 2), groupKey = _ref41[0], group = _ref41[1];
4936
- _context53.next = 3;
5044
+ _context54.next = 3;
4937
5045
  return _this16.loadProductsForPriceQuery({
4938
5046
  ids: Array.from(group.ids),
4939
5047
  schedule: group.schedule,
@@ -4941,27 +5049,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4941
5049
  channel: group.channel
4942
5050
  });
4943
5051
  case 3:
4944
- productsById = _context53.sent;
5052
+ productsById = _context54.sent;
4945
5053
  productMapsByGroup.set(groupKey, productsById);
4946
5054
  case 5:
4947
5055
  case "end":
4948
- return _context53.stop();
5056
+ return _context54.stop();
4949
5057
  }
4950
- }, _callee53);
5058
+ }, _callee54);
4951
5059
  }));
4952
- return function (_x46) {
5060
+ return function (_x48) {
4953
5061
  return _ref40.apply(this, arguments);
4954
5062
  };
4955
5063
  }()));
4956
- case 9:
4957
- _context54.next = 11;
5064
+ case 11:
5065
+ _context55.next = 13;
4958
5066
  return this.loadQuotationForPriceQuery({
4959
5067
  quotation: quotation,
4960
5068
  customer_id: customerId,
4961
5069
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
4962
5070
  });
4963
- case 11:
4964
- return _context54.abrupt("return", paramsList.map(function (params) {
5071
+ case 13:
5072
+ return _context55.abrupt("return", paramsList.map(function (params) {
4965
5073
  var _this16$otherParams2, _productMapsByGroup$g;
4966
5074
  var productInput = params.product || {};
4967
5075
  var productId = _this16.getPriceQueryProductId(productInput);
@@ -4974,16 +5082,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4974
5082
  product: product,
4975
5083
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
4976
5084
  customer_id: customerId,
4977
- quotation: quotation
5085
+ quotation: authoritativeProduct && _this16.preferAuthoritativeProductQueryPrice() ? undefined : quotation
4978
5086
  }));
4979
5087
  }));
4980
- case 12:
5088
+ case 14:
4981
5089
  case "end":
4982
- return _context54.stop();
5090
+ return _context55.stop();
4983
5091
  }
4984
- }, _callee54, this);
5092
+ }, _callee55, this);
4985
5093
  }));
4986
- function calculateProductBookingPrices(_x45) {
5094
+ function calculateProductBookingPrices(_x47) {
4987
5095
  return _calculateProductBookingPrices.apply(this, arguments);
4988
5096
  }
4989
5097
  return calculateProductBookingPrices;
@@ -4991,42 +5099,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4991
5099
  }, {
4992
5100
  key: "addProductToOrder",
4993
5101
  value: function () {
4994
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(product, booking, options) {
4995
- var products;
4996
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4997
- while (1) switch (_context55.prev = _context55.next) {
4998
- case 0:
4999
- _context55.prev = 0;
5000
- if (this.store.order) {
5001
- _context55.next = 3;
5002
- break;
5003
- }
5004
- throw new Error('order 模块未初始化');
5005
- case 3:
5006
- _context55.next = 5;
5007
- return this.store.order.addProductToOrder(product, booking, options);
5008
- case 5:
5009
- products = _context55.sent;
5010
- return _context55.abrupt("return", products);
5011
- case 9:
5012
- _context55.prev = 9;
5013
- _context55.t0 = _context55["catch"](0);
5014
- throw _context55.t0;
5015
- case 12:
5016
- case "end":
5017
- return _context55.stop();
5018
- }
5019
- }, _callee55, this, [[0, 9]]);
5020
- }));
5021
- function addProductToOrder(_x47, _x48, _x49) {
5022
- return _addProductToOrder.apply(this, arguments);
5023
- }
5024
- return addProductToOrder;
5025
- }()
5026
- }, {
5027
- key: "updateOrderProduct",
5028
- value: function () {
5029
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5102
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(product, booking, options) {
5030
5103
  var products;
5031
5104
  return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5032
5105
  while (1) switch (_context56.prev = _context56.next) {
@@ -5039,7 +5112,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5039
5112
  throw new Error('order 模块未初始化');
5040
5113
  case 3:
5041
5114
  _context56.next = 5;
5042
- return this.store.order.updateOrderProduct(params);
5115
+ return this.store.order.addProductToOrder(product, booking, options);
5043
5116
  case 5:
5044
5117
  products = _context56.sent;
5045
5118
  return _context56.abrupt("return", products);
@@ -5053,15 +5126,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5053
5126
  }
5054
5127
  }, _callee56, this, [[0, 9]]);
5055
5128
  }));
5056
- function updateOrderProduct(_x50) {
5057
- return _updateOrderProduct.apply(this, arguments);
5129
+ function addProductToOrder(_x49, _x50, _x51) {
5130
+ return _addProductToOrder.apply(this, arguments);
5058
5131
  }
5059
- return updateOrderProduct;
5132
+ return addProductToOrder;
5060
5133
  }()
5061
5134
  }, {
5062
- key: "updateOrderProducts",
5135
+ key: "updateOrderProduct",
5063
5136
  value: function () {
5064
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(paramsList) {
5137
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5065
5138
  var products;
5066
5139
  return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5067
5140
  while (1) switch (_context57.prev = _context57.next) {
@@ -5074,7 +5147,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5074
5147
  throw new Error('order 模块未初始化');
5075
5148
  case 3:
5076
5149
  _context57.next = 5;
5077
- return this.store.order.updateOrderProducts(paramsList);
5150
+ return this.store.order.updateOrderProduct(params);
5078
5151
  case 5:
5079
5152
  products = _context57.sent;
5080
5153
  return _context57.abrupt("return", products);
@@ -5088,15 +5161,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5088
5161
  }
5089
5162
  }, _callee57, this, [[0, 9]]);
5090
5163
  }));
5091
- function updateOrderProducts(_x51) {
5092
- return _updateOrderProducts.apply(this, arguments);
5164
+ function updateOrderProduct(_x52) {
5165
+ return _updateOrderProduct.apply(this, arguments);
5093
5166
  }
5094
- return updateOrderProducts;
5167
+ return updateOrderProduct;
5095
5168
  }()
5096
5169
  }, {
5097
- key: "updateOrderProductQuantity",
5170
+ key: "updateOrderProducts",
5098
5171
  value: function () {
5099
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5172
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(paramsList) {
5100
5173
  var products;
5101
5174
  return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5102
5175
  while (1) switch (_context58.prev = _context58.next) {
@@ -5109,7 +5182,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5109
5182
  throw new Error('order 模块未初始化');
5110
5183
  case 3:
5111
5184
  _context58.next = 5;
5112
- return this.store.order.updateOrderProductQuantity(params);
5185
+ return this.store.order.updateOrderProducts(paramsList);
5113
5186
  case 5:
5114
5187
  products = _context58.sent;
5115
5188
  return _context58.abrupt("return", products);
@@ -5123,7 +5196,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5123
5196
  }
5124
5197
  }, _callee58, this, [[0, 9]]);
5125
5198
  }));
5126
- function updateOrderProductQuantity(_x52) {
5199
+ function updateOrderProducts(_x53) {
5200
+ return _updateOrderProducts.apply(this, arguments);
5201
+ }
5202
+ return updateOrderProducts;
5203
+ }()
5204
+ }, {
5205
+ key: "updateOrderProductQuantity",
5206
+ value: function () {
5207
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5208
+ var products;
5209
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5210
+ while (1) switch (_context59.prev = _context59.next) {
5211
+ case 0:
5212
+ _context59.prev = 0;
5213
+ if (this.store.order) {
5214
+ _context59.next = 3;
5215
+ break;
5216
+ }
5217
+ throw new Error('order 模块未初始化');
5218
+ case 3:
5219
+ _context59.next = 5;
5220
+ return this.store.order.updateOrderProductQuantity(params);
5221
+ case 5:
5222
+ products = _context59.sent;
5223
+ return _context59.abrupt("return", products);
5224
+ case 9:
5225
+ _context59.prev = 9;
5226
+ _context59.t0 = _context59["catch"](0);
5227
+ throw _context59.t0;
5228
+ case 12:
5229
+ case "end":
5230
+ return _context59.stop();
5231
+ }
5232
+ }, _callee59, this, [[0, 9]]);
5233
+ }));
5234
+ function updateOrderProductQuantity(_x54) {
5127
5235
  return _updateOrderProductQuantity.apply(this, arguments);
5128
5236
  }
5129
5237
  return updateOrderProductQuantity;
@@ -5146,12 +5254,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5146
5254
  }, {
5147
5255
  key: "setOrderProductLineNote",
5148
5256
  value: (function () {
5149
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identity, note) {
5257
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity, note) {
5150
5258
  var params, products;
5151
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5152
- while (1) switch (_context59.prev = _context59.next) {
5259
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5260
+ while (1) switch (_context60.prev = _context60.next) {
5153
5261
  case 0:
5154
- _context59.prev = 0;
5262
+ _context60.prev = 0;
5155
5263
  params = {
5156
5264
  product_id: identity.product_id,
5157
5265
  product_variant_id: identity.product_variant_id,
@@ -5166,22 +5274,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5166
5274
  params.product_sku = identity.product_sku;
5167
5275
  }
5168
5276
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
5169
- _context59.next = 7;
5277
+ _context60.next = 7;
5170
5278
  return this.updateOrderProduct(params);
5171
5279
  case 7:
5172
- products = _context59.sent;
5173
- return _context59.abrupt("return", products);
5280
+ products = _context60.sent;
5281
+ return _context60.abrupt("return", products);
5174
5282
  case 11:
5175
- _context59.prev = 11;
5176
- _context59.t0 = _context59["catch"](0);
5177
- throw _context59.t0;
5283
+ _context60.prev = 11;
5284
+ _context60.t0 = _context60["catch"](0);
5285
+ throw _context60.t0;
5178
5286
  case 14:
5179
5287
  case "end":
5180
- return _context59.stop();
5288
+ return _context60.stop();
5181
5289
  }
5182
- }, _callee59, this, [[0, 11]]);
5290
+ }, _callee60, this, [[0, 11]]);
5183
5291
  }));
5184
- function setOrderProductLineNote(_x53, _x54) {
5292
+ function setOrderProductLineNote(_x55, _x56) {
5185
5293
  return _setOrderProductLineNote.apply(this, arguments);
5186
5294
  }
5187
5295
  return setOrderProductLineNote;
@@ -5196,32 +5304,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5196
5304
  }, {
5197
5305
  key: "removeProductsFromOrder",
5198
5306
  value: (function () {
5199
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identities, options) {
5200
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5201
- while (1) switch (_context60.prev = _context60.next) {
5307
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(identities, options) {
5308
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5309
+ while (1) switch (_context61.prev = _context61.next) {
5202
5310
  case 0:
5203
- _context60.prev = 0;
5311
+ _context61.prev = 0;
5204
5312
  if (this.store.order) {
5205
- _context60.next = 3;
5313
+ _context61.next = 3;
5206
5314
  break;
5207
5315
  }
5208
5316
  throw new Error('order 模块未初始化');
5209
5317
  case 3:
5210
- _context60.next = 5;
5318
+ _context61.next = 5;
5211
5319
  return this.store.order.removeProductsFromOrder(identities, options);
5212
5320
  case 5:
5213
- return _context60.abrupt("return", _context60.sent);
5321
+ return _context61.abrupt("return", _context61.sent);
5214
5322
  case 8:
5215
- _context60.prev = 8;
5216
- _context60.t0 = _context60["catch"](0);
5217
- throw _context60.t0;
5323
+ _context61.prev = 8;
5324
+ _context61.t0 = _context61["catch"](0);
5325
+ throw _context61.t0;
5218
5326
  case 11:
5219
5327
  case "end":
5220
- return _context60.stop();
5328
+ return _context61.stop();
5221
5329
  }
5222
- }, _callee60, this, [[0, 8]]);
5330
+ }, _callee61, this, [[0, 8]]);
5223
5331
  }));
5224
- function removeProductsFromOrder(_x55, _x56) {
5332
+ function removeProductsFromOrder(_x57, _x58) {
5225
5333
  return _removeProductsFromOrder.apply(this, arguments);
5226
5334
  }
5227
5335
  return removeProductsFromOrder;
@@ -5229,18 +5337,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5229
5337
  }, {
5230
5338
  key: "removeProductFromOrder",
5231
5339
  value: function () {
5232
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(identity, options) {
5233
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5234
- while (1) switch (_context61.prev = _context61.next) {
5340
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, options) {
5341
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5342
+ while (1) switch (_context62.prev = _context62.next) {
5235
5343
  case 0:
5236
- return _context61.abrupt("return", this.removeProductsFromOrder([identity], options));
5344
+ return _context62.abrupt("return", this.removeProductsFromOrder([identity], options));
5237
5345
  case 1:
5238
5346
  case "end":
5239
- return _context61.stop();
5347
+ return _context62.stop();
5240
5348
  }
5241
- }, _callee61, this);
5349
+ }, _callee62, this);
5242
5350
  }));
5243
- function removeProductFromOrder(_x57, _x58) {
5351
+ function removeProductFromOrder(_x59, _x60) {
5244
5352
  return _removeProductFromOrder.apply(this, arguments);
5245
5353
  }
5246
5354
  return removeProductFromOrder;
@@ -5290,23 +5398,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5290
5398
  }, {
5291
5399
  key: "applyPromotion",
5292
5400
  value: (function () {
5293
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
5294
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5295
- while (1) switch (_context62.prev = _context62.next) {
5401
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
5402
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5403
+ while (1) switch (_context63.prev = _context63.next) {
5296
5404
  case 0:
5297
5405
  if (this.store.order) {
5298
- _context62.next = 2;
5406
+ _context63.next = 2;
5299
5407
  break;
5300
5408
  }
5301
5409
  throw new Error('order 模块未初始化');
5302
5410
  case 2:
5303
- _context62.next = 4;
5411
+ _context63.next = 4;
5304
5412
  return this.store.order.applyPromotion();
5305
5413
  case 4:
5306
5414
  case "end":
5307
- return _context62.stop();
5415
+ return _context63.stop();
5308
5416
  }
5309
- }, _callee62, this);
5417
+ }, _callee63, this);
5310
5418
  }));
5311
5419
  function applyPromotion() {
5312
5420
  return _applyPromotion.apply(this, arguments);
@@ -5333,18 +5441,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5333
5441
  }, {
5334
5442
  key: "getProductList",
5335
5443
  value: function () {
5336
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
5337
- var _this$otherParams32;
5444
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
5445
+ var _this$otherParams33;
5338
5446
  var menu_list_ids, _this$store$products, res;
5339
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5340
- while (1) switch (_context63.prev = _context63.next) {
5447
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
5448
+ while (1) switch (_context64.prev = _context64.next) {
5341
5449
  case 0:
5342
5450
  // 可以直接通过配置里的 menu 读取
5343
- menu_list_ids = ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 || (_this$otherParams32 = _this$otherParams32.dineInConfig) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32['menu.associated_menus'].map(function (n) {
5451
+ menu_list_ids = ((_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 || (_this$otherParams33 = _this$otherParams33.dineInConfig) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33['menu.associated_menus'].map(function (n) {
5344
5452
  return Number(n.value);
5345
5453
  })) || [];
5346
- _context63.prev = 1;
5347
- _context63.next = 4;
5454
+ _context64.prev = 1;
5455
+ _context64.next = 4;
5348
5456
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
5349
5457
  menu_list_ids: menu_list_ids,
5350
5458
  cacheId: this.cacheId,
@@ -5352,17 +5460,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5352
5460
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
5353
5461
  });
5354
5462
  case 4:
5355
- res = _context63.sent;
5356
- return _context63.abrupt("return", res);
5463
+ res = _context64.sent;
5464
+ return _context64.abrupt("return", res);
5357
5465
  case 8:
5358
- _context63.prev = 8;
5359
- _context63.t0 = _context63["catch"](1);
5360
- throw _context63.t0;
5466
+ _context64.prev = 8;
5467
+ _context64.t0 = _context64["catch"](1);
5468
+ throw _context64.t0;
5361
5469
  case 11:
5362
5470
  case "end":
5363
- return _context63.stop();
5471
+ return _context64.stop();
5364
5472
  }
5365
- }, _callee63, this, [[1, 8]]);
5473
+ }, _callee64, this, [[1, 8]]);
5366
5474
  }));
5367
5475
  function getProductList() {
5368
5476
  return _getProductList.apply(this, arguments);
@@ -5377,33 +5485,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5377
5485
  }, {
5378
5486
  key: "setOtherParams",
5379
5487
  value: function () {
5380
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
5381
- var _this$otherParams33;
5488
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
5489
+ var _this$otherParams34;
5382
5490
  var _ref42,
5383
5491
  _ref42$cover,
5384
5492
  cover,
5385
- _args64 = arguments;
5386
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
5387
- while (1) switch (_context64.prev = _context64.next) {
5493
+ _args65 = arguments;
5494
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
5495
+ while (1) switch (_context65.prev = _context65.next) {
5388
5496
  case 0:
5389
- _ref42 = _args64.length > 1 && _args64[1] !== undefined ? _args64[1] : {}, _ref42$cover = _ref42.cover, cover = _ref42$cover === void 0 ? false : _ref42$cover;
5497
+ _ref42 = _args65.length > 1 && _args65[1] !== undefined ? _args65[1] : {}, _ref42$cover = _ref42.cover, cover = _ref42$cover === void 0 ? false : _ref42$cover;
5390
5498
  if (cover) {
5391
5499
  this.otherParams = _objectSpread({}, params);
5392
5500
  } else {
5393
5501
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
5394
5502
  }
5395
- this.cacheId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.cacheId;
5396
- _context64.next = 5;
5503
+ this.cacheId = (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.cacheId;
5504
+ _context65.next = 5;
5397
5505
  return this.syncOtherParamsToSubModules(params, {
5398
5506
  cover: cover
5399
5507
  });
5400
5508
  case 5:
5401
5509
  case "end":
5402
- return _context64.stop();
5510
+ return _context65.stop();
5403
5511
  }
5404
- }, _callee64, this);
5512
+ }, _callee65, this);
5405
5513
  }));
5406
- function setOtherParams(_x59) {
5514
+ function setOtherParams(_x61) {
5407
5515
  return _setOtherParams.apply(this, arguments);
5408
5516
  }
5409
5517
  return setOtherParams;