@pisell/pisellos 2.1.85 → 2.1.87

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 (111) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/modules/Cart/types.d.ts +0 -2
  4. package/dist/modules/Cart/utils/cartProduct.js +0 -11
  5. package/dist/modules/Cart/utils/changePrice.js +6 -0
  6. package/dist/modules/Discount/index.d.ts +1 -0
  7. package/dist/modules/Discount/index.js +2 -1
  8. package/dist/modules/Discount/types.d.ts +0 -15
  9. package/dist/modules/Payment/index.d.ts +1 -2
  10. package/dist/modules/Payment/index.js +7 -10
  11. package/dist/modules/Payment/utils.js +0 -3
  12. package/dist/modules/Payment/walletpass.d.ts +0 -23
  13. package/dist/modules/Payment/walletpass.js +95 -191
  14. package/dist/modules/Rules/index.d.ts +2 -7
  15. package/dist/modules/Rules/index.js +19 -141
  16. package/dist/modules/Rules/types.d.ts +0 -1
  17. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  18. package/dist/modules/Schedule/getDateIsInSchedule.js +747 -0
  19. package/dist/modules/Schedule/index.d.ts +1 -1
  20. package/dist/modules/Schedule/index.js +2 -0
  21. package/dist/modules/Summary/index.js +47 -5
  22. package/dist/modules/Summary/types.d.ts +0 -2
  23. package/dist/modules/Summary/utils.d.ts +1 -7
  24. package/dist/modules/Summary/utils.js +23 -33
  25. package/dist/plugins/window.d.ts +0 -2
  26. package/dist/solution/BookingByStep/index.d.ts +0 -1
  27. package/dist/solution/BookingByStep/index.js +84 -35
  28. package/dist/solution/Checkout/index.js +0 -2
  29. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  30. package/dist/solution/ShopDiscount/index.js +3 -12
  31. package/dist/solution/ShopDiscount/types.d.ts +0 -1
  32. package/lib/index.d.ts +0 -1
  33. package/lib/index.js +1 -3
  34. package/lib/modules/Cart/types.d.ts +0 -2
  35. package/lib/modules/Cart/utils/cartProduct.js +0 -9
  36. package/lib/modules/Cart/utils/changePrice.js +5 -0
  37. package/lib/modules/Discount/index.d.ts +1 -0
  38. package/lib/modules/Discount/index.js +2 -1
  39. package/lib/modules/Discount/types.d.ts +0 -15
  40. package/lib/modules/Payment/index.d.ts +1 -2
  41. package/lib/modules/Payment/index.js +0 -1
  42. package/lib/modules/Payment/utils.js +0 -3
  43. package/lib/modules/Payment/walletpass.d.ts +0 -23
  44. package/lib/modules/Payment/walletpass.js +17 -94
  45. package/lib/modules/Rules/index.d.ts +2 -7
  46. package/lib/modules/Rules/index.js +149 -285
  47. package/lib/modules/Rules/types.d.ts +0 -1
  48. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  49. package/lib/modules/Schedule/getDateIsInSchedule.js +451 -0
  50. package/lib/modules/Schedule/index.d.ts +1 -1
  51. package/lib/modules/Schedule/index.js +2 -0
  52. package/lib/modules/Summary/index.js +22 -9
  53. package/lib/modules/Summary/types.d.ts +0 -2
  54. package/lib/modules/Summary/utils.d.ts +1 -7
  55. package/lib/modules/Summary/utils.js +22 -28
  56. package/lib/plugins/window.d.ts +0 -2
  57. package/lib/solution/BookingByStep/index.d.ts +0 -1
  58. package/lib/solution/BookingByStep/index.js +34 -3
  59. package/lib/solution/Checkout/index.js +0 -2
  60. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  61. package/lib/solution/ShopDiscount/index.js +2 -7
  62. package/lib/solution/ShopDiscount/types.d.ts +0 -1
  63. package/package.json +1 -1
  64. package/dist/model/index.d.ts +0 -1
  65. package/dist/model/index.js +0 -1
  66. package/dist/model/strategy/adapter/index.d.ts +0 -3
  67. package/dist/model/strategy/adapter/index.js +0 -4
  68. package/dist/model/strategy/adapter/type.d.ts +0 -28
  69. package/dist/model/strategy/adapter/type.js +0 -1
  70. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  71. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -497
  72. package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
  73. package/dist/model/strategy/adapter/walletPass/example.js +0 -258
  74. package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
  75. package/dist/model/strategy/adapter/walletPass/index.js +0 -182
  76. package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  77. package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
  78. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -168
  79. package/dist/model/strategy/adapter/walletPass/type.js +0 -1
  80. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -76
  81. package/dist/model/strategy/adapter/walletPass/utils.js +0 -1043
  82. package/dist/model/strategy/index.d.ts +0 -94
  83. package/dist/model/strategy/index.js +0 -551
  84. package/dist/model/strategy/strategy-example.d.ts +0 -5
  85. package/dist/model/strategy/strategy-example.js +0 -331
  86. package/dist/model/strategy/type.d.ts +0 -228
  87. package/dist/model/strategy/type.js +0 -94
  88. package/lib/model/index.d.ts +0 -1
  89. package/lib/model/index.js +0 -23
  90. package/lib/model/strategy/adapter/index.d.ts +0 -3
  91. package/lib/model/strategy/adapter/index.js +0 -45
  92. package/lib/model/strategy/adapter/type.d.ts +0 -28
  93. package/lib/model/strategy/adapter/type.js +0 -17
  94. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  95. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -421
  96. package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
  97. package/lib/model/strategy/adapter/walletPass/example.js +0 -207
  98. package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
  99. package/lib/model/strategy/adapter/walletPass/index.js +0 -142
  100. package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  101. package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
  102. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -168
  103. package/lib/model/strategy/adapter/walletPass/type.js +0 -17
  104. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -76
  105. package/lib/model/strategy/adapter/walletPass/utils.js +0 -704
  106. package/lib/model/strategy/index.d.ts +0 -94
  107. package/lib/model/strategy/index.js +0 -413
  108. package/lib/model/strategy/strategy-example.d.ts +0 -5
  109. package/lib/model/strategy/strategy-example.js +0 -318
  110. package/lib/model/strategy/type.d.ts +0 -228
  111. package/lib/model/strategy/type.js +0 -44
@@ -31,6 +31,7 @@ import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils"
31
31
  import Decimal from 'decimal.js';
32
32
  import { isBoolean } from 'lodash-es';
33
33
  import dayjs from 'dayjs';
34
+
34
35
  // 临时变量
35
36
  var flatItem;
36
37
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
@@ -43,8 +44,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
43
44
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'rules');
44
45
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
45
46
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
46
- _defineProperty(_assertThisInitialized(_this), "window", void 0);
47
- // WindowPlugin 实例
48
47
  _defineProperty(_assertThisInitialized(_this), "hooks", void 0);
49
48
  _this.hooks = {};
50
49
  return _this;
@@ -59,8 +58,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
59
58
  this.core = core;
60
59
  this.hooks = options === null || options === void 0 ? void 0 : options.hooks;
61
60
  this.store = options === null || options === void 0 ? void 0 : options.store;
62
- this.window = core.getPlugin('window');
63
- case 4:
61
+ case 3:
64
62
  case "end":
65
63
  return _context.stop();
66
64
  }
@@ -97,12 +95,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
97
95
  value: function getRulesList() {
98
96
  return this.store.rulesList;
99
97
  }
100
- }, {
101
- key: "getWalletPassEvaluator",
102
- value: function getWalletPassEvaluator() {
103
- var _this$window$getWalle, _this$window;
104
- return (_this$window$getWalle = (_this$window = this.window).getWalletPassEvaluator) === null || _this$window$getWalle === void 0 ? void 0 : _this$window$getWalle.call(_this$window);
105
- }
106
98
 
107
99
  // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
108
100
  }, {
@@ -131,7 +123,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
131
123
  newDiscountList = _ref.newDiscountList,
132
124
  productList = _ref.productList,
133
125
  holders = _ref.holders,
134
- orderTotalAmount = _ref.orderTotalAmount,
135
126
  isFormSubject = _ref.isFormSubject;
136
127
  // 首先检查是否有新的优惠券可应用
137
128
  if (!newDiscountList || newDiscountList.length === 0) {
@@ -166,7 +157,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
166
157
  discountList: mergedDiscountList,
167
158
  productList: _toConsumableArray(productList),
168
159
  holders: holders,
169
- orderTotalAmount: orderTotalAmount,
170
160
  isFormSubject: isFormSubject
171
161
  }, {
172
162
  scan: true
@@ -292,7 +282,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
292
282
  var discountList = _ref2.discountList,
293
283
  productList = _ref2.productList,
294
284
  holders = _ref2.holders,
295
- orderTotalAmount = _ref2.orderTotalAmount,
296
285
  isFormSubject = _ref2.isFormSubject;
297
286
  // 识别出来是不是在编辑的界面里又新增了商品
298
287
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
@@ -540,57 +529,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
540
529
  return priceB.minus(priceA).toNumber();
541
530
  });
542
531
 
543
- // 🔥 为每个折扣卡/商品券执行策略检查并附加config
544
- var evaluator = this.getWalletPassEvaluator();
545
- if (evaluator) {
546
- addModeDiscount.forEach(function (discount) {
547
- var discountType = discount.tag || discount.type;
548
- // 只对 good_pass 和 discount_card 类型执行策略检查
549
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
550
- var _discount$limited_rel, _discount$limited_rel2;
551
- // 转换 discount 为 Voucher 格式
552
- var voucher = {
553
- id: discount.id,
554
- amount: Number(discount.par_value || 0),
555
- balance: Number(discount.balance || 0),
556
- type: discountType,
557
- product_id: discount.product_id,
558
- unified_available_status: 1,
559
- available_product_type: (_discount$limited_rel = discount.limited_relation_product_data) === null || _discount$limited_rel === void 0 ? void 0 : _discount$limited_rel.type,
560
- available_product_ids: (_discount$limited_rel2 = discount.limited_relation_product_data) === null || _discount$limited_rel2 === void 0 ? void 0 : _discount$limited_rel2.product_ids
561
- };
562
-
563
- // 转换 sortedFlattenedList 为 Product 格式
564
- var productsForEvaluate = sortedFlattenedList.map(function (item) {
565
- return {
566
- product_id: item.id,
567
- price: item.price || 0,
568
- quantity: item.quantity || item.num || 1,
569
- selling_price: item.price || 0
570
- };
571
- });
572
-
573
- // 调用策略检查
574
- var result = evaluator.checkVoucherAvailability({
575
- orderTotalAmount: orderTotalAmount,
576
- products: productsForEvaluate,
577
- vouchers: [voucher]
578
- });
579
-
580
- // 将 config 附加到 discount 对象
581
- if (result.isAvailable) {
582
- discount.config = _objectSpread(_objectSpread({}, result.config), {}, {
583
- isAvailable: true
584
- });
585
- } else {
586
- discount.config = {
587
- isAvailable: false
588
- };
589
- }
590
- }
591
- });
592
- }
593
-
594
532
  /**
595
533
  // 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
596
534
  const sortedProductList = [...productList].sort((a, b) => {
@@ -611,9 +549,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
611
549
  // 标记已使用的优惠券
612
550
  var usedDiscounts = new Map();
613
551
 
614
- // 🔥 统计每个 product_id(商品券商品id)已使用的数量,用于 maxUsagePerOrder 限制
615
- var usedProductIdCounts = new Map();
616
-
617
552
  // 记录每个优惠券适用的商品ID
618
553
  var discountApplicability = new Map();
619
554
 
@@ -843,7 +778,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
843
778
  originProduct = flatItem.originProduct;
844
779
  }
845
780
  addModeDiscount.forEach(function (discount) {
846
- var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
781
+ var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4;
847
782
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
848
783
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
849
784
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
@@ -854,7 +789,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
854
789
  var timeLimit = true;
855
790
  timeLimit = !!filterDiscountListByBookingTime([discount], (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
856
791
  // 是符合折扣的商品
857
- var isLimitedProduct = (limitedData.type === 'product_all' && limitedData.filter !== 1 || limitedData.type === 'product_all' && limitedData.filter === 1 && !limitedData.exclude_product_ids.includes(product.id) || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
792
+ var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
858
793
 
859
794
  // 编辑的商品 使用了优惠券不可用
860
795
  var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
@@ -867,7 +802,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
867
802
  var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
868
803
 
869
804
  // 判断优惠券是否适用于该商品
870
- if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
805
+ if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
871
806
  var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
872
807
  // 记录此优惠券适用的商品
873
808
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -891,8 +826,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
891
826
  title: discount.format_title,
892
827
  original_amount: product.price || product.origin_total,
893
828
  pre_value: discount.par_value,
894
- product_id: originProduct.id,
895
- discount_product_id: discount.product_id
829
+ product_id: originProduct.id
896
830
  },
897
831
  metadata: {
898
832
  num: num
@@ -952,16 +886,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
952
886
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
953
887
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
954
888
  var _product$discount_lis3, _product$discount_lis4;
955
- // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
956
- var discountType = discount.tag || discount.type;
957
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
958
- var _discount$config2;
959
- // 如果策略检查后没有config,说明不可用
960
- if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
961
- return false;
962
- }
963
- }
964
-
965
889
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
966
890
  // 商品券时主商品价格为0不可用
967
891
  if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length) && (discount.tag || discount.type) === 'good_pass') return false;
@@ -974,18 +898,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
974
898
  // 如果优惠券已被使用,则跳过
975
899
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
976
900
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
977
-
978
- // 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
979
- if ((discount.tag || discount.type) === 'good_pass') {
980
- var _discount$config3;
981
- var maxUsagePerOrder = (_discount$config3 = discount.config) === null || _discount$config3 === void 0 ? void 0 : _discount$config3.maxUsagePerOrder;
982
- if (maxUsagePerOrder && maxUsagePerOrder > 0) {
983
- var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
984
- if (currentUsedCount >= maxUsagePerOrder) {
985
- return false;
986
- }
987
- }
988
- }
989
901
  var limitedData = discount.limited_relation_product_data;
990
902
 
991
903
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
@@ -1004,9 +916,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1004
916
 
1005
917
  // 判断优惠券是否适用于该商品
1006
918
  if (limitedData.type === 'product_all') {
1007
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
1008
- return false;
1009
- }
1010
919
  // 检查 package_sub_item_usage_rules
1011
920
  if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
1012
921
  return false;
@@ -1173,13 +1082,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1173
1082
  var availableGoodPassCount = applicableDiscounts.filter(function (item) {
1174
1083
  return (item.tag || item.type) === 'good_pass';
1175
1084
  }).length;
1176
-
1177
- // 🔥 如果selectedDiscount有config配置,则使用config.maxUsagePerOrder限制使用次数
1178
- var maxUsageLimit = availableGoodPassCount;
1179
- if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
1180
- maxUsageLimit = Math.min(availableGoodPassCount, selectedDiscount.config.maxUsagePerOrder);
1181
- }
1182
- var splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
1085
+ var splitCount = isNeedSplit ? Math.min(totalQuantity, availableGoodPassCount) : 1;
1183
1086
  var arr = [];
1184
1087
 
1185
1088
  // 🔥 主商品和bundle子商品分别处理
@@ -1189,8 +1092,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1189
1092
  arr.push(_this3.hooks.setProduct(originProduct, {
1190
1093
  discount_list: [],
1191
1094
  quantity: totalQuantity - splitCount,
1192
- _id: product._id.split('___')[0],
1193
- total: product.origin_total || product.total
1095
+ _id: product._id.split('___')[0]
1194
1096
  }));
1195
1097
  }
1196
1098
  for (var i = 0; i < splitCount; i++) {
@@ -1199,11 +1101,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1199
1101
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1200
1102
  // 标记优惠券为已使用
1201
1103
  usedDiscounts.set(_selectedDiscount.id, true);
1202
- // 🔥 更新 product_id 使用计数
1203
- if ((_selectedDiscount.tag || _selectedDiscount.type) === 'good_pass') {
1204
- var currentCount = usedProductIdCounts.get(_selectedDiscount.product_id) || 0;
1205
- usedProductIdCounts.set(_selectedDiscount.product_id, currentCount + 1);
1206
- }
1207
1104
 
1208
1105
  // 记录实际应用了优惠券的商品信息
1209
1106
  var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
@@ -1237,7 +1134,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1237
1134
  targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
1238
1135
  amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
1239
1136
  }
1240
- var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
1137
+ var discountType = _selectedDiscount.tag || _selectedDiscount.type;
1241
1138
  var isGoodPass = discountType === 'good_pass';
1242
1139
  var discountDetail = {
1243
1140
  amount: amount,
@@ -1250,12 +1147,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1250
1147
  title: _selectedDiscount.format_title,
1251
1148
  original_amount: product.price,
1252
1149
  product_id: originProduct.id,
1253
- percent: _selectedDiscount.par_value,
1254
- discount_product_id: _selectedDiscount.product_id
1150
+ percent: _selectedDiscount.par_value
1255
1151
  },
1256
1152
  // 前端使用的num数量,为了计算优惠金额
1257
1153
  _num: isGoodPass ? 1 : product.num,
1258
- config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1259
1154
  metadata: _objectSpread({
1260
1155
  num: 1
1261
1156
  }, productDiscountDifference !== undefined && {
@@ -1276,6 +1171,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1276
1171
  // 记录应用了优惠券的商品
1277
1172
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
1278
1173
  if (product.isClient) {
1174
+ debugger;
1279
1175
  arr.push(_this3.hooks.setProduct(originProduct, {
1280
1176
  discount_list: [discountDetail],
1281
1177
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
@@ -1317,20 +1213,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1317
1213
  var _selectedDiscount2$me;
1318
1214
  var _selectedDiscount2 = applicableDiscounts[_i];
1319
1215
  usedDiscounts.set(_selectedDiscount2.id, true);
1320
- // 🔥 更新 product_id 使用计数
1321
- if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
1322
- var _currentCount = usedProductIdCounts.get(_selectedDiscount2.product_id) || 0;
1323
- usedProductIdCounts.set(_selectedDiscount2.product_id, _currentCount + 1);
1324
- }
1325
1216
 
1326
1217
  // 🔥 生成唯一的 _id
1327
1218
  var uniqueId = "".concat(flatItem._id, "_split_").concat(_i);
1328
-
1329
- // 计算折扣后的价格(使用 getDiscountAmount,内部已处理 maxDeductionAmount)
1330
- var discountedPrice = getDiscountAmount(_selectedDiscount2, product.origin_total, product.origin_total);
1331
- var bundleDiscountAmount = new Decimal(product.origin_total || 0).minus(discountedPrice).toNumber();
1332
1219
  var _discountDetail = {
1333
- amount: bundleDiscountAmount,
1220
+ amount: product.origin_total,
1334
1221
  type: 'good_pass',
1335
1222
  discount: {
1336
1223
  fixed_amount: product.origin_total,
@@ -1338,16 +1225,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1338
1225
  resource_id: _selectedDiscount2.id,
1339
1226
  title: _selectedDiscount2.format_title,
1340
1227
  original_amount: product.origin_total,
1341
- product_id: product.id,
1342
- discount_product_id: _selectedDiscount2.product_id
1228
+ product_id: product.id
1343
1229
  },
1344
1230
  metadata: {
1345
1231
  // 🔥 使用拆分后的唯一 _id
1346
1232
  custom_product_bundle_map_id: uniqueId,
1347
1233
  num: 1
1348
1234
  },
1349
- _num: 1,
1350
- config: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.config
1235
+ _num: 1
1351
1236
  };
1352
1237
 
1353
1238
  // 记录实际应用的折扣
@@ -1359,9 +1244,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1359
1244
  _id: uniqueId,
1360
1245
  num: 1,
1361
1246
  quantity: 1,
1362
- price: discountedPrice,
1363
- // 折扣后的价格
1364
- total: discountedPrice,
1247
+ price: 0,
1248
+ // 商品券价格为0
1249
+ total: 0,
1365
1250
  discount_list: [_discountDetail],
1366
1251
  processed: true,
1367
1252
  _discountId: _selectedDiscount2.id
@@ -1384,11 +1269,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1384
1269
  // 折扣卡:不拆分数量,直接应用
1385
1270
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
1386
1271
  usedDiscounts.set(_selectedDiscount3.id, true);
1387
- // 🔥 更新 product_id 使用计数(虽然此处主要是折扣卡,但保持一致性)
1388
- if ((_selectedDiscount3.tag || _selectedDiscount3.type) === 'good_pass') {
1389
- var _currentCount2 = usedProductIdCounts.get(_selectedDiscount3.product_id) || 0;
1390
- usedProductIdCounts.set(_selectedDiscount3.product_id, _currentCount2 + 1);
1391
- }
1392
1272
  var _productOriginTotal = product.original_price || product.price || 0;
1393
1273
 
1394
1274
  // 🔥 检查是否是 order_level 固定金额折扣卡
@@ -1408,7 +1288,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1408
1288
  _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1409
1289
  fixedAmountPerItem = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1410
1290
  }
1411
-
1291
+ debugger;
1412
1292
  // 🔥 使用当前的 _id 作为唯一标识
1413
1293
  var _uniqueId = flatItem._id;
1414
1294
  var _discountDetail2 = {
@@ -1422,8 +1302,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1422
1302
  title: _selectedDiscount3.format_title,
1423
1303
  original_amount: product.original_price,
1424
1304
  product_id: product.id,
1425
- percent: _selectedDiscount3.par_value,
1426
- discount_product_id: _selectedDiscount3.product_id
1305
+ percent: _selectedDiscount3.par_value
1427
1306
  },
1428
1307
  metadata: _objectSpread({
1429
1308
  // 🔥 使用唯一的 _id
@@ -1432,7 +1311,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1432
1311
  }, _productDiscountDifference !== undefined && {
1433
1312
  product_discount_difference: _productDiscountDifference
1434
1313
  }),
1435
- config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
1436
1314
  _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
1437
1315
  };
1438
1316
 
@@ -31,7 +31,6 @@ export interface RulesModuleAPI {
31
31
  holders: {
32
32
  form_record_id: number;
33
33
  }[];
34
- orderTotalAmount: number;
35
34
  isFormSubject: boolean;
36
35
  }) => DiscountResult;
37
36
  }
@@ -0,0 +1,32 @@
1
+ import dayjs from "dayjs";
2
+ import { ScheduleItem } from "./types";
3
+ export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
4
+ export type ScheduleTimeSlot = {
5
+ /** 开始时间 HH:mm */
6
+ start_time: string;
7
+ /** 结束时间 HH:mm */
8
+ end_time: string;
9
+ /** 开始日期时间 YYYY-MM-DD HH:mm:ss */
10
+ start_at: dayjs.Dayjs;
11
+ /** 结束日期时间 YYYY-MM-DD HH:mm:ss */
12
+ end_at: dayjs.Dayjs;
13
+ };
14
+ /**
15
+ * 获取当前日期日程时间点
16
+ * @param date 日期 YYYY-MM-DD
17
+ * @param scheduleList 日程列表
18
+ * @returns 当前日期日程时间点 结构,数组 [{
19
+ *
20
+ * // HH:mm
21
+ * end_time: string,
22
+ * // HH:mm
23
+ * start_time: string,
24
+ * // 日期时间
25
+ * // YYYY-MM-DD HH:mm:ss
26
+ * end_at: Dayjs,
27
+ * // YYYY-MM-DD HH:mm:ss
28
+ * start_at: Dayjs,
29
+ *
30
+ * }]
31
+ */
32
+ export declare const getScheduleStartEndTimePoints: (date: string, scheduleList: ScheduleItem[]) => ScheduleTimeSlot[];