@pisell/pisellos 0.0.229 → 0.0.231

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 (65) hide show
  1. package/dist/modules/Order/index.d.ts +13 -2
  2. package/dist/modules/Order/index.js +84 -1
  3. package/dist/modules/Order/types.d.ts +43 -0
  4. package/dist/modules/Order/types.js +8 -0
  5. package/dist/modules/Payment/cash.d.ts +8 -0
  6. package/dist/modules/Payment/cash.js +20 -1
  7. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  8. package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
  9. package/dist/modules/Payment/eftpos.js +1 -1
  10. package/dist/modules/Payment/index.d.ts +57 -94
  11. package/dist/modules/Payment/index.js +810 -1109
  12. package/dist/modules/Payment/mx51.d.ts +0 -0
  13. package/dist/modules/Payment/mx51.js +0 -0
  14. package/dist/modules/Payment/types.d.ts +358 -50
  15. package/dist/modules/Payment/types.js +103 -4
  16. package/dist/modules/Payment/utils.d.ts +17 -0
  17. package/dist/modules/Payment/utils.js +62 -0
  18. package/dist/modules/Payment/walletpass.d.ts +96 -0
  19. package/dist/modules/Payment/walletpass.js +492 -0
  20. package/dist/modules/Schedule/index.d.ts +9 -0
  21. package/dist/modules/Schedule/index.js +60 -0
  22. package/dist/solution/BookingTicket/index.d.ts +1 -1
  23. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  24. package/dist/solution/Checkout/index.d.ts +415 -0
  25. package/dist/solution/Checkout/index.js +3622 -0
  26. package/dist/solution/Checkout/types.d.ts +737 -0
  27. package/dist/solution/Checkout/types.js +137 -0
  28. package/dist/solution/Checkout/utils/index.d.ts +73 -0
  29. package/dist/{modules/Payment/wallet.js → solution/Checkout/utils/index.js} +363 -70
  30. package/dist/solution/index.d.ts +1 -0
  31. package/dist/solution/index.js +2 -1
  32. package/lib/modules/Order/index.d.ts +13 -2
  33. package/lib/modules/Order/index.js +58 -1
  34. package/lib/modules/Order/types.d.ts +43 -0
  35. package/lib/modules/Payment/cash.d.ts +8 -0
  36. package/lib/modules/Payment/cash.js +14 -1
  37. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  38. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  39. package/lib/modules/Payment/eftpos.js +1 -1
  40. package/lib/modules/Payment/index.d.ts +57 -94
  41. package/lib/modules/Payment/index.js +363 -525
  42. package/lib/modules/Payment/mx51.d.ts +0 -0
  43. package/lib/modules/Payment/mx51.js +0 -0
  44. package/lib/modules/Payment/types.d.ts +358 -50
  45. package/lib/modules/Payment/types.js +37 -2
  46. package/lib/modules/Payment/utils.d.ts +17 -0
  47. package/lib/modules/Payment/utils.js +67 -0
  48. package/lib/modules/Payment/walletpass.d.ts +96 -0
  49. package/lib/modules/Payment/walletpass.js +304 -0
  50. package/lib/modules/Schedule/index.d.ts +9 -0
  51. package/lib/modules/Schedule/index.js +36 -0
  52. package/lib/solution/BookingTicket/index.d.ts +1 -1
  53. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  54. package/lib/solution/Checkout/index.d.ts +415 -0
  55. package/lib/solution/Checkout/index.js +2107 -0
  56. package/lib/solution/Checkout/types.d.ts +737 -0
  57. package/lib/solution/Checkout/types.js +80 -0
  58. package/lib/solution/Checkout/utils/index.d.ts +73 -0
  59. package/lib/solution/Checkout/utils/index.js +266 -0
  60. package/lib/solution/index.d.ts +1 -0
  61. package/lib/solution/index.js +3 -1
  62. package/package.json +1 -1
  63. package/dist/modules/Payment/wallet.d.ts +0 -11
  64. package/lib/modules/Payment/wallet.d.ts +0 -11
  65. package/lib/modules/Payment/wallet.js +0 -51
@@ -1,6 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { RequestPlugin } from '../../plugins';
2
3
  import { BaseModule } from '../BaseModule';
3
- import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPayment } from './types';
4
+ import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval } from './types';
4
5
  export * from './types';
5
6
  export { generateRequestUniqueId };
6
7
  /**
@@ -12,40 +13,19 @@ declare function generateRequestUniqueId(): string;
12
13
  /**
13
14
  * 支付模块实现
14
15
  *
15
- * 支付流程说明:
16
- * 1. 用户操作 → 调用支付API (pushPaymentAsync, submitPayAsync等)
17
- * 2. 数据处理 → 更新本地IndexDB中的订单和支付项数据
18
- * 3. 立即完成 → 本地订单状态立即更新为PaymentStatus.Finished(isSynced保持false)
19
- * 4. 后台同步 → 网络请求推送到TasksManager异步同步到服务器
20
- * 5. 同步成功 → 网络请求成功后,isSynced设为true
21
- * 6. 自动重试 → TasksManager自动重试失败的网络请求,直到isSynced为true
22
- *
23
- * 数据状态说明:
24
- * - PaymentStatus.Processing: 订单正在进行支付操作
25
- * - PaymentStatus.PartiallyPaid + isSynced=false: 部分支付完成,等待服务器同步
26
- * - PaymentStatus.PartiallyPaid + isSynced=true: 部分支付且已同步到服务器
27
- * - PaymentStatus.Finished + isSynced=false: 本地支付完成,等待服务器同步
28
- * - PaymentStatus.Finished + isSynced=true: 支付完成且已同步到服务器
29
- *
30
- * 这种设计的优势:
31
- * - 即时反馈:支付操作后立即显示完成状态,用户体验更佳
32
- * - 离线支持:即使网络断开也能正常操作,数据保存在本地
33
- * - 同步追踪:通过isSynced清楚知道哪些数据还未同步到服务器
34
- * - 自动重试:TasksManager会自动重试失败的网络请求
35
- * - 异步处理:不阻塞用户界面,网络同步在后台进行
36
- * - 数据一致性:通过事件系统确保数据状态同步
16
+ * 负责处理支付相关的数据管理和本地存储
37
17
  */
38
18
  export declare class PaymentModule extends BaseModule implements Module, PaymentModuleAPI {
39
19
  protected defaultName: string;
40
20
  protected defaultVersion: string;
41
- private request;
21
+ request: RequestPlugin;
42
22
  private app;
43
23
  private store;
44
24
  private dbManager;
45
25
  private logger;
46
26
  cash: CashPayment;
47
27
  eftpos: EftposPayment;
48
- wallet: WalletPayment;
28
+ wallet: WalletPassPayment;
49
29
  constructor(name?: string, version?: string);
50
30
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
51
31
  /**
@@ -86,33 +66,62 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
86
66
  */
87
67
  getOrderListAsync(): Promise<PaymentOrder[]>;
88
68
  /**
89
- * 根据uuid获取指定订单
69
+ * 根据订单UUID获取支付订单(新方法)
90
70
  */
91
- getOrderByUuidAsync(orderUuid: string): Promise<PaymentOrder | null>;
71
+ getPaymentOrderByUuidAsync(orderUuid: string): Promise<PaymentOrder | null>;
92
72
  /**
93
- * 往交易组中添加订单
73
+ * 创建支付订单(新方法,专注支付数据)
94
74
  */
95
- pushOrderAsync(params: PushOrderParams): Promise<PaymentOrder>;
75
+ createPaymentOrderAsync(params: PushOrderParams): Promise<PaymentOrder>;
96
76
  /**
97
- * 删除订单
77
+ * 删除支付订单(新方法)
98
78
  */
99
- deleteOrderAsync(orderUuid: string): Promise<void>;
79
+ deletePaymentOrderAsync(orderUuid: string): Promise<void>;
100
80
  /**
101
81
  * 更新订单
102
82
  */
103
83
  updateOrderAsync(orderUuid: string, params: Partial<PaymentOrder>): Promise<void>;
104
84
  /**
105
- * 获取支付项
85
+ * 基于UUID替换订单ID
86
+ *
87
+ * 此方法用于将本地虚拟订单ID替换为真实的订单ID。
88
+ * 当前端模拟下单流程完成后,后端返回真实订单ID时调用此方法。
89
+ *
90
+ * @param orderUuid 订单的UUID
91
+ * @param newOrderId 新的订单ID (来自后端)
92
+ * @returns 更新后的订单对象,如果订单不存在则返回null
93
+ */
94
+ replaceOrderIdByUuidAsync(orderUuid: string, newOrderId: string): Promise<PaymentOrder | null>;
95
+ /**
96
+ * 获取支付项(新方法)
97
+ *
98
+ * @param orderUuid 订单UUID
99
+ * @param includeVoided 是否包含已撤销的支付项,默认为false
100
+ * @returns 支付项数组
106
101
  */
107
- getPaymentAsync(orderUuid: string): Promise<PaymentItem[]>;
102
+ getPaymentItemsAsync(orderUuid: string, includeVoided?: boolean): Promise<PaymentItem[]>;
108
103
  /**
109
- * 为某个订单设置一个支付项
104
+ * 获取所有支付项(包括已撤销的)
105
+ *
106
+ * @param orderUuid 订单UUID
107
+ * @returns 所有支付项数组(包括撤销的)
110
108
  */
111
- pushPaymentAsync(orderUuid: string, paymentItem: PaymentItemInput): Promise<void>;
109
+ getAllPaymentItemsAsync(orderUuid: string): Promise<PaymentItem[]>;
112
110
  /**
113
- * 删除一个支付项
111
+ * 为某个订单添加支付项(新方法)
112
+ */
113
+ addPaymentItemAsync(orderUuid: string, paymentItem: PaymentItemInput): Promise<void>;
114
+ /**
115
+ * 删除一个支付项 - 标记删除而非物理删除
114
116
  */
115
117
  deletePaymentAsync(orderUuid: string, paymentUuid: string): Promise<void>;
118
+ /**
119
+ * 批量更新代金券类支付项(覆盖更新)
120
+ *
121
+ * 删除所有现有的带 voucher_id 的支付项,然后添加新的代金券支付项
122
+ * 这是一个覆盖式更新,确保代金券支付项的一致性
123
+ */
124
+ updateVoucherPaymentItemsAsync(orderUuid: string, voucherPaymentItems: PaymentItemInput[]): Promise<void>;
116
125
  /**
117
126
  * 更新一个支付项
118
127
  */
@@ -127,10 +136,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
127
136
  * 提交单个订单的支付(推送到任务队列)
128
137
  */
129
138
  private submitSingleOrderPayment;
130
- /**
131
- * 添加到同步任务队列
132
- */
133
- private addToSyncQueue;
134
139
  /**
135
140
  * 获取订单剩余待付金额
136
141
  */
@@ -155,15 +160,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
155
160
  * 获取钱包支付方式
156
161
  */
157
162
  getWalletPaymentMethod(): Promise<PaymentMethod | null>;
158
- /**
159
- * 注册任务处理函数
160
- */
161
- private registerTaskHandlers;
162
- /**
163
- * 静态方法:处理支付同步任务(后台网络同步)
164
- * 这个方法里不允许用 this,因为需要作为静态方法注入到任务队列里
165
- */
166
- static syncPaymentTask(payload: any): Promise<any>;
167
163
  /**
168
164
  * 确保支付模块所需的数据库表已创建
169
165
  */
@@ -173,55 +169,22 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
173
169
  */
174
170
  getPartiallyPaidOrdersAsync(): Promise<PaymentOrder[]>;
175
171
  /**
176
- * 获取未同步到服务器的订单
177
- */
178
- getUnsyncedOrdersAsync(): Promise<PaymentOrder[]>;
179
- /**
180
- * 清理已完成且已同步的订单
181
- * 注意:只清理完全支付的订单,部分支付的订单保留以便继续支付
182
- */
183
- cleanupFinishedOrders(): Promise<void>;
184
- /**
185
- * 检测未同步的订单并重新加入任务队列
186
- *
187
- * 此方法专门用于处理因网络问题导致任务队列执行失败但队列被清空的情况。
188
- * 它会检查本地 IndexDB 中所有未同步的订单(isSynced: false),
189
- * 并将这些订单重新添加到任务队列中。
190
- *
191
- * 使用场景:
192
- * - 网络恢复后重新检查未同步的订单
193
- * - 应用启动时检查并重新排队未完成的支付
194
- * - 用户手动重试前的预检查
195
- *
196
- * @returns Promise<number> 返回重新加入队列的订单数量
197
- */
198
- recheckAndRequeueUnsyncedOrders(): Promise<number>;
199
- /**
200
- * 手动执行支付同步队列
201
- * 外部可以调用此方法来触发支付同步任务的执行
202
- *
203
- * 注意:此方法只执行现有队列中的任务,不会检查未同步的订单。
204
- * 如果需要检查未同步订单,请先调用 recheckAndRequeueUnsyncedOrders()
172
+ * 智能金额舍入
205
173
  *
206
- * 使用示例:
207
- * ```typescript
208
- * // 1. 先检查并重新排队未同步订单,然后执行队列
209
- * const requeuedCount = await paymentModule.recheckAndRequeueUnsyncedOrders();
210
- * if (requeuedCount > 0) {
211
- * await paymentModule.runPaymentSyncQueue();
212
- * }
174
+ * 根据指定的舍入间隔和规则对金额进行舍入处理
213
175
  *
214
- * // 2. 或者直接执行现有队列(不检查未同步订单)
215
- * await paymentModule.runPaymentSyncQueue();
216
- * ```
176
+ * @param originalAmount 原始金额
177
+ * @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
178
+ * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
179
+ * @returns 舍入后的金额(保留两位小数的字符串)
217
180
  */
218
- runPaymentSyncQueue(): Promise<void>;
181
+ roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<string>;
219
182
  /**
220
- * 重新将订单添加到同步队列
221
- * 用于处理因网络问题导致任务队列清空但订单未同步的情况
183
+ * 标准舍入处理(处理中点情况)
222
184
  *
223
- * @param order 要重新添加的订单
224
- * @returns Promise<boolean> 是否成功添加到队列
185
+ * @param value 要舍入的值
186
+ * @param midpointUp 中点是否向上舍入
187
+ * @returns 舍入后的值
225
188
  */
226
- private reAddOrderToSyncQueue;
189
+ private standardRound;
227
190
  }