@pisell/pisellos 2.1.54 → 2.1.58

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 (100) 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/Discount/types.d.ts +0 -15
  6. package/dist/modules/Payment/index.d.ts +1 -2
  7. package/dist/modules/Payment/index.js +7 -10
  8. package/dist/modules/Payment/utils.js +0 -3
  9. package/dist/modules/Payment/walletpass.d.ts +0 -23
  10. package/dist/modules/Payment/walletpass.js +95 -191
  11. package/dist/modules/Product/index.d.ts +1 -1
  12. package/dist/modules/Rules/index.d.ts +5 -8
  13. package/dist/modules/Rules/index.js +31 -154
  14. package/dist/modules/Rules/types.d.ts +1 -1
  15. package/dist/modules/Summary/types.d.ts +0 -2
  16. package/dist/modules/Summary/utils.d.ts +0 -6
  17. package/dist/modules/Summary/utils.js +0 -21
  18. package/dist/plugins/window.d.ts +0 -2
  19. package/dist/solution/BookingByStep/index.d.ts +0 -1
  20. package/dist/solution/BookingTicket/index.d.ts +1 -1
  21. package/dist/solution/Checkout/index.js +0 -2
  22. package/dist/solution/ShopDiscount/index.d.ts +4 -1
  23. package/dist/solution/ShopDiscount/index.js +11 -12
  24. package/dist/solution/ShopDiscount/types.d.ts +4 -1
  25. package/dist/solution/ShopDiscount/utils.js +11 -26
  26. package/lib/index.d.ts +0 -1
  27. package/lib/index.js +1 -3
  28. package/lib/modules/Cart/types.d.ts +0 -2
  29. package/lib/modules/Cart/utils/cartProduct.js +0 -9
  30. package/lib/modules/Discount/types.d.ts +0 -15
  31. package/lib/modules/Payment/index.d.ts +1 -2
  32. package/lib/modules/Payment/index.js +0 -1
  33. package/lib/modules/Payment/utils.js +0 -3
  34. package/lib/modules/Payment/walletpass.d.ts +0 -23
  35. package/lib/modules/Payment/walletpass.js +17 -94
  36. package/lib/modules/Product/index.d.ts +1 -1
  37. package/lib/modules/Rules/index.d.ts +5 -8
  38. package/lib/modules/Rules/index.js +197 -372
  39. package/lib/modules/Rules/types.d.ts +1 -1
  40. package/lib/modules/Summary/types.d.ts +0 -2
  41. package/lib/modules/Summary/utils.d.ts +0 -6
  42. package/lib/modules/Summary/utils.js +0 -15
  43. package/lib/plugins/window.d.ts +0 -2
  44. package/lib/solution/BookingByStep/index.d.ts +0 -1
  45. package/lib/solution/BookingTicket/index.d.ts +1 -1
  46. package/lib/solution/BookingTicket/index.js +6 -0
  47. package/lib/solution/Checkout/index.js +0 -2
  48. package/lib/solution/ShopDiscount/index.d.ts +4 -1
  49. package/lib/solution/ShopDiscount/index.js +9 -8
  50. package/lib/solution/ShopDiscount/types.d.ts +4 -1
  51. package/lib/solution/ShopDiscount/utils.js +6 -10
  52. package/package.json +1 -1
  53. package/dist/model/index.d.ts +0 -1
  54. package/dist/model/index.js +0 -1
  55. package/dist/model/strategy/adapter/index.d.ts +0 -3
  56. package/dist/model/strategy/adapter/index.js +0 -4
  57. package/dist/model/strategy/adapter/type.d.ts +0 -28
  58. package/dist/model/strategy/adapter/type.js +0 -1
  59. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  60. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -496
  61. package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
  62. package/dist/model/strategy/adapter/walletPass/example.js +0 -258
  63. package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
  64. package/dist/model/strategy/adapter/walletPass/index.js +0 -182
  65. package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  66. package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
  67. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -163
  68. package/dist/model/strategy/adapter/walletPass/type.js +0 -1
  69. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  70. package/dist/model/strategy/adapter/walletPass/utils.js +0 -965
  71. package/dist/model/strategy/index.d.ts +0 -94
  72. package/dist/model/strategy/index.js +0 -551
  73. package/dist/model/strategy/strategy-example.d.ts +0 -5
  74. package/dist/model/strategy/strategy-example.js +0 -331
  75. package/dist/model/strategy/type.d.ts +0 -228
  76. package/dist/model/strategy/type.js +0 -94
  77. package/lib/model/index.d.ts +0 -1
  78. package/lib/model/index.js +0 -23
  79. package/lib/model/strategy/adapter/index.d.ts +0 -3
  80. package/lib/model/strategy/adapter/index.js +0 -45
  81. package/lib/model/strategy/adapter/type.d.ts +0 -28
  82. package/lib/model/strategy/adapter/type.js +0 -17
  83. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  84. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -420
  85. package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
  86. package/lib/model/strategy/adapter/walletPass/example.js +0 -207
  87. package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
  88. package/lib/model/strategy/adapter/walletPass/index.js +0 -142
  89. package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  90. package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
  91. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -163
  92. package/lib/model/strategy/adapter/walletPass/type.js +0 -17
  93. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  94. package/lib/model/strategy/adapter/walletPass/utils.js +0 -660
  95. package/lib/model/strategy/index.d.ts +0 -94
  96. package/lib/model/strategy/index.js +0 -413
  97. package/lib/model/strategy/strategy-example.d.ts +0 -5
  98. package/lib/model/strategy/strategy-example.js +0 -318
  99. package/lib/model/strategy/type.d.ts +0 -228
  100. package/lib/model/strategy/type.js +0 -44
@@ -24,11 +24,12 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
24
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
25
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
26
  import { BaseModule } from "../BaseModule";
27
- import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
27
+ import { uniqueById, getDiscountAmount, filterDiscountListByBookingTime, getDiscountListAmountTotal, getDiscountListAmount } from "../../solution/ShopDiscount/utils";
28
28
  import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
29
29
  import Decimal from 'decimal.js';
30
30
  import { isBoolean } from 'lodash-es';
31
31
  import dayjs from 'dayjs';
32
+
32
33
  // 临时变量
33
34
  var flatItem;
34
35
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
@@ -41,8 +42,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
41
42
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'rules');
42
43
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
43
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
44
- _defineProperty(_assertThisInitialized(_this), "window", void 0);
45
- // WindowPlugin 实例
46
45
  _defineProperty(_assertThisInitialized(_this), "hooks", void 0);
47
46
  _this.hooks = {};
48
47
  return _this;
@@ -57,8 +56,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
57
56
  this.core = core;
58
57
  this.hooks = options === null || options === void 0 ? void 0 : options.hooks;
59
58
  this.store = options === null || options === void 0 ? void 0 : options.store;
60
- this.window = core.getPlugin('window');
61
- case 4:
59
+ case 3:
62
60
  case "end":
63
61
  return _context.stop();
64
62
  }
@@ -95,12 +93,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
95
93
  value: function getRulesList() {
96
94
  return this.store.rulesList;
97
95
  }
98
- }, {
99
- key: "getWalletPassEvaluator",
100
- value: function getWalletPassEvaluator() {
101
- var _this$window$getWalle, _this$window;
102
- return (_this$window$getWalle = (_this$window = this.window).getWalletPassEvaluator) === null || _this$window$getWalle === void 0 ? void 0 : _this$window$getWalle.call(_this$window);
103
- }
104
96
 
105
97
  // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
106
98
  }, {
@@ -130,7 +122,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
130
122
  newDiscountList = _ref.newDiscountList,
131
123
  productList = _ref.productList,
132
124
  holders = _ref.holders,
133
- orderTotalAmount = _ref.orderTotalAmount;
125
+ isFormSubject = _ref.isFormSubject;
134
126
  // 首先检查是否有新的优惠券可应用
135
127
  if (!newDiscountList || newDiscountList.length === 0) {
136
128
  return {
@@ -162,7 +154,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
162
154
  discountList: mergedDiscountList,
163
155
  productList: _toConsumableArray(productList),
164
156
  holders: holders,
165
- orderTotalAmount: orderTotalAmount
157
+ isFormSubject: isFormSubject
166
158
  }, {
167
159
  scan: true
168
160
  });
@@ -206,7 +198,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
206
198
  var discountList = _ref2.discountList,
207
199
  productList = _ref2.productList,
208
200
  holders = _ref2.holders,
209
- orderTotalAmount = _ref2.orderTotalAmount;
201
+ isFormSubject = _ref2.isFormSubject;
210
202
  // 识别出来是不是在编辑的界面里又新增了商品
211
203
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
212
204
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -380,57 +372,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
380
372
  return priceB.minus(priceA).toNumber();
381
373
  });
382
374
 
383
- // 🔥 为每个折扣卡/商品券执行策略检查并附加config
384
- var evaluator = this.getWalletPassEvaluator();
385
- if (evaluator) {
386
- addModeDiscount.forEach(function (discount) {
387
- var discountType = discount.tag || discount.type;
388
- // 只对 good_pass 和 discount_card 类型执行策略检查
389
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
390
- var _discount$limited_rel, _discount$limited_rel2;
391
- // 转换 discount 为 Voucher 格式
392
- var voucher = {
393
- id: discount.id,
394
- amount: Number(discount.par_value || 0),
395
- balance: Number(discount.balance || 0),
396
- type: discountType,
397
- product_id: discount.product_id,
398
- unified_available_status: 1,
399
- available_product_type: (_discount$limited_rel = discount.limited_relation_product_data) === null || _discount$limited_rel === void 0 ? void 0 : _discount$limited_rel.type,
400
- available_product_ids: (_discount$limited_rel2 = discount.limited_relation_product_data) === null || _discount$limited_rel2 === void 0 ? void 0 : _discount$limited_rel2.product_ids
401
- };
402
-
403
- // 转换 sortedFlattenedList 为 Product 格式
404
- var productsForEvaluate = sortedFlattenedList.map(function (item) {
405
- return {
406
- product_id: item.id,
407
- price: item.price || 0,
408
- quantity: item.quantity || item.num || 1,
409
- selling_price: item.price || 0
410
- };
411
- });
412
-
413
- // 调用策略检查
414
- var result = evaluator.checkVoucherAvailability({
415
- orderTotalAmount: orderTotalAmount,
416
- products: productsForEvaluate,
417
- vouchers: [voucher]
418
- });
419
-
420
- // 将 config 附加到 discount 对象
421
- if (result.isAvailable) {
422
- discount.config = _objectSpread(_objectSpread({}, result.config), {}, {
423
- isAvailable: true
424
- });
425
- } else {
426
- discount.config = {
427
- isAvailable: false
428
- };
429
- }
430
- }
431
- });
432
- }
433
-
434
375
  /**
435
376
  // 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
436
377
  const sortedProductList = [...productList].sort((a, b) => {
@@ -451,9 +392,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
451
392
  // 标记已使用的优惠券
452
393
  var usedDiscounts = new Map();
453
394
 
454
- // 🔥 统计每个 product_id(商品券商品id)已使用的数量,用于 maxUsagePerOrder 限制
455
- var usedProductIdCounts = new Map();
456
-
457
395
  // 记录每个优惠券适用的商品ID
458
396
  var discountApplicability = new Map();
459
397
 
@@ -496,18 +434,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
496
434
  originProduct = flatItem.originProduct;
497
435
  }
498
436
  addModeDiscount.forEach(function (discount) {
499
- var _product, _product2, _product3, _product4, _flatItem$bundleItem, _discount$config;
437
+ var _product, _product2, _product3, _product4, _flatItem$bundleItem;
500
438
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
501
439
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
502
440
  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;
503
441
  var isHolderMatch = _this3.checkHolderMatch(discount, {
504
- isNeedHolder: _tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.isNeedHolder,
442
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
505
443
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
506
444
  }, holders);
507
445
  var timeLimit = true;
508
446
  timeLimit = !!filterDiscountListByBookingTime([discount], (((_product = product) === null || _product === void 0 ? void 0 : _product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
509
447
  // 是符合折扣的商品
510
- 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;
448
+ var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
511
449
 
512
450
  // 编辑的商品 使用了优惠券不可用
513
451
  var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (discount) {
@@ -518,7 +456,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
518
456
  var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
519
457
 
520
458
  // 判断优惠券是否适用于该商品
521
- if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
459
+ if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
522
460
  var _discountApplicabilit, _discount$metadata;
523
461
  // 记录此优惠券适用的商品
524
462
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -541,8 +479,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
541
479
  title: discount.format_title,
542
480
  original_amount: product.price || product.origin_total,
543
481
  pre_value: discount.par_value,
544
- product_id: originProduct.id,
545
- discount_product_id: discount.product_id
482
+ product_id: originProduct.id
546
483
  },
547
484
  metadata: {
548
485
  num: num
@@ -601,16 +538,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
601
538
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
602
539
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
603
540
  var _product$discount_lis3, _product$discount_lis4;
604
- // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
605
- var discountType = discount.tag || discount.type;
606
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
607
- var _discount$config2;
608
- // 如果策略检查后没有config,说明不可用
609
- if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
610
- return false;
611
- }
612
- }
613
-
614
541
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
615
542
  // 商品券时主商品价格为0不可用
616
543
  if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.find(function (n) {
@@ -626,24 +553,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
626
553
  // 如果优惠券已被使用,则跳过
627
554
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
628
555
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
629
-
630
- // 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
631
- if ((discount.tag || discount.type) === 'good_pass') {
632
- var _discount$config3;
633
- var maxUsagePerOrder = (_discount$config3 = discount.config) === null || _discount$config3 === void 0 ? void 0 : _discount$config3.maxUsagePerOrder;
634
- if (maxUsagePerOrder && maxUsagePerOrder > 0) {
635
- var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
636
- if (currentUsedCount >= maxUsagePerOrder) {
637
- return false;
638
- }
639
- }
640
- }
641
556
  var limitedData = discount.limited_relation_product_data;
642
557
 
643
558
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
644
559
  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;
645
560
  var isHolderMatch = _this3.checkHolderMatch(discount, {
646
- isNeedHolder: _tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.isNeedHolder,
561
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
647
562
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
648
563
  }, holders);
649
564
  // 如果 holder 不匹配,则不适用
@@ -656,9 +571,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
656
571
 
657
572
  // 判断优惠券是否适用于该商品
658
573
  if (limitedData.type === 'product_all') {
659
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
660
- return false;
661
- }
662
574
  // 检查 package_sub_item_usage_rules
663
575
  if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
664
576
  return false;
@@ -825,13 +737,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
825
737
  var availableGoodPassCount = applicableDiscounts.filter(function (item) {
826
738
  return (item.tag || item.type) === 'good_pass';
827
739
  }).length;
828
-
829
- // 🔥 如果selectedDiscount有config配置,则使用config.maxUsagePerOrder限制使用次数
830
- var maxUsageLimit = availableGoodPassCount;
831
- if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
832
- maxUsageLimit = Math.min(availableGoodPassCount, selectedDiscount.config.maxUsagePerOrder);
833
- }
834
- var splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
740
+ var splitCount = isNeedSplit ? Math.min(totalQuantity, availableGoodPassCount) : 1;
835
741
  var arr = [];
836
742
 
837
743
  // 🔥 主商品和bundle子商品分别处理
@@ -841,8 +747,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
841
747
  arr.push(_this3.hooks.setProduct(originProduct, {
842
748
  discount_list: [],
843
749
  quantity: totalQuantity - splitCount,
844
- _id: product._id.split('___')[0],
845
- total: product.origin_total || product.total
750
+ _id: product._id.split('___')[0]
846
751
  }));
847
752
  }
848
753
  for (var i = 0; i < splitCount; i++) {
@@ -851,11 +756,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
851
756
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
852
757
  // 标记优惠券为已使用
853
758
  usedDiscounts.set(_selectedDiscount.id, true);
854
- // 🔥 更新 product_id 使用计数
855
- if ((_selectedDiscount.tag || _selectedDiscount.type) === 'good_pass') {
856
- var currentCount = usedProductIdCounts.get(_selectedDiscount.product_id) || 0;
857
- usedProductIdCounts.set(_selectedDiscount.product_id, currentCount + 1);
858
- }
859
759
 
860
760
  // 记录实际应用了优惠券的商品信息
861
761
  var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
@@ -873,27 +773,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
873
773
 
874
774
  // 计算使用折扣卡/商品券以后,单个商品的总 total
875
775
  var targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
876
- var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
877
-
878
- // 计算实际折扣金额
879
- var actualDiscountAmount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
776
+ var discountType = _selectedDiscount.tag || _selectedDiscount.type;
880
777
  var isGoodPass = discountType === 'good_pass';
778
+ var amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
881
779
  var discountDetail = {
882
- amount: actualDiscountAmount,
883
- type: discountType,
780
+ amount: amount,
781
+ type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : discountType,
884
782
  discount: {
885
783
  discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
886
- fixed_amount: actualDiscountAmount,
784
+ fixed_amount: amount,
887
785
  resource_id: _selectedDiscount.id,
888
786
  title: _selectedDiscount.format_title,
889
787
  original_amount: product.price,
890
788
  product_id: originProduct.id,
891
- percent: _selectedDiscount.par_value,
892
- discount_product_id: _selectedDiscount.product_id
789
+ percent: _selectedDiscount.par_value
893
790
  },
894
791
  // 前端使用的num数量,为了计算优惠金额
895
792
  _num: isGoodPass ? 1 : product.num,
896
- config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
897
793
  metadata: {
898
794
  num: 1
899
795
  }
@@ -912,6 +808,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
912
808
  // 记录应用了优惠券的商品
913
809
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
914
810
  if (product.isClient) {
811
+ debugger;
915
812
  arr.push(_this3.hooks.setProduct(originProduct, {
916
813
  discount_list: [discountDetail],
917
814
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
@@ -952,36 +849,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
952
849
  for (var _i = 0; _i < discountNum; _i++) {
953
850
  var _selectedDiscount2 = applicableDiscounts[_i];
954
851
  usedDiscounts.set(_selectedDiscount2.id, true);
955
- // 🔥 更新 product_id 使用计数
956
- if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
957
- var _currentCount = usedProductIdCounts.get(_selectedDiscount2.product_id) || 0;
958
- usedProductIdCounts.set(_selectedDiscount2.product_id, _currentCount + 1);
959
- }
960
852
 
961
853
  // 🔥 生成唯一的 _id
962
854
  var uniqueId = "".concat(flatItem._id, "_split_").concat(_i);
963
-
964
- // 计算折扣后的价格(使用 getDiscountAmount,内部已处理 maxDeductionAmount)
965
- var discountedPrice = getDiscountAmount(_selectedDiscount2, product.origin_total, product.origin_total);
966
- var bundleDiscountAmount = new Decimal(product.origin_total || 0).minus(discountedPrice).toNumber();
967
855
  var _discountDetail = {
968
- amount: bundleDiscountAmount,
856
+ amount: product.origin_total,
969
857
  type: 'good_pass',
970
858
  discount: {
971
859
  fixed_amount: product.origin_total,
972
860
  resource_id: _selectedDiscount2.id,
973
861
  title: _selectedDiscount2.format_title,
974
862
  original_amount: product.origin_total,
975
- product_id: product.id,
976
- discount_product_id: _selectedDiscount2.product_id
863
+ product_id: product.id
977
864
  },
978
865
  metadata: {
979
866
  // 🔥 使用拆分后的唯一 _id
980
867
  custom_product_bundle_map_id: uniqueId,
981
868
  num: 1
982
869
  },
983
- _num: 1,
984
- config: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.config
870
+ _num: 1
985
871
  };
986
872
 
987
873
  // 记录实际应用的折扣
@@ -993,9 +879,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
993
879
  _id: uniqueId,
994
880
  num: 1,
995
881
  quantity: 1,
996
- price: discountedPrice,
997
- // 折扣后的价格
998
- total: discountedPrice,
882
+ price: 0,
883
+ // 商品券价格为0
884
+ total: 0,
999
885
  discount_list: [_discountDetail],
1000
886
  processed: true,
1001
887
  _discountId: _selectedDiscount2.id
@@ -1018,38 +904,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1018
904
  // 折扣卡:不拆分数量,直接应用
1019
905
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
1020
906
  usedDiscounts.set(_selectedDiscount3.id, true);
1021
- // 🔥 更新 product_id 使用计数(虽然此处主要是折扣卡,但保持一致性)
1022
- if ((_selectedDiscount3.tag || _selectedDiscount3.type) === 'good_pass') {
1023
- var _currentCount2 = usedProductIdCounts.get(_selectedDiscount3.product_id) || 0;
1024
- usedProductIdCounts.set(_selectedDiscount3.product_id, _currentCount2 + 1);
1025
- }
1026
907
  var _productOriginTotal = product.original_price || product.price || 0;
1027
908
  var _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1028
909
 
1029
- // 计算实际折扣金额
1030
- var bundleActualDiscountAmount = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1031
-
1032
910
  // 🔥 使用当前的 _id 作为唯一标识
1033
911
  var _uniqueId = flatItem._id;
1034
912
  var _discountDetail2 = {
1035
- amount: bundleActualDiscountAmount * (product.num || 1),
913
+ amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber() * (product.num || 1),
1036
914
  type: _selectedDiscount3.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount3.tag,
1037
915
  discount: {
1038
916
  discount_card_type: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me = _selectedDiscount3.metadata) === null || _selectedDiscount3$me === void 0 ? void 0 : _selectedDiscount3$me.discount_card_type,
1039
- fixed_amount: bundleActualDiscountAmount,
917
+ fixed_amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber(),
1040
918
  resource_id: _selectedDiscount3.id,
1041
919
  title: _selectedDiscount3.format_title,
1042
920
  original_amount: product.original_price,
1043
921
  product_id: product.id,
1044
- percent: _selectedDiscount3.par_value,
1045
- discount_product_id: _selectedDiscount3.product_id
922
+ percent: _selectedDiscount3.par_value
1046
923
  },
1047
924
  metadata: {
1048
925
  // 🔥 使用唯一的 _id
1049
926
  custom_product_bundle_map_id: _uniqueId,
1050
927
  num: product.num || 1
1051
928
  },
1052
- config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
1053
929
  _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.num) || 1)
1054
930
  };
1055
931
 
@@ -1115,6 +991,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1115
991
 
1116
992
  // 检查是否有bundle子商品需要重组
1117
993
  var hasBundle = product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0;
994
+ debugger;
1118
995
  if (!hasBundle) {
1119
996
  // 没有bundle,直接使用主商品处理结果
1120
997
  result.push.apply(result, _toConsumableArray(mainProductArr));
@@ -25,7 +25,7 @@ export interface RulesModuleAPI {
25
25
  holders: {
26
26
  form_record_id: number;
27
27
  }[];
28
- orderTotalAmount: number;
28
+ isFormSubject: boolean;
29
29
  }) => DiscountResult;
30
30
  }
31
31
  type ProductDetail = {
@@ -5,8 +5,6 @@ export interface ISummaryState {
5
5
  subtotal: string | number;
6
6
  /** 最终总价 */
7
7
  total: string | number;
8
- /** 最终原始价格 不包含折扣卡商品券折扣 */
9
- originTotal: string | number;
10
8
  /** 税率标题 */
11
9
  taxTitle?: string;
12
10
  /** 商品总费率 */
@@ -8,12 +8,6 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) =
8
8
  * @returns 商品总价字符串,保留2位小数
9
9
  */
10
10
  export declare const calculateSubtotal: (items: CartItem[]) => string;
11
- /**
12
- * 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
13
- * @param items - 购物车商品数组
14
- * @returns 商品总价字符串,保留2位小数
15
- */
16
- export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
17
11
  /**
18
12
  * @title: 单个商品的税费
19
13
  * @description:
@@ -1,21 +1,16 @@
1
1
  import Decimal from 'decimal.js';
2
2
  export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items) {
3
3
  var subtotal = new Decimal(calculateSubtotal(items));
4
- var subOriginTotal = new Decimal(calculateOriginSubtotal(items));
5
4
  var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
6
5
 
7
6
  // 计算总价
8
7
  var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal : subtotal.plus(totalTaxFee);
9
8
 
10
- // 计算总价 不包含折扣卡商品券折扣信息价格
11
- var originTotal = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
12
-
13
9
  // 计算定金
14
10
  var deposit = calculateDeposit(items);
15
11
  return {
16
12
  subtotal: subtotal.toFixed(2),
17
13
  total: total.toFixed(2),
18
- originTotal: originTotal.toFixed(2),
19
14
  taxTitle: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_title,
20
15
  totalTaxFee: totalTaxFee.toFixed(2),
21
16
  isPriceIncludeTax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax,
@@ -39,22 +34,6 @@ export var calculateSubtotal = function calculateSubtotal(items) {
39
34
  return subtotal.toFixed(2);
40
35
  };
41
36
 
42
- /**
43
- * 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
44
- * @param items - 购物车商品数组
45
- * @returns 商品总价字符串,保留2位小数
46
- */
47
- export var calculateOriginSubtotal = function calculateOriginSubtotal(items) {
48
- if (!(items !== null && items !== void 0 && items.length)) {
49
- return '0.00';
50
- }
51
- var subtotal = items.reduce(function (sum, item) {
52
- var cartItemTotalPrice = new Decimal(item.summaryOriginTotal || 0);
53
- return sum.plus(cartItemTotalPrice);
54
- }, new Decimal(0));
55
- return subtotal.toFixed(2);
56
- };
57
-
58
37
  /**
59
38
  * @title: 单个商品的税费
60
39
  * @description:
@@ -1,4 +1,3 @@
1
- import { WalletPassEvaluator } from '../model';
2
1
  import { Plugin } from '../types';
3
2
  /**
4
3
  * WindowPlugin 接口定义
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
15
14
  document: Partial<Document>;
16
15
  history: History;
17
16
  interaction?: any;
18
- getWalletPassEvaluator?: () => WalletPassEvaluator;
19
17
  }
20
18
  /**
21
19
  * 简单的 Storage 接口实现
@@ -144,7 +144,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
144
144
  getSummary(): Promise<{
145
145
  subtotal: string | number;
146
146
  total: string | number;
147
- originTotal: string | number;
148
147
  taxTitle?: string | undefined;
149
148
  totalTaxFee?: string | number | undefined;
150
149
  isPriceIncludeTax?: 0 | 1 | undefined;
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -403,7 +403,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
403
403
  product_id: item.product_id,
404
404
  product_variant_id: item.product_variant_id,
405
405
  quantity: item.num,
406
- is_price_include_tax: item.is_price_include_tax,
407
406
  // 商品是否含税:1;0
408
407
  is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
409
408
  // 若商品不含税,计算得到的税费,单位(元)
@@ -428,7 +427,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
428
427
  },
429
428
  product_bundle: item.product_bundle.map(function (bundle) {
430
429
  return {
431
- is_price_include_tax: item.is_price_include_tax,
432
430
  bundle_id: bundle.bundle_id,
433
431
  bundle_product_id: bundle.bundle_product_id,
434
432
  bundle_variant_id: bundle.bundle_variant_id,
@@ -21,10 +21,13 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
21
21
  getCurrentBookingTime(): string | null;
22
22
  private filterDiscountListByBookingTime;
23
23
  setCustomer(customer: Customer): Promise<void>;
24
- setOriginTotalAmount(amount: number): void;
25
24
  setHolders(holders: {
26
25
  form_record_id: number;
27
26
  }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
28
31
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
29
32
  productList: Record<string, any>[];
30
33
  discountList: Discount[];
@@ -55,7 +55,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
55
55
  originalDiscountList: [],
56
56
  currentBookingTime: "",
57
57
  filteredDiscountList: [],
58
- orderTotalAmount: 0
58
+ bookingSubject: undefined
59
59
  };
60
60
  return _this;
61
61
  }
@@ -287,24 +287,23 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
287
287
  return _setCustomer.apply(this, arguments);
288
288
  }
289
289
  return setCustomer;
290
- }()
291
- }, {
292
- key: "setOriginTotalAmount",
293
- value: function setOriginTotalAmount(amount) {
294
- this.store.orderTotalAmount = amount;
295
- }
296
-
297
- // 设置holders
290
+ }() // 设置holders
298
291
  }, {
299
292
  key: "setHolders",
300
293
  value: function setHolders(holders) {
301
294
  this.store.holders = holders;
302
295
  }
296
+ }, {
297
+ key: "setBookingSubject",
298
+ value: function setBookingSubject(bookingSubject) {
299
+ this.store.bookingSubject = bookingSubject;
300
+ }
303
301
 
304
302
  // 计算优惠券
305
303
  }, {
306
304
  key: "calcDiscount",
307
305
  value: function calcDiscount(productList, options) {
306
+ var _this$store$bookingSu;
308
307
  this.store.productList = productList;
309
308
  var rulesModule = this.core.getModule("".concat(this.name, "_rules"));
310
309
  if (!rulesModule) {
@@ -317,7 +316,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
317
316
  productList: productList,
318
317
  discountList: this.getDiscountList(),
319
318
  holders: this.store.holders || [],
320
- orderTotalAmount: this.store.orderTotalAmount || 0
319
+ isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
321
320
  }, options) || {
322
321
  productList: productList,
323
322
  discountList: this.getDiscountList()
@@ -390,7 +389,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
390
389
  key: "scanCode",
391
390
  value: function () {
392
391
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
393
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
392
+ var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
394
393
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
395
394
  while (1) switch (_context5.prev = _context5.next) {
396
395
  case 0:
@@ -457,7 +456,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
457
456
  oldDiscountList: this.getDiscountList(),
458
457
  newDiscountList: withScanList,
459
458
  holders: this.store.holders || [],
460
- orderTotalAmount: this.store.orderTotalAmount || 0
459
+ isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
461
460
  }) || {
462
461
  isAvailable: false,
463
462
  productList: this.store.productList || [],
@@ -31,7 +31,10 @@ export interface ShopDiscountState {
31
31
  originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
- orderTotalAmount?: number;
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
35
38
  }
36
39
  export interface SetDiscountSelectedParams {
37
40
  discountId: number;