@pisell/pisellos 2.3.43 → 2.3.44

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 (33) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/index.d.ts +2 -1
  3. package/dist/modules/Order/index.js +73 -28
  4. package/dist/modules/Order/types.d.ts +2 -0
  5. package/dist/modules/Payment/walletpass.d.ts +10 -3
  6. package/dist/modules/Payment/walletpass.js +425 -282
  7. package/dist/modules/Rules/index.d.ts +2 -0
  8. package/dist/modules/Rules/index.js +61 -57
  9. package/dist/solution/BaseSales/index.js +6 -3
  10. package/dist/solution/BaseSales/types.d.ts +3 -1
  11. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  12. package/dist/solution/BookingTicket/index.d.ts +1 -1
  13. package/dist/solution/BookingTicket/index.js +6 -3
  14. package/dist/solution/BookingTicket/types.d.ts +1 -0
  15. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +3 -3
  16. package/dist/solution/VenueBooking/index.d.ts +1 -0
  17. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  18. package/lib/modules/Order/index.d.ts +2 -1
  19. package/lib/modules/Order/index.js +46 -7
  20. package/lib/modules/Order/types.d.ts +2 -0
  21. package/lib/modules/Payment/walletpass.d.ts +10 -3
  22. package/lib/modules/Payment/walletpass.js +218 -56
  23. package/lib/modules/Rules/index.d.ts +2 -0
  24. package/lib/modules/Rules/index.js +8 -3
  25. package/lib/solution/BaseSales/index.js +1 -0
  26. package/lib/solution/BaseSales/types.d.ts +3 -1
  27. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  28. package/lib/solution/BookingTicket/index.d.ts +1 -1
  29. package/lib/solution/BookingTicket/index.js +1 -0
  30. package/lib/solution/BookingTicket/types.d.ts +1 -0
  31. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -2
  32. package/lib/solution/VenueBooking/index.d.ts +1 -0
  33. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -81,6 +81,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
81
81
  private ensureEditDiscountConfigForProductChange;
82
82
  scanCode(code: string, customerId?: number): Promise<{
83
83
  isAvailable: boolean;
84
+ isAccepted?: boolean;
84
85
  discountList: Discount[];
85
86
  type: 'server' | 'clientCalc';
86
87
  unavailableReason?: UnavailableReason;
@@ -486,7 +487,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
486
487
  generateIdempotencyToken(): string;
487
488
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
488
489
  createOrder(params: CommitOrderParams['query']): {
489
- type: "appointment_booking" | "virtual";
490
+ type: "virtual" | "appointment_booking";
490
491
  platform: string;
491
492
  sales_channel: string;
492
493
  order_sales_channel: string;
@@ -10,8 +10,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
10
10
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
13
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -27,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
27
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
26
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
27
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
30
30
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -70,6 +70,22 @@ function isManualProductDiscountProduct(product) {
70
70
  }
71
71
  var ORDER_PAYMENT_STATUS_PAID = 'paid';
72
72
  var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
73
+ var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
74
+ function isCustomerPromotionDiscount(discount) {
75
+ return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
76
+ }
77
+ function markScannedDiscounts(discountList, scannedDiscountList) {
78
+ var scannedIds = new Set(scannedDiscountList.map(function (discount) {
79
+ return discount === null || discount === void 0 ? void 0 : discount.id;
80
+ }).filter(function (id) {
81
+ return id !== undefined && id !== null;
82
+ }).map(String));
83
+ return discountList.map(function (discount) {
84
+ return scannedIds.has(String(discount === null || discount === void 0 ? void 0 : discount.id)) ? _objectSpread(_objectSpread({}, discount), {}, {
85
+ isScan: true
86
+ }) : discount;
87
+ });
88
+ }
73
89
  function isVoucherPaymentRecord(payment) {
74
90
  return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
75
91
  }
@@ -147,6 +163,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
147
163
  var item = _step2.value;
148
164
  var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
149
165
  if (!type || type === 'product') continue;
166
+ var isDiscountCard = type === 'discount_card' || type === 'product_discount_card';
150
167
  var resourceId = (_ref = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.order_discount_id;
151
168
  if (resourceId === undefined || resourceId === null || resourceId === '') continue;
152
169
  var id = Number(resourceId);
@@ -169,7 +186,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
169
186
  var _existed$limited_rela;
170
187
  existed.amount = Number(existed.amount || 0) + amount;
171
188
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
172
- existed.balance = String(Number(existed.balance || 0) + amount);
189
+ if (!isDiscountCard) {
190
+ existed.balance = String(Number(existed.balance || 0) + amount);
191
+ }
173
192
  var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
174
193
  if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
175
194
  existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
@@ -201,7 +220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
201
220
  filter: 0,
202
221
  exclude_product_ids: []
203
222
  },
204
- balance: String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
223
+ balance: isDiscountCard ? undefined : String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
205
224
  format_title: title,
206
225
  product: {
207
226
  id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
@@ -664,7 +683,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
664
683
  value: function () {
665
684
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
666
685
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
667
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
686
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
668
687
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
669
688
  while (1) switch (_context6.prev = _context6.next) {
670
689
  case 0:
@@ -693,6 +712,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
693
712
  return _context6.abrupt("return", {
694
713
  type: 'clientCalc',
695
714
  isAvailable: false,
715
+ isAccepted: false,
696
716
  discountList: this.getDiscountList(),
697
717
  scannedDiscountList: resultDiscountList,
698
718
  unavailableReason: UnavailableReason.Unknown
@@ -705,6 +725,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
705
725
  return _context6.abrupt("return", {
706
726
  type: 'server',
707
727
  isAvailable: false,
728
+ isAccepted: false,
708
729
  discountList: this.getDiscountList(),
709
730
  scannedDiscountList: resultDiscountList,
710
731
  unavailableReasonKey: unavailableReasonKey
@@ -732,6 +753,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
732
753
  return _context6.abrupt("return", {
733
754
  type: 'clientCalc',
734
755
  isAvailable: true,
756
+ isAccepted: true,
735
757
  discountList: this.getDiscountList(),
736
758
  scannedDiscountList: resultDiscountList
737
759
  });
@@ -750,24 +772,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
750
772
  }) || {
751
773
  isAvailable: false,
752
774
  discountList: this.getDiscountList()
753
- }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
754
- if (!(isAvailable && newDiscountList)) {
755
- _context6.next = 26;
775
+ }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, evaluatedDiscountList = _ref13.evaluatedDiscountList, unavailableReason = _ref13.unavailableReason;
776
+ shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
777
+ normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
778
+ retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
779
+ resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
780
+ if (!(isAvailable && normalizedNewDiscountList)) {
781
+ _context6.next = 34;
756
782
  break;
757
783
  }
758
- (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
784
+ _context6.next = 28;
785
+ return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
786
+ case 28:
759
787
  this.applyDiscount();
760
- _context6.next = 26;
788
+ _context6.next = 31;
761
789
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
762
- case 26:
790
+ case 31:
791
+ resolvedDiscountList = this.getDiscountList();
792
+ _context6.next = 40;
793
+ break;
794
+ case 34:
795
+ if (!(shouldRetainForLater && retainedDiscountList)) {
796
+ _context6.next = 40;
797
+ break;
798
+ }
799
+ _context6.next = 37;
800
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
801
+ case 37:
802
+ _context6.next = 39;
803
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
804
+ case 39:
805
+ resolvedDiscountList = this.getDiscountList();
806
+ case 40:
763
807
  return _context6.abrupt("return", {
764
808
  type: 'clientCalc',
765
809
  isAvailable: isAvailable || false,
766
- discountList: newDiscountList || this.getDiscountList(),
810
+ isAccepted: Boolean(isAvailable || shouldRetainForLater),
811
+ discountList: resolvedDiscountList,
767
812
  scannedDiscountList: resultDiscountList,
768
813
  unavailableReason: unavailableReason
769
814
  });
770
- case 27:
815
+ case 41:
771
816
  case "end":
772
817
  return _context6.stop();
773
818
  }
@@ -781,7 +826,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
781
826
  }, {
782
827
  key: "applyDiscount",
783
828
  value: function applyDiscount(options) {
784
- var _this$store$discount13,
829
+ var _this$store$discount14,
785
830
  _this$store$summary2,
786
831
  _this2 = this;
787
832
  var tempOrder = this.store.tempOrder;
@@ -791,7 +836,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
791
836
  if (!tempOrder) return;
792
837
  this.syncLinkedBookingHoldersToProducts(tempOrder);
793
838
  delete tempOrder.discount_list;
794
- var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
839
+ var discountList = ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.getDiscountList()) || [];
795
840
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
796
841
  if (shouldSkipDiscountCalculation) return;
797
842
  var rulesModule = this.store.rules;
@@ -823,9 +868,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
823
868
  }));
824
869
  }
825
870
  if (result !== null && result !== void 0 && result.discountList) {
826
- var _this$store$discount14;
871
+ var _this$store$discount15;
827
872
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
828
- (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
873
+ (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 || _this$store$discount15.setDiscountList(result.discountList);
829
874
  }
830
875
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
831
876
  return _this2.productHasCustomerBoundDiscount(product);
@@ -2289,7 +2334,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2289
2334
  }, {
2290
2335
  key: "restoreOrder",
2291
2336
  value: function restoreOrder() {
2292
- var _this$store$discount15, _this$store$discount16;
2337
+ var _this$store$discount16, _this$store$discount17;
2293
2338
  this.logInfo('restoreOrder start', {});
2294
2339
  var freshTempOrder = this.createDefaultTempOrderInstance();
2295
2340
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2297,8 +2342,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2297
2342
  this.store.summary = createEmptySummary();
2298
2343
  this.store.lastOrderInfo = undefined;
2299
2344
  this.store.syncState = undefined;
2300
- void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2301
- void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2345
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList([]));
2346
+ void ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList([]));
2302
2347
  this.persistTempOrder();
2303
2348
  return freshTempOrder;
2304
2349
  }
@@ -3121,11 +3166,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3121
3166
  }, {
3122
3167
  key: "shouldSkipDiscountCalculation",
3123
3168
  value: function shouldSkipDiscountCalculation(tempOrder) {
3124
- var _this$store$discount17,
3125
- _this$store$discount18,
3169
+ var _this$store$discount18,
3170
+ _this$store$discount19,
3126
3171
  _this20 = this;
3127
3172
  if (this.hasActiveCustomerBoundDiscount) return false;
3128
- var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3173
+ var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
3129
3174
  if (discountList.length > 0) return false;
3130
3175
  return !(tempOrder.products || []).some(function (product) {
3131
3176
  return _this20.productHasCustomerBoundDiscount(product);
@@ -5821,8 +5866,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5821
5866
  key: "hydrateTempOrderFromRecord",
5822
5867
  value: (function () {
5823
5868
  var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
5824
- var _this$store$discount19;
5825
- var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5869
+ var _this$store$discount20;
5870
+ var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
5826
5871
  return _regeneratorRuntime().wrap(function _callee44$(_context47) {
5827
5872
  while (1) switch (_context47.prev = _context47.next) {
5828
5873
  case 0:
@@ -5881,7 +5926,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5881
5926
  this.store.syncState = 'local';
5882
5927
  }
5883
5928
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5884
- currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5929
+ currentDiscounts = typeof ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5885
5930
  currentScanDiscounts = currentDiscounts.filter(function (discount) {
5886
5931
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
5887
5932
  });
@@ -5899,10 +5944,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5899
5944
  }
5900
5945
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5901
5946
  _context47.next = 29;
5902
- return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5947
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
5903
5948
  case 29:
5904
5949
  _context47.next = 31;
5905
- return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5950
+ return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
5906
5951
  case 31:
5907
5952
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5908
5953
  _context47.next = 34;
@@ -165,6 +165,8 @@ export interface OrderCustomerChangePayload {
165
165
  }
166
166
  export interface OrderScanCodeResult {
167
167
  isAvailable: boolean;
168
+ /** 卡券已加入当前订单折扣列表,但不一定能立即应用。 */
169
+ isAccepted?: boolean;
168
170
  discountList: Discount[];
169
171
  scannedDiscountList: Discount[];
170
172
  type: 'server' | 'clientCalc';
@@ -21,11 +21,13 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
21
21
  private emitEvent;
22
22
  private publishWalletAssetsState;
23
23
  private recalculateWalletAssets;
24
+ /** 获取当前缓存中所有支付类 Wallet 资产的扫码 code。 */
25
+ private getSearchedWalletAssetCodes;
24
26
  /**
25
- * 使用最新订单参数重验扫码搜索过的支付类 Wallet 资产。
26
- * 请求失败或暂时无匹配结果时保留旧资产,避免商品变化造成列表闪空。
27
+ * 用订单重算接口返回的数据更新扫码 Wallet 缓存。
28
+ * 接口暂时缺失某个扫码 code 时继续保留旧值,避免列表闪空。
27
29
  */
28
- private revalidateSearchedWalletAssets;
30
+ private syncSearchedWalletAssets;
29
31
  /**
30
32
  * 生成钱包API默认参数
31
33
  * 根据业务数据生成标准的钱包API参数,并存储在模块中
@@ -67,6 +69,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
67
69
  noApplicableVoucher: any[];
68
70
  products: any[];
69
71
  }>;
72
+ /**
73
+ * 商品或订单金额变化后,使用聚合接口一次重算已选与剩余 WalletPass。
74
+ * Walk-In 不发送 customer_id;会员才携带真实 customer_id。
75
+ */
76
+ private aggregateRecalculateWalletAssetsAsync;
70
77
  getWalletPassRecommendListAsync(params: WalletDeductionRecommendParams): Promise<WalletRecommendItem[]>;
71
78
  formatWalletPassList2PreparePayments(list: WalletRecommendItem[]): {
72
79
  voucher_id: number;