@pisell/pisellos 2.2.178 → 2.2.179
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/index.js +9 -0
- package/dist/modules/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +18 -88
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +18 -88
- package/lib/modules/Order/index.js +149 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import type { OrderProduct } from '../../../modules/Order/types';
|
|
2
|
-
/**
|
|
3
|
-
* Cart promotion 工具集(OS 内部纯函数)
|
|
4
|
-
*
|
|
5
|
-
* 这是 `private-materials/components/booking/hooks/usePromotion.ts` 中促销/赠品
|
|
6
|
-
* 核心计算(evaluator → 拆分 / 计价 → 赠品差异化 / 未满足提示 / 标签)的 OS 等价实现。
|
|
7
|
-
*
|
|
8
|
-
* 与 legacy 的关键差异:
|
|
9
|
-
* - legacy 操作 booking `_extend.*` 形状;OS 操作 `OrderProduct.metadata.*` 形状。
|
|
10
|
-
* - 行唯一标识不再用 `_id`,统一改用 `metadata.unique_identification_number`。
|
|
11
|
-
* - 赠品标签存到 `metadata._giftInfo`;主商品促销信息存到 `metadata._promotion`;
|
|
12
|
-
* 商品卡列表的促销 tag 存到 `metadata._promotionTags`。
|
|
13
|
-
*
|
|
14
|
-
* 仅暴露纯函数,不持有任何状态;评估器以参数注入。
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const evaluator = appHelper.utils.promotionEvaluator;
|
|
18
|
-
* const result = processCartPromotion(tempOrder.products, evaluator);
|
|
19
|
-
* // result.products: 处理后的商品(带 _promotion / 拆分)
|
|
20
|
-
* // result.giftActions: 需要 add / reduce / remove 的赠品操作
|
|
21
|
-
* // result.unfulfilledPromotions: 未满足策略列表(购物车底部 alert)
|
|
22
|
-
*/
|
|
23
|
-
/** Cart 评估器协议(只描述本文件用到的方法,避免循环依赖) */
|
|
24
|
-
export interface CartPromotionEvaluator {
|
|
25
|
-
evaluateCartWithPricing(input: {
|
|
26
|
-
products: any[];
|
|
27
|
-
channel?: string;
|
|
28
|
-
}): {
|
|
29
|
-
products: Array<{
|
|
30
|
-
id: number;
|
|
31
|
-
originalId?: number;
|
|
32
|
-
product_id: number;
|
|
33
|
-
product_variant_id: number;
|
|
34
|
-
quantity: number;
|
|
35
|
-
price: number;
|
|
36
|
-
finalPrice: number;
|
|
37
|
-
strategyId?: string;
|
|
38
|
-
strategyMetadata?: any;
|
|
39
|
-
inPromotion: boolean;
|
|
40
|
-
isSplit?: boolean;
|
|
41
|
-
matchedBundleIndex?: number;
|
|
42
|
-
bundle?: any[];
|
|
43
|
-
_originalItem?: any;
|
|
44
|
-
_originalId?: string;
|
|
45
|
-
_originalIndex?: number;
|
|
46
|
-
}>;
|
|
47
|
-
gifts: Array<{
|
|
48
|
-
strategyId: string;
|
|
49
|
-
strategyName: string | Record<string, string>;
|
|
50
|
-
giftCount: number;
|
|
51
|
-
giftOptions: Array<{
|
|
52
|
-
product_id: number;
|
|
53
|
-
product_variant_id: number;
|
|
54
|
-
}>;
|
|
55
|
-
}>;
|
|
56
|
-
totalDiscount: number;
|
|
57
|
-
};
|
|
58
|
-
getProductsApplicableStrategies(input: {
|
|
59
|
-
products: any[];
|
|
60
|
-
channel?: string;
|
|
61
|
-
}, matchVariant?: boolean): Array<{
|
|
62
|
-
product: any;
|
|
63
|
-
applicableStrategies: Array<{
|
|
64
|
-
strategyId: string;
|
|
65
|
-
strategyName: string | Record<string, string>;
|
|
66
|
-
strategyMetadata: any;
|
|
67
|
-
actionType: string;
|
|
68
|
-
actionDetail: any;
|
|
69
|
-
display?: {
|
|
70
|
-
text: string | Record<string, string>;
|
|
71
|
-
type: string;
|
|
72
|
-
};
|
|
73
|
-
requiredQuantity: number;
|
|
74
|
-
eligibleProducts: Array<{
|
|
75
|
-
product_id: number;
|
|
76
|
-
product_variant_id: number;
|
|
77
|
-
}>;
|
|
78
|
-
}>;
|
|
79
|
-
hasApplicableStrategy: boolean;
|
|
80
|
-
}>;
|
|
81
|
-
}
|
|
82
|
-
/** 单个赠品减量项 */
|
|
83
|
-
export interface GiftReduceItem {
|
|
84
|
-
/** 赠品行的 `metadata.unique_identification_number` */
|
|
85
|
-
uid: string;
|
|
86
|
-
currentQuantity: number;
|
|
87
|
-
/** 目标数量(>0;==0 走 toRemove) */
|
|
88
|
-
newQuantity: number;
|
|
89
|
-
}
|
|
90
|
-
/** 赠品新增项 */
|
|
91
|
-
export interface GiftToAddAction {
|
|
92
|
-
strategyId: string;
|
|
93
|
-
strategyName: string | Record<string, string>;
|
|
94
|
-
giftCount: number;
|
|
95
|
-
giftOptions: Array<{
|
|
96
|
-
product_id: number;
|
|
97
|
-
product_variant_id: number;
|
|
98
|
-
}>;
|
|
99
|
-
/** 触发此赠品的主商品 uid 列表 */
|
|
100
|
-
sourceProductIds: string[];
|
|
101
|
-
}
|
|
102
|
-
/** 赠品操作集合(OS 侧根据它落地 tempOrder.products) */
|
|
103
|
-
export interface GiftActions {
|
|
104
|
-
toAdd: GiftToAddAction[];
|
|
105
|
-
toReduce: Array<{
|
|
106
|
-
strategyId: string;
|
|
107
|
-
items: GiftReduceItem[];
|
|
108
|
-
}>;
|
|
109
|
-
/** 需要删除的赠品 uid 列表 */
|
|
110
|
-
toRemove: string[];
|
|
111
|
-
}
|
|
112
|
-
/** 未满足促销提示项(购物车底部 alert 数据源) */
|
|
113
|
-
export interface UnfulfilledPromotion {
|
|
114
|
-
strategyId: string;
|
|
115
|
-
strategyName: string | Record<string, string>;
|
|
116
|
-
actionType: string;
|
|
117
|
-
/** 还差几件 */
|
|
118
|
-
needQuantity: number;
|
|
119
|
-
/** 当前已选几件 */
|
|
120
|
-
currentQuantity: number;
|
|
121
|
-
/** 凑齐促销所需件数 */
|
|
122
|
-
requiredQuantity: number;
|
|
123
|
-
/** 可参与本促销的商品列表 */
|
|
124
|
-
eligibleProducts: Array<{
|
|
125
|
-
product_id: number;
|
|
126
|
-
product_variant_id: number;
|
|
127
|
-
}>;
|
|
128
|
-
strategyMetadata?: any;
|
|
129
|
-
display?: {
|
|
130
|
-
text: string | Record<string, string>;
|
|
131
|
-
type: string;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/** 商品卡促销标签结构(写入 `metadata._promotionTags`) */
|
|
135
|
-
export interface PromotionTag {
|
|
136
|
-
text: string | Record<string, string>;
|
|
137
|
-
type: string;
|
|
138
|
-
strategyId?: string;
|
|
139
|
-
}
|
|
140
|
-
/** processCartPromotion 输出 */
|
|
141
|
-
export interface ProcessCartPromotionResult {
|
|
142
|
-
/** 处理后的商品列表(含拆分行、_promotion / _giftInfo 元数据) */
|
|
143
|
-
products: OrderProduct[];
|
|
144
|
-
totalDiscount: number;
|
|
145
|
-
gifts: Array<GiftToAddAction>;
|
|
146
|
-
giftActions: GiftActions;
|
|
147
|
-
unfulfilledPromotions: UnfulfilledPromotion[];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* 获取商品的「主商品基础价」用于评估器入参。
|
|
151
|
-
*
|
|
152
|
-
* 优先级(与 OS v2 schema 一致):
|
|
153
|
-
* 1. `metadata.source_product_price`
|
|
154
|
-
* 2. `metadata.main_product_original_price` 减去 option 合计
|
|
155
|
-
* 3. `original_price`
|
|
156
|
-
*/
|
|
157
|
-
export declare function getOrderProductBasePrice(product: any): number;
|
|
158
|
-
/**
|
|
159
|
-
* 促销均摊专用原价(对齐 legacy `getMainOriginalPrice` 语义)。
|
|
160
|
-
*
|
|
161
|
-
* 必须用券前原价做 X_ITEMS_FOR_Y_PRICE 比例拆分;`source_product_price` 在上一轮 applyPromotion
|
|
162
|
-
* 后可能已被写成促销价(如 5 / 9 / 1),若继续用它会导致同商品两行出现 9+1 而非 5+5。
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* getOrderProductOriginalPriceForPromotion({ metadata: { source_product_price: '9', main_product_original_price: '5.80' } });
|
|
166
|
-
* // => 5.8
|
|
167
|
-
*/
|
|
168
|
-
export declare function getOrderProductOriginalPriceForPromotion(product: any): number;
|
|
169
|
-
/**
|
|
170
|
-
* 合并「同商品 + 同规格指纹 + 同促销策略 + 同促销单价」的参与促销行(num 累加)。
|
|
171
|
-
* 避免 Browse Items 连续加购同款时拆成多行且单价被错误均摊。
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* mergeIdenticalPromotionCartLines(processedProducts);
|
|
175
|
-
*/
|
|
176
|
-
export declare function mergeIdenticalPromotionCartLines(products: any[]): any[];
|
|
177
|
-
/** 获取行 uid(统一以 `metadata.unique_identification_number` 为唯一键) */
|
|
178
|
-
export declare function getOrderProductUid(product: any): string;
|
|
179
|
-
/**
|
|
180
|
-
* 从策略配置的 product_match 规则提取可参与商品列表。
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* extractProductMatchIdentifiersFromStrategyConfig(strategyConfig);
|
|
184
|
-
* // => [{ product_id: 60736, product_variant_id: 0 }]
|
|
185
|
-
*/
|
|
186
|
-
export declare function extractProductMatchIdentifiersFromStrategyConfig(strategyConfig: any): Array<{
|
|
187
|
-
product_id: number;
|
|
188
|
-
product_variant_id: number;
|
|
189
|
-
}>;
|
|
190
|
-
/**
|
|
191
|
-
* 解析策略凑单所需件数(evaluator 原始返回可能不含 requiredQuantity)。
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* resolveStrategyRequiredQuantity({ actionType: 'X_ITEMS_FOR_Y_PRICE', actionDetail: { x: 2 } });
|
|
195
|
-
*/
|
|
196
|
-
export declare function resolveStrategyRequiredQuantity(matched: {
|
|
197
|
-
requiredQuantity?: number;
|
|
198
|
-
actionType?: string;
|
|
199
|
-
actionDetail?: any;
|
|
200
|
-
}): number;
|
|
201
|
-
/**
|
|
202
|
-
* 解析 Browse Items 弹窗候选商品(优先 eligibleProducts,否则读 strategyConfig)。
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* resolveStrategyEligibleProducts(matchedStrategy);
|
|
206
|
-
*/
|
|
207
|
-
export declare function resolveStrategyEligibleProducts(matched: {
|
|
208
|
-
eligibleProducts?: Array<{
|
|
209
|
-
product_id: number;
|
|
210
|
-
product_variant_id: number;
|
|
211
|
-
}>;
|
|
212
|
-
strategyConfig?: any;
|
|
213
|
-
}): Array<{
|
|
214
|
-
product_id: number;
|
|
215
|
-
product_variant_id: number;
|
|
216
|
-
}>;
|
|
217
|
-
/**
|
|
218
|
-
* 计算未满足促销条件(用于购物车底部「再买 N 件即可享受 XX」alert)。
|
|
219
|
-
*
|
|
220
|
-
* 数据源:商品的 `metadata._promotion.inPromotion === false`(来自 processCartPromotion
|
|
221
|
-
* 第 8 步追加的「有适用策略但当前未参与促销」标记)。
|
|
222
|
-
*/
|
|
223
|
-
export declare function calculateUnfulfilledPromotions(processedProducts: any[], applicableStrategiesResult: Array<{
|
|
224
|
-
applicableStrategies: Array<{
|
|
225
|
-
strategyId: string;
|
|
226
|
-
strategyName: string | Record<string, string>;
|
|
227
|
-
strategyMetadata: any;
|
|
228
|
-
actionType: string;
|
|
229
|
-
requiredQuantity?: number;
|
|
230
|
-
eligibleProducts?: Array<{
|
|
231
|
-
product_id: number;
|
|
232
|
-
product_variant_id: number;
|
|
233
|
-
}>;
|
|
234
|
-
actionDetail?: any;
|
|
235
|
-
strategyConfig?: any;
|
|
236
|
-
display?: {
|
|
237
|
-
text: string | Record<string, string>;
|
|
238
|
-
type: string;
|
|
239
|
-
};
|
|
240
|
-
}>;
|
|
241
|
-
hasApplicableStrategy: boolean;
|
|
242
|
-
}>, mainProducts: any[]): UnfulfilledPromotion[];
|
|
243
|
-
/**
|
|
244
|
-
* 给商品列表追加促销标签(写入 `metadata._promotionTags`),供 ProductCard 渲染。
|
|
245
|
-
*
|
|
246
|
-
* - 没有适用策略的商品会清除 `_promotionTags`(避免脏数据)。
|
|
247
|
-
* - 仅基于 product_id 匹配(matchVariant=false),与商品卡通用场景对齐。
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* const list = appendPromotionTags(catalog, evaluator);
|
|
251
|
-
* // list[i].metadata._promotionTags = [{ text, type, strategyId }]
|
|
252
|
-
*/
|
|
253
|
-
export declare function appendPromotionTags<T extends Record<string, any>>(products: T[], evaluator: CartPromotionEvaluator | null | undefined): T[];
|
|
254
|
-
/**
|
|
255
|
-
* 处理购物车的促销计算与赠品差异化。
|
|
256
|
-
*
|
|
257
|
-
* 流程:
|
|
258
|
-
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
259
|
-
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
260
|
-
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
261
|
-
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|
|
262
|
-
* - 拆分的,生成新 uid,复制原行其它字段
|
|
263
|
-
* 4. 计算 `_giftInfo` 挂主商品(每个策略首个主商品)
|
|
264
|
-
* 5. 计算 `giftActions`(toAdd / toReduce / toRemove)
|
|
265
|
-
* 6. 计算 `unfulfilledPromotions`
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* const { products, giftActions, unfulfilledPromotions } = processCartPromotion(
|
|
269
|
-
* tempOrder.products,
|
|
270
|
-
* evaluator,
|
|
271
|
-
* );
|
|
272
|
-
*/
|
|
273
|
-
export declare function processCartPromotion(list: OrderProduct[] | null | undefined, evaluator: CartPromotionEvaluator | null | undefined, options?: {
|
|
274
|
-
channel?: string;
|
|
275
|
-
}): ProcessCartPromotionResult;
|