@pisell/pisellos 2.3.173 → 2.3.174
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 +14 -8
- package/dist/modules/Product/index.d.ts +1 -1
- 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 +13 -7
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Product/index.d.ts +1 -1
- 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,
|
|
@@ -911,6 +913,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
911
913
|
|
|
912
914
|
// 更新已处理数量
|
|
913
915
|
processedQuantityMap.set(_key, _processedQty + _availableQty);
|
|
916
|
+
xItemsProcessedQuantityMap.set(_key, (xItemsProcessedQuantityMap.get(_key) || 0) + _availableQty);
|
|
914
917
|
}
|
|
915
918
|
|
|
916
919
|
// 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
|
|
@@ -1117,7 +1120,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1117
1120
|
*/
|
|
1118
1121
|
}, {
|
|
1119
1122
|
key: "processItemReward",
|
|
1120
|
-
value: function processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
|
|
1123
|
+
value: function processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
1121
1124
|
var _this4 = this;
|
|
1122
1125
|
var strategyId = group.strategyId,
|
|
1123
1126
|
strategyMetadata = group.strategyMetadata,
|
|
@@ -1126,7 +1129,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1126
1129
|
var detail = actionDetail;
|
|
1127
1130
|
var triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
|
|
1128
1131
|
var rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
|
|
1129
|
-
var conditionQuantity = this.
|
|
1132
|
+
var conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
1130
1133
|
if (conditionQuantity < triggerQuantity) {
|
|
1131
1134
|
return {
|
|
1132
1135
|
products: [],
|
|
@@ -1242,9 +1245,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1242
1245
|
var n = Math.floor(Number(value));
|
|
1243
1246
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
1244
1247
|
}
|
|
1248
|
+
|
|
1249
|
+
/** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
|
|
1245
1250
|
}, {
|
|
1246
|
-
key: "
|
|
1247
|
-
value: function
|
|
1251
|
+
key: "getItemRewardTriggerQuantity",
|
|
1252
|
+
value: function getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
1248
1253
|
var total = 0;
|
|
1249
1254
|
var _iterator19 = _createForOfIteratorHelper(products),
|
|
1250
1255
|
_step19;
|
|
@@ -1253,7 +1258,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
1253
1258
|
var product = _step19.value;
|
|
1254
1259
|
var key = this.getProductKey(product);
|
|
1255
1260
|
var processedQty = processedQuantityMap.get(key) || 0;
|
|
1256
|
-
var
|
|
1261
|
+
var xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
|
|
1262
|
+
var availableQty = product.quantity - processedQty + xItemsProcessedQty;
|
|
1257
1263
|
if (availableQty <= 0) continue;
|
|
1258
1264
|
var matchedBundleIndex = matchedBundleIndexMap === null || matchedBundleIndexMap === void 0 ? void 0 : matchedBundleIndexMap.get(product.id);
|
|
1259
1265
|
if (matchedBundleIndex !== undefined && product.bundle) {
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "normal" | "session";
|
|
53
53
|
}
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -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;
|
|
@@ -313,6 +313,8 @@ class PromotionEvaluator {
|
|
|
313
313
|
// 3. 追踪已处理的商品(避免重复处理)
|
|
314
314
|
// key: `${product_id}_${product_variant_id}`
|
|
315
315
|
const processedQuantityMap = new Map();
|
|
316
|
+
// X件Y元处理过的数量仍可作为商品奖励的触发条件。
|
|
317
|
+
const xItemsProcessedQuantityMap = new Map();
|
|
316
318
|
|
|
317
319
|
// 4. 处理每个促销组,收集结果
|
|
318
320
|
const pricedProducts = [];
|
|
@@ -328,7 +330,7 @@ class PromotionEvaluator {
|
|
|
328
330
|
const matchedBundleIndexMap = group.productMatchedBundleIndexMap || new Map();
|
|
329
331
|
if (actionType === _type.PROMOTION_ACTION_TYPES.X_ITEMS_FOR_Y_PRICE) {
|
|
330
332
|
// X件Y元处理
|
|
331
|
-
const result = this.processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap);
|
|
333
|
+
const result = this.processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
332
334
|
pricedProducts.push(...result.products);
|
|
333
335
|
totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
|
|
334
336
|
totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
|
|
@@ -345,7 +347,7 @@ class PromotionEvaluator {
|
|
|
345
347
|
}
|
|
346
348
|
} else if (actionType === _type.PROMOTION_ACTION_TYPES.ITEM_REWARD) {
|
|
347
349
|
// 商品奖励处理:条件商品触发,目标商品行享优惠,不自动新增商品
|
|
348
|
-
const result = this.processItemReward(group, processedQuantityMap, products, matchedBundleIndexMap);
|
|
350
|
+
const result = this.processItemReward(group, processedQuantityMap, products, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
349
351
|
pricedProducts.push(...result.products);
|
|
350
352
|
totalOriginalAmount = totalOriginalAmount.plus(result.originalAmount);
|
|
351
353
|
totalFinalAmount = totalFinalAmount.plus(result.finalAmount);
|
|
@@ -566,7 +568,7 @@ class PromotionEvaluator {
|
|
|
566
568
|
*
|
|
567
569
|
* 注意:每个商品按 id 独立处理,不会合并不同 id 的商品
|
|
568
570
|
*/
|
|
569
|
-
processXItemsForYPrice(group, processedQuantityMap, matchedBundleIndexMap) {
|
|
571
|
+
processXItemsForYPrice(group, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
570
572
|
const {
|
|
571
573
|
strategyId,
|
|
572
574
|
strategyMetadata,
|
|
@@ -759,6 +761,7 @@ class PromotionEvaluator {
|
|
|
759
761
|
|
|
760
762
|
// 更新已处理数量
|
|
761
763
|
processedQuantityMap.set(key, processedQty + availableQty);
|
|
764
|
+
xItemsProcessedQuantityMap.set(key, (xItemsProcessedQuantityMap.get(key) || 0) + availableQty);
|
|
762
765
|
}
|
|
763
766
|
|
|
764
767
|
// 8. 尾差调整:只补实际组价的舍入差额,不将高于原价的组价补到某一件。
|
|
@@ -922,7 +925,7 @@ class PromotionEvaluator {
|
|
|
922
925
|
* 4. 按消费者最优(可节省金额从高到低)选择目标单位
|
|
923
926
|
* 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
|
|
924
927
|
*/
|
|
925
|
-
processItemReward(group, processedQuantityMap, allProducts, matchedBundleIndexMap) {
|
|
928
|
+
processItemReward(group, processedQuantityMap, allProducts, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
926
929
|
const {
|
|
927
930
|
strategyId,
|
|
928
931
|
strategyMetadata,
|
|
@@ -932,7 +935,7 @@ class PromotionEvaluator {
|
|
|
932
935
|
const detail = actionDetail;
|
|
933
936
|
const triggerQuantity = this.normalizePositiveInteger(detail.triggerQuantity, 1);
|
|
934
937
|
const rewardQuantity = this.normalizePositiveInteger(detail.rewardQuantity, 1);
|
|
935
|
-
const conditionQuantity = this.
|
|
938
|
+
const conditionQuantity = this.getItemRewardTriggerQuantity(triggerProducts, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap);
|
|
936
939
|
if (conditionQuantity < triggerQuantity) {
|
|
937
940
|
return {
|
|
938
941
|
products: [],
|
|
@@ -1028,12 +1031,15 @@ class PromotionEvaluator {
|
|
|
1028
1031
|
const n = Math.floor(Number(value));
|
|
1029
1032
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
1030
1033
|
}
|
|
1031
|
-
|
|
1034
|
+
|
|
1035
|
+
/** 仅放开 X件Y元处理过的触发数量,奖励目标仍按全部已处理数量互斥。 */
|
|
1036
|
+
getItemRewardTriggerQuantity(products, processedQuantityMap, xItemsProcessedQuantityMap, matchedBundleIndexMap) {
|
|
1032
1037
|
let total = 0;
|
|
1033
1038
|
for (const product of products) {
|
|
1034
1039
|
const key = this.getProductKey(product);
|
|
1035
1040
|
const processedQty = processedQuantityMap.get(key) || 0;
|
|
1036
|
-
const
|
|
1041
|
+
const xItemsProcessedQty = xItemsProcessedQuantityMap.get(key) || 0;
|
|
1042
|
+
const availableQty = product.quantity - processedQty + xItemsProcessedQty;
|
|
1037
1043
|
if (availableQty <= 0) continue;
|
|
1038
1044
|
const matchedBundleIndex = matchedBundleIndexMap?.get(product.id);
|
|
1039
1045
|
if (matchedBundleIndex !== undefined && product.bundle) {
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "normal" | "session";
|
|
53
53
|
}
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|