@pisell/pisellos 1.0.146 → 1.0.148

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