@pisell/pisellos 2.2.259 → 2.2.260

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 (103) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
  14. package/dist/modules/Order/index.d.ts +1 -32
  15. package/dist/modules/Order/index.js +288 -615
  16. package/dist/modules/Order/types.d.ts +2 -20
  17. package/dist/modules/Order/utils.d.ts +0 -4
  18. package/dist/modules/Order/utils.js +28 -114
  19. package/dist/modules/Product/index.d.ts +1 -1
  20. package/dist/modules/Product/types.d.ts +22 -0
  21. package/dist/modules/ProductList/index.d.ts +1 -1
  22. package/dist/modules/ProductList/index.js +4 -2
  23. package/dist/modules/ProductList/types.d.ts +2 -0
  24. package/dist/modules/Rules/index.d.ts +3 -3
  25. package/dist/modules/Rules/index.js +3 -8
  26. package/dist/modules/Rules/types.d.ts +1 -2
  27. package/dist/modules/SalesSummary/index.d.ts +3 -7
  28. package/dist/modules/SalesSummary/index.js +39 -67
  29. package/dist/modules/SalesSummary/types.d.ts +0 -1
  30. package/dist/modules/SalesSummary/utils.js +1 -2
  31. package/dist/modules/SurchargeList/index.d.ts +4 -6
  32. package/dist/modules/SurchargeList/index.js +39 -62
  33. package/dist/modules/SurchargeList/types.d.ts +2 -6
  34. package/dist/server/index.d.ts +50 -3
  35. package/dist/server/index.js +1040 -1075
  36. package/dist/server/modules/order/index.d.ts +3 -22
  37. package/dist/server/modules/order/index.js +316 -398
  38. package/dist/server/modules/products/index.d.ts +26 -7
  39. package/dist/server/modules/products/index.js +166 -76
  40. package/dist/server/modules/products/types.d.ts +14 -0
  41. package/dist/solution/BaseSales/index.d.ts +2 -22
  42. package/dist/solution/BaseSales/index.js +701 -995
  43. package/dist/solution/BaseSales/types.d.ts +0 -1
  44. package/dist/solution/BaseSales/types.js +1 -2
  45. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
  46. package/dist/solution/BookingByStep/index.d.ts +1 -1
  47. package/dist/solution/BookingTicket/index.d.ts +0 -8
  48. package/dist/solution/BookingTicket/index.js +6 -153
  49. package/dist/solution/BookingTicket/types.d.ts +2 -0
  50. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  51. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  53. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  54. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  55. package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
  56. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  57. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  58. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  59. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  60. package/lib/model/strategy/adapter/index.d.ts +4 -0
  61. package/lib/model/strategy/adapter/index.js +13 -2
  62. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
  63. package/lib/modules/Order/index.d.ts +1 -32
  64. package/lib/modules/Order/index.js +64 -402
  65. package/lib/modules/Order/types.d.ts +2 -20
  66. package/lib/modules/Order/utils.d.ts +0 -4
  67. package/lib/modules/Order/utils.js +2 -84
  68. package/lib/modules/Product/index.d.ts +1 -1
  69. package/lib/modules/Product/types.d.ts +22 -0
  70. package/lib/modules/ProductList/index.d.ts +1 -1
  71. package/lib/modules/ProductList/index.js +4 -2
  72. package/lib/modules/ProductList/types.d.ts +2 -0
  73. package/lib/modules/Rules/index.d.ts +3 -3
  74. package/lib/modules/Rules/index.js +3 -4
  75. package/lib/modules/Rules/types.d.ts +1 -2
  76. package/lib/modules/SalesSummary/index.d.ts +3 -7
  77. package/lib/modules/SalesSummary/index.js +11 -28
  78. package/lib/modules/SalesSummary/types.d.ts +0 -1
  79. package/lib/modules/SalesSummary/utils.js +0 -2
  80. package/lib/modules/SurchargeList/index.d.ts +4 -6
  81. package/lib/modules/SurchargeList/index.js +21 -41
  82. package/lib/modules/SurchargeList/types.d.ts +2 -6
  83. package/lib/server/index.d.ts +50 -3
  84. package/lib/server/index.js +215 -244
  85. package/lib/server/modules/order/index.d.ts +3 -22
  86. package/lib/server/modules/order/index.js +53 -103
  87. package/lib/server/modules/products/index.d.ts +26 -7
  88. package/lib/server/modules/products/index.js +113 -35
  89. package/lib/server/modules/products/types.d.ts +14 -0
  90. package/lib/solution/BaseSales/index.d.ts +2 -22
  91. package/lib/solution/BaseSales/index.js +60 -246
  92. package/lib/solution/BaseSales/types.d.ts +0 -1
  93. package/lib/solution/BaseSales/types.js +1 -2
  94. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
  95. package/lib/solution/BookingByStep/index.d.ts +1 -1
  96. package/lib/solution/BookingTicket/index.d.ts +0 -8
  97. package/lib/solution/BookingTicket/index.js +0 -101
  98. package/lib/solution/BookingTicket/types.d.ts +2 -0
  99. package/package.json +1 -1
  100. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  101. package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
  102. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  103. package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
@@ -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,282 @@
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
+ }
278
+
279
+ // @ts-ignore
280
+ window.runDataVariantDemo = runDataVariantDemo;
281
+ // @ts-ignore
282
+ window.runCustomerScopeDataVariantDemo = runCustomerScopeDataVariantDemo;
@@ -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,4 @@
1
+ export { DataVariantAdapter } from "./adapter";
2
+ export { DataVariantEvaluator } from "./evaluator";
3
+ export { runDataVariantDemo } from "./examples";
4
+ export * from "./type";
@@ -0,0 +1,146 @@
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
+ custom?: Record<string, any>;
106
+ }
107
+ /**
108
+ * 全局预计算后的规则信息。
109
+ */
110
+ export interface EffectiveRuleInfo {
111
+ ruleId: string;
112
+ priority: number;
113
+ strategyConfig: StrategyConfig<DataVariantRuleMetadata>;
114
+ productRules: ConditionRule[];
115
+ globalResult: EvaluationResult;
116
+ }
117
+ export type GlobalEffectiveRuleMap = Map<string, EffectiveRuleInfo>;
118
+ /**
119
+ * 单条商品命中的变体覆盖信息。
120
+ */
121
+ export interface MatchedDataVariant {
122
+ ruleId: string;
123
+ priority: number;
124
+ data: Record<string, any>;
125
+ variant: DataVariantItem;
126
+ }
127
+ /**
128
+ * 商品上记录的 Data Variant 调试信息。
129
+ */
130
+ export interface DataVariantAppliedInfo {
131
+ appliedRuleIds: string[];
132
+ appliedFields: string[];
133
+ original: DataVariantProduct;
134
+ }
135
+ /**
136
+ * 批量解析结果。
137
+ */
138
+ export interface ResolvedDataVariantResult {
139
+ products: DataVariantProduct[];
140
+ globalEffectiveRuleMap: GlobalEffectiveRuleMap;
141
+ menuScopeMap: Map<number, MenuScope>;
142
+ /** 当前策略中 schedule_match 绑定的日程提取出的时间点,格式如 ["10:00", "13:00"] */
143
+ scheduleTimePoints: string[];
144
+ rawResults: EvaluationResult[];
145
+ }
146
+ 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,3 +1,7 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
7
  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); }
@@ -128,14 +132,6 @@ function resolveMainProductPrice(product, fallback) {
128
132
  var parsed = Number(value);
129
133
  return Number.isFinite(parsed) ? parsed : fallback;
130
134
  }
131
- function mapOrderBundleToOtherBundle(bundle) {
132
- return bundle.map(function (item) {
133
- var _ref6, _item$original_price;
134
- return _objectSpread(_objectSpread({}, item), {}, {
135
- original_price: (_ref6 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : item.price
136
- });
137
- });
138
- }
139
135
 
140
136
  /**
141
137
  * catalog 缺 product_resource 时,从 booking.resources 反推最小 product_resource 结构,
@@ -163,10 +159,10 @@ function synthesizeProductResourceFromBooking(booking) {
163
159
  });
164
160
  if (relationIdsByForm.size === 0) return undefined;
165
161
  return {
166
- resources: Array.from(relationIdsByForm.entries()).map(function (_ref7) {
167
- var _ref8 = _slicedToArray(_ref7, 2),
168
- formId = _ref8[0],
169
- relationIds = _ref8[1];
162
+ resources: Array.from(relationIdsByForm.entries()).map(function (_ref6) {
163
+ var _ref7 = _slicedToArray(_ref6, 2),
164
+ formId = _ref7[0],
165
+ relationIds = _ref7[1];
170
166
  return {
171
167
  id: formId,
172
168
  status: 1,
@@ -186,7 +182,7 @@ function synthesizeProductResourceFromBooking(booking) {
186
182
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
187
183
  */
188
184
  export function buildCacheItemFromOrderLine(input) {
189
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref9, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref10, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref11, _booking$id;
185
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref8, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref9, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref10, _booking$id;
190
186
  var product = input.product,
191
187
  booking = input.booking,
192
188
  sourceProduct = input.sourceProduct;
@@ -206,7 +202,7 @@ export function buildCacheItemFromOrderLine(input) {
206
202
  var other = {
207
203
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
208
204
  option: getProductSkuOptions(product),
209
- bundle: mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [])
205
+ bundle: Array.isArray(product.product_bundle) ? _toConsumableArray(product.product_bundle) : []
210
206
  };
211
207
  var extend = _objectSpread({
212
208
  start_date: startDate ? dayjs(startDate) : undefined,
@@ -219,7 +215,7 @@ export function buildCacheItemFromOrderLine(input) {
219
215
  sub_type: booking.sub_type,
220
216
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
221
217
  product_name: productTitle,
222
- note: (_ref9 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref9 !== void 0 ? _ref9 : '',
218
+ note: (_ref8 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref8 !== void 0 ? _ref8 : '',
223
219
  price: mainProductPrice,
224
220
  total: selling,
225
221
  origin_total: original,
@@ -254,7 +250,7 @@ export function buildCacheItemFromOrderLine(input) {
254
250
  var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
255
251
  id: resolvedId,
256
252
  product_id: resolvedId,
257
- extension_type: (_ref10 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref10 !== void 0 ? _ref10 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
253
+ extension_type: (_ref9 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref9 !== void 0 ? _ref9 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
258
254
  title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
259
255
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
260
256
  selling_price: product.selling_price,
@@ -266,7 +262,7 @@ export function buildCacheItemFromOrderLine(input) {
266
262
  new: 0,
267
263
  autoClose: false,
268
264
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
269
- booking_id: (_ref11 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref11 !== void 0 ? _ref11 : 0
265
+ booking_id: (_ref10 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref10 !== void 0 ? _ref10 : 0
270
266
  });
271
267
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
272
268
  base.capacity = sourceProduct.capacity;