@pisell/pisellos 0.0.321 → 0.0.324

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 (74) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Customer/types.d.ts +1 -1
  3. package/dist/modules/Payment/types.d.ts +7 -7
  4. package/dist/modules/Product/index.d.ts +1 -1
  5. package/dist/modules/ProductList/index.js +2 -1
  6. package/dist/modules/Rules/types.d.ts +1 -1
  7. package/dist/modules/Schedule/type.d.ts +7 -7
  8. package/dist/modules/Schedule/types.d.ts +9 -9
  9. package/dist/solution/BookingByStep/index.d.ts +1 -1
  10. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  12. package/dist/types/index.d.ts +1 -1
  13. package/dist/utils/task.d.ts +2 -2
  14. package/dist/utils/watch.d.ts +2 -2
  15. package/lib/core/index.js +27 -28
  16. package/lib/effects/index.d.ts +2 -2
  17. package/lib/effects/index.js +3 -7
  18. package/lib/modules/Account/index.js +9 -10
  19. package/lib/modules/AccountList/index.js +14 -11
  20. package/lib/modules/BaseModule.js +6 -3
  21. package/lib/modules/Cart/index.js +14 -9
  22. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  23. package/lib/modules/Customer/constants.js +1 -1
  24. package/lib/modules/Customer/index.js +18 -15
  25. package/lib/modules/Customer/types.d.ts +1 -1
  26. package/lib/modules/Date/index.js +10 -6
  27. package/lib/modules/Date/types.js +1 -0
  28. package/lib/modules/Discount/index.js +11 -6
  29. package/lib/modules/Guests/index.js +10 -15
  30. package/lib/modules/Order/index.js +11 -9
  31. package/lib/modules/Payment/cash.js +1 -1
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +80 -69
  35. package/lib/modules/Payment/types.d.ts +7 -7
  36. package/lib/modules/Payment/utils.js +3 -6
  37. package/lib/modules/Payment/walletpass.js +31 -31
  38. package/lib/modules/Product/index.d.ts +1 -1
  39. package/lib/modules/Product/index.js +6 -5
  40. package/lib/modules/ProductList/index.js +7 -4
  41. package/lib/modules/Resource/index.js +8 -12
  42. package/lib/modules/Rules/index.js +12 -17
  43. package/lib/modules/Rules/types.d.ts +1 -1
  44. package/lib/modules/Schedule/index.js +8 -5
  45. package/lib/modules/Schedule/type.d.ts +7 -7
  46. package/lib/modules/Schedule/types.d.ts +9 -9
  47. package/lib/modules/Schedule/utils.js +2 -4
  48. package/lib/modules/Step/index.js +7 -4
  49. package/lib/modules/Summary/index.js +9 -4
  50. package/lib/plugins/request.js +34 -33
  51. package/lib/plugins/window.js +101 -113
  52. package/lib/solution/BookingByStep/index.d.ts +1 -1
  53. package/lib/solution/BookingByStep/index.js +70 -104
  54. package/lib/solution/BookingByStep/utils/capacity.js +10 -15
  55. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  56. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  57. package/lib/solution/BookingByStep/utils/stock.js +3 -6
  58. package/lib/solution/BookingByStep/utils/timeslots.js +24 -27
  59. package/lib/solution/BookingTicket/index.js +19 -14
  60. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  61. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  62. package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
  63. package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
  64. package/lib/solution/BuyTickets/index.js +15 -15
  65. package/lib/solution/Checkout/index.js +206 -199
  66. package/lib/solution/Checkout/utils/index.js +18 -22
  67. package/lib/solution/ShopDiscount/index.js +15 -11
  68. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  69. package/lib/types/index.d.ts +1 -1
  70. package/lib/utils/task.d.ts +2 -2
  71. package/lib/utils/task.js +3 -3
  72. package/lib/utils/watch.d.ts +2 -2
  73. package/lib/utils/watch.js +5 -7
  74. package/package.json +1 -1
@@ -43,8 +43,7 @@ function calculateResourceAvailableTime({
43
43
  const matchingTimes = resource.times.filter((time) => {
44
44
  return (0, import_dayjs.default)(time.start_at).isSame((0, import_dayjs.default)(timeSlots.start_at), "day");
45
45
  });
46
- if (matchingTimes.length === 0)
47
- return 0;
46
+ if (matchingTimes.length === 0) return 0;
48
47
  const overlaps = [];
49
48
  for (const time of matchingTimes) {
50
49
  const overlapStart = (0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) ? (0, import_dayjs.default)(time.start_at) : (0, import_dayjs.default)(timeSlots.start_at);
@@ -53,8 +52,7 @@ function calculateResourceAvailableTime({
53
52
  overlaps.push({ start: overlapStart, end: overlapEnd });
54
53
  }
55
54
  }
56
- if (overlaps.length === 0)
57
- return 0;
55
+ if (overlaps.length === 0) return 0;
58
56
  overlaps.sort((a, b) => a.start.diff(b.start));
59
57
  const merged = [];
60
58
  let current = overlaps[0];
@@ -83,7 +81,7 @@ function findFastestAvailableResource({
83
81
  const currentTime = (0, import_dayjs.default)();
84
82
  let fastestTime = null;
85
83
  let fastestResources = [];
86
- console.log("[TimeslotUtils] 查找最快可用资源:", {
84
+ console.log("[TimeslotUtils] \u67E5\u627E\u6700\u5FEB\u53EF\u7528\u8D44\u6E90:", {
87
85
  currentTime: currentTime.format("YYYY-MM-DD HH:mm:ss"),
88
86
  resourceCount: resources.length,
89
87
  currentCapacity,
@@ -96,14 +94,14 @@ function findFastestAvailableResource({
96
94
  return isToday && isStillWorking;
97
95
  });
98
96
  if (todayTimes.length === 0) {
99
- console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
97
+ console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id}(${resource.main_field}) \u4ECA\u65E5\u65E0\u53EF\u7528\u65F6\u95F4\u6BB5`);
100
98
  continue;
101
99
  }
102
100
  for (const time of todayTimes) {
103
101
  const workStartTime = (0, import_dayjs.default)(time.start_at);
104
102
  const workEndTime = (0, import_dayjs.default)(time.end_at);
105
103
  let nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
106
- console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
104
+ console.log(`[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ${resource.id}(${resource.main_field}):`, {
107
105
  workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
108
106
  checkStartTime: nextAvailableTime.format("HH:mm:ss"),
109
107
  eventCount: ((_a = time.event_list) == null ? void 0 : _a.length) || 0
@@ -119,7 +117,7 @@ function findFastestAvailableResource({
119
117
  for (const event of relevantEvents) {
120
118
  const eventStart = (0, import_dayjs.default)(event.start_at);
121
119
  const eventEnd = (0, import_dayjs.default)(event.end_at);
122
- console.log(`[TimeslotUtils] 检查事件冲突:`, {
120
+ console.log(`[TimeslotUtils] \u68C0\u67E5\u4E8B\u4EF6\u51B2\u7A81:`, {
123
121
  resourceId: resource.id,
124
122
  eventTime: `${eventStart.format("HH:mm")}-${eventEnd.format("HH:mm")}`,
125
123
  checkTime: finalAvailableTime.format("HH:mm:ss"),
@@ -128,7 +126,7 @@ function findFastestAvailableResource({
128
126
  if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
129
127
  if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
130
128
  finalAvailableTime = eventEnd;
131
- console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
129
+ console.log(`[TimeslotUtils] \u53D1\u73B0\u65F6\u95F4\u51B2\u7A81\uFF0C\u8C03\u6574\u5230: ${finalAvailableTime.format("HH:mm:ss")}`);
132
130
  }
133
131
  } else {
134
132
  const totalCapacity = resource.capacity || 0;
@@ -138,47 +136,46 @@ function findFastestAvailableResource({
138
136
  const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
139
137
  if (totalRequiredCapacity > totalCapacity) {
140
138
  finalAvailableTime = eventEnd;
141
- console.log(`[TimeslotUtils] 容量不足,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
139
+ console.log(`[TimeslotUtils] \u5BB9\u91CF\u4E0D\u8DB3\uFF0C\u8C03\u6574\u5230: ${finalAvailableTime.format("HH:mm:ss")}`);
142
140
  }
143
141
  }
144
142
  }
145
143
  }
146
144
  if (finalAvailableTime.isAfter(workEndTime)) {
147
- console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
145
+ console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id} \u53EF\u7528\u65F6\u95F4\u8D85\u51FA\u5DE5\u4F5C\u65F6\u95F4\uFF0C\u8DF3\u8FC7`);
148
146
  continue;
149
147
  }
150
- console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 最快可用时间: ${finalAvailableTime.format("HH:mm:ss")}`);
148
+ console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id}(${resource.main_field}) \u6700\u5FEB\u53EF\u7528\u65F6\u95F4: ${finalAvailableTime.format("HH:mm:ss")}`);
151
149
  if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
152
150
  fastestTime = finalAvailableTime;
153
151
  fastestResources = [resource];
154
- console.log(`[TimeslotUtils] 更新最快时间: ${fastestTime.format("HH:mm:ss")}, 资源: ${resource.main_field}`);
152
+ console.log(`[TimeslotUtils] \u66F4\u65B0\u6700\u5FEB\u65F6\u95F4: ${fastestTime.format("HH:mm:ss")}, \u8D44\u6E90: ${resource.main_field}`);
155
153
  } else if (finalAvailableTime.isSame(fastestTime)) {
156
154
  fastestResources.push(resource);
157
- console.log(`[TimeslotUtils] 添加相同时间资源: ${resource.main_field}`);
155
+ console.log(`[TimeslotUtils] \u6DFB\u52A0\u76F8\u540C\u65F6\u95F4\u8D44\u6E90: ${resource.main_field}`);
158
156
  }
159
157
  break;
160
158
  }
161
159
  }
162
160
  if (!fastestTime || fastestResources.length === 0) {
163
- console.log("[TimeslotUtils] 未找到可用资源");
161
+ console.log("[TimeslotUtils] \u672A\u627E\u5230\u53EF\u7528\u8D44\u6E90");
164
162
  return null;
165
163
  }
166
- console.log(`[TimeslotUtils] 找到 ${fastestResources.length} 个最快可用资源,时间: ${fastestTime.format("HH:mm:ss")}`);
164
+ console.log(`[TimeslotUtils] \u627E\u5230 ${fastestResources.length} \u4E2A\u6700\u5FEB\u53EF\u7528\u8D44\u6E90\uFF0C\u65F6\u95F4: ${fastestTime.format("HH:mm:ss")}`);
167
165
  if (fastestResources.length === 1) {
168
- console.log(`[TimeslotUtils] 返回唯一最快资源: ${fastestResources[0].main_field}`);
166
+ console.log(`[TimeslotUtils] \u8FD4\u56DE\u552F\u4E00\u6700\u5FEB\u8D44\u6E90: ${fastestResources[0].main_field}`);
169
167
  return fastestResources[0];
170
168
  }
171
169
  let selectedResource = fastestResources[0];
172
170
  let maxIdleTime = 0;
173
- console.log(`[TimeslotUtils] 比较 ${fastestResources.length} 个资源的空闲时间:`);
171
+ console.log(`[TimeslotUtils] \u6BD4\u8F83 ${fastestResources.length} \u4E2A\u8D44\u6E90\u7684\u7A7A\u95F2\u65F6\u95F4:`);
174
172
  for (const resource of fastestResources) {
175
173
  const workingTime = resource.times.find((time) => {
176
174
  const isToday = (0, import_dayjs.default)(time.start_at).isSame(fastestTime, "day");
177
175
  const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(fastestTime);
178
176
  return isToday && isStillWorking;
179
177
  });
180
- if (!workingTime)
181
- continue;
178
+ if (!workingTime) continue;
182
179
  const workEndTime = (0, import_dayjs.default)(workingTime.end_at);
183
180
  let totalIdleTime = workEndTime.diff(fastestTime, "minute");
184
181
  const relevantEvents = ((_c = workingTime.event_list) == null ? void 0 : _c.filter((event) => {
@@ -192,19 +189,19 @@ function findFastestAvailableResource({
192
189
  const eventDuration = eventEnd.diff(eventStart, "minute");
193
190
  totalIdleTime -= eventDuration;
194
191
  }
195
- console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}):`, {
196
- 工作结束时间: workEndTime.format("HH:mm"),
197
- 总工作时长: workEndTime.diff(fastestTime, "minute") + "分钟",
198
- 预约占用时长: workEndTime.diff(fastestTime, "minute") - totalIdleTime + "分钟",
199
- 实际空闲时长: totalIdleTime + "分钟"
192
+ console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id}(${resource.main_field}):`, {
193
+ \u5DE5\u4F5C\u7ED3\u675F\u65F6\u95F4: workEndTime.format("HH:mm"),
194
+ \u603B\u5DE5\u4F5C\u65F6\u957F: workEndTime.diff(fastestTime, "minute") + "\u5206\u949F",
195
+ \u9884\u7EA6\u5360\u7528\u65F6\u957F: workEndTime.diff(fastestTime, "minute") - totalIdleTime + "\u5206\u949F",
196
+ \u5B9E\u9645\u7A7A\u95F2\u65F6\u957F: totalIdleTime + "\u5206\u949F"
200
197
  });
201
198
  if (totalIdleTime > maxIdleTime) {
202
199
  maxIdleTime = totalIdleTime;
203
200
  selectedResource = resource;
204
- console.log(`[TimeslotUtils] 更新最佳选择: ${resource.main_field} (空闲${totalIdleTime}分钟)`);
201
+ console.log(`[TimeslotUtils] \u66F4\u65B0\u6700\u4F73\u9009\u62E9: ${resource.main_field} (\u7A7A\u95F2${totalIdleTime}\u5206\u949F)`);
205
202
  }
206
203
  }
207
- console.log(`[TimeslotUtils] 最终选择资源: ${selectedResource.main_field} (最长空闲${maxIdleTime}分钟)`);
204
+ console.log(`[TimeslotUtils] \u6700\u7EC8\u9009\u62E9\u8D44\u6E90: ${selectedResource.main_field} (\u6700\u957F\u7A7A\u95F2${maxIdleTime}\u5206\u949F)`);
208
205
  return selectedResource;
209
206
  }
210
207
  function filterConditionTimeSlots(times, startTime, endTime) {
@@ -41,27 +41,32 @@ var import_handleScan = require("./utils/scan/handleScan");
41
41
  var import_scanCache = __toESM(require("./utils/scan/scanCache"));
42
42
  __reExport(BookingTicket_exports, require("./types"), module.exports);
43
43
  var BookingTicketImpl = class extends import_BaseModule.BaseModule {
44
- constructor() {
45
- super(...arguments);
46
- this.defaultName = "bookingTicket";
47
- this.defaultVersion = "1.0.0";
48
- this.isSolution = true;
49
- this.otherParams = {};
50
- }
44
+ defaultName = "bookingTicket";
45
+ defaultVersion = "1.0.0";
46
+ isSolution = true;
47
+ request;
48
+ window;
49
+ shopStore;
50
+ store;
51
+ otherParams = {};
52
+ cacheId;
53
+ platform;
54
+ // 平台类型,用于判断是 PC / H5
55
+ scan;
51
56
  async initialize(core, options) {
52
57
  var _a, _b, _c;
53
58
  this.core = core;
54
59
  this.store = options.store || {};
55
60
  this.otherParams = options.otherParams || {};
56
- console.log("[BookingTicket] 初始化完成");
61
+ console.log("[BookingTicket] \u521D\u59CB\u5316\u5B8C\u6210");
57
62
  this.request = core.getPlugin("request");
58
63
  this.window = core.getPlugin("window");
59
64
  this.shopStore = core.getPlugin("shopStore");
60
65
  if (!this.request) {
61
- throw new Error("bookingTicket解决方案需要 request 插件支持");
66
+ throw new Error("bookingTicket\u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
62
67
  }
63
68
  if (!this.shopStore) {
64
- throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
69
+ throw new Error("bookingTicket\u89E3\u51B3\u65B9\u6848\u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
65
70
  }
66
71
  let targetCacheData = {};
67
72
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
@@ -96,7 +101,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
96
101
  }
97
102
  });
98
103
  } else {
99
- throw new Error(`模块 ${step} 不存在`);
104
+ throw new Error(`\u6A21\u5757 ${step} \u4E0D\u5B58\u5728`);
100
105
  }
101
106
  });
102
107
  this.core.effects.emit(import_types.BookingTicketHooks.onInited, {});
@@ -302,7 +307,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
302
307
  try {
303
308
  callback(d);
304
309
  } catch (error) {
305
- console.error("scanGlobalListener传入的回调函数异常", error);
310
+ console.error("scanGlobalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38", error);
306
311
  }
307
312
  };
308
313
  const listener = { key: "global", callback: safeCallback };
@@ -319,7 +324,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
319
324
  try {
320
325
  callback(d);
321
326
  } catch (error) {
322
- console.error("scanCustomerListener传入的回调函数异常", error);
327
+ console.error("scanCustomerListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38", error);
323
328
  }
324
329
  };
325
330
  const listener = { key: "customer", callback: safeCallback };
@@ -338,7 +343,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
338
343
  callback(d);
339
344
  } catch (error) {
340
345
  console.error(
341
- `scanUniversalListener传入的回调函数异常, key: ${key}`,
346
+ `scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ${key}`,
342
347
  error
343
348
  );
344
349
  }
@@ -57,7 +57,7 @@ var searchWalletPass = async (request, code) => {
57
57
  if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
58
58
  return { searchType: "walletPass", response: res };
59
59
  }
60
- throw new Error("没有找到对应的识别码");
60
+ throw new Error("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
61
61
  } catch (error) {
62
62
  throw error;
63
63
  }
@@ -72,7 +72,7 @@ var searchWallet = async (request, code) => {
72
72
  if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
73
73
  return { searchType: "wallet", response: res };
74
74
  }
75
- throw new Error("没有找到对应的识别码");
75
+ throw new Error("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
76
76
  } catch (error) {
77
77
  throw error;
78
78
  }
@@ -104,7 +104,7 @@ var searchProduct = async (request, code) => {
104
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) {
105
105
  return { searchType: "product", response: res };
106
106
  }
107
- throw new Error("没有找到对应的识别码");
107
+ throw new Error("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
108
108
  } catch (error) {
109
109
  throw error;
110
110
  }
@@ -66,28 +66,28 @@ var handleScanFn = (getRequestList, localSearch) => {
66
66
  try {
67
67
  const localResult = localSearch == null ? void 0 : localSearch(value);
68
68
  if ((localResult == null ? void 0 : localResult.length) > 0) {
69
- console.log("本地搜索到数据>>>>>>>", localResult);
69
+ console.log("\u672C\u5730\u641C\u7D22\u5230\u6570\u636E>>>>>>>", localResult);
70
70
  return {
71
71
  searchType: "local_product",
72
72
  response: { data: { list: localResult } }
73
73
  };
74
74
  } else {
75
- console.log("本地搜索无数据>>>>>>>");
75
+ console.log("\u672C\u5730\u641C\u7D22\u65E0\u6570\u636E>>>>>>>");
76
76
  }
77
77
  } catch (error) {
78
- console.error("本地搜索到数据失败>>>>>>>", error);
78
+ console.error("\u672C\u5730\u641C\u7D22\u5230\u6570\u636E\u5931\u8D25>>>>>>>", error);
79
79
  }
80
80
  }
81
81
  try {
82
82
  if (import_scanCache.default.has(value)) {
83
83
  const result = import_scanCache.default.get(value);
84
- console.log("缓存中搜索到数据>>>>>>>", result);
84
+ console.log("\u7F13\u5B58\u4E2D\u641C\u7D22\u5230\u6570\u636E>>>>>>>", result);
85
85
  return result;
86
86
  } else {
87
- console.log("缓存中无数据>>>>>>>");
87
+ console.log("\u7F13\u5B58\u4E2D\u65E0\u6570\u636E>>>>>>>");
88
88
  }
89
89
  } catch (error) {
90
- console.error("缓存中搜索数据失败>>>>>>>", error);
90
+ console.error("\u7F13\u5B58\u4E2D\u641C\u7D22\u6570\u636E\u5931\u8D25>>>>>>>", error);
91
91
  }
92
92
  const requestList = (getRequestList == null ? void 0 : getRequestList(value)) || [];
93
93
  if (requestList.length === 0) {
@@ -35,8 +35,10 @@ module.exports = __toCommonJS(scan_exports);
35
35
  var import_watch = __toESM(require("../../../../utils/watch"));
36
36
  var import_task = __toESM(require("../../../../utils/task"));
37
37
  var Scan = class {
38
+ solution;
39
+ watchKey;
40
+ listenerConfig = /* @__PURE__ */ new Map();
38
41
  constructor(solution, watchKey) {
39
- this.listenerConfig = /* @__PURE__ */ new Map();
40
42
  var _a, _b, _c, _d, _e;
41
43
  this.solution = solution;
42
44
  this.watchKey = watchKey;
@@ -29,7 +29,7 @@ var compressData = (data) => {
29
29
  }
30
30
  return JSON.stringify(data);
31
31
  } catch (error) {
32
- console.warn("数据压缩失败:", error);
32
+ console.warn("\u6570\u636E\u538B\u7F29\u5931\u8D25:", error);
33
33
  return JSON.stringify(data);
34
34
  }
35
35
  };
@@ -40,17 +40,19 @@ var decompressData = (compressedData) => {
40
40
  }
41
41
  return JSON.parse(compressedData);
42
42
  } catch (error) {
43
- console.warn("数据解压缩失败:", error);
43
+ console.warn("\u6570\u636E\u89E3\u538B\u7F29\u5931\u8D25:", error);
44
44
  return null;
45
45
  }
46
46
  };
47
47
  var LRUCache = class {
48
+ head = null;
49
+ // 最久未使用的节点
50
+ tail = null;
51
+ // 最近使用的节点
52
+ keyMap = /* @__PURE__ */ new Map();
53
+ // key到节点的映射(只存储引用)
54
+ maxSize;
48
55
  constructor(maxSize = 100) {
49
- this.head = null;
50
- // 最久未使用的节点
51
- this.tail = null;
52
- // 最近使用的节点
53
- this.keyMap = /* @__PURE__ */ new Map();
54
56
  this.maxSize = maxSize;
55
57
  }
56
58
  /**
@@ -58,8 +60,7 @@ var LRUCache = class {
58
60
  * @param node 要移动的节点
59
61
  */
60
62
  moveToTail(node) {
61
- if (this.tail === node)
62
- return;
63
+ if (this.tail === node) return;
63
64
  if (node.prev) {
64
65
  node.prev.next = node.next;
65
66
  }
@@ -28,23 +28,26 @@ var import_types = require("./types");
28
28
  var import_BaseModule = require("../../modules/BaseModule");
29
29
  __reExport(BuyTickets_exports, require("./types"), module.exports);
30
30
  var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
31
+ // 提供给 baseModule 用的默认名称 和 默认版本
32
+ defaultName = "buyTickets";
33
+ defaultVersion = "1.0.0";
34
+ isSolution = true;
35
+ request;
36
+ window;
37
+ store;
38
+ otherParams = {};
31
39
  constructor(name, version) {
32
40
  super(name, version);
33
- // 提供给 baseModule 用的默认名称 和 默认版本
34
- this.defaultName = "buyTickets";
35
- this.defaultVersion = "1.0.0";
36
- this.isSolution = true;
37
- this.otherParams = {};
38
41
  }
39
42
  async initialize(core, options) {
40
43
  this.core = core;
41
44
  this.store = options.store || {};
42
45
  this.otherParams = options.otherParams || {};
43
- console.log("[BuyTickets] 初始化完成");
46
+ console.log("[BuyTickets] \u521D\u59CB\u5316\u5B8C\u6210");
44
47
  this.request = core.getPlugin("request");
45
48
  this.window = core.getPlugin("window");
46
49
  if (!this.request) {
47
- throw new Error("购物车模块需要 request 插件支持");
50
+ throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
48
51
  }
49
52
  if (this.otherParams.prodctIds) {
50
53
  await this.loadProductsByIds(this.otherParams.prodctIds);
@@ -76,7 +79,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
76
79
  }
77
80
  async destroy() {
78
81
  await this.core.effects.emit(import_types.BuyTicketsHooks.onDestroy, {});
79
- console.log("[BuyTickets] 已销毁");
82
+ console.log("[BuyTickets] \u5DF2\u9500\u6BC1");
80
83
  }
81
84
  // 获取当前绑定的所有商品
82
85
  async getProducts() {
@@ -94,10 +97,8 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
94
97
  var _a, _b;
95
98
  const mainProduct = await ((_a = this.store.mainProducts) == null ? void 0 : _a.getProduct(id));
96
99
  const otherProduct = await ((_b = this.store.otherProducts) == null ? void 0 : _b.getProduct(id));
97
- if (mainProduct)
98
- return mainProduct;
99
- if (otherProduct)
100
- return otherProduct;
100
+ if (mainProduct) return mainProduct;
101
+ if (otherProduct) return otherProduct;
101
102
  throw new Error(`Product not found: ${id}`);
102
103
  }
103
104
  // 商品列表页提交
@@ -106,13 +107,12 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
106
107
  ...data,
107
108
  products: this.getProducts()
108
109
  });
109
- if (res.status === false)
110
- return res;
110
+ if (res.status === false) return res;
111
111
  this.window.localStorage.setItem(
112
112
  "buyTickets:listSubmit",
113
113
  JSON.stringify({ ...data, products: this.getProducts() })
114
114
  );
115
- console.log("listSubmit 应该走逻辑层的 API 发请求了");
115
+ console.log("listSubmit \u5E94\u8BE5\u8D70\u903B\u8F91\u5C42\u7684 API \u53D1\u8BF7\u6C42\u4E86");
116
116
  }
117
117
  // 购物车提交
118
118
  async cartSubmit(data) {