@pisell/pisellos 2.2.102 → 2.2.104

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.
@@ -20,7 +20,8 @@ var defaultStrategyMetadataCustom = {
20
20
  allowCrossProduct: true,
21
21
  applicableProductLimit: 0,
22
22
  deductTaxAndFee: true,
23
- maxPassesPerItem: 0
23
+ maxPassesPerItem: 0,
24
+ deductOptionPrice: false
24
25
  };
25
26
 
26
27
  /**
@@ -43,6 +43,8 @@ export interface Voucher {
43
43
  applicableProductLimit: number;
44
44
  /** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
45
45
  maxPassesPerItem: number;
46
+ /** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
47
+ deductOptionPrice: boolean;
46
48
  };
47
49
  }
48
50
  /**
@@ -62,6 +64,13 @@ export interface Product {
62
64
  main_product_original_price?: number;
63
65
  /** 主商品折扣后金额,不包含套餐子商品 */
64
66
  main_product_selling_price?: number;
67
+ /** 单规格(Option)列表 */
68
+ product_options?: {
69
+ id: number;
70
+ add_price: number | string;
71
+ num: number;
72
+ [key: string]: any;
73
+ }[];
65
74
  /** 主商品税费 */
66
75
  tax_fee: number;
67
76
  metadata: {
@@ -138,6 +147,8 @@ export interface EvaluatorInput {
138
147
  applicableProductLimit: number;
139
148
  /** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
140
149
  maxPassesPerItem: number;
150
+ /** 是否抵扣单规格价格 (Option Price),默认 false */
151
+ deductOptionPrice: boolean;
141
152
  }>[];
142
153
  }
143
154
  /**
@@ -119,6 +119,8 @@ export interface Discount {
119
119
  allowCrossProduct?: boolean;
120
120
  /** 可用商品数量上限 */
121
121
  applicableProductLimit?: number;
122
+ /** 是否抵扣单规格价格 (Option Price) */
123
+ deductOptionPrice?: boolean;
122
124
  };
123
125
  applicableProductIds?: number[];
124
126
  applicableProductDetails: ApplicableProductDetails[];
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
23
23
  */
24
24
  private logError;
25
25
  createOrder(params: CommitOrderParams['query']): {
26
- type: "appointment_booking" | "virtual";
26
+ type: "virtual" | "appointment_booking";
27
27
  platform: string;
28
28
  sales_channel: string;
29
29
  order_sales_channel: string;
@@ -1,4 +1,8 @@
1
+ var _excluded = ["_original_add_price"],
2
+ _excluded2 = ["_original_price", "_original_add_price"];
1
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
6
  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; }
3
7
  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; }
4
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -485,11 +489,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
485
489
 
486
490
  // 转换 sortedFlattenedList 为 Product 格式
487
491
  var productsForEvaluate = sortedFlattenedList.map(function (item) {
492
+ var _item$product;
488
493
  return {
489
494
  product_id: item.id,
490
495
  price: item.price || 0,
491
496
  quantity: item.quantity || item.num || 1,
492
- selling_price: item.price || 0
497
+ selling_price: item.price || 0,
498
+ product_options: item.type === 'main' ? (_item$product = item.product) === null || _item$product === void 0 ? void 0 : _item$product.options : undefined
493
499
  };
494
500
  });
495
501
 
@@ -826,6 +832,61 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
826
832
  // 🔥 用于存储扁平化商品处理结果的Map
827
833
  var processedFlatItemsMap = new Map();
828
834
 
835
+ // 🔥 Option 折扣辅助函数
836
+ var applyDiscountToOptions = function applyDiscountToOptions(options, discount) {
837
+ if (!(options !== null && options !== void 0 && options.length)) return {
838
+ discountedOptions: options,
839
+ optionDiscountAmount: 0
840
+ };
841
+ var optionDiscountAmount = 0;
842
+ var discountedOptions = options.map(function (option) {
843
+ var _ref5, _ref6, _option$_original_pri, _ref7, _option$num, _rest$price, _option$_original_pri2;
844
+ // 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
845
+ var rawUnit = (_ref5 = (_ref6 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref6 !== void 0 ? _ref6 : option.price) !== null && _ref5 !== void 0 ? _ref5 : option.add_price;
846
+ var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
847
+ if (baseUnitNum <= 0) return option;
848
+ var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
849
+ var optQty = Number((_ref7 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref7 !== void 0 ? _ref7 : 1);
850
+ optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
851
+ var _original_add_price = option._original_add_price,
852
+ rest = _objectWithoutProperties(option, _excluded);
853
+ var tmpl = (_rest$price = rest.price) !== null && _rest$price !== void 0 ? _rest$price : rest.add_price;
854
+ var nextPrice = typeof tmpl === 'string' ? String(discountedPrice) : discountedPrice;
855
+ return _objectSpread(_objectSpread({}, rest), {}, {
856
+ _original_price: (_option$_original_pri2 = option._original_price) !== null && _option$_original_pri2 !== void 0 ? _option$_original_pri2 : _original_add_price !== undefined ? _original_add_price : rawUnit,
857
+ price: nextPrice
858
+ });
859
+ });
860
+ return {
861
+ discountedOptions: discountedOptions,
862
+ optionDiscountAmount: optionDiscountAmount
863
+ };
864
+ };
865
+ var restoreOptionPrices = function restoreOptionPrices(options) {
866
+ if (!(options !== null && options !== void 0 && options.length)) return options;
867
+ return options.map(function (option) {
868
+ var orig = option._original_price !== undefined ? option._original_price : option._original_add_price;
869
+ if (orig !== undefined) {
870
+ var _original_price = option._original_price,
871
+ _original_add_price = option._original_add_price,
872
+ rest = _objectWithoutProperties(option, _excluded2);
873
+ return _objectSpread(_objectSpread({}, rest), {}, {
874
+ price: orig
875
+ });
876
+ }
877
+ return option;
878
+ });
879
+ };
880
+ var getOptionTotal = function getOptionTotal(options) {
881
+ if (!(options !== null && options !== void 0 && options.length)) return 0;
882
+ return options.reduce(function (sum, opt) {
883
+ var _ref8, _opt$price, _ref9, _opt$num;
884
+ var unit = Number((_ref8 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref8 !== void 0 ? _ref8 : 0);
885
+ var n = Number((_ref9 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref9 !== void 0 ? _ref9 : 1);
886
+ return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
887
+ }, 0);
888
+ };
889
+
829
890
  // 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
830
891
  // 🔥 使用扁平化后的列表进行处理
831
892
  sortedFlattenedList.forEach(function (flatItem, index) {
@@ -955,8 +1016,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
955
1016
  var _product$discount_lis5, _product11, _product11$every;
956
1017
  // 主商品:判断自身是否手动折扣
957
1018
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
958
- var _ref5;
959
- return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
1019
+ var _ref10;
1020
+ return !((_ref10 = item.discount_list || []) !== null && _ref10 !== void 0 && _ref10.length);
960
1021
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.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) {
961
1022
  return item.type === 'product';
962
1023
  })));
@@ -969,8 +1030,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
969
1030
  if (parentProduct) {
970
1031
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
971
1032
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
972
- var _ref6;
973
- return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
1033
+ var _ref11;
1034
+ return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
974
1035
  }) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
975
1036
  return item.type === 'product';
976
1037
  })));
@@ -1037,7 +1098,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1037
1098
  // 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
1038
1099
  if (applicableDiscounts.length === 0 || isManualDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1039
1100
  if (flatItem.type === 'main') {
1040
- // 主商品:保持原有逻辑
1101
+ // 主商品:保持原有逻辑,还原 option 价格
1102
+ var restoredOptions = restoreOptionPrices(product.options);
1041
1103
  if (product.isClient) {
1042
1104
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
1043
1105
  origin_total: getProductOriginTotalPrice({
@@ -1045,7 +1107,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1045
1107
  original_price: product.original_price
1046
1108
  },
1047
1109
  bundle: product.bundle,
1048
- options: product.options
1110
+ options: restoredOptions
1049
1111
  }),
1050
1112
  variant: originProduct._productInit.variant,
1051
1113
  original_price: originProduct._productInit.original_price,
@@ -1054,15 +1116,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1054
1116
  price: product.price
1055
1117
  },
1056
1118
  bundle: product.bundle,
1057
- options: product.options
1119
+ options: restoredOptions
1058
1120
  }),
1059
- price: product.price
1121
+ price: product.price,
1122
+ options: restoredOptions
1060
1123
  }), {}, {
1061
1124
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1062
1125
  }))]);
1063
1126
  } else {
1064
- var _ref7, _product$_promotion$f, _product12, _product$origin_total;
1065
- var total = product.inPromotion ? (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1127
+ var _ref12, _product$_promotion$f, _product12, _product$origin_total;
1128
+ var total = product.inPromotion ? (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1066
1129
  var main_product_selling_price = product.price;
1067
1130
  if ((product.discount_list || []).some(function (item) {
1068
1131
  return item.type === 'promotion';
@@ -1078,7 +1141,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1078
1141
  _id: product._id.split('___')[0] + '___' + index,
1079
1142
  total: total,
1080
1143
  price: product.price,
1081
- main_product_selling_price: main_product_selling_price
1144
+ main_product_selling_price: main_product_selling_price,
1145
+ options: restoredOptions
1082
1146
  }), {}, {
1083
1147
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1084
1148
  }))]);
@@ -1135,7 +1199,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1135
1199
  }));
1136
1200
  }
1137
1201
  for (var i = 0; i < splitCount; i++) {
1138
- var _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1202
+ var _originProduct, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1139
1203
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1140
1204
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1141
1205
  // 标记优惠券为已使用
@@ -1165,27 +1229,46 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1165
1229
  var isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount);
1166
1230
  var orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount.id) : null;
1167
1231
  var productAllocation = orderLevelAllocation === null || orderLevelAllocation === void 0 ? void 0 : orderLevelAllocation.get(flatItem._id);
1168
- var targetProductTotal = void 0;
1232
+ var isDeductOptionPrice = !!((_selectedDiscount$con = _selectedDiscount.config) !== null && _selectedDiscount$con !== void 0 && _selectedDiscount$con.deductOptionPrice);
1233
+
1234
+ // 主商品折后价(不含 option);勿与 option 合计混在同一变量,否则 main_product_selling_price 错误
1235
+ var mainProductSellingPrice = void 0;
1169
1236
  var amount = void 0;
1170
1237
  var productDiscountDifference = void 0;
1238
+ var discountedOptions = product.options;
1239
+ var optionDiscountAmount = 0;
1171
1240
  if (isOrderLevel && productAllocation) {
1172
1241
  // order_level:使用预计算的分摊金额
1173
1242
  amount = productAllocation.discountAmount;
1174
1243
  productDiscountDifference = productAllocation.difference;
1175
- targetProductTotal = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1244
+ mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1176
1245
  } else {
1177
1246
  // item_level 或其他类型:使用原有逻辑
1178
- targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
1179
- amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
1247
+ mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
1248
+ amount = new Decimal(product.price).minus(new Decimal(mainProductSellingPrice)).toNumber();
1249
+ }
1250
+ if (isDeductOptionPrice && (_product$options = product.options) !== null && _product$options !== void 0 && _product$options.length) {
1251
+ var optionResult = applyDiscountToOptions(product.options, _selectedDiscount);
1252
+ discountedOptions = optionResult.discountedOptions;
1253
+ optionDiscountAmount = optionResult.optionDiscountAmount;
1180
1254
  }
1255
+
1256
+ // total = 主商品折后 + option 行合计;开启 option 抵扣时必须用 discountedOptions,不能用未折扣的 product.options 再算一遍
1257
+ var optionsForLineTotal = isDeductOptionPrice && (_product$options2 = product.options) !== null && _product$options2 !== void 0 && _product$options2.length ? discountedOptions : product.options;
1258
+ var optionsLineTotal = getOptionTotal(optionsForLineTotal || []);
1259
+ var _total2 = new Decimal(mainProductSellingPrice).plus(optionsLineTotal).toNumber();
1260
+
1261
+ // discount_list.amount / fixed_amount:行级总优惠 = 主商品优惠 + option 优惠(与 total 变化一致)
1262
+ var mainProductDiscountAmount = amount;
1263
+ var lineDiscountAmount = new Decimal(mainProductDiscountAmount).plus(optionDiscountAmount).toNumber();
1181
1264
  var discountType = _selectedDiscount.tag || _selectedDiscount.type;
1182
1265
  var isGoodPass = discountType === 'good_pass';
1183
1266
  var discountDetail = {
1184
- amount: amount,
1267
+ amount: lineDiscountAmount,
1185
1268
  type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : discountType,
1186
1269
  discount: {
1187
1270
  discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
1188
- fixed_amount: amount,
1271
+ fixed_amount: lineDiscountAmount,
1189
1272
  discount_calculation_mode: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met2 = _selectedDiscount.metadata) === null || _selectedDiscount$met2 === void 0 ? void 0 : _selectedDiscount$met2.discount_calculation_mode,
1190
1273
  resource_id: _selectedDiscount.id,
1191
1274
  title: _selectedDiscount.format_title,
@@ -1197,40 +1280,38 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1197
1280
  // 前端使用的num数量,为了计算优惠金额
1198
1281
  _num: isGoodPass ? 1 : product.num,
1199
1282
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1200
- metadata: _objectSpread({
1283
+ metadata: _objectSpread(_objectSpread({
1201
1284
  num: 1
1202
1285
  }, productDiscountDifference !== undefined && {
1203
1286
  product_discount_difference: productDiscountDifference
1287
+ }), {}, {
1288
+ /** 仅主商品上的优惠金额(不含 option) */
1289
+ mainProductDiscountAmount: mainProductDiscountAmount,
1290
+ optionDiscountAmount: optionDiscountAmount
1204
1291
  })
1205
1292
  };
1206
1293
  appliedProducts.push(discountDetail);
1207
1294
  appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
1208
- var _total2 = targetProductTotal;
1209
- if (product.options) {
1210
- _total2 = product.options.reduce(function (accumulator, currentValue) {
1211
- var currentPrice = new Decimal(currentValue.price || 0);
1212
- var currentNum = new Decimal(currentValue.num || 0);
1213
- return accumulator.add(currentPrice.mul(currentNum));
1214
- }, new Decimal(_total2)).toNumber();
1215
- }
1216
1295
 
1217
1296
  // 记录应用了优惠券的商品
1218
1297
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
1219
1298
  if (product.isClient) {
1220
1299
  arr.push(_this3.hooks.setProduct(originProduct, {
1221
1300
  discount_list: [discountDetail],
1222
- price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
1301
+ // good_pass:主商品价以折后价为准;勿用 product.price - amount(amount option 优惠时会算错)
1302
+ price: isGoodPass ? mainProductSellingPrice : product.price,
1223
1303
  quantity: isNeedSplit ? 1 : product.quantity,
1224
1304
  origin_total: getProductOriginTotalPrice({
1225
1305
  product: {
1226
1306
  original_price: product.original_price
1227
1307
  },
1228
1308
  bundle: product.bundle,
1229
- options: product.options
1309
+ options: restoreOptionPrices(product.options)
1230
1310
  }),
1231
1311
  variant: originProduct._productInit.variant,
1232
1312
  original_price: new Decimal(product.price || 0).toNumber(),
1233
- total: _total2
1313
+ total: _total2,
1314
+ options: discountedOptions
1234
1315
  }));
1235
1316
  } else {
1236
1317
  arr.push(_this3.hooks.setProduct(originProduct, {
@@ -1240,7 +1321,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1240
1321
  quantity: isNeedSplit ? 1 : product.quantity,
1241
1322
  total: _total2,
1242
1323
  origin_total: productOriginTotal,
1243
- main_product_selling_price: targetProductTotal
1324
+ main_product_selling_price: mainProductSellingPrice,
1325
+ options: discountedOptions
1244
1326
  }));
1245
1327
  }
1246
1328
  }
@@ -1336,18 +1418,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1336
1418
  var _isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount3);
1337
1419
  var _orderLevelAllocation = _isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount3.id) : null;
1338
1420
  var _productAllocation = _orderLevelAllocation === null || _orderLevelAllocation === void 0 ? void 0 : _orderLevelAllocation.get(flatItem._id);
1339
- var _targetProductTotal;
1421
+ var targetProductTotal;
1340
1422
  var fixedAmountPerItem;
1341
1423
  var _productDiscountDifference;
1342
1424
  if (_isOrderLevel && _productAllocation) {
1343
1425
  // order_level:使用预计算的单价折扣金额(已经是单价,无需再除以数量)
1344
1426
  fixedAmountPerItem = _productAllocation.discountAmount;
1345
1427
  _productDiscountDifference = _productAllocation.difference;
1346
- _targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
1428
+ targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
1347
1429
  } else {
1348
1430
  // item_level 或其他类型:使用原有逻辑
1349
- _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1350
- fixedAmountPerItem = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1431
+ targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1432
+ fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
1351
1433
  }
1352
1434
 
1353
1435
  // 🔥 使用当前的 _id 作为唯一标识
@@ -1382,7 +1464,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1382
1464
  _appliedProducts2.push(_discountDetail2);
1383
1465
  appliedDiscountProducts.set(_selectedDiscount3.id, _appliedProducts2);
1384
1466
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1385
- total: _targetProductTotal,
1467
+ total: targetProductTotal,
1386
1468
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1387
1469
  discount_list: [_discountDetail2],
1388
1470
  processed: true
@@ -1401,8 +1483,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1401
1483
  // 获取主商品处理结果
1402
1484
  var mainProductArr = processedProductsMap.get(product._id);
1403
1485
  if (!mainProductArr || mainProductArr.length === 0) {
1404
- // 如果没有处理结果,返回默认商品
1486
+ // 如果没有处理结果,返回默认商品(还原 option 价格)
1405
1487
  var getDefaultProduct = function getDefaultProduct() {
1488
+ var restoredOptions = restoreOptionPrices(product.options);
1406
1489
  if (product.isClient) {
1407
1490
  return _this3.hooks.setProduct(originProduct, {
1408
1491
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
@@ -1412,7 +1495,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1412
1495
  original_price: product.original_price
1413
1496
  },
1414
1497
  bundle: product.bundle,
1415
- options: product.options
1498
+ options: restoredOptions
1416
1499
  }),
1417
1500
  variant: originProduct._productInit.variant,
1418
1501
  original_price: originProduct._productInit.original_price,
@@ -1421,15 +1504,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1421
1504
  price: product.price
1422
1505
  },
1423
1506
  bundle: product.bundle,
1424
- options: product.options
1425
- })
1507
+ options: restoredOptions
1508
+ }),
1509
+ options: restoredOptions
1426
1510
  });
1427
1511
  } else {
1428
1512
  return _this3.hooks.setProduct(originProduct, {
1429
1513
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1430
1514
  total: product.total,
1431
1515
  origin_total: product.origin_total,
1432
- price: product.price
1516
+ price: product.price,
1517
+ options: restoreOptionPrices(product.options)
1433
1518
  });
1434
1519
  }
1435
1520
  };
@@ -61,6 +61,7 @@ export interface RulesParamsHooks {
61
61
  quantity?: number;
62
62
  bundle?: any[];
63
63
  main_product_selling_price?: string | number;
64
+ options?: any[];
64
65
  }) => Record<string, any>;
65
66
  }
66
67
  export {};
@@ -42,7 +42,8 @@ var defaultStrategyMetadataCustom = {
42
42
  allowCrossProduct: true,
43
43
  applicableProductLimit: 0,
44
44
  deductTaxAndFee: true,
45
- maxPassesPerItem: 0
45
+ maxPassesPerItem: 0,
46
+ deductOptionPrice: false
46
47
  };
47
48
  var WalletPassEvaluator = class {
48
49
  constructor() {
@@ -43,6 +43,8 @@ export interface Voucher {
43
43
  applicableProductLimit: number;
44
44
  /** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
45
45
  maxPassesPerItem: number;
46
+ /** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
47
+ deductOptionPrice: boolean;
46
48
  };
47
49
  }
48
50
  /**
@@ -62,6 +64,13 @@ export interface Product {
62
64
  main_product_original_price?: number;
63
65
  /** 主商品折扣后金额,不包含套餐子商品 */
64
66
  main_product_selling_price?: number;
67
+ /** 单规格(Option)列表 */
68
+ product_options?: {
69
+ id: number;
70
+ add_price: number | string;
71
+ num: number;
72
+ [key: string]: any;
73
+ }[];
65
74
  /** 主商品税费 */
66
75
  tax_fee: number;
67
76
  metadata: {
@@ -138,6 +147,8 @@ export interface EvaluatorInput {
138
147
  applicableProductLimit: number;
139
148
  /** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
140
149
  maxPassesPerItem: number;
150
+ /** 是否抵扣单规格价格 (Option Price),默认 false */
151
+ deductOptionPrice: boolean;
141
152
  }>[];
142
153
  }
143
154
  /**
@@ -119,6 +119,8 @@ export interface Discount {
119
119
  allowCrossProduct?: boolean;
120
120
  /** 可用商品数量上限 */
121
121
  applicableProductLimit?: number;
122
+ /** 是否抵扣单规格价格 (Option Price) */
123
+ deductOptionPrice?: boolean;
122
124
  };
123
125
  applicableProductIds?: number[];
124
126
  applicableProductDetails: ApplicableProductDetails[];
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
23
23
  */
24
24
  private logError;
25
25
  createOrder(params: CommitOrderParams['query']): {
26
- type: "appointment_booking" | "virtual";
26
+ type: "virtual" | "appointment_booking";
27
27
  platform: string;
28
28
  sales_channel: string;
29
29
  order_sales_channel: string;
@@ -353,12 +353,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
353
353
  available_product_type: (_a = discount.limited_relation_product_data) == null ? void 0 : _a.type,
354
354
  available_product_ids: (_b = discount.limited_relation_product_data) == null ? void 0 : _b.product_ids
355
355
  };
356
- const productsForEvaluate = sortedFlattenedList.map((item) => ({
357
- product_id: item.id,
358
- price: item.price || 0,
359
- quantity: item.quantity || item.num || 1,
360
- selling_price: item.price || 0
361
- }));
356
+ const productsForEvaluate = sortedFlattenedList.map((item) => {
357
+ var _a2;
358
+ return {
359
+ product_id: item.id,
360
+ price: item.price || 0,
361
+ quantity: item.quantity || item.num || 1,
362
+ selling_price: item.price || 0,
363
+ product_options: item.type === "main" ? (_a2 = item.product) == null ? void 0 : _a2.options : void 0
364
+ };
365
+ });
362
366
  const result = evaluator.checkVoucherAvailability({
363
367
  orderTotalAmount,
364
368
  products: productsForEvaluate,
@@ -584,8 +588,52 @@ var RulesModule = class extends import_BaseModule.BaseModule {
584
588
  });
585
589
  });
586
590
  const processedFlatItemsMap = /* @__PURE__ */ new Map();
591
+ const applyDiscountToOptions = (options2, discount) => {
592
+ if (!(options2 == null ? void 0 : options2.length))
593
+ return { discountedOptions: options2, optionDiscountAmount: 0 };
594
+ let optionDiscountAmount = 0;
595
+ const discountedOptions = options2.map((option) => {
596
+ const rawUnit = option._original_price ?? option._original_add_price ?? option.price ?? option.add_price;
597
+ const baseUnitNum = Number(rawUnit ?? 0);
598
+ if (baseUnitNum <= 0)
599
+ return option;
600
+ const discountedPrice = (0, import_utils.getDiscountAmount)(discount, baseUnitNum, baseUnitNum);
601
+ const optQty = Number(option.num ?? option.quantity ?? 1);
602
+ optionDiscountAmount = new import_decimal.default(optionDiscountAmount).plus(new import_decimal.default(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
603
+ const { _original_add_price, ...rest } = option;
604
+ const tmpl = rest.price ?? rest.add_price;
605
+ const nextPrice = typeof tmpl === "string" ? String(discountedPrice) : discountedPrice;
606
+ return {
607
+ ...rest,
608
+ _original_price: option._original_price ?? (_original_add_price !== void 0 ? _original_add_price : rawUnit),
609
+ price: nextPrice
610
+ };
611
+ });
612
+ return { discountedOptions, optionDiscountAmount };
613
+ };
614
+ const restoreOptionPrices = (options2) => {
615
+ if (!(options2 == null ? void 0 : options2.length))
616
+ return options2;
617
+ return options2.map((option) => {
618
+ const orig = option._original_price !== void 0 ? option._original_price : option._original_add_price;
619
+ if (orig !== void 0) {
620
+ const { _original_price, _original_add_price, ...rest } = option;
621
+ return { ...rest, price: orig };
622
+ }
623
+ return option;
624
+ });
625
+ };
626
+ const getOptionTotal = (options2) => {
627
+ if (!(options2 == null ? void 0 : options2.length))
628
+ return 0;
629
+ return options2.reduce((sum, opt) => {
630
+ const unit = Number(opt.price ?? opt.add_price ?? 0);
631
+ const n = Number(opt.num ?? opt.quantity ?? 1);
632
+ return new import_decimal.default(sum).plus(new import_decimal.default(unit).mul(n)).toNumber();
633
+ }, 0);
634
+ };
587
635
  sortedFlattenedList.forEach((flatItem, index) => {
588
- 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;
636
+ 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, _D, _E, _F;
589
637
  let product, originProduct;
590
638
  if (flatItem.type === "main") {
591
639
  product = flatItem.product;
@@ -784,6 +832,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
784
832
  }
785
833
  if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
786
834
  if (flatItem.type === "main") {
835
+ const restoredOptions = restoreOptionPrices(product.options);
787
836
  if (product.isClient) {
788
837
  processedProductsMap.set(product._id, [
789
838
  this.hooks.setProduct(originProduct, {
@@ -793,7 +842,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
793
842
  original_price: product.original_price
794
843
  },
795
844
  bundle: product.bundle,
796
- options: product.options
845
+ options: restoredOptions
797
846
  }),
798
847
  variant: originProduct._productInit.variant,
799
848
  original_price: originProduct._productInit.original_price,
@@ -802,9 +851,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
802
851
  price: product.price
803
852
  },
804
853
  bundle: product.bundle,
805
- options: product.options
854
+ options: restoredOptions
806
855
  }),
807
- price: product.price
856
+ price: product.price,
857
+ options: restoredOptions
808
858
  },
809
859
  discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
810
860
  })
@@ -825,7 +875,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
825
875
  _id: product._id.split("___")[0] + "___" + index,
826
876
  total,
827
877
  price: product.price,
828
- main_product_selling_price
878
+ main_product_selling_price,
879
+ options: restoredOptions
829
880
  },
830
881
  discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
831
882
  })
@@ -891,26 +942,46 @@ var RulesModule = class extends import_BaseModule.BaseModule {
891
942
  const isOrderLevel = (0, import_utils3.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
892
943
  const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
893
944
  const productAllocation = orderLevelAllocation == null ? void 0 : orderLevelAllocation.get(flatItem._id);
894
- let targetProductTotal;
945
+ const isDeductOptionPrice = !!((_x = selectedDiscount2.config) == null ? void 0 : _x.deductOptionPrice);
946
+ let mainProductSellingPrice;
895
947
  let amount;
896
948
  let productDiscountDifference;
949
+ let discountedOptions = product.options;
950
+ let optionDiscountAmount = 0;
897
951
  if (isOrderLevel && productAllocation) {
898
952
  amount = productAllocation.discountAmount;
899
953
  productDiscountDifference = productAllocation.difference;
900
- targetProductTotal = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
954
+ mainProductSellingPrice = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
901
955
  } else {
902
- targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
903
- amount = new import_decimal.default(product.price).minus(new import_decimal.default(targetProductTotal)).toNumber();
956
+ mainProductSellingPrice = (0, import_utils.getDiscountAmount)(
957
+ selectedDiscount2,
958
+ product.price,
959
+ product.price
960
+ );
961
+ amount = new import_decimal.default(product.price).minus(new import_decimal.default(mainProductSellingPrice)).toNumber();
962
+ }
963
+ if (isDeductOptionPrice && ((_y = product.options) == null ? void 0 : _y.length)) {
964
+ const optionResult = applyDiscountToOptions(
965
+ product.options,
966
+ selectedDiscount2
967
+ );
968
+ discountedOptions = optionResult.discountedOptions;
969
+ optionDiscountAmount = optionResult.optionDiscountAmount;
904
970
  }
971
+ const optionsForLineTotal = isDeductOptionPrice && ((_z = product.options) == null ? void 0 : _z.length) ? discountedOptions : product.options;
972
+ const optionsLineTotal = getOptionTotal(optionsForLineTotal || []);
973
+ const total = new import_decimal.default(mainProductSellingPrice).plus(optionsLineTotal).toNumber();
974
+ const mainProductDiscountAmount = amount;
975
+ const lineDiscountAmount = new import_decimal.default(mainProductDiscountAmount).plus(optionDiscountAmount).toNumber();
905
976
  const discountType = selectedDiscount2.tag || selectedDiscount2.type;
906
977
  const isGoodPass = discountType === "good_pass";
907
978
  const discountDetail = {
908
- amount,
979
+ amount: lineDiscountAmount,
909
980
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
910
981
  discount: {
911
- discount_card_type: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_card_type,
912
- fixed_amount: amount,
913
- discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
982
+ discount_card_type: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_card_type,
983
+ fixed_amount: lineDiscountAmount,
984
+ discount_calculation_mode: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_calculation_mode,
914
985
  resource_id: selectedDiscount2.id,
915
986
  title: selectedDiscount2.format_title,
916
987
  original_amount: product.price,
@@ -924,35 +995,32 @@ var RulesModule = class extends import_BaseModule.BaseModule {
924
995
  metadata: {
925
996
  num: 1,
926
997
  // 🔥 order_level 分摊差值
927
- ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
998
+ ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference },
999
+ /** 仅主商品上的优惠金额(不含 option) */
1000
+ mainProductDiscountAmount,
1001
+ optionDiscountAmount
928
1002
  }
929
1003
  };
930
1004
  appliedProducts.push(discountDetail);
931
1005
  appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
932
- let total = targetProductTotal;
933
- if (product.options) {
934
- total = product.options.reduce((accumulator, currentValue) => {
935
- const currentPrice = new import_decimal.default(currentValue.price || 0);
936
- const currentNum = new import_decimal.default(currentValue.num || 0);
937
- return accumulator.add(currentPrice.mul(currentNum));
938
- }, new import_decimal.default(total)).toNumber();
939
- }
940
1006
  if (product.isClient) {
941
1007
  arr.push(
942
1008
  this.hooks.setProduct(originProduct, {
943
1009
  discount_list: [discountDetail],
944
- price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
1010
+ // good_pass:主商品价以折后价为准;勿用 product.price - amount(amount option 优惠时会算错)
1011
+ price: isGoodPass ? mainProductSellingPrice : product.price,
945
1012
  quantity: isNeedSplit ? 1 : product.quantity,
946
1013
  origin_total: (0, import_utils2.getProductOriginTotalPrice)({
947
1014
  product: {
948
1015
  original_price: product.original_price
949
1016
  },
950
1017
  bundle: product.bundle,
951
- options: product.options
1018
+ options: restoreOptionPrices(product.options)
952
1019
  }),
953
1020
  variant: originProduct._productInit.variant,
954
1021
  original_price: new import_decimal.default(product.price || 0).toNumber(),
955
- total
1022
+ total,
1023
+ options: discountedOptions
956
1024
  })
957
1025
  );
958
1026
  } else {
@@ -964,7 +1032,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
964
1032
  quantity: isNeedSplit ? 1 : product.quantity,
965
1033
  total,
966
1034
  origin_total: productOriginTotal,
967
- main_product_selling_price: targetProductTotal
1035
+ main_product_selling_price: mainProductSellingPrice,
1036
+ options: discountedOptions
968
1037
  })
969
1038
  );
970
1039
  }
@@ -994,7 +1063,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
994
1063
  type: "good_pass",
995
1064
  discount: {
996
1065
  fixed_amount: product.origin_total,
997
- discount_calculation_mode: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_calculation_mode,
1066
+ discount_calculation_mode: (_C = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _C.discount_calculation_mode,
998
1067
  resource_id: selectedDiscount2.id,
999
1068
  title: selectedDiscount2.format_title,
1000
1069
  original_amount: product.origin_total,
@@ -1068,9 +1137,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1068
1137
  amount: fixedAmountPerItem * (product.num || 1),
1069
1138
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
1070
1139
  discount: {
1071
- discount_card_type: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_card_type,
1140
+ discount_card_type: (_D = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _D.discount_card_type,
1072
1141
  fixed_amount: fixedAmountPerItem,
1073
- discount_calculation_mode: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_calculation_mode,
1142
+ discount_calculation_mode: (_E = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _E.discount_calculation_mode,
1074
1143
  resource_id: selectedDiscount2.id,
1075
1144
  title: selectedDiscount2.format_title,
1076
1145
  original_amount: product.original_price,
@@ -1086,7 +1155,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1086
1155
  ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
1087
1156
  },
1088
1157
  config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
1089
- _num: (product.num || 1) * (((_C = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _C.num) || 1)
1158
+ _num: (product.num || 1) * (((_F = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _F.num) || 1)
1090
1159
  };
1091
1160
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
1092
1161
  appliedProducts.push(discountDetail);
@@ -1109,6 +1178,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1109
1178
  const mainProductArr = processedProductsMap2.get(product._id);
1110
1179
  if (!mainProductArr || mainProductArr.length === 0) {
1111
1180
  const getDefaultProduct = () => {
1181
+ const restoredOptions = restoreOptionPrices(product.options);
1112
1182
  if (product.isClient) {
1113
1183
  return this.hooks.setProduct(originProduct, {
1114
1184
  discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
@@ -1118,7 +1188,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1118
1188
  original_price: product.original_price
1119
1189
  },
1120
1190
  bundle: product.bundle,
1121
- options: product.options
1191
+ options: restoredOptions
1122
1192
  }),
1123
1193
  variant: originProduct._productInit.variant,
1124
1194
  original_price: originProduct._productInit.original_price,
@@ -1127,15 +1197,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1127
1197
  price: product.price
1128
1198
  },
1129
1199
  bundle: product.bundle,
1130
- options: product.options
1131
- })
1200
+ options: restoredOptions
1201
+ }),
1202
+ options: restoredOptions
1132
1203
  });
1133
1204
  } else {
1134
1205
  return this.hooks.setProduct(originProduct, {
1135
1206
  discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
1136
1207
  total: product.total,
1137
1208
  origin_total: product.origin_total,
1138
- price: product.price
1209
+ price: product.price,
1210
+ options: restoreOptionPrices(product.options)
1139
1211
  });
1140
1212
  }
1141
1213
  };
@@ -61,6 +61,7 @@ export interface RulesParamsHooks {
61
61
  quantity?: number;
62
62
  bundle?: any[];
63
63
  main_product_selling_price?: string | number;
64
+ options?: any[];
64
65
  }) => Record<string, any>;
65
66
  }
66
67
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.102",
4
+ "version": "2.2.104",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",