@pisell/pisellos 2.1.59 → 2.1.60

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 (95) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +3 -0
  6. package/dist/model/strategy/adapter/index.js +4 -0
  7. package/dist/model/strategy/adapter/type.d.ts +28 -0
  8. package/dist/model/strategy/adapter/type.js +1 -0
  9. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  10. package/dist/model/strategy/adapter/walletPass/evaluator.js +496 -0
  11. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  12. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  13. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  14. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  15. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  16. package/dist/model/strategy/adapter/walletPass/locales.js +23 -0
  17. package/dist/model/strategy/adapter/walletPass/type.d.ts +163 -0
  18. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  19. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  20. package/dist/model/strategy/adapter/walletPass/utils.js +965 -0
  21. package/dist/model/strategy/index.d.ts +94 -0
  22. package/dist/model/strategy/index.js +551 -0
  23. package/dist/model/strategy/strategy-example.d.ts +5 -0
  24. package/dist/model/strategy/strategy-example.js +331 -0
  25. package/dist/model/strategy/type.d.ts +228 -0
  26. package/dist/model/strategy/type.js +94 -0
  27. package/dist/modules/Cart/types.d.ts +2 -0
  28. package/dist/modules/Cart/utils/cartProduct.js +11 -0
  29. package/dist/modules/Discount/types.d.ts +15 -0
  30. package/dist/modules/Payment/index.d.ts +2 -1
  31. package/dist/modules/Payment/index.js +10 -7
  32. package/dist/modules/Payment/utils.js +3 -0
  33. package/dist/modules/Payment/walletpass.d.ts +23 -0
  34. package/dist/modules/Payment/walletpass.js +191 -95
  35. package/dist/modules/Rules/index.d.ts +8 -3
  36. package/dist/modules/Rules/index.js +152 -26
  37. package/dist/modules/Rules/types.d.ts +1 -0
  38. package/dist/modules/Summary/types.d.ts +2 -0
  39. package/dist/modules/Summary/utils.d.ts +6 -0
  40. package/dist/modules/Summary/utils.js +21 -0
  41. package/dist/plugins/window.d.ts +2 -0
  42. package/dist/solution/BookingByStep/index.d.ts +2 -1
  43. package/dist/solution/Checkout/index.js +2 -0
  44. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  45. package/dist/solution/ShopDiscount/index.js +11 -1
  46. package/dist/solution/ShopDiscount/types.d.ts +1 -0
  47. package/dist/solution/ShopDiscount/utils.js +26 -11
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +3 -1
  50. package/lib/model/index.d.ts +1 -0
  51. package/lib/model/index.js +23 -0
  52. package/lib/model/strategy/adapter/index.d.ts +3 -0
  53. package/lib/model/strategy/adapter/index.js +45 -0
  54. package/lib/model/strategy/adapter/type.d.ts +28 -0
  55. package/lib/model/strategy/adapter/type.js +17 -0
  56. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  57. package/lib/model/strategy/adapter/walletPass/evaluator.js +420 -0
  58. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  59. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  60. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  61. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  62. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  63. package/lib/model/strategy/adapter/walletPass/locales.js +51 -0
  64. package/lib/model/strategy/adapter/walletPass/type.d.ts +163 -0
  65. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  66. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  67. package/lib/model/strategy/adapter/walletPass/utils.js +660 -0
  68. package/lib/model/strategy/index.d.ts +94 -0
  69. package/lib/model/strategy/index.js +413 -0
  70. package/lib/model/strategy/strategy-example.d.ts +5 -0
  71. package/lib/model/strategy/strategy-example.js +318 -0
  72. package/lib/model/strategy/type.d.ts +228 -0
  73. package/lib/model/strategy/type.js +44 -0
  74. package/lib/modules/Cart/types.d.ts +2 -0
  75. package/lib/modules/Cart/utils/cartProduct.js +9 -0
  76. package/lib/modules/Discount/types.d.ts +15 -0
  77. package/lib/modules/Payment/index.d.ts +2 -1
  78. package/lib/modules/Payment/index.js +1 -0
  79. package/lib/modules/Payment/utils.js +3 -0
  80. package/lib/modules/Payment/walletpass.d.ts +23 -0
  81. package/lib/modules/Payment/walletpass.js +94 -17
  82. package/lib/modules/Rules/index.d.ts +8 -3
  83. package/lib/modules/Rules/index.js +370 -192
  84. package/lib/modules/Rules/types.d.ts +1 -0
  85. package/lib/modules/Summary/types.d.ts +2 -0
  86. package/lib/modules/Summary/utils.d.ts +6 -0
  87. package/lib/modules/Summary/utils.js +15 -0
  88. package/lib/plugins/window.d.ts +2 -0
  89. package/lib/solution/BookingByStep/index.d.ts +2 -1
  90. package/lib/solution/Checkout/index.js +2 -0
  91. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  92. package/lib/solution/ShopDiscount/index.js +6 -0
  93. package/lib/solution/ShopDiscount/types.d.ts +1 -0
  94. package/lib/solution/ShopDiscount/utils.js +10 -6
  95. package/package.json +1 -1
@@ -0,0 +1,318 @@
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/strategy-example.ts
20
+ var strategy_example_exports = {};
21
+ __export(strategy_example_exports, {
22
+ runExamples: () => runExamples
23
+ });
24
+ module.exports = __toCommonJS(strategy_example_exports);
25
+ var import_index = require("./index");
26
+ var voucherConfig = {
27
+ metadata: {
28
+ id: "VOUCHER_10",
29
+ name: "10元代金券",
30
+ type: "wallet_pass",
31
+ calculationType: "single"
32
+ },
33
+ conditions: {
34
+ operator: "and",
35
+ rules: [
36
+ {
37
+ type: "operator",
38
+ dimension: "scope_product",
39
+ field: "productId",
40
+ operator: "in",
41
+ value: [60734, 60735]
42
+ },
43
+ {
44
+ type: "operator",
45
+ dimension: "scope_channel",
46
+ field: "channel",
47
+ operator: "in",
48
+ value: ["pos", "mini_program"]
49
+ },
50
+ {
51
+ type: "operator",
52
+ dimension: "transaction",
53
+ field: "applicableProductTotal",
54
+ operator: ">=",
55
+ value: 100
56
+ },
57
+ {
58
+ type: "operator",
59
+ dimension: "limit_usage",
60
+ field: "perUserUsedCount",
61
+ operator: "<",
62
+ value: 1
63
+ }
64
+ ],
65
+ actionIds: ["deduct_10"]
66
+ },
67
+ actions: [
68
+ {
69
+ id: "deduct_10",
70
+ type: "DEDUCT_AMOUNT",
71
+ value: 10,
72
+ valueType: "number",
73
+ valueUnit: "元",
74
+ target: "applicable_products",
75
+ priority: 1,
76
+ config: {
77
+ allowCrossProduct: true,
78
+ deductTaxAndFee: true
79
+ }
80
+ }
81
+ ]
82
+ };
83
+ var voucherContext = {
84
+ entities: {
85
+ order: {
86
+ id: "ORDER_001",
87
+ total: 150,
88
+ items: [
89
+ { productId: 60734, quantity: 2, price: 75 }
90
+ ]
91
+ },
92
+ customer: {
93
+ id: "USER_001",
94
+ level: "vip"
95
+ }
96
+ },
97
+ attributes: {
98
+ productId: 60734,
99
+ channel: "pos",
100
+ applicableProductTotal: 150,
101
+ perUserUsedCount: 0
102
+ },
103
+ metadata: {
104
+ timestamp: Date.now(),
105
+ locale: "zh-CN"
106
+ }
107
+ };
108
+ var tieredDiscountConfig = {
109
+ metadata: {
110
+ id: "TIERED_DISCOUNT",
111
+ name: "阶梯满减",
112
+ type: "promotion",
113
+ calculationType: "single"
114
+ },
115
+ conditions: {
116
+ operator: "or",
117
+ rules: [
118
+ // 档位1:100-199 减10
119
+ {
120
+ operator: "and",
121
+ rules: [
122
+ {
123
+ type: "operator",
124
+ dimension: "transaction",
125
+ field: "orderTotal",
126
+ operator: ">=",
127
+ value: 100
128
+ },
129
+ {
130
+ type: "operator",
131
+ dimension: "transaction",
132
+ field: "orderTotal",
133
+ operator: "<",
134
+ value: 200
135
+ }
136
+ ],
137
+ actionIds: ["deduct_10"]
138
+ },
139
+ // 档位2:200-299 减25
140
+ {
141
+ operator: "and",
142
+ rules: [
143
+ {
144
+ type: "operator",
145
+ dimension: "transaction",
146
+ field: "orderTotal",
147
+ operator: ">=",
148
+ value: 200
149
+ },
150
+ {
151
+ type: "operator",
152
+ dimension: "transaction",
153
+ field: "orderTotal",
154
+ operator: "<",
155
+ value: 300
156
+ }
157
+ ],
158
+ actionIds: ["deduct_25"]
159
+ },
160
+ // 档位3:>= 300 减40
161
+ {
162
+ operator: "and",
163
+ rules: [
164
+ {
165
+ type: "operator",
166
+ dimension: "transaction",
167
+ field: "orderTotal",
168
+ operator: ">=",
169
+ value: 300
170
+ }
171
+ ],
172
+ actionIds: ["deduct_40"]
173
+ }
174
+ ],
175
+ actionIds: []
176
+ },
177
+ actions: [
178
+ {
179
+ id: "deduct_10",
180
+ type: "DEDUCT_AMOUNT",
181
+ value: 10,
182
+ target: "order",
183
+ priority: 1
184
+ },
185
+ {
186
+ id: "deduct_25",
187
+ type: "DEDUCT_AMOUNT",
188
+ value: 25,
189
+ target: "order",
190
+ priority: 2
191
+ },
192
+ {
193
+ id: "deduct_40",
194
+ type: "DEDUCT_AMOUNT",
195
+ value: 40,
196
+ target: "order",
197
+ priority: 3
198
+ }
199
+ ]
200
+ };
201
+ var tieredContext = {
202
+ entities: {
203
+ order: { id: "ORDER_002", total: 250 }
204
+ },
205
+ attributes: {
206
+ orderTotal: 250
207
+ },
208
+ metadata: {
209
+ timestamp: Date.now()
210
+ }
211
+ };
212
+ var codeConditionConfig = {
213
+ metadata: {
214
+ id: "CODE_CONDITION_EXAMPLE",
215
+ name: "代码条件示例",
216
+ type: "custom"
217
+ },
218
+ conditions: {
219
+ operator: "and",
220
+ rules: [
221
+ // 使用 code 模式
222
+ {
223
+ type: "code",
224
+ code: 'attributes.orderTotal >= 100 && entities.customer.level === "vip"'
225
+ },
226
+ // 混合使用 operator 模式
227
+ {
228
+ type: "operator",
229
+ field: "productCount",
230
+ operator: ">=",
231
+ value: 2
232
+ }
233
+ ],
234
+ actionIds: ["vip_discount"]
235
+ },
236
+ actions: [
237
+ {
238
+ id: "vip_discount",
239
+ type: "DISCOUNT_RATE",
240
+ value: 0.85,
241
+ target: "order",
242
+ priority: 1
243
+ }
244
+ ]
245
+ };
246
+ var codeContext = {
247
+ entities: {
248
+ customer: { id: "USER_002", level: "vip" },
249
+ order: { id: "ORDER_003", total: 150 }
250
+ },
251
+ attributes: {
252
+ orderTotal: 150,
253
+ productCount: 3
254
+ },
255
+ metadata: {
256
+ timestamp: Date.now()
257
+ }
258
+ };
259
+ function runExamples() {
260
+ console.log("====== 策略模型使用示例 ======\n");
261
+ const engine = (0, import_index.createStrategyEngine)({
262
+ debug: true,
263
+ enableTrace: true
264
+ });
265
+ console.log("示例1: 10元代金券");
266
+ const result1 = engine.evaluate(voucherConfig, voucherContext);
267
+ console.log("结果:", JSON.stringify(result1, null, 2));
268
+ console.log("\n");
269
+ console.log("示例2: 阶梯满减(订单金额250)");
270
+ const result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
271
+ console.log("结果:", JSON.stringify(result2, null, 2));
272
+ console.log("\n");
273
+ console.log("示例3: Code 模式条件");
274
+ const result3 = engine.evaluate(codeConditionConfig, codeContext);
275
+ console.log("结果:", JSON.stringify(result3, null, 2));
276
+ console.log("\n");
277
+ console.log("示例4: 快速评估");
278
+ const result4 = (0, import_index.evaluate)(voucherConfig, voucherContext);
279
+ console.log("适用:", result4.applicable);
280
+ console.log("匹配动作数:", result4.matchedActions.length);
281
+ console.log("\n");
282
+ console.log("示例5: 自定义运算符");
283
+ engine.registerOperator("divisible_by", (fieldValue, compareValue) => {
284
+ return Number(fieldValue) % Number(compareValue) === 0;
285
+ });
286
+ const customOperatorConfig = {
287
+ metadata: { id: "CUSTOM_OP", name: "自定义运算符", type: "test" },
288
+ conditions: {
289
+ operator: "and",
290
+ rules: [
291
+ {
292
+ type: "operator",
293
+ field: "amount",
294
+ operator: "divisible_by",
295
+ value: 10
296
+ }
297
+ ],
298
+ actionIds: ["bonus"]
299
+ },
300
+ actions: [{ id: "bonus", type: "ADD_POINTS", value: 100, target: "customer" }]
301
+ };
302
+ const customContext = {
303
+ entities: {},
304
+ attributes: { amount: 50 },
305
+ metadata: { timestamp: Date.now() }
306
+ };
307
+ const result5 = engine.evaluate(customOperatorConfig, customContext);
308
+ console.log("结果:", result5.applicable ? "适用" : "不适用");
309
+ console.log("匹配动作:", result5.matchedActions);
310
+ console.log("\n引擎调试信息:", engine.getDebugInfo());
311
+ }
312
+ if (require.main === module) {
313
+ runExamples();
314
+ }
315
+ // Annotate the CommonJS export names for ESM import in node:
316
+ 0 && (module.exports = {
317
+ runExamples
318
+ });
@@ -0,0 +1,228 @@
1
+ /**
2
+ * 策略配置主结构
3
+ */
4
+ export interface StrategyConfig<T = Record<string, any>> {
5
+ /** 元信息 */
6
+ metadata: StrategyMetadata<T>;
7
+ /** 条件组(可嵌套,每层可绑定动作) */
8
+ conditions: ConditionGroup;
9
+ /** 动作列表(带唯一ID) */
10
+ actions: ActionEffect[];
11
+ /** 展示配置(可选) */
12
+ display?: DisplayConfig;
13
+ }
14
+ /**
15
+ * 策略元信息
16
+ */
17
+ export interface StrategyMetadata<T = Record<string, any>> {
18
+ /** 策略ID */
19
+ id: string;
20
+ /** 策略名称 */
21
+ name: string | Record<string, string>;
22
+ /** 策略类型(完全可扩展) */
23
+ type: string;
24
+ /** 计算类型 */
25
+ calculationType?: 'single' | 'cumulative';
26
+ /** 版本 */
27
+ version?: string;
28
+ /** 描述 */
29
+ description?: string | Record<string, string>;
30
+ /** 自定义元数据 */
31
+ custom?: T;
32
+ }
33
+ /**
34
+ * 条件组(支持嵌套)
35
+ */
36
+ export interface ConditionGroup {
37
+ /** 逻辑运算符 */
38
+ operator: 'and' | 'or' | 'not';
39
+ /** 条件规则列表(可以是单条件或嵌套的条件组) */
40
+ rules: Array<ConditionRule | ConditionGroup>;
41
+ /** 关联的动作ID列表(必填,可以为空数组) */
42
+ actionIds: string[];
43
+ }
44
+ /**
45
+ * 条件规则(原子条件)
46
+ * 支持 code 模式使用 eval 执行
47
+ */
48
+ export interface ConditionRule {
49
+ /** 类型 */
50
+ type: 'code' | 'operator';
51
+ /** 代码(code模式使用,使用eval执行) */
52
+ code?: string;
53
+ /** 维度(完全可扩展) */
54
+ dimension?: string;
55
+ /** 字段名 */
56
+ field?: string;
57
+ /** 运算符 */
58
+ operator?: string;
59
+ /** 比较值 */
60
+ value?: any;
61
+ /** 值类型 */
62
+ valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object' | 'date';
63
+ /** 值单位 */
64
+ valueUnit?: string;
65
+ /** 额外配置 */
66
+ config?: Record<string, any>;
67
+ }
68
+ /**
69
+ * 动作效果
70
+ */
71
+ export interface ActionEffect {
72
+ /** 动作的唯一标识 */
73
+ id: string;
74
+ /** 效果类型(完全可扩展) */
75
+ type: string;
76
+ /** 运算符(可选) */
77
+ operator?: string;
78
+ /** 值 */
79
+ value: any;
80
+ /** 值类型 */
81
+ valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object';
82
+ /** 值单位 */
83
+ valueUnit?: string;
84
+ /** 作用目标 */
85
+ target: string;
86
+ /** 优先级(数字越大优先级越高) */
87
+ priority?: number;
88
+ /** 配置(完全可扩展) */
89
+ config?: Record<string, any>;
90
+ }
91
+ /**
92
+ * 展示配置
93
+ */
94
+ export interface DisplayConfig {
95
+ /** 商品卡片展示 */
96
+ productCard?: {
97
+ text: string | Record<string, string>;
98
+ type: 'tag' | 'badge' | 'label';
99
+ image?: string;
100
+ style?: Record<string, any>;
101
+ };
102
+ /** 详情页展示 */
103
+ detail?: {
104
+ title: string | Record<string, string>;
105
+ description: string | Record<string, string>;
106
+ image?: string;
107
+ };
108
+ /** 自定义展示配置 */
109
+ custom?: Record<string, any>;
110
+ }
111
+ /**
112
+ * 运行时上下文结构
113
+ */
114
+ export interface RuntimeContext {
115
+ /** 实体数据(完全开放,由业务层定义) */
116
+ entities: Record<string, any>;
117
+ /** 属性数据(扁平化的计算值,用于条件判断) */
118
+ attributes: Record<string, any>;
119
+ /** 上下文元数据 */
120
+ metadata: ContextMetadata;
121
+ }
122
+ /**
123
+ * 上下文元数据
124
+ */
125
+ export interface ContextMetadata {
126
+ /** 请求ID(用于追踪) */
127
+ requestId?: string;
128
+ /** 时间戳 */
129
+ timestamp: number;
130
+ /** 语言 */
131
+ locale?: string;
132
+ /** 自定义元数据 */
133
+ custom?: Record<string, any>;
134
+ }
135
+ /**
136
+ * 评估结果结构
137
+ */
138
+ export interface EvaluationResult {
139
+ /** 是否成功执行(引擎层面) */
140
+ success: boolean;
141
+ /** 策略是否适用(业务层面) */
142
+ applicable: boolean;
143
+ /** 结果码 */
144
+ code: string;
145
+ /** 消息(多语言key或直接文本) */
146
+ message?: string;
147
+ /** 匹配信息 */
148
+ matched: MatchedInfo;
149
+ /** 匹配的动作列表(按priority排序) */
150
+ matchedActions: ActionEffect[];
151
+ /** 输出结果(完全开放,由适配器定义) */
152
+ outputs: Record<string, any>;
153
+ /** 执行轨迹(可选,用于调试) */
154
+ trace?: ExecutionTrace;
155
+ /** 策略配置 */
156
+ config: StrategyConfig;
157
+ }
158
+ /**
159
+ * 匹配信息
160
+ */
161
+ export interface MatchedInfo {
162
+ /** 条件是否满足 */
163
+ conditions: boolean;
164
+ /** 收集到的 actionIds */
165
+ actionIds: string[];
166
+ /** 详细匹配信息 */
167
+ details: Record<string, any>;
168
+ }
169
+ /**
170
+ * 执行轨迹
171
+ */
172
+ export interface ExecutionTrace {
173
+ /** 执行步骤 */
174
+ steps: TraceStep[];
175
+ /** 总耗时(毫秒) */
176
+ duration: number;
177
+ /** 错误信息 */
178
+ errors?: Array<{
179
+ step: string;
180
+ error: string;
181
+ timestamp: number;
182
+ }>;
183
+ }
184
+ /**
185
+ * 追踪步骤
186
+ */
187
+ export interface TraceStep {
188
+ /** 步骤名称 */
189
+ step: string;
190
+ /** 步骤状态 */
191
+ status: 'success' | 'failed' | 'skipped';
192
+ /** 耗时(毫秒) */
193
+ duration: number;
194
+ /** 详细信息 */
195
+ details?: Record<string, any>;
196
+ }
197
+ /** 成功码 */
198
+ export declare const SUCCESS_CODES: {
199
+ readonly SUCCESS: "SUCCESS";
200
+ };
201
+ /** 不适用码 */
202
+ export declare const NOT_APPLICABLE_CODES: {
203
+ readonly CONDITION_NOT_MET: "CONDITION_NOT_MET";
204
+ };
205
+ /** 错误码 */
206
+ export declare const ERROR_CODES: {
207
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
208
+ readonly INVALID_CONTEXT: "INVALID_CONTEXT";
209
+ readonly EVALUATION_ERROR: "EVALUATION_ERROR";
210
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
211
+ };
212
+ /**
213
+ * 引擎配置选项
214
+ */
215
+ export interface EngineOptions {
216
+ /** 是否启用调试模式 */
217
+ debug?: boolean;
218
+ /** 是否启用追踪 */
219
+ enableTrace?: boolean;
220
+ /** 运算符处理器映射 */
221
+ operatorHandlers?: Record<string, OperatorHandler>;
222
+ /** 自定义错误处理器 */
223
+ errorHandler?: (error: Error, context: RuntimeContext) => void;
224
+ }
225
+ /**
226
+ * 运算符处理器
227
+ */
228
+ export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
@@ -0,0 +1,44 @@
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/type.ts
20
+ var type_exports = {};
21
+ __export(type_exports, {
22
+ ERROR_CODES: () => ERROR_CODES,
23
+ NOT_APPLICABLE_CODES: () => NOT_APPLICABLE_CODES,
24
+ SUCCESS_CODES: () => SUCCESS_CODES
25
+ });
26
+ module.exports = __toCommonJS(type_exports);
27
+ var SUCCESS_CODES = {
28
+ SUCCESS: "SUCCESS"
29
+ };
30
+ var NOT_APPLICABLE_CODES = {
31
+ CONDITION_NOT_MET: "CONDITION_NOT_MET"
32
+ };
33
+ var ERROR_CODES = {
34
+ INVALID_CONFIG: "INVALID_CONFIG",
35
+ INVALID_CONTEXT: "INVALID_CONTEXT",
36
+ EVALUATION_ERROR: "EVALUATION_ERROR",
37
+ UNKNOWN_ERROR: "UNKNOWN_ERROR"
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ERROR_CODES,
42
+ NOT_APPLICABLE_CODES,
43
+ SUCCESS_CODES
44
+ });
@@ -75,6 +75,8 @@ export interface CartItem {
75
75
  summaryTotal?: number | string;
76
76
  /** 商品原价总价,排除原始价格为0的场景 */
77
77
  origin_total?: number | string;
78
+ /** 基于 origin_total 乘以 商品数量的价格 */
79
+ summaryOriginTotal?: number | string;
78
80
  /** 商品数量 */
79
81
  num?: number;
80
82
  /** 商品图片 */
@@ -88,6 +88,14 @@ var formatProductToCartItem = (params) => {
88
88
  num,
89
89
  discounts
90
90
  });
91
+ const origin_total = getProductTotalPrice({
92
+ product: cartItem._productInit || cartItem._productOrigin,
93
+ bundle,
94
+ options,
95
+ num,
96
+ discounts: []
97
+ });
98
+ cartItem.summaryOriginTotal = (origin_total || 0) * (num || 1);
91
99
  cartItem.image = product == null ? void 0 : product.cover;
92
100
  cartItem.like_status = "common";
93
101
  cartItem.duration = product == null ? void 0 : product.duration;
@@ -178,6 +186,7 @@ var getProductTotalPrice = (params) => {
178
186
  price = (0, import_utils2.getDiscountAmount)({
179
187
  tag: currentValue.type,
180
188
  par_value: currentValue.discount.percent,
189
+ config: currentValue.config,
181
190
  metadata: {
182
191
  discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
183
192
  }
@@ -25,6 +25,8 @@ interface Limitedrelationproductdata {
25
25
  product_ids: number[];
26
26
  product_collection_id: number[];
27
27
  package_sub_item_usage_rules?: PackageSubItemUsageRules;
28
+ filter: 0 | 1;
29
+ exclude_product_ids: number[];
28
30
  }
29
31
  interface ApplicableProductDetails {
30
32
  amount: string;
@@ -96,6 +98,19 @@ export interface Discount {
96
98
  isSelected?: boolean;
97
99
  isAvailable?: boolean;
98
100
  isUsed?: boolean;
101
+ config?: {
102
+ isAvailable?: boolean;
103
+ /** 最大抵扣金额 */
104
+ maxDeductionAmount?: number;
105
+ /** 每单最多使用张数 */
106
+ maxUsagePerOrder?: number;
107
+ /** 是否抵扣税费与附加费 */
108
+ deductTaxAndFee?: boolean;
109
+ /** 适用粒度(多商品共用) */
110
+ allowCrossProduct?: boolean;
111
+ /** 可用商品数量上限 */
112
+ applicableProductLimit?: number;
113
+ };
99
114
  applicableProductIds?: number[];
100
115
  applicableProductDetails: ApplicableProductDetails[];
101
116
  appliedProductDetails: ApplicableProductDetails[];
@@ -1,5 +1,5 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { RequestPlugin } from '../../plugins';
2
+ import { RequestPlugin, WindowPlugin } from '../../plugins';
3
3
  import { BaseModule } from '../BaseModule';
4
4
  import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
5
5
  export * from './types';
@@ -21,6 +21,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
21
21
  request: RequestPlugin;
22
22
  private app;
23
23
  private store;
24
+ window: WindowPlugin;
24
25
  private dbManager;
25
26
  private logger;
26
27
  protected otherParams: any;
@@ -70,6 +70,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
70
70
  this.otherParams = options.otherParams || {};
71
71
  this.request = core.getPlugin("request");
72
72
  const appPlugin = core.getPlugin("app");
73
+ this.window = core.getPlugin("window");
73
74
  if (!this.request) {
74
75
  throw new Error("支付模块需要 request 插件支持");
75
76
  }
@@ -25,6 +25,9 @@ __export(utils_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(utils_exports);
27
27
  var getAvailableMaxAmount = (data) => {
28
+ if (typeof data._available_max_amount === "number") {
29
+ return data._available_max_amount;
30
+ }
28
31
  return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
29
32
  };
30
33
  var formatWalletPassList2PreparePayments = (list) => {