@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
@@ -53,35 +53,28 @@ var getProductQuantity = (product) => {
53
53
  function resolveWalletPassLineKey(product, indexInOrder) {
54
54
  const m = (product == null ? void 0 : product.metadata) || {};
55
55
  const u1 = m.product_unique;
56
- if (u1 != null && String(u1).length > 0)
57
- return String(u1);
56
+ if (u1 != null && String(u1).length > 0) return String(u1);
58
57
  const u2 = m.unique_identification_number;
59
- if (u2 != null && String(u2).length > 0)
60
- return String(u2);
61
- if ((product == null ? void 0 : product.id) != null && String(product.id).length > 0)
62
- return `order_item:${product.id}`;
58
+ if (u2 != null && String(u2).length > 0) return String(u2);
59
+ if ((product == null ? void 0 : product.id) != null && String(product.id).length > 0) return `order_item:${product.id}`;
63
60
  if ((product == null ? void 0 : product.product_unique_string) != null && String(product.product_unique_string).length > 0) {
64
61
  return String(product.product_unique_string);
65
62
  }
66
63
  return `order_line_${indexInOrder}`;
67
64
  }
68
65
  function getExpandedOrderLineQuantity(p) {
69
- if ((p == null ? void 0 : p._orderLineQuantity) != null && p._orderLineQuantity > 0)
70
- return p._orderLineQuantity;
66
+ if ((p == null ? void 0 : p._orderLineQuantity) != null && p._orderLineQuantity > 0) return p._orderLineQuantity;
71
67
  return getProductQuantity(p);
72
68
  }
73
69
  function getMaxPassSlotsForExpandedLine(maxPassesPerItem, p) {
74
- if (maxPassesPerItem <= 0)
75
- return Infinity;
70
+ if (maxPassesPerItem <= 0) return Infinity;
76
71
  return maxPassesPerItem * getExpandedOrderLineQuantity(p);
77
72
  }
78
73
  function computePassSlotsIncrement(deductAmount, deductQty, maxPassesPerItem, orderLineQuantity, currentUsage) {
79
- if (maxPassesPerItem <= 0 || !deductAmount.greaterThan(0))
80
- return 0;
74
+ if (maxPassesPerItem <= 0 || !deductAmount.greaterThan(0)) return 0;
81
75
  const cap = maxPassesPerItem * orderLineQuantity;
82
76
  const room = Math.max(0, cap - currentUsage);
83
- if (room <= 0)
84
- return 0;
77
+ if (room <= 0) return 0;
85
78
  const raw = Math.max(1, Math.ceil(Number(deductQty)) || 1);
86
79
  return Math.min(raw, room);
87
80
  }
@@ -89,8 +82,7 @@ function applyMaxPassUsageIncrements(usageMap, walletPassProductId, maxPassesPer
89
82
  deductionDetails.forEach((detail) => {
90
83
  var _a;
91
84
  const lineKey = detail.lineKey;
92
- if (!lineKey || maxPassesPerItem <= 0)
93
- return;
85
+ if (!lineKey || maxPassesPerItem <= 0) return;
94
86
  const orderLineQty = detail.orderLineQuantity != null && detail.orderLineQuantity > 0 ? detail.orderLineQuantity : 1;
95
87
  const cur = ((_a = usageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
96
88
  const inc = computePassSlotsIncrement(
@@ -100,10 +92,8 @@ function applyMaxPassUsageIncrements(usageMap, walletPassProductId, maxPassesPer
100
92
  orderLineQty,
101
93
  cur
102
94
  );
103
- if (inc <= 0)
104
- return;
105
- if (!usageMap.has(walletPassProductId))
106
- usageMap.set(walletPassProductId, /* @__PURE__ */ new Map());
95
+ if (inc <= 0) return;
96
+ if (!usageMap.has(walletPassProductId)) usageMap.set(walletPassProductId, /* @__PURE__ */ new Map());
107
97
  const inner = usageMap.get(walletPassProductId);
108
98
  inner.set(lineKey, cur + inc);
109
99
  });
@@ -157,12 +147,10 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
157
147
  return ((_a = usageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
158
148
  };
159
149
  const filterByMaxPassesPerItem = (products2, usageMap, walletPassProductId, maxPassesPerItem) => {
160
- if (maxPassesPerItem <= 0)
161
- return products2;
150
+ if (maxPassesPerItem <= 0) return products2;
162
151
  return products2.filter((p) => {
163
152
  const lineKey = p._walletPassLineKey;
164
- if (!lineKey)
165
- return true;
153
+ if (!lineKey) return true;
166
154
  return getItemPassUsage(usageMap, walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
167
155
  });
168
156
  };
@@ -189,8 +177,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
189
177
  const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
190
178
  let remainingLimit = applicableProductLimit;
191
179
  for (const product of sortedProducts) {
192
- if (remainingLimit <= 0)
193
- break;
180
+ if (remainingLimit <= 0) break;
194
181
  const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
195
182
  const deductQty = Math.min(currentAvailableQty, remainingLimit);
196
183
  const deductAmount = import_decimal.default.min(
@@ -246,8 +233,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
246
233
  const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
247
234
  const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0)).filter((p) => {
248
235
  const lineKey = p._walletPassLineKey;
249
- if (!lineKey)
250
- return true;
236
+ if (!lineKey) return true;
251
237
  return getItemPassUsage(itemPassUsage, product_id, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
252
238
  });
253
239
  if (availableAfterPassLimit.length === 0) {
@@ -300,8 +286,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
300
286
  productsForRecommendation
301
287
  ).filter((p) => p[amountField].greaterThan(0));
302
288
  applicableProducts = filterByMaxPassesPerItem(applicableProducts, itemPassUsageMap, product_id, maxPassesPerItem);
303
- if (applicableProducts.length === 0)
304
- return false;
289
+ if (applicableProducts.length === 0) return false;
305
290
  const usageAmount = typeof voucher.edit_current_amount === "number" ? voucher.edit_current_amount : getRecommendedAmount(voucher);
306
291
  const baseAmount = import_decimal.default.min(
307
292
  new import_decimal.default(usageAmount),
@@ -313,8 +298,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
313
298
  const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
314
299
  let remainingLimit = applicableProductLimit;
315
300
  for (const product of sortedProducts) {
316
- if (remainingLimit <= 0)
317
- break;
301
+ if (remainingLimit <= 0) break;
318
302
  const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
319
303
  const deductQty = Math.min(currentAvailableQty, remainingLimit);
320
304
  const deductAmount = import_decimal.default.min(
@@ -360,8 +344,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
360
344
  );
361
345
  let remainingLimit = applicableProductLimit > 0 ? applicableProductLimit : Infinity;
362
346
  for (const product of sortedProducts) {
363
- if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
364
- break;
347
+ if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0) break;
365
348
  const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
366
349
  const availableQty = Math.min(currentAvailableQty, remainingLimit);
367
350
  const maxDeductForProduct = import_decimal.default.min(
@@ -462,12 +445,10 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
462
445
  return ((_a = itemPassUsageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
463
446
  };
464
447
  const filterByMaxPassesPerItemRecalc = (products2, walletPassProductId, maxPassesPerItem) => {
465
- if (maxPassesPerItem <= 0)
466
- return products2;
448
+ if (maxPassesPerItem <= 0) return products2;
467
449
  return products2.filter((p) => {
468
450
  const lineKey = p._walletPassLineKey;
469
- if (!lineKey)
470
- return true;
451
+ if (!lineKey) return true;
471
452
  return getItemPassUsageRecalc(walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
472
453
  });
473
454
  };
@@ -506,8 +487,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
506
487
  );
507
488
  let remainingLimit = applicableProductLimit > 0 ? applicableProductLimit : Infinity;
508
489
  for (const product of sortedProducts) {
509
- if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
510
- break;
490
+ if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0) break;
511
491
  const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
512
492
  const availableQty = Math.min(currentAvailableQty, remainingLimit);
513
493
  const maxDeductForProduct = import_decimal.default.min(
@@ -622,8 +602,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
622
602
  const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
623
603
  let remainingLimit = applicableProductLimit;
624
604
  for (const product of sortedProducts) {
625
- if (remainingLimit <= 0)
626
- break;
605
+ if (remainingLimit <= 0) break;
627
606
  const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
628
607
  const deductQty = Math.min(currentAvailableQty, remainingLimit);
629
608
  const deductAmount = import_decimal.default.min(
@@ -26,6 +26,8 @@ __export(engine_exports, {
26
26
  module.exports = __toCommonJS(engine_exports);
27
27
  var import_type = require("./type");
28
28
  var StrategyEngine = class {
29
+ options;
30
+ operatorHandlers;
29
31
  constructor(options = {}) {
30
32
  this.options = {
31
33
  debug: options.debug ?? false,
@@ -367,18 +369,14 @@ var StrategyEngine = class {
367
369
  case "is_not_null":
368
370
  return fieldValue !== null && fieldValue !== void 0;
369
371
  case "is_empty":
370
- if (Array.isArray(fieldValue))
371
- return fieldValue.length === 0;
372
- if (typeof fieldValue === "string")
373
- return fieldValue.length === 0;
372
+ if (Array.isArray(fieldValue)) return fieldValue.length === 0;
373
+ if (typeof fieldValue === "string") return fieldValue.length === 0;
374
374
  if (typeof fieldValue === "object")
375
375
  return Object.keys(fieldValue).length === 0;
376
376
  return !fieldValue;
377
377
  case "is_not_empty":
378
- if (Array.isArray(fieldValue))
379
- return fieldValue.length > 0;
380
- if (typeof fieldValue === "string")
381
- return fieldValue.length > 0;
378
+ if (Array.isArray(fieldValue)) return fieldValue.length > 0;
379
+ if (typeof fieldValue === "string") return fieldValue.length > 0;
382
380
  if (typeof fieldValue === "object")
383
381
  return Object.keys(fieldValue).length > 0;
384
382
  return Boolean(fieldValue);
@@ -26,7 +26,7 @@ var import_index = require("./index");
26
26
  var voucherConfig = {
27
27
  metadata: {
28
28
  id: "VOUCHER_10",
29
- name: "10元代金券",
29
+ name: "10\u5143\u4EE3\u91D1\u5238",
30
30
  type: "wallet_pass",
31
31
  calculationType: "single"
32
32
  },
@@ -70,7 +70,7 @@ var voucherConfig = {
70
70
  type: "DEDUCT_AMOUNT",
71
71
  value: 10,
72
72
  valueType: "number",
73
- valueUnit: "元",
73
+ valueUnit: "\u5143",
74
74
  target: "applicable_products",
75
75
  priority: 1,
76
76
  config: {
@@ -108,7 +108,7 @@ var voucherContext = {
108
108
  var tieredDiscountConfig = {
109
109
  metadata: {
110
110
  id: "TIERED_DISCOUNT",
111
- name: "阶梯满减",
111
+ name: "\u9636\u68AF\u6EE1\u51CF",
112
112
  type: "promotion",
113
113
  calculationType: "single"
114
114
  },
@@ -212,7 +212,7 @@ var tieredContext = {
212
212
  var codeConditionConfig = {
213
213
  metadata: {
214
214
  id: "CODE_CONDITION_EXAMPLE",
215
- name: "代码条件示例",
215
+ name: "\u4EE3\u7801\u6761\u4EF6\u793A\u4F8B",
216
216
  type: "custom"
217
217
  },
218
218
  conditions: {
@@ -257,34 +257,34 @@ var codeContext = {
257
257
  }
258
258
  };
259
259
  function runExamples() {
260
- console.log("====== 策略模型使用示例 ======\n");
260
+ console.log("====== \u7B56\u7565\u6A21\u578B\u4F7F\u7528\u793A\u4F8B ======\n");
261
261
  const engine = (0, import_index.createStrategyEngine)({
262
262
  debug: true,
263
263
  enableTrace: true
264
264
  });
265
- console.log("示例1: 10元代金券");
265
+ console.log("\u793A\u4F8B1: 10\u5143\u4EE3\u91D1\u5238");
266
266
  const result1 = engine.evaluate(voucherConfig, voucherContext);
267
- console.log("结果:", JSON.stringify(result1, null, 2));
267
+ console.log("\u7ED3\u679C:", JSON.stringify(result1, null, 2));
268
268
  console.log("\n");
269
- console.log("示例2: 阶梯满减(订单金额250)");
269
+ console.log("\u793A\u4F8B2: \u9636\u68AF\u6EE1\u51CF\uFF08\u8BA2\u5355\u91D1\u989D250\uFF09");
270
270
  const result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
271
- console.log("结果:", JSON.stringify(result2, null, 2));
271
+ console.log("\u7ED3\u679C:", JSON.stringify(result2, null, 2));
272
272
  console.log("\n");
273
- console.log("示例3: Code 模式条件");
273
+ console.log("\u793A\u4F8B3: Code \u6A21\u5F0F\u6761\u4EF6");
274
274
  const result3 = engine.evaluate(codeConditionConfig, codeContext);
275
- console.log("结果:", JSON.stringify(result3, null, 2));
275
+ console.log("\u7ED3\u679C:", JSON.stringify(result3, null, 2));
276
276
  console.log("\n");
277
- console.log("示例4: 快速评估");
277
+ console.log("\u793A\u4F8B4: \u5FEB\u901F\u8BC4\u4F30");
278
278
  const result4 = (0, import_index.evaluate)(voucherConfig, voucherContext);
279
- console.log("适用:", result4.applicable);
280
- console.log("匹配动作数:", result4.matchedActions.length);
279
+ console.log("\u9002\u7528:", result4.applicable);
280
+ console.log("\u5339\u914D\u52A8\u4F5C\u6570:", result4.matchedActions.length);
281
281
  console.log("\n");
282
- console.log("示例5: 自定义运算符");
282
+ console.log("\u793A\u4F8B5: \u81EA\u5B9A\u4E49\u8FD0\u7B97\u7B26");
283
283
  engine.registerOperator("divisible_by", (fieldValue, compareValue) => {
284
284
  return Number(fieldValue) % Number(compareValue) === 0;
285
285
  });
286
286
  const customOperatorConfig = {
287
- metadata: { id: "CUSTOM_OP", name: "自定义运算符", type: "test" },
287
+ metadata: { id: "CUSTOM_OP", name: "\u81EA\u5B9A\u4E49\u8FD0\u7B97\u7B26", type: "test" },
288
288
  conditions: {
289
289
  operator: "and",
290
290
  rules: [
@@ -305,9 +305,9 @@ function runExamples() {
305
305
  metadata: { timestamp: Date.now() }
306
306
  };
307
307
  const result5 = engine.evaluate(customOperatorConfig, customContext);
308
- console.log("结果:", result5.applicable ? "适用" : "不适用");
309
- console.log("匹配动作:", result5.matchedActions);
310
- console.log("\n引擎调试信息:", engine.getDebugInfo());
308
+ console.log("\u7ED3\u679C:", result5.applicable ? "\u9002\u7528" : "\u4E0D\u9002\u7528");
309
+ console.log("\u5339\u914D\u52A8\u4F5C:", result5.matchedActions);
310
+ console.log("\n\u5F15\u64CE\u8C03\u8BD5\u4FE1\u606F:", engine.getDebugInfo());
311
311
  }
312
312
  if (require.main === module) {
313
313
  runExamples();
@@ -242,4 +242,4 @@ export interface EngineOptions {
242
242
  /**
243
243
  * 运算符处理器
244
244
  */
245
- export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
245
+ export declare type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
@@ -26,16 +26,16 @@ module.exports = __toCommonJS(Account_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
27
  __reExport(Account_exports, require("./types"), module.exports);
28
28
  var AccountModule = class extends import_BaseModule.BaseModule {
29
+ defaultName = "account";
30
+ defaultVersion = "1.0.0";
31
+ isGuest = false;
32
+ store = {
33
+ accountInfo: null,
34
+ isLoggedIn: false,
35
+ active: false
36
+ };
29
37
  constructor(name, version) {
30
38
  super(name, version);
31
- this.defaultName = "account";
32
- this.defaultVersion = "1.0.0";
33
- this.isGuest = false;
34
- this.store = {
35
- accountInfo: null,
36
- isLoggedIn: false,
37
- active: false
38
- };
39
39
  }
40
40
  async initialize(core, options) {
41
41
  this.core = core;
@@ -64,8 +64,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
64
64
  return this.store.accountInfo;
65
65
  }
66
66
  async updateProfile(updates) {
67
- if (!this.store.accountInfo)
68
- return;
67
+ if (!this.store.accountInfo) return;
69
68
  this.store.accountInfo = {
70
69
  ...this.store.accountInfo,
71
70
  ...updates
@@ -28,19 +28,22 @@ var import_BaseModule = require("../BaseModule");
28
28
  var import_types = require("./types");
29
29
  var import_utils = require("./utils");
30
30
  var AccountListModule = class extends import_BaseModule.BaseModule {
31
+ defaultName = "accountList";
32
+ defaultVersion = "1.0.0";
33
+ store = {
34
+ accountList: [],
35
+ // 账号的纯数据列表
36
+ accounts: [],
37
+ // 账号的 module 列表
38
+ isLoading: false,
39
+ error: null
40
+ };
41
+ request;
42
+ cacheId;
43
+ openCache = false;
44
+ fatherModule;
31
45
  constructor(name, version) {
32
46
  super(name, version);
33
- this.defaultName = "accountList";
34
- this.defaultVersion = "1.0.0";
35
- this.store = {
36
- accountList: [],
37
- // 账号的纯数据列表
38
- accounts: [],
39
- // 账号的 module 列表
40
- isLoading: false,
41
- error: null
42
- };
43
- this.openCache = false;
44
47
  }
45
48
  async initialize(core, options) {
46
49
  var _a, _b, _c;
@@ -23,10 +23,13 @@ __export(BaseModule_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(BaseModule_exports);
25
25
  var BaseModule = class {
26
+ defaultName = "baseModule";
27
+ defaultVersion = "1.0.0";
28
+ name;
29
+ version;
30
+ isSolution = false;
31
+ core;
26
32
  constructor(name, version) {
27
- this.defaultName = "baseModule";
28
- this.defaultVersion = "1.0.0";
29
- this.isSolution = false;
30
33
  this.name = name || this.defaultName;
31
34
  this.version = version || this.defaultVersion;
32
35
  }
@@ -32,12 +32,17 @@ var import_utils2 = require("../Product/utils");
32
32
  __reExport(Cart_exports, require("./types"), module.exports);
33
33
  var import_utils3 = require("./utils");
34
34
  var CartModule = class extends import_BaseModule.BaseModule {
35
+ // 提供给 baseModule 用的默认名称 和 默认版本
36
+ defaultName = "cart";
37
+ defaultVersion = "1.0.0";
38
+ request;
39
+ window;
40
+ store;
41
+ cacheId;
42
+ openCache = false;
43
+ fatherModule;
35
44
  constructor(name, version) {
36
45
  super(name || "cart", version || "1.0.0");
37
- // 提供给 baseModule 用的默认名称 和 默认版本
38
- this.defaultName = "cart";
39
- this.defaultVersion = "1.0.0";
40
- this.openCache = false;
41
46
  }
42
47
  /**
43
48
  * 初始化购物车模块
@@ -62,12 +67,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
62
67
  this.request = core.getPlugin("request");
63
68
  this.window = core.getPlugin("window");
64
69
  if (!this.request) {
65
- throw new Error("购物车模块需要 request 插件支持");
70
+ throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
66
71
  }
67
72
  if (!this.window) {
68
- throw new Error("购物车模块需要 window 插件支持");
73
+ throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
69
74
  }
70
- console.log("[CartModule] 初始化完成");
75
+ console.log("[CartModule] \u521D\u59CB\u5316\u5B8C\u6210");
71
76
  }
72
77
  /**
73
78
  * 添加商品到购物车
@@ -118,7 +123,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
118
123
  this.store.list = [...items];
119
124
  await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
120
125
  } catch (error) {
121
- console.error("[CartModule] 更新购物车商品失败", error);
126
+ console.error("[CartModule] \u66F4\u65B0\u8D2D\u7269\u8F66\u5546\u54C1\u5931\u8D25", error);
122
127
  }
123
128
  }
124
129
  // 更新购物车中商品的初始信息
@@ -155,7 +160,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
155
160
  quantity = (tempCartItem == null ? void 0 : tempCartItem.num) || 1;
156
161
  }
157
162
  if (!tempCartItem) {
158
- throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
163
+ throw new Error("[CartModule] \u683C\u5F0F\u5316\u6570\u636E\u5230\u8D2D\u7269\u8F66\u5931\u8D25\uFF0C\u5546\u54C1\u4E0D\u5B58\u5728");
159
164
  }
160
165
  if (cartItem) {
161
166
  tempCartItem = cartItem;
@@ -250,8 +250,7 @@ var getProductOriginTotalPrice = (params) => {
250
250
  return price;
251
251
  };
252
252
  var formatOptions = (options) => {
253
- if (!(options == null ? void 0 : options.length))
254
- return [];
253
+ if (!(options == null ? void 0 : options.length)) return [];
255
254
  return options.map((item) => {
256
255
  return {
257
256
  id: item == null ? void 0 : item.id,
@@ -276,8 +275,7 @@ var formatOptionsToOrigin = (options) => {
276
275
  });
277
276
  };
278
277
  var formatBundle = (bundle) => {
279
- if (!(bundle == null ? void 0 : bundle.length))
280
- return [];
278
+ if (!(bundle == null ? void 0 : bundle.length)) return [];
281
279
  return bundle.map((item) => {
282
280
  return {
283
281
  id: item == null ? void 0 : item.id,
@@ -300,8 +298,7 @@ var formatBundle = (bundle) => {
300
298
  });
301
299
  };
302
300
  var formatBundleToOrigin = (bundle) => {
303
- if (!(bundle == null ? void 0 : bundle.length))
304
- return [];
301
+ if (!(bundle == null ? void 0 : bundle.length)) return [];
305
302
  return bundle.map((d) => {
306
303
  const getBundleValueByKey = (key) => {
307
304
  var _a;
@@ -29,7 +29,7 @@ var DEFAULT_PAGE_SIZE = 20;
29
29
  var DEFAULT_CUSTOMER = {
30
30
  "id": 1,
31
31
  "nickname": "Select a customer",
32
- "name": "选择一个客户"
32
+ "name": "\u9009\u62E9\u4E00\u4E2A\u5BA2\u6237"
33
33
  };
34
34
  // Annotate the CommonJS export names for ESM import in node:
35
35
  0 && (module.exports = {
@@ -28,23 +28,26 @@ var import_BaseModule = require("../BaseModule");
28
28
  var import_constants = require("./constants");
29
29
  __reExport(Customer_exports, require("./types"), module.exports);
30
30
  var CustomerModule = class extends import_BaseModule.BaseModule {
31
+ defaultName = "customer";
32
+ defaultVersion = "1.0.0";
33
+ store = {
34
+ customerList: [],
35
+ selectedCustomer: null,
36
+ total: 0,
37
+ currentPage: 1,
38
+ pageSize: import_constants.DEFAULT_PAGE_SIZE,
39
+ loading: false,
40
+ error: null,
41
+ hasMore: true,
42
+ loadingMore: false,
43
+ searchParams: {}
44
+ };
45
+ request;
46
+ cacheId;
47
+ openCache = false;
48
+ fatherModule;
31
49
  constructor(name, version) {
32
50
  super(name, version);
33
- this.defaultName = "customer";
34
- this.defaultVersion = "1.0.0";
35
- this.store = {
36
- customerList: [],
37
- selectedCustomer: null,
38
- total: 0,
39
- currentPage: 1,
40
- pageSize: import_constants.DEFAULT_PAGE_SIZE,
41
- loading: false,
42
- error: null,
43
- hasMore: true,
44
- loadingMore: false,
45
- searchParams: {}
46
- };
47
- this.openCache = false;
48
51
  }
49
52
  async initialize(core, options) {
50
53
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
@@ -33,7 +33,7 @@ export interface ShopCustomer extends ICustomer {
33
33
  * walletDetails.wallet: 用户所有wallet
34
34
  * latestWalletDetail.wallet: 用户最新wallet
35
35
  */
36
- type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
36
+ declare type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
37
37
  /**
38
38
  * 获取客户列表参数
39
39
  */
@@ -37,11 +37,15 @@ var import_BaseModule = require("../BaseModule");
37
37
  var import_utils = require("./utils");
38
38
  var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
39
39
  var DateModule = class extends import_BaseModule.BaseModule {
40
+ defaultName = "date";
41
+ defaultVersion = "1.0.0";
42
+ store;
43
+ request;
44
+ cacheId;
45
+ openCache = false;
46
+ fatherModule;
40
47
  constructor(name, version) {
41
48
  super(name, version);
42
- this.defaultName = "date";
43
- this.defaultVersion = "1.0.0";
44
- this.openCache = false;
45
49
  }
46
50
  async initialize(core, options) {
47
51
  var _a, _b;
@@ -53,7 +57,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
53
57
  this.store.dateList = options.initialState.dateList;
54
58
  }
55
59
  if (!this.request) {
56
- throw new Error("DateModule 需要 request 插件支持");
60
+ throw new Error("DateModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
57
61
  }
58
62
  if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
59
63
  this.openCache = options.otherParams.openCache;
@@ -197,13 +201,13 @@ var DateModule = class extends import_BaseModule.BaseModule {
197
201
  if (startAt.isBefore(resourceStartTime)) {
198
202
  const roundedStartTime = this.roundUpToNext10Minutes(resourceStartTime);
199
203
  const roundedStartTimeDayjs = (0, import_dayjs.default)(roundedStartTime);
200
- console.log(`[DateModule] 修正时间段开始时间: ${timeSlot.start_at} -> ${roundedStartTime} (资源ID: ${resource.id}, 原始start_time: ${resource.start_time})`);
204
+ console.log(`[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ${timeSlot.start_at} -> ${roundedStartTime} (\u8D44\u6E90ID: ${resource.id}, \u539F\u59CBstart_time: ${resource.start_time})`);
201
205
  const correctedTimeSlot = {
202
206
  ...timeSlot,
203
207
  start_at: roundedStartTime
204
208
  };
205
209
  if (endAt.isBefore(roundedStartTimeDayjs)) {
206
- console.log(`[DateModule] 时间段无效,将被删除: ${timeSlot.start_at} - ${timeSlot.end_at} (资源ID: ${resource.id}, 修正后start_time: ${roundedStartTime})`);
210
+ console.log(`[DateModule] \u65F6\u95F4\u6BB5\u65E0\u6548\uFF0C\u5C06\u88AB\u5220\u9664: ${timeSlot.start_at} - ${timeSlot.end_at} (\u8D44\u6E90ID: ${resource.id}, \u4FEE\u6B63\u540Estart_time: ${roundedStartTime})`);
207
211
  return null;
208
212
  }
209
213
  return correctedTimeSlot;
@@ -23,6 +23,7 @@ __export(types_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(types_exports);
25
25
  var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
26
+ return DateHooks2;
26
27
  })(DateHooks || {});
27
28
  // Annotate the CommonJS export names for ESM import in node:
28
29
  0 && (module.exports = {
@@ -37,11 +37,16 @@ var import_BaseModule = require("../BaseModule");
37
37
  var import_types = require("./types");
38
38
  var import_decimal = __toESM(require("decimal.js"));
39
39
  var DiscountModule = class extends import_BaseModule.BaseModule {
40
+ defaultName = "discount";
41
+ defaultVersion = "1.0.0";
42
+ request;
43
+ window;
44
+ store;
45
+ cacheId;
46
+ openCache = false;
47
+ fatherModule;
40
48
  constructor(name, version) {
41
49
  super(name, version);
42
- this.defaultName = "discount";
43
- this.defaultVersion = "1.0.0";
44
- this.openCache = false;
45
50
  }
46
51
  async initialize(core, options) {
47
52
  var _a, _b, _c, _d;
@@ -67,10 +72,10 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
67
72
  this.request = core.getPlugin("request");
68
73
  this.window = core.getPlugin("window");
69
74
  if (!this.request) {
70
- throw new Error("discount模块需要 request 插件支持");
75
+ throw new Error("discount\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
71
76
  }
72
77
  if (!this.window) {
73
- throw new Error("discount模块需要 window 插件支持");
78
+ throw new Error("discount\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
74
79
  }
75
80
  }
76
81
  async setDiscountList(discountList) {
@@ -255,7 +260,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
255
260
  this.store.discountList = [];
256
261
  this.core.effects.offByModuleDestroy(this.name);
257
262
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
258
- console.log("[Discount] 已销毁");
263
+ console.log("[Discount] \u5DF2\u9500\u6BC1");
259
264
  }
260
265
  async clear() {
261
266
  this.store.discountList = [];
@@ -63,7 +63,7 @@ interface UsageCreditsValue {
63
63
  max_per_week: number;
64
64
  max_per_month: number;
65
65
  }
66
- export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
66
+ export declare type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
67
  export interface DiscountWithReason {
68
68
  discountList: Discount[];
69
69
  unavailableReasonKey: DiscountFilterRejectKey | null;