@pisell/pisellos 1.0.147 → 1.0.148

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 (107) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/itemRule/type.d.ts +6 -6
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/model/strategy/adapter/promotion/type.d.ts +5 -5
  5. package/dist/model/strategy/type.d.ts +1 -1
  6. package/dist/modules/Customer/types.d.ts +1 -1
  7. package/dist/modules/Discount/types.d.ts +1 -1
  8. package/dist/modules/Payment/types.d.ts +7 -7
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Rules/index.js +2 -1
  11. package/dist/modules/Rules/types.d.ts +1 -1
  12. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  13. package/dist/modules/Schedule/type.d.ts +7 -7
  14. package/dist/modules/Schedule/types.d.ts +9 -9
  15. package/dist/solution/BookingByStep/index.d.ts +1 -1
  16. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  17. package/dist/solution/BookingTicket/index.d.ts +1 -1
  18. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  19. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/utils/task.d.ts +2 -2
  22. package/dist/utils/watch.d.ts +2 -2
  23. package/lib/core/index.js +27 -28
  24. package/lib/effects/index.d.ts +2 -2
  25. package/lib/effects/index.js +3 -7
  26. package/lib/model/strategy/adapter/itemRule/adapter.js +7 -14
  27. package/lib/model/strategy/adapter/itemRule/evaluator.js +5 -5
  28. package/lib/model/strategy/adapter/itemRule/examples.js +12 -12
  29. package/lib/model/strategy/adapter/itemRule/type.d.ts +6 -6
  30. package/lib/model/strategy/adapter/promotion/adapter.js +2 -4
  31. package/lib/model/strategy/adapter/promotion/evaluator.js +16 -19
  32. package/lib/model/strategy/adapter/promotion/examples.js +8 -8
  33. package/lib/model/strategy/adapter/promotion/type.d.ts +5 -5
  34. package/lib/model/strategy/adapter/walletPass/evaluator.js +5 -5
  35. package/lib/model/strategy/adapter/walletPass/example.js +21 -21
  36. package/lib/model/strategy/adapter/walletPass/index.js +2 -4
  37. package/lib/model/strategy/adapter/walletPass/locales.js +18 -18
  38. package/lib/model/strategy/adapter/walletPass/utils.js +21 -42
  39. package/lib/model/strategy/engine.js +6 -8
  40. package/lib/model/strategy/strategy-example.js +19 -19
  41. package/lib/model/strategy/type.d.ts +1 -1
  42. package/lib/modules/Account/index.js +9 -10
  43. package/lib/modules/AccountList/index.js +14 -11
  44. package/lib/modules/BaseModule.js +6 -3
  45. package/lib/modules/Cart/index.js +14 -9
  46. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  47. package/lib/modules/Customer/constants.js +1 -1
  48. package/lib/modules/Customer/index.js +18 -15
  49. package/lib/modules/Customer/types.d.ts +1 -1
  50. package/lib/modules/Date/index.js +10 -6
  51. package/lib/modules/Date/types.js +1 -0
  52. package/lib/modules/Discount/index.js +11 -6
  53. package/lib/modules/Discount/types.d.ts +1 -1
  54. package/lib/modules/Guests/index.js +10 -15
  55. package/lib/modules/Order/index.js +10 -7
  56. package/lib/modules/Payment/cash.js +1 -1
  57. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  58. package/lib/modules/Payment/eftpos.js +1 -1
  59. package/lib/modules/Payment/index.js +86 -73
  60. package/lib/modules/Payment/types.d.ts +7 -7
  61. package/lib/modules/Payment/utils.js +3 -6
  62. package/lib/modules/Payment/walletpass.js +33 -33
  63. package/lib/modules/Product/index.d.ts +1 -1
  64. package/lib/modules/Product/index.js +6 -5
  65. package/lib/modules/ProductList/index.js +5 -3
  66. package/lib/modules/Resource/index.js +8 -12
  67. package/lib/modules/Rules/index.js +24 -36
  68. package/lib/modules/Rules/types.d.ts +1 -1
  69. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  70. package/lib/modules/Schedule/index.js +8 -5
  71. package/lib/modules/Schedule/type.d.ts +7 -7
  72. package/lib/modules/Schedule/types.d.ts +9 -9
  73. package/lib/modules/Schedule/utils.js +2 -4
  74. package/lib/modules/Step/index.js +7 -4
  75. package/lib/modules/Summary/index.js +9 -4
  76. package/lib/modules/Summary/utils.js +8 -16
  77. package/lib/plugins/request.js +34 -33
  78. package/lib/plugins/window.js +101 -113
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingByStep/index.js +110 -177
  81. package/lib/solution/BookingByStep/utils/capacity.js +10 -15
  82. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  83. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  84. package/lib/solution/BookingByStep/utils/stock.js +3 -6
  85. package/lib/solution/BookingByStep/utils/timeslots.js +26 -31
  86. package/lib/solution/BookingTicket/index.d.ts +1 -1
  87. package/lib/solution/BookingTicket/index.js +19 -14
  88. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  89. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  90. package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
  91. package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
  92. package/lib/solution/BuyTickets/index.js +15 -15
  93. package/lib/solution/Checkout/index.js +216 -211
  94. package/lib/solution/Checkout/utils/index.js +18 -22
  95. package/lib/solution/RegisterAndLogin/config.js +2 -2
  96. package/lib/solution/RegisterAndLogin/index.js +114 -110
  97. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  98. package/lib/solution/ShopDiscount/index.js +16 -13
  99. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  100. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  101. package/lib/solution/ShopDiscount/utils.js +1 -2
  102. package/lib/types/index.d.ts +1 -1
  103. package/lib/utils/task.d.ts +2 -2
  104. package/lib/utils/task.js +3 -3
  105. package/lib/utils/watch.d.ts +2 -2
  106. package/lib/utils/watch.js +5 -7
  107. package/package.json +16 -17
@@ -25,10 +25,8 @@ __export(adapter_exports, {
25
25
  module.exports = __toCommonJS(adapter_exports);
26
26
  var import_type = require("./type");
27
27
  var ItemRuleAdapter = class {
28
- constructor() {
29
- this.name = "ItemRuleAdapter";
30
- this.version = "1.0.0";
31
- }
28
+ name = "ItemRuleAdapter";
29
+ version = "1.0.0";
32
30
  prepareContext(businessData) {
33
31
  const { pax, cartItems, serviceType, submissionIndex, custom } = businessData;
34
32
  return {
@@ -79,8 +77,7 @@ var ItemRuleAdapter = class {
79
77
  // ============================================
80
78
  processQuantityCheck(action, businessData) {
81
79
  const config = action.config;
82
- if (!config)
83
- return null;
80
+ if (!config) return null;
84
81
  const { scope, quantityRules, targetType, targets, validationMessage } = config;
85
82
  if (!this.shouldEvaluateForScope(scope, businessData.submissionIndex ?? 0)) {
86
83
  return null;
@@ -228,8 +225,7 @@ var ItemRuleAdapter = class {
228
225
  * 格式化校验提示语,替换 {min} {max} 占位符
229
226
  */
230
227
  formatValidationMessage(template, min, max, exact, locale) {
231
- if (!template)
232
- return void 0;
228
+ if (!template) return void 0;
233
229
  let text = typeof template === "string" ? template : template[locale || "en"] || Object.values(template)[0] || "";
234
230
  text = text.replace(/\{min\}/g, String(min ?? ""));
235
231
  text = text.replace(/\{max\}/g, String(max ?? ""));
@@ -248,8 +244,7 @@ var ItemRuleAdapter = class {
248
244
  */
249
245
  extractQuantityLimits(action, businessData) {
250
246
  const config = action.config;
251
- if (!config)
252
- return null;
247
+ if (!config) return null;
253
248
  const { scope, quantityRules, targetType, targets, validationMessage } = config;
254
249
  if (!this.shouldEvaluateForScope(scope, businessData.submissionIndex ?? 0)) {
255
250
  return null;
@@ -338,13 +333,11 @@ var ItemRuleAdapter = class {
338
333
  // ============================================
339
334
  processPrefillCart(action, businessData) {
340
335
  const config = action.config;
341
- if (!(config == null ? void 0 : config.products))
342
- return [];
336
+ if (!(config == null ? void 0 : config.products)) return [];
343
337
  const results = [];
344
338
  for (const prefillProduct of config.products) {
345
339
  const quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
346
- if (quantity <= 0)
347
- continue;
340
+ if (quantity <= 0) continue;
348
341
  results.push({
349
342
  ruleId: action.id,
350
343
  product_id: prefillProduct.product_id,
@@ -26,8 +26,10 @@ var import_engine = require("../../engine");
26
26
  var import_adapter = require("./adapter");
27
27
  var import_type = require("./type");
28
28
  var ItemRuleEvaluator = class {
29
+ engine;
30
+ adapter;
31
+ strategyConfigs = [];
29
32
  constructor() {
30
- this.strategyConfigs = [];
31
33
  this.engine = new import_engine.StrategyEngine({
32
34
  debug: false,
33
35
  enableTrace: false
@@ -87,11 +89,9 @@ var ItemRuleEvaluator = class {
87
89
  const context = this.adapter.prepareContext(businessData);
88
90
  for (const config of configs) {
89
91
  const evalResult = this.engine.evaluate(config, context);
90
- if (!evalResult.applicable)
91
- continue;
92
+ if (!evalResult.applicable) continue;
92
93
  for (const action of evalResult.matchedActions) {
93
- if (action.type !== import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK)
94
- continue;
94
+ if (action.type !== import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK) continue;
95
95
  const limit = this.adapter.extractQuantityLimits(action, businessData);
96
96
  if (limit) {
97
97
  results.push(limit);
@@ -33,12 +33,12 @@ var MIN_CONDIMENT_PER_PERSON_STRATEGY = {
33
33
  metadata: {
34
34
  id: "RULE_MIN_CONDIMENT_PER_PERSON",
35
35
  name: {
36
- "zh-CN": "每人至少一份小料",
36
+ "zh-CN": "\u6BCF\u4EBA\u81F3\u5C11\u4E00\u4EFD\u5C0F\u6599",
37
37
  en: "Min 1 Condiment per person"
38
38
  },
39
39
  type: "item_rule",
40
40
  description: {
41
- "zh-CN": "火锅小料数量不少于成人人数,自动添加",
41
+ "zh-CN": "\u706B\u9505\u5C0F\u6599\u6570\u91CF\u4E0D\u5C11\u4E8E\u6210\u4EBA\u4EBA\u6570\uFF0C\u81EA\u52A8\u6DFB\u52A0",
42
42
  en: "Condiment count must be at least adult pax, auto-added to cart"
43
43
  }
44
44
  },
@@ -62,7 +62,7 @@ var MIN_CONDIMENT_PER_PERSON_STRATEGY = {
62
62
  ],
63
63
  scope: "first_submission_only",
64
64
  validationMessage: {
65
- "zh-CN": "小料至少需要 {min} 份(每位成人一份)",
65
+ "zh-CN": "\u5C0F\u6599\u81F3\u5C11\u9700\u8981 {min} \u4EFD\uFF08\u6BCF\u4F4D\u6210\u4EBA\u4E00\u4EFD\uFF09",
66
66
  en: "Condiment requires at least {min} items (one per adult)"
67
67
  }
68
68
  }
@@ -88,12 +88,12 @@ var MAX_BUNS_PER_TABLE_STRATEGY = {
88
88
  metadata: {
89
89
  id: "RULE_MAX_BUNS_PER_TABLE",
90
90
  name: {
91
- "zh-CN": "每桌限量供应3份包子",
91
+ "zh-CN": "\u6BCF\u684C\u9650\u91CF\u4F9B\u5E943\u4EFD\u5305\u5B50",
92
92
  en: "3 Buns limit per table"
93
93
  },
94
94
  type: "item_rule",
95
95
  description: {
96
- "zh-CN": "肉包和菜包合计每桌不超过3份,含加单累计",
96
+ "zh-CN": "\u8089\u5305\u548C\u83DC\u5305\u5408\u8BA1\u6BCF\u684C\u4E0D\u8D85\u8FC73\u4EFD\uFF0C\u542B\u52A0\u5355\u7D2F\u8BA1",
97
97
  en: "Max 3 buns per table (pork + veggie combined, cumulative)"
98
98
  }
99
99
  },
@@ -120,7 +120,7 @@ var MAX_BUNS_PER_TABLE_STRATEGY = {
120
120
  ],
121
121
  scope: "cumulative",
122
122
  validationMessage: {
123
- "zh-CN": "包子每桌限量 {max} 份(含加单累计)",
123
+ "zh-CN": "\u5305\u5B50\u6BCF\u684C\u9650\u91CF {max} \u4EFD\uFF08\u542B\u52A0\u5355\u7D2F\u8BA1\uFF09",
124
124
  en: "Buns are limited to {max} per table (cumulative)"
125
125
  }
126
126
  }
@@ -131,12 +131,12 @@ var HOTPOT_BASE_REQUIRED_STRATEGY = {
131
131
  metadata: {
132
132
  id: "RULE_HOTPOT_BASE_REQUIRED",
133
133
  name: {
134
- "zh-CN": "锅底必选",
134
+ "zh-CN": "\u9505\u5E95\u5FC5\u9009",
135
135
  en: "Hotpot base required"
136
136
  },
137
137
  type: "item_rule",
138
138
  description: {
139
- "zh-CN": "堂食必须选择一个锅底",
139
+ "zh-CN": "\u5802\u98DF\u5FC5\u987B\u9009\u62E9\u4E00\u4E2A\u9505\u5E95",
140
140
  en: "Hotpot base is mandatory for dine-in"
141
141
  }
142
142
  },
@@ -168,7 +168,7 @@ var HOTPOT_BASE_REQUIRED_STRATEGY = {
168
168
  ],
169
169
  scope: "first_submission_only",
170
170
  validationMessage: {
171
- "zh-CN": "请选择 {exact} 个锅底",
171
+ "zh-CN": "\u8BF7\u9009\u62E9 {exact} \u4E2A\u9505\u5E95",
172
172
  en: "Please select exactly {exact} hotpot base"
173
173
  }
174
174
  }
@@ -195,12 +195,12 @@ var HOTPOT_BASE_PICK_ONE_STRATEGY = {
195
195
  metadata: {
196
196
  id: "RULE_HOTPOT_BASE_PICK_ONE",
197
197
  name: {
198
- "zh-CN": "锅底必选(四选一)",
198
+ "zh-CN": "\u9505\u5E95\u5FC5\u9009\uFF08\u56DB\u9009\u4E00\uFF09",
199
199
  en: "Hotpot base required (pick any)"
200
200
  },
201
201
  type: "item_rule",
202
202
  description: {
203
- "zh-CN": "4 款锅底任选至少 1 ",
203
+ "zh-CN": "4 \u6B3E\u9505\u5E95\u4EFB\u9009\u81F3\u5C11 1 \u4EFD",
204
204
  en: "Pick at least 1 hotpot base from the available options"
205
205
  }
206
206
  },
@@ -229,7 +229,7 @@ var HOTPOT_BASE_PICK_ONE_STRATEGY = {
229
229
  ],
230
230
  scope: "first_submission_only",
231
231
  validationMessage: {
232
- "zh-CN": "请至少选择 {min} 款锅底",
232
+ "zh-CN": "\u8BF7\u81F3\u5C11\u9009\u62E9 {min} \u6B3E\u9505\u5E95",
233
233
  en: "Please select at least {min} hotpot base"
234
234
  }
235
235
  }
@@ -5,7 +5,7 @@ export declare const ITEM_RULE_ACTION_TYPES: {
5
5
  /** 预填购物车 */
6
6
  readonly PREFILL_CART: "PREFILL_CART";
7
7
  };
8
- export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
8
+ export declare type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
9
9
  export declare const ITEM_RULE_TEMPLATES: {
10
10
  /** 空白规则 */
11
11
  readonly BLANK: "blank";
@@ -16,15 +16,15 @@ export declare const ITEM_RULE_TEMPLATES: {
16
16
  /** 必选商品 */
17
17
  readonly MUST_INCLUDE: "must_include";
18
18
  };
19
- export type ItemRuleTemplate = (typeof ITEM_RULE_TEMPLATES)[keyof typeof ITEM_RULE_TEMPLATES];
19
+ export declare type ItemRuleTemplate = (typeof ITEM_RULE_TEMPLATES)[keyof typeof ITEM_RULE_TEMPLATES];
20
20
  /** 数量比较类型 */
21
- export type QuantityComparison = 'minimum' | 'maximum' | 'exact' | 'must_include';
21
+ export declare type QuantityComparison = 'minimum' | 'maximum' | 'exact' | 'must_include';
22
22
  /** 数量来源 */
23
- export type QuantitySource = 'total_pax' | 'adult_pax' | 'fixed';
23
+ export declare type QuantitySource = 'total_pax' | 'adult_pax' | 'fixed';
24
24
  /** 目标类型(当前仅支持按商品) */
25
- export type TargetType = 'product';
25
+ export declare type TargetType = 'product';
26
26
  /** 作用范围 */
27
- export type RuleScope = 'each_submission' | 'first_submission_only' | 'subsequent_only' | 'cumulative';
27
+ export declare type RuleScope = 'each_submission' | 'first_submission_only' | 'subsequent_only' | 'cumulative';
28
28
  /**
29
29
  * 单条数量规则
30
30
  *
@@ -25,10 +25,8 @@ __export(adapter_exports, {
25
25
  module.exports = __toCommonJS(adapter_exports);
26
26
  var import_type = require("./type");
27
27
  var PromotionAdapter = class {
28
- constructor() {
29
- this.name = "PromotionAdapter";
30
- this.version = "1.0.0";
31
- }
28
+ name = "PromotionAdapter";
29
+ version = "1.0.0";
32
30
  /**
33
31
  * 准备运行时上下文
34
32
  *
@@ -43,21 +43,23 @@ var defaultLocales = {
43
43
  product_not_in_promotion: "Product not in promotion scope"
44
44
  },
45
45
  "zh-CN": {
46
- no_applicable_promotion: "无适用的促销活动",
47
- promotion_not_in_time_range: "促销活动不在有效时间范围内",
48
- product_not_in_promotion: "商品不在促销范围内"
46
+ no_applicable_promotion: "\u65E0\u9002\u7528\u7684\u4FC3\u9500\u6D3B\u52A8",
47
+ promotion_not_in_time_range: "\u4FC3\u9500\u6D3B\u52A8\u4E0D\u5728\u6709\u6548\u65F6\u95F4\u8303\u56F4\u5185",
48
+ product_not_in_promotion: "\u5546\u54C1\u4E0D\u5728\u4FC3\u9500\u8303\u56F4\u5185"
49
49
  },
50
50
  "zh-HK": {
51
- no_applicable_promotion: "無適用的促銷活動",
52
- promotion_not_in_time_range: "促銷活動不在有效時間範圍內",
53
- product_not_in_promotion: "商品不在促銷範圍內"
51
+ no_applicable_promotion: "\u7121\u9069\u7528\u7684\u4FC3\u92B7\u6D3B\u52D5",
52
+ promotion_not_in_time_range: "\u4FC3\u92B7\u6D3B\u52D5\u4E0D\u5728\u6709\u6548\u6642\u9593\u7BC4\u570D\u5167",
53
+ product_not_in_promotion: "\u5546\u54C1\u4E0D\u5728\u4FC3\u92B7\u7BC4\u570D\u5167"
54
54
  }
55
55
  };
56
56
  var PromotionEvaluator = class {
57
+ engine;
58
+ adapter;
59
+ strategyConfigs = [];
60
+ locale = "en";
61
+ locales = defaultLocales;
57
62
  constructor() {
58
- this.strategyConfigs = [];
59
- this.locale = "en";
60
- this.locales = defaultLocales;
61
63
  this.engine = new import_engine.StrategyEngine({
62
64
  debug: false,
63
65
  enableTrace: false
@@ -506,8 +508,7 @@ var PromotionEvaluator = class {
506
508
  const key = this.getProductKey(product);
507
509
  const processedQty = processedQuantityMap.get(key) || 0;
508
510
  const availableQty = product.quantity - processedQty;
509
- if (availableQty <= 0)
510
- continue;
511
+ if (availableQty <= 0) continue;
511
512
  for (let i = 0; i < availableQty; i++) {
512
513
  unitProducts.push({
513
514
  product,
@@ -523,8 +524,7 @@ var PromotionEvaluator = class {
523
524
  unitProducts.sort((a, b) => {
524
525
  const aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
525
526
  const bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
526
- if (aIsMultiple !== bIsMultiple)
527
- return bIsMultiple - aIsMultiple;
527
+ if (aIsMultiple !== bIsMultiple) return bIsMultiple - aIsMultiple;
528
528
  return b.price - a.price;
529
529
  });
530
530
  const totalUnits = unitProducts.length;
@@ -569,8 +569,7 @@ var PromotionEvaluator = class {
569
569
  const key = this.getProductKey(product);
570
570
  const processedQty = processedQuantityMap.get(key) || 0;
571
571
  const availableQty = product.quantity - processedQty;
572
- if (availableQty <= 0)
573
- continue;
572
+ if (availableQty <= 0) continue;
574
573
  const promoQty = promotionQtyByProductId.get(product.id) || 0;
575
574
  const remainingQty = remainingQtyByProductId.get(product.id) || 0;
576
575
  const allocatedPrices = allocatedPricesByProductId.get(product.id) || [];
@@ -716,8 +715,7 @@ var PromotionEvaluator = class {
716
715
  const key = this.getProductKey(product);
717
716
  const processedQty = processedQuantityMap.get(key) || 0;
718
717
  const availableQty = product.quantity - processedQty;
719
- if (availableQty <= 0)
720
- continue;
718
+ if (availableQty <= 0) continue;
721
719
  const matchedBundleIndex = matchedBundleIndexMap == null ? void 0 : matchedBundleIndexMap.get(product.id);
722
720
  let promoQty = availableQty;
723
721
  if (matchedBundleIndex !== void 0 && product.bundle) {
@@ -731,8 +729,7 @@ var PromotionEvaluator = class {
731
729
  for (const product of groupProducts) {
732
730
  const key = this.getProductKey(product);
733
731
  const info = productInfoMap.get(key);
734
- if (!info || info.availableQty <= 0)
735
- continue;
732
+ if (!info || info.availableQty <= 0) continue;
736
733
  const processedQty = processedQuantityMap.get(key) || 0;
737
734
  result.push({
738
735
  ...product,
@@ -28,8 +28,8 @@ var X_ITEMS_FOR_Y_PRICE_STRATEGY = {
28
28
  id: "STRATEGY_001",
29
29
  name: {
30
30
  en: "2 items for $10",
31
- "zh-CN": "2杯10元",
32
- "zh-HK": "2杯10元"
31
+ "zh-CN": "2\u676F10\u5143",
32
+ "zh-HK": "2\u676F10\u5143"
33
33
  },
34
34
  type: "promotion",
35
35
  custom: {
@@ -37,8 +37,8 @@ var X_ITEMS_FOR_Y_PRICE_STRATEGY = {
37
37
  product_card: {
38
38
  text: {
39
39
  en: "2 for $10",
40
- "zh-CN": "2杯10元",
41
- "zh-HK": "2杯10元"
40
+ "zh-CN": "2\u676F10\u5143",
41
+ "zh-HK": "2\u676F10\u5143"
42
42
  },
43
43
  type: "tag"
44
44
  }
@@ -107,8 +107,8 @@ var BUY_X_GET_Y_FREE_STRATEGY = {
107
107
  id: "STRATEGY_002",
108
108
  name: {
109
109
  en: "Buy 1 Get 1 Free",
110
- "zh-CN": "买1送1",
111
- "zh-HK": "買1送1"
110
+ "zh-CN": "\u4E701\u90011",
111
+ "zh-HK": "\u8CB71\u90011"
112
112
  },
113
113
  type: "promotion",
114
114
  custom: {
@@ -116,8 +116,8 @@ var BUY_X_GET_Y_FREE_STRATEGY = {
116
116
  product_card: {
117
117
  text: {
118
118
  en: "Buy 1 Get 1",
119
- "zh-CN": "买1送1",
120
- "zh-HK": "買1送1"
119
+ "zh-CN": "\u4E701\u90011",
120
+ "zh-HK": "\u8CB71\u90011"
121
121
  },
122
122
  type: "tag"
123
123
  }
@@ -17,7 +17,7 @@ export declare const PROMOTION_ACTION_TYPES: {
17
17
  /** 固定减价 */
18
18
  readonly DEDUCT_AMOUNT: "DEDUCT_AMOUNT";
19
19
  };
20
- export type PromotionActionType = (typeof PROMOTION_ACTION_TYPES)[keyof typeof PROMOTION_ACTION_TYPES];
20
+ export declare type PromotionActionType = (typeof PROMOTION_ACTION_TYPES)[keyof typeof PROMOTION_ACTION_TYPES];
21
21
  /**
22
22
  * X件Y元 - Action Value
23
23
  *
@@ -54,7 +54,7 @@ export interface BuyXGetYFreeValue {
54
54
  /**
55
55
  * 赠品选择模式
56
56
  */
57
- export type GiftSelectionMode = 'user_select' | 'auto' | 'cheapest';
57
+ export declare type GiftSelectionMode = 'user_select' | 'auto' | 'cheapest';
58
58
  /**
59
59
  * 买X送Y - Action Config
60
60
  */
@@ -105,7 +105,7 @@ export interface BuyXGetYFreeAction extends Omit<ActionEffect, 'type' | 'value'
105
105
  /**
106
106
  * 促销活动 Action 联合类型
107
107
  */
108
- export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction;
108
+ export declare type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction;
109
109
  /**
110
110
  * 促销相关运算符
111
111
  */
@@ -135,7 +135,7 @@ export interface PromotionBusinessData {
135
135
  /** 自定义属性 */
136
136
  custom?: Record<string, any>;
137
137
  }
138
- type ProductBundleItem = {
138
+ declare type ProductBundleItem = {
139
139
  /** 主商品ID */
140
140
  product_id: number;
141
141
  /** 变体ID(0 表示无变体) */
@@ -195,7 +195,7 @@ export interface PromotionTransformResult {
195
195
  /**
196
196
  * Action 详情联合类型
197
197
  */
198
- export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail;
198
+ export declare type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail;
199
199
  /**
200
200
  * X件Y元 Action 详情
201
201
  */
@@ -55,17 +55,17 @@ var AMOUNT_FIELDS = /* @__PURE__ */ new Set([
55
55
  "applicableProductTotalAmount"
56
56
  ]);
57
57
  function formatReason(template, value, currency = "") {
58
- if (!template)
59
- return template;
58
+ if (!template) return template;
60
59
  const v = value === void 0 || value === null ? "" : String(value);
61
60
  const c = currency === void 0 || currency === null ? "" : String(currency);
62
61
  return template.replace(/\$\{value\}/g, () => v).replace(/\{value\}/g, () => v).replace(/\{currency\}/g, () => c);
63
62
  }
64
63
  var WalletPassEvaluator = class {
64
+ engine;
65
+ strategyConfigs = [];
66
+ locale = "en";
67
+ otherParams = {};
65
68
  constructor() {
66
- this.strategyConfigs = [];
67
- this.locale = "en";
68
- this.otherParams = {};
69
69
  this.engine = new import__.StrategyEngine({
70
70
  debug: false,
71
71
  enableTrace: false
@@ -5,13 +5,13 @@ var products = [
5
5
  product_id: 60734,
6
6
  price: 80,
7
7
  quantity: 1,
8
- name: "商品A"
8
+ name: "\u5546\u54C1A"
9
9
  },
10
10
  {
11
11
  product_id: 60735,
12
12
  price: 50,
13
13
  quantity: 2,
14
- name: "商品B"
14
+ name: "\u5546\u54C1B"
15
15
  }
16
16
  ];
17
17
  var vouchers = [
@@ -39,7 +39,7 @@ var strategyConfigs = [
39
39
  {
40
40
  metadata: {
41
41
  id: "STRATEGY_001",
42
- name: "满100减10",
42
+ name: "\u6EE1100\u51CF10",
43
43
  type: "wallet_pass",
44
44
  custom: {
45
45
  maxDeductionAmount: 10,
@@ -86,7 +86,7 @@ var strategyConfigs = [
86
86
  {
87
87
  metadata: {
88
88
  id: "STRATEGY_002",
89
- name: "满150减20",
89
+ name: "\u6EE1150\u51CF20",
90
90
  type: "wallet_pass",
91
91
  custom: {
92
92
  maxDeductionAmount: 20,
@@ -127,7 +127,7 @@ var strategyConfigs = [
127
127
  {
128
128
  metadata: {
129
129
  id: "STRATEGY_003",
130
- name: "满200减50",
130
+ name: "\u6EE1200\u51CF50",
131
131
  type: "wallet_pass",
132
132
  custom: {
133
133
  maxDeductionAmount: 50,
@@ -166,7 +166,7 @@ var strategyConfigs = [
166
166
  }
167
167
  ];
168
168
  function runExample() {
169
- console.log("========== WalletPass 评估器示例 ==========\n");
169
+ console.log("========== WalletPass \u8BC4\u4F30\u5668\u793A\u4F8B ==========\n");
170
170
  const evaluator = new import_evaluator.WalletPassEvaluator();
171
171
  const results = evaluator.evaluate({
172
172
  orderTotalAmount: 180,
@@ -174,33 +174,33 @@ function runExample() {
174
174
  vouchers,
175
175
  strategyConfigs
176
176
  });
177
- console.log("订单信息:");
178
- console.log(`- 总金额: ${180} 元`);
179
- console.log(`- 商品: ${products.map((p) => `${p.name}(${p.quantity})`).join(", ")}
177
+ console.log("\u8BA2\u5355\u4FE1\u606F\uFF1A");
178
+ console.log(`- \u603B\u91D1\u989D: ${180} \u5143`);
179
+ console.log(`- \u5546\u54C1: ${products.map((p) => `${p.name}(${p.quantity}\u4EF6)`).join(", ")}
180
180
  `);
181
- console.log("评估结果:\n");
181
+ console.log("\u8BC4\u4F30\u7ED3\u679C\uFF1A\n");
182
182
  results.forEach((result, index) => {
183
183
  console.log(`Voucher ${index + 1}: ${result.voucher.id}`);
184
- console.log(` 面额: ${result.voucher.amount} 元`);
185
- console.log(` 可用: ${result.isApplicable ? " " : " "}`);
184
+ console.log(` \u9762\u989D: ${result.voucher.amount} \u5143`);
185
+ console.log(` \u53EF\u7528: ${result.isApplicable ? "\u2705 \u662F" : "\u274C \u5426"}`);
186
186
  if (result.isApplicable) {
187
- console.log(` 最大抵扣: ${result.maxDeduction} 元`);
188
- console.log(` 每单可用: ${result.canUseCount} 张`);
189
- console.log(` 抵扣税费: ${result.deductTaxAndFee ? "" : ""}`);
190
- console.log(` 适用商品: ${result.applicableProductIds.join(", ")}`);
187
+ console.log(` \u6700\u5927\u62B5\u6263: ${result.maxDeduction} \u5143`);
188
+ console.log(` \u6BCF\u5355\u53EF\u7528: ${result.canUseCount} \u5F20`);
189
+ console.log(` \u62B5\u6263\u7A0E\u8D39: ${result.deductTaxAndFee ? "\u662F" : "\u5426"}`);
190
+ console.log(` \u9002\u7528\u5546\u54C1: ${result.applicableProductIds.join(", ")}`);
191
191
  } else {
192
- console.log(` 原因: ${result.reason}`);
193
- console.log(` 原因码: ${result.reasonCode}`);
192
+ console.log(` \u539F\u56E0: ${result.reason}`);
193
+ console.log(` \u539F\u56E0\u7801: ${result.reasonCode}`);
194
194
  }
195
195
  console.log("");
196
196
  });
197
197
  const availableVouchers = results.filter((r) => r.isApplicable);
198
198
  console.log(`
199
- ${availableVouchers.length} 张可用`);
199
+ \u5171 ${availableVouchers.length} \u5F20\u53EF\u7528`);
200
200
  if (availableVouchers.length > 0) {
201
- console.log("可用 voucher ID:");
201
+ console.log("\u53EF\u7528 voucher ID:");
202
202
  availableVouchers.forEach((v) => {
203
- console.log(` - ${v.voucher.id}: 最多抵扣 ${v.maxDeduction} 元`);
203
+ console.log(` - ${v.voucher.id}: \u6700\u591A\u62B5\u6263 ${v.maxDeduction} \u5143`);
204
204
  });
205
205
  }
206
206
  }
@@ -24,10 +24,8 @@ __export(walletPass_exports, {
24
24
  module.exports = __toCommonJS(walletPass_exports);
25
25
  var import_utils = require("./utils");
26
26
  var WalletPassAdapter = class {
27
- constructor() {
28
- this.name = "WalletPassAdapter";
29
- this.version = "1.0.0";
30
- }
27
+ name = "WalletPassAdapter";
28
+ version = "1.0.0";
31
29
  /**
32
30
  * 准备运行时上下文
33
31
  * 将业务数据转换为策略引擎可识别的 RuntimeContext
@@ -24,15 +24,15 @@ __export(locales_exports, {
24
24
  module.exports = __toCommonJS(locales_exports);
25
25
  var locales = {
26
26
  "zh-CN": {
27
- "not_meet_the_required_conditions": "未达到使用条件",
28
- "exceeds_the_maximum_deduction_limit": "超出最大抵扣金额限制",
29
- "usage_limit_reached": "已达到使用次数上限",
30
- "max_passes_per_item_reached": "该商品已达到卡券使用上限",
31
- "not_available_for_this_channel": "当前渠道不可使用",
32
- "not_valid_for_this_order_type": "当前订单类型不适用",
33
- "order_total_amount_not_enough": " {currency}{value} 可用",
34
- "applicable_product_total_amount_not_enough": " {currency}{value} 可用",
35
- "applicable_product_count_not_enough": "至少 {value} "
27
+ "not_meet_the_required_conditions": "\u672A\u8FBE\u5230\u4F7F\u7528\u6761\u4EF6",
28
+ "exceeds_the_maximum_deduction_limit": "\u8D85\u51FA\u6700\u5927\u62B5\u6263\u91D1\u989D\u9650\u5236",
29
+ "usage_limit_reached": "\u5DF2\u8FBE\u5230\u4F7F\u7528\u6B21\u6570\u4E0A\u9650",
30
+ "max_passes_per_item_reached": "\u8BE5\u5546\u54C1\u5DF2\u8FBE\u5230\u5361\u5238\u4F7F\u7528\u4E0A\u9650",
31
+ "not_available_for_this_channel": "\u5F53\u524D\u6E20\u9053\u4E0D\u53EF\u4F7F\u7528",
32
+ "not_valid_for_this_order_type": "\u5F53\u524D\u8BA2\u5355\u7C7B\u578B\u4E0D\u9002\u7528",
33
+ "order_total_amount_not_enough": "\u6EE1 {currency}{value} \u53EF\u7528",
34
+ "applicable_product_total_amount_not_enough": "\u6EE1 {currency}{value} \u53EF\u7528",
35
+ "applicable_product_count_not_enough": "\u81F3\u5C11 {value} \u4EF6"
36
36
  },
37
37
  "en": {
38
38
  "not_meet_the_required_conditions": "Not meet the required conditions.",
@@ -46,15 +46,15 @@ var locales = {
46
46
  "applicable_product_count_not_enough": "Min. Qty {value}"
47
47
  },
48
48
  "zh-HK": {
49
- "not_meet_the_required_conditions": "未達使用條件",
50
- "exceeds_the_maximum_deduction_limit": "超出最大抵扣金額限制",
51
- "usage_limit_reached": "已達使用次數上限",
52
- "max_passes_per_item_reached": "該商品已達卡券使用上限",
53
- "not_available_for_this_channel": "當前渠道不可使用",
54
- "not_valid_for_this_order_type": "當前訂單類型不適用",
55
- "order_total_amount_not_enough": "滿 {currency}{value} 可用",
56
- "applicable_product_total_amount_not_enough": "滿 {currency}{value} 可用",
57
- "applicable_product_count_not_enough": "至少 {value} "
49
+ "not_meet_the_required_conditions": "\u672A\u9054\u4F7F\u7528\u689D\u4EF6",
50
+ "exceeds_the_maximum_deduction_limit": "\u8D85\u51FA\u6700\u5927\u62B5\u6263\u91D1\u984D\u9650\u5236",
51
+ "usage_limit_reached": "\u5DF2\u9054\u4F7F\u7528\u6B21\u6578\u4E0A\u9650",
52
+ "max_passes_per_item_reached": "\u8A72\u5546\u54C1\u5DF2\u9054\u5361\u5238\u4F7F\u7528\u4E0A\u9650",
53
+ "not_available_for_this_channel": "\u7576\u524D\u6E20\u9053\u4E0D\u53EF\u4F7F\u7528",
54
+ "not_valid_for_this_order_type": "\u7576\u524D\u8A02\u55AE\u985E\u578B\u4E0D\u9069\u7528",
55
+ "order_total_amount_not_enough": "\u6EFF {currency}{value} \u53EF\u7528",
56
+ "applicable_product_total_amount_not_enough": "\u6EFF {currency}{value} \u53EF\u7528",
57
+ "applicable_product_count_not_enough": "\u81F3\u5C11 {value} \u4EF6"
58
58
  }
59
59
  };
60
60
  // Annotate the CommonJS export names for ESM import in node: