@pisell/pisellos 2.1.94 → 2.1.96

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.
@@ -27,6 +27,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
27
27
  productList: any[];
28
28
  unavailableReason?: UnavailableReason;
29
29
  };
30
+ filterDiscountListByType(discountList: Discount[], type: string): Discount[];
30
31
  private getUnavailableReason;
31
32
  calcDiscount({ discountList, productList, holders, isFormSubject, }: {
32
33
  discountList: Discount[];
@@ -201,6 +201,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
201
201
  unavailableReason: unavailableReason
202
202
  };
203
203
  }
204
+ }, {
205
+ key: "filterDiscountListByType",
206
+ value: function filterDiscountListByType(discountList, type) {
207
+ return (discountList || []).filter(function (item) {
208
+ return item.type === type || item.tag === type;
209
+ });
210
+ }
204
211
 
205
212
  // 获取券不可用的原因
206
213
  }, {
@@ -1048,25 +1055,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1048
1055
  }),
1049
1056
  price: product.price
1050
1057
  }), {}, {
1051
- discount_list: []
1058
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1052
1059
  }))]);
1053
1060
  } else {
1061
+ var _ref8, _product$_promotion$f, _product13, _product$origin_total, _product$main_product, _product$main_product2;
1062
+ var total = product.inPromotion ? (_ref8 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref8 !== void 0 ? _ref8 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1063
+ if ((product.discount_list || []).some(function (item) {
1064
+ return item.type === 'promotion';
1065
+ })) {
1066
+ var _product$total;
1067
+ total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
1068
+ }
1054
1069
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1055
1070
  price: product.price,
1056
- main_product_selling_price: product.price
1071
+ main_product_selling_price: (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : product.price
1057
1072
  } : {
1058
1073
  _id: product._id.split('___')[0] + '___' + index,
1059
- total: product.origin_total || product.total,
1074
+ total: total,
1060
1075
  price: product.price,
1061
- main_product_selling_price: product.price
1076
+ main_product_selling_price: (_product$main_product2 = product.main_product_selling_price) !== null && _product$main_product2 !== void 0 ? _product$main_product2 : product.price
1062
1077
  }), {}, {
1063
- discount_list: []
1078
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1064
1079
  }))]);
1065
1080
  }
1066
1081
  } else {
1082
+ var _flatItem$bundleItem8;
1067
1083
  // bundle子商品:保存到扁平化Map
1068
1084
  processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
1069
- discount_list: [],
1085
+ discount_list: _this3.filterDiscountListByType(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || [], 'promotion'),
1070
1086
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1071
1087
  processed: true
1072
1088
  })]);
@@ -1093,13 +1109,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1093
1109
  // 主商品:保持原有逻辑
1094
1110
  if (splitCount < totalQuantity && isNeedSplit) {
1095
1111
  arr.push(_this3.hooks.setProduct(originProduct, {
1096
- discount_list: [],
1112
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1097
1113
  quantity: totalQuantity - splitCount,
1098
1114
  _id: product._id.split('___')[0]
1099
1115
  }));
1100
1116
  }
1101
1117
  for (var i = 0; i < splitCount; i++) {
1102
- var _product$discount_lis10, _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1118
+ var _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1103
1119
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1104
1120
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1105
1121
  // 标记优惠券为已使用
@@ -1111,7 +1127,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1111
1127
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
1112
1128
  var productOriginTotal = product.origin_total || product.total || 0;
1113
1129
  // 如果当前 product 有 discount_list,则先从 origin_total 拿
1114
- if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
1130
+ if (_this3.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
1115
1131
  productOriginTotal = product.origin_total;
1116
1132
  }
1117
1133
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
@@ -1163,19 +1179,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1163
1179
  };
1164
1180
  appliedProducts.push(discountDetail);
1165
1181
  appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
1166
- var total = targetProductTotal;
1182
+ var _total = targetProductTotal;
1167
1183
  if (product.options) {
1168
- total = product.options.reduce(function (accumulator, currentValue) {
1184
+ _total = product.options.reduce(function (accumulator, currentValue) {
1169
1185
  var currentPrice = new Decimal(currentValue.price || 0);
1170
1186
  var currentNum = new Decimal(currentValue.num || 0);
1171
1187
  return accumulator.add(currentPrice.mul(currentNum));
1172
- }, new Decimal(total)).toNumber();
1188
+ }, new Decimal(_total)).toNumber();
1173
1189
  }
1174
1190
 
1175
1191
  // 记录应用了优惠券的商品
1176
1192
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
1177
1193
  if (product.isClient) {
1178
- debugger;
1179
1194
  arr.push(_this3.hooks.setProduct(originProduct, {
1180
1195
  discount_list: [discountDetail],
1181
1196
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
@@ -1189,15 +1204,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1189
1204
  }),
1190
1205
  variant: originProduct._productInit.variant,
1191
1206
  original_price: new Decimal(product.price || 0).toNumber(),
1192
- total: total
1207
+ total: _total
1193
1208
  }));
1194
1209
  } else {
1195
1210
  arr.push(_this3.hooks.setProduct(originProduct, {
1196
- discount_list: [discountDetail],
1211
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
1197
1212
  _id: product._id.split('___')[0] + "___" + _selectedDiscount.id + index,
1198
1213
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
1199
1214
  quantity: isNeedSplit ? 1 : product.quantity,
1200
- total: total,
1215
+ total: _total,
1201
1216
  origin_total: productOriginTotal,
1202
1217
  main_product_selling_price: targetProductTotal
1203
1218
  }));
@@ -1252,7 +1267,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1252
1267
  price: 0,
1253
1268
  // 商品券价格为0
1254
1269
  total: 0,
1255
- discount_list: [_discountDetail],
1270
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail]),
1256
1271
  processed: true,
1257
1272
  _discountId: _selectedDiscount2.id
1258
1273
  }));
@@ -1265,7 +1280,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1265
1280
  _id: "".concat(flatItem._id, "_split_rest"),
1266
1281
  num: normalNum,
1267
1282
  quantity: normalNum,
1268
- discount_list: [],
1283
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion'),
1269
1284
  processed: true
1270
1285
  }));
1271
1286
  }
@@ -1293,7 +1308,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1293
1308
  _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1294
1309
  fixedAmountPerItem = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1295
1310
  }
1296
- debugger;
1311
+
1297
1312
  // 🔥 使用当前的 _id 作为唯一标识
1298
1313
  var _uniqueId = flatItem._id;
1299
1314
  var _discountDetail2 = {
@@ -1327,7 +1342,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1327
1342
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1328
1343
  total: _targetProductTotal,
1329
1344
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1330
- discount_list: [_discountDetail2],
1345
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1331
1346
  processed: true
1332
1347
  }));
1333
1348
  }
@@ -1348,7 +1363,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1348
1363
  var getDefaultProduct = function getDefaultProduct() {
1349
1364
  if (product.isClient) {
1350
1365
  return _this3.hooks.setProduct(originProduct, {
1351
- discount_list: [],
1366
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1352
1367
  price: product.price,
1353
1368
  origin_total: getProductOriginTotalPrice({
1354
1369
  product: {
@@ -1369,7 +1384,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1369
1384
  });
1370
1385
  } else {
1371
1386
  return _this3.hooks.setProduct(originProduct, {
1372
- discount_list: [],
1387
+ discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1373
1388
  total: product.total,
1374
1389
  origin_total: product.origin_total,
1375
1390
  price: product.price
@@ -1829,10 +1844,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1829
1844
  return true; // 单独购买时可用
1830
1845
  }
1831
1846
  if (isBundleItem) {
1832
- var _flatItem$bundleItem8, _flatItem$bundleItem9;
1847
+ var _flatItem$bundleItem9, _flatItem$bundleItem10;
1833
1848
  // 套餐中购买时,判断是否为原价
1834
- var priceType = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type;
1835
- var priceTypeExt = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type_ext;
1849
+ var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
1850
+ var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
1836
1851
  // original_price 对应:
1837
1852
  // 1. price_type: "markup" && price_type_ext: "product_price"
1838
1853
  // markup_price 对应:
@@ -1870,10 +1885,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1870
1885
  return false; // 单独购买时不可用
1871
1886
  }
1872
1887
  if (isBundleItem) {
1873
- var _flatItem$bundleItem10, _flatItem$bundleItem11;
1888
+ var _flatItem$bundleItem11, _flatItem$bundleItem12;
1874
1889
  // 套餐中购买时,判断是否为原价
1875
- var _priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
1876
- var _priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
1890
+ var _priceType = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type;
1891
+ var _priceTypeExt = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type_ext;
1877
1892
 
1878
1893
  // original_price 对应:
1879
1894
  // 1. price_type: "markup" && price_type_ext: "product_price"
@@ -205,7 +205,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
205
205
  }, {
206
206
  key: "getScheduleListByIds",
207
207
  value: function getScheduleListByIds(ids) {
208
- return this.store.scheduleList.filter(function (n) {
208
+ return (this.store.scheduleList || []).filter(function (n) {
209
209
  return ids.includes(n.id);
210
210
  });
211
211
  }
@@ -120,7 +120,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
120
120
  case 0:
121
121
  shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
122
122
  scheduleModule = this.core.getModule('appointmentBooking_schedule');
123
- needScheduleIds = this.store.surchargeList.map(function (item) {
123
+ needScheduleIds = (this.store.surchargeList || []).map(function (item) {
124
124
  return item.available_schedule_ids;
125
125
  }).flat();
126
126
  scheduleList = scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
@@ -210,7 +210,7 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
210
210
  value: function getSurchargeforUtils(items) {
211
211
  // const surchargeList = this.store.surchargeList;
212
212
  var scheduleModule = this.core.getModule('appointmentBooking_schedule');
213
- var needScheduleIds = this.store.surchargeList.map(function (item) {
213
+ var needScheduleIds = (this.store.surchargeList || []).map(function (item) {
214
214
  return item.available_schedule_ids;
215
215
  }).flat();
216
216
  var scheduleList = scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
313
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
360
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
@@ -27,6 +27,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
27
27
  productList: any[];
28
28
  unavailableReason?: UnavailableReason;
29
29
  };
30
+ filterDiscountListByType(discountList: Discount[], type: string): Discount[];
30
31
  private getUnavailableReason;
31
32
  calcDiscount({ discountList, productList, holders, isFormSubject, }: {
32
33
  discountList: Discount[];
@@ -144,6 +144,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
144
144
  unavailableReason
145
145
  };
146
146
  }
147
+ filterDiscountListByType(discountList, type) {
148
+ return (discountList || []).filter((item) => item.type === type || item.tag === type);
149
+ }
147
150
  // 获取券不可用的原因
148
151
  getUnavailableReason(discountList, productList) {
149
152
  var _a;
@@ -567,7 +570,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
567
570
  });
568
571
  const processedFlatItemsMap = /* @__PURE__ */ new Map();
569
572
  sortedFlattenedList.forEach((flatItem, index) => {
570
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
573
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
571
574
  let product, originProduct;
572
575
  if (flatItem.type === "main") {
573
576
  product = flatItem.product;
@@ -730,30 +733,34 @@ var RulesModule = class extends import_BaseModule.BaseModule {
730
733
  }),
731
734
  price: product.price
732
735
  },
733
- discount_list: []
736
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
734
737
  })]
735
738
  );
736
739
  } else {
740
+ let total = product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
741
+ if ((product.discount_list || []).some((item) => item.type === "promotion")) {
742
+ total = product.total ?? product.origin_total;
743
+ }
737
744
  processedProductsMap.set(
738
745
  product._id,
739
746
  [this.hooks.setProduct(originProduct, {
740
747
  ...isManualDiscount ? {
741
748
  price: product.price,
742
- main_product_selling_price: product.price
749
+ main_product_selling_price: product.main_product_selling_price ?? product.price
743
750
  } : {
744
751
  _id: product._id.split("___")[0] + "___" + index,
745
- total: product.origin_total || product.total,
752
+ total,
746
753
  price: product.price,
747
- main_product_selling_price: product.price
754
+ main_product_selling_price: product.main_product_selling_price ?? product.price
748
755
  },
749
- discount_list: []
756
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
750
757
  })]
751
758
  );
752
759
  }
753
760
  } else {
754
761
  processedFlatItemsMap.set(flatItem._id, [{
755
762
  ...flatItem,
756
- discount_list: [],
763
+ discount_list: this.filterDiscountListByType(((_v = flatItem.bundleItem) == null ? void 0 : _v.discount_list) || [], "promotion"),
757
764
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
758
765
  processed: true
759
766
  }]);
@@ -771,7 +778,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
771
778
  if (flatItem.type === "main") {
772
779
  if (splitCount < totalQuantity && isNeedSplit) {
773
780
  arr.push(this.hooks.setProduct(originProduct, {
774
- discount_list: [],
781
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
775
782
  quantity: totalQuantity - splitCount,
776
783
  _id: product._id.split("___")[0]
777
784
  }));
@@ -781,10 +788,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
781
788
  usedDiscounts.set(selectedDiscount2.id, true);
782
789
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
783
790
  let productOriginTotal = product.origin_total || product.total || 0;
784
- if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
791
+ if (this.filterDiscountListByType(product.discount_list, "promotion").length && product.origin_total) {
785
792
  productOriginTotal = product.origin_total;
786
793
  }
787
- if (Number(((_v = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _v.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
794
+ if (Number(((_w = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _w.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
788
795
  productOriginTotal = product.total;
789
796
  }
790
797
  const isOrderLevel = (0, import_utils.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
@@ -807,9 +814,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
807
814
  amount,
808
815
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
809
816
  discount: {
810
- discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
817
+ discount_card_type: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_card_type,
811
818
  fixed_amount: amount,
812
- discount_calculation_mode: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_calculation_mode,
819
+ discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
813
820
  resource_id: selectedDiscount2.id,
814
821
  title: selectedDiscount2.format_title,
815
822
  original_amount: product.price,
@@ -836,7 +843,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
836
843
  }, new import_decimal.default(total)).toNumber();
837
844
  }
838
845
  if (product.isClient) {
839
- debugger;
840
846
  arr.push(this.hooks.setProduct(originProduct, {
841
847
  discount_list: [discountDetail],
842
848
  price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
@@ -854,7 +860,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
854
860
  }));
855
861
  } else {
856
862
  arr.push(this.hooks.setProduct(originProduct, {
857
- discount_list: [discountDetail],
863
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion").concat([discountDetail]),
858
864
  _id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
859
865
  price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
860
866
  quantity: isNeedSplit ? 1 : product.quantity,
@@ -879,7 +885,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
879
885
  type: "good_pass",
880
886
  discount: {
881
887
  fixed_amount: product.origin_total,
882
- discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
888
+ discount_calculation_mode: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_calculation_mode,
883
889
  resource_id: selectedDiscount2.id,
884
890
  title: selectedDiscount2.format_title,
885
891
  original_amount: product.origin_total,
@@ -905,7 +911,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
905
911
  price: 0,
906
912
  // 商品券价格为0
907
913
  total: 0,
908
- discount_list: [discountDetail],
914
+ discount_list: this.filterDiscountListByType(flatItem.discount_list, "promotion").concat([discountDetail]),
909
915
  processed: true,
910
916
  _discountId: selectedDiscount2.id
911
917
  });
@@ -917,7 +923,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
917
923
  _id: `${flatItem._id}_split_rest`,
918
924
  num: normalNum,
919
925
  quantity: normalNum,
920
- discount_list: [],
926
+ discount_list: this.filterDiscountListByType(flatItem.discount_list, "promotion"),
921
927
  processed: true
922
928
  });
923
929
  }
@@ -943,15 +949,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
943
949
  );
944
950
  fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
945
951
  }
946
- debugger;
947
952
  const uniqueId = flatItem._id;
948
953
  const discountDetail = {
949
954
  amount: fixedAmountPerItem * (product.num || 1),
950
955
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
951
956
  discount: {
952
- discount_card_type: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_card_type,
957
+ discount_card_type: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_card_type,
953
958
  fixed_amount: fixedAmountPerItem,
954
- discount_calculation_mode: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_calculation_mode,
959
+ discount_calculation_mode: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_calculation_mode,
955
960
  resource_id: selectedDiscount2.id,
956
961
  title: selectedDiscount2.format_title,
957
962
  original_amount: product.original_price,
@@ -966,7 +971,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
966
971
  // 🔥 order_level 分摊差值
967
972
  ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
968
973
  },
969
- _num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
974
+ _num: (product.num || 1) * (((_C = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _C.num) || 1)
970
975
  };
971
976
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
972
977
  appliedProducts.push(discountDetail);
@@ -975,7 +980,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
975
980
  ...flatItem,
976
981
  total: targetProductTotal,
977
982
  price: new import_decimal.default(productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
978
- discount_list: [discountDetail],
983
+ discount_list: this.filterDiscountListByType(flatItem.discount_list, "promotion").concat([discountDetail]),
979
984
  processed: true
980
985
  });
981
986
  }
@@ -991,7 +996,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
991
996
  const getDefaultProduct = () => {
992
997
  if (product.isClient) {
993
998
  return this.hooks.setProduct(originProduct, {
994
- discount_list: [],
999
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
995
1000
  price: product.price,
996
1001
  origin_total: (0, import_utils2.getProductOriginTotalPrice)({
997
1002
  product: {
@@ -1012,7 +1017,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1012
1017
  });
1013
1018
  } else {
1014
1019
  return this.hooks.setProduct(originProduct, {
1015
- discount_list: [],
1020
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
1016
1021
  total: product.total,
1017
1022
  origin_total: product.origin_total,
1018
1023
  price: product.price
@@ -135,7 +135,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
135
135
  return dates;
136
136
  }
137
137
  getScheduleListByIds(ids) {
138
- return this.store.scheduleList.filter((n) => ids.includes(n.id));
138
+ return (this.store.scheduleList || []).filter((n) => ids.includes(n.id));
139
139
  }
140
140
  setAvailabilityScheduleDateList(list) {
141
141
  this.store.availabilityDateList = list;
@@ -77,7 +77,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
77
77
  var _a, _b, _c;
78
78
  const shopInfo = ((_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.shop) || {};
79
79
  const scheduleModule = this.core.getModule("appointmentBooking_schedule");
80
- const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
80
+ const needScheduleIds = (this.store.surchargeList || []).map((item) => item.available_schedule_ids).flat();
81
81
  const scheduleList = scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
82
82
  const scheduleById = {};
83
83
  if (Array.isArray(scheduleList)) {
@@ -120,7 +120,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
120
120
  }
121
121
  getSurchargeforUtils(items) {
122
122
  const scheduleModule = this.core.getModule("appointmentBooking_schedule");
123
- const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
123
+ const needScheduleIds = (this.store.surchargeList || []).map((item) => item.available_schedule_ids).flat();
124
124
  const scheduleList = scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
125
125
  const scheduleById = {};
126
126
  if (Array.isArray(scheduleList)) {
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
313
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
360
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.94",
4
+ "version": "2.1.96",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",