@pisell/pisellos 2.2.264 → 2.2.265
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/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +41 -10
- package/dist/modules/Order/index.js +1370 -808
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +49 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +62 -66
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -9
- package/dist/modules/Rules/index.js +69 -43
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +71 -0
- package/dist/server/index.js +2504 -1187
- package/dist/server/modules/order/index.d.ts +56 -5
- package/dist/server/modules/order/index.js +1718 -834
- package/dist/server/modules/order/types.d.ts +15 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +54 -4
- package/dist/solution/BaseSales/index.js +1448 -788
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +50 -97
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +61 -26
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -2
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +41 -10
- package/lib/modules/Order/index.js +505 -119
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +49 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +27 -26
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -9
- package/lib/modules/Rules/index.js +61 -29
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +71 -0
- package/lib/server/index.js +1002 -52
- package/lib/server/modules/order/index.d.ts +56 -5
- package/lib/server/modules/order/index.js +798 -148
- package/lib/server/modules/order/types.d.ts +15 -3
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +54 -4
- package/lib/solution/BaseSales/index.js +475 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +25 -64
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +35 -9
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -87,12 +87,30 @@ export interface PaymentMethod {
|
|
|
87
87
|
/** 其他配置信息 */
|
|
88
88
|
[key: string]: any;
|
|
89
89
|
}
|
|
90
|
+
/** 支付项扩展元数据 */
|
|
91
|
+
export interface PaymentItemMetadata {
|
|
92
|
+
/** 钱箱 ID */
|
|
93
|
+
shop_wallet_pass_id?: string;
|
|
94
|
+
/** 三方支付交易流水号 */
|
|
95
|
+
unique_payment_number?: string;
|
|
96
|
+
/** 刷卡机设备快照;PaymentModule 不解析内部字段 */
|
|
97
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
98
|
+
/** rounding 规则 */
|
|
99
|
+
rounding_rule?: any;
|
|
100
|
+
/** 实付金额(现金支付时的实际给出金额) */
|
|
101
|
+
actual_paid_amount?: number;
|
|
102
|
+
/** 找零金额(现金支付时的找零金额) */
|
|
103
|
+
change_given_amount?: number;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
90
106
|
/**
|
|
91
107
|
* 支付项
|
|
92
108
|
*/
|
|
93
109
|
export interface PaymentItem {
|
|
94
110
|
/** 当前支付项的唯一 ID */
|
|
95
111
|
uuid: string;
|
|
112
|
+
/** 支付项稳定唯一号 */
|
|
113
|
+
payment_number?: string;
|
|
96
114
|
/** 当前支付方式付出去多少钱 */
|
|
97
115
|
amount: string;
|
|
98
116
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -110,18 +128,7 @@ export interface PaymentItem {
|
|
|
110
128
|
/** Wallet Pass 本次使用值 */
|
|
111
129
|
wallet_pass_use_value?: string | number | null;
|
|
112
130
|
/** 拓展参数字段 */
|
|
113
|
-
metadata?:
|
|
114
|
-
/** 钱箱 ID */
|
|
115
|
-
shop_wallet_pass_id?: string;
|
|
116
|
-
/** 唯一支付号 */
|
|
117
|
-
unique_payment_number?: string;
|
|
118
|
-
/** rouding规则 */
|
|
119
|
-
rounding_rule?: any;
|
|
120
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
121
|
-
actual_paid_amount?: number;
|
|
122
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
123
|
-
change_given_amount?: number;
|
|
124
|
-
};
|
|
131
|
+
metadata?: PaymentItemMetadata;
|
|
125
132
|
/** rouding金额 */
|
|
126
133
|
rounding_amount?: string;
|
|
127
134
|
/** 三方支付手续费 */
|
|
@@ -228,6 +235,10 @@ export interface UpdateOrderParams {
|
|
|
228
235
|
* 支付项输入类型(允许 amount 为数字)
|
|
229
236
|
*/
|
|
230
237
|
export interface PaymentItemInput {
|
|
238
|
+
/** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
|
|
239
|
+
uuid?: string;
|
|
240
|
+
/** 支付项稳定唯一号 */
|
|
241
|
+
payment_number?: string;
|
|
231
242
|
/** 当前支付方式付出去多少钱 */
|
|
232
243
|
amount: string | number;
|
|
233
244
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
@@ -256,18 +267,7 @@ export interface PaymentItemInput {
|
|
|
256
267
|
/** 订单支付类型 */
|
|
257
268
|
order_payment_type?: 'normal' | 'deposit';
|
|
258
269
|
/** 扩展参数字段 */
|
|
259
|
-
metadata?:
|
|
260
|
-
/** 钱箱 ID */
|
|
261
|
-
shop_wallet_pass_id?: string;
|
|
262
|
-
/** 唯一支付号 */
|
|
263
|
-
unique_payment_number?: string;
|
|
264
|
-
/** rounding规则 */
|
|
265
|
-
rounding_rule?: any;
|
|
266
|
-
/** 实付金额(现金支付时的实际给出金额) */
|
|
267
|
-
actual_paid_amount?: number;
|
|
268
|
-
/** 找零金额(现金支付时的找零金额) */
|
|
269
|
-
change_given_amount?: number;
|
|
270
|
-
};
|
|
270
|
+
metadata?: PaymentItemMetadata;
|
|
271
271
|
/** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
272
272
|
created_at?: string;
|
|
273
273
|
/** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
|
|
@@ -302,6 +302,8 @@ export interface PaymentUpdateFields {
|
|
|
302
302
|
voucher_id?: string;
|
|
303
303
|
/** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
|
|
304
304
|
isSynced?: boolean;
|
|
305
|
+
/** 支付项扩展元数据;更新时与原 metadata 浅合并 */
|
|
306
|
+
metadata?: PaymentItemMetadata;
|
|
305
307
|
/** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
|
|
306
308
|
syncError?: {
|
|
307
309
|
error: string;
|
|
@@ -9,6 +9,26 @@ export interface ProductCollection {
|
|
|
9
9
|
/** 商品集合封面 */
|
|
10
10
|
cover: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 商品 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
14
|
+
*/
|
|
15
|
+
export interface ProductDataVariant {
|
|
16
|
+
/** 变体记录 id */
|
|
17
|
+
id: number;
|
|
18
|
+
/** 店铺 id */
|
|
19
|
+
shop_id: number;
|
|
20
|
+
/** 所属模块,商品场景固定为 product */
|
|
21
|
+
module: string;
|
|
22
|
+
/** 模块数据 id,商品场景对应 product.id */
|
|
23
|
+
module_data_id: number;
|
|
24
|
+
/** 关联 data_variant_rule.id */
|
|
25
|
+
data_variant_rule_id: number;
|
|
26
|
+
/** 命中策略后覆盖到商品上的字段 */
|
|
27
|
+
data: Record<string, any>;
|
|
28
|
+
created_at: string | null;
|
|
29
|
+
updated_at: string | null;
|
|
30
|
+
deleted_at: string | null;
|
|
31
|
+
}
|
|
12
32
|
/**
|
|
13
33
|
* 商品基本信息接口
|
|
14
34
|
*/
|
|
@@ -214,6 +234,8 @@ export interface ProductData {
|
|
|
214
234
|
bundle_group_count: number;
|
|
215
235
|
/** 选项组数量 */
|
|
216
236
|
option_group_count: number;
|
|
237
|
+
/** 智能定价变体列表,/product/query with dataVariants 返回 */
|
|
238
|
+
data_variants?: ProductDataVariant[];
|
|
217
239
|
/** 服务时长 */
|
|
218
240
|
service_times?: any;
|
|
219
241
|
}
|
|
@@ -26,7 +26,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
26
26
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
27
|
*/
|
|
28
28
|
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
|
|
29
|
-
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
|
|
29
|
+
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
|
|
30
30
|
callback?: (result: any) => void;
|
|
31
31
|
subscriberId?: string;
|
|
32
32
|
}): Promise<any>;
|
|
@@ -152,6 +152,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
152
152
|
extension_type,
|
|
153
153
|
_ref$status,
|
|
154
154
|
status,
|
|
155
|
+
strategy_context,
|
|
155
156
|
options,
|
|
156
157
|
userPlugin,
|
|
157
158
|
customer_id,
|
|
@@ -162,7 +163,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
163
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
163
164
|
while (1) switch (_context4.prev = _context4.next) {
|
|
164
165
|
case 0:
|
|
165
|
-
_ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status;
|
|
166
|
+
_ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
|
|
166
167
|
options = _args4.length > 1 ? _args4[1] : undefined;
|
|
167
168
|
// // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
168
169
|
// if (!schedule_ids?.length) {
|
|
@@ -206,7 +207,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
207
|
is_eject: 1,
|
|
207
208
|
with_schedule: with_schedule,
|
|
208
209
|
schedule_datetime: schedule_datetime,
|
|
209
|
-
extension_type: extension_type
|
|
210
|
+
extension_type: extension_type,
|
|
211
|
+
strategy_context: strategy_context
|
|
210
212
|
}, {
|
|
211
213
|
osServer: true,
|
|
212
214
|
callback: options === null || options === void 0 ? void 0 : options.callback,
|
|
@@ -12,6 +12,8 @@ export interface ProductListLoadProductsParams {
|
|
|
12
12
|
with_schedule?: number;
|
|
13
13
|
extension_type?: string[];
|
|
14
14
|
status?: string;
|
|
15
|
+
/** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
|
|
16
|
+
strategy_context?: Record<string, any>;
|
|
15
17
|
}
|
|
16
18
|
export interface ProductListData {
|
|
17
19
|
list: ProductData[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from '../Discount/types';
|
|
5
|
-
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
5
|
import { WindowPlugin } from '../../plugins';
|
|
7
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
8
7
|
protected defaultName: string;
|
|
@@ -36,7 +35,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
36
35
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
37
36
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
38
37
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
39
|
-
private isItemRewardProductDiscount;
|
|
40
38
|
private getUnavailableReason;
|
|
41
39
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
42
40
|
discountList: Discount[];
|
|
@@ -46,12 +44,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
46
44
|
}[];
|
|
47
45
|
isFormSubject: RulesFormSubject;
|
|
48
46
|
orderTotalAmount: number;
|
|
49
|
-
}, options?:
|
|
50
|
-
isSelected?: boolean;
|
|
51
|
-
discountId?: number;
|
|
52
|
-
selectedList?: SetDiscountSelectedParams[];
|
|
53
|
-
scan?: boolean;
|
|
54
|
-
}): DiscountResult;
|
|
47
|
+
}, options?: RulesCalcDiscountOptions): DiscountResult;
|
|
55
48
|
/**
|
|
56
49
|
* 检查优惠是否符合 PackageSubItemUsageRules 配置
|
|
57
50
|
* @param discount 优惠券
|
|
@@ -241,17 +241,6 @@ 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
|
-
|
|
255
244
|
// 获取券不可用的原因
|
|
256
245
|
}, {
|
|
257
246
|
key: "getUnavailableReason",
|
|
@@ -346,6 +335,32 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
346
335
|
}) && productList.find(function (n) {
|
|
347
336
|
return !n.booking_id;
|
|
348
337
|
});
|
|
338
|
+
var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
|
|
339
|
+
return uid !== undefined && uid !== null && uid !== '';
|
|
340
|
+
}).map(String));
|
|
341
|
+
var getOriginProductUid = function getOriginProductUid(originProduct) {
|
|
342
|
+
var _originProduct$metada, _originProduct$metada2;
|
|
343
|
+
var uid = (_originProduct$metada = originProduct === null || originProduct === void 0 || (_originProduct$metada2 = originProduct.metadata) === null || _originProduct$metada2 === void 0 ? void 0 : _originProduct$metada2.unique_identification_number) !== null && _originProduct$metada !== void 0 ? _originProduct$metada : originProduct === null || originProduct === void 0 ? void 0 : originProduct.unique_identification_number;
|
|
344
|
+
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
345
|
+
return String(uid);
|
|
346
|
+
};
|
|
347
|
+
var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
|
|
348
|
+
if (!selectedDiscount) return false;
|
|
349
|
+
var uid = getOriginProductUid(originProduct);
|
|
350
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
351
|
+
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
352
|
+
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
353
|
+
};
|
|
354
|
+
var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
|
|
355
|
+
var _discount2;
|
|
356
|
+
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
357
|
+
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
358
|
+
if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
|
|
362
|
+
return Number.isFinite(percent) ? percent : undefined;
|
|
363
|
+
};
|
|
349
364
|
var editModeDiscount = [];
|
|
350
365
|
var addModeDiscount = [];
|
|
351
366
|
discountList.forEach(function (discount) {
|
|
@@ -374,11 +389,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
374
389
|
}
|
|
375
390
|
});
|
|
376
391
|
}
|
|
377
|
-
|
|
378
|
-
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
|
|
379
|
-
var filteredDiscountList = addModeDiscount.filter(function (discount) {
|
|
380
|
-
return !discount.isManualSelect;
|
|
381
|
-
});
|
|
382
392
|
var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
|
|
383
393
|
if (!hasDiscountInput) {
|
|
384
394
|
return {
|
|
@@ -386,6 +396,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
386
396
|
productList: productList
|
|
387
397
|
};
|
|
388
398
|
}
|
|
399
|
+
var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
|
|
400
|
+
var discountType = discount.tag || discount.type;
|
|
401
|
+
return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
|
|
405
|
+
// Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
|
|
406
|
+
var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
|
|
407
|
+
return !discount.isManualSelect;
|
|
408
|
+
})), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
|
|
389
409
|
|
|
390
410
|
// 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
|
|
391
411
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
@@ -709,9 +729,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
709
729
|
startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
|
|
710
730
|
};
|
|
711
731
|
}
|
|
712
|
-
if (_this3.isItemRewardProductDiscount(product)) {
|
|
713
|
-
return false;
|
|
714
|
-
}
|
|
715
732
|
|
|
716
733
|
// 编辑的商品使用了优惠券不可用
|
|
717
734
|
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) {
|
|
@@ -898,7 +915,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
915
|
};
|
|
899
916
|
originProduct = flatItem.originProduct;
|
|
900
917
|
}
|
|
901
|
-
var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
|
|
902
918
|
addModeDiscount.forEach(function (discount) {
|
|
903
919
|
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
904
920
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
@@ -924,7 +940,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
924
940
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
925
941
|
|
|
926
942
|
// 判断优惠券是否适用于该商品
|
|
927
|
-
if (isAvailableProduct &&
|
|
943
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
928
944
|
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
929
945
|
// 记录此优惠券适用的商品
|
|
930
946
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -1069,10 +1085,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1069
1085
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1070
1086
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1071
1087
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1072
|
-
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1073
1088
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1074
1089
|
var discountType = discount.tag || discount.type;
|
|
1075
|
-
|
|
1090
|
+
var currentOriginUid = getOriginProductUid(originProduct);
|
|
1091
|
+
var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
|
|
1092
|
+
if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
|
|
1093
|
+
var uid = currentOriginUid;
|
|
1094
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
1095
|
+
if (!discount.isSelected) return false;
|
|
1096
|
+
}
|
|
1097
|
+
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
|
|
1076
1098
|
var _discount$config2;
|
|
1077
1099
|
// 如果策略检查后没有config,说明不可用
|
|
1078
1100
|
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
|
|
@@ -1150,7 +1172,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1172
|
|
|
1151
1173
|
// 如果是手动折扣,则不适用优惠券
|
|
1152
1174
|
var isManualDiscount = false;
|
|
1153
|
-
var isItemRewardProductDiscount = false;
|
|
1154
1175
|
if (flatItem.type === 'main') {
|
|
1155
1176
|
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1156
1177
|
// 主商品:判断自身是否手动折扣
|
|
@@ -1162,8 +1183,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1183
|
}) && (!((_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) {
|
|
1163
1184
|
return item.type === 'product';
|
|
1164
1185
|
})));
|
|
1165
|
-
|
|
1166
|
-
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
1186
|
+
if (product.inPromotion) {
|
|
1167
1187
|
isManualDiscount = false;
|
|
1168
1188
|
}
|
|
1169
1189
|
} else {
|
|
@@ -1273,17 +1293,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1273
1293
|
var main_product_selling_price = product.price;
|
|
1274
1294
|
if ((product.discount_list || []).some(function (item) {
|
|
1275
1295
|
return item.type === 'promotion';
|
|
1276
|
-
}) ||
|
|
1296
|
+
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1277
1297
|
var _product$total, _product$main_product;
|
|
1278
1298
|
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1279
1299
|
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;
|
|
1280
1300
|
}
|
|
1281
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ?
|
|
1301
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1282
1302
|
price: product.price,
|
|
1283
|
-
main_product_selling_price:
|
|
1284
|
-
}
|
|
1285
|
-
total: total
|
|
1286
|
-
} : {}) : {
|
|
1303
|
+
main_product_selling_price: product.price
|
|
1304
|
+
} : {
|
|
1287
1305
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1288
1306
|
total: total,
|
|
1289
1307
|
price: product.price,
|
|
@@ -1304,7 +1322,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1304
1322
|
}
|
|
1305
1323
|
return;
|
|
1306
1324
|
}
|
|
1307
|
-
|
|
1325
|
+
var shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
|
|
1326
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
|
|
1308
1327
|
return;
|
|
1309
1328
|
}
|
|
1310
1329
|
|
|
@@ -1345,7 +1364,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1345
1364
|
}));
|
|
1346
1365
|
}
|
|
1347
1366
|
for (var i = 0; i < splitCount; i++) {
|
|
1348
|
-
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
|
|
1367
|
+
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
|
|
1349
1368
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
1350
1369
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1351
1370
|
// 标记优惠券为已使用
|
|
@@ -1383,11 +1402,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1383
1402
|
var productDiscountDifference = void 0;
|
|
1384
1403
|
var discountedOptions = product.options;
|
|
1385
1404
|
var optionDiscountAmount = 0;
|
|
1405
|
+
var reapplyDiscountPercent = void 0;
|
|
1386
1406
|
if (isOrderLevel && productAllocation) {
|
|
1387
1407
|
// order_level:使用预计算的分摊金额
|
|
1388
1408
|
amount = productAllocation.discountAmount;
|
|
1389
1409
|
productDiscountDifference = productAllocation.difference;
|
|
1390
1410
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1411
|
+
} else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1412
|
+
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1413
|
+
var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
|
|
1414
|
+
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1415
|
+
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1416
|
+
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
1391
1417
|
} else {
|
|
1392
1418
|
// item_level 或其他类型:使用原有逻辑
|
|
1393
1419
|
mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
|
|
@@ -1420,7 +1446,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1420
1446
|
title: _selectedDiscount.format_title,
|
|
1421
1447
|
original_amount: product.price,
|
|
1422
1448
|
product_id: originProduct.id || originProduct.product_id,
|
|
1423
|
-
percent: _selectedDiscount.par_value,
|
|
1449
|
+
percent: (_reapplyDiscountPerce = reapplyDiscountPercent) !== null && _reapplyDiscountPerce !== void 0 ? _reapplyDiscountPerce : _selectedDiscount.par_value,
|
|
1424
1450
|
discount_product_id: _selectedDiscount.product_id
|
|
1425
1451
|
},
|
|
1426
1452
|
// 前端使用的num数量,为了计算优惠金额
|
|
@@ -1724,11 +1750,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1724
1750
|
processedItems.forEach(function (item) {
|
|
1725
1751
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1726
1752
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1727
|
-
var _item$
|
|
1753
|
+
var _item$metadata;
|
|
1728
1754
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1729
1755
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1730
1756
|
num: item.num,
|
|
1731
|
-
custom_product_bundle_map_id: (_item$
|
|
1757
|
+
custom_product_bundle_map_id: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.custom_product_bundle_map_id
|
|
1732
1758
|
})
|
|
1733
1759
|
// num: item.num, // 使用拆分后的 num
|
|
1734
1760
|
});
|
|
@@ -1747,11 +1773,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1747
1773
|
if (item.processed) {
|
|
1748
1774
|
// 🔥 同样需要更新 discount_list 中的 num
|
|
1749
1775
|
var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1750
|
-
var _item$
|
|
1776
|
+
var _item$metadata2;
|
|
1751
1777
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1752
1778
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1753
1779
|
num: item.num,
|
|
1754
|
-
custom_product_bundle_map_id: (_item$
|
|
1780
|
+
custom_product_bundle_map_id: (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.custom_product_bundle_map_id
|
|
1755
1781
|
})
|
|
1756
1782
|
// num: item.num, // 使用当前的 num
|
|
1757
1783
|
});
|
|
@@ -1792,8 +1818,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1792
1818
|
|
|
1793
1819
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1794
1820
|
var mainDiscountList = updatedMainDiscountList.filter(function (item) {
|
|
1795
|
-
var _item$
|
|
1796
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1821
|
+
var _item$metadata3;
|
|
1822
|
+
return !(item !== null && item !== void 0 && (_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.custom_product_bundle_map_id);
|
|
1797
1823
|
});
|
|
1798
1824
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
1799
1825
|
var _Decimal$minus$toNumb, _mainProductData$orig;
|
|
@@ -1866,8 +1892,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1866
1892
|
|
|
1867
1893
|
// 🔥 使用更新后的列表计算折扣金额
|
|
1868
1894
|
var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
|
|
1869
|
-
var _item$
|
|
1870
|
-
return !(item !== null && item !== void 0 && (_item$
|
|
1895
|
+
var _item$metadata4;
|
|
1896
|
+
return !(item !== null && item !== void 0 && (_item$metadata4 = item.metadata) !== null && _item$metadata4 !== void 0 && _item$metadata4.custom_product_bundle_map_id);
|
|
1871
1897
|
});
|
|
1872
1898
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
1873
1899
|
var _Decimal$minus$toNumb2, _mainProductData$orig2;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
2
3
|
export declare enum UnavailableReason {
|
|
3
4
|
TimeLimit = "time_limit",
|
|
4
5
|
ProductNotApplicable = "product_not_applicable",
|
|
@@ -23,6 +24,14 @@ export interface DiscountResult {
|
|
|
23
24
|
discountList: any[];
|
|
24
25
|
}
|
|
25
26
|
export type RulesFormSubject = boolean | ((product: any) => boolean);
|
|
27
|
+
export interface RulesCalcDiscountOptions {
|
|
28
|
+
isSelected?: boolean;
|
|
29
|
+
discountId?: number;
|
|
30
|
+
selectedList?: SetDiscountSelectedParams[];
|
|
31
|
+
scan?: boolean;
|
|
32
|
+
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
33
|
+
reapplyBookingDiscountProductUids?: string[];
|
|
34
|
+
}
|
|
26
35
|
export interface RulesModuleAPI {
|
|
27
36
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
28
37
|
clear: () => Promise<void>;
|
|
@@ -34,7 +43,7 @@ export interface RulesModuleAPI {
|
|
|
34
43
|
}[];
|
|
35
44
|
isFormSubject: RulesFormSubject;
|
|
36
45
|
orderTotalAmount: number;
|
|
37
|
-
}) => DiscountResult;
|
|
46
|
+
}, options?: RulesCalcDiscountOptions) => DiscountResult;
|
|
38
47
|
}
|
|
39
48
|
type ProductDetail = {
|
|
40
49
|
isClient?: boolean;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ declare class Server {
|
|
|
47
47
|
private prefixRouterGet;
|
|
48
48
|
router: Router;
|
|
49
49
|
private productQuerySubscribers;
|
|
50
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
|
+
private productQueryScheduleTimers;
|
|
50
52
|
private orderQuerySubscribers;
|
|
51
53
|
private bookingQuerySubscribers;
|
|
52
54
|
private bookingRemoteQuerySubscribers;
|
|
@@ -55,6 +57,7 @@ declare class Server {
|
|
|
55
57
|
private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
|
|
56
58
|
private salesSearchSubscribers;
|
|
57
59
|
private deviceTaskActionsRegistered;
|
|
60
|
+
private localPaymentUpdateQueues;
|
|
58
61
|
private floorPlanQuerySubscribers;
|
|
59
62
|
private moduleRegistry;
|
|
60
63
|
constructor(core: PisellCore);
|
|
@@ -118,6 +121,8 @@ declare class Server {
|
|
|
118
121
|
private handleSyncSalesTask;
|
|
119
122
|
private runCheckoutSync;
|
|
120
123
|
private omitCheckoutSyncMode;
|
|
124
|
+
private buildRemoteCheckoutData;
|
|
125
|
+
private mergeCheckoutSyncPayments;
|
|
121
126
|
private persistSyncedCheckoutOrder;
|
|
122
127
|
/**
|
|
123
128
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
@@ -210,6 +215,48 @@ declare class Server {
|
|
|
210
215
|
* 根据 subscriberId 移除商品查询订阅者
|
|
211
216
|
*/
|
|
212
217
|
removeProductQuerySubscriber(subscriberId?: string): void;
|
|
218
|
+
/**
|
|
219
|
+
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
220
|
+
*/
|
|
221
|
+
private buildProductQueryResultPayload;
|
|
222
|
+
/**
|
|
223
|
+
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
224
|
+
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
225
|
+
*/
|
|
226
|
+
private shouldScheduleProductQueryReload;
|
|
227
|
+
/**
|
|
228
|
+
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
229
|
+
*/
|
|
230
|
+
private clearSubscriberScheduleTimers;
|
|
231
|
+
/**
|
|
232
|
+
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
233
|
+
*/
|
|
234
|
+
private removeScheduleTimerRef;
|
|
235
|
+
/**
|
|
236
|
+
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
237
|
+
*/
|
|
238
|
+
private computeScheduleTimePointDelayMs;
|
|
239
|
+
/**
|
|
240
|
+
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
241
|
+
*/
|
|
242
|
+
private refreshSubscriberScheduleAtExecution;
|
|
243
|
+
/**
|
|
244
|
+
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
245
|
+
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
246
|
+
*/
|
|
247
|
+
private scheduleSubscriberTimePointReloads;
|
|
248
|
+
/**
|
|
249
|
+
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
250
|
+
*/
|
|
251
|
+
private onScheduleTimePointTimerFire;
|
|
252
|
+
/**
|
|
253
|
+
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
254
|
+
*/
|
|
255
|
+
private recomputeAndNotifySubscriber;
|
|
256
|
+
/**
|
|
257
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
258
|
+
*/
|
|
259
|
+
private syncProductQueryScheduleTimers;
|
|
213
260
|
/**
|
|
214
261
|
* 处理商品查询请求
|
|
215
262
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -409,6 +456,18 @@ declare class Server {
|
|
|
409
456
|
*/
|
|
410
457
|
private handleUpdateLocalOrder;
|
|
411
458
|
private handleOrderSalesCheckout;
|
|
459
|
+
private handleOrderSalesDraft;
|
|
460
|
+
private createLocalPaymentOperationId;
|
|
461
|
+
private buildLocalPaymentOrderLogContext;
|
|
462
|
+
private isValidLocalPaymentDecimal;
|
|
463
|
+
private getInvalidLocalPaymentSurchargeFields;
|
|
464
|
+
private buildLocalPaymentSurchargeUpdate;
|
|
465
|
+
private handleGetLocalPayment;
|
|
466
|
+
private handleUpdateLocalPayment;
|
|
467
|
+
private runLocalPaymentUpdateInQueue;
|
|
468
|
+
private processLocalPaymentUpdate;
|
|
469
|
+
private processSuccessfulLocalPayment;
|
|
470
|
+
private sanitizeLocalRecoveryOrder;
|
|
412
471
|
private handleOrderCheckout;
|
|
413
472
|
private getDeviceTaskPlugin;
|
|
414
473
|
private getIdGeneratorPlugin;
|
|
@@ -436,6 +495,7 @@ declare class Server {
|
|
|
436
495
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
437
496
|
private handleOrderCheckoutSubmit;
|
|
438
497
|
private handleSyncCheckoutSubmit;
|
|
498
|
+
private handleOrderDraftSubmit;
|
|
439
499
|
private handlePendingSyncCheckoutOrder;
|
|
440
500
|
private buildPendingSyncCheckoutOrder;
|
|
441
501
|
private shouldBuildSmallTicketData;
|
|
@@ -445,6 +505,11 @@ declare class Server {
|
|
|
445
505
|
private sumPaidOrderPayments;
|
|
446
506
|
private toAmountNumber;
|
|
447
507
|
private buildSmallTicketProductMap;
|
|
508
|
+
private collectSalesDetailProductIds;
|
|
509
|
+
private buildSalesDetailProductSnapshotMap;
|
|
510
|
+
private withProductCatalogSnapshots;
|
|
511
|
+
private withBundleCatalogSnapshots;
|
|
512
|
+
private withSalesDetailProductSnapshots;
|
|
448
513
|
private withPendingSyncProductTitles;
|
|
449
514
|
private buildProductTitleSnapshot;
|
|
450
515
|
private getProductTitleSnapshotCurrentLocale;
|
|
@@ -565,6 +630,12 @@ declare class Server {
|
|
|
565
630
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
566
631
|
*/
|
|
567
632
|
private computeProductQueryResult;
|
|
633
|
+
/**
|
|
634
|
+
* 构建商品格式化上下文。
|
|
635
|
+
*
|
|
636
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
637
|
+
*/
|
|
638
|
+
private buildProductFormatterContext;
|
|
568
639
|
/**
|
|
569
640
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
570
641
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|