@pisell/pisellos 2.2.206 → 2.2.208

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.
@@ -3479,12 +3479,12 @@ var Server = /*#__PURE__*/function () {
3479
3479
  }, {
3480
3480
  key: "getAppData",
3481
3481
  value: function getAppData(key) {
3482
- var _this$app9, _this$app9$getData, _this$app10, _this$app10$getData, _this$app11, _this$app11$getStore, _this$app11$getStore$, _this$app11$getStore$2, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2;
3483
- var getData = (_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getData = _this$app9.getData) === null || _this$app9$getData === void 0 ? void 0 : _this$app9$getData.call(_this$app9);
3482
+ var _this$core$getPlugin, _this$core$getPlugin$, _this$app9, _this$app9$getData, _this$app10, _this$app10$getStore, _this$app10$getStore$, _this$app10$getStore$2, _this$app11, _this$app11$getStore, _this$app11$getStore$, _this$app11$getStore$2, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2;
3483
+ var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
3484
3484
  if (typeof getData === 'function') return getData(key);
3485
- var directValue = (_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getData = _this$app10.getData) === null || _this$app10$getData === void 0 ? void 0 : _this$app10$getData.call(_this$app10, key);
3485
+ var directValue = (_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getData = _this$app9.getData) === null || _this$app9$getData === void 0 ? void 0 : _this$app9$getData.call(_this$app9, key);
3486
3486
  if (directValue !== undefined) return directValue;
3487
- var coreData = ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.models) === null || _this$app11 === void 0 || (_this$app11$getStore = _this$app11.getStore) === null || _this$app11$getStore === void 0 || (_this$app11$getStore$ = (_this$app11$getStore$2 = _this$app11$getStore.call(_this$app11)).getDataByModel) === null || _this$app11$getStore$ === void 0 ? void 0 : _this$app11$getStore$.call(_this$app11$getStore$2, 'core', 'core')) || ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.data) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.store) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 || (_this$app13$getStore$ = _this$app13$getStore$.call(_this$app13$getStore$2, 'core')) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.core);
3487
+ var coreData = ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10 = _this$app10.models) === null || _this$app10 === void 0 || (_this$app10$getStore = _this$app10.getStore) === null || _this$app10$getStore === void 0 || (_this$app10$getStore$ = (_this$app10$getStore$2 = _this$app10$getStore.call(_this$app10)).getDataByModel) === null || _this$app10$getStore$ === void 0 ? void 0 : _this$app10$getStore$.call(_this$app10$getStore$2, 'core', 'core')) || ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.data) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.store) === null || _this$app11 === void 0 || (_this$app11$getStore = _this$app11.getStore) === null || _this$app11$getStore === void 0 || (_this$app11$getStore$ = (_this$app11$getStore$2 = _this$app11$getStore.call(_this$app11)).getDataByModel) === null || _this$app11$getStore$ === void 0 ? void 0 : _this$app11$getStore$.call(_this$app11$getStore$2, 'core', 'core')) || ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.data) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.store) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 || (_this$app12$getStore$ = _this$app12$getStore$.call(_this$app12$getStore$2, 'core')) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.core);
3488
3488
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
3489
3489
  }
3490
3490
  }, {
@@ -3492,6 +3492,7 @@ var Server = /*#__PURE__*/function () {
3492
3492
  value: function getSmallTicketShopInfo() {
3493
3493
  var _shopInfo$is_price_in;
3494
3494
  var shopInfo = this.getAppData('shop_info') || {};
3495
+ debugger;
3495
3496
  return _objectSpread(_objectSpread({}, shopInfo), {}, {
3496
3497
  currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
3497
3498
  currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
@@ -3533,10 +3534,41 @@ var Server = /*#__PURE__*/function () {
3533
3534
  };
3534
3535
  }
3535
3536
  }, {
3536
- key: "resolveCheckoutTaskDeviceId",
3537
- value: function resolveCheckoutTaskDeviceId(_data) {
3538
- return this.getAppData('device_id') || 0;
3539
- }
3537
+ key: "getShortNumberOrDeviceId",
3538
+ value: function () {
3539
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3540
+ var getAsyncIotDeviceInfo, res;
3541
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3542
+ while (1) switch (_context37.prev = _context37.next) {
3543
+ case 0:
3544
+ debugger;
3545
+ getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
3546
+ if (!getAsyncIotDeviceInfo) {
3547
+ _context37.next = 8;
3548
+ break;
3549
+ }
3550
+ _context37.next = 5;
3551
+ return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
3552
+ case 5:
3553
+ res = _context37.sent;
3554
+ if (!res.short_number) {
3555
+ _context37.next = 8;
3556
+ break;
3557
+ }
3558
+ return _context37.abrupt("return", res.short_number);
3559
+ case 8:
3560
+ return _context37.abrupt("return", this.getAppData('device_id') || 0);
3561
+ case 9:
3562
+ case "end":
3563
+ return _context37.stop();
3564
+ }
3565
+ }, _callee37, this);
3566
+ }));
3567
+ function getShortNumberOrDeviceId() {
3568
+ return _getShortNumberOrDeviceId.apply(this, arguments);
3569
+ }
3570
+ return getShortNumberOrDeviceId;
3571
+ }()
3540
3572
  }, {
3541
3573
  key: "buildCheckoutTaskIdempotencyKey",
3542
3574
  value: function buildCheckoutTaskIdempotencyKey(data) {
@@ -3547,79 +3579,79 @@ var Server = /*#__PURE__*/function () {
3547
3579
  }, {
3548
3580
  key: "ensureCheckoutOrderNumbers",
3549
3581
  value: function () {
3550
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(data, title) {
3582
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(data, title) {
3551
3583
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
3552
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3553
- while (1) switch (_context37.prev = _context37.next) {
3584
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3585
+ while (1) switch (_context38.prev = _context38.next) {
3554
3586
  case 0:
3555
3587
  if (!(!data || _typeof(data) !== 'object')) {
3556
- _context37.next = 2;
3588
+ _context38.next = 2;
3557
3589
  break;
3558
3590
  }
3559
- return _context37.abrupt("return", data);
3591
+ return _context38.abrupt("return", data);
3560
3592
  case 2:
3561
3593
  next = _objectSpread({}, data);
3562
3594
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
3563
3595
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
3564
3596
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
3565
- _context37.next = 7;
3597
+ _context38.next = 7;
3566
3598
  break;
3567
3599
  }
3568
- return _context37.abrupt("return", next);
3600
+ return _context38.abrupt("return", next);
3569
3601
  case 7:
3570
3602
  idGenerator = this.getIdGeneratorPlugin();
3571
3603
  if (idGenerator) {
3572
- _context37.next = 11;
3604
+ _context38.next = 11;
3573
3605
  break;
3574
3606
  }
3575
3607
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
3576
3608
  needsShopOrderNumber: needsShopOrderNumber,
3577
3609
  needsShopFullOrderNumber: needsShopFullOrderNumber
3578
3610
  });
3579
- return _context37.abrupt("return", next);
3611
+ return _context38.abrupt("return", next);
3580
3612
  case 11:
3581
- _context37.prev = 11;
3613
+ _context38.prev = 11;
3582
3614
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
3583
- _context37.next = 16;
3615
+ _context38.next = 16;
3584
3616
  break;
3585
3617
  }
3586
- _context37.next = 15;
3618
+ _context38.next = 15;
3587
3619
  return idGenerator.generateShopOrderNumber({
3588
3620
  biz: next.business_code || 'ticket'
3589
3621
  });
3590
3622
  case 15:
3591
- next.shop_order_number = _context37.sent;
3623
+ next.shop_order_number = _context38.sent;
3592
3624
  case 16:
3593
3625
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
3594
- _context37.next = 20;
3626
+ _context38.next = 20;
3595
3627
  break;
3596
3628
  }
3597
- _context37.next = 19;
3629
+ _context38.next = 19;
3598
3630
  return idGenerator.generateReceiptId({
3599
3631
  biz: next.business_code || 'ticket'
3600
3632
  });
3601
3633
  case 19:
3602
- next.shop_full_order_number = _context37.sent;
3634
+ next.shop_full_order_number = _context38.sent;
3603
3635
  case 20:
3604
3636
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
3605
3637
  shop_order_number: next.shop_order_number,
3606
3638
  shop_full_order_number: next.shop_full_order_number
3607
3639
  });
3608
- _context37.next = 26;
3640
+ _context38.next = 26;
3609
3641
  break;
3610
3642
  case 23:
3611
- _context37.prev = 23;
3612
- _context37.t0 = _context37["catch"](11);
3643
+ _context38.prev = 23;
3644
+ _context38.t0 = _context38["catch"](11);
3613
3645
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
3614
- error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3646
+ error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
3615
3647
  });
3616
3648
  case 26:
3617
- return _context37.abrupt("return", next);
3649
+ return _context38.abrupt("return", next);
3618
3650
  case 27:
3619
3651
  case "end":
3620
- return _context37.stop();
3652
+ return _context38.stop();
3621
3653
  }
3622
- }, _callee37, this, [[11, 23]]);
3654
+ }, _callee38, this, [[11, 23]]);
3623
3655
  }));
3624
3656
  function ensureCheckoutOrderNumbers(_x40, _x41) {
3625
3657
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
@@ -3629,24 +3661,27 @@ var Server = /*#__PURE__*/function () {
3629
3661
  }, {
3630
3662
  key: "dispatchCheckoutSyncTask",
3631
3663
  value: function () {
3632
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3664
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3633
3665
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, result;
3634
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3635
- while (1) switch (_context38.prev = _context38.next) {
3666
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3667
+ while (1) switch (_context39.prev = _context39.next) {
3636
3668
  case 0:
3637
3669
  this.registerDeviceTaskActions();
3638
3670
  deviceTask = this.getDeviceTaskPlugin();
3639
- debugDeviceId = this.resolveCheckoutTaskDeviceId(params.data);
3671
+ _context39.next = 4;
3672
+ return this.getShortNumberOrDeviceId();
3673
+ case 4:
3674
+ debugDeviceId = _context39.sent;
3640
3675
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
3641
3676
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3642
- _context38.next = 7;
3677
+ _context39.next = 9;
3643
3678
  break;
3644
3679
  }
3645
3680
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
3646
- return _context38.abrupt("return");
3647
- case 7:
3648
- _context38.prev = 7;
3649
- _context38.next = 10;
3681
+ return _context39.abrupt("return");
3682
+ case 9:
3683
+ _context39.prev = 9;
3684
+ _context39.next = 12;
3650
3685
  return deviceTask.dispatch({
3651
3686
  action: 'sync_sales',
3652
3687
  device_id: debugDeviceId,
@@ -3662,26 +3697,26 @@ var Server = /*#__PURE__*/function () {
3662
3697
  source_type: 'order',
3663
3698
  source_id: ((_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.order_id) || ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.external_sale_number) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.shop_order_number)
3664
3699
  });
3665
- case 10:
3666
- result = _context38.sent;
3700
+ case 12:
3701
+ result = _context39.sent;
3667
3702
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
3668
3703
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
3669
3704
  status: result === null || result === void 0 ? void 0 : result.status,
3670
3705
  reused: result === null || result === void 0 ? void 0 : result.reused
3671
3706
  });
3672
- _context38.next = 17;
3707
+ _context39.next = 19;
3673
3708
  break;
3674
- case 14:
3675
- _context38.prev = 14;
3676
- _context38.t0 = _context38["catch"](7);
3709
+ case 16:
3710
+ _context39.prev = 16;
3711
+ _context39.t0 = _context39["catch"](9);
3677
3712
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
3678
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
3713
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
3679
3714
  });
3680
- case 17:
3715
+ case 19:
3681
3716
  case "end":
3682
- return _context38.stop();
3717
+ return _context39.stop();
3683
3718
  }
3684
- }, _callee38, this, [[7, 14]]);
3719
+ }, _callee39, this, [[9, 16]]);
3685
3720
  }));
3686
3721
  function dispatchCheckoutSyncTask(_x42) {
3687
3722
  return _dispatchCheckoutSyncTask.apply(this, arguments);
@@ -3691,25 +3726,29 @@ var Server = /*#__PURE__*/function () {
3691
3726
  }, {
3692
3727
  key: "dispatchPrintOtherReceiptTask",
3693
3728
  value: function () {
3694
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3695
- var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity;
3696
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3697
- while (1) switch (_context39.prev = _context39.next) {
3729
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3730
+ var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
3731
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3732
+ while (1) switch (_context40.prev = _context40.next) {
3698
3733
  case 0:
3699
3734
  deviceTask = this.getDeviceTaskPlugin();
3700
3735
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3701
- _context39.next = 4;
3736
+ _context40.next = 4;
3702
3737
  break;
3703
3738
  }
3704
3739
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
3705
- return _context39.abrupt("return");
3740
+ return _context40.abrupt("return");
3706
3741
  case 4:
3707
- _context39.prev = 4;
3742
+ _context40.prev = 4;
3708
3743
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
3709
- _context39.next = 8;
3744
+ _context40.next = 8;
3745
+ return this.getShortNumberOrDeviceId();
3746
+ case 8:
3747
+ deviceId = _context40.sent;
3748
+ _context40.next = 11;
3710
3749
  return deviceTask.dispatch({
3711
3750
  action: 'print_all',
3712
- device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : this.resolveCheckoutTaskDeviceId(params.checkoutData),
3751
+ device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
3713
3752
  payload: {
3714
3753
  type: params.receiptOnly ? '0' : '99',
3715
3754
  data: params.receiptOnly ? {
@@ -3730,20 +3769,20 @@ var Server = /*#__PURE__*/function () {
3730
3769
  source_type: 'order',
3731
3770
  source_id: printIdentity
3732
3771
  });
3733
- case 8:
3734
- _context39.next = 13;
3772
+ case 11:
3773
+ _context40.next = 16;
3735
3774
  break;
3736
- case 10:
3737
- _context39.prev = 10;
3738
- _context39.t0 = _context39["catch"](4);
3775
+ case 13:
3776
+ _context40.prev = 13;
3777
+ _context40.t0 = _context40["catch"](4);
3739
3778
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
3740
- error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
3779
+ error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3741
3780
  });
3742
- case 13:
3781
+ case 16:
3743
3782
  case "end":
3744
- return _context39.stop();
3783
+ return _context40.stop();
3745
3784
  }
3746
- }, _callee39, this, [[4, 10]]);
3785
+ }, _callee40, this, [[4, 13]]);
3747
3786
  }));
3748
3787
  function dispatchPrintOtherReceiptTask(_x43) {
3749
3788
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
@@ -3765,37 +3804,37 @@ var Server = /*#__PURE__*/function () {
3765
3804
  }, {
3766
3805
  key: "dispatchLocalReceiptPrint",
3767
3806
  value: function () {
3768
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3807
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3769
3808
  var _payment_info;
3770
3809
  var printableOrder;
3771
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3772
- while (1) switch (_context40.prev = _context40.next) {
3810
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3811
+ while (1) switch (_context41.prev = _context41.next) {
3773
3812
  case 0:
3774
3813
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
3775
- _context40.next = 2;
3814
+ _context41.next = 2;
3776
3815
  break;
3777
3816
  }
3778
- return _context40.abrupt("return", {
3817
+ return _context41.abrupt("return", {
3779
3818
  printed: false,
3780
3819
  order: params.order
3781
3820
  });
3782
3821
  case 2:
3783
- _context40.next = 4;
3822
+ _context41.next = 4;
3784
3823
  return this.withLocalSmallTicketData(params.order, {
3785
3824
  requireFullyPaid: params.requireFullyPaid
3786
3825
  });
3787
3826
  case 4:
3788
- printableOrder = _context40.sent;
3827
+ printableOrder = _context41.sent;
3789
3828
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
3790
- _context40.next = 7;
3829
+ _context41.next = 7;
3791
3830
  break;
3792
3831
  }
3793
- return _context40.abrupt("return", {
3832
+ return _context41.abrupt("return", {
3794
3833
  printed: false,
3795
3834
  order: printableOrder
3796
3835
  });
3797
3836
  case 7:
3798
- _context40.next = 9;
3837
+ _context41.next = 9;
3799
3838
  return this.dispatchPrintOtherReceiptTask({
3800
3839
  checkoutData: params.checkoutData,
3801
3840
  syncedOrder: printableOrder,
@@ -3803,15 +3842,15 @@ var Server = /*#__PURE__*/function () {
3803
3842
  receiptOnly: true
3804
3843
  });
3805
3844
  case 9:
3806
- return _context40.abrupt("return", {
3845
+ return _context41.abrupt("return", {
3807
3846
  printed: true,
3808
3847
  order: printableOrder
3809
3848
  });
3810
3849
  case 10:
3811
3850
  case "end":
3812
- return _context40.stop();
3851
+ return _context41.stop();
3813
3852
  }
3814
- }, _callee40, this);
3853
+ }, _callee41, this);
3815
3854
  }));
3816
3855
  function dispatchLocalReceiptPrint(_x44) {
3817
3856
  return _dispatchLocalReceiptPrint.apply(this, arguments);
@@ -3821,10 +3860,10 @@ var Server = /*#__PURE__*/function () {
3821
3860
  }, {
3822
3861
  key: "handleOrderCheckoutSubmit",
3823
3862
  value: function () {
3824
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3863
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3825
3864
  var backendPath, data, title, checkoutData, pendingResult, pendingOrder;
3826
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3827
- while (1) switch (_context41.prev = _context41.next) {
3865
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3866
+ while (1) switch (_context42.prev = _context42.next) {
3828
3867
  case 0:
3829
3868
  backendPath = params.backendPath, data = params.data, title = params.title;
3830
3869
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -3833,11 +3872,11 @@ var Server = /*#__PURE__*/function () {
3833
3872
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
3834
3873
  order_number: data === null || data === void 0 ? void 0 : data.order_number
3835
3874
  });
3836
- _context41.next = 4;
3875
+ _context42.next = 4;
3837
3876
  return this.ensureCheckoutOrderNumbers(data, title);
3838
3877
  case 4:
3839
- checkoutData = _context41.sent;
3840
- _context41.next = 7;
3878
+ checkoutData = _context42.sent;
3879
+ _context42.next = 7;
3841
3880
  return this.handlePendingSyncCheckoutOrder({
3842
3881
  backendPath: backendPath,
3843
3882
  data: checkoutData,
@@ -3845,17 +3884,17 @@ var Server = /*#__PURE__*/function () {
3845
3884
  reason: 'checkout 已转入设备任务同步'
3846
3885
  });
3847
3886
  case 7:
3848
- pendingResult = _context41.sent;
3887
+ pendingResult = _context42.sent;
3849
3888
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
3850
- _context41.next = 15;
3889
+ _context42.next = 15;
3851
3890
  break;
3852
3891
  }
3853
3892
  pendingOrder = pendingResult.data;
3854
3893
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder))) {
3855
- _context41.next = 13;
3894
+ _context42.next = 13;
3856
3895
  break;
3857
3896
  }
3858
- _context41.next = 13;
3897
+ _context42.next = 13;
3859
3898
  return this.dispatchLocalReceiptPrint({
3860
3899
  checkoutData: checkoutData,
3861
3900
  order: pendingOrder,
@@ -3863,19 +3902,19 @@ var Server = /*#__PURE__*/function () {
3863
3902
  requireFullyPaid: true
3864
3903
  });
3865
3904
  case 13:
3866
- _context41.next = 15;
3905
+ _context42.next = 15;
3867
3906
  return this.dispatchCheckoutSyncTask({
3868
3907
  backendPath: backendPath,
3869
3908
  data: checkoutData,
3870
3909
  title: title
3871
3910
  });
3872
3911
  case 15:
3873
- return _context41.abrupt("return", pendingResult);
3912
+ return _context42.abrupt("return", pendingResult);
3874
3913
  case 16:
3875
3914
  case "end":
3876
- return _context41.stop();
3915
+ return _context42.stop();
3877
3916
  }
3878
- }, _callee41, this);
3917
+ }, _callee42, this);
3879
3918
  }));
3880
3919
  function handleOrderCheckoutSubmit(_x45) {
3881
3920
  return _handleOrderCheckoutSubmit.apply(this, arguments);
@@ -3885,25 +3924,25 @@ var Server = /*#__PURE__*/function () {
3885
3924
  }, {
3886
3925
  key: "handlePendingSyncCheckoutOrder",
3887
3926
  value: function () {
3888
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3927
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3889
3928
  var backendPath, data, title, reason, pendingOrder, errorMessage;
3890
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3891
- while (1) switch (_context42.prev = _context42.next) {
3929
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3930
+ while (1) switch (_context43.prev = _context43.next) {
3892
3931
  case 0:
3893
3932
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
3894
- _context42.next = 3;
3933
+ _context43.next = 3;
3895
3934
  return this.buildPendingSyncCheckoutOrder(data);
3896
3935
  case 3:
3897
- pendingOrder = _context42.sent;
3936
+ pendingOrder = _context43.sent;
3898
3937
  if (pendingOrder) {
3899
- _context42.next = 7;
3938
+ _context43.next = 7;
3900
3939
  break;
3901
3940
  }
3902
3941
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
3903
3942
  backendPath: backendPath,
3904
3943
  reason: reason
3905
3944
  });
3906
- return _context42.abrupt("return", {
3945
+ return _context43.abrupt("return", {
3907
3946
  code: 500,
3908
3947
  status: false,
3909
3948
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -3911,22 +3950,22 @@ var Server = /*#__PURE__*/function () {
3911
3950
  });
3912
3951
  case 7:
3913
3952
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
3914
- _context42.next = 10;
3953
+ _context43.next = 10;
3915
3954
  break;
3916
3955
  }
3917
3956
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
3918
3957
  backendPath: backendPath,
3919
3958
  reason: reason
3920
3959
  });
3921
- return _context42.abrupt("return", {
3960
+ return _context43.abrupt("return", {
3922
3961
  code: 500,
3923
3962
  status: false,
3924
3963
  message: 'Order 模块不支持本地待同步写入',
3925
3964
  data: null
3926
3965
  });
3927
3966
  case 10:
3928
- _context42.prev = 10;
3929
- _context42.next = 13;
3967
+ _context43.prev = 10;
3968
+ _context43.next = 13;
3930
3969
  return this.order.upsertPendingSyncOrders([pendingOrder]);
3931
3970
  case 13:
3932
3971
  this.logWarning("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -3936,22 +3975,22 @@ var Server = /*#__PURE__*/function () {
3936
3975
  external_sale_number: pendingOrder.external_sale_number,
3937
3976
  order_number: pendingOrder.order_number
3938
3977
  });
3939
- return _context42.abrupt("return", {
3978
+ return _context43.abrupt("return", {
3940
3979
  code: 200,
3941
3980
  status: true,
3942
3981
  message: '',
3943
3982
  data: pendingOrder
3944
3983
  });
3945
3984
  case 17:
3946
- _context42.prev = 17;
3947
- _context42.t0 = _context42["catch"](10);
3948
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3985
+ _context43.prev = 17;
3986
+ _context43.t0 = _context43["catch"](10);
3987
+ errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3949
3988
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
3950
3989
  backendPath: backendPath,
3951
3990
  reason: reason,
3952
3991
  error: errorMessage
3953
3992
  });
3954
- return _context42.abrupt("return", {
3993
+ return _context43.abrupt("return", {
3955
3994
  code: 500,
3956
3995
  status: false,
3957
3996
  message: errorMessage,
@@ -3959,9 +3998,9 @@ var Server = /*#__PURE__*/function () {
3959
3998
  });
3960
3999
  case 22:
3961
4000
  case "end":
3962
- return _context42.stop();
4001
+ return _context43.stop();
3963
4002
  }
3964
- }, _callee42, this, [[10, 17]]);
4003
+ }, _callee43, this, [[10, 17]]);
3965
4004
  }));
3966
4005
  function handlePendingSyncCheckoutOrder(_x46) {
3967
4006
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
@@ -3971,34 +4010,34 @@ var Server = /*#__PURE__*/function () {
3971
4010
  }, {
3972
4011
  key: "buildPendingSyncCheckoutOrder",
3973
4012
  value: function () {
3974
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
4013
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data) {
3975
4014
  var hasStorageKey;
3976
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3977
- while (1) switch (_context43.prev = _context43.next) {
4015
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4016
+ while (1) switch (_context44.prev = _context44.next) {
3978
4017
  case 0:
3979
4018
  if (!(!data || _typeof(data) !== 'object')) {
3980
- _context43.next = 2;
4019
+ _context44.next = 2;
3981
4020
  break;
3982
4021
  }
3983
- return _context43.abrupt("return", null);
4022
+ return _context44.abrupt("return", null);
3984
4023
  case 2:
3985
4024
  hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
3986
4025
  if (hasStorageKey) {
3987
- _context43.next = 5;
4026
+ _context44.next = 5;
3988
4027
  break;
3989
4028
  }
3990
- return _context43.abrupt("return", null);
4029
+ return _context44.abrupt("return", null);
3991
4030
  case 5:
3992
- return _context43.abrupt("return", this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, data), {}, {
4031
+ return _context44.abrupt("return", this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, data), {}, {
3993
4032
  need_sync: 1
3994
4033
  }), {
3995
4034
  requireFullyPaid: true
3996
4035
  }));
3997
4036
  case 6:
3998
4037
  case "end":
3999
- return _context43.stop();
4038
+ return _context44.stop();
4000
4039
  }
4001
- }, _callee43, this);
4040
+ }, _callee44, this);
4002
4041
  }));
4003
4042
  function buildPendingSyncCheckoutOrder(_x47) {
4004
4043
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
@@ -4068,12 +4107,12 @@ var Server = /*#__PURE__*/function () {
4068
4107
  }, {
4069
4108
  key: "buildSmallTicketProductMap",
4070
4109
  value: function () {
4071
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order) {
4110
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order) {
4072
4111
  var _this$products,
4073
4112
  _this11 = this;
4074
4113
  var products, productIds, entries;
4075
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4076
- while (1) switch (_context45.prev = _context45.next) {
4114
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4115
+ while (1) switch (_context46.prev = _context46.next) {
4077
4116
  case 0:
4078
4117
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
4079
4118
  productIds = Array.from(new Set(products.map(function (product) {
@@ -4083,45 +4122,45 @@ var Server = /*#__PURE__*/function () {
4083
4122
  return id !== undefined && id !== null && id !== '';
4084
4123
  })));
4085
4124
  if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
4086
- _context45.next = 4;
4125
+ _context46.next = 4;
4087
4126
  break;
4088
4127
  }
4089
- return _context45.abrupt("return", {});
4128
+ return _context46.abrupt("return", {});
4090
4129
  case 4:
4091
- _context45.next = 6;
4130
+ _context46.next = 6;
4092
4131
  return Promise.all(productIds.map( /*#__PURE__*/function () {
4093
- var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(id) {
4132
+ var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(id) {
4094
4133
  var _this11$products, _this11$products$getP, product;
4095
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4096
- while (1) switch (_context44.prev = _context44.next) {
4134
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4135
+ while (1) switch (_context45.prev = _context45.next) {
4097
4136
  case 0:
4098
- _context44.prev = 0;
4099
- _context44.next = 3;
4137
+ _context45.prev = 0;
4138
+ _context45.next = 3;
4100
4139
  return (_this11$products = _this11.products) === null || _this11$products === void 0 || (_this11$products$getP = _this11$products.getProductById) === null || _this11$products$getP === void 0 ? void 0 : _this11$products$getP.call(_this11$products, Number(id));
4101
4140
  case 3:
4102
- product = _context44.sent;
4103
- return _context44.abrupt("return", product ? [String(id), product] : null);
4141
+ product = _context45.sent;
4142
+ return _context45.abrupt("return", product ? [String(id), product] : null);
4104
4143
  case 7:
4105
- _context44.prev = 7;
4106
- _context44.t0 = _context44["catch"](0);
4144
+ _context45.prev = 7;
4145
+ _context45.t0 = _context45["catch"](0);
4107
4146
  _this11.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
4108
4147
  product_id: id,
4109
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4148
+ error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4110
4149
  });
4111
- return _context44.abrupt("return", null);
4150
+ return _context45.abrupt("return", null);
4112
4151
  case 11:
4113
4152
  case "end":
4114
- return _context44.stop();
4153
+ return _context45.stop();
4115
4154
  }
4116
- }, _callee44, null, [[0, 7]]);
4155
+ }, _callee45, null, [[0, 7]]);
4117
4156
  }));
4118
4157
  return function (_x49) {
4119
4158
  return _ref53.apply(this, arguments);
4120
4159
  };
4121
4160
  }()));
4122
4161
  case 6:
4123
- entries = _context45.sent;
4124
- return _context45.abrupt("return", entries.reduce(function (map, entry) {
4162
+ entries = _context46.sent;
4163
+ return _context46.abrupt("return", entries.reduce(function (map, entry) {
4125
4164
  if (!entry) return map;
4126
4165
  var _entry = _slicedToArray(entry, 2),
4127
4166
  id = _entry[0],
@@ -4131,9 +4170,9 @@ var Server = /*#__PURE__*/function () {
4131
4170
  }, {}));
4132
4171
  case 8:
4133
4172
  case "end":
4134
- return _context45.stop();
4173
+ return _context46.stop();
4135
4174
  }
4136
- }, _callee45, this);
4175
+ }, _callee46, this);
4137
4176
  }));
4138
4177
  function buildSmallTicketProductMap(_x48) {
4139
4178
  return _buildSmallTicketProductMap.apply(this, arguments);
@@ -4143,50 +4182,50 @@ var Server = /*#__PURE__*/function () {
4143
4182
  }, {
4144
4183
  key: "withLocalSmallTicketData",
4145
4184
  value: function () {
4146
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order, options) {
4185
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(order, options) {
4147
4186
  var productMap, smallTicketData;
4148
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4149
- while (1) switch (_context46.prev = _context46.next) {
4187
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4188
+ while (1) switch (_context47.prev = _context47.next) {
4150
4189
  case 0:
4151
4190
  if (this.shouldBuildSmallTicketData(order)) {
4152
- _context46.next = 2;
4191
+ _context47.next = 2;
4153
4192
  break;
4154
4193
  }
4155
- return _context46.abrupt("return", order);
4194
+ return _context47.abrupt("return", order);
4156
4195
  case 2:
4157
4196
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
4158
- _context46.next = 4;
4197
+ _context47.next = 4;
4159
4198
  break;
4160
4199
  }
4161
- return _context46.abrupt("return", order);
4200
+ return _context47.abrupt("return", order);
4162
4201
  case 4:
4163
- _context46.prev = 4;
4164
- _context46.next = 7;
4202
+ _context47.prev = 4;
4203
+ _context47.next = 7;
4165
4204
  return this.buildSmallTicketProductMap(order);
4166
4205
  case 7:
4167
- productMap = _context46.sent;
4206
+ productMap = _context47.sent;
4168
4207
  smallTicketData = buildSmallTicketData({
4169
4208
  order: order,
4170
4209
  shopInfo: this.getSmallTicketShopInfo(),
4171
4210
  productMap: productMap
4172
4211
  });
4173
- return _context46.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4212
+ return _context47.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4174
4213
  payment_info: _objectSpread(_objectSpread({}, order.payment_info || {}), {}, {
4175
4214
  small_ticket_data: smallTicketData
4176
4215
  })
4177
4216
  }));
4178
4217
  case 12:
4179
- _context46.prev = 12;
4180
- _context46.t0 = _context46["catch"](4);
4218
+ _context47.prev = 12;
4219
+ _context47.t0 = _context47["catch"](4);
4181
4220
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
4182
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4221
+ error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4183
4222
  });
4184
- return _context46.abrupt("return", order);
4223
+ return _context47.abrupt("return", order);
4185
4224
  case 16:
4186
4225
  case "end":
4187
- return _context46.stop();
4226
+ return _context47.stop();
4188
4227
  }
4189
- }, _callee46, this, [[4, 12]]);
4228
+ }, _callee47, this, [[4, 12]]);
4190
4229
  }));
4191
4230
  function withLocalSmallTicketData(_x50, _x51) {
4192
4231
  return _withLocalSmallTicketData.apply(this, arguments);
@@ -4250,34 +4289,34 @@ var Server = /*#__PURE__*/function () {
4250
4289
  }, {
4251
4290
  key: "handleUpdateLocalOrdersBatch",
4252
4291
  value: (function () {
4253
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(orderIds) {
4254
- var _this$app14;
4292
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(orderIds) {
4293
+ var _this$app13;
4255
4294
  var existedBefore, _iterator12, _step12, id, fetched, message, fetchedMap, _iterator13, _step13, order, oid, freshOrders, succeedIds, failed, _iterator14, _step14, _id, fresh, _message2, overwritten, inserted;
4256
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4257
- while (1) switch (_context47.prev = _context47.next) {
4295
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4296
+ while (1) switch (_context48.prev = _context48.next) {
4258
4297
  case 0:
4259
4298
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
4260
4299
  count: orderIds.length,
4261
4300
  orderIds: orderIds
4262
4301
  });
4263
4302
  if (this.order) {
4264
- _context47.next = 4;
4303
+ _context48.next = 4;
4265
4304
  break;
4266
4305
  }
4267
4306
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
4268
- return _context47.abrupt("return", {
4307
+ return _context48.abrupt("return", {
4269
4308
  code: 500,
4270
4309
  status: false,
4271
4310
  message: 'Order 模块未注册',
4272
4311
  data: null
4273
4312
  });
4274
4313
  case 4:
4275
- if ((_this$app14 = this.app) !== null && _this$app14 !== void 0 && _this$app14.request) {
4276
- _context47.next = 7;
4314
+ if ((_this$app13 = this.app) !== null && _this$app13 !== void 0 && _this$app13.request) {
4315
+ _context48.next = 7;
4277
4316
  break;
4278
4317
  }
4279
4318
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
4280
- return _context47.abrupt("return", {
4319
+ return _context48.abrupt("return", {
4281
4320
  code: 500,
4282
4321
  status: false,
4283
4322
  message: 'app.request 不可用',
@@ -4300,21 +4339,21 @@ var Server = /*#__PURE__*/function () {
4300
4339
  _iterator12.f();
4301
4340
  }
4302
4341
  fetched = [];
4303
- _context47.prev = 11;
4304
- _context47.next = 14;
4342
+ _context48.prev = 11;
4343
+ _context48.next = 14;
4305
4344
  return this.order.fetchOrdersByHttp(orderIds);
4306
4345
  case 14:
4307
- fetched = _context47.sent;
4308
- _context47.next = 22;
4346
+ fetched = _context48.sent;
4347
+ _context48.next = 22;
4309
4348
  break;
4310
4349
  case 17:
4311
- _context47.prev = 17;
4312
- _context47.t0 = _context47["catch"](11);
4313
- message = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4350
+ _context48.prev = 17;
4351
+ _context48.t0 = _context48["catch"](11);
4352
+ message = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4314
4353
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
4315
4354
  message: message
4316
4355
  });
4317
- return _context47.abrupt("return", {
4356
+ return _context48.abrupt("return", {
4318
4357
  code: 500,
4319
4358
  status: false,
4320
4359
  message: message,
@@ -4324,36 +4363,36 @@ var Server = /*#__PURE__*/function () {
4324
4363
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
4325
4364
  fetchedMap = new Map();
4326
4365
  _iterator13 = _createForOfIteratorHelper(fetched);
4327
- _context47.prev = 24;
4366
+ _context48.prev = 24;
4328
4367
  _iterator13.s();
4329
4368
  case 26:
4330
4369
  if ((_step13 = _iterator13.n()).done) {
4331
- _context47.next = 34;
4370
+ _context48.next = 34;
4332
4371
  break;
4333
4372
  }
4334
4373
  order = _step13.value;
4335
4374
  oid = order === null || order === void 0 ? void 0 : order.order_id;
4336
4375
  if (!(oid === undefined || oid === null)) {
4337
- _context47.next = 31;
4376
+ _context48.next = 31;
4338
4377
  break;
4339
4378
  }
4340
- return _context47.abrupt("continue", 32);
4379
+ return _context48.abrupt("continue", 32);
4341
4380
  case 31:
4342
4381
  fetchedMap.set(String(oid), order);
4343
4382
  case 32:
4344
- _context47.next = 26;
4383
+ _context48.next = 26;
4345
4384
  break;
4346
4385
  case 34:
4347
- _context47.next = 39;
4386
+ _context48.next = 39;
4348
4387
  break;
4349
4388
  case 36:
4350
- _context47.prev = 36;
4351
- _context47.t1 = _context47["catch"](24);
4352
- _iterator13.e(_context47.t1);
4389
+ _context48.prev = 36;
4390
+ _context48.t1 = _context48["catch"](24);
4391
+ _iterator13.e(_context48.t1);
4353
4392
  case 39:
4354
- _context47.prev = 39;
4393
+ _context48.prev = 39;
4355
4394
  _iterator13.f();
4356
- return _context47.finish(39);
4395
+ return _context48.finish(39);
4357
4396
  case 42:
4358
4397
  freshOrders = [];
4359
4398
  succeedIds = [];
@@ -4379,23 +4418,23 @@ var Server = /*#__PURE__*/function () {
4379
4418
  _iterator14.f();
4380
4419
  }
4381
4420
  if (!(freshOrders.length > 0)) {
4382
- _context47.next = 58;
4421
+ _context48.next = 58;
4383
4422
  break;
4384
4423
  }
4385
- _context47.prev = 48;
4386
- _context47.next = 51;
4424
+ _context48.prev = 48;
4425
+ _context48.next = 51;
4387
4426
  return this.order.upsertOrdersFromRemote(freshOrders);
4388
4427
  case 51:
4389
- _context47.next = 58;
4428
+ _context48.next = 58;
4390
4429
  break;
4391
4430
  case 53:
4392
- _context47.prev = 53;
4393
- _context47.t2 = _context47["catch"](48);
4394
- _message2 = _context47.t2 instanceof Error ? _context47.t2.message : String(_context47.t2);
4431
+ _context48.prev = 53;
4432
+ _context48.t2 = _context48["catch"](48);
4433
+ _message2 = _context48.t2 instanceof Error ? _context48.t2.message : String(_context48.t2);
4395
4434
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
4396
4435
  message: _message2
4397
4436
  });
4398
- return _context47.abrupt("return", {
4437
+ return _context48.abrupt("return", {
4399
4438
  code: 500,
4400
4439
  status: false,
4401
4440
  message: _message2,
@@ -4414,7 +4453,7 @@ var Server = /*#__PURE__*/function () {
4414
4453
  insertedCount: inserted.length,
4415
4454
  failedCount: failed.length
4416
4455
  });
4417
- return _context47.abrupt("return", {
4456
+ return _context48.abrupt("return", {
4418
4457
  code: 200,
4419
4458
  status: true,
4420
4459
  message: '',
@@ -4426,9 +4465,9 @@ var Server = /*#__PURE__*/function () {
4426
4465
  });
4427
4466
  case 62:
4428
4467
  case "end":
4429
- return _context47.stop();
4468
+ return _context48.stop();
4430
4469
  }
4431
- }, _callee47, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4470
+ }, _callee48, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4432
4471
  }));
4433
4472
  function handleUpdateLocalOrdersBatch(_x52) {
4434
4473
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
@@ -4667,16 +4706,16 @@ var Server = /*#__PURE__*/function () {
4667
4706
  }, {
4668
4707
  key: "recomputeAndNotifyFloorPlanQuery",
4669
4708
  value: (function () {
4670
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4709
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4671
4710
  var _iterator16, _step16, _step16$value, subscriberId, sub, result, errorMessage;
4672
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4673
- while (1) switch (_context48.prev = _context48.next) {
4711
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4712
+ while (1) switch (_context49.prev = _context49.next) {
4674
4713
  case 0:
4675
4714
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
4676
- _context48.next = 2;
4715
+ _context49.next = 2;
4677
4716
  break;
4678
4717
  }
4679
- return _context48.abrupt("return");
4718
+ return _context49.abrupt("return");
4680
4719
  case 2:
4681
4720
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
4682
4721
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -4706,9 +4745,9 @@ var Server = /*#__PURE__*/function () {
4706
4745
  }
4707
4746
  case 5:
4708
4747
  case "end":
4709
- return _context48.stop();
4748
+ return _context49.stop();
4710
4749
  }
4711
- }, _callee48, this);
4750
+ }, _callee49, this);
4712
4751
  }));
4713
4752
  function recomputeAndNotifyFloorPlanQuery() {
4714
4753
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -4738,21 +4777,21 @@ var Server = /*#__PURE__*/function () {
4738
4777
  * filter 逻辑暂为 mock,仅记录参数
4739
4778
  */
4740
4779
  function () {
4741
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(data) {
4780
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data) {
4742
4781
  var rawList, result;
4743
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4744
- while (1) switch (_context49.prev = _context49.next) {
4782
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4783
+ while (1) switch (_context50.prev = _context50.next) {
4745
4784
  case 0:
4746
4785
  this.logInfo('computeOrderQueryResult: 开始过滤', {
4747
4786
  data: data
4748
4787
  });
4749
4788
  console.log('[Server] computeOrderQueryResult', data);
4750
4789
  if (this.order) {
4751
- _context49.next = 5;
4790
+ _context50.next = 5;
4752
4791
  break;
4753
4792
  }
4754
4793
  this.logError('computeOrderQueryResult: Order 模块未注册');
4755
- return _context49.abrupt("return", {
4794
+ return _context50.abrupt("return", {
4756
4795
  code: 500,
4757
4796
  message: 'Order 模块未注册',
4758
4797
  data: {
@@ -4776,7 +4815,7 @@ var Server = /*#__PURE__*/function () {
4776
4815
  skip: result.skip,
4777
4816
  rejected: result.rejected
4778
4817
  });
4779
- return _context49.abrupt("return", {
4818
+ return _context50.abrupt("return", {
4780
4819
  code: 200,
4781
4820
  data: result,
4782
4821
  message: '',
@@ -4784,9 +4823,9 @@ var Server = /*#__PURE__*/function () {
4784
4823
  });
4785
4824
  case 10:
4786
4825
  case "end":
4787
- return _context49.stop();
4826
+ return _context50.stop();
4788
4827
  }
4789
- }, _callee49, this);
4828
+ }, _callee50, this);
4790
4829
  }));
4791
4830
  function computeOrderQueryResult(_x53) {
4792
4831
  return _computeOrderQueryResult.apply(this, arguments);
@@ -4801,17 +4840,17 @@ var Server = /*#__PURE__*/function () {
4801
4840
  }, {
4802
4841
  key: "computeBookingQueryResult",
4803
4842
  value: (function () {
4804
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data) {
4843
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(data) {
4805
4844
  var rawOrders, result;
4806
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4807
- while (1) switch (_context50.prev = _context50.next) {
4845
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4846
+ while (1) switch (_context51.prev = _context51.next) {
4808
4847
  case 0:
4809
4848
  if (this.order) {
4810
- _context50.next = 3;
4849
+ _context51.next = 3;
4811
4850
  break;
4812
4851
  }
4813
4852
  this.logError('computeBookingQueryResult: Order 模块未注册');
4814
- return _context50.abrupt("return", {
4853
+ return _context51.abrupt("return", {
4815
4854
  code: 500,
4816
4855
  message: 'Order 模块未注册',
4817
4856
  data: {
@@ -4830,7 +4869,7 @@ var Server = /*#__PURE__*/function () {
4830
4869
  size: result.size,
4831
4870
  skip: result.skip
4832
4871
  });
4833
- return _context50.abrupt("return", {
4872
+ return _context51.abrupt("return", {
4834
4873
  code: 200,
4835
4874
  data: result,
4836
4875
  message: '',
@@ -4838,9 +4877,9 @@ var Server = /*#__PURE__*/function () {
4838
4877
  });
4839
4878
  case 8:
4840
4879
  case "end":
4841
- return _context50.stop();
4880
+ return _context51.stop();
4842
4881
  }
4843
- }, _callee50, this);
4882
+ }, _callee51, this);
4844
4883
  }));
4845
4884
  function computeBookingQueryResult(_x54) {
4846
4885
  return _computeBookingQueryResult.apply(this, arguments);
@@ -4858,12 +4897,12 @@ var Server = /*#__PURE__*/function () {
4858
4897
  }, {
4859
4898
  key: "computeProductQueryResult",
4860
4899
  value: (function () {
4861
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(context, options) {
4900
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(context, options) {
4862
4901
  var _menu_list_ids$length3,
4863
4902
  _this13 = this;
4864
4903
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
4865
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4866
- while (1) switch (_context51.prev = _context51.next) {
4904
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4905
+ while (1) switch (_context52.prev = _context52.next) {
4867
4906
  case 0:
4868
4907
  tTotal = performance.now();
4869
4908
  menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, product_id = context.product_id;
@@ -4882,11 +4921,11 @@ var Server = /*#__PURE__*/function () {
4882
4921
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
4883
4922
  });
4884
4923
  if (this.products) {
4885
- _context51.next = 7;
4924
+ _context52.next = 7;
4886
4925
  break;
4887
4926
  }
4888
4927
  this.logError('computeProductQueryResult: Products 模块未注册');
4889
- return _context51.abrupt("return", {
4928
+ return _context52.abrupt("return", {
4890
4929
  message: 'Products 模块未注册',
4891
4930
  data: {
4892
4931
  list: [],
@@ -4895,12 +4934,12 @@ var Server = /*#__PURE__*/function () {
4895
4934
  });
4896
4935
  case 7:
4897
4936
  if (!(queryIds.length > 0)) {
4898
- _context51.next = 18;
4937
+ _context52.next = 18;
4899
4938
  break;
4900
4939
  }
4901
4940
  uniqueIds = Array.from(new Set(queryIds));
4902
4941
  _tPrice = performance.now();
4903
- _context51.next = 12;
4942
+ _context52.next = 12;
4904
4943
  return this.products.getProductsWithPrice(schedule_date, {
4905
4944
  scheduleModule: this.getSchedule(),
4906
4945
  schedule_datetime: schedule_datetime,
@@ -4910,7 +4949,7 @@ var Server = /*#__PURE__*/function () {
4910
4949
  productIds: uniqueIds
4911
4950
  });
4912
4951
  case 12:
4913
- productsWithPrice = _context51.sent;
4952
+ productsWithPrice = _context52.sent;
4914
4953
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
4915
4954
  count: productsWithPrice.length,
4916
4955
  ids: uniqueIds
@@ -4929,7 +4968,7 @@ var Server = /*#__PURE__*/function () {
4929
4968
  ids: uniqueIds,
4930
4969
  count: _filteredProducts.length
4931
4970
  });
4932
- return _context51.abrupt("return", {
4971
+ return _context52.abrupt("return", {
4933
4972
  code: 200,
4934
4973
  data: {
4935
4974
  list: _filteredProducts,
@@ -4940,19 +4979,19 @@ var Server = /*#__PURE__*/function () {
4940
4979
  });
4941
4980
  case 18:
4942
4981
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
4943
- _context51.next = 30;
4982
+ _context52.next = 30;
4944
4983
  break;
4945
4984
  }
4946
4985
  pid = Number(product_id);
4947
4986
  _tPrice2 = performance.now();
4948
- _context51.next = 23;
4987
+ _context52.next = 23;
4949
4988
  return this.products.getProductsWithPrice(schedule_date, {
4950
4989
  scheduleModule: this.getSchedule()
4951
4990
  }, {
4952
4991
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
4953
4992
  });
4954
4993
  case 23:
4955
- allProductsWithPrice = _context51.sent;
4994
+ allProductsWithPrice = _context52.sent;
4956
4995
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
4957
4996
  count: allProductsWithPrice.length,
4958
4997
  productId: pid
@@ -4972,7 +5011,7 @@ var Server = /*#__PURE__*/function () {
4972
5011
  productId: pid,
4973
5012
  found: !!item
4974
5013
  });
4975
- return _context51.abrupt("return", {
5014
+ return _context52.abrupt("return", {
4976
5015
  code: 200,
4977
5016
  data: item,
4978
5017
  message: item ? '' : '商品不存在或未发布',
@@ -4980,11 +5019,11 @@ var Server = /*#__PURE__*/function () {
4980
5019
  });
4981
5020
  case 30:
4982
5021
  if (this.menu) {
4983
- _context51.next = 33;
5022
+ _context52.next = 33;
4984
5023
  break;
4985
5024
  }
4986
5025
  this.logError('computeProductQueryResult: Menu 模块未注册');
4987
- return _context51.abrupt("return", {
5026
+ return _context52.abrupt("return", {
4988
5027
  message: 'Menu 模块未注册',
4989
5028
  data: {
4990
5029
  list: [],
@@ -4993,11 +5032,11 @@ var Server = /*#__PURE__*/function () {
4993
5032
  });
4994
5033
  case 33:
4995
5034
  if (this.schedule) {
4996
- _context51.next = 36;
5035
+ _context52.next = 36;
4997
5036
  break;
4998
5037
  }
4999
5038
  this.logError('computeProductQueryResult: Schedule 模块未注册');
5000
- return _context51.abrupt("return", {
5039
+ return _context52.abrupt("return", {
5001
5040
  message: 'Schedule 模块未注册',
5002
5041
  data: {
5003
5042
  list: [],
@@ -5028,10 +5067,10 @@ var Server = /*#__PURE__*/function () {
5028
5067
  });
5029
5068
  tPrice = performance.now();
5030
5069
  if (!(scopedProductIds.length > 0)) {
5031
- _context51.next = 49;
5070
+ _context52.next = 49;
5032
5071
  break;
5033
5072
  }
5034
- _context51.next = 46;
5073
+ _context52.next = 46;
5035
5074
  return this.products.getProductsWithPrice(schedule_date, {
5036
5075
  scheduleModule: this.getSchedule(),
5037
5076
  schedule_datetime: schedule_datetime,
@@ -5041,13 +5080,13 @@ var Server = /*#__PURE__*/function () {
5041
5080
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
5042
5081
  });
5043
5082
  case 46:
5044
- _context51.t0 = _context51.sent;
5045
- _context51.next = 50;
5083
+ _context52.t0 = _context52.sent;
5084
+ _context52.next = 50;
5046
5085
  break;
5047
5086
  case 49:
5048
- _context51.t0 = [];
5087
+ _context52.t0 = [];
5049
5088
  case 50:
5050
- filteredProducts = _context51.t0;
5089
+ filteredProducts = _context52.t0;
5051
5090
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
5052
5091
  count: filteredProducts.length,
5053
5092
  scopedProductCount: scopedProductIds.length
@@ -5080,7 +5119,7 @@ var Server = /*#__PURE__*/function () {
5080
5119
  filteredCount: filteredProducts.length,
5081
5120
  activeMenuCount: activeMenuList.length
5082
5121
  });
5083
- return _context51.abrupt("return", {
5122
+ return _context52.abrupt("return", {
5084
5123
  code: 200,
5085
5124
  data: {
5086
5125
  list: filteredProducts,
@@ -5091,9 +5130,9 @@ var Server = /*#__PURE__*/function () {
5091
5130
  });
5092
5131
  case 62:
5093
5132
  case "end":
5094
- return _context51.stop();
5133
+ return _context52.stop();
5095
5134
  }
5096
- }, _callee51, this);
5135
+ }, _callee52, this);
5097
5136
  }));
5098
5137
  function computeProductQueryResult(_x55, _x56) {
5099
5138
  return _computeProductQueryResult.apply(this, arguments);
@@ -5110,70 +5149,70 @@ var Server = /*#__PURE__*/function () {
5110
5149
  }, {
5111
5150
  key: "recomputeAndNotifyProductQuery",
5112
5151
  value: (function () {
5113
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(options) {
5152
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(options) {
5114
5153
  var _iterator17, _step17, _step17$value, subscriberId, subscriber, result, errorMessage;
5115
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5116
- while (1) switch (_context52.prev = _context52.next) {
5154
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5155
+ while (1) switch (_context53.prev = _context53.next) {
5117
5156
  case 0:
5118
5157
  if (!(this.productQuerySubscribers.size === 0)) {
5119
- _context52.next = 2;
5158
+ _context53.next = 2;
5120
5159
  break;
5121
5160
  }
5122
- return _context52.abrupt("return");
5161
+ return _context53.abrupt("return");
5123
5162
  case 2:
5124
5163
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
5125
5164
  subscriberCount: this.productQuerySubscribers.size,
5126
5165
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5127
5166
  });
5128
5167
  _iterator17 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
5129
- _context52.prev = 4;
5168
+ _context53.prev = 4;
5130
5169
  _iterator17.s();
5131
5170
  case 6:
5132
5171
  if ((_step17 = _iterator17.n()).done) {
5133
- _context52.next = 22;
5172
+ _context53.next = 22;
5134
5173
  break;
5135
5174
  }
5136
5175
  _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], subscriber = _step17$value[1];
5137
- _context52.prev = 8;
5138
- _context52.next = 11;
5176
+ _context53.prev = 8;
5177
+ _context53.next = 11;
5139
5178
  return this.computeProductQueryResult(subscriber.context, {
5140
5179
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5141
5180
  });
5142
5181
  case 11:
5143
- result = _context52.sent;
5182
+ result = _context53.sent;
5144
5183
  subscriber.callback(result);
5145
5184
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
5146
5185
  subscriberId: subscriberId
5147
5186
  });
5148
- _context52.next = 20;
5187
+ _context53.next = 20;
5149
5188
  break;
5150
5189
  case 16:
5151
- _context52.prev = 16;
5152
- _context52.t0 = _context52["catch"](8);
5153
- errorMessage = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
5190
+ _context53.prev = 16;
5191
+ _context53.t0 = _context53["catch"](8);
5192
+ errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5154
5193
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
5155
5194
  subscriberId: subscriberId,
5156
5195
  error: errorMessage
5157
5196
  });
5158
5197
  case 20:
5159
- _context52.next = 6;
5198
+ _context53.next = 6;
5160
5199
  break;
5161
5200
  case 22:
5162
- _context52.next = 27;
5201
+ _context53.next = 27;
5163
5202
  break;
5164
5203
  case 24:
5165
- _context52.prev = 24;
5166
- _context52.t1 = _context52["catch"](4);
5167
- _iterator17.e(_context52.t1);
5204
+ _context53.prev = 24;
5205
+ _context53.t1 = _context53["catch"](4);
5206
+ _iterator17.e(_context53.t1);
5168
5207
  case 27:
5169
- _context52.prev = 27;
5208
+ _context53.prev = 27;
5170
5209
  _iterator17.f();
5171
- return _context52.finish(27);
5210
+ return _context53.finish(27);
5172
5211
  case 30:
5173
5212
  case "end":
5174
- return _context52.stop();
5213
+ return _context53.stop();
5175
5214
  }
5176
- }, _callee52, this, [[4, 24, 27, 30], [8, 16]]);
5215
+ }, _callee53, this, [[4, 24, 27, 30], [8, 16]]);
5177
5216
  }));
5178
5217
  function recomputeAndNotifyProductQuery(_x57) {
5179
5218
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
@@ -5187,16 +5226,16 @@ var Server = /*#__PURE__*/function () {
5187
5226
  }, {
5188
5227
  key: "recomputeAndNotifyOrderQuery",
5189
5228
  value: (function () {
5190
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5229
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5191
5230
  var notifyStartAt, _iterator18, _step18, _step18$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
5192
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5193
- while (1) switch (_context53.prev = _context53.next) {
5231
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5232
+ while (1) switch (_context54.prev = _context54.next) {
5194
5233
  case 0:
5195
5234
  if (!(this.orderQuerySubscribers.size === 0)) {
5196
- _context53.next = 2;
5235
+ _context54.next = 2;
5197
5236
  break;
5198
5237
  }
5199
- return _context53.abrupt("return");
5238
+ return _context54.abrupt("return");
5200
5239
  case 2:
5201
5240
  notifyStartAt = Date.now();
5202
5241
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -5204,20 +5243,20 @@ var Server = /*#__PURE__*/function () {
5204
5243
  notifyStartAt: new Date(notifyStartAt).toISOString()
5205
5244
  });
5206
5245
  _iterator18 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
5207
- _context53.prev = 5;
5246
+ _context54.prev = 5;
5208
5247
  _iterator18.s();
5209
5248
  case 7:
5210
5249
  if ((_step18 = _iterator18.n()).done) {
5211
- _context53.next = 27;
5250
+ _context54.next = 27;
5212
5251
  break;
5213
5252
  }
5214
5253
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
5215
- _context53.prev = 9;
5254
+ _context54.prev = 9;
5216
5255
  computeStartAt = Date.now();
5217
- _context53.next = 13;
5256
+ _context54.next = 13;
5218
5257
  return this.computeOrderQueryResult(subscriber.context);
5219
5258
  case 13:
5220
- result = _context53.sent;
5259
+ result = _context54.sent;
5221
5260
  computeEndAt = Date.now();
5222
5261
  callbackStartAt = Date.now();
5223
5262
  subscriber.callback(result);
@@ -5228,30 +5267,30 @@ var Server = /*#__PURE__*/function () {
5228
5267
  callbackDurationMs: callbackEndAt - callbackStartAt,
5229
5268
  totalDurationMs: callbackEndAt - computeStartAt
5230
5269
  });
5231
- _context53.next = 25;
5270
+ _context54.next = 25;
5232
5271
  break;
5233
5272
  case 21:
5234
- _context53.prev = 21;
5235
- _context53.t0 = _context53["catch"](9);
5236
- errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5273
+ _context54.prev = 21;
5274
+ _context54.t0 = _context54["catch"](9);
5275
+ errorMessage = _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0);
5237
5276
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
5238
5277
  subscriberId: subscriberId,
5239
5278
  error: errorMessage
5240
5279
  });
5241
5280
  case 25:
5242
- _context53.next = 7;
5281
+ _context54.next = 7;
5243
5282
  break;
5244
5283
  case 27:
5245
- _context53.next = 32;
5284
+ _context54.next = 32;
5246
5285
  break;
5247
5286
  case 29:
5248
- _context53.prev = 29;
5249
- _context53.t1 = _context53["catch"](5);
5250
- _iterator18.e(_context53.t1);
5287
+ _context54.prev = 29;
5288
+ _context54.t1 = _context54["catch"](5);
5289
+ _iterator18.e(_context54.t1);
5251
5290
  case 32:
5252
- _context53.prev = 32;
5291
+ _context54.prev = 32;
5253
5292
  _iterator18.f();
5254
- return _context53.finish(32);
5293
+ return _context54.finish(32);
5255
5294
  case 35:
5256
5295
  notifyEndAt = Date.now();
5257
5296
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -5260,9 +5299,9 @@ var Server = /*#__PURE__*/function () {
5260
5299
  });
5261
5300
  case 37:
5262
5301
  case "end":
5263
- return _context53.stop();
5302
+ return _context54.stop();
5264
5303
  }
5265
- }, _callee53, this, [[5, 29, 32, 35], [9, 21]]);
5304
+ }, _callee54, this, [[5, 29, 32, 35], [9, 21]]);
5266
5305
  }));
5267
5306
  function recomputeAndNotifyOrderQuery() {
5268
5307
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -5400,67 +5439,67 @@ var Server = /*#__PURE__*/function () {
5400
5439
  }, {
5401
5440
  key: "recomputeAndNotifyBookingQuery",
5402
5441
  value: (function () {
5403
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5442
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5404
5443
  var _iterator20, _step20, _step20$value, subscriberId, subscriber, result, errorMessage;
5405
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5406
- while (1) switch (_context54.prev = _context54.next) {
5444
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5445
+ while (1) switch (_context55.prev = _context55.next) {
5407
5446
  case 0:
5408
5447
  if (!(this.bookingQuerySubscribers.size === 0)) {
5409
- _context54.next = 2;
5448
+ _context55.next = 2;
5410
5449
  break;
5411
5450
  }
5412
- return _context54.abrupt("return");
5451
+ return _context55.abrupt("return");
5413
5452
  case 2:
5414
5453
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
5415
5454
  subscriberCount: this.bookingQuerySubscribers.size
5416
5455
  });
5417
5456
  _iterator20 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
5418
- _context54.prev = 4;
5457
+ _context55.prev = 4;
5419
5458
  _iterator20.s();
5420
5459
  case 6:
5421
5460
  if ((_step20 = _iterator20.n()).done) {
5422
- _context54.next = 22;
5461
+ _context55.next = 22;
5423
5462
  break;
5424
5463
  }
5425
5464
  _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
5426
- _context54.prev = 8;
5427
- _context54.next = 11;
5465
+ _context55.prev = 8;
5466
+ _context55.next = 11;
5428
5467
  return this.computeBookingQueryResult(subscriber.context);
5429
5468
  case 11:
5430
- result = _context54.sent;
5469
+ result = _context55.sent;
5431
5470
  subscriber.callback(result);
5432
5471
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
5433
5472
  subscriberId: subscriberId
5434
5473
  });
5435
- _context54.next = 20;
5474
+ _context55.next = 20;
5436
5475
  break;
5437
5476
  case 16:
5438
- _context54.prev = 16;
5439
- _context54.t0 = _context54["catch"](8);
5440
- errorMessage = _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0);
5477
+ _context55.prev = 16;
5478
+ _context55.t0 = _context55["catch"](8);
5479
+ errorMessage = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
5441
5480
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
5442
5481
  subscriberId: subscriberId,
5443
5482
  error: errorMessage
5444
5483
  });
5445
5484
  case 20:
5446
- _context54.next = 6;
5485
+ _context55.next = 6;
5447
5486
  break;
5448
5487
  case 22:
5449
- _context54.next = 27;
5488
+ _context55.next = 27;
5450
5489
  break;
5451
5490
  case 24:
5452
- _context54.prev = 24;
5453
- _context54.t1 = _context54["catch"](4);
5454
- _iterator20.e(_context54.t1);
5491
+ _context55.prev = 24;
5492
+ _context55.t1 = _context55["catch"](4);
5493
+ _iterator20.e(_context55.t1);
5455
5494
  case 27:
5456
- _context54.prev = 27;
5495
+ _context55.prev = 27;
5457
5496
  _iterator20.f();
5458
- return _context54.finish(27);
5497
+ return _context55.finish(27);
5459
5498
  case 30:
5460
5499
  case "end":
5461
- return _context54.stop();
5500
+ return _context55.stop();
5462
5501
  }
5463
- }, _callee54, this, [[4, 24, 27, 30], [8, 16]]);
5502
+ }, _callee55, this, [[4, 24, 27, 30], [8, 16]]);
5464
5503
  }));
5465
5504
  function recomputeAndNotifyBookingQuery() {
5466
5505
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);