@pisell/pisellos 2.2.10 → 2.2.11
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 +26 -41
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +0 -2
- package/dist/modules/Discount/index.js +36 -69
- package/dist/modules/Discount/types.d.ts +0 -16
- package/dist/modules/Order/index.js +1 -4
- package/dist/modules/Order/utils.d.ts +0 -1
- package/dist/modules/Order/utils.js +0 -9
- package/dist/modules/Payment/index.js +2 -2
- package/dist/modules/Payment/types.d.ts +0 -1
- package/dist/modules/Payment/walletpass.js +1 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +9 -8
- package/dist/modules/Rules/index.d.ts +0 -7
- package/dist/modules/Rules/index.js +196 -1065
- package/dist/modules/Rules/types.d.ts +1 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +8 -30
- package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
- package/dist/solution/BookingByStep/utils/products.js +0 -10
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +49 -93
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +19 -80
- package/dist/solution/ShopDiscount/types.d.ts +1 -4
- package/dist/solution/ShopDiscount/utils.d.ts +0 -55
- package/dist/solution/ShopDiscount/utils.js +3 -432
- package/lib/modules/Cart/utils/cartProduct.js +22 -35
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +0 -2
- package/lib/modules/Discount/index.js +4 -19
- package/lib/modules/Discount/types.d.ts +0 -16
- package/lib/modules/Order/index.js +0 -2
- package/lib/modules/Order/utils.d.ts +0 -1
- package/lib/modules/Order/utils.js +0 -11
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +0 -1
- package/lib/modules/Payment/walletpass.js +1 -10
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +7 -0
- package/lib/modules/Rules/index.d.ts +0 -7
- package/lib/modules/Rules/index.js +182 -824
- package/lib/modules/Rules/types.d.ts +1 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +2 -19
- package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
- package/lib/solution/BookingByStep/utils/products.js +2 -8
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +19 -68
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/types.d.ts +1 -4
- package/lib/solution/ShopDiscount/utils.d.ts +0 -55
- package/lib/solution/ShopDiscount/utils.js +3 -266
- package/package.json +2 -2
|
@@ -44,7 +44,6 @@ type ProductDetail = {
|
|
|
44
44
|
quantity: number;
|
|
45
45
|
vouchersApplicable?: boolean;
|
|
46
46
|
holder_id?: number;
|
|
47
|
-
startDate?: any;
|
|
48
47
|
};
|
|
49
48
|
export interface RulesParamsHooks {
|
|
50
49
|
getProduct: (product: Record<string, any>) => ProductDetail;
|
|
@@ -55,10 +54,8 @@ export interface RulesParamsHooks {
|
|
|
55
54
|
origin_total?: number;
|
|
56
55
|
price?: string | number;
|
|
57
56
|
variant?: any[];
|
|
58
|
-
original_price?: number
|
|
57
|
+
original_price?: number;
|
|
59
58
|
quantity?: number;
|
|
60
|
-
bundle?: any[];
|
|
61
|
-
main_product_selling_price?: string | number;
|
|
62
59
|
}) => Record<string, any>;
|
|
63
60
|
}
|
|
64
61
|
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<"duration" | "session" | "normal">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|
|
@@ -185,19 +185,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
collection = [],
|
|
186
186
|
schedule_date
|
|
187
187
|
}) {
|
|
188
|
-
|
|
188
|
+
return 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;
|
|
201
195
|
}
|
|
202
196
|
/**
|
|
203
197
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -234,12 +228,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
234
228
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
235
229
|
(n, index, self) => self.indexOf(n) === index
|
|
236
230
|
);
|
|
237
|
-
|
|
231
|
+
return await this.loadProducts({
|
|
238
232
|
product_ids: allProductIds,
|
|
239
233
|
category_ids,
|
|
240
234
|
schedule_date: date
|
|
241
235
|
});
|
|
242
|
-
return res;
|
|
243
236
|
}
|
|
244
237
|
/**
|
|
245
238
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -606,12 +599,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
606
599
|
quantity = 1
|
|
607
600
|
} = product || {};
|
|
608
601
|
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
|
-
}
|
|
615
602
|
const currentCartItems = this.store.cart.getItems();
|
|
616
603
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
617
604
|
productData,
|
|
@@ -1619,10 +1606,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1619
1606
|
}
|
|
1620
1607
|
});
|
|
1621
1608
|
});
|
|
1622
|
-
this.core.effects.emit(
|
|
1623
|
-
`${this.store.cart.name}:onUpdateBookingDate`,
|
|
1624
|
-
{}
|
|
1625
|
-
);
|
|
1626
1609
|
}
|
|
1627
1610
|
getScheduleDataByIds(scheduleIds) {
|
|
1628
1611
|
const targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
@@ -9,9 +9,3 @@ 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,8 +19,7 @@ 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
|
|
23
|
-
isSessionProduct: () => isSessionProduct
|
|
22
|
+
getAvailableProductResources: () => getAvailableProductResources
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(products_exports);
|
|
26
25
|
var getAvailableProductResources = (products) => {
|
|
@@ -58,12 +57,7 @@ var getAvailableProductResources = (products) => {
|
|
|
58
57
|
});
|
|
59
58
|
return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
|
|
60
59
|
};
|
|
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
|
-
};
|
|
65
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
61
|
0 && (module.exports = {
|
|
67
|
-
getAvailableProductResources
|
|
68
|
-
isSessionProduct
|
|
62
|
+
getAvailableProductResources
|
|
69
63
|
});
|
|
@@ -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, "num" | "skip">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -216,70 +216,23 @@ 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
|
-
|
|
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) || []);
|
|
219
|
+
const productList = ((_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings) == null ? void 0 : _b.map(
|
|
220
|
+
(item) => ({
|
|
221
|
+
product_id: item.product.product_id,
|
|
222
|
+
product_variant_id: item.product.product_variant_id,
|
|
223
|
+
quantity: item.product.num,
|
|
224
|
+
selling_price: item.product.calculated_selling_price,
|
|
225
|
+
holder_id: this.getHolderIdFromBooking(item)
|
|
226
|
+
})
|
|
227
|
+
)) || [];
|
|
228
|
+
const relationProducts = ((_e = (_d = (_c = this.store.currentOrder.order_info) == null ? void 0 : _c.original_order_data) == null ? void 0 : _d.relation_products) == null ? void 0 : _e.map(
|
|
229
|
+
(item) => ({
|
|
230
|
+
product_id: item.product_id,
|
|
231
|
+
product_variant_id: item.product_variant_id,
|
|
232
|
+
quantity: item.num,
|
|
233
|
+
selling_price: item.source_product_price
|
|
234
|
+
})
|
|
235
|
+
)) || [];
|
|
283
236
|
return [...productList, ...relationProducts];
|
|
284
237
|
}
|
|
285
238
|
async initWalletData(params) {
|
|
@@ -304,8 +257,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
304
257
|
isDeposit: (_h = this.store.currentOrder) == null ? void 0 : _h.is_deposit
|
|
305
258
|
},
|
|
306
259
|
products: this.getProductListByOrder(),
|
|
307
|
-
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
308
|
-
// core 有
|
|
309
260
|
...params
|
|
310
261
|
};
|
|
311
262
|
if (this.store.isOrderSynced) {
|
|
@@ -502,7 +453,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
502
453
|
* 会覆盖 order_info 与金额等字段,并重新计算待付金额,最后设置为 currentOrder。
|
|
503
454
|
*/
|
|
504
455
|
async updateLocalOrderAsync(params) {
|
|
505
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
456
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
506
457
|
this.logInfo("updateLocalOrderAsync called", {
|
|
507
458
|
orderId: params.orderId,
|
|
508
459
|
orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
|
|
@@ -709,7 +660,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
709
660
|
}
|
|
710
661
|
});
|
|
711
662
|
this.store.currentOrder = created;
|
|
712
|
-
if (params.existPayment && params.existPayment.length > 0) {
|
|
663
|
+
if (params.existPayment && params.existPayment.length > 0 || ((_p = this.store.currentOrder) == null ? void 0 : _p.order_id) && !(0, import_utils.isVirtualOrderId)((_q = this.store.currentOrder) == null ? void 0 : _q.order_id)) {
|
|
713
664
|
this.store.isOrderSynced = true;
|
|
714
665
|
const syncedPayments = created.payment.filter((p) => p.isSynced && p.status !== "voided");
|
|
715
666
|
const syncedAmount = syncedPayments.reduce((sum, p) => {
|
|
@@ -18,8 +18,6 @@ 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;
|
|
23
21
|
setCustomer(customer: Customer): Promise<void>;
|
|
24
22
|
setHolders(holders: {
|
|
25
23
|
form_record_id: number;
|
|
@@ -36,7 +36,6 @@ 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");
|
|
40
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
41
40
|
var import_lodash_es = require("lodash-es");
|
|
42
41
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -52,8 +51,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
52
51
|
discount: null,
|
|
53
52
|
rules: null,
|
|
54
53
|
originalDiscountList: [],
|
|
55
|
-
currentBookingTime: "",
|
|
56
|
-
filteredDiscountList: [],
|
|
57
54
|
holders: []
|
|
58
55
|
};
|
|
59
56
|
}
|
|
@@ -143,44 +140,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
143
140
|
);
|
|
144
141
|
}
|
|
145
142
|
// =========== 公共 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
|
-
// }
|
|
184
143
|
// 设置客户
|
|
185
144
|
async setCustomer(customer) {
|
|
186
145
|
var _a;
|
|
@@ -372,7 +331,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
372
331
|
editModeDiscountList[index] = {
|
|
373
332
|
...editModeDiscountList[index],
|
|
374
333
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
375
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.
|
|
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()
|
|
376
335
|
};
|
|
377
336
|
} else {
|
|
378
337
|
if (discount.type && !discount.tag) {
|
|
@@ -383,7 +342,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
383
342
|
name: discount.name || discount.discount.title.auto,
|
|
384
343
|
isEditMode: true,
|
|
385
344
|
limited_relation_product_data: {},
|
|
386
|
-
savedAmount: discount.amount * ((product == null ? void 0 : product.
|
|
345
|
+
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|
|
387
346
|
isAvailable: true,
|
|
388
347
|
id: ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id) || discount.id,
|
|
389
348
|
format_title: ((_b = discount.discount) == null ? void 0 : _b.title) || discount.format_title,
|
|
@@ -403,17 +362,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
403
362
|
const isProductFree = (id) => {
|
|
404
363
|
var _a2;
|
|
405
364
|
const targetProduct = productList.find((n) => n.id === id);
|
|
406
|
-
if (!targetProduct)
|
|
407
|
-
return false;
|
|
408
365
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
409
366
|
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);
|
|
410
367
|
};
|
|
411
|
-
const allUsedProductIds = newDiscountList.
|
|
368
|
+
const allUsedProductIds = newDiscountList.map((n) => {
|
|
412
369
|
var _a2;
|
|
413
|
-
return n.isSelected ? (
|
|
370
|
+
return n.isSelected ? (_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
414
371
|
var _a3;
|
|
415
372
|
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
416
|
-
})
|
|
373
|
+
}) : [];
|
|
417
374
|
}).flat();
|
|
418
375
|
newDiscountList.forEach((item) => {
|
|
419
376
|
var _a2;
|
|
@@ -475,7 +432,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
475
432
|
}
|
|
476
433
|
// 加载准备配置
|
|
477
434
|
async loadPrepareConfig(params) {
|
|
478
|
-
var _a, _b, _c, _d
|
|
435
|
+
var _a, _b, _c, _d;
|
|
479
436
|
try {
|
|
480
437
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
481
438
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
@@ -492,11 +449,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
492
449
|
const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
493
450
|
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
494
451
|
this.store.originalDiscountList = newDiscountList;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
this.store.filteredDiscountList = filteredDiscountList;
|
|
498
|
-
this.setDiscountList(filteredDiscountList || []);
|
|
499
|
-
if ((_e = this.store.productList) == null ? void 0 : _e.length) {
|
|
452
|
+
this.setDiscountList(newDiscountList || []);
|
|
453
|
+
if ((_d = this.store.productList) == null ? void 0 : _d.length) {
|
|
500
454
|
const result = this.calcDiscount(this.store.productList);
|
|
501
455
|
await this.core.effects.emit(
|
|
502
456
|
`${this.name}:onLoadPrepareCalcResult`,
|
|
@@ -505,7 +459,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
505
459
|
}
|
|
506
460
|
await this.core.effects.emit(
|
|
507
461
|
`${this.name}:onLoadDiscountList`,
|
|
508
|
-
|
|
462
|
+
newDiscountList
|
|
509
463
|
);
|
|
510
464
|
} catch (error) {
|
|
511
465
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DiscountModule } from '../../modules/Discount';
|
|
1
|
+
import { DiscountModule, Discount } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
|
-
import { Discount } from "../../modules/Discount/types";
|
|
4
3
|
export declare enum ShopDiscountHooks {
|
|
5
4
|
onInited = "shopDiscount:onInited",
|
|
6
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
@@ -29,8 +28,6 @@ export interface ShopDiscountState {
|
|
|
29
28
|
form_id?: number;
|
|
30
29
|
main_field?: string;
|
|
31
30
|
}[];
|
|
32
|
-
currentBookingTime: string | null;
|
|
33
|
-
filteredDiscountList: Discount[];
|
|
34
31
|
}
|
|
35
32
|
export interface SetDiscountSelectedParams {
|
|
36
33
|
discountId: number;
|
|
@@ -1,7 +1,5 @@
|
|
|
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;
|
|
5
3
|
/**
|
|
6
4
|
* 获取折扣金额 基于折扣卡类型计算
|
|
7
5
|
* 商品券:直接返回商品价格
|
|
@@ -12,56 +10,3 @@ export declare const isAllNormalProduct: (items: any[]) => boolean;
|
|
|
12
10
|
* @returns
|
|
13
11
|
*/
|
|
14
12
|
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[];
|