@pisell/pisellos 2.2.262 → 2.2.264

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 (131) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  11. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  14. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
  16. package/dist/modules/Discount/index.d.ts +2 -5
  17. package/dist/modules/Discount/index.js +7 -30
  18. package/dist/modules/Discount/types.d.ts +0 -4
  19. package/dist/modules/Order/index.d.ts +2 -14
  20. package/dist/modules/Order/index.js +736 -1035
  21. package/dist/modules/Order/types.d.ts +0 -16
  22. package/dist/modules/Order/utils.d.ts +3 -4
  23. package/dist/modules/Order/utils.js +61 -54
  24. package/dist/modules/Product/types.d.ts +0 -22
  25. package/dist/modules/ProductList/index.d.ts +1 -1
  26. package/dist/modules/ProductList/index.js +2 -4
  27. package/dist/modules/ProductList/types.d.ts +0 -2
  28. package/dist/modules/Rules/index.d.ts +9 -2
  29. package/dist/modules/Rules/index.js +43 -69
  30. package/dist/modules/Rules/types.d.ts +1 -10
  31. package/dist/server/index.d.ts +0 -55
  32. package/dist/server/index.js +742 -1161
  33. package/dist/server/modules/order/index.d.ts +4 -10
  34. package/dist/server/modules/order/index.js +399 -404
  35. package/dist/server/modules/order/types.d.ts +0 -4
  36. package/dist/server/modules/products/index.d.ts +8 -31
  37. package/dist/server/modules/products/index.js +390 -549
  38. package/dist/server/modules/products/types.d.ts +0 -18
  39. package/dist/solution/BaseSales/index.d.ts +1 -21
  40. package/dist/solution/BaseSales/index.js +789 -1136
  41. package/dist/solution/BaseSales/types.d.ts +1 -6
  42. package/dist/solution/BaseSales/types.js +1 -1
  43. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  44. package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
  45. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
  48. package/dist/solution/BookingByStep/index.d.ts +1 -1
  49. package/dist/solution/BookingTicket/index.js +25 -59
  50. package/dist/solution/BookingTicket/types.d.ts +0 -2
  51. package/dist/solution/ScanOrder/index.js +31 -20
  52. package/dist/solution/ShopDiscount/index.js +14 -15
  53. package/dist/solution/VenueBooking/index.js +30 -19
  54. package/lib/model/strategy/adapter/index.d.ts +0 -4
  55. package/lib/model/strategy/adapter/index.js +2 -13
  56. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  57. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  58. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  59. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  60. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  61. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  62. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  63. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  64. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  65. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  66. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
  67. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
  68. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  69. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
  70. package/lib/modules/Discount/index.d.ts +2 -5
  71. package/lib/modules/Discount/index.js +3 -23
  72. package/lib/modules/Discount/types.d.ts +0 -4
  73. package/lib/modules/Order/index.d.ts +2 -14
  74. package/lib/modules/Order/index.js +60 -326
  75. package/lib/modules/Order/types.d.ts +0 -16
  76. package/lib/modules/Order/utils.d.ts +3 -4
  77. package/lib/modules/Order/utils.js +23 -22
  78. package/lib/modules/Product/types.d.ts +0 -22
  79. package/lib/modules/ProductList/index.d.ts +1 -1
  80. package/lib/modules/ProductList/index.js +2 -4
  81. package/lib/modules/ProductList/types.d.ts +0 -2
  82. package/lib/modules/Rules/index.d.ts +9 -2
  83. package/lib/modules/Rules/index.js +29 -61
  84. package/lib/modules/Rules/types.d.ts +1 -10
  85. package/lib/server/index.d.ts +0 -55
  86. package/lib/server/index.js +31 -327
  87. package/lib/server/modules/order/index.d.ts +4 -10
  88. package/lib/server/modules/order/index.js +139 -198
  89. package/lib/server/modules/order/types.d.ts +0 -4
  90. package/lib/server/modules/products/index.d.ts +8 -31
  91. package/lib/server/modules/products/index.js +35 -134
  92. package/lib/server/modules/products/types.d.ts +0 -18
  93. package/lib/solution/BaseSales/index.d.ts +1 -21
  94. package/lib/solution/BaseSales/index.js +72 -313
  95. package/lib/solution/BaseSales/types.d.ts +1 -6
  96. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  97. package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
  98. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  99. package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
  100. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
  101. package/lib/solution/BookingByStep/index.d.ts +1 -1
  102. package/lib/solution/BookingTicket/index.js +8 -33
  103. package/lib/solution/BookingTicket/types.d.ts +0 -2
  104. package/lib/solution/ScanOrder/index.js +8 -0
  105. package/lib/solution/ShopDiscount/index.js +1 -2
  106. package/lib/solution/VenueBooking/index.js +8 -0
  107. package/package.json +1 -1
  108. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  109. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  110. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  111. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  112. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  113. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  114. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  115. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  116. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  117. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  118. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  119. package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
  120. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  121. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  122. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  123. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  124. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  125. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  126. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  127. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  128. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  129. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  130. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  131. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
@@ -1,39 +0,0 @@
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;
@@ -1,293 +0,0 @@
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
- });
@@ -1,4 +0,0 @@
1
- export { DataVariantAdapter } from './adapter';
2
- export { DataVariantEvaluator } from './evaluator';
3
- export { runDataVariantDemo } from './examples';
4
- export * from './type';
@@ -1,38 +0,0 @@
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
- });
@@ -1,148 +0,0 @@
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';
@@ -1,31 +0,0 @@
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
- });
@@ -1,53 +0,0 @@
1
- export type OrderCollectionKind = 'product' | 'booking' | 'payment';
2
- export interface OrderCollectionIdentityStats {
3
- backfilledUidCount: number;
4
- collapsedDuplicateCount: number;
5
- uidConflictCount: number;
6
- anonymousRowCount: number;
7
- }
8
- export interface OrderCollectionUidRemap {
9
- kind: OrderCollectionKind;
10
- from: string;
11
- to: string;
12
- persistentId: string | null;
13
- /** 默认全局迁移;UID 冲突时只能迁移能由另一侧 UID 明确定位的引用。 */
14
- scope?: 'global' | 'linked-owner';
15
- referenceOwnerUid?: string | null;
16
- }
17
- export interface NormalizeOrderCollectionResult<T> {
18
- items: T[];
19
- stats: OrderCollectionIdentityStats;
20
- uidRemaps: OrderCollectionUidRemap[];
21
- }
22
- export interface NormalizeOrderCollectionsResult<T> {
23
- order: T;
24
- stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
25
- uidRemaps: OrderCollectionUidRemap[];
26
- }
27
- export declare function createUuidV4(): string;
28
- export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
29
- export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
30
- export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: unknown): string | null;
31
- export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
32
- export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
33
- export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
34
- /**
35
- * 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
36
- */
37
- export declare function isSameOrderCollectionItem(kind: OrderCollectionKind, left: unknown, right: unknown): boolean;
38
- export declare function mergeOrderCollectionItems<T>(kind: OrderCollectionKind, currentItem: T, incomingItem: T, options?: {
39
- ensureUid?: boolean;
40
- createAnonymousUid?: () => string;
41
- }): T;
42
- /**
43
- * 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
44
- */
45
- export declare function normalizeOrderCollection<T>(kind: OrderCollectionKind, items: T[] | null | undefined, options?: {
46
- ensureUid?: boolean;
47
- createAnonymousUid?: () => string;
48
- }): NormalizeOrderCollectionResult<T>;
49
- export declare function applyOrderCollectionUidRemaps<T extends Record<string, any>>(sourceOrder: T, uidRemaps: OrderCollectionUidRemap[]): T;
50
- export declare function normalizeOrderCollections<T extends Record<string, any>>(sourceOrder: T, options?: {
51
- ensureUid?: boolean;
52
- createAnonymousUid?: () => string;
53
- }): NormalizeOrderCollectionsResult<T>;