@pisell/pisellos 2.2.264 → 2.2.266

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 (126) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -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 +148 -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 +16 -10
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  16. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  17. package/dist/modules/Discount/index.d.ts +5 -2
  18. package/dist/modules/Discount/index.js +30 -7
  19. package/dist/modules/Discount/types.d.ts +4 -0
  20. package/dist/modules/Order/index.d.ts +41 -10
  21. package/dist/modules/Order/index.js +1379 -810
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +49 -1
  25. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  26. package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
  27. package/dist/modules/Order/utils.d.ts +4 -3
  28. package/dist/modules/Order/utils.js +61 -64
  29. package/dist/modules/Payment/index.d.ts +2 -0
  30. package/dist/modules/Payment/index.js +78 -49
  31. package/dist/modules/Payment/types.d.ts +26 -24
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +22 -0
  34. package/dist/modules/ProductList/index.d.ts +1 -1
  35. package/dist/modules/ProductList/index.js +4 -2
  36. package/dist/modules/ProductList/types.d.ts +2 -0
  37. package/dist/modules/Rules/index.d.ts +2 -8
  38. package/dist/modules/Rules/index.js +55 -9
  39. package/dist/modules/Rules/types.d.ts +10 -1
  40. package/dist/server/index.d.ts +71 -0
  41. package/dist/server/index.js +2504 -1187
  42. package/dist/server/modules/order/index.d.ts +56 -5
  43. package/dist/server/modules/order/index.js +1718 -834
  44. package/dist/server/modules/order/types.d.ts +15 -3
  45. package/dist/server/modules/order/types.js +1 -1
  46. package/dist/server/modules/products/index.d.ts +31 -8
  47. package/dist/server/modules/products/index.js +549 -390
  48. package/dist/server/modules/products/types.d.ts +18 -0
  49. package/dist/solution/BaseSales/index.d.ts +67 -4
  50. package/dist/solution/BaseSales/index.js +1476 -792
  51. package/dist/solution/BaseSales/types.d.ts +6 -1
  52. package/dist/solution/BaseSales/types.js +1 -1
  53. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  54. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  56. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  57. package/dist/solution/BookingByStep/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +94 -54
  59. package/dist/solution/BookingTicket/types.d.ts +2 -0
  60. package/dist/solution/Sales/index.d.ts +1 -0
  61. package/dist/solution/Sales/index.js +10 -2
  62. package/dist/solution/ShopDiscount/index.js +15 -14
  63. package/dist/utils/payment-number.d.ts +9 -0
  64. package/dist/utils/payment-number.js +69 -0
  65. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  66. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  67. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  68. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  69. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  70. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  71. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  72. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  73. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  74. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  75. package/lib/model/strategy/adapter/index.d.ts +4 -0
  76. package/lib/model/strategy/adapter/index.js +13 -2
  77. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  78. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  79. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  80. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  81. package/lib/modules/Discount/index.d.ts +5 -2
  82. package/lib/modules/Discount/index.js +23 -3
  83. package/lib/modules/Discount/types.d.ts +4 -0
  84. package/lib/modules/Order/index.d.ts +41 -10
  85. package/lib/modules/Order/index.js +514 -122
  86. package/lib/modules/Order/payment-utils.d.ts +26 -0
  87. package/lib/modules/Order/payment-utils.js +224 -0
  88. package/lib/modules/Order/types.d.ts +49 -1
  89. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  90. package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
  91. package/lib/modules/Order/utils.d.ts +4 -3
  92. package/lib/modules/Order/utils.js +26 -20
  93. package/lib/modules/Payment/index.d.ts +2 -0
  94. package/lib/modules/Payment/index.js +33 -12
  95. package/lib/modules/Payment/types.d.ts +26 -24
  96. package/lib/modules/Product/types.d.ts +22 -0
  97. package/lib/modules/ProductList/index.d.ts +1 -1
  98. package/lib/modules/ProductList/index.js +4 -2
  99. package/lib/modules/ProductList/types.d.ts +2 -0
  100. package/lib/modules/Rules/index.d.ts +2 -8
  101. package/lib/modules/Rules/index.js +57 -6
  102. package/lib/modules/Rules/types.d.ts +10 -1
  103. package/lib/server/index.d.ts +71 -0
  104. package/lib/server/index.js +1002 -52
  105. package/lib/server/modules/order/index.d.ts +56 -5
  106. package/lib/server/modules/order/index.js +798 -148
  107. package/lib/server/modules/order/types.d.ts +15 -3
  108. package/lib/server/modules/products/index.d.ts +31 -8
  109. package/lib/server/modules/products/index.js +134 -35
  110. package/lib/server/modules/products/types.d.ts +18 -0
  111. package/lib/solution/BaseSales/index.d.ts +67 -4
  112. package/lib/solution/BaseSales/index.js +496 -50
  113. package/lib/solution/BaseSales/types.d.ts +6 -1
  114. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  115. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  116. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  117. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  118. package/lib/solution/BookingByStep/index.d.ts +1 -1
  119. package/lib/solution/BookingTicket/index.js +39 -11
  120. package/lib/solution/BookingTicket/types.d.ts +2 -0
  121. package/lib/solution/Sales/index.d.ts +1 -0
  122. package/lib/solution/Sales/index.js +5 -3
  123. package/lib/solution/ShopDiscount/index.js +2 -1
  124. package/lib/utils/payment-number.d.ts +9 -0
  125. package/lib/utils/payment-number.js +64 -0
  126. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ import type { StrategyConfig } from '../../type';
2
+ import type { ScheduleItem } from '../../../../modules/Schedule/types';
3
+ import type { DataVariantItem, DataVariantMenu, DataVariantProduct, DataVariantRuleMetadata } from './type';
4
+ /**
5
+ * 构造示例用 data_variant 记录,字段结构与后端 /product/query 返回一致。
6
+ */
7
+ export declare function createExampleDataVariant(ruleId: number | string, data: Record<string, any>, overrides?: Partial<Omit<DataVariantItem, 'data_variant_rule_id' | 'data'>>): DataVariantItem;
8
+ /**
9
+ * 晚场餐牌价:命中日程 + 餐牌商品范围后覆盖 price / stock。
10
+ */
11
+ export declare const EVENING_MENU_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
12
+ /**
13
+ * VIP 商品价:演示 product_match 与更高优先级字段覆盖。
14
+ */
15
+ export declare const VIP_PRODUCT_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
16
+ /**
17
+ * 客户/渠道/业务范围价:演示 customer_id、channel、business_code 的 in 条件。
18
+ */
19
+ export declare const CUSTOMER_SCOPE_PRICE_STRATEGY: StrategyConfig<DataVariantRuleMetadata>;
20
+ /**
21
+ * 示例日程:2026-06-26 17:00 ~ 20:00 生效。
22
+ */
23
+ export declare const DATA_VARIANT_EXAMPLE_SCHEDULES: ScheduleItem[];
24
+ /**
25
+ * 示例餐牌:product_collection = 128 的商品均属于餐牌。
26
+ */
27
+ export declare const DATA_VARIANT_EXAMPLE_MENUS: DataVariantMenu[];
28
+ /**
29
+ * 示例商品:同时带两条 Data Variant 覆盖数据。
30
+ */
31
+ export declare const DATA_VARIANT_EXAMPLE_PRODUCTS: DataVariantProduct[];
32
+ /**
33
+ * Data Variant 评估器示例调用。
34
+ */
35
+ export declare function runDataVariantDemo(): import("./type").ResolvedDataVariantResult;
36
+ /**
37
+ * 客户/渠道/业务范围条件示例调用。
38
+ */
39
+ export declare function runCustomerScopeDataVariantDemo(): import("./type").ResolvedDataVariantResult;
@@ -0,0 +1,277 @@
1
+ import { DataVariantEvaluator } from "./evaluator";
2
+ import { DATA_VARIANT_ACTION_TYPES } from "./type";
3
+ /**
4
+ * 构造示例用 data_variant 记录,字段结构与后端 /product/query 返回一致。
5
+ */
6
+ export function createExampleDataVariant(ruleId, data, overrides) {
7
+ var _overrides$id, _overrides$shop_id, _overrides$module, _overrides$module_dat, _overrides$created_at, _overrides$updated_at, _overrides$deleted_at;
8
+ return {
9
+ id: (_overrides$id = overrides === null || overrides === void 0 ? void 0 : overrides.id) !== null && _overrides$id !== void 0 ? _overrides$id : 1,
10
+ shop_id: (_overrides$shop_id = overrides === null || overrides === void 0 ? void 0 : overrides.shop_id) !== null && _overrides$shop_id !== void 0 ? _overrides$shop_id : 9,
11
+ module: (_overrides$module = overrides === null || overrides === void 0 ? void 0 : overrides.module) !== null && _overrides$module !== void 0 ? _overrides$module : 'product',
12
+ module_data_id: (_overrides$module_dat = overrides === null || overrides === void 0 ? void 0 : overrides.module_data_id) !== null && _overrides$module_dat !== void 0 ? _overrides$module_dat : 61416,
13
+ data_variant_rule_id: ruleId,
14
+ data: data,
15
+ created_at: (_overrides$created_at = overrides === null || overrides === void 0 ? void 0 : overrides.created_at) !== null && _overrides$created_at !== void 0 ? _overrides$created_at : null,
16
+ updated_at: (_overrides$updated_at = overrides === null || overrides === void 0 ? void 0 : overrides.updated_at) !== null && _overrides$updated_at !== void 0 ? _overrides$updated_at : null,
17
+ deleted_at: (_overrides$deleted_at = overrides === null || overrides === void 0 ? void 0 : overrides.deleted_at) !== null && _overrides$deleted_at !== void 0 ? _overrides$deleted_at : null
18
+ };
19
+ }
20
+
21
+ /**
22
+ * 晚场餐牌价:命中日程 + 餐牌商品范围后覆盖 price / stock。
23
+ */
24
+ export var EVENING_MENU_PRICE_STRATEGY = {
25
+ metadata: {
26
+ id: '1',
27
+ type: 'data_variant',
28
+ name: {
29
+ 'zh-CN': '晚场餐牌价',
30
+ en: 'Evening menu price'
31
+ },
32
+ custom: {
33
+ module: 'product',
34
+ priority: 100,
35
+ status: 'active',
36
+ updated_at: '2026-06-26 12:00:00'
37
+ }
38
+ },
39
+ conditions: {
40
+ operator: 'and',
41
+ rules: [{
42
+ type: 'operator',
43
+ field: 'schedule',
44
+ operator: 'schedule_match',
45
+ value: [1042]
46
+ }, {
47
+ type: 'operator',
48
+ field: 'product',
49
+ operator: 'menu_match',
50
+ value: [43209]
51
+ }],
52
+ actionIds: ['apply_data_variant']
53
+ },
54
+ actions: [{
55
+ id: 'apply_data_variant',
56
+ type: DATA_VARIANT_ACTION_TYPES.APPLY,
57
+ target: 'product',
58
+ value: null,
59
+ priority: 100
60
+ }]
61
+ };
62
+
63
+ /**
64
+ * VIP 商品价:演示 product_match 与更高优先级字段覆盖。
65
+ */
66
+ export var VIP_PRODUCT_PRICE_STRATEGY = {
67
+ metadata: {
68
+ id: '2',
69
+ type: 'data_variant',
70
+ name: {
71
+ 'zh-CN': 'VIP 商品价',
72
+ en: 'VIP product price'
73
+ },
74
+ custom: {
75
+ module: 'product',
76
+ priority: 200,
77
+ status: 'active',
78
+ updated_at: '2026-06-26 13:00:00'
79
+ }
80
+ },
81
+ conditions: {
82
+ operator: 'and',
83
+ rules: [{
84
+ type: 'operator',
85
+ field: 'productIdAndVariantId',
86
+ operator: 'product_match',
87
+ value: [{
88
+ product_id: 2001,
89
+ product_variant_id: 0
90
+ }]
91
+ }],
92
+ actionIds: ['apply_data_variant']
93
+ },
94
+ actions: [{
95
+ id: 'apply_data_variant',
96
+ type: DATA_VARIANT_ACTION_TYPES.APPLY,
97
+ target: 'product',
98
+ value: null,
99
+ priority: 200
100
+ }]
101
+ };
102
+
103
+ /**
104
+ * 客户/渠道/业务范围价:演示 customer_id、channel、business_code 的 in 条件。
105
+ */
106
+ export var CUSTOMER_SCOPE_PRICE_STRATEGY = {
107
+ metadata: {
108
+ id: '3',
109
+ type: 'data_variant',
110
+ name: {
111
+ 'zh-CN': '指定客户渠道业务价',
112
+ en: 'Scoped customer channel business price'
113
+ },
114
+ custom: {
115
+ module: 'product',
116
+ priority: 150,
117
+ status: 'active',
118
+ updated_at: '2026-06-26 14:00:00'
119
+ }
120
+ },
121
+ conditions: {
122
+ operator: 'and',
123
+ rules: [{
124
+ type: 'operator',
125
+ field: 'customer_id',
126
+ operator: 'in',
127
+ value: [333, 444]
128
+ }, {
129
+ type: 'operator',
130
+ field: 'channel',
131
+ operator: 'in',
132
+ value: ['pos', 'online']
133
+ }, {
134
+ type: 'operator',
135
+ field: 'business_code',
136
+ operator: 'in',
137
+ value: ['venue', 'retail']
138
+ }],
139
+ actionIds: ['apply_data_variant']
140
+ },
141
+ actions: [{
142
+ id: 'apply_data_variant',
143
+ type: DATA_VARIANT_ACTION_TYPES.APPLY,
144
+ target: 'product',
145
+ value: null,
146
+ priority: 150
147
+ }]
148
+ };
149
+
150
+ /**
151
+ * 示例日程:2026-06-26 17:00 ~ 20:00 生效。
152
+ */
153
+ export var DATA_VARIANT_EXAMPLE_SCHEDULES = [{
154
+ id: 1042,
155
+ name: '晚场 17~20',
156
+ color: '#1890ff',
157
+ start_time: '2026-06-26 17:00:00',
158
+ end_time: '2026-06-26 20:00:00',
159
+ repeat_type: 'none',
160
+ repeat_rule: {
161
+ end: {
162
+ type: 'never',
163
+ end_date: null,
164
+ occurrence: null
165
+ },
166
+ frequency: 1,
167
+ excluded_date: [],
168
+ included_date: [],
169
+ frequency_date: []
170
+ },
171
+ type: 'standard',
172
+ time_slot: [],
173
+ designation: [],
174
+ is_all: 0,
175
+ created_at: '2026-06-26 00:00:00',
176
+ updated_at: '2026-06-26 00:00:00',
177
+ order_count: 0,
178
+ relation_count: 0
179
+ }];
180
+
181
+ /**
182
+ * 示例餐牌:product_collection = 128 的商品均属于餐牌。
183
+ */
184
+ export var DATA_VARIANT_EXAMPLE_MENUS = [{
185
+ form_record_id: 43209,
186
+ name: 'kiosk餐牌1 17~20',
187
+ status: 'valid',
188
+ schedule: [1042],
189
+ partyroom_package: {
190
+ type: 'product_collection',
191
+ products: [{
192
+ product_collection_id: 128,
193
+ product_id: 0,
194
+ product_variant_id: 0
195
+ }]
196
+ }
197
+ }];
198
+
199
+ /**
200
+ * 示例商品:同时带两条 Data Variant 覆盖数据。
201
+ */
202
+ export var DATA_VARIANT_EXAMPLE_PRODUCTS = [{
203
+ id: 2001,
204
+ title: '入场票',
205
+ price: 100,
206
+ stock: 50,
207
+ collection: [{
208
+ id: 128,
209
+ title: 'Tickets'
210
+ }],
211
+ data_variants: [createExampleDataVariant(1, {
212
+ price: 80,
213
+ stock: 20
214
+ }, {
215
+ id: 1,
216
+ module_data_id: 2001
217
+ }), createExampleDataVariant(2, {
218
+ price: 70,
219
+ title: 'VIP专属票'
220
+ }, {
221
+ id: 2,
222
+ module_data_id: 2001
223
+ }), createExampleDataVariant(3, {
224
+ price: 65,
225
+ title: 'VIP渠道价'
226
+ }, {
227
+ id: 4,
228
+ module_data_id: 2001
229
+ })]
230
+ }, {
231
+ id: 2002,
232
+ title: '普通票',
233
+ price: 100,
234
+ stock: 50,
235
+ collection: [{
236
+ id: 999,
237
+ title: 'Other'
238
+ }],
239
+ data_variants: [createExampleDataVariant(1, {
240
+ price: 80,
241
+ stock: 20
242
+ }, {
243
+ id: 3,
244
+ module_data_id: 2002
245
+ })]
246
+ }];
247
+
248
+ /**
249
+ * Data Variant 评估器示例调用。
250
+ */
251
+ export function runDataVariantDemo() {
252
+ var evaluator = new DataVariantEvaluator();
253
+ evaluator.setStrategyConfigs([EVENING_MENU_PRICE_STRATEGY, VIP_PRODUCT_PRICE_STRATEGY]);
254
+ var businessData = {
255
+ products: DATA_VARIANT_EXAMPLE_PRODUCTS,
256
+ scheduleDateTime: '2026-06-26 18:00:00',
257
+ scheduleList: DATA_VARIANT_EXAMPLE_SCHEDULES,
258
+ menuList: DATA_VARIANT_EXAMPLE_MENUS,
259
+ orderType: 'booking'
260
+ };
261
+ return evaluator.resolveProducts(businessData);
262
+ }
263
+
264
+ /**
265
+ * 客户/渠道/业务范围条件示例调用。
266
+ */
267
+ export function runCustomerScopeDataVariantDemo() {
268
+ var evaluator = new DataVariantEvaluator();
269
+ evaluator.setStrategyConfigs([CUSTOMER_SCOPE_PRICE_STRATEGY]);
270
+ var businessData = {
271
+ products: [DATA_VARIANT_EXAMPLE_PRODUCTS[0]],
272
+ customerId: 333,
273
+ channel: 'pos',
274
+ businessCode: 'venue'
275
+ };
276
+ return evaluator.resolveProducts(businessData);
277
+ }
@@ -0,0 +1,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,148 @@
1
+ import type { ConditionRule, EvaluationResult, StrategyConfig } from '../../type';
2
+ import type { ScheduleItem } from '../../../../modules/Schedule/types';
3
+ /**
4
+ * Data Variant 动作类型。
5
+ *
6
+ * 当前阶段动作只用于标识“该策略可应用 data variant 覆盖”,真实覆盖数据来自商品 data_variants。
7
+ */
8
+ export declare const DATA_VARIANT_ACTION_TYPES: {
9
+ readonly APPLY: "DATA_VARIANT_APPLY";
10
+ };
11
+ export type DataVariantActionType = (typeof DATA_VARIANT_ACTION_TYPES)[keyof typeof DATA_VARIANT_ACTION_TYPES];
12
+ /**
13
+ * Data Variant 规则元数据。
14
+ *
15
+ * priority 数字越大优先级越高,合并时后覆盖低优先级字段。
16
+ */
17
+ export interface DataVariantRuleMetadata {
18
+ module?: 'product' | string;
19
+ priority?: number;
20
+ status?: 'active' | 'inactive' | string;
21
+ updated_at?: string;
22
+ [key: string]: any;
23
+ }
24
+ /**
25
+ * 商品上的单条 Data Variant 记录,结构与后端 data_variant 表对齐。
26
+ */
27
+ export interface DataVariantItem {
28
+ /** 变体记录 id */
29
+ id?: number;
30
+ /** 店铺 id */
31
+ shop_id?: number;
32
+ /** 所属模块,商品场景固定为 product */
33
+ module?: 'product' | string;
34
+ /** 模块数据 id,商品场景对应 product.id */
35
+ module_data_id?: number;
36
+ /** 关联策略模型 metadata.id / data_variant_rule.id */
37
+ data_variant_rule_id: number | string;
38
+ /** 命中策略后需要覆盖到商品上的字段 */
39
+ data: Record<string, any>;
40
+ created_at?: string | null;
41
+ updated_at?: string | null;
42
+ deleted_at?: string | null;
43
+ }
44
+ /**
45
+ * Data Variant 评估使用的轻量商品结构。
46
+ */
47
+ export interface DataVariantProduct {
48
+ id?: number | string;
49
+ product_id?: number | string;
50
+ product_variant_id?: number | string;
51
+ variant_id?: number | string;
52
+ collection?: Array<{
53
+ id?: number | string;
54
+ [key: string]: any;
55
+ }>;
56
+ /** 后端 /product/query with dataVariants 返回的智能定价变体列表 */
57
+ data_variants?: DataVariantItem[];
58
+ _dataVariant?: DataVariantAppliedInfo;
59
+ [key: string]: any;
60
+ }
61
+ /**
62
+ * 餐牌商品配置项。
63
+ */
64
+ export interface DataVariantMenuProductItem {
65
+ product_collection_id?: number | string;
66
+ product_id?: number | string;
67
+ product_variant_id?: number | string;
68
+ }
69
+ /**
70
+ * 餐牌数据的最小结构。
71
+ */
72
+ export interface DataVariantMenu {
73
+ form_record_id: number | string;
74
+ status?: string;
75
+ schedule?: Array<number | string>;
76
+ partyroom_package?: {
77
+ type?: 'product_all' | 'product_collection' | 'products' | string;
78
+ products?: DataVariantMenuProductItem[];
79
+ };
80
+ [key: string]: any;
81
+ }
82
+ /**
83
+ * 单个餐牌预构建后的商品范围索引。
84
+ */
85
+ export interface MenuScope {
86
+ isAllProducts: boolean;
87
+ collectionIds: Set<number>;
88
+ productKeys: Set<string>;
89
+ productAllVariantIds: Set<number>;
90
+ }
91
+ /**
92
+ * 批量评估输入。
93
+ */
94
+ export interface DataVariantBusinessData {
95
+ products: DataVariantProduct[];
96
+ strategyConfigs?: StrategyConfig<DataVariantRuleMetadata>[];
97
+ scheduleDateTime?: string;
98
+ scheduleList?: ScheduleItem[];
99
+ menuList?: DataVariantMenu[];
100
+ channel?: string;
101
+ orderType?: string;
102
+ /** 当前业务编码,对应策略条件 field: business_code */
103
+ businessCode?: string;
104
+ customerId?: number | string;
105
+ /** 当前客户可用 wallet/pass id 合并列表,对应策略条件 field: available_wallet_ids */
106
+ availableWalletIds?: Array<number | string>;
107
+ custom?: Record<string, any>;
108
+ }
109
+ /**
110
+ * 全局预计算后的规则信息。
111
+ */
112
+ export interface EffectiveRuleInfo {
113
+ ruleId: string;
114
+ priority: number;
115
+ strategyConfig: StrategyConfig<DataVariantRuleMetadata>;
116
+ productRules: ConditionRule[];
117
+ globalResult: EvaluationResult;
118
+ }
119
+ export type GlobalEffectiveRuleMap = Map<string, EffectiveRuleInfo>;
120
+ /**
121
+ * 单条商品命中的变体覆盖信息。
122
+ */
123
+ export interface MatchedDataVariant {
124
+ ruleId: string;
125
+ priority: number;
126
+ data: Record<string, any>;
127
+ variant: DataVariantItem;
128
+ }
129
+ /**
130
+ * 商品上记录的 Data Variant 调试信息。
131
+ */
132
+ export interface DataVariantAppliedInfo {
133
+ appliedRuleIds: string[];
134
+ appliedFields: string[];
135
+ original: DataVariantProduct;
136
+ }
137
+ /**
138
+ * 批量解析结果。
139
+ */
140
+ export interface ResolvedDataVariantResult {
141
+ products: DataVariantProduct[];
142
+ globalEffectiveRuleMap: GlobalEffectiveRuleMap;
143
+ menuScopeMap: Map<number, MenuScope>;
144
+ /** 当前策略中 schedule_match 绑定的日程提取出的时间点,格式如 ["10:00", "13:00"] */
145
+ scheduleTimePoints: string[];
146
+ rawResults: EvaluationResult[];
147
+ }
148
+ export type ConditionScope = 'global' | 'product';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Data Variant 动作类型。
3
+ *
4
+ * 当前阶段动作只用于标识“该策略可应用 data variant 覆盖”,真实覆盖数据来自商品 data_variants。
5
+ */
6
+ export var DATA_VARIANT_ACTION_TYPES = {
7
+ APPLY: 'DATA_VARIANT_APPLY'
8
+ };
9
+
10
+ /**
11
+ * Data Variant 规则元数据。
12
+ *
13
+ * priority 数字越大优先级越高,合并时后覆盖低优先级字段。
14
+ */
15
+
16
+ /**
17
+ * 商品上的单条 Data Variant 记录,结构与后端 data_variant 表对齐。
18
+ */
19
+
20
+ /**
21
+ * Data Variant 评估使用的轻量商品结构。
22
+ */
23
+
24
+ /**
25
+ * 餐牌商品配置项。
26
+ */
27
+
28
+ /**
29
+ * 餐牌数据的最小结构。
30
+ */
31
+
32
+ /**
33
+ * 单个餐牌预构建后的商品范围索引。
34
+ */
35
+
36
+ /**
37
+ * 批量评估输入。
38
+ */
39
+
40
+ /**
41
+ * 全局预计算后的规则信息。
42
+ */
43
+
44
+ /**
45
+ * 单条商品命中的变体覆盖信息。
46
+ */
47
+
48
+ /**
49
+ * 商品上记录的 Data Variant 调试信息。
50
+ */
51
+
52
+ /**
53
+ * 批量解析结果。
54
+ */
@@ -5,3 +5,7 @@ export { PromotionEvaluator } from './promotion/evaluator';
5
5
  export { PromotionAdapter } from './promotion/adapter';
6
6
  export { ItemRuleEvaluator } from './itemRule/evaluator';
7
7
  export { ItemRuleAdapter } from './itemRule/adapter';
8
+ export { DataVariantEvaluator } from './dataVariant/evaluator';
9
+ export { DataVariantAdapter } from './dataVariant/adapter';
10
+ export { runDataVariantDemo } from './dataVariant/examples';
11
+ export * from './dataVariant/type';
@@ -4,4 +4,8 @@ export { WalletPassEvaluator } from "./walletPass/evaluator";
4
4
  export { PromotionEvaluator } from "./promotion/evaluator";
5
5
  export { PromotionAdapter } from "./promotion/adapter";
6
6
  export { ItemRuleEvaluator } from "./itemRule/evaluator";
7
- export { ItemRuleAdapter } from "./itemRule/adapter";
7
+ export { ItemRuleAdapter } from "./itemRule/adapter";
8
+ export { DataVariantEvaluator } from "./dataVariant/evaluator";
9
+ export { DataVariantAdapter } from "./dataVariant/adapter";
10
+ export { runDataVariantDemo } from "./dataVariant/examples";
11
+ export * from "./dataVariant/type";
@@ -121,6 +121,10 @@ function resolveProductTitle(product, booking, sourceProduct) {
121
121
  var metadata = product.metadata || {};
122
122
  return (_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.name) !== null && _ref5 !== void 0 ? _ref5 : metadata.product_title) !== null && _ref4 !== void 0 ? _ref4 : metadata.product_name) !== null && _ref3 !== void 0 ? _ref3 : booking === null || booking === void 0 || (_booking$product = booking.product) === null || _booking$product === void 0 ? void 0 : _booking$product.title) !== null && _ref2 !== void 0 ? _ref2 : booking === null || booking === void 0 || (_booking$detail = booking.detail) === null || _booking$detail === void 0 ? void 0 : _booking$detail.product_title) !== null && _ref !== void 0 ? _ref : '';
123
123
  }
124
+ function resolveProductCover(product, booking, sourceProduct) {
125
+ var _ref6, _cover;
126
+ return (_ref6 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref6 !== void 0 ? _ref6 : '';
127
+ }
124
128
  function resolveMainProductPrice(product, fallback) {
125
129
  var _metadata$main_produc;
126
130
  var metadata = product.metadata || {};
@@ -130,9 +134,9 @@ function resolveMainProductPrice(product, fallback) {
130
134
  }
131
135
  function mapOrderBundleToOtherBundle(bundle) {
132
136
  return bundle.map(function (item) {
133
- var _ref6, _item$original_price;
137
+ var _ref7, _item$original_price;
134
138
  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
139
+ original_price: (_ref7 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : item.price
136
140
  });
137
141
  });
138
142
  }
@@ -163,10 +167,10 @@ function synthesizeProductResourceFromBooking(booking) {
163
167
  });
164
168
  if (relationIdsByForm.size === 0) return undefined;
165
169
  return {
166
- resources: Array.from(relationIdsByForm.entries()).map(function (_ref7) {
167
- var _ref8 = _slicedToArray(_ref7, 2),
168
- formId = _ref8[0],
169
- relationIds = _ref8[1];
170
+ resources: Array.from(relationIdsByForm.entries()).map(function (_ref8) {
171
+ var _ref9 = _slicedToArray(_ref8, 2),
172
+ formId = _ref9[0],
173
+ relationIds = _ref9[1];
170
174
  return {
171
175
  id: formId,
172
176
  status: 1,
@@ -186,7 +190,7 @@ function synthesizeProductResourceFromBooking(booking) {
186
190
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
187
191
  */
188
192
  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;
193
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref12, _booking$id;
190
194
  var product = input.product,
191
195
  booking = input.booking,
192
196
  sourceProduct = input.sourceProduct;
@@ -202,6 +206,7 @@ export function buildCacheItemFromOrderLine(input) {
202
206
  var capacity = resolveCapacityFromBooking(booking);
203
207
  var holderId = (_booking$metadata$hol = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
204
208
  var productTitle = resolveProductTitle(product, booking, sourceProduct);
209
+ var productCover = resolveProductCover(product, booking, sourceProduct);
205
210
  var productOptionString = buildProductOptionStringFromOrderLine(product);
206
211
  var other = {
207
212
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
@@ -219,7 +224,8 @@ export function buildCacheItemFromOrderLine(input) {
219
224
  sub_type: booking.sub_type,
220
225
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
221
226
  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 : '',
227
+ product_cover: productCover,
228
+ note: (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : '',
223
229
  price: mainProductPrice,
224
230
  total: selling,
225
231
  origin_total: original,
@@ -254,7 +260,7 @@ export function buildCacheItemFromOrderLine(input) {
254
260
  var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
255
261
  id: resolvedId,
256
262
  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,
263
+ extension_type: (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
258
264
  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
265
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
260
266
  selling_price: product.selling_price,
@@ -266,7 +272,7 @@ export function buildCacheItemFromOrderLine(input) {
266
272
  new: 0,
267
273
  autoClose: false,
268
274
  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
275
+ booking_id: (_ref12 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref12 !== void 0 ? _ref12 : 0
270
276
  });
271
277
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
272
278
  base.capacity = sourceProduct.capacity;
@@ -75,7 +75,7 @@ function mapOrderBundleToOtherBundle(bundle) {
75
75
  });
76
76
  }
77
77
  export function buildNormalProductCacheItemFromOrderLine(input) {
78
- var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _price3, _product$order_detail;
78
+ var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _ref7, _cover, _price3, _product$order_detail;
79
79
  var product = input.product,
80
80
  sourceProduct = input.sourceProduct;
81
81
  var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
@@ -132,6 +132,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
132
132
  product_id: resolvedId,
133
133
  _id: uid,
134
134
  title: (_ref6 = (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : product.product_title) !== null && _ref6 !== void 0 ? _ref6 : '',
135
+ cover: (_ref7 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref7 !== void 0 ? _ref7 : '',
135
136
  price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
136
137
  selling_price: product.selling_price,
137
138
  original_price: product.original_price
@@ -48,7 +48,7 @@ export interface BookingResourceInput {
48
48
  capacity?: number;
49
49
  like_status?: string;
50
50
  metadata?: Record<string, any>;
51
- children?: any[];
51
+ children?: BookingResourceInput[];
52
52
  }
53
53
  /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
54
54
  export interface BookingCapacityMetadataItem {