@pisell/pisellos 2.3.30 → 2.3.31
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/model/strategy/adapter/promotion/index.js +0 -9
- 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 +2 -1
- package/dist/modules/Order/index.js +25 -11
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- 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 +1095 -849
- 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 +2 -0
- package/dist/solution/BaseSales/index.js +23 -13
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- 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/model/strategy/adapter/promotion/index.js +0 -49
- 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 +2 -1
- package/lib/modules/Order/index.js +13 -1
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- 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/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 +2 -0
- package/lib/solution/BaseSales/index.js +12 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- 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,293 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/model/strategy/adapter/dataVariant/examples.ts
|
|
20
|
+
var examples_exports = {};
|
|
21
|
+
__export(examples_exports, {
|
|
22
|
+
CUSTOMER_SCOPE_PRICE_STRATEGY: () => CUSTOMER_SCOPE_PRICE_STRATEGY,
|
|
23
|
+
DATA_VARIANT_EXAMPLE_MENUS: () => DATA_VARIANT_EXAMPLE_MENUS,
|
|
24
|
+
DATA_VARIANT_EXAMPLE_PRODUCTS: () => DATA_VARIANT_EXAMPLE_PRODUCTS,
|
|
25
|
+
DATA_VARIANT_EXAMPLE_SCHEDULES: () => DATA_VARIANT_EXAMPLE_SCHEDULES,
|
|
26
|
+
EVENING_MENU_PRICE_STRATEGY: () => EVENING_MENU_PRICE_STRATEGY,
|
|
27
|
+
VIP_PRODUCT_PRICE_STRATEGY: () => VIP_PRODUCT_PRICE_STRATEGY,
|
|
28
|
+
createExampleDataVariant: () => createExampleDataVariant,
|
|
29
|
+
runCustomerScopeDataVariantDemo: () => runCustomerScopeDataVariantDemo,
|
|
30
|
+
runDataVariantDemo: () => runDataVariantDemo
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(examples_exports);
|
|
33
|
+
var import_evaluator = require("./evaluator");
|
|
34
|
+
var import_type = require("./type");
|
|
35
|
+
function createExampleDataVariant(ruleId, data, overrides) {
|
|
36
|
+
return {
|
|
37
|
+
id: (overrides == null ? void 0 : overrides.id) ?? 1,
|
|
38
|
+
shop_id: (overrides == null ? void 0 : overrides.shop_id) ?? 9,
|
|
39
|
+
module: (overrides == null ? void 0 : overrides.module) ?? "product",
|
|
40
|
+
module_data_id: (overrides == null ? void 0 : overrides.module_data_id) ?? 61416,
|
|
41
|
+
data_variant_rule_id: ruleId,
|
|
42
|
+
data,
|
|
43
|
+
created_at: (overrides == null ? void 0 : overrides.created_at) ?? null,
|
|
44
|
+
updated_at: (overrides == null ? void 0 : overrides.updated_at) ?? null,
|
|
45
|
+
deleted_at: (overrides == null ? void 0 : overrides.deleted_at) ?? null
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var EVENING_MENU_PRICE_STRATEGY = {
|
|
49
|
+
metadata: {
|
|
50
|
+
id: "1",
|
|
51
|
+
type: "data_variant",
|
|
52
|
+
name: {
|
|
53
|
+
"zh-CN": "晚场餐牌价",
|
|
54
|
+
en: "Evening menu price"
|
|
55
|
+
},
|
|
56
|
+
custom: {
|
|
57
|
+
module: "product",
|
|
58
|
+
priority: 100,
|
|
59
|
+
status: "active",
|
|
60
|
+
updated_at: "2026-06-26 12:00:00"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
conditions: {
|
|
64
|
+
operator: "and",
|
|
65
|
+
rules: [
|
|
66
|
+
{
|
|
67
|
+
type: "operator",
|
|
68
|
+
field: "schedule",
|
|
69
|
+
operator: "schedule_match",
|
|
70
|
+
value: [1042]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "operator",
|
|
74
|
+
field: "product",
|
|
75
|
+
operator: "menu_match",
|
|
76
|
+
value: [43209]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
actionIds: ["apply_data_variant"]
|
|
80
|
+
},
|
|
81
|
+
actions: [
|
|
82
|
+
{
|
|
83
|
+
id: "apply_data_variant",
|
|
84
|
+
type: import_type.DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
85
|
+
target: "product",
|
|
86
|
+
value: null,
|
|
87
|
+
priority: 100
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
var VIP_PRODUCT_PRICE_STRATEGY = {
|
|
92
|
+
metadata: {
|
|
93
|
+
id: "2",
|
|
94
|
+
type: "data_variant",
|
|
95
|
+
name: {
|
|
96
|
+
"zh-CN": "VIP 商品价",
|
|
97
|
+
en: "VIP product price"
|
|
98
|
+
},
|
|
99
|
+
custom: {
|
|
100
|
+
module: "product",
|
|
101
|
+
priority: 200,
|
|
102
|
+
status: "active",
|
|
103
|
+
updated_at: "2026-06-26 13:00:00"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
conditions: {
|
|
107
|
+
operator: "and",
|
|
108
|
+
rules: [
|
|
109
|
+
{
|
|
110
|
+
type: "operator",
|
|
111
|
+
field: "productIdAndVariantId",
|
|
112
|
+
operator: "product_match",
|
|
113
|
+
value: [{ product_id: 2001, product_variant_id: 0 }]
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
actionIds: ["apply_data_variant"]
|
|
117
|
+
},
|
|
118
|
+
actions: [
|
|
119
|
+
{
|
|
120
|
+
id: "apply_data_variant",
|
|
121
|
+
type: import_type.DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
122
|
+
target: "product",
|
|
123
|
+
value: null,
|
|
124
|
+
priority: 200
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
var CUSTOMER_SCOPE_PRICE_STRATEGY = {
|
|
129
|
+
metadata: {
|
|
130
|
+
id: "3",
|
|
131
|
+
type: "data_variant",
|
|
132
|
+
name: {
|
|
133
|
+
"zh-CN": "指定客户渠道业务价",
|
|
134
|
+
en: "Scoped customer channel business price"
|
|
135
|
+
},
|
|
136
|
+
custom: {
|
|
137
|
+
module: "product",
|
|
138
|
+
priority: 150,
|
|
139
|
+
status: "active",
|
|
140
|
+
updated_at: "2026-06-26 14:00:00"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
conditions: {
|
|
144
|
+
operator: "and",
|
|
145
|
+
rules: [
|
|
146
|
+
{
|
|
147
|
+
type: "operator",
|
|
148
|
+
field: "customer_id",
|
|
149
|
+
operator: "in",
|
|
150
|
+
value: [333, 444]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: "operator",
|
|
154
|
+
field: "channel",
|
|
155
|
+
operator: "in",
|
|
156
|
+
value: ["pos", "online"]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: "operator",
|
|
160
|
+
field: "business_code",
|
|
161
|
+
operator: "in",
|
|
162
|
+
value: ["venue", "retail"]
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
actionIds: ["apply_data_variant"]
|
|
166
|
+
},
|
|
167
|
+
actions: [
|
|
168
|
+
{
|
|
169
|
+
id: "apply_data_variant",
|
|
170
|
+
type: import_type.DATA_VARIANT_ACTION_TYPES.APPLY,
|
|
171
|
+
target: "product",
|
|
172
|
+
value: null,
|
|
173
|
+
priority: 150
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
var DATA_VARIANT_EXAMPLE_SCHEDULES = [
|
|
178
|
+
{
|
|
179
|
+
id: 1042,
|
|
180
|
+
name: "晚场 17~20",
|
|
181
|
+
color: "#1890ff",
|
|
182
|
+
start_time: "2026-06-26 17:00:00",
|
|
183
|
+
end_time: "2026-06-26 20:00:00",
|
|
184
|
+
repeat_type: "none",
|
|
185
|
+
repeat_rule: {
|
|
186
|
+
end: { type: "never", end_date: null, occurrence: null },
|
|
187
|
+
frequency: 1,
|
|
188
|
+
excluded_date: [],
|
|
189
|
+
included_date: [],
|
|
190
|
+
frequency_date: []
|
|
191
|
+
},
|
|
192
|
+
type: "standard",
|
|
193
|
+
time_slot: [],
|
|
194
|
+
designation: [],
|
|
195
|
+
is_all: 0,
|
|
196
|
+
created_at: "2026-06-26 00:00:00",
|
|
197
|
+
updated_at: "2026-06-26 00:00:00",
|
|
198
|
+
order_count: 0,
|
|
199
|
+
relation_count: 0
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
var DATA_VARIANT_EXAMPLE_MENUS = [
|
|
203
|
+
{
|
|
204
|
+
form_record_id: 43209,
|
|
205
|
+
name: "kiosk餐牌1 17~20",
|
|
206
|
+
status: "valid",
|
|
207
|
+
schedule: [1042],
|
|
208
|
+
partyroom_package: {
|
|
209
|
+
type: "product_collection",
|
|
210
|
+
products: [
|
|
211
|
+
{
|
|
212
|
+
product_collection_id: 128,
|
|
213
|
+
product_id: 0,
|
|
214
|
+
product_variant_id: 0
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
var DATA_VARIANT_EXAMPLE_PRODUCTS = [
|
|
221
|
+
{
|
|
222
|
+
id: 2001,
|
|
223
|
+
title: "入场票",
|
|
224
|
+
price: 100,
|
|
225
|
+
stock: 50,
|
|
226
|
+
collection: [{ id: 128, title: "Tickets" }],
|
|
227
|
+
data_variants: [
|
|
228
|
+
createExampleDataVariant(1, { price: 80, stock: 20 }, {
|
|
229
|
+
id: 1,
|
|
230
|
+
module_data_id: 2001
|
|
231
|
+
}),
|
|
232
|
+
createExampleDataVariant(2, { price: 70, title: "VIP专属票" }, {
|
|
233
|
+
id: 2,
|
|
234
|
+
module_data_id: 2001
|
|
235
|
+
}),
|
|
236
|
+
createExampleDataVariant(3, { price: 65, title: "VIP渠道价" }, {
|
|
237
|
+
id: 4,
|
|
238
|
+
module_data_id: 2001
|
|
239
|
+
})
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: 2002,
|
|
244
|
+
title: "普通票",
|
|
245
|
+
price: 100,
|
|
246
|
+
stock: 50,
|
|
247
|
+
collection: [{ id: 999, title: "Other" }],
|
|
248
|
+
data_variants: [
|
|
249
|
+
createExampleDataVariant(1, { price: 80, stock: 20 }, {
|
|
250
|
+
id: 3,
|
|
251
|
+
module_data_id: 2002
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
function runDataVariantDemo() {
|
|
257
|
+
const evaluator = new import_evaluator.DataVariantEvaluator();
|
|
258
|
+
evaluator.setStrategyConfigs([
|
|
259
|
+
EVENING_MENU_PRICE_STRATEGY,
|
|
260
|
+
VIP_PRODUCT_PRICE_STRATEGY
|
|
261
|
+
]);
|
|
262
|
+
const businessData = {
|
|
263
|
+
products: DATA_VARIANT_EXAMPLE_PRODUCTS,
|
|
264
|
+
scheduleDateTime: "2026-06-26 18:00:00",
|
|
265
|
+
scheduleList: DATA_VARIANT_EXAMPLE_SCHEDULES,
|
|
266
|
+
menuList: DATA_VARIANT_EXAMPLE_MENUS,
|
|
267
|
+
orderType: "booking"
|
|
268
|
+
};
|
|
269
|
+
return evaluator.resolveProducts(businessData);
|
|
270
|
+
}
|
|
271
|
+
function runCustomerScopeDataVariantDemo() {
|
|
272
|
+
const evaluator = new import_evaluator.DataVariantEvaluator();
|
|
273
|
+
evaluator.setStrategyConfigs([CUSTOMER_SCOPE_PRICE_STRATEGY]);
|
|
274
|
+
const businessData = {
|
|
275
|
+
products: [DATA_VARIANT_EXAMPLE_PRODUCTS[0]],
|
|
276
|
+
customerId: 333,
|
|
277
|
+
channel: "pos",
|
|
278
|
+
businessCode: "venue"
|
|
279
|
+
};
|
|
280
|
+
return evaluator.resolveProducts(businessData);
|
|
281
|
+
}
|
|
282
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
283
|
+
0 && (module.exports = {
|
|
284
|
+
CUSTOMER_SCOPE_PRICE_STRATEGY,
|
|
285
|
+
DATA_VARIANT_EXAMPLE_MENUS,
|
|
286
|
+
DATA_VARIANT_EXAMPLE_PRODUCTS,
|
|
287
|
+
DATA_VARIANT_EXAMPLE_SCHEDULES,
|
|
288
|
+
EVENING_MENU_PRICE_STRATEGY,
|
|
289
|
+
VIP_PRODUCT_PRICE_STRATEGY,
|
|
290
|
+
createExampleDataVariant,
|
|
291
|
+
runCustomerScopeDataVariantDemo,
|
|
292
|
+
runDataVariantDemo
|
|
293
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/model/strategy/adapter/dataVariant/index.ts
|
|
21
|
+
var dataVariant_exports = {};
|
|
22
|
+
__export(dataVariant_exports, {
|
|
23
|
+
DataVariantAdapter: () => import_adapter.DataVariantAdapter,
|
|
24
|
+
DataVariantEvaluator: () => import_evaluator.DataVariantEvaluator,
|
|
25
|
+
runDataVariantDemo: () => import_examples.runDataVariantDemo
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(dataVariant_exports);
|
|
28
|
+
var import_adapter = require("./adapter");
|
|
29
|
+
var import_evaluator = require("./evaluator");
|
|
30
|
+
var import_examples = require("./examples");
|
|
31
|
+
__reExport(dataVariant_exports, require("./type"), module.exports);
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
DataVariantAdapter,
|
|
35
|
+
DataVariantEvaluator,
|
|
36
|
+
runDataVariantDemo,
|
|
37
|
+
...require("./type")
|
|
38
|
+
});
|
|
@@ -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,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/model/strategy/adapter/dataVariant/type.ts
|
|
20
|
+
var type_exports = {};
|
|
21
|
+
__export(type_exports, {
|
|
22
|
+
DATA_VARIANT_ACTION_TYPES: () => DATA_VARIANT_ACTION_TYPES
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(type_exports);
|
|
25
|
+
var DATA_VARIANT_ACTION_TYPES = {
|
|
26
|
+
APPLY: "DATA_VARIANT_APPLY"
|
|
27
|
+
};
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
DATA_VARIANT_ACTION_TYPES
|
|
31
|
+
});
|
|
@@ -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';
|
|
@@ -30,12 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/model/strategy/adapter/index.ts
|
|
31
31
|
var adapter_exports = {};
|
|
32
32
|
__export(adapter_exports, {
|
|
33
|
+
DataVariantAdapter: () => import_adapter3.DataVariantAdapter,
|
|
34
|
+
DataVariantEvaluator: () => import_evaluator4.DataVariantEvaluator,
|
|
33
35
|
ItemRuleAdapter: () => import_adapter2.ItemRuleAdapter,
|
|
34
36
|
ItemRuleEvaluator: () => import_evaluator3.ItemRuleEvaluator,
|
|
35
37
|
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
36
38
|
PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
|
|
37
39
|
WalletPassAdapter: () => import_walletPass.default,
|
|
38
|
-
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
40
|
+
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator,
|
|
41
|
+
runDataVariantDemo: () => import_examples.runDataVariantDemo
|
|
39
42
|
});
|
|
40
43
|
module.exports = __toCommonJS(adapter_exports);
|
|
41
44
|
__reExport(adapter_exports, require("./type"), module.exports);
|
|
@@ -45,13 +48,21 @@ var import_evaluator2 = require("./promotion/evaluator");
|
|
|
45
48
|
var import_adapter = require("./promotion/adapter");
|
|
46
49
|
var import_evaluator3 = require("./itemRule/evaluator");
|
|
47
50
|
var import_adapter2 = require("./itemRule/adapter");
|
|
51
|
+
var import_evaluator4 = require("./dataVariant/evaluator");
|
|
52
|
+
var import_adapter3 = require("./dataVariant/adapter");
|
|
53
|
+
var import_examples = require("./dataVariant/examples");
|
|
54
|
+
__reExport(adapter_exports, require("./dataVariant/type"), module.exports);
|
|
48
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
56
|
0 && (module.exports = {
|
|
57
|
+
DataVariantAdapter,
|
|
58
|
+
DataVariantEvaluator,
|
|
50
59
|
ItemRuleAdapter,
|
|
51
60
|
ItemRuleEvaluator,
|
|
52
61
|
PromotionAdapter,
|
|
53
62
|
PromotionEvaluator,
|
|
54
63
|
WalletPassAdapter,
|
|
55
64
|
WalletPassEvaluator,
|
|
56
|
-
|
|
65
|
+
runDataVariantDemo,
|
|
66
|
+
...require("./type"),
|
|
67
|
+
...require("./dataVariant/type")
|
|
57
68
|
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -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;
|
|
@@ -91,23 +91,43 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
91
91
|
getOriginalDiscountList() {
|
|
92
92
|
return this.store.originalDiscountList || [];
|
|
93
93
|
}
|
|
94
|
+
normalizePositiveNumberIds(values) {
|
|
95
|
+
const ids = values.map((value) => Number(value)).filter((value) => Number.isFinite(value) && value > 0);
|
|
96
|
+
return Array.from(new Set(ids));
|
|
97
|
+
}
|
|
94
98
|
async loadPrepareConfig(params) {
|
|
95
|
-
var _a, _b;
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
96
100
|
if (typeof params.order_id === "string" && params.order_id.startsWith("LOCAL_")) {
|
|
97
101
|
params.order_id = void 0;
|
|
98
102
|
}
|
|
99
103
|
const prepareConfig = await this.request.post(
|
|
100
104
|
`/order/prepare/config`,
|
|
101
|
-
|
|
105
|
+
{
|
|
106
|
+
...params,
|
|
107
|
+
with_available_wallet_flag: params.with_available_wallet_flag ?? 1,
|
|
108
|
+
with_available_wallet_pass_flag: params.with_available_wallet_pass_flag ?? 1
|
|
109
|
+
}
|
|
102
110
|
);
|
|
103
111
|
const rawDiscountList = [
|
|
104
112
|
...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [],
|
|
105
113
|
...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []
|
|
106
114
|
];
|
|
115
|
+
const availableWalletList = [
|
|
116
|
+
...((_c = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _c.avaiable_wallet_list) || [],
|
|
117
|
+
...((_d = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _d.available_wallet_list) || []
|
|
118
|
+
];
|
|
119
|
+
const availableWalletPassList = ((_e = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _e.available_wallet_pass_list) || [];
|
|
120
|
+
const availableWalletIds = this.normalizePositiveNumberIds([
|
|
121
|
+
...availableWalletList.map((item) => item == null ? void 0 : item.wallet_id),
|
|
122
|
+
...availableWalletPassList.map((item) => item == null ? void 0 : item.product_id)
|
|
123
|
+
]);
|
|
107
124
|
const goodPassList = this.filterEnabledDiscountList(
|
|
108
125
|
rawDiscountList
|
|
109
126
|
) || [];
|
|
110
|
-
return
|
|
127
|
+
return {
|
|
128
|
+
discountList: goodPassList,
|
|
129
|
+
availableWalletIds
|
|
130
|
+
};
|
|
111
131
|
}
|
|
112
132
|
async batchSearch(code, options) {
|
|
113
133
|
const { customerId, orderId } = options || {};
|