@pisell/pisellos 2.2.9 → 2.2.10
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/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +69 -36
- package/dist/modules/Discount/types.d.ts +16 -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/Payment/index.js +2 -2
- package/dist/modules/Payment/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +3 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.d.ts +7 -0
- package/dist/modules/Rules/index.js +1065 -196
- package/dist/modules/Rules/types.d.ts +4 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +30 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +61 -17
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +80 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -1
- package/dist/solution/ShopDiscount/utils.d.ts +55 -0
- package/dist/solution/ShopDiscount/utils.js +432 -3
- package/lib/modules/Cart/utils/cartProduct.js +35 -22
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +19 -4
- package/lib/modules/Discount/types.d.ts +16 -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/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +10 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +7 -0
- package/lib/modules/Rules/index.js +824 -182
- package/lib/modules/Rules/types.d.ts +4 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +19 -2
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +66 -17
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/types.d.ts +4 -1
- package/lib/solution/ShopDiscount/utils.d.ts +55 -0
- package/lib/solution/ShopDiscount/utils.js +266 -3
- package/package.json +2 -2
|
@@ -44,6 +44,7 @@ type ProductDetail = {
|
|
|
44
44
|
quantity: number;
|
|
45
45
|
vouchersApplicable?: boolean;
|
|
46
46
|
holder_id?: number;
|
|
47
|
+
startDate?: any;
|
|
47
48
|
};
|
|
48
49
|
export interface RulesParamsHooks {
|
|
49
50
|
getProduct: (product: Record<string, any>) => ProductDetail;
|
|
@@ -54,8 +55,10 @@ export interface RulesParamsHooks {
|
|
|
54
55
|
origin_total?: number;
|
|
55
56
|
price?: string | number;
|
|
56
57
|
variant?: any[];
|
|
57
|
-
original_price?: number;
|
|
58
|
+
original_price?: number | string;
|
|
58
59
|
quantity?: number;
|
|
60
|
+
bundle?: any[];
|
|
61
|
+
main_product_selling_price?: string | number;
|
|
59
62
|
}) => Record<string, any>;
|
|
60
63
|
}
|
|
61
64
|
export {};
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
};
|
|
343
343
|
setOtherData(key: string, value: any): void;
|
|
344
344
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
345
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|
|
@@ -185,13 +185,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
collection = [],
|
|
186
186
|
schedule_date
|
|
187
187
|
}) {
|
|
188
|
-
|
|
188
|
+
const res = await this.store.products.loadProducts({
|
|
189
189
|
category_ids,
|
|
190
190
|
product_ids,
|
|
191
191
|
collection,
|
|
192
192
|
schedule_date,
|
|
193
193
|
cacheId: this.cacheId
|
|
194
194
|
});
|
|
195
|
+
this.getAvailableDate({
|
|
196
|
+
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
197
|
+
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
+
products: [...res]
|
|
199
|
+
});
|
|
200
|
+
return res;
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
203
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -228,11 +234,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
234
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
229
235
|
(n, index, self) => self.indexOf(n) === index
|
|
230
236
|
);
|
|
231
|
-
|
|
237
|
+
const res = await this.loadProducts({
|
|
232
238
|
product_ids: allProductIds,
|
|
233
239
|
category_ids,
|
|
234
240
|
schedule_date: date
|
|
235
241
|
});
|
|
242
|
+
return res;
|
|
236
243
|
}
|
|
237
244
|
/**
|
|
238
245
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -599,6 +606,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
599
606
|
quantity = 1
|
|
600
607
|
} = product || {};
|
|
601
608
|
const productData = { ...origin, product_variant_id };
|
|
609
|
+
debugger;
|
|
610
|
+
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
612
|
+
return { success: false, errorCode: "date_or_time_required" };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
602
615
|
const currentCartItems = this.store.cart.getItems();
|
|
603
616
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
604
617
|
productData,
|
|
@@ -1606,6 +1619,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1606
1619
|
}
|
|
1607
1620
|
});
|
|
1608
1621
|
});
|
|
1622
|
+
this.core.effects.emit(
|
|
1623
|
+
`${this.store.cart.name}:onUpdateBookingDate`,
|
|
1624
|
+
{}
|
|
1625
|
+
);
|
|
1609
1626
|
}
|
|
1610
1627
|
getScheduleDataByIds(scheduleIds) {
|
|
1611
1628
|
const targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/solution/BookingByStep/utils/products.ts
|
|
20
20
|
var products_exports = {};
|
|
21
21
|
__export(products_exports, {
|
|
22
|
-
getAvailableProductResources: () => getAvailableProductResources
|
|
22
|
+
getAvailableProductResources: () => getAvailableProductResources,
|
|
23
|
+
isSessionProduct: () => isSessionProduct
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(products_exports);
|
|
25
26
|
var getAvailableProductResources = (products) => {
|
|
@@ -57,7 +58,12 @@ var getAvailableProductResources = (products) => {
|
|
|
57
58
|
});
|
|
58
59
|
return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
|
|
59
60
|
};
|
|
61
|
+
var isSessionProduct = (product) => {
|
|
62
|
+
var _a;
|
|
63
|
+
return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
64
|
+
};
|
|
60
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
66
|
0 && (module.exports = {
|
|
62
|
-
getAvailableProductResources
|
|
67
|
+
getAvailableProductResources,
|
|
68
|
+
isSessionProduct
|
|
63
69
|
});
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -216,23 +216,70 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
216
216
|
return pre + (item.amount || 0);
|
|
217
217
|
}, 0);
|
|
218
218
|
};
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
+
metadata: {
|
|
240
|
+
// 主商品+非原价(加减价)子商品税费
|
|
241
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
242
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
243
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
244
|
+
// 可选,附加费均摊舍入金额
|
|
245
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
246
|
+
},
|
|
247
|
+
product_bundle: item.product_bundle.map((bundle) => {
|
|
248
|
+
return {
|
|
249
|
+
bundle_id: bundle.bundle_id,
|
|
250
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
251
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
252
|
+
price_type: bundle.price_type,
|
|
253
|
+
price_type_ext: bundle.price_type_ext,
|
|
254
|
+
// 套餐子商品总价,不包含折扣金额
|
|
255
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
256
|
+
// 套餐子商品折扣后金额
|
|
257
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
258
|
+
num: bundle.num,
|
|
259
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
260
|
+
tax_fee: bundle.tax_fee,
|
|
261
|
+
metadata: {
|
|
262
|
+
// 子商品单数量附加费
|
|
263
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
264
|
+
// 可选,附加费均摊舍入金额
|
|
265
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
) || [];
|
|
271
|
+
};
|
|
272
|
+
const productList = formatProduct(
|
|
273
|
+
((_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(
|
|
274
|
+
(item) => {
|
|
275
|
+
return {
|
|
276
|
+
...item.product,
|
|
277
|
+
holder_id: this.getHolderIdFromBooking(item)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
)) || []
|
|
281
|
+
);
|
|
282
|
+
const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
|
|
236
283
|
return [...productList, ...relationProducts];
|
|
237
284
|
}
|
|
238
285
|
async initWalletData(params) {
|
|
@@ -257,6 +304,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
257
304
|
isDeposit: (_h = this.store.currentOrder) == null ? void 0 : _h.is_deposit
|
|
258
305
|
},
|
|
259
306
|
products: this.getProductListByOrder(),
|
|
307
|
+
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
308
|
+
// core 有
|
|
260
309
|
...params
|
|
261
310
|
};
|
|
262
311
|
if (this.store.isOrderSynced) {
|
|
@@ -18,6 +18,8 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
18
18
|
private initializePlugins;
|
|
19
19
|
private registerDependentModules;
|
|
20
20
|
private registerEventListeners;
|
|
21
|
+
getCurrentBookingTime(): string | null;
|
|
22
|
+
private filterDiscountListByBookingTime;
|
|
21
23
|
setCustomer(customer: Customer): Promise<void>;
|
|
22
24
|
setHolders(holders: {
|
|
23
25
|
form_record_id: number;
|
|
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(ShopDiscount_exports);
|
|
|
36
36
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
37
|
var import_Discount = require("../../modules/Discount");
|
|
38
38
|
var import_Rules = require("../../modules/Rules");
|
|
39
|
+
var import_utils = require("./utils");
|
|
39
40
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
41
|
var import_lodash_es = require("lodash-es");
|
|
41
42
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -51,6 +52,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
51
52
|
discount: null,
|
|
52
53
|
rules: null,
|
|
53
54
|
originalDiscountList: [],
|
|
55
|
+
currentBookingTime: "",
|
|
56
|
+
filteredDiscountList: [],
|
|
54
57
|
holders: []
|
|
55
58
|
};
|
|
56
59
|
}
|
|
@@ -140,6 +143,44 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
140
143
|
);
|
|
141
144
|
}
|
|
142
145
|
// =========== 公共 API ===========
|
|
146
|
+
// 设置预约时间
|
|
147
|
+
// public async setBookingTime(bookingTime: string | null): Promise<void> {
|
|
148
|
+
// if (this.store.currentBookingTime !== bookingTime) {
|
|
149
|
+
// this.store.currentBookingTime = bookingTime;
|
|
150
|
+
//
|
|
151
|
+
// // 更新过滤后的优惠券列表
|
|
152
|
+
// await this.updateFilteredDiscountList();
|
|
153
|
+
// }
|
|
154
|
+
// }
|
|
155
|
+
// 获取当前预约时间
|
|
156
|
+
getCurrentBookingTime() {
|
|
157
|
+
return this.store.currentBookingTime;
|
|
158
|
+
}
|
|
159
|
+
// 根据预约时间过滤优惠券列表
|
|
160
|
+
filterDiscountListByBookingTime(discountList, bookingTime) {
|
|
161
|
+
if ((0, import_utils.isAllNormalProduct)(this.store.productList || [])) {
|
|
162
|
+
return discountList;
|
|
163
|
+
}
|
|
164
|
+
return (0, import_utils.filterDiscountListByBookingTime)(discountList, bookingTime);
|
|
165
|
+
}
|
|
166
|
+
// 更新过滤后的优惠券列表
|
|
167
|
+
// private async updateFilteredDiscountList(): Promise<void> {
|
|
168
|
+
// const originalList = this.store.originalDiscountList;
|
|
169
|
+
// const filteredList = this.filterDiscountListByBookingTime(originalList, this.store.currentBookingTime);
|
|
170
|
+
//
|
|
171
|
+
// this.store.filteredDiscountList = filteredList;
|
|
172
|
+
//
|
|
173
|
+
// // 更新 DiscountModule 中的优惠券列表
|
|
174
|
+
// this.setDiscountList(filteredList);
|
|
175
|
+
//
|
|
176
|
+
// if (this.store.productList?.length) {
|
|
177
|
+
// const result = this.calcDiscount(this.store.productList);
|
|
178
|
+
// await this.core.effects.emit(
|
|
179
|
+
// ShopDiscountHooks.onLoadPrepareCalcResult,
|
|
180
|
+
// result,
|
|
181
|
+
// );
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
143
184
|
// 设置客户
|
|
144
185
|
async setCustomer(customer) {
|
|
145
186
|
var _a;
|
|
@@ -331,7 +372,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
331
372
|
editModeDiscountList[index] = {
|
|
332
373
|
...editModeDiscountList[index],
|
|
333
374
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
334
|
-
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()
|
|
375
|
+
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()
|
|
335
376
|
};
|
|
336
377
|
} else {
|
|
337
378
|
if (discount.type && !discount.tag) {
|
|
@@ -342,7 +383,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
383
|
name: discount.name || discount.discount.title.auto,
|
|
343
384
|
isEditMode: true,
|
|
344
385
|
limited_relation_product_data: {},
|
|
345
|
-
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
386
|
+
savedAmount: discount.amount * ((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1),
|
|
346
387
|
isAvailable: true,
|
|
347
388
|
id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
|
|
348
389
|
format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
|
|
@@ -362,15 +403,17 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
362
403
|
const isProductFree = (id) => {
|
|
363
404
|
var _a2;
|
|
364
405
|
const targetProduct = productList.find((n) => n.id === id);
|
|
406
|
+
if (!targetProduct)
|
|
407
|
+
return false;
|
|
365
408
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
366
409
|
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);
|
|
367
410
|
};
|
|
368
|
-
const allUsedProductIds = newDiscountList.map((n) => {
|
|
411
|
+
const allUsedProductIds = newDiscountList.filter((item) => !(item == null ? void 0 : item.isEditMode)).map((n) => {
|
|
369
412
|
var _a2;
|
|
370
|
-
return n.isSelected ? (_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
413
|
+
return n.isSelected ? ((_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
371
414
|
var _a3;
|
|
372
415
|
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
373
|
-
}) : [];
|
|
416
|
+
})) || n.product_id : [];
|
|
374
417
|
}).flat();
|
|
375
418
|
newDiscountList.forEach((item) => {
|
|
376
419
|
var _a2;
|
|
@@ -432,7 +475,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
432
475
|
}
|
|
433
476
|
// 加载准备配置
|
|
434
477
|
async loadPrepareConfig(params) {
|
|
435
|
-
var _a, _b, _c, _d;
|
|
478
|
+
var _a, _b, _c, _d, _e;
|
|
436
479
|
try {
|
|
437
480
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
438
481
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
@@ -449,8 +492,11 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
449
492
|
const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
450
493
|
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
451
494
|
this.store.originalDiscountList = newDiscountList;
|
|
452
|
-
this.
|
|
453
|
-
|
|
495
|
+
await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
|
|
496
|
+
const filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
497
|
+
this.store.filteredDiscountList = filteredDiscountList;
|
|
498
|
+
this.setDiscountList(filteredDiscountList || []);
|
|
499
|
+
if ((_e = this.store.productList) == null ? void 0 : _e.length) {
|
|
454
500
|
const result = this.calcDiscount(this.store.productList);
|
|
455
501
|
await this.core.effects.emit(
|
|
456
502
|
`${this.name}:onLoadPrepareCalcResult`,
|
|
@@ -459,7 +505,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
459
505
|
}
|
|
460
506
|
await this.core.effects.emit(
|
|
461
507
|
`${this.name}:onLoadDiscountList`,
|
|
462
|
-
|
|
508
|
+
filteredDiscountList
|
|
463
509
|
);
|
|
464
510
|
} catch (error) {
|
|
465
511
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DiscountModule
|
|
1
|
+
import { DiscountModule } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
|
+
import { Discount } from "../../modules/Discount/types";
|
|
3
4
|
export declare enum ShopDiscountHooks {
|
|
4
5
|
onInited = "shopDiscount:onInited",
|
|
5
6
|
onDestroy = "shopDiscount:onDestroy",
|
|
@@ -28,6 +29,8 @@ export interface ShopDiscountState {
|
|
|
28
29
|
form_id?: number;
|
|
29
30
|
main_field?: string;
|
|
30
31
|
}[];
|
|
32
|
+
currentBookingTime: string | null;
|
|
33
|
+
filteredDiscountList: Discount[];
|
|
31
34
|
}
|
|
32
35
|
export interface SetDiscountSelectedParams {
|
|
33
36
|
discountId: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Discount } from "../../modules/Discount/types";
|
|
2
2
|
export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
3
|
+
export declare const isNormalProductByDurationSchedule: (item: any) => boolean;
|
|
4
|
+
export declare const isAllNormalProduct: (items: any[]) => boolean;
|
|
3
5
|
/**
|
|
4
6
|
* 获取折扣金额 基于折扣卡类型计算
|
|
5
7
|
* 商品券:直接返回商品价格
|
|
@@ -10,3 +12,56 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
|
10
12
|
* @returns
|
|
11
13
|
*/
|
|
12
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;
|
|
22
|
+
export interface ScheduleItem {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string | {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
28
|
+
start_time: string | null;
|
|
29
|
+
end_time: string | null;
|
|
30
|
+
repeat_type: 'none' | 'daily' | 'weekly';
|
|
31
|
+
repeat_rule: {
|
|
32
|
+
end: {
|
|
33
|
+
type: 'never' | 'date' | 'occurrence';
|
|
34
|
+
end_date: string | null;
|
|
35
|
+
occurrence: number | null;
|
|
36
|
+
};
|
|
37
|
+
frequency: number;
|
|
38
|
+
excluded_date: Array<{
|
|
39
|
+
start: string;
|
|
40
|
+
end: string;
|
|
41
|
+
}>;
|
|
42
|
+
included_date: Array<{
|
|
43
|
+
start: string;
|
|
44
|
+
end: string;
|
|
45
|
+
}>;
|
|
46
|
+
frequency_date: number[];
|
|
47
|
+
} | null;
|
|
48
|
+
designation: Array<{
|
|
49
|
+
start_date: string;
|
|
50
|
+
start_time: string;
|
|
51
|
+
end_date: string;
|
|
52
|
+
end_time: string;
|
|
53
|
+
}> | null;
|
|
54
|
+
is_all: number;
|
|
55
|
+
time_slot: Array<{
|
|
56
|
+
start_time: string;
|
|
57
|
+
end_time: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 根据预约时间过滤优惠券列表
|
|
63
|
+
* @param discountList 优惠券列表
|
|
64
|
+
* @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
|
|
65
|
+
* @returns 过滤后的优惠券列表
|
|
66
|
+
*/
|
|
67
|
+
export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];
|