@pisell/pisellos 2.3.114 → 2.3.115

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.
@@ -395,6 +395,7 @@ function areBaseSalesNotesEquivalent(currentValue, loadedValue, options) {
395
395
  }
396
396
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
397
397
  var _currentTempOrder$_ex, _normalizedLoadedReco;
398
+ var loadedHasOrderMetaList = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'order_meta_list');
398
399
  var loadedHasSalesNotes = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'notes');
399
400
  var hasDirtyLocalSalesNotes = (currentTempOrder === null || currentTempOrder === void 0 || (_currentTempOrder$_ex = currentTempOrder._extend) === null || _currentTempOrder$_ex === void 0 || (_currentTempOrder$_ex = _currentTempOrder$_ex.salesNotesState) === null || _currentTempOrder$_ex === void 0 ? void 0 : _currentTempOrder$_ex.dirty) === true;
400
401
  var incomingSalesNotesMatchLocal = loadedHasSalesNotes && areBaseSalesNotesEquivalent(currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.notes, loadedRecord.notes, {
@@ -413,6 +414,12 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
413
414
  });
414
415
  var uidRemaps = [];
415
416
  var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
417
+ // order_meta_list 是服务端/本地订单携带的完整业务快照。若 incoming
418
+ // 明确提供它,必须整体替换;若省略,则保留当前值,避免 snapshot
419
+ // 数组递归拼接后出现同 ID 的旧数据。
420
+ if (key === 'order_meta_list') {
421
+ return cloneDeep(loadedHasOrderMetaList ? loadedValue : currentValue);
422
+ }
416
423
  if (key === 'notes') {
417
424
  if (preserveDirtyLocalSalesNotes && Array.isArray(currentValue)) {
418
425
  return cloneDeep(currentValue);
@@ -1888,9 +1895,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1888
1895
  key: "syncAppDataToTempOrder",
1889
1896
  value: function syncAppDataToTempOrder(tempOrder) {
1890
1897
  var isPriceIncludeTax = this.getAppData('is_price_include_tax');
1891
- var taxCountryCode = this.getAppData('tax_country_code');
1892
- var currencyCode = this.getAppData('shop_currency_code');
1893
- var currencySymbol = this.getAppData('shop_symbol');
1898
+ var rawTaxCountryCode = this.getAppData('tax_country_code');
1899
+ var rawCurrencyCode = this.getAppData('shop_currency_code');
1900
+ var rawCurrencySymbol = this.getAppData('shop_symbol');
1901
+ var normalizeNonBlankValue = function normalizeNonBlankValue(value) {
1902
+ if (value === undefined || value === null) return undefined;
1903
+ var normalizedValue = String(value).trim();
1904
+ return normalizedValue || undefined;
1905
+ };
1906
+ var taxCountryCode = normalizeNonBlankValue(rawTaxCountryCode);
1907
+ var currencyCode = normalizeNonBlankValue(rawCurrencyCode);
1908
+ var currencySymbol = normalizeNonBlankValue(rawCurrencySymbol);
1909
+ var before = {
1910
+ tax_country_code: tempOrder.tax_country_code,
1911
+ currency_code: tempOrder.currency_code,
1912
+ currency_symbol: tempOrder.currency_symbol
1913
+ };
1894
1914
  // 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
1895
1915
  var isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
1896
1916
  var isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
@@ -1904,9 +1924,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1904
1924
  }
1905
1925
  }
1906
1926
  if (taxCountryCode !== undefined) {
1907
- var nextTaxCountryCode = String(taxCountryCode || '');
1908
- if (tempOrder.tax_country_code !== nextTaxCountryCode) {
1909
- tempOrder.tax_country_code = nextTaxCountryCode;
1927
+ if (tempOrder.tax_country_code !== taxCountryCode) {
1928
+ tempOrder.tax_country_code = taxCountryCode;
1910
1929
  isChanged = true;
1911
1930
  }
1912
1931
  }
@@ -1924,19 +1943,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1924
1943
  }
1925
1944
  }
1926
1945
  if (!isVirtualSettlement && currencyCode !== undefined) {
1927
- var nextCurrencyCode = String(currencyCode || '');
1928
- if (tempOrder.currency_code !== nextCurrencyCode) {
1929
- tempOrder.currency_code = nextCurrencyCode;
1946
+ if (tempOrder.currency_code !== currencyCode) {
1947
+ tempOrder.currency_code = currencyCode;
1930
1948
  isChanged = true;
1931
1949
  }
1932
1950
  }
1933
1951
  if (!isVirtualSettlement && currencySymbol !== undefined) {
1934
- var nextCurrencySymbol = String(currencySymbol || '');
1935
- if (tempOrder.currency_symbol !== nextCurrencySymbol) {
1936
- tempOrder.currency_symbol = nextCurrencySymbol;
1952
+ if (tempOrder.currency_symbol !== currencySymbol) {
1953
+ tempOrder.currency_symbol = currencySymbol;
1937
1954
  isChanged = true;
1938
1955
  }
1939
1956
  }
1957
+ try {
1958
+ var _this$store$order3, _this$store$order3$ge, _this$logger, _this$logger$addLog, _orderIdentity$orderI, _orderIdentity$extern, _orderIdentity$shopOr;
1959
+ var orderIdentity = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getOrderIdentity) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
1960
+ (_this$logger = this.logger) === null || _this$logger === void 0 || (_this$logger$addLog = _this$logger.addLog) === null || _this$logger$addLog === void 0 || _this$logger$addLog.call(_this$logger, {
1961
+ type: 'info',
1962
+ title: 'syncAppDataToTempOrder',
1963
+ metadata: {
1964
+ moduleName: this.name,
1965
+ cacheId: this.cacheId,
1966
+ orderId: (_orderIdentity$orderI = orderIdentity === null || orderIdentity === void 0 ? void 0 : orderIdentity.orderId) !== null && _orderIdentity$orderI !== void 0 ? _orderIdentity$orderI : tempOrder.order_id,
1967
+ externalSaleNumber: (_orderIdentity$extern = orderIdentity === null || orderIdentity === void 0 ? void 0 : orderIdentity.externalSaleNumber) !== null && _orderIdentity$extern !== void 0 ? _orderIdentity$extern : tempOrder.external_sale_number,
1968
+ shopOrderNumber: (_orderIdentity$shopOr = orderIdentity === null || orderIdentity === void 0 ? void 0 : orderIdentity.shopOrderNumber) !== null && _orderIdentity$shopOr !== void 0 ? _orderIdentity$shopOr : tempOrder.shop_order_number,
1969
+ readValues: {
1970
+ tax_country_code: rawTaxCountryCode,
1971
+ shop_currency_code: rawCurrencyCode,
1972
+ shop_symbol: rawCurrencySymbol
1973
+ },
1974
+ before: before,
1975
+ after: {
1976
+ tax_country_code: tempOrder.tax_country_code,
1977
+ currency_code: tempOrder.currency_code,
1978
+ currency_symbol: tempOrder.currency_symbol
1979
+ },
1980
+ isChanged: isChanged
1981
+ }
1982
+ });
1983
+ } catch (_unused4) {
1984
+ // 诊断日志不能影响订单字段同步。
1985
+ }
1940
1986
  return isChanged;
1941
1987
  }
1942
1988
  }, {
@@ -2243,8 +2289,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2243
2289
  }, {
2244
2290
  key: "getTempOrder",
2245
2291
  value: function getTempOrder() {
2246
- var _this$store$order3;
2247
- var result = ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) || null;
2292
+ var _this$store$order4;
2293
+ var result = ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) || null;
2248
2294
  return result;
2249
2295
  }
2250
2296
  }, {
@@ -2877,12 +2923,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2877
2923
  return discount;
2878
2924
  });
2879
2925
  }
2926
+ }, {
2927
+ key: "resolveDiscountConfigCustomerId",
2928
+ value: function resolveDiscountConfigCustomerId(tempOrder) {
2929
+ var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2;
2930
+ return Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
2931
+ }
2932
+
2933
+ /**
2934
+ * Stable across notifyTempOrderChanged's immutable object replacement, while
2935
+ * still distinguishing two local orders for the same customer.
2936
+ */
2937
+ }, {
2938
+ key: "getDiscountConfigOrderIdentityKey",
2939
+ value: function getDiscountConfigOrderIdentityKey(tempOrder) {
2940
+ var _this$store$order5, _this$store$order5$ge, _ref43, _identity$orderId, _tempOrder$request_un, _ref44, _identity$externalSal, _ref45, _ref46, _identity$localId, _tempOrder$_extend3;
2941
+ var identity = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderIdentity) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2942
+ return JSON.stringify([(_ref43 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref43 !== void 0 ? _ref43 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref44 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref44 !== void 0 ? _ref44 : '', (_ref45 = (_ref46 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.localId) !== null && _ref46 !== void 0 ? _ref46 : this.cacheId) !== null && _ref45 !== void 0 ? _ref45 : '']);
2943
+ }
2880
2944
  }, {
2881
2945
  key: "loadDiscountConfig",
2882
2946
  value: function () {
2883
2947
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2884
- var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
2885
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
2948
+ var _this$store$order$get2,
2949
+ _this$store$order6,
2950
+ _tempOrder$customer2,
2951
+ _tempOrder$_extend4,
2952
+ _tempOrder$_extend5,
2953
+ _discountModule$getDi,
2954
+ _discountModule$getOr,
2955
+ _this$store$order$get3,
2956
+ _this$store$order7,
2957
+ _this16 = this,
2958
+ _discountModule$getDi3;
2959
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order8, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2886
2960
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2887
2961
  while (1) switch (_context26.prev = _context26.next) {
2888
2962
  case 0:
@@ -2896,15 +2970,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2896
2970
  orderStore = this.store.order.store || {};
2897
2971
  discountModule = orderStore.discount;
2898
2972
  rulesModule = orderStore.rules;
2899
- orderId = tempOrder.order_id || ((_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 || (_this$getOrderIdentit = _this$getOrderIdentit.call(this)) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId);
2900
- customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
2973
+ orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order6 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order6)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
2974
+ customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer2 = tempOrder.customer) === null || _tempOrder$customer2 === void 0 ? void 0 : _tempOrder$customer2.id) || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.customerSnapshot) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.id) || ((_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 || (_tempOrder$_extend5 = _tempOrder$_extend5.customerSnapshot) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.customer_id) || 0);
2901
2975
  currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
2902
2976
  originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
2903
2977
  hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(function (discount) {
2904
2978
  return discount.isManualSelect;
2905
2979
  });
2906
2980
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
2907
- discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':'); // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
2981
+ requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
2982
+ discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
2983
+ requestEpoch = (_this$store$order$get3 = (_this$store$order7 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order7);
2984
+ isCurrentRequest = function isCurrentRequest() {
2985
+ var _this16$store$order, _this16$store$order$g, _this16$store$order2, _this16$store$order2$;
2986
+ var currentTempOrder = (_this16$store$order = _this16.store.order) === null || _this16$store$order === void 0 || (_this16$store$order$g = _this16$store$order.getTempOrder) === null || _this16$store$order$g === void 0 ? void 0 : _this16$store$order$g.call(_this16$store$order);
2987
+ return Boolean(currentTempOrder && (requestEpoch === undefined || ((_this16$store$order2 = _this16.store.order) === null || _this16$store$order2 === void 0 || (_this16$store$order2$ = _this16$store$order2.getCustomerWalletPrepareConfigEpoch) === null || _this16$store$order2$ === void 0 ? void 0 : _this16$store$order2$.call(_this16$store$order2)) === requestEpoch) && _this16.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && _this16.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2988
+ };
2989
+ getCurrentResult = function getCurrentResult() {
2990
+ var _this16$store$order3, _this16$store$order3$, _discountModule$getDi2;
2991
+ var currentTempOrder = (_this16$store$order3 = _this16.store.order) === null || _this16$store$order3 === void 0 || (_this16$store$order3$ = _this16$store$order3.getTempOrder) === null || _this16$store$order3$ === void 0 ? void 0 : _this16$store$order3$.call(_this16$store$order3);
2992
+ return {
2993
+ productList: (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.products) || [],
2994
+ discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [],
2995
+ availableWalletIds: _this16.getAvailableWalletIds(),
2996
+ virtualCurrencyList: _this16.getVirtualCurrencyList()
2997
+ };
2998
+ }; // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
2908
2999
  // current 优先于 original,保留搜索后的最新选择与可用状态。
2909
3000
  searchedDiscountList = currentDiscountList.filter(function (discount) {
2910
3001
  return discount.isScan;
@@ -2916,65 +3007,110 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2916
3007
  return !searchedDiscountIds.has(String(discount.id));
2917
3008
  })));
2918
3009
  if (!(customerId && customerId !== 1)) {
2919
- _context26.next = 27;
3010
+ _context26.next = 37;
2920
3011
  break;
2921
3012
  }
2922
3013
  if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
2923
- _context26.next = 21;
3014
+ _context26.next = 25;
2924
3015
  break;
2925
3016
  }
2926
3017
  preparedDiscountList = originalDiscountList;
2927
- _context26.next = 27;
3018
+ _context26.next = 37;
2928
3019
  break;
2929
- case 21:
2930
- _context26.next = 23;
2931
- return this.store.order.loadDiscountConfig({
3020
+ case 25:
3021
+ prepareConfigPromise = this.store.order.loadDiscountConfig({
2932
3022
  customerId: customerId,
2933
3023
  action: discountAction,
2934
3024
  orderId: Number(orderId) || undefined,
2935
3025
  apply: false
2936
- });
2937
- case 23:
3026
+ }); // OrderModule increments this epoch synchronously before its first await.
3027
+ requestEpoch = (_this$store$order$get4 = (_this$store$order8 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order8);
3028
+ _context26.next = 29;
3029
+ return prepareConfigPromise;
3030
+ case 29:
2938
3031
  preparedDiscountList = _context26.sent;
2939
- this.discountConfigCacheKey = discountConfigCacheKey;
2940
- _context26.next = 27;
3032
+ if (isCurrentRequest()) {
3033
+ _context26.next = 32;
3034
+ break;
3035
+ }
3036
+ return _context26.abrupt("return", getCurrentResult());
3037
+ case 32:
3038
+ _context26.next = 34;
2941
3039
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2942
- case 27:
3040
+ case 34:
3041
+ if (isCurrentRequest()) {
3042
+ _context26.next = 36;
3043
+ break;
3044
+ }
3045
+ return _context26.abrupt("return", getCurrentResult());
3046
+ case 36:
3047
+ this.discountConfigCacheKey = discountConfigCacheKey;
3048
+ case 37:
2943
3049
  if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
2944
- _context26.next = 35;
3050
+ _context26.next = 51;
3051
+ break;
3052
+ }
3053
+ if (isCurrentRequest()) {
3054
+ _context26.next = 40;
2945
3055
  break;
2946
3056
  }
2947
- _context26.next = 30;
3057
+ return _context26.abrupt("return", getCurrentResult());
3058
+ case 40:
3059
+ _context26.next = 42;
2948
3060
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
2949
- case 30:
2950
- _context26.next = 32;
3061
+ case 42:
3062
+ if (isCurrentRequest()) {
3063
+ _context26.next = 44;
3064
+ break;
3065
+ }
3066
+ return _context26.abrupt("return", getCurrentResult());
3067
+ case 44:
3068
+ _context26.next = 46;
2951
3069
  return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
2952
- case 32:
3070
+ case 46:
3071
+ if (isCurrentRequest()) {
3072
+ _context26.next = 48;
3073
+ break;
3074
+ }
3075
+ return _context26.abrupt("return", getCurrentResult());
3076
+ case 48:
2953
3077
  tempOrder.discount_list = [];
2954
3078
  tempOrder.shop_discount = '0.00';
2955
3079
  return _context26.abrupt("return", {
2956
3080
  productList: tempOrder.products || [],
2957
3081
  discountList: [],
2958
3082
  availableWalletIds: this.getAvailableWalletIds(),
2959
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
3083
+ virtualCurrencyList: this.getVirtualCurrencyList()
2960
3084
  });
2961
- case 35:
3085
+ case 51:
2962
3086
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
2963
- _context26.next = 37;
3087
+ _context26.next = 53;
2964
3088
  break;
2965
3089
  }
2966
3090
  return _context26.abrupt("return", {
2967
3091
  productList: tempOrder.products || [],
2968
3092
  discountList: currentDiscountList,
2969
3093
  availableWalletIds: this.getAvailableWalletIds(),
2970
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
3094
+ virtualCurrencyList: this.getVirtualCurrencyList()
2971
3095
  });
2972
- case 37:
2973
- 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 || []);
3096
+ case 53:
3097
+ nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [], tempOrder.products || []);
2974
3098
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
2975
- _context26.next = 41;
3099
+ if (isCurrentRequest()) {
3100
+ _context26.next = 57;
3101
+ break;
3102
+ }
3103
+ return _context26.abrupt("return", getCurrentResult());
3104
+ case 57:
3105
+ _context26.next = 59;
2976
3106
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2977
- case 41:
3107
+ case 59:
3108
+ if (isCurrentRequest()) {
3109
+ _context26.next = 61;
3110
+ break;
3111
+ }
3112
+ return _context26.abrupt("return", getCurrentResult());
3113
+ case 61:
2978
3114
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
2979
3115
  discountAction: discountAction,
2980
3116
  products: tempOrder.products || [],
@@ -2982,35 +3118,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2982
3118
  nextDiscountList: nextDiscountList
2983
3119
  });
2984
3120
  if (!shouldSkipAutoApplyFetchedDiscounts) {
2985
- _context26.next = 50;
3121
+ _context26.next = 75;
2986
3122
  break;
2987
3123
  }
2988
- _context26.next = 45;
3124
+ _context26.next = 65;
2989
3125
  return this.store.order.recalculateSummary({
2990
3126
  createIfMissing: true
2991
3127
  });
2992
- case 45:
2993
- _summary = _context26.sent;
3128
+ case 65:
3129
+ if (isCurrentRequest()) {
3130
+ _context26.next = 67;
3131
+ break;
3132
+ }
3133
+ return _context26.abrupt("return", getCurrentResult());
3134
+ case 67:
2994
3135
  this.store.order.persistTempOrder();
2995
- _context26.next = 49;
3136
+ if (isCurrentRequest()) {
3137
+ _context26.next = 70;
3138
+ break;
3139
+ }
3140
+ return _context26.abrupt("return", getCurrentResult());
3141
+ case 70:
3142
+ _context26.next = 72;
2996
3143
  return this.effectsEmit('onDiscountApplied', {
2997
3144
  productList: tempOrder.products || [],
2998
3145
  discountList: nextDiscountList,
2999
3146
  selectedDiscountList: tempOrder.discount_list || [],
3000
3147
  tempOrder: tempOrder
3001
3148
  });
3002
- case 49:
3149
+ case 72:
3150
+ if (isCurrentRequest()) {
3151
+ _context26.next = 74;
3152
+ break;
3153
+ }
3154
+ return _context26.abrupt("return", getCurrentResult());
3155
+ case 74:
3003
3156
  return _context26.abrupt("return", {
3004
3157
  productList: tempOrder.products || [],
3005
3158
  discountList: nextDiscountList,
3006
3159
  availableWalletIds: this.getAvailableWalletIds(),
3007
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
3160
+ virtualCurrencyList: this.getVirtualCurrencyList()
3008
3161
  });
3009
- case 50:
3162
+ case 75:
3010
3163
  if (!rulesModule) {
3011
- _context26.next = 86;
3164
+ _context26.next = 117;
3012
3165
  break;
3013
3166
  }
3167
+ if (isCurrentRequest()) {
3168
+ _context26.next = 78;
3169
+ break;
3170
+ }
3171
+ return _context26.abrupt("return", getCurrentResult());
3172
+ case 78:
3014
3173
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
3015
3174
  result = rulesModule.calcDiscount({
3016
3175
  productList: tempOrder.products,
@@ -3028,22 +3187,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3028
3187
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3029
3188
  }
3030
3189
  _iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
3031
- _context26.prev = 55;
3190
+ _context26.prev = 82;
3032
3191
  _iterator3.s();
3033
- case 57:
3192
+ case 84:
3034
3193
  if ((_step3 = _iterator3.n()).done) {
3035
- _context26.next = 72;
3194
+ _context26.next = 99;
3036
3195
  break;
3037
3196
  }
3038
3197
  product = _step3.value;
3039
3198
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
3040
- 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;
3199
+ runtimeOrigin = productUid ? (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6.productsByUid) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6[productUid]) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.origin : undefined;
3041
3200
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3042
- _context26.next = 63;
3201
+ _context26.next = 90;
3043
3202
  break;
3044
3203
  }
3045
- return _context26.abrupt("continue", 70);
3046
- case 63:
3204
+ return _context26.abrupt("continue", 97);
3205
+ case 90:
3047
3206
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
3048
3207
  return sum + Number(pd.amount || 0);
3049
3208
  }, 0);
@@ -3059,60 +3218,95 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3059
3218
  mainPrice: newMainSellingPrice,
3060
3219
  bundle: product.product_bundle
3061
3220
  });
3062
- case 70:
3063
- _context26.next = 57;
3221
+ case 97:
3222
+ _context26.next = 84;
3064
3223
  break;
3065
- case 72:
3066
- _context26.next = 77;
3224
+ case 99:
3225
+ _context26.next = 104;
3067
3226
  break;
3068
- case 74:
3069
- _context26.prev = 74;
3070
- _context26.t0 = _context26["catch"](55);
3227
+ case 101:
3228
+ _context26.prev = 101;
3229
+ _context26.t0 = _context26["catch"](82);
3071
3230
  _iterator3.e(_context26.t0);
3072
- case 77:
3073
- _context26.prev = 77;
3231
+ case 104:
3232
+ _context26.prev = 104;
3074
3233
  _iterator3.f();
3075
- return _context26.finish(77);
3076
- case 80:
3234
+ return _context26.finish(104);
3235
+ case 107:
3077
3236
  if (!result.discountList) {
3078
- _context26.next = 86;
3237
+ _context26.next = 117;
3079
3238
  break;
3080
3239
  }
3081
3240
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
3082
3241
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3083
- _context26.next = 85;
3242
+ if (isCurrentRequest()) {
3243
+ _context26.next = 112;
3244
+ break;
3245
+ }
3246
+ return _context26.abrupt("return", getCurrentResult());
3247
+ case 112:
3248
+ _context26.next = 114;
3084
3249
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3085
- case 85:
3250
+ case 114:
3251
+ if (isCurrentRequest()) {
3252
+ _context26.next = 116;
3253
+ break;
3254
+ }
3255
+ return _context26.abrupt("return", getCurrentResult());
3256
+ case 116:
3086
3257
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
3087
3258
  return discount.isSelected;
3088
3259
  });
3089
- case 86:
3090
- _context26.next = 88;
3260
+ case 117:
3261
+ if (isCurrentRequest()) {
3262
+ _context26.next = 119;
3263
+ break;
3264
+ }
3265
+ return _context26.abrupt("return", getCurrentResult());
3266
+ case 119:
3267
+ _context26.next = 121;
3091
3268
  return this.store.order.recalculateSummary({
3092
3269
  createIfMissing: true
3093
3270
  });
3094
- case 88:
3095
- summary = _context26.sent;
3271
+ case 121:
3272
+ if (isCurrentRequest()) {
3273
+ _context26.next = 123;
3274
+ break;
3275
+ }
3276
+ return _context26.abrupt("return", getCurrentResult());
3277
+ case 123:
3096
3278
  this.store.order.persistTempOrder();
3097
- _context26.next = 92;
3279
+ if (isCurrentRequest()) {
3280
+ _context26.next = 126;
3281
+ break;
3282
+ }
3283
+ return _context26.abrupt("return", getCurrentResult());
3284
+ case 126:
3285
+ _context26.next = 128;
3098
3286
  return this.effectsEmit('onDiscountApplied', {
3099
3287
  productList: tempOrder.products || [],
3100
3288
  discountList: nextDiscountList,
3101
3289
  selectedDiscountList: tempOrder.discount_list || [],
3102
3290
  tempOrder: tempOrder
3103
3291
  });
3104
- case 92:
3292
+ case 128:
3293
+ if (isCurrentRequest()) {
3294
+ _context26.next = 130;
3295
+ break;
3296
+ }
3297
+ return _context26.abrupt("return", getCurrentResult());
3298
+ case 130:
3105
3299
  return _context26.abrupt("return", {
3106
3300
  productList: tempOrder.products || [],
3107
3301
  discountList: nextDiscountList,
3108
3302
  availableWalletIds: this.getAvailableWalletIds(),
3109
- virtualCurrencyList: this.store.order.getVirtualCurrencyList()
3303
+ virtualCurrencyList: this.getVirtualCurrencyList()
3110
3304
  });
3111
- case 93:
3305
+ case 131:
3112
3306
  case "end":
3113
3307
  return _context26.stop();
3114
3308
  }
3115
- }, _callee26, this, [[55, 74, 77, 80]]);
3309
+ }, _callee26, this, [[82, 101, 104, 107]]);
3116
3310
  }));
3117
3311
  function loadDiscountConfig(_x18) {
3118
3312
  return _loadDiscountConfig.apply(this, arguments);
@@ -3122,22 +3316,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3122
3316
  }, {
3123
3317
  key: "getAvailableWalletIds",
3124
3318
  value: function getAvailableWalletIds() {
3125
- var _this$store$order4;
3126
- if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
3319
+ var _this$store$order9;
3320
+ if (!((_this$store$order9 = this.store.order) !== null && _this$store$order9 !== void 0 && _this$store$order9.getAvailableWalletIds)) return [];
3127
3321
  return this.store.order.getAvailableWalletIds();
3128
3322
  }
3129
3323
  }, {
3130
3324
  key: "getVirtualCurrencyList",
3131
3325
  value: function getVirtualCurrencyList() {
3132
- var _this$store$order5;
3133
- if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && _this$store$order5.getVirtualCurrencyList)) return [];
3326
+ var _this$store$order10;
3327
+ if (!((_this$store$order10 = this.store.order) !== null && _this$store$order10 !== void 0 && _this$store$order10.getVirtualCurrencyList)) return [];
3134
3328
  return this.store.order.getVirtualCurrencyList();
3135
3329
  }
3136
3330
  }, {
3137
3331
  key: "bestDiscount",
3138
3332
  value: function () {
3139
3333
  var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(cb) {
3140
- var _discountModule$getOr2, _discountModule$getDi3;
3334
+ var _discountModule$getOr2, _discountModule$getDi4;
3141
3335
  var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
3142
3336
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3143
3337
  while (1) switch (_context27.prev = _context27.next) {
@@ -3164,7 +3358,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3164
3358
  discountModule = orderStore.discount;
3165
3359
  rulesModule = orderStore.rules;
3166
3360
  originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr2 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr2 === void 0 ? void 0 : _discountModule$getOr2.call(discountModule)) || this.getDiscountList();
3167
- currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [];
3361
+ currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi4 = discountModule.getDiscountList) === null || _discountModule$getDi4 === void 0 ? void 0 : _discountModule$getDi4.call(discountModule)) || [];
3168
3362
  nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
3169
3363
  result = {
3170
3364
  productList: tempOrder.products || [],
@@ -3363,7 +3557,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3363
3557
  key: "setDiscountSelected",
3364
3558
  value: function () {
3365
3559
  var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3366
- var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3560
+ var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, _discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend7, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3367
3561
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3368
3562
  while (1) switch (_context30.prev = _context30.next) {
3369
3563
  case 0:
@@ -3402,11 +3596,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3402
3596
  this.hasManualDiscountSelection = true;
3403
3597
  tempOrder = this.store.order.ensureTempOrder();
3404
3598
  orderStore = this.store.order.store || {};
3405
- discountModule = orderStore.discount;
3599
+ _discountModule = orderStore.discount;
3406
3600
  rulesModule = orderStore.rules;
3407
3601
  nextDiscountList = updated;
3408
3602
  _context30.next = 23;
3409
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
3603
+ return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(updated);
3410
3604
  case 23:
3411
3605
  if (rulesModule) {
3412
3606
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
@@ -3476,7 +3670,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3476
3670
  }
3477
3671
  product = _step5.value;
3478
3672
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
3479
- 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;
3673
+ runtimeOrigin = productUid ? (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7.productsByUid) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7[productUid]) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.origin : undefined;
3480
3674
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3481
3675
  _context30.next = 35;
3482
3676
  break;
@@ -3486,10 +3680,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3486
3680
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
3487
3681
  if (Array.isArray(product.product_bundle)) {
3488
3682
  product.product_bundle = product.product_bundle.map(function (bundle) {
3489
- var _ref43, _bundle$original_pric;
3683
+ var _ref47, _bundle$original_pric;
3490
3684
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
3491
3685
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
3492
- var restoredBundlePrice = (_ref43 = (_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 && _ref43 !== void 0 ? _ref43 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
3686
+ var restoredBundlePrice = (_ref47 = (_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 && _ref47 !== void 0 ? _ref47 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
3493
3687
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
3494
3688
  price: restoredBundlePrice,
3495
3689
  bundle_selling_price: restoredBundlePrice
@@ -3533,7 +3727,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3533
3727
  case 54:
3534
3728
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3535
3729
  _context30.next = 57;
3536
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3730
+ return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(nextDiscountList);
3537
3731
  case 57:
3538
3732
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
3539
3733
  return d.isSelected;
@@ -3571,7 +3765,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3571
3765
  key: "applyDiscountCalculationResult",
3572
3766
  value: function () {
3573
3767
  var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(result) {
3574
- var tempOrder, orderStore, discountModule;
3768
+ var tempOrder, orderStore, _discountModule2;
3575
3769
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3576
3770
  while (1) switch (_context31.prev = _context31.next) {
3577
3771
  case 0:
@@ -3590,7 +3784,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3590
3784
  case 5:
3591
3785
  tempOrder = this.store.order.ensureTempOrder();
3592
3786
  orderStore = this.store.order.store || {};
3593
- discountModule = orderStore.discount;
3787
+ _discountModule2 = orderStore.discount;
3594
3788
  if (result.productList) {
3595
3789
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3596
3790
  }
@@ -3600,7 +3794,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3600
3794
  }
3601
3795
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
3602
3796
  _context31.next = 13;
3603
- return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
3797
+ return _discountModule2 === null || _discountModule2 === void 0 ? void 0 : _discountModule2.setDiscountList(result.discountList);
3604
3798
  case 13:
3605
3799
  tempOrder.discount_list = result.discountList.filter(function (discount) {
3606
3800
  return discount.isSelected;
@@ -3998,7 +4192,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3998
4192
  value: function () {
3999
4193
  var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(lookup) {
4000
4194
  var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
4001
- var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order6, _data;
4195
+ var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order11, _data;
4002
4196
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4003
4197
  while (1) switch (_context37.prev = _context37.next) {
4004
4198
  case 0:
@@ -4053,7 +4247,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4053
4247
  break;
4054
4248
  }
4055
4249
  _context37.next = 15;
4056
- 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);
4250
+ return (_this$store$order$app = (_this$store$order11 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order11, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4057
4251
  case 15:
4058
4252
  return _context37.abrupt("return", response);
4059
4253
  case 16:
@@ -4070,13 +4264,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4070
4264
  }, {
4071
4265
  key: "getSubmitPaymentStatus",
4072
4266
  value: function getSubmitPaymentStatus(paymentStatus) {
4073
- var _this$store$order7, _this$store$order7$ge;
4267
+ var _this$store$order12, _this$store$order12$g;
4074
4268
  if (paymentStatus !== undefined) return paymentStatus;
4075
- 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);
4269
+ var 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);
4076
4270
  if (!amountSnapshot) return undefined;
4077
4271
  try {
4078
4272
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
4079
- } catch (_unused4) {
4273
+ } catch (_unused5) {
4080
4274
  return undefined;
4081
4275
  }
4082
4276
  }
@@ -4084,7 +4278,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4084
4278
  key: "syncPaymentsToOrder",
4085
4279
  value: function () {
4086
4280
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4087
- var _ref44, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
4281
+ var _ref48, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
4088
4282
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
4089
4283
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4090
4284
  while (1) switch (_context38.prev = _context38.next) {
@@ -4095,7 +4289,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4095
4289
  }
4096
4290
  throw new Error('order 模块未初始化');
4097
4291
  case 2:
4098
- businessCode = (_ref44 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref44 !== void 0 ? _ref44 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
4292
+ businessCode = (_ref48 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref48 !== void 0 ? _ref48 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
4099
4293
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
4100
4294
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
4101
4295
  syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
@@ -4216,13 +4410,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4216
4410
  }, {
4217
4411
  key: "scheduleQueuedAutoPaymentSyncFlush",
4218
4412
  value: function scheduleQueuedAutoPaymentSyncFlush() {
4219
- var _this16 = this;
4413
+ var _this17 = this;
4220
4414
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
4221
4415
  if (!this.queuedAutoPaymentSync) return;
4222
4416
  if (this.autoPaymentSyncTimer) return;
4223
4417
  this.autoPaymentSyncTimer = setTimeout(function () {
4224
- _this16.autoPaymentSyncTimer = null;
4225
- void _this16.flushQueuedAutoPaymentSync();
4418
+ _this17.autoPaymentSyncTimer = null;
4419
+ void _this17.flushQueuedAutoPaymentSync();
4226
4420
  }, delay);
4227
4421
  }
4228
4422
  }, {
@@ -4360,9 +4554,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4360
4554
  var _this$otherParams33,
4361
4555
  _paymentRecord$paymen,
4362
4556
  _paymentRecord$create,
4363
- _ref45,
4557
+ _ref49,
4364
4558
  _paymentRecord$origin,
4365
- _this17 = this;
4559
+ _this18 = this;
4366
4560
  if (!this.store.order) throw new Error('order 模块未初始化');
4367
4561
  var paymentRecord = payment;
4368
4562
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -4382,7 +4576,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4382
4576
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
4383
4577
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
4384
4578
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
4385
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref45 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref45 !== void 0 ? _ref45 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
4579
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref49 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref49 !== void 0 ? _ref49 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
4386
4580
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
4387
4581
  service_fee: calculatedServiceFee
4388
4582
  } : {}), {}, {
@@ -4406,7 +4600,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4406
4600
  submitWhenPaid: true,
4407
4601
  smallTicketDataFlag: 1
4408
4602
  }).catch(function (error) {
4409
- _this17.logError('auto sync payments failed', {
4603
+ _this18.logError('auto sync payments failed', {
4410
4604
  error: error instanceof Error ? error.message : String(error)
4411
4605
  });
4412
4606
  });
@@ -4424,7 +4618,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4424
4618
  matchMode,
4425
4619
  previousMatch,
4426
4620
  previousPayment,
4427
- _this$store$order$get2,
4621
+ _this$store$order$get5,
4428
4622
  currentPayments,
4429
4623
  _syncResult,
4430
4624
  _options$smallTicketD,
@@ -4472,7 +4666,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4472
4666
  updated: false,
4473
4667
  payment: previousPayment,
4474
4668
  payments: currentPayments,
4475
- summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
4669
+ summary: ((_this$store$order$get5 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.summary) || null
4476
4670
  }, _syncResult !== undefined ? {
4477
4671
  syncResult: _syncResult
4478
4672
  } : {}));
@@ -4602,8 +4796,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4602
4796
  }, {
4603
4797
  key: "getWalletProductList",
4604
4798
  value: function getWalletProductList() {
4605
- var _this$store$order8, _tempOrder$products;
4606
- var tempOrder = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder();
4799
+ var _this$store$order13, _tempOrder$products;
4800
+ var tempOrder = (_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 ? void 0 : _this$store$order13.getTempOrder();
4607
4801
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
4608
4802
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
4609
4803
  // debugger
@@ -4663,8 +4857,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4663
4857
  }, {
4664
4858
  key: "buildWalletInitBusinessData",
4665
4859
  value: function buildWalletInitBusinessData(params) {
4666
- var _this$store$order9, _params$order_wait_pa, _ref46, _tempOrder$is_price_i;
4667
- var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
4860
+ var _this$store$order14, _params$order_wait_pa, _ref50, _tempOrder$is_price_i;
4861
+ var snapshot = (_this$store$order14 = this.store.order) === null || _this$store$order14 === void 0 ? void 0 : _this$store$order14.getOrderSnapshot();
4668
4862
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
4669
4863
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
4670
4864
  if (!tempOrder || !amount) return null;
@@ -4679,7 +4873,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4679
4873
  },
4680
4874
  products: this.getWalletProductList(),
4681
4875
  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),
4682
- is_price_include_tax: (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : 1
4876
+ is_price_include_tax: (_ref50 = (_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 && _ref50 !== void 0 ? _ref50 : 1
4683
4877
  }, snapshot.identity.orderId ? {
4684
4878
  payment_order_id: String(snapshot.identity.orderId)
4685
4879
  } : {});
@@ -4750,8 +4944,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4750
4944
  }, {
4751
4945
  key: "getCommittedWalletAssets",
4752
4946
  value: function getCommittedWalletAssets() {
4753
- var _this$store$order10, _this$store$order10$g;
4754
- 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)) || [];
4947
+ var _this$store$order15, _this$store$order15$g;
4948
+ var payments = ((_this$store$order15 = this.store.order) === null || _this$store$order15 === void 0 || (_this$store$order15$g = _this$store$order15.getOrderPayments) === null || _this$store$order15$g === void 0 ? void 0 : _this$store$order15$g.call(_this$store$order15)) || [];
4755
4949
  var committed = payments.filter(function (payment) {
4756
4950
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
4757
4951
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -4769,9 +4963,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4769
4963
  var walletPassName = fundRecord.wallet_pass_name;
4770
4964
  var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
4771
4965
  var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
4772
- var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref47) {
4773
- var _ref48 = _slicedToArray(_ref47, 2),
4774
- paymentCode = _ref48[1];
4966
+ var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref51) {
4967
+ var _ref52 = _slicedToArray(_ref51, 2),
4968
+ paymentCode = _ref52[1];
4775
4969
  return paymentCode === code;
4776
4970
  })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
4777
4971
  return {
@@ -5191,8 +5385,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5191
5385
  }, {
5192
5386
  key: "updateOrderCustomer",
5193
5387
  value: function updateOrderCustomer(customer) {
5388
+ var _this$store$order$get6, _this$store$order16, _this$store$order$get7, _this$store$order17;
5194
5389
  if (!this.store.order) throw new Error('order 模块未初始化');
5390
+ var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get6 = (_this$store$order16 = this.store.order).getTempOrder) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16));
5195
5391
  var result = this.store.order.updateTempOrderCustomer(customer);
5392
+ var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order17 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order17));
5393
+ if (String(previousCustomerId) !== String(nextCustomerId)) {
5394
+ this.discountConfigCacheKey = null;
5395
+ this.hasManualDiscountSelection = false;
5396
+ }
5196
5397
  this.store.order.recalculateSummary({
5197
5398
  createIfMissing: true
5198
5399
  });
@@ -5257,15 +5458,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5257
5458
  }, {
5258
5459
  key: "getPendingWalletPaymentAmount",
5259
5460
  value: function getPendingWalletPaymentAmount() {
5260
- var _this$store$order11, _this$store$order11$g;
5261
- 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)) || [];
5461
+ var _this$store$order18, _this$store$order18$g;
5462
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 || (_this$store$order18$g = _this$store$order18.getOrderPayments) === null || _this$store$order18$g === void 0 ? void 0 : _this$store$order18$g.call(_this$store$order18)) || [];
5262
5463
  return payments.reduce(function (total, payment) {
5263
5464
  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) {
5264
5465
  return total;
5265
5466
  }
5266
5467
  try {
5267
5468
  return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
5268
- } catch (_unused5) {
5469
+ } catch (_unused6) {
5269
5470
  return total;
5270
5471
  }
5271
5472
  }, new Decimal(0));
@@ -5276,7 +5477,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5276
5477
  key: "getCashPaymentConfig",
5277
5478
  value: (function () {
5278
5479
  var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5279
- var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams34;
5480
+ var _this$store$order19, _this$store$order19$g, _this$store$order20, _this$store$order20$g, _this$otherParams34;
5280
5481
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
5281
5482
  return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5282
5483
  while (1) switch (_context53.prev = _context53.next) {
@@ -5299,10 +5500,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5299
5500
  paymentMethods = _context53.sent;
5300
5501
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
5301
5502
  case 9:
5302
- 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);
5503
+ amountSnapshot = (_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 || (_this$store$order19$g = _this$store$order19.getOrderAmountSnapshot) === null || _this$store$order19$g === void 0 ? void 0 : _this$store$order19$g.call(_this$store$order19);
5303
5504
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5304
5505
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
5305
- currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
5506
+ currency = ((_this$store$order20 = this.store.order) === null || _this$store$order20 === void 0 || (_this$store$order20$g = _this$store$order20.getTempOrder) === null || _this$store$order20$g === void 0 || (_this$store$order20$g = _this$store$order20$g.call(_this$store$order20)) === null || _this$store$order20$g === void 0 ? void 0 : _this$store$order20$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
5306
5507
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
5307
5508
  return _context53.abrupt("return", {
5308
5509
  available: Boolean(paymentMethod && amountDue > 0),
@@ -5332,8 +5533,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5332
5533
  key: "confirmWalletPayment",
5333
5534
  value: (function () {
5334
5535
  var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5335
- var _this$store$order$get3, _this$store$order14, _this$store$order$get5, _this$store$order$get6, _this$store$order16;
5336
- var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get4, _this$store$order15, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5536
+ var _this$store$order$get8, _this$store$order21, _this$store$order$get10, _this$store$order$get11, _this$store$order23;
5537
+ var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get9, _this$store$order22, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5337
5538
  return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5338
5539
  while (1) switch (_context54.prev = _context54.next) {
5339
5540
  case 0:
@@ -5345,7 +5546,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5345
5546
  case 2:
5346
5547
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5347
5548
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5348
- 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);
5549
+ amountSnapshot = (_this$store$order$get8 = (_this$store$order21 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order21);
5349
5550
  if (!pendingWalletAmount.lte(0)) {
5350
5551
  _context54.next = 14;
5351
5552
  break;
@@ -5365,7 +5566,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5365
5566
  }
5366
5567
  throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5367
5568
  case 12:
5368
- _latestAmountSnapshot = (_this$store$order$get4 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order15);
5569
+ _latestAmountSnapshot = (_this$store$order$get9 = (_this$store$order22 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order22);
5369
5570
  return _context54.abrupt("return", {
5370
5571
  submitResult: _submitResult,
5371
5572
  payments: this.store.order.getOrderPayments(),
@@ -5379,7 +5580,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5379
5580
  }
5380
5581
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
5381
5582
  case 17:
5382
- beforePaymentStatus = (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.payment_status;
5583
+ beforePaymentStatus = (_this$store$order$get10 = this.store.order.getTempOrder()) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.payment_status;
5383
5584
  _context54.prev = 18;
5384
5585
  _context54.next = 21;
5385
5586
  return this.submitSalesOrder({
@@ -5431,7 +5632,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5431
5632
  error: _context54.t1 instanceof Error ? _context54.t1.message : String(_context54.t1)
5432
5633
  });
5433
5634
  case 45:
5434
- latestAmountSnapshot = (_this$store$order$get6 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16);
5635
+ latestAmountSnapshot = (_this$store$order$get11 = (_this$store$order23 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.call(_this$store$order23);
5435
5636
  return _context54.abrupt("return", {
5436
5637
  submitResult: submitResult,
5437
5638
  payments: this.store.order.getOrderPayments(),
@@ -5457,7 +5658,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5457
5658
  key: "payCash",
5458
5659
  value: (function () {
5459
5660
  var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5460
- var _this$store$order$get7, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
5661
+ var _this$store$order$get12, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
5461
5662
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5462
5663
  return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5463
5664
  while (1) switch (_context55.prev = _context55.next) {
@@ -5501,7 +5702,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5501
5702
  throw new Error('现金支付金额超过当前待支付金额');
5502
5703
  case 17:
5503
5704
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5504
- beforePaymentStatus = (_this$store$order$get7 = this.store.order.getTempOrder()) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.payment_status;
5705
+ beforePaymentStatus = (_this$store$order$get12 = this.store.order.getTempOrder()) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.payment_status;
5505
5706
  uniquePaymentNumber = createUuidV4();
5506
5707
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5507
5708
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
@@ -5612,7 +5813,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5612
5813
  key: "commitPaymentMethodPayment",
5613
5814
  value: (function () {
5614
5815
  var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5615
- var _this$store$order$get8, _this$store$order17, _this$store$order$get9, _params$metadata, _params$originAmount;
5816
+ var _this$store$order$get13, _this$store$order24, _this$store$order$get14, _params$metadata, _params$originAmount;
5616
5817
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5617
5818
  return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5618
5819
  while (1) switch (_context56.prev = _context56.next) {
@@ -5656,7 +5857,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5656
5857
  }
5657
5858
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
5658
5859
  case 15:
5659
- amountSnapshot = (_this$store$order$get8 = (_this$store$order17 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order17);
5860
+ amountSnapshot = (_this$store$order$get13 = (_this$store$order24 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.call(_this$store$order24);
5660
5861
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5661
5862
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5662
5863
  if (!amountDue.lte(0)) {
@@ -5672,7 +5873,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5672
5873
  throw new Error('支付金额超过当前待支付金额');
5673
5874
  case 22:
5674
5875
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5675
- beforePaymentStatus = (_this$store$order$get9 = this.store.order.getTempOrder()) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.payment_status;
5876
+ beforePaymentStatus = (_this$store$order$get14 = this.store.order.getTempOrder()) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.payment_status;
5676
5877
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5677
5878
  metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
5678
5879
  unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
@@ -5821,7 +6022,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5821
6022
  key: "sendCustomerPayLink",
5822
6023
  value: (function () {
5823
6024
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5824
- var orderIds, _ref49, _ref50, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
6025
+ var orderIds, _ref53, _ref54, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5825
6026
  return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5826
6027
  while (1) switch (_context58.prev = _context58.next) {
5827
6028
  case 0:
@@ -5842,7 +6043,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5842
6043
  });
5843
6044
  case 6:
5844
6045
  submitResult = _context58.sent;
5845
- orderId = (_ref49 = (_ref50 = (_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 && _ref50 !== void 0 ? _ref50 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref49 !== void 0 ? _ref49 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
6046
+ orderId = (_ref53 = (_ref54 = (_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 && _ref54 !== void 0 ? _ref54 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref53 !== void 0 ? _ref53 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
5846
6047
  if (orderId) {
5847
6048
  _context58.next = 10;
5848
6049
  break;
@@ -5932,7 +6133,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5932
6133
  }, {
5933
6134
  key: "getQuotationCustomerScopeInfo",
5934
6135
  value: function getQuotationCustomerScopeInfo() {
5935
- var _this18 = this;
6136
+ var _this19 = this;
5936
6137
  var quotation = this.store.quotation;
5937
6138
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
5938
6139
  return quotation.getQuotationCustomerScopeInfo();
@@ -5944,7 +6145,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5944
6145
  }).map(function (item) {
5945
6146
  var localSeen = new Set();
5946
6147
  var customers = item.customer.filter(function (customer) {
5947
- var customerId = _this18.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
6148
+ var customerId = _this19.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
5948
6149
  if (!customerId || localSeen.has(customerId)) return false;
5949
6150
  localSeen.add(customerId);
5950
6151
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -6009,7 +6210,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6009
6210
  key: "calculateProductBookingPrices",
6010
6211
  value: function () {
6011
6212
  var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(paramsList) {
6012
- var _this19 = this;
6213
+ var _this20 = this;
6013
6214
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
6014
6215
  return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6015
6216
  while (1) switch (_context61.prev = _context61.next) {
@@ -6024,7 +6225,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6024
6225
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6025
6226
  currentOrderCustomerId = this.getCurrentOrderCustomerId();
6026
6227
  resolvedChannels = paramsList.map(function (params) {
6027
- return _this19.getPriceQueryChannel(params.channel);
6228
+ return _this20.getPriceQueryChannel(params.channel);
6028
6229
  });
6029
6230
  authoritativeProducts = paramsList.map(function () {
6030
6231
  return null;
@@ -6032,10 +6233,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6032
6233
  groups = new Map();
6033
6234
  paramsList.forEach(function (params, index) {
6034
6235
  var _params$customer_id2;
6035
- var schedule = _this19.getPriceQuerySchedule(params);
6236
+ var schedule = _this20.getPriceQuerySchedule(params);
6036
6237
  var channel = resolvedChannels[index];
6037
6238
  var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
6038
- var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this19.normalizePriceContextCustomerId(customerId) || ''].join('|');
6239
+ var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this20.normalizePriceContextCustomerId(customerId) || ''].join('|');
6039
6240
  var group = groups.get(groupKey) || {
6040
6241
  indices: [],
6041
6242
  schedule: schedule,
@@ -6047,19 +6248,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6047
6248
  });
6048
6249
  _context61.next = 11;
6049
6250
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
6050
- var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(group) {
6251
+ var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(group) {
6051
6252
  var priceQueries, resolvedProducts;
6052
6253
  return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6053
6254
  while (1) switch (_context60.prev = _context60.next) {
6054
6255
  case 0:
6055
6256
  _context60.next = 2;
6056
- return _this19.prepareProductPriceQueryContext(group.customerId);
6257
+ return _this20.prepareProductPriceQueryContext(group.customerId);
6057
6258
  case 2:
6058
6259
  priceQueries = group.indices.map(function (index) {
6059
6260
  return paramsList[index];
6060
6261
  });
6061
6262
  _context60.next = 5;
6062
- return _this19.resolveProductsForPriceQuery({
6263
+ return _this20.resolveProductsForPriceQuery({
6063
6264
  priceQueries: priceQueries,
6064
6265
  schedule: group.schedule,
6065
6266
  customerId: group.customerId,
@@ -6077,7 +6278,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6077
6278
  }, _callee60);
6078
6279
  }));
6079
6280
  return function (_x50) {
6080
- return _ref51.apply(this, arguments);
6281
+ return _ref55.apply(this, arguments);
6081
6282
  };
6082
6283
  }()));
6083
6284
  case 11:
@@ -6098,7 +6299,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6098
6299
  });
6099
6300
  _context61.next = 16;
6100
6301
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
6101
- return _this19.loadQuotationForPriceQuery(_objectSpread({
6302
+ return _this20.loadQuotationForPriceQuery(_objectSpread({
6102
6303
  quotation: quotation
6103
6304
  }, context));
6104
6305
  }));
@@ -6107,7 +6308,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6107
6308
  var _params$customer_id4;
6108
6309
  var productInput = params.product || {};
6109
6310
  var authoritativeProduct = authoritativeProducts[index];
6110
- var product = _this19.mergeProductForPriceQuery(productInput, authoritativeProduct);
6311
+ var product = _this20.mergeProductForPriceQuery(productInput, authoritativeProduct);
6111
6312
  var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
6112
6313
  var channel = resolvedChannels[index];
6113
6314
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
@@ -6115,7 +6316,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6115
6316
  product: product,
6116
6317
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
6117
6318
  customer_id: customerId,
6118
- quotation: authoritativeProduct && _this19.preferAuthoritativeProductQueryPrice() ? undefined : quotation
6319
+ quotation: authoritativeProduct && _this20.preferAuthoritativeProductQueryPrice() ? undefined : quotation
6119
6320
  }));
6120
6321
  }));
6121
6322
  case 17:
@@ -6457,16 +6658,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6457
6658
  }, {
6458
6659
  key: "getUnfulfilledPromotions",
6459
6660
  value: function getUnfulfilledPromotions() {
6460
- var _this$store$order18;
6461
- return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getUnfulfilledPromotions()) || [];
6661
+ var _this$store$order25;
6662
+ return ((_this$store$order25 = this.store.order) === null || _this$store$order25 === void 0 ? void 0 : _this$store$order25.getUnfulfilledPromotions()) || [];
6462
6663
  }
6463
6664
 
6464
6665
  /** 最近一次促销计算输出的赠品操作 diff。 */
6465
6666
  }, {
6466
6667
  key: "getLastGiftActions",
6467
6668
  value: function getLastGiftActions() {
6468
- var _this$store$order19;
6469
- return ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 ? void 0 : _this$store$order19.getLastGiftActions()) || null;
6669
+ var _this$store$order26;
6670
+ return ((_this$store$order26 = this.store.order) === null || _this$store$order26 === void 0 ? void 0 : _this$store$order26.getLastGiftActions()) || null;
6470
6671
  }
6471
6672
 
6472
6673
  // 获取商品列表
@@ -6520,14 +6721,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6520
6721
  value: function () {
6521
6722
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
6522
6723
  var _this$otherParams37;
6523
- var _ref52,
6524
- _ref52$cover,
6724
+ var _ref56,
6725
+ _ref56$cover,
6525
6726
  cover,
6526
6727
  _args71 = arguments;
6527
6728
  return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6528
6729
  while (1) switch (_context71.prev = _context71.next) {
6529
6730
  case 0:
6530
- _ref52 = _args71.length > 1 && _args71[1] !== undefined ? _args71[1] : {}, _ref52$cover = _ref52.cover, cover = _ref52$cover === void 0 ? false : _ref52$cover;
6731
+ _ref56 = _args71.length > 1 && _args71[1] !== undefined ? _args71[1] : {}, _ref56$cover = _ref56.cover, cover = _ref56$cover === void 0 ? false : _ref56$cover;
6531
6732
  if (cover) {
6532
6733
  this.otherParams = _objectSpread({}, params);
6533
6734
  } else {