@pisell/pisellos 2.2.277 → 2.2.800
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/core/index.d.ts +0 -2
- package/dist/core/index.js +1 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -5
- package/dist/model/strategy/adapter/walletPass/utils.js +26 -57
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +8 -28
- package/dist/modules/Order/index.js +496 -808
- package/dist/modules/Order/types.d.ts +1 -35
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +49 -78
- package/dist/modules/Payment/types.d.ts +25 -106
- package/dist/modules/Payment/types.js +0 -17
- package/dist/modules/Payment/utils.js +1 -4
- package/dist/modules/Payment/walletpass.d.ts +1 -49
- package/dist/modules/Payment/walletpass.js +124 -1081
- package/dist/modules/Rules/index.d.ts +0 -3
- package/dist/modules/Rules/index.js +70 -100
- package/dist/server/index.d.ts +0 -25
- package/dist/server/index.js +1069 -2001
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +4 -70
- package/dist/server/modules/order/index.js +728 -1816
- package/dist/server/modules/order/types.d.ts +3 -25
- package/dist/server/modules/order/types.js +1 -7
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +5 -109
- package/dist/solution/BaseSales/index.js +436 -1802
- package/dist/solution/BaseSales/types.d.ts +1 -55
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +56 -139
- package/dist/solution/BookingTicket/types.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
- package/dist/solution/Sales/index.d.ts +0 -2
- package/dist/solution/Sales/index.js +4 -26
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.d.ts +0 -1
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +1 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -5
- package/lib/model/strategy/adapter/walletPass/utils.js +11 -62
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +8 -28
- package/lib/modules/Order/index.js +69 -231
- package/lib/modules/Order/types.d.ts +1 -35
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +12 -33
- package/lib/modules/Payment/types.d.ts +25 -106
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/utils.js +1 -5
- package/lib/modules/Payment/walletpass.d.ts +1 -49
- package/lib/modules/Payment/walletpass.js +22 -898
- package/lib/modules/Rules/index.d.ts +0 -3
- package/lib/modules/Rules/index.js +9 -38
- package/lib/server/index.d.ts +0 -25
- package/lib/server/index.js +31 -726
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +4 -70
- package/lib/server/modules/order/index.js +69 -818
- package/lib/server/modules/order/types.d.ts +3 -25
- package/lib/server/modules/order/types.js +0 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +5 -109
- package/lib/solution/BaseSales/index.js +27 -874
- package/lib/solution/BaseSales/types.d.ts +1 -55
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +13 -64
- package/lib/solution/BookingTicket/types.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
- package/lib/solution/Sales/index.d.ts +0 -2
- package/lib/solution/Sales/index.js +6 -20
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.d.ts +0 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -27,8 +27,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
27
27
|
}): {
|
|
28
28
|
isAvailable: boolean;
|
|
29
29
|
discountList: Discount[];
|
|
30
|
-
/** 完整规则计算后的列表;调用方可用于保留暂时无适用商品的扫码卡券。 */
|
|
31
|
-
evaluatedDiscountList?: Discount[];
|
|
32
30
|
productList: any[];
|
|
33
31
|
unavailableReason?: UnavailableReason;
|
|
34
32
|
};
|
|
@@ -37,7 +35,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
37
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
38
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
39
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
40
|
-
private isItemRewardProductDiscount;
|
|
41
38
|
private getUnavailableReason;
|
|
42
39
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
43
40
|
discountList: Discount[];
|
|
@@ -150,7 +150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// 编辑商品已有商品券
|
|
153
|
-
if (productList.
|
|
153
|
+
if (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,7 +214,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
214
|
return {
|
|
215
215
|
isAvailable: hasApplicableDiscount,
|
|
216
216
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
217
|
-
evaluatedDiscountList: result.discountList,
|
|
218
217
|
productList: hasApplicableDiscount ? result.productList : productList,
|
|
219
218
|
unavailableReason: unavailableReason
|
|
220
219
|
};
|
|
@@ -242,37 +241,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
241
|
value: function resolveDiscountListForManualOverride(discountList) {
|
|
243
242
|
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
244
243
|
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "isItemRewardProductDiscount",
|
|
247
|
-
value: function isItemRewardProductDiscount(product) {
|
|
248
|
-
var _product$_promotion;
|
|
249
|
-
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
250
|
-
return (product === null || product === void 0 || (_product$_promotion = product._promotion) === null || _product$_promotion === void 0 ? void 0 : _product$_promotion.actionType) === 'ITEM_REWARD' && discountList.some(function (item) {
|
|
251
|
-
var _item$metadata, _item$metadata2;
|
|
252
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
244
|
// 获取券不可用的原因
|
|
257
245
|
}, {
|
|
258
246
|
key: "getUnavailableReason",
|
|
259
247
|
value: function getUnavailableReason(discountList, productList) {
|
|
260
|
-
var _this3 = this;
|
|
261
248
|
// 检查时间限制
|
|
262
249
|
var _iterator = _createForOfIteratorHelper(discountList),
|
|
263
250
|
_step;
|
|
264
251
|
try {
|
|
265
252
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
266
253
|
var discount = _step.value;
|
|
267
|
-
var
|
|
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),
|
|
254
|
+
var _iterator3 = _createForOfIteratorHelper(productList),
|
|
272
255
|
_step3;
|
|
273
256
|
try {
|
|
274
257
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
275
|
-
var
|
|
258
|
+
var item = _step3.value;
|
|
259
|
+
var product = this.hooks.getProduct(item);
|
|
260
|
+
var bookingTime = ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
276
261
|
var filteredList = filterDiscountListByBookingTime([discount], bookingTime);
|
|
277
262
|
if (filteredList.length === 0) {
|
|
278
263
|
return UnavailableReason.TimeLimit;
|
|
@@ -303,12 +288,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
303
288
|
try {
|
|
304
289
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
305
290
|
var _limitedData$product_;
|
|
306
|
-
var
|
|
307
|
-
var
|
|
291
|
+
var _item = _step4.value;
|
|
292
|
+
var _product = this.hooks.getProduct(_item);
|
|
308
293
|
if (limitedData.type === 'product_all') {
|
|
309
294
|
hasApplicableProduct = true;
|
|
310
295
|
break;
|
|
311
|
-
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(
|
|
296
|
+
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(_product.id)) {
|
|
312
297
|
hasApplicableProduct = true;
|
|
313
298
|
break;
|
|
314
299
|
}
|
|
@@ -333,7 +318,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
333
318
|
key: "calcDiscount",
|
|
334
319
|
value: function calcDiscount(_ref2, options) {
|
|
335
320
|
var _options$selectedList,
|
|
336
|
-
|
|
321
|
+
_this3 = this;
|
|
337
322
|
var discountList = _ref2.discountList,
|
|
338
323
|
productList = _ref2.productList,
|
|
339
324
|
holders = _ref2.holders,
|
|
@@ -426,7 +411,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
426
411
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
427
412
|
var flattened = [];
|
|
428
413
|
productList.forEach(function (originProduct) {
|
|
429
|
-
var product =
|
|
414
|
+
var product = _this3.hooks.getProduct(originProduct);
|
|
430
415
|
|
|
431
416
|
// 1. 添加主商品
|
|
432
417
|
flattened.push({
|
|
@@ -444,7 +429,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
444
429
|
// 2. 展开 bundle 子商品
|
|
445
430
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
446
431
|
product.bundle.forEach(function (bundleItem, bundleIndex) {
|
|
447
|
-
var _ref3, _bundleItem$
|
|
432
|
+
var _ref3, _bundleItem$_bundle_p;
|
|
448
433
|
flattened.push({
|
|
449
434
|
type: 'bundle',
|
|
450
435
|
originProduct: originProduct,
|
|
@@ -456,7 +441,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
456
441
|
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
457
442
|
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
458
443
|
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
459
|
-
id: (_ref3 = (_bundleItem$
|
|
444
|
+
id: (_ref3 = (_bundleItem$_bundle_p = bundleItem._bundle_product_id) !== null && _bundleItem$_bundle_p !== void 0 ? _bundleItem$_bundle_p : bundleItem.bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
460
445
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
461
446
|
parentId: product._id,
|
|
462
447
|
num: bundleItem.num || 1,
|
|
@@ -730,7 +715,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
715
|
|
|
731
716
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
732
717
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
733
|
-
var
|
|
718
|
+
var _product2, _product3, _product4, _flatItem$bundleItem, _flatItem$bundleItem2, _product5;
|
|
734
719
|
var product;
|
|
735
720
|
if (flatItem.type === 'main') {
|
|
736
721
|
product = flatItem.product;
|
|
@@ -747,12 +732,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
747
732
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
748
733
|
};
|
|
749
734
|
}
|
|
750
|
-
if (_this4.isItemRewardProductDiscount(product)) {
|
|
751
|
-
return false;
|
|
752
|
-
}
|
|
753
735
|
|
|
754
736
|
// 编辑的商品使用了优惠券不可用
|
|
755
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
737
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
756
738
|
return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
757
739
|
})) : !(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) {
|
|
758
740
|
return d.id;
|
|
@@ -773,7 +755,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
773
755
|
var limitedData = discount.limited_relation_product_data;
|
|
774
756
|
|
|
775
757
|
// 时间限制检查
|
|
776
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
758
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
777
759
|
if (!timeLimit) {
|
|
778
760
|
return false;
|
|
779
761
|
}
|
|
@@ -793,7 +775,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
793
775
|
}
|
|
794
776
|
|
|
795
777
|
// 套餐规则检查
|
|
796
|
-
var isBundleAvailable =
|
|
778
|
+
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
797
779
|
return isLimitedProduct && isBundleAvailable;
|
|
798
780
|
};
|
|
799
781
|
|
|
@@ -936,33 +918,32 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
936
918
|
};
|
|
937
919
|
originProduct = flatItem.originProduct;
|
|
938
920
|
}
|
|
939
|
-
var isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
|
|
940
921
|
addModeDiscount.forEach(function (discount) {
|
|
941
|
-
var
|
|
922
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
942
923
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
943
924
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
944
925
|
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;
|
|
945
|
-
var isHolderMatch =
|
|
926
|
+
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
946
927
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
947
928
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
948
929
|
}, holders);
|
|
949
930
|
var timeLimit = true;
|
|
950
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
931
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
951
932
|
// 是符合折扣的商品
|
|
952
933
|
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;
|
|
953
934
|
|
|
954
935
|
// 编辑的商品 使用了优惠券不可用
|
|
955
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
936
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
|
|
956
937
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
957
938
|
})) : !(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) {
|
|
958
939
|
return discount.id;
|
|
959
940
|
}));
|
|
960
941
|
|
|
961
942
|
// 套餐是否可用判断
|
|
962
|
-
var isBundleAvailable =
|
|
943
|
+
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
963
944
|
|
|
964
945
|
// 判断优惠券是否适用于该商品
|
|
965
|
-
if (isAvailableProduct &&
|
|
946
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
966
947
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
967
948
|
// 记录此优惠券适用的商品
|
|
968
949
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1060,7 +1041,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
1041
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1061
1042
|
// 🔥 使用扁平化后的列表进行处理
|
|
1062
1043
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1063
|
-
var
|
|
1044
|
+
var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product11;
|
|
1064
1045
|
// 获取商品数据
|
|
1065
1046
|
var product, originProduct;
|
|
1066
1047
|
if (flatItem.type === 'main') {
|
|
@@ -1084,8 +1065,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1084
1065
|
};
|
|
1085
1066
|
originProduct = flatItem.originProduct;
|
|
1086
1067
|
}
|
|
1087
|
-
var isPersistedProduct = ((
|
|
1088
|
-
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((
|
|
1068
|
+
var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.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);
|
|
1069
|
+
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
|
|
1089
1070
|
var _discount$id, _discount$discount4;
|
|
1090
1071
|
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;
|
|
1091
1072
|
var discountType = discount.tag || discount.type;
|
|
@@ -1106,7 +1087,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1106
1087
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1107
1088
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1108
1089
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1109
|
-
if (_this4.isItemRewardProductDiscount(product)) return false;
|
|
1110
1090
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1111
1091
|
var discountType = discount.tag || discount.type;
|
|
1112
1092
|
var currentOriginUid = getOriginProductUid(originProduct);
|
|
@@ -1152,7 +1132,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1152
1132
|
|
|
1153
1133
|
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
1154
1134
|
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;
|
|
1155
|
-
var isHolderMatch =
|
|
1135
|
+
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
1156
1136
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
1157
1137
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
1158
1138
|
}, holders);
|
|
@@ -1170,13 +1150,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1150
|
return false;
|
|
1171
1151
|
}
|
|
1172
1152
|
// 检查 package_sub_item_usage_rules
|
|
1173
|
-
if (!
|
|
1153
|
+
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1174
1154
|
return false;
|
|
1175
1155
|
}
|
|
1176
1156
|
return true;
|
|
1177
1157
|
} else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
1178
1158
|
// 检查 package_sub_item_usage_rules
|
|
1179
|
-
if (!
|
|
1159
|
+
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1180
1160
|
return false;
|
|
1181
1161
|
}
|
|
1182
1162
|
return true;
|
|
@@ -1184,36 +1164,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1164
|
return false;
|
|
1185
1165
|
});
|
|
1186
1166
|
|
|
1187
|
-
//
|
|
1188
|
-
//
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1192
|
-
}) : undefined;
|
|
1193
|
-
|
|
1194
|
-
// 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
|
|
1195
|
-
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1167
|
+
// 选择第一个适用的优惠券(已经按过期时间排序)
|
|
1168
|
+
// 如果有 isScan 且 isSelected 的折扣卡,则优先选中,否则再选择第一个
|
|
1169
|
+
// 用于处理:先手动扫描了一张折扣卡,扫描完以后带入客户信息,但是之前那张折扣卡不是最优惠的情况
|
|
1170
|
+
var selectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1196
1171
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1197
1172
|
});
|
|
1198
|
-
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1199
1173
|
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1200
1174
|
|
|
1201
1175
|
// 如果是手动折扣,则不适用优惠券
|
|
1202
1176
|
var isManualDiscount = false;
|
|
1203
|
-
var isItemRewardProductDiscount = false;
|
|
1204
1177
|
if (flatItem.type === 'main') {
|
|
1205
|
-
var _product$discount_lis5, _product$discount_lis6,
|
|
1178
|
+
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1206
1179
|
// 主商品:判断自身是否手动折扣
|
|
1207
1180
|
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) {
|
|
1208
1181
|
return item.type === 'product';
|
|
1209
1182
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1210
1183
|
var _ref12;
|
|
1211
1184
|
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1212
|
-
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((
|
|
1185
|
+
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1213
1186
|
return item.type === 'product';
|
|
1214
1187
|
})));
|
|
1215
|
-
|
|
1216
|
-
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1188
|
+
if (product.inPromotion) {
|
|
1217
1189
|
isManualDiscount = false;
|
|
1218
1190
|
}
|
|
1219
1191
|
} else {
|
|
@@ -1295,7 +1267,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1295
1267
|
// 主商品:保持原有逻辑,还原 option 价格
|
|
1296
1268
|
var restoredOptions = restoreOptionPrices(product.options);
|
|
1297
1269
|
if (product.isClient) {
|
|
1298
|
-
processedProductsMap.set(product._id, [
|
|
1270
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
|
|
1299
1271
|
origin_total: getProductOriginTotalPrice({
|
|
1300
1272
|
product: {
|
|
1301
1273
|
original_price: product.original_price
|
|
@@ -1315,39 +1287,37 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1287
|
price: product.price,
|
|
1316
1288
|
options: restoredOptions
|
|
1317
1289
|
}), {}, {
|
|
1318
|
-
discount_list: isManualDiscount ?
|
|
1290
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1319
1291
|
}))]);
|
|
1320
1292
|
} else {
|
|
1321
|
-
var _ref14, _product$_promotion$f,
|
|
1322
|
-
var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (
|
|
1293
|
+
var _ref14, _product$_promotion$f, _product13, _product$origin_total;
|
|
1294
|
+
var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.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;
|
|
1323
1295
|
var main_product_selling_price = product.price;
|
|
1324
1296
|
if ((product.discount_list || []).some(function (item) {
|
|
1325
1297
|
return item.type === 'promotion';
|
|
1326
|
-
}) ||
|
|
1298
|
+
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1327
1299
|
var _product$total, _product$main_product;
|
|
1328
1300
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1329
1301
|
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;
|
|
1330
1302
|
}
|
|
1331
|
-
processedProductsMap.set(product._id, [
|
|
1303
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1332
1304
|
price: product.price,
|
|
1333
|
-
main_product_selling_price:
|
|
1334
|
-
}
|
|
1335
|
-
total: total
|
|
1336
|
-
} : {}) : {
|
|
1305
|
+
main_product_selling_price: product.price
|
|
1306
|
+
} : {
|
|
1337
1307
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1338
1308
|
total: total,
|
|
1339
1309
|
price: product.price,
|
|
1340
1310
|
main_product_selling_price: main_product_selling_price,
|
|
1341
1311
|
options: restoredOptions
|
|
1342
1312
|
}), {}, {
|
|
1343
|
-
discount_list: isManualDiscount ?
|
|
1313
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1344
1314
|
}))]);
|
|
1345
1315
|
}
|
|
1346
1316
|
} else {
|
|
1347
1317
|
var _flatItem$bundleItem8, _flatItem$bundleItem9;
|
|
1348
1318
|
// bundle子商品:保存到扁平化Map
|
|
1349
1319
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1350
|
-
discount_list: isManualDiscount ?
|
|
1320
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this3.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
|
|
1351
1321
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
1352
1322
|
processed: true
|
|
1353
1323
|
})]);
|
|
@@ -1388,8 +1358,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1358
|
var _product$total2;
|
|
1389
1359
|
_total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
|
|
1390
1360
|
}
|
|
1391
|
-
arr.push(
|
|
1392
|
-
discount_list:
|
|
1361
|
+
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
1362
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1393
1363
|
quantity: totalQuantity - splitCount,
|
|
1394
1364
|
_id: product._id.split('___')[0],
|
|
1395
1365
|
total: _total
|
|
@@ -1413,7 +1383,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1413
1383
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
1414
1384
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
1415
1385
|
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
1416
|
-
if (
|
|
1386
|
+
if (_this3.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
|
|
1417
1387
|
productOriginTotal = product.origin_total;
|
|
1418
1388
|
}
|
|
1419
1389
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
@@ -1500,7 +1470,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1500
1470
|
// 记录应用了优惠券的商品
|
|
1501
1471
|
// 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
|
|
1502
1472
|
if (product.isClient) {
|
|
1503
|
-
arr.push(
|
|
1473
|
+
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
1504
1474
|
discount_list: [discountDetail],
|
|
1505
1475
|
// good_pass:主商品价以折后价为准;勿用 product.price - amount(amount 含 option 优惠时会算错)
|
|
1506
1476
|
price: isGoodPass ? mainProductSellingPrice : product.price,
|
|
@@ -1518,8 +1488,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1518
1488
|
options: discountedOptions
|
|
1519
1489
|
}));
|
|
1520
1490
|
} else {
|
|
1521
|
-
arr.push(
|
|
1522
|
-
discount_list:
|
|
1491
|
+
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
1492
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
|
|
1523
1493
|
_id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
|
|
1524
1494
|
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
1525
1495
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
@@ -1692,7 +1662,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1692
1662
|
var reconstructProductsWithBundle = function reconstructProductsWithBundle(processedProductsMap, processedFlatItemsMap, originalProductList) {
|
|
1693
1663
|
var result = [];
|
|
1694
1664
|
originalProductList.forEach(function (originProduct) {
|
|
1695
|
-
var product =
|
|
1665
|
+
var product = _this3.hooks.getProduct(originProduct);
|
|
1696
1666
|
|
|
1697
1667
|
// 获取主商品处理结果
|
|
1698
1668
|
var mainProductArr = processedProductsMap.get(product._id);
|
|
@@ -1701,8 +1671,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1701
1671
|
var getDefaultProduct = function getDefaultProduct() {
|
|
1702
1672
|
var restoredOptions = restoreOptionPrices(product.options);
|
|
1703
1673
|
if (product.isClient) {
|
|
1704
|
-
return
|
|
1705
|
-
discount_list:
|
|
1674
|
+
return _this3.hooks.setProduct(originProduct, {
|
|
1675
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1706
1676
|
price: product.price,
|
|
1707
1677
|
origin_total: getProductOriginTotalPrice({
|
|
1708
1678
|
product: {
|
|
@@ -1723,8 +1693,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1723
1693
|
options: restoredOptions
|
|
1724
1694
|
});
|
|
1725
1695
|
} else {
|
|
1726
|
-
return
|
|
1727
|
-
discount_list:
|
|
1696
|
+
return _this3.hooks.setProduct(originProduct, {
|
|
1697
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
|
|
1728
1698
|
total: product.total,
|
|
1729
1699
|
origin_total: product.origin_total,
|
|
1730
1700
|
price: product.price,
|
|
@@ -1772,10 +1742,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1772
1742
|
}
|
|
1773
1743
|
|
|
1774
1744
|
// 🔥 2. 如果有子商品应用了商品券,且主商品数量大于1,需要拆分主商品
|
|
1775
|
-
var mainProductQuantity = mainProductArr[0] ?
|
|
1745
|
+
var mainProductQuantity = mainProductArr[0] ? _this3.hooks.getProduct(mainProductArr[0]).quantity : 1;
|
|
1776
1746
|
if (hasGoodPassApplied && mainProductArr.length === 1 && mainProductQuantity > 1) {
|
|
1777
1747
|
var mainProduct = mainProductArr[0];
|
|
1778
|
-
var mainProductData =
|
|
1748
|
+
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1779
1749
|
|
|
1780
1750
|
// 🔥 方案:拆分成2个主商品
|
|
1781
1751
|
// 1. 一个主商品(qty=1)包含拆分后的bundle
|
|
@@ -1790,11 +1760,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1790
1760
|
processedItems.forEach(function (item) {
|
|
1791
1761
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1792
1762
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1793
|
-
var _item$
|
|
1763
|
+
var _item$metadata;
|
|
1794
1764
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1795
1765
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1796
1766
|
num: item.num,
|
|
1797
|
-
custom_product_bundle_map_id: (_item$
|
|
1767
|
+
custom_product_bundle_map_id: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.custom_product_bundle_map_id
|
|
1798
1768
|
})
|
|
1799
1769
|
// num: item.num, // 使用拆分后的 num
|
|
1800
1770
|
});
|
|
@@ -1813,11 +1783,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1813
1783
|
if (item.processed) {
|
|
1814
1784
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1815
1785
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1816
|
-
var _item$
|
|
1786
|
+
var _item$metadata2;
|
|
1817
1787
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1818
1788
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1819
1789
|
num: item.num,
|
|
1820
|
-
custom_product_bundle_map_id: (_item$
|
|
1790
|
+
custom_product_bundle_map_id: (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.custom_product_bundle_map_id
|
|
1821
1791
|
})
|
|
1822
1792
|
// num: item.num, // 使用当前的 num
|
|
1823
1793
|
});
|
|
@@ -1858,8 +1828,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1858
1828
|
|
|
1859
1829
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1860
1830
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1861
|
-
var _item$
|
|
1862
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1831
|
+
var _item$metadata3;
|
|
1832
|
+
return !(item !== null && item !== void 0 && (_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.custom_product_bundle_map_id);
|
|
1863
1833
|
});
|
|
1864
1834
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1865
1835
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1890,7 +1860,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1890
1860
|
}
|
|
1891
1861
|
|
|
1892
1862
|
// 添加第一个主商品:qty=1,包含拆分后的bundle
|
|
1893
|
-
result.push(
|
|
1863
|
+
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1894
1864
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_discount"),
|
|
1895
1865
|
quantity: 1,
|
|
1896
1866
|
discount_list: updatedMainDiscountList,
|
|
@@ -1932,8 +1902,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1932
1902
|
|
|
1933
1903
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1934
1904
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1935
|
-
var _item$
|
|
1936
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1905
|
+
var _item$metadata4;
|
|
1906
|
+
return !(item !== null && item !== void 0 && (_item$metadata4 = item.metadata) !== null && _item$metadata4 !== void 0 && _item$metadata4.custom_product_bundle_map_id);
|
|
1937
1907
|
});
|
|
1938
1908
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1939
1909
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -1962,7 +1932,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1962
1932
|
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1963
1933
|
|
|
1964
1934
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1965
|
-
result.push(
|
|
1935
|
+
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1966
1936
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_normal"),
|
|
1967
1937
|
quantity: mainProductQuantity - 1,
|
|
1968
1938
|
discount_list: updatedMainDiscountListOriginal,
|
|
@@ -1975,7 +1945,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1975
1945
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1976
1946
|
mainProductArr.forEach(function (mainProduct) {
|
|
1977
1947
|
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1978
|
-
var mainProductData =
|
|
1948
|
+
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1979
1949
|
|
|
1980
1950
|
// 重组bundle
|
|
1981
1951
|
var newBundle = [];
|
|
@@ -2062,7 +2032,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2062
2032
|
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
2063
2033
|
|
|
2064
2034
|
// 生成最终的主商品
|
|
2065
|
-
result.push(
|
|
2035
|
+
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
2066
2036
|
bundle: newBundle,
|
|
2067
2037
|
total: newTotal,
|
|
2068
2038
|
origin_total: newOriginTotal
|
package/dist/server/index.d.ts
CHANGED
|
@@ -57,7 +57,6 @@ declare class Server {
|
|
|
57
57
|
private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
|
|
58
58
|
private salesSearchSubscribers;
|
|
59
59
|
private deviceTaskActionsRegistered;
|
|
60
|
-
private localPaymentUpdateQueues;
|
|
61
60
|
private floorPlanQuerySubscribers;
|
|
62
61
|
private moduleRegistry;
|
|
63
62
|
constructor(core: PisellCore);
|
|
@@ -121,8 +120,6 @@ declare class Server {
|
|
|
121
120
|
private handleSyncSalesTask;
|
|
122
121
|
private runCheckoutSync;
|
|
123
122
|
private omitCheckoutSyncMode;
|
|
124
|
-
private buildRemoteCheckoutData;
|
|
125
|
-
private mergeCheckoutSyncPayments;
|
|
126
123
|
private persistSyncedCheckoutOrder;
|
|
127
124
|
/**
|
|
128
125
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
@@ -253,11 +250,6 @@ declare class Server {
|
|
|
253
250
|
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
254
251
|
*/
|
|
255
252
|
private recomputeAndNotifySubscriber;
|
|
256
|
-
/**
|
|
257
|
-
* 根据餐牌 ID 获取其绑定日程中的全部时间点。
|
|
258
|
-
* 商品查询定时器与 schedule-time-points 路由共用此逻辑。
|
|
259
|
-
*/
|
|
260
|
-
private getMenuScheduleTimePoints;
|
|
261
253
|
/**
|
|
262
254
|
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
263
255
|
*/
|
|
@@ -461,18 +453,6 @@ declare class Server {
|
|
|
461
453
|
*/
|
|
462
454
|
private handleUpdateLocalOrder;
|
|
463
455
|
private handleOrderSalesCheckout;
|
|
464
|
-
private handleOrderSalesDraft;
|
|
465
|
-
private createLocalPaymentOperationId;
|
|
466
|
-
private buildLocalPaymentOrderLogContext;
|
|
467
|
-
private isValidLocalPaymentDecimal;
|
|
468
|
-
private getInvalidLocalPaymentSurchargeFields;
|
|
469
|
-
private buildLocalPaymentSurchargeUpdate;
|
|
470
|
-
private handleGetLocalPayment;
|
|
471
|
-
private handleUpdateLocalPayment;
|
|
472
|
-
private runLocalPaymentUpdateInQueue;
|
|
473
|
-
private processLocalPaymentUpdate;
|
|
474
|
-
private processSuccessfulLocalPayment;
|
|
475
|
-
private sanitizeLocalRecoveryOrder;
|
|
476
456
|
private handleOrderCheckout;
|
|
477
457
|
private getDeviceTaskPlugin;
|
|
478
458
|
private getIdGeneratorPlugin;
|
|
@@ -500,13 +480,8 @@ declare class Server {
|
|
|
500
480
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
501
481
|
private handleOrderCheckoutSubmit;
|
|
502
482
|
private handleSyncCheckoutSubmit;
|
|
503
|
-
private handleOrderDraftSubmit;
|
|
504
483
|
private handlePendingSyncCheckoutOrder;
|
|
505
484
|
private buildPendingSyncCheckoutOrder;
|
|
506
|
-
/**
|
|
507
|
-
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
508
|
-
*/
|
|
509
|
-
private shouldAutoPrintCheckoutReceipt;
|
|
510
485
|
private shouldBuildSmallTicketData;
|
|
511
486
|
private shouldPrintSyncedOrder;
|
|
512
487
|
private hasPaymentStatus;
|