@pisell/pisellos 2.2.259 → 2.2.261
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/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 +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/utils.js +2 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +34 -14
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- 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 +2 -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/Order/index.d.ts +1 -1
- package/lib/modules/Order/utils.js +6 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +23 -4
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@ export declare const PROMOTION_ACTION_TYPES: {
|
|
|
12
12
|
readonly X_ITEMS_FOR_Y_PRICE: "X_ITEMS_FOR_Y_PRICE";
|
|
13
13
|
/** 买X送Y(买X件送Y件,可累计) */
|
|
14
14
|
readonly BUY_X_GET_Y_FREE: "BUY_X_GET_Y_FREE";
|
|
15
|
+
/** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
|
|
16
|
+
readonly ITEM_REWARD: "ITEM_REWARD";
|
|
15
17
|
/** 固定折扣 */
|
|
16
18
|
readonly DISCOUNT_RATE: "DISCOUNT_RATE";
|
|
17
19
|
/** 固定减价 */
|
|
@@ -66,6 +68,59 @@ export interface BuyXGetYFreeConfig {
|
|
|
66
68
|
/** 可选的赠品列表 */
|
|
67
69
|
giftProducts?: ProductIdentifier[];
|
|
68
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* 商品奖励优惠方式
|
|
73
|
+
*
|
|
74
|
+
* - free: 目标商品最终价为 0
|
|
75
|
+
* - percent_off: 目标商品按百分比折扣,rewardValue 为 0-100
|
|
76
|
+
* - amount_off: 每个目标商品固定减免 rewardValue
|
|
77
|
+
* - fixed_price: 目标商品改为固定价 rewardValue
|
|
78
|
+
*/
|
|
79
|
+
export type ItemRewardMethod = 'free' | 'percent_off' | 'amount_off' | 'fixed_price';
|
|
80
|
+
/**
|
|
81
|
+
* 商品奖励数量规则
|
|
82
|
+
*
|
|
83
|
+
* - per_condition_quantity: 每满足 N 个条件商品,奖励 Y 个目标商品
|
|
84
|
+
* - all_targets: 满足条件后奖励全部目标商品
|
|
85
|
+
* - max_per_order: 满足条件后每单最多奖励固定数量目标商品
|
|
86
|
+
*/
|
|
87
|
+
export type ItemRewardQuantityRule = 'per_condition_quantity' | 'all_targets' | 'max_per_order';
|
|
88
|
+
/** 商品奖励目标选择规则 */
|
|
89
|
+
export type ItemRewardTargetSelection = 'consumer_best';
|
|
90
|
+
/**
|
|
91
|
+
* 商品奖励 - Action Value
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* value: {
|
|
95
|
+
* rewardMethod: 'free',
|
|
96
|
+
* quantityRule: 'per_condition_quantity',
|
|
97
|
+
* triggerQuantity: 1,
|
|
98
|
+
* rewardQuantity: 1,
|
|
99
|
+
* }
|
|
100
|
+
*/
|
|
101
|
+
export interface ItemRewardValue {
|
|
102
|
+
/** 奖励方式 */
|
|
103
|
+
rewardMethod: ItemRewardMethod;
|
|
104
|
+
/** 奖励值:percent_off/amount_off/fixed_price 使用,free 可省略 */
|
|
105
|
+
rewardValue?: number;
|
|
106
|
+
/** 奖励数量规则 */
|
|
107
|
+
quantityRule: ItemRewardQuantityRule;
|
|
108
|
+
/** 每满足 N 个条件商品;默认 1 */
|
|
109
|
+
triggerQuantity?: number;
|
|
110
|
+
/** 奖励 Y 个目标商品;默认 1 */
|
|
111
|
+
rewardQuantity?: number;
|
|
112
|
+
/** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
|
|
113
|
+
maxRewardQuantity?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 商品奖励 - Action Config
|
|
117
|
+
*/
|
|
118
|
+
export interface ItemRewardConfig {
|
|
119
|
+
/** 奖励对象,本期支持指定商品/变体;product_variant_id=0 表示任意变体 */
|
|
120
|
+
rewardTargets?: ProductIdentifier[];
|
|
121
|
+
/** 目标商品超额时的选择规则;本期支持 consumer_best */
|
|
122
|
+
targetSelection?: ItemRewardTargetSelection;
|
|
123
|
+
}
|
|
69
124
|
/**
|
|
70
125
|
* 商品标识
|
|
71
126
|
*
|
|
@@ -102,10 +157,19 @@ export interface BuyXGetYFreeAction extends Omit<ActionEffect, 'type' | 'value'
|
|
|
102
157
|
valueType: 'object';
|
|
103
158
|
config?: BuyXGetYFreeConfig;
|
|
104
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* 商品奖励 Action
|
|
162
|
+
*/
|
|
163
|
+
export interface ItemRewardAction extends Omit<ActionEffect, 'type' | 'value' | 'config'> {
|
|
164
|
+
type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
|
|
165
|
+
value: ItemRewardValue;
|
|
166
|
+
valueType: 'object';
|
|
167
|
+
config?: ItemRewardConfig;
|
|
168
|
+
}
|
|
105
169
|
/**
|
|
106
170
|
* 促销活动 Action 联合类型
|
|
107
171
|
*/
|
|
108
|
-
export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction;
|
|
172
|
+
export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction | ItemRewardAction;
|
|
109
173
|
/**
|
|
110
174
|
* 促销相关运算符
|
|
111
175
|
*/
|
|
@@ -170,6 +234,8 @@ export interface PromotionProduct {
|
|
|
170
234
|
quantity: number;
|
|
171
235
|
/** 原价 */
|
|
172
236
|
original_price?: number;
|
|
237
|
+
/** 内部字段:编辑态订单行只允许参与 ITEM_REWARD,避免旧促销误算历史行 */
|
|
238
|
+
_promotionOnlyForItemReward?: boolean;
|
|
173
239
|
}
|
|
174
240
|
/**
|
|
175
241
|
* 促销活动适配器转换结果
|
|
@@ -195,7 +261,7 @@ export interface PromotionTransformResult {
|
|
|
195
261
|
/**
|
|
196
262
|
* Action 详情联合类型
|
|
197
263
|
*/
|
|
198
|
-
export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail;
|
|
264
|
+
export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail | ItemRewardActionDetail;
|
|
199
265
|
/**
|
|
200
266
|
* X件Y元 Action 详情
|
|
201
267
|
*/
|
|
@@ -226,6 +292,28 @@ export interface BuyXGetYFreeActionDetail {
|
|
|
226
292
|
/** 可选的赠品列表 */
|
|
227
293
|
giftProducts: ProductIdentifier[];
|
|
228
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* 商品奖励 Action 详情
|
|
297
|
+
*/
|
|
298
|
+
export interface ItemRewardActionDetail {
|
|
299
|
+
type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
|
|
300
|
+
/** 奖励方式 */
|
|
301
|
+
rewardMethod: ItemRewardMethod;
|
|
302
|
+
/** 奖励值:percent_off/amount_off/fixed_price 使用,free 为 0 */
|
|
303
|
+
rewardValue: number;
|
|
304
|
+
/** 奖励数量规则 */
|
|
305
|
+
quantityRule: ItemRewardQuantityRule;
|
|
306
|
+
/** 每满足 N 个条件商品;默认 1 */
|
|
307
|
+
triggerQuantity: number;
|
|
308
|
+
/** 奖励 Y 个目标商品;默认 1 */
|
|
309
|
+
rewardQuantity: number;
|
|
310
|
+
/** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
|
|
311
|
+
maxRewardQuantity?: number;
|
|
312
|
+
/** 奖励对象,本期支持指定商品/变体 */
|
|
313
|
+
rewardTargets: ProductIdentifier[];
|
|
314
|
+
/** 目标商品超额时的选择规则 */
|
|
315
|
+
targetSelection: ItemRewardTargetSelection;
|
|
316
|
+
}
|
|
229
317
|
/**
|
|
230
318
|
* X件Y元 - 业务层计算结果
|
|
231
319
|
*
|
|
@@ -16,6 +16,8 @@ export var PROMOTION_ACTION_TYPES = {
|
|
|
16
16
|
X_ITEMS_FOR_Y_PRICE: 'X_ITEMS_FOR_Y_PRICE',
|
|
17
17
|
/** 买X送Y(买X件送Y件,可累计) */
|
|
18
18
|
BUY_X_GET_Y_FREE: 'BUY_X_GET_Y_FREE',
|
|
19
|
+
/** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
|
|
20
|
+
ITEM_REWARD: 'ITEM_REWARD',
|
|
19
21
|
/** 固定折扣 */
|
|
20
22
|
DISCOUNT_RATE: 'DISCOUNT_RATE',
|
|
21
23
|
/** 固定减价 */
|
|
@@ -54,6 +56,41 @@ export var PROMOTION_ACTION_TYPES = {
|
|
|
54
56
|
* 买X送Y - Action Config
|
|
55
57
|
*/
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* 商品奖励优惠方式
|
|
61
|
+
*
|
|
62
|
+
* - free: 目标商品最终价为 0
|
|
63
|
+
* - percent_off: 目标商品按百分比折扣,rewardValue 为 0-100
|
|
64
|
+
* - amount_off: 每个目标商品固定减免 rewardValue
|
|
65
|
+
* - fixed_price: 目标商品改为固定价 rewardValue
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 商品奖励数量规则
|
|
70
|
+
*
|
|
71
|
+
* - per_condition_quantity: 每满足 N 个条件商品,奖励 Y 个目标商品
|
|
72
|
+
* - all_targets: 满足条件后奖励全部目标商品
|
|
73
|
+
* - max_per_order: 满足条件后每单最多奖励固定数量目标商品
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/** 商品奖励目标选择规则 */
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 商品奖励 - Action Value
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* value: {
|
|
83
|
+
* rewardMethod: 'free',
|
|
84
|
+
* quantityRule: 'per_condition_quantity',
|
|
85
|
+
* triggerQuantity: 1,
|
|
86
|
+
* rewardQuantity: 1,
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 商品奖励 - Action Config
|
|
92
|
+
*/
|
|
93
|
+
|
|
57
94
|
// ============================================
|
|
58
95
|
// 商品标识
|
|
59
96
|
// ============================================
|
|
@@ -78,6 +115,10 @@ export var PROMOTION_ACTION_TYPES = {
|
|
|
78
115
|
* 买X送Y Action
|
|
79
116
|
*/
|
|
80
117
|
|
|
118
|
+
/**
|
|
119
|
+
* 商品奖励 Action
|
|
120
|
+
*/
|
|
121
|
+
|
|
81
122
|
/**
|
|
82
123
|
* 促销活动 Action 联合类型
|
|
83
124
|
*/
|
|
@@ -146,6 +187,10 @@ var obj = {
|
|
|
146
187
|
* 买X送Y Action 详情
|
|
147
188
|
*/
|
|
148
189
|
|
|
190
|
+
/**
|
|
191
|
+
* 商品奖励 Action 详情
|
|
192
|
+
*/
|
|
193
|
+
|
|
149
194
|
// ============================================
|
|
150
195
|
// 业务层输出类型(供参考)
|
|
151
196
|
// ============================================
|
|
@@ -461,7 +461,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
461
461
|
generateIdempotencyToken(): string;
|
|
462
462
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
463
463
|
createOrder(params: CommitOrderParams['query']): {
|
|
464
|
-
type: "
|
|
464
|
+
type: "appointment_booking" | "virtual";
|
|
465
465
|
platform: string;
|
|
466
466
|
sales_channel: string;
|
|
467
467
|
order_sales_channel: string;
|
|
@@ -544,7 +544,8 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
544
544
|
return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
545
545
|
}, 0);
|
|
546
546
|
var hasPromoDiscountItem = discountList.some(function (item) {
|
|
547
|
-
|
|
547
|
+
var _item$metadata, _item$metadata2;
|
|
548
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'promotion' || (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';
|
|
548
549
|
});
|
|
549
550
|
if (hasPromoDiscountItem) return fromList;
|
|
550
551
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -36,6 +36,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
36
36
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
37
37
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
38
38
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
39
|
+
private isItemRewardProductDiscount;
|
|
39
40
|
private getUnavailableReason;
|
|
40
41
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
41
42
|
discountList: Discount[];
|
|
@@ -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",
|
|
@@ -698,6 +709,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
698
709
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
699
710
|
};
|
|
700
711
|
}
|
|
712
|
+
if (_this3.isItemRewardProductDiscount(product)) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
701
715
|
|
|
702
716
|
// 编辑的商品使用了优惠券不可用
|
|
703
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) {
|
|
@@ -884,6 +898,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
884
898
|
};
|
|
885
899
|
originProduct = flatItem.originProduct;
|
|
886
900
|
}
|
|
901
|
+
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
887
902
|
addModeDiscount.forEach(function (discount) {
|
|
888
903
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
889
904
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -909,7 +924,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
909
924
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
910
925
|
|
|
911
926
|
// 判断优惠券是否适用于该商品
|
|
912
|
-
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) {
|
|
913
928
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
914
929
|
// 记录此优惠券适用的商品
|
|
915
930
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1054,6 +1069,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1054
1069
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1055
1070
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1056
1071
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1072
|
+
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1057
1073
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1058
1074
|
var discountType = discount.tag || discount.type;
|
|
1059
1075
|
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
|
|
@@ -1134,6 +1150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1134
1150
|
|
|
1135
1151
|
// 如果是手动折扣,则不适用优惠券
|
|
1136
1152
|
var isManualDiscount = false;
|
|
1153
|
+
var isItemRewardProductDiscount = false;
|
|
1137
1154
|
if (flatItem.type === 'main') {
|
|
1138
1155
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1139
1156
|
// 主商品:判断自身是否手动折扣
|
|
@@ -1145,7 +1162,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1145
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) {
|
|
1146
1163
|
return item.type === 'product';
|
|
1147
1164
|
})));
|
|
1148
|
-
|
|
1165
|
+
isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
1166
|
+
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1149
1167
|
isManualDiscount = false;
|
|
1150
1168
|
}
|
|
1151
1169
|
} else {
|
|
@@ -1255,15 +1273,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1255
1273
|
var main_product_selling_price = product.price;
|
|
1256
1274
|
if ((product.discount_list || []).some(function (item) {
|
|
1257
1275
|
return item.type === 'promotion';
|
|
1258
|
-
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1276
|
+
}) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1259
1277
|
var _product$total, _product$main_product;
|
|
1260
1278
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1261
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;
|
|
1262
1280
|
}
|
|
1263
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1281
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
|
|
1264
1282
|
price: product.price,
|
|
1265
|
-
main_product_selling_price: product.price
|
|
1266
|
-
}
|
|
1283
|
+
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
|
|
1284
|
+
}, isItemRewardProductDiscount ? {
|
|
1285
|
+
total: total
|
|
1286
|
+
} : {}) : {
|
|
1267
1287
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1268
1288
|
total: total,
|
|
1269
1289
|
price: product.price,
|
|
@@ -1704,11 +1724,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1704
1724
|
processedItems.forEach(function (item) {
|
|
1705
1725
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1706
1726
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1707
|
-
var _item$
|
|
1727
|
+
var _item$metadata3;
|
|
1708
1728
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1709
1729
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1710
1730
|
num: item.num,
|
|
1711
|
-
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
|
|
1712
1732
|
})
|
|
1713
1733
|
// num: item.num, // 使用拆分后的 num
|
|
1714
1734
|
});
|
|
@@ -1727,11 +1747,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1747
|
if (item.processed) {
|
|
1728
1748
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1729
1749
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1730
|
-
var _item$
|
|
1750
|
+
var _item$metadata4;
|
|
1731
1751
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1732
1752
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1733
1753
|
num: item.num,
|
|
1734
|
-
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
|
|
1735
1755
|
})
|
|
1736
1756
|
// num: item.num, // 使用当前的 num
|
|
1737
1757
|
});
|
|
@@ -1772,8 +1792,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1772
1792
|
|
|
1773
1793
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1774
1794
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1775
|
-
var _item$
|
|
1776
|
-
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);
|
|
1777
1797
|
});
|
|
1778
1798
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1779
1799
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1846,8 +1866,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1846
1866
|
|
|
1847
1867
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1848
1868
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1849
|
-
var _item$
|
|
1850
|
-
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);
|
|
1851
1871
|
});
|
|
1852
1872
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1853
1873
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -78,6 +78,7 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
+
getStrategyConfigs?: () => unknown[];
|
|
81
82
|
}
|
|
82
83
|
/** 单个赠品减量项 */
|
|
83
84
|
export interface GiftReduceItem {
|
|
@@ -267,7 +268,8 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
267
268
|
* 处理购物车的促销计算与赠品差异化。
|
|
268
269
|
*
|
|
269
270
|
* 流程:
|
|
270
|
-
* 1. 分离 main / gift / edit-product
|
|
271
|
+
* 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
|
|
272
|
+
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
271
273
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
272
274
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
273
275
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|