@pisell/pisellos 2.2.71 → 2.2.72

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 (43) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +2 -0
  2. package/dist/model/strategy/adapter/index.js +2 -1
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  12. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  13. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -1
  14. package/dist/model/strategy/engine.d.ts +106 -0
  15. package/dist/model/strategy/engine.js +611 -0
  16. package/dist/model/strategy/index.d.ts +2 -93
  17. package/dist/model/strategy/index.js +6 -549
  18. package/dist/modules/BaseModule.d.ts +4 -0
  19. package/dist/modules/BaseModule.js +5 -0
  20. package/dist/modules/Rules/index.d.ts +1 -0
  21. package/dist/modules/Rules/index.js +28 -16
  22. package/lib/model/strategy/adapter/index.d.ts +2 -0
  23. package/lib/model/strategy/adapter/index.js +6 -0
  24. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  25. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  26. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  27. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  28. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  29. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  30. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  31. package/lib/model/strategy/adapter/promotion/index.js +0 -0
  32. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  33. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  34. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -1
  35. package/lib/model/strategy/engine.d.ts +106 -0
  36. package/lib/model/strategy/engine.js +450 -0
  37. package/lib/model/strategy/index.d.ts +2 -93
  38. package/lib/model/strategy/index.js +6 -381
  39. package/lib/modules/BaseModule.d.ts +4 -0
  40. package/lib/modules/BaseModule.js +3 -0
  41. package/lib/modules/Rules/index.d.ts +1 -0
  42. package/lib/modules/Rules/index.js +23 -17
  43. package/package.json +1 -1
@@ -20,394 +20,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/model/strategy/index.ts
21
21
  var strategy_exports = {};
22
22
  __export(strategy_exports, {
23
- StrategyEngine: () => StrategyEngine,
24
- createStrategyEngine: () => createStrategyEngine,
25
- evaluate: () => evaluate
23
+ StrategyEngine: () => import_engine.StrategyEngine,
24
+ createStrategyEngine: () => import_engine.createStrategyEngine,
25
+ evaluate: () => import_engine.evaluate
26
26
  });
27
27
  module.exports = __toCommonJS(strategy_exports);
28
- var import_type = require("./type");
28
+ var import_engine = require("./engine");
29
+ __reExport(strategy_exports, require("./type"), module.exports);
29
30
  __reExport(strategy_exports, require("./adapter"), module.exports);
30
- var StrategyEngine = class {
31
- constructor(options = {}) {
32
- this.options = {
33
- debug: options.debug ?? false,
34
- enableTrace: options.enableTrace ?? false,
35
- operatorHandlers: options.operatorHandlers ?? {},
36
- errorHandler: options.errorHandler ?? ((error) => console.error(error))
37
- };
38
- this.operatorHandlers = new Map(
39
- Object.entries(this.options.operatorHandlers)
40
- );
41
- this.initializeBuiltInOperators();
42
- }
43
- /**
44
- * 评估策略
45
- */
46
- evaluate(config, context) {
47
- var _a;
48
- const startTime = Date.now();
49
- const trace = {
50
- steps: [],
51
- duration: 0,
52
- errors: []
53
- };
54
- try {
55
- this.validateConfig(config);
56
- if (this.options.enableTrace) {
57
- trace.steps.push({
58
- step: "validate_config",
59
- status: "success",
60
- duration: Date.now() - startTime
61
- });
62
- }
63
- const evaluateStart = Date.now();
64
- const evaluationResult = this.evaluateConditionGroup(
65
- config.conditions,
66
- context
67
- );
68
- if (this.options.enableTrace) {
69
- trace.steps.push({
70
- step: "evaluate_conditions",
71
- status: "success",
72
- duration: Date.now() - evaluateStart,
73
- details: {
74
- satisfied: evaluationResult.satisfied,
75
- collectedActionIds: evaluationResult.actionIds
76
- }
77
- });
78
- }
79
- const actionStart = Date.now();
80
- const matchedActions = this.getActionsByIds(
81
- evaluationResult.actionIds,
82
- config.actions
83
- );
84
- if (this.options.enableTrace) {
85
- trace.steps.push({
86
- step: "get_actions",
87
- status: "success",
88
- duration: Date.now() - actionStart,
89
- details: { matchedCount: matchedActions.length }
90
- });
91
- }
92
- const sortStart = Date.now();
93
- const sortedActions = this.sortActionsByPriority(matchedActions);
94
- if (this.options.enableTrace) {
95
- trace.steps.push({
96
- step: "sort_actions",
97
- status: "success",
98
- duration: Date.now() - sortStart
99
- });
100
- }
101
- const applicable = evaluationResult.satisfied;
102
- const result = {
103
- success: true,
104
- applicable,
105
- code: applicable ? import_type.SUCCESS_CODES.SUCCESS : import_type.NOT_APPLICABLE_CODES.CONDITION_NOT_MET,
106
- message: applicable ? "Strategy is applicable" : "Conditions not met",
107
- matched: {
108
- conditions: applicable,
109
- actionIds: evaluationResult.actionIds,
110
- details: {}
111
- },
112
- matchedActions: sortedActions,
113
- outputs: {},
114
- config
115
- };
116
- trace.duration = Date.now() - startTime;
117
- if (this.options.enableTrace) {
118
- result.trace = trace;
119
- }
120
- return result;
121
- } catch (error) {
122
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
123
- if (this.options.enableTrace) {
124
- (_a = trace.errors) == null ? void 0 : _a.push({
125
- step: "evaluation",
126
- error: errorMessage,
127
- timestamp: Date.now()
128
- });
129
- trace.duration = Date.now() - startTime;
130
- }
131
- this.options.errorHandler(error, context);
132
- return {
133
- success: false,
134
- applicable: false,
135
- code: import_type.ERROR_CODES.EVALUATION_ERROR,
136
- message: errorMessage,
137
- matched: {
138
- conditions: false,
139
- actionIds: [],
140
- details: {}
141
- },
142
- matchedActions: [],
143
- outputs: {},
144
- trace: this.options.enableTrace ? trace : void 0,
145
- config
146
- };
147
- }
148
- }
149
- /**
150
- * 递归评估条件组
151
- *
152
- * @param group 条件组
153
- * @param context 运行时上下文
154
- * @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
155
- */
156
- evaluateConditionGroup(group, context) {
157
- const collectedActionIds = [];
158
- const isCurrentLayerSatisfied = this.evaluateGroupLogic(group, context);
159
- if (isCurrentLayerSatisfied) {
160
- collectedActionIds.push(...group.actionIds);
161
- for (const rule of group.rules) {
162
- if (this.isConditionGroup(rule)) {
163
- const nestedResult = this.evaluateConditionGroup(rule, context);
164
- collectedActionIds.push(...nestedResult.actionIds);
165
- }
166
- }
167
- }
168
- return {
169
- satisfied: isCurrentLayerSatisfied,
170
- actionIds: collectedActionIds
171
- };
172
- }
173
- /**
174
- * 评估条件组的逻辑运算
175
- */
176
- evaluateGroupLogic(group, context) {
177
- const { operator, rules } = group;
178
- switch (operator) {
179
- case "and":
180
- return rules.every((rule) => this.evaluateRule(rule, context));
181
- case "or":
182
- return rules.some((rule) => this.evaluateRule(rule, context));
183
- case "not":
184
- if (rules.length === 0)
185
- return false;
186
- return !this.evaluateRule(rules[0], context);
187
- default:
188
- throw new Error(`Unknown operator: ${operator}`);
189
- }
190
- }
191
- /**
192
- * 评估单个规则
193
- */
194
- evaluateRule(rule, context) {
195
- if (this.isConditionGroup(rule)) {
196
- return this.evaluateGroupLogic(rule, context);
197
- }
198
- const conditionRule = rule;
199
- if (conditionRule.type === "code" && conditionRule.code) {
200
- return this.evaluateCodeCondition(conditionRule.code, context);
201
- }
202
- return this.evaluateOperatorCondition(conditionRule, context);
203
- }
204
- /**
205
- * 评估代码模式条件
206
- */
207
- evaluateCodeCondition(code, context) {
208
- try {
209
- const { entities, attributes, metadata } = context;
210
- const evalFunc = new Function(
211
- "entities",
212
- "attributes",
213
- "metadata",
214
- `return (${code})`
215
- );
216
- const result = evalFunc(entities, attributes, metadata);
217
- return Boolean(result);
218
- } catch (error) {
219
- if (this.options.debug) {
220
- console.error("Code evaluation error:", error);
221
- }
222
- return false;
223
- }
224
- }
225
- /**
226
- * 评估运算符模式条件
227
- */
228
- evaluateOperatorCondition(rule, context) {
229
- const { field, operator, value } = rule;
230
- if (!field || !operator) {
231
- return false;
232
- }
233
- const fieldValue = this.getFieldValue(field, context);
234
- const handler = this.operatorHandlers.get(operator);
235
- if (handler) {
236
- return handler(fieldValue, value, rule);
237
- }
238
- return this.evaluateBuiltInOperator(fieldValue, operator, value);
239
- }
240
- /**
241
- * 获取字段值
242
- */
243
- getFieldValue(field, context) {
244
- const path = field.split(".");
245
- let value = context.attributes;
246
- for (const key of path) {
247
- if (value && typeof value === "object" && key in value) {
248
- value = value[key];
249
- } else {
250
- return void 0;
251
- }
252
- }
253
- return value;
254
- }
255
- /**
256
- * 评估内置运算符
257
- */
258
- evaluateBuiltInOperator(fieldValue, operator, compareValue) {
259
- switch (operator) {
260
- case "=":
261
- case "==":
262
- return fieldValue == compareValue;
263
- case "!=":
264
- return fieldValue != compareValue;
265
- case ">":
266
- return fieldValue > compareValue;
267
- case ">=":
268
- return fieldValue >= compareValue;
269
- case "<":
270
- return fieldValue < compareValue;
271
- case "<=":
272
- return fieldValue <= compareValue;
273
- case "in":
274
- return Array.isArray(compareValue) && compareValue.includes(fieldValue);
275
- case "not_in":
276
- return Array.isArray(compareValue) && !compareValue.includes(fieldValue);
277
- case "contains":
278
- if (Array.isArray(fieldValue)) {
279
- return fieldValue.includes(compareValue);
280
- }
281
- if (typeof fieldValue === "string") {
282
- return fieldValue.includes(compareValue);
283
- }
284
- return false;
285
- case "not_contains":
286
- if (Array.isArray(fieldValue)) {
287
- return !fieldValue.includes(compareValue);
288
- }
289
- if (typeof fieldValue === "string") {
290
- return !fieldValue.includes(compareValue);
291
- }
292
- return true;
293
- case "starts_with":
294
- return typeof fieldValue === "string" && fieldValue.startsWith(compareValue);
295
- case "ends_with":
296
- return typeof fieldValue === "string" && fieldValue.endsWith(compareValue);
297
- case "regex":
298
- return typeof fieldValue === "string" && new RegExp(compareValue).test(fieldValue);
299
- case "between":
300
- if (!Array.isArray(compareValue) || compareValue.length !== 2)
301
- return false;
302
- return fieldValue >= compareValue[0] && fieldValue <= compareValue[1];
303
- case "is_null":
304
- return fieldValue === null || fieldValue === void 0;
305
- case "is_not_null":
306
- return fieldValue !== null && fieldValue !== void 0;
307
- case "is_empty":
308
- if (Array.isArray(fieldValue))
309
- return fieldValue.length === 0;
310
- if (typeof fieldValue === "string")
311
- return fieldValue.length === 0;
312
- if (typeof fieldValue === "object")
313
- return Object.keys(fieldValue).length === 0;
314
- return !fieldValue;
315
- case "is_not_empty":
316
- if (Array.isArray(fieldValue))
317
- return fieldValue.length > 0;
318
- if (typeof fieldValue === "string")
319
- return fieldValue.length > 0;
320
- if (typeof fieldValue === "object")
321
- return Object.keys(fieldValue).length > 0;
322
- return Boolean(fieldValue);
323
- default:
324
- throw new Error(`Unsupported operator: ${operator}`);
325
- }
326
- }
327
- /**
328
- * 根据 actionIds 获取 ActionEffect 对象
329
- */
330
- getActionsByIds(actionIds, actions) {
331
- const matchedActions = [];
332
- const actionMap = new Map(actions.map((action) => [action.id, action]));
333
- for (const id of actionIds) {
334
- const action = actionMap.get(id);
335
- if (action) {
336
- matchedActions.push(action);
337
- } else {
338
- if (this.options.debug) {
339
- console.warn(`Action with id "${id}" not found in actions array`);
340
- }
341
- }
342
- }
343
- return matchedActions;
344
- }
345
- /**
346
- * 按 priority 排序(降序)
347
- */
348
- sortActionsByPriority(actions) {
349
- return [...actions].sort((a, b) => {
350
- const priorityA = a.priority ?? 0;
351
- const priorityB = b.priority ?? 0;
352
- return priorityB - priorityA;
353
- });
354
- }
355
- /**
356
- * 判断是否为条件组
357
- */
358
- isConditionGroup(rule) {
359
- return "operator" in rule && "rules" in rule && Array.isArray(rule.rules);
360
- }
361
- /**
362
- * 验证配置
363
- */
364
- validateConfig(config) {
365
- if (!config) {
366
- throw new Error("Strategy config is required");
367
- }
368
- if (!config.metadata || !config.metadata.id) {
369
- throw new Error("Strategy metadata.id is required");
370
- }
371
- if (!config.conditions) {
372
- throw new Error("Strategy conditions is required");
373
- }
374
- if (!Array.isArray(config.actions)) {
375
- throw new Error("Strategy actions must be an array");
376
- }
377
- }
378
- /**
379
- * 初始化内置运算符处理器
380
- */
381
- initializeBuiltInOperators() {
382
- }
383
- /**
384
- * 注册自定义运算符
385
- */
386
- registerOperator(operator, handler) {
387
- this.operatorHandlers.set(operator, handler);
388
- }
389
- /**
390
- * 获取调试信息
391
- */
392
- getDebugInfo() {
393
- return {
394
- debug: this.options.debug,
395
- enableTrace: this.options.enableTrace,
396
- registeredOperators: Array.from(this.operatorHandlers.keys())
397
- };
398
- }
399
- };
400
- function createStrategyEngine(options) {
401
- return new StrategyEngine(options);
402
- }
403
- function evaluate(config, context) {
404
- const engine = new StrategyEngine();
405
- return engine.evaluate(config, context);
406
- }
407
31
  // Annotate the CommonJS export names for ESM import in node:
408
32
  0 && (module.exports = {
409
33
  StrategyEngine,
410
34
  createStrategyEngine,
411
35
  evaluate,
36
+ ...require("./type"),
412
37
  ...require("./adapter")
413
38
  });
@@ -17,4 +17,8 @@ export declare class BaseModule {
17
17
  effectsOn(eventType: string, callback: (payload: any) => void): () => void;
18
18
  effectsOff(eventType: string, callback: (payload: any) => void): void;
19
19
  effectsOnce(eventType: string, callback: (payload: any) => void): () => void;
20
+ effectsEmit(eventType: string, payload: any): Promise<{
21
+ status: boolean;
22
+ data: any;
23
+ }>;
20
24
  }
@@ -91,6 +91,9 @@ var BaseModule = class {
91
91
  effectsOnce(eventType, callback) {
92
92
  return this.core.effects.once(`${this.name}:${eventType}`, callback);
93
93
  }
94
+ effectsEmit(eventType, payload) {
95
+ return this.core.effects.emit(`${this.name}:${eventType}`, payload);
96
+ }
94
97
  };
95
98
  // Annotate the CommonJS export names for ESM import in node:
96
99
  0 && (module.exports = {
@@ -30,6 +30,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
30
30
  discountList: Discount[];
31
31
  productList: any[];
32
32
  };
33
+ filterDiscountListByType(discountList: Discount[], type: string): Discount[];
33
34
  calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
34
35
  discountList: Discount[];
35
36
  productList: any[];
@@ -149,6 +149,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
149
149
  productList: hasApplicableDiscount ? result.productList : productList
150
150
  };
151
151
  }
152
+ filterDiscountListByType(discountList, type) {
153
+ return (discountList || []).filter((item) => item.type === type || item.tag === type);
154
+ }
152
155
  calcDiscount({
153
156
  discountList,
154
157
  productList,
@@ -582,7 +585,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
582
585
  });
583
586
  const processedFlatItemsMap = /* @__PURE__ */ new Map();
584
587
  sortedFlattenedList.forEach((flatItem, index) => {
585
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
588
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
586
589
  let product, originProduct;
587
590
  if (flatItem.type === "main") {
588
591
  product = flatItem.product;
@@ -697,6 +700,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
697
700
  _h,
698
701
  (item) => item.type === "product"
699
702
  )));
703
+ if (product.inPromotion) {
704
+ isManualDiscount = false;
705
+ }
700
706
  } else {
701
707
  const parentProduct = flatItem.parentProduct;
702
708
  if (parentProduct) {
@@ -800,7 +806,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
800
806
  }),
801
807
  price: product.price
802
808
  },
803
- discount_list: []
809
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
804
810
  })
805
811
  ]);
806
812
  } else {
@@ -811,18 +817,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
811
817
  main_product_selling_price: product.price
812
818
  } : {
813
819
  _id: product._id.split("___")[0] + "___" + index,
814
- total: product.origin_total || product.total,
820
+ total: product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total || product.total,
815
821
  price: product.price,
816
822
  main_product_selling_price: product.price
817
823
  },
818
- discount_list: []
824
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
819
825
  })
820
826
  ]);
821
827
  }
822
828
  } else {
823
829
  processedFlatItemsMap.set(flatItem._id, [{
824
830
  ...flatItem,
825
- discount_list: [],
831
+ discount_list: this.filterDiscountListByType(((_v = flatItem.bundleItem) == null ? void 0 : _v.discount_list) || [], "promotion"),
826
832
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
827
833
  processed: true
828
834
  }]);
@@ -850,7 +856,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
850
856
  if (splitCount < totalQuantity && isNeedSplit) {
851
857
  arr.push(
852
858
  this.hooks.setProduct(originProduct, {
853
- discount_list: [],
859
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
854
860
  quantity: totalQuantity - splitCount,
855
861
  _id: product._id.split("___")[0],
856
862
  total: product.origin_total || product.total
@@ -866,10 +872,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
866
872
  }
867
873
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
868
874
  let productOriginTotal = product.origin_total || product.total || 0;
869
- if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
875
+ if (this.filterDiscountListByType(product.discount_list, "promotion").length && product.origin_total) {
870
876
  productOriginTotal = product.origin_total;
871
877
  }
872
- if (Number(((_v = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _v.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
878
+ if (Number(((_w = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _w.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
873
879
  productOriginTotal = product.total;
874
880
  }
875
881
  const isOrderLevel = (0, import_utils3.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
@@ -892,9 +898,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
892
898
  amount,
893
899
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
894
900
  discount: {
895
- discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
901
+ discount_card_type: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_card_type,
896
902
  fixed_amount: amount,
897
- discount_calculation_mode: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_calculation_mode,
903
+ discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
898
904
  resource_id: selectedDiscount2.id,
899
905
  title: selectedDiscount2.format_title,
900
906
  original_amount: product.price,
@@ -942,7 +948,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
942
948
  } else {
943
949
  arr.push(
944
950
  this.hooks.setProduct(originProduct, {
945
- discount_list: [discountDetail],
951
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion").concat([discountDetail]),
946
952
  _id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
947
953
  price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
948
954
  quantity: isNeedSplit ? 1 : product.quantity,
@@ -978,7 +984,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
978
984
  type: "good_pass",
979
985
  discount: {
980
986
  fixed_amount: product.origin_total,
981
- discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
987
+ discount_calculation_mode: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_calculation_mode,
982
988
  resource_id: selectedDiscount2.id,
983
989
  title: selectedDiscount2.format_title,
984
990
  original_amount: product.origin_total,
@@ -1052,9 +1058,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1052
1058
  amount: fixedAmountPerItem * (product.num || 1),
1053
1059
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
1054
1060
  discount: {
1055
- discount_card_type: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_card_type,
1061
+ discount_card_type: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_card_type,
1056
1062
  fixed_amount: fixedAmountPerItem,
1057
- discount_calculation_mode: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_calculation_mode,
1063
+ discount_calculation_mode: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_calculation_mode,
1058
1064
  resource_id: selectedDiscount2.id,
1059
1065
  title: selectedDiscount2.format_title,
1060
1066
  original_amount: product.original_price,
@@ -1070,7 +1076,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1070
1076
  ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
1071
1077
  },
1072
1078
  config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
1073
- _num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
1079
+ _num: (product.num || 1) * (((_C = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _C.num) || 1)
1074
1080
  };
1075
1081
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
1076
1082
  appliedProducts.push(discountDetail);
@@ -1095,7 +1101,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1095
1101
  const getDefaultProduct = () => {
1096
1102
  if (product.isClient) {
1097
1103
  return this.hooks.setProduct(originProduct, {
1098
- discount_list: [],
1104
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
1099
1105
  price: product.price,
1100
1106
  origin_total: (0, import_utils2.getProductOriginTotalPrice)({
1101
1107
  product: {
@@ -1116,7 +1122,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1116
1122
  });
1117
1123
  } else {
1118
1124
  return this.hooks.setProduct(originProduct, {
1119
- discount_list: [],
1125
+ discount_list: this.filterDiscountListByType(product.discount_list, "promotion"),
1120
1126
  total: product.total,
1121
1127
  origin_total: product.origin_total,
1122
1128
  price: product.price
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.71",
4
+ "version": "2.2.72",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",