@pisell/pisellos 2.2.263 → 2.2.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- 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 +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -14
- package/dist/modules/Order/index.js +736 -1035
- package/dist/modules/Order/types.d.ts +0 -16
- package/dist/modules/Order/utils.d.ts +3 -4
- package/dist/modules/Order/utils.js +61 -54
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +43 -69
- package/dist/modules/Rules/types.d.ts +1 -10
- package/dist/server/index.d.ts +0 -55
- package/dist/server/index.js +753 -1173
- package/dist/server/modules/order/index.d.ts +4 -10
- package/dist/server/modules/order/index.js +399 -404
- package/dist/server/modules/order/types.d.ts +0 -4
- package/dist/server/modules/products/index.d.ts +8 -31
- package/dist/server/modules/products/index.js +390 -549
- package/dist/server/modules/products/types.d.ts +0 -18
- package/dist/solution/BaseSales/index.d.ts +1 -21
- package/dist/solution/BaseSales/index.js +789 -1136
- package/dist/solution/BaseSales/types.d.ts +1 -6
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +25 -59
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- 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 +51 -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/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -14
- package/lib/modules/Order/index.js +60 -326
- package/lib/modules/Order/types.d.ts +0 -16
- package/lib/modules/Order/utils.d.ts +3 -4
- package/lib/modules/Order/utils.js +23 -22
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +29 -61
- package/lib/modules/Rules/types.d.ts +1 -10
- package/lib/server/index.d.ts +0 -55
- package/lib/server/index.js +34 -332
- package/lib/server/modules/order/index.d.ts +4 -10
- package/lib/server/modules/order/index.js +139 -198
- package/lib/server/modules/order/types.d.ts +0 -4
- package/lib/server/modules/products/index.d.ts +8 -31
- package/lib/server/modules/products/index.js +35 -134
- package/lib/server/modules/products/types.d.ts +0 -18
- package/lib/solution/BaseSales/index.d.ts +1 -21
- package/lib/solution/BaseSales/index.js +72 -313
- package/lib/solution/BaseSales/types.d.ts +1 -6
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -33
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
|
@@ -241,6 +241,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
241
|
value: function resolveDiscountListForManualOverride(discountList) {
|
|
242
242
|
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
243
243
|
}
|
|
244
|
+
}, {
|
|
245
|
+
key: "isItemRewardProductDiscount",
|
|
246
|
+
value: function isItemRewardProductDiscount(product) {
|
|
247
|
+
var _product$_promotion;
|
|
248
|
+
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
249
|
+
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) {
|
|
250
|
+
var _item$metadata, _item$metadata2;
|
|
251
|
+
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';
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
244
255
|
// 获取券不可用的原因
|
|
245
256
|
}, {
|
|
246
257
|
key: "getUnavailableReason",
|
|
@@ -335,32 +346,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
335
346
|
}) && productList.find(function (n) {
|
|
336
347
|
return !n.booking_id;
|
|
337
348
|
});
|
|
338
|
-
var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
|
|
339
|
-
return uid !== undefined && uid !== null && uid !== '';
|
|
340
|
-
}).map(String));
|
|
341
|
-
var getOriginProductUid = function getOriginProductUid(originProduct) {
|
|
342
|
-
var _originProduct$metada, _originProduct$metada2;
|
|
343
|
-
var uid = (_originProduct$metada = originProduct === null || originProduct === void 0 || (_originProduct$metada2 = originProduct.metadata) === null || _originProduct$metada2 === void 0 ? void 0 : _originProduct$metada2.unique_identification_number) !== null && _originProduct$metada !== void 0 ? _originProduct$metada : originProduct === null || originProduct === void 0 ? void 0 : originProduct.unique_identification_number;
|
|
344
|
-
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
345
|
-
return String(uid);
|
|
346
|
-
};
|
|
347
|
-
var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
|
|
348
|
-
if (!selectedDiscount) return false;
|
|
349
|
-
var uid = getOriginProductUid(originProduct);
|
|
350
|
-
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
351
|
-
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
352
|
-
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
353
|
-
};
|
|
354
|
-
var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
|
|
355
|
-
var _discount2;
|
|
356
|
-
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
357
|
-
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
358
|
-
if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
|
|
359
|
-
return undefined;
|
|
360
|
-
}
|
|
361
|
-
var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
|
|
362
|
-
return Number.isFinite(percent) ? percent : undefined;
|
|
363
|
-
};
|
|
364
349
|
var editModeDiscount = [];
|
|
365
350
|
var addModeDiscount = [];
|
|
366
351
|
discountList.forEach(function (discount) {
|
|
@@ -389,6 +374,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
374
|
}
|
|
390
375
|
});
|
|
391
376
|
}
|
|
377
|
+
|
|
378
|
+
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
|
|
379
|
+
var filteredDiscountList = addModeDiscount.filter(function (discount) {
|
|
380
|
+
return !discount.isManualSelect;
|
|
381
|
+
});
|
|
392
382
|
var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
|
|
393
383
|
if (!hasDiscountInput) {
|
|
394
384
|
return {
|
|
@@ -396,16 +386,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
386
|
productList: productList
|
|
397
387
|
};
|
|
398
388
|
}
|
|
399
|
-
var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
|
|
400
|
-
var discountType = discount.tag || discount.type;
|
|
401
|
-
return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
|
|
405
|
-
// Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
|
|
406
|
-
var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
|
|
407
|
-
return !discount.isManualSelect;
|
|
408
|
-
})), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
|
|
409
389
|
|
|
410
390
|
// 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
|
|
411
391
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
@@ -729,6 +709,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
729
709
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
730
710
|
};
|
|
731
711
|
}
|
|
712
|
+
if (_this3.isItemRewardProductDiscount(product)) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
732
715
|
|
|
733
716
|
// 编辑的商品使用了优惠券不可用
|
|
734
717
|
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) {
|
|
@@ -915,6 +898,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
898
|
};
|
|
916
899
|
originProduct = flatItem.originProduct;
|
|
917
900
|
}
|
|
901
|
+
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
918
902
|
addModeDiscount.forEach(function (discount) {
|
|
919
903
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
920
904
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -940,7 +924,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
924
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
941
925
|
|
|
942
926
|
// 判断优惠券是否适用于该商品
|
|
943
|
-
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
927
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
944
928
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
945
929
|
// 记录此优惠券适用的商品
|
|
946
930
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1085,16 +1069,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1085
1069
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1086
1070
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1087
1071
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1072
|
+
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1088
1073
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1089
1074
|
var discountType = discount.tag || discount.type;
|
|
1090
|
-
|
|
1091
|
-
var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
|
|
1092
|
-
if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
|
|
1093
|
-
var uid = currentOriginUid;
|
|
1094
|
-
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
1095
|
-
if (!discount.isSelected) return false;
|
|
1096
|
-
}
|
|
1097
|
-
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
|
|
1075
|
+
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
|
|
1098
1076
|
var _discount$config2;
|
|
1099
1077
|
// 如果策略检查后没有config,说明不可用
|
|
1100
1078
|
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
|
|
@@ -1172,6 +1150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1172
1150
|
|
|
1173
1151
|
// 如果是手动折扣,则不适用优惠券
|
|
1174
1152
|
var isManualDiscount = false;
|
|
1153
|
+
var isItemRewardProductDiscount = false;
|
|
1175
1154
|
if (flatItem.type === 'main') {
|
|
1176
1155
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1177
1156
|
// 主商品:判断自身是否手动折扣
|
|
@@ -1183,7 +1162,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1183
1162
|
}) && (!((_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) {
|
|
1184
1163
|
return item.type === 'product';
|
|
1185
1164
|
})));
|
|
1186
|
-
|
|
1165
|
+
isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
1166
|
+
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1187
1167
|
isManualDiscount = false;
|
|
1188
1168
|
}
|
|
1189
1169
|
} else {
|
|
@@ -1293,15 +1273,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1273
|
var main_product_selling_price = product.price;
|
|
1294
1274
|
if ((product.discount_list || []).some(function (item) {
|
|
1295
1275
|
return item.type === 'promotion';
|
|
1296
|
-
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1276
|
+
}) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1297
1277
|
var _product$total, _product$main_product;
|
|
1298
1278
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1299
1279
|
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;
|
|
1300
1280
|
}
|
|
1301
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1281
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
|
|
1302
1282
|
price: product.price,
|
|
1303
|
-
main_product_selling_price: product.price
|
|
1304
|
-
}
|
|
1283
|
+
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
|
|
1284
|
+
}, isItemRewardProductDiscount ? {
|
|
1285
|
+
total: total
|
|
1286
|
+
} : {}) : {
|
|
1305
1287
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1306
1288
|
total: total,
|
|
1307
1289
|
price: product.price,
|
|
@@ -1322,8 +1304,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1322
1304
|
}
|
|
1323
1305
|
return;
|
|
1324
1306
|
}
|
|
1325
|
-
|
|
1326
|
-
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
|
|
1307
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct) {
|
|
1327
1308
|
return;
|
|
1328
1309
|
}
|
|
1329
1310
|
|
|
@@ -1364,7 +1345,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1364
1345
|
}));
|
|
1365
1346
|
}
|
|
1366
1347
|
for (var i = 0; i < splitCount; i++) {
|
|
1367
|
-
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2
|
|
1348
|
+
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
|
|
1368
1349
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
1369
1350
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1370
1351
|
// 标记优惠券为已使用
|
|
@@ -1402,18 +1383,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1402
1383
|
var productDiscountDifference = void 0;
|
|
1403
1384
|
var discountedOptions = product.options;
|
|
1404
1385
|
var optionDiscountAmount = 0;
|
|
1405
|
-
var reapplyDiscountPercent = void 0;
|
|
1406
1386
|
if (isOrderLevel && productAllocation) {
|
|
1407
1387
|
// order_level:使用预计算的分摊金额
|
|
1408
1388
|
amount = productAllocation.discountAmount;
|
|
1409
1389
|
productDiscountDifference = productAllocation.difference;
|
|
1410
1390
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1411
|
-
} else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1412
|
-
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1413
|
-
var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
|
|
1414
|
-
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1415
|
-
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1416
|
-
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
1417
1391
|
} else {
|
|
1418
1392
|
// item_level 或其他类型:使用原有逻辑
|
|
1419
1393
|
mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
|
|
@@ -1446,7 +1420,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1420
|
title: _selectedDiscount.format_title,
|
|
1447
1421
|
original_amount: product.price,
|
|
1448
1422
|
product_id: originProduct.id || originProduct.product_id,
|
|
1449
|
-
percent:
|
|
1423
|
+
percent: _selectedDiscount.par_value,
|
|
1450
1424
|
discount_product_id: _selectedDiscount.product_id
|
|
1451
1425
|
},
|
|
1452
1426
|
// 前端使用的num数量,为了计算优惠金额
|
|
@@ -1750,11 +1724,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1750
1724
|
processedItems.forEach(function (item) {
|
|
1751
1725
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1752
1726
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1753
|
-
var _item$
|
|
1727
|
+
var _item$metadata3;
|
|
1754
1728
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1755
1729
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1756
1730
|
num: item.num,
|
|
1757
|
-
custom_product_bundle_map_id: (_item$
|
|
1731
|
+
custom_product_bundle_map_id: (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.custom_product_bundle_map_id
|
|
1758
1732
|
})
|
|
1759
1733
|
// num: item.num, // 使用拆分后的 num
|
|
1760
1734
|
});
|
|
@@ -1773,11 +1747,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1773
1747
|
if (item.processed) {
|
|
1774
1748
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1775
1749
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1776
|
-
var _item$
|
|
1750
|
+
var _item$metadata4;
|
|
1777
1751
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1778
1752
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1779
1753
|
num: item.num,
|
|
1780
|
-
custom_product_bundle_map_id: (_item$
|
|
1754
|
+
custom_product_bundle_map_id: (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.custom_product_bundle_map_id
|
|
1781
1755
|
})
|
|
1782
1756
|
// num: item.num, // 使用当前的 num
|
|
1783
1757
|
});
|
|
@@ -1818,8 +1792,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1818
1792
|
|
|
1819
1793
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1820
1794
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1821
|
-
var _item$
|
|
1822
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1795
|
+
var _item$metadata5;
|
|
1796
|
+
return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
|
|
1823
1797
|
});
|
|
1824
1798
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1825
1799
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1892,8 +1866,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1892
1866
|
|
|
1893
1867
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1894
1868
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1895
|
-
var _item$
|
|
1896
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1869
|
+
var _item$metadata6;
|
|
1870
|
+
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
1897
1871
|
});
|
|
1898
1872
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1899
1873
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
-
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
3
2
|
export declare enum UnavailableReason {
|
|
4
3
|
TimeLimit = "time_limit",
|
|
5
4
|
ProductNotApplicable = "product_not_applicable",
|
|
@@ -24,14 +23,6 @@ export interface DiscountResult {
|
|
|
24
23
|
discountList: any[];
|
|
25
24
|
}
|
|
26
25
|
export type RulesFormSubject = boolean | ((product: any) => boolean);
|
|
27
|
-
export interface RulesCalcDiscountOptions {
|
|
28
|
-
isSelected?: boolean;
|
|
29
|
-
discountId?: number;
|
|
30
|
-
selectedList?: SetDiscountSelectedParams[];
|
|
31
|
-
scan?: boolean;
|
|
32
|
-
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
33
|
-
reapplyBookingDiscountProductUids?: string[];
|
|
34
|
-
}
|
|
35
26
|
export interface RulesModuleAPI {
|
|
36
27
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
37
28
|
clear: () => Promise<void>;
|
|
@@ -43,7 +34,7 @@ export interface RulesModuleAPI {
|
|
|
43
34
|
}[];
|
|
44
35
|
isFormSubject: RulesFormSubject;
|
|
45
36
|
orderTotalAmount: number;
|
|
46
|
-
}
|
|
37
|
+
}) => DiscountResult;
|
|
47
38
|
}
|
|
48
39
|
type ProductDetail = {
|
|
49
40
|
isClient?: boolean;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -47,8 +47,6 @@ declare class Server {
|
|
|
47
47
|
private prefixRouterGet;
|
|
48
48
|
router: Router;
|
|
49
49
|
private productQuerySubscribers;
|
|
50
|
-
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
|
-
private productQueryScheduleTimers;
|
|
52
50
|
private orderQuerySubscribers;
|
|
53
51
|
private bookingQuerySubscribers;
|
|
54
52
|
private bookingRemoteQuerySubscribers;
|
|
@@ -212,48 +210,6 @@ declare class Server {
|
|
|
212
210
|
* 根据 subscriberId 移除商品查询订阅者
|
|
213
211
|
*/
|
|
214
212
|
removeProductQuerySubscriber(subscriberId?: string): void;
|
|
215
|
-
/**
|
|
216
|
-
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
217
|
-
*/
|
|
218
|
-
private buildProductQueryResultPayload;
|
|
219
|
-
/**
|
|
220
|
-
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
221
|
-
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
222
|
-
*/
|
|
223
|
-
private shouldScheduleProductQueryReload;
|
|
224
|
-
/**
|
|
225
|
-
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
226
|
-
*/
|
|
227
|
-
private clearSubscriberScheduleTimers;
|
|
228
|
-
/**
|
|
229
|
-
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
230
|
-
*/
|
|
231
|
-
private removeScheduleTimerRef;
|
|
232
|
-
/**
|
|
233
|
-
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
234
|
-
*/
|
|
235
|
-
private computeScheduleTimePointDelayMs;
|
|
236
|
-
/**
|
|
237
|
-
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
238
|
-
*/
|
|
239
|
-
private refreshSubscriberScheduleAtExecution;
|
|
240
|
-
/**
|
|
241
|
-
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
242
|
-
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
243
|
-
*/
|
|
244
|
-
private scheduleSubscriberTimePointReloads;
|
|
245
|
-
/**
|
|
246
|
-
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
247
|
-
*/
|
|
248
|
-
private onScheduleTimePointTimerFire;
|
|
249
|
-
/**
|
|
250
|
-
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
251
|
-
*/
|
|
252
|
-
private recomputeAndNotifySubscriber;
|
|
253
|
-
/**
|
|
254
|
-
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
255
|
-
*/
|
|
256
|
-
private syncProductQueryScheduleTimers;
|
|
257
213
|
/**
|
|
258
214
|
* 处理商品查询请求
|
|
259
215
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -489,11 +445,6 @@ declare class Server {
|
|
|
489
445
|
private sumPaidOrderPayments;
|
|
490
446
|
private toAmountNumber;
|
|
491
447
|
private buildSmallTicketProductMap;
|
|
492
|
-
private collectSalesDetailProductIds;
|
|
493
|
-
private buildSalesDetailProductSnapshotMap;
|
|
494
|
-
private withProductCatalogSnapshots;
|
|
495
|
-
private withBundleCatalogSnapshots;
|
|
496
|
-
private withSalesDetailProductSnapshots;
|
|
497
448
|
private withPendingSyncProductTitles;
|
|
498
449
|
private buildProductTitleSnapshot;
|
|
499
450
|
private getProductTitleSnapshotCurrentLocale;
|
|
@@ -614,12 +565,6 @@ declare class Server {
|
|
|
614
565
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
615
566
|
*/
|
|
616
567
|
private computeProductQueryResult;
|
|
617
|
-
/**
|
|
618
|
-
* 构建商品格式化上下文。
|
|
619
|
-
*
|
|
620
|
-
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
621
|
-
*/
|
|
622
|
-
private buildProductFormatterContext;
|
|
623
568
|
/**
|
|
624
569
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
625
570
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|