@pisell/pisellos 2.1.119 → 2.1.121
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +58 -1
- package/dist/modules/Order/index.js +796 -29
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +28 -0
- package/dist/modules/Order/utils.js +250 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +245 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +4 -1
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +513 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +397 -0
- package/dist/solution/VenueBooking/index.d.ts +163 -0
- package/dist/solution/VenueBooking/index.js +2931 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +130 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +58 -1
- package/lib/modules/Order/index.js +437 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +28 -0
- package/lib/modules/Order/utils.js +250 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +149 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +4 -1
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +452 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +359 -0
- package/lib/solution/VenueBooking/index.d.ts +163 -0
- package/lib/solution/VenueBooking/index.js +1578 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +130 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WalletPass 评估器使用示例
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { WalletPassEvaluator } from "./evaluator";
|
|
6
|
+
|
|
7
|
+
// ============================================
|
|
8
|
+
// 准备测试数据
|
|
9
|
+
// ============================================
|
|
10
|
+
|
|
11
|
+
// 1. 商品列表
|
|
12
|
+
var products = [{
|
|
13
|
+
product_id: 60734,
|
|
14
|
+
price: 80,
|
|
15
|
+
quantity: 1,
|
|
16
|
+
name: '商品A'
|
|
17
|
+
}, {
|
|
18
|
+
product_id: 60735,
|
|
19
|
+
price: 50,
|
|
20
|
+
quantity: 2,
|
|
21
|
+
name: '商品B'
|
|
22
|
+
}];
|
|
23
|
+
|
|
24
|
+
// 订单总金额 = 80 + 50*2 = 180
|
|
25
|
+
|
|
26
|
+
// 2. Voucher 列表
|
|
27
|
+
var vouchers = [{
|
|
28
|
+
id: 'VOUCHER_001',
|
|
29
|
+
amount: 10,
|
|
30
|
+
balance: 10,
|
|
31
|
+
type: 'cash_voucher'
|
|
32
|
+
}, {
|
|
33
|
+
id: 'VOUCHER_002',
|
|
34
|
+
amount: 20,
|
|
35
|
+
balance: 20,
|
|
36
|
+
type: 'cash_voucher'
|
|
37
|
+
}, {
|
|
38
|
+
id: 'VOUCHER_003',
|
|
39
|
+
amount: 50,
|
|
40
|
+
balance: 50,
|
|
41
|
+
type: 'cash_voucher'
|
|
42
|
+
}];
|
|
43
|
+
|
|
44
|
+
// 3. 策略配置
|
|
45
|
+
var strategyConfigs = [
|
|
46
|
+
// 策略1: 满100减10,适用于 VOUCHER_001
|
|
47
|
+
{
|
|
48
|
+
metadata: {
|
|
49
|
+
id: 'STRATEGY_001',
|
|
50
|
+
name: '满100减10',
|
|
51
|
+
type: 'wallet_pass',
|
|
52
|
+
custom: {
|
|
53
|
+
maxDeductionAmount: 10,
|
|
54
|
+
// 最大抵扣10元
|
|
55
|
+
maxUsagePerOrder: 1,
|
|
56
|
+
// 每单最多用1张
|
|
57
|
+
deductTaxAndFee: true,
|
|
58
|
+
// 抵扣税费
|
|
59
|
+
applicableProductIds: [60734, 60735] // 适用于这两个商品
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
conditions: {
|
|
63
|
+
operator: 'and',
|
|
64
|
+
rules: [
|
|
65
|
+
// 匹配 voucher ID
|
|
66
|
+
{
|
|
67
|
+
type: 'operator',
|
|
68
|
+
field: 'voucherId',
|
|
69
|
+
operator: 'in',
|
|
70
|
+
value: ['VOUCHER_001']
|
|
71
|
+
},
|
|
72
|
+
// 适用商品总额需 >= 100
|
|
73
|
+
{
|
|
74
|
+
type: 'operator',
|
|
75
|
+
field: 'applicableProductTotal',
|
|
76
|
+
operator: '>=',
|
|
77
|
+
value: 100
|
|
78
|
+
}],
|
|
79
|
+
actionIds: ['deduct_10']
|
|
80
|
+
},
|
|
81
|
+
actions: [{
|
|
82
|
+
id: 'deduct_10',
|
|
83
|
+
type: 'DEDUCT_AMOUNT',
|
|
84
|
+
value: 10,
|
|
85
|
+
target: 'applicable_products',
|
|
86
|
+
priority: 1
|
|
87
|
+
}]
|
|
88
|
+
},
|
|
89
|
+
// 策略2: 满150减20,适用于 VOUCHER_002
|
|
90
|
+
{
|
|
91
|
+
metadata: {
|
|
92
|
+
id: 'STRATEGY_002',
|
|
93
|
+
name: '满150减20',
|
|
94
|
+
type: 'wallet_pass',
|
|
95
|
+
custom: {
|
|
96
|
+
maxDeductionAmount: 20,
|
|
97
|
+
maxUsagePerOrder: 1,
|
|
98
|
+
deductTaxAndFee: true,
|
|
99
|
+
applicableProductIds: [60734, 60735]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
conditions: {
|
|
103
|
+
operator: 'and',
|
|
104
|
+
rules: [{
|
|
105
|
+
type: 'operator',
|
|
106
|
+
field: 'voucherId',
|
|
107
|
+
operator: 'in',
|
|
108
|
+
value: ['VOUCHER_002']
|
|
109
|
+
}, {
|
|
110
|
+
type: 'operator',
|
|
111
|
+
field: 'applicableProductTotal',
|
|
112
|
+
operator: '>=',
|
|
113
|
+
value: 150
|
|
114
|
+
}],
|
|
115
|
+
actionIds: ['deduct_20']
|
|
116
|
+
},
|
|
117
|
+
actions: [{
|
|
118
|
+
id: 'deduct_20',
|
|
119
|
+
type: 'DEDUCT_AMOUNT',
|
|
120
|
+
value: 20,
|
|
121
|
+
target: 'applicable_products',
|
|
122
|
+
priority: 1
|
|
123
|
+
}]
|
|
124
|
+
},
|
|
125
|
+
// 策略3: 满200减50,适用于 VOUCHER_003
|
|
126
|
+
{
|
|
127
|
+
metadata: {
|
|
128
|
+
id: 'STRATEGY_003',
|
|
129
|
+
name: '满200减50',
|
|
130
|
+
type: 'wallet_pass',
|
|
131
|
+
custom: {
|
|
132
|
+
maxDeductionAmount: 50,
|
|
133
|
+
maxUsagePerOrder: 2,
|
|
134
|
+
deductTaxAndFee: false,
|
|
135
|
+
applicableProductIds: [60734, 60735]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
conditions: {
|
|
139
|
+
operator: 'and',
|
|
140
|
+
rules: [{
|
|
141
|
+
type: 'operator',
|
|
142
|
+
field: 'voucherId',
|
|
143
|
+
operator: 'in',
|
|
144
|
+
value: ['VOUCHER_003']
|
|
145
|
+
}, {
|
|
146
|
+
type: 'operator',
|
|
147
|
+
field: 'applicableProductTotal',
|
|
148
|
+
operator: '>=',
|
|
149
|
+
value: 200
|
|
150
|
+
}],
|
|
151
|
+
actionIds: ['deduct_50']
|
|
152
|
+
},
|
|
153
|
+
actions: [{
|
|
154
|
+
id: 'deduct_50',
|
|
155
|
+
type: 'DEDUCT_AMOUNT',
|
|
156
|
+
value: 50,
|
|
157
|
+
target: 'applicable_products',
|
|
158
|
+
priority: 1
|
|
159
|
+
}]
|
|
160
|
+
}];
|
|
161
|
+
|
|
162
|
+
// ============================================
|
|
163
|
+
// 执行评估
|
|
164
|
+
// ============================================
|
|
165
|
+
|
|
166
|
+
function runExample() {
|
|
167
|
+
console.log('========== WalletPass 评估器示例 ==========\n');
|
|
168
|
+
|
|
169
|
+
// 创建评估器实例
|
|
170
|
+
var evaluator = new WalletPassEvaluator();
|
|
171
|
+
|
|
172
|
+
// 执行评估
|
|
173
|
+
var results = evaluator.evaluate({
|
|
174
|
+
orderTotalAmount: 180,
|
|
175
|
+
products: products,
|
|
176
|
+
vouchers: vouchers,
|
|
177
|
+
strategyConfigs: strategyConfigs
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// 输出结果
|
|
181
|
+
console.log('订单信息:');
|
|
182
|
+
console.log("- \u603B\u91D1\u989D: ".concat(180, " \u5143"));
|
|
183
|
+
console.log("- \u5546\u54C1: ".concat(products.map(function (p) {
|
|
184
|
+
return "".concat(p.name, "(").concat(p.quantity, "\u4EF6)");
|
|
185
|
+
}).join(', '), "\n"));
|
|
186
|
+
console.log('评估结果:\n');
|
|
187
|
+
results.forEach(function (result, index) {
|
|
188
|
+
console.log("Voucher ".concat(index + 1, ": ").concat(result.voucher.id));
|
|
189
|
+
console.log(" \u9762\u989D: ".concat(result.voucher.amount, " \u5143"));
|
|
190
|
+
console.log(" \u53EF\u7528: ".concat(result.isApplicable ? '✅ 是' : '❌ 否'));
|
|
191
|
+
if (result.isApplicable) {
|
|
192
|
+
console.log(" \u6700\u5927\u62B5\u6263: ".concat(result.maxDeduction, " \u5143"));
|
|
193
|
+
console.log(" \u6BCF\u5355\u53EF\u7528: ".concat(result.canUseCount, " \u5F20"));
|
|
194
|
+
console.log(" \u62B5\u6263\u7A0E\u8D39: ".concat(result.deductTaxAndFee ? '是' : '否'));
|
|
195
|
+
console.log(" \u9002\u7528\u5546\u54C1: ".concat(result.applicableProductIds.join(', ')));
|
|
196
|
+
} else {
|
|
197
|
+
console.log(" \u539F\u56E0: ".concat(result.reason));
|
|
198
|
+
console.log(" \u539F\u56E0\u7801: ".concat(result.reasonCode));
|
|
199
|
+
}
|
|
200
|
+
console.log('');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// 筛选可用的 vouchers
|
|
204
|
+
var availableVouchers = results.filter(function (r) {
|
|
205
|
+
return r.isApplicable;
|
|
206
|
+
});
|
|
207
|
+
console.log("\n\u5171 ".concat(availableVouchers.length, " \u5F20\u53EF\u7528"));
|
|
208
|
+
if (availableVouchers.length > 0) {
|
|
209
|
+
console.log('可用 voucher ID:');
|
|
210
|
+
availableVouchers.forEach(function (v) {
|
|
211
|
+
console.log(" - ".concat(v.voucher.id, ": \u6700\u591A\u62B5\u6263 ").concat(v.maxDeduction, " \u5143"));
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 运行示例
|
|
217
|
+
runExample();
|
|
218
|
+
|
|
219
|
+
// ============================================
|
|
220
|
+
// 预期输出
|
|
221
|
+
// ============================================
|
|
222
|
+
/*
|
|
223
|
+
========== WalletPass 评估器示例 ==========
|
|
224
|
+
|
|
225
|
+
订单信息:
|
|
226
|
+
- 总金额: 180 元
|
|
227
|
+
- 商品: 商品A(1件), 商品B(2件)
|
|
228
|
+
|
|
229
|
+
评估结果:
|
|
230
|
+
|
|
231
|
+
Voucher 1: VOUCHER_001
|
|
232
|
+
面额: 10 元
|
|
233
|
+
可用: ✅ 是
|
|
234
|
+
最大抵扣: 10 元
|
|
235
|
+
每单可用: 1 张
|
|
236
|
+
抵扣税费: 是
|
|
237
|
+
适用商品: 60734, 60735
|
|
238
|
+
|
|
239
|
+
Voucher 2: VOUCHER_002
|
|
240
|
+
面额: 20 元
|
|
241
|
+
可用: ✅ 是
|
|
242
|
+
最大抵扣: 20 元
|
|
243
|
+
每单可用: 1 张
|
|
244
|
+
抵扣税费: 是
|
|
245
|
+
适用商品: 60734, 60735
|
|
246
|
+
|
|
247
|
+
Voucher 3: VOUCHER_003
|
|
248
|
+
面额: 50 元
|
|
249
|
+
可用: ❌ 否
|
|
250
|
+
原因: Conditions not met
|
|
251
|
+
原因码: CONDITION_NOT_MET
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
共 2 张可用
|
|
255
|
+
可用 voucher ID:
|
|
256
|
+
- VOUCHER_001: 最多抵扣 10 元
|
|
257
|
+
- VOUCHER_002: 最多抵扣 20 元
|
|
258
|
+
*/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EvaluationResult, RuntimeContext } from '../../type';
|
|
2
|
+
import { BusinessAdapter } from '../type';
|
|
3
|
+
import { WalletPassBusinessData, WalletPassTransformResult } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* Wallet Pass 适配器
|
|
6
|
+
* 用于将 wallet pass 业务数据转换为策略引擎可识别的格式
|
|
7
|
+
*/
|
|
8
|
+
export default class WalletPassAdapter implements BusinessAdapter {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
/**
|
|
12
|
+
* 准备运行时上下文
|
|
13
|
+
* 将业务数据转换为策略引擎可识别的 RuntimeContext
|
|
14
|
+
*/
|
|
15
|
+
prepareContext(businessData: WalletPassBusinessData): RuntimeContext;
|
|
16
|
+
/**
|
|
17
|
+
* 转换执行结果
|
|
18
|
+
* 将策略引擎的通用结果转换为业务层需要的格式
|
|
19
|
+
*/
|
|
20
|
+
transformResult(result: EvaluationResult, businessData?: WalletPassBusinessData): WalletPassTransformResult;
|
|
21
|
+
/**
|
|
22
|
+
* 格式化配置
|
|
23
|
+
*/
|
|
24
|
+
formatConfig(result: EvaluationResult, businessData?: WalletPassBusinessData): {
|
|
25
|
+
result: EvaluationResult;
|
|
26
|
+
businessData?: WalletPassBusinessData;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 计算适用商品的总金额和数量
|
|
30
|
+
*/
|
|
31
|
+
private calculateApplicableProducts;
|
|
32
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import { getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice } from "./utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wallet Pass 适配器
|
|
12
|
+
* 用于将 wallet pass 业务数据转换为策略引擎可识别的格式
|
|
13
|
+
*/
|
|
14
|
+
var WalletPassAdapter = /*#__PURE__*/function () {
|
|
15
|
+
function WalletPassAdapter() {
|
|
16
|
+
_classCallCheck(this, WalletPassAdapter);
|
|
17
|
+
_defineProperty(this, "name", 'WalletPassAdapter');
|
|
18
|
+
_defineProperty(this, "version", '1.0.0');
|
|
19
|
+
}
|
|
20
|
+
_createClass(WalletPassAdapter, [{
|
|
21
|
+
key: "prepareContext",
|
|
22
|
+
value:
|
|
23
|
+
/**
|
|
24
|
+
* 准备运行时上下文
|
|
25
|
+
* 将业务数据转换为策略引擎可识别的 RuntimeContext
|
|
26
|
+
*/
|
|
27
|
+
function prepareContext(businessData) {
|
|
28
|
+
var _strategyConfig$metad, _strategyConfig$metad2;
|
|
29
|
+
var orderTotalAmount = businessData.orderTotalAmount,
|
|
30
|
+
products = businessData.products,
|
|
31
|
+
voucher = businessData.voucher,
|
|
32
|
+
strategyConfig = businessData.strategyConfig;
|
|
33
|
+
|
|
34
|
+
// 提取订单中的商品ID
|
|
35
|
+
var productIds = products.map(function (p) {
|
|
36
|
+
return p.product_id;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 从 voucher 中获取适用商品ID
|
|
40
|
+
var applicableProductIds = getApplicableProductIds(voucher);
|
|
41
|
+
|
|
42
|
+
// 获取 deductTaxAndFee 配置
|
|
43
|
+
var deductTaxAndFee = (_strategyConfig$metad = strategyConfig === null || strategyConfig === void 0 || (_strategyConfig$metad2 = strategyConfig.metadata) === null || _strategyConfig$metad2 === void 0 || (_strategyConfig$metad2 = _strategyConfig$metad2.custom) === null || _strategyConfig$metad2 === void 0 ? void 0 : _strategyConfig$metad2.deductTaxAndFee) !== null && _strategyConfig$metad !== void 0 ? _strategyConfig$metad : true;
|
|
44
|
+
|
|
45
|
+
// 计算适用商品的总金额和数量
|
|
46
|
+
var _this$calculateApplic = this.calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee),
|
|
47
|
+
applicableTotal = _this$calculateApplic.applicableTotal,
|
|
48
|
+
applicableCount = _this$calculateApplic.applicableCount;
|
|
49
|
+
return {
|
|
50
|
+
entities: {
|
|
51
|
+
voucher: voucher,
|
|
52
|
+
products: products,
|
|
53
|
+
order: {
|
|
54
|
+
orderTotalAmount: orderTotalAmount,
|
|
55
|
+
products: products
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
attributes: {
|
|
59
|
+
// 订单消费金额
|
|
60
|
+
orderTotalAmount: orderTotalAmount,
|
|
61
|
+
// 适用商品金额
|
|
62
|
+
applicableProductTotalAmount: applicableTotal,
|
|
63
|
+
// 适用商品购买数量
|
|
64
|
+
applicableProductCount: applicableCount,
|
|
65
|
+
// 当前评估的 voucher ID
|
|
66
|
+
voucherProductId: voucher.product_id,
|
|
67
|
+
// 订单中的商品ID
|
|
68
|
+
productIds: productIds
|
|
69
|
+
},
|
|
70
|
+
metadata: {
|
|
71
|
+
timestamp: Date.now()
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 转换执行结果
|
|
78
|
+
* 将策略引擎的通用结果转换为业务层需要的格式
|
|
79
|
+
*/
|
|
80
|
+
}, {
|
|
81
|
+
key: "transformResult",
|
|
82
|
+
value: function transformResult(result, businessData) {
|
|
83
|
+
// 从策略配置中获取业务配置
|
|
84
|
+
var strategyConfig = businessData === null || businessData === void 0 ? void 0 : businessData.strategyConfig;
|
|
85
|
+
var businessConfig = (strategyConfig === null || strategyConfig === void 0 ? void 0 : strategyConfig.metadata.custom) || {};
|
|
86
|
+
|
|
87
|
+
// 从 voucher 中获取适用商品ID
|
|
88
|
+
var voucher = businessData === null || businessData === void 0 ? void 0 : businessData.voucher;
|
|
89
|
+
var applicableProductIds = voucher ? getApplicableProductIds(voucher) : null;
|
|
90
|
+
if (!result.applicable) {
|
|
91
|
+
return {
|
|
92
|
+
isApplicable: false,
|
|
93
|
+
canUseCount: 0,
|
|
94
|
+
maxDeduction: 0,
|
|
95
|
+
deductTaxAndFee: false,
|
|
96
|
+
applicableProductIds: [],
|
|
97
|
+
reason: result.message,
|
|
98
|
+
reasonCode: result.code,
|
|
99
|
+
strategyResult: result
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 从配置中获取业务字段(不需要计算)
|
|
104
|
+
var maxDeduction = businessConfig.maxDeductionAmount || 0;
|
|
105
|
+
var canUseCount = businessConfig.maxUsagePerOrder || 0;
|
|
106
|
+
var deductTaxAndFee = businessConfig.deductTaxAndFee || false;
|
|
107
|
+
return {
|
|
108
|
+
isApplicable: true,
|
|
109
|
+
canUseCount: canUseCount,
|
|
110
|
+
maxDeduction: maxDeduction,
|
|
111
|
+
deductTaxAndFee: deductTaxAndFee,
|
|
112
|
+
applicableProductIds: applicableProductIds || [],
|
|
113
|
+
strategyResult: result
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 格式化配置
|
|
119
|
+
*/
|
|
120
|
+
}, {
|
|
121
|
+
key: "formatConfig",
|
|
122
|
+
value: function formatConfig(result, businessData) {
|
|
123
|
+
return {
|
|
124
|
+
result: result,
|
|
125
|
+
businessData: businessData
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 计算适用商品的总金额和数量
|
|
131
|
+
*/
|
|
132
|
+
}, {
|
|
133
|
+
key: "calculateApplicableProducts",
|
|
134
|
+
value: function calculateApplicableProducts(products, applicableProductIds) {
|
|
135
|
+
var deductTaxAndFee = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
136
|
+
var total = 0;
|
|
137
|
+
var count = 0;
|
|
138
|
+
|
|
139
|
+
// 如果为空数组,不适用任何商品
|
|
140
|
+
if (applicableProductIds !== null && applicableProductIds.length === 0) {
|
|
141
|
+
return {
|
|
142
|
+
applicableTotal: 0,
|
|
143
|
+
applicableCount: 0
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
products.forEach(function (product) {
|
|
147
|
+
var productQuantity = getProductQuantity(product);
|
|
148
|
+
|
|
149
|
+
// 检查主商品是否适用
|
|
150
|
+
var isMainProductApplicable = applicableProductIds === null || applicableProductIds.includes(product.product_id);
|
|
151
|
+
if (isMainProductApplicable) {
|
|
152
|
+
// 计算主商品价格(包含加减价子商品)
|
|
153
|
+
total += getMainProductPrice(product, deductTaxAndFee) * productQuantity;
|
|
154
|
+
count += productQuantity;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 检查原价子商品(需要单独判断适用性)
|
|
158
|
+
if (product.product_bundle && product.product_bundle.length > 0) {
|
|
159
|
+
product.product_bundle.forEach(function (bundleItem) {
|
|
160
|
+
// 只处理原价子商品,加减价子商品已包含在主商品价格中
|
|
161
|
+
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
162
|
+
// 检查子商品是否适用
|
|
163
|
+
var isBundleItemApplicable = applicableProductIds === null || applicableProductIds.includes(bundleItem.bundle_product_id);
|
|
164
|
+
if (isBundleItemApplicable) {
|
|
165
|
+
// 计算原价子商品价格
|
|
166
|
+
var bundleItemQuantity = bundleItem.num * productQuantity;
|
|
167
|
+
total += getBundleItemPrice(bundleItem, productQuantity, deductTaxAndFee);
|
|
168
|
+
count += bundleItemQuantity;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
applicableTotal: total,
|
|
176
|
+
applicableCount: count
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}]);
|
|
180
|
+
return WalletPassAdapter;
|
|
181
|
+
}();
|
|
182
|
+
export { WalletPassAdapter as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const locales: Record<string, Record<string, string>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var locales = {
|
|
2
|
+
'zh-CN': {
|
|
3
|
+
'not_meet_the_required_conditions': '未达到使用条件',
|
|
4
|
+
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金额限制',
|
|
5
|
+
'usage_limit_reached': '已达到使用次数上限',
|
|
6
|
+
'max_passes_per_item_reached': '该商品已达到卡券使用上限',
|
|
7
|
+
'not_available_for_this_channel': '当前渠道不可使用',
|
|
8
|
+
'not_valid_for_this_order_type': '当前订单类型不适用'
|
|
9
|
+
},
|
|
10
|
+
'en': {
|
|
11
|
+
'not_meet_the_required_conditions': 'Not meet the required conditions.',
|
|
12
|
+
'exceeds_the_maximum_deduction_limit': 'Exceeds the maximum deduction limit.',
|
|
13
|
+
'usage_limit_reached': 'Usage limit reached.',
|
|
14
|
+
'max_passes_per_item_reached': 'Max passes per item reached.',
|
|
15
|
+
'not_available_for_this_channel': 'Not available for this channel.',
|
|
16
|
+
'not_valid_for_this_order_type': 'Not valid for this order type.'
|
|
17
|
+
},
|
|
18
|
+
'zh-HK': {
|
|
19
|
+
'not_meet_the_required_conditions': '未達使用條件',
|
|
20
|
+
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金額限制',
|
|
21
|
+
'usage_limit_reached': '已達使用次數上限',
|
|
22
|
+
'max_passes_per_item_reached': '該商品已達卡券使用上限',
|
|
23
|
+
'not_available_for_this_channel': '當前渠道不可使用',
|
|
24
|
+
'not_valid_for_this_order_type': '當前訂單類型不適用'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { EvaluationResult, StrategyConfig } from '../../type';
|
|
2
|
+
/**
|
|
3
|
+
* Voucher 数据结构
|
|
4
|
+
*/
|
|
5
|
+
export interface Voucher {
|
|
6
|
+
id: number;
|
|
7
|
+
amount: number;
|
|
8
|
+
balance: number;
|
|
9
|
+
type?: string;
|
|
10
|
+
usedCount?: number;
|
|
11
|
+
available_product_type?: 'product_all' | 'product_collection' | 'products';
|
|
12
|
+
available_product_ids?: number[];
|
|
13
|
+
product_id: number;
|
|
14
|
+
unified_available_status: number;
|
|
15
|
+
/** 用户手动编辑的金额,优先于 recommended_usage_amount 使用 */
|
|
16
|
+
edit_current_amount?: number;
|
|
17
|
+
/** 前端基于策略返回的 不可用状态 */
|
|
18
|
+
_unified_available_status?: number;
|
|
19
|
+
/** 前端基于策略返回的 可用最大金额 */
|
|
20
|
+
_available_max_amount?: number;
|
|
21
|
+
/** 前端基于策略返回的 不可用原因 */
|
|
22
|
+
reason?: string;
|
|
23
|
+
/** 前端基于策略返回的 不可用原因码 */
|
|
24
|
+
reasonCode?: string;
|
|
25
|
+
/** 后端计算推荐使用金额 */
|
|
26
|
+
recommended_usage_amount: number;
|
|
27
|
+
/** 后端计算推荐使用金额(仅商品) 不包含税费附加费 */
|
|
28
|
+
recommended_pure_product_usage_amount: number;
|
|
29
|
+
/** 实际抵扣金额 */
|
|
30
|
+
actualDeduction: number;
|
|
31
|
+
/** 抵扣详情 */
|
|
32
|
+
deductionDetails: any[];
|
|
33
|
+
config?: {
|
|
34
|
+
/** 最大抵扣金额 */
|
|
35
|
+
maxDeductionAmount: number;
|
|
36
|
+
/** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
|
|
37
|
+
maxUsagePerOrder: number;
|
|
38
|
+
/** 是否抵扣税费与附加费 */
|
|
39
|
+
deductTaxAndFee: boolean;
|
|
40
|
+
/** 适用粒度(多商品共用) 默认开启勾选项 */
|
|
41
|
+
allowCrossProduct: boolean;
|
|
42
|
+
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
43
|
+
applicableProductLimit: number;
|
|
44
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
|
|
45
|
+
maxPassesPerItem: number;
|
|
46
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
|
|
47
|
+
deductOptionPrice: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 商品数据结构
|
|
52
|
+
*/
|
|
53
|
+
export interface Product {
|
|
54
|
+
product_id: number;
|
|
55
|
+
/** 订单明细 id,参与行唯一键兜底解析 */
|
|
56
|
+
id?: number;
|
|
57
|
+
/** 行级唯一串,参与行唯一键解析 */
|
|
58
|
+
product_unique_string?: string;
|
|
59
|
+
price: number;
|
|
60
|
+
quantity: number;
|
|
61
|
+
name?: string;
|
|
62
|
+
selling_price?: number;
|
|
63
|
+
/** 主商品折扣前金额,不包含套餐子商品 */
|
|
64
|
+
main_product_original_price?: number;
|
|
65
|
+
/** 主商品折扣后金额,不包含套餐子商品 */
|
|
66
|
+
main_product_selling_price?: number;
|
|
67
|
+
/** 单规格(Option)列表 */
|
|
68
|
+
product_options?: {
|
|
69
|
+
id: number;
|
|
70
|
+
add_price: number | string;
|
|
71
|
+
num: number;
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}[];
|
|
74
|
+
/** 主商品税费 */
|
|
75
|
+
tax_fee: number;
|
|
76
|
+
metadata: {
|
|
77
|
+
/** 行唯一标识,优先用于 Wallet Pass 按行配额 */
|
|
78
|
+
product_unique?: string;
|
|
79
|
+
unique_identification_number?: string;
|
|
80
|
+
main_product_attached_bundle_tax_fee?: number;
|
|
81
|
+
main_product_attached_bundle_surcharge_fee?: number;
|
|
82
|
+
surcharge_rounding_remainder?: number;
|
|
83
|
+
tax_fee_rounding_remainder?: number;
|
|
84
|
+
main_product_selling_price: number;
|
|
85
|
+
};
|
|
86
|
+
is_price_include_tax: 0 | 1;
|
|
87
|
+
product_bundle: {
|
|
88
|
+
is_price_include_tax: 0 | 1;
|
|
89
|
+
bundle_id: number;
|
|
90
|
+
bundle_product_id: number;
|
|
91
|
+
bundle_variant_id: number;
|
|
92
|
+
price_type: string;
|
|
93
|
+
price_type_ext: string;
|
|
94
|
+
bundle_selling_price: number;
|
|
95
|
+
num: number;
|
|
96
|
+
is_charge_tax: number;
|
|
97
|
+
tax_fee: number;
|
|
98
|
+
metadata: {
|
|
99
|
+
surcharge_fee: number;
|
|
100
|
+
surcharge_rounding_remainder?: number;
|
|
101
|
+
tax_fee_rounding_remainder?: number;
|
|
102
|
+
};
|
|
103
|
+
}[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Voucher 评估结果
|
|
107
|
+
*/
|
|
108
|
+
export interface VoucherEvaluationResult {
|
|
109
|
+
voucher: Voucher;
|
|
110
|
+
/** 是否可用 */
|
|
111
|
+
isApplicable: boolean;
|
|
112
|
+
/** 每单可使用张数 */
|
|
113
|
+
canUseCount: number;
|
|
114
|
+
/** 最大抵扣金额 */
|
|
115
|
+
maxDeduction: number;
|
|
116
|
+
/** 是否抵扣税费与附加费 */
|
|
117
|
+
deductTaxAndFee: boolean;
|
|
118
|
+
/** 适用商品ID列表 */
|
|
119
|
+
applicableProductIds: number[];
|
|
120
|
+
/** 不可用原因 */
|
|
121
|
+
reason?: string;
|
|
122
|
+
/** 不可用原因码 */
|
|
123
|
+
reasonCode?: string;
|
|
124
|
+
strategyResult?: EvaluationResult;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 评估器输入参数
|
|
128
|
+
*/
|
|
129
|
+
export interface EvaluatorInput {
|
|
130
|
+
/** 订单总金额 */
|
|
131
|
+
orderTotalAmount: number;
|
|
132
|
+
/** 商品列表 */
|
|
133
|
+
products: Product[];
|
|
134
|
+
/** 代金券列表 */
|
|
135
|
+
vouchers: Voucher[];
|
|
136
|
+
/** 策略配置列表 */
|
|
137
|
+
strategyConfigs?: StrategyConfig<{
|
|
138
|
+
/** 最大抵扣金额 */
|
|
139
|
+
maxDeductionAmount: number;
|
|
140
|
+
/** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
|
|
141
|
+
maxUsagePerOrder: number;
|
|
142
|
+
/** 是否抵扣税费与附加费 */
|
|
143
|
+
deductTaxAndFee: boolean;
|
|
144
|
+
/** 适用粒度(多商品共用) 默认开启勾选项 */
|
|
145
|
+
allowCrossProduct: boolean;
|
|
146
|
+
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
147
|
+
applicableProductLimit: number;
|
|
148
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
|
|
149
|
+
maxPassesPerItem: number;
|
|
150
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false */
|
|
151
|
+
deductOptionPrice: boolean;
|
|
152
|
+
}>[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* WalletPassAdapter 业务数据输入
|
|
156
|
+
*/
|
|
157
|
+
export interface WalletPassBusinessData {
|
|
158
|
+
/** 订单总金额 */
|
|
159
|
+
orderTotalAmount: number;
|
|
160
|
+
/** 商品列表 */
|
|
161
|
+
products: Product[];
|
|
162
|
+
/** 当前评估的 voucher */
|
|
163
|
+
voucher: Voucher;
|
|
164
|
+
/** 策略配置 */
|
|
165
|
+
strategyConfig: StrategyConfig;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* WalletPassAdapter 转换结果
|
|
169
|
+
*/
|
|
170
|
+
export interface WalletPassTransformResult {
|
|
171
|
+
/** 是否可用 */
|
|
172
|
+
isApplicable: boolean;
|
|
173
|
+
/** 每单可使用张数 */
|
|
174
|
+
canUseCount: number;
|
|
175
|
+
/** 最大抵扣金额 */
|
|
176
|
+
maxDeduction: number;
|
|
177
|
+
/** 是否抵扣税费与附加费 */
|
|
178
|
+
deductTaxAndFee: boolean;
|
|
179
|
+
/** 适用商品ID列表 */
|
|
180
|
+
applicableProductIds: number[];
|
|
181
|
+
/** 不可用原因 */
|
|
182
|
+
reason?: string;
|
|
183
|
+
/** 不可用原因码 */
|
|
184
|
+
reasonCode?: string;
|
|
185
|
+
/** 原始策略评估结果 */
|
|
186
|
+
strategyResult?: EvaluationResult;
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|