@pisell/pisellos 2.1.151 → 2.1.152
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Discount/index.d.ts +9 -3
- package/dist/modules/Discount/index.js +103 -11
- package/dist/modules/Discount/types.d.ts +8 -19
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +66 -1
- package/dist/modules/Order/index.js +906 -30
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +168 -677
- package/dist/modules/Rules/types.d.ts +0 -2
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +41 -52
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -2
- package/dist/solution/BookingByStep/index.js +46 -43
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +152 -0
- package/dist/solution/ScanOrder/index.js +3132 -0
- package/dist/solution/ScanOrder/types.d.ts +287 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +764 -0
- package/dist/solution/ShopDiscount/index.d.ts +3 -2
- package/dist/solution/ShopDiscount/index.js +60 -59
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.js +12 -26
- package/dist/solution/VenueBooking/index.d.ts +200 -0
- package/dist/solution/VenueBooking/index.js +3459 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Discount/index.d.ts +9 -3
- package/lib/modules/Discount/index.js +65 -4
- package/lib/modules/Discount/types.d.ts +8 -19
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +66 -1
- package/lib/modules/Order/index.js +515 -1
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -3
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +288 -780
- package/lib/modules/Rules/types.d.ts +0 -2
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +22 -31
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -2
- package/lib/solution/BookingByStep/index.js +6 -4
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +152 -0
- package/lib/solution/ScanOrder/index.js +1901 -0
- package/lib/solution/ScanOrder/types.d.ts +287 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +635 -0
- package/lib/solution/ShopDiscount/index.d.ts +3 -2
- package/lib/solution/ShopDiscount/index.js +19 -25
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/VenueBooking/index.d.ts +200 -0
- package/lib/solution/VenueBooking/index.js +1926 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// picoding 相关公共 api
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -719,8 +719,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
719
719
|
unitProducts.push({
|
|
720
720
|
product: product,
|
|
721
721
|
price: product.price,
|
|
722
|
-
productId: product.id
|
|
723
|
-
sourceAvailableQty: availableQty
|
|
722
|
+
productId: product.id
|
|
724
723
|
});
|
|
725
724
|
}
|
|
726
725
|
}
|
|
@@ -737,13 +736,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
737
736
|
};
|
|
738
737
|
}
|
|
739
738
|
|
|
740
|
-
// 2.
|
|
739
|
+
// 2. 按价格从高到低排序(优先使用高价商品)
|
|
741
740
|
unitProducts.sort(function (a, b) {
|
|
742
|
-
// 优先级1:来源购物车项数量是 x 的倍数的排前面(这些商品可以完整凑组,避免拆分)
|
|
743
|
-
var aIsMultiple = a.sourceAvailableQty > 0 && a.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
744
|
-
var bIsMultiple = b.sourceAvailableQty > 0 && b.sourceAvailableQty % x === 0 ? 1 : 0;
|
|
745
|
-
if (aIsMultiple !== bIsMultiple) return bIsMultiple - aIsMultiple;
|
|
746
|
-
// 优先级2:按价格从高到低(优先使用高价商品)
|
|
747
741
|
return b.price - a.price;
|
|
748
742
|
});
|
|
749
743
|
|
|
@@ -839,10 +833,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
839
833
|
var totalAllocated = allocatedPrices.reduce(function (sum, p) {
|
|
840
834
|
return sum.plus(p);
|
|
841
835
|
}, new Decimal(0));
|
|
842
|
-
|
|
843
|
-
var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
844
|
-
var actualTotal = Decimal.min(totalAllocated, productOriginalAmount);
|
|
845
|
-
var finalPricePerUnit = this.formatPrice(actualTotal.div(promoQty));
|
|
836
|
+
var finalPricePerUnit = this.formatPrice(totalAllocated.div(promoQty));
|
|
846
837
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
847
838
|
quantity: promoQty,
|
|
848
839
|
finalPrice: finalPricePerUnit,
|
|
@@ -852,8 +843,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
852
843
|
isSplit: false,
|
|
853
844
|
matchedBundleIndex: matchedBundleIndex
|
|
854
845
|
}));
|
|
846
|
+
var productOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
855
847
|
originalAmount = originalAmount.plus(productOriginalAmount);
|
|
856
|
-
finalAmount = finalAmount.plus(
|
|
848
|
+
finalAmount = finalAmount.plus(totalAllocated);
|
|
857
849
|
} else if (promoQty === 0 && remainingQty > 0) {
|
|
858
850
|
// 全部不参与促销:保留原 id,finalPrice = 原价
|
|
859
851
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
@@ -873,10 +865,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
873
865
|
var _totalAllocated = allocatedPrices.reduce(function (sum, p) {
|
|
874
866
|
return sum.plus(p);
|
|
875
867
|
}, new Decimal(0));
|
|
876
|
-
|
|
877
|
-
var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
878
|
-
var _actualTotal = Decimal.min(_totalAllocated, promoOriginalAmount);
|
|
879
|
-
var _finalPricePerUnit = this.formatPrice(_actualTotal.div(promoQty));
|
|
868
|
+
var _finalPricePerUnit = this.formatPrice(_totalAllocated.div(promoQty));
|
|
880
869
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
881
870
|
id: this.generateRandomId(),
|
|
882
871
|
originalId: _product.id,
|
|
@@ -888,8 +877,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
888
877
|
matchedBundleIndex: matchedBundleIndex,
|
|
889
878
|
isSplit: true
|
|
890
879
|
}));
|
|
880
|
+
var promoOriginalAmount = new Decimal(_product.price).mul(promoQty);
|
|
891
881
|
originalAmount = originalAmount.plus(promoOriginalAmount);
|
|
892
|
-
finalAmount = finalAmount.plus(
|
|
882
|
+
finalAmount = finalAmount.plus(_totalAllocated);
|
|
893
883
|
|
|
894
884
|
// 不参与促销的部分:保留原 id
|
|
895
885
|
result.push(_objectSpread(_objectSpread({}, _product), {}, {
|
|
@@ -908,74 +898,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
908
898
|
// 更新已处理数量
|
|
909
899
|
processedQuantityMap.set(_key, _processedQty + _availableQty);
|
|
910
900
|
}
|
|
911
|
-
|
|
912
|
-
// 8. 尾差调整:确保促销商品的 finalPrice × quantity 之和精确等于 groupPrice × groupCount
|
|
913
901
|
} catch (err) {
|
|
914
902
|
_iterator13.e(err);
|
|
915
903
|
} finally {
|
|
916
904
|
_iterator13.f();
|
|
917
905
|
}
|
|
918
|
-
if (groupCount > 0) {
|
|
919
|
-
var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
|
|
920
|
-
var promoItems = result.filter(function (p) {
|
|
921
|
-
return p.inPromotion;
|
|
922
|
-
});
|
|
923
|
-
var actualPromoTotal = new Decimal(0);
|
|
924
|
-
var _iterator14 = _createForOfIteratorHelper(promoItems),
|
|
925
|
-
_step14;
|
|
926
|
-
try {
|
|
927
|
-
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
928
|
-
var _p = _step14.value;
|
|
929
|
-
actualPromoTotal = actualPromoTotal.plus(new Decimal(_p.finalPrice).mul(_p.quantity));
|
|
930
|
-
}
|
|
931
|
-
} catch (err) {
|
|
932
|
-
_iterator14.e(err);
|
|
933
|
-
} finally {
|
|
934
|
-
_iterator14.f();
|
|
935
|
-
}
|
|
936
|
-
var roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
|
|
937
|
-
if (!roundingDiff.eq(0)) {
|
|
938
|
-
// 优先找 quantity=1 的促销商品调整(差额直接加减到单价上)
|
|
939
|
-
var adjustTarget = promoItems.find(function (p) {
|
|
940
|
-
return p.quantity === 1;
|
|
941
|
-
});
|
|
942
|
-
if (adjustTarget) {
|
|
943
|
-
adjustTarget.finalPrice = this.formatPrice(new Decimal(adjustTarget.finalPrice).minus(roundingDiff));
|
|
944
|
-
} else if (promoItems.length > 0) {
|
|
945
|
-
// 没有 quantity=1 的促销商品,从最后一个促销商品中拆出1件做尾差调整
|
|
946
|
-
var lastPromo = promoItems[promoItems.length - 1];
|
|
947
|
-
var adjustedUnitPrice = this.formatPrice(new Decimal(lastPromo.finalPrice).minus(roundingDiff));
|
|
948
|
-
|
|
949
|
-
// 原商品减少1件
|
|
950
|
-
lastPromo.quantity -= 1;
|
|
951
|
-
lastPromo.isSplit = true;
|
|
952
|
-
|
|
953
|
-
// 拆出1件用调整后的价格
|
|
954
|
-
result.push(_objectSpread(_objectSpread({}, lastPromo), {}, {
|
|
955
|
-
id: this.generateRandomId(),
|
|
956
|
-
originalId: lastPromo.originalId || lastPromo.id,
|
|
957
|
-
quantity: 1,
|
|
958
|
-
finalPrice: adjustedUnitPrice,
|
|
959
|
-
isSplit: true
|
|
960
|
-
}));
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// 重新计算 finalAmount
|
|
964
|
-
finalAmount = new Decimal(0);
|
|
965
|
-
var _iterator15 = _createForOfIteratorHelper(result),
|
|
966
|
-
_step15;
|
|
967
|
-
try {
|
|
968
|
-
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
969
|
-
var p = _step15.value;
|
|
970
|
-
finalAmount = finalAmount.plus(new Decimal(p.finalPrice).mul(p.quantity));
|
|
971
|
-
}
|
|
972
|
-
} catch (err) {
|
|
973
|
-
_iterator15.e(err);
|
|
974
|
-
} finally {
|
|
975
|
-
_iterator15.f();
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
906
|
return {
|
|
980
907
|
products: result,
|
|
981
908
|
originalAmount: originalAmount.toNumber(),
|
|
@@ -1010,11 +937,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1010
937
|
// 对于 bundle 子商品匹配,促销数量 = 主商品数量 × bundle子商品数量
|
|
1011
938
|
var totalPromoQty = 0;
|
|
1012
939
|
var productInfoMap = new Map();
|
|
1013
|
-
var
|
|
1014
|
-
|
|
940
|
+
var _iterator14 = _createForOfIteratorHelper(groupProducts),
|
|
941
|
+
_step14;
|
|
1015
942
|
try {
|
|
1016
|
-
for (
|
|
1017
|
-
var product =
|
|
943
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
944
|
+
var product = _step14.value;
|
|
1018
945
|
var key = this.getProductKey(product);
|
|
1019
946
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
1020
947
|
var availableQty = product.quantity - processedQty;
|
|
@@ -1040,18 +967,18 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1040
967
|
|
|
1041
968
|
// 2. 判断是否满足促销条件
|
|
1042
969
|
} catch (err) {
|
|
1043
|
-
|
|
970
|
+
_iterator14.e(err);
|
|
1044
971
|
} finally {
|
|
1045
|
-
|
|
972
|
+
_iterator14.f();
|
|
1046
973
|
}
|
|
1047
974
|
var isFulfilled = totalPromoQty >= buyQuantity;
|
|
1048
975
|
|
|
1049
976
|
// 3. 生成商品结果(第二次遍历)
|
|
1050
|
-
var
|
|
1051
|
-
|
|
977
|
+
var _iterator15 = _createForOfIteratorHelper(groupProducts),
|
|
978
|
+
_step15;
|
|
1052
979
|
try {
|
|
1053
|
-
for (
|
|
1054
|
-
var _product2 =
|
|
980
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
981
|
+
var _product2 = _step15.value;
|
|
1055
982
|
var _key2 = this.getProductKey(_product2);
|
|
1056
983
|
var info = productInfoMap.get(_key2);
|
|
1057
984
|
if (!info || info.availableQty <= 0) continue;
|
|
@@ -1079,9 +1006,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1079
1006
|
|
|
1080
1007
|
// 4. 计算赠品数量(使用促销数量)
|
|
1081
1008
|
} catch (err) {
|
|
1082
|
-
|
|
1009
|
+
_iterator15.e(err);
|
|
1083
1010
|
} finally {
|
|
1084
|
-
|
|
1011
|
+
_iterator15.f();
|
|
1085
1012
|
}
|
|
1086
1013
|
var giftCount = 0;
|
|
1087
1014
|
if (isFulfilled) {
|
|
@@ -1110,11 +1037,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1110
1037
|
key: "getRemainingProducts",
|
|
1111
1038
|
value: function getRemainingProducts(allProducts, processedQuantityMap) {
|
|
1112
1039
|
var result = [];
|
|
1113
|
-
var
|
|
1114
|
-
|
|
1040
|
+
var _iterator16 = _createForOfIteratorHelper(allProducts),
|
|
1041
|
+
_step16;
|
|
1115
1042
|
try {
|
|
1116
|
-
for (
|
|
1117
|
-
var product =
|
|
1043
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1044
|
+
var product = _step16.value;
|
|
1118
1045
|
var key = this.getProductKey(product);
|
|
1119
1046
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
1120
1047
|
var remainingQty = product.quantity - processedQty;
|
|
@@ -1129,9 +1056,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1129
1056
|
}
|
|
1130
1057
|
}
|
|
1131
1058
|
} catch (err) {
|
|
1132
|
-
|
|
1059
|
+
_iterator16.e(err);
|
|
1133
1060
|
} finally {
|
|
1134
|
-
|
|
1061
|
+
_iterator16.f();
|
|
1135
1062
|
}
|
|
1136
1063
|
return result;
|
|
1137
1064
|
}
|
|
@@ -8,12 +8,10 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
-
private otherParams;
|
|
12
11
|
constructor();
|
|
13
12
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
14
13
|
getStrategyConfigs(): StrategyConfig[];
|
|
15
14
|
setLocale(locale: string): void;
|
|
16
|
-
setOtherParams(otherParams: any): void;
|
|
17
15
|
getText(key: string): string;
|
|
18
16
|
/**
|
|
19
17
|
* 搜索券的格式
|
|
@@ -24,43 +24,6 @@ var defaultStrategyMetadataCustom = {
|
|
|
24
24
|
deductOptionPrice: false
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* 条件 field → reasonCode 映射
|
|
29
|
-
* 用于将策略引擎返回的 failedField 转换为本地化文案 key
|
|
30
|
-
*/
|
|
31
|
-
var FIELD_REASON_CODE_MAP = {
|
|
32
|
-
orderTotalAmount: 'order_total_amount_not_enough',
|
|
33
|
-
applicableProductTotalAmount: 'applicable_product_total_amount_not_enough',
|
|
34
|
-
applicableProductCount: 'applicable_product_count_not_enough'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 金额类型 field 集合(需要在文案前拼货币符号)
|
|
39
|
-
*/
|
|
40
|
-
var AMOUNT_FIELDS = new Set(['orderTotalAmount', 'applicableProductTotalAmount']);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 用阈值与货币符号替换文案中的占位符
|
|
44
|
-
* 支持占位符:{value} / ${value} / {currency}
|
|
45
|
-
*/
|
|
46
|
-
function formatReason(template, value) {
|
|
47
|
-
var currency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
48
|
-
if (!template) return template;
|
|
49
|
-
var v = value === undefined || value === null ? '' : String(value);
|
|
50
|
-
var c = currency === undefined || currency === null ? '' : String(currency);
|
|
51
|
-
// 注意:必须先替换 value,再替换 currency
|
|
52
|
-
// 否则 currency 注入的 "$" 会被后续的 /\$\{value\}/ 正则误吞
|
|
53
|
-
// 使用函数作为替换参数,避免替换串中的 "$" 被 String.prototype.replace
|
|
54
|
-
// 当作特殊序列(如 $$ -> $、$& 等)处理
|
|
55
|
-
return template.replace(/\$\{value\}/g, function () {
|
|
56
|
-
return v;
|
|
57
|
-
}).replace(/\{value\}/g, function () {
|
|
58
|
-
return v;
|
|
59
|
-
}).replace(/\{currency\}/g, function () {
|
|
60
|
-
return c;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
27
|
/**
|
|
65
28
|
* Wallet Pass 评估器
|
|
66
29
|
* 用于评估哪些 voucher 可以在当前订单中使用
|
|
@@ -71,7 +34,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
71
34
|
_defineProperty(this, "engine", void 0);
|
|
72
35
|
_defineProperty(this, "strategyConfigs", []);
|
|
73
36
|
_defineProperty(this, "locale", 'en');
|
|
74
|
-
_defineProperty(this, "otherParams", {});
|
|
75
37
|
this.engine = new StrategyEngine({
|
|
76
38
|
debug: false,
|
|
77
39
|
enableTrace: false
|
|
@@ -95,11 +57,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
95
57
|
value: function setLocale(locale) {
|
|
96
58
|
this.locale = locale;
|
|
97
59
|
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "setOtherParams",
|
|
100
|
-
value: function setOtherParams(otherParams) {
|
|
101
|
-
this.otherParams = otherParams;
|
|
102
|
-
}
|
|
103
60
|
}, {
|
|
104
61
|
key: "getText",
|
|
105
62
|
value: function getText(key) {
|
|
@@ -234,17 +191,13 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
234
191
|
strategyResult: evaluationResult
|
|
235
192
|
});
|
|
236
193
|
} else {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
reasonCode = FIELD_REASON_CODE_MAP[failedField];
|
|
245
|
-
thresholdValue = failedRule === null || failedRule === void 0 ? void 0 : failedRule.value;
|
|
246
|
-
} else if (evaluationResult.code) {
|
|
247
|
-
// 兜底:保留原有 code → reasonCode 映射
|
|
194
|
+
// 根据策略评估结果的 code 映射到 locales 中的原因
|
|
195
|
+
var reasonCode = 'not_meet_the_required_conditions'; // 默认原因
|
|
196
|
+
|
|
197
|
+
// 根据策略引擎返回的 code 映射到本地化的 reasonCode
|
|
198
|
+
if (evaluationResult.code) {
|
|
199
|
+
// 可以根据具体的 code 映射到不同的原因
|
|
200
|
+
// 例如:如果是金额不足、使用次数限制等
|
|
248
201
|
var codeMapping = {
|
|
249
202
|
INSUFFICIENT_AMOUNT: 'not_meet_the_required_conditions',
|
|
250
203
|
USAGE_LIMIT_EXCEEDED: 'usage_limit_reached',
|
|
@@ -254,11 +207,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
254
207
|
};
|
|
255
208
|
reasonCode = codeMapping[evaluationResult.code] || 'not_meet_the_required_conditions';
|
|
256
209
|
}
|
|
257
|
-
var rawText = this.getText(reasonCode);
|
|
258
|
-
// 金额类型字段:从 otherParams.getData 取货币符号;非金额或取不到则留空
|
|
259
|
-
var currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams$get = (_this$otherParams2 = _this$otherParams).getData) === null || _this$otherParams$get === void 0 ? void 0 : _this$otherParams$get.call(_this$otherParams2, 'shop_symbol')) || '' : '';
|
|
260
|
-
console.log(currency, 'currency12345');
|
|
261
|
-
var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
262
210
|
results.push({
|
|
263
211
|
voucher: voucher,
|
|
264
212
|
isApplicable: false,
|
|
@@ -266,7 +214,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
266
214
|
maxDeduction: 0,
|
|
267
215
|
deductTaxAndFee: false,
|
|
268
216
|
applicableProductIds: [],
|
|
269
|
-
reason:
|
|
217
|
+
reason: this.getText(reasonCode),
|
|
270
218
|
reasonCode: reasonCode,
|
|
271
219
|
strategyResult: evaluationResult
|
|
272
220
|
});
|
|
@@ -506,7 +454,6 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
506
454
|
}, {
|
|
507
455
|
key: "calculateApplicableProducts",
|
|
508
456
|
value: function calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
509
|
-
console.log(products, 'products1234');
|
|
510
457
|
var total = 0;
|
|
511
458
|
var count = 0;
|
|
512
459
|
|
|
@@ -5,10 +5,7 @@ export var locales = {
|
|
|
5
5
|
'usage_limit_reached': '已达到使用次数上限',
|
|
6
6
|
'max_passes_per_item_reached': '该商品已达到卡券使用上限',
|
|
7
7
|
'not_available_for_this_channel': '当前渠道不可使用',
|
|
8
|
-
'not_valid_for_this_order_type': '当前订单类型不适用'
|
|
9
|
-
'order_total_amount_not_enough': '满 {currency}{value} 可用',
|
|
10
|
-
'applicable_product_total_amount_not_enough': '满 {currency}{value} 可用',
|
|
11
|
-
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
8
|
+
'not_valid_for_this_order_type': '当前订单类型不适用'
|
|
12
9
|
},
|
|
13
10
|
'en': {
|
|
14
11
|
'not_meet_the_required_conditions': 'Not meet the required conditions.',
|
|
@@ -16,10 +13,7 @@ export var locales = {
|
|
|
16
13
|
'usage_limit_reached': 'Usage limit reached.',
|
|
17
14
|
'max_passes_per_item_reached': 'Max passes per item reached.',
|
|
18
15
|
'not_available_for_this_channel': 'Not available for this channel.',
|
|
19
|
-
'not_valid_for_this_order_type': 'Not valid for this order type.'
|
|
20
|
-
'order_total_amount_not_enough': 'Spend {currency}{value} to use',
|
|
21
|
-
'applicable_product_total_amount_not_enough': 'Spend {currency}{value} to use',
|
|
22
|
-
'applicable_product_count_not_enough': 'Min. Qty {value}'
|
|
16
|
+
'not_valid_for_this_order_type': 'Not valid for this order type.'
|
|
23
17
|
},
|
|
24
18
|
'zh-HK': {
|
|
25
19
|
'not_meet_the_required_conditions': '未達使用條件',
|
|
@@ -27,9 +21,6 @@ export var locales = {
|
|
|
27
21
|
'usage_limit_reached': '已達使用次數上限',
|
|
28
22
|
'max_passes_per_item_reached': '該商品已達卡券使用上限',
|
|
29
23
|
'not_available_for_this_channel': '當前渠道不可使用',
|
|
30
|
-
'not_valid_for_this_order_type': '當前訂單類型不適用'
|
|
31
|
-
'order_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
32
|
-
'applicable_product_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
33
|
-
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
24
|
+
'not_valid_for_this_order_type': '當前訂單類型不適用'
|
|
34
25
|
}
|
|
35
26
|
};
|
|
@@ -27,30 +27,17 @@ export declare class StrategyEngine {
|
|
|
27
27
|
*
|
|
28
28
|
* @param group 条件组
|
|
29
29
|
* @param context 运行时上下文
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
|
|
31
31
|
*/
|
|
32
32
|
private evaluateConditionGroup;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* 失败规则收集策略:
|
|
37
|
-
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
38
|
-
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
39
|
-
* - `not`:被取反规则实际通过时,记录该规则
|
|
40
|
-
*/
|
|
41
|
-
private evaluateGroupLogicDetailed;
|
|
42
|
-
/**
|
|
43
|
-
* 评估单个规则(带失败规则收集)
|
|
44
|
-
*/
|
|
45
|
-
private evaluateRuleDetailed;
|
|
46
|
-
/**
|
|
47
|
-
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
34
|
+
* 评估条件组的逻辑运算
|
|
48
35
|
*/
|
|
49
|
-
private
|
|
36
|
+
private evaluateGroupLogic;
|
|
50
37
|
/**
|
|
51
|
-
*
|
|
38
|
+
* 评估单个规则
|
|
52
39
|
*/
|
|
53
|
-
private
|
|
40
|
+
private evaluateRule;
|
|
54
41
|
/**
|
|
55
42
|
* 评估代码模式条件
|
|
56
43
|
*/
|