@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
|
@@ -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 {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule,
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule, ScheduleModule } from "../../modules";
|
|
2
2
|
export function createModule(moduleName, solutionName, name, version) {
|
|
3
3
|
switch (moduleName) {
|
|
4
4
|
case 'cart':
|
|
5
5
|
return new CartModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
6
6
|
case 'summary':
|
|
7
7
|
return new SummaryModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
8
|
-
case 'salesSummary':
|
|
9
|
-
return new SalesSummaryModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
10
8
|
case 'step':
|
|
11
9
|
return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
12
10
|
case 'products':
|
|
@@ -21,8 +19,6 @@ export function createModule(moduleName, solutionName, name, version) {
|
|
|
21
19
|
return new PaymentModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
22
20
|
case 'schedule':
|
|
23
21
|
return new ScheduleModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
24
|
-
case 'scanOrderLogger':
|
|
25
|
-
return new ScanOrderLoggerModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
26
22
|
default:
|
|
27
23
|
throw new Error("Unknown module type: ".concat(moduleName));
|
|
28
24
|
}
|
|
@@ -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
|
* 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
|
|
@@ -91,14 +91,8 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
91
91
|
_ref2$currentCapacity = _ref2.currentCapacity,
|
|
92
92
|
currentCapacity = _ref2$currentCapacity === void 0 ? 1 : _ref2$currentCapacity,
|
|
93
93
|
_ref2$countMap = _ref2.countMap,
|
|
94
|
-
countMap = _ref2$countMap === void 0 ? {} : _ref2$countMap
|
|
95
|
-
targetDate = _ref2.targetDate,
|
|
96
|
-
_ref2$durationMinutes = _ref2.durationMinutes,
|
|
97
|
-
durationMinutes = _ref2$durationMinutes === void 0 ? 30 : _ref2$durationMinutes;
|
|
94
|
+
countMap = _ref2$countMap === void 0 ? {} : _ref2$countMap;
|
|
98
95
|
var currentTime = dayjs();
|
|
99
|
-
var resolvedDuration = durationMinutes > 0 ? durationMinutes : 30;
|
|
100
|
-
var targetDay = targetDate ? dayjs(targetDate) : currentTime;
|
|
101
|
-
var isTargetDayToday = targetDay.isSame(currentTime, 'day');
|
|
102
96
|
var fastestTime = null;
|
|
103
97
|
var fastestResources = [];
|
|
104
98
|
console.log('[TimeslotUtils] 查找最快可用资源:', {
|
|
@@ -114,18 +108,17 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
114
108
|
try {
|
|
115
109
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
116
110
|
var _resource = _step2.value;
|
|
117
|
-
//
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return dayjs(time.end_at).isAfter(currentTime);
|
|
111
|
+
// 获取资源当天且还在工作时间内的时间段
|
|
112
|
+
var todayTimes = _resource.times.filter(function (time) {
|
|
113
|
+
var isToday = dayjs(time.start_at).isSame(currentTime, 'day');
|
|
114
|
+
var isStillWorking = dayjs(time.end_at).isAfter(currentTime);
|
|
115
|
+
return isToday && isStillWorking;
|
|
123
116
|
});
|
|
124
|
-
if (
|
|
117
|
+
if (todayTimes.length === 0) {
|
|
125
118
|
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, ") \u4ECA\u65E5\u65E0\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
126
119
|
continue;
|
|
127
120
|
}
|
|
128
|
-
var _iterator4 = _createForOfIteratorHelper(
|
|
121
|
+
var _iterator4 = _createForOfIteratorHelper(todayTimes),
|
|
129
122
|
_step4;
|
|
130
123
|
try {
|
|
131
124
|
var _loop = function _loop() {
|
|
@@ -135,7 +128,7 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
135
128
|
var workEndTime = dayjs(time.end_at);
|
|
136
129
|
|
|
137
130
|
// 确定检查的起始时间(当前时间 vs 工作开始时间)
|
|
138
|
-
var nextAvailableTime =
|
|
131
|
+
var nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
|
|
139
132
|
console.log("[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, "):"), {
|
|
140
133
|
workTime: "".concat(workStartTime.format('HH:mm'), "-").concat(workEndTime.format('HH:mm')),
|
|
141
134
|
checkStartTime: nextAvailableTime.format('HH:mm:ss'),
|
|
@@ -172,7 +165,7 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
172
165
|
// 检查资源类型和容量
|
|
173
166
|
if (_resource.resourceType === 'single' || (_resource.capacity || 1) === 1) {
|
|
174
167
|
// 单人预约资源:检查时间冲突
|
|
175
|
-
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(
|
|
168
|
+
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
|
|
176
169
|
// 有冲突,使用事件结束时间
|
|
177
170
|
finalAvailableTime = _eventEnd;
|
|
178
171
|
console.log("[TimeslotUtils] \u53D1\u73B0\u65F6\u95F4\u51B2\u7A81\uFF0C\u8C03\u6574\u5230: ".concat(finalAvailableTime.format('HH:mm:ss')));
|
|
@@ -184,7 +177,7 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
184
177
|
var eventUsedCapacity = _event.pax || 1;
|
|
185
178
|
|
|
186
179
|
// 如果在事件时间范围内,检查容量是否足够
|
|
187
|
-
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(
|
|
180
|
+
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
|
|
188
181
|
var totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
189
182
|
if (totalRequiredCapacity > totalCapacity) {
|
|
190
183
|
// 容量不足,使用事件结束时间
|
|
@@ -201,7 +194,7 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
201
194
|
} finally {
|
|
202
195
|
_iterator5.f();
|
|
203
196
|
}
|
|
204
|
-
if (finalAvailableTime.
|
|
197
|
+
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
205
198
|
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, " \u53EF\u7528\u65F6\u95F4\u8D85\u51FA\u5DE5\u4F5C\u65F6\u95F4\uFF0C\u8DF3\u8FC7"));
|
|
206
199
|
return 0; // continue
|
|
207
200
|
}
|
|
@@ -403,6 +403,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
403
403
|
product_id: item.product_id,
|
|
404
404
|
product_variant_id: item.product_variant_id,
|
|
405
405
|
quantity: item.num,
|
|
406
|
+
is_price_include_tax: item.is_price_include_tax,
|
|
406
407
|
// 商品是否含税:1;0
|
|
407
408
|
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
409
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -427,6 +428,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
427
428
|
},
|
|
428
429
|
product_bundle: (item.product_bundle || []).map(function (bundle) {
|
|
429
430
|
return {
|
|
431
|
+
is_price_include_tax: item.is_price_include_tax,
|
|
430
432
|
bundle_id: bundle.bundle_id,
|
|
431
433
|
bundle_product_id: bundle.bundle_product_id,
|
|
432
434
|
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 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: undefined
|
|
59
|
+
bookingSubject: undefined,
|
|
60
|
+
orderTotalAmount: 0
|
|
60
61
|
};
|
|
61
62
|
return _this;
|
|
62
63
|
}
|
|
@@ -288,7 +289,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
289
|
return _setCustomer.apply(this, arguments);
|
|
289
290
|
}
|
|
290
291
|
return setCustomer;
|
|
291
|
-
}()
|
|
292
|
+
}()
|
|
293
|
+
}, {
|
|
294
|
+
key: "setOriginTotalAmount",
|
|
295
|
+
value: function setOriginTotalAmount(amount) {
|
|
296
|
+
this.store.orderTotalAmount = amount;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 设置holders
|
|
292
300
|
}, {
|
|
293
301
|
key: "setHolders",
|
|
294
302
|
value: function setHolders(holders) {
|
|
@@ -316,6 +324,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
324
|
var _ref = rulesModule.calcDiscount({
|
|
317
325
|
productList: productList,
|
|
318
326
|
discountList: this.getDiscountList(),
|
|
327
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
319
328
|
holders: this.store.holders || [],
|
|
320
329
|
isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
|
|
321
330
|
}, options) || {
|
|
@@ -495,6 +504,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
504
|
productList: this.store.productList || [],
|
|
496
505
|
oldDiscountList: this.getDiscountList(),
|
|
497
506
|
newDiscountList: withScanList,
|
|
507
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
498
508
|
holders: this.store.holders || [],
|
|
499
509
|
isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
|
|
500
510
|
}) || {
|
|
@@ -608,21 +618,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
608
618
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
609
619
|
});
|
|
610
620
|
if (index !== -1) {
|
|
611
|
-
var _discount$metadata;
|
|
621
|
+
var _editModeDiscountList, _discount$metadata, _discount$metadata2;
|
|
612
622
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
623
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
624
|
+
num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
|
|
625
|
+
}),
|
|
613
626
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
614
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
627
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
615
628
|
});
|
|
616
629
|
} else {
|
|
617
|
-
var _discount$
|
|
630
|
+
var _discount$metadata3, _discount$metadata4, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
618
631
|
if (discount.type && !discount.tag) {
|
|
619
632
|
discount.tag = discount.type;
|
|
620
633
|
}
|
|
621
634
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
635
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
636
|
+
num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
|
|
637
|
+
}),
|
|
622
638
|
name: discount.name || discount.discount.title.auto,
|
|
623
639
|
isEditMode: true,
|
|
624
640
|
limited_relation_product_data: {},
|
|
625
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
641
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.product_discount_difference) || 0).toNumber(),
|
|
626
642
|
isAvailable: true,
|
|
627
643
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
628
644
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -815,7 +831,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
815
831
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
816
832
|
case 19:
|
|
817
833
|
_context10.next = 21;
|
|
818
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"),
|
|
834
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
819
835
|
case 21:
|
|
820
836
|
_context10.next = 26;
|
|
821
837
|
break;
|
|
@@ -8,4 +8,5 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
8
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
9
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
10
10
|
return ShopDiscountHooks;
|
|
11
|
-
}({});
|
|
11
|
+
}({});
|
|
12
|
+
;
|
|
@@ -40,23 +40,37 @@ export var isAllNormalProduct = function isAllNormalProduct(items) {
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
|
|
43
|
-
var
|
|
43
|
+
var discountedPrice = 0;
|
|
44
|
+
|
|
44
45
|
// 商品券
|
|
45
46
|
if (discount.tag === 'good_pass') {
|
|
46
|
-
|
|
47
|
+
discountedPrice = new Decimal(price).minus(new Decimal(price || 0)).toNumber();
|
|
48
|
+
} else {
|
|
49
|
+
var _discount$metadata;
|
|
50
|
+
// 判断是否是固定金额
|
|
51
|
+
var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
|
|
52
|
+
|
|
53
|
+
// 固定金额 小于0时返回0
|
|
54
|
+
if (isFixedAmount) {
|
|
55
|
+
discountedPrice = Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
|
|
56
|
+
} else {
|
|
57
|
+
// 百分比:根据折扣卡金额计算
|
|
58
|
+
discountedPrice = new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
59
|
+
}
|
|
47
60
|
}
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
/*
|
|
63
|
+
// 🔥 如果有 maxDeductionAmount 限制,确保折扣金额不超过限制
|
|
64
|
+
if (discount.config?.maxDeductionAmount) {
|
|
65
|
+
const actualDiscountAmount = new Decimal(price).minus(discountedPrice).toNumber();
|
|
66
|
+
if (actualDiscountAmount > discount.config.maxDeductionAmount) {
|
|
67
|
+
// 折扣金额超过限制,重新计算折扣后价格
|
|
68
|
+
discountedPrice = new Decimal(price).minus(discount.config.maxDeductionAmount).toNumber();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
*/
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
73
|
+
return discountedPrice;
|
|
60
74
|
};
|
|
61
75
|
export var getDiscountListAmountTotal = function getDiscountListAmountTotal(discount) {
|
|
62
76
|
return discount.reduce(function (acc, cur) {
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __reExport(src_exports, require("./types"), module.exports);
|
|
|
38
38
|
__reExport(src_exports, require("./modules"), module.exports);
|
|
39
39
|
__reExport(src_exports, require("./plugins"), module.exports);
|
|
40
40
|
__reExport(src_exports, require("./solution"), module.exports);
|
|
41
|
+
__reExport(src_exports, require("./model"), module.exports);
|
|
41
42
|
var import_core = require("./core");
|
|
42
43
|
var import_core2 = __toESM(require("./core"));
|
|
43
44
|
var src_default = import_core2.default;
|
|
@@ -47,5 +48,6 @@ var src_default = import_core2.default;
|
|
|
47
48
|
...require("./types"),
|
|
48
49
|
...require("./modules"),
|
|
49
50
|
...require("./plugins"),
|
|
50
|
-
...require("./solution")
|
|
51
|
+
...require("./solution"),
|
|
52
|
+
...require("./model")
|
|
51
53
|
});
|
|
@@ -512,14 +512,21 @@ var PromotionEvaluator = class {
|
|
|
512
512
|
unitProducts.push({
|
|
513
513
|
product,
|
|
514
514
|
price: product.price,
|
|
515
|
-
productId: product.id
|
|
515
|
+
productId: product.id,
|
|
516
|
+
sourceAvailableQty: availableQty
|
|
516
517
|
});
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
520
|
if (unitProducts.length === 0) {
|
|
520
521
|
return { products: [], originalAmount: 0, finalAmount: 0 };
|
|
521
522
|
}
|
|
522
|
-
unitProducts.sort((a, b) =>
|
|
523
|
+
unitProducts.sort((a, b) => {
|
|
524
|
+
const aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
525
|
+
const bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
526
|
+
if (aIsMultiple !== bIsMultiple)
|
|
527
|
+
return bIsMultiple - aIsMultiple;
|
|
528
|
+
return b.price - a.price;
|
|
529
|
+
});
|
|
523
530
|
const totalUnits = unitProducts.length;
|
|
524
531
|
const groupCount = cumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
525
532
|
const promotionUnits = groupCount * x;
|
|
@@ -573,7 +580,9 @@ var PromotionEvaluator = class {
|
|
|
573
580
|
(sum, p) => sum.plus(p),
|
|
574
581
|
new import_decimal.default(0)
|
|
575
582
|
);
|
|
576
|
-
const
|
|
583
|
+
const productOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
584
|
+
const actualTotal = import_decimal.default.min(totalAllocated, productOriginalAmount);
|
|
585
|
+
const finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
577
586
|
result.push({
|
|
578
587
|
...product,
|
|
579
588
|
quantity: promoQty,
|
|
@@ -584,9 +593,8 @@ var PromotionEvaluator = class {
|
|
|
584
593
|
isSplit: false,
|
|
585
594
|
matchedBundleIndex
|
|
586
595
|
});
|
|
587
|
-
const productOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
588
596
|
originalAmount = originalAmount.plus(productOriginalAmount);
|
|
589
|
-
finalAmount = finalAmount.plus(
|
|
597
|
+
finalAmount = finalAmount.plus(actualTotal);
|
|
590
598
|
} else if (promoQty === 0 && remainingQty > 0) {
|
|
591
599
|
result.push({
|
|
592
600
|
...product,
|
|
@@ -605,7 +613,9 @@ var PromotionEvaluator = class {
|
|
|
605
613
|
(sum, p) => sum.plus(p),
|
|
606
614
|
new import_decimal.default(0)
|
|
607
615
|
);
|
|
608
|
-
const
|
|
616
|
+
const promoOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
617
|
+
const actualTotal = import_decimal.default.min(totalAllocated, promoOriginalAmount);
|
|
618
|
+
const finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
609
619
|
result.push({
|
|
610
620
|
...product,
|
|
611
621
|
id: this.generateRandomId(),
|
|
@@ -618,9 +628,8 @@ var PromotionEvaluator = class {
|
|
|
618
628
|
matchedBundleIndex,
|
|
619
629
|
isSplit: true
|
|
620
630
|
});
|
|
621
|
-
const promoOriginalAmount = new import_decimal.default(product.price).mul(promoQty);
|
|
622
631
|
originalAmount = originalAmount.plus(promoOriginalAmount);
|
|
623
|
-
finalAmount = finalAmount.plus(
|
|
632
|
+
finalAmount = finalAmount.plus(actualTotal);
|
|
624
633
|
result.push({
|
|
625
634
|
...product,
|
|
626
635
|
quantity: remainingQty,
|
|
@@ -636,6 +645,46 @@ var PromotionEvaluator = class {
|
|
|
636
645
|
}
|
|
637
646
|
processedQuantityMap.set(key, processedQty + availableQty);
|
|
638
647
|
}
|
|
648
|
+
if (groupCount > 0) {
|
|
649
|
+
const expectedPromoTotal = new import_decimal.default(groupPrice).mul(groupCount);
|
|
650
|
+
const promoItems = result.filter((p) => p.inPromotion);
|
|
651
|
+
let actualPromoTotal = new import_decimal.default(0);
|
|
652
|
+
for (const p of promoItems) {
|
|
653
|
+
actualPromoTotal = actualPromoTotal.plus(
|
|
654
|
+
new import_decimal.default(p.finalPrice).mul(p.quantity)
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
const roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
|
|
658
|
+
if (!roundingDiff.eq(0)) {
|
|
659
|
+
const adjustTarget = promoItems.find((p) => p.quantity === 1);
|
|
660
|
+
if (adjustTarget) {
|
|
661
|
+
adjustTarget.finalPrice = this.formatPrice(
|
|
662
|
+
new import_decimal.default(adjustTarget.finalPrice).minus(roundingDiff)
|
|
663
|
+
);
|
|
664
|
+
} else if (promoItems.length > 0) {
|
|
665
|
+
const lastPromo = promoItems[promoItems.length - 1];
|
|
666
|
+
const adjustedUnitPrice = this.formatPrice(
|
|
667
|
+
new import_decimal.default(lastPromo.finalPrice).minus(roundingDiff)
|
|
668
|
+
);
|
|
669
|
+
lastPromo.quantity -= 1;
|
|
670
|
+
lastPromo.isSplit = true;
|
|
671
|
+
result.push({
|
|
672
|
+
...lastPromo,
|
|
673
|
+
id: this.generateRandomId(),
|
|
674
|
+
originalId: lastPromo.originalId || lastPromo.id,
|
|
675
|
+
quantity: 1,
|
|
676
|
+
finalPrice: adjustedUnitPrice,
|
|
677
|
+
isSplit: true
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
finalAmount = new import_decimal.default(0);
|
|
681
|
+
for (const p of result) {
|
|
682
|
+
finalAmount = finalAmount.plus(
|
|
683
|
+
new import_decimal.default(p.finalPrice).mul(p.quantity)
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
639
688
|
return {
|
|
640
689
|
products: result,
|
|
641
690
|
originalAmount: originalAmount.toNumber(),
|
|
@@ -8,10 +8,12 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
+
private otherParams;
|
|
11
12
|
constructor();
|
|
12
13
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
13
14
|
getStrategyConfigs(): StrategyConfig[];
|
|
14
15
|
setLocale(locale: string): void;
|
|
16
|
+
setOtherParams(otherParams: any): void;
|
|
15
17
|
getText(key: string): string;
|
|
16
18
|
/**
|
|
17
19
|
* 搜索券的格式
|
|
@@ -45,10 +45,27 @@ var defaultStrategyMetadataCustom = {
|
|
|
45
45
|
maxPassesPerItem: 0,
|
|
46
46
|
deductOptionPrice: false
|
|
47
47
|
};
|
|
48
|
+
var FIELD_REASON_CODE_MAP = {
|
|
49
|
+
orderTotalAmount: "order_total_amount_not_enough",
|
|
50
|
+
applicableProductTotalAmount: "applicable_product_total_amount_not_enough",
|
|
51
|
+
applicableProductCount: "applicable_product_count_not_enough"
|
|
52
|
+
};
|
|
53
|
+
var AMOUNT_FIELDS = /* @__PURE__ */ new Set([
|
|
54
|
+
"orderTotalAmount",
|
|
55
|
+
"applicableProductTotalAmount"
|
|
56
|
+
]);
|
|
57
|
+
function formatReason(template, value, currency = "") {
|
|
58
|
+
if (!template)
|
|
59
|
+
return template;
|
|
60
|
+
const v = value === void 0 || value === null ? "" : String(value);
|
|
61
|
+
const c = currency === void 0 || currency === null ? "" : String(currency);
|
|
62
|
+
return template.replace(/\$\{value\}/g, () => v).replace(/\{value\}/g, () => v).replace(/\{currency\}/g, () => c);
|
|
63
|
+
}
|
|
48
64
|
var WalletPassEvaluator = class {
|
|
49
65
|
constructor() {
|
|
50
66
|
this.strategyConfigs = [];
|
|
51
67
|
this.locale = "en";
|
|
68
|
+
this.otherParams = {};
|
|
52
69
|
this.engine = new import__.StrategyEngine({
|
|
53
70
|
debug: false,
|
|
54
71
|
enableTrace: false
|
|
@@ -64,6 +81,9 @@ var WalletPassEvaluator = class {
|
|
|
64
81
|
setLocale(locale) {
|
|
65
82
|
this.locale = locale;
|
|
66
83
|
}
|
|
84
|
+
setOtherParams(otherParams) {
|
|
85
|
+
this.otherParams = otherParams;
|
|
86
|
+
}
|
|
67
87
|
getText(key) {
|
|
68
88
|
var _a, _b;
|
|
69
89
|
return (_b = (_a = import_locales.locales) == null ? void 0 : _a[this.locale]) == null ? void 0 : _b[key];
|
|
@@ -101,7 +121,7 @@ var WalletPassEvaluator = class {
|
|
|
101
121
|
* 评估可用的 vouchers
|
|
102
122
|
*/
|
|
103
123
|
evaluate(input) {
|
|
104
|
-
var _a, _b;
|
|
124
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
105
125
|
const { orderTotalAmount, products, vouchers, strategyConfigs } = input;
|
|
106
126
|
const productIds = products.map((p) => p.product_id);
|
|
107
127
|
const results = [];
|
|
@@ -176,7 +196,13 @@ var WalletPassEvaluator = class {
|
|
|
176
196
|
});
|
|
177
197
|
} else {
|
|
178
198
|
let reasonCode = "not_meet_the_required_conditions";
|
|
179
|
-
|
|
199
|
+
let thresholdValue = void 0;
|
|
200
|
+
const failedField = (_c = evaluationResult.matched) == null ? void 0 : _c.failedField;
|
|
201
|
+
const failedRule = (_e = (_d = evaluationResult.matched) == null ? void 0 : _d.failedRules) == null ? void 0 : _e[0];
|
|
202
|
+
if (failedField && FIELD_REASON_CODE_MAP[failedField]) {
|
|
203
|
+
reasonCode = FIELD_REASON_CODE_MAP[failedField];
|
|
204
|
+
thresholdValue = failedRule == null ? void 0 : failedRule.value;
|
|
205
|
+
} else if (evaluationResult.code) {
|
|
180
206
|
const codeMapping = {
|
|
181
207
|
INSUFFICIENT_AMOUNT: "not_meet_the_required_conditions",
|
|
182
208
|
USAGE_LIMIT_EXCEEDED: "usage_limit_reached",
|
|
@@ -186,6 +212,10 @@ var WalletPassEvaluator = class {
|
|
|
186
212
|
};
|
|
187
213
|
reasonCode = codeMapping[evaluationResult.code] || "not_meet_the_required_conditions";
|
|
188
214
|
}
|
|
215
|
+
const rawText = this.getText(reasonCode);
|
|
216
|
+
const currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_g = (_f = this.otherParams) == null ? void 0 : _f.getData) == null ? void 0 : _g.call(_f, "shop_symbol")) || "" : "";
|
|
217
|
+
console.log(currency, "currency12345");
|
|
218
|
+
const reason = thresholdValue !== void 0 ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
189
219
|
results.push({
|
|
190
220
|
voucher,
|
|
191
221
|
isApplicable: false,
|
|
@@ -193,7 +223,7 @@ var WalletPassEvaluator = class {
|
|
|
193
223
|
maxDeduction: 0,
|
|
194
224
|
deductTaxAndFee: false,
|
|
195
225
|
applicableProductIds: [],
|
|
196
|
-
reason
|
|
226
|
+
reason,
|
|
197
227
|
reasonCode,
|
|
198
228
|
strategyResult: evaluationResult
|
|
199
229
|
});
|
|
@@ -386,6 +416,7 @@ var WalletPassEvaluator = class {
|
|
|
386
416
|
* 计算适用商品的总金额和数量
|
|
387
417
|
*/
|
|
388
418
|
calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
419
|
+
console.log(products, "products1234");
|
|
389
420
|
let total = 0;
|
|
390
421
|
let count = 0;
|
|
391
422
|
if (applicableProductIds !== null && applicableProductIds.length === 0) {
|
|
@@ -29,7 +29,10 @@ var locales = {
|
|
|
29
29
|
"usage_limit_reached": "已达到使用次数上限",
|
|
30
30
|
"max_passes_per_item_reached": "该商品已达到卡券使用上限",
|
|
31
31
|
"not_available_for_this_channel": "当前渠道不可使用",
|
|
32
|
-
"not_valid_for_this_order_type": "当前订单类型不适用"
|
|
32
|
+
"not_valid_for_this_order_type": "当前订单类型不适用",
|
|
33
|
+
"order_total_amount_not_enough": "满 {currency}{value} 可用",
|
|
34
|
+
"applicable_product_total_amount_not_enough": "满 {currency}{value} 可用",
|
|
35
|
+
"applicable_product_count_not_enough": "至少 {value} 件"
|
|
33
36
|
},
|
|
34
37
|
"en": {
|
|
35
38
|
"not_meet_the_required_conditions": "Not meet the required conditions.",
|
|
@@ -37,7 +40,10 @@ var locales = {
|
|
|
37
40
|
"usage_limit_reached": "Usage limit reached.",
|
|
38
41
|
"max_passes_per_item_reached": "Max passes per item reached.",
|
|
39
42
|
"not_available_for_this_channel": "Not available for this channel.",
|
|
40
|
-
"not_valid_for_this_order_type": "Not valid for this order type."
|
|
43
|
+
"not_valid_for_this_order_type": "Not valid for this order type.",
|
|
44
|
+
"order_total_amount_not_enough": "Spend {currency}{value} to use",
|
|
45
|
+
"applicable_product_total_amount_not_enough": "Spend {currency}{value} to use",
|
|
46
|
+
"applicable_product_count_not_enough": "Min. Qty {value}"
|
|
41
47
|
},
|
|
42
48
|
"zh-HK": {
|
|
43
49
|
"not_meet_the_required_conditions": "未達使用條件",
|
|
@@ -45,7 +51,10 @@ var locales = {
|
|
|
45
51
|
"usage_limit_reached": "已達使用次數上限",
|
|
46
52
|
"max_passes_per_item_reached": "該商品已達卡券使用上限",
|
|
47
53
|
"not_available_for_this_channel": "當前渠道不可使用",
|
|
48
|
-
"not_valid_for_this_order_type": "當前訂單類型不適用"
|
|
54
|
+
"not_valid_for_this_order_type": "當前訂單類型不適用",
|
|
55
|
+
"order_total_amount_not_enough": "滿 {currency}{value} 可用",
|
|
56
|
+
"applicable_product_total_amount_not_enough": "滿 {currency}{value} 可用",
|
|
57
|
+
"applicable_product_count_not_enough": "至少 {value} 件"
|
|
49
58
|
}
|
|
50
59
|
};
|
|
51
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -27,17 +27,30 @@ export declare class StrategyEngine {
|
|
|
27
27
|
*
|
|
28
28
|
* @param group 条件组
|
|
29
29
|
* @param context 运行时上下文
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
|
|
31
31
|
*/
|
|
32
32
|
private evaluateConditionGroup;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 评估条件组的逻辑运算(带失败规则收集)
|
|
35
|
+
*
|
|
36
|
+
* 失败规则收集策略:
|
|
37
|
+
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
38
|
+
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
39
|
+
* - `not`:被取反规则实际通过时,记录该规则
|
|
40
|
+
*/
|
|
41
|
+
private evaluateGroupLogicDetailed;
|
|
42
|
+
/**
|
|
43
|
+
* 评估单个规则(带失败规则收集)
|
|
44
|
+
*/
|
|
45
|
+
private evaluateRuleDetailed;
|
|
46
|
+
/**
|
|
47
|
+
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
35
48
|
*/
|
|
36
|
-
private
|
|
49
|
+
private evaluateAtomicRule;
|
|
37
50
|
/**
|
|
38
|
-
*
|
|
51
|
+
* 构建失败规则信息
|
|
39
52
|
*/
|
|
40
|
-
private
|
|
53
|
+
private buildFailedRuleInfo;
|
|
41
54
|
/**
|
|
42
55
|
* 评估代码模式条件
|
|
43
56
|
*/
|