@pisell/pisellos 1.0.76 → 1.0.78
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 +7 -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 +870 -168
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +3 -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 +7 -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 +679 -159
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +1 -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 {};
|
|
@@ -2186,7 +2186,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2186
2186
|
account
|
|
2187
2187
|
}) {
|
|
2188
2188
|
var _a, _b;
|
|
2189
|
-
const cartItems =
|
|
2189
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2190
2190
|
const currentCartItem = this.convertProductToCartItem({ product, date, account });
|
|
2191
2191
|
cartItems.push(currentCartItem);
|
|
2192
2192
|
if (cartItems.length === 0)
|
|
@@ -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 商品列表
|
|
@@ -314,7 +314,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
314
314
|
if (item.booking_id) {
|
|
315
315
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
316
316
|
(item.discount_list || []).forEach((discount) => {
|
|
317
|
-
var _a3, _b, _c;
|
|
317
|
+
var _a3, _b, _c, _d, _e;
|
|
318
318
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
319
319
|
const index = editModeDiscountList.findIndex((n) => {
|
|
320
320
|
var _a4;
|
|
@@ -324,7 +324,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
324
324
|
editModeDiscountList[index] = {
|
|
325
325
|
...editModeDiscountList[index],
|
|
326
326
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
327
|
-
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()
|
|
327
|
+
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()
|
|
328
328
|
};
|
|
329
329
|
} else {
|
|
330
330
|
if (discount.type && !discount.tag) {
|
|
@@ -335,13 +335,13 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
335
335
|
name: discount.name || discount.discount.title.auto,
|
|
336
336
|
isEditMode: true,
|
|
337
337
|
limited_relation_product_data: {},
|
|
338
|
-
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
338
|
+
savedAmount: discount.amount * (((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.num) || (product == null ? void 0 : product.num) || 1),
|
|
339
339
|
isAvailable: true,
|
|
340
|
-
id: ((
|
|
341
|
-
format_title: ((
|
|
340
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
341
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
342
342
|
isDisabled: true,
|
|
343
343
|
isSelected: true,
|
|
344
|
-
product_id: ((
|
|
344
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
}
|
|
@@ -355,15 +355,17 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
355
355
|
const isProductFree = (id) => {
|
|
356
356
|
var _a2;
|
|
357
357
|
const targetProduct = productList.find((n) => n.id === id);
|
|
358
|
+
if (!targetProduct)
|
|
359
|
+
return false;
|
|
358
360
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
359
361
|
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);
|
|
360
362
|
};
|
|
361
363
|
const allUsedProductIds = newDiscountList.map((n) => {
|
|
362
364
|
var _a2;
|
|
363
|
-
return n.isSelected ? (_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
365
|
+
return n.isSelected ? ((_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
364
366
|
var _a3;
|
|
365
367
|
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
366
|
-
}) : [];
|
|
368
|
+
})) || n.product_id : [];
|
|
367
369
|
}).flat();
|
|
368
370
|
newDiscountList.forEach((item) => {
|
|
369
371
|
var _a2;
|
|
@@ -10,3 +10,10 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
13
|
+
export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
|
|
14
|
+
/**
|
|
15
|
+
* 获取折扣金额 计算每个折扣的金额
|
|
16
|
+
* @param discount
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare const getDiscountListAmount: (discount: Discount[]) => any;
|
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
getDiscountAmount: () => getDiscountAmount,
|
|
33
|
+
getDiscountListAmount: () => getDiscountListAmount,
|
|
34
|
+
getDiscountListAmountTotal: () => getDiscountListAmountTotal,
|
|
33
35
|
uniqueById: () => uniqueById
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -41,16 +43,28 @@ var uniqueById = (arr, key = "id") => {
|
|
|
41
43
|
var getDiscountAmount = (discount, total, price) => {
|
|
42
44
|
var _a;
|
|
43
45
|
if (discount.tag === "good_pass") {
|
|
44
|
-
return new import_decimal.default(
|
|
46
|
+
return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
|
|
45
47
|
}
|
|
46
48
|
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
47
49
|
if (isFixedAmount) {
|
|
48
|
-
return Math.max(new import_decimal.default(
|
|
50
|
+
return Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
|
|
49
51
|
}
|
|
50
|
-
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(
|
|
52
|
+
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
53
|
+
};
|
|
54
|
+
var getDiscountListAmountTotal = (discount) => {
|
|
55
|
+
return discount.reduce((acc, cur) => {
|
|
56
|
+
return new import_decimal.default(acc).plus(new import_decimal.default(cur.num || 1).mul(new import_decimal.default(cur.amount || 0))).toNumber();
|
|
57
|
+
}, new import_decimal.default(0));
|
|
58
|
+
};
|
|
59
|
+
var getDiscountListAmount = (discount) => {
|
|
60
|
+
return discount.reduce((acc, cur) => {
|
|
61
|
+
return new import_decimal.default(acc).plus(new import_decimal.default(cur.amount || 0)).toNumber();
|
|
62
|
+
}, new import_decimal.default(0));
|
|
51
63
|
};
|
|
52
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
65
|
0 && (module.exports = {
|
|
54
66
|
getDiscountAmount,
|
|
67
|
+
getDiscountListAmount,
|
|
68
|
+
getDiscountListAmountTotal,
|
|
55
69
|
uniqueById
|
|
56
70
|
});
|