@pisell/pisellos 2.2.93 → 2.2.95

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 (53) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/plugins/app-types/app/app.d.ts +1 -0
  3. package/dist/server/index.d.ts +55 -0
  4. package/dist/server/index.js +826 -207
  5. package/dist/server/modules/index.d.ts +6 -0
  6. package/dist/server/modules/index.js +7 -0
  7. package/dist/server/modules/order/index.d.ts +87 -0
  8. package/dist/server/modules/order/index.js +916 -0
  9. package/dist/server/modules/order/types.d.ts +530 -0
  10. package/dist/server/modules/order/types.js +141 -0
  11. package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
  12. package/dist/server/modules/order/utils/filterBookings.js +350 -0
  13. package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
  14. package/dist/server/modules/order/utils/filterOrders.js +226 -0
  15. package/dist/server/modules/resource/index.d.ts +88 -0
  16. package/dist/server/modules/resource/index.js +1202 -0
  17. package/dist/server/modules/resource/types.d.ts +121 -0
  18. package/dist/server/modules/resource/types.js +47 -0
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/BookingTicket/index.d.ts +1 -1
  21. package/dist/solution/Sales/index.d.ts +96 -0
  22. package/dist/solution/Sales/index.js +562 -0
  23. package/dist/solution/Sales/types.d.ts +66 -0
  24. package/dist/solution/Sales/types.js +26 -0
  25. package/dist/solution/index.d.ts +1 -0
  26. package/dist/solution/index.js +2 -1
  27. package/lib/modules/Order/index.d.ts +1 -1
  28. package/lib/plugins/app-types/app/app.d.ts +1 -0
  29. package/lib/server/index.d.ts +55 -0
  30. package/lib/server/index.js +343 -1
  31. package/lib/server/modules/index.d.ts +6 -0
  32. package/lib/server/modules/index.js +16 -2
  33. package/lib/server/modules/order/index.d.ts +87 -0
  34. package/lib/server/modules/order/index.js +543 -0
  35. package/lib/server/modules/order/types.d.ts +530 -0
  36. package/lib/server/modules/order/types.js +34 -0
  37. package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
  38. package/lib/server/modules/order/utils/filterBookings.js +320 -0
  39. package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
  40. package/lib/server/modules/order/utils/filterOrders.js +197 -0
  41. package/lib/server/modules/resource/index.d.ts +88 -0
  42. package/lib/server/modules/resource/index.js +571 -0
  43. package/lib/server/modules/resource/types.d.ts +121 -0
  44. package/lib/server/modules/resource/types.js +35 -0
  45. package/lib/solution/BookingByStep/index.d.ts +1 -1
  46. package/lib/solution/BookingTicket/index.d.ts +1 -1
  47. package/lib/solution/Sales/index.d.ts +96 -0
  48. package/lib/solution/Sales/index.js +413 -0
  49. package/lib/solution/Sales/types.d.ts +66 -0
  50. package/lib/solution/Sales/types.js +35 -0
  51. package/lib/solution/index.d.ts +1 -0
  52. package/lib/solution/index.js +3 -1
  53. package/package.json +1 -1
@@ -17,17 +17,27 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
17
17
  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; }
18
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
19
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ import dayjs from 'dayjs';
20
21
  import { ProductsModule } from "./modules/products";
21
22
  import { MenuModule } from "./modules/menu";
22
23
  import { QuotationModule } from "./modules/quotation";
23
24
  import { ScheduleModuleEx } from "./modules/schedule";
25
+ import { ResourceModule } from "./modules/resource";
24
26
  import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
25
27
  import { ProductsHooks } from "./modules/products/types";
26
28
  import { perfMark } from "./utils/product";
29
+ import { OrderModule } from "./modules/order";
30
+ import { OrderHooks } from "./modules/order/types";
31
+ import { filterOrders } from "./modules/order/utils/filterOrders";
32
+ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/filterBookings";
27
33
 
28
34
  // 重新导出类型供外部使用
29
35
 
30
36
  /** 商品查询订阅者 */
37
+
38
+ /** 订单列表查询订阅者 */
39
+
40
+ /** 预约列表查询订阅者 */
31
41
  /**
32
42
  * Server 类
33
43
  * 用于注册和管理服务端模块
@@ -47,6 +57,8 @@ var Server = /*#__PURE__*/function () {
47
57
  _defineProperty(this, "menu", void 0);
48
58
  _defineProperty(this, "quotation", void 0);
49
59
  _defineProperty(this, "schedule", void 0);
60
+ _defineProperty(this, "resource", void 0);
61
+ _defineProperty(this, "order", void 0);
50
62
  // 路由注册表
51
63
  _defineProperty(this, "router", {
52
64
  get: {},
@@ -56,6 +68,9 @@ var Server = /*#__PURE__*/function () {
56
68
  });
57
69
  // ---- 商品查询订阅者 ----
58
70
  _defineProperty(this, "productQuerySubscribers", new Map());
71
+ // ---- 订单 / 预约列表查询订阅者 ----
72
+ _defineProperty(this, "orderQuerySubscribers", new Map());
73
+ _defineProperty(this, "bookingQuerySubscribers", new Map());
59
74
  // 模块注册表 - 定义所有可用的模块配置
60
75
  _defineProperty(this, "moduleRegistry", {
61
76
  products: {
@@ -96,6 +111,26 @@ var Server = /*#__PURE__*/function () {
96
111
  availabilityDateList: [],
97
112
  otherProductsIds: []
98
113
  }
114
+ },
115
+ order: {
116
+ name: 'order',
117
+ moduleClass: OrderModule,
118
+ moduleName: 'server_order',
119
+ version: '1.0.0',
120
+ defaultStore: {
121
+ list: []
122
+ }
123
+ },
124
+ resource: {
125
+ name: 'resource',
126
+ moduleClass: ResourceModule,
127
+ moduleName: 'server_resource',
128
+ version: '1.0.0',
129
+ defaultStore: {
130
+ list: [],
131
+ map: new Map(),
132
+ bookings: []
133
+ }
99
134
  }
100
135
  });
101
136
  /**
@@ -175,18 +210,211 @@ var Server = /*#__PURE__*/function () {
175
210
  return _ref5.apply(this, arguments);
176
211
  };
177
212
  }());
213
+ /**
214
+ * 处理订单列表查询
215
+ * 存储订阅者信息,本地计算结果;数据变更时通过 callback 推送
216
+ */
217
+ _defineProperty(this, "handleOrderList", /*#__PURE__*/function () {
218
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref7) {
219
+ var url, method, data, config, queryPayload, _ref9, callback, subscriberId;
220
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
221
+ while (1) switch (_context3.prev = _context3.next) {
222
+ case 0:
223
+ url = _ref7.url, method = _ref7.method, data = _ref7.data, config = _ref7.config;
224
+ console.log('[Server] handleOrderList:', url, method, data, config);
225
+ queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
226
+ _ref9 = config || {}, callback = _ref9.callback, subscriberId = _ref9.subscriberId;
227
+ _this.logInfo('handleOrderList: 开始处理订单列表请求', {
228
+ data: queryPayload
229
+ });
230
+ if (subscriberId && typeof callback === 'function') {
231
+ _this.orderQuerySubscribers.set(subscriberId, {
232
+ callback: callback,
233
+ context: queryPayload
234
+ });
235
+ _this.logInfo('handleOrderList: 已注册订阅者', {
236
+ subscriberId: subscriberId,
237
+ totalSubscribers: _this.orderQuerySubscribers.size
238
+ });
239
+ }
240
+ return _context3.abrupt("return", _this.computeOrderQueryResult(queryPayload));
241
+ case 7:
242
+ case "end":
243
+ return _context3.stop();
244
+ }
245
+ }, _callee3);
246
+ }));
247
+ return function (_x3) {
248
+ return _ref8.apply(this, arguments);
249
+ };
250
+ }());
251
+ /**
252
+ * 取消订单列表查询订阅(HTTP 路由入口)
253
+ */
254
+ _defineProperty(this, "handleUnsubscribeOrderQuery", /*#__PURE__*/function () {
255
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref10) {
256
+ var data, _ref12, subscriberId;
257
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
258
+ while (1) switch (_context4.prev = _context4.next) {
259
+ case 0:
260
+ data = _ref10.data;
261
+ _ref12 = data || {}, subscriberId = _ref12.subscriberId;
262
+ if (subscriberId) {
263
+ _this.orderQuerySubscribers.delete(subscriberId);
264
+ _this.logInfo('handleUnsubscribeOrderQuery: 已移除订阅者', {
265
+ subscriberId: subscriberId,
266
+ remaining: _this.orderQuerySubscribers.size
267
+ });
268
+ }
269
+ return _context4.abrupt("return", {
270
+ code: 200,
271
+ message: 'ok',
272
+ status: true
273
+ });
274
+ case 4:
275
+ case "end":
276
+ return _context4.stop();
277
+ }
278
+ }, _callee4);
279
+ }));
280
+ return function (_x4) {
281
+ return _ref11.apply(this, arguments);
282
+ };
283
+ }());
284
+ /**
285
+ * 处理预约列表查询
286
+ * 今天:注册订阅者 + 本地数据筛选;非今天:清理订阅者 + 走真实 API
287
+ */
288
+ _defineProperty(this, "handleBookingList", /*#__PURE__*/function () {
289
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref13) {
290
+ var url, method, data, config, queryPayload, _ref15, callback, subscriberId, isToday;
291
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
292
+ while (1) switch (_context5.prev = _context5.next) {
293
+ case 0:
294
+ url = _ref13.url, method = _ref13.method, data = _ref13.data, config = _ref13.config;
295
+ console.log('[Server] handleBookingList:', url, method, data, config);
296
+ queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
297
+ _ref15 = config || {}, callback = _ref15.callback, subscriberId = _ref15.subscriberId;
298
+ isToday = _this.isBookingQueryForToday(queryPayload);
299
+ _this.logInfo('handleBookingList: 开始处理预约列表请求', {
300
+ data: queryPayload,
301
+ isToday: isToday
302
+ });
303
+ if (!isToday) {
304
+ _context5.next = 11;
305
+ break;
306
+ }
307
+ if (subscriberId && typeof callback === 'function') {
308
+ _this.bookingQuerySubscribers.set(subscriberId, {
309
+ callback: callback,
310
+ context: queryPayload
311
+ });
312
+ _this.logInfo('handleBookingList: 已注册订阅者(今天)', {
313
+ subscriberId: subscriberId,
314
+ totalSubscribers: _this.bookingQuerySubscribers.size
315
+ });
316
+ }
317
+ return _context5.abrupt("return", _this.computeBookingQueryResult(queryPayload));
318
+ case 11:
319
+ if (subscriberId) {
320
+ _this.bookingQuerySubscribers.delete(subscriberId);
321
+ _this.logInfo('handleBookingList: 已清理订阅者(非今天)', {
322
+ subscriberId: subscriberId,
323
+ remaining: _this.bookingQuerySubscribers.size
324
+ });
325
+ }
326
+ return _context5.abrupt("return", _this.fetchBookingListFromAPI(queryPayload));
327
+ case 13:
328
+ case "end":
329
+ return _context5.stop();
330
+ }
331
+ }, _callee5);
332
+ }));
333
+ return function (_x5) {
334
+ return _ref14.apply(this, arguments);
335
+ };
336
+ }());
337
+ /**
338
+ * 处理资源列表查询
339
+ * 转发到资源模块去
340
+ */
341
+ _defineProperty(this, "handleResourceList", /*#__PURE__*/function () {
342
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref16) {
343
+ var _this$resource;
344
+ var url, method, data, config, list;
345
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
346
+ while (1) switch (_context6.prev = _context6.next) {
347
+ case 0:
348
+ url = _ref16.url, method = _ref16.method, data = _ref16.data, config = _ref16.config;
349
+ console.log('[Server] handleResourceList:', url, method, data, config);
350
+ list = (_this$resource = _this.resource) === null || _this$resource === void 0 ? void 0 : _this$resource.getResources({
351
+ skip: (data === null || data === void 0 ? void 0 : data.skip) || 1,
352
+ num: (data === null || data === void 0 ? void 0 : data.num) || 10
353
+ });
354
+ return _context6.abrupt("return", {
355
+ code: 200,
356
+ data: {
357
+ list: list,
358
+ count: (list === null || list === void 0 ? void 0 : list.length) || 0
359
+ },
360
+ message: '',
361
+ status: true
362
+ });
363
+ case 4:
364
+ case "end":
365
+ return _context6.stop();
366
+ }
367
+ }, _callee6);
368
+ }));
369
+ return function (_x6) {
370
+ return _ref17.apply(this, arguments);
371
+ };
372
+ }());
373
+ /**
374
+ * 取消预约列表查询订阅(HTTP 路由入口)
375
+ */
376
+ _defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
377
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref18) {
378
+ var data, _ref20, subscriberId;
379
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
380
+ while (1) switch (_context7.prev = _context7.next) {
381
+ case 0:
382
+ data = _ref18.data;
383
+ _ref20 = data || {}, subscriberId = _ref20.subscriberId;
384
+ if (subscriberId) {
385
+ _this.bookingQuerySubscribers.delete(subscriberId);
386
+ _this.logInfo('handleUnsubscribeBookingQuery: 已移除订阅者', {
387
+ subscriberId: subscriberId,
388
+ remaining: _this.bookingQuerySubscribers.size
389
+ });
390
+ }
391
+ return _context7.abrupt("return", {
392
+ code: 200,
393
+ message: 'ok',
394
+ status: true
395
+ });
396
+ case 4:
397
+ case "end":
398
+ return _context7.stop();
399
+ }
400
+ }, _callee7);
401
+ }));
402
+ return function (_x7) {
403
+ return _ref19.apply(this, arguments);
404
+ };
405
+ }());
178
406
  /**
179
407
  * 处理获取日程时间段点的请求
180
408
  * 通过餐牌ID列表获取所有相关日程的时间段点
181
409
  */
182
410
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
183
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref7) {
411
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref21) {
184
412
  var _menu_list_ids$length;
185
413
  var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
186
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
187
- while (1) switch (_context3.prev = _context3.next) {
414
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
415
+ while (1) switch (_context8.prev = _context8.next) {
188
416
  case 0:
189
- url = _ref7.url, method = _ref7.method, data = _ref7.data, config = _ref7.config;
417
+ url = _ref21.url, method = _ref21.method, data = _ref21.data, config = _ref21.config;
190
418
  console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
191
419
  menu_list_ids = data.menu_list_ids;
192
420
  _this.logInfo('handleGetScheduleTimePoints 开始处理', {
@@ -196,12 +424,12 @@ var Server = /*#__PURE__*/function () {
196
424
 
197
425
  // 检查必要的模块是否已注册
198
426
  if (_this.menu) {
199
- _context3.next = 8;
427
+ _context8.next = 8;
200
428
  break;
201
429
  }
202
430
  console.error('[Server] Menu 模块未注册');
203
431
  _this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
204
- return _context3.abrupt("return", {
432
+ return _context8.abrupt("return", {
205
433
  code: 500,
206
434
  message: 'Menu 模块未注册',
207
435
  data: [],
@@ -209,12 +437,12 @@ var Server = /*#__PURE__*/function () {
209
437
  });
210
438
  case 8:
211
439
  if (_this.schedule) {
212
- _context3.next = 12;
440
+ _context8.next = 12;
213
441
  break;
214
442
  }
215
443
  console.error('[Server] Schedule 模块未注册');
216
444
  _this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
217
- return _context3.abrupt("return", {
445
+ return _context8.abrupt("return", {
218
446
  code: 500,
219
447
  message: 'Schedule 模块未注册',
220
448
  data: [],
@@ -222,7 +450,7 @@ var Server = /*#__PURE__*/function () {
222
450
  });
223
451
  case 12:
224
452
  if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
225
- _context3.next = 16;
453
+ _context8.next = 16;
226
454
  break;
227
455
  }
228
456
  console.error('[Server] menu_list_ids 参数无效');
@@ -230,14 +458,14 @@ var Server = /*#__PURE__*/function () {
230
458
  menuListIdsCount: (_menu_list_ids$length2 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length2 !== void 0 ? _menu_list_ids$length2 : 0,
231
459
  menu_list_ids: menu_list_ids
232
460
  });
233
- return _context3.abrupt("return", {
461
+ return _context8.abrupt("return", {
234
462
  code: 400,
235
463
  message: 'menu_list_ids 参数无效',
236
464
  data: [],
237
465
  status: false
238
466
  });
239
467
  case 16:
240
- _context3.prev = 16;
468
+ _context8.prev = 16;
241
469
  // 1. 获取餐牌列表
242
470
  menuList = _this.menu.getMenuByIds(menu_list_ids);
243
471
  console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
@@ -255,13 +483,13 @@ var Server = /*#__PURE__*/function () {
255
483
  scheduleCount: scheduleIds.length
256
484
  });
257
485
  if (!(scheduleIds.length === 0)) {
258
- _context3.next = 26;
486
+ _context8.next = 26;
259
487
  break;
260
488
  }
261
489
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
262
490
  menuListIdsCount: menu_list_ids.length
263
491
  });
264
- return _context3.abrupt("return", {
492
+ return _context8.abrupt("return", {
265
493
  code: 200,
266
494
  message: '没有找到相关日程',
267
495
  data: [],
@@ -285,22 +513,22 @@ var Server = /*#__PURE__*/function () {
285
513
  scheduleCount: scheduleList.length,
286
514
  timePointCount: timePoints.length
287
515
  });
288
- return _context3.abrupt("return", {
516
+ return _context8.abrupt("return", {
289
517
  code: 200,
290
518
  message: '获取成功',
291
519
  data: timePoints,
292
520
  status: true
293
521
  });
294
522
  case 35:
295
- _context3.prev = 35;
296
- _context3.t0 = _context3["catch"](16);
297
- errorMessage = _context3.t0 instanceof Error ? _context3.t0.message : '未知错误';
298
- console.error('[Server] 获取日程时间点失败:', _context3.t0);
523
+ _context8.prev = 35;
524
+ _context8.t0 = _context8["catch"](16);
525
+ errorMessage = _context8.t0 instanceof Error ? _context8.t0.message : '未知错误';
526
+ console.error('[Server] 获取日程时间点失败:', _context8.t0);
299
527
  _this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
300
528
  menuListIdsCount: menu_list_ids.length,
301
529
  error: errorMessage
302
530
  });
303
- return _context3.abrupt("return", {
531
+ return _context8.abrupt("return", {
304
532
  code: 500,
305
533
  message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
306
534
  data: [],
@@ -308,12 +536,12 @@ var Server = /*#__PURE__*/function () {
308
536
  });
309
537
  case 41:
310
538
  case "end":
311
- return _context3.stop();
539
+ return _context8.stop();
312
540
  }
313
- }, _callee3, null, [[16, 35]]);
541
+ }, _callee8, null, [[16, 35]]);
314
542
  }));
315
- return function (_x3) {
316
- return _ref8.apply(this, arguments);
543
+ return function (_x8) {
544
+ return _ref22.apply(this, arguments);
317
545
  };
318
546
  }());
319
547
  this.core = core;
@@ -374,10 +602,10 @@ var Server = /*#__PURE__*/function () {
374
602
  }, {
375
603
  key: "registerModuleWithRoutes",
376
604
  value: (function () {
377
- var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(module, options, moduleName) {
605
+ var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(module, options, moduleName) {
378
606
  var routes;
379
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
380
- while (1) switch (_context4.prev = _context4.next) {
607
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
608
+ while (1) switch (_context9.prev = _context9.next) {
381
609
  case 0:
382
610
  this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
383
611
  moduleName: moduleName,
@@ -385,7 +613,7 @@ var Server = /*#__PURE__*/function () {
385
613
  });
386
614
 
387
615
  // 注册模块到 Core
388
- _context4.next = 3;
616
+ _context9.next = 3;
389
617
  return this.core.registerModule(module, options);
390
618
  case 3:
391
619
  console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
@@ -406,11 +634,11 @@ var Server = /*#__PURE__*/function () {
406
634
  }
407
635
  case 6:
408
636
  case "end":
409
- return _context4.stop();
637
+ return _context9.stop();
410
638
  }
411
- }, _callee4, this);
639
+ }, _callee9, this);
412
640
  }));
413
- function registerModuleWithRoutes(_x4, _x5, _x6) {
641
+ function registerModuleWithRoutes(_x9, _x10, _x11) {
414
642
  return _registerModuleWithRoutes.apply(this, arguments);
415
643
  }
416
644
  return registerModuleWithRoutes;
@@ -423,10 +651,10 @@ var Server = /*#__PURE__*/function () {
423
651
  }, {
424
652
  key: "registerModuleByName",
425
653
  value: (function () {
426
- var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(moduleConfig) {
654
+ var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(moduleConfig) {
427
655
  var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
428
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
429
- while (1) switch (_context5.prev = _context5.next) {
656
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
657
+ while (1) switch (_context10.prev = _context10.next) {
430
658
  case 0:
431
659
  // 解析配置
432
660
  moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
@@ -441,7 +669,7 @@ var Server = /*#__PURE__*/function () {
441
669
  // 查找模块配置
442
670
  registryConfig = this.moduleRegistry[moduleName];
443
671
  if (registryConfig) {
444
- _context5.next = 8;
672
+ _context10.next = 8;
445
673
  break;
446
674
  }
447
675
  this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
@@ -455,7 +683,7 @@ var Server = /*#__PURE__*/function () {
455
683
  moduleOptions = _objectSpread({
456
684
  store: _objectSpread({}, registryConfig.defaultStore)
457
685
  }, customConfig); // 注册模块和路由
458
- _context5.next = 13;
686
+ _context10.next = 13;
459
687
  return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
460
688
  case 13:
461
689
  // 保存模块实例
@@ -465,18 +693,18 @@ var Server = /*#__PURE__*/function () {
465
693
  shouldPreload: shouldPreload,
466
694
  version: registryConfig.version
467
695
  });
468
- return _context5.abrupt("return", {
696
+ return _context10.abrupt("return", {
469
697
  module: moduleInstance,
470
698
  config: registryConfig,
471
699
  shouldPreload: shouldPreload
472
700
  });
473
701
  case 16:
474
702
  case "end":
475
- return _context5.stop();
703
+ return _context10.stop();
476
704
  }
477
- }, _callee5, this);
705
+ }, _callee10, this);
478
706
  }));
479
- function registerModuleByName(_x7) {
707
+ function registerModuleByName(_x12) {
480
708
  return _registerModuleByName.apply(this, arguments);
481
709
  }
482
710
  return registerModuleByName;
@@ -489,10 +717,10 @@ var Server = /*#__PURE__*/function () {
489
717
  }, {
490
718
  key: "registerModules",
491
719
  value: (function () {
492
- var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(moduleConfigs) {
720
+ var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(moduleConfigs) {
493
721
  var configs, registeredModules, _iterator, _step, config, configName, result, errorMessage;
494
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
495
- while (1) switch (_context6.prev = _context6.next) {
722
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
723
+ while (1) switch (_context11.prev = _context11.next) {
496
724
  case 0:
497
725
  console.log('[Server] 开始注册模块...');
498
726
 
@@ -504,47 +732,47 @@ var Server = /*#__PURE__*/function () {
504
732
  });
505
733
  registeredModules = [];
506
734
  _iterator = _createForOfIteratorHelper(configs);
507
- _context6.prev = 5;
735
+ _context11.prev = 5;
508
736
  _iterator.s();
509
737
  case 7:
510
738
  if ((_step = _iterator.n()).done) {
511
- _context6.next = 25;
739
+ _context11.next = 25;
512
740
  break;
513
741
  }
514
742
  config = _step.value;
515
743
  configName = typeof config === 'string' ? config : config.name;
516
- _context6.prev = 10;
517
- _context6.next = 13;
744
+ _context11.prev = 10;
745
+ _context11.next = 13;
518
746
  return this.registerModuleByName(config);
519
747
  case 13:
520
- result = _context6.sent;
748
+ result = _context11.sent;
521
749
  registeredModules.push(result);
522
- _context6.next = 23;
750
+ _context11.next = 23;
523
751
  break;
524
752
  case 17:
525
- _context6.prev = 17;
526
- _context6.t0 = _context6["catch"](10);
527
- errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
753
+ _context11.prev = 17;
754
+ _context11.t0 = _context11["catch"](10);
755
+ errorMessage = _context11.t0 instanceof Error ? _context11.t0.message : String(_context11.t0);
528
756
  this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
529
757
  moduleName: configName,
530
758
  error: errorMessage
531
759
  });
532
- console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context6.t0);
533
- throw _context6.t0;
760
+ console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context11.t0);
761
+ throw _context11.t0;
534
762
  case 23:
535
- _context6.next = 7;
763
+ _context11.next = 7;
536
764
  break;
537
765
  case 25:
538
- _context6.next = 30;
766
+ _context11.next = 30;
539
767
  break;
540
768
  case 27:
541
- _context6.prev = 27;
542
- _context6.t1 = _context6["catch"](5);
543
- _iterator.e(_context6.t1);
769
+ _context11.prev = 27;
770
+ _context11.t1 = _context11["catch"](5);
771
+ _iterator.e(_context11.t1);
544
772
  case 30:
545
- _context6.prev = 30;
773
+ _context11.prev = 30;
546
774
  _iterator.f();
547
- return _context6.finish(30);
775
+ return _context11.finish(30);
548
776
  case 33:
549
777
  console.log('[Server] ✅ 所有模块注册完成');
550
778
  this.logInfo('所有模块注册完成', {
@@ -554,14 +782,14 @@ var Server = /*#__PURE__*/function () {
554
782
  return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
555
783
  })
556
784
  });
557
- return _context6.abrupt("return", registeredModules);
785
+ return _context11.abrupt("return", registeredModules);
558
786
  case 36:
559
787
  case "end":
560
- return _context6.stop();
788
+ return _context11.stop();
561
789
  }
562
- }, _callee6, this, [[5, 27, 30, 33], [10, 17]]);
790
+ }, _callee11, this, [[5, 27, 30, 33], [10, 17]]);
563
791
  }));
564
- function registerModules(_x8) {
792
+ function registerModules(_x13) {
565
793
  return _registerModules.apply(this, arguments);
566
794
  }
567
795
  return registerModules;
@@ -574,10 +802,10 @@ var Server = /*#__PURE__*/function () {
574
802
  }, {
575
803
  key: "preloadModulesData",
576
804
  value: (function () {
577
- var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(registeredModules, options) {
805
+ var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(registeredModules, options) {
578
806
  var modulesToPreload, preloadResults, _iterator2, _step2, _step2$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
579
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
580
- while (1) switch (_context7.prev = _context7.next) {
807
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
808
+ while (1) switch (_context12.prev = _context12.next) {
581
809
  case 0:
582
810
  console.log('[Server] 开始预加载模块数据...');
583
811
  modulesToPreload = registeredModules.filter(function (m) {
@@ -590,16 +818,16 @@ var Server = /*#__PURE__*/function () {
590
818
  });
591
819
  preloadResults = [];
592
820
  _iterator2 = _createForOfIteratorHelper(registeredModules);
593
- _context7.prev = 5;
821
+ _context12.prev = 5;
594
822
  _iterator2.s();
595
823
  case 7:
596
824
  if ((_step2 = _iterator2.n()).done) {
597
- _context7.next = 40;
825
+ _context12.next = 40;
598
826
  break;
599
827
  }
600
828
  _step2$value = _step2.value, module = _step2$value.module, config = _step2$value.config, shouldPreload = _step2$value.shouldPreload;
601
829
  if (shouldPreload) {
602
- _context7.next = 13;
830
+ _context12.next = 13;
603
831
  break;
604
832
  }
605
833
  console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
@@ -607,19 +835,19 @@ var Server = /*#__PURE__*/function () {
607
835
  moduleName: config.name,
608
836
  reason: 'shouldPreload=false'
609
837
  });
610
- return _context7.abrupt("continue", 38);
838
+ return _context12.abrupt("continue", 38);
611
839
  case 13:
612
840
  if (!(typeof module.preload === 'function')) {
613
- _context7.next = 36;
841
+ _context12.next = 36;
614
842
  break;
615
843
  }
616
844
  startTime = Date.now();
617
- _context7.prev = 15;
845
+ _context12.prev = 15;
618
846
  this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
619
847
  moduleName: config.name
620
848
  });
621
849
  options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
622
- _context7.next = 20;
850
+ _context12.next = 20;
623
851
  return module.preload();
624
852
  case 20:
625
853
  options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
@@ -633,14 +861,14 @@ var Server = /*#__PURE__*/function () {
633
861
  name: config.name,
634
862
  success: true
635
863
  });
636
- _context7.next = 34;
864
+ _context12.next = 34;
637
865
  break;
638
866
  case 27:
639
- _context7.prev = 27;
640
- _context7.t0 = _context7["catch"](15);
867
+ _context12.prev = 27;
868
+ _context12.t0 = _context12["catch"](15);
641
869
  _duration = Date.now() - startTime;
642
- errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
643
- console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context7.t0);
870
+ errorMessage = _context12.t0 instanceof Error ? _context12.t0.message : String(_context12.t0);
871
+ console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context12.t0);
644
872
  this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
645
873
  moduleName: config.name,
646
874
  duration: "".concat(_duration, "ms"),
@@ -652,7 +880,7 @@ var Server = /*#__PURE__*/function () {
652
880
  error: errorMessage
653
881
  });
654
882
  case 34:
655
- _context7.next = 38;
883
+ _context12.next = 38;
656
884
  break;
657
885
  case 36:
658
886
  console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
@@ -660,19 +888,19 @@ var Server = /*#__PURE__*/function () {
660
888
  moduleName: config.name
661
889
  });
662
890
  case 38:
663
- _context7.next = 7;
891
+ _context12.next = 7;
664
892
  break;
665
893
  case 40:
666
- _context7.next = 45;
894
+ _context12.next = 45;
667
895
  break;
668
896
  case 42:
669
- _context7.prev = 42;
670
- _context7.t1 = _context7["catch"](5);
671
- _iterator2.e(_context7.t1);
897
+ _context12.prev = 42;
898
+ _context12.t1 = _context12["catch"](5);
899
+ _iterator2.e(_context12.t1);
672
900
  case 45:
673
- _context7.prev = 45;
901
+ _context12.prev = 45;
674
902
  _iterator2.f();
675
- return _context7.finish(45);
903
+ return _context12.finish(45);
676
904
  case 48:
677
905
  successCount = preloadResults.filter(function (r) {
678
906
  return r.success;
@@ -687,11 +915,11 @@ var Server = /*#__PURE__*/function () {
687
915
  });
688
916
  case 52:
689
917
  case "end":
690
- return _context7.stop();
918
+ return _context12.stop();
691
919
  }
692
- }, _callee7, this, [[5, 42, 45, 48], [15, 27]]);
920
+ }, _callee12, this, [[5, 42, 45, 48], [15, 27]]);
693
921
  }));
694
- function preloadModulesData(_x9, _x10) {
922
+ function preloadModulesData(_x14, _x15) {
695
923
  return _preloadModulesData.apply(this, arguments);
696
924
  }
697
925
  return preloadModulesData;
@@ -705,7 +933,7 @@ var Server = /*#__PURE__*/function () {
705
933
  }, {
706
934
  key: "initialize",
707
935
  value: (function () {
708
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(moduleConfigs) {
936
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(moduleConfigs) {
709
937
  var _moduleConfigs$length,
710
938
  _this3 = this;
711
939
  var autoPreload,
@@ -713,12 +941,12 @@ var Server = /*#__PURE__*/function () {
713
941
  startTime,
714
942
  registeredModules,
715
943
  duration,
716
- _args8 = arguments;
717
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
718
- while (1) switch (_context8.prev = _context8.next) {
944
+ _args13 = arguments;
945
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
946
+ while (1) switch (_context13.prev = _context13.next) {
719
947
  case 0:
720
- autoPreload = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : true;
721
- options = _args8.length > 2 ? _args8[2] : undefined;
948
+ autoPreload = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : true;
949
+ options = _args13.length > 2 ? _args13[2] : undefined;
722
950
  startTime = Date.now();
723
951
  this.logInfo('Server 初始化开始', {
724
952
  moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
@@ -730,18 +958,18 @@ var Server = /*#__PURE__*/function () {
730
958
  this.registerServerRoutes();
731
959
 
732
960
  // 注册模块
733
- _context8.next = 7;
961
+ _context13.next = 7;
734
962
  return this.registerModules(moduleConfigs);
735
963
  case 7:
736
- registeredModules = _context8.sent;
964
+ registeredModules = _context13.sent;
737
965
  if (!autoPreload) {
738
- _context8.next = 13;
966
+ _context13.next = 13;
739
967
  break;
740
968
  }
741
- _context8.next = 11;
969
+ _context13.next = 11;
742
970
  return this.preloadModulesData(registeredModules, options);
743
971
  case 11:
744
- _context8.next = 14;
972
+ _context13.next = 14;
745
973
  break;
746
974
  case 13:
747
975
  this.logInfo('跳过自动预加载', {
@@ -754,19 +982,25 @@ var Server = /*#__PURE__*/function () {
754
982
  changedIds: payload === null || payload === void 0 ? void 0 : payload.changedIds
755
983
  });
756
984
  });
985
+
986
+ // 订单 / 预约本地数据变更时,向订阅者推送最新列表
987
+ this.core.effects.on(OrderHooks.onOrdersChanged, function () {
988
+ _this3.recomputeAndNotifyOrderQuery();
989
+ _this3.recomputeAndNotifyBookingQuery();
990
+ });
757
991
  duration = Date.now() - startTime;
758
992
  this.logInfo('Server 初始化完成', {
759
993
  duration: "".concat(duration, "ms"),
760
994
  registeredModuleCount: registeredModules.length
761
995
  });
762
- return _context8.abrupt("return", registeredModules);
763
- case 18:
996
+ return _context13.abrupt("return", registeredModules);
997
+ case 19:
764
998
  case "end":
765
- return _context8.stop();
999
+ return _context13.stop();
766
1000
  }
767
- }, _callee8, this);
1001
+ }, _callee13, this);
768
1002
  }));
769
- function initialize(_x11) {
1003
+ function initialize(_x16) {
770
1004
  return _initialize.apply(this, arguments);
771
1005
  }
772
1006
  return initialize;
@@ -819,6 +1053,8 @@ var Server = /*#__PURE__*/function () {
819
1053
  if (this.menu) modules.push('menu');
820
1054
  if (this.quotation) modules.push('quotation');
821
1055
  if (this.schedule) modules.push('schedule');
1056
+ if (this.resource) modules.push('resource');
1057
+ if (this.order) modules.push('order');
822
1058
  return modules;
823
1059
  }
824
1060
 
@@ -830,45 +1066,45 @@ var Server = /*#__PURE__*/function () {
830
1066
  }, {
831
1067
  key: "refreshProductsInBackground",
832
1068
  value: (function () {
833
- var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1069
+ var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
834
1070
  var startTime, duration, _duration2, errorMessage;
835
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
836
- while (1) switch (_context9.prev = _context9.next) {
1071
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1072
+ while (1) switch (_context14.prev = _context14.next) {
837
1073
  case 0:
838
1074
  if (this.products) {
839
- _context9.next = 3;
1075
+ _context14.next = 3;
840
1076
  break;
841
1077
  }
842
1078
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
843
- return _context9.abrupt("return");
1079
+ return _context14.abrupt("return");
844
1080
  case 3:
845
1081
  this.logInfo('refreshProductsInBackground 开始');
846
1082
  startTime = Date.now();
847
- _context9.prev = 5;
848
- _context9.next = 8;
1083
+ _context14.prev = 5;
1084
+ _context14.next = 8;
849
1085
  return this.products.silentRefresh();
850
1086
  case 8:
851
1087
  duration = Date.now() - startTime;
852
1088
  this.logInfo('refreshProductsInBackground 完成', {
853
1089
  duration: "".concat(duration, "ms")
854
1090
  });
855
- _context9.next = 18;
1091
+ _context14.next = 18;
856
1092
  break;
857
1093
  case 12:
858
- _context9.prev = 12;
859
- _context9.t0 = _context9["catch"](5);
1094
+ _context14.prev = 12;
1095
+ _context14.t0 = _context14["catch"](5);
860
1096
  _duration2 = Date.now() - startTime;
861
- errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
862
- console.error('[Server] refreshProductsInBackground 失败:', _context9.t0);
1097
+ errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
1098
+ console.error('[Server] refreshProductsInBackground 失败:', _context14.t0);
863
1099
  this.logError('refreshProductsInBackground 失败', {
864
1100
  duration: "".concat(_duration2, "ms"),
865
1101
  error: errorMessage
866
1102
  });
867
1103
  case 18:
868
1104
  case "end":
869
- return _context9.stop();
1105
+ return _context14.stop();
870
1106
  }
871
- }, _callee9, this, [[5, 12]]);
1107
+ }, _callee14, this, [[5, 12]]);
872
1108
  }));
873
1109
  function refreshProductsInBackground() {
874
1110
  return _refreshProductsInBackground.apply(this, arguments);
@@ -883,10 +1119,10 @@ var Server = /*#__PURE__*/function () {
883
1119
  }, {
884
1120
  key: "clearAllIndexDB",
885
1121
  value: (function () {
886
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1122
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
887
1123
  var clearTasks, moduleNames, errorMessage;
888
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
889
- while (1) switch (_context10.prev = _context10.next) {
1124
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1125
+ while (1) switch (_context15.prev = _context15.next) {
890
1126
  case 0:
891
1127
  console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
892
1128
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
@@ -908,42 +1144,50 @@ var Server = /*#__PURE__*/function () {
908
1144
  clearTasks.push(this.schedule.clear());
909
1145
  moduleNames.push('Schedule');
910
1146
  }
1147
+ if (this.resource) {
1148
+ clearTasks.push(this.resource.clear());
1149
+ moduleNames.push('Resource');
1150
+ }
1151
+ if (this.order) {
1152
+ clearTasks.push(this.order.clear());
1153
+ moduleNames.push('Order');
1154
+ }
911
1155
  if (!(clearTasks.length === 0)) {
912
- _context10.next = 12;
1156
+ _context15.next = 14;
913
1157
  break;
914
1158
  }
915
1159
  console.warn('[Server] 没有找到已注册的模块,无需清空');
916
1160
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
917
- return _context10.abrupt("return");
918
- case 12:
1161
+ return _context15.abrupt("return");
1162
+ case 14:
919
1163
  this.logInfo('准备清空模块缓存', {
920
1164
  moduleNames: moduleNames
921
1165
  });
922
- _context10.prev = 13;
923
- _context10.next = 16;
1166
+ _context15.prev = 15;
1167
+ _context15.next = 18;
924
1168
  return Promise.all(clearTasks);
925
- case 16:
1169
+ case 18:
926
1170
  console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
927
1171
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
928
1172
  moduleNames: moduleNames
929
1173
  });
930
- _context10.next = 26;
1174
+ _context15.next = 28;
931
1175
  break;
932
- case 20:
933
- _context10.prev = 20;
934
- _context10.t0 = _context10["catch"](13);
935
- errorMessage = _context10.t0 instanceof Error ? _context10.t0.message : String(_context10.t0);
936
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context10.t0);
1176
+ case 22:
1177
+ _context15.prev = 22;
1178
+ _context15.t0 = _context15["catch"](15);
1179
+ errorMessage = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
1180
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context15.t0);
937
1181
  this.logError('清空 IndexedDB 缓存时发生错误', {
938
1182
  moduleNames: moduleNames,
939
1183
  error: errorMessage
940
1184
  });
941
- throw _context10.t0;
942
- case 26:
1185
+ throw _context15.t0;
1186
+ case 28:
943
1187
  case "end":
944
- return _context10.stop();
1188
+ return _context15.stop();
945
1189
  }
946
- }, _callee10, this, [[13, 20]]);
1190
+ }, _callee15, this, [[15, 22]]);
947
1191
  }));
948
1192
  function clearAllIndexDB() {
949
1193
  return _clearAllIndexDB.apply(this, arguments);
@@ -994,13 +1238,12 @@ var Server = /*#__PURE__*/function () {
994
1238
  }, {
995
1239
  key: "handleRoute",
996
1240
  value: (function () {
997
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(method, path, params) {
1241
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(method, path, params) {
998
1242
  var startTime, handler, result, duration, _duration3, errorMessage;
999
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1000
- while (1) switch (_context11.prev = _context11.next) {
1243
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1244
+ while (1) switch (_context16.prev = _context16.next) {
1001
1245
  case 0:
1002
1246
  startTime = Date.now();
1003
- console.log(method, path, params, 'method, path, params');
1004
1247
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
1005
1248
  method: method.toUpperCase(),
1006
1249
  path: path,
@@ -1009,7 +1252,7 @@ var Server = /*#__PURE__*/function () {
1009
1252
  });
1010
1253
  handler = this.getRouteHandler(method, path);
1011
1254
  if (handler) {
1012
- _context11.next = 7;
1255
+ _context16.next = 6;
1013
1256
  break;
1014
1257
  }
1015
1258
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -1017,12 +1260,12 @@ var Server = /*#__PURE__*/function () {
1017
1260
  path: path
1018
1261
  });
1019
1262
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
1020
- case 7:
1021
- _context11.prev = 7;
1022
- _context11.next = 10;
1263
+ case 6:
1264
+ _context16.prev = 6;
1265
+ _context16.next = 9;
1023
1266
  return handler(params);
1024
- case 10:
1025
- result = _context11.sent;
1267
+ case 9:
1268
+ result = _context16.sent;
1026
1269
  duration = Date.now() - startTime;
1027
1270
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
1028
1271
  method: method.toUpperCase(),
@@ -1031,12 +1274,12 @@ var Server = /*#__PURE__*/function () {
1031
1274
  resultCode: result === null || result === void 0 ? void 0 : result.code,
1032
1275
  resultStatus: result === null || result === void 0 ? void 0 : result.status
1033
1276
  });
1034
- return _context11.abrupt("return", result);
1035
- case 16:
1036
- _context11.prev = 16;
1037
- _context11.t0 = _context11["catch"](7);
1277
+ return _context16.abrupt("return", result);
1278
+ case 15:
1279
+ _context16.prev = 15;
1280
+ _context16.t0 = _context16["catch"](6);
1038
1281
  _duration3 = Date.now() - startTime;
1039
- errorMessage = _context11.t0 instanceof Error ? _context11.t0.message : String(_context11.t0);
1282
+ errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1040
1283
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
1041
1284
  method: method.toUpperCase(),
1042
1285
  path: path,
@@ -1044,15 +1287,15 @@ var Server = /*#__PURE__*/function () {
1044
1287
  error: errorMessage,
1045
1288
  data: params.data
1046
1289
  });
1047
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context11.t0);
1048
- throw _context11.t0;
1049
- case 23:
1290
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context16.t0);
1291
+ throw _context16.t0;
1292
+ case 22:
1050
1293
  case "end":
1051
- return _context11.stop();
1294
+ return _context16.stop();
1052
1295
  }
1053
- }, _callee11, this, [[7, 16]]);
1296
+ }, _callee16, this, [[6, 15]]);
1054
1297
  }));
1055
- function handleRoute(_x12, _x13, _x14) {
1298
+ function handleRoute(_x17, _x18, _x19) {
1056
1299
  return _handleRoute.apply(this, arguments);
1057
1300
  }
1058
1301
  return handleRoute;
@@ -1098,6 +1341,26 @@ var Server = /*#__PURE__*/function () {
1098
1341
  method: 'post',
1099
1342
  path: '/shop/menu/schedule-time-points',
1100
1343
  handler: this.handleGetScheduleTimePoints.bind(this)
1344
+ }, {
1345
+ method: 'post',
1346
+ path: '/shop/order/v2/list',
1347
+ handler: this.handleOrderList.bind(this)
1348
+ }, {
1349
+ method: 'post',
1350
+ path: '/shop/order/v2/list/unsubscribe',
1351
+ handler: this.handleUnsubscribeOrderQuery.bind(this)
1352
+ }, {
1353
+ method: 'get',
1354
+ path: '/shop/schedule/booking',
1355
+ handler: this.handleBookingList.bind(this)
1356
+ }, {
1357
+ method: 'get',
1358
+ path: '/shop/schedule/booking/unsubscribe',
1359
+ handler: this.handleUnsubscribeBookingQuery.bind(this)
1360
+ }, {
1361
+ method: 'get',
1362
+ path: '/shop/form/resource/page',
1363
+ handler: this.handleResourceList.bind(this)
1101
1364
  }]);
1102
1365
  }
1103
1366
 
@@ -1116,8 +1379,213 @@ var Server = /*#__PURE__*/function () {
1116
1379
  }
1117
1380
  }
1118
1381
  }, {
1119
- key: "computeProductQueryResult",
1382
+ key: "isBookingQueryForToday",
1383
+ value:
1384
+ /**
1385
+ * 判断预约查询的 sales_time_between 起始日期是否为今天
1386
+ */
1387
+ function isBookingQueryForToday(data) {
1388
+ var range = data === null || data === void 0 ? void 0 : data.sales_time_between;
1389
+ if (!Array.isArray(range) || range.length < 1) return true;
1390
+ var startDateStr = String(range[0]).split('T')[0].split(' ')[0];
1391
+ var todayStr = dayjs().format('YYYY-MM-DD');
1392
+ return startDateStr === todayStr;
1393
+ }
1394
+
1395
+ /**
1396
+ * 非今天的预约查询:通过真实 API 获取数据,再做 flattenOrdersToBookings 拆分
1397
+ */
1398
+ }, {
1399
+ key: "fetchBookingListFromAPI",
1400
+ value: (function () {
1401
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(data) {
1402
+ var _this$app2;
1403
+ var _ref23, _response$data$list, _response$data, response, rawList, list, errorMessage;
1404
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1405
+ while (1) switch (_context17.prev = _context17.next) {
1406
+ case 0:
1407
+ if ((_this$app2 = this.app) !== null && _this$app2 !== void 0 && _this$app2.request) {
1408
+ _context17.next = 3;
1409
+ break;
1410
+ }
1411
+ this.logError('fetchBookingListFromAPI: app.request 不可用');
1412
+ return _context17.abrupt("return", {
1413
+ code: 500,
1414
+ message: 'app.request 不可用',
1415
+ data: {
1416
+ list: [],
1417
+ count: 0
1418
+ },
1419
+ status: false
1420
+ });
1421
+ case 3:
1422
+ _context17.prev = 3;
1423
+ _context17.next = 6;
1424
+ return this.app.request.get('/shop/order/sales', _objectSpread(_objectSpread({}, data), {}, {
1425
+ form_record_ids: undefined,
1426
+ with: ["all"]
1427
+ }), {
1428
+ isShopApi: true
1429
+ });
1430
+ case 6:
1431
+ response = _context17.sent;
1432
+ rawList = (_ref23 = (_response$data$list = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) !== null && _response$data$list !== void 0 ? _response$data$list : response === null || response === void 0 ? void 0 : response.list) !== null && _ref23 !== void 0 ? _ref23 : [];
1433
+ list = filterBookingsFromOrders(rawList, data);
1434
+ this.logInfo('fetchBookingListFromAPI: API 返回并拆分完成', {
1435
+ rawCount: rawList.length,
1436
+ flattenedCount: list.count
1437
+ });
1438
+ return _context17.abrupt("return", {
1439
+ code: 200,
1440
+ data: _objectSpread(_objectSpread({}, response.data), {}, {
1441
+ list: (list === null || list === void 0 ? void 0 : list.list) || []
1442
+ }),
1443
+ message: '',
1444
+ status: true
1445
+ });
1446
+ case 13:
1447
+ _context17.prev = 13;
1448
+ _context17.t0 = _context17["catch"](3);
1449
+ errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1450
+ this.logError('fetchBookingListFromAPI: 请求失败', {
1451
+ error: errorMessage
1452
+ });
1453
+ return _context17.abrupt("return", {
1454
+ code: 500,
1455
+ message: errorMessage,
1456
+ data: {
1457
+ list: [],
1458
+ count: 0
1459
+ },
1460
+ status: false
1461
+ });
1462
+ case 18:
1463
+ case "end":
1464
+ return _context17.stop();
1465
+ }
1466
+ }, _callee17, this, [[3, 13]]);
1467
+ }));
1468
+ function fetchBookingListFromAPI(_x20) {
1469
+ return _fetchBookingListFromAPI.apply(this, arguments);
1470
+ }
1471
+ return fetchBookingListFromAPI;
1472
+ }())
1473
+ }, {
1474
+ key: "computeOrderQueryResult",
1120
1475
  value: (
1476
+ /**
1477
+ * 订单列表本地计算(编排 Order 模块)
1478
+ * filter 逻辑暂为 mock,仅记录参数
1479
+ */
1480
+ function () {
1481
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(data) {
1482
+ var rawList, result;
1483
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1484
+ while (1) switch (_context18.prev = _context18.next) {
1485
+ case 0:
1486
+ this.logInfo('computeOrderQueryResult: 开始过滤', {
1487
+ data: data
1488
+ });
1489
+ console.log('[Server] computeOrderQueryResult', data);
1490
+ if (this.order) {
1491
+ _context18.next = 5;
1492
+ break;
1493
+ }
1494
+ this.logError('computeOrderQueryResult: Order 模块未注册');
1495
+ return _context18.abrupt("return", {
1496
+ code: 500,
1497
+ message: 'Order 模块未注册',
1498
+ data: {
1499
+ list: [],
1500
+ count: 0
1501
+ },
1502
+ status: false
1503
+ });
1504
+ case 5:
1505
+ rawList = this.order.getOrders();
1506
+ this.logInfo('computeOrderQueryResult: 本地订单数量', {
1507
+ rawCount: rawList.length
1508
+ });
1509
+
1510
+ // 使用 filterOrders 进行过滤、排序、分页
1511
+ result = filterOrders(rawList, data);
1512
+ this.logInfo('computeOrderQueryResult: 过滤结果', {
1513
+ rawCount: rawList.length,
1514
+ filteredCount: result.count,
1515
+ size: result.size,
1516
+ skip: result.skip
1517
+ });
1518
+ return _context18.abrupt("return", {
1519
+ code: 200,
1520
+ data: result,
1521
+ message: '',
1522
+ status: true
1523
+ });
1524
+ case 10:
1525
+ case "end":
1526
+ return _context18.stop();
1527
+ }
1528
+ }, _callee18, this);
1529
+ }));
1530
+ function computeOrderQueryResult(_x21) {
1531
+ return _computeOrderQueryResult.apply(this, arguments);
1532
+ }
1533
+ return computeOrderQueryResult;
1534
+ }()
1535
+ /**
1536
+ * 预约列表本地计算(编排 Order 模块)
1537
+ * 从订单中展开 bookings,再按条件筛选 + 分页
1538
+ */
1539
+ )
1540
+ }, {
1541
+ key: "computeBookingQueryResult",
1542
+ value: (function () {
1543
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data) {
1544
+ var rawOrders, result;
1545
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1546
+ while (1) switch (_context19.prev = _context19.next) {
1547
+ case 0:
1548
+ if (this.order) {
1549
+ _context19.next = 3;
1550
+ break;
1551
+ }
1552
+ this.logError('computeBookingQueryResult: Order 模块未注册');
1553
+ return _context19.abrupt("return", {
1554
+ code: 500,
1555
+ message: 'Order 模块未注册',
1556
+ data: {
1557
+ list: [],
1558
+ count: 0
1559
+ },
1560
+ status: false
1561
+ });
1562
+ case 3:
1563
+ rawOrders = this.order.getOrders();
1564
+ result = filterBookingsFromOrders(rawOrders, data);
1565
+ result = sortBookings(result, data);
1566
+ this.logInfo('computeBookingQueryResult: 过滤结果', {
1567
+ orderCount: rawOrders.length,
1568
+ filteredCount: result.count,
1569
+ size: result.size,
1570
+ skip: result.skip
1571
+ });
1572
+ return _context19.abrupt("return", {
1573
+ code: 200,
1574
+ data: result,
1575
+ message: '',
1576
+ status: true
1577
+ });
1578
+ case 8:
1579
+ case "end":
1580
+ return _context19.stop();
1581
+ }
1582
+ }, _callee19, this);
1583
+ }));
1584
+ function computeBookingQueryResult(_x22) {
1585
+ return _computeBookingQueryResult.apply(this, arguments);
1586
+ }
1587
+ return computeBookingQueryResult;
1588
+ }()
1121
1589
  /**
1122
1590
  * 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
1123
1591
  * 供 handleProductQuery 首次返回及 pubsub 变更推送复用
@@ -1125,13 +1593,16 @@ var Server = /*#__PURE__*/function () {
1125
1593
  * @param options 可选参数
1126
1594
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
1127
1595
  */
1128
- function () {
1129
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(context, options) {
1596
+ )
1597
+ }, {
1598
+ key: "computeProductQueryResult",
1599
+ value: (function () {
1600
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(context, options) {
1130
1601
  var _menu_list_ids$length3,
1131
1602
  _this5 = this;
1132
1603
  var tTotal, menu_list_ids, schedule_date, schedule_datetime, activeMenuList, tMenu, menuList, tPrice, allProductsWithPrice, tFilter, filteredProducts, tStatus, beforeStatusCount, tSort;
1133
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1134
- while (1) switch (_context12.prev = _context12.next) {
1604
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1605
+ while (1) switch (_context20.prev = _context20.next) {
1135
1606
  case 0:
1136
1607
  tTotal = performance.now();
1137
1608
  menu_list_ids = context.menu_list_ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime;
@@ -1142,11 +1613,11 @@ var Server = /*#__PURE__*/function () {
1142
1613
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
1143
1614
  });
1144
1615
  if (this.products) {
1145
- _context12.next = 6;
1616
+ _context20.next = 6;
1146
1617
  break;
1147
1618
  }
1148
1619
  this.logError('computeProductQueryResult: Products 模块未注册');
1149
- return _context12.abrupt("return", {
1620
+ return _context20.abrupt("return", {
1150
1621
  message: 'Products 模块未注册',
1151
1622
  data: {
1152
1623
  list: [],
@@ -1155,11 +1626,11 @@ var Server = /*#__PURE__*/function () {
1155
1626
  });
1156
1627
  case 6:
1157
1628
  if (this.menu) {
1158
- _context12.next = 9;
1629
+ _context20.next = 9;
1159
1630
  break;
1160
1631
  }
1161
1632
  this.logError('computeProductQueryResult: Menu 模块未注册');
1162
- return _context12.abrupt("return", {
1633
+ return _context20.abrupt("return", {
1163
1634
  message: 'Menu 模块未注册',
1164
1635
  data: {
1165
1636
  list: [],
@@ -1168,11 +1639,11 @@ var Server = /*#__PURE__*/function () {
1168
1639
  });
1169
1640
  case 9:
1170
1641
  if (this.schedule) {
1171
- _context12.next = 12;
1642
+ _context20.next = 12;
1172
1643
  break;
1173
1644
  }
1174
1645
  this.logError('computeProductQueryResult: Schedule 模块未注册');
1175
- return _context12.abrupt("return", {
1646
+ return _context20.abrupt("return", {
1176
1647
  message: 'Schedule 模块未注册',
1177
1648
  data: {
1178
1649
  list: [],
@@ -1194,14 +1665,14 @@ var Server = /*#__PURE__*/function () {
1194
1665
  });
1195
1666
  }
1196
1667
  tPrice = performance.now();
1197
- _context12.next = 17;
1668
+ _context20.next = 17;
1198
1669
  return this.products.getProductsWithPrice(schedule_date, {
1199
1670
  scheduleModule: this.getSchedule()
1200
1671
  }, {
1201
1672
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
1202
1673
  });
1203
1674
  case 17:
1204
- allProductsWithPrice = _context12.sent;
1675
+ allProductsWithPrice = _context20.sent;
1205
1676
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
1206
1677
  count: allProductsWithPrice.length
1207
1678
  });
@@ -1239,7 +1710,7 @@ var Server = /*#__PURE__*/function () {
1239
1710
  filteredCount: filteredProducts.length,
1240
1711
  activeMenuCount: activeMenuList.length
1241
1712
  });
1242
- return _context12.abrupt("return", {
1713
+ return _context20.abrupt("return", {
1243
1714
  code: 200,
1244
1715
  data: {
1245
1716
  list: filteredProducts,
@@ -1250,11 +1721,11 @@ var Server = /*#__PURE__*/function () {
1250
1721
  });
1251
1722
  case 32:
1252
1723
  case "end":
1253
- return _context12.stop();
1724
+ return _context20.stop();
1254
1725
  }
1255
- }, _callee12, this);
1726
+ }, _callee20, this);
1256
1727
  }));
1257
- function computeProductQueryResult(_x15, _x16) {
1728
+ function computeProductQueryResult(_x23, _x24) {
1258
1729
  return _computeProductQueryResult.apply(this, arguments);
1259
1730
  }
1260
1731
  return computeProductQueryResult;
@@ -1269,76 +1740,224 @@ var Server = /*#__PURE__*/function () {
1269
1740
  }, {
1270
1741
  key: "recomputeAndNotifyProductQuery",
1271
1742
  value: (function () {
1272
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
1743
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(options) {
1273
1744
  var _iterator3, _step3, _step3$value, subscriberId, subscriber, result, errorMessage;
1274
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1275
- while (1) switch (_context13.prev = _context13.next) {
1745
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1746
+ while (1) switch (_context21.prev = _context21.next) {
1276
1747
  case 0:
1277
1748
  if (!(this.productQuerySubscribers.size === 0)) {
1278
- _context13.next = 2;
1749
+ _context21.next = 2;
1279
1750
  break;
1280
1751
  }
1281
- return _context13.abrupt("return");
1752
+ return _context21.abrupt("return");
1282
1753
  case 2:
1283
1754
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
1284
1755
  subscriberCount: this.productQuerySubscribers.size,
1285
1756
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
1286
1757
  });
1287
1758
  _iterator3 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
1288
- _context13.prev = 4;
1759
+ _context21.prev = 4;
1289
1760
  _iterator3.s();
1290
1761
  case 6:
1291
1762
  if ((_step3 = _iterator3.n()).done) {
1292
- _context13.next = 22;
1763
+ _context21.next = 22;
1293
1764
  break;
1294
1765
  }
1295
1766
  _step3$value = _slicedToArray(_step3.value, 2), subscriberId = _step3$value[0], subscriber = _step3$value[1];
1296
- _context13.prev = 8;
1297
- _context13.next = 11;
1767
+ _context21.prev = 8;
1768
+ _context21.next = 11;
1298
1769
  return this.computeProductQueryResult(subscriber.context, {
1299
1770
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
1300
1771
  });
1301
1772
  case 11:
1302
- result = _context13.sent;
1773
+ result = _context21.sent;
1303
1774
  subscriber.callback(result);
1304
1775
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
1305
1776
  subscriberId: subscriberId
1306
1777
  });
1307
- _context13.next = 20;
1778
+ _context21.next = 20;
1308
1779
  break;
1309
1780
  case 16:
1310
- _context13.prev = 16;
1311
- _context13.t0 = _context13["catch"](8);
1312
- errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
1781
+ _context21.prev = 16;
1782
+ _context21.t0 = _context21["catch"](8);
1783
+ errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1313
1784
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
1314
1785
  subscriberId: subscriberId,
1315
1786
  error: errorMessage
1316
1787
  });
1317
1788
  case 20:
1318
- _context13.next = 6;
1789
+ _context21.next = 6;
1319
1790
  break;
1320
1791
  case 22:
1321
- _context13.next = 27;
1792
+ _context21.next = 27;
1322
1793
  break;
1323
1794
  case 24:
1324
- _context13.prev = 24;
1325
- _context13.t1 = _context13["catch"](4);
1326
- _iterator3.e(_context13.t1);
1795
+ _context21.prev = 24;
1796
+ _context21.t1 = _context21["catch"](4);
1797
+ _iterator3.e(_context21.t1);
1327
1798
  case 27:
1328
- _context13.prev = 27;
1799
+ _context21.prev = 27;
1329
1800
  _iterator3.f();
1330
- return _context13.finish(27);
1801
+ return _context21.finish(27);
1331
1802
  case 30:
1332
1803
  case "end":
1333
- return _context13.stop();
1804
+ return _context21.stop();
1334
1805
  }
1335
- }, _callee13, this, [[4, 24, 27, 30], [8, 16]]);
1806
+ }, _callee21, this, [[4, 24, 27, 30], [8, 16]]);
1336
1807
  }));
1337
- function recomputeAndNotifyProductQuery(_x17) {
1808
+ function recomputeAndNotifyProductQuery(_x25) {
1338
1809
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
1339
1810
  }
1340
1811
  return recomputeAndNotifyProductQuery;
1341
1812
  }()
1813
+ /**
1814
+ * 订单数据变更后,遍历订阅者重新计算并通过 callback 推送
1815
+ */
1816
+ )
1817
+ }, {
1818
+ key: "recomputeAndNotifyOrderQuery",
1819
+ value: (function () {
1820
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1821
+ var _iterator4, _step4, _step4$value, subscriberId, subscriber, result, errorMessage;
1822
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1823
+ while (1) switch (_context22.prev = _context22.next) {
1824
+ case 0:
1825
+ if (!(this.orderQuerySubscribers.size === 0)) {
1826
+ _context22.next = 2;
1827
+ break;
1828
+ }
1829
+ return _context22.abrupt("return");
1830
+ case 2:
1831
+ this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
1832
+ subscriberCount: this.orderQuerySubscribers.size
1833
+ });
1834
+ _iterator4 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
1835
+ _context22.prev = 4;
1836
+ _iterator4.s();
1837
+ case 6:
1838
+ if ((_step4 = _iterator4.n()).done) {
1839
+ _context22.next = 22;
1840
+ break;
1841
+ }
1842
+ _step4$value = _slicedToArray(_step4.value, 2), subscriberId = _step4$value[0], subscriber = _step4$value[1];
1843
+ _context22.prev = 8;
1844
+ _context22.next = 11;
1845
+ return this.computeOrderQueryResult(subscriber.context);
1846
+ case 11:
1847
+ result = _context22.sent;
1848
+ subscriber.callback(result);
1849
+ this.logInfo('recomputeAndNotifyOrderQuery: 已推送', {
1850
+ subscriberId: subscriberId
1851
+ });
1852
+ _context22.next = 20;
1853
+ break;
1854
+ case 16:
1855
+ _context22.prev = 16;
1856
+ _context22.t0 = _context22["catch"](8);
1857
+ errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1858
+ this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
1859
+ subscriberId: subscriberId,
1860
+ error: errorMessage
1861
+ });
1862
+ case 20:
1863
+ _context22.next = 6;
1864
+ break;
1865
+ case 22:
1866
+ _context22.next = 27;
1867
+ break;
1868
+ case 24:
1869
+ _context22.prev = 24;
1870
+ _context22.t1 = _context22["catch"](4);
1871
+ _iterator4.e(_context22.t1);
1872
+ case 27:
1873
+ _context22.prev = 27;
1874
+ _iterator4.f();
1875
+ return _context22.finish(27);
1876
+ case 30:
1877
+ case "end":
1878
+ return _context22.stop();
1879
+ }
1880
+ }, _callee22, this, [[4, 24, 27, 30], [8, 16]]);
1881
+ }));
1882
+ function recomputeAndNotifyOrderQuery() {
1883
+ return _recomputeAndNotifyOrderQuery.apply(this, arguments);
1884
+ }
1885
+ return recomputeAndNotifyOrderQuery;
1886
+ }()
1887
+ /**
1888
+ * 预约数据变更后,遍历订阅者重新计算并通过 callback 推送
1889
+ */
1890
+ )
1891
+ }, {
1892
+ key: "recomputeAndNotifyBookingQuery",
1893
+ value: (function () {
1894
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1895
+ var _iterator5, _step5, _step5$value, subscriberId, subscriber, result, errorMessage;
1896
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1897
+ while (1) switch (_context23.prev = _context23.next) {
1898
+ case 0:
1899
+ if (!(this.bookingQuerySubscribers.size === 0)) {
1900
+ _context23.next = 2;
1901
+ break;
1902
+ }
1903
+ return _context23.abrupt("return");
1904
+ case 2:
1905
+ this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
1906
+ subscriberCount: this.bookingQuerySubscribers.size
1907
+ });
1908
+ _iterator5 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
1909
+ _context23.prev = 4;
1910
+ _iterator5.s();
1911
+ case 6:
1912
+ if ((_step5 = _iterator5.n()).done) {
1913
+ _context23.next = 22;
1914
+ break;
1915
+ }
1916
+ _step5$value = _slicedToArray(_step5.value, 2), subscriberId = _step5$value[0], subscriber = _step5$value[1];
1917
+ _context23.prev = 8;
1918
+ _context23.next = 11;
1919
+ return this.computeBookingQueryResult(subscriber.context);
1920
+ case 11:
1921
+ result = _context23.sent;
1922
+ subscriber.callback(result);
1923
+ this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
1924
+ subscriberId: subscriberId
1925
+ });
1926
+ _context23.next = 20;
1927
+ break;
1928
+ case 16:
1929
+ _context23.prev = 16;
1930
+ _context23.t0 = _context23["catch"](8);
1931
+ errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
1932
+ this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
1933
+ subscriberId: subscriberId,
1934
+ error: errorMessage
1935
+ });
1936
+ case 20:
1937
+ _context23.next = 6;
1938
+ break;
1939
+ case 22:
1940
+ _context23.next = 27;
1941
+ break;
1942
+ case 24:
1943
+ _context23.prev = 24;
1944
+ _context23.t1 = _context23["catch"](4);
1945
+ _iterator5.e(_context23.t1);
1946
+ case 27:
1947
+ _context23.prev = 27;
1948
+ _iterator5.f();
1949
+ return _context23.finish(27);
1950
+ case 30:
1951
+ case "end":
1952
+ return _context23.stop();
1953
+ }
1954
+ }, _callee23, this, [[4, 24, 27, 30], [8, 16]]);
1955
+ }));
1956
+ function recomputeAndNotifyBookingQuery() {
1957
+ return _recomputeAndNotifyBookingQuery.apply(this, arguments);
1958
+ }
1959
+ return recomputeAndNotifyBookingQuery;
1960
+ }()
1342
1961
  /**
1343
1962
  * 根据餐牌配置过滤商品
1344
1963
  * @param products 所有商品列表
@@ -1364,11 +1983,11 @@ var Server = /*#__PURE__*/function () {
1364
1983
  var allowedProductIds = new Set();
1365
1984
  var allowedCollectionIds = new Set();
1366
1985
  var hasProductAll = false;
1367
- var _iterator4 = _createForOfIteratorHelper(activeMenuList),
1368
- _step4;
1986
+ var _iterator6 = _createForOfIteratorHelper(activeMenuList),
1987
+ _step6;
1369
1988
  try {
1370
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1371
- var menu = _step4.value;
1989
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1990
+ var menu = _step6.value;
1372
1991
  var config = menu.partyroom_package;
1373
1992
  if (!config) {
1374
1993
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -1428,9 +2047,9 @@ var Server = /*#__PURE__*/function () {
1428
2047
 
1429
2048
  // 如果有餐牌允许所有商品,返回所有商品
1430
2049
  } catch (err) {
1431
- _iterator4.e(err);
2050
+ _iterator6.e(err);
1432
2051
  } finally {
1433
- _iterator4.f();
2052
+ _iterator6.f();
1434
2053
  }
1435
2054
  if (hasProductAll) {
1436
2055
  this.logInfo('filterProductsByMenuConfig: 返回所有商品(product_all)', {