@pisell/pisellos 0.0.338 → 0.0.340
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 +34 -19
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +9 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +7 -0
- package/dist/modules/Rules/index.js +844 -170
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/solution/ShopDiscount/index.js +7 -5
- package/dist/solution/ShopDiscount/utils.d.ts +7 -0
- package/dist/solution/ShopDiscount/utils.js +19 -3
- package/lib/modules/Cart/utils/cartProduct.js +32 -17
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/Order/index.js +2 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +11 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +7 -0
- package/lib/modules/Rules/index.js +697 -159
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/solution/BookingTicket/index.js +0 -6
- package/lib/solution/ShopDiscount/index.js +10 -8
- package/lib/solution/ShopDiscount/utils.d.ts +7 -0
- package/lib/solution/ShopDiscount/utils.js +17 -3
- package/package.json +1 -1
|
@@ -50,8 +50,9 @@ export interface RulesParamsHooks {
|
|
|
50
50
|
origin_total?: number;
|
|
51
51
|
price?: string | number;
|
|
52
52
|
variant?: any[];
|
|
53
|
-
original_price?: number;
|
|
53
|
+
original_price?: number | string;
|
|
54
54
|
quantity?: number;
|
|
55
|
+
bundle?: any[];
|
|
55
56
|
}) => Record<string, any>;
|
|
56
57
|
}
|
|
57
58
|
export {};
|
|
@@ -122,12 +122,6 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
122
122
|
throw error;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
126
|
-
* 初始化外设扫码结果监听
|
|
127
|
-
*/
|
|
128
|
-
initPeripheralsListener() {
|
|
129
|
-
this.scan.initPeripheralsListener();
|
|
130
|
-
}
|
|
131
125
|
/**
|
|
132
126
|
* 获取商品列表(不加载到模块中)
|
|
133
127
|
* @returns 商品列表
|
|
@@ -342,7 +342,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
342
|
if (item.booking_id) {
|
|
343
343
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
344
344
|
(item.discount_list || []).forEach((discount) => {
|
|
345
|
-
var _a3, _b, _c;
|
|
345
|
+
var _a3, _b, _c, _d, _e;
|
|
346
346
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
347
347
|
const index = editModeDiscountList.findIndex((n) => {
|
|
348
348
|
var _a4;
|
|
@@ -352,7 +352,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
352
352
|
editModeDiscountList[index] = {
|
|
353
353
|
...editModeDiscountList[index],
|
|
354
354
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
355
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
355
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.num) || (product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
356
356
|
};
|
|
357
357
|
} else {
|
|
358
358
|
if (discount.type && !discount.tag) {
|
|
@@ -363,13 +363,13 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
363
363
|
name: discount.name || discount.discount.title.auto,
|
|
364
364
|
isEditMode: true,
|
|
365
365
|
limited_relation_product_data: {},
|
|
366
|
-
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
366
|
+
savedAmount: discount.amount * (((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.num) || (product == null ? void 0 : product.num) || 1),
|
|
367
367
|
isAvailable: true,
|
|
368
|
-
id: ((
|
|
369
|
-
format_title: ((
|
|
368
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
369
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
370
370
|
isDisabled: true,
|
|
371
371
|
isSelected: true,
|
|
372
|
-
product_id: ((
|
|
372
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
373
373
|
});
|
|
374
374
|
}
|
|
375
375
|
}
|
|
@@ -383,15 +383,17 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
383
383
|
const isProductFree = (id) => {
|
|
384
384
|
var _a2;
|
|
385
385
|
const targetProduct = productList.find((n) => n.id === id);
|
|
386
|
+
if (!targetProduct)
|
|
387
|
+
return false;
|
|
386
388
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
387
389
|
return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
|
|
388
390
|
};
|
|
389
391
|
const allUsedProductIds = newDiscountList.map((n) => {
|
|
390
392
|
var _a2;
|
|
391
|
-
return n.isSelected ? (_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
393
|
+
return n.isSelected ? ((_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
392
394
|
var _a3;
|
|
393
395
|
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
394
|
-
}) : [];
|
|
396
|
+
})) || n.product_id : [];
|
|
395
397
|
}).flat();
|
|
396
398
|
newDiscountList.forEach((item) => {
|
|
397
399
|
var _a2;
|
|
@@ -12,6 +12,13 @@ export declare const isAllNormalProduct: (items: any[]) => boolean;
|
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
14
|
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
15
|
+
export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
|
|
16
|
+
/**
|
|
17
|
+
* 获取折扣金额 计算每个折扣的金额
|
|
18
|
+
* @param discount
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const getDiscountListAmount: (discount: Discount[]) => any;
|
|
15
22
|
export interface ScheduleItem {
|
|
16
23
|
id: number;
|
|
17
24
|
name: string | {
|
|
@@ -32,6 +32,8 @@ __export(utils_exports, {
|
|
|
32
32
|
filterDiscountListByBookingTime: () => filterDiscountListByBookingTime,
|
|
33
33
|
getDateIsInSchedule: () => getDateIsInSchedule,
|
|
34
34
|
getDiscountAmount: () => getDiscountAmount,
|
|
35
|
+
getDiscountListAmount: () => getDiscountListAmount,
|
|
36
|
+
getDiscountListAmountTotal: () => getDiscountListAmountTotal,
|
|
35
37
|
isAllNormalProduct: () => isAllNormalProduct,
|
|
36
38
|
isNormalProductByDurationSchedule: () => isNormalProductByDurationSchedule,
|
|
37
39
|
uniqueById: () => uniqueById
|
|
@@ -53,13 +55,23 @@ var isAllNormalProduct = (items) => {
|
|
|
53
55
|
var getDiscountAmount = (discount, total, price) => {
|
|
54
56
|
var _a;
|
|
55
57
|
if (discount.tag === "good_pass") {
|
|
56
|
-
return new import_decimal.default(
|
|
58
|
+
return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
|
|
57
59
|
}
|
|
58
60
|
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
59
61
|
if (isFixedAmount) {
|
|
60
|
-
return Math.max(new import_decimal.default(
|
|
62
|
+
return Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
|
|
61
63
|
}
|
|
62
|
-
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(
|
|
64
|
+
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
65
|
+
};
|
|
66
|
+
var getDiscountListAmountTotal = (discount) => {
|
|
67
|
+
return discount.reduce((acc, cur) => {
|
|
68
|
+
return new import_decimal.default(acc).plus(new import_decimal.default(cur.num || 1).mul(new import_decimal.default(cur.amount || 0))).toNumber();
|
|
69
|
+
}, new import_decimal.default(0));
|
|
70
|
+
};
|
|
71
|
+
var getDiscountListAmount = (discount) => {
|
|
72
|
+
return discount.reduce((acc, cur) => {
|
|
73
|
+
return new import_decimal.default(acc).plus(new import_decimal.default(cur.amount || 0)).toNumber();
|
|
74
|
+
}, new import_decimal.default(0));
|
|
63
75
|
};
|
|
64
76
|
var getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
65
77
|
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
@@ -222,6 +234,8 @@ var filterDiscountListByBookingTime = (discountList, bookingTime) => {
|
|
|
222
234
|
filterDiscountListByBookingTime,
|
|
223
235
|
getDateIsInSchedule,
|
|
224
236
|
getDiscountAmount,
|
|
237
|
+
getDiscountListAmount,
|
|
238
|
+
getDiscountListAmountTotal,
|
|
225
239
|
isAllNormalProduct,
|
|
226
240
|
isNormalProductByDurationSchedule,
|
|
227
241
|
uniqueById
|