@pisell/pisellos 0.0.229 → 0.0.230
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/modules/Payment/index.d.ts +59 -6
- package/dist/modules/Payment/index.js +823 -504
- package/dist/modules/Payment/types.d.ts +62 -32
- package/dist/modules/Payment/types.js +2 -2
- package/dist/modules/Payment/walletpass.d.ts +0 -0
- package/dist/modules/Payment/walletpass.js +0 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +181 -0
- package/dist/solution/Checkout/index.js +1596 -0
- package/dist/solution/Checkout/types.d.ts +550 -0
- package/dist/solution/Checkout/types.js +132 -0
- package/dist/solution/Checkout/utils/index.d.ts +73 -0
- package/dist/solution/Checkout/utils/index.js +371 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/modules/Payment/index.d.ts +59 -6
- package/lib/modules/Payment/index.js +203 -64
- package/lib/modules/Payment/types.d.ts +62 -32
- package/lib/modules/Payment/walletpass.d.ts +0 -0
- package/lib/modules/Payment/walletpass.js +0 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +181 -0
- package/lib/solution/Checkout/index.js +864 -0
- package/lib/solution/Checkout/types.d.ts +550 -0
- package/lib/solution/Checkout/types.js +75 -0
- package/lib/solution/Checkout/utils/index.d.ts +73 -0
- package/lib/solution/Checkout/utils/index.js +266 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/package.json +1 -1
|
@@ -106,17 +106,15 @@ export interface OrderInfo {
|
|
|
106
106
|
deposit_amount: string;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
109
|
+
* 支付订单(简化版,仅保留支付相关信息)
|
|
110
110
|
*/
|
|
111
111
|
export interface PaymentOrder {
|
|
112
112
|
/** 当前订单的唯一 ID */
|
|
113
113
|
uuid: string;
|
|
114
|
-
/** 订单ID */
|
|
115
|
-
id:
|
|
116
|
-
/**
|
|
117
|
-
|
|
118
|
-
/** 支付状态 */
|
|
119
|
-
payment_status: PaymentStatus;
|
|
114
|
+
/** 订单ID(字符串类型,支持本地虚拟ID) */
|
|
115
|
+
id: string;
|
|
116
|
+
/** 订单ID(数字类型,兼容旧版本) */
|
|
117
|
+
order_id: string;
|
|
120
118
|
/** 支付项列表 */
|
|
121
119
|
payment: PaymentItem[];
|
|
122
120
|
/** 修改的支付项列表 */
|
|
@@ -125,8 +123,16 @@ export interface PaymentOrder {
|
|
|
125
123
|
total_amount: string;
|
|
126
124
|
/** 待付金额 */
|
|
127
125
|
expect_amount: string;
|
|
126
|
+
/** 支付状态 */
|
|
127
|
+
payment_status: PaymentStatus;
|
|
128
|
+
/** 是否是定金订单 */
|
|
129
|
+
is_deposit: number;
|
|
130
|
+
/** 定金金额 */
|
|
131
|
+
deposit_amount: string;
|
|
128
132
|
/** 总税费 */
|
|
129
133
|
tax_fee: string;
|
|
134
|
+
/** 原始订单数据(由 Checkout 模块传入) */
|
|
135
|
+
order_info?: any;
|
|
130
136
|
}
|
|
131
137
|
/**
|
|
132
138
|
* 支付状态
|
|
@@ -134,11 +140,19 @@ export interface PaymentOrder {
|
|
|
134
140
|
export interface PaymentState {
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
137
|
-
*
|
|
143
|
+
* 推送订单参数(简化版)
|
|
138
144
|
*/
|
|
139
145
|
export interface PushOrderParams {
|
|
140
|
-
/**
|
|
141
|
-
|
|
146
|
+
/** 订单ID */
|
|
147
|
+
order_id: string;
|
|
148
|
+
/** 总金额 */
|
|
149
|
+
total_amount: string;
|
|
150
|
+
/** 是否是定金订单 */
|
|
151
|
+
is_deposit?: number;
|
|
152
|
+
/** 定金金额 */
|
|
153
|
+
deposit_amount?: string;
|
|
154
|
+
/** 原始订单数据(可选,由 Checkout 模块传入) */
|
|
155
|
+
order_info?: any;
|
|
142
156
|
}
|
|
143
157
|
/**
|
|
144
158
|
* 更新订单参数
|
|
@@ -262,32 +276,30 @@ export interface PaymentModuleAPI {
|
|
|
262
276
|
wallet: WalletPayment;
|
|
263
277
|
/** 获取支付方式列表 */
|
|
264
278
|
getPayMethodListAsync: () => Promise<PaymentMethod[]>;
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
/** 更新订单 */
|
|
274
|
-
updateOrderAsync: (orderUuid: string, params: Partial<PaymentOrder>) => Promise<void>;
|
|
279
|
+
/** 创建支付订单(仅保存支付相关信息) */
|
|
280
|
+
createPaymentOrderAsync: (params: PushOrderParams) => Promise<PaymentOrder>;
|
|
281
|
+
/** 根据订单UUID获取支付订单 */
|
|
282
|
+
getPaymentOrderByUuidAsync: (orderUuid: string) => Promise<PaymentOrder | null>;
|
|
283
|
+
/** 基于UUID替换订单ID */
|
|
284
|
+
replaceOrderIdByUuidAsync: (orderUuid: string, newOrderId: string) => Promise<PaymentOrder | null>;
|
|
285
|
+
/** 删除支付订单 */
|
|
286
|
+
deletePaymentOrderAsync: (orderUuid: string) => Promise<void>;
|
|
275
287
|
/** 获取支付项 */
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
|
|
288
|
+
getPaymentItemsAsync: (orderUuid: string) => Promise<PaymentItem[]>;
|
|
289
|
+
/** 为某个订单添加支付项 */
|
|
290
|
+
addPaymentItemAsync: (orderUuid: string, paymentItem: PaymentItemInput) => Promise<void>;
|
|
291
|
+
/** 删除支付项 */
|
|
292
|
+
deletePaymentItemAsync: (orderUuid: string, paymentUuid: string) => Promise<void>;
|
|
293
|
+
/** 更新支付项 */
|
|
294
|
+
updatePaymentItemAsync: (orderUuid: string, paymentUuid: string, params: PaymentUpdateFields) => Promise<void>;
|
|
295
|
+
/** 获取订单剩余待付金额 */
|
|
296
|
+
getRemainingAmountAsync: (orderUuid: string) => Promise<number>;
|
|
297
|
+
/** 获取订单剩余待付金额(基于用户输入的金额) */
|
|
298
|
+
getRemainingAmountWithInputAsync: (inputAmount: string | number, orderUuid: string) => Promise<number>;
|
|
283
299
|
/** 提交支付 */
|
|
284
|
-
|
|
300
|
+
submitPaymentAsync: (orderUuid: string) => Promise<{
|
|
285
301
|
status: 'success' | 'failed';
|
|
286
302
|
}>;
|
|
287
|
-
/** 获取订单剩余待付金额 */
|
|
288
|
-
getRemainingOrderAmountAsync: (orderUuid: string) => Promise<number>;
|
|
289
|
-
/** 获取订单剩余待付金额(基于用户输入的金额) */
|
|
290
|
-
getRemainingOrderAmountWithInputAsync: (inputAmount: string | number, orderUuid: string) => Promise<number>;
|
|
291
303
|
/** 获取部分支付的订单 */
|
|
292
304
|
getPartiallyPaidOrdersAsync: () => Promise<PaymentOrder[]>;
|
|
293
305
|
/** 获取未同步到服务器的订单 */
|
|
@@ -296,6 +308,24 @@ export interface PaymentModuleAPI {
|
|
|
296
308
|
recheckAndRequeueUnsyncedOrders: () => Promise<number>;
|
|
297
309
|
/** 手动执行支付同步队列 */
|
|
298
310
|
runPaymentSyncQueue: () => Promise<void>;
|
|
311
|
+
/** @deprecated 使用 createPaymentOrderAsync 替代 */
|
|
312
|
+
pushOrderAsync: (params: PushOrderParams) => Promise<PaymentOrder>;
|
|
313
|
+
/** @deprecated 使用 getPaymentItemsAsync 替代 */
|
|
314
|
+
getPaymentAsync: (orderUuid: string) => Promise<PaymentItem[]>;
|
|
315
|
+
/** @deprecated 使用 addPaymentItemAsync 替代 */
|
|
316
|
+
pushPaymentAsync: (orderUuid: string, paymentItem: PaymentItemInput) => Promise<void>;
|
|
317
|
+
/** @deprecated 使用 deletePaymentItemAsync 替代 */
|
|
318
|
+
deletePaymentAsync: (orderUuid: string, paymentUuid: string) => Promise<void>;
|
|
319
|
+
/** @deprecated 使用 updatePaymentItemAsync 替代 */
|
|
320
|
+
updatePaymentAsync: (orderUuid: string, paymentUuid: string, params: PaymentUpdateFields) => Promise<void>;
|
|
321
|
+
/** @deprecated 使用 submitPaymentAsync 替代 */
|
|
322
|
+
submitPayAsync: (orderUuid?: string) => Promise<{
|
|
323
|
+
status: 'success' | 'failed';
|
|
324
|
+
}>;
|
|
325
|
+
/** @deprecated 使用 getRemainingAmountAsync 替代 */
|
|
326
|
+
getRemainingOrderAmountAsync: (orderUuid: string) => Promise<number>;
|
|
327
|
+
/** @deprecated 使用 getRemainingAmountWithInputAsync 替代 */
|
|
328
|
+
getRemainingOrderAmountWithInputAsync: (inputAmount: string | number, orderUuid: string) => Promise<number>;
|
|
299
329
|
}
|
|
300
330
|
/**
|
|
301
331
|
* 订单变化事件数据
|
|
@@ -47,7 +47,7 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
|
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* 支付订单(简化版,仅保留支付相关信息)
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -55,7 +55,7 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
|
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* 推送订单参数(简化版)
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
61
|
/**
|
|
File without changes
|
|
File without changes
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"appointment_booking","platform":"PC","sales_channel":"my_pisel","order_sales_channel":"online_store","bookings":[{"id":0,"number":1,"registration_type":"all","relation_products":[],"is_all":false,"product":{"num":1,"product_id":61170,"product_variant_id":0,"product_bundle":[],"product_option_item":[],"discount_list":[{"amount":100,"type":"good_pass","discount":{"resource_id":64523,"title":{"auto":"玄-商品券","original":"玄-商品券","en":null,"zh-CN":null,"zh-HK":null},"original_amount":100,"product_id":61170,"percent":"1.00"}}]},"sub_type":"minutes","duration":480,"like_status":"common","resources":[{"relation_type":"form","like_status":"common","form_id":35,"relation_id":40357,"capacity":1,"metadata":{"combined_resource":{"status":1,"resource_ids":[40262,40263]},"form_name":"桌台","resource_name":"组合资源测试table-0422-01"},"children":[{"relation_type":"form","like_status":"common","id":40262,"main_field":"A01(组合资源-小桌-4 人)","resourceType":"single","form_id":35,"relation_id":40262,"capacity":1,"metadata":{"combined_resource":null,"form_name":"桌台","resource_name":"A01(组合资源-小桌-4 人)"}},{"relation_type":"form","like_status":"common","id":40263,"main_field":"A02(组合资源-小桌-4 人)","resourceType":"single","form_id":35,"relation_id":40263,"capacity":0,"metadata":{"combined_resource":null,"form_name":"桌台","resource_name":"A02(组合资源-小桌-4 人)"}}]},{"relation_type":"form","like_status":"common","form_id":214,"relation_id":38350,"capacity":1,"metadata":{"combined_resource":null,"form_name":"校区2","resource_name":"West Campus"}}],"schedule_id":0,"start_date":"2025-08-22","start_time":"09:00","select_date":"2025-08-22","end_time":"17:00","end_date":"2025-08-22","metadata":{"account":{"id":13433,"username":"a a"},"capacity":[{"id":0,"value":1,"name":""}]},"holder":null,"relation_forms":[]}],"shop_note":"","schedule_date":"2025-08-22 09:00:00","is_deposit":0,"relation_products":[],"relation_forms":[]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
+
import { OrderModule } from '../../modules/Order';
|
|
4
|
+
import { PaymentModule } from '../../modules/Payment';
|
|
5
|
+
import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo } from './types';
|
|
6
|
+
import { PaymentOrder, PaymentMethod } from '../../modules/Payment/types';
|
|
7
|
+
export * from './types';
|
|
8
|
+
/**
|
|
9
|
+
* 结账解决方案实现
|
|
10
|
+
*
|
|
11
|
+
* 整合订单处理和支付功能,提供完整的结账流程管理。
|
|
12
|
+
* 支持多种支付方式,提供实时状态跟踪和错误处理。
|
|
13
|
+
*/
|
|
14
|
+
export declare class CheckoutImpl extends BaseModule implements Module, CheckoutModuleAPI {
|
|
15
|
+
protected defaultName: string;
|
|
16
|
+
protected defaultVersion: string;
|
|
17
|
+
isSolution: boolean;
|
|
18
|
+
private request;
|
|
19
|
+
private store;
|
|
20
|
+
private otherParams;
|
|
21
|
+
constructor(name?: string, version?: string);
|
|
22
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* 初始化子模块
|
|
25
|
+
*/
|
|
26
|
+
private initializeSubModules;
|
|
27
|
+
/**
|
|
28
|
+
* 设置支付模块事件监听
|
|
29
|
+
*/
|
|
30
|
+
private setupPaymentEventListeners;
|
|
31
|
+
/**
|
|
32
|
+
* 初始化结账流程
|
|
33
|
+
*/
|
|
34
|
+
initializeCheckoutAsync(params: CheckoutInitParams): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 创建本地订单 (前端模拟下单流程)
|
|
37
|
+
*
|
|
38
|
+
* 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
|
|
39
|
+
* 用户在购物车点击下单时,会把购物车参数传递给此方法,
|
|
40
|
+
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
41
|
+
*/
|
|
42
|
+
createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
|
|
43
|
+
/**
|
|
44
|
+
* 手动下单 (根据虚拟订单生成实际订单)
|
|
45
|
+
*
|
|
46
|
+
* 使用当前存储的本地订单数据调用 Order 模块创建真实订单
|
|
47
|
+
*/
|
|
48
|
+
placeOrderAsync(params?: PlaceOrderParams): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
orderId?: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* 创建订单
|
|
55
|
+
*/
|
|
56
|
+
createOrderAsync(params: CreateOrderParams): Promise<PaymentOrder>;
|
|
57
|
+
/**
|
|
58
|
+
* 处理支付
|
|
59
|
+
*/
|
|
60
|
+
processPaymentAsync(params: ProcessPaymentParams): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* 完成结账
|
|
63
|
+
*/
|
|
64
|
+
completeCheckoutAsync(): Promise<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
orderId?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* 取消结账
|
|
70
|
+
*/
|
|
71
|
+
cancelCheckoutAsync(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* 获取结账状态
|
|
74
|
+
*/
|
|
75
|
+
getCheckoutStatus(): CheckoutStatusInfo;
|
|
76
|
+
/**
|
|
77
|
+
* 获取结账摘要
|
|
78
|
+
*/
|
|
79
|
+
getCheckoutSummaryAsync(): Promise<CheckoutSummary>;
|
|
80
|
+
/**
|
|
81
|
+
* 获取可用支付方式
|
|
82
|
+
*/
|
|
83
|
+
getAvailablePaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
84
|
+
/**
|
|
85
|
+
* 刷新支付方式缓存
|
|
86
|
+
*
|
|
87
|
+
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
88
|
+
*/
|
|
89
|
+
refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
90
|
+
/**
|
|
91
|
+
* 获取当前订单基础信息
|
|
92
|
+
*
|
|
93
|
+
* 返回当前订单的基础信息,包括订单状态、金额、支付状态等
|
|
94
|
+
*/
|
|
95
|
+
getCurrentOrderInfo(): CurrentOrderInfo | null;
|
|
96
|
+
/**
|
|
97
|
+
* 验证结账前置条件
|
|
98
|
+
*/
|
|
99
|
+
validateCheckoutAsync(): Promise<{
|
|
100
|
+
valid: boolean;
|
|
101
|
+
errors: string[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* 重试失败的操作
|
|
105
|
+
*/
|
|
106
|
+
retryFailedOperationAsync(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* 设置当前步骤
|
|
109
|
+
*/
|
|
110
|
+
setCurrentStep(step: CheckoutStep): void;
|
|
111
|
+
/**
|
|
112
|
+
* 获取订单模块
|
|
113
|
+
*/
|
|
114
|
+
getOrderModule(): OrderModule;
|
|
115
|
+
/**
|
|
116
|
+
* 获取支付模块
|
|
117
|
+
*/
|
|
118
|
+
getPaymentModule(): PaymentModule;
|
|
119
|
+
/**
|
|
120
|
+
* 替换本地订单ID为真实订单ID
|
|
121
|
+
*
|
|
122
|
+
* 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
|
|
123
|
+
*
|
|
124
|
+
* @param newOrderId 后端返回的真实订单ID
|
|
125
|
+
* @returns 更新后的订单对象,如果当前没有订单则返回null
|
|
126
|
+
*/
|
|
127
|
+
replaceLocalOrderIdAsync(newOrderId: string): Promise<PaymentOrder | null>;
|
|
128
|
+
/**
|
|
129
|
+
* 设置状态
|
|
130
|
+
*/
|
|
131
|
+
private setStatus;
|
|
132
|
+
/**
|
|
133
|
+
* 设置步骤
|
|
134
|
+
*/
|
|
135
|
+
private setStep;
|
|
136
|
+
/**
|
|
137
|
+
* 处理错误
|
|
138
|
+
*/
|
|
139
|
+
private handleError;
|
|
140
|
+
/**
|
|
141
|
+
* 处理支付成功
|
|
142
|
+
*/
|
|
143
|
+
private handlePaymentSuccess;
|
|
144
|
+
/**
|
|
145
|
+
* 处理支付错误
|
|
146
|
+
*/
|
|
147
|
+
private handlePaymentError;
|
|
148
|
+
/**
|
|
149
|
+
* 验证结账参数
|
|
150
|
+
*/
|
|
151
|
+
private validateCheckoutParams;
|
|
152
|
+
/**
|
|
153
|
+
* 验证本地订单数据
|
|
154
|
+
*/
|
|
155
|
+
private validateLocalOrderData;
|
|
156
|
+
/**
|
|
157
|
+
* 生成本地订单ID
|
|
158
|
+
*/
|
|
159
|
+
private generateLocalOrderId;
|
|
160
|
+
/**
|
|
161
|
+
* 从购物车小计数据中提取金额信息
|
|
162
|
+
*/
|
|
163
|
+
private extractAmountFromCartSummary;
|
|
164
|
+
/**
|
|
165
|
+
* 预加载支付方式(在初始化时调用)
|
|
166
|
+
*/
|
|
167
|
+
private preloadPaymentMethods;
|
|
168
|
+
/**
|
|
169
|
+
* 计算总金额
|
|
170
|
+
*/
|
|
171
|
+
private calculateTotalAmount;
|
|
172
|
+
/**
|
|
173
|
+
* 计算已支付金额
|
|
174
|
+
*/
|
|
175
|
+
private calculatePaidAmount;
|
|
176
|
+
/**
|
|
177
|
+
* 获取状态消息
|
|
178
|
+
*/
|
|
179
|
+
private getStatusMessage;
|
|
180
|
+
destroy(): Promise<void>;
|
|
181
|
+
}
|