@pisell/pisellos 2.2.265 → 2.2.270
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- 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/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +10 -3
- package/dist/modules/Order/utils.js +2 -1
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +34 -14
- package/dist/solution/BaseSales/index.d.ts +14 -1
- package/dist/solution/BaseSales/index.js +36 -12
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -1
- package/dist/solution/BookingTicket/index.js +43 -31
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/dist/types/index.d.ts +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- 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 +0 -49
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +9 -3
- package/lib/modules/Order/utils.js +6 -1
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +23 -4
- package/lib/solution/BaseSales/index.d.ts +14 -1
- package/lib/solution/BaseSales/index.js +22 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -1
- package/lib/solution/BookingTicket/index.js +11 -3
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -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
|
// ============================================
|
|
@@ -27,6 +27,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
27
27
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
28
28
|
getOpenData(): OpenDataConfig | null;
|
|
29
29
|
getLastFetchedAt(): number | null;
|
|
30
|
+
/** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
|
|
31
|
+
clearCache(): void;
|
|
30
32
|
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
31
33
|
storeChange(): void;
|
|
32
34
|
}
|
|
@@ -166,6 +166,14 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
166
166
|
var _this$store$lastFetch;
|
|
167
167
|
return (_this$store$lastFetch = this.store.lastFetchedAt) !== null && _this$store$lastFetch !== void 0 ? _this$store$lastFetch : null;
|
|
168
168
|
}
|
|
169
|
+
|
|
170
|
+
/** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
|
|
171
|
+
}, {
|
|
172
|
+
key: "clearCache",
|
|
173
|
+
value: function clearCache() {
|
|
174
|
+
this.store.data = null;
|
|
175
|
+
this.store.lastFetchedAt = null;
|
|
176
|
+
}
|
|
169
177
|
}, {
|
|
170
178
|
key: "checkAvailability",
|
|
171
179
|
value: function checkAvailability(scheduleModule) {
|
|
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
485
485
|
generateIdempotencyToken(): string;
|
|
486
486
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
487
487
|
createOrder(params: CommitOrderParams['query']): {
|
|
488
|
-
type: "
|
|
488
|
+
type: "appointment_booking" | "virtual";
|
|
489
489
|
platform: string;
|
|
490
490
|
sales_channel: string;
|
|
491
491
|
order_sales_channel: string;
|
|
@@ -85,6 +85,10 @@ function isPaidPaymentRecord(payment) {
|
|
|
85
85
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
86
86
|
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
87
87
|
}
|
|
88
|
+
function getVoucherPaymentLifecycleKey(payment) {
|
|
89
|
+
if (!isVoucherPaymentRecord(payment)) return null;
|
|
90
|
+
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
91
|
+
}
|
|
88
92
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
89
93
|
_inherits(OrderModule, _BaseModule);
|
|
90
94
|
var _super = _createSuper(OrderModule);
|
|
@@ -3630,14 +3634,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3630
3634
|
}).map(function (payment) {
|
|
3631
3635
|
return String(payment.order_payment_id);
|
|
3632
3636
|
}));
|
|
3633
|
-
var
|
|
3634
|
-
return
|
|
3637
|
+
var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
|
|
3638
|
+
return getVoucherPaymentLifecycleKey(payment);
|
|
3639
|
+
}).filter(function (key) {
|
|
3640
|
+
return key !== null;
|
|
3635
3641
|
}));
|
|
3636
3642
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3637
3643
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3638
3644
|
return false;
|
|
3639
3645
|
}
|
|
3640
|
-
|
|
3646
|
+
var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
|
|
3647
|
+
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
3641
3648
|
return false;
|
|
3642
3649
|
}
|
|
3643
3650
|
return true;
|
|
@@ -533,7 +533,8 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
533
533
|
return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
534
534
|
}, 0);
|
|
535
535
|
var hasPromoDiscountItem = discountList.some(function (item) {
|
|
536
|
-
|
|
536
|
+
var _item$metadata, _item$metadata2;
|
|
537
|
+
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';
|
|
537
538
|
});
|
|
538
539
|
if (hasPromoDiscountItem) return fromList;
|
|
539
540
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
@@ -35,6 +35,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
35
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
36
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
37
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
38
|
+
private isItemRewardProductDiscount;
|
|
38
39
|
private getUnavailableReason;
|
|
39
40
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
40
41
|
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",
|
|
@@ -729,6 +740,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
729
740
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
730
741
|
};
|
|
731
742
|
}
|
|
743
|
+
if (_this3.isItemRewardProductDiscount(product)) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
732
746
|
|
|
733
747
|
// 编辑的商品使用了优惠券不可用
|
|
734
748
|
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) {
|
|
@@ -915,6 +929,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
929
|
};
|
|
916
930
|
originProduct = flatItem.originProduct;
|
|
917
931
|
}
|
|
932
|
+
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
918
933
|
addModeDiscount.forEach(function (discount) {
|
|
919
934
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
920
935
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -940,7 +955,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
955
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
941
956
|
|
|
942
957
|
// 判断优惠券是否适用于该商品
|
|
943
|
-
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
958
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
944
959
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
945
960
|
// 记录此优惠券适用的商品
|
|
946
961
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1085,6 +1100,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1085
1100
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1086
1101
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1087
1102
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1103
|
+
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1088
1104
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1089
1105
|
var discountType = discount.tag || discount.type;
|
|
1090
1106
|
var currentOriginUid = getOriginProductUid(originProduct);
|
|
@@ -1172,6 +1188,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1172
1188
|
|
|
1173
1189
|
// 如果是手动折扣,则不适用优惠券
|
|
1174
1190
|
var isManualDiscount = false;
|
|
1191
|
+
var isItemRewardProductDiscount = false;
|
|
1175
1192
|
if (flatItem.type === 'main') {
|
|
1176
1193
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1177
1194
|
// 主商品:判断自身是否手动折扣
|
|
@@ -1183,7 +1200,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1183
1200
|
}) && (!((_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) {
|
|
1184
1201
|
return item.type === 'product';
|
|
1185
1202
|
})));
|
|
1186
|
-
|
|
1203
|
+
isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
1204
|
+
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1187
1205
|
isManualDiscount = false;
|
|
1188
1206
|
}
|
|
1189
1207
|
} else {
|
|
@@ -1293,15 +1311,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1311
|
var main_product_selling_price = product.price;
|
|
1294
1312
|
if ((product.discount_list || []).some(function (item) {
|
|
1295
1313
|
return item.type === 'promotion';
|
|
1296
|
-
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1314
|
+
}) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1297
1315
|
var _product$total, _product$main_product;
|
|
1298
1316
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1299
1317
|
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;
|
|
1300
1318
|
}
|
|
1301
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1319
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
|
|
1302
1320
|
price: product.price,
|
|
1303
|
-
main_product_selling_price: product.price
|
|
1304
|
-
}
|
|
1321
|
+
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
|
|
1322
|
+
}, isItemRewardProductDiscount ? {
|
|
1323
|
+
total: total
|
|
1324
|
+
} : {}) : {
|
|
1305
1325
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1306
1326
|
total: total,
|
|
1307
1327
|
price: product.price,
|
|
@@ -1750,11 +1770,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1750
1770
|
processedItems.forEach(function (item) {
|
|
1751
1771
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1752
1772
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1753
|
-
var _item$
|
|
1773
|
+
var _item$metadata3;
|
|
1754
1774
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1755
1775
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1756
1776
|
num: item.num,
|
|
1757
|
-
custom_product_bundle_map_id: (_item$
|
|
1777
|
+
custom_product_bundle_map_id: (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.custom_product_bundle_map_id
|
|
1758
1778
|
})
|
|
1759
1779
|
// num: item.num, // 使用拆分后的 num
|
|
1760
1780
|
});
|
|
@@ -1773,11 +1793,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1773
1793
|
if (item.processed) {
|
|
1774
1794
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1775
1795
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1776
|
-
var _item$
|
|
1796
|
+
var _item$metadata4;
|
|
1777
1797
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1778
1798
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1779
1799
|
num: item.num,
|
|
1780
|
-
custom_product_bundle_map_id: (_item$
|
|
1800
|
+
custom_product_bundle_map_id: (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.custom_product_bundle_map_id
|
|
1781
1801
|
})
|
|
1782
1802
|
// num: item.num, // 使用当前的 num
|
|
1783
1803
|
});
|
|
@@ -1818,8 +1838,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1818
1838
|
|
|
1819
1839
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1820
1840
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1821
|
-
var _item$
|
|
1822
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1841
|
+
var _item$metadata5;
|
|
1842
|
+
return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
|
|
1823
1843
|
});
|
|
1824
1844
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1825
1845
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1892,8 +1912,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1892
1912
|
|
|
1893
1913
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1894
1914
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1895
|
-
var _item$
|
|
1896
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1915
|
+
var _item$metadata6;
|
|
1916
|
+
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
1897
1917
|
});
|
|
1898
1918
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1899
1919
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -48,6 +48,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
48
48
|
protected store: BaseSalesState;
|
|
49
49
|
protected otherParams: Record<string, any>;
|
|
50
50
|
protected cacheId: string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
53
|
+
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
54
|
+
*/
|
|
55
|
+
protected paymentNumberDevicePrefix: string | null;
|
|
51
56
|
/**
|
|
52
57
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
53
58
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -141,6 +146,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
141
146
|
*/
|
|
142
147
|
protected readSessionCacheData(): Record<string, any>;
|
|
143
148
|
protected getAppData<T>(key: string): T | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
151
|
+
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
152
|
+
*/
|
|
153
|
+
protected setPaymentNumberDevicePrefix(prefix: unknown): void;
|
|
144
154
|
private getPaymentNumberDevicePrefixSync;
|
|
145
155
|
private getPaymentNumberDevicePrefixAsync;
|
|
146
156
|
private syncAppDataToTempOrder;
|
|
@@ -284,7 +294,10 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
284
294
|
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
285
295
|
*/
|
|
286
296
|
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
287
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
299
|
+
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
300
|
+
*/
|
|
288
301
|
addOrderPaymentAsync(payment: OrderPaymentSource): Promise<OrderPaymentData[]>;
|
|
289
302
|
private addOrderPaymentWithDevicePrefix;
|
|
290
303
|
/** 更新当前订单中的指定支付项。 */
|
|
@@ -304,6 +304,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
304
304
|
});
|
|
305
305
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
306
306
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
307
|
+
/**
|
|
308
|
+
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
309
|
+
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
310
|
+
*/
|
|
311
|
+
_defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
|
|
307
312
|
/**
|
|
308
313
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
309
314
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -1148,6 +1153,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1148
1153
|
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1149
1154
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1150
1155
|
}
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
1159
|
+
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
1160
|
+
*/
|
|
1161
|
+
}, {
|
|
1162
|
+
key: "setPaymentNumberDevicePrefix",
|
|
1163
|
+
value: function setPaymentNumberDevicePrefix(prefix) {
|
|
1164
|
+
var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
|
|
1165
|
+
this.paymentNumberDevicePrefix = normalized || null;
|
|
1166
|
+
}
|
|
1151
1167
|
}, {
|
|
1152
1168
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1153
1169
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
@@ -1162,6 +1178,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1178
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1163
1179
|
var _this8 = this;
|
|
1164
1180
|
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1181
|
+
if (this.paymentNumberDevicePrefix) {
|
|
1182
|
+
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1183
|
+
}
|
|
1165
1184
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1166
1185
|
return _this8.getAppData(key);
|
|
1167
1186
|
});
|
|
@@ -1222,6 +1241,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1241
|
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1223
1242
|
this.core = core;
|
|
1224
1243
|
this.initializeOptions = options || {};
|
|
1244
|
+
this.paymentNumberDevicePrefix = null;
|
|
1225
1245
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1226
1246
|
this.otherParams = options.otherParams || {};
|
|
1227
1247
|
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
@@ -1232,11 +1252,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1232
1252
|
// 获取 logger 实例
|
|
1233
1253
|
this.appPlugin = core.getPlugin('app');
|
|
1234
1254
|
if (this.appPlugin) {
|
|
1235
|
-
_context11.next =
|
|
1255
|
+
_context11.next = 12;
|
|
1236
1256
|
break;
|
|
1237
1257
|
}
|
|
1238
1258
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1239
|
-
case
|
|
1259
|
+
case 12:
|
|
1240
1260
|
app = this.appPlugin.getApp();
|
|
1241
1261
|
this.logger = app.logger;
|
|
1242
1262
|
targetCacheData = this.readSessionCacheData();
|
|
@@ -1263,21 +1283,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1263
1283
|
}));
|
|
1264
1284
|
});
|
|
1265
1285
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1266
|
-
_context11.next =
|
|
1286
|
+
_context11.next = 20;
|
|
1267
1287
|
break;
|
|
1268
1288
|
}
|
|
1269
|
-
_context11.next =
|
|
1289
|
+
_context11.next = 20;
|
|
1270
1290
|
return this.store.schedule.loadAllSchedule();
|
|
1271
|
-
case
|
|
1291
|
+
case 20:
|
|
1272
1292
|
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
1273
1293
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1274
1294
|
}
|
|
1275
|
-
_context11.next =
|
|
1295
|
+
_context11.next = 23;
|
|
1276
1296
|
return this.getPaymentMethodsAsync();
|
|
1277
|
-
case
|
|
1297
|
+
case 23:
|
|
1278
1298
|
this.registerServerOrderChangeSync();
|
|
1279
1299
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1280
|
-
case
|
|
1300
|
+
case 25:
|
|
1281
1301
|
case "end":
|
|
1282
1302
|
return _context11.stop();
|
|
1283
1303
|
}
|
|
@@ -1311,13 +1331,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1311
1331
|
}
|
|
1312
1332
|
});
|
|
1313
1333
|
this.currentSalesDetail = null;
|
|
1334
|
+
this.paymentNumberDevicePrefix = null;
|
|
1314
1335
|
this.queuedServerOrderChanges = [];
|
|
1315
1336
|
this.salesDetailLoadSequence += 1;
|
|
1316
|
-
_context12.next =
|
|
1337
|
+
_context12.next = 9;
|
|
1317
1338
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1318
|
-
case 8:
|
|
1319
|
-
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1320
1339
|
case 9:
|
|
1340
|
+
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1341
|
+
case 10:
|
|
1321
1342
|
case "end":
|
|
1322
1343
|
return _context12.stop();
|
|
1323
1344
|
}
|
|
@@ -3106,7 +3127,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3106
3127
|
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3107
3128
|
}
|
|
3108
3129
|
|
|
3109
|
-
/**
|
|
3130
|
+
/**
|
|
3131
|
+
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
3132
|
+
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
3133
|
+
*/
|
|
3110
3134
|
}, {
|
|
3111
3135
|
key: "addOrderPaymentAsync",
|
|
3112
3136
|
value: (function () {
|
|
@@ -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`
|