@pisell/pisellos 2.3.27 → 2.3.29
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/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +7 -1
- package/dist/modules/Order/index.js +187 -74
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +2 -1
- package/dist/modules/Order/utils.js +2 -8
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/server/index.d.ts +50 -0
- package/dist/server/index.js +995 -749
- package/dist/server/modules/order/index.d.ts +10 -4
- package/dist/server/modules/order/index.js +404 -399
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +167 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +998 -756
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +14 -2
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +7 -1
- package/lib/modules/Order/index.js +104 -6
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +2 -1
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/server/index.d.ts +50 -0
- package/lib/server/index.js +206 -29
- package/lib/server/modules/order/index.d.ts +10 -4
- package/lib/server/modules/order/index.js +199 -141
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +114 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +229 -54
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +14 -2
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { StrategyConfig } from '../../type';
|
|
2
|
+
import type { ScheduleItem } from '../../../../modules/Schedule/types';
|
|
3
|
+
import type { DataVariantItem, DataVariantMenu, DataVariantProduct, DataVariantRuleMetadata } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* 构造示例用 data_variant 记录,字段结构与后端 /product/query 返回一致。
|
|
6
|
+
*/
|
|
7
|
+
export declare function createExampleDataVariant(ruleId: number | string, data: Record<string, any>, overrides?: Partial<Omit<DataVariantItem, 'data_variant_rule_id' | 'data'>>): DataVariantItem;
|
|
8
|
+
/**
|
|
9
|
+
* 晚场餐牌价:命中日程 + 餐牌商品范围后覆盖 price / stock。
|
|
10
|
+
*/
|
|
11
|
+
export declare const EVENING_MENU_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
|
|
12
|
+
/**
|
|
13
|
+
* VIP 商品价:演示 product_match 与更高优先级字段覆盖。
|
|
14
|
+
*/
|
|
15
|
+
export declare const VIP_PRODUCT_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
|
|
16
|
+
/**
|
|
17
|
+
* 客户/渠道/业务范围价:演示 customer_id、channel、business_code 的 in 条件。
|
|
18
|
+
*/
|
|
19
|
+
export declare const CUSTOMER_SCOPE_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
|
|
20
|
+
/**
|
|
21
|
+
* 示例日程:2026-06-26 17:00 ~ 20:00 生效。
|
|
22
|
+
*/
|
|
23
|
+
export declare const DATA_VARIANT_EXAMPLE_SCHEDULES: ScheduleItem[];
|
|
24
|
+
/**
|
|
25
|
+
* 示例餐牌:product_collection = 128 的商品均属于餐牌。
|
|
26
|
+
*/
|
|
27
|
+
export declare const DATA_VARIANT_EXAMPLE_MENUS: DataVariantMenu[];
|
|
28
|
+
/**
|
|
29
|
+
* 示例商品:同时带两条 Data Variant 覆盖数据。
|
|
30
|
+
*/
|
|
31
|
+
export declare const DATA_VARIANT_EXAMPLE_PRODUCTS: DataVariantProduct[];
|
|
32
|
+
/**
|
|
33
|
+
* Data Variant 评估器示例调用。
|
|
34
|
+
*/
|
|
35
|
+
export declare function runDataVariantDemo(): import("./type").ResolvedDataVariantResult;
|
|
36
|
+
/**
|
|
37
|
+
* 客户/渠道/业务范围条件示例调用。
|
|
38
|
+
*/
|
|
39
|
+
export declare function runCustomerScopeDataVariantDemo(): import("./type").ResolvedDataVariantResult;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { DataVariantEvaluator } from "./evaluator";
|
|
2
|
+
import { DATA_VARIANT_ACTION_TYPES } from "./type";
|
|
3
|
+
/**
|
|
4
|
+
* 构造示例用 data_variant 记录,字段结构与后端 /product/query 返回一致。
|
|
5
|
+
*/
|
|
6
|
+
export function createExampleDataVariant(ruleId, data, overrides) {
|
|
7
|
+
var _overrides$id, _overrides$shop_id, _overrides$module, _overrides$module_dat, _overrides$created_at, _overrides$updated_at, _overrides$deleted_at;
|
|
8
|
+
return {
|
|
9
|
+
id: (_overrides$id = overrides === null || overrides === void 0 ? void 0 : overrides.id) !== null && _overrides$id !== void 0 ? _overrides$id : 1,
|
|
10
|
+
shop_id: (_overrides$shop_id = overrides === null || overrides === void 0 ? void 0 : overrides.shop_id) !== null && _overrides$shop_id !== void 0 ? _overrides$shop_id : 9,
|
|
11
|
+
module: (_overrides$module = overrides === null || overrides === void 0 ? void 0 : overrides.module) !== null && _overrides$module !== void 0 ? _overrides$module : 'product',
|
|
12
|
+
module_data_id: (_overrides$module_dat = overrides === null || overrides === void 0 ? void 0 : overrides.module_data_id) !== null && _overrides$module_dat !== void 0 ? _overrides$module_dat : 61416,
|
|
13
|
+
data_variant_rule_id: ruleId,
|
|
14
|
+
data: data,
|
|
15
|
+
created_at: (_overrides$created_at = overrides === null || overrides === void 0 ? void 0 : overrides.created_at) !== null && _overrides$created_at !== void 0 ? _overrides$created_at : null,
|
|
16
|
+
updated_at: (_overrides$updated_at = overrides === null || overrides === void 0 ? void 0 : overrides.updated_at) !== null && _overrides$updated_at !== void 0 ? _overrides$updated_at : null,
|
|
17
|
+
deleted_at: (_overrides$deleted_at = overrides === null || overrides === void 0 ? void 0 : overrides.deleted_at) !== null && _overrides$deleted_at !== void 0 ? _overrides$deleted_at : null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 晚场餐牌价:命中日程 + 餐牌商品范围后覆盖 price / stock。
|
|
23
|
+
*/
|
|
24
|
+
export var EVENING_MENU_PRICE_STRATEGY = {
|
|
25
|
+
metadata: {
|
|
26
|
+
id: '1',
|
|
27
|
+
type: 'data_variant',
|
|
28
|
+
name: {
|
|
29
|
+
'zh-CN': '晚场餐牌价',
|
|
30
|
+
en: 'Evening menu price'
|
|
31
|
+
},
|
|
32
|
+
custom: {
|
|
33
|
+
module: 'product',
|
|
34
|
+
priority: 100,
|
|
35
|
+
status: 'active',
|
|
36
|
+
updated_at: '2026-06-26 12:00:00'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
conditions: {
|
|
40
|
+
operator: 'and',
|
|
41
|
+
rules: [{
|
|
42
|
+
type: 'operator',
|
|
43
|
+
field: 'schedule',
|
|
44
|
+
operator: 'schedule_match',
|
|
45
|
+
value: [1042]
|
|
46
|
+
}, {
|
|
47
|
+
type: 'operator',
|
|
48
|
+
field: 'product',
|
|
49
|
+
operator: 'menu_match',
|
|
50
|
+
value: [43209]
|
|
51
|
+
}],
|
|
52
|
+
actionIds: ['apply_data_variant']
|
|
53
|
+
},
|
|
54
|
+
actions: [{
|
|
55
|
+
id: 'apply_data_variant',
|
|
56
|
+
type: DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
57
|
+
target: 'product',
|
|
58
|
+
value: null,
|
|
59
|
+
priority: 100
|
|
60
|
+
}]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* VIP 商品价:演示 product_match 与更高优先级字段覆盖。
|
|
65
|
+
*/
|
|
66
|
+
export var VIP_PRODUCT_PRICE_STRATEGY = {
|
|
67
|
+
metadata: {
|
|
68
|
+
id: '2',
|
|
69
|
+
type: 'data_variant',
|
|
70
|
+
name: {
|
|
71
|
+
'zh-CN': 'VIP 商品价',
|
|
72
|
+
en: 'VIP product price'
|
|
73
|
+
},
|
|
74
|
+
custom: {
|
|
75
|
+
module: 'product',
|
|
76
|
+
priority: 200,
|
|
77
|
+
status: 'active',
|
|
78
|
+
updated_at: '2026-06-26 13:00:00'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
conditions: {
|
|
82
|
+
operator: 'and',
|
|
83
|
+
rules: [{
|
|
84
|
+
type: 'operator',
|
|
85
|
+
field: 'productIdAndVariantId',
|
|
86
|
+
operator: 'product_match',
|
|
87
|
+
value: [{
|
|
88
|
+
product_id: 2001,
|
|
89
|
+
product_variant_id: 0
|
|
90
|
+
}]
|
|
91
|
+
}],
|
|
92
|
+
actionIds: ['apply_data_variant']
|
|
93
|
+
},
|
|
94
|
+
actions: [{
|
|
95
|
+
id: 'apply_data_variant',
|
|
96
|
+
type: DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
97
|
+
target: 'product',
|
|
98
|
+
value: null,
|
|
99
|
+
priority: 200
|
|
100
|
+
}]
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 客户/渠道/业务范围价:演示 customer_id、channel、business_code 的 in 条件。
|
|
105
|
+
*/
|
|
106
|
+
export var CUSTOMER_SCOPE_PRICE_STRATEGY = {
|
|
107
|
+
metadata: {
|
|
108
|
+
id: '3',
|
|
109
|
+
type: 'data_variant',
|
|
110
|
+
name: {
|
|
111
|
+
'zh-CN': '指定客户渠道业务价',
|
|
112
|
+
en: 'Scoped customer channel business price'
|
|
113
|
+
},
|
|
114
|
+
custom: {
|
|
115
|
+
module: 'product',
|
|
116
|
+
priority: 150,
|
|
117
|
+
status: 'active',
|
|
118
|
+
updated_at: '2026-06-26 14:00:00'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
conditions: {
|
|
122
|
+
operator: 'and',
|
|
123
|
+
rules: [{
|
|
124
|
+
type: 'operator',
|
|
125
|
+
field: 'customer_id',
|
|
126
|
+
operator: 'in',
|
|
127
|
+
value: [333, 444]
|
|
128
|
+
}, {
|
|
129
|
+
type: 'operator',
|
|
130
|
+
field: 'channel',
|
|
131
|
+
operator: 'in',
|
|
132
|
+
value: ['pos', 'online']
|
|
133
|
+
}, {
|
|
134
|
+
type: 'operator',
|
|
135
|
+
field: 'business_code',
|
|
136
|
+
operator: 'in',
|
|
137
|
+
value: ['venue', 'retail']
|
|
138
|
+
}],
|
|
139
|
+
actionIds: ['apply_data_variant']
|
|
140
|
+
},
|
|
141
|
+
actions: [{
|
|
142
|
+
id: 'apply_data_variant',
|
|
143
|
+
type: DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
144
|
+
target: 'product',
|
|
145
|
+
value: null,
|
|
146
|
+
priority: 150
|
|
147
|
+
}]
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 示例日程:2026-06-26 17:00 ~ 20:00 生效。
|
|
152
|
+
*/
|
|
153
|
+
export var DATA_VARIANT_EXAMPLE_SCHEDULES = [{
|
|
154
|
+
id: 1042,
|
|
155
|
+
name: '晚场 17~20',
|
|
156
|
+
color: '#1890ff',
|
|
157
|
+
start_time: '2026-06-26 17:00:00',
|
|
158
|
+
end_time: '2026-06-26 20:00:00',
|
|
159
|
+
repeat_type: 'none',
|
|
160
|
+
repeat_rule: {
|
|
161
|
+
end: {
|
|
162
|
+
type: 'never',
|
|
163
|
+
end_date: null,
|
|
164
|
+
occurrence: null
|
|
165
|
+
},
|
|
166
|
+
frequency: 1,
|
|
167
|
+
excluded_date: [],
|
|
168
|
+
included_date: [],
|
|
169
|
+
frequency_date: []
|
|
170
|
+
},
|
|
171
|
+
type: 'standard',
|
|
172
|
+
time_slot: [],
|
|
173
|
+
designation: [],
|
|
174
|
+
is_all: 0,
|
|
175
|
+
created_at: '2026-06-26 00:00:00',
|
|
176
|
+
updated_at: '2026-06-26 00:00:00',
|
|
177
|
+
order_count: 0,
|
|
178
|
+
relation_count: 0
|
|
179
|
+
}];
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 示例餐牌:product_collection = 128 的商品均属于餐牌。
|
|
183
|
+
*/
|
|
184
|
+
export var DATA_VARIANT_EXAMPLE_MENUS = [{
|
|
185
|
+
form_record_id: 43209,
|
|
186
|
+
name: 'kiosk餐牌1 17~20',
|
|
187
|
+
status: 'valid',
|
|
188
|
+
schedule: [1042],
|
|
189
|
+
partyroom_package: {
|
|
190
|
+
type: 'product_collection',
|
|
191
|
+
products: [{
|
|
192
|
+
product_collection_id: 128,
|
|
193
|
+
product_id: 0,
|
|
194
|
+
product_variant_id: 0
|
|
195
|
+
}]
|
|
196
|
+
}
|
|
197
|
+
}];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 示例商品:同时带两条 Data Variant 覆盖数据。
|
|
201
|
+
*/
|
|
202
|
+
export var DATA_VARIANT_EXAMPLE_PRODUCTS = [{
|
|
203
|
+
id: 2001,
|
|
204
|
+
title: '入场票',
|
|
205
|
+
price: 100,
|
|
206
|
+
stock: 50,
|
|
207
|
+
collection: [{
|
|
208
|
+
id: 128,
|
|
209
|
+
title: 'Tickets'
|
|
210
|
+
}],
|
|
211
|
+
data_variants: [createExampleDataVariant(1, {
|
|
212
|
+
price: 80,
|
|
213
|
+
stock: 20
|
|
214
|
+
}, {
|
|
215
|
+
id: 1,
|
|
216
|
+
module_data_id: 2001
|
|
217
|
+
}), createExampleDataVariant(2, {
|
|
218
|
+
price: 70,
|
|
219
|
+
title: 'VIP专属票'
|
|
220
|
+
}, {
|
|
221
|
+
id: 2,
|
|
222
|
+
module_data_id: 2001
|
|
223
|
+
}), createExampleDataVariant(3, {
|
|
224
|
+
price: 65,
|
|
225
|
+
title: 'VIP渠道价'
|
|
226
|
+
}, {
|
|
227
|
+
id: 4,
|
|
228
|
+
module_data_id: 2001
|
|
229
|
+
})]
|
|
230
|
+
}, {
|
|
231
|
+
id: 2002,
|
|
232
|
+
title: '普通票',
|
|
233
|
+
price: 100,
|
|
234
|
+
stock: 50,
|
|
235
|
+
collection: [{
|
|
236
|
+
id: 999,
|
|
237
|
+
title: 'Other'
|
|
238
|
+
}],
|
|
239
|
+
data_variants: [createExampleDataVariant(1, {
|
|
240
|
+
price: 80,
|
|
241
|
+
stock: 20
|
|
242
|
+
}, {
|
|
243
|
+
id: 3,
|
|
244
|
+
module_data_id: 2002
|
|
245
|
+
})]
|
|
246
|
+
}];
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Data Variant 评估器示例调用。
|
|
250
|
+
*/
|
|
251
|
+
export function runDataVariantDemo() {
|
|
252
|
+
var evaluator = new DataVariantEvaluator();
|
|
253
|
+
evaluator.setStrategyConfigs([EVENING_MENU_PRICE_STRATEGY, VIP_PRODUCT_PRICE_STRATEGY]);
|
|
254
|
+
var businessData = {
|
|
255
|
+
products: DATA_VARIANT_EXAMPLE_PRODUCTS,
|
|
256
|
+
scheduleDateTime: '2026-06-26 18:00:00',
|
|
257
|
+
scheduleList: DATA_VARIANT_EXAMPLE_SCHEDULES,
|
|
258
|
+
menuList: DATA_VARIANT_EXAMPLE_MENUS,
|
|
259
|
+
orderType: 'booking'
|
|
260
|
+
};
|
|
261
|
+
return evaluator.resolveProducts(businessData);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 客户/渠道/业务范围条件示例调用。
|
|
266
|
+
*/
|
|
267
|
+
export function runCustomerScopeDataVariantDemo() {
|
|
268
|
+
var evaluator = new DataVariantEvaluator();
|
|
269
|
+
evaluator.setStrategyConfigs([CUSTOMER_SCOPE_PRICE_STRATEGY]);
|
|
270
|
+
var businessData = {
|
|
271
|
+
products: [DATA_VARIANT_EXAMPLE_PRODUCTS[0]],
|
|
272
|
+
customerId: 333,
|
|
273
|
+
channel: 'pos',
|
|
274
|
+
businessCode: 'venue'
|
|
275
|
+
};
|
|
276
|
+
return evaluator.resolveProducts(businessData);
|
|
277
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { ConditionRule, EvaluationResult, StrategyConfig } from '../../type';
|
|
2
|
+
import type { ScheduleItem } from '../../../../modules/Schedule/types';
|
|
3
|
+
/**
|
|
4
|
+
* Data Variant 动作类型。
|
|
5
|
+
*
|
|
6
|
+
* 当前阶段动作只用于标识“该策略可应用 data variant 覆盖”,真实覆盖数据来自商品 data_variants。
|
|
7
|
+
*/
|
|
8
|
+
export declare const DATA_VARIANT_ACTION_TYPES: {
|
|
9
|
+
readonly APPLY: "DATA_VARIANT_APPLY";
|
|
10
|
+
};
|
|
11
|
+
export type DataVariantActionType = (typeof DATA_VARIANT_ACTION_TYPES)[keyof typeof DATA_VARIANT_ACTION_TYPES];
|
|
12
|
+
/**
|
|
13
|
+
* Data Variant 规则元数据。
|
|
14
|
+
*
|
|
15
|
+
* priority 数字越大优先级越高,合并时后覆盖低优先级字段。
|
|
16
|
+
*/
|
|
17
|
+
export interface DataVariantRuleMetadata {
|
|
18
|
+
module?: 'product' | string;
|
|
19
|
+
priority?: number;
|
|
20
|
+
status?: 'active' | 'inactive' | string;
|
|
21
|
+
updated_at?: string;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 商品上的单条 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
26
|
+
*/
|
|
27
|
+
export interface DataVariantItem {
|
|
28
|
+
/** 变体记录 id */
|
|
29
|
+
id?: number;
|
|
30
|
+
/** 店铺 id */
|
|
31
|
+
shop_id?: number;
|
|
32
|
+
/** 所属模块,商品场景固定为 product */
|
|
33
|
+
module?: 'product' | string;
|
|
34
|
+
/** 模块数据 id,商品场景对应 product.id */
|
|
35
|
+
module_data_id?: number;
|
|
36
|
+
/** 关联策略模型 metadata.id / data_variant_rule.id */
|
|
37
|
+
data_variant_rule_id: number | string;
|
|
38
|
+
/** 命中策略后需要覆盖到商品上的字段 */
|
|
39
|
+
data: Record<string, any>;
|
|
40
|
+
created_at?: string | null;
|
|
41
|
+
updated_at?: string | null;
|
|
42
|
+
deleted_at?: string | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Data Variant 评估使用的轻量商品结构。
|
|
46
|
+
*/
|
|
47
|
+
export interface DataVariantProduct {
|
|
48
|
+
id?: number | string;
|
|
49
|
+
product_id?: number | string;
|
|
50
|
+
product_variant_id?: number | string;
|
|
51
|
+
variant_id?: number | string;
|
|
52
|
+
collection?: Array<{
|
|
53
|
+
id?: number | string;
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
}>;
|
|
56
|
+
/** 后端 /product/query with dataVariants 返回的智能定价变体列表 */
|
|
57
|
+
data_variants?: DataVariantItem[];
|
|
58
|
+
_dataVariant?: DataVariantAppliedInfo;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 餐牌商品配置项。
|
|
63
|
+
*/
|
|
64
|
+
export interface DataVariantMenuProductItem {
|
|
65
|
+
product_collection_id?: number | string;
|
|
66
|
+
product_id?: number | string;
|
|
67
|
+
product_variant_id?: number | string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 餐牌数据的最小结构。
|
|
71
|
+
*/
|
|
72
|
+
export interface DataVariantMenu {
|
|
73
|
+
form_record_id: number | string;
|
|
74
|
+
status?: string;
|
|
75
|
+
schedule?: Array<number | string>;
|
|
76
|
+
partyroom_package?: {
|
|
77
|
+
type?: 'product_all' | 'product_collection' | 'products' | string;
|
|
78
|
+
products?: DataVariantMenuProductItem[];
|
|
79
|
+
};
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 单个餐牌预构建后的商品范围索引。
|
|
84
|
+
*/
|
|
85
|
+
export interface MenuScope {
|
|
86
|
+
isAllProducts: boolean;
|
|
87
|
+
collectionIds: Set<number>;
|
|
88
|
+
productKeys: Set<string>;
|
|
89
|
+
productAllVariantIds: Set<number>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 批量评估输入。
|
|
93
|
+
*/
|
|
94
|
+
export interface DataVariantBusinessData {
|
|
95
|
+
products: DataVariantProduct[];
|
|
96
|
+
strategyConfigs?: StrategyConfig<DataVariantRuleMetadata>[];
|
|
97
|
+
scheduleDateTime?: string;
|
|
98
|
+
scheduleList?: ScheduleItem[];
|
|
99
|
+
menuList?: DataVariantMenu[];
|
|
100
|
+
channel?: string;
|
|
101
|
+
orderType?: string;
|
|
102
|
+
/** 当前业务编码,对应策略条件 field: business_code */
|
|
103
|
+
businessCode?: string;
|
|
104
|
+
customerId?: number | string;
|
|
105
|
+
/** 当前客户可用 wallet/pass id 合并列表,对应策略条件 field: available_wallet_ids */
|
|
106
|
+
availableWalletIds?: Array<number | string>;
|
|
107
|
+
custom?: Record<string, any>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 全局预计算后的规则信息。
|
|
111
|
+
*/
|
|
112
|
+
export interface EffectiveRuleInfo {
|
|
113
|
+
ruleId: string;
|
|
114
|
+
priority: number;
|
|
115
|
+
strategyConfig: StrategyConfig<DataVariantRuleMetadata>;
|
|
116
|
+
productRules: ConditionRule[];
|
|
117
|
+
globalResult: EvaluationResult;
|
|
118
|
+
}
|
|
119
|
+
export type GlobalEffectiveRuleMap = Map<string, EffectiveRuleInfo>;
|
|
120
|
+
/**
|
|
121
|
+
* 单条商品命中的变体覆盖信息。
|
|
122
|
+
*/
|
|
123
|
+
export interface MatchedDataVariant {
|
|
124
|
+
ruleId: string;
|
|
125
|
+
priority: number;
|
|
126
|
+
data: Record<string, any>;
|
|
127
|
+
variant: DataVariantItem;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 商品上记录的 Data Variant 调试信息。
|
|
131
|
+
*/
|
|
132
|
+
export interface DataVariantAppliedInfo {
|
|
133
|
+
appliedRuleIds: string[];
|
|
134
|
+
appliedFields: string[];
|
|
135
|
+
original: DataVariantProduct;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 批量解析结果。
|
|
139
|
+
*/
|
|
140
|
+
export interface ResolvedDataVariantResult {
|
|
141
|
+
products: DataVariantProduct[];
|
|
142
|
+
globalEffectiveRuleMap: GlobalEffectiveRuleMap;
|
|
143
|
+
menuScopeMap: Map<number, MenuScope>;
|
|
144
|
+
/** 当前策略中 schedule_match 绑定的日程提取出的时间点,格式如 ["10:00", "13:00"] */
|
|
145
|
+
scheduleTimePoints: string[];
|
|
146
|
+
rawResults: EvaluationResult[];
|
|
147
|
+
}
|
|
148
|
+
export type ConditionScope = 'global' | 'product';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Variant 动作类型。
|
|
3
|
+
*
|
|
4
|
+
* 当前阶段动作只用于标识“该策略可应用 data variant 覆盖”,真实覆盖数据来自商品 data_variants。
|
|
5
|
+
*/
|
|
6
|
+
export var DATA_VARIANT_ACTION_TYPES = {
|
|
7
|
+
APPLY: 'DATA_VARIANT_APPLY'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Data Variant 规则元数据。
|
|
12
|
+
*
|
|
13
|
+
* priority 数字越大优先级越高,合并时后覆盖低优先级字段。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 商品上的单条 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Data Variant 评估使用的轻量商品结构。
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 餐牌商品配置项。
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 餐牌数据的最小结构。
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 单个餐牌预构建后的商品范围索引。
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 批量评估输入。
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 全局预计算后的规则信息。
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 单条商品命中的变体覆盖信息。
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 商品上记录的 Data Variant 调试信息。
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 批量解析结果。
|
|
54
|
+
*/
|
|
@@ -5,3 +5,7 @@ export { PromotionEvaluator } from './promotion/evaluator';
|
|
|
5
5
|
export { PromotionAdapter } from './promotion/adapter';
|
|
6
6
|
export { ItemRuleEvaluator } from './itemRule/evaluator';
|
|
7
7
|
export { ItemRuleAdapter } from './itemRule/adapter';
|
|
8
|
+
export { DataVariantEvaluator } from './dataVariant/evaluator';
|
|
9
|
+
export { DataVariantAdapter } from './dataVariant/adapter';
|
|
10
|
+
export { runDataVariantDemo } from './dataVariant/examples';
|
|
11
|
+
export * from './dataVariant/type';
|
|
@@ -4,4 +4,8 @@ export { WalletPassEvaluator } from "./walletPass/evaluator";
|
|
|
4
4
|
export { PromotionEvaluator } from "./promotion/evaluator";
|
|
5
5
|
export { PromotionAdapter } from "./promotion/adapter";
|
|
6
6
|
export { ItemRuleEvaluator } from "./itemRule/evaluator";
|
|
7
|
-
export { ItemRuleAdapter } from "./itemRule/adapter";
|
|
7
|
+
export { ItemRuleAdapter } from "./itemRule/adapter";
|
|
8
|
+
export { DataVariantEvaluator } from "./dataVariant/evaluator";
|
|
9
|
+
export { DataVariantAdapter } from "./dataVariant/adapter";
|
|
10
|
+
export { runDataVariantDemo } from "./dataVariant/examples";
|
|
11
|
+
export * from "./dataVariant/type";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason, DiscountPrepareConfigResult } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -16,15 +16,18 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
16
16
|
getDiscountList(): Discount[];
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
|
+
private normalizePositiveNumberIds;
|
|
19
20
|
loadPrepareConfig(params: {
|
|
20
21
|
action?: 'create' | 'edit';
|
|
21
22
|
with_good_pass: 0 | 1;
|
|
22
23
|
with_discount_card: 0 | 1;
|
|
23
24
|
customer_id: number;
|
|
24
25
|
with_wallet_pass_holder: 0 | 1;
|
|
26
|
+
with_available_wallet_flag?: 0 | 1;
|
|
27
|
+
with_available_wallet_pass_flag?: 0 | 1;
|
|
25
28
|
request_timezone: string;
|
|
26
29
|
order_id?: number | string;
|
|
27
|
-
}): Promise<
|
|
30
|
+
}): Promise<DiscountPrepareConfigResult>;
|
|
28
31
|
batchSearch(code: string, options?: {
|
|
29
32
|
customerId?: number;
|
|
30
33
|
orderId?: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
7
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -151,12 +151,22 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
151
151
|
value: function getOriginalDiscountList() {
|
|
152
152
|
return this.store.originalDiscountList || [];
|
|
153
153
|
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "normalizePositiveNumberIds",
|
|
156
|
+
value: function normalizePositiveNumberIds(values) {
|
|
157
|
+
var ids = values.map(function (value) {
|
|
158
|
+
return Number(value);
|
|
159
|
+
}).filter(function (value) {
|
|
160
|
+
return Number.isFinite(value) && value > 0;
|
|
161
|
+
});
|
|
162
|
+
return Array.from(new Set(ids));
|
|
163
|
+
}
|
|
154
164
|
}, {
|
|
155
165
|
key: "loadPrepareConfig",
|
|
156
166
|
value: function () {
|
|
157
167
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
158
|
-
var _prepareConfig$data, _prepareConfig$data2;
|
|
159
|
-
var prepareConfig, rawDiscountList, goodPassList;
|
|
168
|
+
var _params$with_availabl, _params$with_availabl2, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
|
|
169
|
+
var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, goodPassList;
|
|
160
170
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
161
171
|
while (1) switch (_context4.prev = _context4.next) {
|
|
162
172
|
case 0:
|
|
@@ -164,13 +174,26 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
164
174
|
params.order_id = undefined;
|
|
165
175
|
}
|
|
166
176
|
_context4.next = 3;
|
|
167
|
-
return this.request.post("/order/prepare/config", params)
|
|
177
|
+
return this.request.post("/order/prepare/config", _objectSpread(_objectSpread({}, params), {}, {
|
|
178
|
+
with_available_wallet_flag: (_params$with_availabl = params.with_available_wallet_flag) !== null && _params$with_availabl !== void 0 ? _params$with_availabl : 1,
|
|
179
|
+
with_available_wallet_pass_flag: (_params$with_availabl2 = params.with_available_wallet_pass_flag) !== null && _params$with_availabl2 !== void 0 ? _params$with_availabl2 : 1
|
|
180
|
+
}));
|
|
168
181
|
case 3:
|
|
169
182
|
prepareConfig = _context4.sent;
|
|
170
183
|
rawDiscountList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []));
|
|
184
|
+
availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.available_wallet_list) || []));
|
|
185
|
+
availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_pass_list) || [];
|
|
186
|
+
availableWalletIds = this.normalizePositiveNumberIds([].concat(_toConsumableArray(availableWalletList.map(function (item) {
|
|
187
|
+
return item === null || item === void 0 ? void 0 : item.wallet_id;
|
|
188
|
+
})), _toConsumableArray(availableWalletPassList.map(function (item) {
|
|
189
|
+
return item === null || item === void 0 ? void 0 : item.product_id;
|
|
190
|
+
}))));
|
|
171
191
|
goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
|
|
172
|
-
return _context4.abrupt("return",
|
|
173
|
-
|
|
192
|
+
return _context4.abrupt("return", {
|
|
193
|
+
discountList: goodPassList,
|
|
194
|
+
availableWalletIds: availableWalletIds
|
|
195
|
+
});
|
|
196
|
+
case 10:
|
|
174
197
|
case "end":
|
|
175
198
|
return _context4.stop();
|
|
176
199
|
}
|