@pisell/pisellos 2.1.171 → 2.1.172

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 (230) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  8. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  9. package/dist/model/strategy/engine.d.ts +18 -5
  10. package/dist/model/strategy/engine.js +145 -45
  11. package/dist/model/strategy/type.d.ts +17 -0
  12. package/dist/model/strategy/type.js +4 -0
  13. package/dist/modules/Cart/types.d.ts +2 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  15. package/dist/modules/Cart/utils/changePrice.js +9 -16
  16. package/dist/modules/Discount/index.d.ts +4 -13
  17. package/dist/modules/Discount/index.js +12 -124
  18. package/dist/modules/Discount/types.d.ts +18 -13
  19. package/dist/modules/Order/index.d.ts +1 -67
  20. package/dist/modules/Order/index.js +30 -918
  21. package/dist/modules/Order/types.d.ts +12 -176
  22. package/dist/modules/Order/types.js +0 -2
  23. package/dist/modules/Order/utils.d.ts +0 -118
  24. package/dist/modules/Order/utils.js +2 -586
  25. package/dist/modules/Payment/index.d.ts +2 -1
  26. package/dist/modules/Payment/index.js +10 -7
  27. package/dist/modules/Payment/utils.js +3 -0
  28. package/dist/modules/Payment/walletpass.d.ts +23 -0
  29. package/dist/modules/Payment/walletpass.js +191 -95
  30. package/dist/modules/Product/utils.js +2 -2
  31. package/dist/modules/ProductList/index.d.ts +2 -4
  32. package/dist/modules/ProductList/index.js +12 -24
  33. package/dist/modules/Rules/index.d.ts +9 -5
  34. package/dist/modules/Rules/index.js +669 -173
  35. package/dist/modules/Rules/types.d.ts +2 -0
  36. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  37. package/dist/modules/Schedule/utils.d.ts +1 -1
  38. package/dist/modules/Summary/types.d.ts +2 -0
  39. package/dist/modules/Summary/utils.d.ts +9 -3
  40. package/dist/modules/Summary/utils.js +57 -67
  41. package/dist/modules/index.d.ts +0 -4
  42. package/dist/modules/index.js +1 -5
  43. package/dist/plugins/window.d.ts +2 -0
  44. package/dist/solution/BookingByStep/index.d.ts +3 -2
  45. package/dist/solution/BookingByStep/index.js +43 -46
  46. package/dist/solution/BookingByStep/types.d.ts +1 -3
  47. package/dist/solution/BookingByStep/types.js +1 -5
  48. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  49. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  50. package/dist/solution/Checkout/index.js +2 -0
  51. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  52. package/dist/solution/ShopDiscount/index.js +60 -62
  53. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  54. package/dist/solution/ShopDiscount/types.js +2 -1
  55. package/dist/solution/ShopDiscount/utils.js +26 -12
  56. package/dist/solution/index.d.ts +0 -2
  57. package/dist/solution/index.js +1 -3
  58. package/lib/index.d.ts +1 -1
  59. package/lib/index.js +3 -4
  60. package/lib/model/strategy/adapter/index.d.ts +0 -4
  61. package/lib/model/strategy/adapter/index.js +2 -13
  62. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  63. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  64. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  65. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  66. package/lib/model/strategy/engine.d.ts +18 -5
  67. package/lib/model/strategy/engine.js +85 -21
  68. package/lib/model/strategy/type.d.ts +17 -0
  69. package/lib/modules/Cart/types.d.ts +2 -0
  70. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  71. package/lib/modules/Cart/utils/changePrice.js +9 -13
  72. package/lib/modules/Discount/index.d.ts +4 -13
  73. package/lib/modules/Discount/index.js +5 -76
  74. package/lib/modules/Discount/types.d.ts +18 -13
  75. package/lib/modules/Order/index.d.ts +1 -67
  76. package/lib/modules/Order/index.js +1 -525
  77. package/lib/modules/Order/types.d.ts +12 -176
  78. package/lib/modules/Order/utils.d.ts +0 -118
  79. package/lib/modules/Order/utils.js +2 -483
  80. package/lib/modules/Payment/index.d.ts +2 -1
  81. package/lib/modules/Payment/index.js +1 -0
  82. package/lib/modules/Payment/utils.js +3 -0
  83. package/lib/modules/Payment/walletpass.d.ts +23 -0
  84. package/lib/modules/Payment/walletpass.js +94 -17
  85. package/lib/modules/Product/utils.js +2 -2
  86. package/lib/modules/ProductList/index.d.ts +2 -4
  87. package/lib/modules/ProductList/index.js +39 -46
  88. package/lib/modules/Rules/index.d.ts +9 -5
  89. package/lib/modules/Rules/index.js +776 -292
  90. package/lib/modules/Rules/types.d.ts +2 -0
  91. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  92. package/lib/modules/Schedule/utils.d.ts +1 -1
  93. package/lib/modules/Summary/types.d.ts +2 -0
  94. package/lib/modules/Summary/utils.d.ts +9 -3
  95. package/lib/modules/Summary/utils.js +34 -45
  96. package/lib/modules/index.d.ts +0 -4
  97. package/lib/modules/index.js +1 -9
  98. package/lib/plugins/window.d.ts +2 -0
  99. package/lib/solution/BookingByStep/index.d.ts +3 -2
  100. package/lib/solution/BookingByStep/index.js +4 -6
  101. package/lib/solution/BookingByStep/types.d.ts +1 -3
  102. package/lib/solution/BookingByStep/types.js +0 -10
  103. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  104. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  105. package/lib/solution/Checkout/index.js +2 -0
  106. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  107. package/lib/solution/ShopDiscount/index.js +27 -22
  108. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  109. package/lib/solution/ShopDiscount/utils.js +10 -6
  110. package/lib/solution/index.d.ts +0 -2
  111. package/lib/solution/index.js +1 -5
  112. package/package.json +2 -2
  113. package/dist/apis/picoding.d.ts +0 -0
  114. package/dist/apis/picoding.js +0 -1
  115. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  116. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  117. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  119. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  120. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  121. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  122. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  124. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  125. package/dist/modules/OpenData/index.d.ts +0 -24
  126. package/dist/modules/OpenData/index.js +0 -173
  127. package/dist/modules/OpenData/types.d.ts +0 -73
  128. package/dist/modules/OpenData/types.js +0 -1
  129. package/dist/modules/OpenData/utils.d.ts +0 -2
  130. package/dist/modules/OpenData/utils.js +0 -75
  131. package/dist/modules/Quotation/index.d.ts +0 -48
  132. package/dist/modules/Quotation/index.js +0 -248
  133. package/dist/modules/Quotation/types.d.ts +0 -42
  134. package/dist/modules/Quotation/types.js +0 -1
  135. package/dist/modules/SalesSummary/index.d.ts +0 -63
  136. package/dist/modules/SalesSummary/index.js +0 -174
  137. package/dist/modules/SalesSummary/types.d.ts +0 -60
  138. package/dist/modules/SalesSummary/types.js +0 -1
  139. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  140. package/dist/modules/SalesSummary/utils.js +0 -480
  141. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  142. package/dist/modules/ScanOrderLogger/index.js +0 -174
  143. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  144. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  145. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  146. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  147. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  148. package/dist/modules/ScanOrderLogger/types.js +0 -1
  149. package/dist/solution/ScanOrder/index.d.ts +0 -158
  150. package/dist/solution/ScanOrder/index.js +0 -3474
  151. package/dist/solution/ScanOrder/types.d.ts +0 -306
  152. package/dist/solution/ScanOrder/types.js +0 -35
  153. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  154. package/dist/solution/ScanOrder/utils.js +0 -796
  155. package/dist/solution/VenueBooking/index.d.ts +0 -262
  156. package/dist/solution/VenueBooking/index.js +0 -3991
  157. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  158. package/dist/solution/VenueBooking/types.d.ts +0 -156
  159. package/dist/solution/VenueBooking/types.js +0 -22
  160. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  161. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  162. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  163. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  164. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  165. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  166. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  167. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  168. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  169. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  170. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  171. package/dist/solution/VenueBooking/utils.js +0 -1
  172. package/lib/apis/picoding.d.ts +0 -0
  173. package/lib/apis/picoding.js +0 -0
  174. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  175. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  176. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  178. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  179. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  180. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  181. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  182. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  183. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  184. package/lib/modules/OpenData/index.d.ts +0 -24
  185. package/lib/modules/OpenData/index.js +0 -119
  186. package/lib/modules/OpenData/types.d.ts +0 -73
  187. package/lib/modules/OpenData/types.js +0 -17
  188. package/lib/modules/OpenData/utils.d.ts +0 -2
  189. package/lib/modules/OpenData/utils.js +0 -111
  190. package/lib/modules/Quotation/index.d.ts +0 -48
  191. package/lib/modules/Quotation/index.js +0 -152
  192. package/lib/modules/Quotation/types.d.ts +0 -42
  193. package/lib/modules/Quotation/types.js +0 -17
  194. package/lib/modules/SalesSummary/index.d.ts +0 -63
  195. package/lib/modules/SalesSummary/index.js +0 -105
  196. package/lib/modules/SalesSummary/types.d.ts +0 -60
  197. package/lib/modules/SalesSummary/types.js +0 -17
  198. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  199. package/lib/modules/SalesSummary/utils.js +0 -420
  200. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  201. package/lib/modules/ScanOrderLogger/index.js +0 -147
  202. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  204. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  206. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  207. package/lib/modules/ScanOrderLogger/types.js +0 -17
  208. package/lib/solution/ScanOrder/index.d.ts +0 -158
  209. package/lib/solution/ScanOrder/index.js +0 -2135
  210. package/lib/solution/ScanOrder/types.d.ts +0 -306
  211. package/lib/solution/ScanOrder/types.js +0 -36
  212. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  213. package/lib/solution/ScanOrder/utils.js +0 -658
  214. package/lib/solution/VenueBooking/index.d.ts +0 -262
  215. package/lib/solution/VenueBooking/index.js +0 -2394
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  217. package/lib/solution/VenueBooking/types.d.ts +0 -156
  218. package/lib/solution/VenueBooking/types.js +0 -45
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  222. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  225. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  226. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
  227. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  228. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  229. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  230. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -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,24 +0,0 @@
1
- import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { BaseModule } from '../BaseModule';
3
- import type { ScheduleModule } from '../Schedule';
4
- import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult } from './types';
5
- export * from './types';
6
- export { computeAvailability } from './utils';
7
- export declare class OpenDataModule extends BaseModule implements Module {
8
- protected defaultName: string;
9
- protected defaultVersion: string;
10
- private request;
11
- private window;
12
- private store;
13
- private cacheId;
14
- private openCache;
15
- private fatherModule;
16
- private otherParams;
17
- constructor(name?: string, version?: string);
18
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
19
- fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
20
- getOpenData(): OpenDataConfig | null;
21
- getLastFetchedAt(): number | null;
22
- checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
23
- storeChange(): void;
24
- }
@@ -1,119 +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/modules/OpenData/index.ts
21
- var OpenData_exports = {};
22
- __export(OpenData_exports, {
23
- OpenDataModule: () => OpenDataModule,
24
- computeAvailability: () => import_utils2.computeAvailability
25
- });
26
- module.exports = __toCommonJS(OpenData_exports);
27
- var import_BaseModule = require("../BaseModule");
28
- var import_utils = require("./utils");
29
- __reExport(OpenData_exports, require("./types"), module.exports);
30
- var import_utils2 = require("./utils");
31
- var OpenDataModule = class extends import_BaseModule.BaseModule {
32
- constructor(name, version) {
33
- super(name, version);
34
- this.defaultName = "openData";
35
- this.defaultVersion = "1.0.0";
36
- this.openCache = false;
37
- this.otherParams = {};
38
- }
39
- async initialize(core, options) {
40
- var _a, _b;
41
- this.core = core;
42
- this.store = options.store;
43
- this.store.data = ((_a = options.initialState) == null ? void 0 : _a.data) ?? null;
44
- this.store.lastFetchedAt = ((_b = options.initialState) == null ? void 0 : _b.lastFetchedAt) ?? null;
45
- this.otherParams = options.otherParams || {};
46
- if (this.otherParams.cacheId) {
47
- this.openCache = this.otherParams.openCache ?? false;
48
- this.cacheId = this.otherParams.cacheId;
49
- }
50
- if (this.otherParams.fatherModule) {
51
- this.fatherModule = this.otherParams.fatherModule;
52
- }
53
- this.request = core.getPlugin("request");
54
- this.window = core.getPlugin("window");
55
- if (!this.request)
56
- throw new Error("OpenDataModule 需要 request 插件支持");
57
- if (!this.window)
58
- throw new Error("OpenDataModule 需要 window 插件支持");
59
- console.log("[OpenDataModule] 初始化完成");
60
- }
61
- async fetchOpenData(params) {
62
- var _a, _b, _c, _d;
63
- const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
64
- if (!shopId)
65
- throw new Error("[OpenDataModule] 无法获取 shop_id");
66
- const tenantId = (_d = (_c = this.otherParams) == null ? void 0 : _c.getStateData) == null ? void 0 : _d.call(_c, "tenant_id");
67
- const headers = {};
68
- if (tenantId)
69
- headers["Tenant-Id"] = String(tenantId);
70
- const response = await this.request.post(
71
- `/open/my-pisell/${shopId}/setting`,
72
- {
73
- scope: params.scope,
74
- target: params.target,
75
- section_code: params.section_code
76
- },
77
- { pisell2: true, headers }
78
- );
79
- if ((response == null ? void 0 : response.status) === false) {
80
- throw new Error((response == null ? void 0 : response.message) || "获取 OpenData 配置失败");
81
- }
82
- const data = (response == null ? void 0 : response.data) || {};
83
- this.store.data = data;
84
- this.store.lastFetchedAt = Date.now();
85
- return data;
86
- }
87
- getOpenData() {
88
- return this.store.data;
89
- }
90
- getLastFetchedAt() {
91
- return this.store.lastFetchedAt ?? null;
92
- }
93
- checkAvailability(scheduleModule) {
94
- var _a;
95
- const scheduleList = scheduleModule ? scheduleModule.getScheduleListByIds(
96
- ((_a = this.store.data) == null ? void 0 : _a["availability.operating_hours"]) || []
97
- ) : void 0;
98
- return (0, import_utils.computeAvailability)({
99
- config: this.store.data,
100
- scheduleList
101
- });
102
- }
103
- storeChange() {
104
- if (this.openCache) {
105
- this.checkSaveCache({
106
- cacheId: this.cacheId,
107
- fatherModule: this.fatherModule,
108
- store: this.store,
109
- cacheKey: ["data", "lastFetchedAt"]
110
- });
111
- }
112
- }
113
- };
114
- // Annotate the CommonJS export names for ESM import in node:
115
- 0 && (module.exports = {
116
- OpenDataModule,
117
- computeAvailability,
118
- ...require("./types")
119
- });