@pisell/pisellos 2.2.62 → 2.2.63

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 (53) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -2
  2. package/dist/model/strategy/adapter/index.js +1 -2
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +1 -4
  4. package/dist/model/strategy/index.d.ts +93 -2
  5. package/dist/model/strategy/index.js +549 -6
  6. package/dist/modules/BaseModule.d.ts +0 -4
  7. package/dist/modules/BaseModule.js +0 -5
  8. package/dist/modules/Product/index.d.ts +1 -1
  9. package/dist/modules/Rules/index.d.ts +0 -1
  10. package/dist/modules/Rules/index.js +16 -28
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +1 -1
  14. package/dist/solution/ShopDiscount/index.js +1 -0
  15. package/lib/model/strategy/adapter/index.d.ts +0 -2
  16. package/lib/model/strategy/adapter/index.js +0 -6
  17. package/lib/model/strategy/adapter/walletPass/evaluator.js +1 -2
  18. package/lib/model/strategy/index.d.ts +93 -2
  19. package/lib/model/strategy/index.js +381 -6
  20. package/lib/modules/BaseModule.d.ts +0 -4
  21. package/lib/modules/BaseModule.js +0 -3
  22. package/lib/modules/Product/index.d.ts +1 -1
  23. package/lib/modules/Rules/index.d.ts +0 -1
  24. package/lib/modules/Rules/index.js +17 -23
  25. package/lib/solution/BookingByStep/index.d.ts +1 -1
  26. package/lib/solution/BookingTicket/index.d.ts +1 -1
  27. package/lib/solution/Checkout/index.js +1 -1
  28. package/lib/solution/ShopDiscount/index.js +2 -0
  29. package/package.json +1 -1
  30. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -66
  31. package/dist/model/strategy/adapter/promotion/adapter.js +0 -271
  32. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -213
  33. package/dist/model/strategy/adapter/promotion/evaluator.js +0 -1206
  34. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -138
  35. package/dist/model/strategy/adapter/promotion/examples.js +0 -166
  36. package/dist/model/strategy/adapter/promotion/index.d.ts +0 -4
  37. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  38. package/dist/model/strategy/adapter/promotion/type.d.ts +0 -447
  39. package/dist/model/strategy/adapter/promotion/type.js +0 -209
  40. package/dist/model/strategy/engine.d.ts +0 -106
  41. package/dist/model/strategy/engine.js +0 -611
  42. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -66
  43. package/lib/model/strategy/adapter/promotion/adapter.js +0 -217
  44. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -213
  45. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -844
  46. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -138
  47. package/lib/model/strategy/adapter/promotion/examples.js +0 -192
  48. package/lib/model/strategy/adapter/promotion/index.d.ts +0 -4
  49. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  50. package/lib/model/strategy/adapter/promotion/type.d.ts +0 -447
  51. package/lib/model/strategy/adapter/promotion/type.js +0 -51
  52. package/lib/model/strategy/engine.d.ts +0 -106
  53. package/lib/model/strategy/engine.js +0 -450
@@ -79,11 +79,6 @@ export var BaseModule = /*#__PURE__*/function () {
79
79
  value: function effectsOnce(eventType, callback) {
80
80
  return this.core.effects.once("".concat(this.name, ":").concat(eventType), callback);
81
81
  }
82
- }, {
83
- key: "effectsEmit",
84
- value: function effectsEmit(eventType, payload) {
85
- return this.core.effects.emit("".concat(this.name, ":").concat(eventType), payload);
86
- }
87
82
  }]);
88
83
  return BaseModule;
89
84
  }();
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -30,7 +30,6 @@ 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[];
34
33
  calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
35
34
  discountList: Discount[];
36
35
  productList: any[];
@@ -201,13 +201,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
201
201
  productList: hasApplicableDiscount ? result.productList : productList
202
202
  };
203
203
  }
204
- }, {
205
- key: "filterDiscountListByType",
206
- value: function filterDiscountListByType(discountList, type) {
207
- return (discountList || []).filter(function (item) {
208
- return item.type === type || item.tag === type;
209
- });
210
- }
211
204
  }, {
212
205
  key: "calcDiscount",
213
206
  value: function calcDiscount(_ref2, options) {
@@ -960,9 +953,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
960
953
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
961
954
  return item.type === 'product';
962
955
  })));
963
- if (product.inPromotion) {
964
- isManualDiscount = false;
965
- }
966
956
  } else {
967
957
  // bundle子商品:判断父主商品是否手动折扣
968
958
  var parentProduct = flatItem.parentProduct;
@@ -1058,27 +1048,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1058
1048
  }),
1059
1049
  price: product.price
1060
1050
  }), {}, {
1061
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1051
+ discount_list: []
1062
1052
  }))]);
1063
1053
  } else {
1064
- var _ref7, _product$_promotion$f, _product12;
1065
1054
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1066
1055
  price: product.price,
1067
1056
  main_product_selling_price: product.price
1068
1057
  } : {
1069
1058
  _id: product._id.split('___')[0] + '___' + index,
1070
- total: product.inPromotion ? (_ref7 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref7 !== void 0 ? _ref7 : product.total : product.origin_total || product.total,
1059
+ total: product.origin_total || product.total,
1071
1060
  price: product.price,
1072
1061
  main_product_selling_price: product.price
1073
1062
  }), {}, {
1074
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1063
+ discount_list: []
1075
1064
  }))]);
1076
1065
  }
1077
1066
  } else {
1078
- var _flatItem$bundleItem8;
1079
1067
  // bundle子商品:保存到扁平化Map
1080
1068
  processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
1081
- discount_list: _this3.filterDiscountListByType(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || [], 'promotion'),
1069
+ discount_list: [],
1082
1070
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1083
1071
  processed: true
1084
1072
  })]);
@@ -1111,14 +1099,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1111
1099
  // 主商品:保持原有逻辑
1112
1100
  if (splitCount < totalQuantity && isNeedSplit) {
1113
1101
  arr.push(_this3.hooks.setProduct(originProduct, {
1114
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1102
+ discount_list: [],
1115
1103
  quantity: totalQuantity - splitCount,
1116
1104
  _id: product._id.split('___')[0],
1117
1105
  total: product.origin_total || product.total
1118
1106
  }));
1119
1107
  }
1120
1108
  for (var i = 0; i < splitCount; i++) {
1121
- var _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1109
+ var _product$discount_lis10, _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1122
1110
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1123
1111
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1124
1112
  // 标记优惠券为已使用
@@ -1135,7 +1123,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1135
1123
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
1136
1124
  var productOriginTotal = product.origin_total || product.total || 0;
1137
1125
  // 如果当前 product 有 discount_list,则先从 origin_total 拿
1138
- if (_this3.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
1126
+ if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
1139
1127
  productOriginTotal = product.origin_total;
1140
1128
  }
1141
1129
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
@@ -1217,7 +1205,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1217
1205
  }));
1218
1206
  } else {
1219
1207
  arr.push(_this3.hooks.setProduct(originProduct, {
1220
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
1208
+ discount_list: [discountDetail],
1221
1209
  _id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
1222
1210
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
1223
1211
  quantity: isNeedSplit ? 1 : product.quantity,
@@ -1388,7 +1376,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1388
1376
  var getDefaultProduct = function getDefaultProduct() {
1389
1377
  if (product.isClient) {
1390
1378
  return _this3.hooks.setProduct(originProduct, {
1391
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1379
+ discount_list: [],
1392
1380
  price: product.price,
1393
1381
  origin_total: getProductOriginTotalPrice({
1394
1382
  product: {
@@ -1409,7 +1397,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1409
1397
  });
1410
1398
  } else {
1411
1399
  return _this3.hooks.setProduct(originProduct, {
1412
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1400
+ discount_list: [],
1413
1401
  total: product.total,
1414
1402
  origin_total: product.origin_total,
1415
1403
  price: product.price
@@ -1869,10 +1857,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1869
1857
  return true; // 单独购买时可用
1870
1858
  }
1871
1859
  if (isBundleItem) {
1872
- var _flatItem$bundleItem9, _flatItem$bundleItem10;
1860
+ var _flatItem$bundleItem8, _flatItem$bundleItem9;
1873
1861
  // 套餐中购买时,判断是否为原价
1874
- var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
1875
- var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
1862
+ var priceType = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type;
1863
+ var priceTypeExt = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type_ext;
1876
1864
  // original_price 对应:
1877
1865
  // 1. price_type: "markup" && price_type_ext: "product_price"
1878
1866
  // markup_price 对应:
@@ -1910,10 +1898,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1910
1898
  return false; // 单独购买时不可用
1911
1899
  }
1912
1900
  if (isBundleItem) {
1913
- var _flatItem$bundleItem11, _flatItem$bundleItem12;
1901
+ var _flatItem$bundleItem10, _flatItem$bundleItem11;
1914
1902
  // 套餐中购买时,判断是否为原价
1915
- var _priceType = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type;
1916
- var _priceTypeExt = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type_ext;
1903
+ var _priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
1904
+ var _priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
1917
1905
 
1918
1906
  // original_price 对应:
1919
1907
  // 1. price_type: "markup" && price_type_ext: "product_price"
@@ -344,7 +344,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
344
344
  };
345
345
  setOtherData(key: string, value: any): void;
346
346
  getOtherData(key: string): any;
347
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
347
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
348
348
  /**
349
349
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
350
350
  *
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -428,7 +428,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
428
428
  // 可选,附加费均摊舍入金额
429
429
  "surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
430
430
  },
431
- product_bundle: item.product_bundle.map(function (bundle) {
431
+ product_bundle: (item.product_bundle || []).map(function (bundle) {
432
432
  return {
433
433
  is_price_include_tax: item.is_price_include_tax,
434
434
  bundle_id: bundle.bundle_id,
@@ -370,6 +370,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
370
370
 
371
371
  // 找到需要修改状态的优惠券
372
372
  var newDiscountList = discountList.map(function (discount) {
373
+ if (discount.isEditMode) return discount;
373
374
  if (selectionMap.has(discount.id)) {
374
375
  var targetIsSelected = selectionMap.get(discount.id);
375
376
  return _objectSpread(_objectSpread({}, discount), {}, {
@@ -1,5 +1,3 @@
1
1
  export * from './type';
2
2
  export { default as WalletPassAdapter } from './walletPass';
3
3
  export { WalletPassEvaluator } from './walletPass/evaluator';
4
- export { PromotionEvaluator } from './promotion/evaluator';
5
- export { PromotionAdapter } from './promotion/adapter';
@@ -30,8 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/model/strategy/adapter/index.ts
31
31
  var adapter_exports = {};
32
32
  __export(adapter_exports, {
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
35
33
  WalletPassAdapter: () => import_walletPass.default,
36
34
  WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
37
35
  });
@@ -39,12 +37,8 @@ module.exports = __toCommonJS(adapter_exports);
39
37
  __reExport(adapter_exports, require("./type"), module.exports);
40
38
  var import_walletPass = __toESM(require("./walletPass"));
41
39
  var import_evaluator = require("./walletPass/evaluator");
42
- var import_evaluator2 = require("./promotion/evaluator");
43
- var import_adapter = require("./promotion/adapter");
44
40
  // Annotate the CommonJS export names for ESM import in node:
45
41
  0 && (module.exports = {
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
42
  WalletPassAdapter,
49
43
  WalletPassEvaluator,
50
44
  ...require("./type")
@@ -53,8 +53,7 @@ var WalletPassEvaluator = class {
53
53
  });
54
54
  }
55
55
  setStrategyConfigs(strategyConfigs) {
56
- const newStrategyConfigs = strategyConfigs.filter((item) => item.metadata.type === "wallet_pass");
57
- this.strategyConfigs = newStrategyConfigs;
56
+ this.strategyConfigs = strategyConfigs;
58
57
  }
59
58
  getStrategyConfigs() {
60
59
  return this.strategyConfigs;
@@ -1,3 +1,94 @@
1
- export { StrategyEngine, createStrategyEngine, evaluate } from './engine';
2
- export * from './type';
1
+ import { StrategyConfig, RuntimeContext, EvaluationResult, EngineOptions, OperatorHandler } from './type';
2
+ /**
3
+ * 策略模型 - 核心实现
4
+ *
5
+ * 完全业务无关的通用策略引擎
6
+ * 支持条件评估、动作匹配、结果返回
7
+ */
8
+ /**
9
+ * 策略引擎
10
+ *
11
+ * 核心职责:
12
+ * 1. 递归评估条件组
13
+ * 2. 收集满足条件的 actionIds
14
+ * 3. 根据 actionIds 获取 ActionEffect 对象
15
+ * 4. 按 priority 排序返回
16
+ */
17
+ export declare class StrategyEngine {
18
+ private options;
19
+ private operatorHandlers;
20
+ constructor(options?: EngineOptions);
21
+ /**
22
+ * 评估策略
23
+ */
24
+ evaluate(config: StrategyConfig, context: RuntimeContext): EvaluationResult;
25
+ /**
26
+ * 递归评估条件组
27
+ *
28
+ * @param group 条件组
29
+ * @param context 运行时上下文
30
+ * @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
31
+ */
32
+ private evaluateConditionGroup;
33
+ /**
34
+ * 评估条件组的逻辑运算
35
+ */
36
+ private evaluateGroupLogic;
37
+ /**
38
+ * 评估单个规则
39
+ */
40
+ private evaluateRule;
41
+ /**
42
+ * 评估代码模式条件
43
+ */
44
+ private evaluateCodeCondition;
45
+ /**
46
+ * 评估运算符模式条件
47
+ */
48
+ private evaluateOperatorCondition;
49
+ /**
50
+ * 获取字段值
51
+ */
52
+ private getFieldValue;
53
+ /**
54
+ * 评估内置运算符
55
+ */
56
+ private evaluateBuiltInOperator;
57
+ /**
58
+ * 根据 actionIds 获取 ActionEffect 对象
59
+ */
60
+ private getActionsByIds;
61
+ /**
62
+ * 按 priority 排序(降序)
63
+ */
64
+ private sortActionsByPriority;
65
+ /**
66
+ * 判断是否为条件组
67
+ */
68
+ private isConditionGroup;
69
+ /**
70
+ * 验证配置
71
+ */
72
+ private validateConfig;
73
+ /**
74
+ * 初始化内置运算符处理器
75
+ */
76
+ private initializeBuiltInOperators;
77
+ /**
78
+ * 注册自定义运算符
79
+ */
80
+ registerOperator(operator: string, handler: OperatorHandler): void;
81
+ /**
82
+ * 获取调试信息
83
+ */
84
+ getDebugInfo(): Record<string, any>;
85
+ }
3
86
  export * from './adapter';
87
+ /**
88
+ * 创建策略引擎实例
89
+ */
90
+ export declare function createStrategyEngine(options?: EngineOptions): StrategyEngine;
91
+ /**
92
+ * 快速评估(使用默认引擎配置)
93
+ */
94
+ export declare function evaluate(config: StrategyConfig, context: RuntimeContext): EvaluationResult;