@pisell/pisellos 2.0.42 → 2.0.44

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.
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -71,7 +71,8 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
71
71
  product: product,
72
72
  bundle: bundle,
73
73
  options: options,
74
- num: num
74
+ num: num,
75
+ discounts: discounts
75
76
  });
76
77
  cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
77
78
  cartItem.like_status = 'common';
@@ -206,10 +207,11 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
206
207
  export var getProductOriginTotalPrice = function getProductOriginTotalPrice(params) {
207
208
  var product = params.product,
208
209
  bundle = params.bundle,
209
- options = params.options;
210
+ options = params.options,
211
+ discounts = params.discounts;
210
212
  var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
211
213
  var price = Number(product.original_price);
212
- if (isNaN(price) || price === 0) {
214
+ if ((isNaN(price) || price === 0) && !(discounts !== null && discounts !== void 0 && discounts.length)) {
213
215
  return undefined;
214
216
  }
215
217
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -330,7 +330,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
330
330
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
331
331
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
332
332
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
333
- if (Number(product.price) === 0 || !product.price) return false;
333
+ if (Number(product.price) === 0 && discount.tag === 'good_pass' || Number(product.total) === 0 && discount.tag !== 'good_pass' || !product.price) return false;
334
334
  // 如果优惠券已被使用,则跳过
335
335
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
336
336
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
@@ -504,7 +504,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
504
504
  return n.id === id;
505
505
  });
506
506
  var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
507
- return Number(product === null || product === void 0 ? void 0 : product.price) === 0;
507
+ return Number(product === null || product === void 0 ? void 0 : product.total) === 0;
508
508
  };
509
509
  var isAllProductUsedOrFree = (_item$applicableProdu = item.applicableProductIds) === null || _item$applicableProdu === void 0 ? void 0 : _item$applicableProdu.every(function (id) {
510
510
  var _item$applicableProdu2;
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -82,7 +82,8 @@ var formatProductToCartItem = (params) => {
82
82
  product,
83
83
  bundle,
84
84
  options,
85
- num
85
+ num,
86
+ discounts
86
87
  });
87
88
  cartItem.image = product == null ? void 0 : product.cover;
88
89
  cartItem.like_status = "common";
@@ -189,10 +190,10 @@ var getProductTotalPrice = (params) => {
189
190
  return price;
190
191
  };
191
192
  var getProductOriginTotalPrice = (params) => {
192
- const { product, bundle, options } = params;
193
+ const { product, bundle, options, discounts } = params;
193
194
  const num = (params == null ? void 0 : params.num) || 1;
194
195
  let price = Number(product.original_price);
195
- if (isNaN(price) || price === 0) {
196
+ if ((isNaN(price) || price === 0) && !(discounts == null ? void 0 : discounts.length)) {
196
197
  return void 0;
197
198
  }
198
199
  if (bundle == null ? void 0 : bundle.length) {
@@ -213,7 +213,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
213
213
  return;
214
214
  }
215
215
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
216
- if (Number(product.price) === 0 || !product.price)
216
+ if (Number(product.price) === 0 && discount.tag === "good_pass" || Number(product.total) === 0 && discount.tag !== "good_pass" || !product.price)
217
217
  return false;
218
218
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
219
219
  if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
@@ -346,7 +346,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
346
346
  var _a3;
347
347
  const targetProduct = productList.find((n) => n.id === id);
348
348
  const product = (_a3 = this.hooks) == null ? void 0 : _a3.getProduct(targetProduct);
349
- return Number(product == null ? void 0 : product.price) === 0;
349
+ return Number(product == null ? void 0 : product.total) === 0;
350
350
  };
351
351
  const isAllProductUsedOrFree = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
352
352
  var _a3;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.42",
4
+ "version": "2.0.44",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",