@pisell/pisellos 2.2.23 → 2.2.25
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/Cart/utils/cartProduct.js +21 -4
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.js +3 -3
- package/dist/modules/Discount/types.d.ts +9 -0
- package/dist/modules/Order/utils.js +1 -1
- package/dist/modules/Rules/index.js +401 -102
- package/dist/modules/Summary/utils.d.ts +6 -1
- package/dist/modules/Summary/utils.js +36 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +12 -1
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +241 -114
- package/dist/solution/ShopDiscount/index.js +4 -3
- package/dist/solution/ShopDiscount/utils.d.ts +24 -0
- package/dist/solution/ShopDiscount/utils.js +135 -1
- package/lib/modules/Cart/utils/cartProduct.js +22 -6
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.js +3 -3
- package/lib/modules/Discount/types.d.ts +9 -0
- package/lib/modules/Order/utils.js +1 -1
- package/lib/modules/Rules/index.js +290 -63
- package/lib/modules/Summary/utils.d.ts +6 -1
- package/lib/modules/Summary/utils.js +27 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +12 -1
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +329 -251
- package/lib/solution/ShopDiscount/index.js +6 -6
- package/lib/solution/ShopDiscount/utils.d.ts +24 -0
- package/lib/solution/ShopDiscount/utils.js +88 -1
- package/package.json +1 -1
|
@@ -32,7 +32,8 @@ __export(utils_exports, {
|
|
|
32
32
|
calculateDeposit: () => calculateDeposit,
|
|
33
33
|
calculatePriceDetails: () => calculatePriceDetails,
|
|
34
34
|
calculateSubtotal: () => calculateSubtotal,
|
|
35
|
-
calculateTaxFee: () => calculateTaxFee
|
|
35
|
+
calculateTaxFee: () => calculateTaxFee,
|
|
36
|
+
getBundleDiscountList: () => getBundleDiscountList
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(utils_exports);
|
|
38
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -50,13 +51,35 @@ var calculatePriceDetails = (shopInfo, items) => {
|
|
|
50
51
|
deposit
|
|
51
52
|
};
|
|
52
53
|
};
|
|
54
|
+
var getBundleDiscountList = (bundle) => {
|
|
55
|
+
if (!bundle) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
let discountList = [];
|
|
59
|
+
bundle.forEach((d) => {
|
|
60
|
+
if (d.discount_list && Array.isArray(d.discount_list)) {
|
|
61
|
+
discountList.push(...d.discount_list.filter((item) => !item.id));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return discountList;
|
|
65
|
+
};
|
|
66
|
+
var getProductDiscountProductDiscountDifference = (item) => {
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
const mainDiscountList = ((_b = (_a = item._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
69
|
+
const bundleDiscountList = getBundleDiscountList(((_d = (_c = item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.product_bundle) || []);
|
|
70
|
+
const discountList = [...mainDiscountList, ...bundleDiscountList];
|
|
71
|
+
return discountList.reduce((pre, cur) => {
|
|
72
|
+
return pre + (cur.metadata.product_discount_difference || 0);
|
|
73
|
+
}, 0);
|
|
74
|
+
};
|
|
53
75
|
var calculateSubtotal = (items) => {
|
|
54
76
|
if (!(items == null ? void 0 : items.length)) {
|
|
55
77
|
return "0.00";
|
|
56
78
|
}
|
|
57
79
|
const subtotal = items.reduce((sum, item) => {
|
|
58
80
|
const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
|
|
59
|
-
|
|
81
|
+
const productDiscountProductDiscountDifference = getProductDiscountProductDiscountDifference(item);
|
|
82
|
+
return sum.plus(cartItemTotalPrice).sub(productDiscountProductDiscountDifference);
|
|
60
83
|
}, new import_decimal.default(0));
|
|
61
84
|
return subtotal.toFixed(2);
|
|
62
85
|
};
|
|
@@ -103,5 +126,6 @@ var calculateDeposit = (items) => {
|
|
|
103
126
|
calculateDeposit,
|
|
104
127
|
calculatePriceDetails,
|
|
105
128
|
calculateSubtotal,
|
|
106
|
-
calculateTaxFee
|
|
129
|
+
calculateTaxFee,
|
|
130
|
+
getBundleDiscountList
|
|
107
131
|
});
|
|
@@ -315,6 +315,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
315
315
|
end_at: dayjs.Dayjs;
|
|
316
316
|
count: number;
|
|
317
317
|
left: number;
|
|
318
|
+
summaryCount: number;
|
|
318
319
|
}[];
|
|
319
320
|
/**
|
|
320
321
|
* 找到多个资源的公共可用时间段
|
|
@@ -342,7 +343,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
343
|
};
|
|
343
344
|
setOtherData(key: string, value: any): void;
|
|
344
345
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
346
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
346
347
|
/**
|
|
347
348
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
349
|
*
|
|
@@ -1735,8 +1735,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1735
1735
|
const resourcesUseableMap = {};
|
|
1736
1736
|
let count = 0;
|
|
1737
1737
|
let bookingLeft = 0;
|
|
1738
|
+
let summaryCount = 0;
|
|
1738
1739
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1739
1740
|
let currentResourcesCount = 0;
|
|
1741
|
+
let currentResourcesSummaryCount = 0;
|
|
1740
1742
|
const currentResourcesTimeSlotCanUsedArr = [];
|
|
1741
1743
|
const mTimes = m.times.filter((n) => {
|
|
1742
1744
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
@@ -1764,6 +1766,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1764
1766
|
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1765
1767
|
currentResourcesCount = res.remainingCapacity;
|
|
1766
1768
|
}
|
|
1769
|
+
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
1770
|
+
currentResourcesSummaryCount = res.remainingCapacity;
|
|
1771
|
+
}
|
|
1767
1772
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1768
1773
|
});
|
|
1769
1774
|
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
@@ -1775,6 +1780,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1775
1780
|
}
|
|
1776
1781
|
if (!m.onlyComputed) {
|
|
1777
1782
|
bookingLeft += 1;
|
|
1783
|
+
summaryCount += currentResourcesSummaryCount;
|
|
1778
1784
|
}
|
|
1779
1785
|
}
|
|
1780
1786
|
});
|
|
@@ -1789,6 +1795,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1789
1795
|
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
|
|
1790
1796
|
bookingLeft = 0;
|
|
1791
1797
|
count = 0;
|
|
1798
|
+
summaryCount = 0;
|
|
1792
1799
|
}
|
|
1793
1800
|
const otherCartItems = cartItems2.filter((m) => {
|
|
1794
1801
|
var _a2, _b2, _c2;
|
|
@@ -1814,6 +1821,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1814
1821
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
1815
1822
|
bookingLeft = 0;
|
|
1816
1823
|
count = 0;
|
|
1824
|
+
summaryCount = 0;
|
|
1817
1825
|
}
|
|
1818
1826
|
} else {
|
|
1819
1827
|
const sameCartItems = cartItems2.filter((m) => {
|
|
@@ -1825,6 +1833,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1825
1833
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
1826
1834
|
bookingLeft = 0;
|
|
1827
1835
|
count = 0;
|
|
1836
|
+
summaryCount = 0;
|
|
1828
1837
|
}
|
|
1829
1838
|
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
1830
1839
|
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
@@ -1869,6 +1878,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1869
1878
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
1870
1879
|
bookingLeft = 0;
|
|
1871
1880
|
count = 0;
|
|
1881
|
+
summaryCount = 0;
|
|
1872
1882
|
}
|
|
1873
1883
|
}
|
|
1874
1884
|
});
|
|
@@ -1880,7 +1890,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1880
1890
|
start_at: startDayJs,
|
|
1881
1891
|
end_at: endDayJs,
|
|
1882
1892
|
count,
|
|
1883
|
-
left: bookingLeft
|
|
1893
|
+
left: bookingLeft,
|
|
1894
|
+
summaryCount
|
|
1884
1895
|
};
|
|
1885
1896
|
});
|
|
1886
1897
|
return formatScheduleTimeSlots;
|
|
@@ -20,6 +20,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
20
20
|
private otherParams;
|
|
21
21
|
private logger;
|
|
22
22
|
private calculationCache;
|
|
23
|
+
private syncOrderToBackendInFlightByOrderKey;
|
|
23
24
|
order: OrderModule;
|
|
24
25
|
payment: PaymentModule;
|
|
25
26
|
constructor(name?: string, version?: string);
|