@pisell/pisellos 2.2.224 → 2.2.225

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.
@@ -2131,10 +2131,11 @@ var Server = /*#__PURE__*/function () {
2131
2131
  });
2132
2132
  return _context26.abrupt("return", this.taskFail('BACKEND_REJECTED', _message, backendError));
2133
2133
  case 51:
2134
- errorMessage = _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0);
2134
+ errorMessage = this.getUnknownErrorMessage(_context26.t0);
2135
2135
  this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
2136
2136
  backendPath: backendPath,
2137
- error: errorMessage
2137
+ error: errorMessage,
2138
+ error_detail: this.normalizeUnknownError(_context26.t0)
2138
2139
  });
2139
2140
  return _context26.abrupt("return", this.taskTimeout(errorMessage));
2140
2141
  case 54:
@@ -3000,10 +3001,10 @@ var Server = /*#__PURE__*/function () {
3000
3001
  var next = {};
3001
3002
  for (var _i = 0, _Object$entries = Object.entries(value); _i < _Object$entries.length; _i++) {
3002
3003
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3003
- _key = _Object$entries$_i[0],
3004
+ _key2 = _Object$entries$_i[0],
3004
3005
  item = _Object$entries$_i[1];
3005
- if (_key === 'page' || _key === 'skip') continue;
3006
- next[_key] = this.stripSalesSearchPageParams(item);
3006
+ if (_key2 === 'page' || _key2 === 'skip') continue;
3007
+ next[_key2] = this.stripSalesSearchPageParams(item);
3007
3008
  }
3008
3009
  return next;
3009
3010
  }
@@ -3254,11 +3255,11 @@ var Server = /*#__PURE__*/function () {
3254
3255
  try {
3255
3256
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3256
3257
  var _step6$value = _slicedToArray(_step6.value, 2),
3257
- _key2 = _step6$value[0],
3258
+ _key3 = _step6$value[0],
3258
3259
  cache = _step6$value[1];
3259
3260
  if (cache.updatedAt < oldestTime) {
3260
3261
  oldestTime = cache.updatedAt;
3261
- oldestKey = _key2;
3262
+ oldestKey = _key3;
3262
3263
  }
3263
3264
  }
3264
3265
  } catch (err) {
@@ -3385,8 +3386,8 @@ var Server = /*#__PURE__*/function () {
3385
3386
  try {
3386
3387
  for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3387
3388
  var order = _step10.value;
3388
- var _key3 = this.toOrderIdKey(order);
3389
- if (_key3) orderMap.set(_key3, order);
3389
+ var _key4 = this.toOrderIdKey(order);
3390
+ if (_key4) orderMap.set(_key4, order);
3390
3391
  }
3391
3392
  } catch (err) {
3392
3393
  _iterator10.e(err);
@@ -3399,14 +3400,14 @@ var Server = /*#__PURE__*/function () {
3399
3400
  try {
3400
3401
  for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3401
3402
  var latest = _step11.value;
3402
- var _key4 = this.toOrderIdKey(latest);
3403
- if (!_key4) continue;
3404
- if (orderMap.has(_key4)) {
3405
- orderMap.set(_key4, latest);
3403
+ var _key5 = this.toOrderIdKey(latest);
3404
+ if (!_key5) continue;
3405
+ if (orderMap.has(_key5)) {
3406
+ orderMap.set(_key5, latest);
3406
3407
  changed = true;
3407
3408
  continue;
3408
3409
  }
3409
- orderMap.set(_key4, latest);
3410
+ orderMap.set(_key5, latest);
3410
3411
  changed = true;
3411
3412
  }
3412
3413
  } catch (err) {
@@ -3771,10 +3772,20 @@ var Server = /*#__PURE__*/function () {
3771
3772
  return "sync_sales:".concat(identity);
3772
3773
  }
3773
3774
  }, {
3774
- key: "ensureCheckoutOrderNumbers",
3775
+ key: "isBlankCheckoutValue",
3776
+ value: function isBlankCheckoutValue(value) {
3777
+ return value === undefined || value === null || value === '';
3778
+ }
3779
+ }, {
3780
+ key: "isLocalCheckoutOrderId",
3781
+ value: function isLocalCheckoutOrderId(orderId) {
3782
+ return typeof orderId === 'string' && orderId.startsWith('LOCAL_');
3783
+ }
3784
+ }, {
3785
+ key: "normalizeCheckoutSubmitData",
3775
3786
  value: function () {
3776
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data, title) {
3777
- var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
3787
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data, title) {
3788
+ var next, externalSaleNumber, shouldClearLocalOrderId, localOrder;
3778
3789
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3779
3790
  while (1) switch (_context40.prev = _context40.next) {
3780
3791
  case 0:
@@ -3783,71 +3794,166 @@ var Server = /*#__PURE__*/function () {
3783
3794
  break;
3784
3795
  }
3785
3796
  return _context40.abrupt("return", data);
3797
+ case 2:
3798
+ next = _objectSpread({}, data);
3799
+ externalSaleNumber = next.external_sale_number;
3800
+ shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
3801
+ if (shouldClearLocalOrderId) next.order_id = null;
3802
+ if (!this.isBlankCheckoutValue(externalSaleNumber)) {
3803
+ _context40.next = 9;
3804
+ break;
3805
+ }
3806
+ if (shouldClearLocalOrderId) {
3807
+ this.logInfo("".concat(title, ": checkout \u672C\u5730\u8BA2\u5355\u53F7\u5DF2\u6E05\u7406"), {
3808
+ original_order_id: data.order_id,
3809
+ order_id: next.order_id
3810
+ });
3811
+ }
3812
+ return _context40.abrupt("return", next);
3813
+ case 9:
3814
+ if (!(!this.order || typeof this.order.getLocalOrderByLookup !== 'function')) {
3815
+ _context40.next = 12;
3816
+ break;
3817
+ }
3818
+ if (shouldClearLocalOrderId) {
3819
+ this.logInfo("".concat(title, ": checkout \u672C\u5730\u8BA2\u5355\u53F7\u5DF2\u6E05\u7406"), {
3820
+ original_order_id: data.order_id,
3821
+ external_sale_number: externalSaleNumber
3822
+ });
3823
+ }
3824
+ return _context40.abrupt("return", next);
3825
+ case 12:
3826
+ _context40.prev = 12;
3827
+ _context40.next = 15;
3828
+ return this.order.getLocalOrderByLookup(externalSaleNumber);
3829
+ case 15:
3830
+ localOrder = _context40.sent;
3831
+ if (localOrder) {
3832
+ _context40.next = 19;
3833
+ break;
3834
+ }
3835
+ if (shouldClearLocalOrderId) {
3836
+ this.logInfo("".concat(title, ": checkout \u672C\u5730\u8BA2\u5355\u53F7\u5DF2\u6E05\u7406"), {
3837
+ original_order_id: data.order_id,
3838
+ external_sale_number: externalSaleNumber,
3839
+ localOrderFound: false
3840
+ });
3841
+ }
3842
+ return _context40.abrupt("return", next);
3843
+ case 19:
3844
+ if (this.isBlankCheckoutValue(next.shop_order_number)) {
3845
+ next.shop_order_number = localOrder.shop_order_number;
3846
+ }
3847
+ if (this.isBlankCheckoutValue(next.shop_full_order_number)) {
3848
+ next.shop_full_order_number = localOrder.shop_full_order_number;
3849
+ }
3850
+ this.logInfo("".concat(title, ": checkout \u5DF2\u590D\u7528\u672C\u5730\u8BA2\u5355\u53F7"), {
3851
+ original_order_id: data.order_id,
3852
+ order_id: next.order_id,
3853
+ external_sale_number: externalSaleNumber,
3854
+ local_order_id: localOrder.order_id,
3855
+ shop_order_number: next.shop_order_number,
3856
+ shop_full_order_number: next.shop_full_order_number
3857
+ });
3858
+ return _context40.abrupt("return", next);
3859
+ case 25:
3860
+ _context40.prev = 25;
3861
+ _context40.t0 = _context40["catch"](12);
3862
+ this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
3863
+ external_sale_number: externalSaleNumber,
3864
+ error: this.getUnknownErrorMessage(_context40.t0),
3865
+ error_detail: this.normalizeUnknownError(_context40.t0)
3866
+ });
3867
+ return _context40.abrupt("return", next);
3868
+ case 29:
3869
+ case "end":
3870
+ return _context40.stop();
3871
+ }
3872
+ }, _callee40, this, [[12, 25]]);
3873
+ }));
3874
+ function normalizeCheckoutSubmitData(_x42, _x43) {
3875
+ return _normalizeCheckoutSubmitData.apply(this, arguments);
3876
+ }
3877
+ return normalizeCheckoutSubmitData;
3878
+ }()
3879
+ }, {
3880
+ key: "ensureCheckoutOrderNumbers",
3881
+ value: function () {
3882
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data, title) {
3883
+ var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
3884
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3885
+ while (1) switch (_context41.prev = _context41.next) {
3886
+ case 0:
3887
+ if (!(!data || _typeof(data) !== 'object')) {
3888
+ _context41.next = 2;
3889
+ break;
3890
+ }
3891
+ return _context41.abrupt("return", data);
3786
3892
  case 2:
3787
3893
  next = _objectSpread({}, data);
3788
3894
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
3789
3895
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
3790
3896
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
3791
- _context40.next = 7;
3897
+ _context41.next = 7;
3792
3898
  break;
3793
3899
  }
3794
- return _context40.abrupt("return", next);
3900
+ return _context41.abrupt("return", next);
3795
3901
  case 7:
3796
3902
  idGenerator = this.getIdGeneratorPlugin();
3797
3903
  if (idGenerator) {
3798
- _context40.next = 11;
3904
+ _context41.next = 11;
3799
3905
  break;
3800
3906
  }
3801
3907
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
3802
3908
  needsShopOrderNumber: needsShopOrderNumber,
3803
3909
  needsShopFullOrderNumber: needsShopFullOrderNumber
3804
3910
  });
3805
- return _context40.abrupt("return", next);
3911
+ return _context41.abrupt("return", next);
3806
3912
  case 11:
3807
- _context40.prev = 11;
3913
+ _context41.prev = 11;
3808
3914
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
3809
- _context40.next = 16;
3915
+ _context41.next = 16;
3810
3916
  break;
3811
3917
  }
3812
- _context40.next = 15;
3918
+ _context41.next = 15;
3813
3919
  return idGenerator.generateShopOrderNumber({
3814
3920
  biz: next.business_code || 'ticket'
3815
3921
  });
3816
3922
  case 15:
3817
- next.shop_order_number = _context40.sent;
3923
+ next.shop_order_number = _context41.sent;
3818
3924
  case 16:
3819
3925
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
3820
- _context40.next = 20;
3926
+ _context41.next = 20;
3821
3927
  break;
3822
3928
  }
3823
- _context40.next = 19;
3929
+ _context41.next = 19;
3824
3930
  return idGenerator.generateReceiptId({
3825
3931
  biz: next.business_code || 'ticket'
3826
3932
  });
3827
3933
  case 19:
3828
- next.shop_full_order_number = _context40.sent;
3934
+ next.shop_full_order_number = _context41.sent;
3829
3935
  case 20:
3830
3936
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
3831
3937
  shop_order_number: next.shop_order_number,
3832
3938
  shop_full_order_number: next.shop_full_order_number
3833
3939
  });
3834
- _context40.next = 26;
3940
+ _context41.next = 26;
3835
3941
  break;
3836
3942
  case 23:
3837
- _context40.prev = 23;
3838
- _context40.t0 = _context40["catch"](11);
3943
+ _context41.prev = 23;
3944
+ _context41.t0 = _context41["catch"](11);
3839
3945
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
3840
- error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3946
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
3841
3947
  });
3842
3948
  case 26:
3843
- return _context40.abrupt("return", next);
3949
+ return _context41.abrupt("return", next);
3844
3950
  case 27:
3845
3951
  case "end":
3846
- return _context40.stop();
3952
+ return _context41.stop();
3847
3953
  }
3848
- }, _callee40, this, [[11, 23]]);
3954
+ }, _callee41, this, [[11, 23]]);
3849
3955
  }));
3850
- function ensureCheckoutOrderNumbers(_x42, _x43) {
3956
+ function ensureCheckoutOrderNumbers(_x44, _x45) {
3851
3957
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
3852
3958
  }
3853
3959
  return ensureCheckoutOrderNumbers;
@@ -3855,27 +3961,27 @@ var Server = /*#__PURE__*/function () {
3855
3961
  }, {
3856
3962
  key: "dispatchCheckoutSyncTask",
3857
3963
  value: function () {
3858
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3964
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3859
3965
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
3860
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3861
- while (1) switch (_context41.prev = _context41.next) {
3966
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3967
+ while (1) switch (_context42.prev = _context42.next) {
3862
3968
  case 0:
3863
3969
  this.registerDeviceTaskActions();
3864
3970
  deviceTask = this.getDeviceTaskPlugin();
3865
- _context41.next = 4;
3971
+ _context42.next = 4;
3866
3972
  return this.getShortNumberOrDeviceId();
3867
3973
  case 4:
3868
- debugDeviceId = _context41.sent;
3974
+ debugDeviceId = _context42.sent;
3869
3975
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
3870
3976
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3871
- _context41.next = 9;
3977
+ _context42.next = 9;
3872
3978
  break;
3873
3979
  }
3874
3980
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
3875
- return _context41.abrupt("return");
3981
+ return _context42.abrupt("return");
3876
3982
  case 9:
3877
- _context41.prev = 9;
3878
- _context41.next = 12;
3983
+ _context42.prev = 9;
3984
+ _context42.next = 12;
3879
3985
  return deviceTask.dispatch({
3880
3986
  action: 'sync_sales',
3881
3987
  device_id: debugDeviceId,
@@ -3893,27 +3999,27 @@ var Server = /*#__PURE__*/function () {
3893
3999
  source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
3894
4000
  });
3895
4001
  case 12:
3896
- result = _context41.sent;
4002
+ result = _context42.sent;
3897
4003
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
3898
4004
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
3899
4005
  status: result === null || result === void 0 ? void 0 : result.status,
3900
4006
  reused: result === null || result === void 0 ? void 0 : result.reused
3901
4007
  });
3902
- _context41.next = 19;
4008
+ _context42.next = 19;
3903
4009
  break;
3904
4010
  case 16:
3905
- _context41.prev = 16;
3906
- _context41.t0 = _context41["catch"](9);
4011
+ _context42.prev = 16;
4012
+ _context42.t0 = _context42["catch"](9);
3907
4013
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
3908
- error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
4014
+ error: _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0)
3909
4015
  });
3910
4016
  case 19:
3911
4017
  case "end":
3912
- return _context41.stop();
4018
+ return _context42.stop();
3913
4019
  }
3914
- }, _callee41, this, [[9, 16]]);
4020
+ }, _callee42, this, [[9, 16]]);
3915
4021
  }));
3916
- function dispatchCheckoutSyncTask(_x44) {
4022
+ function dispatchCheckoutSyncTask(_x46) {
3917
4023
  return _dispatchCheckoutSyncTask.apply(this, arguments);
3918
4024
  }
3919
4025
  return dispatchCheckoutSyncTask;
@@ -3921,26 +4027,26 @@ var Server = /*#__PURE__*/function () {
3921
4027
  }, {
3922
4028
  key: "dispatchPrintOtherReceiptTask",
3923
4029
  value: function () {
3924
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4030
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3925
4031
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
3926
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3927
- while (1) switch (_context42.prev = _context42.next) {
4032
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4033
+ while (1) switch (_context43.prev = _context43.next) {
3928
4034
  case 0:
3929
4035
  deviceTask = this.getDeviceTaskPlugin();
3930
4036
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3931
- _context42.next = 4;
4037
+ _context43.next = 4;
3932
4038
  break;
3933
4039
  }
3934
4040
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
3935
- return _context42.abrupt("return");
4041
+ return _context43.abrupt("return");
3936
4042
  case 4:
3937
- _context42.prev = 4;
4043
+ _context43.prev = 4;
3938
4044
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
3939
- _context42.next = 8;
4045
+ _context43.next = 8;
3940
4046
  return this.getShortNumberOrDeviceId();
3941
4047
  case 8:
3942
- deviceId = _context42.sent;
3943
- _context42.next = 11;
4048
+ deviceId = _context43.sent;
4049
+ _context43.next = 11;
3944
4050
  return deviceTask.dispatch({
3945
4051
  action: 'print_all',
3946
4052
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -3965,21 +4071,21 @@ var Server = /*#__PURE__*/function () {
3965
4071
  source_id: printIdentity
3966
4072
  });
3967
4073
  case 11:
3968
- _context42.next = 16;
4074
+ _context43.next = 16;
3969
4075
  break;
3970
4076
  case 13:
3971
- _context42.prev = 13;
3972
- _context42.t0 = _context42["catch"](4);
4077
+ _context43.prev = 13;
4078
+ _context43.t0 = _context43["catch"](4);
3973
4079
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
3974
- error: _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0)
4080
+ error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
3975
4081
  });
3976
4082
  case 16:
3977
4083
  case "end":
3978
- return _context42.stop();
4084
+ return _context43.stop();
3979
4085
  }
3980
- }, _callee42, this, [[4, 13]]);
4086
+ }, _callee43, this, [[4, 13]]);
3981
4087
  }));
3982
- function dispatchPrintOtherReceiptTask(_x45) {
4088
+ function dispatchPrintOtherReceiptTask(_x47) {
3983
4089
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
3984
4090
  }
3985
4091
  return dispatchPrintOtherReceiptTask;
@@ -3999,37 +4105,37 @@ var Server = /*#__PURE__*/function () {
3999
4105
  }, {
4000
4106
  key: "dispatchLocalReceiptPrint",
4001
4107
  value: function () {
4002
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4108
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
4003
4109
  var _payment_info;
4004
4110
  var printableOrder;
4005
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4006
- while (1) switch (_context43.prev = _context43.next) {
4111
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4112
+ while (1) switch (_context44.prev = _context44.next) {
4007
4113
  case 0:
4008
4114
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
4009
- _context43.next = 2;
4115
+ _context44.next = 2;
4010
4116
  break;
4011
4117
  }
4012
- return _context43.abrupt("return", {
4118
+ return _context44.abrupt("return", {
4013
4119
  printed: false,
4014
4120
  order: params.order
4015
4121
  });
4016
4122
  case 2:
4017
- _context43.next = 4;
4123
+ _context44.next = 4;
4018
4124
  return this.withLocalSmallTicketData(params.order, {
4019
4125
  requireFullyPaid: params.requireFullyPaid
4020
4126
  });
4021
4127
  case 4:
4022
- printableOrder = _context43.sent;
4128
+ printableOrder = _context44.sent;
4023
4129
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
4024
- _context43.next = 7;
4130
+ _context44.next = 7;
4025
4131
  break;
4026
4132
  }
4027
- return _context43.abrupt("return", {
4133
+ return _context44.abrupt("return", {
4028
4134
  printed: false,
4029
4135
  order: printableOrder
4030
4136
  });
4031
4137
  case 7:
4032
- _context43.next = 9;
4138
+ _context44.next = 9;
4033
4139
  return this.dispatchPrintOtherReceiptTask({
4034
4140
  checkoutData: params.checkoutData,
4035
4141
  syncedOrder: printableOrder,
@@ -4037,17 +4143,17 @@ var Server = /*#__PURE__*/function () {
4037
4143
  receiptOnly: true
4038
4144
  });
4039
4145
  case 9:
4040
- return _context43.abrupt("return", {
4146
+ return _context44.abrupt("return", {
4041
4147
  printed: true,
4042
4148
  order: printableOrder
4043
4149
  });
4044
4150
  case 10:
4045
4151
  case "end":
4046
- return _context43.stop();
4152
+ return _context44.stop();
4047
4153
  }
4048
- }, _callee43, this);
4154
+ }, _callee44, this);
4049
4155
  }));
4050
- function dispatchLocalReceiptPrint(_x46) {
4156
+ function dispatchLocalReceiptPrint(_x48) {
4051
4157
  return _dispatchLocalReceiptPrint.apply(this, arguments);
4052
4158
  }
4053
4159
  return dispatchLocalReceiptPrint;
@@ -4074,10 +4180,10 @@ var Server = /*#__PURE__*/function () {
4074
4180
  }, {
4075
4181
  key: "handleOrderCheckoutSubmit",
4076
4182
  value: function () {
4077
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
4078
- var backendPath, data, title, checkoutData, pendingResult, pendingOrder;
4079
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4080
- while (1) switch (_context44.prev = _context44.next) {
4183
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4184
+ var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
4185
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4186
+ while (1) switch (_context45.prev = _context45.next) {
4081
4187
  case 0:
4082
4188
  backendPath = params.backendPath, data = params.data, title = params.title;
4083
4189
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -4086,21 +4192,25 @@ var Server = /*#__PURE__*/function () {
4086
4192
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
4087
4193
  order_number: data === null || data === void 0 ? void 0 : data.order_number
4088
4194
  });
4089
- _context44.next = 4;
4090
- return this.ensureCheckoutOrderNumbers(data, title);
4195
+ _context45.next = 4;
4196
+ return this.normalizeCheckoutSubmitData(data, title);
4091
4197
  case 4:
4092
- checkoutData = _context44.sent;
4093
- _context44.next = 7;
4198
+ normalizedData = _context45.sent;
4199
+ _context45.next = 7;
4200
+ return this.ensureCheckoutOrderNumbers(normalizedData, title);
4201
+ case 7:
4202
+ checkoutData = _context45.sent;
4203
+ _context45.next = 10;
4094
4204
  return this.handlePendingSyncCheckoutOrder({
4095
4205
  backendPath: backendPath,
4096
4206
  data: checkoutData,
4097
4207
  title: title,
4098
4208
  reason: 'checkout 已转入设备任务同步'
4099
4209
  });
4100
- case 7:
4101
- pendingResult = _context44.sent;
4210
+ case 10:
4211
+ pendingResult = _context45.sent;
4102
4212
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
4103
- _context44.next = 15;
4213
+ _context45.next = 18;
4104
4214
  break;
4105
4215
  }
4106
4216
  pendingOrder = pendingResult.data;
@@ -4108,42 +4218,42 @@ var Server = /*#__PURE__*/function () {
4108
4218
  // TODO 这里先加个兼容,只有 type 为 virtual 才走打印
4109
4219
  // 后期需要迁移到 picoding ,根据工作流配置
4110
4220
  checkoutData.type === 'virtual')) {
4111
- _context44.next = 13;
4221
+ _context45.next = 16;
4112
4222
  break;
4113
4223
  }
4114
- _context44.next = 13;
4224
+ _context45.next = 16;
4115
4225
  return this.dispatchLocalReceiptPrint({
4116
4226
  checkoutData: checkoutData,
4117
4227
  order: pendingOrder,
4118
4228
  response: pendingResult,
4119
4229
  requireFullyPaid: true
4120
4230
  });
4121
- case 13:
4122
- _context44.next = 15;
4231
+ case 16:
4232
+ _context45.next = 18;
4123
4233
  return this.dispatchCheckoutSyncTask({
4124
4234
  backendPath: backendPath,
4125
4235
  data: checkoutData,
4126
4236
  title: title
4127
4237
  });
4128
- case 15:
4238
+ case 18:
4129
4239
  if (pendingResult.data.order_id) {
4130
- _context44.next = 17;
4240
+ _context45.next = 20;
4131
4241
  break;
4132
4242
  }
4133
- return _context44.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4243
+ return _context45.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4134
4244
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
4135
4245
  order_id: pendingResult.data.external_sale_number
4136
4246
  })
4137
4247
  }));
4138
- case 17:
4139
- return _context44.abrupt("return", pendingResult);
4140
- case 18:
4248
+ case 20:
4249
+ return _context45.abrupt("return", pendingResult);
4250
+ case 21:
4141
4251
  case "end":
4142
- return _context44.stop();
4252
+ return _context45.stop();
4143
4253
  }
4144
- }, _callee44, this);
4254
+ }, _callee45, this);
4145
4255
  }));
4146
- function handleOrderCheckoutSubmit(_x47) {
4256
+ function handleOrderCheckoutSubmit(_x49) {
4147
4257
  return _handleOrderCheckoutSubmit.apply(this, arguments);
4148
4258
  }
4149
4259
  return handleOrderCheckoutSubmit;
@@ -4151,26 +4261,26 @@ var Server = /*#__PURE__*/function () {
4151
4261
  }, {
4152
4262
  key: "handlePendingSyncCheckoutOrder",
4153
4263
  value: function () {
4154
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4264
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
4155
4265
  var _this10 = this;
4156
4266
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
4157
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4158
- while (1) switch (_context45.prev = _context45.next) {
4267
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4268
+ while (1) switch (_context46.prev = _context46.next) {
4159
4269
  case 0:
4160
4270
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
4161
- _context45.next = 3;
4271
+ _context46.next = 3;
4162
4272
  return this.buildPendingSyncCheckoutOrder(data);
4163
4273
  case 3:
4164
- pendingOrder = _context45.sent;
4274
+ pendingOrder = _context46.sent;
4165
4275
  if (pendingOrder) {
4166
- _context45.next = 7;
4276
+ _context46.next = 7;
4167
4277
  break;
4168
4278
  }
4169
4279
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
4170
4280
  backendPath: backendPath,
4171
4281
  reason: reason
4172
4282
  });
4173
- return _context45.abrupt("return", {
4283
+ return _context46.abrupt("return", {
4174
4284
  code: 500,
4175
4285
  status: false,
4176
4286
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -4178,22 +4288,22 @@ var Server = /*#__PURE__*/function () {
4178
4288
  });
4179
4289
  case 7:
4180
4290
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
4181
- _context45.next = 10;
4291
+ _context46.next = 10;
4182
4292
  break;
4183
4293
  }
4184
4294
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
4185
4295
  backendPath: backendPath,
4186
4296
  reason: reason
4187
4297
  });
4188
- return _context45.abrupt("return", {
4298
+ return _context46.abrupt("return", {
4189
4299
  code: 500,
4190
4300
  status: false,
4191
4301
  message: 'Order 模块不支持本地待同步写入',
4192
4302
  data: null
4193
4303
  });
4194
4304
  case 10:
4195
- _context45.prev = 10;
4196
- _context45.next = 13;
4305
+ _context46.prev = 10;
4306
+ _context46.next = 13;
4197
4307
  return this.order.upsertPendingSyncOrders([pendingOrder]);
4198
4308
  case 13:
4199
4309
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -4207,7 +4317,7 @@ var Server = /*#__PURE__*/function () {
4207
4317
  var _payment$metadata;
4208
4318
  return sum + _this10.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
4209
4319
  }, 0);
4210
- return _context45.abrupt("return", {
4320
+ return _context46.abrupt("return", {
4211
4321
  code: 200,
4212
4322
  status: true,
4213
4323
  message: '',
@@ -4222,15 +4332,15 @@ var Server = /*#__PURE__*/function () {
4222
4332
  })
4223
4333
  });
4224
4334
  case 18:
4225
- _context45.prev = 18;
4226
- _context45.t0 = _context45["catch"](10);
4227
- errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
4335
+ _context46.prev = 18;
4336
+ _context46.t0 = _context46["catch"](10);
4337
+ errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4228
4338
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
4229
4339
  backendPath: backendPath,
4230
4340
  reason: reason,
4231
4341
  error: errorMessage
4232
4342
  });
4233
- return _context45.abrupt("return", {
4343
+ return _context46.abrupt("return", {
4234
4344
  code: 500,
4235
4345
  status: false,
4236
4346
  message: errorMessage,
@@ -4238,11 +4348,11 @@ var Server = /*#__PURE__*/function () {
4238
4348
  });
4239
4349
  case 23:
4240
4350
  case "end":
4241
- return _context45.stop();
4351
+ return _context46.stop();
4242
4352
  }
4243
- }, _callee45, this, [[10, 18]]);
4353
+ }, _callee46, this, [[10, 18]]);
4244
4354
  }));
4245
- function handlePendingSyncCheckoutOrder(_x48) {
4355
+ function handlePendingSyncCheckoutOrder(_x50) {
4246
4356
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
4247
4357
  }
4248
4358
  return handlePendingSyncCheckoutOrder;
@@ -4250,43 +4360,43 @@ var Server = /*#__PURE__*/function () {
4250
4360
  }, {
4251
4361
  key: "buildPendingSyncCheckoutOrder",
4252
4362
  value: function () {
4253
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4363
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4254
4364
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
4255
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4256
- while (1) switch (_context46.prev = _context46.next) {
4365
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4366
+ while (1) switch (_context47.prev = _context47.next) {
4257
4367
  case 0:
4258
4368
  if (!(!data || _typeof(data) !== 'object')) {
4259
- _context46.next = 2;
4369
+ _context47.next = 2;
4260
4370
  break;
4261
4371
  }
4262
- return _context46.abrupt("return", null);
4372
+ return _context47.abrupt("return", null);
4263
4373
  case 2:
4264
4374
  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 !== '';
4265
4375
  if (hasStorageKey) {
4266
- _context46.next = 5;
4376
+ _context47.next = 5;
4267
4377
  break;
4268
4378
  }
4269
- return _context46.abrupt("return", null);
4379
+ return _context47.abrupt("return", null);
4270
4380
  case 5:
4271
4381
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
4272
4382
  need_sync: 1
4273
4383
  });
4274
- _context46.next = 8;
4384
+ _context47.next = 8;
4275
4385
  return this.buildSmallTicketProductMap(pendingOrder);
4276
4386
  case 8:
4277
- productMap = _context46.sent;
4387
+ productMap = _context47.sent;
4278
4388
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
4279
- return _context46.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
4389
+ return _context47.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
4280
4390
  requireFullyPaid: true,
4281
4391
  productMap: productMap
4282
4392
  }));
4283
4393
  case 11:
4284
4394
  case "end":
4285
- return _context46.stop();
4395
+ return _context47.stop();
4286
4396
  }
4287
- }, _callee46, this);
4397
+ }, _callee47, this);
4288
4398
  }));
4289
- function buildPendingSyncCheckoutOrder(_x49) {
4399
+ function buildPendingSyncCheckoutOrder(_x51) {
4290
4400
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
4291
4401
  }
4292
4402
  return buildPendingSyncCheckoutOrder;
@@ -4354,12 +4464,12 @@ var Server = /*#__PURE__*/function () {
4354
4464
  }, {
4355
4465
  key: "buildSmallTicketProductMap",
4356
4466
  value: function () {
4357
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order) {
4467
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(order) {
4358
4468
  var _this$products,
4359
4469
  _this12 = this;
4360
4470
  var products, productIdSet, productIds, entries;
4361
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4362
- while (1) switch (_context48.prev = _context48.next) {
4471
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4472
+ while (1) switch (_context49.prev = _context49.next) {
4363
4473
  case 0:
4364
4474
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
4365
4475
  productIdSet = new Set();
@@ -4381,45 +4491,45 @@ var Server = /*#__PURE__*/function () {
4381
4491
  });
4382
4492
  productIds = Array.from(productIdSet);
4383
4493
  if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
4384
- _context48.next = 6;
4494
+ _context49.next = 6;
4385
4495
  break;
4386
4496
  }
4387
- return _context48.abrupt("return", {});
4497
+ return _context49.abrupt("return", {});
4388
4498
  case 6:
4389
- _context48.next = 8;
4499
+ _context49.next = 8;
4390
4500
  return Promise.all(productIds.map( /*#__PURE__*/function () {
4391
- var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(id) {
4501
+ var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(id) {
4392
4502
  var _this12$products, _this12$products$getP, product;
4393
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4394
- while (1) switch (_context47.prev = _context47.next) {
4503
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4504
+ while (1) switch (_context48.prev = _context48.next) {
4395
4505
  case 0:
4396
- _context47.prev = 0;
4397
- _context47.next = 3;
4506
+ _context48.prev = 0;
4507
+ _context48.next = 3;
4398
4508
  return (_this12$products = _this12.products) === null || _this12$products === void 0 || (_this12$products$getP = _this12$products.getProductById) === null || _this12$products$getP === void 0 ? void 0 : _this12$products$getP.call(_this12$products, Number(id));
4399
4509
  case 3:
4400
- product = _context47.sent;
4401
- return _context47.abrupt("return", product ? [String(id), product] : null);
4510
+ product = _context48.sent;
4511
+ return _context48.abrupt("return", product ? [String(id), product] : null);
4402
4512
  case 7:
4403
- _context47.prev = 7;
4404
- _context47.t0 = _context47["catch"](0);
4513
+ _context48.prev = 7;
4514
+ _context48.t0 = _context48["catch"](0);
4405
4515
  _this12.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
4406
4516
  product_id: id,
4407
- error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4517
+ error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
4408
4518
  });
4409
- return _context47.abrupt("return", null);
4519
+ return _context48.abrupt("return", null);
4410
4520
  case 11:
4411
4521
  case "end":
4412
- return _context47.stop();
4522
+ return _context48.stop();
4413
4523
  }
4414
- }, _callee47, null, [[0, 7]]);
4524
+ }, _callee48, null, [[0, 7]]);
4415
4525
  }));
4416
- return function (_x51) {
4526
+ return function (_x53) {
4417
4527
  return _ref58.apply(this, arguments);
4418
4528
  };
4419
4529
  }()));
4420
4530
  case 8:
4421
- entries = _context48.sent;
4422
- return _context48.abrupt("return", entries.reduce(function (map, entry) {
4531
+ entries = _context49.sent;
4532
+ return _context49.abrupt("return", entries.reduce(function (map, entry) {
4423
4533
  if (!entry) return map;
4424
4534
  var _entry = _slicedToArray(entry, 2),
4425
4535
  id = _entry[0],
@@ -4429,11 +4539,11 @@ var Server = /*#__PURE__*/function () {
4429
4539
  }, {}));
4430
4540
  case 10:
4431
4541
  case "end":
4432
- return _context48.stop();
4542
+ return _context49.stop();
4433
4543
  }
4434
- }, _callee48, this);
4544
+ }, _callee49, this);
4435
4545
  }));
4436
- function buildSmallTicketProductMap(_x50) {
4546
+ function buildSmallTicketProductMap(_x52) {
4437
4547
  return _buildSmallTicketProductMap.apply(this, arguments);
4438
4548
  }
4439
4549
  return buildSmallTicketProductMap;
@@ -4529,8 +4639,8 @@ var Server = /*#__PURE__*/function () {
4529
4639
  if (_typeof(value) !== 'object') return String(value);
4530
4640
  var preferredKeys = ['auto', 'en', 'original', 'zh-CN', 'zh_CN', 'zh-HK', 'zh_HK', 'kitchen', 'ja', 'pt', 'default'];
4531
4641
  for (var _i2 = 0, _preferredKeys = preferredKeys; _i2 < _preferredKeys.length; _i2++) {
4532
- var _key5 = _preferredKeys[_i2];
4533
- var rawValue = value[_key5];
4642
+ var _key6 = _preferredKeys[_i2];
4643
+ var rawValue = value[_key6];
4534
4644
  if (rawValue !== undefined && rawValue !== null && rawValue !== '') return String(rawValue);
4535
4645
  }
4536
4646
  var firstValue = Object.values(value).find(function (item) {
@@ -4541,62 +4651,62 @@ var Server = /*#__PURE__*/function () {
4541
4651
  }, {
4542
4652
  key: "withLocalSmallTicketData",
4543
4653
  value: function () {
4544
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(order, options) {
4654
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(order, options) {
4545
4655
  var _options$productMap, productMap, smallTicketData;
4546
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4547
- while (1) switch (_context49.prev = _context49.next) {
4656
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4657
+ while (1) switch (_context50.prev = _context50.next) {
4548
4658
  case 0:
4549
4659
  if (this.shouldBuildSmallTicketData(order)) {
4550
- _context49.next = 2;
4660
+ _context50.next = 2;
4551
4661
  break;
4552
4662
  }
4553
- return _context49.abrupt("return", order);
4663
+ return _context50.abrupt("return", order);
4554
4664
  case 2:
4555
4665
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
4556
- _context49.next = 4;
4666
+ _context50.next = 4;
4557
4667
  break;
4558
4668
  }
4559
- return _context49.abrupt("return", order);
4669
+ return _context50.abrupt("return", order);
4560
4670
  case 4:
4561
- _context49.prev = 4;
4671
+ _context50.prev = 4;
4562
4672
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
4563
- _context49.next = 9;
4673
+ _context50.next = 9;
4564
4674
  break;
4565
4675
  }
4566
- _context49.t0 = _options$productMap;
4567
- _context49.next = 12;
4676
+ _context50.t0 = _options$productMap;
4677
+ _context50.next = 12;
4568
4678
  break;
4569
4679
  case 9:
4570
- _context49.next = 11;
4680
+ _context50.next = 11;
4571
4681
  return this.buildSmallTicketProductMap(order);
4572
4682
  case 11:
4573
- _context49.t0 = _context49.sent;
4683
+ _context50.t0 = _context50.sent;
4574
4684
  case 12:
4575
- productMap = _context49.t0;
4685
+ productMap = _context50.t0;
4576
4686
  smallTicketData = buildSmallTicketData({
4577
4687
  order: order,
4578
4688
  shopInfo: this.getSmallTicketShopInfo(),
4579
4689
  productMap: productMap
4580
4690
  });
4581
- return _context49.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4691
+ return _context50.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4582
4692
  payment_info: _objectSpread(_objectSpread({}, order.payment_info || {}), {}, {
4583
4693
  small_ticket_data: smallTicketData
4584
4694
  })
4585
4695
  }));
4586
4696
  case 17:
4587
- _context49.prev = 17;
4588
- _context49.t1 = _context49["catch"](4);
4697
+ _context50.prev = 17;
4698
+ _context50.t1 = _context50["catch"](4);
4589
4699
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
4590
- error: _context49.t1 instanceof Error ? _context49.t1.message : String(_context49.t1)
4700
+ error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1)
4591
4701
  });
4592
- return _context49.abrupt("return", order);
4702
+ return _context50.abrupt("return", order);
4593
4703
  case 21:
4594
4704
  case "end":
4595
- return _context49.stop();
4705
+ return _context50.stop();
4596
4706
  }
4597
- }, _callee49, this, [[4, 17]]);
4707
+ }, _callee50, this, [[4, 17]]);
4598
4708
  }));
4599
- function withLocalSmallTicketData(_x52, _x53) {
4709
+ function withLocalSmallTicketData(_x54, _x55) {
4600
4710
  return _withLocalSmallTicketData.apply(this, arguments);
4601
4711
  }
4602
4712
  return withLocalSmallTicketData;
@@ -4658,22 +4768,22 @@ var Server = /*#__PURE__*/function () {
4658
4768
  }, {
4659
4769
  key: "handleUpdateLocalOrdersBatch",
4660
4770
  value: (function () {
4661
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderIds) {
4771
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderIds) {
4662
4772
  var _this$app14;
4663
4773
  var existedBefore, _iterator12, _step12, id, fetched, message, fetchedMap, _iterator13, _step13, order, oid, freshOrders, succeedIds, failed, _iterator14, _step14, _id, fresh, _message2, overwritten, inserted;
4664
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4665
- while (1) switch (_context50.prev = _context50.next) {
4774
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4775
+ while (1) switch (_context51.prev = _context51.next) {
4666
4776
  case 0:
4667
4777
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
4668
4778
  count: orderIds.length,
4669
4779
  orderIds: orderIds
4670
4780
  });
4671
4781
  if (this.order) {
4672
- _context50.next = 4;
4782
+ _context51.next = 4;
4673
4783
  break;
4674
4784
  }
4675
4785
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
4676
- return _context50.abrupt("return", {
4786
+ return _context51.abrupt("return", {
4677
4787
  code: 500,
4678
4788
  status: false,
4679
4789
  message: 'Order 模块未注册',
@@ -4681,11 +4791,11 @@ var Server = /*#__PURE__*/function () {
4681
4791
  });
4682
4792
  case 4:
4683
4793
  if ((_this$app14 = this.app) !== null && _this$app14 !== void 0 && _this$app14.request) {
4684
- _context50.next = 7;
4794
+ _context51.next = 7;
4685
4795
  break;
4686
4796
  }
4687
4797
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
4688
- return _context50.abrupt("return", {
4798
+ return _context51.abrupt("return", {
4689
4799
  code: 500,
4690
4800
  status: false,
4691
4801
  message: 'app.request 不可用',
@@ -4708,21 +4818,21 @@ var Server = /*#__PURE__*/function () {
4708
4818
  _iterator12.f();
4709
4819
  }
4710
4820
  fetched = [];
4711
- _context50.prev = 11;
4712
- _context50.next = 14;
4821
+ _context51.prev = 11;
4822
+ _context51.next = 14;
4713
4823
  return this.order.fetchOrdersByHttp(orderIds);
4714
4824
  case 14:
4715
- fetched = _context50.sent;
4716
- _context50.next = 22;
4825
+ fetched = _context51.sent;
4826
+ _context51.next = 22;
4717
4827
  break;
4718
4828
  case 17:
4719
- _context50.prev = 17;
4720
- _context50.t0 = _context50["catch"](11);
4721
- message = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
4829
+ _context51.prev = 17;
4830
+ _context51.t0 = _context51["catch"](11);
4831
+ message = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
4722
4832
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
4723
4833
  message: message
4724
4834
  });
4725
- return _context50.abrupt("return", {
4835
+ return _context51.abrupt("return", {
4726
4836
  code: 500,
4727
4837
  status: false,
4728
4838
  message: message,
@@ -4732,36 +4842,36 @@ var Server = /*#__PURE__*/function () {
4732
4842
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
4733
4843
  fetchedMap = new Map();
4734
4844
  _iterator13 = _createForOfIteratorHelper(fetched);
4735
- _context50.prev = 24;
4845
+ _context51.prev = 24;
4736
4846
  _iterator13.s();
4737
4847
  case 26:
4738
4848
  if ((_step13 = _iterator13.n()).done) {
4739
- _context50.next = 34;
4849
+ _context51.next = 34;
4740
4850
  break;
4741
4851
  }
4742
4852
  order = _step13.value;
4743
4853
  oid = order === null || order === void 0 ? void 0 : order.order_id;
4744
4854
  if (!(oid === undefined || oid === null)) {
4745
- _context50.next = 31;
4855
+ _context51.next = 31;
4746
4856
  break;
4747
4857
  }
4748
- return _context50.abrupt("continue", 32);
4858
+ return _context51.abrupt("continue", 32);
4749
4859
  case 31:
4750
4860
  fetchedMap.set(String(oid), order);
4751
4861
  case 32:
4752
- _context50.next = 26;
4862
+ _context51.next = 26;
4753
4863
  break;
4754
4864
  case 34:
4755
- _context50.next = 39;
4865
+ _context51.next = 39;
4756
4866
  break;
4757
4867
  case 36:
4758
- _context50.prev = 36;
4759
- _context50.t1 = _context50["catch"](24);
4760
- _iterator13.e(_context50.t1);
4868
+ _context51.prev = 36;
4869
+ _context51.t1 = _context51["catch"](24);
4870
+ _iterator13.e(_context51.t1);
4761
4871
  case 39:
4762
- _context50.prev = 39;
4872
+ _context51.prev = 39;
4763
4873
  _iterator13.f();
4764
- return _context50.finish(39);
4874
+ return _context51.finish(39);
4765
4875
  case 42:
4766
4876
  freshOrders = [];
4767
4877
  succeedIds = [];
@@ -4787,23 +4897,23 @@ var Server = /*#__PURE__*/function () {
4787
4897
  _iterator14.f();
4788
4898
  }
4789
4899
  if (!(freshOrders.length > 0)) {
4790
- _context50.next = 58;
4900
+ _context51.next = 58;
4791
4901
  break;
4792
4902
  }
4793
- _context50.prev = 48;
4794
- _context50.next = 51;
4903
+ _context51.prev = 48;
4904
+ _context51.next = 51;
4795
4905
  return this.order.upsertOrdersFromRemote(freshOrders);
4796
4906
  case 51:
4797
- _context50.next = 58;
4907
+ _context51.next = 58;
4798
4908
  break;
4799
4909
  case 53:
4800
- _context50.prev = 53;
4801
- _context50.t2 = _context50["catch"](48);
4802
- _message2 = _context50.t2 instanceof Error ? _context50.t2.message : String(_context50.t2);
4910
+ _context51.prev = 53;
4911
+ _context51.t2 = _context51["catch"](48);
4912
+ _message2 = _context51.t2 instanceof Error ? _context51.t2.message : String(_context51.t2);
4803
4913
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
4804
4914
  message: _message2
4805
4915
  });
4806
- return _context50.abrupt("return", {
4916
+ return _context51.abrupt("return", {
4807
4917
  code: 500,
4808
4918
  status: false,
4809
4919
  message: _message2,
@@ -4822,7 +4932,7 @@ var Server = /*#__PURE__*/function () {
4822
4932
  insertedCount: inserted.length,
4823
4933
  failedCount: failed.length
4824
4934
  });
4825
- return _context50.abrupt("return", {
4935
+ return _context51.abrupt("return", {
4826
4936
  code: 200,
4827
4937
  status: true,
4828
4938
  message: '',
@@ -4834,11 +4944,11 @@ var Server = /*#__PURE__*/function () {
4834
4944
  });
4835
4945
  case 62:
4836
4946
  case "end":
4837
- return _context50.stop();
4947
+ return _context51.stop();
4838
4948
  }
4839
- }, _callee50, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4949
+ }, _callee51, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4840
4950
  }));
4841
- function handleUpdateLocalOrdersBatch(_x54) {
4951
+ function handleUpdateLocalOrdersBatch(_x56) {
4842
4952
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
4843
4953
  }
4844
4954
  return handleUpdateLocalOrdersBatch;
@@ -5007,13 +5117,67 @@ var Server = /*#__PURE__*/function () {
5007
5117
  var isErrorSuccess = (normalized === null || normalized === void 0 ? void 0 : normalized.success) === false;
5008
5118
  return isErrorCode || isErrorStatus || isErrorSuccess;
5009
5119
  }
5120
+ }, {
5121
+ key: "getUnknownErrorMessage",
5122
+ value: function getUnknownErrorMessage(error) {
5123
+ var _error$response, _error$data, _error$response2, _error$body;
5124
+ if (error instanceof Error && error.message) return error.message;
5125
+ if (typeof error === 'string') return error;
5126
+ var candidates = [error === null || error === void 0 ? void 0 : error.message, error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, error === null || error === void 0 || (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.body) === null || _error$response2 === void 0 ? void 0 : _error$response2.message, error === null || error === void 0 || (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message];
5127
+ var message = candidates.find(function (candidate) {
5128
+ return typeof candidate === 'string' && candidate !== '';
5129
+ });
5130
+ if (message) return message;
5131
+ var normalized = this.normalizeUnknownError(error);
5132
+ if (typeof normalized === 'string') return normalized;
5133
+ try {
5134
+ return JSON.stringify(normalized);
5135
+ } catch (_unused3) {
5136
+ return String(error);
5137
+ }
5138
+ }
5139
+ }, {
5140
+ key: "normalizeUnknownError",
5141
+ value: function normalizeUnknownError(error) {
5142
+ if (error instanceof Error) {
5143
+ var _record$response, _record$response2;
5144
+ var normalized = {
5145
+ name: error.name,
5146
+ message: error.message,
5147
+ stack: error.stack
5148
+ };
5149
+ var record = error;
5150
+ if (((_record$response = record.response) === null || _record$response === void 0 ? void 0 : _record$response.data) !== undefined) normalized.responseData = record.response.data;
5151
+ if (record.data !== undefined) normalized.data = record.data;
5152
+ if (((_record$response2 = record.response) === null || _record$response2 === void 0 ? void 0 : _record$response2.body) !== undefined) normalized.responseBody = record.response.body;
5153
+ if (record.body !== undefined) normalized.body = record.body;
5154
+ return this.safeJsonClone(normalized);
5155
+ }
5156
+ if (!error || _typeof(error) !== 'object') return String(error);
5157
+ return this.safeJsonClone(error);
5158
+ }
5159
+ }, {
5160
+ key: "safeJsonClone",
5161
+ value: function safeJsonClone(value) {
5162
+ var seen = new WeakSet();
5163
+ try {
5164
+ return JSON.parse(JSON.stringify(value, function (_key, current) {
5165
+ if (!current || _typeof(current) !== 'object') return current;
5166
+ if (seen.has(current)) return '[Circular]';
5167
+ seen.add(current);
5168
+ return current;
5169
+ }));
5170
+ } catch (_unused4) {
5171
+ return String(value);
5172
+ }
5173
+ }
5010
5174
  }, {
5011
5175
  key: "extractBackendErrorResponse",
5012
5176
  value: function extractBackendErrorResponse(error) {
5013
- var _error$response,
5014
- _error$response2,
5177
+ var _error$response3,
5178
+ _error$response4,
5015
5179
  _this15 = this;
5016
- var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
5180
+ var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
5017
5181
  return candidates.find(function (candidate) {
5018
5182
  return _this15.isExplicitBackendErrorResponse(candidate);
5019
5183
  }) || null;
@@ -5036,7 +5200,7 @@ var Server = /*#__PURE__*/function () {
5036
5200
  try {
5037
5201
  var pathname = url.startsWith('http') ? new URL(url).pathname : noQuery;
5038
5202
  return pathname.replace(/\/$/, '') || pathname;
5039
- } catch (_unused3) {
5203
+ } catch (_unused5) {
5040
5204
  return noQuery.replace(/\/$/, '');
5041
5205
  }
5042
5206
  }
@@ -5134,16 +5298,16 @@ var Server = /*#__PURE__*/function () {
5134
5298
  }, {
5135
5299
  key: "recomputeAndNotifyFloorPlanQuery",
5136
5300
  value: (function () {
5137
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
5301
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5138
5302
  var _iterator16, _step16, _step16$value, subscriberId, sub, result, errorMessage;
5139
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5140
- while (1) switch (_context51.prev = _context51.next) {
5303
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5304
+ while (1) switch (_context52.prev = _context52.next) {
5141
5305
  case 0:
5142
5306
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
5143
- _context51.next = 2;
5307
+ _context52.next = 2;
5144
5308
  break;
5145
5309
  }
5146
- return _context51.abrupt("return");
5310
+ return _context52.abrupt("return");
5147
5311
  case 2:
5148
5312
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
5149
5313
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -5173,9 +5337,9 @@ var Server = /*#__PURE__*/function () {
5173
5337
  }
5174
5338
  case 5:
5175
5339
  case "end":
5176
- return _context51.stop();
5340
+ return _context52.stop();
5177
5341
  }
5178
- }, _callee51, this);
5342
+ }, _callee52, this);
5179
5343
  }));
5180
5344
  function recomputeAndNotifyFloorPlanQuery() {
5181
5345
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -5205,21 +5369,21 @@ var Server = /*#__PURE__*/function () {
5205
5369
  * filter 逻辑暂为 mock,仅记录参数
5206
5370
  */
5207
5371
  function () {
5208
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data) {
5372
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data) {
5209
5373
  var rawList, result;
5210
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5211
- while (1) switch (_context52.prev = _context52.next) {
5374
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5375
+ while (1) switch (_context53.prev = _context53.next) {
5212
5376
  case 0:
5213
5377
  this.logInfo('computeOrderQueryResult: 开始过滤', {
5214
5378
  data: data
5215
5379
  });
5216
5380
  console.log('[Server] computeOrderQueryResult', data);
5217
5381
  if (this.order) {
5218
- _context52.next = 5;
5382
+ _context53.next = 5;
5219
5383
  break;
5220
5384
  }
5221
5385
  this.logError('computeOrderQueryResult: Order 模块未注册');
5222
- return _context52.abrupt("return", {
5386
+ return _context53.abrupt("return", {
5223
5387
  code: 500,
5224
5388
  message: 'Order 模块未注册',
5225
5389
  data: {
@@ -5243,7 +5407,7 @@ var Server = /*#__PURE__*/function () {
5243
5407
  skip: result.skip,
5244
5408
  rejected: result.rejected
5245
5409
  });
5246
- return _context52.abrupt("return", {
5410
+ return _context53.abrupt("return", {
5247
5411
  code: 200,
5248
5412
  data: result,
5249
5413
  message: '',
@@ -5251,11 +5415,11 @@ var Server = /*#__PURE__*/function () {
5251
5415
  });
5252
5416
  case 10:
5253
5417
  case "end":
5254
- return _context52.stop();
5418
+ return _context53.stop();
5255
5419
  }
5256
- }, _callee52, this);
5420
+ }, _callee53, this);
5257
5421
  }));
5258
- function computeOrderQueryResult(_x55) {
5422
+ function computeOrderQueryResult(_x57) {
5259
5423
  return _computeOrderQueryResult.apply(this, arguments);
5260
5424
  }
5261
5425
  return computeOrderQueryResult;
@@ -5268,17 +5432,17 @@ var Server = /*#__PURE__*/function () {
5268
5432
  }, {
5269
5433
  key: "computeBookingQueryResult",
5270
5434
  value: (function () {
5271
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data) {
5435
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
5272
5436
  var rawOrders, result;
5273
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5274
- while (1) switch (_context53.prev = _context53.next) {
5437
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5438
+ while (1) switch (_context54.prev = _context54.next) {
5275
5439
  case 0:
5276
5440
  if (this.order) {
5277
- _context53.next = 3;
5441
+ _context54.next = 3;
5278
5442
  break;
5279
5443
  }
5280
5444
  this.logError('computeBookingQueryResult: Order 模块未注册');
5281
- return _context53.abrupt("return", {
5445
+ return _context54.abrupt("return", {
5282
5446
  code: 500,
5283
5447
  message: 'Order 模块未注册',
5284
5448
  data: {
@@ -5297,7 +5461,7 @@ var Server = /*#__PURE__*/function () {
5297
5461
  size: result.size,
5298
5462
  skip: result.skip
5299
5463
  });
5300
- return _context53.abrupt("return", {
5464
+ return _context54.abrupt("return", {
5301
5465
  code: 200,
5302
5466
  data: result,
5303
5467
  message: '',
@@ -5305,11 +5469,11 @@ var Server = /*#__PURE__*/function () {
5305
5469
  });
5306
5470
  case 8:
5307
5471
  case "end":
5308
- return _context53.stop();
5472
+ return _context54.stop();
5309
5473
  }
5310
- }, _callee53, this);
5474
+ }, _callee54, this);
5311
5475
  }));
5312
- function computeBookingQueryResult(_x56) {
5476
+ function computeBookingQueryResult(_x58) {
5313
5477
  return _computeBookingQueryResult.apply(this, arguments);
5314
5478
  }
5315
5479
  return computeBookingQueryResult;
@@ -5325,12 +5489,12 @@ var Server = /*#__PURE__*/function () {
5325
5489
  }, {
5326
5490
  key: "computeProductQueryResult",
5327
5491
  value: (function () {
5328
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(context, options) {
5492
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(context, options) {
5329
5493
  var _menu_list_ids$length3,
5330
5494
  _this16 = this;
5331
5495
  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;
5332
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5333
- while (1) switch (_context54.prev = _context54.next) {
5496
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5497
+ while (1) switch (_context55.prev = _context55.next) {
5334
5498
  case 0:
5335
5499
  tTotal = performance.now();
5336
5500
  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;
@@ -5349,11 +5513,11 @@ var Server = /*#__PURE__*/function () {
5349
5513
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5350
5514
  });
5351
5515
  if (this.products) {
5352
- _context54.next = 7;
5516
+ _context55.next = 7;
5353
5517
  break;
5354
5518
  }
5355
5519
  this.logError('computeProductQueryResult: Products 模块未注册');
5356
- return _context54.abrupt("return", {
5520
+ return _context55.abrupt("return", {
5357
5521
  message: 'Products 模块未注册',
5358
5522
  data: {
5359
5523
  list: [],
@@ -5362,12 +5526,12 @@ var Server = /*#__PURE__*/function () {
5362
5526
  });
5363
5527
  case 7:
5364
5528
  if (!(queryIds.length > 0)) {
5365
- _context54.next = 18;
5529
+ _context55.next = 18;
5366
5530
  break;
5367
5531
  }
5368
5532
  uniqueIds = Array.from(new Set(queryIds));
5369
5533
  _tPrice = performance.now();
5370
- _context54.next = 12;
5534
+ _context55.next = 12;
5371
5535
  return this.products.getProductsWithPrice(schedule_date, {
5372
5536
  scheduleModule: this.getSchedule(),
5373
5537
  schedule_datetime: schedule_datetime,
@@ -5377,7 +5541,7 @@ var Server = /*#__PURE__*/function () {
5377
5541
  productIds: uniqueIds
5378
5542
  });
5379
5543
  case 12:
5380
- productsWithPrice = _context54.sent;
5544
+ productsWithPrice = _context55.sent;
5381
5545
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
5382
5546
  count: productsWithPrice.length,
5383
5547
  ids: uniqueIds
@@ -5396,7 +5560,7 @@ var Server = /*#__PURE__*/function () {
5396
5560
  ids: uniqueIds,
5397
5561
  count: _filteredProducts.length
5398
5562
  });
5399
- return _context54.abrupt("return", {
5563
+ return _context55.abrupt("return", {
5400
5564
  code: 200,
5401
5565
  data: {
5402
5566
  list: _filteredProducts,
@@ -5407,19 +5571,19 @@ var Server = /*#__PURE__*/function () {
5407
5571
  });
5408
5572
  case 18:
5409
5573
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
5410
- _context54.next = 30;
5574
+ _context55.next = 30;
5411
5575
  break;
5412
5576
  }
5413
5577
  pid = Number(product_id);
5414
5578
  _tPrice2 = performance.now();
5415
- _context54.next = 23;
5579
+ _context55.next = 23;
5416
5580
  return this.products.getProductsWithPrice(schedule_date, {
5417
5581
  scheduleModule: this.getSchedule()
5418
5582
  }, {
5419
5583
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5420
5584
  });
5421
5585
  case 23:
5422
- allProductsWithPrice = _context54.sent;
5586
+ allProductsWithPrice = _context55.sent;
5423
5587
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
5424
5588
  count: allProductsWithPrice.length,
5425
5589
  productId: pid
@@ -5439,7 +5603,7 @@ var Server = /*#__PURE__*/function () {
5439
5603
  productId: pid,
5440
5604
  found: !!item
5441
5605
  });
5442
- return _context54.abrupt("return", {
5606
+ return _context55.abrupt("return", {
5443
5607
  code: 200,
5444
5608
  data: item,
5445
5609
  message: item ? '' : '商品不存在或未发布',
@@ -5447,11 +5611,11 @@ var Server = /*#__PURE__*/function () {
5447
5611
  });
5448
5612
  case 30:
5449
5613
  if (this.menu) {
5450
- _context54.next = 33;
5614
+ _context55.next = 33;
5451
5615
  break;
5452
5616
  }
5453
5617
  this.logError('computeProductQueryResult: Menu 模块未注册');
5454
- return _context54.abrupt("return", {
5618
+ return _context55.abrupt("return", {
5455
5619
  message: 'Menu 模块未注册',
5456
5620
  data: {
5457
5621
  list: [],
@@ -5460,11 +5624,11 @@ var Server = /*#__PURE__*/function () {
5460
5624
  });
5461
5625
  case 33:
5462
5626
  if (this.schedule) {
5463
- _context54.next = 36;
5627
+ _context55.next = 36;
5464
5628
  break;
5465
5629
  }
5466
5630
  this.logError('computeProductQueryResult: Schedule 模块未注册');
5467
- return _context54.abrupt("return", {
5631
+ return _context55.abrupt("return", {
5468
5632
  message: 'Schedule 模块未注册',
5469
5633
  data: {
5470
5634
  list: [],
@@ -5495,10 +5659,10 @@ var Server = /*#__PURE__*/function () {
5495
5659
  });
5496
5660
  tPrice = performance.now();
5497
5661
  if (!(scopedProductIds.length > 0)) {
5498
- _context54.next = 49;
5662
+ _context55.next = 49;
5499
5663
  break;
5500
5664
  }
5501
- _context54.next = 46;
5665
+ _context55.next = 46;
5502
5666
  return this.products.getProductsWithPrice(schedule_date, {
5503
5667
  scheduleModule: this.getSchedule(),
5504
5668
  schedule_datetime: schedule_datetime,
@@ -5508,13 +5672,13 @@ var Server = /*#__PURE__*/function () {
5508
5672
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
5509
5673
  });
5510
5674
  case 46:
5511
- _context54.t0 = _context54.sent;
5512
- _context54.next = 50;
5675
+ _context55.t0 = _context55.sent;
5676
+ _context55.next = 50;
5513
5677
  break;
5514
5678
  case 49:
5515
- _context54.t0 = [];
5679
+ _context55.t0 = [];
5516
5680
  case 50:
5517
- filteredProducts = _context54.t0;
5681
+ filteredProducts = _context55.t0;
5518
5682
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
5519
5683
  count: filteredProducts.length,
5520
5684
  scopedProductCount: scopedProductIds.length
@@ -5547,7 +5711,7 @@ var Server = /*#__PURE__*/function () {
5547
5711
  filteredCount: filteredProducts.length,
5548
5712
  activeMenuCount: activeMenuList.length
5549
5713
  });
5550
- return _context54.abrupt("return", {
5714
+ return _context55.abrupt("return", {
5551
5715
  code: 200,
5552
5716
  data: {
5553
5717
  list: filteredProducts,
@@ -5558,11 +5722,11 @@ var Server = /*#__PURE__*/function () {
5558
5722
  });
5559
5723
  case 62:
5560
5724
  case "end":
5561
- return _context54.stop();
5725
+ return _context55.stop();
5562
5726
  }
5563
- }, _callee54, this);
5727
+ }, _callee55, this);
5564
5728
  }));
5565
- function computeProductQueryResult(_x57, _x58) {
5729
+ function computeProductQueryResult(_x59, _x60) {
5566
5730
  return _computeProductQueryResult.apply(this, arguments);
5567
5731
  }
5568
5732
  return computeProductQueryResult;
@@ -5577,72 +5741,72 @@ var Server = /*#__PURE__*/function () {
5577
5741
  }, {
5578
5742
  key: "recomputeAndNotifyProductQuery",
5579
5743
  value: (function () {
5580
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(options) {
5744
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(options) {
5581
5745
  var _iterator17, _step17, _step17$value, subscriberId, subscriber, result, errorMessage;
5582
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5583
- while (1) switch (_context55.prev = _context55.next) {
5746
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5747
+ while (1) switch (_context56.prev = _context56.next) {
5584
5748
  case 0:
5585
5749
  if (!(this.productQuerySubscribers.size === 0)) {
5586
- _context55.next = 2;
5750
+ _context56.next = 2;
5587
5751
  break;
5588
5752
  }
5589
- return _context55.abrupt("return");
5753
+ return _context56.abrupt("return");
5590
5754
  case 2:
5591
5755
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
5592
5756
  subscriberCount: this.productQuerySubscribers.size,
5593
5757
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5594
5758
  });
5595
5759
  _iterator17 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
5596
- _context55.prev = 4;
5760
+ _context56.prev = 4;
5597
5761
  _iterator17.s();
5598
5762
  case 6:
5599
5763
  if ((_step17 = _iterator17.n()).done) {
5600
- _context55.next = 22;
5764
+ _context56.next = 22;
5601
5765
  break;
5602
5766
  }
5603
5767
  _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], subscriber = _step17$value[1];
5604
- _context55.prev = 8;
5605
- _context55.next = 11;
5768
+ _context56.prev = 8;
5769
+ _context56.next = 11;
5606
5770
  return this.computeProductQueryResult(subscriber.context, {
5607
5771
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5608
5772
  });
5609
5773
  case 11:
5610
- result = _context55.sent;
5774
+ result = _context56.sent;
5611
5775
  subscriber.callback(result);
5612
5776
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
5613
5777
  subscriberId: subscriberId
5614
5778
  });
5615
- _context55.next = 20;
5779
+ _context56.next = 20;
5616
5780
  break;
5617
5781
  case 16:
5618
- _context55.prev = 16;
5619
- _context55.t0 = _context55["catch"](8);
5620
- errorMessage = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
5782
+ _context56.prev = 16;
5783
+ _context56.t0 = _context56["catch"](8);
5784
+ errorMessage = _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0);
5621
5785
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
5622
5786
  subscriberId: subscriberId,
5623
5787
  error: errorMessage
5624
5788
  });
5625
5789
  case 20:
5626
- _context55.next = 6;
5790
+ _context56.next = 6;
5627
5791
  break;
5628
5792
  case 22:
5629
- _context55.next = 27;
5793
+ _context56.next = 27;
5630
5794
  break;
5631
5795
  case 24:
5632
- _context55.prev = 24;
5633
- _context55.t1 = _context55["catch"](4);
5634
- _iterator17.e(_context55.t1);
5796
+ _context56.prev = 24;
5797
+ _context56.t1 = _context56["catch"](4);
5798
+ _iterator17.e(_context56.t1);
5635
5799
  case 27:
5636
- _context55.prev = 27;
5800
+ _context56.prev = 27;
5637
5801
  _iterator17.f();
5638
- return _context55.finish(27);
5802
+ return _context56.finish(27);
5639
5803
  case 30:
5640
5804
  case "end":
5641
- return _context55.stop();
5805
+ return _context56.stop();
5642
5806
  }
5643
- }, _callee55, this, [[4, 24, 27, 30], [8, 16]]);
5807
+ }, _callee56, this, [[4, 24, 27, 30], [8, 16]]);
5644
5808
  }));
5645
- function recomputeAndNotifyProductQuery(_x59) {
5809
+ function recomputeAndNotifyProductQuery(_x61) {
5646
5810
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
5647
5811
  }
5648
5812
  return recomputeAndNotifyProductQuery;
@@ -5654,16 +5818,16 @@ var Server = /*#__PURE__*/function () {
5654
5818
  }, {
5655
5819
  key: "recomputeAndNotifyOrderQuery",
5656
5820
  value: (function () {
5657
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5821
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5658
5822
  var notifyStartAt, _iterator18, _step18, _step18$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
5659
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5660
- while (1) switch (_context56.prev = _context56.next) {
5823
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5824
+ while (1) switch (_context57.prev = _context57.next) {
5661
5825
  case 0:
5662
5826
  if (!(this.orderQuerySubscribers.size === 0)) {
5663
- _context56.next = 2;
5827
+ _context57.next = 2;
5664
5828
  break;
5665
5829
  }
5666
- return _context56.abrupt("return");
5830
+ return _context57.abrupt("return");
5667
5831
  case 2:
5668
5832
  notifyStartAt = Date.now();
5669
5833
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -5671,20 +5835,20 @@ var Server = /*#__PURE__*/function () {
5671
5835
  notifyStartAt: new Date(notifyStartAt).toISOString()
5672
5836
  });
5673
5837
  _iterator18 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
5674
- _context56.prev = 5;
5838
+ _context57.prev = 5;
5675
5839
  _iterator18.s();
5676
5840
  case 7:
5677
5841
  if ((_step18 = _iterator18.n()).done) {
5678
- _context56.next = 27;
5842
+ _context57.next = 27;
5679
5843
  break;
5680
5844
  }
5681
5845
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
5682
- _context56.prev = 9;
5846
+ _context57.prev = 9;
5683
5847
  computeStartAt = Date.now();
5684
- _context56.next = 13;
5848
+ _context57.next = 13;
5685
5849
  return this.computeOrderQueryResult(subscriber.context);
5686
5850
  case 13:
5687
- result = _context56.sent;
5851
+ result = _context57.sent;
5688
5852
  computeEndAt = Date.now();
5689
5853
  callbackStartAt = Date.now();
5690
5854
  subscriber.callback(result);
@@ -5695,30 +5859,30 @@ var Server = /*#__PURE__*/function () {
5695
5859
  callbackDurationMs: callbackEndAt - callbackStartAt,
5696
5860
  totalDurationMs: callbackEndAt - computeStartAt
5697
5861
  });
5698
- _context56.next = 25;
5862
+ _context57.next = 25;
5699
5863
  break;
5700
5864
  case 21:
5701
- _context56.prev = 21;
5702
- _context56.t0 = _context56["catch"](9);
5703
- errorMessage = _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0);
5865
+ _context57.prev = 21;
5866
+ _context57.t0 = _context57["catch"](9);
5867
+ errorMessage = _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0);
5704
5868
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
5705
5869
  subscriberId: subscriberId,
5706
5870
  error: errorMessage
5707
5871
  });
5708
5872
  case 25:
5709
- _context56.next = 7;
5873
+ _context57.next = 7;
5710
5874
  break;
5711
5875
  case 27:
5712
- _context56.next = 32;
5876
+ _context57.next = 32;
5713
5877
  break;
5714
5878
  case 29:
5715
- _context56.prev = 29;
5716
- _context56.t1 = _context56["catch"](5);
5717
- _iterator18.e(_context56.t1);
5879
+ _context57.prev = 29;
5880
+ _context57.t1 = _context57["catch"](5);
5881
+ _iterator18.e(_context57.t1);
5718
5882
  case 32:
5719
- _context56.prev = 32;
5883
+ _context57.prev = 32;
5720
5884
  _iterator18.f();
5721
- return _context56.finish(32);
5885
+ return _context57.finish(32);
5722
5886
  case 35:
5723
5887
  notifyEndAt = Date.now();
5724
5888
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -5727,9 +5891,9 @@ var Server = /*#__PURE__*/function () {
5727
5891
  });
5728
5892
  case 37:
5729
5893
  case "end":
5730
- return _context56.stop();
5894
+ return _context57.stop();
5731
5895
  }
5732
- }, _callee56, this, [[5, 29, 32, 35], [9, 21]]);
5896
+ }, _callee57, this, [[5, 29, 32, 35], [9, 21]]);
5733
5897
  }));
5734
5898
  function recomputeAndNotifyOrderQuery() {
5735
5899
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -5867,67 +6031,67 @@ var Server = /*#__PURE__*/function () {
5867
6031
  }, {
5868
6032
  key: "recomputeAndNotifyBookingQuery",
5869
6033
  value: (function () {
5870
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
6034
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
5871
6035
  var _iterator20, _step20, _step20$value, subscriberId, subscriber, result, errorMessage;
5872
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5873
- while (1) switch (_context57.prev = _context57.next) {
6036
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6037
+ while (1) switch (_context58.prev = _context58.next) {
5874
6038
  case 0:
5875
6039
  if (!(this.bookingQuerySubscribers.size === 0)) {
5876
- _context57.next = 2;
6040
+ _context58.next = 2;
5877
6041
  break;
5878
6042
  }
5879
- return _context57.abrupt("return");
6043
+ return _context58.abrupt("return");
5880
6044
  case 2:
5881
6045
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
5882
6046
  subscriberCount: this.bookingQuerySubscribers.size
5883
6047
  });
5884
6048
  _iterator20 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
5885
- _context57.prev = 4;
6049
+ _context58.prev = 4;
5886
6050
  _iterator20.s();
5887
6051
  case 6:
5888
6052
  if ((_step20 = _iterator20.n()).done) {
5889
- _context57.next = 22;
6053
+ _context58.next = 22;
5890
6054
  break;
5891
6055
  }
5892
6056
  _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
5893
- _context57.prev = 8;
5894
- _context57.next = 11;
6057
+ _context58.prev = 8;
6058
+ _context58.next = 11;
5895
6059
  return this.computeBookingQueryResult(subscriber.context);
5896
6060
  case 11:
5897
- result = _context57.sent;
6061
+ result = _context58.sent;
5898
6062
  subscriber.callback(result);
5899
6063
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
5900
6064
  subscriberId: subscriberId
5901
6065
  });
5902
- _context57.next = 20;
6066
+ _context58.next = 20;
5903
6067
  break;
5904
6068
  case 16:
5905
- _context57.prev = 16;
5906
- _context57.t0 = _context57["catch"](8);
5907
- errorMessage = _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0);
6069
+ _context58.prev = 16;
6070
+ _context58.t0 = _context58["catch"](8);
6071
+ errorMessage = _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0);
5908
6072
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
5909
6073
  subscriberId: subscriberId,
5910
6074
  error: errorMessage
5911
6075
  });
5912
6076
  case 20:
5913
- _context57.next = 6;
6077
+ _context58.next = 6;
5914
6078
  break;
5915
6079
  case 22:
5916
- _context57.next = 27;
6080
+ _context58.next = 27;
5917
6081
  break;
5918
6082
  case 24:
5919
- _context57.prev = 24;
5920
- _context57.t1 = _context57["catch"](4);
5921
- _iterator20.e(_context57.t1);
6083
+ _context58.prev = 24;
6084
+ _context58.t1 = _context58["catch"](4);
6085
+ _iterator20.e(_context58.t1);
5922
6086
  case 27:
5923
- _context57.prev = 27;
6087
+ _context58.prev = 27;
5924
6088
  _iterator20.f();
5925
- return _context57.finish(27);
6089
+ return _context58.finish(27);
5926
6090
  case 30:
5927
6091
  case "end":
5928
- return _context57.stop();
6092
+ return _context58.stop();
5929
6093
  }
5930
- }, _callee57, this, [[4, 24, 27, 30], [8, 16]]);
6094
+ }, _callee58, this, [[4, 24, 27, 30], [8, 16]]);
5931
6095
  }));
5932
6096
  function recomputeAndNotifyBookingQuery() {
5933
6097
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -6073,7 +6237,7 @@ var Server = /*#__PURE__*/function () {
6073
6237
  metadata: metadata || {}
6074
6238
  });
6075
6239
  }
6076
- } catch (_unused4) {
6240
+ } catch (_unused6) {
6077
6241
  // 日志记录失败不影响主流程
6078
6242
  }
6079
6243
  }
@@ -6094,7 +6258,7 @@ var Server = /*#__PURE__*/function () {
6094
6258
  metadata: metadata || {}
6095
6259
  });
6096
6260
  }
6097
- } catch (_unused5) {
6261
+ } catch (_unused7) {
6098
6262
  // 日志记录失败不影响主流程
6099
6263
  }
6100
6264
  }
@@ -6115,7 +6279,7 @@ var Server = /*#__PURE__*/function () {
6115
6279
  metadata: metadata || {}
6116
6280
  });
6117
6281
  }
6118
- } catch (_unused6) {
6282
+ } catch (_unused8) {
6119
6283
  // 日志记录失败不影响主流程
6120
6284
  }
6121
6285
  }