@pisell/pisellos 2.2.125 → 2.2.127
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.
- package/dist/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +551 -362
- package/dist/server/modules/order/index.d.ts +7 -0
- package/dist/server/modules/order/index.js +221 -151
- package/dist/server/modules/order/utils/filterBookings.js +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/core/index.js +1 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +116 -0
- package/lib/server/modules/order/index.d.ts +7 -0
- package/lib/server/modules/order/index.js +34 -0
- package/lib/server/modules/order/utils/filterBookings.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -55,7 +55,7 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
|
|
|
55
55
|
var Server = /*#__PURE__*/function () {
|
|
56
56
|
function Server(core) {
|
|
57
57
|
var _this = this,
|
|
58
|
-
_this$
|
|
58
|
+
_this$app2;
|
|
59
59
|
_classCallCheck(this, Server);
|
|
60
60
|
_defineProperty(this, "core", void 0);
|
|
61
61
|
_defineProperty(this, "app", void 0);
|
|
@@ -443,19 +443,161 @@ var Server = /*#__PURE__*/function () {
|
|
|
443
443
|
};
|
|
444
444
|
}());
|
|
445
445
|
/**
|
|
446
|
-
*
|
|
446
|
+
* 代理刷新单个本地订单:
|
|
447
|
+
* - 入参:order_id(data 或 url query)
|
|
448
|
+
* - 流程:本地存在性校验 → 调后端 /order/sales/{id}?with[]=... → 覆盖本地 → 落 SQLite → emit onOrdersChanged
|
|
449
|
+
* - 监听级联:onOrdersChanged 触发订单/预约/bookingRemoteCache 三路订阅者推送
|
|
447
450
|
*/
|
|
448
|
-
_defineProperty(this, "
|
|
451
|
+
_defineProperty(this, "handleUpdateLocalOrder", /*#__PURE__*/function () {
|
|
449
452
|
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref18) {
|
|
450
|
-
var
|
|
453
|
+
var _ref20, _this$app;
|
|
454
|
+
var url, data, rawOrderId, orderId, backendPath, _response$data, response, fresh, _yield$_this$order$ov, overwritten, errorMessage;
|
|
451
455
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
452
456
|
while (1) switch (_context7.prev = _context7.next) {
|
|
453
457
|
case 0:
|
|
454
|
-
url = _ref18.url, data = _ref18.data
|
|
458
|
+
url = _ref18.url, data = _ref18.data;
|
|
459
|
+
rawOrderId = (_ref20 = data && _typeof(data) === 'object' ? data.order_id : undefined) !== null && _ref20 !== void 0 ? _ref20 : _this.extractQueryParam(url, 'order_id');
|
|
460
|
+
orderId = rawOrderId === undefined || rawOrderId === null || rawOrderId === '' ? null : String(rawOrderId).trim();
|
|
461
|
+
_this.logInfo('handleUpdateLocalOrder: 开始处理', {
|
|
462
|
+
url: url,
|
|
463
|
+
orderId: orderId
|
|
464
|
+
});
|
|
465
|
+
if (orderId) {
|
|
466
|
+
_context7.next = 7;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
_this.logWarning('handleUpdateLocalOrder: order_id 缺失', {
|
|
470
|
+
url: url,
|
|
471
|
+
data: data
|
|
472
|
+
});
|
|
473
|
+
return _context7.abrupt("return", {
|
|
474
|
+
code: 400,
|
|
475
|
+
status: false,
|
|
476
|
+
message: 'order_id 缺失',
|
|
477
|
+
data: null
|
|
478
|
+
});
|
|
479
|
+
case 7:
|
|
480
|
+
if (_this.order) {
|
|
481
|
+
_context7.next = 10;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
_this.logError('handleUpdateLocalOrder: Order 模块未注册');
|
|
485
|
+
return _context7.abrupt("return", {
|
|
486
|
+
code: 500,
|
|
487
|
+
status: false,
|
|
488
|
+
message: 'Order 模块未注册',
|
|
489
|
+
data: null
|
|
490
|
+
});
|
|
491
|
+
case 10:
|
|
492
|
+
if (_this.order.getOrderByOrderId(orderId)) {
|
|
493
|
+
_context7.next = 13;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
_this.logInfo('handleUpdateLocalOrder: 本地不存在该订单,忽略', {
|
|
497
|
+
orderId: orderId
|
|
498
|
+
});
|
|
499
|
+
return _context7.abrupt("return", {
|
|
500
|
+
code: 200,
|
|
501
|
+
status: true,
|
|
502
|
+
message: '本地无此订单,已忽略',
|
|
503
|
+
data: {
|
|
504
|
+
overwritten: false
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
case 13:
|
|
508
|
+
if ((_this$app = _this.app) !== null && _this$app !== void 0 && _this$app.request) {
|
|
509
|
+
_context7.next = 16;
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
_this.logError('handleUpdateLocalOrder: app.request 不可用');
|
|
513
|
+
return _context7.abrupt("return", {
|
|
514
|
+
code: 500,
|
|
515
|
+
status: false,
|
|
516
|
+
message: 'app.request 不可用',
|
|
517
|
+
data: null
|
|
518
|
+
});
|
|
519
|
+
case 16:
|
|
520
|
+
backendPath = "/shop/order/sales/".concat(encodeURIComponent(orderId), "?with%5B%5D=all");
|
|
521
|
+
_context7.prev = 17;
|
|
522
|
+
_context7.next = 20;
|
|
523
|
+
return _this.app.request.get(backendPath, undefined, {
|
|
524
|
+
isShopApi: true
|
|
525
|
+
});
|
|
526
|
+
case 20:
|
|
527
|
+
response = _context7.sent;
|
|
528
|
+
fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
|
|
529
|
+
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
530
|
+
_context7.next = 25;
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
_this.logError('handleUpdateLocalOrder: 后端返回订单为空', {
|
|
534
|
+
orderId: orderId,
|
|
535
|
+
backendPath: backendPath
|
|
536
|
+
});
|
|
537
|
+
return _context7.abrupt("return", {
|
|
538
|
+
code: 500,
|
|
539
|
+
status: false,
|
|
540
|
+
message: '后端返回订单为空',
|
|
541
|
+
data: null
|
|
542
|
+
});
|
|
543
|
+
case 25:
|
|
544
|
+
_context7.next = 27;
|
|
545
|
+
return _this.order.overwriteExistingOrder(fresh);
|
|
546
|
+
case 27:
|
|
547
|
+
_yield$_this$order$ov = _context7.sent;
|
|
548
|
+
overwritten = _yield$_this$order$ov.overwritten;
|
|
549
|
+
_this.logInfo('handleUpdateLocalOrder: 覆盖完成', {
|
|
550
|
+
orderId: orderId,
|
|
551
|
+
overwritten: overwritten
|
|
552
|
+
});
|
|
553
|
+
return _context7.abrupt("return", {
|
|
554
|
+
code: 200,
|
|
555
|
+
status: true,
|
|
556
|
+
message: '',
|
|
557
|
+
data: {
|
|
558
|
+
overwritten: overwritten,
|
|
559
|
+
order_id: orderId
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
case 33:
|
|
563
|
+
_context7.prev = 33;
|
|
564
|
+
_context7.t0 = _context7["catch"](17);
|
|
565
|
+
errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
|
|
566
|
+
_this.logError('handleUpdateLocalOrder: 请求失败', {
|
|
567
|
+
orderId: orderId,
|
|
568
|
+
backendPath: backendPath,
|
|
569
|
+
error: errorMessage
|
|
570
|
+
});
|
|
571
|
+
return _context7.abrupt("return", {
|
|
572
|
+
code: 500,
|
|
573
|
+
status: false,
|
|
574
|
+
message: errorMessage,
|
|
575
|
+
data: null
|
|
576
|
+
});
|
|
577
|
+
case 38:
|
|
578
|
+
case "end":
|
|
579
|
+
return _context7.stop();
|
|
580
|
+
}
|
|
581
|
+
}, _callee7, null, [[17, 33]]);
|
|
582
|
+
}));
|
|
583
|
+
return function (_x7) {
|
|
584
|
+
return _ref19.apply(this, arguments);
|
|
585
|
+
};
|
|
586
|
+
}());
|
|
587
|
+
/**
|
|
588
|
+
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
589
|
+
*/
|
|
590
|
+
_defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
|
|
591
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref21) {
|
|
592
|
+
var url, data, config, routePath, base, path, _subscriberId, _ref23, callback, subscriberId, ctx;
|
|
593
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
594
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
595
|
+
case 0:
|
|
596
|
+
url = _ref21.url, data = _ref21.data, config = _ref21.config, routePath = _ref21.path;
|
|
455
597
|
base = '/shop/schedule/floor-plan';
|
|
456
598
|
path = _this.parseRequestPath(url, routePath);
|
|
457
599
|
if (!(path === "".concat(base, "/unsubscribe"))) {
|
|
458
|
-
|
|
600
|
+
_context8.next = 7;
|
|
459
601
|
break;
|
|
460
602
|
}
|
|
461
603
|
_subscriberId = data === null || data === void 0 ? void 0 : data.subscriberId;
|
|
@@ -466,19 +608,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
466
608
|
remaining: _this.floorPlanQuerySubscribers.size
|
|
467
609
|
});
|
|
468
610
|
}
|
|
469
|
-
return
|
|
611
|
+
return _context8.abrupt("return", {
|
|
470
612
|
code: 200,
|
|
471
613
|
message: 'ok',
|
|
472
614
|
status: true
|
|
473
615
|
});
|
|
474
616
|
case 7:
|
|
475
|
-
|
|
617
|
+
_ref23 = config || {}, callback = _ref23.callback, subscriberId = _ref23.subscriberId;
|
|
476
618
|
ctx = _this.resolveFloorPlanQueryContext(path, base);
|
|
477
619
|
if (ctx) {
|
|
478
|
-
|
|
620
|
+
_context8.next = 11;
|
|
479
621
|
break;
|
|
480
622
|
}
|
|
481
|
-
return
|
|
623
|
+
return _context8.abrupt("return", {
|
|
482
624
|
status: false,
|
|
483
625
|
code: 404,
|
|
484
626
|
message: 'Not Found',
|
|
@@ -496,28 +638,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
496
638
|
total: _this.floorPlanQuerySubscribers.size
|
|
497
639
|
});
|
|
498
640
|
}
|
|
499
|
-
return
|
|
641
|
+
return _context8.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
|
|
500
642
|
case 13:
|
|
501
643
|
case "end":
|
|
502
|
-
return
|
|
644
|
+
return _context8.stop();
|
|
503
645
|
}
|
|
504
|
-
},
|
|
646
|
+
}, _callee8);
|
|
505
647
|
}));
|
|
506
|
-
return function (
|
|
507
|
-
return
|
|
648
|
+
return function (_x8) {
|
|
649
|
+
return _ref22.apply(this, arguments);
|
|
508
650
|
};
|
|
509
651
|
}());
|
|
510
652
|
/**
|
|
511
653
|
* 取消预约列表查询订阅(HTTP 路由入口)
|
|
512
654
|
*/
|
|
513
655
|
_defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
|
|
514
|
-
var
|
|
515
|
-
var data,
|
|
516
|
-
return _regeneratorRuntime().wrap(function
|
|
517
|
-
while (1) switch (
|
|
656
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref24) {
|
|
657
|
+
var data, _ref26, subscriberId;
|
|
658
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
659
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
518
660
|
case 0:
|
|
519
|
-
data =
|
|
520
|
-
|
|
661
|
+
data = _ref24.data;
|
|
662
|
+
_ref26 = data || {}, subscriberId = _ref26.subscriberId;
|
|
521
663
|
if (subscriberId) {
|
|
522
664
|
_this.bookingQuerySubscribers.delete(subscriberId);
|
|
523
665
|
_this.bookingRemoteQuerySubscribers.delete(subscriberId);
|
|
@@ -527,19 +669,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
527
669
|
remainingRemote: _this.bookingRemoteQuerySubscribers.size
|
|
528
670
|
});
|
|
529
671
|
}
|
|
530
|
-
return
|
|
672
|
+
return _context9.abrupt("return", {
|
|
531
673
|
code: 200,
|
|
532
674
|
message: 'ok',
|
|
533
675
|
status: true
|
|
534
676
|
});
|
|
535
677
|
case 4:
|
|
536
678
|
case "end":
|
|
537
|
-
return
|
|
679
|
+
return _context9.stop();
|
|
538
680
|
}
|
|
539
|
-
},
|
|
681
|
+
}, _callee9);
|
|
540
682
|
}));
|
|
541
|
-
return function (
|
|
542
|
-
return
|
|
683
|
+
return function (_x9) {
|
|
684
|
+
return _ref25.apply(this, arguments);
|
|
543
685
|
};
|
|
544
686
|
}());
|
|
545
687
|
/**
|
|
@@ -547,13 +689,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
547
689
|
* 通过餐牌ID列表获取所有相关日程的时间段点
|
|
548
690
|
*/
|
|
549
691
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
550
|
-
var
|
|
692
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref27) {
|
|
551
693
|
var _menu_list_ids$length;
|
|
552
694
|
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
553
|
-
return _regeneratorRuntime().wrap(function
|
|
554
|
-
while (1) switch (
|
|
695
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
696
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
555
697
|
case 0:
|
|
556
|
-
url =
|
|
698
|
+
url = _ref27.url, method = _ref27.method, data = _ref27.data, config = _ref27.config;
|
|
557
699
|
console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
|
|
558
700
|
menu_list_ids = data.menu_list_ids;
|
|
559
701
|
_this.logInfo('handleGetScheduleTimePoints 开始处理', {
|
|
@@ -563,12 +705,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
563
705
|
|
|
564
706
|
// 检查必要的模块是否已注册
|
|
565
707
|
if (_this.menu) {
|
|
566
|
-
|
|
708
|
+
_context10.next = 8;
|
|
567
709
|
break;
|
|
568
710
|
}
|
|
569
711
|
console.error('[Server] Menu 模块未注册');
|
|
570
712
|
_this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
|
|
571
|
-
return
|
|
713
|
+
return _context10.abrupt("return", {
|
|
572
714
|
code: 500,
|
|
573
715
|
message: 'Menu 模块未注册',
|
|
574
716
|
data: [],
|
|
@@ -576,12 +718,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
576
718
|
});
|
|
577
719
|
case 8:
|
|
578
720
|
if (_this.schedule) {
|
|
579
|
-
|
|
721
|
+
_context10.next = 12;
|
|
580
722
|
break;
|
|
581
723
|
}
|
|
582
724
|
console.error('[Server] Schedule 模块未注册');
|
|
583
725
|
_this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
|
|
584
|
-
return
|
|
726
|
+
return _context10.abrupt("return", {
|
|
585
727
|
code: 500,
|
|
586
728
|
message: 'Schedule 模块未注册',
|
|
587
729
|
data: [],
|
|
@@ -589,7 +731,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
589
731
|
});
|
|
590
732
|
case 12:
|
|
591
733
|
if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
|
|
592
|
-
|
|
734
|
+
_context10.next = 16;
|
|
593
735
|
break;
|
|
594
736
|
}
|
|
595
737
|
console.error('[Server] menu_list_ids 参数无效');
|
|
@@ -597,14 +739,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
597
739
|
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,
|
|
598
740
|
menu_list_ids: menu_list_ids
|
|
599
741
|
});
|
|
600
|
-
return
|
|
742
|
+
return _context10.abrupt("return", {
|
|
601
743
|
code: 400,
|
|
602
744
|
message: 'menu_list_ids 参数无效',
|
|
603
745
|
data: [],
|
|
604
746
|
status: false
|
|
605
747
|
});
|
|
606
748
|
case 16:
|
|
607
|
-
|
|
749
|
+
_context10.prev = 16;
|
|
608
750
|
// 1. 获取餐牌列表
|
|
609
751
|
menuList = _this.menu.getMenuByIds(menu_list_ids);
|
|
610
752
|
console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
|
|
@@ -622,13 +764,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
622
764
|
scheduleCount: scheduleIds.length
|
|
623
765
|
});
|
|
624
766
|
if (!(scheduleIds.length === 0)) {
|
|
625
|
-
|
|
767
|
+
_context10.next = 26;
|
|
626
768
|
break;
|
|
627
769
|
}
|
|
628
770
|
_this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
|
|
629
771
|
menuListIdsCount: menu_list_ids.length
|
|
630
772
|
});
|
|
631
|
-
return
|
|
773
|
+
return _context10.abrupt("return", {
|
|
632
774
|
code: 200,
|
|
633
775
|
message: '没有找到相关日程',
|
|
634
776
|
data: [],
|
|
@@ -652,22 +794,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
652
794
|
scheduleCount: scheduleList.length,
|
|
653
795
|
timePointCount: timePoints.length
|
|
654
796
|
});
|
|
655
|
-
return
|
|
797
|
+
return _context10.abrupt("return", {
|
|
656
798
|
code: 200,
|
|
657
799
|
message: '获取成功',
|
|
658
800
|
data: timePoints,
|
|
659
801
|
status: true
|
|
660
802
|
});
|
|
661
803
|
case 35:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
errorMessage =
|
|
665
|
-
console.error('[Server] 获取日程时间点失败:',
|
|
804
|
+
_context10.prev = 35;
|
|
805
|
+
_context10.t0 = _context10["catch"](16);
|
|
806
|
+
errorMessage = _context10.t0 instanceof Error ? _context10.t0.message : '未知错误';
|
|
807
|
+
console.error('[Server] 获取日程时间点失败:', _context10.t0);
|
|
666
808
|
_this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
|
|
667
809
|
menuListIdsCount: menu_list_ids.length,
|
|
668
810
|
error: errorMessage
|
|
669
811
|
});
|
|
670
|
-
return
|
|
812
|
+
return _context10.abrupt("return", {
|
|
671
813
|
code: 500,
|
|
672
814
|
message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
|
|
673
815
|
data: [],
|
|
@@ -675,18 +817,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
675
817
|
});
|
|
676
818
|
case 41:
|
|
677
819
|
case "end":
|
|
678
|
-
return
|
|
820
|
+
return _context10.stop();
|
|
679
821
|
}
|
|
680
|
-
},
|
|
822
|
+
}, _callee10, null, [[16, 35]]);
|
|
681
823
|
}));
|
|
682
|
-
return function (
|
|
683
|
-
return
|
|
824
|
+
return function (_x10) {
|
|
825
|
+
return _ref28.apply(this, arguments);
|
|
684
826
|
};
|
|
685
827
|
}());
|
|
686
828
|
this.core = core;
|
|
687
829
|
var appPlugin = core.getPlugin('app');
|
|
688
830
|
this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
|
|
689
|
-
this.logger = ((_this$
|
|
831
|
+
this.logger = ((_this$app2 = this.app) === null || _this$app2 === void 0 ? void 0 : _this$app2.logger) || null;
|
|
690
832
|
console.log('[Server] Server 初始化', this.core);
|
|
691
833
|
this.logInfo('Server 初始化', {
|
|
692
834
|
hasApp: !!this.app,
|
|
@@ -777,10 +919,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
777
919
|
}, {
|
|
778
920
|
key: "registerModuleWithRoutes",
|
|
779
921
|
value: (function () {
|
|
780
|
-
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
922
|
+
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(module, options, moduleName) {
|
|
781
923
|
var routes;
|
|
782
|
-
return _regeneratorRuntime().wrap(function
|
|
783
|
-
while (1) switch (
|
|
924
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
925
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
784
926
|
case 0:
|
|
785
927
|
this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
|
|
786
928
|
moduleName: moduleName,
|
|
@@ -788,7 +930,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
788
930
|
});
|
|
789
931
|
|
|
790
932
|
// 注册模块到 Core
|
|
791
|
-
|
|
933
|
+
_context11.next = 3;
|
|
792
934
|
return this.core.registerModule(module, options);
|
|
793
935
|
case 3:
|
|
794
936
|
console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
|
|
@@ -809,11 +951,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
809
951
|
}
|
|
810
952
|
case 6:
|
|
811
953
|
case "end":
|
|
812
|
-
return
|
|
954
|
+
return _context11.stop();
|
|
813
955
|
}
|
|
814
|
-
},
|
|
956
|
+
}, _callee11, this);
|
|
815
957
|
}));
|
|
816
|
-
function registerModuleWithRoutes(
|
|
958
|
+
function registerModuleWithRoutes(_x11, _x12, _x13) {
|
|
817
959
|
return _registerModuleWithRoutes.apply(this, arguments);
|
|
818
960
|
}
|
|
819
961
|
return registerModuleWithRoutes;
|
|
@@ -826,10 +968,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
826
968
|
}, {
|
|
827
969
|
key: "registerModuleByName",
|
|
828
970
|
value: (function () {
|
|
829
|
-
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
971
|
+
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(moduleConfig) {
|
|
830
972
|
var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
|
|
831
|
-
return _regeneratorRuntime().wrap(function
|
|
832
|
-
while (1) switch (
|
|
973
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
974
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
833
975
|
case 0:
|
|
834
976
|
// 解析配置
|
|
835
977
|
moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
|
|
@@ -844,7 +986,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
844
986
|
// 查找模块配置
|
|
845
987
|
registryConfig = this.moduleRegistry[moduleName];
|
|
846
988
|
if (registryConfig) {
|
|
847
|
-
|
|
989
|
+
_context12.next = 8;
|
|
848
990
|
break;
|
|
849
991
|
}
|
|
850
992
|
this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
|
|
@@ -858,7 +1000,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
858
1000
|
moduleOptions = _objectSpread({
|
|
859
1001
|
store: _objectSpread({}, registryConfig.defaultStore)
|
|
860
1002
|
}, customConfig); // 注册模块和路由
|
|
861
|
-
|
|
1003
|
+
_context12.next = 13;
|
|
862
1004
|
return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
|
|
863
1005
|
case 13:
|
|
864
1006
|
// 保存模块实例
|
|
@@ -868,18 +1010,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
868
1010
|
shouldPreload: shouldPreload,
|
|
869
1011
|
version: registryConfig.version
|
|
870
1012
|
});
|
|
871
|
-
return
|
|
1013
|
+
return _context12.abrupt("return", {
|
|
872
1014
|
module: moduleInstance,
|
|
873
1015
|
config: registryConfig,
|
|
874
1016
|
shouldPreload: shouldPreload
|
|
875
1017
|
});
|
|
876
1018
|
case 16:
|
|
877
1019
|
case "end":
|
|
878
|
-
return
|
|
1020
|
+
return _context12.stop();
|
|
879
1021
|
}
|
|
880
|
-
},
|
|
1022
|
+
}, _callee12, this);
|
|
881
1023
|
}));
|
|
882
|
-
function registerModuleByName(
|
|
1024
|
+
function registerModuleByName(_x14) {
|
|
883
1025
|
return _registerModuleByName.apply(this, arguments);
|
|
884
1026
|
}
|
|
885
1027
|
return registerModuleByName;
|
|
@@ -892,10 +1034,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
892
1034
|
}, {
|
|
893
1035
|
key: "registerModules",
|
|
894
1036
|
value: (function () {
|
|
895
|
-
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1037
|
+
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(moduleConfigs) {
|
|
896
1038
|
var configs, registeredModules, _iterator2, _step2, config, configName, result, errorMessage;
|
|
897
|
-
return _regeneratorRuntime().wrap(function
|
|
898
|
-
while (1) switch (
|
|
1039
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1040
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
899
1041
|
case 0:
|
|
900
1042
|
console.log('[Server] 开始注册模块...');
|
|
901
1043
|
|
|
@@ -907,47 +1049,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
907
1049
|
});
|
|
908
1050
|
registeredModules = [];
|
|
909
1051
|
_iterator2 = _createForOfIteratorHelper(configs);
|
|
910
|
-
|
|
1052
|
+
_context13.prev = 5;
|
|
911
1053
|
_iterator2.s();
|
|
912
1054
|
case 7:
|
|
913
1055
|
if ((_step2 = _iterator2.n()).done) {
|
|
914
|
-
|
|
1056
|
+
_context13.next = 25;
|
|
915
1057
|
break;
|
|
916
1058
|
}
|
|
917
1059
|
config = _step2.value;
|
|
918
1060
|
configName = typeof config === 'string' ? config : config.name;
|
|
919
|
-
|
|
920
|
-
|
|
1061
|
+
_context13.prev = 10;
|
|
1062
|
+
_context13.next = 13;
|
|
921
1063
|
return this.registerModuleByName(config);
|
|
922
1064
|
case 13:
|
|
923
|
-
result =
|
|
1065
|
+
result = _context13.sent;
|
|
924
1066
|
registeredModules.push(result);
|
|
925
|
-
|
|
1067
|
+
_context13.next = 23;
|
|
926
1068
|
break;
|
|
927
1069
|
case 17:
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
errorMessage =
|
|
1070
|
+
_context13.prev = 17;
|
|
1071
|
+
_context13.t0 = _context13["catch"](10);
|
|
1072
|
+
errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
|
|
931
1073
|
this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
|
|
932
1074
|
moduleName: configName,
|
|
933
1075
|
error: errorMessage
|
|
934
1076
|
});
|
|
935
|
-
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:",
|
|
936
|
-
throw
|
|
1077
|
+
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context13.t0);
|
|
1078
|
+
throw _context13.t0;
|
|
937
1079
|
case 23:
|
|
938
|
-
|
|
1080
|
+
_context13.next = 7;
|
|
939
1081
|
break;
|
|
940
1082
|
case 25:
|
|
941
|
-
|
|
1083
|
+
_context13.next = 30;
|
|
942
1084
|
break;
|
|
943
1085
|
case 27:
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
_iterator2.e(
|
|
1086
|
+
_context13.prev = 27;
|
|
1087
|
+
_context13.t1 = _context13["catch"](5);
|
|
1088
|
+
_iterator2.e(_context13.t1);
|
|
947
1089
|
case 30:
|
|
948
|
-
|
|
1090
|
+
_context13.prev = 30;
|
|
949
1091
|
_iterator2.f();
|
|
950
|
-
return
|
|
1092
|
+
return _context13.finish(30);
|
|
951
1093
|
case 33:
|
|
952
1094
|
console.log('[Server] ✅ 所有模块注册完成');
|
|
953
1095
|
this.logInfo('所有模块注册完成', {
|
|
@@ -957,14 +1099,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
957
1099
|
return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
|
|
958
1100
|
})
|
|
959
1101
|
});
|
|
960
|
-
return
|
|
1102
|
+
return _context13.abrupt("return", registeredModules);
|
|
961
1103
|
case 36:
|
|
962
1104
|
case "end":
|
|
963
|
-
return
|
|
1105
|
+
return _context13.stop();
|
|
964
1106
|
}
|
|
965
|
-
},
|
|
1107
|
+
}, _callee13, this, [[5, 27, 30, 33], [10, 17]]);
|
|
966
1108
|
}));
|
|
967
|
-
function registerModules(
|
|
1109
|
+
function registerModules(_x15) {
|
|
968
1110
|
return _registerModules.apply(this, arguments);
|
|
969
1111
|
}
|
|
970
1112
|
return registerModules;
|
|
@@ -977,10 +1119,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
977
1119
|
}, {
|
|
978
1120
|
key: "preloadModulesData",
|
|
979
1121
|
value: (function () {
|
|
980
|
-
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1122
|
+
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(registeredModules, options) {
|
|
981
1123
|
var modulesToPreload, preloadResults, _iterator3, _step3, _step3$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
|
|
982
|
-
return _regeneratorRuntime().wrap(function
|
|
983
|
-
while (1) switch (
|
|
1124
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1125
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
984
1126
|
case 0:
|
|
985
1127
|
console.log('[Server] 开始预加载模块数据...');
|
|
986
1128
|
modulesToPreload = registeredModules.filter(function (m) {
|
|
@@ -993,16 +1135,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
993
1135
|
});
|
|
994
1136
|
preloadResults = [];
|
|
995
1137
|
_iterator3 = _createForOfIteratorHelper(registeredModules);
|
|
996
|
-
|
|
1138
|
+
_context14.prev = 5;
|
|
997
1139
|
_iterator3.s();
|
|
998
1140
|
case 7:
|
|
999
1141
|
if ((_step3 = _iterator3.n()).done) {
|
|
1000
|
-
|
|
1142
|
+
_context14.next = 40;
|
|
1001
1143
|
break;
|
|
1002
1144
|
}
|
|
1003
1145
|
_step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
|
|
1004
1146
|
if (shouldPreload) {
|
|
1005
|
-
|
|
1147
|
+
_context14.next = 13;
|
|
1006
1148
|
break;
|
|
1007
1149
|
}
|
|
1008
1150
|
console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
|
|
@@ -1010,19 +1152,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1010
1152
|
moduleName: config.name,
|
|
1011
1153
|
reason: 'shouldPreload=false'
|
|
1012
1154
|
});
|
|
1013
|
-
return
|
|
1155
|
+
return _context14.abrupt("continue", 38);
|
|
1014
1156
|
case 13:
|
|
1015
1157
|
if (!(typeof module.preload === 'function')) {
|
|
1016
|
-
|
|
1158
|
+
_context14.next = 36;
|
|
1017
1159
|
break;
|
|
1018
1160
|
}
|
|
1019
1161
|
startTime = Date.now();
|
|
1020
|
-
|
|
1162
|
+
_context14.prev = 15;
|
|
1021
1163
|
this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
|
|
1022
1164
|
moduleName: config.name
|
|
1023
1165
|
});
|
|
1024
1166
|
options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
|
|
1025
|
-
|
|
1167
|
+
_context14.next = 20;
|
|
1026
1168
|
return module.preload();
|
|
1027
1169
|
case 20:
|
|
1028
1170
|
options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
|
|
@@ -1036,14 +1178,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1036
1178
|
name: config.name,
|
|
1037
1179
|
success: true
|
|
1038
1180
|
});
|
|
1039
|
-
|
|
1181
|
+
_context14.next = 34;
|
|
1040
1182
|
break;
|
|
1041
1183
|
case 27:
|
|
1042
|
-
|
|
1043
|
-
|
|
1184
|
+
_context14.prev = 27;
|
|
1185
|
+
_context14.t0 = _context14["catch"](15);
|
|
1044
1186
|
_duration = Date.now() - startTime;
|
|
1045
|
-
errorMessage =
|
|
1046
|
-
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"),
|
|
1187
|
+
errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
|
|
1188
|
+
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context14.t0);
|
|
1047
1189
|
this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
|
|
1048
1190
|
moduleName: config.name,
|
|
1049
1191
|
duration: "".concat(_duration, "ms"),
|
|
@@ -1055,7 +1197,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1055
1197
|
error: errorMessage
|
|
1056
1198
|
});
|
|
1057
1199
|
case 34:
|
|
1058
|
-
|
|
1200
|
+
_context14.next = 38;
|
|
1059
1201
|
break;
|
|
1060
1202
|
case 36:
|
|
1061
1203
|
console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
|
|
@@ -1063,19 +1205,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1063
1205
|
moduleName: config.name
|
|
1064
1206
|
});
|
|
1065
1207
|
case 38:
|
|
1066
|
-
|
|
1208
|
+
_context14.next = 7;
|
|
1067
1209
|
break;
|
|
1068
1210
|
case 40:
|
|
1069
|
-
|
|
1211
|
+
_context14.next = 45;
|
|
1070
1212
|
break;
|
|
1071
1213
|
case 42:
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
_iterator3.e(
|
|
1214
|
+
_context14.prev = 42;
|
|
1215
|
+
_context14.t1 = _context14["catch"](5);
|
|
1216
|
+
_iterator3.e(_context14.t1);
|
|
1075
1217
|
case 45:
|
|
1076
|
-
|
|
1218
|
+
_context14.prev = 45;
|
|
1077
1219
|
_iterator3.f();
|
|
1078
|
-
return
|
|
1220
|
+
return _context14.finish(45);
|
|
1079
1221
|
case 48:
|
|
1080
1222
|
successCount = preloadResults.filter(function (r) {
|
|
1081
1223
|
return r.success;
|
|
@@ -1090,11 +1232,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1090
1232
|
});
|
|
1091
1233
|
case 52:
|
|
1092
1234
|
case "end":
|
|
1093
|
-
return
|
|
1235
|
+
return _context14.stop();
|
|
1094
1236
|
}
|
|
1095
|
-
},
|
|
1237
|
+
}, _callee14, this, [[5, 42, 45, 48], [15, 27]]);
|
|
1096
1238
|
}));
|
|
1097
|
-
function preloadModulesData(
|
|
1239
|
+
function preloadModulesData(_x16, _x17) {
|
|
1098
1240
|
return _preloadModulesData.apply(this, arguments);
|
|
1099
1241
|
}
|
|
1100
1242
|
return preloadModulesData;
|
|
@@ -1108,7 +1250,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1108
1250
|
}, {
|
|
1109
1251
|
key: "initialize",
|
|
1110
1252
|
value: (function () {
|
|
1111
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1253
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(moduleConfigs) {
|
|
1112
1254
|
var _moduleConfigs$length,
|
|
1113
1255
|
_this3 = this;
|
|
1114
1256
|
var autoPreload,
|
|
@@ -1116,12 +1258,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1116
1258
|
startTime,
|
|
1117
1259
|
registeredModules,
|
|
1118
1260
|
duration,
|
|
1119
|
-
|
|
1120
|
-
return _regeneratorRuntime().wrap(function
|
|
1121
|
-
while (1) switch (
|
|
1261
|
+
_args15 = arguments;
|
|
1262
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1263
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1122
1264
|
case 0:
|
|
1123
|
-
autoPreload =
|
|
1124
|
-
options =
|
|
1265
|
+
autoPreload = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : true;
|
|
1266
|
+
options = _args15.length > 2 ? _args15[2] : undefined;
|
|
1125
1267
|
startTime = Date.now();
|
|
1126
1268
|
this.logInfo('Server 初始化开始', {
|
|
1127
1269
|
moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
|
|
@@ -1133,18 +1275,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1133
1275
|
this.registerServerRoutes();
|
|
1134
1276
|
|
|
1135
1277
|
// 注册模块
|
|
1136
|
-
|
|
1278
|
+
_context15.next = 7;
|
|
1137
1279
|
return this.registerModules(moduleConfigs);
|
|
1138
1280
|
case 7:
|
|
1139
|
-
registeredModules =
|
|
1281
|
+
registeredModules = _context15.sent;
|
|
1140
1282
|
if (!autoPreload) {
|
|
1141
|
-
|
|
1283
|
+
_context15.next = 13;
|
|
1142
1284
|
break;
|
|
1143
1285
|
}
|
|
1144
|
-
|
|
1286
|
+
_context15.next = 11;
|
|
1145
1287
|
return this.preloadModulesData(registeredModules, options);
|
|
1146
1288
|
case 11:
|
|
1147
|
-
|
|
1289
|
+
_context15.next = 14;
|
|
1148
1290
|
break;
|
|
1149
1291
|
case 13:
|
|
1150
1292
|
this.logInfo('跳过自动预加载', {
|
|
@@ -1174,14 +1316,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1174
1316
|
duration: "".concat(duration, "ms"),
|
|
1175
1317
|
registeredModuleCount: registeredModules.length
|
|
1176
1318
|
});
|
|
1177
|
-
return
|
|
1319
|
+
return _context15.abrupt("return", registeredModules);
|
|
1178
1320
|
case 20:
|
|
1179
1321
|
case "end":
|
|
1180
|
-
return
|
|
1322
|
+
return _context15.stop();
|
|
1181
1323
|
}
|
|
1182
|
-
},
|
|
1324
|
+
}, _callee15, this);
|
|
1183
1325
|
}));
|
|
1184
|
-
function initialize(
|
|
1326
|
+
function initialize(_x18) {
|
|
1185
1327
|
return _initialize.apply(this, arguments);
|
|
1186
1328
|
}
|
|
1187
1329
|
return initialize;
|
|
@@ -1248,45 +1390,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
1248
1390
|
}, {
|
|
1249
1391
|
key: "refreshProductsInBackground",
|
|
1250
1392
|
value: (function () {
|
|
1251
|
-
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1393
|
+
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1252
1394
|
var startTime, duration, _duration2, errorMessage;
|
|
1253
|
-
return _regeneratorRuntime().wrap(function
|
|
1254
|
-
while (1) switch (
|
|
1395
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1396
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1255
1397
|
case 0:
|
|
1256
1398
|
if (this.products) {
|
|
1257
|
-
|
|
1399
|
+
_context16.next = 3;
|
|
1258
1400
|
break;
|
|
1259
1401
|
}
|
|
1260
1402
|
this.logWarning('refreshProductsInBackground: Products 模块未注册');
|
|
1261
|
-
return
|
|
1403
|
+
return _context16.abrupt("return");
|
|
1262
1404
|
case 3:
|
|
1263
1405
|
this.logInfo('refreshProductsInBackground 开始');
|
|
1264
1406
|
startTime = Date.now();
|
|
1265
|
-
|
|
1266
|
-
|
|
1407
|
+
_context16.prev = 5;
|
|
1408
|
+
_context16.next = 8;
|
|
1267
1409
|
return this.products.silentRefresh();
|
|
1268
1410
|
case 8:
|
|
1269
1411
|
duration = Date.now() - startTime;
|
|
1270
1412
|
this.logInfo('refreshProductsInBackground 完成', {
|
|
1271
1413
|
duration: "".concat(duration, "ms")
|
|
1272
1414
|
});
|
|
1273
|
-
|
|
1415
|
+
_context16.next = 18;
|
|
1274
1416
|
break;
|
|
1275
1417
|
case 12:
|
|
1276
|
-
|
|
1277
|
-
|
|
1418
|
+
_context16.prev = 12;
|
|
1419
|
+
_context16.t0 = _context16["catch"](5);
|
|
1278
1420
|
_duration2 = Date.now() - startTime;
|
|
1279
|
-
errorMessage =
|
|
1280
|
-
console.error('[Server] refreshProductsInBackground 失败:',
|
|
1421
|
+
errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
|
|
1422
|
+
console.error('[Server] refreshProductsInBackground 失败:', _context16.t0);
|
|
1281
1423
|
this.logError('refreshProductsInBackground 失败', {
|
|
1282
1424
|
duration: "".concat(_duration2, "ms"),
|
|
1283
1425
|
error: errorMessage
|
|
1284
1426
|
});
|
|
1285
1427
|
case 18:
|
|
1286
1428
|
case "end":
|
|
1287
|
-
return
|
|
1429
|
+
return _context16.stop();
|
|
1288
1430
|
}
|
|
1289
|
-
},
|
|
1431
|
+
}, _callee16, this, [[5, 12]]);
|
|
1290
1432
|
}));
|
|
1291
1433
|
function refreshProductsInBackground() {
|
|
1292
1434
|
return _refreshProductsInBackground.apply(this, arguments);
|
|
@@ -1301,10 +1443,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1301
1443
|
}, {
|
|
1302
1444
|
key: "clearAllIndexDB",
|
|
1303
1445
|
value: (function () {
|
|
1304
|
-
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1446
|
+
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1305
1447
|
var clearTasks, moduleNames, errorMessage;
|
|
1306
|
-
return _regeneratorRuntime().wrap(function
|
|
1307
|
-
while (1) switch (
|
|
1448
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1449
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1308
1450
|
case 0:
|
|
1309
1451
|
console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
|
|
1310
1452
|
this.logInfo('开始清空所有模块的 IndexedDB 缓存');
|
|
@@ -1339,41 +1481,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
1339
1481
|
moduleNames.push('FloorPlan');
|
|
1340
1482
|
}
|
|
1341
1483
|
if (!(clearTasks.length === 0)) {
|
|
1342
|
-
|
|
1484
|
+
_context17.next = 15;
|
|
1343
1485
|
break;
|
|
1344
1486
|
}
|
|
1345
1487
|
console.warn('[Server] 没有找到已注册的模块,无需清空');
|
|
1346
1488
|
this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
|
|
1347
|
-
return
|
|
1489
|
+
return _context17.abrupt("return");
|
|
1348
1490
|
case 15:
|
|
1349
1491
|
this.logInfo('准备清空模块缓存', {
|
|
1350
1492
|
moduleNames: moduleNames
|
|
1351
1493
|
});
|
|
1352
|
-
|
|
1353
|
-
|
|
1494
|
+
_context17.prev = 16;
|
|
1495
|
+
_context17.next = 19;
|
|
1354
1496
|
return Promise.all(clearTasks);
|
|
1355
1497
|
case 19:
|
|
1356
1498
|
console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
|
|
1357
1499
|
this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
|
|
1358
1500
|
moduleNames: moduleNames
|
|
1359
1501
|
});
|
|
1360
|
-
|
|
1502
|
+
_context17.next = 29;
|
|
1361
1503
|
break;
|
|
1362
1504
|
case 23:
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
errorMessage =
|
|
1366
|
-
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:',
|
|
1505
|
+
_context17.prev = 23;
|
|
1506
|
+
_context17.t0 = _context17["catch"](16);
|
|
1507
|
+
errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
|
|
1508
|
+
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context17.t0);
|
|
1367
1509
|
this.logError('清空 IndexedDB 缓存时发生错误', {
|
|
1368
1510
|
moduleNames: moduleNames,
|
|
1369
1511
|
error: errorMessage
|
|
1370
1512
|
});
|
|
1371
|
-
throw
|
|
1513
|
+
throw _context17.t0;
|
|
1372
1514
|
case 29:
|
|
1373
1515
|
case "end":
|
|
1374
|
-
return
|
|
1516
|
+
return _context17.stop();
|
|
1375
1517
|
}
|
|
1376
|
-
},
|
|
1518
|
+
}, _callee17, this, [[16, 23]]);
|
|
1377
1519
|
}));
|
|
1378
1520
|
function clearAllIndexDB() {
|
|
1379
1521
|
return _clearAllIndexDB.apply(this, arguments);
|
|
@@ -1444,10 +1586,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1444
1586
|
}, {
|
|
1445
1587
|
key: "handleRoute",
|
|
1446
1588
|
value: (function () {
|
|
1447
|
-
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1589
|
+
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(method, path, params) {
|
|
1448
1590
|
var startTime, handler, result, duration, _duration3, errorMessage;
|
|
1449
|
-
return _regeneratorRuntime().wrap(function
|
|
1450
|
-
while (1) switch (
|
|
1591
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1592
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1451
1593
|
case 0:
|
|
1452
1594
|
startTime = Date.now();
|
|
1453
1595
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -1458,7 +1600,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1458
1600
|
});
|
|
1459
1601
|
handler = this.getRouteHandler(method, path);
|
|
1460
1602
|
if (handler) {
|
|
1461
|
-
|
|
1603
|
+
_context18.next = 6;
|
|
1462
1604
|
break;
|
|
1463
1605
|
}
|
|
1464
1606
|
this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -1467,13 +1609,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1467
1609
|
});
|
|
1468
1610
|
throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
|
|
1469
1611
|
case 6:
|
|
1470
|
-
|
|
1471
|
-
|
|
1612
|
+
_context18.prev = 6;
|
|
1613
|
+
_context18.next = 9;
|
|
1472
1614
|
return handler(_objectSpread(_objectSpread({}, params), {}, {
|
|
1473
1615
|
path: path
|
|
1474
1616
|
}));
|
|
1475
1617
|
case 9:
|
|
1476
|
-
result =
|
|
1618
|
+
result = _context18.sent;
|
|
1477
1619
|
duration = Date.now() - startTime;
|
|
1478
1620
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
1479
1621
|
method: method.toUpperCase(),
|
|
@@ -1482,12 +1624,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1482
1624
|
resultCode: result === null || result === void 0 ? void 0 : result.code,
|
|
1483
1625
|
resultStatus: result === null || result === void 0 ? void 0 : result.status
|
|
1484
1626
|
});
|
|
1485
|
-
return
|
|
1627
|
+
return _context18.abrupt("return", result);
|
|
1486
1628
|
case 15:
|
|
1487
|
-
|
|
1488
|
-
|
|
1629
|
+
_context18.prev = 15;
|
|
1630
|
+
_context18.t0 = _context18["catch"](6);
|
|
1489
1631
|
_duration3 = Date.now() - startTime;
|
|
1490
|
-
errorMessage =
|
|
1632
|
+
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1491
1633
|
this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
1492
1634
|
method: method.toUpperCase(),
|
|
1493
1635
|
path: path,
|
|
@@ -1495,15 +1637,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
1495
1637
|
error: errorMessage,
|
|
1496
1638
|
data: params.data
|
|
1497
1639
|
});
|
|
1498
|
-
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path),
|
|
1499
|
-
throw
|
|
1640
|
+
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context18.t0);
|
|
1641
|
+
throw _context18.t0;
|
|
1500
1642
|
case 22:
|
|
1501
1643
|
case "end":
|
|
1502
|
-
return
|
|
1644
|
+
return _context18.stop();
|
|
1503
1645
|
}
|
|
1504
|
-
},
|
|
1646
|
+
}, _callee18, this, [[6, 15]]);
|
|
1505
1647
|
}));
|
|
1506
|
-
function handleRoute(
|
|
1648
|
+
function handleRoute(_x19, _x20, _x21) {
|
|
1507
1649
|
return _handleRoute.apply(this, arguments);
|
|
1508
1650
|
}
|
|
1509
1651
|
return handleRoute;
|
|
@@ -1569,6 +1711,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1569
1711
|
method: 'get',
|
|
1570
1712
|
path: '/shop/form/resource/page',
|
|
1571
1713
|
handler: this.handleResourceList.bind(this)
|
|
1714
|
+
}, {
|
|
1715
|
+
method: 'get',
|
|
1716
|
+
path: '/update/localOrder',
|
|
1717
|
+
handler: this.handleUpdateLocalOrder.bind(this)
|
|
1572
1718
|
}]);
|
|
1573
1719
|
this.registerPrefixRoutes([{
|
|
1574
1720
|
method: 'get',
|
|
@@ -1984,18 +2130,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1984
2130
|
}, {
|
|
1985
2131
|
key: "fetchOrderListFromAPI",
|
|
1986
2132
|
value: (function () {
|
|
1987
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1988
|
-
var _this$
|
|
1989
|
-
var _response$
|
|
1990
|
-
return _regeneratorRuntime().wrap(function
|
|
1991
|
-
while (1) switch (
|
|
2133
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data) {
|
|
2134
|
+
var _this$app3;
|
|
2135
|
+
var _response$data2, response, payload, list, count, errorMessage;
|
|
2136
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2137
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1992
2138
|
case 0:
|
|
1993
|
-
if ((_this$
|
|
1994
|
-
|
|
2139
|
+
if ((_this$app3 = this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
|
|
2140
|
+
_context19.next = 3;
|
|
1995
2141
|
break;
|
|
1996
2142
|
}
|
|
1997
2143
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
1998
|
-
return
|
|
2144
|
+
return _context19.abrupt("return", {
|
|
1999
2145
|
code: 500,
|
|
2000
2146
|
message: 'app.request 不可用',
|
|
2001
2147
|
data: {
|
|
@@ -2005,17 +2151,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2005
2151
|
status: false
|
|
2006
2152
|
});
|
|
2007
2153
|
case 3:
|
|
2008
|
-
|
|
2009
|
-
|
|
2154
|
+
_context19.prev = 3;
|
|
2155
|
+
_context19.next = 6;
|
|
2010
2156
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
2011
2157
|
isShopApi: true
|
|
2012
2158
|
});
|
|
2013
2159
|
case 6:
|
|
2014
|
-
response =
|
|
2015
|
-
payload = (_response$
|
|
2160
|
+
response = _context19.sent;
|
|
2161
|
+
payload = (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response;
|
|
2016
2162
|
list = Array.isArray(payload === null || payload === void 0 ? void 0 : payload.list) ? payload.list : [];
|
|
2017
2163
|
count = typeof (payload === null || payload === void 0 ? void 0 : payload.count) === 'number' ? payload.count : list.length;
|
|
2018
|
-
return
|
|
2164
|
+
return _context19.abrupt("return", {
|
|
2019
2165
|
code: 200,
|
|
2020
2166
|
data: _objectSpread(_objectSpread({}, payload), {}, {
|
|
2021
2167
|
list: list,
|
|
@@ -2025,13 +2171,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
2025
2171
|
status: true
|
|
2026
2172
|
});
|
|
2027
2173
|
case 13:
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
errorMessage =
|
|
2174
|
+
_context19.prev = 13;
|
|
2175
|
+
_context19.t0 = _context19["catch"](3);
|
|
2176
|
+
errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
|
|
2031
2177
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
2032
2178
|
error: errorMessage
|
|
2033
2179
|
});
|
|
2034
|
-
return
|
|
2180
|
+
return _context19.abrupt("return", {
|
|
2035
2181
|
code: 500,
|
|
2036
2182
|
message: errorMessage,
|
|
2037
2183
|
data: {
|
|
@@ -2042,11 +2188,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2042
2188
|
});
|
|
2043
2189
|
case 18:
|
|
2044
2190
|
case "end":
|
|
2045
|
-
return
|
|
2191
|
+
return _context19.stop();
|
|
2046
2192
|
}
|
|
2047
|
-
},
|
|
2193
|
+
}, _callee19, this, [[3, 13]]);
|
|
2048
2194
|
}));
|
|
2049
|
-
function fetchOrderListFromAPI(
|
|
2195
|
+
function fetchOrderListFromAPI(_x22) {
|
|
2050
2196
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
2051
2197
|
}
|
|
2052
2198
|
return fetchOrderListFromAPI;
|
|
@@ -2058,17 +2204,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2058
2204
|
}, {
|
|
2059
2205
|
key: "fetchBookingListFromAPI",
|
|
2060
2206
|
value: (function () {
|
|
2061
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2207
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(data) {
|
|
2062
2208
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
2063
|
-
return _regeneratorRuntime().wrap(function
|
|
2064
|
-
while (1) switch (
|
|
2209
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2210
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2065
2211
|
case 0:
|
|
2066
2212
|
if (this.order) {
|
|
2067
|
-
|
|
2213
|
+
_context20.next = 3;
|
|
2068
2214
|
break;
|
|
2069
2215
|
}
|
|
2070
2216
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
2071
|
-
return
|
|
2217
|
+
return _context20.abrupt("return", {
|
|
2072
2218
|
code: 500,
|
|
2073
2219
|
message: 'Order 模块不可用',
|
|
2074
2220
|
data: {
|
|
@@ -2078,18 +2224,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
2078
2224
|
status: false
|
|
2079
2225
|
});
|
|
2080
2226
|
case 3:
|
|
2081
|
-
|
|
2227
|
+
_context20.prev = 3;
|
|
2082
2228
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
2083
2229
|
withFields = this.resolveBookingSalesWith(data);
|
|
2084
2230
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
2085
2231
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
2086
2232
|
if (!memoryCacheEnabled) {
|
|
2087
|
-
|
|
2233
|
+
_context20.next = 13;
|
|
2088
2234
|
break;
|
|
2089
2235
|
}
|
|
2090
2236
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
2091
2237
|
if (!cached) {
|
|
2092
|
-
|
|
2238
|
+
_context20.next = 13;
|
|
2093
2239
|
break;
|
|
2094
2240
|
}
|
|
2095
2241
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -2097,14 +2243,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2097
2243
|
listCount: cached.bookingResult.count,
|
|
2098
2244
|
withFields: cached.withFields
|
|
2099
2245
|
});
|
|
2100
|
-
return
|
|
2246
|
+
return _context20.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
2101
2247
|
cache_hit: true
|
|
2102
2248
|
}));
|
|
2103
2249
|
case 13:
|
|
2104
|
-
|
|
2250
|
+
_context20.next = 15;
|
|
2105
2251
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
2106
2252
|
case 15:
|
|
2107
|
-
rawList =
|
|
2253
|
+
rawList = _context20.sent;
|
|
2108
2254
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
2109
2255
|
if (typeof globalThis !== 'undefined') {
|
|
2110
2256
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -2151,15 +2297,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2151
2297
|
cacheKey: cacheKey,
|
|
2152
2298
|
withFields: withFields
|
|
2153
2299
|
});
|
|
2154
|
-
return
|
|
2300
|
+
return _context20.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
2155
2301
|
case 23:
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
errorMessage =
|
|
2302
|
+
_context20.prev = 23;
|
|
2303
|
+
_context20.t0 = _context20["catch"](3);
|
|
2304
|
+
errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0);
|
|
2159
2305
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
2160
2306
|
error: errorMessage
|
|
2161
2307
|
});
|
|
2162
|
-
return
|
|
2308
|
+
return _context20.abrupt("return", {
|
|
2163
2309
|
code: 500,
|
|
2164
2310
|
message: errorMessage,
|
|
2165
2311
|
data: {
|
|
@@ -2170,28 +2316,71 @@ var Server = /*#__PURE__*/function () {
|
|
|
2170
2316
|
});
|
|
2171
2317
|
case 28:
|
|
2172
2318
|
case "end":
|
|
2173
|
-
return
|
|
2319
|
+
return _context20.stop();
|
|
2174
2320
|
}
|
|
2175
|
-
},
|
|
2321
|
+
}, _callee20, this, [[3, 23]]);
|
|
2176
2322
|
}));
|
|
2177
|
-
function fetchBookingListFromAPI(
|
|
2323
|
+
function fetchBookingListFromAPI(_x23) {
|
|
2178
2324
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
2179
2325
|
}
|
|
2180
2326
|
return fetchBookingListFromAPI;
|
|
2181
2327
|
}())
|
|
2182
2328
|
}, {
|
|
2183
|
-
key: "
|
|
2329
|
+
key: "extractQueryParam",
|
|
2184
2330
|
value:
|
|
2331
|
+
/**
|
|
2332
|
+
* 从 url 中解析指定 query 参数,兼容相对路径与绝对路径
|
|
2333
|
+
*/
|
|
2334
|
+
function extractQueryParam(url, key) {
|
|
2335
|
+
if (!url) return null;
|
|
2336
|
+
try {
|
|
2337
|
+
var target = url.startsWith('http') ? new URL(url) : new URL(url, 'http://placeholder.local');
|
|
2338
|
+
var value = target.searchParams.get(key);
|
|
2339
|
+
return value !== null && value !== void 0 ? value : null;
|
|
2340
|
+
} catch (_unused) {
|
|
2341
|
+
var queryIndex = url.indexOf('?');
|
|
2342
|
+
if (queryIndex < 0) return null;
|
|
2343
|
+
var query = url.slice(queryIndex + 1);
|
|
2344
|
+
var _iterator11 = _createForOfIteratorHelper(query.split('&')),
|
|
2345
|
+
_step11;
|
|
2346
|
+
try {
|
|
2347
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2348
|
+
var pair = _step11.value;
|
|
2349
|
+
if (!pair) continue;
|
|
2350
|
+
var _pair$split = pair.split('='),
|
|
2351
|
+
_pair$split2 = _slicedToArray(_pair$split, 2),
|
|
2352
|
+
rawKey = _pair$split2[0],
|
|
2353
|
+
_pair$split2$ = _pair$split2[1],
|
|
2354
|
+
rawValue = _pair$split2$ === void 0 ? '' : _pair$split2$;
|
|
2355
|
+
try {
|
|
2356
|
+
if (decodeURIComponent(rawKey) === key) {
|
|
2357
|
+
return decodeURIComponent(rawValue);
|
|
2358
|
+
}
|
|
2359
|
+
} catch (_unused2) {
|
|
2360
|
+
if (rawKey === key) return rawValue;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
} catch (err) {
|
|
2364
|
+
_iterator11.e(err);
|
|
2365
|
+
} finally {
|
|
2366
|
+
_iterator11.f();
|
|
2367
|
+
}
|
|
2368
|
+
return null;
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2185
2372
|
/**
|
|
2186
2373
|
* 从 url 或路由 path 解析 pathname(不含 query,去掉末尾 /)
|
|
2187
2374
|
*/
|
|
2188
|
-
|
|
2375
|
+
}, {
|
|
2376
|
+
key: "parseRequestPath",
|
|
2377
|
+
value: function parseRequestPath(url, routePath) {
|
|
2189
2378
|
var raw = routePath || url;
|
|
2190
2379
|
var noQuery = raw.split('?')[0] || '';
|
|
2191
2380
|
try {
|
|
2192
2381
|
var pathname = url.startsWith('http') ? new URL(url).pathname : noQuery;
|
|
2193
2382
|
return pathname.replace(/\/$/, '') || pathname;
|
|
2194
|
-
} catch (
|
|
2383
|
+
} catch (_unused3) {
|
|
2195
2384
|
return noQuery.replace(/\/$/, '');
|
|
2196
2385
|
}
|
|
2197
2386
|
}
|
|
@@ -2289,24 +2478,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
2289
2478
|
}, {
|
|
2290
2479
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
2291
2480
|
value: (function () {
|
|
2292
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2293
|
-
var
|
|
2294
|
-
return _regeneratorRuntime().wrap(function
|
|
2295
|
-
while (1) switch (
|
|
2481
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2482
|
+
var _iterator12, _step12, _step12$value, subscriberId, sub, result, errorMessage;
|
|
2483
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2484
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2296
2485
|
case 0:
|
|
2297
2486
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
2298
|
-
|
|
2487
|
+
_context21.next = 2;
|
|
2299
2488
|
break;
|
|
2300
2489
|
}
|
|
2301
|
-
return
|
|
2490
|
+
return _context21.abrupt("return");
|
|
2302
2491
|
case 2:
|
|
2303
2492
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
2304
2493
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
2305
2494
|
});
|
|
2306
|
-
|
|
2495
|
+
_iterator12 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
|
|
2307
2496
|
try {
|
|
2308
|
-
for (
|
|
2309
|
-
|
|
2497
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
2498
|
+
_step12$value = _slicedToArray(_step12.value, 2), subscriberId = _step12$value[0], sub = _step12$value[1];
|
|
2310
2499
|
try {
|
|
2311
2500
|
result = this.computeFloorPlanQueryResult(sub.context);
|
|
2312
2501
|
sub.callback(result);
|
|
@@ -2322,15 +2511,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2322
2511
|
}
|
|
2323
2512
|
}
|
|
2324
2513
|
} catch (err) {
|
|
2325
|
-
|
|
2514
|
+
_iterator12.e(err);
|
|
2326
2515
|
} finally {
|
|
2327
|
-
|
|
2516
|
+
_iterator12.f();
|
|
2328
2517
|
}
|
|
2329
2518
|
case 5:
|
|
2330
2519
|
case "end":
|
|
2331
|
-
return
|
|
2520
|
+
return _context21.stop();
|
|
2332
2521
|
}
|
|
2333
|
-
},
|
|
2522
|
+
}, _callee21, this);
|
|
2334
2523
|
}));
|
|
2335
2524
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
2336
2525
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -2360,21 +2549,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2360
2549
|
* filter 逻辑暂为 mock,仅记录参数
|
|
2361
2550
|
*/
|
|
2362
2551
|
function () {
|
|
2363
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2552
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(data) {
|
|
2364
2553
|
var rawList, result;
|
|
2365
|
-
return _regeneratorRuntime().wrap(function
|
|
2366
|
-
while (1) switch (
|
|
2554
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2555
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2367
2556
|
case 0:
|
|
2368
2557
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
2369
2558
|
data: data
|
|
2370
2559
|
});
|
|
2371
2560
|
console.log('[Server] computeOrderQueryResult', data);
|
|
2372
2561
|
if (this.order) {
|
|
2373
|
-
|
|
2562
|
+
_context22.next = 5;
|
|
2374
2563
|
break;
|
|
2375
2564
|
}
|
|
2376
2565
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
2377
|
-
return
|
|
2566
|
+
return _context22.abrupt("return", {
|
|
2378
2567
|
code: 500,
|
|
2379
2568
|
message: 'Order 模块未注册',
|
|
2380
2569
|
data: {
|
|
@@ -2397,7 +2586,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2397
2586
|
size: result.size,
|
|
2398
2587
|
skip: result.skip
|
|
2399
2588
|
});
|
|
2400
|
-
return
|
|
2589
|
+
return _context22.abrupt("return", {
|
|
2401
2590
|
code: 200,
|
|
2402
2591
|
data: result,
|
|
2403
2592
|
message: '',
|
|
@@ -2405,11 +2594,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2405
2594
|
});
|
|
2406
2595
|
case 10:
|
|
2407
2596
|
case "end":
|
|
2408
|
-
return
|
|
2597
|
+
return _context22.stop();
|
|
2409
2598
|
}
|
|
2410
|
-
},
|
|
2599
|
+
}, _callee22, this);
|
|
2411
2600
|
}));
|
|
2412
|
-
function computeOrderQueryResult(
|
|
2601
|
+
function computeOrderQueryResult(_x24) {
|
|
2413
2602
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
2414
2603
|
}
|
|
2415
2604
|
return computeOrderQueryResult;
|
|
@@ -2422,17 +2611,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2422
2611
|
}, {
|
|
2423
2612
|
key: "computeBookingQueryResult",
|
|
2424
2613
|
value: (function () {
|
|
2425
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2614
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(data) {
|
|
2426
2615
|
var rawOrders, result;
|
|
2427
|
-
return _regeneratorRuntime().wrap(function
|
|
2428
|
-
while (1) switch (
|
|
2616
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2617
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2429
2618
|
case 0:
|
|
2430
2619
|
if (this.order) {
|
|
2431
|
-
|
|
2620
|
+
_context23.next = 3;
|
|
2432
2621
|
break;
|
|
2433
2622
|
}
|
|
2434
2623
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
2435
|
-
return
|
|
2624
|
+
return _context23.abrupt("return", {
|
|
2436
2625
|
code: 500,
|
|
2437
2626
|
message: 'Order 模块未注册',
|
|
2438
2627
|
data: {
|
|
@@ -2451,7 +2640,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2451
2640
|
size: result.size,
|
|
2452
2641
|
skip: result.skip
|
|
2453
2642
|
});
|
|
2454
|
-
return
|
|
2643
|
+
return _context23.abrupt("return", {
|
|
2455
2644
|
code: 200,
|
|
2456
2645
|
data: result,
|
|
2457
2646
|
message: '',
|
|
@@ -2459,11 +2648,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2459
2648
|
});
|
|
2460
2649
|
case 8:
|
|
2461
2650
|
case "end":
|
|
2462
|
-
return
|
|
2651
|
+
return _context23.stop();
|
|
2463
2652
|
}
|
|
2464
|
-
},
|
|
2653
|
+
}, _callee23, this);
|
|
2465
2654
|
}));
|
|
2466
|
-
function computeBookingQueryResult(
|
|
2655
|
+
function computeBookingQueryResult(_x25) {
|
|
2467
2656
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
2468
2657
|
}
|
|
2469
2658
|
return computeBookingQueryResult;
|
|
@@ -2479,12 +2668,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2479
2668
|
}, {
|
|
2480
2669
|
key: "computeProductQueryResult",
|
|
2481
2670
|
value: (function () {
|
|
2482
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2671
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(context, options) {
|
|
2483
2672
|
var _menu_list_ids$length3,
|
|
2484
2673
|
_this6 = this;
|
|
2485
2674
|
var tTotal, menu_list_ids, schedule_date, schedule_datetime, activeMenuList, tMenu, menuList, tPrice, allProductsWithPrice, tFilter, filteredProducts, tStatus, beforeStatusCount, tSort;
|
|
2486
|
-
return _regeneratorRuntime().wrap(function
|
|
2487
|
-
while (1) switch (
|
|
2675
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2676
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2488
2677
|
case 0:
|
|
2489
2678
|
tTotal = performance.now();
|
|
2490
2679
|
menu_list_ids = context.menu_list_ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime;
|
|
@@ -2495,11 +2684,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2495
2684
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
2496
2685
|
});
|
|
2497
2686
|
if (this.products) {
|
|
2498
|
-
|
|
2687
|
+
_context24.next = 6;
|
|
2499
2688
|
break;
|
|
2500
2689
|
}
|
|
2501
2690
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
2502
|
-
return
|
|
2691
|
+
return _context24.abrupt("return", {
|
|
2503
2692
|
message: 'Products 模块未注册',
|
|
2504
2693
|
data: {
|
|
2505
2694
|
list: [],
|
|
@@ -2508,11 +2697,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2508
2697
|
});
|
|
2509
2698
|
case 6:
|
|
2510
2699
|
if (this.menu) {
|
|
2511
|
-
|
|
2700
|
+
_context24.next = 9;
|
|
2512
2701
|
break;
|
|
2513
2702
|
}
|
|
2514
2703
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
2515
|
-
return
|
|
2704
|
+
return _context24.abrupt("return", {
|
|
2516
2705
|
message: 'Menu 模块未注册',
|
|
2517
2706
|
data: {
|
|
2518
2707
|
list: [],
|
|
@@ -2521,11 +2710,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2521
2710
|
});
|
|
2522
2711
|
case 9:
|
|
2523
2712
|
if (this.schedule) {
|
|
2524
|
-
|
|
2713
|
+
_context24.next = 12;
|
|
2525
2714
|
break;
|
|
2526
2715
|
}
|
|
2527
2716
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
2528
|
-
return
|
|
2717
|
+
return _context24.abrupt("return", {
|
|
2529
2718
|
message: 'Schedule 模块未注册',
|
|
2530
2719
|
data: {
|
|
2531
2720
|
list: [],
|
|
@@ -2547,14 +2736,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2547
2736
|
});
|
|
2548
2737
|
}
|
|
2549
2738
|
tPrice = performance.now();
|
|
2550
|
-
|
|
2739
|
+
_context24.next = 17;
|
|
2551
2740
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
2552
2741
|
scheduleModule: this.getSchedule()
|
|
2553
2742
|
}, {
|
|
2554
2743
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
2555
2744
|
});
|
|
2556
2745
|
case 17:
|
|
2557
|
-
allProductsWithPrice =
|
|
2746
|
+
allProductsWithPrice = _context24.sent;
|
|
2558
2747
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
2559
2748
|
count: allProductsWithPrice.length
|
|
2560
2749
|
});
|
|
@@ -2592,7 +2781,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2592
2781
|
filteredCount: filteredProducts.length,
|
|
2593
2782
|
activeMenuCount: activeMenuList.length
|
|
2594
2783
|
});
|
|
2595
|
-
return
|
|
2784
|
+
return _context24.abrupt("return", {
|
|
2596
2785
|
code: 200,
|
|
2597
2786
|
data: {
|
|
2598
2787
|
list: filteredProducts,
|
|
@@ -2603,11 +2792,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2603
2792
|
});
|
|
2604
2793
|
case 32:
|
|
2605
2794
|
case "end":
|
|
2606
|
-
return
|
|
2795
|
+
return _context24.stop();
|
|
2607
2796
|
}
|
|
2608
|
-
},
|
|
2797
|
+
}, _callee24, this);
|
|
2609
2798
|
}));
|
|
2610
|
-
function computeProductQueryResult(
|
|
2799
|
+
function computeProductQueryResult(_x26, _x27) {
|
|
2611
2800
|
return _computeProductQueryResult.apply(this, arguments);
|
|
2612
2801
|
}
|
|
2613
2802
|
return computeProductQueryResult;
|
|
@@ -2622,72 +2811,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
2622
2811
|
}, {
|
|
2623
2812
|
key: "recomputeAndNotifyProductQuery",
|
|
2624
2813
|
value: (function () {
|
|
2625
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2626
|
-
var
|
|
2627
|
-
return _regeneratorRuntime().wrap(function
|
|
2628
|
-
while (1) switch (
|
|
2814
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(options) {
|
|
2815
|
+
var _iterator13, _step13, _step13$value, subscriberId, subscriber, result, errorMessage;
|
|
2816
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2817
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2629
2818
|
case 0:
|
|
2630
2819
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
2631
|
-
|
|
2820
|
+
_context25.next = 2;
|
|
2632
2821
|
break;
|
|
2633
2822
|
}
|
|
2634
|
-
return
|
|
2823
|
+
return _context25.abrupt("return");
|
|
2635
2824
|
case 2:
|
|
2636
2825
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
2637
2826
|
subscriberCount: this.productQuerySubscribers.size,
|
|
2638
2827
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
2639
2828
|
});
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2829
|
+
_iterator13 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
2830
|
+
_context25.prev = 4;
|
|
2831
|
+
_iterator13.s();
|
|
2643
2832
|
case 6:
|
|
2644
|
-
if ((
|
|
2645
|
-
|
|
2833
|
+
if ((_step13 = _iterator13.n()).done) {
|
|
2834
|
+
_context25.next = 22;
|
|
2646
2835
|
break;
|
|
2647
2836
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2837
|
+
_step13$value = _slicedToArray(_step13.value, 2), subscriberId = _step13$value[0], subscriber = _step13$value[1];
|
|
2838
|
+
_context25.prev = 8;
|
|
2839
|
+
_context25.next = 11;
|
|
2651
2840
|
return this.computeProductQueryResult(subscriber.context, {
|
|
2652
2841
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
2653
2842
|
});
|
|
2654
2843
|
case 11:
|
|
2655
|
-
result =
|
|
2844
|
+
result = _context25.sent;
|
|
2656
2845
|
subscriber.callback(result);
|
|
2657
2846
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
2658
2847
|
subscriberId: subscriberId
|
|
2659
2848
|
});
|
|
2660
|
-
|
|
2849
|
+
_context25.next = 20;
|
|
2661
2850
|
break;
|
|
2662
2851
|
case 16:
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
errorMessage =
|
|
2852
|
+
_context25.prev = 16;
|
|
2853
|
+
_context25.t0 = _context25["catch"](8);
|
|
2854
|
+
errorMessage = _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0);
|
|
2666
2855
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
2667
2856
|
subscriberId: subscriberId,
|
|
2668
2857
|
error: errorMessage
|
|
2669
2858
|
});
|
|
2670
2859
|
case 20:
|
|
2671
|
-
|
|
2860
|
+
_context25.next = 6;
|
|
2672
2861
|
break;
|
|
2673
2862
|
case 22:
|
|
2674
|
-
|
|
2863
|
+
_context25.next = 27;
|
|
2675
2864
|
break;
|
|
2676
2865
|
case 24:
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2866
|
+
_context25.prev = 24;
|
|
2867
|
+
_context25.t1 = _context25["catch"](4);
|
|
2868
|
+
_iterator13.e(_context25.t1);
|
|
2680
2869
|
case 27:
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
return
|
|
2870
|
+
_context25.prev = 27;
|
|
2871
|
+
_iterator13.f();
|
|
2872
|
+
return _context25.finish(27);
|
|
2684
2873
|
case 30:
|
|
2685
2874
|
case "end":
|
|
2686
|
-
return
|
|
2875
|
+
return _context25.stop();
|
|
2687
2876
|
}
|
|
2688
|
-
},
|
|
2877
|
+
}, _callee25, this, [[4, 24, 27, 30], [8, 16]]);
|
|
2689
2878
|
}));
|
|
2690
|
-
function recomputeAndNotifyProductQuery(
|
|
2879
|
+
function recomputeAndNotifyProductQuery(_x28) {
|
|
2691
2880
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
2692
2881
|
}
|
|
2693
2882
|
return recomputeAndNotifyProductQuery;
|
|
@@ -2699,37 +2888,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
2699
2888
|
}, {
|
|
2700
2889
|
key: "recomputeAndNotifyOrderQuery",
|
|
2701
2890
|
value: (function () {
|
|
2702
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2703
|
-
var notifyStartAt,
|
|
2704
|
-
return _regeneratorRuntime().wrap(function
|
|
2705
|
-
while (1) switch (
|
|
2891
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2892
|
+
var notifyStartAt, _iterator14, _step14, _step14$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
2893
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2894
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2706
2895
|
case 0:
|
|
2707
2896
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
2708
|
-
|
|
2897
|
+
_context26.next = 2;
|
|
2709
2898
|
break;
|
|
2710
2899
|
}
|
|
2711
|
-
return
|
|
2900
|
+
return _context26.abrupt("return");
|
|
2712
2901
|
case 2:
|
|
2713
2902
|
notifyStartAt = Date.now();
|
|
2714
2903
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
2715
2904
|
subscriberCount: this.orderQuerySubscribers.size,
|
|
2716
2905
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
2717
2906
|
});
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2907
|
+
_iterator14 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
2908
|
+
_context26.prev = 5;
|
|
2909
|
+
_iterator14.s();
|
|
2721
2910
|
case 7:
|
|
2722
|
-
if ((
|
|
2723
|
-
|
|
2911
|
+
if ((_step14 = _iterator14.n()).done) {
|
|
2912
|
+
_context26.next = 27;
|
|
2724
2913
|
break;
|
|
2725
2914
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2915
|
+
_step14$value = _slicedToArray(_step14.value, 2), subscriberId = _step14$value[0], subscriber = _step14$value[1];
|
|
2916
|
+
_context26.prev = 9;
|
|
2728
2917
|
computeStartAt = Date.now();
|
|
2729
|
-
|
|
2918
|
+
_context26.next = 13;
|
|
2730
2919
|
return this.computeOrderQueryResult(subscriber.context);
|
|
2731
2920
|
case 13:
|
|
2732
|
-
result =
|
|
2921
|
+
result = _context26.sent;
|
|
2733
2922
|
computeEndAt = Date.now();
|
|
2734
2923
|
callbackStartAt = Date.now();
|
|
2735
2924
|
subscriber.callback(result);
|
|
@@ -2740,30 +2929,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
2740
2929
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
2741
2930
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
2742
2931
|
});
|
|
2743
|
-
|
|
2932
|
+
_context26.next = 25;
|
|
2744
2933
|
break;
|
|
2745
2934
|
case 21:
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
errorMessage =
|
|
2935
|
+
_context26.prev = 21;
|
|
2936
|
+
_context26.t0 = _context26["catch"](9);
|
|
2937
|
+
errorMessage = _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0);
|
|
2749
2938
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
2750
2939
|
subscriberId: subscriberId,
|
|
2751
2940
|
error: errorMessage
|
|
2752
2941
|
});
|
|
2753
2942
|
case 25:
|
|
2754
|
-
|
|
2943
|
+
_context26.next = 7;
|
|
2755
2944
|
break;
|
|
2756
2945
|
case 27:
|
|
2757
|
-
|
|
2946
|
+
_context26.next = 32;
|
|
2758
2947
|
break;
|
|
2759
2948
|
case 29:
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2949
|
+
_context26.prev = 29;
|
|
2950
|
+
_context26.t1 = _context26["catch"](5);
|
|
2951
|
+
_iterator14.e(_context26.t1);
|
|
2763
2952
|
case 32:
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
return
|
|
2953
|
+
_context26.prev = 32;
|
|
2954
|
+
_iterator14.f();
|
|
2955
|
+
return _context26.finish(32);
|
|
2767
2956
|
case 35:
|
|
2768
2957
|
notifyEndAt = Date.now();
|
|
2769
2958
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -2772,9 +2961,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
2772
2961
|
});
|
|
2773
2962
|
case 37:
|
|
2774
2963
|
case "end":
|
|
2775
|
-
return
|
|
2964
|
+
return _context26.stop();
|
|
2776
2965
|
}
|
|
2777
|
-
},
|
|
2966
|
+
}, _callee26, this, [[5, 29, 32, 35], [9, 21]]);
|
|
2778
2967
|
}));
|
|
2779
2968
|
function recomputeAndNotifyOrderQuery() {
|
|
2780
2969
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -2788,67 +2977,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
2788
2977
|
}, {
|
|
2789
2978
|
key: "recomputeAndNotifyBookingQuery",
|
|
2790
2979
|
value: (function () {
|
|
2791
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2792
|
-
var
|
|
2793
|
-
return _regeneratorRuntime().wrap(function
|
|
2794
|
-
while (1) switch (
|
|
2980
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2981
|
+
var _iterator15, _step15, _step15$value, subscriberId, subscriber, result, errorMessage;
|
|
2982
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2983
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2795
2984
|
case 0:
|
|
2796
2985
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
2797
|
-
|
|
2986
|
+
_context27.next = 2;
|
|
2798
2987
|
break;
|
|
2799
2988
|
}
|
|
2800
|
-
return
|
|
2989
|
+
return _context27.abrupt("return");
|
|
2801
2990
|
case 2:
|
|
2802
2991
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
2803
2992
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
2804
2993
|
});
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2994
|
+
_iterator15 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
2995
|
+
_context27.prev = 4;
|
|
2996
|
+
_iterator15.s();
|
|
2808
2997
|
case 6:
|
|
2809
|
-
if ((
|
|
2810
|
-
|
|
2998
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2999
|
+
_context27.next = 22;
|
|
2811
3000
|
break;
|
|
2812
3001
|
}
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
3002
|
+
_step15$value = _slicedToArray(_step15.value, 2), subscriberId = _step15$value[0], subscriber = _step15$value[1];
|
|
3003
|
+
_context27.prev = 8;
|
|
3004
|
+
_context27.next = 11;
|
|
2816
3005
|
return this.computeBookingQueryResult(subscriber.context);
|
|
2817
3006
|
case 11:
|
|
2818
|
-
result =
|
|
3007
|
+
result = _context27.sent;
|
|
2819
3008
|
subscriber.callback(result);
|
|
2820
3009
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
2821
3010
|
subscriberId: subscriberId
|
|
2822
3011
|
});
|
|
2823
|
-
|
|
3012
|
+
_context27.next = 20;
|
|
2824
3013
|
break;
|
|
2825
3014
|
case 16:
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
errorMessage =
|
|
3015
|
+
_context27.prev = 16;
|
|
3016
|
+
_context27.t0 = _context27["catch"](8);
|
|
3017
|
+
errorMessage = _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0);
|
|
2829
3018
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
2830
3019
|
subscriberId: subscriberId,
|
|
2831
3020
|
error: errorMessage
|
|
2832
3021
|
});
|
|
2833
3022
|
case 20:
|
|
2834
|
-
|
|
3023
|
+
_context27.next = 6;
|
|
2835
3024
|
break;
|
|
2836
3025
|
case 22:
|
|
2837
|
-
|
|
3026
|
+
_context27.next = 27;
|
|
2838
3027
|
break;
|
|
2839
3028
|
case 24:
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
3029
|
+
_context27.prev = 24;
|
|
3030
|
+
_context27.t1 = _context27["catch"](4);
|
|
3031
|
+
_iterator15.e(_context27.t1);
|
|
2843
3032
|
case 27:
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
return
|
|
3033
|
+
_context27.prev = 27;
|
|
3034
|
+
_iterator15.f();
|
|
3035
|
+
return _context27.finish(27);
|
|
2847
3036
|
case 30:
|
|
2848
3037
|
case "end":
|
|
2849
|
-
return
|
|
3038
|
+
return _context27.stop();
|
|
2850
3039
|
}
|
|
2851
|
-
},
|
|
3040
|
+
}, _callee27, this, [[4, 24, 27, 30], [8, 16]]);
|
|
2852
3041
|
}));
|
|
2853
3042
|
function recomputeAndNotifyBookingQuery() {
|
|
2854
3043
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|
|
@@ -2880,11 +3069,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2880
3069
|
var allowedProductIds = new Set();
|
|
2881
3070
|
var allowedCollectionIds = new Set();
|
|
2882
3071
|
var hasProductAll = false;
|
|
2883
|
-
var
|
|
2884
|
-
|
|
3072
|
+
var _iterator16 = _createForOfIteratorHelper(activeMenuList),
|
|
3073
|
+
_step16;
|
|
2885
3074
|
try {
|
|
2886
|
-
for (
|
|
2887
|
-
var menu =
|
|
3075
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
3076
|
+
var menu = _step16.value;
|
|
2888
3077
|
var config = menu.partyroom_package;
|
|
2889
3078
|
if (!config) {
|
|
2890
3079
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
@@ -2944,9 +3133,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
2944
3133
|
|
|
2945
3134
|
// 如果有餐牌允许所有商品,返回所有商品
|
|
2946
3135
|
} catch (err) {
|
|
2947
|
-
|
|
3136
|
+
_iterator16.e(err);
|
|
2948
3137
|
} finally {
|
|
2949
|
-
|
|
3138
|
+
_iterator16.f();
|
|
2950
3139
|
}
|
|
2951
3140
|
if (hasProductAll) {
|
|
2952
3141
|
this.logInfo('filterProductsByMenuConfig: 返回所有商品(product_all)', {
|
|
@@ -3016,7 +3205,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3016
3205
|
metadata: metadata || {}
|
|
3017
3206
|
});
|
|
3018
3207
|
}
|
|
3019
|
-
} catch (
|
|
3208
|
+
} catch (_unused4) {
|
|
3020
3209
|
// 日志记录失败不影响主流程
|
|
3021
3210
|
}
|
|
3022
3211
|
}
|
|
@@ -3037,7 +3226,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3037
3226
|
metadata: metadata || {}
|
|
3038
3227
|
});
|
|
3039
3228
|
}
|
|
3040
|
-
} catch (
|
|
3229
|
+
} catch (_unused5) {
|
|
3041
3230
|
// 日志记录失败不影响主流程
|
|
3042
3231
|
}
|
|
3043
3232
|
}
|
|
@@ -3058,7 +3247,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3058
3247
|
metadata: metadata || {}
|
|
3059
3248
|
});
|
|
3060
3249
|
}
|
|
3061
|
-
} catch (
|
|
3250
|
+
} catch (_unused6) {
|
|
3062
3251
|
// 日志记录失败不影响主流程
|
|
3063
3252
|
}
|
|
3064
3253
|
}
|