@pisell/pisellos 2.1.118 → 2.1.119
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +24 -56
- package/dist/modules/Discount/types.d.ts +0 -18
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +162 -674
- package/dist/modules/Rules/types.d.ts +0 -2
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +0 -6
- package/dist/modules/Summary/utils.js +0 -21
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +44 -42
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +7 -23
- package/dist/solution/ShopDiscount/types.d.ts +0 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.js +12 -26
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +11 -39
- package/lib/modules/Discount/types.d.ts +0 -18
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +284 -779
- package/lib/modules/Rules/types.d.ts +0 -2
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +0 -6
- package/lib/modules/Summary/utils.js +0 -15
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +4 -2
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +8 -22
- package/lib/solution/ShopDiscount/types.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/package.json +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -1
- package/dist/model/strategy/adapter/index.d.ts +0 -3
- package/dist/model/strategy/adapter/index.js +0 -4
- package/dist/model/strategy/adapter/type.d.ts +0 -28
- package/dist/model/strategy/adapter/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -499
- package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/dist/model/strategy/adapter/walletPass/example.js +0 -258
- package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/dist/model/strategy/adapter/walletPass/index.js +0 -182
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.js +0 -26
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -187
- package/dist/model/strategy/adapter/walletPass/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -1104
- package/dist/model/strategy/index.d.ts +0 -94
- package/dist/model/strategy/index.js +0 -551
- package/dist/model/strategy/strategy-example.d.ts +0 -5
- package/dist/model/strategy/strategy-example.js +0 -331
- package/dist/model/strategy/type.d.ts +0 -228
- package/dist/model/strategy/type.js +0 -94
- package/lib/model/index.d.ts +0 -1
- package/lib/model/index.js +0 -23
- package/lib/model/strategy/adapter/index.d.ts +0 -3
- package/lib/model/strategy/adapter/index.js +0 -45
- package/lib/model/strategy/adapter/type.d.ts +0 -28
- package/lib/model/strategy/adapter/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -423
- package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/lib/model/strategy/adapter/walletPass/example.js +0 -207
- package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/lib/model/strategy/adapter/walletPass/index.js +0 -142
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +0 -54
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -187
- package/lib/model/strategy/adapter/walletPass/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -791
- package/lib/model/strategy/index.d.ts +0 -94
- package/lib/model/strategy/index.js +0 -413
- package/lib/model/strategy/strategy-example.d.ts +0 -5
- package/lib/model/strategy/strategy-example.js +0 -318
- package/lib/model/strategy/type.d.ts +0 -228
- package/lib/model/strategy/type.js +0 -44
|
@@ -28,7 +28,6 @@ export interface RulesModuleAPI {
|
|
|
28
28
|
calcDiscount: (params: {
|
|
29
29
|
discountList: any[];
|
|
30
30
|
productList: any[];
|
|
31
|
-
orderTotalAmount: number;
|
|
32
31
|
holders: {
|
|
33
32
|
form_record_id: number;
|
|
34
33
|
}[];
|
|
@@ -67,7 +66,6 @@ export interface RulesParamsHooks {
|
|
|
67
66
|
quantity?: number;
|
|
68
67
|
bundle?: any[];
|
|
69
68
|
main_product_selling_price?: string | number;
|
|
70
|
-
options?: any[];
|
|
71
69
|
}) => Record<string, any>;
|
|
72
70
|
}
|
|
73
71
|
export {};
|
|
@@ -58,12 +58,6 @@ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
|
|
|
58
58
|
* @returns 商品总价字符串,保留2位小数
|
|
59
59
|
*/
|
|
60
60
|
export declare const calculateSubtotal: (items: CartItem[]) => string;
|
|
61
|
-
/**
|
|
62
|
-
* 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
|
|
63
|
-
* @param items - 购物车商品数组
|
|
64
|
-
* @returns 商品总价字符串,保留2位小数
|
|
65
|
-
*/
|
|
66
|
-
export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
|
|
67
61
|
/**
|
|
68
62
|
* @title: 单个商品的税费
|
|
69
63
|
* @description:
|
|
@@ -31,7 +31,6 @@ var utils_exports = {};
|
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
calcDiscountListDifference: () => calcDiscountListDifference,
|
|
33
33
|
calculateDeposit: () => calculateDeposit,
|
|
34
|
-
calculateOriginSubtotal: () => calculateOriginSubtotal,
|
|
35
34
|
calculatePriceDetails: () => calculatePriceDetails,
|
|
36
35
|
calculateSubtotal: () => calculateSubtotal,
|
|
37
36
|
calculateTaxFee: () => calculateTaxFee,
|
|
@@ -47,7 +46,6 @@ var import_utils = require("../Product/utils");
|
|
|
47
46
|
var import_dayjs = __toESM(require("dayjs"));
|
|
48
47
|
var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList, scheduleById) => {
|
|
49
48
|
const subtotal = new import_decimal.default(calculateSubtotal(items));
|
|
50
|
-
const subOriginTotal = new import_decimal.default(calculateOriginSubtotal(items));
|
|
51
49
|
const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
|
|
52
50
|
const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate, surcharge_list: surchargeList, scheduleById });
|
|
53
51
|
const surchargeAmount = new import_decimal.default(getSurchargeAmount({ bookingDetail: null, bookingId: void 0 }, surcharge, { isEdit: false }));
|
|
@@ -61,12 +59,10 @@ var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList,
|
|
|
61
59
|
is_price_include_tax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
|
|
62
60
|
});
|
|
63
61
|
const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
64
|
-
const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
65
62
|
const deposit = calculateDeposit(items);
|
|
66
63
|
return {
|
|
67
64
|
subtotal: subtotal.toFixed(2),
|
|
68
65
|
total: total.toFixed(2),
|
|
69
|
-
originTotal: originTotal.toFixed(2),
|
|
70
66
|
taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
|
|
71
67
|
taxRate: shopInfo == null ? void 0 : shopInfo.tax_rate,
|
|
72
68
|
totalTaxFee: tax,
|
|
@@ -364,16 +360,6 @@ var calculateSubtotal = (items) => {
|
|
|
364
360
|
}, new import_decimal.default(0));
|
|
365
361
|
return subtotal.toFixed(2);
|
|
366
362
|
};
|
|
367
|
-
var calculateOriginSubtotal = (items) => {
|
|
368
|
-
if (!(items == null ? void 0 : items.length)) {
|
|
369
|
-
return "0.00";
|
|
370
|
-
}
|
|
371
|
-
const subtotal = items.reduce((sum, item) => {
|
|
372
|
-
const cartItemTotalPrice = new import_decimal.default(item.summaryOriginTotal || 0);
|
|
373
|
-
return sum.plus(cartItemTotalPrice);
|
|
374
|
-
}, new import_decimal.default(0));
|
|
375
|
-
return subtotal.toFixed(2);
|
|
376
|
-
};
|
|
377
363
|
var calculateTaxFee = (shopInfo, items) => {
|
|
378
364
|
if (!(items == null ? void 0 : items.length)) {
|
|
379
365
|
return "0.00";
|
|
@@ -799,7 +785,6 @@ function resetItemsSurchargeSideEffects({ service, addons }) {
|
|
|
799
785
|
0 && (module.exports = {
|
|
800
786
|
calcDiscountListDifference,
|
|
801
787
|
calculateDeposit,
|
|
802
|
-
calculateOriginSubtotal,
|
|
803
788
|
calculatePriceDetails,
|
|
804
789
|
calculateSubtotal,
|
|
805
790
|
calculateTaxFee,
|
package/lib/plugins/window.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WalletPassEvaluator } from '../model';
|
|
2
1
|
import { Plugin } from '../types';
|
|
3
2
|
/**
|
|
4
3
|
* WindowPlugin 接口定义
|
|
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
|
|
|
15
14
|
document: Partial<Document>;
|
|
16
15
|
history: History;
|
|
17
16
|
interaction?: any;
|
|
18
|
-
getWalletPassEvaluator?: () => WalletPassEvaluator;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* 简单的 Storage 接口实现
|
|
@@ -144,7 +144,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
144
144
|
getSummary(): Promise<{
|
|
145
145
|
subtotal: string | number;
|
|
146
146
|
total: string | number;
|
|
147
|
-
originTotal: string | number;
|
|
148
147
|
taxTitle?: string | undefined;
|
|
149
148
|
totalTaxFee?: string | number | undefined;
|
|
150
149
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
@@ -1235,7 +1235,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
);
|
|
1237
1237
|
cartItems2.forEach((item, index) => {
|
|
1238
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1238
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1239
1239
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
1240
1240
|
const hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !(timeSlots == null ? void 0 : timeSlots.start_time);
|
|
1241
1241
|
if (hasOriginTimeSlot) {
|
|
@@ -1368,7 +1368,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1368
1368
|
const fastestResource = (0, import_timeslots.findFastestAvailableResource)({
|
|
1369
1369
|
resources: targetRenderList,
|
|
1370
1370
|
currentCapacity,
|
|
1371
|
-
countMap: selectResourcesMap
|
|
1371
|
+
countMap: selectResourcesMap,
|
|
1372
|
+
targetDate: (_k = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _k.date,
|
|
1373
|
+
durationMinutes: ((_l = item == null ? void 0 : item.duration) == null ? void 0 : _l.value) || ((_n = (_m = item == null ? void 0 : item._productOrigin) == null ? void 0 : _m.duration) == null ? void 0 : _n.value) || 10
|
|
1372
1374
|
});
|
|
1373
1375
|
const targetResource = fastestResource || targetRenderList[0];
|
|
1374
1376
|
targetResource.capacity = currentCapacity;
|
|
@@ -19,10 +19,12 @@ export declare function calculateResourceAvailableTime({ resource, timeSlots, cu
|
|
|
19
19
|
* @param countMap 已预约数量映射
|
|
20
20
|
* @returns 最快可用的资源
|
|
21
21
|
*/
|
|
22
|
-
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, }: {
|
|
22
|
+
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, targetDate, durationMinutes, }: {
|
|
23
23
|
resources: ResourceItem[];
|
|
24
24
|
currentCapacity?: number;
|
|
25
25
|
countMap?: Record<number, number>;
|
|
26
|
+
targetDate?: string | Dayjs;
|
|
27
|
+
durationMinutes?: number;
|
|
26
28
|
}): ResourceItem | null;
|
|
27
29
|
/**
|
|
28
30
|
* 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
|
|
@@ -77,10 +77,15 @@ function calculateResourceAvailableTime({
|
|
|
77
77
|
function findFastestAvailableResource({
|
|
78
78
|
resources,
|
|
79
79
|
currentCapacity = 1,
|
|
80
|
-
countMap = {}
|
|
80
|
+
countMap = {},
|
|
81
|
+
targetDate,
|
|
82
|
+
durationMinutes = 30
|
|
81
83
|
}) {
|
|
82
84
|
var _a, _b, _c;
|
|
83
85
|
const currentTime = (0, import_dayjs.default)();
|
|
86
|
+
const resolvedDuration = durationMinutes > 0 ? durationMinutes : 30;
|
|
87
|
+
const targetDay = targetDate ? (0, import_dayjs.default)(targetDate) : currentTime;
|
|
88
|
+
const isTargetDayToday = targetDay.isSame(currentTime, "day");
|
|
84
89
|
let fastestTime = null;
|
|
85
90
|
let fastestResources = [];
|
|
86
91
|
console.log("[TimeslotUtils] 查找最快可用资源:", {
|
|
@@ -90,19 +95,22 @@ function findFastestAvailableResource({
|
|
|
90
95
|
countMap
|
|
91
96
|
});
|
|
92
97
|
for (const resource of resources) {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
const targetDayTimes = resource.times.filter((time) => {
|
|
99
|
+
const isSameTargetDay = (0, import_dayjs.default)(time.start_at).isSame(targetDay, "day");
|
|
100
|
+
if (!isSameTargetDay)
|
|
101
|
+
return false;
|
|
102
|
+
if (!isTargetDayToday)
|
|
103
|
+
return true;
|
|
104
|
+
return (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
|
|
97
105
|
});
|
|
98
|
-
if (
|
|
106
|
+
if (targetDayTimes.length === 0) {
|
|
99
107
|
console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
|
|
100
108
|
continue;
|
|
101
109
|
}
|
|
102
|
-
for (const time of
|
|
110
|
+
for (const time of targetDayTimes) {
|
|
103
111
|
const workStartTime = (0, import_dayjs.default)(time.start_at);
|
|
104
112
|
const workEndTime = (0, import_dayjs.default)(time.end_at);
|
|
105
|
-
let nextAvailableTime = currentTime.
|
|
113
|
+
let nextAvailableTime = isTargetDayToday && currentTime.isAfter(workStartTime) ? currentTime : workStartTime;
|
|
106
114
|
console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
|
|
107
115
|
workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
|
|
108
116
|
checkStartTime: nextAvailableTime.format("HH:mm:ss"),
|
|
@@ -126,7 +134,7 @@ function findFastestAvailableResource({
|
|
|
126
134
|
pax: event.pax || 1
|
|
127
135
|
});
|
|
128
136
|
if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
|
|
129
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
137
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
|
|
130
138
|
finalAvailableTime = eventEnd;
|
|
131
139
|
console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
132
140
|
}
|
|
@@ -134,7 +142,7 @@ function findFastestAvailableResource({
|
|
|
134
142
|
const totalCapacity = resource.capacity || 0;
|
|
135
143
|
const currentUsedCapacity = countMap[resource.id] || 0;
|
|
136
144
|
const eventUsedCapacity = event.pax || 1;
|
|
137
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
145
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
|
|
138
146
|
const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
139
147
|
if (totalRequiredCapacity > totalCapacity) {
|
|
140
148
|
finalAvailableTime = eventEnd;
|
|
@@ -143,7 +151,7 @@ function findFastestAvailableResource({
|
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
|
-
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
154
|
+
if (finalAvailableTime.add(resolvedDuration, "minute").isAfter(workEndTime)) {
|
|
147
155
|
console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
|
|
148
156
|
continue;
|
|
149
157
|
}
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -222,7 +222,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
222
222
|
product_id: item.product_id,
|
|
223
223
|
product_variant_id: item.product_variant_id,
|
|
224
224
|
quantity: item.num,
|
|
225
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
226
225
|
// 商品是否含税:1;0
|
|
227
226
|
is_charge_tax: item.is_charge_tax ?? 0,
|
|
228
227
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -247,7 +246,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
247
246
|
},
|
|
248
247
|
product_bundle: (item.product_bundle || []).map((bundle) => {
|
|
249
248
|
return {
|
|
250
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
251
249
|
bundle_id: bundle.bundle_id,
|
|
252
250
|
bundle_product_id: bundle.bundle_product_id,
|
|
253
251
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
@@ -22,7 +22,6 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
22
22
|
getCurrentBookingTime(): string | null;
|
|
23
23
|
private filterDiscountListByBookingTime;
|
|
24
24
|
setCustomer(customer: Customer): Promise<void>;
|
|
25
|
-
setOriginTotalAmount(amount: number): void;
|
|
26
25
|
setHolders(holders: {
|
|
27
26
|
form_record_id: number;
|
|
28
27
|
}[]): void;
|
|
@@ -56,8 +56,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: void 0
|
|
60
|
-
orderTotalAmount: 0
|
|
59
|
+
bookingSubject: void 0
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
62
|
// =========== 生命周期方法 ===========
|
|
@@ -195,9 +194,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
195
194
|
);
|
|
196
195
|
}
|
|
197
196
|
}
|
|
198
|
-
setOriginTotalAmount(amount) {
|
|
199
|
-
this.store.orderTotalAmount = amount;
|
|
200
|
-
}
|
|
201
197
|
// 设置holders
|
|
202
198
|
setHolders(holders) {
|
|
203
199
|
this.store.holders = holders;
|
|
@@ -217,7 +213,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
217
213
|
{
|
|
218
214
|
productList,
|
|
219
215
|
discountList: this.getDiscountList(),
|
|
220
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
221
216
|
holders: this.store.holders || [],
|
|
222
217
|
isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
|
|
223
218
|
},
|
|
@@ -325,7 +320,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
325
320
|
productList: this.store.productList || [],
|
|
326
321
|
oldDiscountList: this.getDiscountList(),
|
|
327
322
|
newDiscountList: withScanList,
|
|
328
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
329
323
|
holders: this.store.holders || [],
|
|
330
324
|
isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
|
|
331
325
|
}) || {
|
|
@@ -394,7 +388,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
394
388
|
if (item.booking_id) {
|
|
395
389
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
396
390
|
(item.discount_list || []).forEach((discount) => {
|
|
397
|
-
var _a3, _b, _c, _d, _e
|
|
391
|
+
var _a3, _b, _c, _d, _e;
|
|
398
392
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
399
393
|
const index = editModeDiscountList.findIndex((n) => {
|
|
400
394
|
var _a4;
|
|
@@ -403,12 +397,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
403
397
|
if (index !== -1) {
|
|
404
398
|
editModeDiscountList[index] = {
|
|
405
399
|
...editModeDiscountList[index],
|
|
406
|
-
metadata: {
|
|
407
|
-
...discount.metadata || {},
|
|
408
|
-
num: (((_b = (_a3 = editModeDiscountList == null ? void 0 : editModeDiscountList[index]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b.num) || 1) + (((_c = discount.metadata) == null ? void 0 : _c.num) || 1)
|
|
409
|
-
},
|
|
410
400
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
411
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
401
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
412
402
|
};
|
|
413
403
|
} else {
|
|
414
404
|
if (discount.type && !discount.tag) {
|
|
@@ -416,20 +406,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
416
406
|
}
|
|
417
407
|
editModeDiscountList.push({
|
|
418
408
|
...discount,
|
|
419
|
-
metadata: {
|
|
420
|
-
...discount.metadata || {},
|
|
421
|
-
num: ((_e = discount.metadata) == null ? void 0 : _e.num) || 1
|
|
422
|
-
},
|
|
423
409
|
name: discount.name || discount.discount.title.auto,
|
|
424
410
|
isEditMode: true,
|
|
425
411
|
limited_relation_product_data: {},
|
|
426
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
412
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.product_discount_difference) || 0).toNumber(),
|
|
427
413
|
isAvailable: true,
|
|
428
|
-
id: ((
|
|
429
|
-
format_title: ((
|
|
414
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
415
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
430
416
|
isDisabled: true,
|
|
431
417
|
isSelected: true,
|
|
432
|
-
product_id: ((
|
|
418
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
433
419
|
});
|
|
434
420
|
}
|
|
435
421
|
}
|
|
@@ -546,7 +532,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
546
532
|
}
|
|
547
533
|
await this.core.effects.emit(
|
|
548
534
|
`${this.name}:onLoadDiscountList`,
|
|
549
|
-
|
|
535
|
+
filteredDiscountList
|
|
550
536
|
);
|
|
551
537
|
} catch (error) {
|
|
552
538
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
@@ -56,18 +56,14 @@ var isAllNormalProduct = (items) => {
|
|
|
56
56
|
};
|
|
57
57
|
var getDiscountAmount = (discount, total, price) => {
|
|
58
58
|
var _a;
|
|
59
|
-
let discountedPrice = 0;
|
|
60
59
|
if (discount.tag === "good_pass") {
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} else {
|
|
67
|
-
discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
68
|
-
}
|
|
60
|
+
return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
|
|
61
|
+
}
|
|
62
|
+
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
63
|
+
if (isFixedAmount) {
|
|
64
|
+
return Math.max(new import_decimal.default(price).minus(new import_decimal.default((discount.amount ?? discount.par_value) || 0)).toNumber(), 0);
|
|
69
65
|
}
|
|
70
|
-
return
|
|
66
|
+
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
71
67
|
};
|
|
72
68
|
var getDiscountListAmountTotal = (discount) => {
|
|
73
69
|
return discount.reduce((acc, cur) => {
|
package/package.json
CHANGED
package/dist/model/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './strategy';
|
package/dist/model/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./strategy";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { EvaluationResult, RuntimeContext } from '../type';
|
|
2
|
-
export interface BusinessAdapter {
|
|
3
|
-
/**
|
|
4
|
-
* 适配器名称
|
|
5
|
-
*/
|
|
6
|
-
name: string;
|
|
7
|
-
/**
|
|
8
|
-
* 适配器版本
|
|
9
|
-
*/
|
|
10
|
-
version: string;
|
|
11
|
-
/**
|
|
12
|
-
* 准备运行时上下文
|
|
13
|
-
* 将业务数据转换为策略引擎可识别的上下文
|
|
14
|
-
*/
|
|
15
|
-
prepareContext(businessData: any): RuntimeContext;
|
|
16
|
-
/**
|
|
17
|
-
* 转换执行结果
|
|
18
|
-
* 将策略引擎的通用结果转换为业务层需要的格式
|
|
19
|
-
*/
|
|
20
|
-
transformResult(result: EvaluationResult, businessData?: any): any;
|
|
21
|
-
/**
|
|
22
|
-
* 根据业务数据重新格式化配置
|
|
23
|
-
*/
|
|
24
|
-
formatConfig(result: EvaluationResult, businessData?: any): {
|
|
25
|
-
result: EvaluationResult;
|
|
26
|
-
businessData?: any;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { StrategyConfig } from '../../type';
|
|
2
|
-
import { Voucher, Product, VoucherEvaluationResult, EvaluatorInput } from './type';
|
|
3
|
-
/**
|
|
4
|
-
* Wallet Pass 评估器
|
|
5
|
-
* 用于评估哪些 voucher 可以在当前订单中使用
|
|
6
|
-
*/
|
|
7
|
-
export declare class WalletPassEvaluator {
|
|
8
|
-
private engine;
|
|
9
|
-
private strategyConfigs;
|
|
10
|
-
private locale;
|
|
11
|
-
constructor();
|
|
12
|
-
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
|
-
getStrategyConfigs(): StrategyConfig[];
|
|
14
|
-
setLocale(locale: string): void;
|
|
15
|
-
getText(key: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* 搜索券的格式
|
|
18
|
-
* @param input 输入
|
|
19
|
-
* @returns 返回搜索券的格式
|
|
20
|
-
*/
|
|
21
|
-
searchVoucherFormat(input: EvaluatorInput): Voucher[];
|
|
22
|
-
/**
|
|
23
|
-
* 评估可用的 vouchers
|
|
24
|
-
*/
|
|
25
|
-
evaluate(input: EvaluatorInput): VoucherEvaluationResult[];
|
|
26
|
-
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
27
|
-
checkVoucherAvailability(input: EvaluatorInput): {
|
|
28
|
-
isAvailable: boolean;
|
|
29
|
-
config: {
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* 获取推荐券
|
|
35
|
-
* @param input 输入
|
|
36
|
-
* @returns 返回推荐券列表
|
|
37
|
-
*/
|
|
38
|
-
getRecommendedVouchers(input: EvaluatorInput): {
|
|
39
|
-
recommendedAmount: any;
|
|
40
|
-
recommended: any[];
|
|
41
|
-
transformList: any[];
|
|
42
|
-
noApplicableVoucher: Voucher[];
|
|
43
|
-
};
|
|
44
|
-
enhanceWithReason(voucher: any): any;
|
|
45
|
-
/**
|
|
46
|
-
* 优惠券处理函数
|
|
47
|
-
* @param applicableVouchers 可用的券列表
|
|
48
|
-
* @param orderTotalAmount 订单总金额
|
|
49
|
-
* @param products 订单商品列表
|
|
50
|
-
* @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
|
|
51
|
-
*/
|
|
52
|
-
processVouchers(vouchers: Voucher[], orderTotalAmount: number, products: Product[]): {
|
|
53
|
-
recommended: any[];
|
|
54
|
-
transformList: any[];
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* 重新计算优惠券状态(基于已选券的增量计算)
|
|
58
|
-
* @param allVouchers 所有原始券列表
|
|
59
|
-
* @param selectedVouchers 已选中的券列表(按选中顺序)
|
|
60
|
-
* @param orderTotalAmount 订单总金额
|
|
61
|
-
* @param products 订单商品列表
|
|
62
|
-
* @returns 返回更新后的所有券列表和已选券的详细抵扣信息
|
|
63
|
-
*/
|
|
64
|
-
recalculateVouchers(allVouchers: any[], selectedVouchers: any[], orderTotalAmount: number, products: any[]): {
|
|
65
|
-
allWithUpdatedStatus: any[];
|
|
66
|
-
selectedWithDetails: any[];
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* 查找适用于指定 voucher 的策略配置
|
|
70
|
-
*/
|
|
71
|
-
private findApplicableStrategies;
|
|
72
|
-
/**
|
|
73
|
-
* 检查策略中是否包含指定的 voucher ID
|
|
74
|
-
*/
|
|
75
|
-
private checkVoucherInStrategy;
|
|
76
|
-
/**
|
|
77
|
-
* 递归检查条件组中是否包含 voucher ID
|
|
78
|
-
*/
|
|
79
|
-
private checkVoucherInConditionGroup;
|
|
80
|
-
/**
|
|
81
|
-
* 计算适用商品的总金额和数量
|
|
82
|
-
*/
|
|
83
|
-
private calculateApplicableProducts;
|
|
84
|
-
}
|