@pisell/pisellos 0.0.234 → 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 (31) hide show
  1. package/dist/modules/Payment/index.d.ts +3 -3
  2. package/dist/modules/Payment/index.js +74 -10
  3. package/dist/modules/Payment/types.d.ts +24 -3
  4. package/dist/modules/Payment/types.js +9 -1
  5. package/dist/modules/Payment/utils.js +1 -1
  6. package/dist/modules/Payment/walletpass.d.ts +5 -2
  7. package/dist/modules/Payment/walletpass.js +63 -11
  8. package/dist/solution/BookingTicket/index.d.ts +9 -1
  9. package/dist/solution/BookingTicket/index.js +27 -3
  10. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  11. package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
  12. package/dist/solution/Checkout/index.d.ts +50 -7
  13. package/dist/solution/Checkout/index.js +890 -474
  14. package/dist/solution/Checkout/types.d.ts +69 -3
  15. package/dist/solution/Checkout/types.js +5 -0
  16. package/lib/modules/Payment/index.d.ts +3 -3
  17. package/lib/modules/Payment/index.js +30 -5
  18. package/lib/modules/Payment/types.d.ts +24 -3
  19. package/lib/modules/Payment/types.js +1 -1
  20. package/lib/modules/Payment/utils.js +1 -1
  21. package/lib/modules/Payment/walletpass.d.ts +5 -2
  22. package/lib/modules/Payment/walletpass.js +30 -2
  23. package/lib/solution/BookingTicket/index.d.ts +9 -1
  24. package/lib/solution/BookingTicket/index.js +23 -2
  25. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
  26. package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
  27. package/lib/solution/Checkout/index.d.ts +50 -7
  28. package/lib/solution/Checkout/index.js +267 -92
  29. package/lib/solution/Checkout/types.d.ts +69 -3
  30. package/lib/solution/Checkout/types.js +1 -0
  31. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { RequestPlugin } from '../../plugins';
3
3
  import { BaseModule } from '../BaseModule';
4
- import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval } from './types';
4
+ import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
5
5
  export * from './types';
6
6
  export { generateRequestUniqueId };
7
7
  /**
@@ -176,9 +176,9 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
176
176
  * @param originalAmount 原始金额
177
177
  * @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
178
178
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
179
- * @returns 舍入后的金额(保留两位小数的字符串)
179
+ * @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
180
180
  */
181
- roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<string>;
181
+ roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<RoundingResult>;
182
182
  /**
183
183
  * 标准舍入处理(处理中点情况)
184
184
  *
@@ -506,7 +506,64 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
506
506
  }
507
507
 
508
508
  // 检查关键字段是否有变化
509
- if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.enabled !== newMethod.enabled) {
509
+ if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
510
+ console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F ".concat(newMethod.id, " (").concat(newMethod.code, ") \u53D1\u751F\u53D8\u5316:"), {
511
+ id: newMethod.id,
512
+ changes: {
513
+ code: oldMethod.code !== newMethod.code ? {
514
+ old: oldMethod.code,
515
+ new: newMethod.code
516
+ } : undefined,
517
+ name: oldMethod.name !== newMethod.name ? {
518
+ old: oldMethod.name,
519
+ new: newMethod.name
520
+ } : undefined,
521
+ type: oldMethod.type !== newMethod.type ? {
522
+ old: oldMethod.type,
523
+ new: newMethod.type
524
+ } : undefined,
525
+ description: oldMethod.description !== newMethod.description ? {
526
+ old: oldMethod.description,
527
+ new: newMethod.description
528
+ } : undefined,
529
+ status: oldMethod.status !== newMethod.status ? {
530
+ old: oldMethod.status,
531
+ new: newMethod.status
532
+ } : undefined,
533
+ disable: oldMethod.disable !== newMethod.disable ? {
534
+ old: oldMethod.disable,
535
+ new: newMethod.disable
536
+ } : undefined,
537
+ is_surcharge: oldMethod.is_surcharge !== newMethod.is_surcharge ? {
538
+ old: oldMethod.is_surcharge,
539
+ new: newMethod.is_surcharge
540
+ } : undefined,
541
+ fixed: oldMethod.fixed !== newMethod.fixed ? {
542
+ old: oldMethod.fixed,
543
+ new: newMethod.fixed
544
+ } : undefined,
545
+ percentage: oldMethod.percentage !== newMethod.percentage ? {
546
+ old: oldMethod.percentage,
547
+ new: newMethod.percentage
548
+ } : undefined,
549
+ enabled: oldMethod.enabled !== newMethod.enabled ? {
550
+ old: oldMethod.enabled,
551
+ new: newMethod.enabled
552
+ } : undefined,
553
+ channel_application: JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) ? {
554
+ old: oldMethod.channel_application,
555
+ new: newMethod.channel_application
556
+ } : undefined,
557
+ companies: JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) ? {
558
+ old: oldMethod.companies,
559
+ new: newMethod.companies
560
+ } : undefined,
561
+ metadata: JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {}) ? {
562
+ old: oldMethod.metadata,
563
+ new: newMethod.metadata
564
+ } : undefined
565
+ }
566
+ });
510
567
  return true; // 方法属性有变化
511
568
  }
512
569
  }
@@ -1906,14 +1963,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1906
1963
  * @param originalAmount 原始金额
1907
1964
  * @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
1908
1965
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
1909
- * @returns 舍入后的金额(保留两位小数的字符串)
1966
+ * @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
1910
1967
  */
1911
1968
  )
1912
1969
  }, {
1913
1970
  key: "roundAmountAsync",
1914
1971
  value: function () {
1915
1972
  var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
1916
- var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, result;
1973
+ var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, roundedAmountStr, originalAmountStr, roundingDifference, roundingDifferenceStr;
1917
1974
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1918
1975
  while (1) switch (_context26.prev = _context26.next) {
1919
1976
  case 0:
@@ -1961,19 +2018,26 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1961
2018
  case 22:
1962
2019
  // 计算最终金额:roundedValue * interval
1963
2020
  finalAmount = roundedValue.mul(roundingInterval);
1964
- result = finalAmount.toFixed(2);
1965
- console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u820D\u5165\u503C: ".concat(roundedValue.toString(), ", \u6700\u7EC8\u91D1\u989D: ").concat(result));
1966
- return _context26.abrupt("return", result);
1967
- case 28:
1968
- _context26.prev = 28;
2021
+ roundedAmountStr = finalAmount.toFixed(2);
2022
+ originalAmountStr = amount.toFixed(2); // 计算舍入差额
2023
+ roundingDifference = finalAmount.sub(amount);
2024
+ roundingDifferenceStr = roundingDifference.toFixed(2);
2025
+ console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
2026
+ return _context26.abrupt("return", {
2027
+ originalAmount: originalAmountStr,
2028
+ roundedAmount: roundedAmountStr,
2029
+ roundingDifference: roundingDifferenceStr
2030
+ });
2031
+ case 31:
2032
+ _context26.prev = 31;
1969
2033
  _context26.t1 = _context26["catch"](0);
1970
2034
  console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
1971
2035
  throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
1972
- case 32:
2036
+ case 35:
1973
2037
  case "end":
1974
2038
  return _context26.stop();
1975
2039
  }
1976
- }, _callee26, this, [[0, 28]]);
2040
+ }, _callee26, this, [[0, 31]]);
1977
2041
  }));
1978
2042
  function roundAmountAsync(_x28, _x29, _x30) {
1979
2043
  return _roundAmountAsync.apply(this, arguments);
@@ -36,7 +36,7 @@ export declare enum TaskRunStatus {
36
36
  */
37
37
  export declare enum RoundingRule {
38
38
  /** 标准舍入(中点向上) */
39
- Standard = "standard",
39
+ Standard = "standard_rounding",
40
40
  /** 标准舍入(中点向下) */
41
41
  StandardDown = "standard_down",
42
42
  /** 总是向上舍入 */
@@ -44,6 +44,17 @@ export declare enum RoundingRule {
44
44
  /** 总是向下舍入 */
45
45
  AlwaysDown = "always_down"
46
46
  }
47
+ /**
48
+ * 舍入结果
49
+ */
50
+ export interface RoundingResult {
51
+ /** 原始金额 */
52
+ originalAmount: string;
53
+ /** 舍入后的金额 */
54
+ roundedAmount: string;
55
+ /** 舍入差额(舍入后金额 - 原始金额) */
56
+ roundingDifference: string;
57
+ }
47
58
  /**
48
59
  * 舍入间隔枚举
49
60
  */
@@ -306,7 +317,7 @@ export interface WalletPassPayment {
306
317
  /** 查询用户识别码列表(异步获取并缓存) */
307
318
  getUserIdentificationCodeListAsync: (params: UserIdentificationCodeParams) => Promise<UserIdentificationCodeItem[]>;
308
319
  /** 搜索识别码信息 */
309
- searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<SearchIdentificationCodeItem[]>;
320
+ searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<SearchIdentificationCodeResult>;
310
321
  /** 获取缓存的搜索结果列表 */
311
322
  getSearchResults: () => SearchIdentificationCodeItem[];
312
323
  /** 根据识别码查找搜索结果 */
@@ -371,7 +382,7 @@ export interface PaymentModuleAPI {
371
382
  * @param rule 舍入规则 (standard, standard_down, always_up, always_down)
372
383
  * @returns 舍入后的金额
373
384
  */
374
- roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<string>;
385
+ roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<RoundingResult>;
375
386
  /** 提交支付 */
376
387
  submitPayAsync: (orderUuid?: string) => Promise<{
377
388
  status: 'success' | 'failed';
@@ -636,6 +647,16 @@ export interface SearchIdentificationCodeResponse {
636
647
  /** 响应数据 */
637
648
  data?: SearchIdentificationCodeItem[];
638
649
  }
650
+ /**
651
+ * 搜索识别码结果类型
652
+ */
653
+ export type SearchIdentificationCodeResult = {
654
+ type: 'walletCode';
655
+ data: SearchIdentificationCodeItem[];
656
+ } | {
657
+ type: 'normalCode';
658
+ data: SearchIdentificationCodeItem[];
659
+ };
639
660
  /**
640
661
  * 搜索识别码项目
641
662
  */
@@ -38,13 +38,17 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
38
38
  * 舍入规则枚举
39
39
  */
40
40
  export var RoundingRule = /*#__PURE__*/function (RoundingRule) {
41
- RoundingRule["Standard"] = "standard";
41
+ RoundingRule["Standard"] = "standard_rounding";
42
42
  RoundingRule["StandardDown"] = "standard_down";
43
43
  RoundingRule["AlwaysUp"] = "always_up";
44
44
  RoundingRule["AlwaysDown"] = "always_down";
45
45
  return RoundingRule;
46
46
  }({});
47
47
 
48
+ /**
49
+ * 舍入结果
50
+ */
51
+
48
52
  /**
49
53
  * 舍入间隔枚举
50
54
  */
@@ -225,6 +229,10 @@ export var PaymentHooks = /*#__PURE__*/function (PaymentHooks) {
225
229
  * 搜索识别码响应数据
226
230
  */
227
231
 
232
+ /**
233
+ * 搜索识别码结果类型
234
+ */
235
+
228
236
  /**
229
237
  * 搜索识别码项目
230
238
  */
@@ -11,7 +11,7 @@ export var formatWalletPassList2PreparePayments = function formatWalletPassList2
11
11
  return (list || []).map(function (item) {
12
12
  return {
13
13
  voucher_id: item.id || 0,
14
- amount: Number(getAvailableMaxAmount(item)) || 0,
14
+ amount: Number(item.edit_current_amount || getAvailableMaxAmount(item)) || 0,
15
15
  tag: item.tag || ''
16
16
  };
17
17
  });
@@ -1,4 +1,4 @@
1
- import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, WalletInitBusinessData } from './types';
1
+ import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData } from './types';
2
2
  import type { PaymentModule } from './index';
3
3
  /**
4
4
  * 钱包支付实现
@@ -57,8 +57,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
57
57
  * 搜索识别码信息
58
58
  * 通过识别码搜索相关的钱包通行证信息
59
59
  * 基于 WalletDeductionRecommendParams 参数结构
60
+ * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
60
61
  */
61
- searchIdentificationCodeAsync(params: SearchIdentificationCodeParams): Promise<SearchIdentificationCodeItem[]>;
62
+ searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
63
+ noCache?: boolean;
64
+ }): Promise<SearchIdentificationCodeResult>;
62
65
  processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
63
66
  getWalletBalance(voucherId: string): Promise<number>;
64
67
  /**
@@ -274,16 +274,55 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
274
274
  * 搜索识别码信息
275
275
  * 通过识别码搜索相关的钱包通行证信息
276
276
  * 基于 WalletDeductionRecommendParams 参数结构
277
+ * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
277
278
  */
278
279
  }, {
279
280
  key: "searchIdentificationCodeAsync",
280
281
  value: (function () {
281
282
  var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
282
- var baseWalletParams, searchParams, response, searchResults, _this$searchResults, existingCodes, newResults;
283
+ var config,
284
+ code,
285
+ isWalletCode,
286
+ walletDetailParams,
287
+ _response,
288
+ _searchResults,
289
+ baseWalletParams,
290
+ searchParams,
291
+ response,
292
+ searchResults,
293
+ _this$searchResults,
294
+ existingCodes,
295
+ newResults,
296
+ _args5 = arguments;
283
297
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
284
298
  while (1) switch (_context5.prev = _context5.next) {
285
299
  case 0:
286
- _context5.prev = 0;
300
+ config = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
301
+ _context5.prev = 1;
302
+ code = params.code; // 检查识别码是否为9位且前3位为"000"
303
+ // const isWalletCode = code.length === 9 && code.startsWith('000');
304
+ // 测试环境先使用 WL
305
+ isWalletCode = code.startsWith('WL');
306
+ if (!isWalletCode) {
307
+ _context5.next = 11;
308
+ break;
309
+ }
310
+ // 钱包识别码直接调用专门接口,不缓存,直接返回
311
+ walletDetailParams = {
312
+ code: code,
313
+ with_customer: 1,
314
+ with: ['latestWalletDetail.wallet']
315
+ };
316
+ _context5.next = 8;
317
+ return this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
318
+ case 8:
319
+ _response = _context5.sent;
320
+ _searchResults = (_response === null || _response === void 0 ? void 0 : _response.data) || [];
321
+ return _context5.abrupt("return", {
322
+ type: 'walletCode',
323
+ data: _searchResults
324
+ });
325
+ case 11:
287
326
  // 合并钱包参数和搜索参数
288
327
  baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
289
328
  searchParams = {
@@ -300,11 +339,21 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
300
339
  // 搜索特有参数
301
340
  code: params.code
302
341
  };
303
- _context5.next = 5;
342
+ _context5.next = 15;
304
343
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
305
- case 5:
344
+ case 15:
306
345
  response = _context5.sent;
307
- searchResults = (response === null || response === void 0 ? void 0 : response.data) || []; // 将搜索结果存储到缓存数组中
346
+ searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
347
+ if (!config.noCache) {
348
+ _context5.next = 19;
349
+ break;
350
+ }
351
+ return _context5.abrupt("return", {
352
+ type: 'normalCode',
353
+ data: searchResults
354
+ });
355
+ case 19:
356
+ // 将搜索结果存储到缓存数组中
308
357
  if (searchResults.length > 0) {
309
358
  // 避免重复存储相同的识别码
310
359
  existingCodes = new Set(this.searchResults.map(function (item) {
@@ -323,17 +372,20 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
323
372
  cachedSearchResults: _toConsumableArray(this.searchResults),
324
373
  searchParams: params
325
374
  });
326
- return _context5.abrupt("return", searchResults);
327
- case 12:
328
- _context5.prev = 12;
329
- _context5.t0 = _context5["catch"](0);
375
+ return _context5.abrupt("return", {
376
+ type: 'normalCode',
377
+ data: searchResults
378
+ });
379
+ case 24:
380
+ _context5.prev = 24;
381
+ _context5.t0 = _context5["catch"](1);
330
382
  console.error('[WalletPass] 搜索识别码信息失败:', _context5.t0);
331
383
  throw _context5.t0;
332
- case 16:
384
+ case 28:
333
385
  case "end":
334
386
  return _context5.stop();
335
387
  }
336
- }, _callee5, this, [[0, 12]]);
388
+ }, _callee5, this, [[1, 24]]);
337
389
  }));
338
390
  function searchIdentificationCodeAsync(_x5) {
339
391
  return _searchIdentificationCodeAsync.apply(this, arguments);
@@ -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, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -131,6 +131,14 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  scanCustomerListener(callback: (data: IScanResult) => void): {
132
132
  remove: () => void;
133
133
  };
134
+ /**
135
+ * @title 通用扫描监听
136
+ * @description 直接将扫描结果返回给调用方
137
+ * @param callback 回调
138
+ */
139
+ scanUniversalListener(callback: (data: IScanResult) => void, key: string): {
140
+ remove: () => void;
141
+ };
134
142
  /**
135
143
  * 调用摄像头
136
144
  * @param data 用户自定义数据
@@ -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
  };