@pisell/pisellos 2.2.318 → 2.2.320
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/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +19 -12
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.js +740 -775
- package/dist/modules/Order/types.d.ts +2 -2
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/utils.js +45 -45
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -10
- package/dist/modules/Rules/index.js +169 -87
- package/dist/modules/Rules/promotionSelection.d.ts +14 -0
- package/dist/modules/Rules/promotionSelection.js +390 -0
- package/dist/modules/Rules/types.d.ts +9 -0
- package/dist/solution/BaseSales/index.js +41 -21
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +18 -11
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.js +13 -8
- package/lib/modules/Order/types.d.ts +2 -2
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/utils.js +1 -1
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -10
- package/lib/modules/Rules/index.js +62 -22
- package/lib/modules/Rules/promotionSelection.d.ts +14 -0
- package/lib/modules/Rules/promotionSelection.js +230 -0
- package/lib/modules/Rules/types.d.ts +9 -0
- package/lib/solution/BaseSales/index.js +19 -5
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -180,7 +180,8 @@ export declare class PromotionEvaluator {
|
|
|
180
180
|
*/
|
|
181
181
|
private processItemReward;
|
|
182
182
|
private normalizePositiveInteger;
|
|
183
|
-
|
|
183
|
+
/** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
|
|
184
|
+
private getItemRewardTriggerQuantity;
|
|
184
185
|
private buildItemRewardTargetUnits;
|
|
185
186
|
private resolveItemRewardFinalPrice;
|
|
186
187
|
private resolveItemRewardLimit;
|
|
@@ -375,6 +375,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
375
375
|
// 3. 追踪已处理的商品(避免重复处理)
|
|
376
376
|
// key: `${product_id}_${product_variant_id}`
|
|
377
377
|
var processedQuantityMap = new Map();
|
|
378
|
+
// X件Y元处理过的数量仍可作为商品奖励的触发条件。
|
|
379
|
+
var xItemsProcessedQuantityMap = new Map();
|
|
378
380
|
|
|
379
381
|
// 4. 处理每个促销组,收集结果
|
|
380
382
|
var pricedProducts = [];
|
|
@@ -392,7 +394,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
392
394
|
var matchedBundleIndexMap = group.productMatchedBundleIndexMap || new Map();
|
|
393
395
|
if (actionType === PROMOTION_ACTION_TYPES.X_ITEMS_FOR_Y_PRICE) {
|
|
394
396
|
// X件Y元处理
|
|
395
|
-
var result = this.processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap);
|
|
397
|
+
var result = this.processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
396
398
|
pricedProducts.push.apply(pricedProducts, _toConsumableArray(result.products));
|
|
397
399
|
totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
|
|
398
400
|
totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
|
|
@@ -409,7 +411,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
409
411
|
}
|
|
410
412
|
} else if (actionType === PROMOTION_ACTION_TYPES.ITEM_REWARD) {
|
|
411
413
|
// 商品奖励处理:条件商品触发,目标商品行享优惠,不自动新增商品
|
|
412
|
-
var _result2 = this.processItemReward(group, processedQuantityMap, products, matchedBundleIndexMap);
|
|
414
|
+
var _result2 = this.processItemReward(group, processedQuantityMap, products, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
413
415
|
pricedProducts.push.apply(pricedProducts, _toConsumableArray(_result2.products));
|
|
414
416
|
totalOriginalAmount = totalOriginalAmount.plus(_result2.originalAmount);
|
|
415
417
|
totalFinalAmount = totalFinalAmount.plus(_result2.finalAmount);
|
|
@@ -689,7 +691,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
689
691
|
*/
|
|
690
692
|
}, {
|
|
691
693
|
key: "processXItemsForYPrice",
|
|
692
|
-
value: function processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap) {
|
|
694
|
+
value: function processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
693
695
|
var strategyId = group.strategyId,
|
|
694
696
|
strategyMetadata = group.strategyMetadata,
|
|
695
697
|
actionDetail = group.actionDetail,
|
|
@@ -792,6 +794,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
792
794
|
_iterator11.f();
|
|
793
795
|
}
|
|
794
796
|
var allocatedPricesByProductId = new Map();
|
|
797
|
+
var expectedPromoTotal = new Decimal(0);
|
|
795
798
|
for (var g = 0; g < groupCount; g++) {
|
|
796
799
|
var startIdx = g * x;
|
|
797
800
|
var endIdx = startIdx + x;
|
|
@@ -802,8 +805,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
802
805
|
return sum.plus(u.price);
|
|
803
806
|
}, new Decimal(0));
|
|
804
807
|
|
|
805
|
-
//
|
|
806
|
-
var groupPriceDecimal = new Decimal(groupPrice);
|
|
808
|
+
// 组价高于本组原价时保留原价,尾差目标也必须使用封顶后的实际组价。
|
|
809
|
+
var groupPriceDecimal = Decimal.min(new Decimal(groupPrice), groupOriginalTotal);
|
|
810
|
+
expectedPromoTotal = expectedPromoTotal.plus(groupPriceDecimal);
|
|
807
811
|
var allocatedSum = new Decimal(0);
|
|
808
812
|
for (var i = 0; i < groupUnits.length; i++) {
|
|
809
813
|
var unit = groupUnits[i];
|
|
@@ -909,16 +913,16 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
909
913
|
|
|
910
914
|
// 更新已处理数量
|
|
911
915
|
processedQuantityMap.set(_key, _processedQty + _availableQty);
|
|
916
|
+
xItemsProcessedQuantityMap.set(_key, (xItemsProcessedQuantityMap.get(_key) || 0) + _availableQty);
|
|
912
917
|
}
|
|
913
918
|
|
|
914
|
-
// 8.
|
|
919
|
+
// 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
|
|
915
920
|
} catch (err) {
|
|
916
921
|
_iterator12.e(err);
|
|
917
922
|
} finally {
|
|
918
923
|
_iterator12.f();
|
|
919
924
|
}
|
|
920
925
|
if (groupCount > 0) {
|
|
921
|
-
var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
|
|
922
926
|
var promoItems = result.filter(function (p) {
|
|
923
927
|
return p.inPromotion;
|
|
924
928
|
});
|
|
@@ -1116,7 +1120,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1116
1120
|
*/
|
|
1117
1121
|
}, {
|
|
1118
1122
|
key: "processItemReward",
|
|
1119
|
-
value: function processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
|
|
1123
|
+
value: function processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
1120
1124
|
var _this4 = this;
|
|
1121
1125
|
var strategyId = group.strategyId,
|
|
1122
1126
|
strategyMetadata = group.strategyMetadata,
|
|
@@ -1125,7 +1129,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1125
1129
|
var detail = actionDetail;
|
|
1126
1130
|
var triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
|
|
1127
1131
|
var rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
|
|
1128
|
-
var conditionQuantity = this.
|
|
1132
|
+
var conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
1129
1133
|
if (conditionQuantity < triggerQuantity) {
|
|
1130
1134
|
return {
|
|
1131
1135
|
products: [],
|
|
@@ -1241,9 +1245,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1241
1245
|
var n = Math.floor(Number(value));
|
|
1242
1246
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
1243
1247
|
}
|
|
1248
|
+
|
|
1249
|
+
/** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
|
|
1244
1250
|
}, {
|
|
1245
|
-
key: "
|
|
1246
|
-
value: function
|
|
1251
|
+
key: "getItemRewardTriggerQuantity",
|
|
1252
|
+
value: function getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
1247
1253
|
var total = 0;
|
|
1248
1254
|
var _iterator19 = _createForOfIteratorHelper(products),
|
|
1249
1255
|
_step19;
|
|
@@ -1252,7 +1258,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1252
1258
|
var product = _step19.value;
|
|
1253
1259
|
var key = this.getProductKey(product);
|
|
1254
1260
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
1255
|
-
var
|
|
1261
|
+
var xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
|
|
1262
|
+
var availableQty = product.quantity - processedQty + xItemsProcessedQty;
|
|
1256
1263
|
if (availableQty <= 0) continue;
|
|
1257
1264
|
var matchedBundleIndex = matchedBundleIndexMap === null || matchedBundleIndexMap === void 0 ? void 0 : matchedBundleIndexMap.get(product.id);
|
|
1258
1265
|
if (matchedBundleIndex !== undefined && product.bundle) {
|
|
@@ -158,6 +158,10 @@ export interface Discount {
|
|
|
158
158
|
discount_calculation_mode: 'item_level' | 'order_level';
|
|
159
159
|
};
|
|
160
160
|
isManualSelect?: boolean;
|
|
161
|
+
/** X 件 Y 元互斥选择的手动意图;isSelected 只表示本次实际应用结果。 */
|
|
162
|
+
promotionSelection?: 'card' | 'promotion';
|
|
163
|
+
/** 记录手动操作影响的促销组,避免卡失效后普通重算丢失取消意图。 */
|
|
164
|
+
promotionSelectionStrategyIds?: string[];
|
|
161
165
|
isDisabled?: boolean;
|
|
162
166
|
isSelected?: boolean;
|
|
163
167
|
isAvailable?: boolean;
|