@pisell/pisellos 2.3.42 → 2.3.44
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/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +5 -2
- package/dist/modules/Order/index.js +127 -53
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Payment/walletpass.d.ts +10 -3
- package/dist/modules/Payment/walletpass.js +425 -282
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +106 -68
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +772 -657
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +70 -45
- package/dist/solution/BaseSales/types.d.ts +3 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.js +8 -5
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +3 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1891 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +40 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +5 -2
- package/lib/modules/Order/index.js +72 -17
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Payment/walletpass.d.ts +10 -3
- package/lib/modules/Payment/walletpass.js +218 -56
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +41 -19
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +65 -5
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +25 -8
- package/lib/solution/BaseSales/types.d.ts +3 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.js +11 -2
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1084 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +40 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -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({
|
|
@@ -434,7 +438,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
438
|
_id: product._id,
|
|
435
439
|
parentId: product._id,
|
|
436
440
|
quantity: product.quantity,
|
|
437
|
-
num: product.num
|
|
441
|
+
num: product.num,
|
|
442
|
+
booking_id: product.booking_id
|
|
438
443
|
});
|
|
439
444
|
|
|
440
445
|
// 2. 展开 bundle 子商品
|
|
@@ -458,7 +463,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
458
463
|
origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
459
464
|
original_price: bundleItem.original_price,
|
|
460
465
|
// 继承主商品属性
|
|
461
|
-
booking_id:
|
|
466
|
+
booking_id: bundleItem.booking_id,
|
|
462
467
|
discount_list: bundleItem.discount_list || []
|
|
463
468
|
});
|
|
464
469
|
});
|
|
@@ -723,7 +728,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
723
728
|
|
|
724
729
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
725
730
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
726
|
-
var _product2, _product3,
|
|
731
|
+
var _product, _product2, _product3, _flatItem$bundleItem, _flatItem$bundleItem2, _product4;
|
|
727
732
|
var product;
|
|
728
733
|
if (flatItem.type === 'main') {
|
|
729
734
|
product = flatItem.product;
|
|
@@ -740,12 +745,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
740
745
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
741
746
|
};
|
|
742
747
|
}
|
|
743
|
-
if (
|
|
748
|
+
if (_this4.isItemRewardProductDiscount(product)) {
|
|
744
749
|
return false;
|
|
745
750
|
}
|
|
746
751
|
|
|
747
752
|
// 编辑的商品使用了优惠券不可用
|
|
748
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
753
|
+
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
754
|
return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
750
755
|
})) : !(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
756
|
return d.id;
|
|
@@ -766,7 +771,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
766
771
|
var limitedData = discount.limited_relation_product_data;
|
|
767
772
|
|
|
768
773
|
// 时间限制检查
|
|
769
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
774
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product4 = product) === null || _product4 === void 0 ? void 0 : _product4.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
770
775
|
if (!timeLimit) {
|
|
771
776
|
return false;
|
|
772
777
|
}
|
|
@@ -786,7 +791,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
786
791
|
}
|
|
787
792
|
|
|
788
793
|
// 套餐规则检查
|
|
789
|
-
var isBundleAvailable =
|
|
794
|
+
var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
|
|
790
795
|
return isLimitedProduct && isBundleAvailable;
|
|
791
796
|
};
|
|
792
797
|
|
|
@@ -929,30 +934,30 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
934
|
};
|
|
930
935
|
originProduct = flatItem.originProduct;
|
|
931
936
|
}
|
|
932
|
-
var isItemRewardProductDiscount =
|
|
937
|
+
var isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
|
|
933
938
|
addModeDiscount.forEach(function (discount) {
|
|
934
|
-
var _product6, _product7, _product8,
|
|
939
|
+
var _product5, _product6, _product7, _product8, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
935
940
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
936
941
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
937
942
|
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 =
|
|
943
|
+
var isHolderMatch = _this4.checkHolderMatch(discount, {
|
|
939
944
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
940
945
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
941
946
|
}, holders);
|
|
942
947
|
var timeLimit = true;
|
|
943
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
948
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
944
949
|
// 是符合折扣的商品
|
|
945
950
|
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
951
|
|
|
947
952
|
// 编辑的商品 使用了优惠券不可用
|
|
948
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
953
|
+
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
954
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
950
955
|
})) : !(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
956
|
return discount.id;
|
|
952
957
|
}));
|
|
953
958
|
|
|
954
959
|
// 套餐是否可用判断
|
|
955
|
-
var isBundleAvailable =
|
|
960
|
+
var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
|
|
956
961
|
|
|
957
962
|
// 判断优惠券是否适用于该商品
|
|
958
963
|
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
@@ -983,7 +988,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
983
988
|
discount_product_id: discount.product_id
|
|
984
989
|
},
|
|
985
990
|
metadata: {
|
|
986
|
-
num: num
|
|
991
|
+
num: num,
|
|
992
|
+
discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
|
|
987
993
|
}
|
|
988
994
|
};
|
|
989
995
|
applicableProducts.push(productData);
|
|
@@ -1053,7 +1059,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1053
1059
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1054
1060
|
// 🔥 使用扁平化后的列表进行处理
|
|
1055
1061
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1056
|
-
var
|
|
1062
|
+
var _product9, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product10;
|
|
1057
1063
|
// 获取商品数据
|
|
1058
1064
|
var product, originProduct;
|
|
1059
1065
|
if (flatItem.type === 'main') {
|
|
@@ -1077,8 +1083,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1077
1083
|
};
|
|
1078
1084
|
originProduct = flatItem.originProduct;
|
|
1079
1085
|
}
|
|
1080
|
-
var isPersistedProduct = ((
|
|
1081
|
-
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((
|
|
1086
|
+
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);
|
|
1087
|
+
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
1088
|
var _discount$id, _discount$discount4;
|
|
1083
1089
|
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
1090
|
var discountType = discount.tag || discount.type;
|
|
@@ -1100,7 +1106,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
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
|
|
@@ -1479,7 +1485,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1479
1485
|
_num: isGoodPass ? 1 : product.num,
|
|
1480
1486
|
config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
|
|
1481
1487
|
metadata: _objectSpread(_objectSpread({
|
|
1482
|
-
num: 1
|
|
1488
|
+
num: 1,
|
|
1489
|
+
discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
|
|
1483
1490
|
}, productDiscountDifference !== undefined && {
|
|
1484
1491
|
product_discount_difference: productDiscountDifference
|
|
1485
1492
|
}), {}, {
|
|
@@ -1494,7 +1501,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1494
1501
|
// 记录应用了优惠券的商品
|
|
1495
1502
|
// 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
|
|
1496
1503
|
if (product.isClient) {
|
|
1497
|
-
arr.push(
|
|
1504
|
+
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1498
1505
|
discount_list: [discountDetail],
|
|
1499
1506
|
// good_pass:主商品价以折后价为准;勿用 product.price - amount(amount 含 option 优惠时会算错)
|
|
1500
1507
|
price: isGoodPass ? mainProductSellingPrice : product.price,
|
|
@@ -1512,8 +1519,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1512
1519
|
options: discountedOptions
|
|
1513
1520
|
}));
|
|
1514
1521
|
} else {
|
|
1515
|
-
arr.push(
|
|
1516
|
-
discount_list:
|
|
1522
|
+
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1523
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
|
|
1517
1524
|
_id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
|
|
1518
1525
|
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
1519
1526
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
@@ -1566,6 +1573,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1566
1573
|
metadata: {
|
|
1567
1574
|
// 🔥 使用拆分后的唯一 _id
|
|
1568
1575
|
custom_product_bundle_map_id: uniqueId,
|
|
1576
|
+
discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
|
|
1569
1577
|
num: 1
|
|
1570
1578
|
},
|
|
1571
1579
|
_num: 1,
|
|
@@ -1597,7 +1605,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1597
1605
|
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1598
1606
|
num: normalNum,
|
|
1599
1607
|
quantity: normalNum,
|
|
1600
|
-
discount_list:
|
|
1608
|
+
discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion'),
|
|
1601
1609
|
processed: true
|
|
1602
1610
|
}));
|
|
1603
1611
|
}
|
|
@@ -1651,6 +1659,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1651
1659
|
metadata: _objectSpread({
|
|
1652
1660
|
// 🔥 使用唯一的 _id
|
|
1653
1661
|
custom_product_bundle_map_id: _uniqueId,
|
|
1662
|
+
discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
|
|
1654
1663
|
num: product.num || 1
|
|
1655
1664
|
}, _productDiscountDifference !== undefined && {
|
|
1656
1665
|
product_discount_difference: _productDiscountDifference
|
|
@@ -1666,7 +1675,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1666
1675
|
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1667
1676
|
total: targetProductTotal,
|
|
1668
1677
|
price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
1669
|
-
discount_list: [_discountDetail2],
|
|
1678
|
+
discount_list: _this4.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
|
|
1670
1679
|
processed: true
|
|
1671
1680
|
}));
|
|
1672
1681
|
}
|
|
@@ -1678,7 +1687,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1678
1687
|
var reconstructProductsWithBundle = function reconstructProductsWithBundle(processedProductsMap, processedFlatItemsMap, originalProductList) {
|
|
1679
1688
|
var result = [];
|
|
1680
1689
|
originalProductList.forEach(function (originProduct) {
|
|
1681
|
-
var product =
|
|
1690
|
+
var product = _this4.hooks.getProduct(originProduct);
|
|
1682
1691
|
|
|
1683
1692
|
// 获取主商品处理结果
|
|
1684
1693
|
var mainProductArr = processedProductsMap.get(product._id);
|
|
@@ -1687,8 +1696,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1687
1696
|
var getDefaultProduct = function getDefaultProduct() {
|
|
1688
1697
|
var restoredOptions = restoreOptionPrices(product.options);
|
|
1689
1698
|
if (product.isClient) {
|
|
1690
|
-
return
|
|
1691
|
-
discount_list:
|
|
1699
|
+
return _this4.hooks.setProduct(originProduct, {
|
|
1700
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1692
1701
|
price: product.price,
|
|
1693
1702
|
origin_total: getProductOriginTotalPrice({
|
|
1694
1703
|
product: {
|
|
@@ -1709,8 +1718,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1709
1718
|
options: restoredOptions
|
|
1710
1719
|
});
|
|
1711
1720
|
} else {
|
|
1712
|
-
return
|
|
1713
|
-
discount_list:
|
|
1721
|
+
return _this4.hooks.setProduct(originProduct, {
|
|
1722
|
+
discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1714
1723
|
total: product.total,
|
|
1715
1724
|
origin_total: product.origin_total,
|
|
1716
1725
|
price: product.price,
|
|
@@ -1758,10 +1767,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1758
1767
|
}
|
|
1759
1768
|
|
|
1760
1769
|
// 🔥 2. 如果有子商品应用了商品券,且主商品数量大于1,需要拆分主商品
|
|
1761
|
-
var mainProductQuantity = mainProductArr[0] ?
|
|
1770
|
+
var mainProductQuantity = mainProductArr[0] ? _this4.hooks.getProduct(mainProductArr[0]).quantity : 1;
|
|
1762
1771
|
if (hasGoodPassApplied && mainProductArr.length === 1 && mainProductQuantity > 1) {
|
|
1763
1772
|
var mainProduct = mainProductArr[0];
|
|
1764
|
-
var mainProductData =
|
|
1773
|
+
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1765
1774
|
|
|
1766
1775
|
// 🔥 方案:拆分成2个主商品
|
|
1767
1776
|
// 1. 一个主商品(qty=1)包含拆分后的bundle
|
|
@@ -1876,7 +1885,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1876
1885
|
}
|
|
1877
1886
|
|
|
1878
1887
|
// 添加第一个主商品:qty=1,包含拆分后的bundle
|
|
1879
|
-
result.push(
|
|
1888
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1880
1889
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_discount"),
|
|
1881
1890
|
quantity: 1,
|
|
1882
1891
|
discount_list: updatedMainDiscountList,
|
|
@@ -1948,7 +1957,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1948
1957
|
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1949
1958
|
|
|
1950
1959
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1951
|
-
result.push(
|
|
1960
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1952
1961
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_normal"),
|
|
1953
1962
|
quantity: mainProductQuantity - 1,
|
|
1954
1963
|
discount_list: updatedMainDiscountListOriginal,
|
|
@@ -1961,7 +1970,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
1970
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1962
1971
|
mainProductArr.forEach(function (mainProduct) {
|
|
1963
1972
|
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1964
|
-
var mainProductData =
|
|
1973
|
+
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1965
1974
|
|
|
1966
1975
|
// 重组bundle
|
|
1967
1976
|
var newBundle = [];
|
|
@@ -2048,7 +2057,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
2057
|
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
2049
2058
|
|
|
2050
2059
|
// 生成最终的主商品
|
|
2051
|
-
result.push(
|
|
2060
|
+
result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
2052
2061
|
bundle: newBundle,
|
|
2053
2062
|
total: newTotal,
|
|
2054
2063
|
origin_total: newOriginTotal
|
|
@@ -2141,6 +2150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2141
2150
|
}, {
|
|
2142
2151
|
key: "checkPackageSubItemUsageRules",
|
|
2143
2152
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2153
|
+
var _flatItem$product;
|
|
2144
2154
|
var limitedData = discount.limited_relation_product_data;
|
|
2145
2155
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2146
2156
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2162,6 +2172,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2162
2172
|
filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
|
|
2163
2173
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2164
2174
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2175
|
+
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2165
2176
|
|
|
2166
2177
|
// 主商品直接可用
|
|
2167
2178
|
if (isMainProduct) {
|
|
@@ -2204,13 +2215,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2204
2215
|
if (!filter) {
|
|
2205
2216
|
isScopeValid = true;
|
|
2206
2217
|
} else {
|
|
2207
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(
|
|
2218
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2208
2219
|
}
|
|
2209
2220
|
}
|
|
2210
2221
|
|
|
2211
2222
|
// 包含套餐判断, products值兼容旧数据
|
|
2212
2223
|
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2213
|
-
isScopeValid = include_bundle_product_ids.includes(Number(
|
|
2224
|
+
isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2214
2225
|
}
|
|
2215
2226
|
|
|
2216
2227
|
// 价格和套餐适用范围都符合,则可用
|
|
@@ -2260,16 +2271,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2260
2271
|
|
|
2261
2272
|
// 检查 rules
|
|
2262
2273
|
if (rules.length > 0) {
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2274
|
+
var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
|
|
2275
|
+
var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
|
|
2276
|
+
// 价格是否符合规则:原价或加价
|
|
2277
|
+
var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
|
|
2278
|
+
// 套餐适用范围校验
|
|
2279
|
+
var _isScopeValid = false;
|
|
2280
|
+
|
|
2281
|
+
// 排除套餐判断, product_all值兼容旧数据
|
|
2282
|
+
if (scopeType === 'all_packages' || scopeType === 'product_all') {
|
|
2283
|
+
// 所有套餐可用
|
|
2284
|
+
if (!filter) {
|
|
2285
|
+
_isScopeValid = true;
|
|
2286
|
+
} else {
|
|
2287
|
+
_isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2288
|
+
}
|
|
2266
2289
|
}
|
|
2267
2290
|
|
|
2268
|
-
//
|
|
2269
|
-
if (
|
|
2291
|
+
// 包含套餐判断, products值兼容旧数据
|
|
2292
|
+
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2293
|
+
_isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// 价格和套餐适用范围都符合,则可用
|
|
2297
|
+
if (_isPriceValid && _isScopeValid) {
|
|
2270
2298
|
return true;
|
|
2271
2299
|
}
|
|
2272
2300
|
|
|
2301
|
+
// 检查原价
|
|
2302
|
+
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2303
|
+
// return true;
|
|
2304
|
+
// }
|
|
2305
|
+
|
|
2306
|
+
// 检查加价
|
|
2307
|
+
// if (isMarkupPrice && rules.includes('markup_price')) {
|
|
2308
|
+
// return true;
|
|
2309
|
+
// }
|
|
2310
|
+
|
|
2273
2311
|
// 如果都不匹配,则不可用
|
|
2274
2312
|
return false;
|
|
2275
2313
|
}
|
|
@@ -64,21 +64,19 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
64
64
|
this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
|
|
65
65
|
this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
|
|
66
66
|
this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
72
|
-
case 10:
|
|
67
|
+
|
|
68
|
+
// if (!this.appPlugin) {
|
|
69
|
+
// throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
70
|
+
// }
|
|
73
71
|
if (this.request) {
|
|
74
|
-
_context.next =
|
|
72
|
+
_context.next = 10;
|
|
75
73
|
break;
|
|
76
74
|
}
|
|
77
75
|
throw new Error('SalesSummaryModule 需要 request 插件支持');
|
|
78
|
-
case
|
|
79
|
-
_context.next =
|
|
76
|
+
case 10:
|
|
77
|
+
_context.next = 12;
|
|
80
78
|
return this.getSurchargeList();
|
|
81
|
-
case
|
|
79
|
+
case 12:
|
|
82
80
|
case "end":
|
|
83
81
|
return _context.stop();
|
|
84
82
|
}
|
|
@@ -192,10 +190,11 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
192
190
|
}, {
|
|
193
191
|
key: "getAppData",
|
|
194
192
|
value: function getAppData(key) {
|
|
195
|
-
var _this$appPlugin$getDa, _this$
|
|
196
|
-
var getData = (_this$appPlugin
|
|
193
|
+
var _this$appPlugin, _this$appPlugin$getDa, _this$appPlugin2, _this$appPlugin2$getA, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
194
|
+
var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
197
195
|
if (typeof getData === 'function') return getData(key);
|
|
198
|
-
var app = this.appPlugin.getApp();
|
|
196
|
+
var app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
|
|
197
|
+
if (!app) return undefined;
|
|
199
198
|
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
200
199
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
201
200
|
}
|
|
@@ -11,10 +11,12 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
|
|
|
11
11
|
protected defaultName: string;
|
|
12
12
|
protected defaultVersion: string;
|
|
13
13
|
private store;
|
|
14
|
+
private window?;
|
|
14
15
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
15
16
|
setContext(context: ScanOrderLoggerContext): void;
|
|
16
17
|
setProvider(provider: ScanOrderLoggerProviderType): void;
|
|
17
18
|
setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
|
|
19
|
+
private getCurrentHost;
|
|
18
20
|
private buildRecord;
|
|
19
21
|
addLog(params: ScanOrderLogInput): Promise<void>;
|
|
20
22
|
}
|