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