@pisell/pisellos 0.0.233 → 0.0.235

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 (37) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/modules/Order/index.js +1 -1
  3. package/dist/modules/Payment/index.d.ts +3 -3
  4. package/dist/modules/Payment/index.js +74 -10
  5. package/dist/modules/Payment/types.d.ts +24 -3
  6. package/dist/modules/Payment/types.js +9 -1
  7. package/dist/modules/Payment/utils.js +1 -1
  8. package/dist/modules/Payment/walletpass.d.ts +5 -2
  9. package/dist/modules/Payment/walletpass.js +63 -11
  10. package/dist/solution/BookingByStep/utils/timeslots.js +88 -38
  11. package/dist/solution/BookingTicket/index.d.ts +8 -0
  12. package/dist/solution/BookingTicket/index.js +27 -3
  13. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  14. package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
  15. package/dist/solution/Checkout/index.d.ts +50 -7
  16. package/dist/solution/Checkout/index.js +890 -474
  17. package/dist/solution/Checkout/types.d.ts +69 -3
  18. package/dist/solution/Checkout/types.js +5 -0
  19. package/lib/modules/Order/index.d.ts +1 -1
  20. package/lib/modules/Order/index.js +1 -1
  21. package/lib/modules/Payment/index.d.ts +3 -3
  22. package/lib/modules/Payment/index.js +30 -5
  23. package/lib/modules/Payment/types.d.ts +24 -3
  24. package/lib/modules/Payment/types.js +1 -1
  25. package/lib/modules/Payment/utils.js +1 -1
  26. package/lib/modules/Payment/walletpass.d.ts +5 -2
  27. package/lib/modules/Payment/walletpass.js +30 -2
  28. package/lib/solution/BookingByStep/utils/timeslots.js +38 -3
  29. package/lib/solution/BookingTicket/index.d.ts +8 -0
  30. package/lib/solution/BookingTicket/index.js +23 -2
  31. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  32. package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
  33. package/lib/solution/Checkout/index.d.ts +50 -7
  34. package/lib/solution/Checkout/index.js +267 -92
  35. package/lib/solution/Checkout/types.d.ts +69 -3
  36. package/lib/solution/Checkout/types.js +1 -0
  37. package/package.json +1 -1
@@ -20,7 +20,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
20
20
  import { BaseModule } from "../../modules/BaseModule";
21
21
  import { BookingTicketHooks, createModule } from "./types";
22
22
  import Scan from "./utils/scan";
23
- import { handleGlobalScan, handleCustomerScan } from "./utils/scan/handleScan";
23
+ import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
24
24
  import scanCache from "./utils/scan/scanCache";
25
25
  export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
26
26
  _inherits(BookingTicketImpl, _BaseModule);
@@ -503,7 +503,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
503
503
  try {
504
504
  callback(d);
505
505
  } catch (error) {
506
- console.error('scanGlobalListener回掉函数异常', error);
506
+ console.error('scanGlobalListener传入的回调函数异常', error);
507
507
  }
508
508
  };
509
509
  var listener = {
@@ -526,7 +526,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
526
526
  try {
527
527
  callback(d);
528
528
  } catch (error) {
529
- console.error('scanCustomerListener回掉函数异常', error);
529
+ console.error('scanCustomerListener传入的回调函数异常', error);
530
530
  }
531
531
  };
532
532
  var listener = {
@@ -537,6 +537,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
537
537
  return removeListener;
538
538
  }
539
539
 
540
+ /**
541
+ * @title 通用扫描监听
542
+ * @description 直接将扫描结果返回给调用方
543
+ * @param callback 回调
544
+ */
545
+ }, {
546
+ key: "scanUniversalListener",
547
+ value: function scanUniversalListener(callback, key) {
548
+ var scanCallback = handleUniversalScan();
549
+ var safeCallback = function safeCallback(d) {
550
+ try {
551
+ callback(d);
552
+ } catch (error) {
553
+ console.error("scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ".concat(key), error);
554
+ }
555
+ };
556
+ var listener = {
557
+ key: key,
558
+ callback: safeCallback
559
+ };
560
+ var removeListener = this.scan.addListener(listener, scanCallback);
561
+ return removeListener;
562
+ }
563
+
540
564
  /**
541
565
  * 调用摄像头
542
566
  * @param data 用户自定义数据
@@ -14,3 +14,9 @@ export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v:
14
14
  * @returns 处理结果
15
15
  */
16
16
  export declare const handleCustomerScan: () => () => Promise<{}>;
17
+ /**
18
+ * 处理钱包扫码
19
+ * @param request 请求插件
20
+ * @returns 处理结果
21
+ */
22
+ export declare const handleUniversalScan: () => () => Promise<{}>;
@@ -69,10 +69,14 @@ var handleScanFn = function handleScanFn(getRequestList, localSearch) {
69
69
  while (1) switch (_context2.prev = _context2.next) {
70
70
  case 0:
71
71
  _ref3 = scanResult || {}, value = _ref3.value; // 本地解析识别码
72
- _context2.prev = 1;
72
+ if (!localSearch) {
73
+ _context2.next = 15;
74
+ break;
75
+ }
76
+ _context2.prev = 2;
73
77
  localResult = localSearch === null || localSearch === void 0 ? void 0 : localSearch(value);
74
78
  if (!((localResult === null || localResult === void 0 ? void 0 : localResult.length) > 0)) {
75
- _context2.next = 8;
79
+ _context2.next = 9;
76
80
  break;
77
81
  }
78
82
  console.log('本地搜索到数据>>>>>>>', localResult);
@@ -84,58 +88,58 @@ var handleScanFn = function handleScanFn(getRequestList, localSearch) {
84
88
  }
85
89
  }
86
90
  });
87
- case 8:
88
- console.log('本地搜索无数据>>>>>>>');
89
91
  case 9:
90
- _context2.next = 14;
92
+ console.log('本地搜索无数据>>>>>>>');
93
+ case 10:
94
+ _context2.next = 15;
91
95
  break;
92
- case 11:
93
- _context2.prev = 11;
94
- _context2.t0 = _context2["catch"](1);
96
+ case 12:
97
+ _context2.prev = 12;
98
+ _context2.t0 = _context2["catch"](2);
95
99
  console.error('本地搜索到数据失败>>>>>>>', _context2.t0);
96
- case 14:
97
- _context2.prev = 14;
100
+ case 15:
101
+ _context2.prev = 15;
98
102
  if (!scanCache.has(value)) {
99
- _context2.next = 21;
103
+ _context2.next = 22;
100
104
  break;
101
105
  }
102
106
  result = scanCache.get(value);
103
107
  console.log('缓存中搜索到数据>>>>>>>', result);
104
108
  return _context2.abrupt("return", result);
105
- case 21:
106
- console.log('缓存中无数据>>>>>>>');
107
109
  case 22:
108
- _context2.next = 27;
110
+ console.log('缓存中无数据>>>>>>>');
111
+ case 23:
112
+ _context2.next = 28;
109
113
  break;
110
- case 24:
111
- _context2.prev = 24;
112
- _context2.t1 = _context2["catch"](14);
114
+ case 25:
115
+ _context2.prev = 25;
116
+ _context2.t1 = _context2["catch"](15);
113
117
  console.error('缓存中搜索数据失败>>>>>>>', _context2.t1);
114
- case 27:
118
+ case 28:
115
119
  requestList = (getRequestList === null || getRequestList === void 0 ? void 0 : getRequestList(value)) || [];
116
120
  if (!(requestList.length === 0)) {
117
- _context2.next = 30;
121
+ _context2.next = 31;
118
122
  break;
119
123
  }
120
124
  throw new Error('requestList is empty');
121
- case 30:
122
- _context2.prev = 30;
123
- _context2.next = 33;
125
+ case 31:
126
+ _context2.prev = 31;
127
+ _context2.next = 34;
124
128
  return promiseAny(requestList);
125
- case 33:
129
+ case 34:
126
130
  _result = _context2.sent;
127
131
  // 将结果缓存
128
132
  scanCache.set(value, _result);
129
133
  return _context2.abrupt("return", _result);
130
- case 38:
131
- _context2.prev = 38;
132
- _context2.t2 = _context2["catch"](30);
134
+ case 39:
135
+ _context2.prev = 39;
136
+ _context2.t2 = _context2["catch"](31);
133
137
  throw _context2.t2;
134
- case 41:
138
+ case 42:
135
139
  case "end":
136
140
  return _context2.stop();
137
141
  }
138
- }, _callee2, null, [[1, 11], [14, 24], [30, 38]]);
142
+ }, _callee2, null, [[2, 12], [15, 25], [31, 39]]);
139
143
  }));
140
144
  return function (_x2) {
141
145
  return _ref2.apply(this, arguments);
@@ -171,4 +175,15 @@ export var handleCustomerScan = function handleCustomerScan() {
171
175
  return function () {
172
176
  return Promise.resolve({});
173
177
  };
178
+ };
179
+
180
+ /**
181
+ * 处理钱包扫码
182
+ * @param request 请求插件
183
+ * @returns 处理结果
184
+ */
185
+ export var handleUniversalScan = function handleUniversalScan() {
186
+ return function () {
187
+ return Promise.resolve({});
188
+ };
174
189
  };
@@ -2,7 +2,7 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { OrderModule } from '../../modules/Order';
4
4
  import { PaymentModule } from '../../modules/Payment';
5
- import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo, CartSummaryItem, ExtractedAmountInfo } from './types';
5
+ import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo, CartSummaryItem, ExtractedAmountInfo, SendCustomerPayLinkParams } from './types';
6
6
  import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
7
7
  export * from './types';
8
8
  /**
@@ -251,11 +251,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
251
251
  customer_name?: string;
252
252
  } | null;
253
253
  /**
254
- * 检查订单是否需要手动同步
254
+ * 检查订单是否需要手动同步(异步版本)
255
255
  *
256
256
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
257
+ * 从 Payment 模块获取最新的支付项数据
257
258
  */
258
- needsManualSync(): boolean;
259
+ needsManualSyncAsync(): Promise<boolean>;
259
260
  /**
260
261
  * 手动同步订单到后端
261
262
  *
@@ -279,6 +280,25 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
279
280
  * @returns 当前订单的ID,如果没有订单则返回null
280
281
  */
281
282
  getCurrentOrderId(): string | null;
283
+ /**
284
+ * 获取当前订单是否已同步到后端
285
+ *
286
+ * @returns 当前订单是否已同步状态,如果没有订单则返回false
287
+ */
288
+ isCurrentOrderSynced(): boolean;
289
+ /**
290
+ * 取消当前本地订单
291
+ *
292
+ * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
293
+ *
294
+ * @param cancelReason 取消原因(可选)
295
+ * @returns 取消结果
296
+ */
297
+ cancelCurrentOrderAsync(cancelReason?: string): Promise<{
298
+ success: boolean;
299
+ message?: string;
300
+ orderId?: string;
301
+ }>;
282
302
  /**
283
303
  * 保存订单并稍后支付
284
304
  *
@@ -363,13 +383,13 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
363
383
  */
364
384
  private calculateTotalAmount;
365
385
  /**
366
- * 计算已支付金额
386
+ * 计算已支付金额(从 Payment 模块获取最新数据)
367
387
  */
368
- private calculatePaidAmount;
388
+ private calculatePaidAmountAsync;
369
389
  /**
370
- * 计算剩余未支付金额
390
+ * 计算剩余未支付金额(从 Payment 模块获取最新数据)
371
391
  */
372
- private calculateRemainingAmount;
392
+ private calculateRemainingAmountAsync;
373
393
  /**
374
394
  * 更新 stateAmount 为当前剩余未支付金额
375
395
  */
@@ -432,5 +452,28 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
432
452
  message?: string;
433
453
  orderId?: string | number;
434
454
  }>;
455
+ /**
456
+ * 发送客户支付链接邮件
457
+ *
458
+ * 向指定邮箱发送订单支付提醒邮件
459
+ *
460
+ * @param params 发送参数
461
+ * @returns 发送结果
462
+ */
463
+ sendCustomerPayLinkAsync(params: SendCustomerPayLinkParams): Promise<{
464
+ success: boolean;
465
+ message?: string;
466
+ }>;
467
+ /**
468
+ * 金额舍入
469
+ *
470
+ * @param amount 原始金额
471
+ * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
472
+ */
473
+ roundAmountAsync(amount: number): Promise<{
474
+ originalAmount: string;
475
+ roundedAmount: string;
476
+ roundingDifference: string;
477
+ }>;
435
478
  destroy(): Promise<void>;
436
479
  }