@pisell/pisellos 0.10.7 → 0.10.9

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 (124) hide show
  1. package/dist/core/index.js +0 -1
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  4. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  6. package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
  7. package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
  9. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  10. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  11. package/dist/modules/Customer/index.d.ts +4 -0
  12. package/dist/modules/Customer/index.js +91 -59
  13. package/dist/modules/Customer/types.d.ts +2 -0
  14. package/dist/modules/Discount/index.d.ts +2 -0
  15. package/dist/modules/Discount/index.js +38 -5
  16. package/dist/modules/Discount/types.d.ts +11 -0
  17. package/dist/modules/Order/index.d.ts +32 -6
  18. package/dist/modules/Order/index.js +1165 -819
  19. package/dist/modules/Order/types.d.ts +32 -4
  20. package/dist/modules/Order/types.js +11 -0
  21. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  22. package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
  23. package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
  24. package/dist/modules/Order/utils/virtualSettlement.js +271 -0
  25. package/dist/modules/Order/utils.js +89 -48
  26. package/dist/modules/Payment/types.d.ts +2 -0
  27. package/dist/modules/Payment/utils.js +4 -1
  28. package/dist/modules/Payment/walletpass.d.ts +11 -0
  29. package/dist/modules/Payment/walletpass.js +235 -60
  30. package/dist/modules/Product/types.d.ts +23 -0
  31. package/dist/modules/ProductList/index.d.ts +15 -2
  32. package/dist/modules/ProductList/index.js +92 -13
  33. package/dist/modules/Rules/index.js +125 -52
  34. package/dist/modules/SalesSummary/index.d.ts +1 -0
  35. package/dist/modules/SalesSummary/index.js +4 -3
  36. package/dist/modules/SalesSummary/types.d.ts +1 -0
  37. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  38. package/dist/modules/SalesSummary/utils.js +28 -2
  39. package/dist/server/index.d.ts +15 -0
  40. package/dist/server/index.js +894 -781
  41. package/dist/server/modules/order/index.d.ts +2 -0
  42. package/dist/server/modules/order/index.js +261 -96
  43. package/dist/server/modules/order/types.d.ts +1 -1
  44. package/dist/server/utils/small-ticket.js +2 -1
  45. package/dist/solution/BaseSales/index.d.ts +41 -7
  46. package/dist/solution/BaseSales/index.js +1405 -974
  47. package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
  48. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
  50. package/dist/solution/BaseSales/utils.js +31 -20
  51. package/dist/solution/BookingByStep/index.d.ts +3 -3
  52. package/dist/solution/BookingTicket/index.d.ts +5 -1
  53. package/dist/solution/BookingTicket/index.js +221 -162
  54. package/dist/solution/BookingTicket/types.d.ts +3 -0
  55. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  56. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  57. package/dist/solution/Sales/index.d.ts +1 -0
  58. package/dist/solution/Sales/index.js +16 -2
  59. package/dist/solution/ScanOrder/index.js +25 -64
  60. package/dist/solution/ScanOrder/utils.js +31 -20
  61. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  62. package/dist/solution/UnifiedBookingSales/index.js +51 -39
  63. package/lib/core/index.js +0 -1
  64. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  65. package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
  66. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  67. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  68. package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
  69. package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
  70. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
  71. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  72. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  73. package/lib/modules/Customer/index.d.ts +4 -0
  74. package/lib/modules/Customer/index.js +11 -0
  75. package/lib/modules/Customer/types.d.ts +2 -0
  76. package/lib/modules/Discount/index.d.ts +2 -0
  77. package/lib/modules/Discount/index.js +37 -3
  78. package/lib/modules/Discount/types.d.ts +11 -0
  79. package/lib/modules/Order/index.d.ts +32 -6
  80. package/lib/modules/Order/index.js +518 -148
  81. package/lib/modules/Order/types.d.ts +32 -4
  82. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  83. package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
  84. package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
  85. package/lib/modules/Order/utils/virtualSettlement.js +300 -0
  86. package/lib/modules/Order/utils.js +65 -21
  87. package/lib/modules/Payment/types.d.ts +2 -0
  88. package/lib/modules/Payment/utils.js +5 -1
  89. package/lib/modules/Payment/walletpass.d.ts +11 -0
  90. package/lib/modules/Payment/walletpass.js +198 -17
  91. package/lib/modules/Product/types.d.ts +23 -0
  92. package/lib/modules/ProductList/index.d.ts +15 -2
  93. package/lib/modules/ProductList/index.js +85 -3
  94. package/lib/modules/Rules/index.js +100 -20
  95. package/lib/modules/SalesSummary/index.d.ts +1 -0
  96. package/lib/modules/SalesSummary/index.js +10 -2
  97. package/lib/modules/SalesSummary/types.d.ts +1 -0
  98. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  99. package/lib/modules/SalesSummary/utils.js +30 -2
  100. package/lib/server/index.d.ts +15 -0
  101. package/lib/server/index.js +105 -14
  102. package/lib/server/modules/order/index.d.ts +2 -0
  103. package/lib/server/modules/order/index.js +75 -5
  104. package/lib/server/modules/order/types.d.ts +1 -1
  105. package/lib/server/utils/small-ticket.js +1 -1
  106. package/lib/solution/BaseSales/index.d.ts +41 -7
  107. package/lib/solution/BaseSales/index.js +325 -39
  108. package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
  109. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  110. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
  111. package/lib/solution/BaseSales/utils.js +29 -18
  112. package/lib/solution/BookingByStep/index.d.ts +3 -3
  113. package/lib/solution/BookingTicket/index.d.ts +5 -1
  114. package/lib/solution/BookingTicket/index.js +31 -6
  115. package/lib/solution/BookingTicket/types.d.ts +3 -0
  116. package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
  117. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  118. package/lib/solution/Sales/index.d.ts +1 -0
  119. package/lib/solution/Sales/index.js +15 -3
  120. package/lib/solution/ScanOrder/index.js +17 -54
  121. package/lib/solution/ScanOrder/utils.js +29 -18
  122. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  123. package/lib/solution/UnifiedBookingSales/index.js +35 -26
  124. package/package.json +1 -1
@@ -37,6 +37,7 @@ import Decimal from 'decimal.js';
37
37
  import { cloneDeep, mergeWith } from 'lodash-es';
38
38
  import { createModule } from "../BookingByStep/types";
39
39
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
40
+ import { getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
40
41
  import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
41
42
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
42
43
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
@@ -65,19 +66,21 @@ function isRejectedSalesSubmitResult(result) {
65
66
  var _result$response, _result$response2;
66
67
  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
68
  return candidates.some(function (candidate) {
68
- var _candidate$code;
69
69
  if (!candidate || _typeof(candidate) !== 'object') return false;
70
- var responseCode = Number((_candidate$code = candidate.code) !== null && _candidate$code !== void 0 ? _candidate$code : candidate.statusCode);
71
- if (Number.isFinite(responseCode) && responseCode >= 400) return true;
70
+ if (candidate.code !== undefined && candidate.code !== 200 && candidate.code !== '200') {
71
+ return true;
72
+ }
73
+ var statusCode = Number(candidate.statusCode);
74
+ if (Number.isFinite(statusCode) && statusCode >= 400) return true;
72
75
  if (candidate.status === false || candidate.success === false || candidate.result === false) {
73
76
  return true;
74
77
  }
75
78
  return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
76
79
  });
77
80
  }
78
- function getSalesSubmitErrorMessage(result) {
81
+ function getSalesSubmitErrorMessage(result, fallbackMessage) {
79
82
  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 支付确认失败';
83
+ 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
84
  }
82
85
  function toWalletFundValue(value) {
83
86
  try {
@@ -865,6 +868,75 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
865
868
  if (!Number.isFinite(productId)) return null;
866
869
  return productId;
867
870
  }
871
+
872
+ /**
873
+ * Change Time / customer reprice 必须沿用商品列表的渠道口径。
874
+ * SalesSdk Provider 通常将渠道存为 platform,因此不能只读取 otherParams.channel。
875
+ */
876
+ }, {
877
+ key: "getPriceQueryChannel",
878
+ value: function getPriceQueryChannel(channel) {
879
+ var _this$otherParams2, _ref12, _ref13, _this$otherParams3, _this$otherParams4;
880
+ var strategyContext = (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
881
+ var value = (_ref12 = (_ref13 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref13 !== void 0 ? _ref13 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel) !== null && _ref12 !== void 0 ? _ref12 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform;
882
+ if (value === undefined || value === null || String(value).trim() === '') {
883
+ return undefined;
884
+ }
885
+ return String(value).trim();
886
+ }
887
+ /**
888
+ * /product/query 的智能定价评估只读取 strategy_context;
889
+ * application_code 仅作为接口兼容字段,不能替代 channel / business_code。
890
+ */
891
+ }, {
892
+ key: "getPriceQueryStrategyContext",
893
+ value: function getPriceQueryStrategyContext(channel) {
894
+ var _this$otherParams5, _ref14, _strategyContext$busi, _this$otherParams6, _this$otherParams7;
895
+ var inherited = (_this$otherParams5 = this.otherParams) !== null && _this$otherParams5 !== void 0 && _this$otherParams5.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
896
+ var strategyContext = _objectSpread({}, inherited);
897
+ var resolvedChannel = this.getPriceQueryChannel(channel);
898
+ var businessCode = (_ref14 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref14 !== void 0 ? _ref14 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code;
899
+ if (resolvedChannel) strategyContext.channel = resolvedChannel;
900
+ if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
901
+ strategyContext.business_code = String(businessCode).trim();
902
+ }
903
+ var availableWalletIds = this.getAvailableWalletIds();
904
+ if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
905
+ strategyContext.available_wallet_ids = availableWalletIds;
906
+ }
907
+ return strategyContext;
908
+ }
909
+
910
+ /**
911
+ * 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
912
+ */
913
+ }, {
914
+ key: "prepareProductPriceQueryContext",
915
+ value: (function () {
916
+ var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_customerId) {
917
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
918
+ while (1) switch (_context7.prev = _context7.next) {
919
+ case 0:
920
+ case "end":
921
+ return _context7.stop();
922
+ }
923
+ }, _callee7);
924
+ }));
925
+ function prepareProductPriceQueryContext(_x6) {
926
+ return _prepareProductPriceQueryContext.apply(this, arguments);
927
+ }
928
+ return prepareProductPriceQueryContext;
929
+ }()
930
+ /**
931
+ * 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
932
+ * 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
933
+ */
934
+ )
935
+ }, {
936
+ key: "preferAuthoritativeProductQueryPrice",
937
+ value: function preferAuthoritativeProductQueryPrice() {
938
+ return false;
939
+ }
868
940
  }, {
869
941
  key: "getPriceQuerySchedule",
870
942
  value: function getPriceQuerySchedule(params) {
@@ -896,24 +968,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
896
968
  }, {
897
969
  key: "loadProductsForPriceQuery",
898
970
  value: function () {
899
- var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
900
- var ids, productsById, _this$otherParams2, _response$data, response, list;
901
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
902
- while (1) switch (_context7.prev = _context7.next) {
971
+ var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
972
+ var ids, productsById, channel, strategyContext, _response$data, response, list;
973
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
974
+ while (1) switch (_context8.prev = _context8.next) {
903
975
  case 0:
904
976
  ids = Array.from(new Set(params.ids.filter(function (id) {
905
977
  return Number.isFinite(id);
906
978
  })));
907
979
  productsById = new Map();
908
980
  if (!(!ids.length || !this.request)) {
909
- _context7.next = 4;
981
+ _context8.next = 4;
910
982
  break;
911
983
  }
912
- return _context7.abrupt("return", productsById);
984
+ return _context8.abrupt("return", productsById);
913
985
  case 4:
914
- _context7.prev = 4;
915
- _context7.next = 7;
916
- return this.request.post('/product/query', {
986
+ channel = this.getPriceQueryChannel(params.channel);
987
+ strategyContext = this.getPriceQueryStrategyContext(channel);
988
+ _context8.prev = 6;
989
+ _context8.next = 9;
990
+ return this.request.post('/product/query', _objectSpread({
917
991
  ids: ids,
918
992
  open_quotation: 1,
919
993
  open_bundle: 1,
@@ -923,41 +997,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
923
997
  customer_id: params.customerId,
924
998
  schedule_date: params.schedule.schedule_date,
925
999
  schedule_datetime: params.schedule.schedule_datetime,
926
- application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
927
- }, {
1000
+ application_code: channel
1001
+ }, Object.keys(strategyContext).length ? {
1002
+ strategy_context: strategyContext
1003
+ } : {}), {
928
1004
  osServer: true,
929
1005
  customToast: function customToast() {}
930
1006
  });
931
- case 7:
932
- response = _context7.sent;
1007
+ case 9:
1008
+ response = _context8.sent;
933
1009
  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) || [];
934
1010
  if (Array.isArray(list)) {
935
- _context7.next = 11;
1011
+ _context8.next = 13;
936
1012
  break;
937
1013
  }
938
- return _context7.abrupt("return", productsById);
939
- case 11:
1014
+ return _context8.abrupt("return", productsById);
1015
+ case 13:
940
1016
  list.forEach(function (item) {
941
1017
  var _item$id;
942
1018
  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);
943
1019
  if (Number.isFinite(productId)) productsById.set(productId, item);
944
1020
  });
945
- return _context7.abrupt("return", productsById);
946
- case 15:
947
- _context7.prev = 15;
948
- _context7.t0 = _context7["catch"](4);
1021
+ return _context8.abrupt("return", productsById);
1022
+ case 17:
1023
+ _context8.prev = 17;
1024
+ _context8.t0 = _context8["catch"](6);
949
1025
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
950
1026
  ids: ids,
951
- error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
1027
+ error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
952
1028
  });
953
- return _context7.abrupt("return", productsById);
954
- case 19:
1029
+ return _context8.abrupt("return", productsById);
1030
+ case 21:
955
1031
  case "end":
956
- return _context7.stop();
1032
+ return _context8.stop();
957
1033
  }
958
- }, _callee7, this, [[4, 15]]);
1034
+ }, _callee8, this, [[6, 17]]);
959
1035
  }));
960
- function loadProductsForPriceQuery(_x6) {
1036
+ function loadProductsForPriceQuery(_x7) {
961
1037
  return _loadProductsForPriceQuery.apply(this, arguments);
962
1038
  }
963
1039
  return loadProductsForPriceQuery;
@@ -965,21 +1041,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
965
1041
  }, {
966
1042
  key: "loadProductForPriceQuery",
967
1043
  value: function () {
968
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
1044
+ var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, customerId) {
969
1045
  var product, productId, schedule, productsById;
970
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
971
- while (1) switch (_context8.prev = _context8.next) {
1046
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1047
+ while (1) switch (_context9.prev = _context9.next) {
972
1048
  case 0:
973
1049
  product = params.product || {};
974
1050
  productId = this.getPriceQueryProductId(product);
975
1051
  if (!(productId === null || !this.request)) {
976
- _context8.next = 4;
1052
+ _context9.next = 4;
977
1053
  break;
978
1054
  }
979
- return _context8.abrupt("return", null);
1055
+ return _context9.abrupt("return", null);
980
1056
  case 4:
981
1057
  schedule = this.getPriceQuerySchedule(params);
982
- _context8.next = 7;
1058
+ _context9.next = 7;
983
1059
  return this.loadProductsForPriceQuery({
984
1060
  ids: [productId],
985
1061
  schedule: schedule,
@@ -987,15 +1063,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
987
1063
  channel: params.channel
988
1064
  });
989
1065
  case 7:
990
- productsById = _context8.sent;
991
- return _context8.abrupt("return", productsById.get(productId) || null);
1066
+ productsById = _context9.sent;
1067
+ return _context9.abrupt("return", productsById.get(productId) || null);
992
1068
  case 9:
993
1069
  case "end":
994
- return _context8.stop();
1070
+ return _context9.stop();
995
1071
  }
996
- }, _callee8, this);
1072
+ }, _callee9, this);
997
1073
  }));
998
- function loadProductForPriceQuery(_x7, _x8) {
1074
+ function loadProductForPriceQuery(_x8, _x9) {
999
1075
  return _loadProductForPriceQuery.apply(this, arguments);
1000
1076
  }
1001
1077
  return loadProductForPriceQuery;
@@ -1008,10 +1084,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1008
1084
  return groups.flatMap(function (group) {
1009
1085
  var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
1010
1086
  return items.map(function (item) {
1011
- var _item$group_id, _ref12, _item$bundle_group_id;
1087
+ var _item$group_id, _ref15, _item$bundle_group_id;
1012
1088
  return _objectSpread(_objectSpread({}, item), {}, {
1013
1089
  group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
1014
- bundle_group_id: (_ref12 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref12 !== void 0 ? _ref12 : group === null || group === void 0 ? void 0 : group.id
1090
+ bundle_group_id: (_ref15 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref15 !== void 0 ? _ref15 : group === null || group === void 0 ? void 0 : group.id
1015
1091
  });
1016
1092
  });
1017
1093
  });
@@ -1042,21 +1118,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1042
1118
  }, {
1043
1119
  key: "getAuthoritativeBundleUnitPrice",
1044
1120
  value: function getAuthoritativeBundleUnitPrice(bundle) {
1045
- var _ref13, _ref14, _ref15, _bundle$price;
1046
- return (_ref13 = (_ref14 = (_ref15 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.custom_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.product_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.base_price;
1121
+ var _ref16, _ref17, _ref18, _bundle$price;
1122
+ return (_ref16 = (_ref17 = (_ref18 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref18 !== void 0 ? _ref18 : bundle.custom_price) !== null && _ref17 !== void 0 ? _ref17 : bundle.product_price) !== null && _ref16 !== void 0 ? _ref16 : bundle.base_price;
1047
1123
  }
1048
1124
  }, {
1049
1125
  key: "mergeProductForPriceQuery",
1050
1126
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
1051
1127
  var _this5 = this,
1052
1128
  _product$id,
1053
- _ref16,
1129
+ _ref19,
1054
1130
  _product$product_id2,
1055
- _ref17,
1131
+ _ref20,
1056
1132
  _product$product_vari,
1057
- _ref18,
1133
+ _ref21,
1058
1134
  _product$num,
1059
- _ref19,
1135
+ _ref22,
1060
1136
  _product$quantity,
1061
1137
  _product$metadata4;
1062
1138
  if (!authoritativeProduct) return product;
@@ -1076,10 +1152,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1076
1152
  });
1077
1153
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
1078
1154
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
1079
- product_id: (_ref16 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref16 !== void 0 ? _ref16 : authoritativeProduct.id,
1080
- product_variant_id: (_ref17 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0,
1081
- num: (_ref18 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref18 !== void 0 ? _ref18 : authoritativeProduct.num,
1082
- quantity: (_ref19 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.quantity,
1155
+ product_id: (_ref19 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.id,
1156
+ product_variant_id: (_ref20 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
1157
+ num: (_ref21 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref21 !== void 0 ? _ref21 : authoritativeProduct.num,
1158
+ quantity: (_ref22 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref22 !== void 0 ? _ref22 : authoritativeProduct.quantity,
1083
1159
  product_sku: function () {
1084
1160
  var authoritativeSku = ensureProductSku(authoritativeProduct);
1085
1161
  var productSku = ensureProductSku(product);
@@ -1095,8 +1171,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1095
1171
  }, {
1096
1172
  key: "getSubmitOrderSalesChannel",
1097
1173
  value: function getSubmitOrderSalesChannel() {
1098
- var _this$otherParams3;
1099
- return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
1174
+ var _this$otherParams8;
1175
+ return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
1100
1176
  }
1101
1177
 
1102
1178
  /**
@@ -1163,60 +1239,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1163
1239
  }, {
1164
1240
  key: "syncOtherParamsToSubModules",
1165
1241
  value: (function () {
1166
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
1242
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
1167
1243
  var _this6 = this;
1168
- var _ref20,
1169
- _ref20$cover,
1244
+ var _ref23,
1245
+ _ref23$cover,
1170
1246
  cover,
1171
- _args10 = arguments;
1172
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1173
- while (1) switch (_context10.prev = _context10.next) {
1247
+ _args11 = arguments;
1248
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1249
+ while (1) switch (_context11.prev = _context11.next) {
1174
1250
  case 0:
1175
- _ref20 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref20$cover = _ref20.cover, cover = _ref20$cover === void 0 ? false : _ref20$cover;
1176
- _context10.next = 3;
1251
+ _ref23 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
1252
+ _context11.next = 3;
1177
1253
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1178
- var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
1179
- var _ref23, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1180
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1181
- while (1) switch (_context9.prev = _context9.next) {
1254
+ var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref24) {
1255
+ var _ref26, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1256
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1257
+ while (1) switch (_context10.prev = _context10.next) {
1182
1258
  case 0:
1183
- _ref23 = _slicedToArray(_ref21, 2), moduleName = _ref23[0], subModule = _ref23[1];
1259
+ _ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
1184
1260
  if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1185
- _context9.next = 3;
1261
+ _context10.next = 3;
1186
1262
  break;
1187
1263
  }
1188
- return _context9.abrupt("return");
1264
+ return _context10.abrupt("return");
1189
1265
  case 3:
1190
1266
  targetModule = subModule;
1191
1267
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
1192
- _context9.next = 6;
1268
+ _context10.next = 6;
1193
1269
  break;
1194
1270
  }
1195
- return _context9.abrupt("return");
1271
+ return _context10.abrupt("return");
1196
1272
  case 6:
1197
1273
  nextSubModuleOtherParams = _this6.buildSubModuleOtherParams(moduleName);
1198
- _context9.next = 9;
1274
+ _context10.next = 9;
1199
1275
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
1200
1276
  changedParams: changedParams,
1201
1277
  cover: cover
1202
1278
  });
1203
1279
  case 9:
1204
1280
  case "end":
1205
- return _context9.stop();
1281
+ return _context10.stop();
1206
1282
  }
1207
- }, _callee9);
1283
+ }, _callee10);
1208
1284
  }));
1209
- return function (_x10) {
1210
- return _ref22.apply(this, arguments);
1285
+ return function (_x11) {
1286
+ return _ref25.apply(this, arguments);
1211
1287
  };
1212
1288
  }()));
1213
1289
  case 3:
1214
1290
  case "end":
1215
- return _context10.stop();
1291
+ return _context11.stop();
1216
1292
  }
1217
- }, _callee10, this);
1293
+ }, _callee11, this);
1218
1294
  }));
1219
- function syncOtherParamsToSubModules(_x9) {
1295
+ function syncOtherParamsToSubModules(_x10) {
1220
1296
  return _syncOtherParamsToSubModules.apply(this, arguments);
1221
1297
  }
1222
1298
  return syncOtherParamsToSubModules;
@@ -1284,6 +1360,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1284
1360
  return _this8.getAppData(key);
1285
1361
  });
1286
1362
  }
1363
+ }, {
1364
+ key: "isMultiCurrencySettlementEnabled",
1365
+ value: function isMultiCurrencySettlementEnabled() {
1366
+ var _this$otherParams9;
1367
+ return ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.enableMultiCurrencySettlement) === true;
1368
+ }
1369
+ }, {
1370
+ key: "isActiveVirtualSettlementOrder",
1371
+ value: function isActiveVirtualSettlementOrder(tempOrder) {
1372
+ return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
1373
+ }
1374
+ }, {
1375
+ key: "isHistoricalVirtualSettlementOrder",
1376
+ value: function isHistoricalVirtualSettlementOrder(tempOrder) {
1377
+ var _tempOrder$metadata;
1378
+ return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
1379
+ }
1287
1380
  }, {
1288
1381
  key: "syncAppDataToTempOrder",
1289
1382
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1291,6 +1384,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1291
1384
  var taxCountryCode = this.getAppData('tax_country_code');
1292
1385
  var currencyCode = this.getAppData('shop_currency_code');
1293
1386
  var currencySymbol = this.getAppData('shop_symbol');
1387
+ // 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
1388
+ var isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
1389
+ var isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
1390
+ var shouldManageLegalCurrencySnapshot = this.isMultiCurrencySettlementEnabled() || isHistoricalVirtualSettlement;
1294
1391
  var isChanged = false;
1295
1392
  if (isPriceIncludeTax !== undefined) {
1296
1393
  var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
@@ -1306,14 +1403,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1306
1403
  isChanged = true;
1307
1404
  }
1308
1405
  }
1309
- if (currencyCode !== undefined) {
1406
+ tempOrder.metadata = tempOrder.metadata || {};
1407
+ if (shouldManageLegalCurrencySnapshot) {
1408
+ var _ref27, _ref28, _tempOrder$metadata$l, _ref29, _ref30, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
1409
+ var legalCurrencySnapshot = {
1410
+ currency_code: String((_ref27 = (_ref28 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref28 !== void 0 ? _ref28 : tempOrder.currency_code) !== null && _ref27 !== void 0 ? _ref27 : ''),
1411
+ currency_symbol: String((_ref29 = (_ref30 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref30 !== void 0 ? _ref30 : tempOrder.currency_symbol) !== null && _ref29 !== void 0 ? _ref29 : ''),
1412
+ currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
1413
+ };
1414
+ if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
1415
+ tempOrder.metadata.legal_currency_snapshot = legalCurrencySnapshot;
1416
+ isChanged = true;
1417
+ }
1418
+ }
1419
+ if (!isVirtualSettlement && currencyCode !== undefined) {
1310
1420
  var nextCurrencyCode = String(currencyCode || '');
1311
1421
  if (tempOrder.currency_code !== nextCurrencyCode) {
1312
1422
  tempOrder.currency_code = nextCurrencyCode;
1313
1423
  isChanged = true;
1314
1424
  }
1315
1425
  }
1316
- if (currencySymbol !== undefined) {
1426
+ if (!isVirtualSettlement && currencySymbol !== undefined) {
1317
1427
  var nextCurrencySymbol = String(currencySymbol || '');
1318
1428
  if (tempOrder.currency_symbol !== nextCurrencySymbol) {
1319
1429
  tempOrder.currency_symbol = nextCurrencySymbol;
@@ -1325,27 +1435,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1325
1435
  }, {
1326
1436
  key: "initialize",
1327
1437
  value: function () {
1328
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1329
- var _this$otherParams4,
1438
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
1439
+ var _this$otherParams10,
1330
1440
  _this$appPlugin2,
1331
1441
  _this$appPlugin2$getA,
1332
1442
  _this9 = this,
1333
- _this$otherParams5;
1443
+ _this$otherParams11;
1334
1444
  var options,
1335
1445
  app,
1336
1446
  targetCacheData,
1337
1447
  moduleNames,
1338
- _args11 = arguments;
1339
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1340
- while (1) switch (_context11.prev = _context11.next) {
1448
+ _args12 = arguments;
1449
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1450
+ while (1) switch (_context12.prev = _context12.next) {
1341
1451
  case 0:
1342
- options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1452
+ options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
1343
1453
  this.core = core;
1344
1454
  this.initializeOptions = options || {};
1345
1455
  this.paymentNumberDevicePrefix = null;
1346
1456
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1347
1457
  this.otherParams = options.otherParams || {};
1348
- this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
1458
+ this.cacheId = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.cacheId;
1349
1459
  this.reusedSharedSubModuleNames.clear();
1350
1460
  this.window = core.getPlugin('window');
1351
1461
  this.request = core.getPlugin('request');
@@ -1381,27 +1491,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1381
1491
  }));
1382
1492
  });
1383
1493
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1384
- _context11.next = 19;
1494
+ _context12.next = 19;
1385
1495
  break;
1386
1496
  }
1387
- _context11.next = 19;
1497
+ _context12.next = 19;
1388
1498
  return this.store.schedule.loadAllSchedule();
1389
1499
  case 19:
1390
- if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
1500
+ if (this.store.order && typeof ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableTempOrderPersist) === 'boolean') {
1391
1501
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1392
1502
  }
1393
- _context11.next = 22;
1503
+ _context12.next = 22;
1394
1504
  return this.getPaymentMethodsAsync();
1395
1505
  case 22:
1396
1506
  this.registerServerOrderChangeSync();
1397
1507
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1398
1508
  case 24:
1399
1509
  case "end":
1400
- return _context11.stop();
1510
+ return _context12.stop();
1401
1511
  }
1402
- }, _callee11, this);
1512
+ }, _callee12, this);
1403
1513
  }));
1404
- function initialize(_x11) {
1514
+ function initialize(_x12) {
1405
1515
  return _initialize.apply(this, arguments);
1406
1516
  }
1407
1517
  return initialize;
@@ -1409,11 +1519,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1409
1519
  }, {
1410
1520
  key: "destroy",
1411
1521
  value: function () {
1412
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1522
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1413
1523
  var _this$serverOrderChan2,
1414
1524
  _this10 = this;
1415
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1416
- while (1) switch (_context12.prev = _context12.next) {
1525
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1526
+ while (1) switch (_context13.prev = _context13.next) {
1417
1527
  case 0:
1418
1528
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1419
1529
  this.serverOrderChangeUnsubscribe = null;
@@ -1433,15 +1543,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1433
1543
  this.queuedServerOrderChanges = [];
1434
1544
  this.salesDetailLoadSequence += 1;
1435
1545
  this.walletAssetsRefreshSequence += 1;
1436
- _context12.next = 10;
1546
+ _context13.next = 10;
1437
1547
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1438
1548
  case 10:
1439
1549
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1440
1550
  case 11:
1441
1551
  case "end":
1442
- return _context12.stop();
1552
+ return _context13.stop();
1443
1553
  }
1444
- }, _callee12, this);
1554
+ }, _callee13, this);
1445
1555
  }));
1446
1556
  function destroy() {
1447
1557
  return _destroy.apply(this, arguments);
@@ -1458,51 +1568,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1458
1568
  }, {
1459
1569
  key: "loadSalesDetail",
1460
1570
  value: (function () {
1461
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1462
- var loadSequence, _ref24, _ref25, _ref26, _ref27, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
1463
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1464
- while (1) switch (_context13.prev = _context13.next) {
1571
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
1572
+ var loadSequence, _ref31, _ref32, _ref33, _ref34, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
1573
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1574
+ while (1) switch (_context14.prev = _context14.next) {
1465
1575
  case 0:
1466
1576
  if (this.store.order) {
1467
- _context13.next = 2;
1577
+ _context14.next = 2;
1468
1578
  break;
1469
1579
  }
1470
1580
  throw new Error('order 模块未初始化');
1471
1581
  case 2:
1472
1582
  loadSequence = ++this.salesDetailLoadSequence;
1473
1583
  this.salesDetailLoadInFlightCount += 1;
1474
- _context13.prev = 4;
1584
+ _context14.prev = 4;
1475
1585
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
1476
1586
  orderId: orderIdOrParams
1477
1587
  };
1478
1588
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1479
1589
  preloadedSalesDetail = params.preloadedSalesDetail;
1480
- lookup = (_ref24 = (_ref25 = (_ref26 = (_ref27 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref27 !== void 0 ? _ref27 : params.orderNumber) !== null && _ref26 !== void 0 ? _ref26 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref25 !== void 0 ? _ref25 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref24 !== void 0 ? _ref24 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1590
+ lookup = (_ref31 = (_ref32 = (_ref33 = (_ref34 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref34 !== void 0 ? _ref34 : params.orderNumber) !== null && _ref33 !== void 0 ? _ref33 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref32 !== void 0 ? _ref32 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref31 !== void 0 ? _ref31 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1481
1591
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1482
- _context13.next = 11;
1592
+ _context14.next = 11;
1483
1593
  break;
1484
1594
  }
1485
1595
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
1486
1596
  case 11:
1487
1597
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
1488
- _context13.next = 15;
1598
+ _context14.next = 15;
1489
1599
  break;
1490
1600
  }
1491
- _context13.t0 = preloadedSalesDetail;
1492
- _context13.next = 18;
1601
+ _context14.t0 = preloadedSalesDetail;
1602
+ _context14.next = 18;
1493
1603
  break;
1494
1604
  case 15:
1495
- _context13.next = 17;
1605
+ _context14.next = 17;
1496
1606
  return this.store.order.getSalesOrderByLookup({
1497
1607
  lookup: lookup,
1498
1608
  forceRemote: params.forceRemote
1499
1609
  });
1500
1610
  case 17:
1501
- _context13.t0 = _context13.sent;
1611
+ _context14.t0 = _context14.sent;
1502
1612
  case 18:
1503
- loadedRecord = _context13.t0;
1613
+ loadedRecord = _context14.t0;
1504
1614
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
1505
- _context13.next = 22;
1615
+ _context14.next = 22;
1506
1616
  break;
1507
1617
  }
1508
1618
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
@@ -1514,38 +1624,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1514
1624
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1515
1625
  mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1516
1626
  record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
1517
- _context13.next = 30;
1627
+ _context14.next = 30;
1518
1628
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence, params.hydrateSource);
1519
1629
  case 30:
1520
- return _context13.abrupt("return", _context13.sent);
1630
+ return _context14.abrupt("return", _context14.sent);
1521
1631
  case 31:
1522
- _context13.prev = 31;
1632
+ _context14.prev = 31;
1523
1633
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1524
1634
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1525
- _context13.next = 42;
1635
+ _context14.next = 42;
1526
1636
  break;
1527
1637
  }
1528
- _context13.prev = 34;
1529
- _context13.next = 37;
1638
+ _context14.prev = 34;
1639
+ _context14.next = 37;
1530
1640
  return this.drainQueuedServerOrderChanges();
1531
1641
  case 37:
1532
- _context13.next = 42;
1642
+ _context14.next = 42;
1533
1643
  break;
1534
1644
  case 39:
1535
- _context13.prev = 39;
1536
- _context13.t1 = _context13["catch"](34);
1645
+ _context14.prev = 39;
1646
+ _context14.t1 = _context14["catch"](34);
1537
1647
  this.logError('drain queued server order changes failed', {
1538
- error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1648
+ error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
1539
1649
  });
1540
1650
  case 42:
1541
- return _context13.finish(31);
1651
+ return _context14.finish(31);
1542
1652
  case 43:
1543
1653
  case "end":
1544
- return _context13.stop();
1654
+ return _context14.stop();
1545
1655
  }
1546
- }, _callee13, this, [[4,, 31, 43], [34, 39]]);
1656
+ }, _callee14, this, [[4,, 31, 43], [34, 39]]);
1547
1657
  }));
1548
- function loadSalesDetail(_x12) {
1658
+ function loadSalesDetail(_x13) {
1549
1659
  return _loadSalesDetail.apply(this, arguments);
1550
1660
  }
1551
1661
  return loadSalesDetail;
@@ -1625,34 +1735,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1625
1735
  }, {
1626
1736
  key: "replaceTempOrder",
1627
1737
  value: function () {
1628
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
1738
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
1629
1739
  var nextTempOrder;
1630
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1631
- while (1) switch (_context14.prev = _context14.next) {
1740
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1741
+ while (1) switch (_context15.prev = _context15.next) {
1632
1742
  case 0:
1633
1743
  if (this.store.order) {
1634
- _context14.next = 2;
1744
+ _context15.next = 2;
1635
1745
  break;
1636
1746
  }
1637
1747
  throw new Error('order 模块未初始化');
1638
1748
  case 2:
1639
- _context14.next = 4;
1640
- return this.store.order.replaceTempOrder(tempOrder);
1749
+ _context15.next = 4;
1750
+ return this.store.order.replaceTempOrder(tempOrder, options);
1641
1751
  case 4:
1642
- nextTempOrder = _context14.sent;
1643
- _context14.next = 7;
1752
+ nextTempOrder = _context15.sent;
1753
+ _context15.next = 7;
1644
1754
  return this.effectsEmit('onTempOrderReplaced', {
1645
1755
  tempOrder: nextTempOrder
1646
1756
  });
1647
1757
  case 7:
1648
- return _context14.abrupt("return", nextTempOrder);
1758
+ return _context15.abrupt("return", nextTempOrder);
1649
1759
  case 8:
1650
1760
  case "end":
1651
- return _context14.stop();
1761
+ return _context15.stop();
1652
1762
  }
1653
- }, _callee14, this);
1763
+ }, _callee15, this);
1654
1764
  }));
1655
- function replaceTempOrder(_x13) {
1765
+ function replaceTempOrder(_x14, _x15) {
1656
1766
  return _replaceTempOrder.apply(this, arguments);
1657
1767
  }
1658
1768
  return replaceTempOrder;
@@ -1750,40 +1860,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1750
1860
  }, {
1751
1861
  key: "addNewOrder",
1752
1862
  value: function () {
1753
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1863
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1754
1864
  var tempOrder;
1755
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1756
- while (1) switch (_context15.prev = _context15.next) {
1865
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1866
+ while (1) switch (_context16.prev = _context16.next) {
1757
1867
  case 0:
1758
- _context15.prev = 0;
1868
+ _context16.prev = 0;
1759
1869
  if (this.store.order) {
1760
- _context15.next = 3;
1870
+ _context16.next = 3;
1761
1871
  break;
1762
1872
  }
1763
1873
  throw new Error('order 模块未初始化');
1764
1874
  case 3:
1765
- _context15.next = 5;
1875
+ _context16.next = 5;
1766
1876
  return this.store.order.addNewOrder();
1767
1877
  case 5:
1768
- tempOrder = _context15.sent;
1878
+ tempOrder = _context16.sent;
1769
1879
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1770
- _context15.next = 10;
1880
+ _context16.next = 10;
1771
1881
  break;
1772
1882
  }
1773
1883
  this.store.order.persistTempOrder();
1774
- _context15.next = 10;
1884
+ _context16.next = 10;
1775
1885
  return this.store.order.saveDraft();
1776
1886
  case 10:
1777
- return _context15.abrupt("return", tempOrder);
1887
+ return _context16.abrupt("return", tempOrder);
1778
1888
  case 13:
1779
- _context15.prev = 13;
1780
- _context15.t0 = _context15["catch"](0);
1781
- throw _context15.t0;
1889
+ _context16.prev = 13;
1890
+ _context16.t0 = _context16["catch"](0);
1891
+ throw _context16.t0;
1782
1892
  case 16:
1783
1893
  case "end":
1784
- return _context15.stop();
1894
+ return _context16.stop();
1785
1895
  }
1786
- }, _callee15, this, [[0, 13]]);
1896
+ }, _callee16, this, [[0, 13]]);
1787
1897
  }));
1788
1898
  function addNewOrder() {
1789
1899
  return _addNewOrder.apply(this, arguments);
@@ -1793,22 +1903,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1793
1903
  }, {
1794
1904
  key: "saveDraft",
1795
1905
  value: function () {
1796
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1797
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1798
- while (1) switch (_context16.prev = _context16.next) {
1906
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1907
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1908
+ while (1) switch (_context17.prev = _context17.next) {
1799
1909
  case 0:
1800
1910
  if (this.store.order) {
1801
- _context16.next = 2;
1911
+ _context17.next = 2;
1802
1912
  break;
1803
1913
  }
1804
1914
  throw new Error('order 模块未初始化');
1805
1915
  case 2:
1806
- return _context16.abrupt("return", this.store.order.saveDraft());
1916
+ return _context17.abrupt("return", this.store.order.saveDraft());
1807
1917
  case 3:
1808
1918
  case "end":
1809
- return _context16.stop();
1919
+ return _context17.stop();
1810
1920
  }
1811
- }, _callee16, this);
1921
+ }, _callee17, this);
1812
1922
  }));
1813
1923
  function saveDraft() {
1814
1924
  return _saveDraft.apply(this, arguments);
@@ -1819,14 +1929,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1819
1929
  }, {
1820
1930
  key: "restoreOrder",
1821
1931
  value: function () {
1822
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1932
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1823
1933
  var _this$store$payment, tempOrder, wallet;
1824
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1825
- while (1) switch (_context17.prev = _context17.next) {
1934
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1935
+ while (1) switch (_context18.prev = _context18.next) {
1826
1936
  case 0:
1827
- _context17.prev = 0;
1937
+ _context18.prev = 0;
1828
1938
  if (this.store.order) {
1829
- _context17.next = 3;
1939
+ _context18.next = 3;
1830
1940
  break;
1831
1941
  }
1832
1942
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -1838,37 +1948,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1838
1948
  this.hasManualDiscountSelection = false;
1839
1949
  wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
1840
1950
  if (!wallet) {
1841
- _context17.next = 13;
1951
+ _context18.next = 13;
1842
1952
  break;
1843
1953
  }
1844
1954
  this.walletAssetsRefreshSequence += 1;
1845
1955
  wallet.clearAllCache();
1846
- _context17.next = 13;
1956
+ _context18.next = 13;
1847
1957
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
1848
1958
  case 13:
1849
- _context17.next = 15;
1959
+ _context18.next = 15;
1850
1960
  return this.effectsEmit('onTempOrderReplaced', {
1851
1961
  tempOrder: tempOrder
1852
1962
  });
1853
1963
  case 15:
1854
1964
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1855
- _context17.next = 19;
1965
+ _context18.next = 19;
1856
1966
  break;
1857
1967
  }
1858
1968
  this.store.order.persistTempOrder();
1859
- _context17.next = 19;
1969
+ _context18.next = 19;
1860
1970
  return this.store.order.saveDraft();
1861
1971
  case 19:
1862
- return _context17.abrupt("return", tempOrder);
1972
+ return _context18.abrupt("return", tempOrder);
1863
1973
  case 22:
1864
- _context17.prev = 22;
1865
- _context17.t0 = _context17["catch"](0);
1866
- throw _context17.t0;
1974
+ _context18.prev = 22;
1975
+ _context18.t0 = _context18["catch"](0);
1976
+ throw _context18.t0;
1867
1977
  case 25:
1868
1978
  case "end":
1869
- return _context17.stop();
1979
+ return _context18.stop();
1870
1980
  }
1871
- }, _callee17, this, [[0, 22]]);
1981
+ }, _callee18, this, [[0, 22]]);
1872
1982
  }));
1873
1983
  function restoreOrder() {
1874
1984
  return _restoreOrder.apply(this, arguments);
@@ -1882,22 +1992,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1882
1992
  }, {
1883
1993
  key: "clearOrderCartLines",
1884
1994
  value: (function () {
1885
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1995
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1886
1996
  var tempOrder;
1887
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1888
- while (1) switch (_context18.prev = _context18.next) {
1997
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1998
+ while (1) switch (_context19.prev = _context19.next) {
1889
1999
  case 0:
1890
- _context18.prev = 0;
2000
+ _context19.prev = 0;
1891
2001
  if (this.store.order) {
1892
- _context18.next = 3;
2002
+ _context19.next = 3;
1893
2003
  break;
1894
2004
  }
1895
2005
  throw new Error('order 模块未初始化');
1896
2006
  case 3:
1897
- _context18.next = 5;
2007
+ _context19.next = 5;
1898
2008
  return this.store.order.clearOrderCartLines();
1899
2009
  case 5:
1900
- tempOrder = _context18.sent;
2010
+ tempOrder = _context19.sent;
1901
2011
  if (this.currentSalesDetail) {
1902
2012
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1903
2013
  products: [],
@@ -1907,34 +2017,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1907
2017
  discount_list: []
1908
2018
  });
1909
2019
  }
1910
- _context18.next = 9;
2020
+ _context19.next = 9;
1911
2021
  return this.effectsEmit('onTempOrderReplaced', {
1912
2022
  tempOrder: tempOrder
1913
2023
  });
1914
2024
  case 9:
1915
2025
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1916
- _context18.next = 13;
2026
+ _context19.next = 13;
1917
2027
  break;
1918
2028
  }
1919
2029
  this.store.order.persistTempOrder();
1920
- _context18.next = 13;
2030
+ _context19.next = 13;
1921
2031
  return this.store.order.saveDraft();
1922
2032
  case 13:
1923
- return _context18.abrupt("return", tempOrder);
2033
+ return _context19.abrupt("return", tempOrder);
1924
2034
  case 16:
1925
- _context18.prev = 16;
1926
- _context18.t0 = _context18["catch"](0);
1927
- throw _context18.t0;
2035
+ _context19.prev = 16;
2036
+ _context19.t0 = _context19["catch"](0);
2037
+ throw _context19.t0;
1928
2038
  case 19:
1929
2039
  case "end":
1930
- return _context18.stop();
2040
+ return _context19.stop();
1931
2041
  }
1932
- }, _callee18, this, [[0, 16]]);
2042
+ }, _callee19, this, [[0, 16]]);
1933
2043
  }));
1934
2044
  function clearOrderCartLines() {
1935
2045
  return _clearOrderCartLines.apply(this, arguments);
1936
2046
  }
1937
2047
  return clearOrderCartLines;
2048
+ }() /** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */)
2049
+ }, {
2050
+ key: "clearOrderForSettlementSwitch",
2051
+ value: (function () {
2052
+ var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2053
+ var tempOrder;
2054
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2055
+ while (1) switch (_context20.prev = _context20.next) {
2056
+ case 0:
2057
+ if (this.store.order) {
2058
+ _context20.next = 2;
2059
+ break;
2060
+ }
2061
+ throw new Error('order 模块未初始化');
2062
+ case 2:
2063
+ _context20.next = 4;
2064
+ return this.store.order.clearOrderForSettlementSwitch();
2065
+ case 4:
2066
+ tempOrder = _context20.sent;
2067
+ if (this.currentSalesDetail) {
2068
+ this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2069
+ products: [],
2070
+ bookings: [],
2071
+ rootBooking: null,
2072
+ bookingsByProductUid: {},
2073
+ discount_list: [],
2074
+ payments: []
2075
+ });
2076
+ }
2077
+ return _context20.abrupt("return", tempOrder);
2078
+ case 7:
2079
+ case "end":
2080
+ return _context20.stop();
2081
+ }
2082
+ }, _callee20, this);
2083
+ }));
2084
+ function clearOrderForSettlementSwitch() {
2085
+ return _clearOrderForSettlementSwitch.apply(this, arguments);
2086
+ }
2087
+ return clearOrderForSettlementSwitch;
1938
2088
  }())
1939
2089
  }, {
1940
2090
  key: "getOrderProducts",
@@ -1946,32 +2096,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1946
2096
  }, {
1947
2097
  key: "getSummary",
1948
2098
  value: function () {
1949
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2099
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1950
2100
  var summary;
1951
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1952
- while (1) switch (_context19.prev = _context19.next) {
2101
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2102
+ while (1) switch (_context21.prev = _context21.next) {
1953
2103
  case 0:
1954
- _context19.prev = 0;
2104
+ _context21.prev = 0;
1955
2105
  if (this.store.order) {
1956
- _context19.next = 3;
2106
+ _context21.next = 3;
1957
2107
  break;
1958
2108
  }
1959
2109
  throw new Error('order 模块未初始化');
1960
2110
  case 3:
1961
- _context19.next = 5;
2111
+ _context21.next = 5;
1962
2112
  return this.store.order.getOrderSummary();
1963
2113
  case 5:
1964
- summary = _context19.sent;
1965
- return _context19.abrupt("return", summary);
2114
+ summary = _context21.sent;
2115
+ return _context21.abrupt("return", summary);
1966
2116
  case 9:
1967
- _context19.prev = 9;
1968
- _context19.t0 = _context19["catch"](0);
1969
- throw _context19.t0;
2117
+ _context21.prev = 9;
2118
+ _context21.t0 = _context21["catch"](0);
2119
+ throw _context21.t0;
1970
2120
  case 12:
1971
2121
  case "end":
1972
- return _context19.stop();
2122
+ return _context21.stop();
1973
2123
  }
1974
- }, _callee19, this, [[0, 9]]);
2124
+ }, _callee21, this, [[0, 9]]);
1975
2125
  }));
1976
2126
  function getSummary() {
1977
2127
  return _getSummary.apply(this, arguments);
@@ -2088,14 +2238,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2088
2238
  }, {
2089
2239
  key: "loadDiscountConfig",
2090
2240
  value: function () {
2091
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2241
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2092
2242
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
2093
- 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;
2094
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2095
- while (1) switch (_context20.prev = _context20.next) {
2243
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, 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;
2244
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2245
+ while (1) switch (_context22.prev = _context22.next) {
2096
2246
  case 0:
2097
2247
  if (this.store.order) {
2098
- _context20.next = 2;
2248
+ _context22.next = 2;
2099
2249
  break;
2100
2250
  }
2101
2251
  throw new Error('order 模块未初始化');
@@ -2115,18 +2265,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2115
2265
  discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
2116
2266
  preparedDiscountList = [];
2117
2267
  if (!(customerId && customerId !== 1)) {
2118
- _context20.next = 25;
2268
+ _context22.next = 25;
2119
2269
  break;
2120
2270
  }
2121
- if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
2122
- _context20.next = 19;
2271
+ if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
2272
+ _context22.next = 19;
2123
2273
  break;
2124
2274
  }
2125
2275
  preparedDiscountList = originalDiscountList;
2126
- _context20.next = 25;
2276
+ _context22.next = 25;
2127
2277
  break;
2128
2278
  case 19:
2129
- _context20.next = 21;
2279
+ _context22.next = 21;
2130
2280
  return this.store.order.loadDiscountConfig({
2131
2281
  customerId: customerId,
2132
2282
  action: discountAction,
@@ -2134,26 +2284,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2134
2284
  apply: false
2135
2285
  });
2136
2286
  case 21:
2137
- preparedDiscountList = _context20.sent;
2287
+ preparedDiscountList = _context22.sent;
2138
2288
  this.discountConfigCacheKey = discountConfigCacheKey;
2139
- _context20.next = 25;
2289
+ _context22.next = 25;
2140
2290
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2141
2291
  case 25:
2292
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
2293
+ _context22.next = 33;
2294
+ break;
2295
+ }
2296
+ _context22.next = 28;
2297
+ return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
2298
+ case 28:
2299
+ _context22.next = 30;
2300
+ return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
2301
+ case 30:
2302
+ tempOrder.discount_list = [];
2303
+ tempOrder.shop_discount = '0.00';
2304
+ return _context22.abrupt("return", {
2305
+ productList: tempOrder.products || [],
2306
+ discountList: [],
2307
+ availableWalletIds: this.getAvailableWalletIds(),
2308
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2309
+ });
2310
+ case 33:
2142
2311
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
2143
- _context20.next = 27;
2312
+ _context22.next = 35;
2144
2313
  break;
2145
2314
  }
2146
- return _context20.abrupt("return", {
2315
+ return _context22.abrupt("return", {
2147
2316
  productList: tempOrder.products || [],
2148
2317
  discountList: currentDiscountList,
2149
- availableWalletIds: this.getAvailableWalletIds()
2318
+ availableWalletIds: this.getAvailableWalletIds(),
2319
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2150
2320
  });
2151
- case 27:
2321
+ case 35:
2152
2322
  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 || []);
2153
2323
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2154
- _context20.next = 31;
2324
+ _context22.next = 39;
2155
2325
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2156
- case 31:
2326
+ case 39:
2157
2327
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
2158
2328
  discountAction: discountAction,
2159
2329
  products: tempOrder.products || [],
@@ -2161,32 +2331,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2161
2331
  nextDiscountList: nextDiscountList
2162
2332
  });
2163
2333
  if (!shouldSkipAutoApplyFetchedDiscounts) {
2164
- _context20.next = 40;
2334
+ _context22.next = 48;
2165
2335
  break;
2166
2336
  }
2167
- _context20.next = 35;
2337
+ _context22.next = 43;
2168
2338
  return this.store.order.recalculateSummary({
2169
2339
  createIfMissing: true
2170
2340
  });
2171
- case 35:
2172
- _summary = _context20.sent;
2341
+ case 43:
2342
+ _summary = _context22.sent;
2173
2343
  this.store.order.persistTempOrder();
2174
- _context20.next = 39;
2344
+ _context22.next = 47;
2175
2345
  return this.effectsEmit('onDiscountApplied', {
2176
2346
  productList: tempOrder.products || [],
2177
2347
  discountList: nextDiscountList,
2178
2348
  selectedDiscountList: tempOrder.discount_list || [],
2179
2349
  tempOrder: tempOrder
2180
2350
  });
2181
- case 39:
2182
- return _context20.abrupt("return", {
2351
+ case 47:
2352
+ return _context22.abrupt("return", {
2183
2353
  productList: tempOrder.products || [],
2184
2354
  discountList: nextDiscountList,
2185
- availableWalletIds: this.getAvailableWalletIds()
2355
+ availableWalletIds: this.getAvailableWalletIds(),
2356
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2186
2357
  });
2187
- case 40:
2358
+ case 48:
2188
2359
  if (!rulesModule) {
2189
- _context20.next = 77;
2360
+ _context22.next = 85;
2190
2361
  break;
2191
2362
  }
2192
2363
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
@@ -2207,22 +2378,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2207
2378
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2208
2379
  }
2209
2380
  _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
2210
- _context20.prev = 46;
2381
+ _context22.prev = 54;
2211
2382
  _iterator2.s();
2212
- case 48:
2383
+ case 56:
2213
2384
  if ((_step2 = _iterator2.n()).done) {
2214
- _context20.next = 63;
2385
+ _context22.next = 71;
2215
2386
  break;
2216
2387
  }
2217
2388
  product = _step2.value;
2218
2389
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2219
2390
  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;
2220
2391
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2221
- _context20.next = 54;
2392
+ _context22.next = 62;
2222
2393
  break;
2223
2394
  }
2224
- return _context20.abrupt("continue", 61);
2225
- case 54:
2395
+ return _context22.abrupt("continue", 69);
2396
+ case 62:
2226
2397
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2227
2398
  return sum + Number(pd.amount || 0);
2228
2399
  }, 0);
@@ -2238,61 +2409,62 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2238
2409
  mainPrice: newMainSellingPrice,
2239
2410
  bundle: product.product_bundle
2240
2411
  });
2241
- case 61:
2242
- _context20.next = 48;
2412
+ case 69:
2413
+ _context22.next = 56;
2243
2414
  break;
2244
- case 63:
2245
- _context20.next = 68;
2415
+ case 71:
2416
+ _context22.next = 76;
2246
2417
  break;
2247
- case 65:
2248
- _context20.prev = 65;
2249
- _context20.t0 = _context20["catch"](46);
2250
- _iterator2.e(_context20.t0);
2251
- case 68:
2252
- _context20.prev = 68;
2418
+ case 73:
2419
+ _context22.prev = 73;
2420
+ _context22.t0 = _context22["catch"](54);
2421
+ _iterator2.e(_context22.t0);
2422
+ case 76:
2423
+ _context22.prev = 76;
2253
2424
  _iterator2.f();
2254
- return _context20.finish(68);
2255
- case 71:
2425
+ return _context22.finish(76);
2426
+ case 79:
2256
2427
  if (!result.discountList) {
2257
- _context20.next = 77;
2428
+ _context22.next = 85;
2258
2429
  break;
2259
2430
  }
2260
2431
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2261
2432
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2262
- _context20.next = 76;
2433
+ _context22.next = 84;
2263
2434
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2264
- case 76:
2435
+ case 84:
2265
2436
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2266
2437
  return discount.isSelected;
2267
2438
  });
2268
- case 77:
2269
- _context20.next = 79;
2439
+ case 85:
2440
+ _context22.next = 87;
2270
2441
  return this.store.order.recalculateSummary({
2271
2442
  createIfMissing: true
2272
2443
  });
2273
- case 79:
2274
- summary = _context20.sent;
2444
+ case 87:
2445
+ summary = _context22.sent;
2275
2446
  this.store.order.persistTempOrder();
2276
- _context20.next = 83;
2447
+ _context22.next = 91;
2277
2448
  return this.effectsEmit('onDiscountApplied', {
2278
2449
  productList: tempOrder.products || [],
2279
2450
  discountList: nextDiscountList,
2280
2451
  selectedDiscountList: tempOrder.discount_list || [],
2281
2452
  tempOrder: tempOrder
2282
2453
  });
2283
- case 83:
2284
- return _context20.abrupt("return", {
2454
+ case 91:
2455
+ return _context22.abrupt("return", {
2285
2456
  productList: tempOrder.products || [],
2286
2457
  discountList: nextDiscountList,
2287
- availableWalletIds: this.getAvailableWalletIds()
2458
+ availableWalletIds: this.getAvailableWalletIds(),
2459
+ virtualCurrencyList: this.store.order.getVirtualCurrencyList()
2288
2460
  });
2289
- case 84:
2461
+ case 92:
2290
2462
  case "end":
2291
- return _context20.stop();
2463
+ return _context22.stop();
2292
2464
  }
2293
- }, _callee20, this, [[46, 65, 68, 71]]);
2465
+ }, _callee22, this, [[54, 73, 76, 79]]);
2294
2466
  }));
2295
- function loadDiscountConfig(_x14) {
2467
+ function loadDiscountConfig(_x16) {
2296
2468
  return _loadDiscountConfig.apply(this, arguments);
2297
2469
  }
2298
2470
  return loadDiscountConfig;
@@ -2304,22 +2476,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2304
2476
  if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2305
2477
  return this.store.order.getAvailableWalletIds();
2306
2478
  }
2479
+ }, {
2480
+ key: "getVirtualCurrencyList",
2481
+ value: function getVirtualCurrencyList() {
2482
+ var _this$store$order5;
2483
+ if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && _this$store$order5.getVirtualCurrencyList)) return [];
2484
+ return this.store.order.getVirtualCurrencyList();
2485
+ }
2307
2486
  }, {
2308
2487
  key: "bestDiscount",
2309
2488
  value: function () {
2310
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
2489
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(cb) {
2311
2490
  var _discountModule$getOr2, _discountModule$getDi3;
2312
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2313
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2314
- while (1) switch (_context21.prev = _context21.next) {
2491
+ var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2492
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2493
+ while (1) switch (_context23.prev = _context23.next) {
2315
2494
  case 0:
2316
2495
  if (this.store.order) {
2317
- _context21.next = 2;
2496
+ _context23.next = 2;
2318
2497
  break;
2319
2498
  }
2320
2499
  throw new Error('order 模块未初始化');
2321
2500
  case 2:
2322
2501
  tempOrder = this.store.order.ensureTempOrder();
2502
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
2503
+ _context23.next = 7;
2504
+ break;
2505
+ }
2506
+ _result2 = {
2507
+ productList: tempOrder.products || [],
2508
+ discountList: []
2509
+ };
2510
+ cb === null || cb === void 0 || cb(_result2);
2511
+ return _context23.abrupt("return", _result2);
2512
+ case 7:
2323
2513
  orderStore = this.store.order.store || {};
2324
2514
  discountModule = orderStore.discount;
2325
2515
  rulesModule = orderStore.rules;
@@ -2330,11 +2520,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2330
2520
  productList: tempOrder.products || [],
2331
2521
  discountList: nextDiscountList
2332
2522
  };
2333
- _context21.next = 12;
2523
+ _context23.next = 16;
2334
2524
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2335
- case 12:
2525
+ case 16:
2336
2526
  if (!rulesModule) {
2337
- _context21.next = 24;
2527
+ _context23.next = 28;
2338
2528
  break;
2339
2529
  }
2340
2530
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -2352,14 +2542,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2352
2542
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2353
2543
  }
2354
2544
  if (!result.discountList) {
2355
- _context21.next = 24;
2545
+ _context23.next = 28;
2356
2546
  break;
2357
2547
  }
2358
2548
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2359
2549
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2360
- _context21.next = 22;
2550
+ _context23.next = 26;
2361
2551
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2362
- case 22:
2552
+ case 26:
2363
2553
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2364
2554
  return discount.isSelected;
2365
2555
  });
@@ -2367,30 +2557,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2367
2557
  productList: tempOrder.products,
2368
2558
  discountList: nextDiscountList
2369
2559
  };
2370
- case 24:
2371
- _context21.next = 26;
2560
+ case 28:
2561
+ _context23.next = 30;
2372
2562
  return this.store.order.recalculateSummary({
2373
2563
  createIfMissing: true
2374
2564
  });
2375
- case 26:
2565
+ case 30:
2376
2566
  this.store.order.persistTempOrder();
2377
- _context21.next = 29;
2567
+ _context23.next = 33;
2378
2568
  return this.effectsEmit('onDiscountApplied', {
2379
2569
  productList: tempOrder.products || [],
2380
2570
  discountList: nextDiscountList,
2381
2571
  selectedDiscountList: tempOrder.discount_list || [],
2382
2572
  tempOrder: tempOrder
2383
2573
  });
2384
- case 29:
2574
+ case 33:
2385
2575
  cb === null || cb === void 0 || cb(result);
2386
- return _context21.abrupt("return", result);
2387
- case 31:
2576
+ return _context23.abrupt("return", result);
2577
+ case 35:
2388
2578
  case "end":
2389
- return _context21.stop();
2579
+ return _context23.stop();
2390
2580
  }
2391
- }, _callee21, this);
2581
+ }, _callee23, this);
2392
2582
  }));
2393
- function bestDiscount(_x15) {
2583
+ function bestDiscount(_x17) {
2394
2584
  return _bestDiscount.apply(this, arguments);
2395
2585
  }
2396
2586
  return bestDiscount;
@@ -2419,41 +2609,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2419
2609
  }, {
2420
2610
  key: "replaceDiscountStoreLists",
2421
2611
  value: (function () {
2422
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2612
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2423
2613
  var _store2;
2424
2614
  var discountModule;
2425
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2426
- while (1) switch (_context22.prev = _context22.next) {
2615
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2616
+ while (1) switch (_context24.prev = _context24.next) {
2427
2617
  case 0:
2428
2618
  if (this.store.order) {
2429
- _context22.next = 2;
2619
+ _context24.next = 2;
2430
2620
  break;
2431
2621
  }
2432
2622
  throw new Error('order 模块未初始化');
2433
2623
  case 2:
2434
2624
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2435
2625
  if (discountModule) {
2436
- _context22.next = 5;
2626
+ _context24.next = 5;
2437
2627
  break;
2438
2628
  }
2439
- return _context22.abrupt("return");
2629
+ return _context24.abrupt("return");
2440
2630
  case 5:
2441
2631
  if (!params.originalDiscountList) {
2442
- _context22.next = 8;
2632
+ _context24.next = 8;
2443
2633
  break;
2444
2634
  }
2445
- _context22.next = 8;
2635
+ _context24.next = 8;
2446
2636
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
2447
2637
  case 8:
2448
- _context22.next = 10;
2638
+ _context24.next = 10;
2449
2639
  return discountModule.setDiscountList(params.discountList);
2450
2640
  case 10:
2451
2641
  case "end":
2452
- return _context22.stop();
2642
+ return _context24.stop();
2453
2643
  }
2454
- }, _callee22, this);
2644
+ }, _callee24, this);
2455
2645
  }));
2456
- function replaceDiscountStoreLists(_x16) {
2646
+ function replaceDiscountStoreLists(_x18) {
2457
2647
  return _replaceDiscountStoreLists.apply(this, arguments);
2458
2648
  }
2459
2649
  return replaceDiscountStoreLists;
@@ -2461,34 +2651,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2461
2651
  }, {
2462
2652
  key: "scanPromotionCode",
2463
2653
  value: function () {
2464
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
2654
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(code, customerId) {
2465
2655
  var raw, tempOrder;
2466
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2467
- while (1) switch (_context23.prev = _context23.next) {
2656
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2657
+ while (1) switch (_context25.prev = _context25.next) {
2468
2658
  case 0:
2469
- _context23.prev = 0;
2659
+ _context25.prev = 0;
2470
2660
  if (this.store.order) {
2471
- _context23.next = 3;
2661
+ _context25.next = 3;
2472
2662
  break;
2473
2663
  }
2474
2664
  throw new Error('order 模块未初始化');
2475
2665
  case 3:
2476
- _context23.next = 5;
2666
+ _context25.next = 5;
2477
2667
  return this.store.order.scanCode(code, customerId);
2478
2668
  case 5:
2479
- raw = _context23.sent;
2669
+ raw = _context25.sent;
2480
2670
  if (!raw.isAvailable) {
2481
- _context23.next = 13;
2671
+ _context25.next = 13;
2482
2672
  break;
2483
2673
  }
2484
- _context23.next = 9;
2674
+ _context25.next = 9;
2485
2675
  return this.store.order.recalculateSummary({
2486
2676
  createIfMissing: true
2487
2677
  });
2488
2678
  case 9:
2489
2679
  this.store.order.persistTempOrder();
2490
2680
  tempOrder = this.store.order.ensureTempOrder();
2491
- _context23.next = 13;
2681
+ _context25.next = 13;
2492
2682
  return this.effectsEmit('onDiscountApplied', {
2493
2683
  productList: tempOrder.products || [],
2494
2684
  discountList: this.store.order.getDiscountList(),
@@ -2496,7 +2686,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2496
2686
  tempOrder: tempOrder
2497
2687
  });
2498
2688
  case 13:
2499
- return _context23.abrupt("return", _objectSpread(_objectSpread({
2689
+ return _context25.abrupt("return", _objectSpread(_objectSpread({
2500
2690
  isAvailable: raw.isAvailable
2501
2691
  }, raw.isAccepted !== undefined ? {
2502
2692
  isAccepted: raw.isAccepted
@@ -2506,16 +2696,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2506
2696
  scannedDiscountList: raw.scannedDiscountList
2507
2697
  }));
2508
2698
  case 16:
2509
- _context23.prev = 16;
2510
- _context23.t0 = _context23["catch"](0);
2511
- throw _context23.t0;
2512
- case 19:
2699
+ _context25.prev = 16;
2700
+ _context25.t0 = _context25["catch"](0);
2701
+ throw _context25.t0;
2702
+ case 19:
2513
2703
  case "end":
2514
- return _context23.stop();
2704
+ return _context25.stop();
2515
2705
  }
2516
- }, _callee23, this, [[0, 16]]);
2706
+ }, _callee25, this, [[0, 16]]);
2517
2707
  }));
2518
- function scanPromotionCode(_x17, _x18) {
2708
+ function scanPromotionCode(_x19, _x20) {
2519
2709
  return _scanPromotionCode.apply(this, arguments);
2520
2710
  }
2521
2711
  return scanPromotionCode;
@@ -2523,18 +2713,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2523
2713
  }, {
2524
2714
  key: "setDiscountSelected",
2525
2715
  value: function () {
2526
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2527
- 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;
2528
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2529
- while (1) switch (_context24.prev = _context24.next) {
2716
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2717
+ var currentOrder, _store3, _store3$setDiscountLi, 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;
2718
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2719
+ while (1) switch (_context26.prev = _context26.next) {
2530
2720
  case 0:
2531
- _context24.prev = 0;
2721
+ _context26.prev = 0;
2532
2722
  if (this.store.order) {
2533
- _context24.next = 3;
2723
+ _context26.next = 3;
2534
2724
  break;
2535
2725
  }
2536
2726
  throw new Error('order 模块未初始化');
2537
2727
  case 3:
2728
+ currentOrder = this.store.order.ensureTempOrder();
2729
+ if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
2730
+ _context26.next = 13;
2731
+ break;
2732
+ }
2733
+ currentOrder.discount_list = [];
2734
+ currentOrder.shop_discount = '0.00';
2735
+ _context26.next = 9;
2736
+ return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
2737
+ case 9:
2738
+ _context26.next = 11;
2739
+ return this.store.order.recalculateSummary({
2740
+ createIfMissing: true
2741
+ });
2742
+ case 11:
2743
+ this.store.order.persistTempOrder();
2744
+ return _context26.abrupt("return");
2745
+ case 13:
2538
2746
  list = this.store.order.getDiscountList();
2539
2747
  updated = list.map(function (d) {
2540
2748
  return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
@@ -2548,9 +2756,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2548
2756
  discountModule = orderStore.discount;
2549
2757
  rulesModule = orderStore.rules;
2550
2758
  nextDiscountList = updated;
2551
- _context24.next = 13;
2759
+ _context26.next = 23;
2552
2760
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2553
- case 13:
2761
+ case 23:
2554
2762
  if (rulesModule) {
2555
2763
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
2556
2764
  console.log('[BaseSales.setDiscountSelected.calcDiscount]');
@@ -2611,29 +2819,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2611
2819
  });
2612
2820
  };
2613
2821
  _iterator4 = _createForOfIteratorHelper(tempOrder.products);
2614
- _context24.prev = 17;
2822
+ _context26.prev = 27;
2615
2823
  _iterator4.s();
2616
- case 19:
2824
+ case 29:
2617
2825
  if ((_step4 = _iterator4.n()).done) {
2618
- _context24.next = 36;
2826
+ _context26.next = 46;
2619
2827
  break;
2620
2828
  }
2621
2829
  product = _step4.value;
2622
2830
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
2623
2831
  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;
2624
2832
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2625
- _context24.next = 25;
2833
+ _context26.next = 35;
2626
2834
  break;
2627
2835
  }
2628
- return _context24.abrupt("continue", 34);
2629
- case 25:
2836
+ return _context26.abrupt("continue", 44);
2837
+ case 35:
2630
2838
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2631
2839
  if (Array.isArray(product.product_bundle)) {
2632
2840
  product.product_bundle = product.product_bundle.map(function (bundle) {
2633
- var _ref28, _bundle$original_pric;
2841
+ var _ref35, _bundle$original_pric;
2634
2842
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2635
2843
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2636
- var restoredBundlePrice = (_ref28 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref28 !== void 0 ? _ref28 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2844
+ var restoredBundlePrice = (_ref35 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2637
2845
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2638
2846
  price: restoredBundlePrice,
2639
2847
  bundle_selling_price: restoredBundlePrice
@@ -2660,33 +2868,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2660
2868
  mainPrice: newMainSellingPrice,
2661
2869
  bundle: product.product_bundle
2662
2870
  });
2663
- case 34:
2664
- _context24.next = 19;
2871
+ case 44:
2872
+ _context26.next = 29;
2665
2873
  break;
2666
- case 36:
2667
- _context24.next = 41;
2874
+ case 46:
2875
+ _context26.next = 51;
2668
2876
  break;
2669
- case 38:
2670
- _context24.prev = 38;
2671
- _context24.t0 = _context24["catch"](17);
2672
- _iterator4.e(_context24.t0);
2673
- case 41:
2674
- _context24.prev = 41;
2877
+ case 48:
2878
+ _context26.prev = 48;
2879
+ _context26.t0 = _context26["catch"](27);
2880
+ _iterator4.e(_context26.t0);
2881
+ case 51:
2882
+ _context26.prev = 51;
2675
2883
  _iterator4.f();
2676
- return _context24.finish(41);
2677
- case 44:
2884
+ return _context26.finish(51);
2885
+ case 54:
2678
2886
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2679
- _context24.next = 47;
2887
+ _context26.next = 57;
2680
2888
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2681
- case 47:
2889
+ case 57:
2682
2890
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2683
2891
  return d.isSelected;
2684
2892
  });
2685
- _context24.next = 50;
2893
+ _context26.next = 60;
2686
2894
  return this.store.order.recalculateSummary({
2687
2895
  createIfMissing: true
2688
2896
  });
2689
- case 50:
2897
+ case 60:
2690
2898
  this.store.order.persistTempOrder();
2691
2899
  this.effectsEmit('onDiscountApplied', {
2692
2900
  productList: tempOrder.products,
@@ -2694,19 +2902,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2694
2902
  selectedDiscountList: tempOrder.discount_list,
2695
2903
  tempOrder: tempOrder
2696
2904
  });
2697
- _context24.next = 57;
2905
+ _context26.next = 67;
2698
2906
  break;
2699
- case 54:
2700
- _context24.prev = 54;
2701
- _context24.t1 = _context24["catch"](0);
2702
- throw _context24.t1;
2703
- case 57:
2907
+ case 64:
2908
+ _context26.prev = 64;
2909
+ _context26.t1 = _context26["catch"](0);
2910
+ throw _context26.t1;
2911
+ case 67:
2704
2912
  case "end":
2705
- return _context24.stop();
2913
+ return _context26.stop();
2706
2914
  }
2707
- }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2915
+ }, _callee26, this, [[0, 64], [27, 48, 51, 54]]);
2708
2916
  }));
2709
- function setDiscountSelected(_x19) {
2917
+ function setDiscountSelected(_x21) {
2710
2918
  return _setDiscountSelected.apply(this, arguments);
2711
2919
  }
2712
2920
  return setDiscountSelected;
@@ -2714,23 +2922,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2714
2922
  }, {
2715
2923
  key: "applyDiscountCalculationResult",
2716
2924
  value: function () {
2717
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
2925
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(result) {
2718
2926
  var tempOrder, orderStore, discountModule;
2719
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2720
- while (1) switch (_context25.prev = _context25.next) {
2927
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2928
+ while (1) switch (_context27.prev = _context27.next) {
2721
2929
  case 0:
2722
- _context25.prev = 0;
2930
+ _context27.prev = 0;
2723
2931
  if (this.store.order) {
2724
- _context25.next = 3;
2932
+ _context27.next = 3;
2725
2933
  break;
2726
2934
  }
2727
2935
  throw new Error('order 模块未初始化');
2728
2936
  case 3:
2729
2937
  if (result) {
2730
- _context25.next = 5;
2938
+ _context27.next = 5;
2731
2939
  break;
2732
2940
  }
2733
- return _context25.abrupt("return");
2941
+ return _context27.abrupt("return");
2734
2942
  case 5:
2735
2943
  tempOrder = this.store.order.ensureTempOrder();
2736
2944
  orderStore = this.store.order.store || {};
@@ -2739,24 +2947,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2739
2947
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2740
2948
  }
2741
2949
  if (!result.discountList) {
2742
- _context25.next = 14;
2950
+ _context27.next = 14;
2743
2951
  break;
2744
2952
  }
2745
2953
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
2746
- _context25.next = 13;
2954
+ _context27.next = 13;
2747
2955
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
2748
2956
  case 13:
2749
2957
  tempOrder.discount_list = result.discountList.filter(function (discount) {
2750
2958
  return discount.isSelected;
2751
2959
  });
2752
2960
  case 14:
2753
- _context25.next = 16;
2961
+ _context27.next = 16;
2754
2962
  return this.store.order.recalculateSummary({
2755
2963
  createIfMissing: true
2756
2964
  });
2757
2965
  case 16:
2758
2966
  this.store.order.persistTempOrder();
2759
- _context25.next = 19;
2967
+ _context27.next = 19;
2760
2968
  return this.effectsEmit('onDiscountApplied', {
2761
2969
  productList: tempOrder.products || [],
2762
2970
  discountList: result.discountList || [],
@@ -2764,19 +2972,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2764
2972
  tempOrder: tempOrder
2765
2973
  });
2766
2974
  case 19:
2767
- _context25.next = 24;
2975
+ _context27.next = 24;
2768
2976
  break;
2769
2977
  case 21:
2770
- _context25.prev = 21;
2771
- _context25.t0 = _context25["catch"](0);
2772
- throw _context25.t0;
2978
+ _context27.prev = 21;
2979
+ _context27.t0 = _context27["catch"](0);
2980
+ throw _context27.t0;
2773
2981
  case 24:
2774
2982
  case "end":
2775
- return _context25.stop();
2983
+ return _context27.stop();
2776
2984
  }
2777
- }, _callee25, this, [[0, 21]]);
2985
+ }, _callee27, this, [[0, 21]]);
2778
2986
  }));
2779
- function applyDiscountCalculationResult(_x20) {
2987
+ function applyDiscountCalculationResult(_x22) {
2780
2988
  return _applyDiscountCalculationResult.apply(this, arguments);
2781
2989
  }
2782
2990
  return applyDiscountCalculationResult;
@@ -2784,22 +2992,155 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2784
2992
  }, {
2785
2993
  key: "submitScanOrder",
2786
2994
  value: function () {
2787
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2788
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2789
- while (1) switch (_context26.prev = _context26.next) {
2995
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2996
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2997
+ while (1) switch (_context28.prev = _context28.next) {
2790
2998
  case 0:
2791
- return _context26.abrupt("return", this.submitSalesOrder(params));
2999
+ return _context28.abrupt("return", this.submitSalesOrder(params));
2792
3000
  case 1:
2793
3001
  case "end":
2794
- return _context26.stop();
3002
+ return _context28.stop();
2795
3003
  }
2796
- }, _callee26, this);
3004
+ }, _callee28, this);
2797
3005
  }));
2798
- function submitScanOrder(_x21) {
3006
+ function submitScanOrder(_x23) {
2799
3007
  return _submitScanOrder.apply(this, arguments);
2800
3008
  }
2801
3009
  return submitScanOrder;
2802
3010
  }()
3011
+ }, {
3012
+ key: "buildVirtualSettlementSubmitData",
3013
+ value: function () {
3014
+ var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3015
+ var _tempOrder$metadata$c, _tempOrder$metadata2, _paymentMethod$custom;
3016
+ var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, paymentMethods, paymentMethod, amountText, payment;
3017
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3018
+ while (1) switch (_context29.prev = _context29.next) {
3019
+ case 0:
3020
+ if (this.store.order) {
3021
+ _context29.next = 2;
3022
+ break;
3023
+ }
3024
+ return _context29.abrupt("return", null);
3025
+ case 2:
3026
+ tempOrder = this.store.order.getTempOrder();
3027
+ if (this.isActiveVirtualSettlementOrder(tempOrder)) {
3028
+ _context29.next = 5;
3029
+ break;
3030
+ }
3031
+ return _context29.abrupt("return", null);
3032
+ case 5:
3033
+ snapshot = getTempOrderSettlementSnapshot(tempOrder);
3034
+ currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
3035
+ if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
3036
+ _context29.next = 9;
3037
+ break;
3038
+ }
3039
+ throw new Error('Virtual currency settlement configuration is invalid.');
3040
+ case 9:
3041
+ _context29.next = 11;
3042
+ return this.store.order.recalculateSummary({
3043
+ createIfMissing: true
3044
+ });
3045
+ case 11:
3046
+ summary = _context29.sent;
3047
+ amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
3048
+ customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
3049
+ if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
3050
+ _context29.next = 17;
3051
+ break;
3052
+ }
3053
+ _context29.next = 17;
3054
+ return this.store.order.loadDiscountConfig({
3055
+ customerId: customerId,
3056
+ action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
3057
+ orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
3058
+ apply: false
3059
+ });
3060
+ case 17:
3061
+ asset = this.store.order.getVirtualCurrencyList().find(function (item) {
3062
+ return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
3063
+ });
3064
+ currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
3065
+ currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
3066
+ currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
3067
+ if (!amount.lte(0)) {
3068
+ _context29.next = 23;
3069
+ break;
3070
+ }
3071
+ return _context29.abrupt("return", {
3072
+ payments: [],
3073
+ snapshot: snapshot,
3074
+ currencyProductId: currencyProductId,
3075
+ currencyCode: currencyCode,
3076
+ currencySymbol: currencySymbol,
3077
+ currencyFormat: currencyFormat
3078
+ });
3079
+ case 23:
3080
+ if (asset) {
3081
+ _context29.next = 25;
3082
+ break;
3083
+ }
3084
+ throw new Error('No matching virtual currency card is available.');
3085
+ case 25:
3086
+ balance = new Decimal(asset.balance || 0);
3087
+ if (!balance.lt(amount)) {
3088
+ _context29.next = 28;
3089
+ break;
3090
+ }
3091
+ throw new Error('Insufficient virtual currency balance.');
3092
+ case 28:
3093
+ _context29.next = 30;
3094
+ return this.getPaymentMethodsAsync();
3095
+ case 30:
3096
+ paymentMethods = _context29.sent;
3097
+ paymentMethod = paymentMethods.find(function (method) {
3098
+ return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
3099
+ });
3100
+ if (paymentMethod) {
3101
+ _context29.next = 34;
3102
+ break;
3103
+ }
3104
+ throw new Error('PRODUCTVOUCHER payment method is unavailable.');
3105
+ case 34:
3106
+ amountText = amount.toFixed(2);
3107
+ payment = {
3108
+ payment_number: "LOCAL_".concat(createUuidV4()),
3109
+ amount: amountText,
3110
+ origin_amount: amountText,
3111
+ code: paymentMethod.code,
3112
+ custom_payment_id: paymentMethod.id,
3113
+ custom_payment_type: (_paymentMethod$custom = paymentMethod.custom_payment_type) !== null && _paymentMethod$custom !== void 0 ? _paymentMethod$custom : paymentMethod.type,
3114
+ name: paymentMethod.name,
3115
+ type: 'normal',
3116
+ voucher_id: asset.id,
3117
+ order_payment_type: 'normal',
3118
+ wallet_pass_usage_unit: {
3119
+ price: 1,
3120
+ points: 1
3121
+ },
3122
+ wallet_pass_use_value: amountText,
3123
+ metadata: {}
3124
+ };
3125
+ return _context29.abrupt("return", {
3126
+ payments: [payment],
3127
+ snapshot: snapshot,
3128
+ currencyProductId: currencyProductId,
3129
+ currencyCode: currencyCode,
3130
+ currencySymbol: currencySymbol,
3131
+ currencyFormat: currencyFormat
3132
+ });
3133
+ case 37:
3134
+ case "end":
3135
+ return _context29.stop();
3136
+ }
3137
+ }, _callee29, this);
3138
+ }));
3139
+ function buildVirtualSettlementSubmitData() {
3140
+ return _buildVirtualSettlementSubmitData.apply(this, arguments);
3141
+ }
3142
+ return buildVirtualSettlementSubmitData;
3143
+ }()
2803
3144
  /**
2804
3145
  * 提交当前 Sales 订单。
2805
3146
  *
@@ -2809,47 +3150,70 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2809
3150
  }, {
2810
3151
  key: "submitSalesOrder",
2811
3152
  value: (function () {
2812
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2813
- var _params$smallTicketDa, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
2814
- var inferredPaymentStatus, smallTicketDataFlag, submitParams;
2815
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2816
- while (1) switch (_context27.prev = _context27.next) {
3153
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3154
+ var _params$smallTicketDa, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15;
3155
+ var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, submitParams;
3156
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3157
+ while (1) switch (_context30.prev = _context30.next) {
2817
3158
  case 0:
2818
3159
  if (this.store.order) {
2819
- _context27.next = 2;
3160
+ _context30.next = 2;
2820
3161
  break;
2821
3162
  }
2822
3163
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2823
3164
  case 2:
3165
+ _context30.next = 4;
3166
+ return this.buildVirtualSettlementSubmitData();
3167
+ case 4:
3168
+ virtualSettlement = _context30.sent;
2824
3169
  // this.store.order.persistTempOrder();
2825
3170
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2826
3171
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
2827
3172
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2828
3173
  cacheId: this.cacheId,
2829
- platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
2830
- businessCode: ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code),
3174
+ platform: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform,
3175
+ businessCode: ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code),
2831
3176
  channel: this.getSubmitOrderSalesChannel(),
2832
- type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
3177
+ type: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.type,
2833
3178
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
2834
- }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
3179
+ }, virtualSettlement ? {
3180
+ payments: virtualSettlement.payments
3181
+ } : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2835
3182
  payments: params.payments
2836
3183
  } : {}), inferredPaymentStatus !== undefined ? {
2837
3184
  paymentStatus: inferredPaymentStatus
2838
3185
  } : {}), smallTicketDataFlag !== undefined ? {
2839
3186
  smallTicketDataFlag: smallTicketDataFlag
2840
- } : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
3187
+ } : {}), virtualSettlement ? {
3188
+ confirmPendingVoucherPayments: false
3189
+ } : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
2841
3190
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
2842
- } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
3191
+ } : {}), virtualSettlement ? {
3192
+ enhancePayload: function enhancePayload(payload, ctx) {
3193
+ var callerPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
3194
+ return _objectSpread(_objectSpread({}, callerPayload), {}, {
3195
+ metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
3196
+ currency_settlement_config: {
3197
+ settlement_type: 'virtual_currency',
3198
+ settlement_ids: [virtualSettlement.currencyProductId]
3199
+ }
3200
+ }),
3201
+ currency_code: virtualSettlement.currencyCode,
3202
+ currency_symbol: virtualSettlement.currencySymbol,
3203
+ currency_format: virtualSettlement.currencyFormat
3204
+ });
3205
+ }
3206
+ } : (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2843
3207
  enhancePayload: params.enhancePayload
2844
3208
  } : {});
2845
- return _context27.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
2846
- case 6:
3209
+ return _context30.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
3210
+ case 9:
2847
3211
  case "end":
2848
- return _context27.stop();
3212
+ return _context30.stop();
2849
3213
  }
2850
- }, _callee27, this);
3214
+ }, _callee30, this);
2851
3215
  }));
2852
- function submitSalesOrder(_x22) {
3216
+ function submitSalesOrder(_x24) {
2853
3217
  return _submitSalesOrder.apply(this, arguments);
2854
3218
  }
2855
3219
  return submitSalesOrder;
@@ -2857,33 +3221,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2857
3221
  }, {
2858
3222
  key: "saveSalesOrderDraft",
2859
3223
  value: function () {
2860
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2861
- var _params$platform, _this$otherParams10, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2862
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2863
- while (1) switch (_context28.prev = _context28.next) {
3224
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3225
+ var _params$platform, _this$otherParams16, _this$otherParams17, _this$otherParams18, _params$channel, _params$type, _this$otherParams19;
3226
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3227
+ while (1) switch (_context31.prev = _context31.next) {
2864
3228
  case 0:
2865
3229
  if (this.store.order) {
2866
- _context28.next = 2;
3230
+ _context31.next = 2;
2867
3231
  break;
2868
3232
  }
2869
3233
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2870
3234
  case 2:
2871
- return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
3235
+ return _context31.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2872
3236
  cacheId: this.cacheId,
2873
- platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2874
- businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
3237
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform,
3238
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.businessCode) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.business_code),
2875
3239
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2876
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
3240
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.type
2877
3241
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2878
3242
  enhancePayload: params.enhancePayload
2879
3243
  } : {})));
2880
3244
  case 3:
2881
3245
  case "end":
2882
- return _context28.stop();
3246
+ return _context31.stop();
2883
3247
  }
2884
- }, _callee28, this);
3248
+ }, _callee31, this);
2885
3249
  }));
2886
- function saveSalesOrderDraft(_x23) {
3250
+ function saveSalesOrderDraft(_x25) {
2887
3251
  return _saveSalesOrderDraft.apply(this, arguments);
2888
3252
  }
2889
3253
  return saveSalesOrderDraft;
@@ -2891,14 +3255,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2891
3255
  }, {
2892
3256
  key: "submitTempOrderAsync",
2893
3257
  value: function () {
2894
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2895
- var _params$smallTicketDa2, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
3258
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3259
+ var _params$smallTicketDa2, _this$otherParams20, _this$otherParams21, _this$otherParams22, _this$otherParams23;
2896
3260
  var inferredPaymentStatus, smallTicketDataFlag, submitParams;
2897
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2898
- while (1) switch (_context29.prev = _context29.next) {
3261
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3262
+ while (1) switch (_context32.prev = _context32.next) {
2899
3263
  case 0:
2900
3264
  if (this.store.order) {
2901
- _context29.next = 2;
3265
+ _context32.next = 2;
2902
3266
  break;
2903
3267
  }
2904
3268
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2907,10 +3271,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2907
3271
  smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
2908
3272
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2909
3273
  cacheId: this.cacheId,
2910
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2911
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
3274
+ platform: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform,
3275
+ businessCode: ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.businessCode) || ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.business_code),
2912
3276
  channel: this.getSubmitOrderSalesChannel(),
2913
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type,
3277
+ type: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.type,
2914
3278
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
2915
3279
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2916
3280
  payments: params.payments
@@ -2923,14 +3287,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2923
3287
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2924
3288
  enhancePayload: params.enhancePayload
2925
3289
  } : {});
2926
- return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
3290
+ return _context32.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2927
3291
  case 6:
2928
3292
  case "end":
2929
- return _context29.stop();
3293
+ return _context32.stop();
2930
3294
  }
2931
- }, _callee29, this);
3295
+ }, _callee32, this);
2932
3296
  }));
2933
- function submitTempOrderAsync(_x24) {
3297
+ function submitTempOrderAsync(_x26) {
2934
3298
  return _submitTempOrderAsync.apply(this, arguments);
2935
3299
  }
2936
3300
  return submitTempOrderAsync;
@@ -2942,8 +3306,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2942
3306
  }, {
2943
3307
  key: "shouldUseCheckoutSyncTask",
2944
3308
  value: function shouldUseCheckoutSyncTask() {
2945
- var _this$otherParams18;
2946
- var configured = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.checkoutSyncTaskEnabled;
3309
+ var _this$otherParams24;
3310
+ var configured = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.checkoutSyncTaskEnabled;
2947
3311
  return typeof configured === 'boolean' ? configured : true;
2948
3312
  }
2949
3313
 
@@ -2956,14 +3320,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2956
3320
  }, {
2957
3321
  key: "printLocalOrderReceipt",
2958
3322
  value: function () {
2959
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2960
- var _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
2961
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2962
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2963
- while (1) switch (_context30.prev = _context30.next) {
3323
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(lookup) {
3324
+ var _this$otherParams25, _this$otherParams26, _this$otherParams27, _this$otherParams28;
3325
+ var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order6, _data;
3326
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3327
+ while (1) switch (_context33.prev = _context33.next) {
2964
3328
  case 0:
2965
3329
  if (this.store.order) {
2966
- _context30.next = 2;
3330
+ _context33.next = 2;
2967
3331
  break;
2968
3332
  }
2969
3333
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2975,10 +3339,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2975
3339
  external_sale_number: lookup
2976
3340
  };
2977
3341
  context = {
2978
- platform: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform,
2979
- 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),
3342
+ platform: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform,
3343
+ businessCode: ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.businessCode) || ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.business_code),
2980
3344
  channel: this.getSubmitOrderSalesChannel(),
2981
- type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
3345
+ type: (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.type
2982
3346
  };
2983
3347
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2984
3348
  lookup_order_from_db: 1,
@@ -2994,28 +3358,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2994
3358
  channel: context.channel,
2995
3359
  type: context.type
2996
3360
  });
2997
- _context30.next = 8;
3361
+ _context33.next = 8;
2998
3362
  return this.request.post('/local/print-order', payload, {
2999
3363
  osServer: true,
3000
3364
  customToast: function customToast() {}
3001
3365
  });
3002
3366
  case 8:
3003
- response = _context30.sent;
3367
+ response = _context33.sent;
3004
3368
  if (hasLookup) {
3005
- _context30.next = 12;
3369
+ _context33.next = 12;
3006
3370
  break;
3007
3371
  }
3008
- _context30.next = 12;
3009
- 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);
3372
+ _context33.next = 12;
3373
+ return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
3010
3374
  case 12:
3011
- return _context30.abrupt("return", response);
3375
+ return _context33.abrupt("return", response);
3012
3376
  case 13:
3013
3377
  case "end":
3014
- return _context30.stop();
3378
+ return _context33.stop();
3015
3379
  }
3016
- }, _callee30, this);
3380
+ }, _callee33, this);
3017
3381
  }));
3018
- function printLocalOrderReceipt(_x25) {
3382
+ function printLocalOrderReceipt(_x27) {
3019
3383
  return _printLocalOrderReceipt.apply(this, arguments);
3020
3384
  }
3021
3385
  return printLocalOrderReceipt;
@@ -3023,9 +3387,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3023
3387
  }, {
3024
3388
  key: "getSubmitPaymentStatus",
3025
3389
  value: function getSubmitPaymentStatus(paymentStatus) {
3026
- var _this$store$order6, _this$store$order6$ge;
3390
+ var _this$store$order7, _this$store$order7$ge;
3027
3391
  if (paymentStatus !== undefined) return paymentStatus;
3028
- var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
3392
+ var amountSnapshot = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderAmountSnapshot) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
3029
3393
  if (!amountSnapshot) return undefined;
3030
3394
  try {
3031
3395
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -3036,19 +3400,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3036
3400
  }, {
3037
3401
  key: "syncPaymentsToOrder",
3038
3402
  value: function () {
3039
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3040
- var _ref29, _params$businessCode, _this$otherParams23, _this$otherParams24, _params$channel2;
3403
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3404
+ var _ref36, _params$businessCode, _this$otherParams29, _this$otherParams30, _params$channel2;
3041
3405
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
3042
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3043
- while (1) switch (_context31.prev = _context31.next) {
3406
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3407
+ while (1) switch (_context34.prev = _context34.next) {
3044
3408
  case 0:
3045
3409
  if (this.store.order) {
3046
- _context31.next = 2;
3410
+ _context34.next = 2;
3047
3411
  break;
3048
3412
  }
3049
3413
  throw new Error('order 模块未初始化');
3050
3414
  case 2:
3051
- businessCode = (_ref29 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) !== null && _ref29 !== void 0 ? _ref29 : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code;
3415
+ businessCode = (_ref36 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.businessCode) !== null && _ref36 !== void 0 ? _ref36 : (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.business_code;
3052
3416
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
3053
3417
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
3054
3418
  checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
@@ -3059,14 +3423,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3059
3423
  } : {});
3060
3424
  syncState = this.store.order.getOrderSyncState();
3061
3425
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
3062
- _context31.next = 9;
3426
+ _context34.next = 9;
3063
3427
  break;
3064
3428
  }
3065
3429
  this.queueLatestAutoPaymentSync();
3066
- return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3430
+ return _context34.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
3067
3431
  case 9:
3068
3432
  payments = params.payments || [];
3069
- _context31.next = 12;
3433
+ _context34.next = 12;
3070
3434
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
3071
3435
  payments: payments,
3072
3436
  params: syncParams,
@@ -3074,11 +3438,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3074
3438
  orderSnapshot: this.store.order.getOrderSnapshot()
3075
3439
  });
3076
3440
  case 12:
3077
- _context31.prev = 12;
3078
- _context31.next = 15;
3441
+ _context34.prev = 12;
3442
+ _context34.next = 15;
3079
3443
  return this.store.order.syncPaymentsToOrder(syncParams);
3080
3444
  case 15:
3081
- syncResult = _context31.sent;
3445
+ syncResult = _context34.sent;
3082
3446
  latestPayments = this.store.order.getOrderPayments();
3083
3447
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
3084
3448
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -3096,25 +3460,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3096
3460
  depositAmount: syncResult.depositAmount,
3097
3461
  orderExpectedAmount: syncResult.orderExpectedAmount
3098
3462
  };
3099
- _context31.next = 22;
3463
+ _context34.next = 22;
3100
3464
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
3101
3465
  case 22:
3102
3466
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
3103
- _context31.next = 25;
3467
+ _context34.next = 25;
3104
3468
  break;
3105
3469
  }
3106
- _context31.next = 25;
3470
+ _context34.next = 25;
3107
3471
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
3108
3472
  case 25:
3109
3473
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3110
- return _context31.abrupt("return", syncResult);
3474
+ return _context34.abrupt("return", syncResult);
3111
3475
  case 29:
3112
- _context31.prev = 29;
3113
- _context31.t0 = _context31["catch"](12);
3114
- _context31.next = 33;
3476
+ _context34.prev = 29;
3477
+ _context34.t0 = _context34["catch"](12);
3478
+ _context34.next = 33;
3115
3479
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
3116
3480
  ok: false,
3117
- error: _context31.t0,
3481
+ error: _context34.t0,
3118
3482
  payments: this.store.order.getOrderPayments(),
3119
3483
  params: syncParams,
3120
3484
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -3122,14 +3486,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3122
3486
  });
3123
3487
  case 33:
3124
3488
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3125
- throw _context31.t0;
3489
+ throw _context34.t0;
3126
3490
  case 35:
3127
3491
  case "end":
3128
- return _context31.stop();
3492
+ return _context34.stop();
3129
3493
  }
3130
- }, _callee31, this, [[12, 29]]);
3494
+ }, _callee34, this, [[12, 29]]);
3131
3495
  }));
3132
- function syncPaymentsToOrder(_x26) {
3496
+ function syncPaymentsToOrder(_x28) {
3133
3497
  return _syncPaymentsToOrder.apply(this, arguments);
3134
3498
  }
3135
3499
  return syncPaymentsToOrder;
@@ -3178,46 +3542,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3178
3542
  }, {
3179
3543
  key: "flushQueuedAutoPaymentSync",
3180
3544
  value: function () {
3181
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
3545
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
3182
3546
  var payments;
3183
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3184
- while (1) switch (_context32.prev = _context32.next) {
3547
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3548
+ while (1) switch (_context35.prev = _context35.next) {
3185
3549
  case 0:
3186
3550
  if (this.store.order) {
3187
- _context32.next = 2;
3551
+ _context35.next = 2;
3188
3552
  break;
3189
3553
  }
3190
- return _context32.abrupt("return");
3554
+ return _context35.abrupt("return");
3191
3555
  case 2:
3192
3556
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3193
- _context32.next = 4;
3557
+ _context35.next = 4;
3194
3558
  break;
3195
3559
  }
3196
- return _context32.abrupt("return");
3560
+ return _context35.abrupt("return");
3197
3561
  case 4:
3198
3562
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3199
- _context32.next = 7;
3563
+ _context35.next = 7;
3200
3564
  break;
3201
3565
  }
3202
3566
  this.scheduleQueuedAutoPaymentSyncFlush();
3203
- return _context32.abrupt("return");
3567
+ return _context35.abrupt("return");
3204
3568
  case 7:
3205
3569
  this.autoPaymentSyncFlushing = true;
3206
- _context32.prev = 8;
3570
+ _context35.prev = 8;
3207
3571
  case 9:
3208
3572
  if (!this.queuedAutoPaymentSync) {
3209
- _context32.next = 18;
3573
+ _context35.next = 18;
3210
3574
  break;
3211
3575
  }
3212
3576
  this.queuedAutoPaymentSync = false;
3213
3577
  payments = this.store.order.getOrderPayments();
3214
3578
  if (payments.length) {
3215
- _context32.next = 14;
3579
+ _context35.next = 14;
3216
3580
  break;
3217
3581
  }
3218
- return _context32.abrupt("continue", 9);
3582
+ return _context35.abrupt("continue", 9);
3219
3583
  case 14:
3220
- _context32.next = 16;
3584
+ _context35.next = 16;
3221
3585
  return this.syncPaymentsToOrder({
3222
3586
  payments: payments,
3223
3587
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3225,29 +3589,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3225
3589
  smallTicketDataFlag: 1
3226
3590
  });
3227
3591
  case 16:
3228
- _context32.next = 9;
3592
+ _context35.next = 9;
3229
3593
  break;
3230
3594
  case 18:
3231
- _context32.next = 23;
3595
+ _context35.next = 23;
3232
3596
  break;
3233
3597
  case 20:
3234
- _context32.prev = 20;
3235
- _context32.t0 = _context32["catch"](8);
3598
+ _context35.prev = 20;
3599
+ _context35.t0 = _context35["catch"](8);
3236
3600
  this.logError('queued auto sync payments failed', {
3237
- error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
3601
+ error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
3238
3602
  });
3239
3603
  case 23:
3240
- _context32.prev = 23;
3604
+ _context35.prev = 23;
3241
3605
  this.autoPaymentSyncFlushing = false;
3242
3606
  if (this.queuedAutoPaymentSync) {
3243
3607
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3244
3608
  }
3245
- return _context32.finish(23);
3609
+ return _context35.finish(23);
3246
3610
  case 27:
3247
3611
  case "end":
3248
- return _context32.stop();
3612
+ return _context35.stop();
3249
3613
  }
3250
- }, _callee32, this, [[8, 20, 23, 27]]);
3614
+ }, _callee35, this, [[8, 20, 23, 27]]);
3251
3615
  }));
3252
3616
  function flushQueuedAutoPaymentSync() {
3253
3617
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -3271,35 +3635,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3271
3635
  }, {
3272
3636
  key: "addOrderPaymentAsync",
3273
3637
  value: (function () {
3274
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3638
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payment) {
3275
3639
  var paymentRecord, hasPaymentNumber, devicePrefix;
3276
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3277
- while (1) switch (_context33.prev = _context33.next) {
3640
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3641
+ while (1) switch (_context36.prev = _context36.next) {
3278
3642
  case 0:
3279
3643
  paymentRecord = payment;
3280
3644
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3281
3645
  if (!hasPaymentNumber) {
3282
- _context33.next = 6;
3646
+ _context36.next = 6;
3283
3647
  break;
3284
3648
  }
3285
- _context33.t0 = 'LOCAL';
3286
- _context33.next = 9;
3649
+ _context36.t0 = 'LOCAL';
3650
+ _context36.next = 9;
3287
3651
  break;
3288
3652
  case 6:
3289
- _context33.next = 8;
3653
+ _context36.next = 8;
3290
3654
  return this.getPaymentNumberDevicePrefixAsync();
3291
3655
  case 8:
3292
- _context33.t0 = _context33.sent;
3656
+ _context36.t0 = _context36.sent;
3293
3657
  case 9:
3294
- devicePrefix = _context33.t0;
3295
- return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3658
+ devicePrefix = _context36.t0;
3659
+ return _context36.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3296
3660
  case 11:
3297
3661
  case "end":
3298
- return _context33.stop();
3662
+ return _context36.stop();
3299
3663
  }
3300
- }, _callee33, this);
3664
+ }, _callee36, this);
3301
3665
  }));
3302
- function addOrderPaymentAsync(_x27) {
3666
+ function addOrderPaymentAsync(_x29) {
3303
3667
  return _addOrderPaymentAsync.apply(this, arguments);
3304
3668
  }
3305
3669
  return addOrderPaymentAsync;
@@ -3307,10 +3671,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3307
3671
  }, {
3308
3672
  key: "addOrderPaymentWithDevicePrefix",
3309
3673
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3310
- var _this$otherParams25,
3674
+ var _this$otherParams31,
3311
3675
  _paymentRecord$paymen,
3312
3676
  _paymentRecord$create,
3313
- _ref30,
3677
+ _ref37,
3314
3678
  _paymentRecord$origin,
3315
3679
  _this14 = this;
3316
3680
  if (!this.store.order) throw new Error('order 模块未初始化');
@@ -3323,7 +3687,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3323
3687
  return this.store.order.getOrderPayments();
3324
3688
  }
3325
3689
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3326
- var shopWalletPassId = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.shop_wallet_pass_id;
3690
+ var shopWalletPassId = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.shop_wallet_pass_id;
3327
3691
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3328
3692
  metadata.shop_wallet_pass_id = shopWalletPassId;
3329
3693
  }
@@ -3332,7 +3696,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3332
3696
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3333
3697
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3334
3698
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3335
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref30 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref30 !== void 0 ? _ref30 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3699
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref37 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref37 !== void 0 ? _ref37 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3336
3700
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3337
3701
  service_fee: calculatedServiceFee
3338
3702
  } : {}), {}, {
@@ -3368,7 +3732,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3368
3732
  }, {
3369
3733
  key: "updateOrderPayment",
3370
3734
  value: (function () {
3371
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3735
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paymentIdentity, updates) {
3372
3736
  var _result$payment, _result$payment2;
3373
3737
  var options,
3374
3738
  matchMode,
@@ -3385,13 +3749,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3385
3749
  shouldSubmit,
3386
3750
  syncResult,
3387
3751
  _options$smallTicketD2,
3388
- _args34 = arguments;
3389
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3390
- while (1) switch (_context34.prev = _context34.next) {
3752
+ _args37 = arguments;
3753
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3754
+ while (1) switch (_context37.prev = _context37.next) {
3391
3755
  case 0:
3392
- options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3756
+ options = _args37.length > 2 && _args37[2] !== undefined ? _args37[2] : {};
3393
3757
  if (this.store.order) {
3394
- _context34.next = 3;
3758
+ _context37.next = 3;
3395
3759
  break;
3396
3760
  }
3397
3761
  throw new Error('order 模块未初始化');
@@ -3400,15 +3764,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3400
3764
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3401
3765
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3402
3766
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3403
- _context34.next = 13;
3767
+ _context37.next = 13;
3404
3768
  break;
3405
3769
  }
3406
3770
  currentPayments = this.store.order.getOrderPayments();
3407
3771
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3408
- _context34.next = 12;
3772
+ _context37.next = 12;
3409
3773
  break;
3410
3774
  }
3411
- _context34.next = 11;
3775
+ _context37.next = 11;
3412
3776
  return this.syncPaymentsToOrder({
3413
3777
  payments: currentPayments,
3414
3778
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -3416,9 +3780,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3416
3780
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3417
3781
  });
3418
3782
  case 11:
3419
- _syncResult = _context34.sent;
3783
+ _syncResult = _context37.sent;
3420
3784
  case 12:
3421
- return _context34.abrupt("return", _objectSpread({
3785
+ return _context37.abrupt("return", _objectSpread({
3422
3786
  updated: false,
3423
3787
  payment: previousPayment,
3424
3788
  payments: currentPayments,
@@ -3427,44 +3791,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3427
3791
  syncResult: _syncResult
3428
3792
  } : {}));
3429
3793
  case 13:
3430
- _context34.next = 15;
3794
+ _context37.next = 15;
3431
3795
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3432
3796
  matchBy: matchMode
3433
3797
  });
3434
3798
  case 15:
3435
- result = _context34.sent;
3799
+ result = _context37.sent;
3436
3800
  if (!(options.persistDraft !== false)) {
3437
- _context34.next = 29;
3801
+ _context37.next = 29;
3438
3802
  break;
3439
3803
  }
3440
- _context34.prev = 17;
3441
- _context34.next = 20;
3804
+ _context37.prev = 17;
3805
+ _context37.next = 20;
3442
3806
  return this.saveSalesOrderDraft();
3443
3807
  case 20:
3444
- draftResult = _context34.sent;
3445
- _context34.next = 29;
3808
+ draftResult = _context37.sent;
3809
+ _context37.next = 29;
3446
3810
  break;
3447
3811
  case 23:
3448
- _context34.prev = 23;
3449
- _context34.t0 = _context34["catch"](17);
3450
- draftError = _context34.t0;
3812
+ _context37.prev = 23;
3813
+ _context37.t0 = _context37["catch"](17);
3814
+ draftError = _context37.t0;
3451
3815
  this.logError('updateOrderPayment: 保存支付草稿失败', {
3452
3816
  paymentIdentity: paymentIdentity,
3453
- error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3817
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3454
3818
  });
3455
3819
  if (options.submitWhenPaid) {
3456
- _context34.next = 29;
3820
+ _context37.next = 29;
3457
3821
  break;
3458
3822
  }
3459
- throw _context34.t0;
3823
+ throw _context37.t0;
3460
3824
  case 29:
3461
3825
  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';
3462
3826
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3463
3827
  if (!shouldSubmit) {
3464
- _context34.next = 35;
3828
+ _context37.next = 35;
3465
3829
  break;
3466
3830
  }
3467
- _context34.next = 34;
3831
+ _context37.next = 34;
3468
3832
  return this.syncPaymentsToOrder({
3469
3833
  payments: result.payments,
3470
3834
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -3472,9 +3836,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3472
3836
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3473
3837
  });
3474
3838
  case 34:
3475
- syncResult = _context34.sent;
3839
+ syncResult = _context37.sent;
3476
3840
  case 35:
3477
- return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3841
+ return _context37.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3478
3842
  draftResult: draftResult
3479
3843
  } : {}), draftError !== undefined ? {
3480
3844
  draftError: draftError
@@ -3483,11 +3847,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3483
3847
  } : {}));
3484
3848
  case 36:
3485
3849
  case "end":
3486
- return _context34.stop();
3850
+ return _context37.stop();
3487
3851
  }
3488
- }, _callee34, this, [[17, 23]]);
3852
+ }, _callee37, this, [[17, 23]]);
3489
3853
  }));
3490
- function updateOrderPayment(_x28, _x29) {
3854
+ function updateOrderPayment(_x30, _x31) {
3491
3855
  return _updateOrderPayment.apply(this, arguments);
3492
3856
  }
3493
3857
  return updateOrderPayment;
@@ -3509,24 +3873,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3509
3873
  }, {
3510
3874
  key: "updateVoucherOrderPaymentsAsync",
3511
3875
  value: function () {
3512
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3513
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3514
- while (1) switch (_context35.prev = _context35.next) {
3876
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(payments, options) {
3877
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3878
+ while (1) switch (_context38.prev = _context38.next) {
3515
3879
  case 0:
3516
3880
  if (this.store.order) {
3517
- _context35.next = 2;
3881
+ _context38.next = 2;
3518
3882
  break;
3519
3883
  }
3520
3884
  throw new Error('order 模块未初始化');
3521
3885
  case 2:
3522
- return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3886
+ return _context38.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3523
3887
  case 3:
3524
3888
  case "end":
3525
- return _context35.stop();
3889
+ return _context38.stop();
3526
3890
  }
3527
- }, _callee35, this);
3891
+ }, _callee38, this);
3528
3892
  }));
3529
- function updateVoucherOrderPaymentsAsync(_x30, _x31) {
3893
+ function updateVoucherOrderPaymentsAsync(_x32, _x33) {
3530
3894
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3531
3895
  }
3532
3896
  return updateVoucherOrderPaymentsAsync;
@@ -3552,8 +3916,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3552
3916
  }, {
3553
3917
  key: "getWalletProductList",
3554
3918
  value: function getWalletProductList() {
3555
- var _this$store$order7, _tempOrder$products;
3556
- var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
3919
+ var _this$store$order8, _tempOrder$products;
3920
+ var tempOrder = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder();
3557
3921
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
3558
3922
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
3559
3923
  // debugger
@@ -3613,8 +3977,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3613
3977
  }, {
3614
3978
  key: "buildWalletInitBusinessData",
3615
3979
  value: function buildWalletInitBusinessData(params) {
3616
- var _this$store$order8, _params$order_wait_pa, _ref31, _tempOrder$is_price_i;
3617
- var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
3980
+ var _this$store$order9, _params$order_wait_pa, _ref38, _tempOrder$is_price_i;
3981
+ var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
3618
3982
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3619
3983
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3620
3984
  if (!tempOrder || !amount) return null;
@@ -3629,7 +3993,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3629
3993
  },
3630
3994
  products: this.getWalletProductList(),
3631
3995
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
3632
- is_price_include_tax: (_ref31 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref31 !== void 0 ? _ref31 : 1
3996
+ is_price_include_tax: (_ref38 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref38 !== void 0 ? _ref38 : 1
3633
3997
  }, snapshot.identity.orderId ? {
3634
3998
  payment_order_id: String(snapshot.identity.orderId)
3635
3999
  } : {});
@@ -3637,20 +4001,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3637
4001
  }, {
3638
4002
  key: "initWalletData",
3639
4003
  value: function () {
3640
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4004
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3641
4005
  var _snapshot$identity;
3642
4006
  var snapshot, walletBusinessData, result;
3643
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3644
- while (1) switch (_context36.prev = _context36.next) {
4007
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4008
+ while (1) switch (_context39.prev = _context39.next) {
3645
4009
  case 0:
3646
4010
  if (this.store.order) {
3647
- _context36.next = 2;
4011
+ _context39.next = 2;
3648
4012
  break;
3649
4013
  }
3650
4014
  throw new Error('order 模块未初始化');
3651
4015
  case 2:
3652
4016
  if (this.store.payment) {
3653
- _context36.next = 4;
4017
+ _context39.next = 4;
3654
4018
  break;
3655
4019
  }
3656
4020
  throw new Error('payment 模块未初始化');
@@ -3658,10 +4022,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3658
4022
  snapshot = this.store.order.getOrderSnapshot();
3659
4023
  walletBusinessData = this.buildWalletInitBusinessData(params);
3660
4024
  if (walletBusinessData) {
3661
- _context36.next = 8;
4025
+ _context39.next = 8;
3662
4026
  break;
3663
4027
  }
3664
- return _context36.abrupt("return", {
4028
+ return _context39.abrupt("return", {
3665
4029
  walletRecommendList: [],
3666
4030
  userIdentificationCodes: [],
3667
4031
  transformList: [],
@@ -3669,11 +4033,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3669
4033
  products: []
3670
4034
  });
3671
4035
  case 8:
3672
- _context36.next = 10;
4036
+ _context39.next = 10;
3673
4037
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3674
4038
  case 10:
3675
- result = _context36.sent;
3676
- _context36.next = 13;
4039
+ result = _context39.sent;
4040
+ _context39.next = 13;
3677
4041
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3678
4042
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
3679
4043
  customerId: walletBusinessData.customer_id,
@@ -3685,14 +4049,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3685
4049
  timestamp: Date.now()
3686
4050
  });
3687
4051
  case 13:
3688
- return _context36.abrupt("return", result);
4052
+ return _context39.abrupt("return", result);
3689
4053
  case 14:
3690
4054
  case "end":
3691
- return _context36.stop();
4055
+ return _context39.stop();
3692
4056
  }
3693
- }, _callee36, this);
4057
+ }, _callee39, this);
3694
4058
  }));
3695
- function initWalletData(_x32) {
4059
+ function initWalletData(_x34) {
3696
4060
  return _initWalletData.apply(this, arguments);
3697
4061
  }
3698
4062
  return initWalletData;
@@ -3700,8 +4064,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3700
4064
  }, {
3701
4065
  key: "getCommittedWalletAssets",
3702
4066
  value: function getCommittedWalletAssets() {
3703
- var _this$store$order9, _this$store$order9$ge;
3704
- var payments = ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$ge = _this$store$order9.getOrderPayments) === null || _this$store$order9$ge === void 0 ? void 0 : _this$store$order9$ge.call(_this$store$order9)) || [];
4067
+ var _this$store$order10, _this$store$order10$g;
4068
+ var payments = ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
3705
4069
  var committed = payments.filter(function (payment) {
3706
4070
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
3707
4071
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -3719,9 +4083,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3719
4083
  var walletPassName = fundRecord.wallet_pass_name;
3720
4084
  var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
3721
4085
  var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
3722
- var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref32) {
3723
- var _ref33 = _slicedToArray(_ref32, 2),
3724
- paymentCode = _ref33[1];
4086
+ var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref39) {
4087
+ var _ref40 = _slicedToArray(_ref39, 2),
4088
+ paymentCode = _ref40[1];
3725
4089
  return paymentCode === code;
3726
4090
  })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
3727
4091
  return {
@@ -3743,23 +4107,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3743
4107
  }, {
3744
4108
  key: "publishWalletAssetsState",
3745
4109
  value: function () {
3746
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
3747
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3748
- while (1) switch (_context37.prev = _context37.next) {
4110
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(state) {
4111
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4112
+ while (1) switch (_context40.prev = _context40.next) {
3749
4113
  case 0:
3750
- _context37.next = 2;
4114
+ _context40.next = 2;
3751
4115
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
3752
4116
  state: state
3753
4117
  });
3754
4118
  case 2:
3755
- return _context37.abrupt("return", state);
4119
+ return _context40.abrupt("return", state);
3756
4120
  case 3:
3757
4121
  case "end":
3758
- return _context37.stop();
4122
+ return _context40.stop();
3759
4123
  }
3760
- }, _callee37, this);
4124
+ }, _callee40, this);
3761
4125
  }));
3762
- function publishWalletAssetsState(_x33) {
4126
+ function publishWalletAssetsState(_x35) {
3763
4127
  return _publishWalletAssetsState.apply(this, arguments);
3764
4128
  }
3765
4129
  return publishWalletAssetsState;
@@ -3767,26 +4131,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3767
4131
  }, {
3768
4132
  key: "syncSelectedWalletAssets",
3769
4133
  value: function () {
3770
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
4134
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(state) {
3771
4135
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
3772
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3773
- while (1) switch (_context38.prev = _context38.next) {
4136
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4137
+ while (1) switch (_context41.prev = _context41.next) {
3774
4138
  case 0:
3775
4139
  if (!(!this.store.order || !this.store.payment)) {
3776
- _context38.next = 2;
4140
+ _context41.next = 2;
3777
4141
  break;
3778
4142
  }
3779
4143
  throw new Error('订单或支付模块未初始化');
3780
4144
  case 2:
3781
4145
  paymentMethods = this.getPaymentMethods();
3782
4146
  if (!(!paymentMethods.length && state.selectedItems.length)) {
3783
- _context38.next = 7;
4147
+ _context41.next = 7;
3784
4148
  break;
3785
4149
  }
3786
- _context38.next = 6;
4150
+ _context41.next = 6;
3787
4151
  return this.getPaymentMethodsAsync();
3788
4152
  case 6:
3789
- paymentMethods = _context38.sent;
4153
+ paymentMethods = _context41.sent;
3790
4154
  case 7:
3791
4155
  methodByCode = new Map(paymentMethods.map(function (method) {
3792
4156
  return [String(method.code || '').toUpperCase(), method];
@@ -3828,19 +4192,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3828
4192
  payments = this.updateVoucherOrderPayments(voucherPayments, {
3829
4193
  status: 'payment_pending'
3830
4194
  });
3831
- _context38.next = 14;
4195
+ _context41.next = 14;
3832
4196
  return this.store.order.recalculateSummary({
3833
4197
  createIfMissing: true
3834
4198
  });
3835
4199
  case 14:
3836
- return _context38.abrupt("return", payments);
4200
+ return _context41.abrupt("return", payments);
3837
4201
  case 15:
3838
4202
  case "end":
3839
- return _context38.stop();
4203
+ return _context41.stop();
3840
4204
  }
3841
- }, _callee38, this);
4205
+ }, _callee41, this);
3842
4206
  }));
3843
- function syncSelectedWalletAssets(_x34) {
4207
+ function syncSelectedWalletAssets(_x36) {
3844
4208
  return _syncSelectedWalletAssets.apply(this, arguments);
3845
4209
  }
3846
4210
  return syncSelectedWalletAssets;
@@ -3874,29 +4238,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3874
4238
  }, {
3875
4239
  key: "importWalletAssetsSnapshot",
3876
4240
  value: (function () {
3877
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
4241
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(snapshot) {
3878
4242
  var state;
3879
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3880
- while (1) switch (_context39.prev = _context39.next) {
4243
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4244
+ while (1) switch (_context42.prev = _context42.next) {
3881
4245
  case 0:
3882
4246
  if (this.store.payment) {
3883
- _context39.next = 2;
4247
+ _context42.next = 2;
3884
4248
  break;
3885
4249
  }
3886
4250
  throw new Error('payment 模块未初始化');
3887
4251
  case 2:
3888
4252
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
3889
- _context39.next = 5;
4253
+ _context42.next = 5;
3890
4254
  return this.syncSelectedWalletAssets(state);
3891
4255
  case 5:
3892
- return _context39.abrupt("return", this.publishWalletAssetsState(state));
4256
+ return _context42.abrupt("return", this.publishWalletAssetsState(state));
3893
4257
  case 6:
3894
4258
  case "end":
3895
- return _context39.stop();
4259
+ return _context42.stop();
3896
4260
  }
3897
- }, _callee39, this);
4261
+ }, _callee42, this);
3898
4262
  }));
3899
- function importWalletAssetsSnapshot(_x35) {
4263
+ function importWalletAssetsSnapshot(_x37) {
3900
4264
  return _importWalletAssetsSnapshot.apply(this, arguments);
3901
4265
  }
3902
4266
  return importWalletAssetsSnapshot;
@@ -3908,20 +4272,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3908
4272
  }, {
3909
4273
  key: "refreshWalletAssets",
3910
4274
  value: (function () {
3911
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
4275
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3912
4276
  var _previousState$custom, _businessData$custome;
3913
4277
  var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
3914
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3915
- while (1) switch (_context40.prev = _context40.next) {
4278
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4279
+ while (1) switch (_context43.prev = _context43.next) {
3916
4280
  case 0:
3917
4281
  if (this.store.order) {
3918
- _context40.next = 2;
4282
+ _context43.next = 2;
3919
4283
  break;
3920
4284
  }
3921
4285
  throw new Error('order 模块未初始化');
3922
4286
  case 2:
3923
4287
  if (this.store.payment) {
3924
- _context40.next = 4;
4288
+ _context43.next = 4;
3925
4289
  break;
3926
4290
  }
3927
4291
  throw new Error('payment 模块未初始化');
@@ -3930,7 +4294,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3930
4294
  wallet = this.store.payment.wallet;
3931
4295
  businessData = this.buildWalletInitBusinessData(params);
3932
4296
  if (businessData) {
3933
- _context40.next = 12;
4297
+ _context43.next = 12;
3934
4298
  break;
3935
4299
  }
3936
4300
  wallet.clearAllCache();
@@ -3938,53 +4302,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3938
4302
  this.updateVoucherOrderPayments([], {
3939
4303
  status: 'payment_pending'
3940
4304
  });
3941
- return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
4305
+ return _context43.abrupt("return", this.publishWalletAssetsState(emptyState));
3942
4306
  case 12:
3943
4307
  previousState = wallet.getWalletAssetsState();
3944
4308
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
3945
4309
  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 : '');
3946
4310
  if (!customerChanged) {
3947
- _context40.next = 20;
4311
+ _context43.next = 20;
3948
4312
  break;
3949
4313
  }
3950
4314
  clearedState = wallet.clearWalletAssetSelection();
3951
4315
  this.updateVoucherOrderPayments([], {
3952
4316
  status: 'payment_pending'
3953
4317
  });
3954
- _context40.next = 20;
4318
+ _context43.next = 20;
3955
4319
  return this.publishWalletAssetsState(clearedState);
3956
4320
  case 20:
3957
4321
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
3958
4322
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
3959
4323
  });
3960
- _context40.next = 23;
4324
+ _context43.next = 23;
3961
4325
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
3962
4326
  case 23:
3963
- _context40.next = 25;
4327
+ _context43.next = 25;
3964
4328
  return refreshTask;
3965
4329
  case 25:
3966
- state = _context40.sent;
4330
+ state = _context43.sent;
3967
4331
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
3968
- _context40.next = 28;
4332
+ _context43.next = 28;
3969
4333
  break;
3970
4334
  }
3971
- return _context40.abrupt("return", wallet.getWalletAssetsState());
4335
+ return _context43.abrupt("return", wallet.getWalletAssetsState());
3972
4336
  case 28:
3973
4337
  if (state.status !== 'error') {
3974
4338
  committed = this.getCommittedWalletAssets();
3975
4339
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
3976
4340
  }
3977
- _context40.next = 31;
4341
+ _context43.next = 31;
3978
4342
  return this.syncSelectedWalletAssets(state);
3979
4343
  case 31:
3980
- return _context40.abrupt("return", this.publishWalletAssetsState(state));
4344
+ return _context43.abrupt("return", this.publishWalletAssetsState(state));
3981
4345
  case 32:
3982
4346
  case "end":
3983
- return _context40.stop();
4347
+ return _context43.stop();
3984
4348
  }
3985
- }, _callee40, this);
4349
+ }, _callee43, this);
3986
4350
  }));
3987
- function refreshWalletAssets(_x36) {
4351
+ function refreshWalletAssets(_x38) {
3988
4352
  return _refreshWalletAssets.apply(this, arguments);
3989
4353
  }
3990
4354
  return refreshWalletAssets;
@@ -3992,13 +4356,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3992
4356
  }, {
3993
4357
  key: "selectWalletAsset",
3994
4358
  value: (function () {
3995
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4359
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3996
4360
  var state;
3997
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3998
- while (1) switch (_context41.prev = _context41.next) {
4361
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4362
+ while (1) switch (_context44.prev = _context44.next) {
3999
4363
  case 0:
4000
4364
  if (this.store.payment) {
4001
- _context41.next = 2;
4365
+ _context44.next = 2;
4002
4366
  break;
4003
4367
  }
4004
4368
  throw new Error('payment 模块未初始化');
@@ -4007,57 +4371,92 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4007
4371
  selected: params.selected,
4008
4372
  source: params.source
4009
4373
  });
4010
- _context41.next = 5;
4374
+ _context44.next = 5;
4011
4375
  return this.syncSelectedWalletAssets(state);
4012
4376
  case 5:
4013
- return _context41.abrupt("return", this.publishWalletAssetsState(state));
4377
+ return _context44.abrupt("return", this.publishWalletAssetsState(state));
4014
4378
  case 6:
4015
4379
  case "end":
4016
- return _context41.stop();
4380
+ return _context44.stop();
4017
4381
  }
4018
- }, _callee41, this);
4382
+ }, _callee44, this);
4019
4383
  }));
4020
- function selectWalletAsset(_x37) {
4384
+ function selectWalletAsset(_x39) {
4021
4385
  return _selectWalletAsset.apply(this, arguments);
4022
4386
  }
4023
4387
  return selectWalletAsset;
4388
+ }() /** 更新已选钱包资产的手动使用金额,并同步 pending payment。 */)
4389
+ }, {
4390
+ key: "updateWalletAssetAmount",
4391
+ value: (function () {
4392
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4393
+ var state;
4394
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4395
+ while (1) switch (_context45.prev = _context45.next) {
4396
+ case 0:
4397
+ if (this.store.payment) {
4398
+ _context45.next = 2;
4399
+ break;
4400
+ }
4401
+ throw new Error('payment 模块未初始化');
4402
+ case 2:
4403
+ state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
4404
+ _context45.next = 5;
4405
+ return this.syncSelectedWalletAssets(state);
4406
+ case 5:
4407
+ return _context45.abrupt("return", this.publishWalletAssetsState(state));
4408
+ case 6:
4409
+ case "end":
4410
+ return _context45.stop();
4411
+ }
4412
+ }, _callee45, this);
4413
+ }));
4414
+ function updateWalletAssetAmount(_x40) {
4415
+ return _updateWalletAssetAmount.apply(this, arguments);
4416
+ }
4417
+ return updateWalletAssetAmount;
4024
4418
  }() /** 扫码精确查券;仅可用资产会被自动选中。 */)
4025
4419
  }, {
4026
4420
  key: "scanWalletAsset",
4027
4421
  value: (function () {
4028
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(code) {
4029
- var result;
4030
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4031
- while (1) switch (_context42.prev = _context42.next) {
4422
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(code) {
4423
+ var wallet, businessData, result;
4424
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4425
+ while (1) switch (_context46.prev = _context46.next) {
4032
4426
  case 0:
4033
4427
  if (this.store.payment) {
4034
- _context42.next = 2;
4428
+ _context46.next = 2;
4035
4429
  break;
4036
4430
  }
4037
4431
  throw new Error('payment 模块未初始化');
4038
4432
  case 2:
4039
- _context42.next = 4;
4040
- return this.store.payment.wallet.scanWalletAssetAsync(code);
4041
- case 4:
4042
- result = _context42.sent;
4433
+ wallet = this.store.payment.wallet; // 扫码可能早于后台 Wallet 刷新,搜索参数必须以当前订单为准。
4434
+ businessData = this.buildWalletInitBusinessData();
4435
+ if (businessData) {
4436
+ wallet.generateWalletParams(businessData);
4437
+ }
4438
+ _context46.next = 7;
4439
+ return wallet.scanWalletAssetAsync(code);
4440
+ case 7:
4441
+ result = _context46.sent;
4043
4442
  if (!(result.type === 'normalCode')) {
4044
- _context42.next = 10;
4443
+ _context46.next = 13;
4045
4444
  break;
4046
4445
  }
4047
- _context42.next = 8;
4446
+ _context46.next = 11;
4048
4447
  return this.syncSelectedWalletAssets(result.state);
4049
- case 8:
4050
- _context42.next = 10;
4051
- return this.publishWalletAssetsState(result.state);
4052
- case 10:
4053
- return _context42.abrupt("return", result);
4054
4448
  case 11:
4449
+ _context46.next = 13;
4450
+ return this.publishWalletAssetsState(result.state);
4451
+ case 13:
4452
+ return _context46.abrupt("return", result);
4453
+ case 14:
4055
4454
  case "end":
4056
- return _context42.stop();
4455
+ return _context46.stop();
4057
4456
  }
4058
- }, _callee42, this);
4457
+ }, _callee46, this);
4059
4458
  }));
4060
- function scanWalletAsset(_x38) {
4459
+ function scanWalletAsset(_x41) {
4061
4460
  return _scanWalletAsset.apply(this, arguments);
4062
4461
  }
4063
4462
  return scanWalletAsset;
@@ -4065,27 +4464,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4065
4464
  }, {
4066
4465
  key: "clearWalletAssetSelection",
4067
4466
  value: (function () {
4068
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
4467
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4069
4468
  var state;
4070
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4071
- while (1) switch (_context43.prev = _context43.next) {
4469
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4470
+ while (1) switch (_context47.prev = _context47.next) {
4072
4471
  case 0:
4073
4472
  if (this.store.payment) {
4074
- _context43.next = 2;
4473
+ _context47.next = 2;
4075
4474
  break;
4076
4475
  }
4077
4476
  throw new Error('payment 模块未初始化');
4078
4477
  case 2:
4079
4478
  state = this.store.payment.wallet.clearWalletAssetSelection();
4080
- _context43.next = 5;
4479
+ _context47.next = 5;
4081
4480
  return this.syncSelectedWalletAssets(state);
4082
4481
  case 5:
4083
- return _context43.abrupt("return", this.publishWalletAssetsState(state));
4482
+ return _context47.abrupt("return", this.publishWalletAssetsState(state));
4084
4483
  case 6:
4085
4484
  case "end":
4086
- return _context43.stop();
4485
+ return _context47.stop();
4087
4486
  }
4088
- }, _callee43, this);
4487
+ }, _callee47, this);
4089
4488
  }));
4090
4489
  function clearWalletAssetSelection() {
4091
4490
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -4115,35 +4514,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4115
4514
  }, {
4116
4515
  key: "getPaymentMethodsAsync",
4117
4516
  value: (function () {
4118
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4517
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4119
4518
  var response, paymentMethods;
4120
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4121
- while (1) switch (_context44.prev = _context44.next) {
4519
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4520
+ while (1) switch (_context48.prev = _context48.next) {
4122
4521
  case 0:
4123
- _context44.prev = 0;
4124
- _context44.next = 3;
4522
+ _context48.prev = 0;
4523
+ _context48.next = 3;
4125
4524
  return this.request.get('/pay/custom-payment/all', {
4126
4525
  filterPaymentMethods: true
4127
4526
  }, {
4128
4527
  osServer: true
4129
4528
  });
4130
4529
  case 3:
4131
- response = _context44.sent;
4530
+ response = _context48.sent;
4132
4531
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
4133
4532
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
4134
- return _context44.abrupt("return", this.getPaymentMethods());
4533
+ return _context48.abrupt("return", this.getPaymentMethods());
4135
4534
  case 9:
4136
- _context44.prev = 9;
4137
- _context44.t0 = _context44["catch"](0);
4535
+ _context48.prev = 9;
4536
+ _context48.t0 = _context48["catch"](0);
4138
4537
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
4139
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4538
+ error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
4140
4539
  });
4141
- return _context44.abrupt("return", this.getPaymentMethods());
4540
+ return _context48.abrupt("return", this.getPaymentMethods());
4142
4541
  case 13:
4143
4542
  case "end":
4144
- return _context44.stop();
4543
+ return _context48.stop();
4145
4544
  }
4146
- }, _callee44, this, [[0, 9]]);
4545
+ }, _callee48, this, [[0, 9]]);
4147
4546
  }));
4148
4547
  function getPaymentMethodsAsync() {
4149
4548
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -4168,8 +4567,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4168
4567
  }, {
4169
4568
  key: "getPendingWalletPaymentAmount",
4170
4569
  value: function getPendingWalletPaymentAmount() {
4171
- var _this$store$order10, _this$store$order10$g;
4172
- var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
4570
+ var _this$store$order11, _this$store$order11$g;
4571
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderPayments) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11)) || [];
4173
4572
  return payments.reduce(function (total, payment) {
4174
4573
  if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
4175
4574
  return total;
@@ -4186,14 +4585,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4186
4585
  }, {
4187
4586
  key: "getCashPaymentConfig",
4188
4587
  value: (function () {
4189
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4190
- var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams26;
4588
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4589
+ var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams32;
4191
4590
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
4192
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4193
- while (1) switch (_context45.prev = _context45.next) {
4591
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4592
+ while (1) switch (_context49.prev = _context49.next) {
4194
4593
  case 0:
4195
4594
  if (this.store.payment) {
4196
- _context45.next = 2;
4595
+ _context49.next = 2;
4197
4596
  break;
4198
4597
  }
4199
4598
  throw new Error('payment 模块未初始化');
@@ -4201,21 +4600,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4201
4600
  paymentMethods = this.getPaymentMethods();
4202
4601
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4203
4602
  if (paymentMethod) {
4204
- _context45.next = 9;
4603
+ _context49.next = 9;
4205
4604
  break;
4206
4605
  }
4207
- _context45.next = 7;
4606
+ _context49.next = 7;
4208
4607
  return this.getPaymentMethodsAsync();
4209
4608
  case 7:
4210
- paymentMethods = _context45.sent;
4609
+ paymentMethods = _context49.sent;
4211
4610
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
4212
4611
  case 9:
4213
- 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);
4612
+ amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
4214
4613
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4215
4614
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
4216
- 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$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.currency) || 'USD';
4615
+ currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.currency) || 'USD';
4217
4616
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
4218
- return _context45.abrupt("return", {
4617
+ return _context49.abrupt("return", {
4219
4618
  available: Boolean(paymentMethod && amountDue > 0),
4220
4619
  paymentMethod: paymentMethod,
4221
4620
  amountDue: amountDue,
@@ -4223,9 +4622,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4223
4622
  });
4224
4623
  case 15:
4225
4624
  case "end":
4226
- return _context45.stop();
4625
+ return _context49.stop();
4227
4626
  }
4228
- }, _callee45, this);
4627
+ }, _callee49, this);
4229
4628
  }));
4230
4629
  function getCashPaymentConfig() {
4231
4630
  return _getCashPaymentConfig.apply(this, arguments);
@@ -4242,14 +4641,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4242
4641
  }, {
4243
4642
  key: "confirmWalletPayment",
4244
4643
  value: (function () {
4245
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4246
- var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
4644
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4645
+ var _this$store$order$get3, _this$store$order14, _this$store$order$get4, _this$store$order$get5, _this$store$order15;
4247
4646
  var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
4248
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4249
- while (1) switch (_context46.prev = _context46.next) {
4647
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4648
+ while (1) switch (_context50.prev = _context50.next) {
4250
4649
  case 0:
4251
4650
  if (this.store.order) {
4252
- _context46.next = 2;
4651
+ _context50.next = 2;
4253
4652
  break;
4254
4653
  }
4255
4654
  throw new Error('order 模块未初始化');
@@ -4257,82 +4656,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4257
4656
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
4258
4657
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
4259
4658
  if (!pendingWalletAmount.lte(0)) {
4260
- _context46.next = 6;
4659
+ _context50.next = 6;
4261
4660
  break;
4262
4661
  }
4263
4662
  throw new Error('当前订单没有待确认的 Wallet 支付');
4264
4663
  case 6:
4265
- 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);
4664
+ amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
4266
4665
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4267
4666
  if (!effectiveAmountDue.gt(0.01)) {
4268
- _context46.next = 10;
4667
+ _context50.next = 10;
4269
4668
  break;
4270
4669
  }
4271
4670
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
4272
4671
  case 10:
4273
4672
  beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
4274
- _context46.prev = 11;
4275
- _context46.next = 14;
4673
+ _context50.prev = 11;
4674
+ _context50.next = 14;
4276
4675
  return this.submitSalesOrder({
4277
4676
  smallTicketDataFlag: 1,
4278
4677
  confirmPendingVoucherPayments: true
4279
4678
  });
4280
4679
  case 14:
4281
- submitResult = _context46.sent;
4680
+ submitResult = _context50.sent;
4282
4681
  if (!isRejectedSalesSubmitResult(submitResult)) {
4283
- _context46.next = 17;
4682
+ _context50.next = 17;
4284
4683
  break;
4285
4684
  }
4286
- throw new Error(getSalesSubmitErrorMessage(submitResult));
4685
+ throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
4287
4686
  case 17:
4288
- _context46.next = 27;
4687
+ _context50.next = 27;
4289
4688
  break;
4290
4689
  case 19:
4291
- _context46.prev = 19;
4292
- _context46.t0 = _context46["catch"](11);
4690
+ _context50.prev = 19;
4691
+ _context50.t0 = _context50["catch"](11);
4293
4692
  this.store.order.setOrderPayments(beforePayments);
4294
4693
  restoredTempOrder = this.store.order.getTempOrder();
4295
4694
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4296
4695
  restoredTempOrder.payment_status = beforePaymentStatus;
4297
4696
  this.store.order.persistTempOrder();
4298
4697
  }
4299
- _context46.next = 26;
4698
+ _context50.next = 26;
4300
4699
  return this.store.order.recalculateSummary({
4301
4700
  createIfMissing: true
4302
4701
  });
4303
4702
  case 26:
4304
- throw _context46.t0;
4703
+ throw _context50.t0;
4305
4704
  case 27:
4306
4705
  if (!this.store.payment) {
4307
- _context46.next = 38;
4706
+ _context50.next = 38;
4308
4707
  break;
4309
4708
  }
4310
- _context46.prev = 28;
4709
+ _context50.prev = 28;
4311
4710
  committed = this.getCommittedWalletAssets();
4312
4711
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4313
- _context46.next = 33;
4712
+ _context50.next = 33;
4314
4713
  return this.publishWalletAssetsState(walletState);
4315
4714
  case 33:
4316
- _context46.next = 38;
4715
+ _context50.next = 38;
4317
4716
  break;
4318
4717
  case 35:
4319
- _context46.prev = 35;
4320
- _context46.t1 = _context46["catch"](28);
4718
+ _context50.prev = 35;
4719
+ _context50.t1 = _context50["catch"](28);
4321
4720
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
4322
- error: _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1)
4721
+ error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1)
4323
4722
  });
4324
4723
  case 38:
4325
- 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);
4326
- return _context46.abrupt("return", {
4724
+ latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order15);
4725
+ return _context50.abrupt("return", {
4327
4726
  submitResult: submitResult,
4328
4727
  payments: this.store.order.getOrderPayments(),
4329
4728
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
4330
4729
  });
4331
4730
  case 40:
4332
4731
  case "end":
4333
- return _context46.stop();
4732
+ return _context50.stop();
4334
4733
  }
4335
- }, _callee46, this, [[11, 19], [28, 35]]);
4734
+ }, _callee50, this, [[11, 19], [28, 35]]);
4336
4735
  }));
4337
4736
  function confirmWalletPayment() {
4338
4737
  return _confirmWalletPayment.apply(this, arguments);
@@ -4347,38 +4746,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4347
4746
  }, {
4348
4747
  key: "payCash",
4349
4748
  value: (function () {
4350
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4351
- var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams27, _this$window, _this$window$postMess;
4749
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4750
+ var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams33, _this$window, _this$window$postMess;
4352
4751
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4353
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4354
- while (1) switch (_context47.prev = _context47.next) {
4752
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4753
+ while (1) switch (_context51.prev = _context51.next) {
4355
4754
  case 0:
4356
4755
  if (this.store.order) {
4357
- _context47.next = 2;
4756
+ _context51.next = 2;
4358
4757
  break;
4359
4758
  }
4360
4759
  throw new Error('order 模块未初始化');
4361
4760
  case 2:
4362
4761
  amount = Number(params.amount || 0);
4363
4762
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4364
- _context47.next = 5;
4763
+ _context51.next = 5;
4365
4764
  break;
4366
4765
  }
4367
4766
  throw new Error('现金支付金额必须大于 0');
4368
4767
  case 5:
4369
- _context47.next = 7;
4768
+ _context51.next = 7;
4370
4769
  return this.getCashPaymentConfig();
4371
4770
  case 7:
4372
- config = _context47.sent;
4771
+ config = _context51.sent;
4373
4772
  paymentMethod = config.paymentMethod;
4374
4773
  if (paymentMethod) {
4375
- _context47.next = 11;
4774
+ _context51.next = 11;
4376
4775
  break;
4377
4776
  }
4378
4777
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
4379
4778
  case 11:
4380
4779
  if (!(config.amountDue <= 0)) {
4381
- _context47.next = 13;
4780
+ _context51.next = 13;
4382
4781
  break;
4383
4782
  }
4384
4783
  throw new Error('当前订单没有待支付金额');
@@ -4386,7 +4785,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4386
4785
  roundingAmount = Number(params.roundingAmount || 0);
4387
4786
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
4388
4787
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
4389
- _context47.next = 17;
4788
+ _context51.next = 17;
4390
4789
  break;
4391
4790
  }
4392
4791
  throw new Error('现金支付金额超过当前待支付金额');
@@ -4397,9 +4796,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4397
4796
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
4398
4797
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
4399
4798
  changeAmount = Number(params.changeAmount || 0);
4400
- shopWalletPassId = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.shop_wallet_pass_id;
4799
+ shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
4401
4800
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
4402
- _context47.next = 26;
4801
+ _context51.next = 26;
4403
4802
  break;
4404
4803
  }
4405
4804
  throw new Error('顾客实收现金不能小于支付金额');
@@ -4434,8 +4833,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4434
4833
  var _item$metadata2;
4435
4834
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
4436
4835
  });
4437
- _context47.prev = 29;
4438
- _context47.next = 32;
4836
+ _context51.prev = 29;
4837
+ _context51.next = 32;
4439
4838
  return this.syncPaymentsToOrder({
4440
4839
  payments: payments,
4441
4840
  submitWhenPaid: true,
@@ -4443,44 +4842,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4443
4842
  confirmPendingVoucherPayments: true
4444
4843
  });
4445
4844
  case 32:
4446
- syncResult = _context47.sent;
4845
+ syncResult = _context51.sent;
4846
+ if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
4847
+ _context51.next = 35;
4848
+ break;
4849
+ }
4850
+ throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
4851
+ case 35:
4447
4852
  if (!this.store.payment) {
4448
- _context47.next = 38;
4853
+ _context51.next = 40;
4449
4854
  break;
4450
4855
  }
4451
4856
  committed = this.getCommittedWalletAssets();
4452
4857
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4453
- _context47.next = 38;
4858
+ _context51.next = 40;
4454
4859
  return this.publishWalletAssetsState(walletState);
4455
- case 38:
4456
- return _context47.abrupt("return", {
4860
+ case 40:
4861
+ return _context51.abrupt("return", {
4457
4862
  payment: payment || {},
4458
4863
  payments: this.store.order.getOrderPayments(),
4459
4864
  syncResult: syncResult,
4460
4865
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4461
4866
  });
4462
- case 41:
4463
- _context47.prev = 41;
4464
- _context47.t0 = _context47["catch"](29);
4867
+ case 43:
4868
+ _context51.prev = 43;
4869
+ _context51.t0 = _context51["catch"](29);
4465
4870
  this.store.order.setOrderPayments(beforePayments);
4466
4871
  restoredTempOrder = this.store.order.getTempOrder();
4467
4872
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4468
4873
  restoredTempOrder.payment_status = beforePaymentStatus;
4469
4874
  this.store.order.persistTempOrder();
4470
4875
  }
4471
- _context47.next = 48;
4876
+ _context51.next = 50;
4472
4877
  return this.store.order.recalculateSummary({
4473
4878
  createIfMissing: true
4474
4879
  });
4475
- case 48:
4476
- throw _context47.t0;
4477
- case 49:
4880
+ case 50:
4881
+ throw _context51.t0;
4882
+ case 51:
4478
4883
  case "end":
4479
- return _context47.stop();
4884
+ return _context51.stop();
4480
4885
  }
4481
- }, _callee47, this, [[29, 41]]);
4886
+ }, _callee51, this, [[29, 43]]);
4482
4887
  }));
4483
- function payCash(_x39) {
4888
+ function payCash(_x42) {
4484
4889
  return _payCash.apply(this, arguments);
4485
4890
  }
4486
4891
  return payCash;
@@ -4496,21 +4901,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4496
4901
  }, {
4497
4902
  key: "commitPaymentMethodPayment",
4498
4903
  value: (function () {
4499
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4500
- var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
4904
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4905
+ var _this$store$order$get7, _this$store$order16, _this$store$order$get8, _params$metadata, _params$originAmount;
4501
4906
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
4502
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4503
- while (1) switch (_context48.prev = _context48.next) {
4907
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4908
+ while (1) switch (_context52.prev = _context52.next) {
4504
4909
  case 0:
4505
4910
  if (this.store.order) {
4506
- _context48.next = 2;
4911
+ _context52.next = 2;
4507
4912
  break;
4508
4913
  }
4509
4914
  throw new Error('order 模块未初始化');
4510
4915
  case 2:
4511
4916
  amount = Number(params.amount || 0);
4512
4917
  if (!(!Number.isFinite(amount) || amount <= 0)) {
4513
- _context48.next = 5;
4918
+ _context52.next = 5;
4514
4919
  break;
4515
4920
  }
4516
4921
  throw new Error('支付金额必须大于 0');
@@ -4526,32 +4931,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4526
4931
  };
4527
4932
  paymentMethod = findPaymentMethod();
4528
4933
  if (paymentMethod) {
4529
- _context48.next = 13;
4934
+ _context52.next = 13;
4530
4935
  break;
4531
4936
  }
4532
- _context48.next = 11;
4937
+ _context52.next = 11;
4533
4938
  return this.getPaymentMethodsAsync();
4534
4939
  case 11:
4535
- paymentMethods = _context48.sent;
4940
+ paymentMethods = _context52.sent;
4536
4941
  paymentMethod = findPaymentMethod();
4537
4942
  case 13:
4538
4943
  if (paymentMethod) {
4539
- _context48.next = 15;
4944
+ _context52.next = 15;
4540
4945
  break;
4541
4946
  }
4542
4947
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
4543
4948
  case 15:
4544
- amountSnapshot = (_this$store$order$get7 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order15);
4949
+ amountSnapshot = (_this$store$order$get7 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16);
4545
4950
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
4546
4951
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
4547
4952
  if (!amountDue.lte(0)) {
4548
- _context48.next = 20;
4953
+ _context52.next = 20;
4549
4954
  break;
4550
4955
  }
4551
4956
  throw new Error('当前订单没有待支付金额');
4552
4957
  case 20:
4553
4958
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
4554
- _context48.next = 22;
4959
+ _context52.next = 22;
4555
4960
  break;
4556
4961
  }
4557
4962
  throw new Error('支付金额超过当前待支付金额');
@@ -4590,8 +4995,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4590
4995
  var _item$metadata3;
4591
4996
  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;
4592
4997
  });
4593
- _context48.prev = 30;
4594
- _context48.next = 33;
4998
+ _context52.prev = 30;
4999
+ _context52.next = 33;
4595
5000
  return this.syncPaymentsToOrder({
4596
5001
  payments: payments,
4597
5002
  submitWhenPaid: true,
@@ -4599,44 +5004,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4599
5004
  confirmPendingVoucherPayments: true
4600
5005
  });
4601
5006
  case 33:
4602
- syncResult = _context48.sent;
5007
+ syncResult = _context52.sent;
5008
+ if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5009
+ _context52.next = 36;
5010
+ break;
5011
+ }
5012
+ throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5013
+ case 36:
4603
5014
  if (!this.store.payment) {
4604
- _context48.next = 39;
5015
+ _context52.next = 41;
4605
5016
  break;
4606
5017
  }
4607
5018
  committed = this.getCommittedWalletAssets();
4608
5019
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
4609
- _context48.next = 39;
5020
+ _context52.next = 41;
4610
5021
  return this.publishWalletAssetsState(walletState);
4611
- case 39:
4612
- return _context48.abrupt("return", {
5022
+ case 41:
5023
+ return _context52.abrupt("return", {
4613
5024
  payment: payment || {},
4614
5025
  payments: this.store.order.getOrderPayments(),
4615
5026
  syncResult: syncResult,
4616
5027
  isOrderFullyPaid: syncResult.isOrderFullyPaid
4617
5028
  });
4618
- case 42:
4619
- _context48.prev = 42;
4620
- _context48.t0 = _context48["catch"](30);
5029
+ case 44:
5030
+ _context52.prev = 44;
5031
+ _context52.t0 = _context52["catch"](30);
4621
5032
  this.store.order.setOrderPayments(beforePayments);
4622
5033
  restoredTempOrder = this.store.order.getTempOrder();
4623
5034
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
4624
5035
  restoredTempOrder.payment_status = beforePaymentStatus;
4625
5036
  this.store.order.persistTempOrder();
4626
5037
  }
4627
- _context48.next = 49;
5038
+ _context52.next = 51;
4628
5039
  return this.store.order.recalculateSummary({
4629
5040
  createIfMissing: true
4630
5041
  });
4631
- case 49:
4632
- throw _context48.t0;
4633
- case 50:
5042
+ case 51:
5043
+ throw _context52.t0;
5044
+ case 52:
4634
5045
  case "end":
4635
- return _context48.stop();
5046
+ return _context52.stop();
4636
5047
  }
4637
- }, _callee48, this, [[30, 42]]);
5048
+ }, _callee52, this, [[30, 44]]);
4638
5049
  }));
4639
- function commitPaymentMethodPayment(_x40) {
5050
+ function commitPaymentMethodPayment(_x43) {
4640
5051
  return _commitPaymentMethodPayment.apply(this, arguments);
4641
5052
  }
4642
5053
  return commitPaymentMethodPayment;
@@ -4651,40 +5062,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4651
5062
  }, {
4652
5063
  key: "roundAmount",
4653
5064
  value: (function () {
4654
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
5065
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
4655
5066
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
4656
5067
  var amount, cashManualPayment;
4657
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4658
- while (1) switch (_context49.prev = _context49.next) {
5068
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5069
+ while (1) switch (_context53.prev = _context53.next) {
4659
5070
  case 0:
4660
5071
  amount = params.amount;
4661
5072
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
4662
5073
  return paymentMethod.code === 'CASHMANUAL';
4663
5074
  });
4664
5075
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
4665
- _context49.next = 4;
5076
+ _context53.next = 4;
4666
5077
  break;
4667
5078
  }
4668
- return _context49.abrupt("return", {
5079
+ return _context53.abrupt("return", {
4669
5080
  originalAmount: amount.toString(),
4670
5081
  roundedAmount: amount.toString(),
4671
5082
  roundingDifference: '0.00'
4672
5083
  });
4673
5084
  case 4:
4674
5085
  if (this.payment) {
4675
- _context49.next = 6;
5086
+ _context53.next = 6;
4676
5087
  break;
4677
5088
  }
4678
5089
  throw new Error('payment 模块未初始化');
4679
5090
  case 6:
4680
- return _context49.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
5091
+ return _context53.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));
4681
5092
  case 7:
4682
5093
  case "end":
4683
- return _context49.stop();
5094
+ return _context53.stop();
4684
5095
  }
4685
- }, _callee49, this);
5096
+ }, _callee53, this);
4686
5097
  }));
4687
- function roundAmount(_x41) {
5098
+ function roundAmount(_x44) {
4688
5099
  return _roundAmount.apply(this, arguments);
4689
5100
  }
4690
5101
  return roundAmount;
@@ -4699,49 +5110,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4699
5110
  }, {
4700
5111
  key: "sendCustomerPayLink",
4701
5112
  value: (function () {
4702
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4703
- var orderIds, _ref34, _ref35, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
4704
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4705
- while (1) switch (_context50.prev = _context50.next) {
5113
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5114
+ var orderIds, _ref41, _ref42, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5115
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5116
+ while (1) switch (_context54.prev = _context54.next) {
4706
5117
  case 0:
4707
5118
  if (this.store.order) {
4708
- _context50.next = 2;
5119
+ _context54.next = 2;
4709
5120
  break;
4710
5121
  }
4711
5122
  throw new Error('order 模块未初始化');
4712
5123
  case 2:
4713
5124
  orderIds = params.order_ids || params.orderIds || [];
4714
5125
  if (!(!orderIds.length || params.submitBeforeSend)) {
4715
- _context50.next = 11;
5126
+ _context54.next = 11;
4716
5127
  break;
4717
5128
  }
4718
- _context50.next = 6;
5129
+ _context54.next = 6;
4719
5130
  return this.submitSalesOrder({
4720
5131
  smallTicketDataFlag: 1
4721
5132
  });
4722
5133
  case 6:
4723
- submitResult = _context50.sent;
4724
- orderId = (_ref34 = (_ref35 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref35 !== void 0 ? _ref35 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref34 !== void 0 ? _ref34 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
5134
+ submitResult = _context54.sent;
5135
+ orderId = (_ref41 = (_ref42 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref42 !== void 0 ? _ref42 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref41 !== void 0 ? _ref41 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
4725
5136
  if (orderId) {
4726
- _context50.next = 10;
5137
+ _context54.next = 10;
4727
5138
  break;
4728
5139
  }
4729
5140
  throw new Error('本地订单提交云端失败,无法发送支付链接');
4730
5141
  case 10:
4731
5142
  orderIds = [orderId];
4732
5143
  case 11:
4733
- return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
5144
+ return _context54.abrupt("return", this.store.order.sendCustomerPayLink({
4734
5145
  emails: params.emails,
4735
5146
  notify_action: params.notify_action,
4736
5147
  order_ids: orderIds
4737
5148
  }));
4738
5149
  case 12:
4739
5150
  case "end":
4740
- return _context50.stop();
5151
+ return _context54.stop();
4741
5152
  }
4742
- }, _callee50, this);
5153
+ }, _callee54, this);
4743
5154
  }));
4744
- function sendCustomerPayLink(_x42) {
5155
+ function sendCustomerPayLink(_x45) {
4745
5156
  return _sendCustomerPayLink.apply(this, arguments);
4746
5157
  }
4747
5158
  return sendCustomerPayLink;
@@ -4754,39 +5165,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4754
5165
  }, {
4755
5166
  key: "calculateProductBookingPrice",
4756
5167
  value: function () {
4757
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5168
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
4758
5169
  var _params$customer_id;
4759
5170
  var quotation, customerId, authoritativeProduct, product;
4760
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4761
- while (1) switch (_context51.prev = _context51.next) {
5171
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5172
+ while (1) switch (_context55.prev = _context55.next) {
4762
5173
  case 0:
4763
5174
  quotation = this.store.quotation;
4764
5175
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
4765
- _context51.next = 4;
4766
- return this.loadProductForPriceQuery(params, customerId);
5176
+ _context55.next = 4;
5177
+ return this.prepareProductPriceQueryContext(customerId);
4767
5178
  case 4:
4768
- authoritativeProduct = _context51.sent;
5179
+ _context55.next = 6;
5180
+ return this.loadProductForPriceQuery(params, customerId);
5181
+ case 6:
5182
+ authoritativeProduct = _context55.sent;
4769
5183
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
4770
- _context51.next = 8;
5184
+ _context55.next = 10;
4771
5185
  return this.loadQuotationForPriceQuery({
4772
5186
  quotation: quotation,
4773
5187
  customer_id: customerId,
4774
5188
  channel: params.channel
4775
5189
  });
4776
- case 8:
4777
- return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
5190
+ case 10:
5191
+ return _context55.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
4778
5192
  product: product,
4779
5193
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
4780
5194
  customer_id: customerId,
4781
- quotation: quotation
5195
+ quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
4782
5196
  })));
4783
- case 9:
5197
+ case 11:
4784
5198
  case "end":
4785
- return _context51.stop();
5199
+ return _context55.stop();
4786
5200
  }
4787
- }, _callee51, this);
5201
+ }, _callee55, this);
4788
5202
  }));
4789
- function calculateProductBookingPrice(_x43) {
5203
+ function calculateProductBookingPrice(_x46) {
4790
5204
  return _calculateProductBookingPrice.apply(this, arguments);
4791
5205
  }
4792
5206
  return calculateProductBookingPrice;
@@ -4830,6 +5244,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4830
5244
  quotationScopes: quotationScopes
4831
5245
  };
4832
5246
  }
5247
+ }, {
5248
+ key: "hasSmartPricingStrategies",
5249
+ value: function hasSmartPricingStrategies() {
5250
+ var _this$core3;
5251
+ 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;
5252
+ if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
5253
+ return false;
5254
+ }
5255
+ var configs = evaluator.getStrategyConfigs();
5256
+ return Array.isArray(configs) && configs.length > 0;
5257
+ }
4833
5258
  }, {
4834
5259
  key: "shouldRecalculateProductBookingPricesForContextChange",
4835
5260
  value: function shouldRecalculateProductBookingPricesForContextChange(params) {
@@ -4839,6 +5264,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4839
5264
  }));
4840
5265
  var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
4841
5266
  var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
5267
+ if (this.hasSmartPricingStrategies()) {
5268
+ return previousCustomerId !== nextCustomerId;
5269
+ }
4842
5270
  var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
4843
5271
  var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
4844
5272
  var shouldRecalculate = false;
@@ -4856,23 +5284,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4856
5284
  }, {
4857
5285
  key: "calculateProductBookingPrices",
4858
5286
  value: function () {
4859
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
5287
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(paramsList) {
4860
5288
  var _paramsList$0$custome,
4861
5289
  _paramsList$,
4862
5290
  _this16 = this,
4863
5291
  _paramsList$2;
4864
5292
  var quotation, customerId, productMapsByGroup, groups;
4865
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4866
- while (1) switch (_context53.prev = _context53.next) {
5293
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5294
+ while (1) switch (_context57.prev = _context57.next) {
4867
5295
  case 0:
4868
5296
  if (paramsList.length) {
4869
- _context53.next = 2;
5297
+ _context57.next = 2;
4870
5298
  break;
4871
5299
  }
4872
- return _context53.abrupt("return", []);
5300
+ return _context57.abrupt("return", []);
4873
5301
  case 2:
4874
5302
  quotation = this.store.quotation;
4875
5303
  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();
5304
+ _context57.next = 6;
5305
+ return this.prepareProductPriceQueryContext(customerId);
5306
+ case 6:
4876
5307
  productMapsByGroup = new Map();
4877
5308
  groups = new Map();
4878
5309
  paramsList.forEach(function (params) {
@@ -4891,15 +5322,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4891
5322
  group.ids.add(productId);
4892
5323
  groups.set(groupKey, group);
4893
5324
  });
4894
- _context53.next = 9;
5325
+ _context57.next = 11;
4895
5326
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
4896
- var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(_ref36) {
4897
- var _ref38, groupKey, group, productsById;
4898
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4899
- while (1) switch (_context52.prev = _context52.next) {
5327
+ var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(_ref43) {
5328
+ var _ref45, groupKey, group, productsById;
5329
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5330
+ while (1) switch (_context56.prev = _context56.next) {
4900
5331
  case 0:
4901
- _ref38 = _slicedToArray(_ref36, 2), groupKey = _ref38[0], group = _ref38[1];
4902
- _context52.next = 3;
5332
+ _ref45 = _slicedToArray(_ref43, 2), groupKey = _ref45[0], group = _ref45[1];
5333
+ _context56.next = 3;
4903
5334
  return _this16.loadProductsForPriceQuery({
4904
5335
  ids: Array.from(group.ids),
4905
5336
  schedule: group.schedule,
@@ -4907,27 +5338,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4907
5338
  channel: group.channel
4908
5339
  });
4909
5340
  case 3:
4910
- productsById = _context52.sent;
5341
+ productsById = _context56.sent;
4911
5342
  productMapsByGroup.set(groupKey, productsById);
4912
5343
  case 5:
4913
5344
  case "end":
4914
- return _context52.stop();
5345
+ return _context56.stop();
4915
5346
  }
4916
- }, _callee52);
5347
+ }, _callee56);
4917
5348
  }));
4918
- return function (_x45) {
4919
- return _ref37.apply(this, arguments);
5349
+ return function (_x48) {
5350
+ return _ref44.apply(this, arguments);
4920
5351
  };
4921
5352
  }()));
4922
- case 9:
4923
- _context53.next = 11;
5353
+ case 11:
5354
+ _context57.next = 13;
4924
5355
  return this.loadQuotationForPriceQuery({
4925
5356
  quotation: quotation,
4926
5357
  customer_id: customerId,
4927
5358
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
4928
5359
  });
4929
- case 11:
4930
- return _context53.abrupt("return", paramsList.map(function (params) {
5360
+ case 13:
5361
+ return _context57.abrupt("return", paramsList.map(function (params) {
4931
5362
  var _this16$otherParams2, _productMapsByGroup$g;
4932
5363
  var productInput = params.product || {};
4933
5364
  var productId = _this16.getPriceQueryProductId(productInput);
@@ -4940,16 +5371,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4940
5371
  product: product,
4941
5372
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
4942
5373
  customer_id: customerId,
4943
- quotation: quotation
5374
+ quotation: authoritativeProduct && _this16.preferAuthoritativeProductQueryPrice() ? undefined : quotation
4944
5375
  }));
4945
5376
  }));
4946
- case 12:
5377
+ case 14:
4947
5378
  case "end":
4948
- return _context53.stop();
5379
+ return _context57.stop();
4949
5380
  }
4950
- }, _callee53, this);
5381
+ }, _callee57, this);
4951
5382
  }));
4952
- function calculateProductBookingPrices(_x44) {
5383
+ function calculateProductBookingPrices(_x47) {
4953
5384
  return _calculateProductBookingPrices.apply(this, arguments);
4954
5385
  }
4955
5386
  return calculateProductBookingPrices;
@@ -4957,34 +5388,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4957
5388
  }, {
4958
5389
  key: "addProductToOrder",
4959
5390
  value: function () {
4960
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking) {
5391
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(product, booking, options) {
4961
5392
  var products;
4962
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4963
- while (1) switch (_context54.prev = _context54.next) {
5393
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5394
+ while (1) switch (_context58.prev = _context58.next) {
4964
5395
  case 0:
4965
- _context54.prev = 0;
5396
+ _context58.prev = 0;
4966
5397
  if (this.store.order) {
4967
- _context54.next = 3;
5398
+ _context58.next = 3;
4968
5399
  break;
4969
5400
  }
4970
5401
  throw new Error('order 模块未初始化');
4971
5402
  case 3:
4972
- _context54.next = 5;
4973
- return this.store.order.addProductToOrder(product, booking);
5403
+ _context58.next = 5;
5404
+ return this.store.order.addProductToOrder(product, booking, options);
4974
5405
  case 5:
4975
- products = _context54.sent;
4976
- return _context54.abrupt("return", products);
5406
+ products = _context58.sent;
5407
+ return _context58.abrupt("return", products);
4977
5408
  case 9:
4978
- _context54.prev = 9;
4979
- _context54.t0 = _context54["catch"](0);
4980
- throw _context54.t0;
5409
+ _context58.prev = 9;
5410
+ _context58.t0 = _context58["catch"](0);
5411
+ throw _context58.t0;
4981
5412
  case 12:
4982
5413
  case "end":
4983
- return _context54.stop();
5414
+ return _context58.stop();
4984
5415
  }
4985
- }, _callee54, this, [[0, 9]]);
5416
+ }, _callee58, this, [[0, 9]]);
4986
5417
  }));
4987
- function addProductToOrder(_x46, _x47) {
5418
+ function addProductToOrder(_x49, _x50, _x51) {
4988
5419
  return _addProductToOrder.apply(this, arguments);
4989
5420
  }
4990
5421
  return addProductToOrder;
@@ -4992,34 +5423,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4992
5423
  }, {
4993
5424
  key: "updateOrderProduct",
4994
5425
  value: function () {
4995
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5426
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
4996
5427
  var products;
4997
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4998
- while (1) switch (_context55.prev = _context55.next) {
5428
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5429
+ while (1) switch (_context59.prev = _context59.next) {
4999
5430
  case 0:
5000
- _context55.prev = 0;
5431
+ _context59.prev = 0;
5001
5432
  if (this.store.order) {
5002
- _context55.next = 3;
5433
+ _context59.next = 3;
5003
5434
  break;
5004
5435
  }
5005
5436
  throw new Error('order 模块未初始化');
5006
5437
  case 3:
5007
- _context55.next = 5;
5438
+ _context59.next = 5;
5008
5439
  return this.store.order.updateOrderProduct(params);
5009
5440
  case 5:
5010
- products = _context55.sent;
5011
- return _context55.abrupt("return", products);
5441
+ products = _context59.sent;
5442
+ return _context59.abrupt("return", products);
5012
5443
  case 9:
5013
- _context55.prev = 9;
5014
- _context55.t0 = _context55["catch"](0);
5015
- throw _context55.t0;
5444
+ _context59.prev = 9;
5445
+ _context59.t0 = _context59["catch"](0);
5446
+ throw _context59.t0;
5016
5447
  case 12:
5017
5448
  case "end":
5018
- return _context55.stop();
5449
+ return _context59.stop();
5019
5450
  }
5020
- }, _callee55, this, [[0, 9]]);
5451
+ }, _callee59, this, [[0, 9]]);
5021
5452
  }));
5022
- function updateOrderProduct(_x48) {
5453
+ function updateOrderProduct(_x52) {
5023
5454
  return _updateOrderProduct.apply(this, arguments);
5024
5455
  }
5025
5456
  return updateOrderProduct;
@@ -5027,34 +5458,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5027
5458
  }, {
5028
5459
  key: "updateOrderProducts",
5029
5460
  value: function () {
5030
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
5461
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
5031
5462
  var products;
5032
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5033
- while (1) switch (_context56.prev = _context56.next) {
5463
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5464
+ while (1) switch (_context60.prev = _context60.next) {
5034
5465
  case 0:
5035
- _context56.prev = 0;
5466
+ _context60.prev = 0;
5036
5467
  if (this.store.order) {
5037
- _context56.next = 3;
5468
+ _context60.next = 3;
5038
5469
  break;
5039
5470
  }
5040
5471
  throw new Error('order 模块未初始化');
5041
5472
  case 3:
5042
- _context56.next = 5;
5473
+ _context60.next = 5;
5043
5474
  return this.store.order.updateOrderProducts(paramsList);
5044
5475
  case 5:
5045
- products = _context56.sent;
5046
- return _context56.abrupt("return", products);
5476
+ products = _context60.sent;
5477
+ return _context60.abrupt("return", products);
5047
5478
  case 9:
5048
- _context56.prev = 9;
5049
- _context56.t0 = _context56["catch"](0);
5050
- throw _context56.t0;
5479
+ _context60.prev = 9;
5480
+ _context60.t0 = _context60["catch"](0);
5481
+ throw _context60.t0;
5051
5482
  case 12:
5052
5483
  case "end":
5053
- return _context56.stop();
5484
+ return _context60.stop();
5054
5485
  }
5055
- }, _callee56, this, [[0, 9]]);
5486
+ }, _callee60, this, [[0, 9]]);
5056
5487
  }));
5057
- function updateOrderProducts(_x49) {
5488
+ function updateOrderProducts(_x53) {
5058
5489
  return _updateOrderProducts.apply(this, arguments);
5059
5490
  }
5060
5491
  return updateOrderProducts;
@@ -5062,34 +5493,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5062
5493
  }, {
5063
5494
  key: "updateOrderProductQuantity",
5064
5495
  value: function () {
5065
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5496
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5066
5497
  var products;
5067
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5068
- while (1) switch (_context57.prev = _context57.next) {
5498
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5499
+ while (1) switch (_context61.prev = _context61.next) {
5069
5500
  case 0:
5070
- _context57.prev = 0;
5501
+ _context61.prev = 0;
5071
5502
  if (this.store.order) {
5072
- _context57.next = 3;
5503
+ _context61.next = 3;
5073
5504
  break;
5074
5505
  }
5075
5506
  throw new Error('order 模块未初始化');
5076
5507
  case 3:
5077
- _context57.next = 5;
5508
+ _context61.next = 5;
5078
5509
  return this.store.order.updateOrderProductQuantity(params);
5079
5510
  case 5:
5080
- products = _context57.sent;
5081
- return _context57.abrupt("return", products);
5511
+ products = _context61.sent;
5512
+ return _context61.abrupt("return", products);
5082
5513
  case 9:
5083
- _context57.prev = 9;
5084
- _context57.t0 = _context57["catch"](0);
5085
- throw _context57.t0;
5514
+ _context61.prev = 9;
5515
+ _context61.t0 = _context61["catch"](0);
5516
+ throw _context61.t0;
5086
5517
  case 12:
5087
5518
  case "end":
5088
- return _context57.stop();
5519
+ return _context61.stop();
5089
5520
  }
5090
- }, _callee57, this, [[0, 9]]);
5521
+ }, _callee61, this, [[0, 9]]);
5091
5522
  }));
5092
- function updateOrderProductQuantity(_x50) {
5523
+ function updateOrderProductQuantity(_x54) {
5093
5524
  return _updateOrderProductQuantity.apply(this, arguments);
5094
5525
  }
5095
5526
  return updateOrderProductQuantity;
@@ -5112,12 +5543,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5112
5543
  }, {
5113
5544
  key: "setOrderProductLineNote",
5114
5545
  value: (function () {
5115
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
5546
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, note) {
5116
5547
  var params, products;
5117
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5118
- while (1) switch (_context58.prev = _context58.next) {
5548
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5549
+ while (1) switch (_context62.prev = _context62.next) {
5119
5550
  case 0:
5120
- _context58.prev = 0;
5551
+ _context62.prev = 0;
5121
5552
  params = {
5122
5553
  product_id: identity.product_id,
5123
5554
  product_variant_id: identity.product_variant_id,
@@ -5132,22 +5563,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5132
5563
  params.product_sku = identity.product_sku;
5133
5564
  }
5134
5565
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
5135
- _context58.next = 7;
5566
+ _context62.next = 7;
5136
5567
  return this.updateOrderProduct(params);
5137
5568
  case 7:
5138
- products = _context58.sent;
5139
- return _context58.abrupt("return", products);
5569
+ products = _context62.sent;
5570
+ return _context62.abrupt("return", products);
5140
5571
  case 11:
5141
- _context58.prev = 11;
5142
- _context58.t0 = _context58["catch"](0);
5143
- throw _context58.t0;
5572
+ _context62.prev = 11;
5573
+ _context62.t0 = _context62["catch"](0);
5574
+ throw _context62.t0;
5144
5575
  case 14:
5145
5576
  case "end":
5146
- return _context58.stop();
5577
+ return _context62.stop();
5147
5578
  }
5148
- }, _callee58, this, [[0, 11]]);
5579
+ }, _callee62, this, [[0, 11]]);
5149
5580
  }));
5150
- function setOrderProductLineNote(_x51, _x52) {
5581
+ function setOrderProductLineNote(_x55, _x56) {
5151
5582
  return _setOrderProductLineNote.apply(this, arguments);
5152
5583
  }
5153
5584
  return setOrderProductLineNote;
@@ -5162,32 +5593,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5162
5593
  }, {
5163
5594
  key: "removeProductsFromOrder",
5164
5595
  value: (function () {
5165
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identities) {
5166
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5167
- while (1) switch (_context59.prev = _context59.next) {
5596
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(identities, options) {
5597
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5598
+ while (1) switch (_context63.prev = _context63.next) {
5168
5599
  case 0:
5169
- _context59.prev = 0;
5600
+ _context63.prev = 0;
5170
5601
  if (this.store.order) {
5171
- _context59.next = 3;
5602
+ _context63.next = 3;
5172
5603
  break;
5173
5604
  }
5174
5605
  throw new Error('order 模块未初始化');
5175
5606
  case 3:
5176
- _context59.next = 5;
5177
- return this.store.order.removeProductsFromOrder(identities);
5607
+ _context63.next = 5;
5608
+ return this.store.order.removeProductsFromOrder(identities, options);
5178
5609
  case 5:
5179
- return _context59.abrupt("return", _context59.sent);
5610
+ return _context63.abrupt("return", _context63.sent);
5180
5611
  case 8:
5181
- _context59.prev = 8;
5182
- _context59.t0 = _context59["catch"](0);
5183
- throw _context59.t0;
5612
+ _context63.prev = 8;
5613
+ _context63.t0 = _context63["catch"](0);
5614
+ throw _context63.t0;
5184
5615
  case 11:
5185
5616
  case "end":
5186
- return _context59.stop();
5617
+ return _context63.stop();
5187
5618
  }
5188
- }, _callee59, this, [[0, 8]]);
5619
+ }, _callee63, this, [[0, 8]]);
5189
5620
  }));
5190
- function removeProductsFromOrder(_x53) {
5621
+ function removeProductsFromOrder(_x57, _x58) {
5191
5622
  return _removeProductsFromOrder.apply(this, arguments);
5192
5623
  }
5193
5624
  return removeProductsFromOrder;
@@ -5195,18 +5626,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5195
5626
  }, {
5196
5627
  key: "removeProductFromOrder",
5197
5628
  value: function () {
5198
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity) {
5199
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5200
- while (1) switch (_context60.prev = _context60.next) {
5629
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(identity, options) {
5630
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
5631
+ while (1) switch (_context64.prev = _context64.next) {
5201
5632
  case 0:
5202
- return _context60.abrupt("return", this.removeProductsFromOrder([identity]));
5633
+ return _context64.abrupt("return", this.removeProductsFromOrder([identity], options));
5203
5634
  case 1:
5204
5635
  case "end":
5205
- return _context60.stop();
5636
+ return _context64.stop();
5206
5637
  }
5207
- }, _callee60, this);
5638
+ }, _callee64, this);
5208
5639
  }));
5209
- function removeProductFromOrder(_x54) {
5640
+ function removeProductFromOrder(_x59, _x60) {
5210
5641
  return _removeProductFromOrder.apply(this, arguments);
5211
5642
  }
5212
5643
  return removeProductFromOrder;
@@ -5256,23 +5687,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5256
5687
  }, {
5257
5688
  key: "applyPromotion",
5258
5689
  value: (function () {
5259
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
5260
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5261
- while (1) switch (_context61.prev = _context61.next) {
5690
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
5691
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
5692
+ while (1) switch (_context65.prev = _context65.next) {
5262
5693
  case 0:
5263
5694
  if (this.store.order) {
5264
- _context61.next = 2;
5695
+ _context65.next = 2;
5265
5696
  break;
5266
5697
  }
5267
5698
  throw new Error('order 模块未初始化');
5268
5699
  case 2:
5269
- _context61.next = 4;
5700
+ _context65.next = 4;
5270
5701
  return this.store.order.applyPromotion();
5271
5702
  case 4:
5272
5703
  case "end":
5273
- return _context61.stop();
5704
+ return _context65.stop();
5274
5705
  }
5275
- }, _callee61, this);
5706
+ }, _callee65, this);
5276
5707
  }));
5277
5708
  function applyPromotion() {
5278
5709
  return _applyPromotion.apply(this, arguments);
@@ -5282,16 +5713,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5282
5713
  }, {
5283
5714
  key: "getUnfulfilledPromotions",
5284
5715
  value: function getUnfulfilledPromotions() {
5285
- var _this$store$order16;
5286
- return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
5716
+ var _this$store$order17;
5717
+ return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getUnfulfilledPromotions()) || [];
5287
5718
  }
5288
5719
 
5289
5720
  /** 最近一次促销计算输出的赠品操作 diff。 */
5290
5721
  }, {
5291
5722
  key: "getLastGiftActions",
5292
5723
  value: function getLastGiftActions() {
5293
- var _this$store$order17;
5294
- return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
5724
+ var _this$store$order18;
5725
+ return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getLastGiftActions()) || null;
5295
5726
  }
5296
5727
 
5297
5728
  // 获取商品列表
@@ -5299,18 +5730,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5299
5730
  }, {
5300
5731
  key: "getProductList",
5301
5732
  value: function () {
5302
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
5303
- var _this$otherParams28;
5733
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
5734
+ var _this$otherParams34;
5304
5735
  var menu_list_ids, _this$store$products, res;
5305
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5306
- while (1) switch (_context62.prev = _context62.next) {
5736
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
5737
+ while (1) switch (_context66.prev = _context66.next) {
5307
5738
  case 0:
5308
5739
  // 可以直接通过配置里的 menu 读取
5309
- menu_list_ids = ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 || (_this$otherParams28 = _this$otherParams28.dineInConfig) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28['menu.associated_menus'].map(function (n) {
5740
+ menu_list_ids = ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 || (_this$otherParams34 = _this$otherParams34.dineInConfig) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34['menu.associated_menus'].map(function (n) {
5310
5741
  return Number(n.value);
5311
5742
  })) || [];
5312
- _context62.prev = 1;
5313
- _context62.next = 4;
5743
+ _context66.prev = 1;
5744
+ _context66.next = 4;
5314
5745
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
5315
5746
  menu_list_ids: menu_list_ids,
5316
5747
  cacheId: this.cacheId,
@@ -5318,17 +5749,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5318
5749
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
5319
5750
  });
5320
5751
  case 4:
5321
- res = _context62.sent;
5322
- return _context62.abrupt("return", res);
5752
+ res = _context66.sent;
5753
+ return _context66.abrupt("return", res);
5323
5754
  case 8:
5324
- _context62.prev = 8;
5325
- _context62.t0 = _context62["catch"](1);
5326
- throw _context62.t0;
5755
+ _context66.prev = 8;
5756
+ _context66.t0 = _context66["catch"](1);
5757
+ throw _context66.t0;
5327
5758
  case 11:
5328
5759
  case "end":
5329
- return _context62.stop();
5760
+ return _context66.stop();
5330
5761
  }
5331
- }, _callee62, this, [[1, 8]]);
5762
+ }, _callee66, this, [[1, 8]]);
5332
5763
  }));
5333
5764
  function getProductList() {
5334
5765
  return _getProductList.apply(this, arguments);
@@ -5343,33 +5774,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5343
5774
  }, {
5344
5775
  key: "setOtherParams",
5345
5776
  value: function () {
5346
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
5347
- var _this$otherParams29;
5348
- var _ref39,
5349
- _ref39$cover,
5777
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
5778
+ var _this$otherParams35;
5779
+ var _ref46,
5780
+ _ref46$cover,
5350
5781
  cover,
5351
- _args63 = arguments;
5352
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5353
- while (1) switch (_context63.prev = _context63.next) {
5782
+ _args67 = arguments;
5783
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
5784
+ while (1) switch (_context67.prev = _context67.next) {
5354
5785
  case 0:
5355
- _ref39 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref39$cover = _ref39.cover, cover = _ref39$cover === void 0 ? false : _ref39$cover;
5786
+ _ref46 = _args67.length > 1 && _args67[1] !== undefined ? _args67[1] : {}, _ref46$cover = _ref46.cover, cover = _ref46$cover === void 0 ? false : _ref46$cover;
5356
5787
  if (cover) {
5357
5788
  this.otherParams = _objectSpread({}, params);
5358
5789
  } else {
5359
5790
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
5360
5791
  }
5361
- this.cacheId = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.cacheId;
5362
- _context63.next = 5;
5792
+ this.cacheId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.cacheId;
5793
+ _context67.next = 5;
5363
5794
  return this.syncOtherParamsToSubModules(params, {
5364
5795
  cover: cover
5365
5796
  });
5366
5797
  case 5:
5367
5798
  case "end":
5368
- return _context63.stop();
5799
+ return _context67.stop();
5369
5800
  }
5370
- }, _callee63, this);
5801
+ }, _callee67, this);
5371
5802
  }));
5372
- function setOtherParams(_x55) {
5803
+ function setOtherParams(_x61) {
5373
5804
  return _setOtherParams.apply(this, arguments);
5374
5805
  }
5375
5806
  return setOtherParams;