@pisell/pisellos 0.0.459 → 0.0.461
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 +21 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +1 -0
- package/dist/solution/ShopDiscount/index.js +10 -4
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Rules/index.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +2 -0
- package/lib/solution/ShopDiscount/index.js +14 -6
- package/package.json +1 -1
|
@@ -83,6 +83,7 @@ export interface Discount {
|
|
|
83
83
|
balance: string;
|
|
84
84
|
format_title: Formattitle;
|
|
85
85
|
metadata?: {
|
|
86
|
+
num?: number;
|
|
86
87
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
87
88
|
custom_product_bundle_map_id?: string;
|
|
88
89
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
@@ -627,6 +627,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
627
627
|
// 🔥 统计每张折扣卡的 applicableProductLimit 已使用次数(跨商品全局计数)
|
|
628
628
|
var usedDiscountCardLimitCounts = new Map();
|
|
629
629
|
|
|
630
|
+
// 🔥 预先将 editModeDiscount 中的折扣卡计入 applicableProductLimit 已使用次数
|
|
631
|
+
editModeDiscount.forEach(function (discount) {
|
|
632
|
+
var discountType = discount.tag || discount.type;
|
|
633
|
+
if (['discount_card', 'product_discount_card'].includes(discountType)) {
|
|
634
|
+
var _discount$metadata4;
|
|
635
|
+
var currentCount = usedDiscountCardLimitCounts.get(discount.id) || 0;
|
|
636
|
+
usedDiscountCardLimitCounts.set(discount.id, currentCount + (((_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.num) || 1));
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
|
|
630
640
|
// 记录每个优惠券适用的商品ID
|
|
631
641
|
var discountApplicability = new Map();
|
|
632
642
|
|
|
@@ -881,7 +891,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
881
891
|
|
|
882
892
|
// 判断优惠券是否适用于该商品
|
|
883
893
|
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
884
|
-
var _discountApplicabilit, _discount$
|
|
894
|
+
var _discountApplicabilit, _discount$metadata5, _discount$metadata6;
|
|
885
895
|
// 记录此优惠券适用的商品
|
|
886
896
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
887
897
|
|
|
@@ -897,9 +907,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
897
907
|
type: discountType,
|
|
898
908
|
tag: discountType,
|
|
899
909
|
discount: {
|
|
900
|
-
discount_card_type: discount === null || discount === void 0 || (_discount$
|
|
910
|
+
discount_card_type: discount === null || discount === void 0 || (_discount$metadata5 = discount.metadata) === null || _discount$metadata5 === void 0 ? void 0 : _discount$metadata5.discount_card_type,
|
|
901
911
|
fixed_amount: product.price,
|
|
902
|
-
discount_calculation_mode: discount === null || discount === void 0 || (_discount$
|
|
912
|
+
discount_calculation_mode: discount === null || discount === void 0 || (_discount$metadata6 = discount.metadata) === null || _discount$metadata6 === void 0 ? void 0 : _discount$metadata6.discount_calculation_mode,
|
|
903
913
|
resource_id: discount.id,
|
|
904
914
|
title: discount.format_title,
|
|
905
915
|
original_amount: product.price || product.origin_total,
|
|
@@ -1687,8 +1697,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1687
1697
|
|
|
1688
1698
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=1)
|
|
1689
1699
|
var updatedMainDiscountList = mainProductData.discount_list.map(function (discount) {
|
|
1690
|
-
var _discount$
|
|
1691
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1700
|
+
var _discount$metadata7, _discount$metadata8;
|
|
1701
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata7 = discount.metadata) !== null && _discount$metadata7 !== void 0 && _discount$metadata7.custom_product_bundle_map_id) {
|
|
1692
1702
|
// bundle的discount_list保持不变
|
|
1693
1703
|
return discount;
|
|
1694
1704
|
}
|
|
@@ -1696,7 +1706,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1696
1706
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1697
1707
|
// num: 1,
|
|
1698
1708
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1699
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1709
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata8 = discount.metadata) === null || _discount$metadata8 === void 0 ? void 0 : _discount$metadata8.custom_product_bundle_map_id,
|
|
1700
1710
|
num: 1
|
|
1701
1711
|
})
|
|
1702
1712
|
});
|
|
@@ -1761,8 +1771,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1761
1771
|
|
|
1762
1772
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=原quantity-1)
|
|
1763
1773
|
var updatedMainDiscountListOriginal = mainProductData.discount_list.map(function (discount) {
|
|
1764
|
-
var _discount$
|
|
1765
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1774
|
+
var _discount$metadata9, _discount$metadata10;
|
|
1775
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata9 = discount.metadata) !== null && _discount$metadata9 !== void 0 && _discount$metadata9.custom_product_bundle_map_id) {
|
|
1766
1776
|
// bundle的discount_list保持不变
|
|
1767
1777
|
return discount;
|
|
1768
1778
|
}
|
|
@@ -1770,7 +1780,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1770
1780
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1771
1781
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1772
1782
|
num: mainProductQuantity - 1,
|
|
1773
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1783
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata10 = discount.metadata) === null || _discount$metadata10 === void 0 ? void 0 : _discount$metadata10.custom_product_bundle_map_id
|
|
1774
1784
|
})
|
|
1775
1785
|
// num: mainProductQuantity - 1,
|
|
1776
1786
|
});
|
|
@@ -1835,11 +1845,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1835
1845
|
processedBundleItems.forEach(function (item) {
|
|
1836
1846
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1837
1847
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1838
|
-
var _discount$
|
|
1848
|
+
var _discount$metadata11;
|
|
1839
1849
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1840
1850
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1841
1851
|
num: item.num,
|
|
1842
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1852
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata11 = discount.metadata) === null || _discount$metadata11 === void 0 ? void 0 : _discount$metadata11.custom_product_bundle_map_id
|
|
1843
1853
|
})
|
|
1844
1854
|
// num: item.num, // 使用拆分后的 num
|
|
1845
1855
|
});
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 | 3 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -2390,6 +2390,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2390
2390
|
// 计算容量的辅助函数
|
|
2391
2391
|
calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2392
2392
|
var _items$0$_resourceOri2;
|
|
2393
|
+
if (items.length === 0) return 0;
|
|
2393
2394
|
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2394
2395
|
var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
|
|
2395
2396
|
var sameResourceLength = items.filter(function (item) {
|
|
@@ -618,21 +618,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
618
618
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
619
619
|
});
|
|
620
620
|
if (index !== -1) {
|
|
621
|
-
var _discount$metadata;
|
|
621
|
+
var _editModeDiscountList, _discount$metadata, _discount$metadata2;
|
|
622
622
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
623
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
624
|
+
num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
|
|
625
|
+
}),
|
|
623
626
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
624
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
627
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
625
628
|
});
|
|
626
629
|
} else {
|
|
627
|
-
var _discount$
|
|
630
|
+
var _discount$metadata3, _discount$metadata4, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
628
631
|
if (discount.type && !discount.tag) {
|
|
629
632
|
discount.tag = discount.type;
|
|
630
633
|
}
|
|
631
634
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
635
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
636
|
+
num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
|
|
637
|
+
}),
|
|
632
638
|
name: discount.name || discount.discount.title.auto,
|
|
633
639
|
isEditMode: true,
|
|
634
640
|
limited_relation_product_data: {},
|
|
635
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
641
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.product_discount_difference) || 0).toNumber(),
|
|
636
642
|
isAvailable: true,
|
|
637
643
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
638
644
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -83,6 +83,7 @@ export interface Discount {
|
|
|
83
83
|
balance: string;
|
|
84
84
|
format_title: Formattitle;
|
|
85
85
|
metadata?: {
|
|
86
|
+
num?: number;
|
|
86
87
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
87
88
|
custom_product_bundle_map_id?: string;
|
|
88
89
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
@@ -418,6 +418,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
418
418
|
const usedDiscounts = /* @__PURE__ */ new Map();
|
|
419
419
|
const usedProductIdCounts = /* @__PURE__ */ new Map();
|
|
420
420
|
const usedDiscountCardLimitCounts = /* @__PURE__ */ new Map();
|
|
421
|
+
editModeDiscount.forEach((discount) => {
|
|
422
|
+
var _a;
|
|
423
|
+
const discountType = discount.tag || discount.type;
|
|
424
|
+
if (["discount_card", "product_discount_card"].includes(discountType)) {
|
|
425
|
+
const currentCount = usedDiscountCardLimitCounts.get(discount.id) || 0;
|
|
426
|
+
usedDiscountCardLimitCounts.set(discount.id, currentCount + (((_a = discount.metadata) == null ? void 0 : _a.num) || 1));
|
|
427
|
+
}
|
|
428
|
+
});
|
|
421
429
|
const discountApplicability = /* @__PURE__ */ new Map();
|
|
422
430
|
const discountApplicableProducts = /* @__PURE__ */ new Map();
|
|
423
431
|
addModeDiscount.forEach((discount) => {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 | 3 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -1670,6 +1670,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1670
1670
|
}
|
|
1671
1671
|
const calculateCapacityFromCartItems = (items) => {
|
|
1672
1672
|
var _a2;
|
|
1673
|
+
if (items.length === 0)
|
|
1674
|
+
return 0;
|
|
1673
1675
|
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1674
1676
|
const sameResourceLength = items.filter((item) => {
|
|
1675
1677
|
var _a3;
|
|
@@ -394,7 +394,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
394
394
|
if (item.booking_id) {
|
|
395
395
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
396
396
|
(item.discount_list || []).forEach((discount) => {
|
|
397
|
-
var _a3, _b, _c, _d, _e;
|
|
397
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
398
398
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
399
399
|
const index = editModeDiscountList.findIndex((n) => {
|
|
400
400
|
var _a4;
|
|
@@ -403,8 +403,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
403
403
|
if (index !== -1) {
|
|
404
404
|
editModeDiscountList[index] = {
|
|
405
405
|
...editModeDiscountList[index],
|
|
406
|
+
metadata: {
|
|
407
|
+
...discount.metadata || {},
|
|
408
|
+
num: (((_b = (_a3 = editModeDiscountList == null ? void 0 : editModeDiscountList[index]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b.num) || 1) + (((_c = discount.metadata) == null ? void 0 : _c.num) || 1)
|
|
409
|
+
},
|
|
406
410
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
407
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
411
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
408
412
|
};
|
|
409
413
|
} else {
|
|
410
414
|
if (discount.type && !discount.tag) {
|
|
@@ -412,16 +416,20 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
412
416
|
}
|
|
413
417
|
editModeDiscountList.push({
|
|
414
418
|
...discount,
|
|
419
|
+
metadata: {
|
|
420
|
+
...discount.metadata || {},
|
|
421
|
+
num: ((_e = discount.metadata) == null ? void 0 : _e.num) || 1
|
|
422
|
+
},
|
|
415
423
|
name: discount.name || discount.discount.title.auto,
|
|
416
424
|
isEditMode: true,
|
|
417
425
|
limited_relation_product_data: {},
|
|
418
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
426
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_f = discount == null ? void 0 : discount.metadata) == null ? void 0 : _f.product_discount_difference) || 0).toNumber(),
|
|
419
427
|
isAvailable: true,
|
|
420
|
-
id: ((
|
|
421
|
-
format_title: ((
|
|
428
|
+
id: ((_g = discount.discount) == null ? void 0 : _g.resource_id) || discount.id,
|
|
429
|
+
format_title: ((_h = discount.discount) == null ? void 0 : _h.title) || discount.format_title,
|
|
422
430
|
isDisabled: true,
|
|
423
431
|
isSelected: true,
|
|
424
|
-
product_id: ((
|
|
432
|
+
product_id: ((_i = discount.discount) == null ? void 0 : _i.product_id) || discount.product_id
|
|
425
433
|
});
|
|
426
434
|
}
|
|
427
435
|
}
|