@pisell/pisellos 0.0.215 → 0.0.217

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 (35) hide show
  1. package/dist/modules/Customer/index.d.ts +33 -0
  2. package/dist/modules/Customer/index.js +316 -58
  3. package/dist/modules/Customer/types.d.ts +17 -1
  4. package/dist/modules/Customer/types.js +2 -0
  5. package/dist/modules/ProductList/index.d.ts +6 -0
  6. package/dist/modules/ProductList/index.js +20 -0
  7. package/dist/solution/BookingTicket/index.d.ts +33 -0
  8. package/dist/solution/BookingTicket/index.js +167 -21
  9. package/dist/solution/BookingTicket/types.d.ts +3 -1
  10. package/dist/solution/BookingTicket/types.js +2 -0
  11. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +15 -3
  12. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
  13. package/dist/solution/BookingTicket/utils/scan/handleScan.js +99 -55
  14. package/dist/solution/BookingTicket/utils/scan/index.d.ts +12 -4
  15. package/dist/solution/BookingTicket/utils/scan/index.js +32 -20
  16. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  17. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  18. package/lib/modules/Customer/index.d.ts +33 -0
  19. package/lib/modules/Customer/index.js +168 -32
  20. package/lib/modules/Customer/types.d.ts +17 -1
  21. package/lib/modules/Customer/types.js +2 -0
  22. package/lib/modules/ProductList/index.d.ts +6 -0
  23. package/lib/modules/ProductList/index.js +18 -0
  24. package/lib/solution/BookingTicket/index.d.ts +33 -0
  25. package/lib/solution/BookingTicket/index.js +98 -8
  26. package/lib/solution/BookingTicket/types.d.ts +3 -1
  27. package/lib/solution/BookingTicket/types.js +2 -0
  28. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +23 -3
  29. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
  30. package/lib/solution/BookingTicket/utils/scan/handleScan.js +58 -16
  31. package/lib/solution/BookingTicket/utils/scan/index.d.ts +12 -4
  32. package/lib/solution/BookingTicket/utils/scan/index.js +16 -20
  33. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  34. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  35. package/package.json +1 -1
@@ -91,6 +91,32 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
91
91
  * @returns 客户列表响应
92
92
  */
93
93
  changeCustomerPage(page: number, pageSize?: number): Promise<import("../../modules").ICustomerListResponse>;
94
+ /**
95
+ * 滚动加载更多客户数据 - 数据会追加到现有列表中
96
+ * @returns 客户列表响应
97
+ */
98
+ loadMoreCustomers(): Promise<import("../../modules").ICustomerListResponse>;
99
+ /**
100
+ * 重置并重新开始滚动加载客户数据
101
+ * @param params 查询参数
102
+ * @returns 客户列表响应
103
+ */
104
+ resetAndLoadCustomers(params?: IGetCustomerListParams): Promise<import("../../modules").ICustomerListResponse>;
105
+ /**
106
+ * 检查是否还有更多客户数据可以加载
107
+ * @returns 是否还有更多数据
108
+ */
109
+ hasMoreCustomers(): boolean;
110
+ /**
111
+ * 获取当前的客户搜索条件
112
+ * @returns 当前搜索条件
113
+ */
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
115
+ /**
116
+ * 获取客户列表状态(包含滚动加载相关状态)
117
+ * @returns 客户状态
118
+ */
119
+ getCustomerState(): import("../../modules").CustomerState;
94
120
  /**
95
121
  * 全局扫描监听
96
122
  * @param callback 回调
@@ -105,6 +131,13 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
105
131
  scanCustomerListener(callback: (data: IScanResult) => void): {
106
132
  remove: () => void;
107
133
  };
134
+ /**
135
+ * 调用摄像头
136
+ * @param data 用户自定义数据
137
+ */
138
+ activateCamera(data?: {
139
+ [key: string]: any;
140
+ }): void;
108
141
  /**
109
142
  * 设置其他参数
110
143
  * @param params 参数
@@ -19,8 +19,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
19
19
  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); }
20
20
  import { BaseModule } from "../../modules/BaseModule";
21
21
  import { BookingTicketHooks, createModule } from "./types";
22
- import { Scan } from "./utils/scan/index";
22
+ import Scan from "./utils/scan";
23
23
  import { handleGlobalScan, handleCustomerScan } from "./utils/scan/handleScan";
24
+ import scanCache from "./utils/scan/scanCache";
24
25
  export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
25
26
  _inherits(BookingTicketImpl, _BaseModule);
26
27
  var _super = _createSuper(BookingTicketImpl);
@@ -379,20 +380,137 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
379
380
  }
380
381
  return changeCustomerPage;
381
382
  }()
383
+ /**
384
+ * 滚动加载更多客户数据 - 数据会追加到现有列表中
385
+ * @returns 客户列表响应
386
+ */
387
+ )
388
+ }, {
389
+ key: "loadMoreCustomers",
390
+ value: (function () {
391
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
392
+ var result;
393
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
394
+ while (1) switch (_context6.prev = _context6.next) {
395
+ case 0:
396
+ _context6.prev = 0;
397
+ _context6.next = 3;
398
+ return this.store.customer.loadMoreCustomers();
399
+ case 3:
400
+ result = _context6.sent;
401
+ this.core.effects.emit(BookingTicketHooks.onCustomerListUpdate, result);
402
+ return _context6.abrupt("return", result);
403
+ case 8:
404
+ _context6.prev = 8;
405
+ _context6.t0 = _context6["catch"](0);
406
+ console.error('Failed to load more customers:', _context6.t0);
407
+ throw _context6.t0;
408
+ case 12:
409
+ case "end":
410
+ return _context6.stop();
411
+ }
412
+ }, _callee6, this, [[0, 8]]);
413
+ }));
414
+ function loadMoreCustomers() {
415
+ return _loadMoreCustomers.apply(this, arguments);
416
+ }
417
+ return loadMoreCustomers;
418
+ }()
419
+ /**
420
+ * 重置并重新开始滚动加载客户数据
421
+ * @param params 查询参数
422
+ * @returns 客户列表响应
423
+ */
424
+ )
425
+ }, {
426
+ key: "resetAndLoadCustomers",
427
+ value: (function () {
428
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
429
+ var params,
430
+ result,
431
+ _args7 = arguments;
432
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
433
+ while (1) switch (_context7.prev = _context7.next) {
434
+ case 0:
435
+ params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
436
+ _context7.prev = 1;
437
+ _context7.next = 4;
438
+ return this.store.customer.resetAndLoadCustomers(params);
439
+ case 4:
440
+ result = _context7.sent;
441
+ this.core.effects.emit(BookingTicketHooks.onCustomerListReset, result);
442
+ return _context7.abrupt("return", result);
443
+ case 9:
444
+ _context7.prev = 9;
445
+ _context7.t0 = _context7["catch"](1);
446
+ console.error('Failed to reset and load customers:', _context7.t0);
447
+ throw _context7.t0;
448
+ case 13:
449
+ case "end":
450
+ return _context7.stop();
451
+ }
452
+ }, _callee7, this, [[1, 9]]);
453
+ }));
454
+ function resetAndLoadCustomers() {
455
+ return _resetAndLoadCustomers.apply(this, arguments);
456
+ }
457
+ return resetAndLoadCustomers;
458
+ }()
459
+ /**
460
+ * 检查是否还有更多客户数据可以加载
461
+ * @returns 是否还有更多数据
462
+ */
463
+ )
464
+ }, {
465
+ key: "hasMoreCustomers",
466
+ value: function hasMoreCustomers() {
467
+ return this.store.customer.hasMoreCustomers();
468
+ }
469
+
470
+ /**
471
+ * 获取当前的客户搜索条件
472
+ * @returns 当前搜索条件
473
+ */
474
+ }, {
475
+ key: "getCurrentCustomerSearchParams",
476
+ value: function getCurrentCustomerSearchParams() {
477
+ return this.store.customer.getCurrentSearchParams();
478
+ }
479
+
480
+ /**
481
+ * 获取客户列表状态(包含滚动加载相关状态)
482
+ * @returns 客户状态
483
+ */
484
+ }, {
485
+ key: "getCustomerState",
486
+ value: function getCustomerState() {
487
+ return this.store.customer.getState();
488
+ }
489
+
382
490
  /**
383
491
  * 全局扫描监听
384
492
  * @param callback 回调
385
493
  */
386
- )
387
494
  }, {
388
495
  key: "scanGlobalListener",
389
496
  value: function scanGlobalListener(callback) {
390
- var listenerCallback = handleGlobalScan(this.request);
497
+ var _this3 = this;
498
+ var localSearch = function localSearch(v) {
499
+ return _this3.store.products.findProductsByCodeOrBarcode(v);
500
+ };
501
+ var scanCallback = handleGlobalScan(this.request, localSearch);
502
+ var safeCallback = function safeCallback(d) {
503
+ try {
504
+ callback(d);
505
+ } catch (error) {
506
+ console.error('scanGlobalListener回掉函数异常', error);
507
+ }
508
+ };
391
509
  var listener = {
392
510
  key: 'global',
393
- callback: callback
511
+ callback: safeCallback
394
512
  };
395
- var removeListener = this.scan.addListener(listener, listenerCallback);
513
+ var removeListener = this.scan.addListener(listener, scanCallback);
396
514
  return removeListener;
397
515
  }
398
516
 
@@ -403,15 +521,41 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
403
521
  }, {
404
522
  key: "scanCustomerListener",
405
523
  value: function scanCustomerListener(callback) {
406
- var listenerCallback = handleCustomerScan(this.request);
524
+ var _this4 = this;
525
+ var localSearch = function localSearch(v) {
526
+ return _this4.store.products.findProductsByCodeOrBarcode(v);
527
+ };
528
+ var scanCallback = handleCustomerScan(this.request, localSearch);
529
+ var safeCallback = function safeCallback(d) {
530
+ try {
531
+ callback(d);
532
+ } catch (error) {
533
+ console.error('scanCustomerListener回掉函数异常', error);
534
+ }
535
+ };
407
536
  var listener = {
408
537
  key: 'customer',
409
- callback: callback
538
+ callback: safeCallback
410
539
  };
411
- var removeListener = this.scan.addListener(listener, listenerCallback);
540
+ var removeListener = this.scan.addListener(listener, scanCallback);
412
541
  return removeListener;
413
542
  }
414
543
 
544
+ /**
545
+ * 调用摄像头
546
+ * @param data 用户自定义数据
547
+ */
548
+ }, {
549
+ key: "activateCamera",
550
+ value: function activateCamera(data) {
551
+ var _this$window, _this$window$postMess;
552
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
553
+ module: 'global',
554
+ key: 'active_native_scanner',
555
+ data: data
556
+ });
557
+ }
558
+
415
559
  /**
416
560
  * 设置其他参数
417
561
  * @param params 参数
@@ -420,15 +564,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
420
564
  }, {
421
565
  key: "setOtherParams",
422
566
  value: (function () {
423
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
567
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
424
568
  var _ref,
425
569
  _ref$cover,
426
570
  cover,
427
- _args6 = arguments;
428
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
429
- while (1) switch (_context6.prev = _context6.next) {
571
+ _args8 = arguments;
572
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
573
+ while (1) switch (_context8.prev = _context8.next) {
430
574
  case 0:
431
- _ref = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
575
+ _ref = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {}, _ref$cover = _ref.cover, cover = _ref$cover === void 0 ? false : _ref$cover;
432
576
  if (cover) {
433
577
  this.otherParams = params;
434
578
  } else {
@@ -436,9 +580,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
436
580
  }
437
581
  case 2:
438
582
  case "end":
439
- return _context6.stop();
583
+ return _context8.stop();
440
584
  }
441
- }, _callee6, this);
585
+ }, _callee8, this);
442
586
  }));
443
587
  function setOtherParams(_x5) {
444
588
  return _setOtherParams.apply(this, arguments);
@@ -453,16 +597,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
453
597
  }, {
454
598
  key: "getOtherParams",
455
599
  value: (function () {
456
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
457
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
458
- while (1) switch (_context7.prev = _context7.next) {
600
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
601
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
602
+ while (1) switch (_context9.prev = _context9.next) {
459
603
  case 0:
460
- return _context7.abrupt("return", this.otherParams);
604
+ return _context9.abrupt("return", this.otherParams);
461
605
  case 1:
462
606
  case "end":
463
- return _context7.stop();
607
+ return _context9.stop();
464
608
  }
465
- }, _callee7, this);
609
+ }, _callee9, this);
466
610
  }));
467
611
  function getOtherParams() {
468
612
  return _getOtherParams.apply(this, arguments);
@@ -484,6 +628,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
484
628
  (_this$store$order = this.store.order) === null || _this$store$order === void 0 || _this$store$order.destroy();
485
629
  this.core.effects.offByModuleDestroy(this.name);
486
630
  this.core.unregisterModule(this);
631
+ // 清除scan数据内存缓存
632
+ scanCache.clear();
487
633
  }
488
634
  }]);
489
635
  return BookingTicketImpl;
@@ -12,7 +12,9 @@ export declare enum BookingTicketHooks {
12
12
  onInited = "bookingTicket:onInited",
13
13
  onDestroy = "bookingTicket:onDestroy",
14
14
  onProductsLoaded = "bookingTicket:onProductsLoaded",
15
- onCustomerSelected = "bookingTicket:onCustomerSelected"
15
+ onCustomerSelected = "bookingTicket:onCustomerSelected",
16
+ onCustomerListUpdate = "bookingTicket:onCustomerListUpdate",
17
+ onCustomerListReset = "bookingTicket:onCustomerListReset"
16
18
  }
17
19
  /**
18
20
  * 获取客户列表的参数
@@ -21,6 +21,8 @@ export var BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
21
21
  BookingTicketHooks["onDestroy"] = "bookingTicket:onDestroy";
22
22
  BookingTicketHooks["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
23
23
  BookingTicketHooks["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
24
+ BookingTicketHooks["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
25
+ BookingTicketHooks["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
24
26
  return BookingTicketHooks;
25
27
  }({});
26
28
 
@@ -17,6 +17,7 @@ export var searchWalletPass = /*#__PURE__*/function () {
17
17
  // 翻译识别码名称 0:不翻译 1:翻译
18
18
  relation_product: 1,
19
19
  // 组装关联商品: 0不处理 1处理
20
+ with: ['customer'],
20
21
  tags: ['point_card',
21
22
  // 积分卡
22
23
  'gift_card',
@@ -72,7 +73,8 @@ export var searchWallet = /*#__PURE__*/function () {
72
73
  while (1) switch (_context2.prev = _context2.next) {
73
74
  case 0:
74
75
  params = {
75
- code: code
76
+ code: code,
77
+ with_customer: 1
76
78
  };
77
79
  _context2.prev = 1;
78
80
  _context2.next = 4;
@@ -114,11 +116,21 @@ export var searchProduct = /*#__PURE__*/function () {
114
116
  while (1) switch (_context3.prev = _context3.next) {
115
117
  case 0:
116
118
  params = {
117
- search: code
119
+ exact_search: code,
120
+ open_bundle: 0,
121
+ // 套餐子信息
122
+ open_quotation: 1,
123
+ // 报价单
124
+ skip: 1,
125
+ num: 20,
126
+ status: 'published',
127
+ with: ['variantGroup'],
128
+ with_count: ['bundleGroup', 'optionGroup'],
129
+ exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item']
118
130
  };
119
131
  _context3.prev = 1;
120
132
  _context3.next = 4;
121
- return request === null || request === void 0 ? void 0 : request.get('/product/list', params);
133
+ return request === null || request === void 0 ? void 0 : request.post('/product/query', params);
122
134
  case 4:
123
135
  res = _context3.sent;
124
136
  if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.list) === null || _res$data === void 0 ? void 0 : _res$data.length) > 0)) {
@@ -4,7 +4,7 @@ import { RequestPlugin } from '../../../../plugins';
4
4
  * @param request 请求插件
5
5
  * @returns 处理结果
6
6
  */
7
- export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult: {
7
+ export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
8
8
  type: string;
9
9
  value: string;
10
10
  }) => Promise<any>;
@@ -13,7 +13,7 @@ export declare const handleGlobalScan: (request: RequestPlugin) => (scanResult:
13
13
  * @param request 请求插件
14
14
  * @returns 处理结果
15
15
  */
16
- export declare const handleCustomerScan: (request: RequestPlugin) => (scanResult: {
16
+ export declare const handleCustomerScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
17
17
  type: string;
18
18
  value: string;
19
19
  }) => Promise<any>;
@@ -3,6 +3,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
3
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
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
5
  import { searchWalletPass, searchWallet, searchProduct } from "./cloudSearch";
6
+ import scanCache from "./scanCache";
6
7
 
7
8
  /**
8
9
  * Promise.any 的替代实现
@@ -56,39 +57,85 @@ var promiseAny = /*#__PURE__*/function () {
56
57
  }();
57
58
 
58
59
  /**
59
- * 处理全局扫码
60
- * @param request 请求插件
60
+ * 处理扫码
61
+ * @param getRequestList 获取请求列表
61
62
  * @returns 处理结果
62
63
  */
63
- export var handleGlobalScan = function handleGlobalScan(request) {
64
+ var handleScanFn = function handleScanFn(getRequestList, localSearch) {
64
65
  return /*#__PURE__*/function () {
65
66
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(scanResult) {
66
- var _ref3, value, requestList, result;
67
+ var _ref3, value, localResult, result, requestList, _result;
67
68
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
68
69
  while (1) switch (_context2.prev = _context2.next) {
69
70
  case 0:
70
- _ref3 = scanResult || {}, value = _ref3.value; // TODO: 本地解析识别码
71
- requestList = []; // 如果value是已WL开头的,则认为是钱包识别码
72
- if (value.startsWith('WL')) {
73
- requestList = [searchWallet(request, value)];
74
- } else {
75
- requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value)];
71
+ _ref3 = scanResult || {}, value = _ref3.value; // 本地解析识别码
72
+ _context2.prev = 1;
73
+ localResult = localSearch === null || localSearch === void 0 ? void 0 : localSearch(value);
74
+ if (!((localResult === null || localResult === void 0 ? void 0 : localResult.length) > 0)) {
75
+ _context2.next = 8;
76
+ break;
76
77
  }
77
- _context2.prev = 3;
78
- _context2.next = 6;
79
- return promiseAny(requestList);
80
- case 6:
81
- result = _context2.sent;
78
+ console.log('本地搜索到数据>>>>>>>', localResult);
79
+ return _context2.abrupt("return", {
80
+ searchType: 'local_product',
81
+ response: {
82
+ data: {
83
+ list: localResult
84
+ }
85
+ }
86
+ });
87
+ case 8:
88
+ console.log('本地搜索无数据>>>>>>>');
89
+ case 9:
90
+ _context2.next = 14;
91
+ break;
92
+ case 11:
93
+ _context2.prev = 11;
94
+ _context2.t0 = _context2["catch"](1);
95
+ console.error('本地搜索到数据失败>>>>>>>', _context2.t0);
96
+ case 14:
97
+ _context2.prev = 14;
98
+ if (!scanCache.has(value)) {
99
+ _context2.next = 21;
100
+ break;
101
+ }
102
+ result = scanCache.get(value);
103
+ console.log('缓存中搜索到数据>>>>>>>', result);
82
104
  return _context2.abrupt("return", result);
83
- case 10:
84
- _context2.prev = 10;
85
- _context2.t0 = _context2["catch"](3);
86
- throw _context2.t0;
87
- case 13:
105
+ case 21:
106
+ console.log('缓存中无数据>>>>>>>');
107
+ case 22:
108
+ _context2.next = 27;
109
+ break;
110
+ case 24:
111
+ _context2.prev = 24;
112
+ _context2.t1 = _context2["catch"](14);
113
+ console.error('缓存中搜索数据失败>>>>>>>', _context2.t1);
114
+ case 27:
115
+ requestList = (getRequestList === null || getRequestList === void 0 ? void 0 : getRequestList(value)) || [];
116
+ if (!(requestList.length === 0)) {
117
+ _context2.next = 30;
118
+ break;
119
+ }
120
+ throw new Error('requestList is empty');
121
+ case 30:
122
+ _context2.prev = 30;
123
+ _context2.next = 33;
124
+ return promiseAny(requestList);
125
+ case 33:
126
+ _result = _context2.sent;
127
+ // 将结果缓存
128
+ scanCache.set(value, _result);
129
+ return _context2.abrupt("return", _result);
130
+ case 38:
131
+ _context2.prev = 38;
132
+ _context2.t2 = _context2["catch"](30);
133
+ throw _context2.t2;
134
+ case 41:
88
135
  case "end":
89
136
  return _context2.stop();
90
137
  }
91
- }, _callee2, null, [[3, 10]]);
138
+ }, _callee2, null, [[1, 11], [14, 24], [30, 38]]);
92
139
  }));
93
140
  return function (_x2) {
94
141
  return _ref2.apply(this, arguments);
@@ -96,43 +143,40 @@ export var handleGlobalScan = function handleGlobalScan(request) {
96
143
  }();
97
144
  };
98
145
 
146
+ /**
147
+ * 处理全局扫码
148
+ * @param request 请求插件
149
+ * @returns 处理结果
150
+ */
151
+ export var handleGlobalScan = function handleGlobalScan(request, localSearch) {
152
+ var getRequestList = function getRequestList(value) {
153
+ var requestList = [];
154
+ // 如果value是已WL开头的,则认为是钱包识别码
155
+ if (value.startsWith('WL')) {
156
+ requestList = [searchWallet(request, value)];
157
+ } else {
158
+ requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value)];
159
+ }
160
+ return requestList;
161
+ };
162
+ return handleScanFn(getRequestList, localSearch);
163
+ };
164
+
99
165
  /**
100
166
  * 处理客户扫码
101
167
  * @param request 请求插件
102
168
  * @returns 处理结果
103
169
  */
104
- export var handleCustomerScan = function handleCustomerScan(request) {
105
- return /*#__PURE__*/function () {
106
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(scanResult) {
107
- var _ref5, value, requestList, result;
108
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
109
- while (1) switch (_context3.prev = _context3.next) {
110
- case 0:
111
- _ref5 = scanResult || {}, value = _ref5.value; // TODO: 本地解析识别码
112
- requestList = []; // 如果value是已WL开头的,则认为是钱包识别码
113
- if (value.startsWith('WL')) {
114
- requestList = [searchWallet(request, value)];
115
- } else {
116
- requestList = [searchWalletPass(request, value), searchWallet(request, value)];
117
- }
118
- _context3.prev = 3;
119
- _context3.next = 6;
120
- return Promise.race(requestList);
121
- case 6:
122
- result = _context3.sent;
123
- return _context3.abrupt("return", result);
124
- case 10:
125
- _context3.prev = 10;
126
- _context3.t0 = _context3["catch"](3);
127
- throw _context3.t0;
128
- case 13:
129
- case "end":
130
- return _context3.stop();
131
- }
132
- }, _callee3, null, [[3, 10]]);
133
- }));
134
- return function (_x3) {
135
- return _ref4.apply(this, arguments);
136
- };
137
- }();
170
+ export var handleCustomerScan = function handleCustomerScan(request, localSearch) {
171
+ var getRequestList = function getRequestList(value) {
172
+ var requestList = [];
173
+ // 如果value是已WL开头的,则认为是钱包识别码
174
+ if (value.startsWith('WL')) {
175
+ requestList = [searchWallet(request, value)];
176
+ } else {
177
+ requestList = [searchWalletPass(request, value), searchWallet(request, value)];
178
+ }
179
+ return requestList;
180
+ };
181
+ return handleScanFn(getRequestList, localSearch);
138
182
  };
@@ -2,10 +2,18 @@ import { WatchEventItem } from '../../../../utils/watch';
2
2
  import { BookingTicketImpl } from '../../index';
3
3
  import Tasks from '../../../../utils/task';
4
4
  interface ScanResult {
5
- type: string;
5
+ type: ScanResultType;
6
6
  value: string;
7
+ data?: {
8
+ [key: string]: any;
9
+ };
10
+ }
11
+ declare enum ScanResultType {
12
+ Scanner = "scanner",
13
+ NFC = "nfc",
14
+ NativeScanner = "nativeScanner"
7
15
  }
8
- export declare class Scan {
16
+ export default class Scan {
9
17
  private solution;
10
18
  private watchKey;
11
19
  private listenerConfig;
@@ -15,7 +23,7 @@ export declare class Scan {
15
23
  * @param watchKey 监听的key
16
24
  * @param event 事件
17
25
  */
18
- addListener(event: WatchEventItem, callback?: (result: ScanResult) => Promise<any>): {
26
+ addListener(event: WatchEventItem, scanCallback?: (result: ScanResult) => Promise<any>): {
19
27
  remove: () => void;
20
28
  };
21
29
  /**
@@ -39,7 +47,7 @@ export declare class Scan {
39
47
  * @returns 监听配置
40
48
  */
41
49
  getListenerConfig(eventKey: string): {
42
- callback?: ((result: ScanResult) => Promise<any>) | undefined;
50
+ scanCallback?: ((result: ScanResult) => Promise<any>) | undefined;
43
51
  task: Tasks;
44
52
  } | undefined;
45
53
  /**