@pisell/pisellos 2.1.93 → 2.1.95
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 +0 -11
- package/dist/modules/Discount/types.d.ts +0 -16
- 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/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +128 -541
- package/dist/modules/Rules/types.d.ts +0 -1
- 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 +1 -2
- package/dist/solution/BookingByStep/index.js +5 -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 +0 -9
- package/lib/modules/Discount/types.d.ts +0 -16
- 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/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +261 -667
- package/lib/modules/Rules/types.d.ts +0 -1
- 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 +1 -2
- package/lib/solution/BookingByStep/index.js +3 -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 -497
- 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 -23
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -165
- 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 -965
- 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 -421
- 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 -51
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -165
- 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 -660
- 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
|
@@ -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;
|
|
@@ -311,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
310
|
date: string;
|
|
312
311
|
status: string;
|
|
313
312
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
313
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
314
|
}[]>;
|
|
316
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
316
|
private getScheduleDataByIds;
|
|
@@ -1774,10 +1774,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1774
1774
|
currentStartTime: currentStartTime2,
|
|
1775
1775
|
times
|
|
1776
1776
|
}) {
|
|
1777
|
+
var _a4;
|
|
1777
1778
|
const currentStart = (0, import_dayjs.default)(currentStartTime2);
|
|
1778
1779
|
let earliestBlockStart;
|
|
1779
1780
|
for (const time of times || []) {
|
|
1780
|
-
|
|
1781
|
+
const blockedTimes = (_a4 = time.event_list) == null ? void 0 : _a4.filter((event) => event.type !== "schedule_event");
|
|
1782
|
+
for (const event of blockedTimes || []) {
|
|
1781
1783
|
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
1782
1784
|
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
1783
1785
|
if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
|
|
@@ -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
|
-
}
|