@pisell/pisellos 2.1.100 → 2.1.101

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 (80) 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/Rules/types.d.ts +1 -1
  5. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  6. package/dist/modules/Schedule/type.d.ts +7 -7
  7. package/dist/modules/Schedule/types.d.ts +9 -9
  8. package/dist/solution/BookingByStep/index.d.ts +1 -1
  9. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  10. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  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 +28 -27
  16. package/lib/effects/index.d.ts +2 -2
  17. package/lib/effects/index.js +7 -3
  18. package/lib/modules/Account/index.js +10 -9
  19. package/lib/modules/AccountList/index.js +11 -14
  20. package/lib/modules/BaseModule.js +3 -6
  21. package/lib/modules/Cart/index.js +9 -14
  22. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  23. package/lib/modules/Customer/constants.js +1 -1
  24. package/lib/modules/Customer/index.js +15 -18
  25. package/lib/modules/Customer/types.d.ts +1 -1
  26. package/lib/modules/Date/index.js +6 -10
  27. package/lib/modules/Date/types.js +0 -1
  28. package/lib/modules/Discount/index.js +6 -11
  29. package/lib/modules/Guests/index.js +15 -10
  30. package/lib/modules/Order/index.js +7 -10
  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 +73 -84
  35. package/lib/modules/Payment/types.d.ts +7 -7
  36. package/lib/modules/Payment/utils.js +6 -3
  37. package/lib/modules/Payment/walletpass.js +31 -31
  38. package/lib/modules/Product/index.js +5 -6
  39. package/lib/modules/ProductList/index.js +3 -5
  40. package/lib/modules/Resource/index.js +12 -8
  41. package/lib/modules/Rules/index.js +35 -21
  42. package/lib/modules/Rules/types.d.ts +1 -1
  43. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  44. package/lib/modules/Schedule/index.js +5 -8
  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 +4 -2
  48. package/lib/modules/Step/index.js +4 -7
  49. package/lib/modules/Summary/index.js +4 -9
  50. package/lib/modules/Summary/utils.js +16 -8
  51. package/lib/plugins/request.js +33 -34
  52. package/lib/plugins/window.js +113 -101
  53. package/lib/solution/BookingByStep/index.d.ts +1 -1
  54. package/lib/solution/BookingByStep/index.js +177 -110
  55. package/lib/solution/BookingByStep/utils/capacity.js +16 -11
  56. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  57. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  58. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  59. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  60. package/lib/solution/BookingTicket/index.js +14 -19
  61. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  62. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  63. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  64. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  65. package/lib/solution/BuyTickets/index.js +15 -15
  66. package/lib/solution/Checkout/index.js +211 -216
  67. package/lib/solution/Checkout/utils/index.js +22 -18
  68. package/lib/solution/RegisterAndLogin/config.js +2 -2
  69. package/lib/solution/RegisterAndLogin/index.js +110 -114
  70. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  71. package/lib/solution/ShopDiscount/index.js +13 -16
  72. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  73. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  74. package/lib/solution/ShopDiscount/utils.js +2 -1
  75. package/lib/types/index.d.ts +1 -1
  76. package/lib/utils/task.d.ts +2 -2
  77. package/lib/utils/task.js +3 -3
  78. package/lib/utils/watch.d.ts +2 -2
  79. package/lib/utils/watch.js +7 -5
  80. package/package.json +17 -16
@@ -53,7 +53,7 @@ var formatDefaultCapacitys = ({
53
53
  );
54
54
  if (!item && (window == null ? void 0 : window.sendWarningLog)) {
55
55
  window.sendWarningLog({
56
- title: "\u672A\u627E\u5230\u5957\u9910 capacity \u914D\u7F6E",
56
+ title: "未找到套餐 capacity 配置",
57
57
  content: [
58
58
  {
59
59
  key: "product_id",
@@ -151,16 +151,19 @@ function calculateCartItemsCapacityUsageByResourceType({
151
151
  const resourcesInThisType = resourceTypeMap[formId];
152
152
  const resourceIdsInThisType = resourcesInThisType.map((r) => r.id);
153
153
  cartItems.forEach((cartItem) => {
154
- if (!cartItem.start_time || !cartItem.end_time) return;
154
+ if (!cartItem.start_time || !cartItem.end_time)
155
+ return;
155
156
  const itemStart = `${cartItem.start_date} ${cartItem.start_time}`;
156
157
  const itemEnd = `${cartItem.end_date || cartItem.start_date} ${cartItem.end_time}`;
157
158
  const hasTimeOverlap = !((0, import_dayjs.default)(itemEnd).isBefore((0, import_dayjs.default)(timeSlotStart)) || (0, import_dayjs.default)(itemStart).isAfter((0, import_dayjs.default)(timeSlotEnd)));
158
- if (!hasTimeOverlap) return;
159
+ if (!hasTimeOverlap)
160
+ return;
159
161
  const productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
160
162
  const hasResourceTypeOverlap = productResourceIds.some(
161
163
  (id) => resourceIdsInThisType.includes(id)
162
164
  );
163
- if (!hasResourceTypeOverlap) return;
165
+ if (!hasResourceTypeOverlap)
166
+ return;
164
167
  const { currentCapacity } = getCapacityInfoByCartItem(cartItem);
165
168
  totalUsage += currentCapacity;
166
169
  });
@@ -220,7 +223,8 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
220
223
  });
221
224
  for (const [formId, requiredCapacity] of Object.entries(requiredCapacityByType)) {
222
225
  const resourcesInType = resourceTypeMap[formId];
223
- if (resourcesInType.length === 0) continue;
226
+ if (resourcesInType.length === 0)
227
+ continue;
224
228
  let resourceTypeConfig = null;
225
229
  for (const cartItem of cartItems) {
226
230
  if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
@@ -230,11 +234,12 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
230
234
  return ((_a2 = r.id) == null ? void 0 : _a2.toString()) === formId && r.status === 1;
231
235
  }
232
236
  );
233
- if (resourceTypeConfig) break;
237
+ if (resourceTypeConfig)
238
+ break;
234
239
  }
235
240
  }
236
241
  const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
237
- console.log(`capacity.ts - \u8D44\u6E90\u7C7B\u578B ${formId} \u914D\u7F6E:`, {
242
+ console.log(`capacity.ts - 资源类型 ${formId} 配置:`, {
238
243
  resourceTypeConfig,
239
244
  type: resourceTypeConfig == null ? void 0 : resourceTypeConfig.type,
240
245
  isMultipleBooking,
@@ -250,9 +255,9 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
250
255
  totalAvailableCapacity += resource.capacity || 0;
251
256
  }
252
257
  });
253
- console.log(`capacity.ts - \u8D44\u6E90\u7C7B\u578B ${formId} \u591A\u4E2A\u9884\u7EA6\u68C0\u67E5: \u603B\u5BB9\u91CF ${totalAvailableCapacity}, \u9700\u6C42 ${requiredCapacity}`);
258
+ console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
254
259
  if (totalAvailableCapacity < requiredCapacity) {
255
- console.log(`\u8D44\u6E90\u7C7B\u578B ${formId} \u5BB9\u91CF\u4E0D\u8DB3: \u9700\u8981 ${requiredCapacity}, \u53EF\u7528 ${totalAvailableCapacity}`);
260
+ console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
256
261
  return {
257
262
  success: false,
258
263
  required: requiredCapacity,
@@ -269,9 +274,9 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
269
274
  availableResourceCount++;
270
275
  }
271
276
  });
272
- console.log(`capacity.ts - \u8D44\u6E90\u7C7B\u578B ${formId} \u5355\u4E2A\u9884\u7EA6\u68C0\u67E5: \u53EF\u7528\u8D44\u6E90\u6570 ${availableResourceCount}, \u9700\u6C42 ${requiredCapacity}`);
277
+ console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
273
278
  if (availableResourceCount < requiredCapacity) {
274
- console.log(`\u8D44\u6E90\u7C7B\u578B ${formId} \u6570\u91CF\u4E0D\u8DB3: \u9700\u8981 ${requiredCapacity}, \u53EF\u7528 ${availableResourceCount}`);
279
+ console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
275
280
  return {
276
281
  success: false,
277
282
  required: requiredCapacity,
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
6
6
  * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
7
7
  *
8
8
  */
9
- declare type DateType = Dayjs;
9
+ type DateType = Dayjs;
10
10
  export interface TimeSliceItem {
11
11
  start_time: string;
12
12
  end_time: string;
@@ -458,8 +458,10 @@ var getTimeSlicesByResources = ({
458
458
  var _a, _b, _c, _d;
459
459
  const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
460
460
  const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
461
- if (aIsCombined && !bIsCombined) return 1;
462
- if (!aIsCombined && bIsCombined) return -1;
461
+ if (aIsCombined && !bIsCombined)
462
+ return 1;
463
+ if (!aIsCombined && bIsCombined)
464
+ return -1;
463
465
  return 0;
464
466
  });
465
467
  let timeSliceList = resources.reduce(
@@ -543,7 +545,8 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
543
545
  }, []);
544
546
  };
545
547
  function filterScheduleByDateRange(schedule, startDate, endDate) {
546
- if (!(schedule == null ? void 0 : schedule.length)) return [];
548
+ if (!(schedule == null ? void 0 : schedule.length))
549
+ return [];
547
550
  const start = new Date(startDate);
548
551
  const end = new Date(endDate);
549
552
  return schedule.filter((item) => {
@@ -609,7 +612,8 @@ function filterResourcesByFormItem(resources, form_id) {
609
612
  }
610
613
  function checkTwoResourcesIntersection(resource1, resource2) {
611
614
  var _a, _b;
612
- if (resource1.id === resource2.id) return true;
615
+ if (resource1.id === resource2.id)
616
+ return true;
613
617
  if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
614
618
  // 1、当前其他购物车里是否选了当前组合资源的子资源
615
619
  // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
@@ -61,10 +61,13 @@ function checkProductStock({
61
61
  const bundleRequiredQuantity = (bundleItem.num || 1) * quantity;
62
62
  const isBundleTrackingEnabled = bundleItem.is_track === 1 || bundleItem.is_track === true;
63
63
  const isBundleOverSoldDisabled = bundleItem.over_sold === 0;
64
- if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled) continue;
65
- if (bundleStockQuantity === void 0 || bundleStockQuantity === null) continue;
64
+ if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled)
65
+ continue;
66
+ if (bundleStockQuantity === void 0 || bundleStockQuantity === null)
67
+ continue;
66
68
  const existingBundleQuantity = currentCartItems.reduce((total, cartItem) => {
67
- if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin)) return total;
69
+ if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin))
70
+ return total;
68
71
  cartItem._bundleOrigin.forEach((cartBundleItem) => {
69
72
  if (cartBundleItem.bundle_product_id === bundleProductId) {
70
73
  total += (cartBundleItem.num || 1) * (cartItem.num || 1);
@@ -43,7 +43,8 @@ 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) return 0;
46
+ if (matchingTimes.length === 0)
47
+ return 0;
47
48
  const overlaps = [];
48
49
  for (const time of matchingTimes) {
49
50
  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);
@@ -52,7 +53,8 @@ function calculateResourceAvailableTime({
52
53
  overlaps.push({ start: overlapStart, end: overlapEnd });
53
54
  }
54
55
  }
55
- if (overlaps.length === 0) return 0;
56
+ if (overlaps.length === 0)
57
+ return 0;
56
58
  overlaps.sort((a, b) => a.start.diff(b.start));
57
59
  const merged = [];
58
60
  let current = overlaps[0];
@@ -81,7 +83,7 @@ function findFastestAvailableResource({
81
83
  const currentTime = (0, import_dayjs.default)();
82
84
  let fastestTime = null;
83
85
  let fastestResources = [];
84
- console.log("[TimeslotUtils] \u67E5\u627E\u6700\u5FEB\u53EF\u7528\u8D44\u6E90:", {
86
+ console.log("[TimeslotUtils] 查找最快可用资源:", {
85
87
  currentTime: currentTime.format("YYYY-MM-DD HH:mm:ss"),
86
88
  resourceCount: resources.length,
87
89
  currentCapacity,
@@ -94,14 +96,14 @@ function findFastestAvailableResource({
94
96
  return isToday && isStillWorking;
95
97
  });
96
98
  if (todayTimes.length === 0) {
97
- console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id}(${resource.main_field}) \u4ECA\u65E5\u65E0\u53EF\u7528\u65F6\u95F4\u6BB5`);
99
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
98
100
  continue;
99
101
  }
100
102
  for (const time of todayTimes) {
101
103
  const workStartTime = (0, import_dayjs.default)(time.start_at);
102
104
  const workEndTime = (0, import_dayjs.default)(time.end_at);
103
105
  let nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
104
- console.log(`[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ${resource.id}(${resource.main_field}):`, {
106
+ console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
105
107
  workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
106
108
  checkStartTime: nextAvailableTime.format("HH:mm:ss"),
107
109
  eventCount: ((_a = time.event_list) == null ? void 0 : _a.length) || 0
@@ -117,7 +119,7 @@ function findFastestAvailableResource({
117
119
  for (const event of relevantEvents) {
118
120
  const eventStart = (0, import_dayjs.default)(event.start_at);
119
121
  const eventEnd = (0, import_dayjs.default)(event.end_at);
120
- console.log(`[TimeslotUtils] \u68C0\u67E5\u4E8B\u4EF6\u51B2\u7A81:`, {
122
+ console.log(`[TimeslotUtils] 检查事件冲突:`, {
121
123
  resourceId: resource.id,
122
124
  eventTime: `${eventStart.format("HH:mm")}-${eventEnd.format("HH:mm")}`,
123
125
  checkTime: finalAvailableTime.format("HH:mm:ss"),
@@ -126,7 +128,7 @@ function findFastestAvailableResource({
126
128
  if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
127
129
  if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
128
130
  finalAvailableTime = eventEnd;
129
- console.log(`[TimeslotUtils] \u53D1\u73B0\u65F6\u95F4\u51B2\u7A81\uFF0C\u8C03\u6574\u5230: ${finalAvailableTime.format("HH:mm:ss")}`);
131
+ console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
130
132
  }
131
133
  } else {
132
134
  const totalCapacity = resource.capacity || 0;
@@ -136,46 +138,47 @@ function findFastestAvailableResource({
136
138
  const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
137
139
  if (totalRequiredCapacity > totalCapacity) {
138
140
  finalAvailableTime = eventEnd;
139
- console.log(`[TimeslotUtils] \u5BB9\u91CF\u4E0D\u8DB3\uFF0C\u8C03\u6574\u5230: ${finalAvailableTime.format("HH:mm:ss")}`);
141
+ console.log(`[TimeslotUtils] 容量不足,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
140
142
  }
141
143
  }
142
144
  }
143
145
  }
144
146
  if (finalAvailableTime.isAfter(workEndTime)) {
145
- console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id} \u53EF\u7528\u65F6\u95F4\u8D85\u51FA\u5DE5\u4F5C\u65F6\u95F4\uFF0C\u8DF3\u8FC7`);
147
+ console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
146
148
  continue;
147
149
  }
148
- console.log(`[TimeslotUtils] \u8D44\u6E90 ${resource.id}(${resource.main_field}) \u6700\u5FEB\u53EF\u7528\u65F6\u95F4: ${finalAvailableTime.format("HH:mm:ss")}`);
150
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 最快可用时间: ${finalAvailableTime.format("HH:mm:ss")}`);
149
151
  if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
150
152
  fastestTime = finalAvailableTime;
151
153
  fastestResources = [resource];
152
- console.log(`[TimeslotUtils] \u66F4\u65B0\u6700\u5FEB\u65F6\u95F4: ${fastestTime.format("HH:mm:ss")}, \u8D44\u6E90: ${resource.main_field}`);
154
+ console.log(`[TimeslotUtils] 更新最快时间: ${fastestTime.format("HH:mm:ss")}, 资源: ${resource.main_field}`);
153
155
  } else if (finalAvailableTime.isSame(fastestTime)) {
154
156
  fastestResources.push(resource);
155
- console.log(`[TimeslotUtils] \u6DFB\u52A0\u76F8\u540C\u65F6\u95F4\u8D44\u6E90: ${resource.main_field}`);
157
+ console.log(`[TimeslotUtils] 添加相同时间资源: ${resource.main_field}`);
156
158
  }
157
159
  break;
158
160
  }
159
161
  }
160
162
  if (!fastestTime || fastestResources.length === 0) {
161
- console.log("[TimeslotUtils] \u672A\u627E\u5230\u53EF\u7528\u8D44\u6E90");
163
+ console.log("[TimeslotUtils] 未找到可用资源");
162
164
  return null;
163
165
  }
164
- console.log(`[TimeslotUtils] \u627E\u5230 ${fastestResources.length} \u4E2A\u6700\u5FEB\u53EF\u7528\u8D44\u6E90\uFF0C\u65F6\u95F4: ${fastestTime.format("HH:mm:ss")}`);
166
+ console.log(`[TimeslotUtils] 找到 ${fastestResources.length} 个最快可用资源,时间: ${fastestTime.format("HH:mm:ss")}`);
165
167
  if (fastestResources.length === 1) {
166
- console.log(`[TimeslotUtils] \u8FD4\u56DE\u552F\u4E00\u6700\u5FEB\u8D44\u6E90: ${fastestResources[0].main_field}`);
168
+ console.log(`[TimeslotUtils] 返回唯一最快资源: ${fastestResources[0].main_field}`);
167
169
  return fastestResources[0];
168
170
  }
169
171
  let selectedResource = fastestResources[0];
170
172
  let maxIdleTime = 0;
171
- console.log(`[TimeslotUtils] \u6BD4\u8F83 ${fastestResources.length} \u4E2A\u8D44\u6E90\u7684\u7A7A\u95F2\u65F6\u95F4:`);
173
+ console.log(`[TimeslotUtils] 比较 ${fastestResources.length} 个资源的空闲时间:`);
172
174
  for (const resource of fastestResources) {
173
175
  const workingTime = resource.times.find((time) => {
174
176
  const isToday = (0, import_dayjs.default)(time.start_at).isSame(fastestTime, "day");
175
177
  const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(fastestTime);
176
178
  return isToday && isStillWorking;
177
179
  });
178
- if (!workingTime) continue;
180
+ if (!workingTime)
181
+ continue;
179
182
  const workEndTime = (0, import_dayjs.default)(workingTime.end_at);
180
183
  let totalIdleTime = workEndTime.diff(fastestTime, "minute");
181
184
  const relevantEvents = ((_c = workingTime.event_list) == null ? void 0 : _c.filter((event) => {
@@ -189,19 +192,19 @@ function findFastestAvailableResource({
189
192
  const eventDuration = eventEnd.diff(eventStart, "minute");
190
193
  totalIdleTime -= eventDuration;
191
194
  }
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"
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 + "分钟"
197
200
  });
198
201
  if (totalIdleTime > maxIdleTime) {
199
202
  maxIdleTime = totalIdleTime;
200
203
  selectedResource = resource;
201
- console.log(`[TimeslotUtils] \u66F4\u65B0\u6700\u4F73\u9009\u62E9: ${resource.main_field} (\u7A7A\u95F2${totalIdleTime}\u5206\u949F)`);
204
+ console.log(`[TimeslotUtils] 更新最佳选择: ${resource.main_field} (空闲${totalIdleTime}分钟)`);
202
205
  }
203
206
  }
204
- console.log(`[TimeslotUtils] \u6700\u7EC8\u9009\u62E9\u8D44\u6E90: ${selectedResource.main_field} (\u6700\u957F\u7A7A\u95F2${maxIdleTime}\u5206\u949F)`);
207
+ console.log(`[TimeslotUtils] 最终选择资源: ${selectedResource.main_field} (最长空闲${maxIdleTime}分钟)`);
205
208
  return selectedResource;
206
209
  }
207
210
  function filterConditionTimeSlots(times, startTime, endTime) {
@@ -41,32 +41,27 @@ 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
- 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;
44
+ constructor() {
45
+ super(...arguments);
46
+ this.defaultName = "bookingTicket";
47
+ this.defaultVersion = "1.0.0";
48
+ this.isSolution = true;
49
+ this.otherParams = {};
50
+ }
56
51
  async initialize(core, options) {
57
52
  var _a, _b, _c;
58
53
  this.core = core;
59
54
  this.store = options.store || {};
60
55
  this.otherParams = options.otherParams || {};
61
- console.log("[BookingTicket] \u521D\u59CB\u5316\u5B8C\u6210");
56
+ console.log("[BookingTicket] 初始化完成");
62
57
  this.request = core.getPlugin("request");
63
58
  this.window = core.getPlugin("window");
64
59
  this.shopStore = core.getPlugin("shopStore");
65
60
  if (!this.request) {
66
- throw new Error("bookingTicket\u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
61
+ throw new Error("bookingTicket解决方案需要 request 插件支持");
67
62
  }
68
63
  if (!this.shopStore) {
69
- throw new Error("bookingTicket\u89E3\u51B3\u65B9\u6848\u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
64
+ throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
70
65
  }
71
66
  let targetCacheData = {};
72
67
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
@@ -101,7 +96,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
101
96
  }
102
97
  });
103
98
  } else {
104
- throw new Error(`\u6A21\u5757 ${step} \u4E0D\u5B58\u5728`);
99
+ throw new Error(`模块 ${step} 不存在`);
105
100
  }
106
101
  });
107
102
  this.core.effects.emit(`${this.name}:onInited`, {});
@@ -313,7 +308,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
313
308
  try {
314
309
  callback(d);
315
310
  } catch (error) {
316
- console.error("scanGlobalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38", error);
311
+ console.error("scanGlobalListener传入的回调函数异常", error);
317
312
  }
318
313
  };
319
314
  const listener = { key: "global", callback: safeCallback };
@@ -330,7 +325,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
330
325
  try {
331
326
  callback(d);
332
327
  } catch (error) {
333
- console.error("scanCustomerListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38", error);
328
+ console.error("scanCustomerListener传入的回调函数异常", error);
334
329
  }
335
330
  };
336
331
  const listener = { key: "customer", callback: safeCallback };
@@ -349,7 +344,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
349
344
  callback(d);
350
345
  } catch (error) {
351
346
  console.error(
352
- `scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ${key}`,
347
+ `scanUniversalListener传入的回调函数异常, key: ${key}`,
353
348
  error
354
349
  );
355
350
  }
@@ -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("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
60
+ throw new Error("没有找到对应的识别码");
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("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
75
+ throw new Error("没有找到对应的识别码");
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("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8BC6\u522B\u7801");
107
+ throw new Error("没有找到对应的识别码");
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("\u672C\u5730\u641C\u7D22\u5230\u6570\u636E>>>>>>>", localResult);
69
+ console.log("本地搜索到数据>>>>>>>", localResult);
70
70
  return {
71
71
  searchType: "local_product",
72
72
  response: { data: { list: localResult } }
73
73
  };
74
74
  } else {
75
- console.log("\u672C\u5730\u641C\u7D22\u65E0\u6570\u636E>>>>>>>");
75
+ console.log("本地搜索无数据>>>>>>>");
76
76
  }
77
77
  } catch (error) {
78
- console.error("\u672C\u5730\u641C\u7D22\u5230\u6570\u636E\u5931\u8D25>>>>>>>", error);
78
+ console.error("本地搜索到数据失败>>>>>>>", 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("\u7F13\u5B58\u4E2D\u641C\u7D22\u5230\u6570\u636E>>>>>>>", result);
84
+ console.log("缓存中搜索到数据>>>>>>>", result);
85
85
  return result;
86
86
  } else {
87
- console.log("\u7F13\u5B58\u4E2D\u65E0\u6570\u636E>>>>>>>");
87
+ console.log("缓存中无数据>>>>>>>");
88
88
  }
89
89
  } catch (error) {
90
- console.error("\u7F13\u5B58\u4E2D\u641C\u7D22\u6570\u636E\u5931\u8D25>>>>>>>", error);
90
+ console.error("缓存中搜索数据失败>>>>>>>", error);
91
91
  }
92
92
  const requestList = (getRequestList == null ? void 0 : getRequestList(value)) || [];
93
93
  if (requestList.length === 0) {
@@ -35,10 +35,8 @@ 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();
41
38
  constructor(solution, watchKey) {
39
+ this.listenerConfig = /* @__PURE__ */ new Map();
42
40
  this.solution = solution;
43
41
  this.watchKey = watchKey;
44
42
  this.initPeripheralsListener();
@@ -29,7 +29,7 @@ var compressData = (data) => {
29
29
  }
30
30
  return JSON.stringify(data);
31
31
  } catch (error) {
32
- console.warn("\u6570\u636E\u538B\u7F29\u5931\u8D25:", error);
32
+ console.warn("数据压缩失败:", error);
33
33
  return JSON.stringify(data);
34
34
  }
35
35
  };
@@ -40,19 +40,17 @@ var decompressData = (compressedData) => {
40
40
  }
41
41
  return JSON.parse(compressedData);
42
42
  } catch (error) {
43
- console.warn("\u6570\u636E\u89E3\u538B\u7F29\u5931\u8D25:", error);
43
+ console.warn("数据解压缩失败:", 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;
55
48
  constructor(maxSize = 100) {
49
+ this.head = null;
50
+ // 最久未使用的节点
51
+ this.tail = null;
52
+ // 最近使用的节点
53
+ this.keyMap = /* @__PURE__ */ new Map();
56
54
  this.maxSize = maxSize;
57
55
  }
58
56
  /**
@@ -60,7 +58,8 @@ var LRUCache = class {
60
58
  * @param node 要移动的节点
61
59
  */
62
60
  moveToTail(node) {
63
- if (this.tail === node) return;
61
+ if (this.tail === node)
62
+ return;
64
63
  if (node.prev) {
65
64
  node.prev.next = node.next;
66
65
  }
@@ -27,26 +27,23 @@ var import_modules = require("../../modules/");
27
27
  var import_BaseModule = require("../../modules/BaseModule");
28
28
  __reExport(BuyTickets_exports, require("./types"), module.exports);
29
29
  var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
30
- // 提供给 baseModule 用的默认名称 和 默认版本
31
- defaultName = "buyTickets";
32
- defaultVersion = "1.0.0";
33
- isSolution = true;
34
- request;
35
- window;
36
- store;
37
- otherParams = {};
38
30
  constructor(name, version) {
39
31
  super(name, version);
32
+ // 提供给 baseModule 用的默认名称 和 默认版本
33
+ this.defaultName = "buyTickets";
34
+ this.defaultVersion = "1.0.0";
35
+ this.isSolution = true;
36
+ this.otherParams = {};
40
37
  }
41
38
  async initialize(core, options) {
42
39
  this.core = core;
43
40
  this.store = options.store || {};
44
41
  this.otherParams = options.otherParams || {};
45
- console.log("[BuyTickets] \u521D\u59CB\u5316\u5B8C\u6210");
42
+ console.log("[BuyTickets] 初始化完成");
46
43
  this.request = core.getPlugin("request");
47
44
  this.window = core.getPlugin("window");
48
45
  if (!this.request) {
49
- throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
46
+ throw new Error("购物车模块需要 request 插件支持");
50
47
  }
51
48
  if (this.otherParams.prodctIds) {
52
49
  await this.loadProductsByIds(this.otherParams.prodctIds);
@@ -78,7 +75,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
78
75
  }
79
76
  async destroy() {
80
77
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
81
- console.log("[BuyTickets] \u5DF2\u9500\u6BC1");
78
+ console.log("[BuyTickets] 已销毁");
82
79
  }
83
80
  // 获取当前绑定的所有商品
84
81
  async getProducts() {
@@ -96,8 +93,10 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
96
93
  var _a, _b;
97
94
  const mainProduct = await ((_a = this.store.mainProducts) == null ? void 0 : _a.getProduct(id));
98
95
  const otherProduct = await ((_b = this.store.otherProducts) == null ? void 0 : _b.getProduct(id));
99
- if (mainProduct) return mainProduct;
100
- if (otherProduct) return otherProduct;
96
+ if (mainProduct)
97
+ return mainProduct;
98
+ if (otherProduct)
99
+ return otherProduct;
101
100
  throw new Error(`Product not found: ${id}`);
102
101
  }
103
102
  // 商品列表页提交
@@ -106,12 +105,13 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
106
105
  ...data,
107
106
  products: this.getProducts()
108
107
  });
109
- if (res.status === false) return res;
108
+ if (res.status === false)
109
+ return res;
110
110
  this.window.localStorage.setItem(
111
111
  "buyTickets:listSubmit",
112
112
  JSON.stringify({ ...data, products: this.getProducts() })
113
113
  );
114
- console.log("listSubmit \u5E94\u8BE5\u8D70\u903B\u8F91\u5C42\u7684 API \u53D1\u8BF7\u6C42\u4E86");
114
+ console.log("listSubmit 应该走逻辑层的 API 发请求了");
115
115
  }
116
116
  // 购物车提交
117
117
  async cartSubmit(data) {