@pisell/pisellos 2.2.264 → 2.2.266
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/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 +1379 -810
- 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 +61 -64
- 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 -8
- package/dist/modules/Rules/index.js +55 -9
- 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 +67 -4
- package/dist/solution/BaseSales/index.js +1476 -792
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- 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 +94 -54
- 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/ShopDiscount/index.js +15 -14
- 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/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 +514 -122
- 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 +26 -20
- 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 -8
- package/lib/modules/Rules/index.js +57 -6
- 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 +67 -4
- package/lib/solution/BaseSales/index.js +496 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- 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 +39 -11
- 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/ShopDiscount/index.js +2 -1
- 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;
|
|
@@ -46,12 +45,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
46
45
|
}[];
|
|
47
46
|
isFormSubject: RulesFormSubject;
|
|
48
47
|
orderTotalAmount: number;
|
|
49
|
-
}, options?:
|
|
50
|
-
isSelected?: boolean;
|
|
51
|
-
discountId?: number;
|
|
52
|
-
selectedList?: SetDiscountSelectedParams[];
|
|
53
|
-
scan?: boolean;
|
|
54
|
-
}): DiscountResult;
|
|
48
|
+
}, options?: RulesCalcDiscountOptions): DiscountResult;
|
|
55
49
|
/**
|
|
56
50
|
* 检查优惠是否符合 PackageSubItemUsageRules 配置
|
|
57
51
|
* @param discount 优惠券
|
|
@@ -346,6 +346,32 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
346
346
|
}) && productList.find(function (n) {
|
|
347
347
|
return !n.booking_id;
|
|
348
348
|
});
|
|
349
|
+
var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
|
|
350
|
+
return uid !== undefined && uid !== null && uid !== '';
|
|
351
|
+
}).map(String));
|
|
352
|
+
var getOriginProductUid = function getOriginProductUid(originProduct) {
|
|
353
|
+
var _originProduct$metada, _originProduct$metada2;
|
|
354
|
+
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;
|
|
355
|
+
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
356
|
+
return String(uid);
|
|
357
|
+
};
|
|
358
|
+
var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
|
|
359
|
+
if (!selectedDiscount) return false;
|
|
360
|
+
var uid = getOriginProductUid(originProduct);
|
|
361
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
362
|
+
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
363
|
+
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
364
|
+
};
|
|
365
|
+
var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
|
|
366
|
+
var _discount2;
|
|
367
|
+
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
368
|
+
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
369
|
+
if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
|
|
373
|
+
return Number.isFinite(percent) ? percent : undefined;
|
|
374
|
+
};
|
|
349
375
|
var editModeDiscount = [];
|
|
350
376
|
var addModeDiscount = [];
|
|
351
377
|
discountList.forEach(function (discount) {
|
|
@@ -374,11 +400,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
374
400
|
}
|
|
375
401
|
});
|
|
376
402
|
}
|
|
377
|
-
|
|
378
|
-
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
|
|
379
|
-
var filteredDiscountList = addModeDiscount.filter(function (discount) {
|
|
380
|
-
return !discount.isManualSelect;
|
|
381
|
-
});
|
|
382
403
|
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
404
|
if (!hasDiscountInput) {
|
|
384
405
|
return {
|
|
@@ -386,6 +407,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
386
407
|
productList: productList
|
|
387
408
|
};
|
|
388
409
|
}
|
|
410
|
+
var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
|
|
411
|
+
var discountType = discount.tag || discount.type;
|
|
412
|
+
return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
|
|
416
|
+
// Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
|
|
417
|
+
var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
|
|
418
|
+
return !discount.isManualSelect;
|
|
419
|
+
})), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
|
|
389
420
|
|
|
390
421
|
// 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
|
|
391
422
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
@@ -1072,7 +1103,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1072
1103
|
if (_this3.isItemRewardProductDiscount(product)) return false;
|
|
1073
1104
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1074
1105
|
var discountType = discount.tag || discount.type;
|
|
1075
|
-
|
|
1106
|
+
var currentOriginUid = getOriginProductUid(originProduct);
|
|
1107
|
+
var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
|
|
1108
|
+
if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
|
|
1109
|
+
var uid = currentOriginUid;
|
|
1110
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
1111
|
+
if (!discount.isSelected) return false;
|
|
1112
|
+
}
|
|
1113
|
+
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
|
|
1076
1114
|
var _discount$config2;
|
|
1077
1115
|
// 如果策略检查后没有config,说明不可用
|
|
1078
1116
|
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
|
|
@@ -1304,7 +1342,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1304
1342
|
}
|
|
1305
1343
|
return;
|
|
1306
1344
|
}
|
|
1307
|
-
|
|
1345
|
+
var shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
|
|
1346
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
|
|
1308
1347
|
return;
|
|
1309
1348
|
}
|
|
1310
1349
|
|
|
@@ -1345,7 +1384,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1345
1384
|
}));
|
|
1346
1385
|
}
|
|
1347
1386
|
for (var i = 0; i < splitCount; i++) {
|
|
1348
|
-
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
|
|
1387
|
+
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
|
|
1349
1388
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
1350
1389
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1351
1390
|
// 标记优惠券为已使用
|
|
@@ -1383,11 +1422,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1383
1422
|
var productDiscountDifference = void 0;
|
|
1384
1423
|
var discountedOptions = product.options;
|
|
1385
1424
|
var optionDiscountAmount = 0;
|
|
1425
|
+
var reapplyDiscountPercent = void 0;
|
|
1386
1426
|
if (isOrderLevel && productAllocation) {
|
|
1387
1427
|
// order_level:使用预计算的分摊金额
|
|
1388
1428
|
amount = productAllocation.discountAmount;
|
|
1389
1429
|
productDiscountDifference = productAllocation.difference;
|
|
1390
1430
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1431
|
+
} else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1432
|
+
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1433
|
+
var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
|
|
1434
|
+
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1435
|
+
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1436
|
+
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
1391
1437
|
} else {
|
|
1392
1438
|
// item_level 或其他类型:使用原有逻辑
|
|
1393
1439
|
mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
|
|
@@ -1420,7 +1466,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1420
1466
|
title: _selectedDiscount.format_title,
|
|
1421
1467
|
original_amount: product.price,
|
|
1422
1468
|
product_id: originProduct.id || originProduct.product_id,
|
|
1423
|
-
percent: _selectedDiscount.par_value,
|
|
1469
|
+
percent: (_reapplyDiscountPerce = reapplyDiscountPercent) !== null && _reapplyDiscountPerce !== void 0 ? _reapplyDiscountPerce : _selectedDiscount.par_value,
|
|
1424
1470
|
discount_product_id: _selectedDiscount.product_id
|
|
1425
1471
|
},
|
|
1426
1472
|
// 前端使用的num数量,为了计算优惠金额
|
|
@@ -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 事件触发
|