@pisell/pisellos 0.0.483 → 0.0.485

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -15,6 +15,20 @@ import { isNormalProduct } from "../../Product/utils";
15
15
  import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
16
16
  import { calcDiscountListDifference } from "../../Summary/utils";
17
17
 
18
+ /** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
19
+ var toDiscountPayload = function toDiscountPayload(discountItem) {
20
+ var _discountItem$discoun, _discountItem$discoun2;
21
+ return {
22
+ amount: discountItem.amount,
23
+ tag: discountItem.type,
24
+ par_value: (_discountItem$discoun = discountItem.discount) === null || _discountItem$discoun === void 0 ? void 0 : _discountItem$discoun.percent,
25
+ config: discountItem.config,
26
+ metadata: {
27
+ discount_card_type: discountItem === null || discountItem === void 0 || (_discountItem$discoun2 = discountItem.discount) === null || _discountItem$discoun2 === void 0 ? void 0 : _discountItem$discoun2.discount_card_type
28
+ }
29
+ };
30
+ };
31
+
18
32
  /**
19
33
  * @title 处理组合商品
20
34
  * @description 组合商品需要直接修改 product 里的价格和 is_charge_tax
@@ -195,6 +209,7 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
195
209
  * @returns 商品总价
196
210
  */
197
211
  export var getProductTotalPrice = function getProductTotalPrice(params) {
212
+ var _options$map;
198
213
  var product = params.product,
199
214
  bundle = params.bundle,
200
215
  options = params.options,
@@ -202,23 +217,29 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
202
217
  // const num = params.num || 1;
203
218
  var price = Number(product.price);
204
219
 
220
+ // option 行:unit 折后价在循环中与主商品使用同一套 getDiscountAmount(含 deductOptionPrice)
221
+ var optionRows = (_options$map = options === null || options === void 0 ? void 0 : options.map(function (currentValue) {
222
+ var _ref, _currentValue$price, _ref2, _currentValue$num;
223
+ return {
224
+ unit: Number((_ref = (_currentValue$price = currentValue.price) !== null && _currentValue$price !== void 0 ? _currentValue$price : currentValue.add_price) !== null && _ref !== void 0 ? _ref : 0),
225
+ num: Number((_ref2 = (_currentValue$num = currentValue.num) !== null && _currentValue$num !== void 0 ? _currentValue$num : currentValue.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1)
226
+ };
227
+ })) !== null && _options$map !== void 0 ? _options$map : [];
228
+
205
229
  // 如果商品有折扣,则计算折扣
206
230
  if (discounts !== null && discounts !== void 0 && discounts.length) {
207
231
  discounts.forEach(function (currentValue) {
208
- var _currentValue$discoun;
209
- // 不是商品券则代表折扣卡,计算打折后的价格
210
- // 一个商品折扣卡只能存在于一张
211
- // if (currentValue.type !== 'good_pass') {
212
- price = getDiscountAmount({
213
- amount: currentValue.amount,
214
- tag: currentValue.type,
215
- par_value: currentValue.discount.percent,
216
- config: currentValue.config,
217
- metadata: {
218
- discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
232
+ var _currentValue$config;
233
+ var payload = toDiscountPayload(currentValue);
234
+ price = getDiscountAmount(payload, price, price);
235
+ if (currentValue !== null && currentValue !== void 0 && (_currentValue$config = currentValue.config) !== null && _currentValue$config !== void 0 && _currentValue$config.deductOptionPrice && optionRows.length) {
236
+ for (var i = 0; i < optionRows.length; i++) {
237
+ var row = optionRows[i];
238
+ optionRows[i] = _objectSpread(_objectSpread({}, row), {}, {
239
+ unit: getDiscountAmount(payload, row.unit, row.unit)
240
+ });
219
241
  }
220
- }, price, price);
221
- // }
242
+ }
222
243
  });
223
244
  }
224
245
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -227,10 +248,10 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
227
248
  }, price);
228
249
  }
229
250
 
230
- // 单规格
231
- if (options !== null && options !== void 0 && options.length) {
232
- price = options.reduce(function (accumulator, currentValue) {
233
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
251
+ // 单规格 / 加购 option
252
+ if (optionRows.length) {
253
+ price = optionRows.reduce(function (accumulator, row) {
254
+ return accumulator + row.unit * row.num;
234
255
  }, price);
235
256
  }
236
257
  return Math.max(0, price);
@@ -389,11 +410,11 @@ export var getProductDeposit = function getProductDeposit(params) {
389
410
  // 判定商品是否有定金规则
390
411
  if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
391
412
  var total = new Decimal(0);
392
- var _ref = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
393
- deposit_fixed = _ref.deposit_fixed,
394
- deposit_percentage = _ref.deposit_percentage,
395
- deposit_policy_data = _ref.deposit_policy_data,
396
- self_deposit_policy_ids = _ref.self_deposit_policy_ids;
413
+ var _ref3 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
414
+ deposit_fixed = _ref3.deposit_fixed,
415
+ deposit_percentage = _ref3.deposit_percentage,
416
+ deposit_policy_data = _ref3.deposit_policy_data,
417
+ self_deposit_policy_ids = _ref3.self_deposit_policy_ids;
397
418
  // 所有协议数据
398
419
  var allProtocols = deposit_policy_data || [];
399
420
  // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
@@ -487,9 +508,9 @@ export var handleProductDeposit = function handleProductDeposit(params) {
487
508
  depositTotal: new Decimal(0)
488
509
  };
489
510
  }
490
- var _ref2 = depositData || {},
491
- deposit_fixed = _ref2.deposit_fixed,
492
- deposit_percentage = _ref2.deposit_percentage;
511
+ var _ref4 = depositData || {},
512
+ deposit_fixed = _ref4.deposit_fixed,
513
+ deposit_percentage = _ref4.deposit_percentage;
493
514
  if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
494
515
  var depositFixed = Decimal(deposit_fixed || 0);
495
516
  var depositPercent = Decimal(deposit_percentage || 0);
@@ -1,4 +1,5 @@
1
- var _excluded = ["_original_add_price"];
1
+ var _excluded = ["_original_add_price"],
2
+ _excluded2 = ["_original_price", "_original_add_price"];
2
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); }
3
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; }
4
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; }
@@ -943,15 +944,21 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
943
944
  };
944
945
  var optionDiscountAmount = 0;
945
946
  var discountedOptions = options.map(function (option) {
946
- var _ref6, _option$num, _option$_original_add;
947
- var addPrice = Number(option.add_price || 0);
948
- if (addPrice <= 0) return option;
949
- var discountedPrice = getDiscountAmount(discount, addPrice, addPrice);
950
- var optQty = Number((_ref6 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1);
951
- optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(addPrice).minus(discountedPrice).mul(optQty)).toNumber();
952
- return _objectSpread(_objectSpread({}, option), {}, {
953
- _original_add_price: (_option$_original_add = option._original_add_price) !== null && _option$_original_add !== void 0 ? _option$_original_add : option.add_price,
954
- add_price: discountedPrice
947
+ var _ref6, _ref7, _option$_original_pri, _ref8, _option$num, _rest$price, _option$_original_pri2;
948
+ // 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
949
+ var rawUnit = (_ref6 = (_ref7 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref7 !== void 0 ? _ref7 : option.price) !== null && _ref6 !== void 0 ? _ref6 : option.add_price;
950
+ var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
951
+ if (baseUnitNum <= 0) return option;
952
+ var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
953
+ var optQty = Number((_ref8 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref8 !== void 0 ? _ref8 : 1);
954
+ optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
955
+ var _original_add_price = option._original_add_price,
956
+ rest = _objectWithoutProperties(option, _excluded);
957
+ var tmpl = (_rest$price = rest.price) !== null && _rest$price !== void 0 ? _rest$price : rest.add_price;
958
+ var nextPrice = typeof tmpl === 'string' ? String(discountedPrice) : discountedPrice;
959
+ return _objectSpread(_objectSpread({}, rest), {}, {
960
+ _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,
961
+ price: nextPrice
955
962
  });
956
963
  });
957
964
  return {
@@ -962,11 +969,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
962
969
  var restoreOptionPrices = function restoreOptionPrices(options) {
963
970
  if (!(options !== null && options !== void 0 && options.length)) return options;
964
971
  return options.map(function (option) {
965
- if (option._original_add_price !== undefined) {
966
- var _original_add_price = option._original_add_price,
967
- rest = _objectWithoutProperties(option, _excluded);
972
+ var orig = option._original_price !== undefined ? option._original_price : option._original_add_price;
973
+ if (orig !== undefined) {
974
+ var _original_price = option._original_price,
975
+ _original_add_price = option._original_add_price,
976
+ rest = _objectWithoutProperties(option, _excluded2);
968
977
  return _objectSpread(_objectSpread({}, rest), {}, {
969
- add_price: _original_add_price
978
+ price: orig
970
979
  });
971
980
  }
972
981
  return option;
@@ -975,9 +984,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
975
984
  var getOptionTotal = function getOptionTotal(options) {
976
985
  if (!(options !== null && options !== void 0 && options.length)) return 0;
977
986
  return options.reduce(function (sum, opt) {
978
- var _ref7, _opt$add_price, _ref8, _opt$num;
979
- var unit = Number((_ref7 = (_opt$add_price = opt.add_price) !== null && _opt$add_price !== void 0 ? _opt$add_price : opt.price) !== null && _ref7 !== void 0 ? _ref7 : 0);
980
- var n = Number((_ref8 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref8 !== void 0 ? _ref8 : 1);
987
+ var _ref9, _opt$price, _ref10, _opt$num;
988
+ var unit = Number((_ref9 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
989
+ var n = Number((_ref10 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1);
981
990
  return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
982
991
  }, 0);
983
992
  };
@@ -1124,8 +1133,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1124
1133
  var _product$discount_lis5, _product12, _product12$every;
1125
1134
  // 主商品:判断自身是否手动折扣
1126
1135
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
1127
- var _ref9;
1128
- return !((_ref9 = item.discount_list || []) !== null && _ref9 !== void 0 && _ref9.length);
1136
+ var _ref11;
1137
+ return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
1129
1138
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
1130
1139
  return item.type === 'product';
1131
1140
  })));
@@ -1138,8 +1147,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1138
1147
  if (parentProduct) {
1139
1148
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
1140
1149
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
1141
- var _ref10;
1142
- return !((_ref10 = item.discount_list || []) !== null && _ref10 !== void 0 && _ref10.length);
1150
+ var _ref12;
1151
+ return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1143
1152
  }) && (!((_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) {
1144
1153
  return item.type === 'product';
1145
1154
  })));
@@ -1232,8 +1241,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1232
1241
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1233
1242
  }))]);
1234
1243
  } else {
1235
- var _ref11, _product$_promotion$f, _product13, _product$origin_total, _product$price2;
1236
- var total = product.inPromotion ? (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1244
+ var _ref13, _product$_promotion$f, _product13, _product$origin_total, _product$price2;
1245
+ var total = product.inPromotion ? (_ref13 = (_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 && _ref13 !== void 0 ? _ref13 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1237
1246
  var main_product_selling_price = (_product$price2 = product.price) !== null && _product$price2 !== void 0 ? _product$price2 : product.main_product_selling_price;
1238
1247
  if ((product.discount_list || []).some(function (item) {
1239
1248
  return item.type === 'promotion';
@@ -46,6 +46,18 @@ var import_decimal = __toESM(require("decimal.js"));
46
46
  var import_utils = require("../../Product/utils");
47
47
  var import_utils2 = require("../../../solution/ShopDiscount/utils");
48
48
  var import_utils3 = require("../../Summary/utils");
49
+ var toDiscountPayload = (discountItem) => {
50
+ var _a, _b;
51
+ return {
52
+ amount: discountItem.amount,
53
+ tag: discountItem.type,
54
+ par_value: (_a = discountItem.discount) == null ? void 0 : _a.percent,
55
+ config: discountItem.config,
56
+ metadata: {
57
+ discount_card_type: (_b = discountItem == null ? void 0 : discountItem.discount) == null ? void 0 : _b.discount_card_type
58
+ }
59
+ };
60
+ };
49
61
  var handleVariantProduct = (product) => {
50
62
  var _a;
51
63
  if (product == null ? void 0 : product.product_variant_id) {
@@ -192,18 +204,24 @@ var formatProductToCartItemOrigin = (params) => {
192
204
  var getProductTotalPrice = (params) => {
193
205
  const { product, bundle, options, discounts } = params;
194
206
  let price = Number(product.price);
207
+ const optionRows = (options == null ? void 0 : options.map((currentValue) => ({
208
+ unit: Number(currentValue.price ?? currentValue.add_price ?? 0),
209
+ num: Number(currentValue.num ?? currentValue.quantity ?? 1)
210
+ }))) ?? [];
195
211
  if (discounts == null ? void 0 : discounts.length) {
196
212
  discounts.forEach((currentValue) => {
197
213
  var _a;
198
- price = (0, import_utils2.getDiscountAmount)({
199
- amount: currentValue.amount,
200
- tag: currentValue.type,
201
- par_value: currentValue.discount.percent,
202
- config: currentValue.config,
203
- metadata: {
204
- discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
214
+ const payload = toDiscountPayload(currentValue);
215
+ price = (0, import_utils2.getDiscountAmount)(payload, price, price);
216
+ if (((_a = currentValue == null ? void 0 : currentValue.config) == null ? void 0 : _a.deductOptionPrice) && optionRows.length) {
217
+ for (let i = 0; i < optionRows.length; i++) {
218
+ const row = optionRows[i];
219
+ optionRows[i] = {
220
+ ...row,
221
+ unit: (0, import_utils2.getDiscountAmount)(payload, row.unit, row.unit)
222
+ };
205
223
  }
206
- }, price, price);
224
+ }
207
225
  });
208
226
  }
209
227
  if (bundle == null ? void 0 : bundle.length) {
@@ -211,10 +229,11 @@ var getProductTotalPrice = (params) => {
211
229
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
212
230
  }, price);
213
231
  }
214
- if (options == null ? void 0 : options.length) {
215
- price = options.reduce((accumulator, currentValue) => {
216
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
217
- }, price);
232
+ if (optionRows.length) {
233
+ price = optionRows.reduce(
234
+ (accumulator, row) => accumulator + row.unit * row.num,
235
+ price
236
+ );
218
237
  }
219
238
  return Math.max(0, price);
220
239
  };
@@ -641,16 +641,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
641
641
  return { discountedOptions: options2, optionDiscountAmount: 0 };
642
642
  let optionDiscountAmount = 0;
643
643
  const discountedOptions = options2.map((option) => {
644
- const addPrice = Number(option.add_price || 0);
645
- if (addPrice <= 0)
644
+ const rawUnit = option._original_price ?? option._original_add_price ?? option.price ?? option.add_price;
645
+ const baseUnitNum = Number(rawUnit ?? 0);
646
+ if (baseUnitNum <= 0)
646
647
  return option;
647
- const discountedPrice = (0, import_utils.getDiscountAmount)(discount, addPrice, addPrice);
648
+ const discountedPrice = (0, import_utils.getDiscountAmount)(discount, baseUnitNum, baseUnitNum);
648
649
  const optQty = Number(option.num ?? option.quantity ?? 1);
649
- optionDiscountAmount = new import_decimal.default(optionDiscountAmount).plus(new import_decimal.default(addPrice).minus(discountedPrice).mul(optQty)).toNumber();
650
+ optionDiscountAmount = new import_decimal.default(optionDiscountAmount).plus(new import_decimal.default(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
651
+ const { _original_add_price, ...rest } = option;
652
+ const tmpl = rest.price ?? rest.add_price;
653
+ const nextPrice = typeof tmpl === "string" ? String(discountedPrice) : discountedPrice;
650
654
  return {
651
- ...option,
652
- _original_add_price: option._original_add_price ?? option.add_price,
653
- add_price: discountedPrice
655
+ ...rest,
656
+ _original_price: option._original_price ?? (_original_add_price !== void 0 ? _original_add_price : rawUnit),
657
+ price: nextPrice
654
658
  };
655
659
  });
656
660
  return { discountedOptions, optionDiscountAmount };
@@ -659,9 +663,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
659
663
  if (!(options2 == null ? void 0 : options2.length))
660
664
  return options2;
661
665
  return options2.map((option) => {
662
- if (option._original_add_price !== void 0) {
663
- const { _original_add_price, ...rest } = option;
664
- return { ...rest, add_price: _original_add_price };
666
+ const orig = option._original_price !== void 0 ? option._original_price : option._original_add_price;
667
+ if (orig !== void 0) {
668
+ const { _original_price, _original_add_price, ...rest } = option;
669
+ return { ...rest, price: orig };
665
670
  }
666
671
  return option;
667
672
  });
@@ -670,7 +675,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
670
675
  if (!(options2 == null ? void 0 : options2.length))
671
676
  return 0;
672
677
  return options2.reduce((sum, opt) => {
673
- const unit = Number(opt.add_price ?? opt.price ?? 0);
678
+ const unit = Number(opt.price ?? opt.add_price ?? 0);
674
679
  const n = Number(opt.num ?? opt.quantity ?? 1);
675
680
  return new import_decimal.default(sum).plus(new import_decimal.default(unit).mul(n)).toNumber();
676
681
  }, 0);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.483",
4
+ "version": "0.0.485",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",