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