@pisell/pisellos 0.0.192 → 0.0.194

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.
Files changed (161) hide show
  1. package/dist/modules/Cart/index.js +1 -1
  2. package/dist/modules/Payment/cash.d.ts +11 -0
  3. package/dist/modules/Payment/cash.js +78 -0
  4. package/dist/modules/Payment/eftpos.d.ts +11 -0
  5. package/dist/modules/Payment/eftpos.js +80 -0
  6. package/dist/modules/Payment/index.d.ts +175 -9
  7. package/dist/modules/Payment/index.js +1909 -102
  8. package/dist/modules/Payment/types.d.ts +351 -31
  9. package/dist/modules/Payment/types.js +116 -14
  10. package/dist/modules/Payment/wallet.d.ts +11 -0
  11. package/dist/modules/Payment/wallet.js +78 -0
  12. package/dist/plugins/app-types/app/app.d.ts +83 -0
  13. package/dist/plugins/app-types/app/const.d.ts +4 -0
  14. package/dist/plugins/app-types/app/index.d.ts +14 -0
  15. package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
  16. package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
  17. package/dist/plugins/app-types/config.d.ts +3 -0
  18. package/dist/plugins/app-types/cookie/index.d.ts +13 -0
  19. package/dist/plugins/app-types/data/index.d.ts +8 -0
  20. package/dist/plugins/app-types/history/config.d.ts +24 -0
  21. package/dist/plugins/app-types/history/index.d.ts +20 -0
  22. package/dist/plugins/app-types/history/type.d.ts +2 -0
  23. package/dist/plugins/app-types/hooks/index.d.ts +12 -0
  24. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  25. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  26. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  27. package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  28. package/dist/plugins/app-types/index.d.ts +6 -0
  29. package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
  30. package/dist/plugins/app-types/locales/en.d.ts +3 -0
  31. package/dist/plugins/app-types/locales/index.d.ts +37 -0
  32. package/dist/plugins/app-types/locales/original.d.ts +3 -0
  33. package/dist/plugins/app-types/locales/type.d.ts +19 -0
  34. package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
  35. package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
  36. package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
  37. package/dist/plugins/app-types/logger/index.d.ts +122 -0
  38. package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
  39. package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
  40. package/dist/plugins/app-types/models/global.d.ts +32 -0
  41. package/dist/plugins/app-types/models/index.d.ts +45 -0
  42. package/dist/plugins/app-types/models/type.d.ts +2 -0
  43. package/dist/plugins/app-types/package.json +15 -0
  44. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  45. package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
  46. package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
  47. package/dist/plugins/app-types/request/cache.d.ts +46 -0
  48. package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
  49. package/dist/plugins/app-types/request/config.d.ts +3 -0
  50. package/dist/plugins/app-types/request/constants.d.ts +2 -0
  51. package/dist/plugins/app-types/request/index.d.ts +24 -0
  52. package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
  53. package/dist/plugins/app-types/request/type.d.ts +41 -0
  54. package/dist/plugins/app-types/request/utils.d.ts +46 -0
  55. package/dist/plugins/app-types/routes/config.d.ts +7 -0
  56. package/dist/plugins/app-types/routes/index.d.ts +28 -0
  57. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  58. package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
  59. package/dist/plugins/app-types/socket/constants.d.ts +33 -0
  60. package/dist/plugins/app-types/socket/events.d.ts +31 -0
  61. package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
  62. package/dist/plugins/app-types/socket/index.d.ts +61 -0
  63. package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
  64. package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
  65. package/dist/plugins/app-types/socket/socket.d.ts +129 -0
  66. package/dist/plugins/app-types/socket/types.d.ts +85 -0
  67. package/dist/plugins/app-types/storage/index.d.ts +17 -0
  68. package/dist/plugins/app-types/tasks/index.d.ts +77 -0
  69. package/dist/plugins/app-types/tasks/type.d.ts +62 -0
  70. package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
  71. package/dist/plugins/app-types/type.d.ts +2 -0
  72. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  73. package/dist/plugins/app-types/variables/config.d.ts +3 -0
  74. package/dist/plugins/app-types/variables/index.d.ts +6 -0
  75. package/dist/plugins/app-types/variables/type.d.ts +2 -0
  76. package/dist/plugins/app-types/website/index.d.ts +6 -0
  77. package/dist/plugins/app.d.ts +8 -0
  78. package/dist/plugins/app.js +1 -0
  79. package/dist/solution/BookingByStep/index.js +1 -1
  80. package/dist/solution/BookingByStep/utils/resources.js +0 -1
  81. package/lib/modules/Cart/index.js +1 -1
  82. package/lib/modules/Payment/cash.d.ts +11 -0
  83. package/lib/modules/Payment/cash.js +51 -0
  84. package/lib/modules/Payment/eftpos.d.ts +11 -0
  85. package/lib/modules/Payment/eftpos.js +51 -0
  86. package/lib/modules/Payment/index.d.ts +175 -9
  87. package/lib/modules/Payment/index.js +962 -49
  88. package/lib/modules/Payment/types.d.ts +351 -31
  89. package/lib/modules/Payment/types.js +41 -6
  90. package/lib/modules/Payment/wallet.d.ts +11 -0
  91. package/lib/modules/Payment/wallet.js +51 -0
  92. package/lib/plugins/app-types/app/app.d.ts +83 -0
  93. package/lib/plugins/app-types/app/const.d.ts +4 -0
  94. package/lib/plugins/app-types/app/index.d.ts +14 -0
  95. package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
  96. package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
  97. package/lib/plugins/app-types/config.d.ts +3 -0
  98. package/lib/plugins/app-types/cookie/index.d.ts +13 -0
  99. package/lib/plugins/app-types/data/index.d.ts +8 -0
  100. package/lib/plugins/app-types/history/config.d.ts +24 -0
  101. package/lib/plugins/app-types/history/index.d.ts +20 -0
  102. package/lib/plugins/app-types/history/type.d.ts +2 -0
  103. package/lib/plugins/app-types/hooks/index.d.ts +12 -0
  104. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  105. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  106. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  107. package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  108. package/lib/plugins/app-types/index.d.ts +6 -0
  109. package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
  110. package/lib/plugins/app-types/locales/en.d.ts +3 -0
  111. package/lib/plugins/app-types/locales/index.d.ts +37 -0
  112. package/lib/plugins/app-types/locales/original.d.ts +3 -0
  113. package/lib/plugins/app-types/locales/type.d.ts +19 -0
  114. package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
  115. package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
  116. package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
  117. package/lib/plugins/app-types/logger/index.d.ts +122 -0
  118. package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
  119. package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
  120. package/lib/plugins/app-types/models/global.d.ts +32 -0
  121. package/lib/plugins/app-types/models/index.d.ts +45 -0
  122. package/lib/plugins/app-types/models/type.d.ts +2 -0
  123. package/lib/plugins/app-types/package.json +15 -0
  124. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  125. package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
  126. package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
  127. package/lib/plugins/app-types/request/cache.d.ts +46 -0
  128. package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
  129. package/lib/plugins/app-types/request/config.d.ts +3 -0
  130. package/lib/plugins/app-types/request/constants.d.ts +2 -0
  131. package/lib/plugins/app-types/request/index.d.ts +24 -0
  132. package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
  133. package/lib/plugins/app-types/request/type.d.ts +41 -0
  134. package/lib/plugins/app-types/request/utils.d.ts +46 -0
  135. package/lib/plugins/app-types/routes/config.d.ts +7 -0
  136. package/lib/plugins/app-types/routes/index.d.ts +28 -0
  137. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  138. package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
  139. package/lib/plugins/app-types/socket/constants.d.ts +33 -0
  140. package/lib/plugins/app-types/socket/events.d.ts +31 -0
  141. package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
  142. package/lib/plugins/app-types/socket/index.d.ts +61 -0
  143. package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
  144. package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
  145. package/lib/plugins/app-types/socket/socket.d.ts +129 -0
  146. package/lib/plugins/app-types/socket/types.d.ts +85 -0
  147. package/lib/plugins/app-types/storage/index.d.ts +17 -0
  148. package/lib/plugins/app-types/tasks/index.d.ts +77 -0
  149. package/lib/plugins/app-types/tasks/type.d.ts +62 -0
  150. package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
  151. package/lib/plugins/app-types/type.d.ts +2 -0
  152. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  153. package/lib/plugins/app-types/variables/config.d.ts +3 -0
  154. package/lib/plugins/app-types/variables/index.d.ts +6 -0
  155. package/lib/plugins/app-types/variables/type.d.ts +2 -0
  156. package/lib/plugins/app-types/website/index.d.ts +6 -0
  157. package/lib/plugins/app.d.ts +8 -0
  158. package/lib/plugins/app.js +17 -0
  159. package/lib/solution/BookingByStep/index.js +1 -2
  160. package/lib/solution/BookingByStep/utils/resources.js +0 -1
  161. package/package.json +3 -1
@@ -1,47 +1,367 @@
1
- export declare enum PaymentHooks {
2
- OnPaymentInit = "payment:onPaymentInit",
3
- OnPaymentSuccess = "payment:onPaymentSuccess",
4
- OnPaymentFailure = "payment:onPaymentFailure",
5
- OnPaymentRefund = "payment:onPaymentRefund"
1
+ /**
2
+ * 支付相关类型定义
3
+ */
4
+ /**
5
+ * 支付方式枚举
6
+ */
7
+ export declare enum PaymentMethodType {
8
+ Cash = "CASHMANUAL",
9
+ Eftpos = "EFTPOS",
10
+ Wallet = "WALLET"
6
11
  }
7
12
  /**
8
- * 支付方式
13
+ * 支付状态枚举
9
14
  */
10
- export type PaymentMethod = 'credit_card' | 'debit_card' | 'paypal' | 'alipay' | 'wechat_pay' | 'bank_transfer';
15
+ export declare enum PaymentStatus {
16
+ /** 支付处理中 - 订单正在进行支付操作 */
17
+ Processing = "payment_processing",
18
+ /** 同步中 - 暂时不使用,为了向后兼容保留 */
19
+ Sync = "sync",
20
+ /** 部分支付 - 支付金额不足订单总金额 */
21
+ PartiallyPaid = "partially_paid",
22
+ /** 已完成 - 本地支付完成,后台自动同步到服务器 */
23
+ Finished = "finish"
24
+ }
11
25
  /**
12
- * 支付状态
26
+ * 任务状态枚举
27
+ */
28
+ export declare enum TaskRunStatus {
29
+ Pending = "pending",
30
+ Running = "running",
31
+ Success = "success",
32
+ Failed = "failed"
33
+ }
34
+ /**
35
+ * 支付方式信息
36
+ */
37
+ export interface PaymentMethod {
38
+ /** 支付方式ID */
39
+ id: number;
40
+ /** 支付方式代码 */
41
+ code: string;
42
+ /** 支付方式名称 */
43
+ name: string;
44
+ /** 支付方式类型 */
45
+ type: string;
46
+ /** 是否启用 */
47
+ enabled: boolean;
48
+ /** 其他配置信息 */
49
+ [key: string]: any;
50
+ }
51
+ /**
52
+ * 支付项
53
+ */
54
+ export interface PaymentItem {
55
+ /** 当前支付项的唯一 ID */
56
+ uuid: string;
57
+ /** 当前支付方式付出去多少钱 */
58
+ amount: string;
59
+ /** 支付类型,跟支付列表上对应的支付方式保持一致 */
60
+ code: string;
61
+ /** 支付类型id,跟支付列表上对应的支付方式保持一致 */
62
+ id: number;
63
+ /** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
64
+ name: string;
65
+ /** 支付类型type,跟支付列表上对应的支付方式保持一致 */
66
+ type: string;
67
+ /** 代金券、充值卡、积分卡等wallet pass id */
68
+ voucher_id?: string;
69
+ /** 拓展参数字段 */
70
+ metadata?: {
71
+ /** 钱箱 ID */
72
+ shop_wallet_pass_id?: string;
73
+ /** 唯一支付号 */
74
+ unique_payment_number?: string;
75
+ /** rouding规则 */
76
+ rounding_rule?: any;
77
+ };
78
+ /** rouding金额 */
79
+ rounding_amount?: string;
80
+ /** 三方支付手续费 */
81
+ service_charge?: {
82
+ percentage: string;
83
+ amount: string;
84
+ };
85
+ /** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
86
+ isSynced?: boolean;
87
+ /** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
88
+ syncError?: {
89
+ error: string;
90
+ errorCode?: string;
91
+ statusCode?: number;
92
+ timestamp: number;
93
+ };
94
+ }
95
+ /**
96
+ * 订单信息
13
97
  */
14
- export type PaymentStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded';
98
+ export interface OrderInfo {
99
+ /** 订单 id */
100
+ order_id: number;
101
+ /** 订单总金额 */
102
+ total_amount: string;
103
+ /** 是否是定金订单 */
104
+ is_deposit: number;
105
+ /** 定金金额 */
106
+ deposit_amount: string;
107
+ }
15
108
  /**
16
- * 支付信息
109
+ * 支付订单
17
110
  */
18
- export interface Payment {
19
- id: string;
20
- orderId: string;
21
- amount: number;
22
- currency: string;
23
- method: PaymentMethod;
24
- status: PaymentStatus;
25
- transactionId?: string;
26
- createdAt: Date;
27
- updatedAt: Date;
28
- metadata?: Record<string, any>;
111
+ export interface PaymentOrder {
112
+ /** 当前订单的唯一 ID */
113
+ uuid: string;
114
+ /** 订单ID */
115
+ id: number;
116
+ /** 订单信息 */
117
+ order_info: OrderInfo;
118
+ /** 支付状态 */
119
+ payment_status: PaymentStatus;
120
+ /** 支付项列表 */
121
+ payment: PaymentItem[];
122
+ /** 修改的支付项列表 */
123
+ adjust_offline_payments: PaymentItem[];
124
+ /** 总计金额 */
125
+ total_amount: string;
126
+ /** 待付金额 */
127
+ expect_amount: string;
128
+ /** 总税费 */
129
+ tax_fee: string;
29
130
  }
30
131
  /**
31
- * 支付模块状态
132
+ * 支付状态
32
133
  */
33
134
  export interface PaymentState {
34
- currentPayment: Payment | null;
35
- paymentHistory: Payment[];
36
135
  }
37
136
  /**
38
- * 支付模块 API
137
+ * 推送订单参数
138
+ */
139
+ export interface PushOrderParams {
140
+ /** 订单信息 */
141
+ order_info: OrderInfo;
142
+ }
143
+ /**
144
+ * 更新订单参数
145
+ */
146
+ export interface UpdateOrderParams {
147
+ /** 订单UUID */
148
+ uuid: string;
149
+ /** 更新的字段 */
150
+ [key: string]: any;
151
+ }
152
+ /**
153
+ * 支付项输入类型(允许 amount 为数字)
154
+ */
155
+ export interface PaymentItemInput {
156
+ /** 当前支付方式付出去多少钱 */
157
+ amount: string | number;
158
+ /** 支付类型,跟支付列表上对应的支付方式保持一致 */
159
+ code: string;
160
+ /** 支付类型id,跟支付列表上对应的支付方式保持一致 */
161
+ id: number;
162
+ /** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
163
+ name: string;
164
+ /** 支付类型type,跟支付列表上对应的支付方式保持一致 */
165
+ type: string;
166
+ /** 代金券、充值卡、积分卡等wallet pass id */
167
+ voucher_id?: string;
168
+ }
169
+ /**
170
+ * 推送支付项参数
171
+ */
172
+ export interface PushPaymentParams {
173
+ /** 订单UUID */
174
+ orderUuid: string;
175
+ /** 支付项信息 */
176
+ paymentItem: PaymentItemInput;
177
+ }
178
+ /**
179
+ * 更新支付项参数中的字段类型(允许 amount 为数字)
180
+ */
181
+ export interface PaymentUpdateFields {
182
+ /** 当前支付项的唯一 ID */
183
+ uuid?: string;
184
+ /** 当前支付方式付出去多少钱 */
185
+ amount?: string | number;
186
+ /** 支付类型,跟支付列表上对应的支付方式保持一致 */
187
+ code?: string;
188
+ /** 支付类型id,跟支付列表上对应的支付方式保持一致 */
189
+ id?: number;
190
+ /** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
191
+ name?: string;
192
+ /** 支付类型type,跟支付列表上对应的支付方式保持一致 */
193
+ type?: string;
194
+ /** 代金券、充值卡、积分卡等wallet pass id */
195
+ voucher_id?: string;
196
+ /** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
197
+ isSynced?: boolean;
198
+ /** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
199
+ syncError?: {
200
+ error: string;
201
+ errorCode?: string;
202
+ statusCode?: number;
203
+ timestamp: number;
204
+ };
205
+ }
206
+ /**
207
+ * 更新支付项参数
208
+ */
209
+ export interface UpdatePaymentParams {
210
+ /** 订单UUID */
211
+ orderUuid: string;
212
+ /** 支付项UUID */
213
+ paymentUuid: string;
214
+ /** 更新的字段 */
215
+ params: PaymentUpdateFields;
216
+ }
217
+ /**
218
+ * 删除支付项参数
219
+ */
220
+ export interface DeletePaymentParams {
221
+ /** 订单UUID */
222
+ orderUuid: string;
223
+ /** 支付项UUID */
224
+ paymentUuid: string;
225
+ }
226
+ /**
227
+ * 现金支付接口
228
+ */
229
+ export interface CashPayment {
230
+ /** 处理现金支付 */
231
+ processCashPayment: (amount: number, orderUuid: string) => Promise<void>;
232
+ /** 获取现金余额 */
233
+ getCashBalance: () => Promise<number>;
234
+ }
235
+ /**
236
+ * Eftpos支付接口
237
+ */
238
+ export interface EftposPayment {
239
+ /** 处理Eftpos支付 */
240
+ processEftposPayment: (amount: number, orderUuid: string) => Promise<void>;
241
+ /** 检查Eftpos设备状态 */
242
+ checkDeviceStatus: () => Promise<boolean>;
243
+ }
244
+ /**
245
+ * 钱包支付接口
246
+ */
247
+ export interface WalletPayment {
248
+ /** 处理钱包支付 */
249
+ processWalletPayment: (amount: number, orderUuid: string, voucherId?: string) => Promise<void>;
250
+ /** 获取钱包余额 */
251
+ getWalletBalance: (voucherId: string) => Promise<number>;
252
+ }
253
+ /**
254
+ * 支付模块API接口
39
255
  */
40
256
  export interface PaymentModuleAPI {
41
- processPayment: (paymentId: string) => Promise<void>;
42
- getPayment: (paymentId: string) => Promise<Payment>;
43
- getPaymentHistory: () => Promise<Payment[]>;
44
- refund: (paymentId: string) => Promise<void>;
45
- getAvailablePaymentMethods: () => PaymentMethod[];
46
- checkPaymentStatus: (paymentId: string) => Promise<PaymentStatus>;
257
+ /** 现金支付相关方法 */
258
+ cash: CashPayment;
259
+ /** Eftpos支付相关方法 */
260
+ eftpos: EftposPayment;
261
+ /** 钱包支付相关方法 */
262
+ wallet: WalletPayment;
263
+ /** 获取支付方式列表 */
264
+ getPayMethodListAsync: () => Promise<PaymentMethod[]>;
265
+ /** 获取订单列表 */
266
+ getOrderListAsync: () => Promise<PaymentOrder[]>;
267
+ /** 根据uuid获取指定订单 */
268
+ getOrderByUuidAsync: (orderUuid: string) => Promise<PaymentOrder | null>;
269
+ /** 往交易组中添加订单 */
270
+ pushOrderAsync: (params: PushOrderParams) => Promise<PaymentOrder>;
271
+ /** 删除订单 */
272
+ deleteOrderAsync: (orderUuid: string) => Promise<void>;
273
+ /** 更新订单 */
274
+ updateOrderAsync: (orderUuid: string, params: Partial<PaymentOrder>) => Promise<void>;
275
+ /** 获取支付项 */
276
+ getPaymentAsync: (orderUuid: string) => Promise<PaymentItem[]>;
277
+ /** 为某个订单设置一个支付项 */
278
+ pushPaymentAsync: (orderUuid: string, paymentItem: PaymentItemInput) => Promise<void>;
279
+ /** 删除一个支付项 */
280
+ deletePaymentAsync: (orderUuid: string, paymentUuid: string) => Promise<void>;
281
+ /** 更新一个支付项 */
282
+ updatePaymentAsync: (orderUuid: string, paymentUuid: string, params: PaymentUpdateFields) => Promise<void>;
283
+ /** 提交支付 */
284
+ submitPayAsync: (orderUuid?: string) => Promise<{
285
+ status: 'success' | 'failed';
286
+ }>;
287
+ /** 获取订单剩余待付金额 */
288
+ getRemainingOrderAmountAsync: (orderUuid: string) => Promise<number>;
289
+ /** 获取订单剩余待付金额(基于用户输入的金额) */
290
+ getRemainingOrderAmountWithInputAsync: (inputAmount: string | number, orderUuid: string) => Promise<number>;
291
+ /** 获取部分支付的订单 */
292
+ getPartiallyPaidOrdersAsync: () => Promise<PaymentOrder[]>;
293
+ /** 获取未同步到服务器的订单 */
294
+ getUnsyncedOrdersAsync: () => Promise<PaymentOrder[]>;
295
+ /** 手动执行支付同步队列 */
296
+ runPaymentSyncQueue: () => Promise<void>;
297
+ }
298
+ /**
299
+ * 订单变化事件数据
300
+ */
301
+ export interface OnOrderChangedEventData {
302
+ /** 操作类型 */
303
+ action: 'add' | 'delete' | 'update' | 'payment_add' | 'payment_delete' | 'payment_update' | 'submit';
304
+ /** 当前订单 */
305
+ order: PaymentOrder;
306
+ /** 原始订单(仅在 update 操作时提供) */
307
+ originalOrder?: PaymentOrder;
308
+ /** 相关的支付项(仅在 payment_* 操作时提供) */
309
+ paymentItem?: PaymentItem;
310
+ }
311
+ /**
312
+ * 支付方式变化事件数据
313
+ */
314
+ export interface OnPaymentMethodsChangedEventData {
315
+ /** 旧的支付方式列表 */
316
+ oldMethods: PaymentMethod[];
317
+ /** 新的支付方式列表 */
318
+ newMethods: PaymentMethod[];
319
+ }
320
+ /**
321
+ * 支付同步错误事件数据
322
+ */
323
+ export interface OnPaymentSyncErrorEventData {
324
+ /** 订单UUID */
325
+ orderUuid: string;
326
+ /** 订单ID */
327
+ orderId: number;
328
+ /** 错误信息 */
329
+ error: string;
330
+ /** 错误代码 */
331
+ errorCode?: string;
332
+ /** HTTP状态码 */
333
+ statusCode?: number;
334
+ /** 错误发生时间 */
335
+ timestamp: number;
336
+ /** 响应数据(当HTTP请求成功但业务失败时) */
337
+ responseData?: any;
338
+ }
339
+ /**
340
+ * 支付同步成功事件数据
341
+ */
342
+ export interface OnPaymentSyncSuccessEventData {
343
+ /** 订单UUID */
344
+ orderUuid: string;
345
+ /** 订单ID */
346
+ orderId: number;
347
+ /** 成功时间 */
348
+ timestamp: number;
349
+ }
350
+ /**
351
+ * 支付钩子事件
352
+ */
353
+ export declare enum PaymentHooks {
354
+ OnPaymentMethodsLoaded = "payment:onPaymentMethodsLoaded",
355
+ OnPaymentMethodsChanged = "payment:onPaymentMethodsChanged",
356
+ OnOrderChanged = "payment:onOrderChanged",
357
+ OnOrderAdded = "payment:onOrderAdded",
358
+ OnOrderUpdated = "payment:onOrderUpdated",
359
+ OnOrderDeleted = "payment:onOrderDeleted",
360
+ OnPaymentAdded = "payment:onPaymentAdded",
361
+ OnPaymentUpdated = "payment:onPaymentUpdated",
362
+ OnPaymentDeleted = "payment:onPaymentDeleted",
363
+ OnPaymentSubmitted = "payment:onPaymentSubmitted",
364
+ OnOrderAmountChanged = "payment:onOrderAmountChanged",
365
+ OnPaymentSyncError = "payment:onPaymentSyncError",
366
+ OnPaymentSyncSuccess = "payment:onPaymentSyncSuccess"
47
367
  }
@@ -1,33 +1,135 @@
1
- // import { Order } from '../Order/types'
1
+ /**
2
+ * 支付相关类型定义
3
+ */
2
4
 
3
- export var PaymentHooks = /*#__PURE__*/function (PaymentHooks) {
4
- PaymentHooks["OnPaymentInit"] = "payment:onPaymentInit";
5
- PaymentHooks["OnPaymentSuccess"] = "payment:onPaymentSuccess";
6
- PaymentHooks["OnPaymentFailure"] = "payment:onPaymentFailure";
7
- PaymentHooks["OnPaymentRefund"] = "payment:onPaymentRefund";
8
- return PaymentHooks;
5
+ /**
6
+ * 支付方式枚举
7
+ */
8
+ export var PaymentMethodType = /*#__PURE__*/function (PaymentMethodType) {
9
+ PaymentMethodType["Cash"] = "CASHMANUAL";
10
+ PaymentMethodType["Eftpos"] = "EFTPOS";
11
+ PaymentMethodType["Wallet"] = "WALLET";
12
+ return PaymentMethodType;
13
+ }({});
14
+
15
+ /**
16
+ * 支付状态枚举
17
+ */
18
+ export var PaymentStatus = /*#__PURE__*/function (PaymentStatus) {
19
+ PaymentStatus["Processing"] = "payment_processing";
20
+ PaymentStatus["Sync"] = "sync";
21
+ PaymentStatus["PartiallyPaid"] = "partially_paid";
22
+ PaymentStatus["Finished"] = "finish";
23
+ return PaymentStatus;
24
+ }({});
25
+
26
+ /**
27
+ * 任务状态枚举
28
+ */
29
+ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
30
+ TaskRunStatus["Pending"] = "pending";
31
+ TaskRunStatus["Running"] = "running";
32
+ TaskRunStatus["Success"] = "success";
33
+ TaskRunStatus["Failed"] = "failed";
34
+ return TaskRunStatus;
9
35
  }({});
10
36
 
11
37
  /**
12
- * 支付方式
38
+ * 支付方式信息
39
+ */
40
+
41
+ /**
42
+ * 支付项
43
+ */
44
+
45
+ /**
46
+ * 订单信息
13
47
  */
14
48
 
15
- // 银行转账
49
+ /**
50
+ * 支付订单
51
+ */
16
52
 
17
53
  /**
18
54
  * 支付状态
19
55
  */
20
56
 
21
- // 已退款
57
+ /**
58
+ * 推送订单参数
59
+ */
60
+
61
+ /**
62
+ * 更新订单参数
63
+ */
64
+
65
+ /**
66
+ * 支付项输入类型(允许 amount 为数字)
67
+ */
22
68
 
23
69
  /**
24
- * 支付信息
70
+ * 推送支付项参数
25
71
  */
26
72
 
27
73
  /**
28
- * 支付模块状态
74
+ * 更新支付项参数中的字段类型(允许 amount 为数字)
29
75
  */
30
76
 
31
77
  /**
32
- * 支付模块 API
33
- */
78
+ * 更新支付项参数
79
+ */
80
+
81
+ /**
82
+ * 删除支付项参数
83
+ */
84
+
85
+ /**
86
+ * 现金支付接口
87
+ */
88
+
89
+ /**
90
+ * Eftpos支付接口
91
+ */
92
+
93
+ /**
94
+ * 钱包支付接口
95
+ */
96
+
97
+ /**
98
+ * 支付模块API接口
99
+ */
100
+
101
+ /**
102
+ * 订单变化事件数据
103
+ */
104
+
105
+ /**
106
+ * 支付方式变化事件数据
107
+ */
108
+
109
+ /**
110
+ * 支付同步错误事件数据
111
+ */
112
+
113
+ /**
114
+ * 支付同步成功事件数据
115
+ */
116
+
117
+ /**
118
+ * 支付钩子事件
119
+ */
120
+ export var PaymentHooks = /*#__PURE__*/function (PaymentHooks) {
121
+ PaymentHooks["OnPaymentMethodsLoaded"] = "payment:onPaymentMethodsLoaded";
122
+ PaymentHooks["OnPaymentMethodsChanged"] = "payment:onPaymentMethodsChanged";
123
+ PaymentHooks["OnOrderChanged"] = "payment:onOrderChanged";
124
+ PaymentHooks["OnOrderAdded"] = "payment:onOrderAdded";
125
+ PaymentHooks["OnOrderUpdated"] = "payment:onOrderUpdated";
126
+ PaymentHooks["OnOrderDeleted"] = "payment:onOrderDeleted";
127
+ PaymentHooks["OnPaymentAdded"] = "payment:onPaymentAdded";
128
+ PaymentHooks["OnPaymentUpdated"] = "payment:onPaymentUpdated";
129
+ PaymentHooks["OnPaymentDeleted"] = "payment:onPaymentDeleted";
130
+ PaymentHooks["OnPaymentSubmitted"] = "payment:onPaymentSubmitted";
131
+ PaymentHooks["OnOrderAmountChanged"] = "payment:onOrderAmountChanged";
132
+ PaymentHooks["OnPaymentSyncError"] = "payment:onPaymentSyncError";
133
+ PaymentHooks["OnPaymentSyncSuccess"] = "payment:onPaymentSyncSuccess";
134
+ return PaymentHooks;
135
+ }({});
@@ -0,0 +1,11 @@
1
+ import { WalletPayment } from './types';
2
+ import type { PaymentModule } from './index';
3
+ /**
4
+ * 钱包支付实现
5
+ */
6
+ export declare class WalletPaymentImpl implements WalletPayment {
7
+ private paymentModule;
8
+ constructor(paymentModule: PaymentModule);
9
+ processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
10
+ getWalletBalance(voucherId: string): Promise<number>;
11
+ }
@@ -0,0 +1,78 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ /**
11
+ * 钱包支付实现
12
+ */
13
+ export var WalletPaymentImpl = /*#__PURE__*/function () {
14
+ function WalletPaymentImpl(paymentModule) {
15
+ _classCallCheck(this, WalletPaymentImpl);
16
+ this.paymentModule = paymentModule;
17
+ }
18
+ _createClass(WalletPaymentImpl, [{
19
+ key: "processWalletPayment",
20
+ value: function () {
21
+ var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(amount, orderUuid, voucherId) {
22
+ var walletMethod, paymentItem;
23
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ _context.next = 2;
27
+ return this.paymentModule.getWalletPaymentMethod();
28
+ case 2:
29
+ walletMethod = _context.sent;
30
+ if (walletMethod) {
31
+ _context.next = 5;
32
+ break;
33
+ }
34
+ throw new Error('钱包支付方式未找到');
35
+ case 5:
36
+ paymentItem = {
37
+ amount: amount.toString(),
38
+ code: walletMethod.code,
39
+ id: walletMethod.id,
40
+ name: walletMethod.name,
41
+ type: walletMethod.type,
42
+ voucher_id: voucherId || ''
43
+ };
44
+ _context.next = 8;
45
+ return this.paymentModule.pushPaymentAsync(orderUuid, paymentItem);
46
+ case 8:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }, _callee, this);
51
+ }));
52
+ function processWalletPayment(_x, _x2, _x3) {
53
+ return _processWalletPayment.apply(this, arguments);
54
+ }
55
+ return processWalletPayment;
56
+ }()
57
+ }, {
58
+ key: "getWalletBalance",
59
+ value: function () {
60
+ var _getWalletBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(voucherId) {
61
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
62
+ while (1) switch (_context2.prev = _context2.next) {
63
+ case 0:
64
+ return _context2.abrupt("return", 0);
65
+ case 1:
66
+ case "end":
67
+ return _context2.stop();
68
+ }
69
+ }, _callee2);
70
+ }));
71
+ function getWalletBalance(_x4) {
72
+ return _getWalletBalance.apply(this, arguments);
73
+ }
74
+ return getWalletBalance;
75
+ }()
76
+ }]);
77
+ return WalletPaymentImpl;
78
+ }();