@pisell/pisellos 2.1.165 → 2.1.166

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.
Files changed (78) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +3 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  4. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  5. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  6. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  7. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  8. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  9. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  10. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  11. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  12. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  13. package/dist/model/strategy/adapter/index.d.ts +4 -0
  14. package/dist/model/strategy/adapter/index.js +5 -1
  15. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  16. package/dist/modules/Discount/index.d.ts +5 -2
  17. package/dist/modules/Discount/index.js +21 -1
  18. package/dist/modules/Discount/types.d.ts +4 -0
  19. package/dist/modules/Order/index.d.ts +1 -0
  20. package/dist/modules/Order/index.js +18 -6
  21. package/dist/modules/Order/types.d.ts +2 -0
  22. package/dist/modules/ProductList/index.d.ts +3 -1
  23. package/dist/modules/ProductList/index.js +22 -11
  24. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  25. package/dist/solution/BookingByStep/index.d.ts +2 -2
  26. package/dist/solution/ScanOrder/index.js +1 -1
  27. package/dist/solution/ShopDiscount/index.js +16 -15
  28. package/dist/solution/VenueBooking/index.d.ts +40 -3
  29. package/dist/solution/VenueBooking/index.js +394 -261
  30. package/dist/solution/VenueBooking/types.d.ts +3 -1
  31. package/dist/solution/VenueBooking/types.js +1 -0
  32. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  33. package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
  34. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  35. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
  36. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
  37. package/dist/solution/VenueBooking/utils/smartPricing.js +233 -0
  38. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  39. package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +3 -0
  42. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  43. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  44. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  46. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  48. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  50. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  52. package/lib/model/strategy/adapter/index.d.ts +4 -0
  53. package/lib/model/strategy/adapter/index.js +13 -2
  54. package/lib/modules/Discount/index.d.ts +5 -2
  55. package/lib/modules/Discount/index.js +11 -1
  56. package/lib/modules/Discount/types.d.ts +4 -0
  57. package/lib/modules/Order/index.d.ts +1 -0
  58. package/lib/modules/Order/index.js +11 -1
  59. package/lib/modules/Order/types.d.ts +2 -0
  60. package/lib/modules/ProductList/index.d.ts +3 -1
  61. package/lib/modules/ProductList/index.js +45 -39
  62. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  63. package/lib/solution/BookingByStep/index.d.ts +2 -2
  64. package/lib/solution/ScanOrder/index.js +1 -1
  65. package/lib/solution/ShopDiscount/index.js +3 -2
  66. package/lib/solution/VenueBooking/index.d.ts +40 -3
  67. package/lib/solution/VenueBooking/index.js +257 -111
  68. package/lib/solution/VenueBooking/types.d.ts +3 -1
  69. package/lib/solution/VenueBooking/types.js +1 -0
  70. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  71. package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
  72. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  73. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
  74. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
  75. package/lib/solution/VenueBooking/utils/smartPricing.js +180 -0
  76. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  77. package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
  78. 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,4 @@
1
+ export { DataVariantAdapter } from './adapter';
2
+ export { DataVariantEvaluator } from './evaluator';
3
+ export { runDataVariantDemo } from './examples';
4
+ export * from './type';
@@ -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
- ...require("./type")
65
+ runDataVariantDemo,
66
+ ...require("./type"),
67
+ ...require("./dataVariant/type")
57
68
  });
@@ -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;
@@ -22,9 +22,12 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
22
22
  with_discount_card: 0 | 1;
23
23
  customer_id: number;
24
24
  with_wallet_pass_holder: 0 | 1;
25
+ with_available_wallet_flag?: 0 | 1;
26
+ with_available_wallet_pass_flag?: 0 | 1;
25
27
  request_timezone: string;
26
28
  order_id?: number;
27
- }): Promise<Discount[]>;
29
+ }): Promise<DiscountPrepareConfigResult>;
30
+ private extractAvailableWalletIds;
28
31
  batchSearch(code: string, options?: {
29
32
  customerId?: number;
30
33
  orderId?: number;
@@ -100,7 +100,17 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
100
100
  const goodPassList = this.filterEnabledDiscountList(
101
101
  [...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
102
102
  ) || [];
103
- return goodPassList;
103
+ return {
104
+ discountList: goodPassList,
105
+ availableWalletIds: this.extractAvailableWalletIds(prepareConfig == null ? void 0 : prepareConfig.data)
106
+ };
107
+ }
108
+ extractAvailableWalletIds(data) {
109
+ const availableWalletList = Array.isArray(data == null ? void 0 : data.avaiable_wallet_list) ? data.avaiable_wallet_list : Array.isArray(data == null ? void 0 : data.available_wallet_list) ? data.available_wallet_list : [];
110
+ const availableWalletPassList = Array.isArray(data == null ? void 0 : data.available_wallet_pass_list) ? data.available_wallet_pass_list : [];
111
+ const walletIds = availableWalletList.map((item) => Number(item == null ? void 0 : item.wallet_id)).filter((id) => Number.isFinite(id) && id > 0);
112
+ const walletPassProductIds = availableWalletPassList.map((item) => Number(item == null ? void 0 : item.product_id)).filter((id) => Number.isFinite(id) && id > 0);
113
+ return Array.from(/* @__PURE__ */ new Set([...walletIds, ...walletPassProductIds]));
104
114
  }
105
115
  async batchSearch(code, options) {
106
116
  const { customerId, orderId } = options || {};
@@ -68,6 +68,10 @@ export interface DiscountWithReason {
68
68
  discountList: Discount[];
69
69
  unavailableReasonKey: DiscountFilterRejectKey | null;
70
70
  }
71
+ export interface DiscountPrepareConfigResult {
72
+ discountList: Discount[];
73
+ availableWalletIds: number[];
74
+ }
71
75
  interface ExtensionData {
72
76
  id: number;
73
77
  shop_id: number;
@@ -42,6 +42,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
42
42
  action?: 'create';
43
43
  }): Promise<void>;
44
44
  getDiscountList(): Discount[];
45
+ getAvailableWalletIds(): number[];
45
46
  scanCode(code: string, customerId?: number): Promise<{
46
47
  isAvailable: boolean;
47
48
  discountList: Discount[];
@@ -76,6 +76,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
76
76
  if (!this.store.tempOrder) {
77
77
  this.store.tempOrder = null;
78
78
  }
79
+ if (!Array.isArray(this.store.availableWalletIds)) {
80
+ this.store.availableWalletIds = [];
81
+ }
79
82
  this.request = this.core.getPlugin("request");
80
83
  this.window = this.core.getPlugin("window");
81
84
  const otherParams = options.otherParams || {};
@@ -163,14 +166,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
163
166
  // ─── Discount: 公共 API ───
164
167
  async loadDiscountConfig(params) {
165
168
  var _a, _b, _c, _d;
166
- const discountList = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
169
+ const prepareConfig = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
167
170
  customer_id: params.customerId,
168
171
  action: params.action || "create",
169
172
  with_good_pass: 1,
170
173
  with_discount_card: 1,
171
174
  with_wallet_pass_holder: 1,
175
+ with_available_wallet_flag: 1,
176
+ with_available_wallet_pass_flag: 1,
172
177
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
173
178
  }));
179
+ const discountList = prepareConfig == null ? void 0 : prepareConfig.discountList;
180
+ this.store.availableWalletIds = (prepareConfig == null ? void 0 : prepareConfig.availableWalletIds) || [];
174
181
  if (discountList) {
175
182
  (_b = this.store.discount) == null ? void 0 : _b.setDiscountList(discountList);
176
183
  }
@@ -182,6 +189,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
182
189
  var _a;
183
190
  return ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
184
191
  }
192
+ getAvailableWalletIds() {
193
+ return this.store.availableWalletIds || [];
194
+ }
185
195
  async scanCode(code, customerId) {
186
196
  var _a, _b, _c, _d;
187
197
  const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
@@ -15,6 +15,7 @@ export interface OrderState {
15
15
  discountList: any[];
16
16
  discount: DiscountModule | null;
17
17
  rules: RulesModule | null;
18
+ availableWalletIds?: number[];
18
19
  }
19
20
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
20
21
  export interface UpdateProductInOrderParams {
@@ -248,5 +249,6 @@ export interface OrderModuleAPI {
248
249
  action?: 'create';
249
250
  }) => Promise<void>;
250
251
  getDiscountList: () => Discount[];
252
+ getAvailableWalletIds: () => number[];
251
253
  applyDiscount: () => void;
252
254
  }