@pisell/pisellos 0.0.146 → 0.0.147
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.
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Rules/index.js +2 -0
- package/dist/solution/ShopDiscount/index.js +21 -12
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Rules/index.js +2 -0
- package/lib/solution/ShopDiscount/index.js +20 -12
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ export interface Discount {
|
|
|
62
62
|
applicableProductDetails: ApplicableProductDetails[];
|
|
63
63
|
appliedProductDetails: ApplicableProductDetails[];
|
|
64
64
|
isDisabledForProductUsed?: boolean;
|
|
65
|
+
amount?: number;
|
|
65
66
|
}
|
|
66
67
|
export interface DiscountState {
|
|
67
68
|
discountList: Discount[];
|
|
@@ -282,6 +282,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
282
|
|
|
283
283
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
284
284
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
285
|
+
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
286
|
+
if (Number(product.price) === 0 || !product.price) return false;
|
|
285
287
|
// 如果优惠券已被使用,则跳过
|
|
286
288
|
var targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
287
289
|
if (targetUsedDiscounts && discount.type === 'good_pass') return false;
|
|
@@ -441,18 +441,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
441
441
|
var product = (_this3$hooks = _this3.hooks) === null || _this3$hooks === void 0 ? void 0 : _this3$hooks.getProduct(item);
|
|
442
442
|
(item.discount_list || []).forEach(function (discount) {
|
|
443
443
|
if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
|
|
444
|
-
var
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
444
|
+
var index = editModeDiscountList.findIndex(function (n) {
|
|
445
|
+
return n.id === discount.id;
|
|
446
|
+
});
|
|
447
|
+
if (index !== -1) {
|
|
448
|
+
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
449
|
+
amount: discount.amount + editModeDiscountList[index].amount
|
|
450
|
+
});
|
|
451
|
+
} else {
|
|
452
|
+
var _discount$discount, _discount$discount2, _discount$discount3;
|
|
453
|
+
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
454
|
+
isEditMode: true,
|
|
455
|
+
limited_relation_product_data: {},
|
|
456
|
+
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
457
|
+
isAvailable: true,
|
|
458
|
+
id: ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id,
|
|
459
|
+
format_title: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.title) || discount.format_title,
|
|
460
|
+
isDisabled: true,
|
|
461
|
+
isSelected: true,
|
|
462
|
+
product_id: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.product_id) || discount.product_id
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
456
465
|
}
|
|
457
466
|
});
|
|
458
467
|
}
|
|
@@ -62,6 +62,7 @@ export interface Discount {
|
|
|
62
62
|
applicableProductDetails: ApplicableProductDetails[];
|
|
63
63
|
appliedProductDetails: ApplicableProductDetails[];
|
|
64
64
|
isDisabledForProductUsed?: boolean;
|
|
65
|
+
amount?: number;
|
|
65
66
|
}
|
|
66
67
|
export interface DiscountState {
|
|
67
68
|
discountList: Discount[];
|
|
@@ -191,6 +191,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
194
|
+
if (Number(product.price) === 0 || !product.price)
|
|
195
|
+
return false;
|
|
194
196
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
195
197
|
if (targetUsedDiscounts && discount.type === "good_pass")
|
|
196
198
|
return false;
|
|
@@ -276,18 +276,26 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
276
276
|
(item.discount_list || []).forEach((discount) => {
|
|
277
277
|
var _a3, _b, _c;
|
|
278
278
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
279
|
-
editModeDiscountList.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
279
|
+
const index = editModeDiscountList.findIndex((n) => n.id === discount.id);
|
|
280
|
+
if (index !== -1) {
|
|
281
|
+
editModeDiscountList[index] = {
|
|
282
|
+
...editModeDiscountList[index],
|
|
283
|
+
amount: discount.amount + editModeDiscountList[index].amount
|
|
284
|
+
};
|
|
285
|
+
} else {
|
|
286
|
+
editModeDiscountList.push({
|
|
287
|
+
...discount,
|
|
288
|
+
isEditMode: true,
|
|
289
|
+
limited_relation_product_data: {},
|
|
290
|
+
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
291
|
+
isAvailable: true,
|
|
292
|
+
id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
|
|
293
|
+
format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
|
|
294
|
+
isDisabled: true,
|
|
295
|
+
isSelected: true,
|
|
296
|
+
product_id: ((_c = discount.discount) == null ? void 0 : _c.product_id) || discount.product_id
|
|
297
|
+
});
|
|
298
|
+
}
|
|
291
299
|
}
|
|
292
300
|
});
|
|
293
301
|
}
|