@pisell/pisellos 2.2.319 → 2.2.321
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/server/modules/order/index.js +2 -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 +13 -7
- package/lib/server/modules/order/index.js +2 -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,
|
|
@@ -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) {
|
|
@@ -541,7 +541,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
541
541
|
continue;
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
-
//
|
|
544
|
+
// 远端商品成员、Holder 关系或预约数据确实变化时必须落库,避免被回声窗口跳过。
|
|
545
545
|
if (forceWriteStorageKeys.has(storageKey)) {
|
|
546
546
|
toWrite.push(order);
|
|
547
547
|
continue;
|
|
@@ -3045,7 +3045,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3045
3045
|
mergedStorageKey = this.getOrderStorageKey(mergedOrder);
|
|
3046
3046
|
if (mergedStorageKey) forceWriteStorageKeys.add(mergedStorageKey);
|
|
3047
3047
|
}
|
|
3048
|
-
if (nextStorageKey && !isEqual(existingOrder.holder_relations, mergedOrder.holder_relations)) {
|
|
3048
|
+
if (nextStorageKey && (!isEqual(existingOrder.holder_relations, mergedOrder.holder_relations) || !isEqual(existingOrder.bookings, mergedOrder.bookings))) {
|
|
3049
3049
|
forceWriteStorageKeys.add(nextStorageKey);
|
|
3050
3050
|
}
|
|
3051
3051
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
|
|
@@ -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 | 1 | 2 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
347
347
|
count: number;
|
|
348
348
|
left: number;
|
|
349
349
|
summaryCount: number;
|
|
350
|
-
status: "
|
|
350
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
351
351
|
}[];
|
|
352
352
|
/**
|
|
353
353
|
* 找到多个资源的公共可用时间段
|
|
@@ -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) {
|
|
@@ -366,7 +366,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
366
366
|
continue;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
//
|
|
369
|
+
// 远端商品成员、Holder 关系或预约数据确实变化时必须落库,避免被回声窗口跳过。
|
|
370
370
|
if (forceWriteStorageKeys.has(storageKey)) {
|
|
371
371
|
toWrite.push(order);
|
|
372
372
|
continue;
|
|
@@ -1841,7 +1841,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1841
1841
|
const mergedStorageKey = this.getOrderStorageKey(mergedOrder);
|
|
1842
1842
|
if (mergedStorageKey) forceWriteStorageKeys.add(mergedStorageKey);
|
|
1843
1843
|
}
|
|
1844
|
-
if (nextStorageKey && !(0, _lodashEs.isEqual)(existingOrder.holder_relations, mergedOrder.holder_relations)) {
|
|
1844
|
+
if (nextStorageKey && (!(0, _lodashEs.isEqual)(existingOrder.holder_relations, mergedOrder.holder_relations) || !(0, _lodashEs.isEqual)(existingOrder.bookings, mergedOrder.bookings))) {
|
|
1845
1845
|
forceWriteStorageKeys.add(nextStorageKey);
|
|
1846
1846
|
}
|
|
1847
1847
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
|
|
@@ -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 | 1 | 2 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
347
347
|
count: number;
|
|
348
348
|
left: number;
|
|
349
349
|
summaryCount: number;
|
|
350
|
-
status: "
|
|
350
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
351
351
|
}[];
|
|
352
352
|
/**
|
|
353
353
|
* 找到多个资源的公共可用时间段
|