@pisell/pisellos 2.2.39 → 2.2.41

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/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/Rules/index.d.ts +3 -8
  12. package/dist/modules/Rules/index.js +23 -143
  13. package/dist/modules/Rules/types.d.ts +0 -1
  14. package/dist/modules/Schedule/index.d.ts +9 -0
  15. package/dist/modules/Schedule/index.js +18 -2
  16. package/dist/modules/Summary/types.d.ts +0 -2
  17. package/dist/modules/Summary/utils.d.ts +0 -6
  18. package/dist/modules/Summary/utils.js +0 -21
  19. package/dist/plugins/window.d.ts +0 -2
  20. package/dist/solution/BookingByStep/index.d.ts +0 -1
  21. package/dist/solution/Checkout/index.js +0 -2
  22. package/dist/solution/RegisterAndLogin/config.js +339 -1
  23. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  24. package/dist/solution/ShopDiscount/index.js +3 -13
  25. package/dist/solution/ShopDiscount/types.d.ts +0 -1
  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/Rules/index.d.ts +3 -8
  37. package/lib/modules/Rules/index.js +187 -352
  38. package/lib/modules/Rules/types.d.ts +0 -1
  39. package/lib/modules/Schedule/index.d.ts +9 -0
  40. package/lib/modules/Schedule/index.js +11 -0
  41. package/lib/modules/Summary/types.d.ts +0 -2
  42. package/lib/modules/Summary/utils.d.ts +0 -6
  43. package/lib/modules/Summary/utils.js +0 -15
  44. package/lib/plugins/window.d.ts +0 -2
  45. package/lib/solution/BookingByStep/index.d.ts +0 -1
  46. package/lib/solution/Checkout/index.js +0 -2
  47. package/lib/solution/RegisterAndLogin/config.js +265 -1
  48. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  49. package/lib/solution/ShopDiscount/index.js +2 -8
  50. package/lib/solution/ShopDiscount/types.d.ts +0 -1
  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 -497
  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 -165
  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 -421
  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 -165
  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
@@ -36,8 +36,8 @@ var import_BaseModule = require("../BaseModule");
36
36
  var import_utils = require("../../solution/ShopDiscount/utils");
37
37
  var import_utils2 = require("../Cart/utils");
38
38
  var import_decimal = __toESM(require("decimal.js"));
39
- var import_lodash_es = require("lodash-es");
40
39
  var import_dayjs = __toESM(require("dayjs"));
40
+ var import_lodash_es = require("lodash-es");
41
41
  var import_utils3 = require("../../solution/ShopDiscount/utils");
42
42
  var import_utils4 = require("../../solution/ShopDiscount/utils");
43
43
  var RulesModule = class extends import_BaseModule.BaseModule {
@@ -51,7 +51,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
51
51
  this.core = core;
52
52
  this.hooks = options == null ? void 0 : options.hooks;
53
53
  this.store = options == null ? void 0 : options.store;
54
- this.window = core.getPlugin("window");
55
54
  }
56
55
  async setRulesList(rulesList) {
57
56
  this.store.rulesList = rulesList;
@@ -60,10 +59,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
60
59
  getRulesList() {
61
60
  return this.store.rulesList;
62
61
  }
63
- getWalletPassEvaluator() {
64
- var _a, _b;
65
- return (_b = (_a = this.window).getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
66
- }
67
62
  // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
68
63
  checkHolderMatch(discount, product, holders) {
69
64
  var _a;
@@ -82,7 +77,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
82
77
  oldDiscountList,
83
78
  newDiscountList,
84
79
  productList,
85
- orderTotalAmount,
86
80
  holders,
87
81
  isFormSubject
88
82
  }) {
@@ -104,25 +98,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
104
98
  productList
105
99
  };
106
100
  }
107
- const filteredOldDiscountList = oldDiscountList.filter(
108
- (discount) => !discount.isEditMode && discount.tag !== "good_pass"
109
- );
110
- const mergedDiscountList = (0, import_utils.uniqueById)(
111
- (0, import_utils.uniqueById)([...filteredOldDiscountList, ...newDiscountList]),
112
- "product_id"
113
- );
114
- const result = this.calcDiscount(
115
- {
116
- discountList: mergedDiscountList,
117
- productList: [...productList],
118
- orderTotalAmount,
119
- holders,
120
- isFormSubject
121
- },
122
- {
123
- scan: true
124
- }
125
- );
101
+ const filteredOldDiscountList = oldDiscountList.filter((discount) => !discount.isEditMode && discount.tag !== "good_pass");
102
+ const mergedDiscountList = (0, import_utils.uniqueById)((0, import_utils.uniqueById)([
103
+ ...filteredOldDiscountList,
104
+ ...newDiscountList
105
+ ]), "product_id");
106
+ const result = this.calcDiscount({
107
+ discountList: mergedDiscountList,
108
+ productList: [...productList],
109
+ holders,
110
+ isFormSubject
111
+ }, {
112
+ scan: true
113
+ });
126
114
  let hasApplicableDiscount = false;
127
115
  const newDiscountIds = newDiscountList.map((discount) => discount.id);
128
116
  result.productList.forEach((product) => {
@@ -153,8 +141,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
153
141
  discountList,
154
142
  productList,
155
143
  holders,
156
- isFormSubject,
157
- orderTotalAmount
144
+ isFormSubject
158
145
  }, options) {
159
146
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
160
147
  const editModeDiscount = [];
@@ -332,50 +319,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
332
319
  }
333
320
  return priceB.minus(priceA).toNumber();
334
321
  });
335
- const evaluator = this.getWalletPassEvaluator();
336
- if (evaluator) {
337
- addModeDiscount.forEach((discount) => {
338
- var _a, _b;
339
- const discountType = discount.tag || discount.type;
340
- if (["good_pass", "discount_card", "product_discount_card"].includes(
341
- discountType
342
- )) {
343
- const voucher = {
344
- id: discount.id,
345
- amount: Number(discount.par_value || 0),
346
- balance: Number(discount.balance || 0),
347
- type: discountType,
348
- product_id: discount.product_id,
349
- unified_available_status: 1,
350
- available_product_type: (_a = discount.limited_relation_product_data) == null ? void 0 : _a.type,
351
- available_product_ids: (_b = discount.limited_relation_product_data) == null ? void 0 : _b.product_ids
352
- };
353
- const productsForEvaluate = sortedFlattenedList.map((item) => ({
354
- product_id: item.id,
355
- price: item.price || 0,
356
- quantity: item.quantity || item.num || 1,
357
- selling_price: item.price || 0
358
- }));
359
- const result = evaluator.checkVoucherAvailability({
360
- orderTotalAmount,
361
- products: productsForEvaluate,
362
- vouchers: [voucher]
363
- });
364
- if (result.isAvailable) {
365
- discount.config = {
366
- ...result.config,
367
- isAvailable: true
368
- };
369
- } else {
370
- discount.config = {
371
- isAvailable: false
372
- };
373
- }
374
- }
375
- });
376
- }
377
322
  const usedDiscounts = /* @__PURE__ */ new Map();
378
- const usedProductIdCounts = /* @__PURE__ */ new Map();
379
323
  const discountApplicability = /* @__PURE__ */ new Map();
380
324
  const discountApplicableProducts = /* @__PURE__ */ new Map();
381
325
  addModeDiscount.forEach((discount) => {
@@ -528,7 +472,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
528
472
  originProduct = flatItem.originProduct;
529
473
  }
530
474
  addModeDiscount.forEach((discount) => {
531
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
475
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
532
476
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
533
477
  const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
534
478
  const isHolderMatch = this.checkHolderMatch(
@@ -541,7 +485,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
541
485
  );
542
486
  let timeLimit = true;
543
487
  timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
544
- const 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;
488
+ const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
545
489
  const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a2 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a2.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every(
546
490
  (discount2) => discount2.id && [
547
491
  "good_pass",
@@ -550,8 +494,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
550
494
  ].includes(discount2.tag || discount2.type)
551
495
  ))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) == null ? void 0 : _d.length) && ((_f = (_e = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.every((discount2) => discount2.id)));
552
496
  const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
553
- if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && ((_g = discount.config) == null ? void 0 : _g.isAvailable)) {
554
- (_h = discountApplicability.get(discount.id)) == null ? void 0 : _h.push(product.id);
497
+ if (isAvailableProduct && isLimitedProduct && isBundleAvailable && timeLimit) {
498
+ (_g = discountApplicability.get(discount.id)) == null ? void 0 : _g.push(product.id);
555
499
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
556
500
  const discountType = discount.tag || discount.type;
557
501
  const isGoodPass = discountType === "good_pass";
@@ -561,15 +505,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
561
505
  type: discountType,
562
506
  tag: discountType,
563
507
  discount: {
564
- discount_card_type: (_i = discount == null ? void 0 : discount.metadata) == null ? void 0 : _i.discount_card_type,
508
+ discount_card_type: (_h = discount == null ? void 0 : discount.metadata) == null ? void 0 : _h.discount_card_type,
565
509
  fixed_amount: product.price,
566
- discount_calculation_mode: (_j = discount == null ? void 0 : discount.metadata) == null ? void 0 : _j.discount_calculation_mode,
510
+ discount_calculation_mode: (_i = discount == null ? void 0 : discount.metadata) == null ? void 0 : _i.discount_calculation_mode,
567
511
  resource_id: discount.id,
568
512
  title: discount.format_title,
569
513
  original_amount: product.price || product.origin_total,
570
514
  pre_value: discount.par_value,
571
- product_id: originProduct.id,
572
- discount_product_id: discount.product_id
515
+ product_id: originProduct.id
573
516
  },
574
517
  metadata: {
575
518
  num
@@ -603,36 +546,22 @@ var RulesModule = class extends import_BaseModule.BaseModule {
603
546
  };
604
547
  originProduct = flatItem.originProduct;
605
548
  }
606
- if ((product == null ? void 0 : product.booking_id) && ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every(
607
- (discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(
608
- discount.tag || discount.type
609
- )
610
- ))) {
549
+ if ((product == null ? void 0 : product.booking_id) && ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
611
550
  if (flatItem.type === "main") {
612
551
  processedProductsMap.set(product._id, [originProduct]);
613
552
  } else {
614
- processedFlatItemsMap.set(flatItem._id, [
615
- {
616
- ...flatItem,
617
- processed: true
618
- }
619
- ]);
553
+ processedFlatItemsMap.set(flatItem._id, [{
554
+ ...flatItem,
555
+ processed: true
556
+ }]);
620
557
  }
621
558
  return;
622
559
  }
623
560
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
624
- var _a2, _b2, _c2, _d2;
625
- const discountType = discount.tag || discount.type;
626
- if (["good_pass", "discount_card", "product_discount_card"].includes(
627
- discountType
628
- )) {
629
- if (discount.config === void 0 || !((_a2 = discount == null ? void 0 : discount.config) == null ? void 0 : _a2.isAvailable)) {
630
- return false;
631
- }
632
- }
633
- if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.length) && (discount.tag || discount.type) === "good_pass")
561
+ var _a2, _b2;
562
+ if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass")
634
563
  return false;
635
- if ((Number(product.price) <= 0 || !product.price) && !((_c2 = product.discount_list) == null ? void 0 : _c2.find((n) => {
564
+ if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
636
565
  var _a3;
637
566
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
638
567
  })) && (discount.tag || discount.type) !== "good_pass")
@@ -640,15 +569,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
640
569
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
641
570
  if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
642
571
  return false;
643
- if ((discount.tag || discount.type) === "good_pass") {
644
- const maxUsagePerOrder = (_d2 = discount.config) == null ? void 0 : _d2.maxUsagePerOrder;
645
- if (maxUsagePerOrder && maxUsagePerOrder > 0) {
646
- const currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
647
- if (currentUsedCount >= maxUsagePerOrder) {
648
- return false;
649
- }
650
- }
651
- }
652
572
  const limitedData = discount.limited_relation_product_data;
653
573
  const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
654
574
  const isHolderMatch = this.checkHolderMatch(
@@ -667,9 +587,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
667
587
  return false;
668
588
  }
669
589
  if (limitedData.type === "product_all") {
670
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
671
- return false;
672
- }
673
590
  if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
674
591
  return false;
675
592
  }
@@ -682,96 +599,66 @@ var RulesModule = class extends import_BaseModule.BaseModule {
682
599
  }
683
600
  return false;
684
601
  });
685
- const selectedDiscountCard = applicableDiscounts.find(
686
- (n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
687
- );
602
+ const selectedDiscountCard = applicableDiscounts.find((n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass");
688
603
  const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
689
604
  let isManualDiscount = false;
690
605
  if (flatItem.type === "main") {
691
- isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(
692
- (item) => {
693
- var _a2;
694
- return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
695
- }
696
- ) && (!((_g = product.discount_list) == null ? void 0 : _g.length) || ((_i = (_h = product == null ? void 0 : product.discount_list) == null ? void 0 : _h.every) == null ? void 0 : _i.call(
697
- _h,
698
- (item) => item.type === "product"
699
- )));
606
+ isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every((item) => {
607
+ var _a2;
608
+ return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
609
+ }) && (!((_g = product.discount_list) == null ? void 0 : _g.length) || ((_i = (_h = product == null ? void 0 : product.discount_list) == null ? void 0 : _h.every) == null ? void 0 : _i.call(_h, (item) => item.type === "product")));
700
610
  } else {
701
611
  const parentProduct = flatItem.parentProduct;
702
612
  if (parentProduct) {
703
- isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(
704
- (item) => {
705
- var _a2;
706
- return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
707
- }
708
- ) && (!((_j = parentProduct.discount_list) == null ? void 0 : _j.length) || ((_l = (_k = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _k.every) == null ? void 0 : _l.call(
709
- _k,
710
- (item) => item.type === "product"
711
- )));
613
+ isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every((item) => {
614
+ var _a2;
615
+ return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
616
+ }) && (!((_j = parentProduct.discount_list) == null ? void 0 : _j.length) || ((_l = (_k = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _k.every) == null ? void 0 : _l.call(_k, (item) => item.type === "product")));
712
617
  }
713
618
  }
714
619
  if (options == null ? void 0 : options.discountId) {
715
- if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some(
716
- (item) => {
717
- var _a2;
718
- return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
719
- }
720
- ))) {
620
+ if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
621
+ var _a2;
622
+ return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
623
+ }))) {
721
624
  isManualDiscount = false;
722
625
  }
723
626
  if (flatItem.type === "bundle") {
724
- if (((_n = product.discount_list) == null ? void 0 : _n.some(
725
- (item) => {
726
- var _a2;
727
- return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
728
- }
729
- )) || ((_p = (_o = flatItem.parentProduct) == null ? void 0 : _o.discount_list) == null ? void 0 : _p.some(
730
- (item) => {
731
- var _a2;
732
- return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
733
- }
734
- ))) {
627
+ if (((_n = product.discount_list) == null ? void 0 : _n.some((item) => {
628
+ var _a2;
629
+ return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
630
+ })) || ((_p = (_o = flatItem.parentProduct) == null ? void 0 : _o.discount_list) == null ? void 0 : _p.some((item) => {
631
+ var _a2;
632
+ return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
633
+ }))) {
735
634
  isManualDiscount = false;
736
635
  }
737
636
  }
738
637
  }
739
638
  if (options == null ? void 0 : options.selectedList) {
740
- if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some(
741
- (item) => {
742
- var _a2;
743
- return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
744
- (n) => {
745
- var _a3;
746
- return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
747
- }
748
- );
749
- }
750
- ))) {
639
+ if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
640
+ var _a2;
641
+ return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
642
+ var _a3;
643
+ return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
644
+ });
645
+ }))) {
751
646
  isManualDiscount = false;
752
647
  }
753
648
  if (flatItem.type === "bundle") {
754
- if (((_r = product.discount_list) == null ? void 0 : _r.some(
755
- (item) => {
756
- var _a2;
757
- return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
758
- (n) => {
759
- var _a3;
760
- return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
761
- }
762
- );
763
- }
764
- )) || ((_t = (_s = flatItem.parentProduct) == null ? void 0 : _s.discount_list) == null ? void 0 : _t.some(
765
- (item) => {
766
- var _a2;
767
- return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
768
- (n) => {
769
- var _a3;
770
- return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
771
- }
772
- );
773
- }
774
- ))) {
649
+ if (((_r = product.discount_list) == null ? void 0 : _r.some((item) => {
650
+ var _a2;
651
+ return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
652
+ var _a3;
653
+ return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
654
+ });
655
+ })) || ((_t = (_s = flatItem.parentProduct) == null ? void 0 : _s.discount_list) == null ? void 0 : _t.some((item) => {
656
+ var _a2;
657
+ return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
658
+ var _a3;
659
+ return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
660
+ });
661
+ }))) {
775
662
  isManualDiscount = false;
776
663
  }
777
664
  }
@@ -779,8 +666,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
779
666
  if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
780
667
  if (flatItem.type === "main") {
781
668
  if (product.isClient) {
782
- processedProductsMap.set(product._id, [
783
- this.hooks.setProduct(originProduct, {
669
+ processedProductsMap.set(
670
+ product._id,
671
+ [this.hooks.setProduct(originProduct, {
784
672
  ...isManualDiscount ? {} : {
785
673
  origin_total: (0, import_utils2.getProductOriginTotalPrice)({
786
674
  product: {
@@ -801,11 +689,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
801
689
  price: product.price
802
690
  },
803
691
  discount_list: []
804
- })
805
- ]);
692
+ })]
693
+ );
806
694
  } else {
807
- processedProductsMap.set(product._id, [
808
- this.hooks.setProduct(originProduct, {
695
+ processedProductsMap.set(
696
+ product._id,
697
+ [this.hooks.setProduct(originProduct, {
809
698
  ...isManualDiscount ? {
810
699
  price: product.price,
811
700
  main_product_selling_price: product.price
@@ -816,8 +705,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
816
705
  main_product_selling_price: product.price
817
706
  },
818
707
  discount_list: []
819
- })
820
- ]);
708
+ })]
709
+ );
821
710
  }
822
711
  } else {
823
712
  processedFlatItemsMap.set(flatItem._id, [{
@@ -834,36 +723,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
834
723
  }
835
724
  const isNeedSplit = (selectedDiscount.tag || selectedDiscount.type) === "good_pass";
836
725
  const totalQuantity = product.quantity || product.num || 1;
837
- const availableGoodPassCount = applicableDiscounts.filter(
838
- (item) => (item.tag || item.type) === "good_pass"
839
- ).length;
840
- let maxUsageLimit = availableGoodPassCount;
841
- if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
842
- maxUsageLimit = Math.min(
843
- availableGoodPassCount,
844
- selectedDiscount.config.maxUsagePerOrder
845
- );
846
- }
847
- const splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
726
+ const availableGoodPassCount = applicableDiscounts.filter((item) => (item.tag || item.type) === "good_pass").length;
727
+ const splitCount = isNeedSplit ? Math.min(totalQuantity, availableGoodPassCount) : 1;
848
728
  const arr = [];
849
729
  if (flatItem.type === "main") {
850
730
  if (splitCount < totalQuantity && isNeedSplit) {
851
- arr.push(
852
- this.hooks.setProduct(originProduct, {
853
- discount_list: [],
854
- quantity: totalQuantity - splitCount,
855
- _id: product._id.split("___")[0],
856
- total: product.origin_total || product.total
857
- })
858
- );
731
+ arr.push(this.hooks.setProduct(originProduct, {
732
+ discount_list: [],
733
+ quantity: totalQuantity - splitCount,
734
+ _id: product._id.split("___")[0]
735
+ }));
859
736
  }
860
737
  for (let i = 0; i < splitCount; i++) {
861
738
  const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[i];
862
739
  usedDiscounts.set(selectedDiscount2.id, true);
863
- if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
864
- const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
865
- usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
866
- }
867
740
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
868
741
  let productOriginTotal = product.origin_total || product.total || 0;
869
742
  if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
@@ -899,12 +772,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
899
772
  title: selectedDiscount2.format_title,
900
773
  original_amount: product.price,
901
774
  product_id: originProduct.id,
902
- percent: selectedDiscount2.par_value,
903
- discount_product_id: selectedDiscount2.product_id
775
+ percent: selectedDiscount2.par_value
904
776
  },
905
777
  // 前端使用的num数量,为了计算优惠金额
906
778
  _num: isGoodPass ? 1 : product.num,
907
- config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
908
779
  metadata: {
909
780
  num: 1,
910
781
  // 🔥 order_level 分摊差值
@@ -922,35 +793,32 @@ var RulesModule = class extends import_BaseModule.BaseModule {
922
793
  }, new import_decimal.default(total)).toNumber();
923
794
  }
924
795
  if (product.isClient) {
925
- arr.push(
926
- this.hooks.setProduct(originProduct, {
927
- discount_list: [discountDetail],
928
- price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
929
- quantity: isNeedSplit ? 1 : product.quantity,
930
- origin_total: (0, import_utils2.getProductOriginTotalPrice)({
931
- product: {
932
- original_price: product.original_price
933
- },
934
- bundle: product.bundle,
935
- options: product.options
936
- }),
937
- variant: originProduct._productInit.variant,
938
- original_price: new import_decimal.default(product.price || 0).toNumber(),
939
- total
940
- })
941
- );
796
+ debugger;
797
+ arr.push(this.hooks.setProduct(originProduct, {
798
+ discount_list: [discountDetail],
799
+ price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
800
+ quantity: isNeedSplit ? 1 : product.quantity,
801
+ origin_total: (0, import_utils2.getProductOriginTotalPrice)({
802
+ product: {
803
+ original_price: product.original_price
804
+ },
805
+ bundle: product.bundle,
806
+ options: product.options
807
+ }),
808
+ variant: originProduct._productInit.variant,
809
+ original_price: new import_decimal.default(product.price || 0).toNumber(),
810
+ total
811
+ }));
942
812
  } else {
943
- arr.push(
944
- this.hooks.setProduct(originProduct, {
945
- discount_list: [discountDetail],
946
- _id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
947
- price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
948
- quantity: isNeedSplit ? 1 : product.quantity,
949
- total,
950
- origin_total: productOriginTotal,
951
- main_product_selling_price: targetProductTotal
952
- })
953
- );
813
+ arr.push(this.hooks.setProduct(originProduct, {
814
+ discount_list: [discountDetail],
815
+ _id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
816
+ price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
817
+ quantity: isNeedSplit ? 1 : product.quantity,
818
+ total,
819
+ origin_total: productOriginTotal,
820
+ main_product_selling_price: targetProductTotal
821
+ }));
954
822
  }
955
823
  }
956
824
  processedProductsMap.set(product._id, arr);
@@ -962,19 +830,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
962
830
  for (let i = 0; i < discountNum; i++) {
963
831
  const selectedDiscount2 = applicableDiscounts[i];
964
832
  usedDiscounts.set(selectedDiscount2.id, true);
965
- if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
966
- const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
967
- usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
968
- }
969
833
  const uniqueId = `${flatItem._id}_split_${i}`;
970
- const discountedPrice = (0, import_utils.getDiscountAmount)(
971
- selectedDiscount2,
972
- product.origin_total,
973
- product.origin_total
974
- );
975
- const bundleDiscountAmount = new import_decimal.default(product.origin_total || 0).minus(discountedPrice).toNumber();
976
834
  const discountDetail = {
977
- amount: bundleDiscountAmount,
835
+ amount: product.origin_total,
978
836
  type: "good_pass",
979
837
  discount: {
980
838
  fixed_amount: product.origin_total,
@@ -982,16 +840,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
982
840
  resource_id: selectedDiscount2.id,
983
841
  title: selectedDiscount2.format_title,
984
842
  original_amount: product.origin_total,
985
- product_id: product.id,
986
- discount_product_id: selectedDiscount2.product_id
843
+ product_id: product.id
987
844
  },
988
845
  metadata: {
989
846
  // 🔥 使用拆分后的唯一 _id
990
847
  custom_product_bundle_map_id: uniqueId,
991
848
  num: 1
992
849
  },
993
- _num: 1,
994
- config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config
850
+ _num: 1
995
851
  };
996
852
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
997
853
  appliedProducts.push(discountDetail);
@@ -1002,9 +858,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1002
858
  _id: uniqueId,
1003
859
  num: 1,
1004
860
  quantity: 1,
1005
- price: discountedPrice,
1006
- // 折扣后的价格
1007
- total: discountedPrice,
861
+ price: 0,
862
+ // 商品券价格为0
863
+ total: 0,
1008
864
  discount_list: [discountDetail],
1009
865
  processed: true,
1010
866
  _discountId: selectedDiscount2.id
@@ -1024,10 +880,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1024
880
  } else {
1025
881
  const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[0];
1026
882
  usedDiscounts.set(selectedDiscount2.id, true);
1027
- if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
1028
- const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
1029
- usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
1030
- }
1031
883
  const productOriginTotal = product.original_price || product.price || 0;
1032
884
  const isOrderLevel = (0, import_utils3.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
1033
885
  const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
@@ -1047,6 +899,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1047
899
  );
1048
900
  fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
1049
901
  }
902
+ debugger;
1050
903
  const uniqueId = flatItem._id;
1051
904
  const discountDetail = {
1052
905
  amount: fixedAmountPerItem * (product.num || 1),
@@ -1059,8 +912,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1059
912
  title: selectedDiscount2.format_title,
1060
913
  original_amount: product.original_price,
1061
914
  product_id: product.id,
1062
- percent: selectedDiscount2.par_value,
1063
- discount_product_id: selectedDiscount2.product_id
915
+ percent: selectedDiscount2.par_value
1064
916
  },
1065
917
  metadata: {
1066
918
  // 🔥 使用唯一的 _id
@@ -1069,7 +921,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1069
921
  // 🔥 order_level 分摊差值
1070
922
  ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
1071
923
  },
1072
- config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
1073
924
  _num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
1074
925
  };
1075
926
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
@@ -1159,67 +1010,61 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1159
1010
  const mainProduct = mainProductArr[0];
1160
1011
  const mainProductData = this.hooks.getProduct(mainProduct);
1161
1012
  const newBundleWithDiscount = [];
1162
- (product.bundle || []).forEach(
1163
- (bundleItem, bundleIndex) => {
1164
- const processedItems = bundleProcessingInfo.get(
1165
- bundleIndex
1166
- ) || [bundleItem];
1167
- if (processedItems.length > 1) {
1168
- processedItems.forEach((item) => {
1169
- const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
1170
- var _a;
1171
- return {
1172
- ...discount,
1173
- metadata: {
1174
- ...discount.metadata,
1175
- num: item.num,
1176
- custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
1177
- }
1178
- // num: item.num, // 使用拆分后的 num
1179
- };
1180
- });
1181
- newBundleWithDiscount.push({
1182
- ...bundleItem,
1183
- _id: item._id,
1184
- product_id: bundleItem.product_id,
1185
- price: item.price,
1186
- num: item.num,
1187
- discount_list: updatedDiscountList2
1188
- });
1013
+ (product.bundle || []).forEach((bundleItem, bundleIndex) => {
1014
+ const processedItems = bundleProcessingInfo.get(bundleIndex) || [bundleItem];
1015
+ if (processedItems.length > 1) {
1016
+ processedItems.forEach((item) => {
1017
+ const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
1018
+ var _a;
1019
+ return {
1020
+ ...discount,
1021
+ metadata: {
1022
+ ...discount.metadata,
1023
+ num: item.num,
1024
+ custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
1025
+ }
1026
+ // num: item.num, // 使用拆分后的 num
1027
+ };
1028
+ });
1029
+ newBundleWithDiscount.push({
1030
+ ...bundleItem,
1031
+ _id: item._id,
1032
+ product_id: bundleItem.product_id,
1033
+ price: item.price,
1034
+ num: item.num,
1035
+ discount_list: updatedDiscountList2
1036
+ });
1037
+ });
1038
+ } else {
1039
+ const item = processedItems[0];
1040
+ if (item.processed) {
1041
+ const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
1042
+ var _a;
1043
+ return {
1044
+ ...discount,
1045
+ metadata: {
1046
+ ...discount.metadata,
1047
+ num: item.num,
1048
+ custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
1049
+ }
1050
+ // num: item.num, // 使用当前的 num
1051
+ };
1052
+ });
1053
+ newBundleWithDiscount.push({
1054
+ ...bundleItem,
1055
+ _id: item._id,
1056
+ product_id: bundleItem.product_id,
1057
+ price: item.price,
1058
+ num: item.num,
1059
+ discount_list: updatedDiscountList2
1189
1060
  });
1190
1061
  } else {
1191
- const item = processedItems[0];
1192
- if (item.processed) {
1193
- const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
1194
- var _a;
1195
- return {
1196
- ...discount,
1197
- metadata: {
1198
- ...discount.metadata,
1199
- num: item.num,
1200
- custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
1201
- }
1202
- // num: item.num, // 使用当前的 num
1203
- };
1204
- });
1205
- newBundleWithDiscount.push({
1206
- ...bundleItem,
1207
- _id: item._id,
1208
- product_id: bundleItem.product_id,
1209
- price: item.price,
1210
- num: item.num,
1211
- discount_list: updatedDiscountList2
1212
- });
1213
- } else {
1214
- newBundleWithDiscount.push(item);
1215
- }
1062
+ newBundleWithDiscount.push(item);
1216
1063
  }
1217
1064
  }
1218
- );
1065
+ });
1219
1066
  let newTotalWithDiscount = Number(mainProductData.price || 0);
1220
- let newOriginTotalWithDiscount = Number(
1221
- mainProductData.original_price || mainProductData.price || 0
1222
- );
1067
+ let newOriginTotalWithDiscount = Number(mainProductData.original_price || mainProductData.price || 0);
1223
1068
  const updatedMainDiscountList = mainProductData.discount_list.map((discount) => {
1224
1069
  var _a, _b;
1225
1070
  if ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) {
@@ -1235,12 +1080,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1235
1080
  }
1236
1081
  };
1237
1082
  });
1238
- const mainDiscountList = updatedMainDiscountList.filter(
1239
- (item) => {
1240
- var _a;
1241
- return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
1242
- }
1243
- );
1083
+ const mainDiscountList = updatedMainDiscountList.filter((item) => {
1084
+ var _a;
1085
+ return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
1086
+ });
1244
1087
  if (mainDiscountList && mainDiscountList.length > 0) {
1245
1088
  const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
1246
1089
  newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
@@ -1276,18 +1119,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1276
1119
  );
1277
1120
  if (mainProductQuantity > 1) {
1278
1121
  const newBundleOriginal = [];
1279
- (product.bundle || []).forEach(
1280
- (bundleItem, bundleIndex) => {
1281
- newBundleOriginal.push({
1282
- ...bundleItem,
1283
- discount_list: []
1284
- });
1285
- }
1286
- );
1122
+ (product.bundle || []).forEach((bundleItem, bundleIndex) => {
1123
+ newBundleOriginal.push({
1124
+ ...bundleItem,
1125
+ discount_list: []
1126
+ });
1127
+ });
1287
1128
  let newTotalOriginal = Number(mainProductData.price || 0);
1288
- let newOriginTotalOriginal = Number(
1289
- mainProductData.original_price || mainProductData.price || 0
1290
- );
1129
+ let newOriginTotalOriginal = Number(mainProductData.original_price || mainProductData.price || 0);
1291
1130
  const updatedMainDiscountListOriginal = mainProductData.discount_list.map((discount) => {
1292
1131
  var _a, _b;
1293
1132
  if ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) {
@@ -1303,16 +1142,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1303
1142
  // num: mainProductQuantity - 1,
1304
1143
  };
1305
1144
  });
1306
- const mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(
1307
- (item) => {
1308
- var _a;
1309
- return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
1310
- }
1311
- );
1145
+ const mainDiscountListOriginal = updatedMainDiscountListOriginal.filter((item) => {
1146
+ var _a;
1147
+ return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
1148
+ });
1312
1149
  if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
1313
- const allDiscountAmount = (0, import_utils.getDiscountListAmount)(
1314
- mainDiscountListOriginal
1315
- );
1150
+ const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
1316
1151
  newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
1317
1152
  newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
1318
1153
  }