@pisell/pisellos 2.1.151 → 2.1.152

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 (201) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
  8. package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
  9. package/dist/model/strategy/engine.d.ts +5 -18
  10. package/dist/model/strategy/engine.js +45 -145
  11. package/dist/model/strategy/type.d.ts +0 -17
  12. package/dist/model/strategy/type.js +0 -4
  13. package/dist/modules/Cart/types.d.ts +0 -2
  14. package/dist/modules/Cart/utils/cartProduct.js +25 -56
  15. package/dist/modules/Discount/index.d.ts +9 -3
  16. package/dist/modules/Discount/index.js +103 -11
  17. package/dist/modules/Discount/types.d.ts +8 -19
  18. package/dist/modules/OpenData/index.d.ts +24 -0
  19. package/dist/modules/OpenData/index.js +173 -0
  20. package/dist/modules/OpenData/types.d.ts +73 -0
  21. package/dist/modules/OpenData/types.js +1 -0
  22. package/dist/modules/OpenData/utils.d.ts +2 -0
  23. package/dist/modules/OpenData/utils.js +75 -0
  24. package/dist/modules/Order/index.d.ts +66 -1
  25. package/dist/modules/Order/index.js +906 -30
  26. package/dist/modules/Order/types.d.ts +174 -12
  27. package/dist/modules/Order/types.js +2 -0
  28. package/dist/modules/Order/utils.d.ts +118 -0
  29. package/dist/modules/Order/utils.js +586 -2
  30. package/dist/modules/Payment/index.d.ts +1 -2
  31. package/dist/modules/Payment/index.js +7 -10
  32. package/dist/modules/Payment/utils.js +0 -3
  33. package/dist/modules/Payment/walletpass.d.ts +0 -23
  34. package/dist/modules/Payment/walletpass.js +95 -191
  35. package/dist/modules/Product/utils.js +2 -2
  36. package/dist/modules/ProductList/index.d.ts +1 -1
  37. package/dist/modules/ProductList/index.js +4 -3
  38. package/dist/modules/Quotation/index.d.ts +48 -0
  39. package/dist/modules/Quotation/index.js +248 -0
  40. package/dist/modules/Quotation/types.d.ts +42 -0
  41. package/dist/modules/Quotation/types.js +1 -0
  42. package/dist/modules/Rules/index.d.ts +5 -9
  43. package/dist/modules/Rules/index.js +168 -677
  44. package/dist/modules/Rules/types.d.ts +0 -2
  45. package/dist/modules/SalesSummary/index.d.ts +63 -0
  46. package/dist/modules/SalesSummary/index.js +174 -0
  47. package/dist/modules/SalesSummary/types.d.ts +60 -0
  48. package/dist/modules/SalesSummary/types.js +1 -0
  49. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  50. package/dist/modules/SalesSummary/utils.js +480 -0
  51. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  52. package/dist/modules/ScanOrderLogger/index.js +174 -0
  53. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  54. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  55. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  56. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  57. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  58. package/dist/modules/ScanOrderLogger/types.js +1 -0
  59. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  60. package/dist/modules/Schedule/utils.d.ts +1 -1
  61. package/dist/modules/Summary/types.d.ts +0 -2
  62. package/dist/modules/Summary/utils.d.ts +3 -9
  63. package/dist/modules/Summary/utils.js +41 -52
  64. package/dist/modules/index.d.ts +4 -0
  65. package/dist/modules/index.js +5 -1
  66. package/dist/plugins/window.d.ts +0 -2
  67. package/dist/solution/BookingByStep/index.d.ts +1 -2
  68. package/dist/solution/BookingByStep/index.js +46 -43
  69. package/dist/solution/BookingByStep/types.d.ts +3 -1
  70. package/dist/solution/BookingByStep/types.js +5 -1
  71. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  72. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  73. package/dist/solution/Checkout/index.js +0 -2
  74. package/dist/solution/ScanOrder/index.d.ts +152 -0
  75. package/dist/solution/ScanOrder/index.js +3132 -0
  76. package/dist/solution/ScanOrder/types.d.ts +287 -0
  77. package/dist/solution/ScanOrder/types.js +35 -0
  78. package/dist/solution/ScanOrder/utils.d.ts +167 -0
  79. package/dist/solution/ScanOrder/utils.js +764 -0
  80. package/dist/solution/ShopDiscount/index.d.ts +3 -2
  81. package/dist/solution/ShopDiscount/index.js +60 -59
  82. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  83. package/dist/solution/ShopDiscount/types.js +1 -2
  84. package/dist/solution/ShopDiscount/utils.js +12 -26
  85. package/dist/solution/VenueBooking/index.d.ts +200 -0
  86. package/dist/solution/VenueBooking/index.js +3459 -0
  87. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  88. package/dist/solution/VenueBooking/types.d.ts +154 -0
  89. package/dist/solution/VenueBooking/types.js +21 -0
  90. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  91. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  92. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  93. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  94. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  95. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  96. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  97. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  98. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  99. package/dist/solution/VenueBooking/utils.js +1 -0
  100. package/dist/solution/index.d.ts +2 -0
  101. package/dist/solution/index.js +3 -1
  102. package/lib/apis/picoding.d.ts +0 -0
  103. package/lib/apis/picoding.js +0 -0
  104. package/lib/index.d.ts +0 -1
  105. package/lib/index.js +1 -3
  106. package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
  107. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  108. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  109. package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
  110. package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
  111. package/lib/model/strategy/engine.d.ts +5 -18
  112. package/lib/model/strategy/engine.js +21 -85
  113. package/lib/model/strategy/type.d.ts +0 -17
  114. package/lib/modules/Cart/types.d.ts +0 -2
  115. package/lib/modules/Cart/utils/cartProduct.js +12 -39
  116. package/lib/modules/Discount/index.d.ts +9 -3
  117. package/lib/modules/Discount/index.js +65 -4
  118. package/lib/modules/Discount/types.d.ts +8 -19
  119. package/lib/modules/OpenData/index.d.ts +24 -0
  120. package/lib/modules/OpenData/index.js +119 -0
  121. package/lib/modules/OpenData/types.d.ts +73 -0
  122. package/lib/modules/OpenData/types.js +17 -0
  123. package/lib/modules/OpenData/utils.d.ts +2 -0
  124. package/lib/modules/OpenData/utils.js +111 -0
  125. package/lib/modules/Order/index.d.ts +66 -1
  126. package/lib/modules/Order/index.js +515 -1
  127. package/lib/modules/Order/types.d.ts +174 -12
  128. package/lib/modules/Order/utils.d.ts +118 -0
  129. package/lib/modules/Order/utils.js +483 -2
  130. package/lib/modules/Payment/index.d.ts +1 -2
  131. package/lib/modules/Payment/index.js +0 -1
  132. package/lib/modules/Payment/utils.js +0 -3
  133. package/lib/modules/Payment/walletpass.d.ts +0 -23
  134. package/lib/modules/Payment/walletpass.js +17 -94
  135. package/lib/modules/Product/utils.js +2 -2
  136. package/lib/modules/ProductList/index.d.ts +1 -1
  137. package/lib/modules/ProductList/index.js +5 -3
  138. package/lib/modules/Quotation/index.d.ts +48 -0
  139. package/lib/modules/Quotation/index.js +152 -0
  140. package/lib/modules/Quotation/types.d.ts +42 -0
  141. package/lib/modules/Quotation/types.js +17 -0
  142. package/lib/modules/Rules/index.d.ts +5 -9
  143. package/lib/modules/Rules/index.js +288 -780
  144. package/lib/modules/Rules/types.d.ts +0 -2
  145. package/lib/modules/SalesSummary/index.d.ts +63 -0
  146. package/lib/modules/SalesSummary/index.js +105 -0
  147. package/lib/modules/SalesSummary/types.d.ts +60 -0
  148. package/lib/modules/SalesSummary/types.js +17 -0
  149. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  150. package/lib/modules/SalesSummary/utils.js +420 -0
  151. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  152. package/lib/modules/ScanOrderLogger/index.js +147 -0
  153. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  154. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  155. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  156. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  157. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  158. package/lib/modules/ScanOrderLogger/types.js +17 -0
  159. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  160. package/lib/modules/Schedule/utils.d.ts +1 -1
  161. package/lib/modules/Summary/types.d.ts +0 -2
  162. package/lib/modules/Summary/utils.d.ts +3 -9
  163. package/lib/modules/Summary/utils.js +22 -31
  164. package/lib/modules/index.d.ts +4 -0
  165. package/lib/modules/index.js +9 -1
  166. package/lib/plugins/window.d.ts +0 -2
  167. package/lib/solution/BookingByStep/index.d.ts +1 -2
  168. package/lib/solution/BookingByStep/index.js +6 -4
  169. package/lib/solution/BookingByStep/types.d.ts +3 -1
  170. package/lib/solution/BookingByStep/types.js +10 -0
  171. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  172. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  173. package/lib/solution/Checkout/index.js +0 -2
  174. package/lib/solution/ScanOrder/index.d.ts +152 -0
  175. package/lib/solution/ScanOrder/index.js +1901 -0
  176. package/lib/solution/ScanOrder/types.d.ts +287 -0
  177. package/lib/solution/ScanOrder/types.js +36 -0
  178. package/lib/solution/ScanOrder/utils.d.ts +167 -0
  179. package/lib/solution/ScanOrder/utils.js +635 -0
  180. package/lib/solution/ShopDiscount/index.d.ts +3 -2
  181. package/lib/solution/ShopDiscount/index.js +19 -25
  182. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  183. package/lib/solution/ShopDiscount/utils.js +6 -10
  184. package/lib/solution/VenueBooking/index.d.ts +200 -0
  185. package/lib/solution/VenueBooking/index.js +1926 -0
  186. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  187. package/lib/solution/VenueBooking/types.d.ts +154 -0
  188. package/lib/solution/VenueBooking/types.js +44 -0
  189. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  190. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  191. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  192. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  193. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  194. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  195. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  196. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  197. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  198. package/lib/solution/VenueBooking/utils.js +69 -0
  199. package/lib/solution/index.d.ts +2 -0
  200. package/lib/solution/index.js +5 -1
  201. package/package.json +1 -1
File without changes
@@ -0,0 +1 @@
1
+ // picoding 相关公共 api
package/dist/index.d.ts CHANGED
@@ -6,7 +6,6 @@ export * from './types';
6
6
  export * from './modules';
7
7
  export * from './plugins';
8
8
  export * from './solution';
9
- export * from './model';
10
9
  export { PisellOSCore } from './core';
11
10
  import PisellOSCore from './core';
12
11
  export default PisellOSCore;
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ export * from "./types";
8
8
  export * from "./modules";
9
9
  export * from "./plugins";
10
10
  export * from "./solution";
11
- export * from "./model";
12
11
 
13
12
  // 导出核心实现
14
13
  export { PisellOSCore } from "./core";
@@ -719,8 +719,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
719
719
  unitProducts.push({
720
720
  product: product,
721
721
  price: product.price,
722
- productId: product.id,
723
- sourceAvailableQty: availableQty
722
+ productId: product.id
724
723
  });
725
724
  }
726
725
  }
@@ -737,13 +736,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
737
736
  };
738
737
  }
739
738
 
740
- // 2. 排序:优先选择来源数量是 x 倍数的商品(可完整凑组不拆分),然后按价格从高到低
739
+ // 2. 按价格从高到低排序(优先使用高价商品)
741
740
  unitProducts.sort(function (a, b) {
742
- // 优先级1:来源购物车项数量是 x 的倍数的排前面(这些商品可以完整凑组,避免拆分)
743
- var aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
744
- var bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
745
- if (aIsMultiple !== bIsMultiple) return bIsMultiple - aIsMultiple;
746
- // 优先级2:按价格从高到低(优先使用高价商品)
747
741
  return b.price - a.price;
748
742
  });
749
743
 
@@ -839,10 +833,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
839
833
  var totalAllocated = allocatedPrices.reduce(function (sum, p) {
840
834
  return sum.plus(p);
841
835
  }, new Decimal(0));
842
- // 取促销价和原价的最小值,避免促销反而加价
843
- var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
844
- var actualTotal = Decimal.min(totalAllocated, productOriginalAmount);
845
- var finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
836
+ var finalPricePerUnit = this.formatPrice(totalAllocated.div(promoQty));
846
837
  result.push(_objectSpread(_objectSpread({}, _product), {}, {
847
838
  quantity: promoQty,
848
839
  finalPrice: finalPricePerUnit,
@@ -852,8 +843,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
852
843
  isSplit: false,
853
844
  matchedBundleIndex: matchedBundleIndex
854
845
  }));
846
+ var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
855
847
  originalAmount = originalAmount.plus(productOriginalAmount);
856
- finalAmount = finalAmount.plus(actualTotal);
848
+ finalAmount = finalAmount.plus(totalAllocated);
857
849
  } else if (promoQty === 0 && remainingQty > 0) {
858
850
  // 全部不参与促销:保留原 id,finalPrice = 原价
859
851
  result.push(_objectSpread(_objectSpread({}, _product), {}, {
@@ -873,10 +865,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
873
865
  var _totalAllocated = allocatedPrices.reduce(function (sum, p) {
874
866
  return sum.plus(p);
875
867
  }, new Decimal(0));
876
- // 取促销价和原价的最小值,避免促销反而加价
877
- var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
878
- var _actualTotal = Decimal.min(_totalAllocated, promoOriginalAmount);
879
- var _finalPricePerUnit = this.formatPrice(_actualTotal.div(promoQty));
868
+ var _finalPricePerUnit = this.formatPrice(_totalAllocated.div(promoQty));
880
869
  result.push(_objectSpread(_objectSpread({}, _product), {}, {
881
870
  id: this.generateRandomId(),
882
871
  originalId: _product.id,
@@ -888,8 +877,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
888
877
  matchedBundleIndex: matchedBundleIndex,
889
878
  isSplit: true
890
879
  }));
880
+ var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
891
881
  originalAmount = originalAmount.plus(promoOriginalAmount);
892
- finalAmount = finalAmount.plus(_actualTotal);
882
+ finalAmount = finalAmount.plus(_totalAllocated);
893
883
 
894
884
  // 不参与促销的部分:保留原 id
895
885
  result.push(_objectSpread(_objectSpread({}, _product), {}, {
@@ -908,74 +898,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
908
898
  // 更新已处理数量
909
899
  processedQuantityMap.set(_key, _processedQty + _availableQty);
910
900
  }
911
-
912
- // 8. 尾差调整:确保促销商品的 finalPrice × quantity 之和精确等于 groupPrice × groupCount
913
901
  } catch (err) {
914
902
  _iterator13.e(err);
915
903
  } finally {
916
904
  _iterator13.f();
917
905
  }
918
- if (groupCount > 0) {
919
- var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
920
- var promoItems = result.filter(function (p) {
921
- return p.inPromotion;
922
- });
923
- var actualPromoTotal = new Decimal(0);
924
- var _iterator14 = _createForOfIteratorHelper(promoItems),
925
- _step14;
926
- try {
927
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
928
- var _p = _step14.value;
929
- actualPromoTotal = actualPromoTotal.plus(new Decimal(_p.finalPrice).mul(_p.quantity));
930
- }
931
- } catch (err) {
932
- _iterator14.e(err);
933
- } finally {
934
- _iterator14.f();
935
- }
936
- var roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
937
- if (!roundingDiff.eq(0)) {
938
- // 优先找 quantity=1 的促销商品调整(差额直接加减到单价上)
939
- var adjustTarget = promoItems.find(function (p) {
940
- return p.quantity === 1;
941
- });
942
- if (adjustTarget) {
943
- adjustTarget.finalPrice = this.formatPrice(new Decimal(adjustTarget.finalPrice).minus(roundingDiff));
944
- } else if (promoItems.length > 0) {
945
- // 没有 quantity=1 的促销商品,从最后一个促销商品中拆出1件做尾差调整
946
- var lastPromo = promoItems[promoItems.length - 1];
947
- var adjustedUnitPrice = this.formatPrice(new Decimal(lastPromo.finalPrice).minus(roundingDiff));
948
-
949
- // 原商品减少1件
950
- lastPromo.quantity -= 1;
951
- lastPromo.isSplit = true;
952
-
953
- // 拆出1件用调整后的价格
954
- result.push(_objectSpread(_objectSpread({}, lastPromo), {}, {
955
- id: this.generateRandomId(),
956
- originalId: lastPromo.originalId || lastPromo.id,
957
- quantity: 1,
958
- finalPrice: adjustedUnitPrice,
959
- isSplit: true
960
- }));
961
- }
962
-
963
- // 重新计算 finalAmount
964
- finalAmount = new Decimal(0);
965
- var _iterator15 = _createForOfIteratorHelper(result),
966
- _step15;
967
- try {
968
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
969
- var p = _step15.value;
970
- finalAmount = finalAmount.plus(new Decimal(p.finalPrice).mul(p.quantity));
971
- }
972
- } catch (err) {
973
- _iterator15.e(err);
974
- } finally {
975
- _iterator15.f();
976
- }
977
- }
978
- }
979
906
  return {
980
907
  products: result,
981
908
  originalAmount: originalAmount.toNumber(),
@@ -1010,11 +937,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1010
937
  // 对于 bundle 子商品匹配,促销数量 = 主商品数量 × bundle子商品数量
1011
938
  var totalPromoQty = 0;
1012
939
  var productInfoMap = new Map();
1013
- var _iterator16 = _createForOfIteratorHelper(groupProducts),
1014
- _step16;
940
+ var _iterator14 = _createForOfIteratorHelper(groupProducts),
941
+ _step14;
1015
942
  try {
1016
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1017
- var product = _step16.value;
943
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
944
+ var product = _step14.value;
1018
945
  var key = this.getProductKey(product);
1019
946
  var processedQty = processedQuantityMap.get(key) || 0;
1020
947
  var availableQty = product.quantity - processedQty;
@@ -1040,18 +967,18 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1040
967
 
1041
968
  // 2. 判断是否满足促销条件
1042
969
  } catch (err) {
1043
- _iterator16.e(err);
970
+ _iterator14.e(err);
1044
971
  } finally {
1045
- _iterator16.f();
972
+ _iterator14.f();
1046
973
  }
1047
974
  var isFulfilled = totalPromoQty >= buyQuantity;
1048
975
 
1049
976
  // 3. 生成商品结果(第二次遍历)
1050
- var _iterator17 = _createForOfIteratorHelper(groupProducts),
1051
- _step17;
977
+ var _iterator15 = _createForOfIteratorHelper(groupProducts),
978
+ _step15;
1052
979
  try {
1053
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
1054
- var _product2 = _step17.value;
980
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
981
+ var _product2 = _step15.value;
1055
982
  var _key2 = this.getProductKey(_product2);
1056
983
  var info = productInfoMap.get(_key2);
1057
984
  if (!info || info.availableQty <= 0) continue;
@@ -1079,9 +1006,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1079
1006
 
1080
1007
  // 4. 计算赠品数量(使用促销数量)
1081
1008
  } catch (err) {
1082
- _iterator17.e(err);
1009
+ _iterator15.e(err);
1083
1010
  } finally {
1084
- _iterator17.f();
1011
+ _iterator15.f();
1085
1012
  }
1086
1013
  var giftCount = 0;
1087
1014
  if (isFulfilled) {
@@ -1110,11 +1037,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1110
1037
  key: "getRemainingProducts",
1111
1038
  value: function getRemainingProducts(allProducts, processedQuantityMap) {
1112
1039
  var result = [];
1113
- var _iterator18 = _createForOfIteratorHelper(allProducts),
1114
- _step18;
1040
+ var _iterator16 = _createForOfIteratorHelper(allProducts),
1041
+ _step16;
1115
1042
  try {
1116
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1117
- var product = _step18.value;
1043
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1044
+ var product = _step16.value;
1118
1045
  var key = this.getProductKey(product);
1119
1046
  var processedQty = processedQuantityMap.get(key) || 0;
1120
1047
  var remainingQty = product.quantity - processedQty;
@@ -1129,9 +1056,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1129
1056
  }
1130
1057
  }
1131
1058
  } catch (err) {
1132
- _iterator18.e(err);
1059
+ _iterator16.e(err);
1133
1060
  } finally {
1134
- _iterator18.f();
1061
+ _iterator16.f();
1135
1062
  }
1136
1063
  return result;
1137
1064
  }
@@ -8,12 +8,10 @@ export declare class WalletPassEvaluator {
8
8
  private engine;
9
9
  private strategyConfigs;
10
10
  private locale;
11
- private otherParams;
12
11
  constructor();
13
12
  setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
14
13
  getStrategyConfigs(): StrategyConfig[];
15
14
  setLocale(locale: string): void;
16
- setOtherParams(otherParams: any): void;
17
15
  getText(key: string): string;
18
16
  /**
19
17
  * 搜索券的格式
@@ -24,43 +24,6 @@ var defaultStrategyMetadataCustom = {
24
24
  deductOptionPrice: false
25
25
  };
26
26
 
27
- /**
28
- * 条件 field → reasonCode 映射
29
- * 用于将策略引擎返回的 failedField 转换为本地化文案 key
30
- */
31
- var FIELD_REASON_CODE_MAP = {
32
- orderTotalAmount: 'order_total_amount_not_enough',
33
- applicableProductTotalAmount: 'applicable_product_total_amount_not_enough',
34
- applicableProductCount: 'applicable_product_count_not_enough'
35
- };
36
-
37
- /**
38
- * 金额类型 field 集合(需要在文案前拼货币符号)
39
- */
40
- var AMOUNT_FIELDS = new Set(['orderTotalAmount', 'applicableProductTotalAmount']);
41
-
42
- /**
43
- * 用阈值与货币符号替换文案中的占位符
44
- * 支持占位符:{value} / ${value} / {currency}
45
- */
46
- function formatReason(template, value) {
47
- var currency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
48
- if (!template) return template;
49
- var v = value === undefined || value === null ? '' : String(value);
50
- var c = currency === undefined || currency === null ? '' : String(currency);
51
- // 注意:必须先替换 value,再替换 currency
52
- // 否则 currency 注入的 "$" 会被后续的 /\$\{value\}/ 正则误吞
53
- // 使用函数作为替换参数,避免替换串中的 "$" 被 String.prototype.replace
54
- // 当作特殊序列(如 $$ -> $、$& 等)处理
55
- return template.replace(/\$\{value\}/g, function () {
56
- return v;
57
- }).replace(/\{value\}/g, function () {
58
- return v;
59
- }).replace(/\{currency\}/g, function () {
60
- return c;
61
- });
62
- }
63
-
64
27
  /**
65
28
  * Wallet Pass 评估器
66
29
  * 用于评估哪些 voucher 可以在当前订单中使用
@@ -71,7 +34,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
71
34
  _defineProperty(this, "engine", void 0);
72
35
  _defineProperty(this, "strategyConfigs", []);
73
36
  _defineProperty(this, "locale", 'en');
74
- _defineProperty(this, "otherParams", {});
75
37
  this.engine = new StrategyEngine({
76
38
  debug: false,
77
39
  enableTrace: false
@@ -95,11 +57,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
95
57
  value: function setLocale(locale) {
96
58
  this.locale = locale;
97
59
  }
98
- }, {
99
- key: "setOtherParams",
100
- value: function setOtherParams(otherParams) {
101
- this.otherParams = otherParams;
102
- }
103
60
  }, {
104
61
  key: "getText",
105
62
  value: function getText(key) {
@@ -234,17 +191,13 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
234
191
  strategyResult: evaluationResult
235
192
  });
236
193
  } else {
237
- var _evaluationResult$mat, _evaluationResult$mat2, _this$otherParams, _this$otherParams$get, _this$otherParams2;
238
- // 优先根据失败的 field 映射到具体的 reasonCode(更精确的失败原因)
239
- var reasonCode = 'not_meet_the_required_conditions';
240
- var thresholdValue = undefined;
241
- var failedField = (_evaluationResult$mat = evaluationResult.matched) === null || _evaluationResult$mat === void 0 ? void 0 : _evaluationResult$mat.failedField;
242
- var failedRule = (_evaluationResult$mat2 = evaluationResult.matched) === null || _evaluationResult$mat2 === void 0 || (_evaluationResult$mat2 = _evaluationResult$mat2.failedRules) === null || _evaluationResult$mat2 === void 0 ? void 0 : _evaluationResult$mat2[0];
243
- if (failedField && FIELD_REASON_CODE_MAP[failedField]) {
244
- reasonCode = FIELD_REASON_CODE_MAP[failedField];
245
- thresholdValue = failedRule === null || failedRule === void 0 ? void 0 : failedRule.value;
246
- } else if (evaluationResult.code) {
247
- // 兜底:保留原有 code → reasonCode 映射
194
+ // 根据策略评估结果的 code 映射到 locales 中的原因
195
+ var reasonCode = 'not_meet_the_required_conditions'; // 默认原因
196
+
197
+ // 根据策略引擎返回的 code 映射到本地化的 reasonCode
198
+ if (evaluationResult.code) {
199
+ // 可以根据具体的 code 映射到不同的原因
200
+ // 例如:如果是金额不足、使用次数限制等
248
201
  var codeMapping = {
249
202
  INSUFFICIENT_AMOUNT: 'not_meet_the_required_conditions',
250
203
  USAGE_LIMIT_EXCEEDED: 'usage_limit_reached',
@@ -254,11 +207,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
254
207
  };
255
208
  reasonCode = codeMapping[evaluationResult.code] || 'not_meet_the_required_conditions';
256
209
  }
257
- var rawText = this.getText(reasonCode);
258
- // 金额类型字段:从 otherParams.getData 取货币符号;非金额或取不到则留空
259
- var currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams$get = (_this$otherParams2 = _this$otherParams).getData) === null || _this$otherParams$get === void 0 ? void 0 : _this$otherParams$get.call(_this$otherParams2, 'shop_symbol')) || '' : '';
260
- console.log(currency, 'currency12345');
261
- var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue, currency) : rawText;
262
210
  results.push({
263
211
  voucher: voucher,
264
212
  isApplicable: false,
@@ -266,7 +214,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
266
214
  maxDeduction: 0,
267
215
  deductTaxAndFee: false,
268
216
  applicableProductIds: [],
269
- reason: reason,
217
+ reason: this.getText(reasonCode),
270
218
  reasonCode: reasonCode,
271
219
  strategyResult: evaluationResult
272
220
  });
@@ -506,7 +454,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
506
454
  }, {
507
455
  key: "calculateApplicableProducts",
508
456
  value: function calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
509
- console.log(products, 'products1234');
510
457
  var total = 0;
511
458
  var count = 0;
512
459
 
@@ -5,10 +5,7 @@ export var locales = {
5
5
  'usage_limit_reached': '已达到使用次数上限',
6
6
  'max_passes_per_item_reached': '该商品已达到卡券使用上限',
7
7
  'not_available_for_this_channel': '当前渠道不可使用',
8
- 'not_valid_for_this_order_type': '当前订单类型不适用',
9
- 'order_total_amount_not_enough': '满 {currency}{value} 可用',
10
- 'applicable_product_total_amount_not_enough': '满 {currency}{value} 可用',
11
- 'applicable_product_count_not_enough': '至少 {value} 件'
8
+ 'not_valid_for_this_order_type': '当前订单类型不适用'
12
9
  },
13
10
  'en': {
14
11
  'not_meet_the_required_conditions': 'Not meet the required conditions.',
@@ -16,10 +13,7 @@ export var locales = {
16
13
  'usage_limit_reached': 'Usage limit reached.',
17
14
  'max_passes_per_item_reached': 'Max passes per item reached.',
18
15
  'not_available_for_this_channel': 'Not available for this channel.',
19
- 'not_valid_for_this_order_type': 'Not valid for this order type.',
20
- 'order_total_amount_not_enough': 'Spend {currency}{value} to use',
21
- 'applicable_product_total_amount_not_enough': 'Spend {currency}{value} to use',
22
- 'applicable_product_count_not_enough': 'Min. Qty {value}'
16
+ 'not_valid_for_this_order_type': 'Not valid for this order type.'
23
17
  },
24
18
  'zh-HK': {
25
19
  'not_meet_the_required_conditions': '未達使用條件',
@@ -27,9 +21,6 @@ export var locales = {
27
21
  'usage_limit_reached': '已達使用次數上限',
28
22
  'max_passes_per_item_reached': '該商品已達卡券使用上限',
29
23
  'not_available_for_this_channel': '當前渠道不可使用',
30
- 'not_valid_for_this_order_type': '當前訂單類型不適用',
31
- 'order_total_amount_not_enough': '滿 {currency}{value} 可用',
32
- 'applicable_product_total_amount_not_enough': '滿 {currency}{value} 可用',
33
- 'applicable_product_count_not_enough': '至少 {value} 件'
24
+ 'not_valid_for_this_order_type': '當前訂單類型不適用'
34
25
  }
35
26
  };
@@ -27,30 +27,17 @@ export declare class StrategyEngine {
27
27
  *
28
28
  * @param group 条件组
29
29
  * @param context 运行时上下文
30
- * @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
30
+ * @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
31
31
  */
32
32
  private evaluateConditionGroup;
33
33
  /**
34
- * 评估条件组的逻辑运算(带失败规则收集)
35
- *
36
- * 失败规则收集策略:
37
- * - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
38
- * - `or`:所有分支失败时,聚合每个分支的失败规则
39
- * - `not`:被取反规则实际通过时,记录该规则
40
- */
41
- private evaluateGroupLogicDetailed;
42
- /**
43
- * 评估单个规则(带失败规则收集)
44
- */
45
- private evaluateRuleDetailed;
46
- /**
47
- * 评估原子规则(不收集失败信息,仅返回布尔结果)
34
+ * 评估条件组的逻辑运算
48
35
  */
49
- private evaluateAtomicRule;
36
+ private evaluateGroupLogic;
50
37
  /**
51
- * 构建失败规则信息
38
+ * 评估单个规则
52
39
  */
53
- private buildFailedRuleInfo;
40
+ private evaluateRule;
54
41
  /**
55
42
  * 评估代码模式条件
56
43
  */