@pisell/pisellos 2.3.66 → 2.3.68

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 (47) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BaseModule.d.ts +1 -0
  3. package/dist/modules/BaseModule.js +24 -28
  4. package/dist/modules/Order/index.d.ts +22 -2
  5. package/dist/modules/Order/index.js +313 -142
  6. package/dist/modules/Order/types.d.ts +13 -1
  7. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  8. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  9. package/dist/modules/Order/utils.js +0 -1
  10. package/dist/modules/Payment/index.d.ts +4 -0
  11. package/dist/modules/Payment/index.js +14 -4
  12. package/dist/modules/Payment/walletpass.js +21 -7
  13. package/dist/modules/Rules/index.js +46 -31
  14. package/dist/solution/BaseSales/index.d.ts +3 -1
  15. package/dist/solution/BaseSales/index.js +99 -82
  16. package/dist/solution/BaseSales/utils.js +31 -20
  17. package/dist/solution/BookingByStep/index.d.ts +1 -1
  18. package/dist/solution/BookingTicket/index.d.ts +4 -2
  19. package/dist/solution/BookingTicket/index.js +89 -65
  20. package/dist/solution/ScanOrder/utils.js +31 -20
  21. package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
  22. package/dist/solution/UnifiedBookingSales/index.js +640 -321
  23. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
  24. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  25. package/lib/modules/BaseModule.d.ts +1 -0
  26. package/lib/modules/BaseModule.js +24 -37
  27. package/lib/modules/Order/index.d.ts +22 -2
  28. package/lib/modules/Order/index.js +212 -54
  29. package/lib/modules/Order/types.d.ts +13 -1
  30. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  31. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  32. package/lib/modules/Order/utils.js +0 -1
  33. package/lib/modules/Payment/index.d.ts +4 -0
  34. package/lib/modules/Payment/index.js +7 -0
  35. package/lib/modules/Payment/walletpass.js +12 -0
  36. package/lib/modules/Rules/index.js +17 -1
  37. package/lib/solution/BaseSales/index.d.ts +3 -1
  38. package/lib/solution/BaseSales/index.js +29 -16
  39. package/lib/solution/BaseSales/utils.js +29 -18
  40. package/lib/solution/BookingByStep/index.d.ts +1 -1
  41. package/lib/solution/BookingTicket/index.d.ts +4 -2
  42. package/lib/solution/BookingTicket/index.js +35 -12
  43. package/lib/solution/ScanOrder/utils.js +29 -18
  44. package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
  45. package/lib/solution/UnifiedBookingSales/index.js +188 -0
  46. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
  47. package/package.json +1 -1
@@ -579,6 +579,10 @@ export interface LoadSalesDetailParams {
579
579
  * 存在时 loadSalesDetail 会跳过远端 lookup,直接复用 hydrate 后半段逻辑。
580
580
  */
581
581
  preloadedSalesDetail?: Record<string, any>;
582
+ /**
583
+ * sessionStorage 快照复用详情 hydrate 时使用;不带该值时保持既有编辑订单语义。
584
+ */
585
+ hydrateSource?: 'sessionStorage';
582
586
  forceRemote?: boolean;
583
587
  merge?: boolean;
584
588
  }
@@ -749,8 +753,15 @@ export interface OrderModuleAPI {
749
753
  removeProductFromOrder: (identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
750
754
  /** 批量删除购物车行,末尾仅触发一次促销重算与 summary 刷新 */
751
755
  removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
752
- /** @deprecated no-op;OrderModule 不再负责 tempOrder localStorage 持久化。 */
756
+ /** 在显式开启时保存当前 tempOrder sessionStorage 会话快照。 */
753
757
  persistTempOrder: () => void;
758
+ /**
759
+ * 删除当前 cacheId 的 tempOrder 会话快照,并阻止当前模块实例再次写入。
760
+ * 新模块实例初始化时会按 otherParams 重新启用持久化。
761
+ */
762
+ clearSessionStoragePersistedTempOrder: () => void;
763
+ /** 取出一次待恢复的 sessionStorage tempOrder 快照。 */
764
+ consumeSessionStorageRestore: () => Record<string, any> | null;
754
765
  /**
755
766
  * 控制 IndexedDB 草稿(saveDraft)开关;localStorage tempOrder 持久化已废弃。
756
767
  * BigSale 弹窗等场景传 false 可跳过 saveDraft。
@@ -808,6 +819,7 @@ export interface OrderModuleAPI {
808
819
  saveDraft: () => Promise<void>;
809
820
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
810
821
  recalcOnHydrate?: boolean;
822
+ source?: 'salesDetail' | 'sessionStorage';
811
823
  }) => Promise<OrderTempOrder>;
812
824
  syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
813
825
  getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
@@ -24,6 +24,16 @@ export interface NormalizeOrderCollectionsResult<T> {
24
24
  stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
25
25
  uidRemaps: OrderCollectionUidRemap[];
26
26
  }
27
+ export interface ProductLineIdentityRepair {
28
+ index: number;
29
+ from: string;
30
+ to: string;
31
+ }
32
+ export interface RepairDuplicateProductLineIdentitiesResult<T> {
33
+ products: T[];
34
+ productsByUid?: Record<string, Record<string, any>>;
35
+ repairs: ProductLineIdentityRepair[];
36
+ }
27
37
  export declare function createUuidV4(): string;
28
38
  export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
29
39
  export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
@@ -31,6 +41,11 @@ export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: u
31
41
  export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
32
42
  export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
33
43
  export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
44
+ /**
45
+ * Rules 会把同一商品按商品券拆成多条真实订单行。拆行结果会继承原商品 UID,
46
+ * 因此必须在通用 collection normalization 之前为后续行派生稳定身份,避免被折叠。
47
+ */
48
+ export declare function repairDuplicateProductLineIdentities<T extends Record<string, any>>(products: T[] | null | undefined, productsByUid?: Record<string, Record<string, any>> | null): RepairDuplicateProductLineIdentitiesResult<T>;
34
49
  /**
35
50
  * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
36
51
  */
@@ -74,6 +74,81 @@ export function setOrderCollectionUid(kind, item, uid) {
74
74
  delete record[uidField];
75
75
  return record;
76
76
  }
77
+ function getGoodPassResourceId(product) {
78
+ var _ref, _ref2, _goodPass$discount$re, _goodPass$discount;
79
+ var goodPass = (product.discount_list || []).find(function (item) {
80
+ var _item$discount, _item$discount2;
81
+ var type = (item === null || item === void 0 ? void 0 : item.type) || (item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.type) || (item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.tag);
82
+ return type === 'good_pass';
83
+ });
84
+ if (!goodPass) return null;
85
+ var resourceId = (_ref = (_ref2 = (_goodPass$discount$re = (_goodPass$discount = goodPass.discount) === null || _goodPass$discount === void 0 ? void 0 : _goodPass$discount.resource_id) !== null && _goodPass$discount$re !== void 0 ? _goodPass$discount$re : goodPass.resource_id) !== null && _ref2 !== void 0 ? _ref2 : goodPass.discount_id) !== null && _ref !== void 0 ? _ref : goodPass.id;
86
+ return isBlankOrderCollectionIdentity(resourceId) ? null : String(resourceId);
87
+ }
88
+ function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
89
+ var encodedOriginalUid = encodeURIComponent(originalUid);
90
+ var resourceId = getGoodPassResourceId(product);
91
+ if (resourceId) {
92
+ return "os-split:product:".concat(encodedOriginalUid, ":good-pass:").concat(encodeURIComponent(resourceId), ":").concat(duplicateOrdinal);
93
+ }
94
+ return "os-split:product:".concat(encodedOriginalUid, ":duplicate:").concat(duplicateOrdinal);
95
+ }
96
+
97
+ /**
98
+ * Rules 会把同一商品按商品券拆成多条真实订单行。拆行结果会继承原商品 UID,
99
+ * 因此必须在通用 collection normalization 之前为后续行派生稳定身份,避免被折叠。
100
+ */
101
+ export function repairDuplicateProductLineIdentities(products, productsByUid) {
102
+ var repairedProducts = cloneDeep(products || []);
103
+ var repairedProductsByUid = productsByUid ? cloneDeep(productsByUid) : undefined;
104
+ var occupiedUids = new Set(repairedProducts.map(function (product) {
105
+ return getOrderCollectionUid('product', product);
106
+ }).filter(function (uid) {
107
+ return Boolean(uid);
108
+ }));
109
+ Object.keys(repairedProductsByUid || {}).forEach(function (uid) {
110
+ return occupiedUids.add(uid);
111
+ });
112
+ var occurrences = new Map();
113
+ var repairs = [];
114
+ repairedProducts.forEach(function (product, index) {
115
+ var originalUid = getOrderCollectionUid('product', product);
116
+ if (!originalUid) return;
117
+ var occurrence = (occurrences.get(originalUid) || 0) + 1;
118
+ occurrences.set(originalUid, occurrence);
119
+ if (occurrence === 1) return;
120
+ var duplicateOrdinal = occurrence - 1;
121
+ var baseCandidate = buildSplitProductUid(originalUid, product, duplicateOrdinal);
122
+ var nextUid = baseCandidate;
123
+ var conflictOrdinal = 1;
124
+ while (occupiedUids.has(nextUid)) {
125
+ nextUid = "".concat(baseCandidate, ":conflict:").concat(conflictOrdinal);
126
+ conflictOrdinal += 1;
127
+ }
128
+ var repairedProduct = setOrderCollectionUid('product', product, nextUid);
129
+ repairedProduct.identity_key = nextUid;
130
+ repairedProducts[index] = repairedProduct;
131
+ occupiedUids.add(nextUid);
132
+ repairs.push({
133
+ index: index,
134
+ from: originalUid,
135
+ to: nextUid
136
+ });
137
+ var runtimeSource = repairedProductsByUid === null || repairedProductsByUid === void 0 ? void 0 : repairedProductsByUid[originalUid];
138
+ if (runtimeSource && repairedProductsByUid) {
139
+ repairedProductsByUid[nextUid] = _objectSpread(_objectSpread({}, cloneDeep(runtimeSource)), runtimeSource.rowKey !== undefined ? {
140
+ rowKey: nextUid
141
+ } : {});
142
+ }
143
+ });
144
+ return _objectSpread(_objectSpread({
145
+ products: repairedProducts
146
+ }, repairedProductsByUid ? {
147
+ productsByUid: repairedProductsByUid
148
+ } : {}), {}, {
149
+ repairs: repairs
150
+ });
151
+ }
77
152
 
78
153
  /**
79
154
  * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
@@ -1401,7 +1401,6 @@ export function productRequiresFormSubject(tempOrder, product) {
1401
1401
  }
1402
1402
  export function resolveIsFormSubject(tempOrder, product) {
1403
1403
  var _tempOrder$holder;
1404
- debugger;
1405
1404
  // 旧版预约维度的 holder 类型仍然生效;新版则从当前商品 holder_config 判断。
1406
1405
  if ((tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.type) === 'form') return true;
1407
1406
  if (product) return productRequiresFormSubject(tempOrder, product);
@@ -41,6 +41,10 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
41
41
  * paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
42
42
  */
43
43
  updateOtherParams(params: Record<string, any>): void;
44
+ /**
45
+ * 获取标准化后的宿主平台标识,供支付子能力做平台边界判断。
46
+ */
47
+ getPlatform(): string;
44
48
  private getPaymentNumberAppData;
45
49
  /**
46
50
  * 记录信息日志
@@ -231,6 +231,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
231
231
  value: function updateOtherParams(params) {
232
232
  this.otherParams = params || {};
233
233
  }
234
+
235
+ /**
236
+ * 获取标准化后的宿主平台标识,供支付子能力做平台边界判断。
237
+ */
238
+ }, {
239
+ key: "getPlatform",
240
+ value: function getPlatform() {
241
+ var _this$otherParams;
242
+ return String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
243
+ }
234
244
  }, {
235
245
  key: "getPaymentNumberAppData",
236
246
  value: function getPaymentNumberAppData(key) {
@@ -247,10 +257,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
247
257
  }, {
248
258
  key: "logInfo",
249
259
  value: function logInfo(title, metadata) {
250
- var _this$otherParams;
251
- if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.fatherModule) {
252
- var _this$otherParams2;
253
- var fatherModule = this.core.getModule((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule);
260
+ var _this$otherParams2;
261
+ if ((_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.fatherModule) {
262
+ var _this$otherParams3;
263
+ var fatherModule = this.core.getModule((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.fatherModule);
254
264
  if (fatherModule) {
255
265
  fatherModule.logInfo("".concat(title), metadata);
256
266
  return;
@@ -851,7 +851,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
851
851
  key: "getUserIdentificationCodeListAsync",
852
852
  value: function () {
853
853
  var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
854
- var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams, response, sortedData;
854
+ var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams, platform, response, sortedData;
855
855
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
856
856
  while (1) switch (_context6.prev = _context6.next) {
857
857
  case 0:
@@ -864,6 +864,20 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
864
864
  this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
865
865
  return _context6.abrupt("return", []);
866
866
  case 5:
867
+ platform = this.paymentModule.getPlatform();
868
+ if (!(platform === 'pc' || platform === 'h5')) {
869
+ _context6.next = 11;
870
+ break;
871
+ }
872
+ this.userIdentificationCodes = [];
873
+ this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
874
+ userIdentificationCodes: []
875
+ });
876
+ this.paymentModule.logInfo('[WalletPass] 用户端平台跳过获取用户识别码列表', {
877
+ platform: platform
878
+ });
879
+ return _context6.abrupt("return", []);
880
+ case 11:
867
881
  if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
868
882
  newParams.payment_order_id = undefined;
869
883
  }
@@ -874,9 +888,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
874
888
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
875
889
  payment_order_id: (_this$walletParams4 = this.walletParams) === null || _this$walletParams4 === void 0 ? void 0 : _this$walletParams4.payment_order_id
876
890
  });
877
- _context6.next = 9;
891
+ _context6.next = 15;
878
892
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
879
- case 9:
893
+ case 15:
880
894
  response = _context6.sent;
881
895
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
882
896
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
@@ -897,19 +911,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
897
911
  })
898
912
  });
899
913
  return _context6.abrupt("return", this.userIdentificationCodes);
900
- case 17:
901
- _context6.prev = 17;
914
+ case 23:
915
+ _context6.prev = 23;
902
916
  _context6.t0 = _context6["catch"](0);
903
917
  this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context6.t0, {
904
918
  customer_id: params.customer_id,
905
919
  available: params.available
906
920
  });
907
921
  return _context6.abrupt("return", []);
908
- case 21:
922
+ case 27:
909
923
  case "end":
910
924
  return _context6.stop();
911
925
  }
912
- }, _callee6, this, [[0, 17]]);
926
+ }, _callee6, this, [[0, 23]]);
913
927
  }));
914
928
  function getUserIdentificationCodeListAsync(_x7) {
915
929
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
@@ -1195,11 +1195,26 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1195
1195
  // 折扣卡会复用于整条商品行;商品券必须继续按单张拆分,不能复用该分支。
1196
1196
  var explicitlySelectedDiscountCard = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) !== 'good_pass' ? explicitlySelectedDiscount : undefined;
1197
1197
 
1198
- // 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
1198
+ // 商品数量等变化会触发无 discountId 的重算。只要当前行已应用的折扣卡仍在
1199
+ // applicableDiscounts 中,就应保留该行选择,避免被自动排序中力度更大的卡替换。
1200
+ var appliedDiscountCardIds = new Set((product.discount_list || []).filter(function (item) {
1201
+ return ['discount_card', 'product_discount_card'].includes((item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 ? void 0 : item.type));
1202
+ }).map(function (item) {
1203
+ var _ref12, _item$discount$resour, _item$discount;
1204
+ return (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : item === null || item === void 0 ? void 0 : item.id;
1205
+ }).filter(function (id) {
1206
+ return id !== undefined && id !== null;
1207
+ }).map(String));
1208
+ var appliedDiscountCard = options !== null && options !== void 0 && options.scan ? undefined : applicableDiscounts.find(function (discount) {
1209
+ var discountType = discount.tag || discount.type;
1210
+ return discount.isSelected === true && ['discount_card', 'product_discount_card'].includes(discountType) && appliedDiscountCardIds.has(String(discount.id));
1211
+ });
1212
+
1213
+ // 优先级:本次显式选择 > 当前行既有选择 > 扫码选择 > 自动排序第一项。
1199
1214
  var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
1200
1215
  return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
1201
1216
  });
1202
- var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
1217
+ var selectedDiscountCard = explicitlySelectedDiscountCard || appliedDiscountCard || scannedSelectedDiscountCard;
1203
1218
  var selectedDiscount = explicitlySelectedDiscount || selectedDiscountCard || applicableDiscounts[0];
1204
1219
  var prioritizedApplicableDiscounts = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) === 'good_pass' ? [explicitlySelectedDiscount].concat(_toConsumableArray(applicableDiscounts.filter(function (discount) {
1205
1220
  var discountType = discount.tag || discount.type;
@@ -1217,8 +1232,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1217
1232
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
1218
1233
  return item.type === 'product';
1219
1234
  })) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
1220
- var _ref12;
1221
- return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1235
+ var _ref13;
1236
+ return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
1222
1237
  }) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
1223
1238
  return item.type === 'product';
1224
1239
  })));
@@ -1234,8 +1249,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1234
1249
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
1235
1250
  return item.type === 'product';
1236
1251
  })) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
1237
- var _ref13;
1238
- return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
1252
+ var _ref14;
1253
+ return !((_ref14 = item.discount_list || []) !== null && _ref14 !== void 0 && _ref14.length);
1239
1254
  }) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
1240
1255
  return item.type === 'product';
1241
1256
  })));
@@ -1247,8 +1262,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1247
1262
  var _product$discount_lis7;
1248
1263
  // 主商品:检查自己的 discount_list
1249
1264
  if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
1250
- var _item$discount;
1251
- return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
1265
+ var _item$discount2;
1266
+ return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
1252
1267
  })) {
1253
1268
  isManualDiscount = false;
1254
1269
  }
@@ -1256,11 +1271,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1256
1271
  if (flatItem.type === 'bundle') {
1257
1272
  var _product$discount_lis8, _flatItem$parentProdu7;
1258
1273
  if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
1259
- var _item$discount2;
1260
- return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
1261
- }) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
1262
1274
  var _item$discount3;
1263
1275
  return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
1276
+ }) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
1277
+ var _item$discount4;
1278
+ return ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id) === options.discountId;
1264
1279
  })) {
1265
1280
  isManualDiscount = false;
1266
1281
  }
@@ -1272,8 +1287,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1272
1287
  if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
1273
1288
  var _options$selectedList2;
1274
1289
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
1275
- var _item$discount4;
1276
- return n.discountId === ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id);
1290
+ var _item$discount5;
1291
+ return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
1277
1292
  });
1278
1293
  })) {
1279
1294
  isManualDiscount = false;
@@ -1284,14 +1299,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1284
1299
  if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
1285
1300
  var _options$selectedList3;
1286
1301
  return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
1287
- var _item$discount5;
1288
- return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
1302
+ var _item$discount6;
1303
+ return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
1289
1304
  });
1290
1305
  }) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
1291
1306
  var _options$selectedList4;
1292
1307
  return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
1293
- var _item$discount6;
1294
- return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
1308
+ var _item$discount7;
1309
+ return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
1295
1310
  });
1296
1311
  })) {
1297
1312
  isManualDiscount = false;
@@ -1328,8 +1343,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1328
1343
  discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
1329
1344
  }))]);
1330
1345
  } else {
1331
- var _ref14, _product$_promotion$f, _product12, _product$origin_total;
1332
- var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1346
+ var _ref15, _product$_promotion$f, _product12, _product$origin_total;
1347
+ var total = product.inPromotion ? (_ref15 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref15 !== void 0 ? _ref15 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1333
1348
  var main_product_selling_price = product.price;
1334
1349
  if ((product.discount_list || []).some(function (item) {
1335
1350
  return item.type === 'promotion';
@@ -2027,7 +2042,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2027
2042
  } else {
2028
2043
  // 🔥 没有子商品被拆分,使用原有逻辑
2029
2044
  mainProductArr.forEach(function (mainProduct) {
2030
- var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
2045
+ var _ref17, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
2031
2046
  var mainProductData = _this4.hooks.getProduct(mainProduct);
2032
2047
 
2033
2048
  // 重组bundle
@@ -2042,9 +2057,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2042
2057
  } else {
2043
2058
  // 🔥 关键:拆分后的bundle item
2044
2059
  processedBundleItems.forEach(function (item) {
2045
- var _item$price, _ref15, _item$bundle_selling_;
2060
+ var _item$price, _ref16, _item$bundle_selling_;
2046
2061
  var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
2047
- var nextBundleSellingPrice = (_ref15 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref15 !== void 0 ? _ref15 : bundleItem.bundle_selling_price;
2062
+ var nextBundleSellingPrice = (_ref16 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref16 !== void 0 ? _ref16 : bundleItem.bundle_selling_price;
2048
2063
  // 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
2049
2064
  var updatedDiscountList = (item.discount_list || []).map(function (discount) {
2050
2065
  var _discount$metadata10;
@@ -2071,7 +2086,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2071
2086
 
2072
2087
  // 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
2073
2088
  // 避免把主商品 discount_list 再扣一次。
2074
- var mainSellingPrice = (_ref16 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref16 !== void 0 ? _ref16 : 0;
2089
+ var mainSellingPrice = (_ref17 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref17 !== void 0 ? _ref17 : 0;
2075
2090
  var newTotal = Number(mainSellingPrice || 0);
2076
2091
  var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
2077
2092
 
@@ -2220,14 +2235,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2220
2235
  var ruleType = usageRules.type;
2221
2236
  // 套餐适用范围配置
2222
2237
  var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
2223
- var _ref17 = packageScope || {},
2224
- scopeType = _ref17.type,
2225
- _ref17$exclude_bundle = _ref17.exclude_bundle_product_ids,
2226
- exclude_bundle_product_ids = _ref17$exclude_bundle === void 0 ? [] : _ref17$exclude_bundle,
2227
- _ref17$include_bundle = _ref17.include_bundle_product_ids,
2228
- include_bundle_product_ids = _ref17$include_bundle === void 0 ? [] : _ref17$include_bundle,
2229
- _ref17$filter = _ref17.filter,
2230
- filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
2238
+ var _ref18 = packageScope || {},
2239
+ scopeType = _ref18.type,
2240
+ _ref18$exclude_bundle = _ref18.exclude_bundle_product_ids,
2241
+ exclude_bundle_product_ids = _ref18$exclude_bundle === void 0 ? [] : _ref18$exclude_bundle,
2242
+ _ref18$include_bundle = _ref18.include_bundle_product_ids,
2243
+ include_bundle_product_ids = _ref18$include_bundle === void 0 ? [] : _ref18$include_bundle,
2244
+ _ref18$filter = _ref18.filter,
2245
+ filter = _ref18$filter === void 0 ? 0 : _ref18$filter;
2231
2246
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2232
2247
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2233
2248
  var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
@@ -141,7 +141,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
141
141
  * const params = this.buildSubModuleOtherParams();
142
142
  * this.core.registerModule(orderModule, { otherParams: params });
143
143
  */
144
- protected buildSubModuleOtherParams(): Record<string, any>;
144
+ protected isSessionStoragePersistEnabled(): boolean;
145
+ protected shouldUseSessionStorageForSubModule(_moduleName?: string): boolean;
146
+ protected buildSubModuleOtherParams(moduleName?: string): Record<string, any>;
145
147
  /**
146
148
  * 将父级 otherParams 的变更显式同步给已注册的子模块。
147
149
  *