@pisell/pisellos 2.1.85 → 2.1.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +0 -11
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/Discount/types.d.ts +0 -15
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Rules/index.d.ts +2 -7
- package/dist/modules/Rules/index.js +19 -141
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +747 -0
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +2 -0
- package/dist/modules/Summary/index.js +47 -5
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +1 -7
- package/dist/modules/Summary/utils.js +23 -33
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +84 -35
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +3 -12
- package/dist/solution/ShopDiscount/types.d.ts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +0 -9
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/Discount/types.d.ts +0 -15
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Rules/index.d.ts +2 -7
- package/lib/modules/Rules/index.js +149 -285
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +451 -0
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +2 -0
- package/lib/modules/Summary/index.js +22 -9
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +1 -7
- package/lib/modules/Summary/utils.js +22 -28
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +34 -3
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -7
- package/lib/solution/ShopDiscount/types.d.ts +0 -1
- package/package.json +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -1
- package/dist/model/strategy/adapter/index.d.ts +0 -3
- package/dist/model/strategy/adapter/index.js +0 -4
- package/dist/model/strategy/adapter/type.d.ts +0 -28
- package/dist/model/strategy/adapter/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -497
- package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/dist/model/strategy/adapter/walletPass/example.js +0 -258
- package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/dist/model/strategy/adapter/walletPass/index.js +0 -182
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -168
- package/dist/model/strategy/adapter/walletPass/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -76
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -1043
- package/dist/model/strategy/index.d.ts +0 -94
- package/dist/model/strategy/index.js +0 -551
- package/dist/model/strategy/strategy-example.d.ts +0 -5
- package/dist/model/strategy/strategy-example.js +0 -331
- package/dist/model/strategy/type.d.ts +0 -228
- package/dist/model/strategy/type.js +0 -94
- package/lib/model/index.d.ts +0 -1
- package/lib/model/index.js +0 -23
- package/lib/model/strategy/adapter/index.d.ts +0 -3
- package/lib/model/strategy/adapter/index.js +0 -45
- package/lib/model/strategy/adapter/type.d.ts +0 -28
- package/lib/model/strategy/adapter/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -421
- package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/lib/model/strategy/adapter/walletPass/example.js +0 -207
- package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/lib/model/strategy/adapter/walletPass/index.js +0 -142
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -168
- package/lib/model/strategy/adapter/walletPass/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -76
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -704
- package/lib/model/strategy/index.d.ts +0 -94
- package/lib/model/strategy/index.js +0 -413
- package/lib/model/strategy/strategy-example.d.ts +0 -5
- package/lib/model/strategy/strategy-example.js +0 -318
- package/lib/model/strategy/type.d.ts +0 -228
- package/lib/model/strategy/type.js +0 -44
|
@@ -50,7 +50,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
50
50
|
this.core = core;
|
|
51
51
|
this.hooks = options == null ? void 0 : options.hooks;
|
|
52
52
|
this.store = options == null ? void 0 : options.store;
|
|
53
|
-
this.window = core.getPlugin("window");
|
|
54
53
|
}
|
|
55
54
|
async setRulesList(rulesList) {
|
|
56
55
|
this.store.rulesList = rulesList;
|
|
@@ -59,10 +58,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
59
58
|
getRulesList() {
|
|
60
59
|
return this.store.rulesList;
|
|
61
60
|
}
|
|
62
|
-
getWalletPassEvaluator() {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
return (_b = (_a = this.window).getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
65
|
-
}
|
|
66
61
|
// 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
|
|
67
62
|
checkHolderMatch(discount, product, holders) {
|
|
68
63
|
var _a;
|
|
@@ -82,7 +77,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
82
77
|
newDiscountList,
|
|
83
78
|
productList,
|
|
84
79
|
holders,
|
|
85
|
-
orderTotalAmount,
|
|
86
80
|
isFormSubject
|
|
87
81
|
}) {
|
|
88
82
|
if (!newDiscountList || newDiscountList.length === 0) {
|
|
@@ -115,7 +109,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
115
109
|
discountList: mergedDiscountList,
|
|
116
110
|
productList: [...productList],
|
|
117
111
|
holders,
|
|
118
|
-
orderTotalAmount,
|
|
119
112
|
isFormSubject
|
|
120
113
|
}, {
|
|
121
114
|
scan: true
|
|
@@ -187,7 +180,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
187
180
|
discountList,
|
|
188
181
|
productList,
|
|
189
182
|
holders,
|
|
190
|
-
orderTotalAmount,
|
|
191
183
|
isFormSubject
|
|
192
184
|
}, options) {
|
|
193
185
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
@@ -366,50 +358,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
366
358
|
}
|
|
367
359
|
return priceB.minus(priceA).toNumber();
|
|
368
360
|
});
|
|
369
|
-
const evaluator = this.getWalletPassEvaluator();
|
|
370
|
-
if (evaluator) {
|
|
371
|
-
addModeDiscount.forEach((discount) => {
|
|
372
|
-
var _a, _b;
|
|
373
|
-
const discountType = discount.tag || discount.type;
|
|
374
|
-
if (["good_pass", "discount_card", "product_discount_card"].includes(
|
|
375
|
-
discountType
|
|
376
|
-
)) {
|
|
377
|
-
const voucher = {
|
|
378
|
-
id: discount.id,
|
|
379
|
-
amount: Number(discount.par_value || 0),
|
|
380
|
-
balance: Number(discount.balance || 0),
|
|
381
|
-
type: discountType,
|
|
382
|
-
product_id: discount.product_id,
|
|
383
|
-
unified_available_status: 1,
|
|
384
|
-
available_product_type: (_a = discount.limited_relation_product_data) == null ? void 0 : _a.type,
|
|
385
|
-
available_product_ids: (_b = discount.limited_relation_product_data) == null ? void 0 : _b.product_ids
|
|
386
|
-
};
|
|
387
|
-
const productsForEvaluate = sortedFlattenedList.map((item) => ({
|
|
388
|
-
product_id: item.id,
|
|
389
|
-
price: item.price || 0,
|
|
390
|
-
quantity: item.quantity || item.num || 1,
|
|
391
|
-
selling_price: item.price || 0
|
|
392
|
-
}));
|
|
393
|
-
const result = evaluator.checkVoucherAvailability({
|
|
394
|
-
orderTotalAmount,
|
|
395
|
-
products: productsForEvaluate,
|
|
396
|
-
vouchers: [voucher]
|
|
397
|
-
});
|
|
398
|
-
if (result.isAvailable) {
|
|
399
|
-
discount.config = {
|
|
400
|
-
...result.config,
|
|
401
|
-
isAvailable: true
|
|
402
|
-
};
|
|
403
|
-
} else {
|
|
404
|
-
discount.config = {
|
|
405
|
-
isAvailable: false
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
361
|
const usedDiscounts = /* @__PURE__ */ new Map();
|
|
412
|
-
const usedProductIdCounts = /* @__PURE__ */ new Map();
|
|
413
362
|
const discountApplicability = /* @__PURE__ */ new Map();
|
|
414
363
|
const discountApplicableProducts = /* @__PURE__ */ new Map();
|
|
415
364
|
addModeDiscount.forEach((discount) => {
|
|
@@ -563,7 +512,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
563
512
|
originProduct = flatItem.originProduct;
|
|
564
513
|
}
|
|
565
514
|
addModeDiscount.forEach((discount) => {
|
|
566
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i
|
|
515
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
567
516
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
568
517
|
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
569
518
|
const isHolderMatch = this.checkHolderMatch(
|
|
@@ -576,7 +525,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
576
525
|
);
|
|
577
526
|
let timeLimit = true;
|
|
578
527
|
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
579
|
-
const isLimitedProduct = (limitedData.type === "product_all"
|
|
528
|
+
const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
580
529
|
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(
|
|
581
530
|
(discount2) => discount2.id && [
|
|
582
531
|
"good_pass",
|
|
@@ -585,8 +534,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
585
534
|
].includes(discount2.tag || discount2.type)
|
|
586
535
|
))) : !((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)));
|
|
587
536
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
588
|
-
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable
|
|
589
|
-
(
|
|
537
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
538
|
+
(_g = discountApplicability.get(discount.id)) == null ? void 0 : _g.push(product.id);
|
|
590
539
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
591
540
|
const discountType = discount.tag || discount.type;
|
|
592
541
|
const isGoodPass = discountType === "good_pass";
|
|
@@ -596,15 +545,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
596
545
|
type: discountType,
|
|
597
546
|
tag: discountType,
|
|
598
547
|
discount: {
|
|
599
|
-
discount_card_type: (
|
|
548
|
+
discount_card_type: (_h = discount == null ? void 0 : discount.metadata) == null ? void 0 : _h.discount_card_type,
|
|
600
549
|
fixed_amount: product.price,
|
|
601
|
-
discount_calculation_mode: (
|
|
550
|
+
discount_calculation_mode: (_i = discount == null ? void 0 : discount.metadata) == null ? void 0 : _i.discount_calculation_mode,
|
|
602
551
|
resource_id: discount.id,
|
|
603
552
|
title: discount.format_title,
|
|
604
553
|
original_amount: product.price || product.origin_total,
|
|
605
554
|
pre_value: discount.par_value,
|
|
606
|
-
product_id: originProduct.id
|
|
607
|
-
discount_product_id: discount.product_id
|
|
555
|
+
product_id: originProduct.id
|
|
608
556
|
},
|
|
609
557
|
metadata: {
|
|
610
558
|
num
|
|
@@ -638,36 +586,22 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
638
586
|
};
|
|
639
587
|
originProduct = flatItem.originProduct;
|
|
640
588
|
}
|
|
641
|
-
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(
|
|
642
|
-
(discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(
|
|
643
|
-
discount.tag || discount.type
|
|
644
|
-
)
|
|
645
|
-
))) {
|
|
589
|
+
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)))) {
|
|
646
590
|
if (flatItem.type === "main") {
|
|
647
591
|
processedProductsMap.set(product._id, [originProduct]);
|
|
648
592
|
} else {
|
|
649
|
-
processedFlatItemsMap.set(flatItem._id, [
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
]);
|
|
593
|
+
processedFlatItemsMap.set(flatItem._id, [{
|
|
594
|
+
...flatItem,
|
|
595
|
+
processed: true
|
|
596
|
+
}]);
|
|
655
597
|
}
|
|
656
598
|
return;
|
|
657
599
|
}
|
|
658
600
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
659
|
-
var _a2, _b2
|
|
660
|
-
|
|
661
|
-
if (["good_pass", "discount_card", "product_discount_card"].includes(
|
|
662
|
-
discountType
|
|
663
|
-
)) {
|
|
664
|
-
if (discount.config === void 0 || !((_a2 = discount == null ? void 0 : discount.config) == null ? void 0 : _a2.isAvailable)) {
|
|
665
|
-
return false;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.length) && (discount.tag || discount.type) === "good_pass")
|
|
601
|
+
var _a2, _b2;
|
|
602
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass")
|
|
669
603
|
return false;
|
|
670
|
-
if ((Number(product.price) <= 0 || !product.price) && !((
|
|
604
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
|
|
671
605
|
var _a3;
|
|
672
606
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
673
607
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
@@ -675,15 +609,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
675
609
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
676
610
|
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
677
611
|
return false;
|
|
678
|
-
if ((discount.tag || discount.type) === "good_pass") {
|
|
679
|
-
const maxUsagePerOrder = (_d2 = discount.config) == null ? void 0 : _d2.maxUsagePerOrder;
|
|
680
|
-
if (maxUsagePerOrder && maxUsagePerOrder > 0) {
|
|
681
|
-
const currentUsedCount = usedProductIdCounts.get(discount.product_id) || 0;
|
|
682
|
-
if (currentUsedCount >= maxUsagePerOrder) {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
612
|
const limitedData = discount.limited_relation_product_data;
|
|
688
613
|
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
689
614
|
const isHolderMatch = this.checkHolderMatch(
|
|
@@ -702,9 +627,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
702
627
|
return false;
|
|
703
628
|
}
|
|
704
629
|
if (limitedData.type === "product_all") {
|
|
705
|
-
if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
|
|
706
|
-
return false;
|
|
707
|
-
}
|
|
708
630
|
if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
709
631
|
return false;
|
|
710
632
|
}
|
|
@@ -717,9 +639,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
717
639
|
}
|
|
718
640
|
return false;
|
|
719
641
|
});
|
|
720
|
-
const selectedDiscountCard = applicableDiscounts.find(
|
|
721
|
-
(n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
|
|
722
|
-
);
|
|
642
|
+
const selectedDiscountCard = applicableDiscounts.find((n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass");
|
|
723
643
|
const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
724
644
|
let isManualDiscount = false;
|
|
725
645
|
if (flatItem.type === "main") {
|
|
@@ -737,12 +657,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
737
657
|
}
|
|
738
658
|
}
|
|
739
659
|
if (options == null ? void 0 : options.discountId) {
|
|
740
|
-
if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
))) {
|
|
660
|
+
if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
|
|
661
|
+
var _a2;
|
|
662
|
+
return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
|
|
663
|
+
}))) {
|
|
746
664
|
isManualDiscount = false;
|
|
747
665
|
}
|
|
748
666
|
if (flatItem.type === "bundle") {
|
|
@@ -758,17 +676,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
758
676
|
}
|
|
759
677
|
}
|
|
760
678
|
if (options == null ? void 0 : options.selectedList) {
|
|
761
|
-
if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
);
|
|
770
|
-
}
|
|
771
|
-
))) {
|
|
679
|
+
if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
|
|
680
|
+
var _a2;
|
|
681
|
+
return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
|
|
682
|
+
var _a3;
|
|
683
|
+
return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
|
|
684
|
+
});
|
|
685
|
+
}))) {
|
|
772
686
|
isManualDiscount = false;
|
|
773
687
|
}
|
|
774
688
|
if (flatItem.type === "bundle") {
|
|
@@ -792,8 +706,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
792
706
|
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
793
707
|
if (flatItem.type === "main") {
|
|
794
708
|
if (product.isClient) {
|
|
795
|
-
processedProductsMap.set(
|
|
796
|
-
|
|
709
|
+
processedProductsMap.set(
|
|
710
|
+
product._id,
|
|
711
|
+
[this.hooks.setProduct(originProduct, {
|
|
797
712
|
...isManualDiscount ? {} : {
|
|
798
713
|
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
799
714
|
product: {
|
|
@@ -814,11 +729,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
814
729
|
price: product.price
|
|
815
730
|
},
|
|
816
731
|
discount_list: []
|
|
817
|
-
})
|
|
818
|
-
|
|
732
|
+
})]
|
|
733
|
+
);
|
|
819
734
|
} else {
|
|
820
|
-
processedProductsMap.set(
|
|
821
|
-
|
|
735
|
+
processedProductsMap.set(
|
|
736
|
+
product._id,
|
|
737
|
+
[this.hooks.setProduct(originProduct, {
|
|
822
738
|
...isManualDiscount ? {
|
|
823
739
|
price: product.price,
|
|
824
740
|
main_product_selling_price: product.price
|
|
@@ -829,8 +745,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
829
745
|
main_product_selling_price: product.price
|
|
830
746
|
},
|
|
831
747
|
discount_list: []
|
|
832
|
-
})
|
|
833
|
-
|
|
748
|
+
})]
|
|
749
|
+
);
|
|
834
750
|
}
|
|
835
751
|
} else {
|
|
836
752
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
@@ -847,36 +763,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
847
763
|
}
|
|
848
764
|
const isNeedSplit = (selectedDiscount.tag || selectedDiscount.type) === "good_pass";
|
|
849
765
|
const totalQuantity = product.quantity || product.num || 1;
|
|
850
|
-
const availableGoodPassCount = applicableDiscounts.filter(
|
|
851
|
-
|
|
852
|
-
).length;
|
|
853
|
-
let maxUsageLimit = availableGoodPassCount;
|
|
854
|
-
if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
|
|
855
|
-
maxUsageLimit = Math.min(
|
|
856
|
-
availableGoodPassCount,
|
|
857
|
-
selectedDiscount.config.maxUsagePerOrder
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
const splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
|
|
766
|
+
const availableGoodPassCount = applicableDiscounts.filter((item) => (item.tag || item.type) === "good_pass").length;
|
|
767
|
+
const splitCount = isNeedSplit ? Math.min(totalQuantity, availableGoodPassCount) : 1;
|
|
861
768
|
const arr = [];
|
|
862
769
|
if (flatItem.type === "main") {
|
|
863
770
|
if (splitCount < totalQuantity && isNeedSplit) {
|
|
864
|
-
arr.push(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
total: product.origin_total || product.total
|
|
870
|
-
})
|
|
871
|
-
);
|
|
771
|
+
arr.push(this.hooks.setProduct(originProduct, {
|
|
772
|
+
discount_list: [],
|
|
773
|
+
quantity: totalQuantity - splitCount,
|
|
774
|
+
_id: product._id.split("___")[0]
|
|
775
|
+
}));
|
|
872
776
|
}
|
|
873
777
|
for (let i = 0; i < splitCount; i++) {
|
|
874
778
|
const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[i];
|
|
875
779
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
876
|
-
if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
|
|
877
|
-
const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
|
|
878
|
-
usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
|
|
879
|
-
}
|
|
880
780
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
881
781
|
let productOriginTotal = product.origin_total || product.total || 0;
|
|
882
782
|
if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
|
|
@@ -899,7 +799,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
899
799
|
targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
|
|
900
800
|
amount = new import_decimal.default(product.price).minus(new import_decimal.default(targetProductTotal)).toNumber();
|
|
901
801
|
}
|
|
902
|
-
const discountType = selectedDiscount2.tag
|
|
802
|
+
const discountType = selectedDiscount2.tag || selectedDiscount2.type;
|
|
903
803
|
const isGoodPass = discountType === "good_pass";
|
|
904
804
|
const discountDetail = {
|
|
905
805
|
amount,
|
|
@@ -912,12 +812,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
912
812
|
title: selectedDiscount2.format_title,
|
|
913
813
|
original_amount: product.price,
|
|
914
814
|
product_id: originProduct.id,
|
|
915
|
-
percent: selectedDiscount2.par_value
|
|
916
|
-
discount_product_id: selectedDiscount2.product_id
|
|
815
|
+
percent: selectedDiscount2.par_value
|
|
917
816
|
},
|
|
918
817
|
// 前端使用的num数量,为了计算优惠金额
|
|
919
818
|
_num: isGoodPass ? 1 : product.num,
|
|
920
|
-
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
921
819
|
metadata: {
|
|
922
820
|
num: 1,
|
|
923
821
|
// 🔥 order_level 分摊差值
|
|
@@ -935,6 +833,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
935
833
|
}, new import_decimal.default(total)).toNumber();
|
|
936
834
|
}
|
|
937
835
|
if (product.isClient) {
|
|
836
|
+
debugger;
|
|
938
837
|
arr.push(this.hooks.setProduct(originProduct, {
|
|
939
838
|
discount_list: [discountDetail],
|
|
940
839
|
price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
|
|
@@ -971,19 +870,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
971
870
|
for (let i = 0; i < discountNum; i++) {
|
|
972
871
|
const selectedDiscount2 = applicableDiscounts[i];
|
|
973
872
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
974
|
-
if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
|
|
975
|
-
const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
|
|
976
|
-
usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
|
|
977
|
-
}
|
|
978
873
|
const uniqueId = `${flatItem._id}_split_${i}`;
|
|
979
|
-
const discountedPrice = (0, import_utils.getDiscountAmount)(
|
|
980
|
-
selectedDiscount2,
|
|
981
|
-
product.origin_total,
|
|
982
|
-
product.origin_total
|
|
983
|
-
);
|
|
984
|
-
const bundleDiscountAmount = new import_decimal.default(product.origin_total || 0).minus(discountedPrice).toNumber();
|
|
985
874
|
const discountDetail = {
|
|
986
|
-
amount:
|
|
875
|
+
amount: product.origin_total,
|
|
987
876
|
type: "good_pass",
|
|
988
877
|
discount: {
|
|
989
878
|
fixed_amount: product.origin_total,
|
|
@@ -991,16 +880,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
991
880
|
resource_id: selectedDiscount2.id,
|
|
992
881
|
title: selectedDiscount2.format_title,
|
|
993
882
|
original_amount: product.origin_total,
|
|
994
|
-
product_id: product.id
|
|
995
|
-
discount_product_id: selectedDiscount2.product_id
|
|
883
|
+
product_id: product.id
|
|
996
884
|
},
|
|
997
885
|
metadata: {
|
|
998
886
|
// 🔥 使用拆分后的唯一 _id
|
|
999
887
|
custom_product_bundle_map_id: uniqueId,
|
|
1000
888
|
num: 1
|
|
1001
889
|
},
|
|
1002
|
-
_num: 1
|
|
1003
|
-
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config
|
|
890
|
+
_num: 1
|
|
1004
891
|
};
|
|
1005
892
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
1006
893
|
appliedProducts.push(discountDetail);
|
|
@@ -1011,9 +898,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1011
898
|
_id: uniqueId,
|
|
1012
899
|
num: 1,
|
|
1013
900
|
quantity: 1,
|
|
1014
|
-
price:
|
|
1015
|
-
//
|
|
1016
|
-
total:
|
|
901
|
+
price: 0,
|
|
902
|
+
// 商品券价格为0
|
|
903
|
+
total: 0,
|
|
1017
904
|
discount_list: [discountDetail],
|
|
1018
905
|
processed: true,
|
|
1019
906
|
_discountId: selectedDiscount2.id
|
|
@@ -1033,10 +920,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1033
920
|
} else {
|
|
1034
921
|
const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[0];
|
|
1035
922
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
1036
|
-
if ((selectedDiscount2.tag || selectedDiscount2.type) === "good_pass") {
|
|
1037
|
-
const currentCount = usedProductIdCounts.get(selectedDiscount2.product_id) || 0;
|
|
1038
|
-
usedProductIdCounts.set(selectedDiscount2.product_id, currentCount + 1);
|
|
1039
|
-
}
|
|
1040
923
|
const productOriginTotal = product.original_price || product.price || 0;
|
|
1041
924
|
const isOrderLevel = (0, import_utils.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
|
|
1042
925
|
const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
|
|
@@ -1056,6 +939,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1056
939
|
);
|
|
1057
940
|
fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1058
941
|
}
|
|
942
|
+
debugger;
|
|
1059
943
|
const uniqueId = flatItem._id;
|
|
1060
944
|
const discountDetail = {
|
|
1061
945
|
amount: fixedAmountPerItem * (product.num || 1),
|
|
@@ -1068,8 +952,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1068
952
|
title: selectedDiscount2.format_title,
|
|
1069
953
|
original_amount: product.original_price,
|
|
1070
954
|
product_id: product.id,
|
|
1071
|
-
percent: selectedDiscount2.par_value
|
|
1072
|
-
discount_product_id: selectedDiscount2.product_id
|
|
955
|
+
percent: selectedDiscount2.par_value
|
|
1073
956
|
},
|
|
1074
957
|
metadata: {
|
|
1075
958
|
// 🔥 使用唯一的 _id
|
|
@@ -1078,7 +961,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1078
961
|
// 🔥 order_level 分摊差值
|
|
1079
962
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
1080
963
|
},
|
|
1081
|
-
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
1082
964
|
_num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
|
|
1083
965
|
};
|
|
1084
966
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
@@ -1168,67 +1050,61 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1168
1050
|
const mainProduct = mainProductArr[0];
|
|
1169
1051
|
const mainProductData = this.hooks.getProduct(mainProduct);
|
|
1170
1052
|
const newBundleWithDiscount = [];
|
|
1171
|
-
(product.bundle || []).forEach(
|
|
1172
|
-
(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
metadata:
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1053
|
+
(product.bundle || []).forEach((bundleItem, bundleIndex) => {
|
|
1054
|
+
const processedItems = bundleProcessingInfo.get(bundleIndex) || [bundleItem];
|
|
1055
|
+
if (processedItems.length > 1) {
|
|
1056
|
+
processedItems.forEach((item) => {
|
|
1057
|
+
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1058
|
+
var _a;
|
|
1059
|
+
return {
|
|
1060
|
+
...discount,
|
|
1061
|
+
metadata: {
|
|
1062
|
+
...discount.metadata,
|
|
1063
|
+
num: item.num,
|
|
1064
|
+
custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
|
|
1065
|
+
}
|
|
1066
|
+
// num: item.num, // 使用拆分后的 num
|
|
1067
|
+
};
|
|
1068
|
+
});
|
|
1069
|
+
newBundleWithDiscount.push({
|
|
1070
|
+
...bundleItem,
|
|
1071
|
+
_id: item._id,
|
|
1072
|
+
product_id: bundleItem.product_id,
|
|
1073
|
+
price: item.price,
|
|
1074
|
+
num: item.num,
|
|
1075
|
+
discount_list: updatedDiscountList2
|
|
1076
|
+
});
|
|
1077
|
+
});
|
|
1078
|
+
} else {
|
|
1079
|
+
const item = processedItems[0];
|
|
1080
|
+
if (item.processed) {
|
|
1081
|
+
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1082
|
+
var _a;
|
|
1083
|
+
return {
|
|
1084
|
+
...discount,
|
|
1085
|
+
metadata: {
|
|
1086
|
+
...discount.metadata,
|
|
1087
|
+
num: item.num,
|
|
1088
|
+
custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
|
|
1089
|
+
}
|
|
1090
|
+
// num: item.num, // 使用当前的 num
|
|
1091
|
+
};
|
|
1092
|
+
});
|
|
1093
|
+
newBundleWithDiscount.push({
|
|
1094
|
+
...bundleItem,
|
|
1095
|
+
_id: item._id,
|
|
1096
|
+
product_id: bundleItem.product_id,
|
|
1097
|
+
price: item.price,
|
|
1098
|
+
num: item.num,
|
|
1099
|
+
discount_list: updatedDiscountList2
|
|
1198
1100
|
});
|
|
1199
1101
|
} else {
|
|
1200
|
-
|
|
1201
|
-
if (item.processed) {
|
|
1202
|
-
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1203
|
-
var _a;
|
|
1204
|
-
return {
|
|
1205
|
-
...discount,
|
|
1206
|
-
metadata: {
|
|
1207
|
-
...discount.metadata,
|
|
1208
|
-
num: item.num,
|
|
1209
|
-
custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
|
|
1210
|
-
}
|
|
1211
|
-
// num: item.num, // 使用当前的 num
|
|
1212
|
-
};
|
|
1213
|
-
});
|
|
1214
|
-
newBundleWithDiscount.push({
|
|
1215
|
-
...bundleItem,
|
|
1216
|
-
_id: item._id,
|
|
1217
|
-
product_id: bundleItem.product_id,
|
|
1218
|
-
price: item.price,
|
|
1219
|
-
num: item.num,
|
|
1220
|
-
discount_list: updatedDiscountList2
|
|
1221
|
-
});
|
|
1222
|
-
} else {
|
|
1223
|
-
newBundleWithDiscount.push(item);
|
|
1224
|
-
}
|
|
1102
|
+
newBundleWithDiscount.push(item);
|
|
1225
1103
|
}
|
|
1226
1104
|
}
|
|
1227
|
-
);
|
|
1105
|
+
});
|
|
1228
1106
|
let newTotalWithDiscount = Number(mainProductData.price || 0);
|
|
1229
|
-
let newOriginTotalWithDiscount = Number(
|
|
1230
|
-
mainProductData.original_price || mainProductData.price || 0
|
|
1231
|
-
);
|
|
1107
|
+
let newOriginTotalWithDiscount = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
1232
1108
|
const updatedMainDiscountList = mainProductData.discount_list.map((discount) => {
|
|
1233
1109
|
var _a, _b;
|
|
1234
1110
|
if ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) {
|
|
@@ -1244,12 +1120,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1244
1120
|
}
|
|
1245
1121
|
};
|
|
1246
1122
|
});
|
|
1247
|
-
const mainDiscountList = updatedMainDiscountList.filter(
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
}
|
|
1252
|
-
);
|
|
1123
|
+
const mainDiscountList = updatedMainDiscountList.filter((item) => {
|
|
1124
|
+
var _a;
|
|
1125
|
+
return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
|
|
1126
|
+
});
|
|
1253
1127
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1254
1128
|
const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
|
|
1255
1129
|
newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
|
|
@@ -1285,18 +1159,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1285
1159
|
);
|
|
1286
1160
|
if (mainProductQuantity > 1) {
|
|
1287
1161
|
const newBundleOriginal = [];
|
|
1288
|
-
(product.bundle || []).forEach(
|
|
1289
|
-
(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}
|
|
1295
|
-
);
|
|
1162
|
+
(product.bundle || []).forEach((bundleItem, bundleIndex) => {
|
|
1163
|
+
newBundleOriginal.push({
|
|
1164
|
+
...bundleItem,
|
|
1165
|
+
discount_list: []
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1296
1168
|
let newTotalOriginal = Number(mainProductData.price || 0);
|
|
1297
|
-
let newOriginTotalOriginal = Number(
|
|
1298
|
-
mainProductData.original_price || mainProductData.price || 0
|
|
1299
|
-
);
|
|
1169
|
+
let newOriginTotalOriginal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
1300
1170
|
const updatedMainDiscountListOriginal = mainProductData.discount_list.map((discount) => {
|
|
1301
1171
|
var _a, _b;
|
|
1302
1172
|
if ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) {
|
|
@@ -1312,16 +1182,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1312
1182
|
// num: mainProductQuantity - 1,
|
|
1313
1183
|
};
|
|
1314
1184
|
});
|
|
1315
|
-
const mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1320
|
-
);
|
|
1185
|
+
const mainDiscountListOriginal = updatedMainDiscountListOriginal.filter((item) => {
|
|
1186
|
+
var _a;
|
|
1187
|
+
return !((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id);
|
|
1188
|
+
});
|
|
1321
1189
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1322
|
-
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(
|
|
1323
|
-
mainDiscountListOriginal
|
|
1324
|
-
);
|
|
1190
|
+
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
|
|
1325
1191
|
newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
|
|
1326
1192
|
newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
|
|
1327
1193
|
}
|
|
@@ -1356,38 +1222,36 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1356
1222
|
const mainProductData = this.hooks.getProduct(mainProduct);
|
|
1357
1223
|
const newBundle = [];
|
|
1358
1224
|
if (product.bundle && Array.isArray(product.bundle)) {
|
|
1359
|
-
product.bundle.forEach(
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
metadata
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
discount_list: updatedDiscountList2
|
|
1386
|
-
});
|
|
1225
|
+
product.bundle.forEach((bundleItem, bundleIndex) => {
|
|
1226
|
+
const bundleItemId = `${product._id}_bundle_${bundleIndex}`;
|
|
1227
|
+
const processedBundleItems = processedFlatItemsMap2.get(bundleItemId);
|
|
1228
|
+
if (!processedBundleItems || processedBundleItems.length === 0) {
|
|
1229
|
+
newBundle.push(bundleItem);
|
|
1230
|
+
} else {
|
|
1231
|
+
processedBundleItems.forEach((item) => {
|
|
1232
|
+
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1233
|
+
var _a2;
|
|
1234
|
+
return {
|
|
1235
|
+
...discount,
|
|
1236
|
+
metadata: {
|
|
1237
|
+
...discount.metadata,
|
|
1238
|
+
num: item.num,
|
|
1239
|
+
custom_product_bundle_map_id: (_a2 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id
|
|
1240
|
+
}
|
|
1241
|
+
// num: item.num, // 使用拆分后的 num
|
|
1242
|
+
};
|
|
1243
|
+
});
|
|
1244
|
+
newBundle.push({
|
|
1245
|
+
...bundleItem,
|
|
1246
|
+
_id: item._id,
|
|
1247
|
+
product_id: bundleItem.product_id,
|
|
1248
|
+
price: item.price,
|
|
1249
|
+
num: item.num,
|
|
1250
|
+
discount_list: updatedDiscountList2
|
|
1387
1251
|
});
|
|
1388
|
-
}
|
|
1252
|
+
});
|
|
1389
1253
|
}
|
|
1390
|
-
);
|
|
1254
|
+
});
|
|
1391
1255
|
}
|
|
1392
1256
|
let newTotal = Number(mainProductData.price || 0);
|
|
1393
1257
|
let newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|