@pisell/pisellos 2.2.273 → 2.2.275
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +7 -6
- package/dist/modules/Order/index.js +217 -115
- package/dist/modules/Order/types.d.ts +23 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +81 -4
- package/dist/modules/Payment/types.js +18 -3
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +78 -64
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +27 -18
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +16 -0
- package/dist/server/modules/order/index.js +964 -776
- package/dist/server/modules/order/types.d.ts +14 -0
- package/dist/server/modules/order/types.js +6 -0
- package/dist/solution/BaseSales/index.d.ts +80 -15
- package/dist/solution/BaseSales/index.js +1498 -444
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +8 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +12 -3
- package/dist/solution/BookingTicket/types.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +7 -6
- package/lib/modules/Order/index.js +127 -20
- package/lib/modules/Order/types.d.ts +23 -3
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +81 -4
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +24 -14
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +14 -6
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +16 -0
- package/lib/server/modules/order/index.js +140 -4
- package/lib/server/modules/order/types.d.ts +14 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +80 -15
- package/lib/solution/BaseSales/index.js +712 -48
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +8 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/types.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -27,6 +27,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
27
27
|
}): {
|
|
28
28
|
isAvailable: boolean;
|
|
29
29
|
discountList: Discount[];
|
|
30
|
+
/** 完整规则计算后的列表;调用方可用于保留暂时无适用商品的扫码卡券。 */
|
|
31
|
+
evaluatedDiscountList?: Discount[];
|
|
30
32
|
productList: any[];
|
|
31
33
|
unavailableReason?: UnavailableReason;
|
|
32
34
|
};
|
|
@@ -150,7 +150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// 编辑商品已有商品券
|
|
153
|
-
if (productList.every(function (item) {
|
|
153
|
+
if (productList.length > 0 && productList.every(function (item) {
|
|
154
154
|
var _product$discount_lis;
|
|
155
155
|
var product = _this2.hooks.getProduct(item);
|
|
156
156
|
return product.booking_id && (((_product$discount_lis = product.discount_list) === null || _product$discount_lis === void 0 ? void 0 : _product$discount_lis.length) || product.total == 0);
|
|
@@ -214,6 +214,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
214
|
return {
|
|
215
215
|
isAvailable: hasApplicableDiscount,
|
|
216
216
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
217
|
+
evaluatedDiscountList: result.discountList,
|
|
217
218
|
productList: hasApplicableDiscount ? result.productList : productList,
|
|
218
219
|
unavailableReason: unavailableReason
|
|
219
220
|
};
|
|
@@ -256,19 +257,22 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
256
257
|
}, {
|
|
257
258
|
key: "getUnavailableReason",
|
|
258
259
|
value: function getUnavailableReason(discountList, productList) {
|
|
260
|
+
var _this3 = this;
|
|
259
261
|
// 检查时间限制
|
|
260
262
|
var _iterator = _createForOfIteratorHelper(discountList),
|
|
261
263
|
_step;
|
|
262
264
|
try {
|
|
263
265
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
264
266
|
var discount = _step.value;
|
|
265
|
-
var
|
|
267
|
+
var bookingTimes = productList.length ? productList.map(function (item) {
|
|
268
|
+
var product = _this3.hooks.getProduct(item);
|
|
269
|
+
return ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
270
|
+
}) : [dayjs().format('YYYY-MM-DD HH:mm:ss')];
|
|
271
|
+
var _iterator3 = _createForOfIteratorHelper(bookingTimes),
|
|
266
272
|
_step3;
|
|
267
273
|
try {
|
|
268
274
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
269
|
-
var
|
|
270
|
-
var product = this.hooks.getProduct(item);
|
|
271
|
-
var bookingTime = ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
275
|
+
var bookingTime = _step3.value;
|
|
272
276
|
var filteredList = filterDiscountListByBookingTime([discount], bookingTime);
|
|
273
277
|
if (filteredList.length === 0) {
|
|
274
278
|
return UnavailableReason.TimeLimit;
|
|
@@ -299,12 +303,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
303
|
try {
|
|
300
304
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
301
305
|
var _limitedData$product_;
|
|
302
|
-
var
|
|
303
|
-
var
|
|
306
|
+
var item = _step4.value;
|
|
307
|
+
var product = this.hooks.getProduct(item);
|
|
304
308
|
if (limitedData.type === 'product_all') {
|
|
305
309
|
hasApplicableProduct = true;
|
|
306
310
|
break;
|
|
307
|
-
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(
|
|
311
|
+
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(product.id)) {
|
|
308
312
|
hasApplicableProduct = true;
|
|
309
313
|
break;
|
|
310
314
|
}
|
|
@@ -329,7 +333,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
333
|
key: "calcDiscount",
|
|
330
334
|
value: function calcDiscount(_ref2, options) {
|
|
331
335
|
var _options$selectedList,
|
|
332
|
-
|
|
336
|
+
_this4 = this;
|
|
333
337
|
var discountList = _ref2.discountList,
|
|
334
338
|
productList = _ref2.productList,
|
|
335
339
|
holders = _ref2.holders,
|
|
@@ -362,7 +366,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
362
366
|
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
363
367
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
364
368
|
};
|
|
365
|
-
var
|
|
369
|
+
var resolveReapplyBookingDiscountPercent = function resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount) {
|
|
366
370
|
var _discount2;
|
|
367
371
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
368
372
|
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
@@ -422,7 +426,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
422
426
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
423
427
|
var flattened = [];
|
|
424
428
|
productList.forEach(function (originProduct) {
|
|
425
|
-
var product =
|
|
429
|
+
var product = _this4.hooks.getProduct(originProduct);
|
|
426
430
|
|
|
427
431
|
// 1. 添加主商品
|
|
428
432
|
flattened.push({
|
|
@@ -449,6 +453,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
449
453
|
bundleIndex: bundleIndex,
|
|
450
454
|
// 虚拟商品属性
|
|
451
455
|
price: Number(bundleItem.price || 0),
|
|
456
|
+
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
457
|
+
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
458
|
+
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
452
459
|
id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
453
460
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
454
461
|
parentId: product._id,
|
|
@@ -723,7 +730,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
723
730
|
|
|
724
731
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
725
732
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
726
|
-
var _product2, _product3,
|
|
733
|
+
var _product, _product2, _product3, _flatItem$bundleItem, _flatItem$bundleItem2, _product4;
|
|
727
734
|
var product;
|
|
728
735
|
if (flatItem.type === 'main') {
|
|
729
736
|
product = flatItem.product;
|
|
@@ -740,12 +747,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
740
747
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
741
748
|
};
|
|
742
749
|
}
|
|
743
|
-
if (
|
|
750
|
+
if (_this4.isItemRewardProductDiscount(product)) {
|
|
744
751
|
return false;
|
|
745
752
|
}
|
|
746
753
|
|
|
747
754
|
// 编辑的商品使用了优惠券不可用
|
|
748
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
755
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product = product) !== null && _product !== void 0 && _product.booking_id && (_product2 = product) !== null && _product2 !== void 0 && (_product2 = _product2.discount_list) !== null && _product2 !== void 0 && _product2.length && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.every(function (d) {
|
|
749
756
|
return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
750
757
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.discount_list) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem2 = flatItem.bundleItem) !== null && _flatItem$bundleItem2 !== void 0 && (_flatItem$bundleItem2 = _flatItem$bundleItem2.discount_list) !== null && _flatItem$bundleItem2 !== void 0 && _flatItem$bundleItem2.every(function (d) {
|
|
751
758
|
return d.id;
|
|
@@ -766,7 +773,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
766
773
|
var limitedData = discount.limited_relation_product_data;
|
|
767
774
|
|
|
768
775
|
// 时间限制检查
|
|
769
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
776
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product4 = product) === null || _product4 === void 0 ? void 0 : _product4.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
770
777
|
if (!timeLimit) {
|
|
771
778
|
return false;
|
|
772
779
|
}
|
|
@@ -786,7 +793,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
786
793
|
}
|
|
787
794
|
|
|
788
795
|
// 套餐规则检查
|
|
789
|
-
var isBundleAvailable =
|
|
796
|
+
var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
|
|
790
797
|
return isLimitedProduct && isBundleAvailable;
|
|
791
798
|
};
|
|
792
799
|
|
|
@@ -929,30 +936,30 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
936
|
};
|
|
930
937
|
originProduct = flatItem.originProduct;
|
|
931
938
|
}
|
|
932
|
-
var isItemRewardProductDiscount =
|
|
939
|
+
var isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
|
|
933
940
|
addModeDiscount.forEach(function (discount) {
|
|
934
|
-
var _product6, _product7, _product8,
|
|
941
|
+
var _product5, _product6, _product7, _product8, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
935
942
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
936
943
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
937
944
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
938
|
-
var isHolderMatch =
|
|
945
|
+
var isHolderMatch = _this4.checkHolderMatch(discount, {
|
|
939
946
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
940
947
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
941
948
|
}, holders);
|
|
942
949
|
var timeLimit = true;
|
|
943
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
950
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
944
951
|
// 是符合折扣的商品
|
|
945
952
|
var isLimitedProduct = (limitedData.type === 'product_all' && limitedData.filter !== 1 || limitedData.type === 'product_all' && limitedData.filter === 1 && !limitedData.exclude_product_ids.includes(product.id) || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
946
953
|
|
|
947
954
|
// 编辑的商品 使用了优惠券不可用
|
|
948
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
955
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product6 = product) !== null && _product6 !== void 0 && _product6.booking_id && (_product7 = product) !== null && _product7 !== void 0 && (_product7 = _product7.discount_list) !== null && _product7 !== void 0 && _product7.length && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.every(function (discount) {
|
|
949
956
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
950
957
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem3 = flatItem.bundleItem) !== null && _flatItem$bundleItem3 !== void 0 && (_flatItem$bundleItem3 = _flatItem$bundleItem3.discount_list) !== null && _flatItem$bundleItem3 !== void 0 && _flatItem$bundleItem3.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem4 = flatItem.bundleItem) !== null && _flatItem$bundleItem4 !== void 0 && (_flatItem$bundleItem4 = _flatItem$bundleItem4.discount_list) !== null && _flatItem$bundleItem4 !== void 0 && _flatItem$bundleItem4.every(function (discount) {
|
|
951
958
|
return discount.id;
|
|
952
959
|
}));
|
|
953
960
|
|
|
954
961
|
// 套餐是否可用判断
|
|
955
|
-
var isBundleAvailable =
|
|
962
|
+
var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
|
|
956
963
|
|
|
957
964
|
// 判断优惠券是否适用于该商品
|
|
958
965
|
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
@@ -1053,7 +1060,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1053
1060
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1054
1061
|
// 🔥 使用扁平化后的列表进行处理
|
|
1055
1062
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1056
|
-
var
|
|
1063
|
+
var _product9, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product10;
|
|
1057
1064
|
// 获取商品数据
|
|
1058
1065
|
var product, originProduct;
|
|
1059
1066
|
if (flatItem.type === 'main') {
|
|
@@ -1077,8 +1084,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1077
1084
|
};
|
|
1078
1085
|
originProduct = flatItem.originProduct;
|
|
1079
1086
|
}
|
|
1080
|
-
var isPersistedProduct = ((
|
|
1081
|
-
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((
|
|
1087
|
+
var isPersistedProduct = ((_product9 = product) === null || _product9 === void 0 ? void 0 : _product9.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
|
|
1088
|
+
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product10 = product) === null || _product10 === void 0 || (_product10 = _product10.discount_list) === null || _product10 === void 0 ? void 0 : _product10.every(function (discount) {
|
|
1082
1089
|
var _discount$id, _discount$discount4;
|
|
1083
1090
|
var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
|
|
1084
1091
|
var discountType = discount.tag || discount.type;
|
|
@@ -1089,18 +1096,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1089
1096
|
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
1090
1097
|
if (flatItem.type === 'main') {
|
|
1091
1098
|
processedProductsMap.set(product._id, [originProduct]);
|
|
1092
|
-
} else {
|
|
1093
|
-
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1094
|
-
processed: true
|
|
1095
|
-
})]);
|
|
1096
1099
|
}
|
|
1100
|
+
// bundle 虚拟项没有携带完整的历史价格字段。这里不写入 processed map,
|
|
1101
|
+
// 重组阶段会直接保留原始 bundleItem,避免把 bundle_selling_price
|
|
1102
|
+
// 覆盖为未折扣的 price,导致已支付金额再次进入应付。
|
|
1097
1103
|
return;
|
|
1098
1104
|
}
|
|
1099
1105
|
|
|
1100
1106
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1101
1107
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1102
1108
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1103
|
-
if (
|
|
1109
|
+
if (_this4.isItemRewardProductDiscount(product)) return false;
|
|
1104
1110
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1105
1111
|
var discountType = discount.tag || discount.type;
|
|
1106
1112
|
var currentOriginUid = getOriginProductUid(originProduct);
|
|
@@ -1146,7 +1152,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1146
1152
|
|
|
1147
1153
|
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
1148
1154
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
1149
|
-
var isHolderMatch =
|
|
1155
|
+
var isHolderMatch = _this4.checkHolderMatch(discount, {
|
|
1150
1156
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
1151
1157
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
1152
1158
|
}, holders);
|
|
@@ -1164,13 +1170,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1164
1170
|
return false;
|
|
1165
1171
|
}
|
|
1166
1172
|
// 检查 package_sub_item_usage_rules
|
|
1167
|
-
if (!
|
|
1173
|
+
if (!_this4.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1168
1174
|
return false;
|
|
1169
1175
|
}
|
|
1170
1176
|
return true;
|
|
1171
1177
|
} else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
1172
1178
|
// 检查 package_sub_item_usage_rules
|
|
1173
|
-
if (!
|
|
1179
|
+
if (!_this4.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1174
1180
|
return false;
|
|
1175
1181
|
}
|
|
1176
1182
|
return true;
|
|
@@ -1196,17 +1202,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1202
|
var isManualDiscount = false;
|
|
1197
1203
|
var isItemRewardProductDiscount = false;
|
|
1198
1204
|
if (flatItem.type === 'main') {
|
|
1199
|
-
var _product$discount_lis5, _product$discount_lis6,
|
|
1205
|
+
var _product$discount_lis5, _product$discount_lis6, _product11, _product11$every;
|
|
1200
1206
|
// 主商品:判断自身是否手动折扣
|
|
1201
1207
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1202
1208
|
return item.type === 'product';
|
|
1203
1209
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1204
1210
|
var _ref12;
|
|
1205
1211
|
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1206
|
-
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((
|
|
1212
|
+
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
|
|
1207
1213
|
return item.type === 'product';
|
|
1208
1214
|
})));
|
|
1209
|
-
isItemRewardProductDiscount =
|
|
1215
|
+
isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
|
|
1210
1216
|
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1211
1217
|
isManualDiscount = false;
|
|
1212
1218
|
}
|
|
@@ -1289,7 +1295,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1295
|
// 主商品:保持原有逻辑,还原 option 价格
|
|
1290
1296
|
var restoredOptions = restoreOptionPrices(product.options);
|
|
1291
1297
|
if (product.isClient) {
|
|
1292
|
-
processedProductsMap.set(product._id, [
|
|
1298
|
+
processedProductsMap.set(product._id, [_this4.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
|
|
1293
1299
|
origin_total: getProductOriginTotalPrice({
|
|
1294
1300
|
product: {
|
|
1295
1301
|
original_price: product.original_price
|
|
@@ -1309,11 +1315,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1309
1315
|
price: product.price,
|
|
1310
1316
|
options: restoredOptions
|
|
1311
1317
|
}), {}, {
|
|
1312
|
-
discount_list: isManualDiscount ?
|
|
1318
|
+
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1313
1319
|
}))]);
|
|
1314
1320
|
} else {
|
|
1315
|
-
var _ref14, _product$_promotion$f,
|
|
1316
|
-
var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (
|
|
1321
|
+
var _ref14, _product$_promotion$f, _product12, _product$origin_total;
|
|
1322
|
+
var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1317
1323
|
var main_product_selling_price = product.price;
|
|
1318
1324
|
if ((product.discount_list || []).some(function (item) {
|
|
1319
1325
|
return item.type === 'promotion';
|
|
@@ -1322,7 +1328,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1322
1328
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1323
1329
|
main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
|
|
1324
1330
|
}
|
|
1325
|
-
processedProductsMap.set(product._id, [
|
|
1331
|
+
processedProductsMap.set(product._id, [_this4.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
|
|
1326
1332
|
price: product.price,
|
|
1327
1333
|
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
|
|
1328
1334
|
}, isItemRewardProductDiscount ? {
|
|
@@ -1334,14 +1340,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1334
1340
|
main_product_selling_price: main_product_selling_price,
|
|
1335
1341
|
options: restoredOptions
|
|
1336
1342
|
}), {}, {
|
|
1337
|
-
discount_list: isManualDiscount ?
|
|
1343
|
+
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1338
1344
|
}))]);
|
|
1339
1345
|
}
|
|
1340
1346
|
} else {
|
|
1341
1347
|
var _flatItem$bundleItem8, _flatItem$bundleItem9;
|
|
1342
1348
|
// bundle子商品:保存到扁平化Map
|
|
1343
1349
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1344
|
-
discount_list: isManualDiscount ?
|
|
1350
|
+
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this4.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
|
|
1345
1351
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
1346
1352
|
processed: true
|
|
1347
1353
|
})]);
|
|
@@ -1382,8 +1388,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1382
1388
|
var _product$total2;
|
|
1383
1389
|
_total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
|
|
1384
1390
|
}
|
|
1385
|
-
arr.push(
|
|
1386
|
-
discount_list:
|
|
1391
|
+
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1392
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1387
1393
|
quantity: totalQuantity - splitCount,
|
|
1388
1394
|
_id: product._id.split('___')[0],
|
|
1389
1395
|
total: _total
|
|
@@ -1407,7 +1413,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1407
1413
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
1408
1414
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
1409
1415
|
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
1410
|
-
if (
|
|
1416
|
+
if (_this4.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
|
|
1411
1417
|
productOriginTotal = product.origin_total;
|
|
1412
1418
|
}
|
|
1413
1419
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
@@ -1434,9 +1440,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1440
|
amount = productAllocation.discountAmount;
|
|
1435
1441
|
productDiscountDifference = productAllocation.difference;
|
|
1436
1442
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1437
|
-
} else if (
|
|
1443
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1438
1444
|
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1439
|
-
var percent =
|
|
1445
|
+
var percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount);
|
|
1440
1446
|
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1441
1447
|
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1442
1448
|
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
@@ -1494,7 +1500,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1494
1500
|
// 记录应用了优惠券的商品
|
|
1495
1501
|
// 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
|
|
1496
1502
|
if (product.isClient) {
|
|
1497
|
-
arr.push(
|
|
1503
|
+
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1498
1504
|
discount_list: [discountDetail],
|
|
1499
1505
|
// good_pass:主商品价以折后价为准;勿用 product.price - amount(amount 含 option 优惠时会算错)
|
|
1500
1506
|
price: isGoodPass ? mainProductSellingPrice : product.price,
|
|
@@ -1512,8 +1518,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1512
1518
|
options: discountedOptions
|
|
1513
1519
|
}));
|
|
1514
1520
|
} else {
|
|
1515
|
-
arr.push(
|
|
1516
|
-
discount_list:
|
|
1521
|
+
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1522
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
|
|
1517
1523
|
_id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
|
|
1518
1524
|
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
1519
1525
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
@@ -1602,7 +1608,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1602
1608
|
}));
|
|
1603
1609
|
}
|
|
1604
1610
|
} else {
|
|
1605
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1611
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _reapplyDiscountPerce2, _flatItem$parentProdu9;
|
|
1606
1612
|
// 折扣卡:不拆分数量,直接应用
|
|
1607
1613
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1608
1614
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1620,11 +1626,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1620
1626
|
var targetProductTotal;
|
|
1621
1627
|
var fixedAmountPerItem;
|
|
1622
1628
|
var _productDiscountDifference;
|
|
1629
|
+
var _reapplyDiscountPercent;
|
|
1623
1630
|
if (_isOrderLevel && _productAllocation) {
|
|
1624
1631
|
// order_level:使用预计算的单价折扣金额(已经是单价,无需再除以数量)
|
|
1625
1632
|
fixedAmountPerItem = _productAllocation.discountAmount;
|
|
1626
1633
|
_productDiscountDifference = _productAllocation.difference;
|
|
1627
1634
|
targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1635
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3) !== undefined) {
|
|
1636
|
+
// hydrate 后 par_value 可能是余额/原值(例如 3500),百分比口径以
|
|
1637
|
+
// 后端折扣快照 discount.percent 为准,与主商品重套逻辑保持一致。
|
|
1638
|
+
var _percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3);
|
|
1639
|
+
_reapplyDiscountPercent = new Decimal(_percent).toFixed(2);
|
|
1640
|
+
targetProductTotal = new Decimal(_productOriginTotal).mul(new Decimal(100).minus(_percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1641
|
+
fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1628
1642
|
} else {
|
|
1629
1643
|
// item_level 或其他类型:使用原有逻辑
|
|
1630
1644
|
targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
|
|
@@ -1645,7 +1659,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1645
1659
|
title: _selectedDiscount3.format_title,
|
|
1646
1660
|
original_amount: product.original_price,
|
|
1647
1661
|
product_id: product.id || product.product_id,
|
|
1648
|
-
percent: _selectedDiscount3.par_value,
|
|
1662
|
+
percent: (_reapplyDiscountPerce2 = _reapplyDiscountPercent) !== null && _reapplyDiscountPerce2 !== void 0 ? _reapplyDiscountPerce2 : _selectedDiscount3.par_value,
|
|
1649
1663
|
discount_product_id: _selectedDiscount3.product_id
|
|
1650
1664
|
},
|
|
1651
1665
|
metadata: _objectSpread({
|
|
@@ -1678,7 +1692,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1678
1692
|
var reconstructProductsWithBundle = function reconstructProductsWithBundle(processedProductsMap, processedFlatItemsMap, originalProductList) {
|
|
1679
1693
|
var result = [];
|
|
1680
1694
|
originalProductList.forEach(function (originProduct) {
|
|
1681
|
-
var product =
|
|
1695
|
+
var product = _this4.hooks.getProduct(originProduct);
|
|
1682
1696
|
|
|
1683
1697
|
// 获取主商品处理结果
|
|
1684
1698
|
var mainProductArr = processedProductsMap.get(product._id);
|
|
@@ -1687,8 +1701,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1687
1701
|
var getDefaultProduct = function getDefaultProduct() {
|
|
1688
1702
|
var restoredOptions = restoreOptionPrices(product.options);
|
|
1689
1703
|
if (product.isClient) {
|
|
1690
|
-
return
|
|
1691
|
-
discount_list:
|
|
1704
|
+
return _this4.hooks.setProduct(originProduct, {
|
|
1705
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1692
1706
|
price: product.price,
|
|
1693
1707
|
origin_total: getProductOriginTotalPrice({
|
|
1694
1708
|
product: {
|
|
@@ -1709,8 +1723,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1709
1723
|
options: restoredOptions
|
|
1710
1724
|
});
|
|
1711
1725
|
} else {
|
|
1712
|
-
return
|
|
1713
|
-
discount_list:
|
|
1726
|
+
return _this4.hooks.setProduct(originProduct, {
|
|
1727
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1714
1728
|
total: product.total,
|
|
1715
1729
|
origin_total: product.origin_total,
|
|
1716
1730
|
price: product.price,
|
|
@@ -1758,10 +1772,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1758
1772
|
}
|
|
1759
1773
|
|
|
1760
1774
|
// 🔥 2. 如果有子商品应用了商品券,且主商品数量大于1,需要拆分主商品
|
|
1761
|
-
var mainProductQuantity = mainProductArr[0] ?
|
|
1775
|
+
var mainProductQuantity = mainProductArr[0] ? _this4.hooks.getProduct(mainProductArr[0]).quantity : 1;
|
|
1762
1776
|
if (hasGoodPassApplied && mainProductArr.length === 1 && mainProductQuantity > 1) {
|
|
1763
1777
|
var mainProduct = mainProductArr[0];
|
|
1764
|
-
var mainProductData =
|
|
1778
|
+
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1765
1779
|
|
|
1766
1780
|
// 🔥 方案:拆分成2个主商品
|
|
1767
1781
|
// 1. 一个主商品(qty=1)包含拆分后的bundle
|
|
@@ -1876,7 +1890,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1876
1890
|
}
|
|
1877
1891
|
|
|
1878
1892
|
// 添加第一个主商品:qty=1,包含拆分后的bundle
|
|
1879
|
-
result.push(
|
|
1893
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1880
1894
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_discount"),
|
|
1881
1895
|
quantity: 1,
|
|
1882
1896
|
discount_list: updatedMainDiscountList,
|
|
@@ -1948,7 +1962,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1948
1962
|
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1949
1963
|
|
|
1950
1964
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1951
|
-
result.push(
|
|
1965
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1952
1966
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_normal"),
|
|
1953
1967
|
quantity: mainProductQuantity - 1,
|
|
1954
1968
|
discount_list: updatedMainDiscountListOriginal,
|
|
@@ -1961,7 +1975,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
1975
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1962
1976
|
mainProductArr.forEach(function (mainProduct) {
|
|
1963
1977
|
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1964
|
-
var mainProductData =
|
|
1978
|
+
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1965
1979
|
|
|
1966
1980
|
// 重组bundle
|
|
1967
1981
|
var newBundle = [];
|
|
@@ -2048,7 +2062,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
2062
|
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
2049
2063
|
|
|
2050
2064
|
// 生成最终的主商品
|
|
2051
|
-
result.push(
|
|
2065
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
2052
2066
|
bundle: newBundle,
|
|
2053
2067
|
total: newTotal,
|
|
2054
2068
|
origin_total: newOriginTotal
|
|
@@ -87,7 +87,13 @@ function getUnitOriginalTotal(product) {
|
|
|
87
87
|
function isGeneratedVoucherProduct(product) {
|
|
88
88
|
var record = product;
|
|
89
89
|
var metadata = (record === null || record === void 0 ? void 0 : record.metadata) || {};
|
|
90
|
-
|
|
90
|
+
var isGeneratedChild = metadata.parent_order_detail_id !== undefined || metadata.gift_card_type !== undefined;
|
|
91
|
+
if (isGeneratedChild) return true;
|
|
92
|
+
|
|
93
|
+
// `product_voucher` 既可能是当前购物车生成的零价子券,也可能是独立售卖的
|
|
94
|
+
// gift card。已有 order_detail_id 且没有 parent 标记的是后者,必须继续计价。
|
|
95
|
+
var isPersisted = (record === null || record === void 0 ? void 0 : record.order_detail_id) !== undefined && (record === null || record === void 0 ? void 0 : record.order_detail_id) !== null;
|
|
96
|
+
return (record === null || record === void 0 ? void 0 : record.extension_type) === 'product_voucher' && !isPersisted;
|
|
91
97
|
}
|
|
92
98
|
function buildSurchargeServiceItems(products) {
|
|
93
99
|
return products.map(function (product) {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -498,6 +498,10 @@ declare class Server {
|
|
|
498
498
|
private handleOrderDraftSubmit;
|
|
499
499
|
private handlePendingSyncCheckoutOrder;
|
|
500
500
|
private buildPendingSyncCheckoutOrder;
|
|
501
|
+
/**
|
|
502
|
+
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
503
|
+
*/
|
|
504
|
+
private shouldAutoPrintCheckoutReceipt;
|
|
501
505
|
private shouldBuildSmallTicketData;
|
|
502
506
|
private shouldPrintSyncedOrder;
|
|
503
507
|
private hasPaymentStatus;
|