@pisell/pisellos 2.1.60 → 2.1.62

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 (99) 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/Customer/index.js +1 -1
  6. package/dist/modules/Discount/types.d.ts +0 -15
  7. package/dist/modules/Payment/index.d.ts +1 -2
  8. package/dist/modules/Payment/index.js +7 -10
  9. package/dist/modules/Payment/utils.js +0 -3
  10. package/dist/modules/Payment/walletpass.d.ts +0 -23
  11. package/dist/modules/Payment/walletpass.js +95 -191
  12. package/dist/modules/Rules/index.d.ts +3 -8
  13. package/dist/modules/Rules/index.js +36 -164
  14. package/dist/modules/Rules/types.d.ts +0 -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 +0 -1
  23. package/dist/solution/ShopDiscount/index.js +1 -11
  24. package/dist/solution/ShopDiscount/types.d.ts +0 -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/Customer/index.js +1 -1
  31. package/lib/modules/Discount/types.d.ts +0 -15
  32. package/lib/modules/Payment/index.d.ts +1 -2
  33. package/lib/modules/Payment/index.js +0 -1
  34. package/lib/modules/Payment/utils.js +0 -3
  35. package/lib/modules/Payment/walletpass.d.ts +0 -23
  36. package/lib/modules/Payment/walletpass.js +17 -94
  37. package/lib/modules/Rules/index.d.ts +3 -8
  38. package/lib/modules/Rules/index.js +197 -375
  39. package/lib/modules/Rules/types.d.ts +0 -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/Checkout/index.js +0 -2
  47. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  48. package/lib/solution/ShopDiscount/index.js +0 -6
  49. package/lib/solution/ShopDiscount/types.d.ts +0 -1
  50. package/lib/solution/ShopDiscount/utils.js +6 -10
  51. package/package.json +1 -1
  52. package/dist/model/index.d.ts +0 -1
  53. package/dist/model/index.js +0 -1
  54. package/dist/model/strategy/adapter/index.d.ts +0 -3
  55. package/dist/model/strategy/adapter/index.js +0 -4
  56. package/dist/model/strategy/adapter/type.d.ts +0 -28
  57. package/dist/model/strategy/adapter/type.js +0 -1
  58. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  59. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -496
  60. package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
  61. package/dist/model/strategy/adapter/walletPass/example.js +0 -258
  62. package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
  63. package/dist/model/strategy/adapter/walletPass/index.js +0 -182
  64. package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  65. package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
  66. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -163
  67. package/dist/model/strategy/adapter/walletPass/type.js +0 -1
  68. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  69. package/dist/model/strategy/adapter/walletPass/utils.js +0 -965
  70. package/dist/model/strategy/index.d.ts +0 -94
  71. package/dist/model/strategy/index.js +0 -551
  72. package/dist/model/strategy/strategy-example.d.ts +0 -5
  73. package/dist/model/strategy/strategy-example.js +0 -331
  74. package/dist/model/strategy/type.d.ts +0 -228
  75. package/dist/model/strategy/type.js +0 -94
  76. package/lib/model/index.d.ts +0 -1
  77. package/lib/model/index.js +0 -23
  78. package/lib/model/strategy/adapter/index.d.ts +0 -3
  79. package/lib/model/strategy/adapter/index.js +0 -45
  80. package/lib/model/strategy/adapter/type.d.ts +0 -28
  81. package/lib/model/strategy/adapter/type.js +0 -17
  82. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
  83. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -420
  84. package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
  85. package/lib/model/strategy/adapter/walletPass/example.js +0 -207
  86. package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
  87. package/lib/model/strategy/adapter/walletPass/index.js +0 -142
  88. package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
  89. package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
  90. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -163
  91. package/lib/model/strategy/adapter/walletPass/type.js +0 -17
  92. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
  93. package/lib/model/strategy/adapter/walletPass/utils.js +0 -660
  94. package/lib/model/strategy/index.d.ts +0 -94
  95. package/lib/model/strategy/index.js +0 -413
  96. package/lib/model/strategy/strategy-example.d.ts +0 -5
  97. package/lib/model/strategy/strategy-example.js +0 -318
  98. package/lib/model/strategy/type.d.ts +0 -228
  99. 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,6 @@ 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,
134
125
  isFormSubject = _ref.isFormSubject;
135
126
  // 首先检查是否有新的优惠券可应用
136
127
  if (!newDiscountList || newDiscountList.length === 0) {
@@ -163,7 +154,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
163
154
  discountList: mergedDiscountList,
164
155
  productList: _toConsumableArray(productList),
165
156
  holders: holders,
166
- orderTotalAmount: orderTotalAmount,
167
157
  isFormSubject: isFormSubject
168
158
  }, {
169
159
  scan: true
@@ -208,7 +198,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
208
198
  var discountList = _ref2.discountList,
209
199
  productList = _ref2.productList,
210
200
  holders = _ref2.holders,
211
- orderTotalAmount = _ref2.orderTotalAmount,
212
201
  isFormSubject = _ref2.isFormSubject;
213
202
  // 识别出来是不是在编辑的界面里又新增了商品
214
203
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
@@ -360,8 +349,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
360
349
 
361
350
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
362
351
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
363
- var priceA = new Decimal(a.price || '0');
364
- var priceB = new Decimal(b.price || '0');
352
+ var _ref3, _a$original_price, _ref4, _b$original_price;
353
+ // 子商品优先使用 original_price,主商品使用 price
354
+ var priceA = new Decimal(a.type === 'bundle' ? (_ref3 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref3 !== void 0 ? _ref3 : '0' : a.price || '0');
355
+ var priceB = new Decimal(b.type === 'bundle' ? (_ref4 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : b.price || '0');
365
356
  if (priceA.equals(priceB)) {
366
357
  // 价格相同时,主商品优先
367
358
  if (a.type !== b.type) {
@@ -383,57 +374,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
383
374
  return priceB.minus(priceA).toNumber();
384
375
  });
385
376
 
386
- // 🔥 为每个折扣卡/商品券执行策略检查并附加config
387
- var evaluator = this.getWalletPassEvaluator();
388
- if (evaluator) {
389
- addModeDiscount.forEach(function (discount) {
390
- var discountType = discount.tag || discount.type;
391
- // 只对 good_pass 和 discount_card 类型执行策略检查
392
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
393
- var _discount$limited_rel, _discount$limited_rel2;
394
- // 转换 discount 为 Voucher 格式
395
- var voucher = {
396
- id: discount.id,
397
- amount: Number(discount.par_value || 0),
398
- balance: Number(discount.balance || 0),
399
- type: discountType,
400
- product_id: discount.product_id,
401
- unified_available_status: 1,
402
- available_product_type: (_discount$limited_rel = discount.limited_relation_product_data) === null || _discount$limited_rel === void 0 ? void 0 : _discount$limited_rel.type,
403
- available_product_ids: (_discount$limited_rel2 = discount.limited_relation_product_data) === null || _discount$limited_rel2 === void 0 ? void 0 : _discount$limited_rel2.product_ids
404
- };
405
-
406
- // 转换 sortedFlattenedList 为 Product 格式
407
- var productsForEvaluate = sortedFlattenedList.map(function (item) {
408
- return {
409
- product_id: item.id,
410
- price: item.price || 0,
411
- quantity: item.quantity || item.num || 1,
412
- selling_price: item.price || 0
413
- };
414
- });
415
-
416
- // 调用策略检查
417
- var result = evaluator.checkVoucherAvailability({
418
- orderTotalAmount: orderTotalAmount,
419
- products: productsForEvaluate,
420
- vouchers: [voucher]
421
- });
422
-
423
- // 将 config 附加到 discount 对象
424
- if (result.isAvailable) {
425
- discount.config = _objectSpread(_objectSpread({}, result.config), {}, {
426
- isAvailable: true
427
- });
428
- } else {
429
- discount.config = {
430
- isAvailable: false
431
- };
432
- }
433
- }
434
- });
435
- }
436
-
437
377
  /**
438
378
  // 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
439
379
  const sortedProductList = [...productList].sort((a, b) => {
@@ -454,9 +394,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
454
394
  // 标记已使用的优惠券
455
395
  var usedDiscounts = new Map();
456
396
 
457
- // 🔥 统计每个 product_id(商品券商品id)已使用的数量,用于 maxUsagePerOrder 限制
458
- var usedProductIdCounts = new Map();
459
-
460
397
  // 记录每个优惠券适用的商品ID
461
398
  var discountApplicability = new Map();
462
399
 
@@ -499,7 +436,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
499
436
  originProduct = flatItem.originProduct;
500
437
  }
501
438
  addModeDiscount.forEach(function (discount) {
502
- var _product, _product2, _product3, _product4, _flatItem$bundleItem, _discount$config;
439
+ var _product, _product2, _product3, _product4, _flatItem$bundleItem;
503
440
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
504
441
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
505
442
  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;
@@ -510,7 +447,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
510
447
  var timeLimit = true;
511
448
  timeLimit = !!filterDiscountListByBookingTime([discount], (((_product = product) === null || _product === void 0 ? void 0 : _product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
512
449
  // 是符合折扣的商品
513
- 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;
450
+ var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
514
451
 
515
452
  // 编辑的商品 使用了优惠券不可用
516
453
  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) {
@@ -521,7 +458,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
521
458
  var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
522
459
 
523
460
  // 判断优惠券是否适用于该商品
524
- if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
461
+ if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
525
462
  var _discountApplicabilit, _discount$metadata;
526
463
  // 记录此优惠券适用的商品
527
464
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -544,8 +481,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
544
481
  title: discount.format_title,
545
482
  original_amount: product.price || product.origin_total,
546
483
  pre_value: discount.par_value,
547
- product_id: originProduct.id,
548
- discount_product_id: discount.product_id
484
+ product_id: originProduct.id
549
485
  },
550
486
  metadata: {
551
487
  num: num
@@ -604,43 +540,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
604
540
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
605
541
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
606
542
  var _product$discount_lis3, _product$discount_lis4;
607
- // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
608
- var discountType = discount.tag || discount.type;
609
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
610
- var _discount$config2;
611
- // 如果策略检查后没有config,说明不可用
612
- if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
613
- return false;
614
- }
615
- }
616
-
617
543
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
618
544
  // 商品券时主商品价格为0不可用
619
- 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) {
620
- var _n$discount;
621
- return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
622
- })) && (discount.tag || discount.type) === 'good_pass') return false;
545
+ 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;
623
546
 
624
547
  // 折扣卡商品价格为0时不可用
625
548
  if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
626
- var _n$discount2;
627
- return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
549
+ var _n$discount;
550
+ return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
628
551
  })) && (discount.tag || discount.type) !== 'good_pass') return false;
629
552
  // 如果优惠券已被使用,则跳过
630
553
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
631
554
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
632
-
633
- // 🔥 检查 maxUsagePerOrder 限制:同一 product_id 的商品券使用数量不能超过配置值
634
- if ((discount.tag || discount.type) === 'good_pass') {
635
- var _discount$config3;
636
- var maxUsagePerOrder = (_discount$config3 = discount.config) === null || _discount$config3 === void 0 ? void 0 : _discount$config3.maxUsagePerOrder;
637
- if (maxUsagePerOrder && maxUsagePerOrder > 0) {
638
- var currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
639
- if (currentUsedCount >= maxUsagePerOrder) {
640
- return false;
641
- }
642
- }
643
- }
644
555
  var limitedData = discount.limited_relation_product_data;
645
556
 
646
557
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
@@ -659,9 +570,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
659
570
 
660
571
  // 判断优惠券是否适用于该商品
661
572
  if (limitedData.type === 'product_all') {
662
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
663
- return false;
664
- }
665
573
  // 检查 package_sub_item_usage_rules
666
574
  if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
667
575
  return false;
@@ -691,8 +599,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
691
599
  var _product$discount_lis5, _product7, _product7$every;
692
600
  // 主商品:判断自身是否手动折扣
693
601
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
694
- var _ref3;
695
- return !((_ref3 = item.discount_list || []) !== null && _ref3 !== void 0 && _ref3.length);
602
+ var _ref5;
603
+ return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
696
604
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product7 = product) === null || _product7 === void 0 || (_product7 = _product7.discount_list) === null || _product7 === void 0 || (_product7$every = _product7.every) === null || _product7$every === void 0 ? void 0 : _product7$every.call(_product7, function (item) {
697
605
  return item.type === 'product';
698
606
  })));
@@ -702,8 +610,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
702
610
  if (parentProduct) {
703
611
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
704
612
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
705
- var _ref4;
706
- return !((_ref4 = item.discount_list || []) !== null && _ref4 !== void 0 && _ref4.length);
613
+ var _ref6;
614
+ return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
707
615
  }) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
708
616
  return item.type === 'product';
709
617
  })));
@@ -828,13 +736,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
828
736
  var availableGoodPassCount = applicableDiscounts.filter(function (item) {
829
737
  return (item.tag || item.type) === 'good_pass';
830
738
  }).length;
831
-
832
- // 🔥 如果selectedDiscount有config配置,则使用config.maxUsagePerOrder限制使用次数
833
- var maxUsageLimit = availableGoodPassCount;
834
- if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
835
- maxUsageLimit = Math.min(availableGoodPassCount, selectedDiscount.config.maxUsagePerOrder);
836
- }
837
- var splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
739
+ var splitCount = isNeedSplit ? Math.min(totalQuantity, availableGoodPassCount) : 1;
838
740
  var arr = [];
839
741
 
840
742
  // 🔥 主商品和bundle子商品分别处理
@@ -844,8 +746,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
844
746
  arr.push(_this3.hooks.setProduct(originProduct, {
845
747
  discount_list: [],
846
748
  quantity: totalQuantity - splitCount,
847
- _id: product._id.split('___')[0],
848
- total: product.origin_total || product.total
749
+ _id: product._id.split('___')[0]
849
750
  }));
850
751
  }
851
752
  for (var i = 0; i < splitCount; i++) {
@@ -854,11 +755,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
854
755
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
855
756
  // 标记优惠券为已使用
856
757
  usedDiscounts.set(_selectedDiscount.id, true);
857
- // 🔥 更新 product_id 使用计数
858
- if ((_selectedDiscount.tag || _selectedDiscount.type) === 'good_pass') {
859
- var currentCount = usedProductIdCounts.get(_selectedDiscount.product_id) || 0;
860
- usedProductIdCounts.set(_selectedDiscount.product_id, currentCount + 1);
861
- }
862
758
 
863
759
  // 记录实际应用了优惠券的商品信息
864
760
  var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
@@ -876,27 +772,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
876
772
 
877
773
  // 计算使用折扣卡/商品券以后,单个商品的总 total
878
774
  var targetProductTotal = getDiscountAmount(_selectedDiscount, product.price, product.price);
879
- var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
880
-
881
- // 计算实际折扣金额
882
- var actualDiscountAmount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
775
+ var discountType = _selectedDiscount.tag || _selectedDiscount.type;
883
776
  var isGoodPass = discountType === 'good_pass';
777
+ var amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
884
778
  var discountDetail = {
885
- amount: actualDiscountAmount,
886
- type: discountType,
779
+ amount: amount,
780
+ type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : discountType,
887
781
  discount: {
888
782
  discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
889
- fixed_amount: actualDiscountAmount,
783
+ fixed_amount: amount,
890
784
  resource_id: _selectedDiscount.id,
891
785
  title: _selectedDiscount.format_title,
892
786
  original_amount: product.price,
893
787
  product_id: originProduct.id,
894
- percent: _selectedDiscount.par_value,
895
- discount_product_id: _selectedDiscount.product_id
788
+ percent: _selectedDiscount.par_value
896
789
  },
897
790
  // 前端使用的num数量,为了计算优惠金额
898
791
  _num: isGoodPass ? 1 : product.num,
899
- config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
900
792
  metadata: {
901
793
  num: 1
902
794
  }
@@ -915,6 +807,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
915
807
  // 记录应用了优惠券的商品
916
808
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
917
809
  if (product.isClient) {
810
+ debugger;
918
811
  arr.push(_this3.hooks.setProduct(originProduct, {
919
812
  discount_list: [discountDetail],
920
813
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
@@ -955,36 +848,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
955
848
  for (var _i = 0; _i < discountNum; _i++) {
956
849
  var _selectedDiscount2 = applicableDiscounts[_i];
957
850
  usedDiscounts.set(_selectedDiscount2.id, true);
958
- // 🔥 更新 product_id 使用计数
959
- if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
960
- var _currentCount = usedProductIdCounts.get(_selectedDiscount2.product_id) || 0;
961
- usedProductIdCounts.set(_selectedDiscount2.product_id, _currentCount + 1);
962
- }
963
851
 
964
852
  // 🔥 生成唯一的 _id
965
853
  var uniqueId = "".concat(flatItem._id, "_split_").concat(_i);
966
-
967
- // 计算折扣后的价格(使用 getDiscountAmount,内部已处理 maxDeductionAmount)
968
- var discountedPrice = getDiscountAmount(_selectedDiscount2, product.origin_total, product.origin_total);
969
- var bundleDiscountAmount = new Decimal(product.origin_total || 0).minus(discountedPrice).toNumber();
970
854
  var _discountDetail = {
971
- amount: bundleDiscountAmount,
855
+ amount: product.origin_total,
972
856
  type: 'good_pass',
973
857
  discount: {
974
858
  fixed_amount: product.origin_total,
975
859
  resource_id: _selectedDiscount2.id,
976
860
  title: _selectedDiscount2.format_title,
977
861
  original_amount: product.origin_total,
978
- product_id: product.id,
979
- discount_product_id: _selectedDiscount2.product_id
862
+ product_id: product.id
980
863
  },
981
864
  metadata: {
982
865
  // 🔥 使用拆分后的唯一 _id
983
866
  custom_product_bundle_map_id: uniqueId,
984
867
  num: 1
985
868
  },
986
- _num: 1,
987
- config: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.config
869
+ _num: 1
988
870
  };
989
871
 
990
872
  // 记录实际应用的折扣
@@ -996,9 +878,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
996
878
  _id: uniqueId,
997
879
  num: 1,
998
880
  quantity: 1,
999
- price: discountedPrice,
1000
- // 折扣后的价格
1001
- total: discountedPrice,
881
+ price: 0,
882
+ // 商品券价格为0
883
+ total: 0,
1002
884
  discount_list: [_discountDetail],
1003
885
  processed: true,
1004
886
  _discountId: _selectedDiscount2.id
@@ -1021,38 +903,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1021
903
  // 折扣卡:不拆分数量,直接应用
1022
904
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
1023
905
  usedDiscounts.set(_selectedDiscount3.id, true);
1024
- // 🔥 更新 product_id 使用计数(虽然此处主要是折扣卡,但保持一致性)
1025
- if ((_selectedDiscount3.tag || _selectedDiscount3.type) === 'good_pass') {
1026
- var _currentCount2 = usedProductIdCounts.get(_selectedDiscount3.product_id) || 0;
1027
- usedProductIdCounts.set(_selectedDiscount3.product_id, _currentCount2 + 1);
1028
- }
1029
906
  var _productOriginTotal = product.original_price || product.price || 0;
1030
907
  var _targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
1031
908
 
1032
- // 计算实际折扣金额
1033
- var bundleActualDiscountAmount = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
1034
-
1035
909
  // 🔥 使用当前的 _id 作为唯一标识
1036
910
  var _uniqueId = flatItem._id;
1037
911
  var _discountDetail2 = {
1038
- amount: bundleActualDiscountAmount * (product.num || 1),
912
+ amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber() * (product.num || 1),
1039
913
  type: _selectedDiscount3.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount3.tag,
1040
914
  discount: {
1041
915
  discount_card_type: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me = _selectedDiscount3.metadata) === null || _selectedDiscount3$me === void 0 ? void 0 : _selectedDiscount3$me.discount_card_type,
1042
- fixed_amount: bundleActualDiscountAmount,
916
+ fixed_amount: new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber(),
1043
917
  resource_id: _selectedDiscount3.id,
1044
918
  title: _selectedDiscount3.format_title,
1045
919
  original_amount: product.original_price,
1046
920
  product_id: product.id,
1047
- percent: _selectedDiscount3.par_value,
1048
- discount_product_id: _selectedDiscount3.product_id
921
+ percent: _selectedDiscount3.par_value
1049
922
  },
1050
923
  metadata: {
1051
924
  // 🔥 使用唯一的 _id
1052
925
  custom_product_bundle_map_id: _uniqueId,
1053
926
  num: product.num || 1
1054
927
  },
1055
- config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
1056
928
  _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.num) || 1)
1057
929
  };
1058
930
 
@@ -25,7 +25,6 @@ export interface RulesModuleAPI {
25
25
  holders: {
26
26
  form_record_id: number;
27
27
  }[];
28
- orderTotalAmount: number;
29
28
  isFormSubject: boolean;
30
29
  }) => DiscountResult;
31
30
  }
@@ -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,7 +21,6 @@ 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;
@@ -55,7 +55,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
55
55
  originalDiscountList: [],
56
56
  currentBookingTime: "",
57
57
  filteredDiscountList: [],
58
- orderTotalAmount: 0,
59
58
  bookingSubject: undefined
60
59
  };
61
60
  return _this;
@@ -288,14 +287,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
288
287
  return _setCustomer.apply(this, arguments);
289
288
  }
290
289
  return setCustomer;
291
- }()
292
- }, {
293
- key: "setOriginTotalAmount",
294
- value: function setOriginTotalAmount(amount) {
295
- this.store.orderTotalAmount = amount;
296
- }
297
-
298
- // 设置holders
290
+ }() // 设置holders
299
291
  }, {
300
292
  key: "setHolders",
301
293
  value: function setHolders(holders) {
@@ -324,7 +316,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
324
316
  productList: productList,
325
317
  discountList: this.getDiscountList(),
326
318
  holders: this.store.holders || [],
327
- orderTotalAmount: this.store.orderTotalAmount || 0,
328
319
  isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
329
320
  }, options) || {
330
321
  productList: productList,
@@ -465,7 +456,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
465
456
  oldDiscountList: this.getDiscountList(),
466
457
  newDiscountList: withScanList,
467
458
  holders: this.store.holders || [],
468
- orderTotalAmount: this.store.orderTotalAmount || 0,
469
459
  isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
470
460
  }) || {
471
461
  isAvailable: false,
@@ -31,7 +31,6 @@ export interface ShopDiscountState {
31
31
  originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
- orderTotalAmount?: number;
35
34
  bookingSubject?: {
36
35
  type?: 'form' | 'customer';
37
36
  [key: string]: any;