@pisell/pisellos 2.2.248 → 2.2.250

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.
@@ -4887,64 +4887,171 @@ var Server = /*#__PURE__*/function () {
4887
4887
  return firstValue === undefined ? null : String(firstValue);
4888
4888
  }
4889
4889
  }, {
4890
- key: "withLocalSmallTicketData",
4890
+ key: "getPaymentCodeKey",
4891
+ value: function getPaymentCodeKey(code) {
4892
+ if (code === undefined || code === null) return '';
4893
+ return String(code).trim().toUpperCase();
4894
+ }
4895
+ }, {
4896
+ key: "isBlankPaymentName",
4897
+ value: function isBlankPaymentName(name) {
4898
+ if (name === undefined || name === null) return true;
4899
+ if (typeof name === 'string') return name.trim() === '';
4900
+ return false;
4901
+ }
4902
+ }, {
4903
+ key: "shouldLookupPaymentMethodNameByCode",
4904
+ value: function shouldLookupPaymentMethodNameByCode(code) {
4905
+ var codeKey = this.getPaymentCodeKey(code);
4906
+ if (!codeKey) return false;
4907
+ var builtInNameTokens = ['CASH', 'EFTPOS', 'CARD', 'WALLET', 'GIFT'];
4908
+ return !builtInNameTokens.some(function (token) {
4909
+ return codeKey.includes(token);
4910
+ });
4911
+ }
4912
+ }, {
4913
+ key: "enrichPaymentNamesByCode",
4891
4914
  value: function () {
4892
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(order, options) {
4893
- var _options$productMap, productMap, smallTicketData;
4915
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(order) {
4916
+ var _this15 = this;
4917
+ var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
4894
4918
  return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4895
4919
  while (1) switch (_context53.prev = _context53.next) {
4896
4920
  case 0:
4897
- if (this.shouldBuildSmallTicketData(order)) {
4898
- _context53.next = 2;
4921
+ payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
4922
+ hasMissingName = payments.some(function (payment) {
4923
+ return _this15.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this15.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
4924
+ });
4925
+ if (hasMissingName) {
4926
+ _context53.next = 4;
4899
4927
  break;
4900
4928
  }
4901
4929
  return _context53.abrupt("return", order);
4930
+ case 4:
4931
+ _context53.prev = 4;
4932
+ _context53.next = 7;
4933
+ return this.getPaymentRouteModule();
4934
+ case 7:
4935
+ paymentModule = _context53.sent;
4936
+ _context53.next = 10;
4937
+ return paymentModule.getPayMethodListAsync();
4938
+ case 10:
4939
+ payMethods = _context53.sent;
4940
+ nameByCode = new Map();
4941
+ _iterator12 = _createForOfIteratorHelper(payMethods || []);
4942
+ try {
4943
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
4944
+ method = _step12.value;
4945
+ codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
4946
+ name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
4947
+ if (codeKey && name) nameByCode.set(codeKey, name);
4948
+ }
4949
+ } catch (err) {
4950
+ _iterator12.e(err);
4951
+ } finally {
4952
+ _iterator12.f();
4953
+ }
4954
+ hasResolvedName = false;
4955
+ enrichedPayments = payments.map(function (payment) {
4956
+ if (!_this15.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
4957
+ if (!_this15.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
4958
+ var name = nameByCode.get(_this15.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
4959
+ if (!name) return payment;
4960
+ hasResolvedName = true;
4961
+ return _objectSpread(_objectSpread({}, payment), {}, {
4962
+ name: name
4963
+ });
4964
+ });
4965
+ if (hasResolvedName) {
4966
+ _context53.next = 18;
4967
+ break;
4968
+ }
4969
+ return _context53.abrupt("return", order);
4970
+ case 18:
4971
+ return _context53.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4972
+ payments: enrichedPayments
4973
+ }));
4974
+ case 21:
4975
+ _context53.prev = 21;
4976
+ _context53.t0 = _context53["catch"](4);
4977
+ this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
4978
+ error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
4979
+ });
4980
+ return _context53.abrupt("return", order);
4981
+ case 25:
4982
+ case "end":
4983
+ return _context53.stop();
4984
+ }
4985
+ }, _callee53, this, [[4, 21]]);
4986
+ }));
4987
+ function enrichPaymentNamesByCode(_x57) {
4988
+ return _enrichPaymentNamesByCode.apply(this, arguments);
4989
+ }
4990
+ return enrichPaymentNamesByCode;
4991
+ }()
4992
+ }, {
4993
+ key: "withLocalSmallTicketData",
4994
+ value: function () {
4995
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order, options) {
4996
+ var _options$productMap, enrichedOrder, productMap, smallTicketData;
4997
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4998
+ while (1) switch (_context54.prev = _context54.next) {
4999
+ case 0:
5000
+ if (this.shouldBuildSmallTicketData(order)) {
5001
+ _context54.next = 2;
5002
+ break;
5003
+ }
5004
+ return _context54.abrupt("return", order);
4902
5005
  case 2:
4903
5006
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
4904
- _context53.next = 4;
5007
+ _context54.next = 4;
4905
5008
  break;
4906
5009
  }
4907
- return _context53.abrupt("return", order);
5010
+ return _context54.abrupt("return", order);
4908
5011
  case 4:
4909
- _context53.prev = 4;
5012
+ _context54.prev = 4;
5013
+ _context54.next = 7;
5014
+ return this.enrichPaymentNamesByCode(order);
5015
+ case 7:
5016
+ enrichedOrder = _context54.sent;
4910
5017
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
4911
- _context53.next = 9;
5018
+ _context54.next = 12;
4912
5019
  break;
4913
5020
  }
4914
- _context53.t0 = _options$productMap;
4915
- _context53.next = 12;
5021
+ _context54.t0 = _options$productMap;
5022
+ _context54.next = 15;
4916
5023
  break;
4917
- case 9:
4918
- _context53.next = 11;
4919
- return this.buildSmallTicketProductMap(order);
4920
- case 11:
4921
- _context53.t0 = _context53.sent;
4922
5024
  case 12:
4923
- productMap = _context53.t0;
5025
+ _context54.next = 14;
5026
+ return this.buildSmallTicketProductMap(enrichedOrder);
5027
+ case 14:
5028
+ _context54.t0 = _context54.sent;
5029
+ case 15:
5030
+ productMap = _context54.t0;
4924
5031
  smallTicketData = buildSmallTicketData({
4925
- order: order,
5032
+ order: enrichedOrder,
4926
5033
  shopInfo: this.getSmallTicketShopInfo(),
4927
5034
  productMap: productMap
4928
5035
  });
4929
- return _context53.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4930
- payment_info: _objectSpread(_objectSpread({}, order.payment_info || {}), {}, {
5036
+ return _context54.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
5037
+ payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
4931
5038
  small_ticket_data: smallTicketData
4932
5039
  })
4933
5040
  }));
4934
- case 17:
4935
- _context53.prev = 17;
4936
- _context53.t1 = _context53["catch"](4);
5041
+ case 20:
5042
+ _context54.prev = 20;
5043
+ _context54.t1 = _context54["catch"](4);
4937
5044
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
4938
- error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
5045
+ error: _context54.t1 instanceof Error ? _context54.t1.message : String(_context54.t1)
4939
5046
  });
4940
- return _context53.abrupt("return", order);
4941
- case 21:
5047
+ return _context54.abrupt("return", order);
5048
+ case 24:
4942
5049
  case "end":
4943
- return _context53.stop();
5050
+ return _context54.stop();
4944
5051
  }
4945
- }, _callee53, this, [[4, 17]]);
5052
+ }, _callee54, this, [[4, 20]]);
4946
5053
  }));
4947
- function withLocalSmallTicketData(_x57, _x58) {
5054
+ function withLocalSmallTicketData(_x58, _x59) {
4948
5055
  return _withLocalSmallTicketData.apply(this, arguments);
4949
5056
  }
4950
5057
  return withLocalSmallTicketData;
@@ -5006,22 +5113,22 @@ var Server = /*#__PURE__*/function () {
5006
5113
  }, {
5007
5114
  key: "handleUpdateLocalOrdersBatch",
5008
5115
  value: (function () {
5009
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(orderIds) {
5116
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(orderIds) {
5010
5117
  var _this$app16;
5011
- var existedBefore, _iterator12, _step12, id, fetched, message, fetchedMap, _iterator13, _step13, order, oid, freshOrders, succeedIds, failed, _iterator14, _step14, _id, fresh, _message, overwritten, inserted;
5012
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5013
- while (1) switch (_context54.prev = _context54.next) {
5118
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message, overwritten, inserted;
5119
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5120
+ while (1) switch (_context55.prev = _context55.next) {
5014
5121
  case 0:
5015
5122
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
5016
5123
  count: orderIds.length,
5017
5124
  orderIds: orderIds
5018
5125
  });
5019
5126
  if (this.order) {
5020
- _context54.next = 4;
5127
+ _context55.next = 4;
5021
5128
  break;
5022
5129
  }
5023
5130
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
5024
- return _context54.abrupt("return", {
5131
+ return _context55.abrupt("return", {
5025
5132
  code: 500,
5026
5133
  status: false,
5027
5134
  message: 'Order 模块未注册',
@@ -5029,11 +5136,11 @@ var Server = /*#__PURE__*/function () {
5029
5136
  });
5030
5137
  case 4:
5031
5138
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && _this$app16.request) {
5032
- _context54.next = 7;
5139
+ _context55.next = 7;
5033
5140
  break;
5034
5141
  }
5035
5142
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
5036
- return _context54.abrupt("return", {
5143
+ return _context55.abrupt("return", {
5037
5144
  code: 500,
5038
5145
  status: false,
5039
5146
  message: 'app.request 不可用',
@@ -5042,35 +5149,35 @@ var Server = /*#__PURE__*/function () {
5042
5149
  case 7:
5043
5150
  // 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
5044
5151
  existedBefore = new Map();
5045
- _iterator12 = _createForOfIteratorHelper(orderIds);
5152
+ _iterator13 = _createForOfIteratorHelper(orderIds);
5046
5153
  try {
5047
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
5048
- id = _step12.value;
5154
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
5155
+ id = _step13.value;
5049
5156
  existedBefore.set(id, !!this.order.getOrderByOrderId(id));
5050
5157
  }
5051
5158
 
5052
5159
  // 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
5053
5160
  } catch (err) {
5054
- _iterator12.e(err);
5161
+ _iterator13.e(err);
5055
5162
  } finally {
5056
- _iterator12.f();
5163
+ _iterator13.f();
5057
5164
  }
5058
5165
  fetched = [];
5059
- _context54.prev = 11;
5060
- _context54.next = 14;
5166
+ _context55.prev = 11;
5167
+ _context55.next = 14;
5061
5168
  return this.order.fetchOrdersByHttp(orderIds);
5062
5169
  case 14:
5063
- fetched = _context54.sent;
5064
- _context54.next = 22;
5170
+ fetched = _context55.sent;
5171
+ _context55.next = 22;
5065
5172
  break;
5066
5173
  case 17:
5067
- _context54.prev = 17;
5068
- _context54.t0 = _context54["catch"](11);
5069
- message = _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0);
5174
+ _context55.prev = 17;
5175
+ _context55.t0 = _context55["catch"](11);
5176
+ message = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
5070
5177
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
5071
5178
  message: message
5072
5179
  });
5073
- return _context54.abrupt("return", {
5180
+ return _context55.abrupt("return", {
5074
5181
  code: 500,
5075
5182
  status: false,
5076
5183
  message: message,
@@ -5079,45 +5186,45 @@ var Server = /*#__PURE__*/function () {
5079
5186
  case 22:
5080
5187
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
5081
5188
  fetchedMap = new Map();
5082
- _iterator13 = _createForOfIteratorHelper(fetched);
5083
- _context54.prev = 24;
5084
- _iterator13.s();
5189
+ _iterator14 = _createForOfIteratorHelper(fetched);
5190
+ _context55.prev = 24;
5191
+ _iterator14.s();
5085
5192
  case 26:
5086
- if ((_step13 = _iterator13.n()).done) {
5087
- _context54.next = 34;
5193
+ if ((_step14 = _iterator14.n()).done) {
5194
+ _context55.next = 34;
5088
5195
  break;
5089
5196
  }
5090
- order = _step13.value;
5197
+ order = _step14.value;
5091
5198
  oid = order === null || order === void 0 ? void 0 : order.order_id;
5092
5199
  if (!(oid === undefined || oid === null)) {
5093
- _context54.next = 31;
5200
+ _context55.next = 31;
5094
5201
  break;
5095
5202
  }
5096
- return _context54.abrupt("continue", 32);
5203
+ return _context55.abrupt("continue", 32);
5097
5204
  case 31:
5098
5205
  fetchedMap.set(String(oid), order);
5099
5206
  case 32:
5100
- _context54.next = 26;
5207
+ _context55.next = 26;
5101
5208
  break;
5102
5209
  case 34:
5103
- _context54.next = 39;
5210
+ _context55.next = 39;
5104
5211
  break;
5105
5212
  case 36:
5106
- _context54.prev = 36;
5107
- _context54.t1 = _context54["catch"](24);
5108
- _iterator13.e(_context54.t1);
5213
+ _context55.prev = 36;
5214
+ _context55.t1 = _context55["catch"](24);
5215
+ _iterator14.e(_context55.t1);
5109
5216
  case 39:
5110
- _context54.prev = 39;
5111
- _iterator13.f();
5112
- return _context54.finish(39);
5217
+ _context55.prev = 39;
5218
+ _iterator14.f();
5219
+ return _context55.finish(39);
5113
5220
  case 42:
5114
5221
  freshOrders = [];
5115
5222
  succeedIds = [];
5116
5223
  failed = [];
5117
- _iterator14 = _createForOfIteratorHelper(orderIds);
5224
+ _iterator15 = _createForOfIteratorHelper(orderIds);
5118
5225
  try {
5119
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
5120
- _id = _step14.value;
5226
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
5227
+ _id = _step15.value;
5121
5228
  fresh = fetchedMap.get(_id);
5122
5229
  if (fresh) {
5123
5230
  freshOrders.push(fresh);
@@ -5130,28 +5237,28 @@ var Server = /*#__PURE__*/function () {
5130
5237
  }
5131
5238
  }
5132
5239
  } catch (err) {
5133
- _iterator14.e(err);
5240
+ _iterator15.e(err);
5134
5241
  } finally {
5135
- _iterator14.f();
5242
+ _iterator15.f();
5136
5243
  }
5137
5244
  if (!(freshOrders.length > 0)) {
5138
- _context54.next = 58;
5245
+ _context55.next = 58;
5139
5246
  break;
5140
5247
  }
5141
- _context54.prev = 48;
5142
- _context54.next = 51;
5248
+ _context55.prev = 48;
5249
+ _context55.next = 51;
5143
5250
  return this.order.upsertOrdersFromRemote(freshOrders);
5144
5251
  case 51:
5145
- _context54.next = 58;
5252
+ _context55.next = 58;
5146
5253
  break;
5147
5254
  case 53:
5148
- _context54.prev = 53;
5149
- _context54.t2 = _context54["catch"](48);
5150
- _message = _context54.t2 instanceof Error ? _context54.t2.message : String(_context54.t2);
5255
+ _context55.prev = 53;
5256
+ _context55.t2 = _context55["catch"](48);
5257
+ _message = _context55.t2 instanceof Error ? _context55.t2.message : String(_context55.t2);
5151
5258
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
5152
5259
  message: _message
5153
5260
  });
5154
- return _context54.abrupt("return", {
5261
+ return _context55.abrupt("return", {
5155
5262
  code: 500,
5156
5263
  status: false,
5157
5264
  message: _message,
@@ -5170,7 +5277,7 @@ var Server = /*#__PURE__*/function () {
5170
5277
  insertedCount: inserted.length,
5171
5278
  failedCount: failed.length
5172
5279
  });
5173
- return _context54.abrupt("return", {
5280
+ return _context55.abrupt("return", {
5174
5281
  code: 200,
5175
5282
  status: true,
5176
5283
  message: '',
@@ -5182,11 +5289,11 @@ var Server = /*#__PURE__*/function () {
5182
5289
  });
5183
5290
  case 62:
5184
5291
  case "end":
5185
- return _context54.stop();
5292
+ return _context55.stop();
5186
5293
  }
5187
- }, _callee54, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
5294
+ }, _callee55, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
5188
5295
  }));
5189
- function handleUpdateLocalOrdersBatch(_x59) {
5296
+ function handleUpdateLocalOrdersBatch(_x60) {
5190
5297
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
5191
5298
  }
5192
5299
  return handleUpdateLocalOrdersBatch;
@@ -5207,11 +5314,11 @@ var Server = /*#__PURE__*/function () {
5207
5314
  var queryIndex = url.indexOf('?');
5208
5315
  if (queryIndex < 0) return null;
5209
5316
  var query = url.slice(queryIndex + 1);
5210
- var _iterator15 = _createForOfIteratorHelper(query.split('&')),
5211
- _step15;
5317
+ var _iterator16 = _createForOfIteratorHelper(query.split('&')),
5318
+ _step16;
5212
5319
  try {
5213
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
5214
- var pair = _step15.value;
5320
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5321
+ var pair = _step16.value;
5215
5322
  if (!pair) continue;
5216
5323
  var _pair$split = pair.split('='),
5217
5324
  _pair$split2 = _slicedToArray(_pair$split, 2),
@@ -5227,9 +5334,9 @@ var Server = /*#__PURE__*/function () {
5227
5334
  }
5228
5335
  }
5229
5336
  } catch (err) {
5230
- _iterator15.e(err);
5337
+ _iterator16.e(err);
5231
5338
  } finally {
5232
- _iterator15.f();
5339
+ _iterator16.f();
5233
5340
  }
5234
5341
  return null;
5235
5342
  }
@@ -5428,10 +5535,10 @@ var Server = /*#__PURE__*/function () {
5428
5535
  value: function extractBackendErrorResponse(error) {
5429
5536
  var _error$response3,
5430
5537
  _error$response4,
5431
- _this15 = this;
5538
+ _this16 = this;
5432
5539
  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];
5433
5540
  return candidates.find(function (candidate) {
5434
- return _this15.isExplicitBackendErrorResponse(candidate);
5541
+ return _this16.isExplicitBackendErrorResponse(candidate);
5435
5542
  }) || null;
5436
5543
  }
5437
5544
  }, {
@@ -5550,24 +5657,24 @@ var Server = /*#__PURE__*/function () {
5550
5657
  }, {
5551
5658
  key: "recomputeAndNotifyFloorPlanQuery",
5552
5659
  value: (function () {
5553
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5554
- var _iterator16, _step16, _step16$value, subscriberId, sub, result, errorMessage;
5555
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5556
- while (1) switch (_context55.prev = _context55.next) {
5660
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5661
+ var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
5662
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5663
+ while (1) switch (_context56.prev = _context56.next) {
5557
5664
  case 0:
5558
5665
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
5559
- _context55.next = 2;
5666
+ _context56.next = 2;
5560
5667
  break;
5561
5668
  }
5562
- return _context55.abrupt("return");
5669
+ return _context56.abrupt("return");
5563
5670
  case 2:
5564
5671
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
5565
5672
  subscriberCount: this.floorPlanQuerySubscribers.size
5566
5673
  });
5567
- _iterator16 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
5674
+ _iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
5568
5675
  try {
5569
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5570
- _step16$value = _slicedToArray(_step16.value, 2), subscriberId = _step16$value[0], sub = _step16$value[1];
5676
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
5677
+ _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
5571
5678
  try {
5572
5679
  result = this.computeFloorPlanQueryResult(sub.context);
5573
5680
  sub.callback(result);
@@ -5583,15 +5690,15 @@ var Server = /*#__PURE__*/function () {
5583
5690
  }
5584
5691
  }
5585
5692
  } catch (err) {
5586
- _iterator16.e(err);
5693
+ _iterator17.e(err);
5587
5694
  } finally {
5588
- _iterator16.f();
5695
+ _iterator17.f();
5589
5696
  }
5590
5697
  case 5:
5591
5698
  case "end":
5592
- return _context55.stop();
5699
+ return _context56.stop();
5593
5700
  }
5594
- }, _callee55, this);
5701
+ }, _callee56, this);
5595
5702
  }));
5596
5703
  function recomputeAndNotifyFloorPlanQuery() {
5597
5704
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -5621,21 +5728,21 @@ var Server = /*#__PURE__*/function () {
5621
5728
  * filter 逻辑暂为 mock,仅记录参数
5622
5729
  */
5623
5730
  function () {
5624
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(data) {
5731
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data) {
5625
5732
  var rawList, result;
5626
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5627
- while (1) switch (_context56.prev = _context56.next) {
5733
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5734
+ while (1) switch (_context57.prev = _context57.next) {
5628
5735
  case 0:
5629
5736
  this.logInfo('computeOrderQueryResult: 开始过滤', {
5630
5737
  data: data
5631
5738
  });
5632
5739
  console.log('[Server] computeOrderQueryResult', data);
5633
5740
  if (this.order) {
5634
- _context56.next = 5;
5741
+ _context57.next = 5;
5635
5742
  break;
5636
5743
  }
5637
5744
  this.logError('computeOrderQueryResult: Order 模块未注册');
5638
- return _context56.abrupt("return", {
5745
+ return _context57.abrupt("return", {
5639
5746
  code: 500,
5640
5747
  message: 'Order 模块未注册',
5641
5748
  data: {
@@ -5659,7 +5766,7 @@ var Server = /*#__PURE__*/function () {
5659
5766
  skip: result.skip,
5660
5767
  rejected: result.rejected
5661
5768
  });
5662
- return _context56.abrupt("return", {
5769
+ return _context57.abrupt("return", {
5663
5770
  code: 200,
5664
5771
  data: result,
5665
5772
  message: '',
@@ -5667,11 +5774,11 @@ var Server = /*#__PURE__*/function () {
5667
5774
  });
5668
5775
  case 10:
5669
5776
  case "end":
5670
- return _context56.stop();
5777
+ return _context57.stop();
5671
5778
  }
5672
- }, _callee56, this);
5779
+ }, _callee57, this);
5673
5780
  }));
5674
- function computeOrderQueryResult(_x60) {
5781
+ function computeOrderQueryResult(_x61) {
5675
5782
  return _computeOrderQueryResult.apply(this, arguments);
5676
5783
  }
5677
5784
  return computeOrderQueryResult;
@@ -5684,17 +5791,17 @@ var Server = /*#__PURE__*/function () {
5684
5791
  }, {
5685
5792
  key: "computeBookingQueryResult",
5686
5793
  value: (function () {
5687
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data) {
5794
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(data) {
5688
5795
  var rawOrders, result;
5689
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5690
- while (1) switch (_context57.prev = _context57.next) {
5796
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5797
+ while (1) switch (_context58.prev = _context58.next) {
5691
5798
  case 0:
5692
5799
  if (this.order) {
5693
- _context57.next = 3;
5800
+ _context58.next = 3;
5694
5801
  break;
5695
5802
  }
5696
5803
  this.logError('computeBookingQueryResult: Order 模块未注册');
5697
- return _context57.abrupt("return", {
5804
+ return _context58.abrupt("return", {
5698
5805
  code: 500,
5699
5806
  message: 'Order 模块未注册',
5700
5807
  data: {
@@ -5713,7 +5820,7 @@ var Server = /*#__PURE__*/function () {
5713
5820
  size: result.size,
5714
5821
  skip: result.skip
5715
5822
  });
5716
- return _context57.abrupt("return", {
5823
+ return _context58.abrupt("return", {
5717
5824
  code: 200,
5718
5825
  data: result,
5719
5826
  message: '',
@@ -5721,11 +5828,11 @@ var Server = /*#__PURE__*/function () {
5721
5828
  });
5722
5829
  case 8:
5723
5830
  case "end":
5724
- return _context57.stop();
5831
+ return _context58.stop();
5725
5832
  }
5726
- }, _callee57, this);
5833
+ }, _callee58, this);
5727
5834
  }));
5728
- function computeBookingQueryResult(_x61) {
5835
+ function computeBookingQueryResult(_x62) {
5729
5836
  return _computeBookingQueryResult.apply(this, arguments);
5730
5837
  }
5731
5838
  return computeBookingQueryResult;
@@ -5784,12 +5891,12 @@ var Server = /*#__PURE__*/function () {
5784
5891
  }, {
5785
5892
  key: "computeProductQueryResult",
5786
5893
  value: (function () {
5787
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(context, options) {
5894
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(context, options) {
5788
5895
  var _menu_list_ids$length3,
5789
- _this16 = this;
5896
+ _this17 = this;
5790
5897
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
5791
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5792
- while (1) switch (_context58.prev = _context58.next) {
5898
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5899
+ while (1) switch (_context59.prev = _context59.next) {
5793
5900
  case 0:
5794
5901
  tTotal = performance.now();
5795
5902
  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, extension_type = context.extension_type, product_id = context.product_id;
@@ -5809,11 +5916,11 @@ var Server = /*#__PURE__*/function () {
5809
5916
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5810
5917
  });
5811
5918
  if (this.products) {
5812
- _context58.next = 7;
5919
+ _context59.next = 7;
5813
5920
  break;
5814
5921
  }
5815
5922
  this.logError('computeProductQueryResult: Products 模块未注册');
5816
- return _context58.abrupt("return", {
5923
+ return _context59.abrupt("return", {
5817
5924
  message: 'Products 模块未注册',
5818
5925
  data: {
5819
5926
  list: [],
@@ -5822,12 +5929,12 @@ var Server = /*#__PURE__*/function () {
5822
5929
  });
5823
5930
  case 7:
5824
5931
  if (!(queryIds.length > 0)) {
5825
- _context58.next = 19;
5932
+ _context59.next = 19;
5826
5933
  break;
5827
5934
  }
5828
5935
  uniqueIds = Array.from(new Set(queryIds));
5829
5936
  _tPrice = performance.now();
5830
- _context58.next = 12;
5937
+ _context59.next = 12;
5831
5938
  return this.products.getProductsWithPrice(schedule_date, {
5832
5939
  scheduleModule: this.getSchedule(),
5833
5940
  schedule_datetime: schedule_datetime,
@@ -5837,7 +5944,7 @@ var Server = /*#__PURE__*/function () {
5837
5944
  productIds: uniqueIds
5838
5945
  });
5839
5946
  case 12:
5840
- productsWithPrice = _context58.sent;
5947
+ productsWithPrice = _context59.sent;
5841
5948
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
5842
5949
  count: productsWithPrice.length,
5843
5950
  ids: uniqueIds
@@ -5857,7 +5964,7 @@ var Server = /*#__PURE__*/function () {
5857
5964
  ids: uniqueIds,
5858
5965
  count: extensionFilteredProducts.length
5859
5966
  });
5860
- return _context58.abrupt("return", {
5967
+ return _context59.abrupt("return", {
5861
5968
  code: 200,
5862
5969
  data: {
5863
5970
  list: extensionFilteredProducts,
@@ -5868,19 +5975,19 @@ var Server = /*#__PURE__*/function () {
5868
5975
  });
5869
5976
  case 19:
5870
5977
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
5871
- _context58.next = 31;
5978
+ _context59.next = 31;
5872
5979
  break;
5873
5980
  }
5874
5981
  pid = Number(product_id);
5875
5982
  _tPrice2 = performance.now();
5876
- _context58.next = 24;
5983
+ _context59.next = 24;
5877
5984
  return this.products.getProductsWithPrice(schedule_date, {
5878
5985
  scheduleModule: this.getSchedule()
5879
5986
  }, {
5880
5987
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5881
5988
  });
5882
5989
  case 24:
5883
- allProductsWithPrice = _context58.sent;
5990
+ allProductsWithPrice = _context59.sent;
5884
5991
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
5885
5992
  count: allProductsWithPrice.length,
5886
5993
  productId: pid
@@ -5900,7 +6007,7 @@ var Server = /*#__PURE__*/function () {
5900
6007
  productId: pid,
5901
6008
  found: !!item
5902
6009
  });
5903
- return _context58.abrupt("return", {
6010
+ return _context59.abrupt("return", {
5904
6011
  code: 200,
5905
6012
  data: item,
5906
6013
  message: item ? '' : '商品不存在或未发布',
@@ -5908,11 +6015,11 @@ var Server = /*#__PURE__*/function () {
5908
6015
  });
5909
6016
  case 31:
5910
6017
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
5911
- _context58.next = 51;
6018
+ _context59.next = 51;
5912
6019
  break;
5913
6020
  }
5914
6021
  _tPrice3 = performance.now();
5915
- _context58.next = 35;
6022
+ _context59.next = 35;
5916
6023
  return this.products.getProductsWithPrice(schedule_date, {
5917
6024
  scheduleModule: this.getSchedule(),
5918
6025
  schedule_datetime: schedule_datetime,
@@ -5921,7 +6028,7 @@ var Server = /*#__PURE__*/function () {
5921
6028
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5922
6029
  });
5923
6030
  case 35:
5924
- _filteredProducts2 = _context58.sent;
6031
+ _filteredProducts2 = _context59.sent;
5925
6032
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
5926
6033
  count: _filteredProducts2.length,
5927
6034
  extension_type: extension_type
@@ -5960,7 +6067,7 @@ var Server = /*#__PURE__*/function () {
5960
6067
  filteredCount: _filteredProducts2.length,
5961
6068
  extension_type: extension_type
5962
6069
  });
5963
- return _context58.abrupt("return", {
6070
+ return _context59.abrupt("return", {
5964
6071
  code: 200,
5965
6072
  data: {
5966
6073
  list: _filteredProducts2,
@@ -5971,11 +6078,11 @@ var Server = /*#__PURE__*/function () {
5971
6078
  });
5972
6079
  case 51:
5973
6080
  if (this.menu) {
5974
- _context58.next = 54;
6081
+ _context59.next = 54;
5975
6082
  break;
5976
6083
  }
5977
6084
  this.logError('computeProductQueryResult: Menu 模块未注册');
5978
- return _context58.abrupt("return", {
6085
+ return _context59.abrupt("return", {
5979
6086
  message: 'Menu 模块未注册',
5980
6087
  data: {
5981
6088
  list: [],
@@ -5984,11 +6091,11 @@ var Server = /*#__PURE__*/function () {
5984
6091
  });
5985
6092
  case 54:
5986
6093
  if (this.schedule) {
5987
- _context58.next = 57;
6094
+ _context59.next = 57;
5988
6095
  break;
5989
6096
  }
5990
6097
  this.logError('computeProductQueryResult: Schedule 模块未注册');
5991
- return _context58.abrupt("return", {
6098
+ return _context59.abrupt("return", {
5992
6099
  message: 'Schedule 模块未注册',
5993
6100
  data: {
5994
6101
  list: [],
@@ -6001,8 +6108,8 @@ var Server = /*#__PURE__*/function () {
6001
6108
  tMenu = performance.now();
6002
6109
  menuList = this.menu.getMenuByIds(menu_list_ids);
6003
6110
  activeMenuList = menuList.filter(function (menu) {
6004
- var _this16$schedule;
6005
- return ((_this16$schedule = _this16.schedule) === null || _this16$schedule === void 0 ? void 0 : _this16$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6111
+ var _this17$schedule;
6112
+ return ((_this17$schedule = _this17.schedule) === null || _this17$schedule === void 0 ? void 0 : _this17$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6006
6113
  });
6007
6114
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
6008
6115
  totalMenu: menuList.length,
@@ -6019,10 +6126,10 @@ var Server = /*#__PURE__*/function () {
6019
6126
  });
6020
6127
  tPrice = performance.now();
6021
6128
  if (!(scopedProductIds.length > 0)) {
6022
- _context58.next = 70;
6129
+ _context59.next = 70;
6023
6130
  break;
6024
6131
  }
6025
- _context58.next = 67;
6132
+ _context59.next = 67;
6026
6133
  return this.products.getProductsWithPrice(schedule_date, {
6027
6134
  scheduleModule: this.getSchedule(),
6028
6135
  schedule_datetime: schedule_datetime,
@@ -6032,13 +6139,13 @@ var Server = /*#__PURE__*/function () {
6032
6139
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
6033
6140
  });
6034
6141
  case 67:
6035
- _context58.t0 = _context58.sent;
6036
- _context58.next = 71;
6142
+ _context59.t0 = _context59.sent;
6143
+ _context59.next = 71;
6037
6144
  break;
6038
6145
  case 70:
6039
- _context58.t0 = [];
6146
+ _context59.t0 = [];
6040
6147
  case 71:
6041
- filteredProducts = _context58.t0;
6148
+ filteredProducts = _context59.t0;
6042
6149
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
6043
6150
  count: filteredProducts.length,
6044
6151
  scopedProductCount: scopedProductIds.length
@@ -6079,7 +6186,7 @@ var Server = /*#__PURE__*/function () {
6079
6186
  filteredCount: filteredProducts.length,
6080
6187
  activeMenuCount: activeMenuList.length
6081
6188
  });
6082
- return _context58.abrupt("return", {
6189
+ return _context59.abrupt("return", {
6083
6190
  code: 200,
6084
6191
  data: {
6085
6192
  list: filteredProducts,
@@ -6090,11 +6197,11 @@ var Server = /*#__PURE__*/function () {
6090
6197
  });
6091
6198
  case 87:
6092
6199
  case "end":
6093
- return _context58.stop();
6200
+ return _context59.stop();
6094
6201
  }
6095
- }, _callee58, this);
6202
+ }, _callee59, this);
6096
6203
  }));
6097
- function computeProductQueryResult(_x62, _x63) {
6204
+ function computeProductQueryResult(_x63, _x64) {
6098
6205
  return _computeProductQueryResult.apply(this, arguments);
6099
6206
  }
6100
6207
  return computeProductQueryResult;
@@ -6109,72 +6216,72 @@ var Server = /*#__PURE__*/function () {
6109
6216
  }, {
6110
6217
  key: "recomputeAndNotifyProductQuery",
6111
6218
  value: (function () {
6112
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(options) {
6113
- var _iterator17, _step17, _step17$value, subscriberId, subscriber, result, errorMessage;
6114
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6115
- while (1) switch (_context59.prev = _context59.next) {
6219
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(options) {
6220
+ var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
6221
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6222
+ while (1) switch (_context60.prev = _context60.next) {
6116
6223
  case 0:
6117
6224
  if (!(this.productQuerySubscribers.size === 0)) {
6118
- _context59.next = 2;
6225
+ _context60.next = 2;
6119
6226
  break;
6120
6227
  }
6121
- return _context59.abrupt("return");
6228
+ return _context60.abrupt("return");
6122
6229
  case 2:
6123
6230
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
6124
6231
  subscriberCount: this.productQuerySubscribers.size,
6125
6232
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6126
6233
  });
6127
- _iterator17 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6128
- _context59.prev = 4;
6129
- _iterator17.s();
6234
+ _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6235
+ _context60.prev = 4;
6236
+ _iterator18.s();
6130
6237
  case 6:
6131
- if ((_step17 = _iterator17.n()).done) {
6132
- _context59.next = 22;
6238
+ if ((_step18 = _iterator18.n()).done) {
6239
+ _context60.next = 22;
6133
6240
  break;
6134
6241
  }
6135
- _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], subscriber = _step17$value[1];
6136
- _context59.prev = 8;
6137
- _context59.next = 11;
6242
+ _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
6243
+ _context60.prev = 8;
6244
+ _context60.next = 11;
6138
6245
  return this.computeProductQueryResult(subscriber.context, {
6139
6246
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6140
6247
  });
6141
6248
  case 11:
6142
- result = _context59.sent;
6249
+ result = _context60.sent;
6143
6250
  subscriber.callback(result);
6144
6251
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
6145
6252
  subscriberId: subscriberId
6146
6253
  });
6147
- _context59.next = 20;
6254
+ _context60.next = 20;
6148
6255
  break;
6149
6256
  case 16:
6150
- _context59.prev = 16;
6151
- _context59.t0 = _context59["catch"](8);
6152
- errorMessage = _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0);
6257
+ _context60.prev = 16;
6258
+ _context60.t0 = _context60["catch"](8);
6259
+ errorMessage = _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0);
6153
6260
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
6154
6261
  subscriberId: subscriberId,
6155
6262
  error: errorMessage
6156
6263
  });
6157
6264
  case 20:
6158
- _context59.next = 6;
6265
+ _context60.next = 6;
6159
6266
  break;
6160
6267
  case 22:
6161
- _context59.next = 27;
6268
+ _context60.next = 27;
6162
6269
  break;
6163
6270
  case 24:
6164
- _context59.prev = 24;
6165
- _context59.t1 = _context59["catch"](4);
6166
- _iterator17.e(_context59.t1);
6271
+ _context60.prev = 24;
6272
+ _context60.t1 = _context60["catch"](4);
6273
+ _iterator18.e(_context60.t1);
6167
6274
  case 27:
6168
- _context59.prev = 27;
6169
- _iterator17.f();
6170
- return _context59.finish(27);
6275
+ _context60.prev = 27;
6276
+ _iterator18.f();
6277
+ return _context60.finish(27);
6171
6278
  case 30:
6172
6279
  case "end":
6173
- return _context59.stop();
6280
+ return _context60.stop();
6174
6281
  }
6175
- }, _callee59, this, [[4, 24, 27, 30], [8, 16]]);
6282
+ }, _callee60, this, [[4, 24, 27, 30], [8, 16]]);
6176
6283
  }));
6177
- function recomputeAndNotifyProductQuery(_x64) {
6284
+ function recomputeAndNotifyProductQuery(_x65) {
6178
6285
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
6179
6286
  }
6180
6287
  return recomputeAndNotifyProductQuery;
@@ -6186,37 +6293,37 @@ var Server = /*#__PURE__*/function () {
6186
6293
  }, {
6187
6294
  key: "recomputeAndNotifyOrderQuery",
6188
6295
  value: (function () {
6189
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
6190
- var notifyStartAt, _iterator18, _step18, _step18$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
6191
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6192
- while (1) switch (_context60.prev = _context60.next) {
6296
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
6297
+ var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
6298
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6299
+ while (1) switch (_context61.prev = _context61.next) {
6193
6300
  case 0:
6194
6301
  if (!(this.orderQuerySubscribers.size === 0)) {
6195
- _context60.next = 2;
6302
+ _context61.next = 2;
6196
6303
  break;
6197
6304
  }
6198
- return _context60.abrupt("return");
6305
+ return _context61.abrupt("return");
6199
6306
  case 2:
6200
6307
  notifyStartAt = Date.now();
6201
6308
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
6202
6309
  subscriberCount: this.orderQuerySubscribers.size,
6203
6310
  notifyStartAt: new Date(notifyStartAt).toISOString()
6204
6311
  });
6205
- _iterator18 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
6206
- _context60.prev = 5;
6207
- _iterator18.s();
6312
+ _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
6313
+ _context61.prev = 5;
6314
+ _iterator19.s();
6208
6315
  case 7:
6209
- if ((_step18 = _iterator18.n()).done) {
6210
- _context60.next = 27;
6316
+ if ((_step19 = _iterator19.n()).done) {
6317
+ _context61.next = 27;
6211
6318
  break;
6212
6319
  }
6213
- _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
6214
- _context60.prev = 9;
6320
+ _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
6321
+ _context61.prev = 9;
6215
6322
  computeStartAt = Date.now();
6216
- _context60.next = 13;
6323
+ _context61.next = 13;
6217
6324
  return this.computeOrderQueryResult(subscriber.context);
6218
6325
  case 13:
6219
- result = _context60.sent;
6326
+ result = _context61.sent;
6220
6327
  computeEndAt = Date.now();
6221
6328
  callbackStartAt = Date.now();
6222
6329
  subscriber.callback(result);
@@ -6227,30 +6334,30 @@ var Server = /*#__PURE__*/function () {
6227
6334
  callbackDurationMs: callbackEndAt - callbackStartAt,
6228
6335
  totalDurationMs: callbackEndAt - computeStartAt
6229
6336
  });
6230
- _context60.next = 25;
6337
+ _context61.next = 25;
6231
6338
  break;
6232
6339
  case 21:
6233
- _context60.prev = 21;
6234
- _context60.t0 = _context60["catch"](9);
6235
- errorMessage = _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0);
6340
+ _context61.prev = 21;
6341
+ _context61.t0 = _context61["catch"](9);
6342
+ errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
6236
6343
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
6237
6344
  subscriberId: subscriberId,
6238
6345
  error: errorMessage
6239
6346
  });
6240
6347
  case 25:
6241
- _context60.next = 7;
6348
+ _context61.next = 7;
6242
6349
  break;
6243
6350
  case 27:
6244
- _context60.next = 32;
6351
+ _context61.next = 32;
6245
6352
  break;
6246
6353
  case 29:
6247
- _context60.prev = 29;
6248
- _context60.t1 = _context60["catch"](5);
6249
- _iterator18.e(_context60.t1);
6354
+ _context61.prev = 29;
6355
+ _context61.t1 = _context61["catch"](5);
6356
+ _iterator19.e(_context61.t1);
6250
6357
  case 32:
6251
- _context60.prev = 32;
6252
- _iterator18.f();
6253
- return _context60.finish(32);
6358
+ _context61.prev = 32;
6359
+ _iterator19.f();
6360
+ return _context61.finish(32);
6254
6361
  case 35:
6255
6362
  notifyEndAt = Date.now();
6256
6363
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -6259,9 +6366,9 @@ var Server = /*#__PURE__*/function () {
6259
6366
  });
6260
6367
  case 37:
6261
6368
  case "end":
6262
- return _context60.stop();
6369
+ return _context61.stop();
6263
6370
  }
6264
- }, _callee60, this, [[5, 29, 32, 35], [9, 21]]);
6371
+ }, _callee61, this, [[5, 29, 32, 35], [9, 21]]);
6265
6372
  }));
6266
6373
  function recomputeAndNotifyOrderQuery() {
6267
6374
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -6279,48 +6386,51 @@ var Server = /*#__PURE__*/function () {
6279
6386
  }, {
6280
6387
  key: "notifySalesSearchSubscribers",
6281
6388
  value: function notifySalesSearchSubscribers(payload) {
6282
- var _this17 = this;
6389
+ var _this18 = this;
6283
6390
  if (this.salesSearchSubscribers.size === 0) return;
6284
6391
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
6285
6392
  if (changedOrders.length === 0) {
6286
6393
  return;
6287
6394
  }
6288
- var _iterator19 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
6289
- _step19;
6395
+ // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
6396
+ // 导致模块被销毁 ,checkout 弹窗永远无法关闭
6397
+ if (window.isPaymentModalPluginOpen) return;
6398
+ var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
6399
+ _step20;
6290
6400
  try {
6291
6401
  var _loop = function _loop() {
6292
- var _step19$value = _slicedToArray(_step19.value, 2),
6293
- subscriberId = _step19$value[0],
6294
- subscriber = _step19$value[1];
6402
+ var _step20$value = _slicedToArray(_step20.value, 2),
6403
+ subscriberId = _step20$value[0],
6404
+ subscriber = _step20$value[1];
6295
6405
  try {
6296
6406
  var changedVisibleOrders = changedOrders.filter(function (order) {
6297
- var orderId = _this17.getSalesSearchOrderId(order);
6407
+ var orderId = _this18.getSalesSearchOrderId(order);
6298
6408
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
6299
6409
  });
6300
6410
  if (changedVisibleOrders.length === 0) {
6301
6411
  return 1; // continue
6302
6412
  }
6303
- subscriber.callback(_this17.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
6304
- _this17.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
6413
+ subscriber.callback(_this18.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
6414
+ _this18.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
6305
6415
  subscriberId: subscriberId,
6306
6416
  kind: subscriber.kind,
6307
6417
  count: changedVisibleOrders.length
6308
6418
  });
6309
6419
  } catch (error) {
6310
6420
  var errorMessage = error instanceof Error ? error.message : String(error);
6311
- _this17.logError('notifySalesSearchSubscribers: 推送失败', {
6421
+ _this18.logError('notifySalesSearchSubscribers: 推送失败', {
6312
6422
  subscriberId: subscriberId,
6313
6423
  error: errorMessage
6314
6424
  });
6315
6425
  }
6316
6426
  };
6317
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
6427
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
6318
6428
  if (_loop()) continue;
6319
6429
  }
6320
6430
  } catch (err) {
6321
- _iterator19.e(err);
6431
+ _iterator20.e(err);
6322
6432
  } finally {
6323
- _iterator19.f();
6433
+ _iterator20.f();
6324
6434
  }
6325
6435
  }
6326
6436
 
@@ -6399,67 +6509,67 @@ var Server = /*#__PURE__*/function () {
6399
6509
  }, {
6400
6510
  key: "recomputeAndNotifyBookingQuery",
6401
6511
  value: (function () {
6402
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
6403
- var _iterator20, _step20, _step20$value, subscriberId, subscriber, result, errorMessage;
6404
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6405
- while (1) switch (_context61.prev = _context61.next) {
6512
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
6513
+ var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
6514
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6515
+ while (1) switch (_context62.prev = _context62.next) {
6406
6516
  case 0:
6407
6517
  if (!(this.bookingQuerySubscribers.size === 0)) {
6408
- _context61.next = 2;
6518
+ _context62.next = 2;
6409
6519
  break;
6410
6520
  }
6411
- return _context61.abrupt("return");
6521
+ return _context62.abrupt("return");
6412
6522
  case 2:
6413
6523
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
6414
6524
  subscriberCount: this.bookingQuerySubscribers.size
6415
6525
  });
6416
- _iterator20 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
6417
- _context61.prev = 4;
6418
- _iterator20.s();
6526
+ _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
6527
+ _context62.prev = 4;
6528
+ _iterator21.s();
6419
6529
  case 6:
6420
- if ((_step20 = _iterator20.n()).done) {
6421
- _context61.next = 22;
6530
+ if ((_step21 = _iterator21.n()).done) {
6531
+ _context62.next = 22;
6422
6532
  break;
6423
6533
  }
6424
- _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
6425
- _context61.prev = 8;
6426
- _context61.next = 11;
6534
+ _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
6535
+ _context62.prev = 8;
6536
+ _context62.next = 11;
6427
6537
  return this.computeBookingQueryResult(subscriber.context);
6428
6538
  case 11:
6429
- result = _context61.sent;
6539
+ result = _context62.sent;
6430
6540
  subscriber.callback(result);
6431
6541
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
6432
6542
  subscriberId: subscriberId
6433
6543
  });
6434
- _context61.next = 20;
6544
+ _context62.next = 20;
6435
6545
  break;
6436
6546
  case 16:
6437
- _context61.prev = 16;
6438
- _context61.t0 = _context61["catch"](8);
6439
- errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
6547
+ _context62.prev = 16;
6548
+ _context62.t0 = _context62["catch"](8);
6549
+ errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6440
6550
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
6441
6551
  subscriberId: subscriberId,
6442
6552
  error: errorMessage
6443
6553
  });
6444
6554
  case 20:
6445
- _context61.next = 6;
6555
+ _context62.next = 6;
6446
6556
  break;
6447
6557
  case 22:
6448
- _context61.next = 27;
6558
+ _context62.next = 27;
6449
6559
  break;
6450
6560
  case 24:
6451
- _context61.prev = 24;
6452
- _context61.t1 = _context61["catch"](4);
6453
- _iterator20.e(_context61.t1);
6561
+ _context62.prev = 24;
6562
+ _context62.t1 = _context62["catch"](4);
6563
+ _iterator21.e(_context62.t1);
6454
6564
  case 27:
6455
- _context61.prev = 27;
6456
- _iterator20.f();
6457
- return _context61.finish(27);
6565
+ _context62.prev = 27;
6566
+ _iterator21.f();
6567
+ return _context62.finish(27);
6458
6568
  case 30:
6459
6569
  case "end":
6460
- return _context61.stop();
6570
+ return _context62.stop();
6461
6571
  }
6462
- }, _callee61, this, [[4, 24, 27, 30], [8, 16]]);
6572
+ }, _callee62, this, [[4, 24, 27, 30], [8, 16]]);
6463
6573
  }));
6464
6574
  function recomputeAndNotifyBookingQuery() {
6465
6575
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -6489,11 +6599,11 @@ var Server = /*#__PURE__*/function () {
6489
6599
  var allowedProductIds = new Set();
6490
6600
  var allowedCollectionIds = new Set();
6491
6601
  var hasProductAll = false;
6492
- var _iterator21 = _createForOfIteratorHelper(activeMenuList),
6493
- _step21;
6602
+ var _iterator22 = _createForOfIteratorHelper(activeMenuList),
6603
+ _step22;
6494
6604
  try {
6495
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
6496
- var menu = _step21.value;
6605
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
6606
+ var menu = _step22.value;
6497
6607
  var config = menu.partyroom_package;
6498
6608
  if (!config) {
6499
6609
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -6553,9 +6663,9 @@ var Server = /*#__PURE__*/function () {
6553
6663
 
6554
6664
  // 如果有餐牌允许所有商品,返回所有商品
6555
6665
  } catch (err) {
6556
- _iterator21.e(err);
6666
+ _iterator22.e(err);
6557
6667
  } finally {
6558
- _iterator21.f();
6668
+ _iterator22.f();
6559
6669
  }
6560
6670
  if (hasProductAll) {
6561
6671
  this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');