@pisell/pisellos 2.1.46 → 2.1.47
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 +41 -26
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/Discount/types.d.ts +9 -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/Rules/index.d.ts +7 -0
- package/dist/modules/Rules/index.js +1043 -192
- package/dist/modules/Rules/types.d.ts +3 -1
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +69 -28
- package/dist/solution/ShopDiscount/index.js +8 -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 +35 -22
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/Discount/types.d.ts +9 -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/Rules/index.d.ts +7 -0
- package/lib/modules/Rules/index.js +801 -175
- package/lib/modules/Rules/types.d.ts +3 -1
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +58 -16
- package/lib/solution/ShopDiscount/index.js +7 -5
- package/lib/solution/ShopDiscount/utils.d.ts +7 -0
- package/lib/solution/ShopDiscount/utils.js +17 -3
- package/package.json +1 -1
|
@@ -51,8 +51,10 @@ export interface RulesParamsHooks {
|
|
|
51
51
|
origin_total?: number;
|
|
52
52
|
price?: string | number;
|
|
53
53
|
variant?: any[];
|
|
54
|
-
original_price?: number;
|
|
54
|
+
original_price?: number | string;
|
|
55
55
|
quantity?: number;
|
|
56
|
+
bundle?: any[];
|
|
57
|
+
main_product_selling_price?: string | number;
|
|
56
58
|
}) => Record<string, any>;
|
|
57
59
|
}
|
|
58
60
|
export {};
|
|
@@ -48,6 +48,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
48
48
|
* 初始化结账流程
|
|
49
49
|
*/
|
|
50
50
|
initializeCheckoutAsync(params: CheckoutInitParams): Promise<void>;
|
|
51
|
+
getHolderIdFromBooking(obj: any): number | undefined;
|
|
51
52
|
getProductListByOrder(): {
|
|
52
53
|
product_id: number;
|
|
53
54
|
product_variant_id: string;
|
|
@@ -196,6 +196,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
196
196
|
throw error;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
getHolderIdFromBooking(obj) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!obj)
|
|
202
|
+
return void 0;
|
|
203
|
+
let ret = obj.holder_id || ((_a = obj.holder) == null ? void 0 : _a.form_record);
|
|
204
|
+
if (Array.isArray(ret)) {
|
|
205
|
+
return ret.length > 0 ? Number(ret[0]) : void 0;
|
|
206
|
+
}
|
|
207
|
+
return Number(ret) || void 0;
|
|
208
|
+
}
|
|
199
209
|
getProductListByOrder() {
|
|
200
210
|
var _a, _b, _c, _d, _e;
|
|
201
211
|
if (!this.store.currentOrder) {
|
|
@@ -206,22 +216,54 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
206
216
|
return pre + (item.amount || 0);
|
|
207
217
|
}, 0);
|
|
208
218
|
};
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
const formatProduct = (items) => {
|
|
220
|
+
return items.map(
|
|
221
|
+
(item) => ({
|
|
222
|
+
product_id: item.product_id,
|
|
223
|
+
product_variant_id: item.product_variant_id,
|
|
224
|
+
quantity: item.num,
|
|
225
|
+
// 商品是否含税:1;0
|
|
226
|
+
is_charge_tax: item.is_charge_tax ?? 0,
|
|
227
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
228
|
+
tax_fee: item.tax_fee,
|
|
229
|
+
// 整个商品折扣后的总金额
|
|
230
|
+
selling_price: item.calculated_selling_price,
|
|
231
|
+
// 使用者id
|
|
232
|
+
holder_id: item.holder_id,
|
|
233
|
+
// 整个商品折扣前的总金额
|
|
234
|
+
original_price: item.calculated_original_price,
|
|
235
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
236
|
+
main_product_original_price: item.price,
|
|
237
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
238
|
+
main_product_selling_price: item.main_product_selling_price,
|
|
239
|
+
product_bundle: item.product_bundle.map((bundle) => {
|
|
240
|
+
return {
|
|
241
|
+
bundle_id: bundle.bundle_id,
|
|
242
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
243
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
244
|
+
price_type: bundle.price_type,
|
|
245
|
+
price_type_ext: bundle.price_type_ext,
|
|
246
|
+
// 套餐子商品总价,不包含折扣金额
|
|
247
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
248
|
+
// 套餐子商品折扣后金额
|
|
249
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
250
|
+
num: bundle.num
|
|
251
|
+
};
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
) || [];
|
|
255
|
+
};
|
|
256
|
+
const productList = formatProduct(
|
|
257
|
+
((_c = (_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.map(
|
|
258
|
+
(item) => {
|
|
259
|
+
return {
|
|
260
|
+
...item.product,
|
|
261
|
+
holder_id: this.getHolderIdFromBooking(item)
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
)) || []
|
|
265
|
+
);
|
|
266
|
+
const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
|
|
225
267
|
return [...productList, ...relationProducts];
|
|
226
268
|
}
|
|
227
269
|
async initWalletData(params) {
|
|
@@ -365,7 +365,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
365
365
|
editModeDiscountList[index] = {
|
|
366
366
|
...editModeDiscountList[index],
|
|
367
367
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
368
|
-
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()
|
|
368
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
369
369
|
};
|
|
370
370
|
} else {
|
|
371
371
|
if (discount.type && !discount.tag) {
|
|
@@ -376,7 +376,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
376
376
|
name: discount.name || discount.discount.title.auto,
|
|
377
377
|
isEditMode: true,
|
|
378
378
|
limited_relation_product_data: {},
|
|
379
|
-
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
379
|
+
savedAmount: discount.amount * ((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1),
|
|
380
380
|
isAvailable: true,
|
|
381
381
|
id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
|
|
382
382
|
format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
|
|
@@ -396,15 +396,17 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
396
396
|
const isProductFree = (id) => {
|
|
397
397
|
var _a2;
|
|
398
398
|
const targetProduct = productList.find((n) => n.id === id);
|
|
399
|
+
if (!targetProduct)
|
|
400
|
+
return false;
|
|
399
401
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
400
402
|
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);
|
|
401
403
|
};
|
|
402
|
-
const allUsedProductIds = newDiscountList.map((n) => {
|
|
404
|
+
const allUsedProductIds = newDiscountList.filter((item) => !(item == null ? void 0 : item.isEditMode)).map((n) => {
|
|
403
405
|
var _a2;
|
|
404
|
-
return n.isSelected ? (_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
406
|
+
return n.isSelected ? ((_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
405
407
|
var _a3;
|
|
406
408
|
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
407
|
-
}) : [];
|
|
409
|
+
})) || n.product_id : [];
|
|
408
410
|
}).flat();
|
|
409
411
|
newDiscountList.forEach((item) => {
|
|
410
412
|
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) {
|
|
@@ -290,6 +302,8 @@ var filterDiscountListByBookingTime = (discountList, bookingTime) => {
|
|
|
290
302
|
filterDiscountListByBookingTime,
|
|
291
303
|
getDateIsInSchedule,
|
|
292
304
|
getDiscountAmount,
|
|
305
|
+
getDiscountListAmount,
|
|
306
|
+
getDiscountListAmountTotal,
|
|
293
307
|
isAllNormalProduct,
|
|
294
308
|
isNormalProductByDurationSchedule,
|
|
295
309
|
uniqueById
|