@pisell/pisellos 2.1.149 → 2.1.151
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 +1 -0
- package/dist/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Discount/types.d.ts +19 -1
- package/dist/modules/Order/index.d.ts +1 -65
- package/dist/modules/Order/index.js +30 -899
- package/dist/modules/Order/types.d.ts +12 -174
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -4
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +677 -168
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -11
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +52 -41
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -7
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Discount/types.d.ts +19 -1
- package/lib/modules/Order/index.d.ts +1 -65
- package/lib/modules/Order/index.js +1 -513
- package/lib/modules/Order/types.d.ts +12 -174
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +780 -288
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -9
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +31 -22
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +22 -8
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +1 -1
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -152
- package/dist/solution/ScanOrder/index.js +0 -3132
- package/dist/solution/ScanOrder/types.d.ts +0 -287
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -167
- package/dist/solution/ScanOrder/utils.js +0 -764
- package/dist/solution/VenueBooking/index.d.ts +0 -199
- package/dist/solution/VenueBooking/index.js +0 -3459
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -154
- package/dist/solution/VenueBooking/types.js +0 -21
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -104
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -239
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -453
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -152
- package/lib/solution/ScanOrder/index.js +0 -1901
- package/lib/solution/ScanOrder/types.d.ts +0 -287
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -167
- package/lib/solution/ScanOrder/utils.js +0 -635
- package/lib/solution/VenueBooking/index.d.ts +0 -199
- package/lib/solution/VenueBooking/index.js +0 -1926
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -154
- package/lib/solution/VenueBooking/types.js +0 -44
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -110
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -237
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -339
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -28,6 +28,7 @@ export interface RulesModuleAPI {
|
|
|
28
28
|
calcDiscount: (params: {
|
|
29
29
|
discountList: any[];
|
|
30
30
|
productList: any[];
|
|
31
|
+
orderTotalAmount: number;
|
|
31
32
|
holders: {
|
|
32
33
|
form_record_id: number;
|
|
33
34
|
}[];
|
|
@@ -66,6 +67,7 @@ export interface RulesParamsHooks {
|
|
|
66
67
|
quantity?: number;
|
|
67
68
|
bundle?: any[];
|
|
68
69
|
main_product_selling_price?: string | number;
|
|
70
|
+
options?: any[];
|
|
69
71
|
}) => Record<string, any>;
|
|
70
72
|
}
|
|
71
73
|
export {};
|
|
@@ -70,7 +70,7 @@ var isInStandardSchedule = (targetDate, targetDateString, targetTimeString, sche
|
|
|
70
70
|
}
|
|
71
71
|
const startDate = (0, import_dayjs.default)(schedule.start_time);
|
|
72
72
|
const endDate = (0, import_dayjs.default)(schedule.end_time);
|
|
73
|
-
const isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.
|
|
73
|
+
const isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate);
|
|
74
74
|
if (schedule.repeat_type === "none") {
|
|
75
75
|
return isInBasicRange;
|
|
76
76
|
}
|
|
@@ -80,14 +80,16 @@ var isInTimeSlotsSchedule = (targetDate, targetDateString, targetTimeString, sch
|
|
|
80
80
|
if (!schedule.start_time) {
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
83
|
+
const scheduleDate = schedule.start_time.split(" ")[0];
|
|
84
|
+
if (targetDateString !== scheduleDate) {
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
for (const timeSlot of schedule.time_slot) {
|
|
88
|
-
const slotStart =
|
|
89
|
-
const slotEnd =
|
|
90
|
-
|
|
88
|
+
const slotStart = `${scheduleDate} ${timeSlot.start_time}:00`;
|
|
89
|
+
const slotEnd = `${scheduleDate} ${timeSlot.end_time}:00`;
|
|
90
|
+
const slotStartDate = (0, import_dayjs.default)(slotStart);
|
|
91
|
+
const slotEndDate = (0, import_dayjs.default)(slotEnd);
|
|
92
|
+
if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
|
|
91
93
|
return true;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -102,7 +104,7 @@ var isInDesignationSchedule = (targetDate, targetDateString, targetTimeString, s
|
|
|
102
104
|
const endDateTime = `${designation.end_date} ${designation.end_time}:00`;
|
|
103
105
|
const startDate = (0, import_dayjs.default)(startDateTime);
|
|
104
106
|
const endDate = (0, import_dayjs.default)(endDateTime);
|
|
105
|
-
if (targetDate.isSameOrAfter(startDate) && targetDate.
|
|
107
|
+
if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
|
|
106
108
|
return true;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -156,7 +158,7 @@ var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
|
156
158
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
157
159
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
158
160
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
159
|
-
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay
|
|
161
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
160
162
|
};
|
|
161
163
|
var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
162
164
|
const targetDayOfWeek = targetDate.day();
|
|
@@ -173,7 +175,7 @@ var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
|
|
|
173
175
|
const targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
|
|
174
176
|
const startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
|
|
175
177
|
const endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
|
|
176
|
-
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay
|
|
178
|
+
return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
|
|
177
179
|
};
|
|
178
180
|
var getScheduleStartEndTimePoints = (date, scheduleList) => {
|
|
179
181
|
if (!date || !scheduleList || scheduleList.length === 0) {
|
|
@@ -46,7 +46,7 @@ export declare const formatScheduleResult: (schedule: ScheduleItem) => {
|
|
|
46
46
|
};
|
|
47
47
|
export declare const calcScheduleDateRange: (schedule: ScheduleItem) => any[];
|
|
48
48
|
export declare const calcCalendarDataBySchedules: (schedules: ScheduleItem[]) => unknown[];
|
|
49
|
-
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) =>
|
|
49
|
+
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) => {};
|
|
50
50
|
/**
|
|
51
51
|
* @title: 格式化日程数据
|
|
52
52
|
* @description:
|
|
@@ -7,8 +7,8 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], i
|
|
|
7
7
|
* @param item
|
|
8
8
|
*/
|
|
9
9
|
export declare const getBundleDiscountList: (bundle: any[]) => any[];
|
|
10
|
-
export declare const calcDiscountListDifference: (discountList: any[]) =>
|
|
11
|
-
export declare const getProductDiscountProductDiscountDifference: (item: CartItem) =>
|
|
10
|
+
export declare const calcDiscountListDifference: (discountList: any[]) => any;
|
|
11
|
+
export declare const getProductDiscountProductDiscountDifference: (item: CartItem) => any;
|
|
12
12
|
/**
|
|
13
13
|
* 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
|
|
14
14
|
*
|
|
@@ -58,6 +58,12 @@ 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;
|
|
61
67
|
/**
|
|
62
68
|
* @title: 单个商品的税费
|
|
63
69
|
* @description:
|
|
@@ -94,7 +100,7 @@ export declare const calculateDeposit: (items: CartItem[]) => {
|
|
|
94
100
|
export declare const getSurchargeAmount: ({ bookingDetail, bookingId }: {
|
|
95
101
|
bookingDetail?: any;
|
|
96
102
|
bookingId?: number | undefined;
|
|
97
|
-
}, surcharge: any[], options: any) =>
|
|
103
|
+
}, surcharge: any[], options: any) => any;
|
|
98
104
|
/**
|
|
99
105
|
* 订单附加费各项信息
|
|
100
106
|
*
|
|
@@ -31,6 +31,7 @@ var utils_exports = {};
|
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
calcDiscountListDifference: () => calcDiscountListDifference,
|
|
33
33
|
calculateDeposit: () => calculateDeposit,
|
|
34
|
+
calculateOriginSubtotal: () => calculateOriginSubtotal,
|
|
34
35
|
calculatePriceDetails: () => calculatePriceDetails,
|
|
35
36
|
calculateSubtotal: () => calculateSubtotal,
|
|
36
37
|
calculateTaxFee: () => calculateTaxFee,
|
|
@@ -46,6 +47,7 @@ var import_utils = require("../Product/utils");
|
|
|
46
47
|
var import_dayjs = __toESM(require("dayjs"));
|
|
47
48
|
var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList, scheduleById) => {
|
|
48
49
|
const subtotal = new import_decimal.default(calculateSubtotal(items));
|
|
50
|
+
const subOriginTotal = new import_decimal.default(calculateOriginSubtotal(items));
|
|
49
51
|
const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
|
|
50
52
|
const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate, surcharge_list: surchargeList, scheduleById });
|
|
51
53
|
const surchargeAmount = new import_decimal.default(getSurchargeAmount({ bookingDetail: null, bookingId: void 0 }, surcharge, { isEdit: false }));
|
|
@@ -59,10 +61,12 @@ var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList,
|
|
|
59
61
|
is_price_include_tax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
|
|
60
62
|
});
|
|
61
63
|
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);
|
|
62
65
|
const deposit = calculateDeposit(items);
|
|
63
66
|
return {
|
|
64
67
|
subtotal: subtotal.toFixed(2),
|
|
65
68
|
total: total.toFixed(2),
|
|
69
|
+
originTotal: originTotal.toFixed(2),
|
|
66
70
|
taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
|
|
67
71
|
taxRate: shopInfo == null ? void 0 : shopInfo.tax_rate,
|
|
68
72
|
totalTaxFee: tax,
|
|
@@ -87,8 +91,8 @@ var getBundleDiscountList = (bundle) => {
|
|
|
87
91
|
var calcDiscountListDifference = (discountList) => {
|
|
88
92
|
return discountList.reduce((pre, cur) => {
|
|
89
93
|
var _a;
|
|
90
|
-
return pre
|
|
91
|
-
},
|
|
94
|
+
return pre + (((_a = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a.product_discount_difference) || 0);
|
|
95
|
+
}, 0);
|
|
92
96
|
};
|
|
93
97
|
var getProductDiscountProductDiscountDifference = (item) => {
|
|
94
98
|
var _a, _b, _c, _d;
|
|
@@ -360,6 +364,16 @@ var calculateSubtotal = (items) => {
|
|
|
360
364
|
}, new import_decimal.default(0));
|
|
361
365
|
return subtotal.toFixed(2);
|
|
362
366
|
};
|
|
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
|
+
};
|
|
363
377
|
var calculateTaxFee = (shopInfo, items) => {
|
|
364
378
|
if (!(items == null ? void 0 : items.length)) {
|
|
365
379
|
return "0.00";
|
|
@@ -408,8 +422,8 @@ var getSurchargeAmount = ({ bookingDetail, bookingId }, surcharge, options) => {
|
|
|
408
422
|
if (!Array.isArray(surcharge))
|
|
409
423
|
return 0;
|
|
410
424
|
return surcharge.reduce((total, item) => {
|
|
411
|
-
return total
|
|
412
|
-
},
|
|
425
|
+
return total + (item.value || 0);
|
|
426
|
+
}, 0);
|
|
413
427
|
};
|
|
414
428
|
var getBundleItemIsOriginalPrice = (item) => {
|
|
415
429
|
return (item == null ? void 0 : item.price_type) === "markup" && (item == null ? void 0 : item.price_type_ext) === "product_price";
|
|
@@ -429,24 +443,18 @@ var getDiscountAmount = (discounts) => {
|
|
|
429
443
|
}, new import_decimal.default(0)).toNumber();
|
|
430
444
|
};
|
|
431
445
|
var getMainProductTotal = (item) => {
|
|
432
|
-
var _a, _b, _c, _d, _e, _f
|
|
433
|
-
let total = new import_decimal.default(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
total = total.minus(mainProductDiscountAmount);
|
|
445
|
-
if ((item == null ? void 0 : item.option) && Array.isArray(item == null ? void 0 : item.option)) {
|
|
446
|
-
total = total.add(item == null ? void 0 : item.option.reduce((t, option) => {
|
|
447
|
-
return t.add(new import_decimal.default(option.price || 0).mul(option.num || 1));
|
|
448
|
-
}, new import_decimal.default(0)));
|
|
449
|
-
}
|
|
446
|
+
var _a, _b, _c, _d, _e, _f;
|
|
447
|
+
let total = new import_decimal.default((item == null ? void 0 : item.main_product_selling_price) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.main_product_selling_price) ?? item.price ?? 0);
|
|
448
|
+
const discount = ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_f = (_e = (_d = item == null ? void 0 : item._originData) == null ? void 0 : _d.product) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.filter((item2) => {
|
|
449
|
+
var _a2;
|
|
450
|
+
return !((_a2 = item2 == null ? void 0 : item2.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
451
|
+
})) || [];
|
|
452
|
+
const mainProductDiscountAmount = getDiscountAmount(discount);
|
|
453
|
+
total = total.minus(mainProductDiscountAmount);
|
|
454
|
+
if ((item == null ? void 0 : item.option) && Array.isArray(item == null ? void 0 : item.option)) {
|
|
455
|
+
total = total.add(item == null ? void 0 : item.option.reduce((t, option) => {
|
|
456
|
+
return t.add(new import_decimal.default(option.price || 0).mul(option.num || 1));
|
|
457
|
+
}, new import_decimal.default(0)));
|
|
450
458
|
}
|
|
451
459
|
for (let bundleItem of (item == null ? void 0 : item.bundle) || []) {
|
|
452
460
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
@@ -791,6 +799,7 @@ function resetItemsSurchargeSideEffects({ service, addons }) {
|
|
|
791
799
|
0 && (module.exports = {
|
|
792
800
|
calcDiscountListDifference,
|
|
793
801
|
calculateDeposit,
|
|
802
|
+
calculateOriginSubtotal,
|
|
794
803
|
calculatePriceDetails,
|
|
795
804
|
calculateSubtotal,
|
|
796
805
|
calculateTaxFee,
|
package/lib/modules/index.d.ts
CHANGED
|
@@ -11,8 +11,4 @@ export * from './Payment';
|
|
|
11
11
|
export * from './Resource';
|
|
12
12
|
export * from './Step';
|
|
13
13
|
export * from './Summary';
|
|
14
|
-
export * from './SalesSummary';
|
|
15
14
|
export * from './Schedule';
|
|
16
|
-
export * from './Quotation';
|
|
17
|
-
export * from './ScanOrderLogger';
|
|
18
|
-
export * from './OpenData';
|
package/lib/modules/index.js
CHANGED
|
@@ -29,11 +29,7 @@ __reExport(modules_exports, require("./Payment"), module.exports);
|
|
|
29
29
|
__reExport(modules_exports, require("./Resource"), module.exports);
|
|
30
30
|
__reExport(modules_exports, require("./Step"), module.exports);
|
|
31
31
|
__reExport(modules_exports, require("./Summary"), module.exports);
|
|
32
|
-
__reExport(modules_exports, require("./SalesSummary"), module.exports);
|
|
33
32
|
__reExport(modules_exports, require("./Schedule"), module.exports);
|
|
34
|
-
__reExport(modules_exports, require("./Quotation"), module.exports);
|
|
35
|
-
__reExport(modules_exports, require("./ScanOrderLogger"), module.exports);
|
|
36
|
-
__reExport(modules_exports, require("./OpenData"), module.exports);
|
|
37
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
34
|
0 && (module.exports = {
|
|
39
35
|
...require("./Product"),
|
|
@@ -49,9 +45,5 @@ __reExport(modules_exports, require("./OpenData"), module.exports);
|
|
|
49
45
|
...require("./Resource"),
|
|
50
46
|
...require("./Step"),
|
|
51
47
|
...require("./Summary"),
|
|
52
|
-
...require("./
|
|
53
|
-
...require("./Schedule"),
|
|
54
|
-
...require("./Quotation"),
|
|
55
|
-
...require("./ScanOrderLogger"),
|
|
56
|
-
...require("./OpenData")
|
|
48
|
+
...require("./Schedule")
|
|
57
49
|
});
|
package/lib/plugins/window.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WalletPassEvaluator } from '../model';
|
|
1
2
|
import { Plugin } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* WindowPlugin 接口定义
|
|
@@ -14,6 +15,7 @@ export interface WindowPlugin extends Plugin {
|
|
|
14
15
|
document: Partial<Document>;
|
|
15
16
|
history: History;
|
|
16
17
|
interaction?: any;
|
|
18
|
+
getWalletPassEvaluator?: () => WalletPassEvaluator;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* 简单的 Storage 接口实现
|
|
@@ -144,6 +144,7 @@ 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;
|
|
147
148
|
taxTitle?: string | undefined;
|
|
148
149
|
totalTaxFee?: string | number | undefined;
|
|
149
150
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
@@ -301,7 +302,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
301
302
|
autoSelectAllProductResources(resources_code: string, timeSlots?: TimeSliceItem): {
|
|
302
303
|
errorList: any[];
|
|
303
304
|
};
|
|
304
|
-
getTimeSlotByAllResources(resources_code: string
|
|
305
|
+
getTimeSlotByAllResources(resources_code: string): any[];
|
|
305
306
|
getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }: {
|
|
306
307
|
resources_code: string;
|
|
307
308
|
startDate: string;
|
|
@@ -310,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
311
|
date: string;
|
|
311
312
|
status: string;
|
|
312
313
|
week: string;
|
|
313
|
-
weekNum: 0 | 2 | 1 | 5 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
314
315
|
}[]>;
|
|
315
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
317
|
private getScheduleDataByIds;
|
|
@@ -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;
|
|
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,9 +1368,7 @@ 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
|
|
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
|
|
1371
|
+
countMap: selectResourcesMap
|
|
1374
1372
|
});
|
|
1375
1373
|
const targetResource = fastestResource || targetRenderList[0];
|
|
1376
1374
|
targetResource.capacity = currentCapacity;
|
|
@@ -1407,7 +1405,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1407
1405
|
return { errorList };
|
|
1408
1406
|
}
|
|
1409
1407
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1410
|
-
getTimeSlotByAllResources(resources_code
|
|
1408
|
+
getTimeSlotByAllResources(resources_code) {
|
|
1411
1409
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1412
1410
|
let dateRange = this.store.date.getDateRange();
|
|
1413
1411
|
const resources = [];
|
|
@@ -1565,7 +1563,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1565
1563
|
resourcesMap,
|
|
1566
1564
|
duration,
|
|
1567
1565
|
currentDate: dateRange[0].date,
|
|
1568
|
-
split,
|
|
1566
|
+
split: 10,
|
|
1569
1567
|
resourcesUseableMap,
|
|
1570
1568
|
capacity: maxCapacity,
|
|
1571
1569
|
cut_off_time: maxCutOffTime,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule,
|
|
1
|
+
import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
|
|
2
2
|
export interface BookingByStepState {
|
|
3
3
|
cart: CartModule;
|
|
4
4
|
summary: SummaryModule;
|
|
@@ -14,8 +14,6 @@ export interface BookingByStepState {
|
|
|
14
14
|
currentProduct?: ProductData;
|
|
15
15
|
currentProductMeta?: Record<string, any>;
|
|
16
16
|
schedule: ScheduleModule;
|
|
17
|
-
salesSummary?: SalesSummaryModule;
|
|
18
|
-
scanOrderLogger?: ScanOrderLoggerModule;
|
|
19
17
|
}
|
|
20
18
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
21
19
|
export declare enum BookingByStepHooks {
|
|
@@ -36,11 +36,6 @@ function createModule(moduleName, solutionName, name, version) {
|
|
|
36
36
|
`${solutionName}_${name || moduleName}`,
|
|
37
37
|
version
|
|
38
38
|
);
|
|
39
|
-
case "salesSummary":
|
|
40
|
-
return new import_modules.SalesSummaryModule(
|
|
41
|
-
`${solutionName}_${name || moduleName}`,
|
|
42
|
-
version
|
|
43
|
-
);
|
|
44
39
|
case "step":
|
|
45
40
|
return new import_modules.StepModule(
|
|
46
41
|
`${solutionName}_${name || moduleName}`,
|
|
@@ -76,11 +71,6 @@ function createModule(moduleName, solutionName, name, version) {
|
|
|
76
71
|
`${solutionName}_${name || moduleName}`,
|
|
77
72
|
version
|
|
78
73
|
);
|
|
79
|
-
case "scanOrderLogger":
|
|
80
|
-
return new import_modules.ScanOrderLoggerModule(
|
|
81
|
-
`${solutionName}_${name || moduleName}`,
|
|
82
|
-
version
|
|
83
|
-
);
|
|
84
74
|
default:
|
|
85
75
|
throw new Error(`Unknown module type: ${moduleName}`);
|
|
86
76
|
}
|
|
@@ -19,12 +19,10 @@ 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, }: {
|
|
23
23
|
resources: ResourceItem[];
|
|
24
24
|
currentCapacity?: number;
|
|
25
25
|
countMap?: Record<number, number>;
|
|
26
|
-
targetDate?: string | Dayjs;
|
|
27
|
-
durationMinutes?: number;
|
|
28
26
|
}): ResourceItem | null;
|
|
29
27
|
/**
|
|
30
28
|
* 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
|
|
@@ -77,15 +77,10 @@ function calculateResourceAvailableTime({
|
|
|
77
77
|
function findFastestAvailableResource({
|
|
78
78
|
resources,
|
|
79
79
|
currentCapacity = 1,
|
|
80
|
-
countMap = {}
|
|
81
|
-
targetDate,
|
|
82
|
-
durationMinutes = 30
|
|
80
|
+
countMap = {}
|
|
83
81
|
}) {
|
|
84
82
|
var _a, _b, _c;
|
|
85
83
|
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");
|
|
89
84
|
let fastestTime = null;
|
|
90
85
|
let fastestResources = [];
|
|
91
86
|
console.log("[TimeslotUtils] 查找最快可用资源:", {
|
|
@@ -95,22 +90,19 @@ function findFastestAvailableResource({
|
|
|
95
90
|
countMap
|
|
96
91
|
});
|
|
97
92
|
for (const resource of resources) {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!isTargetDayToday)
|
|
103
|
-
return true;
|
|
104
|
-
return (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
|
|
93
|
+
const todayTimes = resource.times.filter((time) => {
|
|
94
|
+
const isToday = (0, import_dayjs.default)(time.start_at).isSame(currentTime, "day");
|
|
95
|
+
const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
|
|
96
|
+
return isToday && isStillWorking;
|
|
105
97
|
});
|
|
106
|
-
if (
|
|
98
|
+
if (todayTimes.length === 0) {
|
|
107
99
|
console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
|
|
108
100
|
continue;
|
|
109
101
|
}
|
|
110
|
-
for (const time of
|
|
102
|
+
for (const time of todayTimes) {
|
|
111
103
|
const workStartTime = (0, import_dayjs.default)(time.start_at);
|
|
112
104
|
const workEndTime = (0, import_dayjs.default)(time.end_at);
|
|
113
|
-
let nextAvailableTime =
|
|
105
|
+
let nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
|
|
114
106
|
console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
|
|
115
107
|
workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
|
|
116
108
|
checkStartTime: nextAvailableTime.format("HH:mm:ss"),
|
|
@@ -134,7 +126,7 @@ function findFastestAvailableResource({
|
|
|
134
126
|
pax: event.pax || 1
|
|
135
127
|
});
|
|
136
128
|
if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
|
|
137
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
129
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
|
|
138
130
|
finalAvailableTime = eventEnd;
|
|
139
131
|
console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
140
132
|
}
|
|
@@ -142,7 +134,7 @@ function findFastestAvailableResource({
|
|
|
142
134
|
const totalCapacity = resource.capacity || 0;
|
|
143
135
|
const currentUsedCapacity = countMap[resource.id] || 0;
|
|
144
136
|
const eventUsedCapacity = event.pax || 1;
|
|
145
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
137
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
|
|
146
138
|
const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
147
139
|
if (totalRequiredCapacity > totalCapacity) {
|
|
148
140
|
finalAvailableTime = eventEnd;
|
|
@@ -151,7 +143,7 @@ function findFastestAvailableResource({
|
|
|
151
143
|
}
|
|
152
144
|
}
|
|
153
145
|
}
|
|
154
|
-
if (finalAvailableTime.
|
|
146
|
+
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
155
147
|
console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
|
|
156
148
|
continue;
|
|
157
149
|
}
|
|
@@ -222,6 +222,7 @@ 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,
|
|
225
226
|
// 商品是否含税:1;0
|
|
226
227
|
is_charge_tax: item.is_charge_tax ?? 0,
|
|
227
228
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -246,6 +247,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
246
247
|
},
|
|
247
248
|
product_bundle: (item.product_bundle || []).map((bundle) => {
|
|
248
249
|
return {
|
|
250
|
+
is_price_include_tax: item.is_price_include_tax,
|
|
249
251
|
bundle_id: bundle.bundle_id,
|
|
250
252
|
bundle_product_id: bundle.bundle_product_id,
|
|
251
253
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
@@ -22,6 +22,7 @@ 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;
|
|
25
26
|
setHolders(holders: {
|
|
26
27
|
form_record_id: number;
|
|
27
28
|
}[]): void;
|
|
@@ -56,7 +56,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: void 0
|
|
59
|
+
bookingSubject: void 0,
|
|
60
|
+
orderTotalAmount: 0
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
// =========== 生命周期方法 ===========
|
|
@@ -194,6 +195,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
194
195
|
);
|
|
195
196
|
}
|
|
196
197
|
}
|
|
198
|
+
setOriginTotalAmount(amount) {
|
|
199
|
+
this.store.orderTotalAmount = amount;
|
|
200
|
+
}
|
|
197
201
|
// 设置holders
|
|
198
202
|
setHolders(holders) {
|
|
199
203
|
this.store.holders = holders;
|
|
@@ -213,6 +217,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
213
217
|
{
|
|
214
218
|
productList,
|
|
215
219
|
discountList: this.getDiscountList(),
|
|
220
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
216
221
|
holders: this.store.holders || [],
|
|
217
222
|
isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
|
|
218
223
|
},
|
|
@@ -320,6 +325,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
320
325
|
productList: this.store.productList || [],
|
|
321
326
|
oldDiscountList: this.getDiscountList(),
|
|
322
327
|
newDiscountList: withScanList,
|
|
328
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
323
329
|
holders: this.store.holders || [],
|
|
324
330
|
isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
|
|
325
331
|
}) || {
|
|
@@ -388,7 +394,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
388
394
|
if (item.booking_id) {
|
|
389
395
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
390
396
|
(item.discount_list || []).forEach((discount) => {
|
|
391
|
-
var _a3, _b, _c, _d, _e;
|
|
397
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
392
398
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
393
399
|
const index = editModeDiscountList.findIndex((n) => {
|
|
394
400
|
var _a4;
|
|
@@ -397,8 +403,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
397
403
|
if (index !== -1) {
|
|
398
404
|
editModeDiscountList[index] = {
|
|
399
405
|
...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
|
+
},
|
|
400
410
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
401
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
411
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
402
412
|
};
|
|
403
413
|
} else {
|
|
404
414
|
if (discount.type && !discount.tag) {
|
|
@@ -406,16 +416,20 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
406
416
|
}
|
|
407
417
|
editModeDiscountList.push({
|
|
408
418
|
...discount,
|
|
419
|
+
metadata: {
|
|
420
|
+
...discount.metadata || {},
|
|
421
|
+
num: ((_e = discount.metadata) == null ? void 0 : _e.num) || 1
|
|
422
|
+
},
|
|
409
423
|
name: discount.name || discount.discount.title.auto,
|
|
410
424
|
isEditMode: true,
|
|
411
425
|
limited_relation_product_data: {},
|
|
412
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
426
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_f = discount == null ? void 0 : discount.metadata) == null ? void 0 : _f.product_discount_difference) || 0).toNumber(),
|
|
413
427
|
isAvailable: true,
|
|
414
|
-
id: ((
|
|
415
|
-
format_title: ((
|
|
428
|
+
id: ((_g = discount.discount) == null ? void 0 : _g.resource_id) || discount.id,
|
|
429
|
+
format_title: ((_h = discount.discount) == null ? void 0 : _h.title) || discount.format_title,
|
|
416
430
|
isDisabled: true,
|
|
417
431
|
isSelected: true,
|
|
418
|
-
product_id: ((
|
|
432
|
+
product_id: ((_i = discount.discount) == null ? void 0 : _i.product_id) || discount.product_id
|
|
419
433
|
});
|
|
420
434
|
}
|
|
421
435
|
}
|
|
@@ -532,7 +546,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
532
546
|
}
|
|
533
547
|
await this.core.effects.emit(
|
|
534
548
|
`${this.name}:onLoadDiscountList`,
|
|
535
|
-
|
|
549
|
+
newDiscountList
|
|
536
550
|
);
|
|
537
551
|
} catch (error) {
|
|
538
552
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
@@ -56,14 +56,18 @@ var isAllNormalProduct = (items) => {
|
|
|
56
56
|
};
|
|
57
57
|
var getDiscountAmount = (discount, total, price) => {
|
|
58
58
|
var _a;
|
|
59
|
+
let discountedPrice = 0;
|
|
59
60
|
if (discount.tag === "good_pass") {
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
discountedPrice = new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
|
|
62
|
+
} else {
|
|
63
|
+
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
64
|
+
if (isFixedAmount) {
|
|
65
|
+
discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
|
|
66
|
+
} else {
|
|
67
|
+
discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
|
-
return
|
|
70
|
+
return discountedPrice;
|
|
67
71
|
};
|
|
68
72
|
var getDiscountListAmountTotal = (discount) => {
|
|
69
73
|
return discount.reduce((acc, cur) => {
|