@pisell/pisellos 0.0.215 → 0.0.216

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.
@@ -0,0 +1,305 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ /**
9
+ * 简单的数据压缩函数
10
+ * @param data 要压缩的数据
11
+ * @returns 压缩后的字符串
12
+ */
13
+ var compressData = function compressData(data) {
14
+ try {
15
+ // 处理undefined值
16
+ if (data === undefined) {
17
+ return 'undefined';
18
+ }
19
+ return JSON.stringify(data);
20
+ } catch (error) {
21
+ console.warn('数据压缩失败:', error);
22
+ return JSON.stringify(data);
23
+ }
24
+ };
25
+
26
+ /**
27
+ * 数据解压缩函数
28
+ * @param compressedData 压缩后的数据
29
+ * @returns 解压缩后的数据
30
+ */
31
+ var decompressData = function decompressData(compressedData) {
32
+ try {
33
+ // 处理undefined值
34
+ if (compressedData === 'undefined') {
35
+ return undefined;
36
+ }
37
+ return JSON.parse(compressedData);
38
+ } catch (error) {
39
+ console.warn('数据解压缩失败:', error);
40
+ return null;
41
+ }
42
+ };
43
+
44
+ /**
45
+ * 双向链表节点
46
+ */
47
+ /**
48
+ * LRU缓存类,用于缓存接口数据
49
+ * 限制最多存储100条数据,超过时移除最久未使用的数据
50
+ * 支持数据压缩以减小缓存压力
51
+ * 尾部优先策略:新节点插入尾部,最近使用的节点移动到尾部,删除头部节点
52
+ */
53
+ var LRUCache = /*#__PURE__*/function () {
54
+ function LRUCache() {
55
+ var maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
56
+ _classCallCheck(this, LRUCache);
57
+ _defineProperty(this, "head", null);
58
+ // 最久未使用的节点
59
+ _defineProperty(this, "tail", null);
60
+ // 最近使用的节点
61
+ _defineProperty(this, "keyMap", new Map());
62
+ // key到节点的映射(只存储引用)
63
+ _defineProperty(this, "maxSize", void 0);
64
+ this.maxSize = maxSize;
65
+ }
66
+
67
+ /**
68
+ * 将节点移动到链表尾部(最近使用)
69
+ * @param node 要移动的节点
70
+ */
71
+ _createClass(LRUCache, [{
72
+ key: "moveToTail",
73
+ value: function moveToTail(node) {
74
+ if (this.tail === node) return; // 已经是尾部
75
+
76
+ // 从当前位置移除
77
+ if (node.prev) {
78
+ node.prev.next = node.next;
79
+ }
80
+ if (node.next) {
81
+ node.next.prev = node.prev;
82
+ }
83
+
84
+ // 如果是头部,更新头部
85
+ if (this.head === node) {
86
+ this.head = node.next;
87
+ }
88
+
89
+ // 移动到尾部
90
+ if (this.tail) {
91
+ this.tail.next = node;
92
+ }
93
+ node.prev = this.tail;
94
+ node.next = null;
95
+ this.tail = node;
96
+
97
+ // 如果链表为空,设置头部
98
+ if (!this.head) {
99
+ this.head = node;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * 添加新节点到链表尾部
105
+ * @param key 缓存键
106
+ * @param compressedData 压缩后的数据
107
+ * @param timestamp 时间戳
108
+ */
109
+ }, {
110
+ key: "addToTail",
111
+ value: function addToTail(key, compressedData, timestamp) {
112
+ // 先保存当前的tail引用
113
+ var oldTail = this.tail;
114
+ var node = {
115
+ key: key,
116
+ compressedData: compressedData,
117
+ timestamp: timestamp,
118
+ prev: oldTail,
119
+ // 使用保存的引用,避免循环引用
120
+ next: null
121
+ };
122
+
123
+ // 存储节点引用
124
+ this.keyMap.set(key, node);
125
+
126
+ // 更新链表关系
127
+ if (oldTail) {
128
+ oldTail.next = node;
129
+ }
130
+ this.tail = node;
131
+
132
+ // 如果是第一个节点,设置head
133
+ if (!this.head) {
134
+ this.head = node;
135
+ }
136
+ return node;
137
+ }
138
+
139
+ /**
140
+ * 从链表中移除节点
141
+ * @param node 要移除的节点
142
+ */
143
+ }, {
144
+ key: "removeNode",
145
+ value: function removeNode(node) {
146
+ if (node.prev) {
147
+ node.prev.next = node.next;
148
+ }
149
+ if (node.next) {
150
+ node.next.prev = node.prev;
151
+ }
152
+ if (this.head === node) {
153
+ this.head = node.next;
154
+ }
155
+ if (this.tail === node) {
156
+ this.tail = node.prev;
157
+ }
158
+
159
+ // 从Map中移除引用
160
+ this.keyMap.delete(node.key);
161
+ }
162
+
163
+ /**
164
+ * 移除最久未使用的节点(链表头部)
165
+ */
166
+ }, {
167
+ key: "removeOldest",
168
+ value: function removeOldest() {
169
+ if (this.head) {
170
+ this.removeNode(this.head);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * 设置缓存
176
+ * @param key 缓存键
177
+ * @param data 缓存数据
178
+ */
179
+ }, {
180
+ key: "set",
181
+ value: function set(key, data) {
182
+ // 压缩数据
183
+ var compressedData = compressData(data);
184
+ var timestamp = Date.now();
185
+
186
+ // 检查是否已存在该key
187
+ var existingNode = this.keyMap.get(key);
188
+ if (existingNode) {
189
+ // 如果已存在,更新数据并移动到链表尾部
190
+ existingNode.compressedData = compressedData;
191
+ existingNode.timestamp = timestamp;
192
+ this.moveToTail(existingNode);
193
+ } else {
194
+ // 如果是新数据且缓存已满,移除最久未使用的数据(头部)
195
+ if (this.keyMap.size >= this.maxSize) {
196
+ this.removeOldest();
197
+ }
198
+
199
+ // 添加新数据到尾部
200
+ this.addToTail(key, compressedData, timestamp);
201
+ }
202
+ }
203
+
204
+ /**
205
+ * 获取缓存
206
+ * @param key 缓存键
207
+ * @returns 缓存数据或undefined
208
+ */
209
+ }, {
210
+ key: "get",
211
+ value: function get(key) {
212
+ var node = this.keyMap.get(key);
213
+ if (node) {
214
+ // 解压缩数据
215
+ var decompressedData = decompressData(node.compressedData);
216
+ if (decompressedData !== null) {
217
+ // 更新访问时间戳并移动到链表尾部
218
+ node.timestamp = Date.now();
219
+ this.moveToTail(node);
220
+ return decompressedData;
221
+ } else {
222
+ // 如果解压缩失败,删除该缓存项
223
+ this.removeNode(node);
224
+ return undefined;
225
+ }
226
+ }
227
+ return undefined;
228
+ }
229
+
230
+ /**
231
+ * 检查是否存在缓存
232
+ * @param key 缓存键
233
+ * @returns 是否存在
234
+ */
235
+ }, {
236
+ key: "has",
237
+ value: function has(key) {
238
+ return this.keyMap.has(key);
239
+ }
240
+
241
+ /**
242
+ * 清除所有缓存
243
+ */
244
+ }, {
245
+ key: "clear",
246
+ value: function clear() {
247
+ // 清除所有节点的引用关系,帮助垃圾回收
248
+ var current = this.head;
249
+ while (current) {
250
+ var next = current.next;
251
+ current.prev = null;
252
+ current.next = null;
253
+ current = next;
254
+ }
255
+
256
+ // 清除Map和头尾指针
257
+ this.keyMap.clear();
258
+ this.head = null;
259
+ this.tail = null;
260
+ }
261
+
262
+ /**
263
+ * 获取缓存大小
264
+ * @returns 当前缓存数量
265
+ */
266
+ }, {
267
+ key: "size",
268
+ value: function size() {
269
+ return this.keyMap.size;
270
+ }
271
+
272
+ /**
273
+ * 获取缓存统计信息
274
+ * @returns 缓存统计信息
275
+ */
276
+ }, {
277
+ key: "getStats",
278
+ value: function getStats() {
279
+ return {
280
+ size: this.keyMap.size,
281
+ maxSize: this.maxSize,
282
+ usage: Math.round(this.keyMap.size / this.maxSize * 100)
283
+ };
284
+ }
285
+
286
+ /**
287
+ * 删除指定的缓存项
288
+ * @param key 要删除的缓存键
289
+ * @returns 是否删除成功
290
+ */
291
+ }, {
292
+ key: "delete",
293
+ value: function _delete(key) {
294
+ var node = this.keyMap.get(key);
295
+ if (node) {
296
+ this.removeNode(node);
297
+ return true;
298
+ }
299
+ return false;
300
+ }
301
+ }]);
302
+ return LRUCache;
303
+ }(); // 创建全局缓存实例
304
+ var scanCache = new LRUCache();
305
+ export default scanCache;
@@ -100,6 +100,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
100
100
  num,
101
101
  sort_by: import_constants.SORT_BY,
102
102
  with: ["latestWalletDetail.wallet"],
103
+ search_wallet_flag: 1,
103
104
  search_wallet_pass_flag: 1,
104
105
  ...search && { search },
105
106
  ...otherParams
@@ -33,4 +33,10 @@ export declare class ProductList extends BaseModule implements Module {
33
33
  getProduct(id: number): Promise<Product | undefined>;
34
34
  addProduct(products: ProductData[]): Promise<void>;
35
35
  selectProducts(products: ProductData[]): Promise<void>;
36
+ /**
37
+ * 根据商品编码或条码搜索商品
38
+ * @param code 商品编码或条码
39
+ * @returns 匹配的商品列表,如果没有匹配则返回空数组
40
+ */
41
+ findProductsByCodeOrBarcode(code: string): ProductData[];
36
42
  }
@@ -170,6 +170,24 @@ var ProductList = class extends import_BaseModule.BaseModule {
170
170
  async selectProducts(products) {
171
171
  this.store.selectProducts = products;
172
172
  }
173
+ /**
174
+ * 根据商品编码或条码搜索商品
175
+ * @param code 商品编码或条码
176
+ * @returns 匹配的商品列表,如果没有匹配则返回空数组
177
+ */
178
+ findProductsByCodeOrBarcode(code) {
179
+ if (!code || typeof code !== "string") {
180
+ return [];
181
+ }
182
+ const trimmedCode = code.trim();
183
+ if (!trimmedCode) {
184
+ return [];
185
+ }
186
+ const matchingProducts = this.store.list.filter((product) => {
187
+ return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
188
+ });
189
+ return (0, import_lodash_es.cloneDeep)(matchingProducts);
190
+ }
173
191
  };
174
192
  // Annotate the CommonJS export names for ESM import in node:
175
193
  0 && (module.exports = {
@@ -105,6 +105,13 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
105
105
  scanCustomerListener(callback: (data: IScanResult) => void): {
106
106
  remove: () => void;
107
107
  };
108
+ /**
109
+ * 调用摄像头
110
+ * @param data 用户自定义数据
111
+ */
112
+ activateCamera(data?: {
113
+ [key: string]: any;
114
+ }): void;
108
115
  /**
109
116
  * 设置其他参数
110
117
  * @param params 参数
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  return to;
16
18
  };
17
19
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/solution/BookingTicket/index.ts
@@ -26,8 +36,9 @@ __export(BookingTicket_exports, {
26
36
  module.exports = __toCommonJS(BookingTicket_exports);
27
37
  var import_BaseModule = require("../../modules/BaseModule");
28
38
  var import_types = require("./types");
29
- var import_scan = require("./utils/scan/index");
39
+ var import_scan = __toESM(require("./utils/scan"));
30
40
  var import_handleScan = require("./utils/scan/handleScan");
41
+ var import_scanCache = __toESM(require("./utils/scan/scanCache"));
31
42
  __reExport(BookingTicket_exports, require("./types"), module.exports);
32
43
  var BookingTicketImpl = class extends import_BaseModule.BaseModule {
33
44
  constructor() {
@@ -55,7 +66,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
55
66
  let targetCacheData = {};
56
67
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
57
68
  this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
58
- this.scan = new import_scan.Scan(this, "BOOKING_TICKET_SCAN");
69
+ this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
59
70
  if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
60
71
  const sessionData = this.window.sessionStorage.getItem(this.name);
61
72
  if (sessionData) {
@@ -235,9 +246,17 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
235
246
  * @param callback 回调
236
247
  */
237
248
  scanGlobalListener(callback) {
238
- const listenerCallback = (0, import_handleScan.handleGlobalScan)(this.request);
239
- const listener = { key: "global", callback };
240
- const removeListener = this.scan.addListener(listener, listenerCallback);
249
+ const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
250
+ const scanCallback = (0, import_handleScan.handleGlobalScan)(this.request, localSearch);
251
+ const safeCallback = (d) => {
252
+ try {
253
+ callback(d);
254
+ } catch (error) {
255
+ console.error("scanGlobalListener回掉函数异常", error);
256
+ }
257
+ };
258
+ const listener = { key: "global", callback: safeCallback };
259
+ const removeListener = this.scan.addListener(listener, scanCallback);
241
260
  return removeListener;
242
261
  }
243
262
  /**
@@ -245,11 +264,31 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
245
264
  * @param callback 回调
246
265
  */
247
266
  scanCustomerListener(callback) {
248
- const listenerCallback = (0, import_handleScan.handleCustomerScan)(this.request);
249
- const listener = { key: "customer", callback };
250
- const removeListener = this.scan.addListener(listener, listenerCallback);
267
+ const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
268
+ const scanCallback = (0, import_handleScan.handleCustomerScan)(this.request, localSearch);
269
+ const safeCallback = (d) => {
270
+ try {
271
+ callback(d);
272
+ } catch (error) {
273
+ console.error("scanCustomerListener回掉函数异常", error);
274
+ }
275
+ };
276
+ const listener = { key: "customer", callback: safeCallback };
277
+ const removeListener = this.scan.addListener(listener, scanCallback);
251
278
  return removeListener;
252
279
  }
280
+ /**
281
+ * 调用摄像头
282
+ * @param data 用户自定义数据
283
+ */
284
+ activateCamera(data) {
285
+ var _a, _b, _c, _d;
286
+ (_d = (_c = (_b = (_a = this.window) == null ? void 0 : _a.interaction) == null ? void 0 : _b.utils) == null ? void 0 : _c.postMessageToApp) == null ? void 0 : _d.call(_c, {
287
+ module: "global",
288
+ key: "active_native_scanner",
289
+ data
290
+ });
291
+ }
253
292
  /**
254
293
  * 设置其他参数
255
294
  * @param params 参数
@@ -281,6 +320,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
281
320
  (_e = this.store.order) == null ? void 0 : _e.destroy();
282
321
  this.core.effects.offByModuleDestroy(this.name);
283
322
  this.core.unregisterModule(this);
323
+ import_scanCache.default.clear();
284
324
  }
285
325
  };
286
326
  // Annotate the CommonJS export names for ESM import in node:
@@ -31,6 +31,7 @@ var searchWalletPass = async (request, code) => {
31
31
  // 翻译识别码名称 0:不翻译 1:翻译
32
32
  relation_product: 1,
33
33
  // 组装关联商品: 0不处理 1处理
34
+ with: ["customer"],
34
35
  tags: [
35
36
  "point_card",
36
37
  // 积分卡
@@ -62,7 +63,7 @@ var searchWalletPass = async (request, code) => {
62
63
  }
63
64
  };
64
65
  var searchWallet = async (request, code) => {
65
- const params = { code };
66
+ const params = { code, with_customer: 1 };
66
67
  try {
67
68
  const res = await (request == null ? void 0 : request.post(
68
69
  "/wallet/detail/search",
@@ -78,9 +79,28 @@ var searchWallet = async (request, code) => {
78
79
  };
79
80
  var searchProduct = async (request, code) => {
80
81
  var _a, _b;
81
- const params = { search: code };
82
+ const params = {
83
+ exact_search: code,
84
+ open_bundle: 0,
85
+ // 套餐子信息
86
+ open_quotation: 1,
87
+ // 报价单
88
+ skip: 1,
89
+ num: 20,
90
+ status: "published",
91
+ with: ["variantGroup"],
92
+ with_count: ["bundleGroup", "optionGroup"],
93
+ exclude_extension_type: [
94
+ "product_party",
95
+ "product_event",
96
+ "product_series_event",
97
+ "product_package_ticket",
98
+ "ticket",
99
+ "event_item"
100
+ ]
101
+ };
82
102
  try {
83
- const res = await (request == null ? void 0 : request.get("/product/list", params));
103
+ const res = await (request == null ? void 0 : request.post("/product/query", params));
84
104
  if ((res == null ? void 0 : res.code) == 200 && ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b.length) > 0) {
85
105
  return { searchType: "product", response: res };
86
106
  }
@@ -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>;
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/solution/BookingTicket/utils/scan/handleScan.ts
@@ -24,6 +34,7 @@ __export(handleScan_exports, {
24
34
  });
25
35
  module.exports = __toCommonJS(handleScan_exports);
26
36
  var import_cloudSearch = require("./cloudSearch");
37
+ var import_scanCache = __toESM(require("./scanCache"));
27
38
  var promiseAny = async (promises) => {
28
39
  if (promises.length === 0) {
29
40
  throw new Error("No promises provided");
@@ -47,9 +58,49 @@ var promiseAny = async (promises) => {
47
58
  });
48
59
  });
49
60
  };
50
- var handleGlobalScan = (request) => {
61
+ var handleScanFn = (getRequestList, localSearch) => {
51
62
  return async (scanResult) => {
52
63
  const { value } = scanResult || {};
64
+ try {
65
+ const localResult = localSearch == null ? void 0 : localSearch(value);
66
+ if ((localResult == null ? void 0 : localResult.length) > 0) {
67
+ console.log("本地搜索到数据>>>>>>>", localResult);
68
+ return {
69
+ searchType: "local_product",
70
+ response: { data: { list: localResult } }
71
+ };
72
+ } else {
73
+ console.log("本地搜索无数据>>>>>>>");
74
+ }
75
+ } catch (error) {
76
+ console.error("本地搜索到数据失败>>>>>>>", error);
77
+ }
78
+ try {
79
+ if (import_scanCache.default.has(value)) {
80
+ const result = import_scanCache.default.get(value);
81
+ console.log("缓存中搜索到数据>>>>>>>", result);
82
+ return result;
83
+ } else {
84
+ console.log("缓存中无数据>>>>>>>");
85
+ }
86
+ } catch (error) {
87
+ console.error("缓存中搜索数据失败>>>>>>>", error);
88
+ }
89
+ const requestList = (getRequestList == null ? void 0 : getRequestList(value)) || [];
90
+ if (requestList.length === 0) {
91
+ throw new Error("requestList is empty");
92
+ }
93
+ try {
94
+ const result = await promiseAny(requestList);
95
+ import_scanCache.default.set(value, result);
96
+ return result;
97
+ } catch (error) {
98
+ throw error;
99
+ }
100
+ };
101
+ };
102
+ var handleGlobalScan = (request, localSearch) => {
103
+ const getRequestList = (value) => {
53
104
  let requestList = [];
54
105
  if (value.startsWith("WL")) {
55
106
  requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
@@ -60,17 +111,12 @@ var handleGlobalScan = (request) => {
60
111
  (0, import_cloudSearch.searchProduct)(request, value)
61
112
  ];
62
113
  }
63
- try {
64
- const result = await promiseAny(requestList);
65
- return result;
66
- } catch (error) {
67
- throw error;
68
- }
114
+ return requestList;
69
115
  };
116
+ return handleScanFn(getRequestList, localSearch);
70
117
  };
71
- var handleCustomerScan = (request) => {
72
- return async (scanResult) => {
73
- const { value } = scanResult || {};
118
+ var handleCustomerScan = (request, localSearch) => {
119
+ const getRequestList = (value) => {
74
120
  let requestList = [];
75
121
  if (value.startsWith("WL")) {
76
122
  requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
@@ -80,13 +126,9 @@ var handleCustomerScan = (request) => {
80
126
  (0, import_cloudSearch.searchWallet)(request, value)
81
127
  ];
82
128
  }
83
- try {
84
- const result = await Promise.race(requestList);
85
- return result;
86
- } catch (error) {
87
- throw error;
88
- }
129
+ return requestList;
89
130
  };
131
+ return handleScanFn(getRequestList, localSearch);
90
132
  };
91
133
  // Annotate the CommonJS export names for ESM import in node:
92
134
  0 && (module.exports = {