@pisell/pisellos 2.2.101 → 2.2.103

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.
@@ -1,4 +1,7 @@
1
+ var _excluded = ["_original_add_price"];
1
2
  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); }
3
+ 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; }
4
+ 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
5
  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
6
  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
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -485,11 +488,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
485
488
 
486
489
  // 转换 sortedFlattenedList 为 Product 格式
487
490
  var productsForEvaluate = sortedFlattenedList.map(function (item) {
491
+ var _item$product;
488
492
  return {
489
493
  product_id: item.id,
490
494
  price: item.price || 0,
491
495
  quantity: item.quantity || item.num || 1,
492
- selling_price: item.price || 0
496
+ selling_price: item.price || 0,
497
+ product_options: item.type === 'main' ? (_item$product = item.product) === null || _item$product === void 0 ? void 0 : _item$product.options : undefined
493
498
  };
494
499
  });
495
500
 
@@ -826,6 +831,53 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
826
831
  // 🔥 用于存储扁平化商品处理结果的Map
827
832
  var processedFlatItemsMap = new Map();
828
833
 
834
+ // 🔥 Option 折扣辅助函数
835
+ var applyDiscountToOptions = function applyDiscountToOptions(options, discount) {
836
+ if (!(options !== null && options !== void 0 && options.length)) return {
837
+ discountedOptions: options,
838
+ optionDiscountAmount: 0
839
+ };
840
+ var optionDiscountAmount = 0;
841
+ var discountedOptions = options.map(function (option) {
842
+ var _ref5, _option$num, _option$_original_add;
843
+ var addPrice = Number(option.add_price || 0);
844
+ if (addPrice <= 0) return option;
845
+ var discountedPrice = getDiscountAmount(discount, addPrice, addPrice);
846
+ var optQty = Number((_ref5 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref5 !== void 0 ? _ref5 : 1);
847
+ optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(addPrice).minus(discountedPrice).mul(optQty)).toNumber();
848
+ return _objectSpread(_objectSpread({}, option), {}, {
849
+ _original_add_price: (_option$_original_add = option._original_add_price) !== null && _option$_original_add !== void 0 ? _option$_original_add : option.add_price,
850
+ add_price: discountedPrice
851
+ });
852
+ });
853
+ return {
854
+ discountedOptions: discountedOptions,
855
+ optionDiscountAmount: optionDiscountAmount
856
+ };
857
+ };
858
+ var restoreOptionPrices = function restoreOptionPrices(options) {
859
+ if (!(options !== null && options !== void 0 && options.length)) return options;
860
+ return options.map(function (option) {
861
+ if (option._original_add_price !== undefined) {
862
+ var _original_add_price = option._original_add_price,
863
+ rest = _objectWithoutProperties(option, _excluded);
864
+ return _objectSpread(_objectSpread({}, rest), {}, {
865
+ add_price: _original_add_price
866
+ });
867
+ }
868
+ return option;
869
+ });
870
+ };
871
+ var getOptionTotal = function getOptionTotal(options) {
872
+ if (!(options !== null && options !== void 0 && options.length)) return 0;
873
+ return options.reduce(function (sum, opt) {
874
+ var _ref6, _opt$add_price, _ref7, _opt$num;
875
+ var unit = Number((_ref6 = (_opt$add_price = opt.add_price) !== null && _opt$add_price !== void 0 ? _opt$add_price : opt.price) !== null && _ref6 !== void 0 ? _ref6 : 0);
876
+ var n = Number((_ref7 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref7 !== void 0 ? _ref7 : 1);
877
+ return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
878
+ }, 0);
879
+ };
880
+
829
881
  // 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
830
882
  // 🔥 使用扁平化后的列表进行处理
831
883
  sortedFlattenedList.forEach(function (flatItem, index) {
@@ -955,8 +1007,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
955
1007
  var _product$discount_lis5, _product11, _product11$every;
956
1008
  // 主商品:判断自身是否手动折扣
957
1009
  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);
1010
+ var _ref8;
1011
+ return !((_ref8 = item.discount_list || []) !== null && _ref8 !== void 0 && _ref8.length);
960
1012
  }) && (!((_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
1013
  return item.type === 'product';
962
1014
  })));
@@ -969,8 +1021,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
969
1021
  if (parentProduct) {
970
1022
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
971
1023
  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);
1024
+ var _ref9;
1025
+ return !((_ref9 = item.discount_list || []) !== null && _ref9 !== void 0 && _ref9.length);
974
1026
  }) && (!((_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
1027
  return item.type === 'product';
976
1028
  })));
@@ -1037,7 +1089,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1037
1089
  // 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
1038
1090
  if (applicableDiscounts.length === 0 || isManualDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1039
1091
  if (flatItem.type === 'main') {
1040
- // 主商品:保持原有逻辑
1092
+ // 主商品:保持原有逻辑,还原 option 价格
1093
+ var restoredOptions = restoreOptionPrices(product.options);
1041
1094
  if (product.isClient) {
1042
1095
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
1043
1096
  origin_total: getProductOriginTotalPrice({
@@ -1045,7 +1098,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1045
1098
  original_price: product.original_price
1046
1099
  },
1047
1100
  bundle: product.bundle,
1048
- options: product.options
1101
+ options: restoredOptions
1049
1102
  }),
1050
1103
  variant: originProduct._productInit.variant,
1051
1104
  original_price: originProduct._productInit.original_price,
@@ -1054,15 +1107,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1054
1107
  price: product.price
1055
1108
  },
1056
1109
  bundle: product.bundle,
1057
- options: product.options
1110
+ options: restoredOptions
1058
1111
  }),
1059
- price: product.price
1112
+ price: product.price,
1113
+ options: restoredOptions
1060
1114
  }), {}, {
1061
1115
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1062
1116
  }))]);
1063
1117
  } 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;
1118
+ var _ref10, _product$_promotion$f, _product12, _product$origin_total;
1119
+ var total = product.inPromotion ? (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1066
1120
  var main_product_selling_price = product.price;
1067
1121
  if ((product.discount_list || []).some(function (item) {
1068
1122
  return item.type === 'promotion';
@@ -1078,7 +1132,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1078
1132
  _id: product._id.split('___')[0] + '___' + index,
1079
1133
  total: total,
1080
1134
  price: product.price,
1081
- main_product_selling_price: main_product_selling_price
1135
+ main_product_selling_price: main_product_selling_price,
1136
+ options: restoredOptions
1082
1137
  }), {}, {
1083
1138
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1084
1139
  }))]);
@@ -1135,7 +1190,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1135
1190
  }));
1136
1191
  }
1137
1192
  for (var i = 0; i < splitCount; i++) {
1138
- var _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1193
+ var _originProduct, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1139
1194
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1140
1195
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1141
1196
  // 标记优惠券为已使用
@@ -1165,27 +1220,46 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1165
1220
  var isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount);
1166
1221
  var orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount.id) : null;
1167
1222
  var productAllocation = orderLevelAllocation === null || orderLevelAllocation === void 0 ? void 0 : orderLevelAllocation.get(flatItem._id);
1168
- var targetProductTotal = void 0;
1223
+ var isDeductOptionPrice = !!((_selectedDiscount$con = _selectedDiscount.config) !== null && _selectedDiscount$con !== void 0 && _selectedDiscount$con.deductOptionPrice);
1224
+
1225
+ // 主商品折后价(不含 option);勿与 option 合计混在同一变量,否则 main_product_selling_price 错误
1226
+ var mainProductSellingPrice = void 0;
1169
1227
  var amount = void 0;
1170
1228
  var productDiscountDifference = void 0;
1229
+ var discountedOptions = product.options;
1230
+ var optionDiscountAmount = 0;
1171
1231
  if (isOrderLevel && productAllocation) {
1172
1232
  // order_level:使用预计算的分摊金额
1173
1233
  amount = productAllocation.discountAmount;
1174
1234
  productDiscountDifference = productAllocation.difference;
1175
- targetProductTotal = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1235
+ mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1176
1236
  } else {
1177
1237
  // item_level 或其他类型:使用原有逻辑
1178
- targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
1179
- amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
1238
+ mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
1239
+ amount = new Decimal(product.price).minus(new Decimal(mainProductSellingPrice)).toNumber();
1240
+ }
1241
+ if (isDeductOptionPrice && (_product$options = product.options) !== null && _product$options !== void 0 && _product$options.length) {
1242
+ var optionResult = applyDiscountToOptions(product.options, _selectedDiscount);
1243
+ discountedOptions = optionResult.discountedOptions;
1244
+ optionDiscountAmount = optionResult.optionDiscountAmount;
1180
1245
  }
1246
+
1247
+ // total = 主商品折后 + option 行合计;开启 option 抵扣时必须用 discountedOptions,不能用未折扣的 product.options 再算一遍
1248
+ var optionsForLineTotal = isDeductOptionPrice && (_product$options2 = product.options) !== null && _product$options2 !== void 0 && _product$options2.length ? discountedOptions : product.options;
1249
+ var optionsLineTotal = getOptionTotal(optionsForLineTotal || []);
1250
+ var _total2 = new Decimal(mainProductSellingPrice).plus(optionsLineTotal).toNumber();
1251
+
1252
+ // discount_list.amount / fixed_amount:行级总优惠 = 主商品优惠 + option 优惠(与 total 变化一致)
1253
+ var mainProductDiscountAmount = amount;
1254
+ var lineDiscountAmount = new Decimal(mainProductDiscountAmount).plus(optionDiscountAmount).toNumber();
1181
1255
  var discountType = _selectedDiscount.tag || _selectedDiscount.type;
1182
1256
  var isGoodPass = discountType === 'good_pass';
1183
1257
  var discountDetail = {
1184
- amount: amount,
1258
+ amount: lineDiscountAmount,
1185
1259
  type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : discountType,
1186
1260
  discount: {
1187
1261
  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,
1262
+ fixed_amount: lineDiscountAmount,
1189
1263
  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
1264
  resource_id: _selectedDiscount.id,
1191
1265
  title: _selectedDiscount.format_title,
@@ -1197,40 +1271,38 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1197
1271
  // 前端使用的num数量,为了计算优惠金额
1198
1272
  _num: isGoodPass ? 1 : product.num,
1199
1273
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1200
- metadata: _objectSpread({
1274
+ metadata: _objectSpread(_objectSpread({
1201
1275
  num: 1
1202
1276
  }, productDiscountDifference !== undefined && {
1203
1277
  product_discount_difference: productDiscountDifference
1278
+ }), {}, {
1279
+ /** 仅主商品上的优惠金额(不含 option) */
1280
+ mainProductDiscountAmount: mainProductDiscountAmount,
1281
+ optionDiscountAmount: optionDiscountAmount
1204
1282
  })
1205
1283
  };
1206
1284
  appliedProducts.push(discountDetail);
1207
1285
  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
1286
 
1217
1287
  // 记录应用了优惠券的商品
1218
1288
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
1219
1289
  if (product.isClient) {
1220
1290
  arr.push(_this3.hooks.setProduct(originProduct, {
1221
1291
  discount_list: [discountDetail],
1222
- price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
1292
+ // good_pass:主商品价以折后价为准;勿用 product.price - amount(amount option 优惠时会算错)
1293
+ price: isGoodPass ? mainProductSellingPrice : product.price,
1223
1294
  quantity: isNeedSplit ? 1 : product.quantity,
1224
1295
  origin_total: getProductOriginTotalPrice({
1225
1296
  product: {
1226
1297
  original_price: product.original_price
1227
1298
  },
1228
1299
  bundle: product.bundle,
1229
- options: product.options
1300
+ options: restoreOptionPrices(product.options)
1230
1301
  }),
1231
1302
  variant: originProduct._productInit.variant,
1232
1303
  original_price: new Decimal(product.price || 0).toNumber(),
1233
- total: _total2
1304
+ total: _total2,
1305
+ options: discountedOptions
1234
1306
  }));
1235
1307
  } else {
1236
1308
  arr.push(_this3.hooks.setProduct(originProduct, {
@@ -1240,7 +1312,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1240
1312
  quantity: isNeedSplit ? 1 : product.quantity,
1241
1313
  total: _total2,
1242
1314
  origin_total: productOriginTotal,
1243
- main_product_selling_price: targetProductTotal
1315
+ main_product_selling_price: mainProductSellingPrice,
1316
+ options: discountedOptions
1244
1317
  }));
1245
1318
  }
1246
1319
  }
@@ -1336,18 +1409,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1336
1409
  var _isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount3);
1337
1410
  var _orderLevelAllocation = _isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount3.id) : null;
1338
1411
  var _productAllocation = _orderLevelAllocation === null || _orderLevelAllocation === void 0 ? void 0 : _orderLevelAllocation.get(flatItem._id);
1339
- var _targetProductTotal;
1412
+ var targetProductTotal;
1340
1413
  var fixedAmountPerItem;
1341
1414
  var _productDiscountDifference;
1342
1415
  if (_isOrderLevel && _productAllocation) {
1343
1416
  // order_level:使用预计算的单价折扣金额(已经是单价,无需再除以数量)
1344
1417
  fixedAmountPerItem = _productAllocation.discountAmount;
1345
1418
  _productDiscountDifference = _productAllocation.difference;
1346
- _targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
1419
+ targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
1347
1420
  } else {
1348
1421
  // item_level 或其他类型:使用原有逻辑
1349
- _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1350
- fixedAmountPerItem = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1422
+ targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1423
+ fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
1351
1424
  }
1352
1425
 
1353
1426
  // 🔥 使用当前的 _id 作为唯一标识
@@ -1382,7 +1455,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1382
1455
  _appliedProducts2.push(_discountDetail2);
1383
1456
  appliedDiscountProducts.set(_selectedDiscount3.id, _appliedProducts2);
1384
1457
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1385
- total: _targetProductTotal,
1458
+ total: targetProductTotal,
1386
1459
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1387
1460
  discount_list: [_discountDetail2],
1388
1461
  processed: true
@@ -1401,8 +1474,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1401
1474
  // 获取主商品处理结果
1402
1475
  var mainProductArr = processedProductsMap.get(product._id);
1403
1476
  if (!mainProductArr || mainProductArr.length === 0) {
1404
- // 如果没有处理结果,返回默认商品
1477
+ // 如果没有处理结果,返回默认商品(还原 option 价格)
1405
1478
  var getDefaultProduct = function getDefaultProduct() {
1479
+ var restoredOptions = restoreOptionPrices(product.options);
1406
1480
  if (product.isClient) {
1407
1481
  return _this3.hooks.setProduct(originProduct, {
1408
1482
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
@@ -1412,7 +1486,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1412
1486
  original_price: product.original_price
1413
1487
  },
1414
1488
  bundle: product.bundle,
1415
- options: product.options
1489
+ options: restoredOptions
1416
1490
  }),
1417
1491
  variant: originProduct._productInit.variant,
1418
1492
  original_price: originProduct._productInit.original_price,
@@ -1421,15 +1495,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1421
1495
  price: product.price
1422
1496
  },
1423
1497
  bundle: product.bundle,
1424
- options: product.options
1425
- })
1498
+ options: restoredOptions
1499
+ }),
1500
+ options: restoredOptions
1426
1501
  });
1427
1502
  } else {
1428
1503
  return _this3.hooks.setProduct(originProduct, {
1429
1504
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1430
1505
  total: product.total,
1431
1506
  origin_total: product.origin_total,
1432
- price: product.price
1507
+ price: product.price,
1508
+ options: restoreOptionPrices(product.options)
1433
1509
  });
1434
1510
  }
1435
1511
  };
@@ -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 {};
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -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() {
@@ -41,8 +41,10 @@ export interface Voucher {
41
41
  allowCrossProduct: boolean;
42
42
  /** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
43
43
  applicableProductLimit: number;
44
- /** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
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
  /**
@@ -50,6 +52,10 @@ export interface Voucher {
50
52
  */
51
53
  export interface Product {
52
54
  product_id: number;
55
+ /** 订单明细 id,参与行唯一键兜底解析 */
56
+ id?: number;
57
+ /** 行级唯一串,参与行唯一键解析 */
58
+ product_unique_string?: string;
53
59
  price: number;
54
60
  quantity: number;
55
61
  name?: string;
@@ -58,9 +64,19 @@ export interface Product {
58
64
  main_product_original_price?: number;
59
65
  /** 主商品折扣后金额,不包含套餐子商品 */
60
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
+ }[];
61
74
  /** 主商品税费 */
62
75
  tax_fee: number;
63
76
  metadata: {
77
+ /** 行唯一标识,优先用于 Wallet Pass 按行配额 */
78
+ product_unique?: string;
79
+ unique_identification_number?: string;
64
80
  main_product_attached_bundle_tax_fee?: number;
65
81
  main_product_attached_bundle_surcharge_fee?: number;
66
82
  surcharge_rounding_remainder?: number;
@@ -129,8 +145,10 @@ export interface EvaluatorInput {
129
145
  allowCrossProduct: boolean;
130
146
  /** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
131
147
  applicableProductLimit: number;
132
- /** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
148
+ /** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
133
149
  maxPassesPerItem: number;
150
+ /** 是否抵扣单规格价格 (Option Price),默认 false */
151
+ deductOptionPrice: boolean;
134
152
  }>[];
135
153
  }
136
154
  /**
@@ -1,4 +1,10 @@
1
1
  import { Product, Voucher } from './type';
2
+ /** 订单商品数量 */
3
+ export declare const getProductQuantity: (product: any) => any;
4
+ /**
5
+ * 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
6
+ */
7
+ export declare function resolveWalletPassLineKey(product: any, indexInOrder: number): string;
2
8
  export declare const getApplicableProductIds: (voucher: Voucher) => number[] | null;
3
9
  /**
4
10
  * 优惠券处理函数
@@ -24,26 +30,20 @@ export declare function recalculateVouchers(allVouchers: any[], selectedVouchers
24
30
  selectedWithDetails: any[];
25
31
  };
26
32
  /**
27
- * 获取主商品价格
33
+ * 获取主商品价格(单价,不含舍入余数)
28
34
  * @param product 商品
29
35
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
30
- * @returns 商品价格
36
+ * @returns 商品单价
31
37
  */
32
38
  export declare const getMainProductPrice: (product: Product, isDeductTaxAndFee: boolean) => number;
33
39
  /**
34
- * 获取套餐子商品价格
40
+ * 获取套餐子商品价格(不含舍入余数)
35
41
  * @param bundleItem 套餐子商品
36
42
  * @param parentQuantity 父商品数量
37
43
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
38
- * @returns 子商品总价格
44
+ * @returns 子商品总价格(不含舍入余数)
39
45
  */
40
46
  export declare const getBundleItemPrice: (bundleItem: any, parentQuantity: number, isDeductTaxAndFee: boolean) => number;
41
- /**
42
- * 获取商品数量
43
- * @param product 商品
44
- * @returns 商品数量
45
- */
46
- export declare const getProductQuantity: (product: any) => any;
47
47
  export declare const getBundleItemIsOriginalPrice: (item: any) => boolean;
48
48
  export declare const getBundleItemIsMarkupPrice: (item: any) => boolean;
49
49
  export declare const getBundleItemIsDiscountPrice: (item: any) => boolean;