@pisell/pisellos 0.10.96 → 0.10.97

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.
@@ -130,7 +130,6 @@ var Server = /*#__PURE__*/function () {
130
130
  _defineProperty(this, "localPaymentUpdateQueues", new Map());
131
131
  _defineProperty(this, "paymentIdentityRefreshes", new Map());
132
132
  _defineProperty(this, "receiptFulfillmentConfigInFlight", new Map());
133
- _defineProperty(this, "cloudInvoiceSubmissions", new Map());
134
133
  _defineProperty(this, "floorPlanQuerySubscribers", new Map());
135
134
  // 模块注册表 - 定义所有可用的模块配置
136
135
  _defineProperty(this, "moduleRegistry", {
@@ -6656,80 +6655,19 @@ var Server = /*#__PURE__*/function () {
6656
6655
  });
6657
6656
  }
6658
6657
  }, {
6659
- key: "getCloudInvoiceDevice",
6658
+ key: "loadCloudInvoiceOrder",
6660
6659
  value: function () {
6661
- var _getCloudInvoiceDevice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(shopId) {
6662
- var readDevice, iot, iotId, fullNumber;
6660
+ var _loadCloudInvoiceOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(orderId, shopId, assertCurrentShop) {
6661
+ var hasReceiptDetail, local, result, saved;
6663
6662
  return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6664
6663
  while (1) switch (_context68.prev = _context68.next) {
6665
- case 0:
6666
- readDevice = this.getAppData('async_iot_device_info');
6667
- _context68.next = 3;
6668
- return readDevice === null || readDevice === void 0 ? void 0 : readDevice();
6669
- case 3:
6670
- iot = _context68.sent;
6671
- if (!((iot === null || iot === void 0 ? void 0 : iot.shop_id) != null && String(iot.shop_id) !== shopId)) {
6672
- _context68.next = 6;
6673
- break;
6674
- }
6675
- throw new Error('Cloud invoice device belongs to another shop');
6676
- case 6:
6677
- iotId = String((iot === null || iot === void 0 ? void 0 : iot.id) || '').trim();
6678
- fullNumber = String((iot === null || iot === void 0 ? void 0 : iot.number) || !iotId && this.getAppData('device_id') || '').trim();
6679
- if (!(fullNumber && fullNumber !== '0')) {
6680
- _context68.next = 10;
6681
- break;
6682
- }
6683
- return _context68.abrupt("return", {
6684
- id: fullNumber,
6685
- target: (iot === null || iot === void 0 ? void 0 : iot.short_number) || fullNumber.slice(-2)
6686
- });
6687
- case 10:
6688
- if (!(iotId && iotId !== '0')) {
6689
- _context68.next = 12;
6690
- break;
6691
- }
6692
- return _context68.abrupt("return", {
6693
- id: 'iot-id:' + iotId,
6694
- target: (iot === null || iot === void 0 ? void 0 : iot.short_number) || iotId
6695
- });
6696
- case 12:
6697
- throw new Error('Cloud invoice device is unavailable');
6698
- case 13:
6699
- case "end":
6700
- return _context68.stop();
6701
- }
6702
- }, _callee68, this);
6703
- }));
6704
- function getCloudInvoiceDevice(_x72) {
6705
- return _getCloudInvoiceDevice.apply(this, arguments);
6706
- }
6707
- return getCloudInvoiceDevice;
6708
- }()
6709
- }, {
6710
- key: "assertCloudInvoiceContext",
6711
- value: function assertCloudInvoiceContext(context) {
6712
- var _this$getAppData2, _this$getAppData3;
6713
- if (String((_this$getAppData2 = this.getAppData('shop_id')) !== null && _this$getAppData2 !== void 0 ? _this$getAppData2 : '') !== context.shopId || String((_this$getAppData3 = this.getAppData('tenant_id')) !== null && _this$getAppData3 !== void 0 ? _this$getAppData3 : '') !== context.tenantId) {
6714
- throw new Error('Cloud invoice shop context changed');
6715
- }
6716
- }
6717
- }, {
6718
- key: "loadCloudInvoiceOrder",
6719
- value: function () {
6720
- var _loadCloudInvoiceOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(context) {
6721
- var _this19 = this;
6722
- var orderId, shopId, hasReceiptDetail, local, result, saved;
6723
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6724
- while (1) switch (_context69.prev = _context69.next) {
6725
6664
  case 0:
6726
6665
  if (this.order) {
6727
- _context69.next = 2;
6666
+ _context68.next = 2;
6728
6667
  break;
6729
6668
  }
6730
6669
  throw new Error('Cloud invoice order service is unavailable');
6731
6670
  case 2:
6732
- orderId = context.orderId, shopId = context.shopId;
6733
6671
  hasReceiptDetail = function hasReceiptDetail(order) {
6734
6672
  var _order$summary, _order$summary2;
6735
6673
  // Use the same amount fields as the receipt builder, including historical
@@ -6739,34 +6677,34 @@ var Server = /*#__PURE__*/function () {
6739
6677
  });
6740
6678
  return typeof order.business_code === 'string' && !!order.business_code.trim() && (typeof total === 'number' || typeof total === 'string' && !!total.trim()) && Number.isFinite(Number(total)) && (Array.isArray(order.products) || Array.isArray(order.bookings));
6741
6679
  };
6742
- _context69.next = 6;
6680
+ _context68.next = 5;
6743
6681
  return this.order.getLocalOrderByLookup(orderId, {
6744
6682
  exactOrderId: true
6745
6683
  });
6746
- case 6:
6747
- local = _context69.sent;
6748
- this.assertCloudInvoiceContext(context);
6684
+ case 5:
6685
+ local = _context68.sent;
6686
+ assertCurrentShop();
6749
6687
  if (!(local && String(local.order_id) === orderId)) {
6750
- _context69.next = 13;
6688
+ _context68.next = 12;
6751
6689
  break;
6752
6690
  }
6753
6691
  if (!(local.shop_id != null && String(local.shop_id) !== shopId)) {
6754
- _context69.next = 11;
6692
+ _context68.next = 10;
6755
6693
  break;
6756
6694
  }
6757
6695
  throw new Error('Cloud invoice order belongs to another shop');
6758
- case 11:
6696
+ case 10:
6759
6697
  if (!(String(local.shop_id) === shopId && hasReceiptDetail(local))) {
6760
- _context69.next = 13;
6698
+ _context68.next = 12;
6761
6699
  break;
6762
6700
  }
6763
- return _context69.abrupt("return", local);
6764
- case 13:
6765
- _context69.next = 15;
6701
+ return _context68.abrupt("return", local);
6702
+ case 12:
6703
+ _context68.next = 14;
6766
6704
  return this.fetchAndPersistSalesOrderByLookup(orderId, {
6767
6705
  with: ['all']
6768
6706
  }, 'cloudOrderInvoice', undefined, function (fresh) {
6769
- _this19.assertCloudInvoiceContext(context);
6707
+ assertCurrentShop();
6770
6708
  if (String(fresh.order_id) !== orderId || fresh.shop_id != null && String(fresh.shop_id) !== shopId || !hasReceiptDetail(fresh)) {
6771
6709
  throw new Error('Cloud invoice order identity or detail is invalid');
6772
6710
  }
@@ -6775,122 +6713,122 @@ var Server = /*#__PURE__*/function () {
6775
6713
  shop_id: Number(shopId)
6776
6714
  }) : fresh;
6777
6715
  });
6778
- case 15:
6779
- result = _context69.sent;
6780
- this.assertCloudInvoiceContext(context);
6716
+ case 14:
6717
+ result = _context68.sent;
6718
+ assertCurrentShop();
6781
6719
  saved = result.order;
6782
6720
  if (!(!saved || String(saved.order_id) !== orderId || String(saved.shop_id) !== shopId || !hasReceiptDetail(saved))) {
6783
- _context69.next = 20;
6721
+ _context68.next = 19;
6784
6722
  break;
6785
6723
  }
6786
6724
  throw new Error(result.message || 'Cloud invoice order detail is unavailable');
6725
+ case 19:
6726
+ return _context68.abrupt("return", saved);
6787
6727
  case 20:
6788
- return _context69.abrupt("return", saved);
6789
- case 21:
6790
6728
  case "end":
6791
- return _context69.stop();
6729
+ return _context68.stop();
6792
6730
  }
6793
- }, _callee69, this);
6731
+ }, _callee68, this);
6794
6732
  }));
6795
- function loadCloudInvoiceOrder(_x73) {
6733
+ function loadCloudInvoiceOrder(_x72, _x73, _x74) {
6796
6734
  return _loadCloudInvoiceOrder.apply(this, arguments);
6797
6735
  }
6798
6736
  return loadCloudInvoiceOrder;
6799
6737
  }()
6800
6738
  }, {
6801
- key: "resolveCloudOrderInvoice",
6739
+ key: "handleCloudOrderInvoice",
6802
6740
  value: function () {
6803
- var _resolveCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(context, input, submit) {
6804
- var _input$template_setti, _receipt$payment_info;
6805
- var deviceTask, prior, _prior$payload, _prior$payload2, order, businessCode, settings, receipt, smallTicketData, device, task;
6806
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6807
- while (1) switch (_context70.prev = _context70.next) {
6741
+ var _handleCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(input, submit) {
6742
+ var _this19 = this;
6743
+ var orderId, _this$getAppData2, _this$getAppData3, _input$template_setti, _receipt$payment_info, shopId, tenantId, assertCurrentShop, order, businessCode, settings, receipt, smallTicketData, deviceTask, deviceId, message;
6744
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6745
+ while (1) switch (_context69.prev = _context69.next) {
6808
6746
  case 0:
6809
- deviceTask = this.getDeviceTaskPlugin();
6810
- if (!(!(deviceTask !== null && deviceTask !== void 0 && deviceTask.findByIdempotencyKey) || !deviceTask.dispatch)) {
6811
- _context70.next = 3;
6747
+ orderId = typeof (input === null || input === void 0 ? void 0 : input.order_id) === 'string' ? input.order_id.trim() : Number.isSafeInteger(input === null || input === void 0 ? void 0 : input.order_id) ? String(input.order_id) : '';
6748
+ if (/^[1-9]\d*$/.test(orderId)) {
6749
+ _context69.next = 3;
6812
6750
  break;
6813
6751
  }
6814
- throw new Error('Cloud invoice task service is unavailable');
6752
+ return _context69.abrupt("return", {
6753
+ code: 400,
6754
+ status: false,
6755
+ message: 'Invalid cloud invoice order ID',
6756
+ data: null
6757
+ });
6815
6758
  case 3:
6816
- _context70.next = 5;
6817
- return deviceTask.findByIdempotencyKey(context.taskKey);
6818
- case 5:
6819
- prior = _context70.sent;
6820
- this.assertCloudInvoiceContext(context);
6821
- if (!prior) {
6822
- _context70.next = 11;
6759
+ _context69.prev = 3;
6760
+ shopId = String((_this$getAppData2 = this.getAppData('shop_id')) !== null && _this$getAppData2 !== void 0 ? _this$getAppData2 : '');
6761
+ tenantId = String((_this$getAppData3 = this.getAppData('tenant_id')) !== null && _this$getAppData3 !== void 0 ? _this$getAppData3 : '');
6762
+ if (!(!/^[1-9]\d*$/.test(shopId) || !Number.isSafeInteger(Number(shopId)))) {
6763
+ _context69.next = 8;
6823
6764
  break;
6824
6765
  }
6825
- if (!(!prior.uuid || String((_prior$payload = prior.payload) === null || _prior$payload === void 0 || (_prior$payload = _prior$payload.data) === null || _prior$payload === void 0 ? void 0 : _prior$payload.order_id) !== context.orderId || ((_prior$payload2 = prior.payload) === null || _prior$payload2 === void 0 ? void 0 : _prior$payload2.channel) !== context.channel)) {
6826
- _context70.next = 10;
6827
- break;
6828
- }
6829
- throw new Error('Cloud invoice message UUID conflicts with another task');
6830
- case 10:
6831
- return _context70.abrupt("return", {
6832
- task_uuid: prior.uuid
6833
- });
6766
+ throw new Error('Cloud invoice shop is unavailable');
6767
+ case 8:
6768
+ assertCurrentShop = function assertCurrentShop() {
6769
+ var _this19$getAppData, _this19$getAppData2;
6770
+ if (String((_this19$getAppData = _this19.getAppData('shop_id')) !== null && _this19$getAppData !== void 0 ? _this19$getAppData : '') !== shopId || String((_this19$getAppData2 = _this19.getAppData('tenant_id')) !== null && _this19$getAppData2 !== void 0 ? _this19$getAppData2 : '') !== tenantId) {
6771
+ throw new Error('Cloud invoice shop context changed');
6772
+ }
6773
+ };
6774
+ _context69.next = 11;
6775
+ return this.loadCloudInvoiceOrder(orderId, shopId, assertCurrentShop);
6834
6776
  case 11:
6835
- _context70.next = 13;
6836
- return this.loadCloudInvoiceOrder(context);
6837
- case 13:
6838
- order = _context70.sent;
6777
+ order = _context69.sent;
6839
6778
  businessCode = order.business_code.trim();
6840
6779
  if (submit) {
6841
- _context70.next = 17;
6780
+ _context69.next = 15;
6842
6781
  break;
6843
6782
  }
6844
- return _context70.abrupt("return", {
6845
- business_code: businessCode,
6846
- device_id: context.deviceId
6783
+ return _context69.abrupt("return", {
6784
+ code: 200,
6785
+ status: true,
6786
+ message: '',
6787
+ data: {
6788
+ business_code: businessCode
6789
+ }
6847
6790
  });
6848
- case 17:
6791
+ case 15:
6849
6792
  if (!(input.business_code !== businessCode || typeof ((_input$template_setti = input.template_settings) === null || _input$template_setti === void 0 ? void 0 : _input$template_setti.template) !== 'string' || !input.template_settings.template.trim() || !Array.isArray(input.template_settings.modules))) {
6850
- _context70.next = 19;
6793
+ _context69.next = 17;
6851
6794
  break;
6852
6795
  }
6853
6796
  throw new Error('Cloud invoice template is missing or belongs to another business');
6854
- case 19:
6797
+ case 17:
6855
6798
  settings = this.normalizePrintInvoiceTemplateSettings(input.template_settings);
6856
- _context70.next = 22;
6799
+ _context69.next = 20;
6857
6800
  return this.rebuildOrderReceipt(order, settings);
6858
- case 22:
6859
- receipt = _context70.sent;
6801
+ case 20:
6802
+ receipt = _context69.sent;
6860
6803
  smallTicketData = (_receipt$payment_info = receipt.payment_info) === null || _receipt$payment_info === void 0 ? void 0 : _receipt$payment_info.small_ticket_data;
6861
6804
  if (hasSmallTicketData(smallTicketData)) {
6862
- _context70.next = 26;
6805
+ _context69.next = 24;
6863
6806
  break;
6864
6807
  }
6865
6808
  throw new Error('Cloud invoice snapshot is unavailable');
6866
- case 26:
6867
- _context70.next = 28;
6868
- return this.getCloudInvoiceDevice(context.shopId);
6869
- case 28:
6870
- device = _context70.sent;
6871
- if (!(device.id !== context.deviceId)) {
6872
- _context70.next = 31;
6809
+ case 24:
6810
+ deviceTask = this.getDeviceTaskPlugin();
6811
+ if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6812
+ _context69.next = 27;
6873
6813
  break;
6874
6814
  }
6875
- throw new Error('Cloud invoice device changed');
6876
- case 31:
6877
- this.assertCloudInvoiceContext(context);
6878
- _context70.next = 34;
6815
+ throw new Error('Print task service is unavailable');
6816
+ case 27:
6817
+ _context69.next = 29;
6818
+ return this.getShortNumberOrDeviceId();
6819
+ case 29:
6820
+ deviceId = _context69.sent;
6821
+ assertCurrentShop();
6822
+ _context69.next = 33;
6879
6823
  return deviceTask.dispatch({
6880
6824
  action: 'print_all',
6881
- device_id: device.target,
6825
+ device_id: deviceId,
6882
6826
  name: 'PRINT_V1',
6883
6827
  source: 'server',
6884
- source_type: 'cloud_order_invoice',
6828
+ source_type: 'order',
6885
6829
  source_id: order.order_id,
6886
- durability: 'durable',
6887
- idempotency_key: context.taskKey,
6888
6830
  payload: {
6889
6831
  type: '0',
6890
- shop_id: context.shopId,
6891
- device_id: context.deviceId,
6892
- message_uuid: context.messageUuid,
6893
- channel: context.channel,
6894
6832
  template_settings: settings,
6895
6833
  data: {
6896
6834
  order_id: order.order_id,
@@ -6898,151 +6836,34 @@ var Server = /*#__PURE__*/function () {
6898
6836
  }
6899
6837
  }
6900
6838
  });
6901
- case 34:
6902
- task = _context70.sent;
6903
- if (task !== null && task !== void 0 && task.uuid) {
6904
- _context70.next = 37;
6905
- break;
6906
- }
6907
- throw new Error('Cloud invoice task was not accepted');
6908
- case 37:
6909
- return _context70.abrupt("return", {
6910
- task_uuid: task.uuid
6911
- });
6912
- case 38:
6913
- case "end":
6914
- return _context70.stop();
6915
- }
6916
- }, _callee70, this);
6917
- }));
6918
- function resolveCloudOrderInvoice(_x74, _x75, _x76) {
6919
- return _resolveCloudOrderInvoice.apply(this, arguments);
6920
- }
6921
- return resolveCloudOrderInvoice;
6922
- }()
6923
- }, {
6924
- key: "handleCloudOrderInvoice",
6925
- value: function () {
6926
- var _handleCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(input, submit) {
6927
- var _input$order_id2, _input$shop_id;
6928
- var orderId, shopId, messageUuid, channel, _this$getAppData4, tenantId, _yield$this$getCloudI, deviceId, taskKey, context, result, pending, submission, message;
6929
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6930
- while (1) switch (_context71.prev = _context71.next) {
6931
- case 0:
6932
- orderId = String((_input$order_id2 = input === null || input === void 0 ? void 0 : input.order_id) !== null && _input$order_id2 !== void 0 ? _input$order_id2 : '').trim();
6933
- shopId = String((_input$shop_id = input === null || input === void 0 ? void 0 : input.shop_id) !== null && _input$shop_id !== void 0 ? _input$shop_id : '').trim();
6934
- messageUuid = typeof (input === null || input === void 0 ? void 0 : input.message_uuid) === 'string' ? input.message_uuid.trim() : '';
6935
- channel = typeof (input === null || input === void 0 ? void 0 : input.channel) === 'string' ? input.channel.trim() : '';
6936
- if (!(!/^[1-9]\d*$/.test(orderId) || !/^[1-9]\d*$/.test(shopId) || !Number.isSafeInteger(Number(shopId)) || typeof input.order_id === 'number' && !Number.isSafeInteger(input.order_id) || !messageUuid || !channel)) {
6937
- _context71.next = 6;
6938
- break;
6939
- }
6940
- return _context71.abrupt("return", {
6941
- code: 400,
6942
- status: false,
6943
- message: 'Invalid cloud invoice command',
6944
- data: null
6945
- });
6946
- case 6:
6947
- _context71.prev = 6;
6948
- tenantId = String((_this$getAppData4 = this.getAppData('tenant_id')) !== null && _this$getAppData4 !== void 0 ? _this$getAppData4 : '');
6949
- _context71.next = 10;
6950
- return this.getCloudInvoiceDevice(shopId);
6951
- case 10:
6952
- _yield$this$getCloudI = _context71.sent;
6953
- deviceId = _yield$this$getCloudI.id;
6954
- if (!(submit && input.device_id !== deviceId)) {
6955
- _context71.next = 14;
6956
- break;
6957
- }
6958
- throw new Error('Cloud invoice device changed');
6959
- case 14:
6960
- taskKey = 'cloud_order_invoice:' + JSON.stringify([shopId, deviceId, messageUuid]);
6961
- context = {
6962
- taskKey: taskKey,
6963
- shopId: shopId,
6964
- tenantId: tenantId,
6965
- deviceId: deviceId,
6966
- orderId: orderId,
6967
- messageUuid: messageUuid,
6968
- channel: channel
6969
- };
6970
- this.assertCloudInvoiceContext(context);
6971
- pending = this.cloudInvoiceSubmissions.get(taskKey);
6972
- if (!pending) {
6973
- _context71.next = 26;
6974
- break;
6975
- }
6976
- if (!(pending.context.orderId !== orderId || pending.context.channel !== channel || pending.context.tenantId !== tenantId)) {
6977
- _context71.next = 21;
6978
- break;
6979
- }
6980
- throw new Error('Cloud invoice message UUID conflicts with an in-flight order');
6981
- case 21:
6982
- _context71.next = 23;
6983
- return pending.result;
6984
- case 23:
6985
- result = _context71.sent;
6986
- _context71.next = 41;
6987
- break;
6988
- case 26:
6989
- if (!submit) {
6990
- _context71.next = 38;
6991
- break;
6992
- }
6993
- submission = this.resolveCloudOrderInvoice(context, input, true);
6994
- this.cloudInvoiceSubmissions.set(taskKey, {
6995
- context: context,
6996
- result: submission
6997
- });
6998
- _context71.prev = 29;
6999
- _context71.next = 32;
7000
- return submission;
7001
- case 32:
7002
- result = _context71.sent;
7003
6839
  case 33:
7004
- _context71.prev = 33;
7005
- this.cloudInvoiceSubmissions.delete(taskKey);
7006
- return _context71.finish(33);
7007
- case 36:
7008
- _context71.next = 41;
7009
- break;
7010
- case 38:
7011
- _context71.next = 40;
7012
- return this.resolveCloudOrderInvoice(context, input, false);
7013
- case 40:
7014
- result = _context71.sent;
7015
- case 41:
7016
- return _context71.abrupt("return", {
6840
+ return _context69.abrupt("return", {
7017
6841
  code: 200,
7018
6842
  status: true,
7019
6843
  message: '',
7020
- data: result
6844
+ data: null
7021
6845
  });
7022
- case 44:
7023
- _context71.prev = 44;
7024
- _context71.t0 = _context71["catch"](6);
7025
- message = this.getUnknownErrorMessage(_context71.t0);
6846
+ case 36:
6847
+ _context69.prev = 36;
6848
+ _context69.t0 = _context69["catch"](3);
6849
+ message = this.getUnknownErrorMessage(_context69.t0);
7026
6850
  this.logWarning('Cloud invoice request failed', {
7027
- shopId: shopId,
7028
6851
  orderId: orderId,
7029
- messageUuid: messageUuid,
7030
- channel: channel,
7031
6852
  message: message
7032
6853
  });
7033
- return _context71.abrupt("return", {
6854
+ return _context69.abrupt("return", {
7034
6855
  code: 500,
7035
6856
  status: false,
7036
6857
  message: message,
7037
6858
  data: null
7038
6859
  });
7039
- case 49:
6860
+ case 41:
7040
6861
  case "end":
7041
- return _context71.stop();
6862
+ return _context69.stop();
7042
6863
  }
7043
- }, _callee71, this, [[6, 44], [29,, 33, 36]]);
6864
+ }, _callee69, this, [[3, 36]]);
7044
6865
  }));
7045
- function handleCloudOrderInvoice(_x77, _x78) {
6866
+ function handleCloudOrderInvoice(_x75, _x76) {
7046
6867
  return _handleCloudOrderInvoice.apply(this, arguments);
7047
6868
  }
7048
6869
  return handleCloudOrderInvoice;
@@ -7084,57 +6905,57 @@ var Server = /*#__PURE__*/function () {
7084
6905
  }, {
7085
6906
  key: "syncMachinecodeRedeemStatusToLocalOrder",
7086
6907
  value: function () {
7087
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data, ids, status) {
6908
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(data, ids, status) {
7088
6909
  var _this$order5, _data$order_id2;
7089
6910
  var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
7090
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7091
- while (1) switch (_context72.prev = _context72.next) {
6911
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6912
+ while (1) switch (_context70.prev = _context70.next) {
7092
6913
  case 0:
7093
6914
  title = 'handleMachinecodeBatchMetadata';
7094
6915
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
7095
6916
  if (!(lookup === undefined)) {
7096
- _context72.next = 5;
6917
+ _context70.next = 5;
7097
6918
  break;
7098
6919
  }
7099
6920
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
7100
6921
  batchSize: ids.length,
7101
6922
  status: status
7102
6923
  });
7103
- return _context72.abrupt("return");
6924
+ return _context70.abrupt("return");
7104
6925
  case 5:
7105
6926
  if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
7106
- _context72.next = 8;
6927
+ _context70.next = 8;
7107
6928
  break;
7108
6929
  }
7109
6930
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
7110
6931
  lookup: lookup,
7111
6932
  status: status
7112
6933
  });
7113
- return _context72.abrupt("return");
6934
+ return _context70.abrupt("return");
7114
6935
  case 8:
7115
- _context72.next = 10;
6936
+ _context70.next = 10;
7116
6937
  return this.order.getLocalOrderByLookup(lookup);
7117
6938
  case 10:
7118
- localOrder = _context72.sent;
6939
+ localOrder = _context70.sent;
7119
6940
  orderId = (_data$order_id2 = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id2 !== void 0 ? _data$order_id2 : data === null || data === void 0 ? void 0 : data.orderId;
7120
6941
  if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
7121
- _context72.next = 16;
6942
+ _context70.next = 16;
7122
6943
  break;
7123
6944
  }
7124
- _context72.next = 15;
6945
+ _context70.next = 15;
7125
6946
  return this.order.getLocalOrderByLookup(orderId);
7126
6947
  case 15:
7127
- localOrder = _context72.sent;
6948
+ localOrder = _context70.sent;
7128
6949
  case 16:
7129
6950
  if (localOrder) {
7130
- _context72.next = 19;
6951
+ _context70.next = 19;
7131
6952
  break;
7132
6953
  }
7133
6954
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
7134
6955
  lookup: lookup,
7135
6956
  status: status
7136
6957
  });
7137
- return _context72.abrupt("return");
6958
+ return _context70.abrupt("return");
7138
6959
  case 19:
7139
6960
  voucherIdSet = new Set(ids.filter(function (id) {
7140
6961
  return id !== undefined && id !== null && id !== '';
@@ -7142,14 +6963,14 @@ var Server = /*#__PURE__*/function () {
7142
6963
  return String(id);
7143
6964
  }));
7144
6965
  if (!(voucherIdSet.size === 0)) {
7145
- _context72.next = 23;
6966
+ _context70.next = 23;
7146
6967
  break;
7147
6968
  }
7148
6969
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
7149
6970
  lookup: lookup,
7150
6971
  status: status
7151
6972
  });
7152
- return _context72.abrupt("return");
6973
+ return _context70.abrupt("return");
7153
6974
  case 23:
7154
6975
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
7155
6976
  hasUpdatedVoucher = false;
@@ -7163,7 +6984,7 @@ var Server = /*#__PURE__*/function () {
7163
6984
  });
7164
6985
  });
7165
6986
  if (hasUpdatedVoucher) {
7166
- _context72.next = 29;
6987
+ _context70.next = 29;
7167
6988
  break;
7168
6989
  }
7169
6990
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -7171,13 +6992,13 @@ var Server = /*#__PURE__*/function () {
7171
6992
  voucher_ids: Array.from(voucherIdSet),
7172
6993
  status: status
7173
6994
  });
7174
- return _context72.abrupt("return");
6995
+ return _context70.abrupt("return");
7175
6996
  case 29:
7176
6997
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
7177
- _context72.next = 34;
6998
+ _context70.next = 34;
7178
6999
  break;
7179
7000
  }
7180
- _context72.next = 32;
7001
+ _context70.next = 32;
7181
7002
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
7182
7003
  vouchers: nextVouchers
7183
7004
  }));
@@ -7187,13 +7008,13 @@ var Server = /*#__PURE__*/function () {
7187
7008
  updatedCount: voucherIdSet.size,
7188
7009
  status: status
7189
7010
  });
7190
- return _context72.abrupt("return");
7011
+ return _context70.abrupt("return");
7191
7012
  case 34:
7192
7013
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
7193
- _context72.next = 39;
7014
+ _context70.next = 39;
7194
7015
  break;
7195
7016
  }
7196
- _context72.next = 37;
7017
+ _context70.next = 37;
7197
7018
  return this.order.markOrderSyncedByExternalSaleNumber({
7198
7019
  externalSaleNumber: data.external_sale_number,
7199
7020
  patch: {
@@ -7206,7 +7027,7 @@ var Server = /*#__PURE__*/function () {
7206
7027
  updatedCount: voucherIdSet.size,
7207
7028
  status: status
7208
7029
  });
7209
- return _context72.abrupt("return");
7030
+ return _context70.abrupt("return");
7210
7031
  case 39:
7211
7032
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
7212
7033
  lookup: lookup,
@@ -7214,11 +7035,11 @@ var Server = /*#__PURE__*/function () {
7214
7035
  });
7215
7036
  case 40:
7216
7037
  case "end":
7217
- return _context72.stop();
7038
+ return _context70.stop();
7218
7039
  }
7219
- }, _callee72, this);
7040
+ }, _callee70, this);
7220
7041
  }));
7221
- function syncMachinecodeRedeemStatusToLocalOrder(_x79, _x80, _x81) {
7042
+ function syncMachinecodeRedeemStatusToLocalOrder(_x77, _x78, _x79) {
7222
7043
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
7223
7044
  }
7224
7045
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -7226,30 +7047,30 @@ var Server = /*#__PURE__*/function () {
7226
7047
  }, {
7227
7048
  key: "handleOrderCheckoutSubmit",
7228
7049
  value: function () {
7229
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
7050
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
7230
7051
  var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
7231
7052
  var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
7232
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7233
- while (1) switch (_context73.prev = _context73.next) {
7053
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7054
+ while (1) switch (_context71.prev = _context71.next) {
7234
7055
  case 0:
7235
7056
  backendPath = params.backendPath, title = params.title;
7236
7057
  lookup = ((_params$data5 = params.data) === null || _params$data5 === void 0 ? void 0 : _params$data5.order_id) || ((_params$data6 = params.data) === null || _params$data6 === void 0 ? void 0 : _params$data6.external_sale_number);
7237
- _context73.t0 = lookup;
7238
- if (!_context73.t0) {
7239
- _context73.next = 7;
7058
+ _context71.t0 = lookup;
7059
+ if (!_context71.t0) {
7060
+ _context71.next = 7;
7240
7061
  break;
7241
7062
  }
7242
- _context73.next = 6;
7063
+ _context71.next = 6;
7243
7064
  return (_this$order6 = this.order) === null || _this$order6 === void 0 || (_this$order6$getLocal = _this$order6.getLocalOrderByLookup) === null || _this$order6$getLocal === void 0 ? void 0 : _this$order6$getLocal.call(_this$order6, lookup);
7244
7065
  case 6:
7245
- _context73.t0 = _context73.sent;
7066
+ _context71.t0 = _context71.sent;
7246
7067
  case 7:
7247
- localOrder = _context73.t0;
7068
+ localOrder = _context71.t0;
7248
7069
  if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
7249
- _context73.next = 10;
7070
+ _context71.next = 10;
7250
7071
  break;
7251
7072
  }
7252
- return _context73.abrupt("return", {
7073
+ return _context71.abrupt("return", {
7253
7074
  code: 409,
7254
7075
  status: false,
7255
7076
  message: PAYMENT_REFRESH_MESSAGE,
@@ -7273,10 +7094,10 @@ var Server = /*#__PURE__*/function () {
7273
7094
  order_number: data === null || data === void 0 ? void 0 : data.order_number
7274
7095
  });
7275
7096
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
7276
- _context73.next = 19;
7097
+ _context71.next = 19;
7277
7098
  break;
7278
7099
  }
7279
- return _context73.abrupt("return", this.handleSyncCheckoutSubmit({
7100
+ return _context71.abrupt("return", this.handleSyncCheckoutSubmit({
7280
7101
  backendPath: backendPath,
7281
7102
  data: data,
7282
7103
  title: title,
@@ -7285,16 +7106,16 @@ var Server = /*#__PURE__*/function () {
7285
7106
  receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
7286
7107
  }));
7287
7108
  case 19:
7288
- _context73.next = 21;
7109
+ _context71.next = 21;
7289
7110
  return this.normalizeCheckoutSubmitData(data, title);
7290
7111
  case 21:
7291
- normalizedData = _context73.sent;
7292
- _context73.next = 24;
7112
+ normalizedData = _context71.sent;
7113
+ _context71.next = 24;
7293
7114
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
7294
7115
  case 24:
7295
- numberedData = _context73.sent;
7116
+ numberedData = _context71.sent;
7296
7117
  checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
7297
- _context73.next = 28;
7118
+ _context71.next = 28;
7298
7119
  return this.handlePendingSyncCheckoutOrder({
7299
7120
  backendPath: backendPath,
7300
7121
  data: checkoutData,
@@ -7303,18 +7124,18 @@ var Server = /*#__PURE__*/function () {
7303
7124
  invoiceTemplateSettings: invoiceTemplateSettings
7304
7125
  });
7305
7126
  case 28:
7306
- pendingResult = _context73.sent;
7127
+ pendingResult = _context71.sent;
7307
7128
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
7308
- _context73.next = 43;
7129
+ _context71.next = 43;
7309
7130
  break;
7310
7131
  }
7311
7132
  pendingOrder = pendingResult.data;
7312
7133
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
7313
- _context73.next = 41;
7134
+ _context71.next = 41;
7314
7135
  break;
7315
7136
  }
7316
- _context73.prev = 32;
7317
- _context73.next = 35;
7137
+ _context71.prev = 32;
7138
+ _context71.next = 35;
7318
7139
  return this.dispatchLocalReceiptPrint({
7319
7140
  checkoutData: checkoutData,
7320
7141
  order: pendingOrder,
@@ -7324,19 +7145,19 @@ var Server = /*#__PURE__*/function () {
7324
7145
  invoiceTemplateSettings: invoiceTemplateSettings
7325
7146
  });
7326
7147
  case 35:
7327
- _context73.next = 41;
7148
+ _context71.next = 41;
7328
7149
  break;
7329
7150
  case 37:
7330
- _context73.prev = 37;
7331
- _context73.t1 = _context73["catch"](32);
7151
+ _context71.prev = 37;
7152
+ _context71.t1 = _context71["catch"](32);
7332
7153
  // The sale is already persisted. A failed receipt must not cancel its
7333
7154
  // sync task or send an unfiltered fallback to the printer.
7334
- pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context73.t1);
7155
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context71.t1);
7335
7156
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
7336
7157
  error: pendingResult.receipt_print_error
7337
7158
  });
7338
7159
  case 41:
7339
- _context73.next = 43;
7160
+ _context71.next = 43;
7340
7161
  return this.dispatchCheckoutSyncTask({
7341
7162
  backendPath: backendPath,
7342
7163
  data: checkoutData,
@@ -7346,23 +7167,23 @@ var Server = /*#__PURE__*/function () {
7346
7167
  });
7347
7168
  case 43:
7348
7169
  if (pendingResult.data.order_id) {
7349
- _context73.next = 45;
7170
+ _context71.next = 45;
7350
7171
  break;
7351
7172
  }
7352
- return _context73.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
7173
+ return _context71.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
7353
7174
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
7354
7175
  order_id: pendingResult.data.external_sale_number
7355
7176
  })
7356
7177
  }));
7357
7178
  case 45:
7358
- return _context73.abrupt("return", pendingResult);
7179
+ return _context71.abrupt("return", pendingResult);
7359
7180
  case 46:
7360
7181
  case "end":
7361
- return _context73.stop();
7182
+ return _context71.stop();
7362
7183
  }
7363
- }, _callee73, this, [[32, 37]]);
7184
+ }, _callee71, this, [[32, 37]]);
7364
7185
  }));
7365
- function handleOrderCheckoutSubmit(_x82) {
7186
+ function handleOrderCheckoutSubmit(_x80) {
7366
7187
  return _handleOrderCheckoutSubmit.apply(this, arguments);
7367
7188
  }
7368
7189
  return handleOrderCheckoutSubmit;
@@ -7370,27 +7191,27 @@ var Server = /*#__PURE__*/function () {
7370
7191
  }, {
7371
7192
  key: "handleSyncCheckoutSubmit",
7372
7193
  value: function () {
7373
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7194
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7374
7195
  var _this$app18;
7375
7196
  var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
7376
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7377
- while (1) switch (_context74.prev = _context74.next) {
7197
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7198
+ while (1) switch (_context72.prev = _context72.next) {
7378
7199
  case 0:
7379
7200
  backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
7380
7201
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && (_this$app18 = _this$app18.request) !== null && _this$app18 !== void 0 && _this$app18.post) {
7381
- _context74.next = 4;
7202
+ _context72.next = 4;
7382
7203
  break;
7383
7204
  }
7384
7205
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
7385
- return _context74.abrupt("return", {
7206
+ return _context72.abrupt("return", {
7386
7207
  code: 500,
7387
7208
  status: false,
7388
7209
  message: 'app.request 不可用',
7389
7210
  data: null
7390
7211
  });
7391
7212
  case 4:
7392
- _context74.prev = 4;
7393
- _context74.next = 7;
7213
+ _context72.prev = 4;
7214
+ _context72.next = 7;
7394
7215
  return this.runCheckoutSync({
7395
7216
  backendPath: backendPath,
7396
7217
  data: data,
@@ -7400,13 +7221,13 @@ var Server = /*#__PURE__*/function () {
7400
7221
  invoiceTemplateSettings: invoiceTemplateSettings
7401
7222
  });
7402
7223
  case 7:
7403
- syncResult = _context74.sent;
7224
+ syncResult = _context72.sent;
7404
7225
  if (!syncResult.rejected) {
7405
- _context74.next = 11;
7226
+ _context72.next = 11;
7406
7227
  break;
7407
7228
  }
7408
7229
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
7409
- return _context74.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
7230
+ return _context72.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
7410
7231
  status: false,
7411
7232
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
7412
7233
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -7415,11 +7236,11 @@ var Server = /*#__PURE__*/function () {
7415
7236
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
7416
7237
  syncedOrder = syncResult.syncedOrder;
7417
7238
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
7418
- _context74.next = 23;
7239
+ _context72.next = 23;
7419
7240
  break;
7420
7241
  }
7421
- _context74.prev = 14;
7422
- _context74.next = 17;
7242
+ _context72.prev = 14;
7243
+ _context72.next = 17;
7423
7244
  return this.dispatchLocalReceiptPrint({
7424
7245
  checkoutData: syncResult.checkoutData,
7425
7246
  order: syncedOrder,
@@ -7429,41 +7250,41 @@ var Server = /*#__PURE__*/function () {
7429
7250
  invoiceTemplateSettings: invoiceTemplateSettings
7430
7251
  });
7431
7252
  case 17:
7432
- _context74.next = 23;
7253
+ _context72.next = 23;
7433
7254
  break;
7434
7255
  case 19:
7435
- _context74.prev = 19;
7436
- _context74.t0 = _context74["catch"](14);
7256
+ _context72.prev = 19;
7257
+ _context72.t0 = _context72["catch"](14);
7437
7258
  // Checkout already succeeded remotely; report the receipt failure
7438
7259
  // separately instead of implying that payment/order creation failed.
7439
- response.receipt_print_error = this.getUnknownErrorMessage(_context74.t0);
7260
+ response.receipt_print_error = this.getUnknownErrorMessage(_context72.t0);
7440
7261
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
7441
7262
  error: response.receipt_print_error
7442
7263
  });
7443
7264
  case 23:
7444
- return _context74.abrupt("return", response);
7265
+ return _context72.abrupt("return", response);
7445
7266
  case 26:
7446
- _context74.prev = 26;
7447
- _context74.t1 = _context74["catch"](4);
7448
- backendError = this.extractBackendErrorResponse(_context74.t1);
7267
+ _context72.prev = 26;
7268
+ _context72.t1 = _context72["catch"](4);
7269
+ backendError = this.extractBackendErrorResponse(_context72.t1);
7449
7270
  if (!backendError) {
7450
- _context74.next = 32;
7271
+ _context72.next = 32;
7451
7272
  break;
7452
7273
  }
7453
7274
  _normalized = this.normalizeCheckoutResponse(backendError);
7454
- return _context74.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
7275
+ return _context72.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
7455
7276
  status: false,
7456
7277
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
7457
7278
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
7458
7279
  }));
7459
7280
  case 32:
7460
- message = this.getUnknownErrorMessage(_context74.t1);
7281
+ message = this.getUnknownErrorMessage(_context72.t1);
7461
7282
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
7462
7283
  backendPath: backendPath,
7463
7284
  error: message,
7464
- error_detail: this.normalizeUnknownError(_context74.t1)
7285
+ error_detail: this.normalizeUnknownError(_context72.t1)
7465
7286
  });
7466
- return _context74.abrupt("return", {
7287
+ return _context72.abrupt("return", {
7467
7288
  code: 500,
7468
7289
  status: false,
7469
7290
  message: message,
@@ -7471,11 +7292,11 @@ var Server = /*#__PURE__*/function () {
7471
7292
  });
7472
7293
  case 35:
7473
7294
  case "end":
7474
- return _context74.stop();
7295
+ return _context72.stop();
7475
7296
  }
7476
- }, _callee74, this, [[4, 26], [14, 19]]);
7297
+ }, _callee72, this, [[4, 26], [14, 19]]);
7477
7298
  }));
7478
- function handleSyncCheckoutSubmit(_x83) {
7299
+ function handleSyncCheckoutSubmit(_x81) {
7479
7300
  return _handleSyncCheckoutSubmit.apply(this, arguments);
7480
7301
  }
7481
7302
  return handleSyncCheckoutSubmit;
@@ -7483,10 +7304,10 @@ var Server = /*#__PURE__*/function () {
7483
7304
  }, {
7484
7305
  key: "handleOrderDraftSubmit",
7485
7306
  value: function () {
7486
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(params) {
7307
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
7487
7308
  var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
7488
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7489
- while (1) switch (_context75.prev = _context75.next) {
7309
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7310
+ while (1) switch (_context73.prev = _context73.next) {
7490
7311
  case 0:
7491
7312
  title = params.title;
7492
7313
  extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
@@ -7500,10 +7321,10 @@ var Server = /*#__PURE__*/function () {
7500
7321
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
7501
7322
  order_number: data === null || data === void 0 ? void 0 : data.order_number
7502
7323
  });
7503
- _context75.next = 6;
7324
+ _context73.next = 6;
7504
7325
  return this.normalizeCheckoutSubmitData(data, title);
7505
7326
  case 6:
7506
- normalizedData = _context75.sent;
7327
+ normalizedData = _context73.sent;
7507
7328
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
7508
7329
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
7509
7330
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -7513,26 +7334,26 @@ var Server = /*#__PURE__*/function () {
7513
7334
  is_draft_order: 1
7514
7335
  });
7515
7336
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
7516
- _context75.next = 12;
7337
+ _context73.next = 12;
7517
7338
  break;
7518
7339
  }
7519
7340
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
7520
- return _context75.abrupt("return", {
7341
+ return _context73.abrupt("return", {
7521
7342
  code: 500,
7522
7343
  status: false,
7523
7344
  message: 'Order 模块不支持本地草稿写入',
7524
7345
  data: null
7525
7346
  });
7526
7347
  case 12:
7527
- _context75.prev = 12;
7528
- _context75.next = 15;
7348
+ _context73.prev = 12;
7349
+ _context73.next = 15;
7529
7350
  return this.order.upsertLocalDraftOrders([draftOrder]);
7530
7351
  case 15:
7531
7352
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
7532
7353
  order_id: draftOrder.order_id,
7533
7354
  external_sale_number: draftOrder.external_sale_number
7534
7355
  });
7535
- return _context75.abrupt("return", {
7356
+ return _context73.abrupt("return", {
7536
7357
  code: 200,
7537
7358
  status: true,
7538
7359
  message: '',
@@ -7544,13 +7365,13 @@ var Server = /*#__PURE__*/function () {
7544
7365
  })
7545
7366
  });
7546
7367
  case 19:
7547
- _context75.prev = 19;
7548
- _context75.t0 = _context75["catch"](12);
7549
- errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
7368
+ _context73.prev = 19;
7369
+ _context73.t0 = _context73["catch"](12);
7370
+ errorMessage = _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0);
7550
7371
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
7551
7372
  error: errorMessage
7552
7373
  });
7553
- return _context75.abrupt("return", {
7374
+ return _context73.abrupt("return", {
7554
7375
  code: 500,
7555
7376
  status: false,
7556
7377
  message: errorMessage,
@@ -7558,11 +7379,11 @@ var Server = /*#__PURE__*/function () {
7558
7379
  });
7559
7380
  case 24:
7560
7381
  case "end":
7561
- return _context75.stop();
7382
+ return _context73.stop();
7562
7383
  }
7563
- }, _callee75, this, [[12, 19]]);
7384
+ }, _callee73, this, [[12, 19]]);
7564
7385
  }));
7565
- function handleOrderDraftSubmit(_x84) {
7386
+ function handleOrderDraftSubmit(_x82) {
7566
7387
  return _handleOrderDraftSubmit.apply(this, arguments);
7567
7388
  }
7568
7389
  return handleOrderDraftSubmit;
@@ -7570,26 +7391,26 @@ var Server = /*#__PURE__*/function () {
7570
7391
  }, {
7571
7392
  key: "handlePendingSyncCheckoutOrder",
7572
7393
  value: function () {
7573
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
7394
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7574
7395
  var _this20 = this;
7575
7396
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
7576
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7577
- while (1) switch (_context76.prev = _context76.next) {
7397
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7398
+ while (1) switch (_context74.prev = _context74.next) {
7578
7399
  case 0:
7579
7400
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
7580
- _context76.next = 3;
7401
+ _context74.next = 3;
7581
7402
  return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
7582
7403
  case 3:
7583
- pendingOrder = _context76.sent;
7404
+ pendingOrder = _context74.sent;
7584
7405
  if (pendingOrder) {
7585
- _context76.next = 7;
7406
+ _context74.next = 7;
7586
7407
  break;
7587
7408
  }
7588
7409
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
7589
7410
  backendPath: backendPath,
7590
7411
  reason: reason
7591
7412
  });
7592
- return _context76.abrupt("return", {
7413
+ return _context74.abrupt("return", {
7593
7414
  code: 500,
7594
7415
  status: false,
7595
7416
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -7597,22 +7418,22 @@ var Server = /*#__PURE__*/function () {
7597
7418
  });
7598
7419
  case 7:
7599
7420
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
7600
- _context76.next = 10;
7421
+ _context74.next = 10;
7601
7422
  break;
7602
7423
  }
7603
7424
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
7604
7425
  backendPath: backendPath,
7605
7426
  reason: reason
7606
7427
  });
7607
- return _context76.abrupt("return", {
7428
+ return _context74.abrupt("return", {
7608
7429
  code: 500,
7609
7430
  status: false,
7610
7431
  message: 'Order 模块不支持本地待同步写入',
7611
7432
  data: null
7612
7433
  });
7613
7434
  case 10:
7614
- _context76.prev = 10;
7615
- _context76.next = 13;
7435
+ _context74.prev = 10;
7436
+ _context74.next = 13;
7616
7437
  return this.order.upsertPendingSyncOrders([pendingOrder]);
7617
7438
  case 13:
7618
7439
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -7626,7 +7447,7 @@ var Server = /*#__PURE__*/function () {
7626
7447
  var _payment$metadata;
7627
7448
  return sum + _this20.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7628
7449
  }, 0);
7629
- return _context76.abrupt("return", {
7450
+ return _context74.abrupt("return", {
7630
7451
  code: 200,
7631
7452
  status: true,
7632
7453
  message: '',
@@ -7641,15 +7462,15 @@ var Server = /*#__PURE__*/function () {
7641
7462
  })
7642
7463
  });
7643
7464
  case 18:
7644
- _context76.prev = 18;
7645
- _context76.t0 = _context76["catch"](10);
7646
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
7465
+ _context74.prev = 18;
7466
+ _context74.t0 = _context74["catch"](10);
7467
+ errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
7647
7468
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
7648
7469
  backendPath: backendPath,
7649
7470
  reason: reason,
7650
7471
  error: errorMessage
7651
7472
  });
7652
- return _context76.abrupt("return", {
7473
+ return _context74.abrupt("return", {
7653
7474
  code: 500,
7654
7475
  status: false,
7655
7476
  message: errorMessage,
@@ -7657,11 +7478,11 @@ var Server = /*#__PURE__*/function () {
7657
7478
  });
7658
7479
  case 23:
7659
7480
  case "end":
7660
- return _context76.stop();
7481
+ return _context74.stop();
7661
7482
  }
7662
- }, _callee76, this, [[10, 18]]);
7483
+ }, _callee74, this, [[10, 18]]);
7663
7484
  }));
7664
- function handlePendingSyncCheckoutOrder(_x85) {
7485
+ function handlePendingSyncCheckoutOrder(_x83) {
7665
7486
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
7666
7487
  }
7667
7488
  return handlePendingSyncCheckoutOrder;
@@ -7669,45 +7490,45 @@ var Server = /*#__PURE__*/function () {
7669
7490
  }, {
7670
7491
  key: "buildPendingSyncCheckoutOrder",
7671
7492
  value: function () {
7672
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(data, invoiceTemplateSettings) {
7493
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data, invoiceTemplateSettings) {
7673
7494
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
7674
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7675
- while (1) switch (_context77.prev = _context77.next) {
7495
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7496
+ while (1) switch (_context75.prev = _context75.next) {
7676
7497
  case 0:
7677
7498
  if (!(!data || _typeof(data) !== 'object')) {
7678
- _context77.next = 2;
7499
+ _context75.next = 2;
7679
7500
  break;
7680
7501
  }
7681
- return _context77.abrupt("return", null);
7502
+ return _context75.abrupt("return", null);
7682
7503
  case 2:
7683
7504
  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 !== '';
7684
7505
  if (hasStorageKey) {
7685
- _context77.next = 5;
7506
+ _context75.next = 5;
7686
7507
  break;
7687
7508
  }
7688
- return _context77.abrupt("return", null);
7509
+ return _context75.abrupt("return", null);
7689
7510
  case 5:
7690
7511
  pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
7691
7512
  need_sync: 1,
7692
7513
  is_draft_order: 0
7693
7514
  }));
7694
- _context77.next = 8;
7515
+ _context75.next = 8;
7695
7516
  return this.buildSmallTicketProductMap(pendingOrder);
7696
7517
  case 8:
7697
- productMap = _context77.sent;
7518
+ productMap = _context75.sent;
7698
7519
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
7699
- return _context77.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7520
+ return _context75.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7700
7521
  requireFullyPaid: true,
7701
7522
  productMap: productMap,
7702
7523
  invoiceTemplateSettings: invoiceTemplateSettings
7703
7524
  }));
7704
7525
  case 11:
7705
7526
  case "end":
7706
- return _context77.stop();
7527
+ return _context75.stop();
7707
7528
  }
7708
- }, _callee77, this);
7529
+ }, _callee75, this);
7709
7530
  }));
7710
- function buildPendingSyncCheckoutOrder(_x86, _x87) {
7531
+ function buildPendingSyncCheckoutOrder(_x84, _x85) {
7711
7532
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
7712
7533
  }
7713
7534
  return buildPendingSyncCheckoutOrder;
@@ -7816,12 +7637,12 @@ var Server = /*#__PURE__*/function () {
7816
7637
  }, {
7817
7638
  key: "buildSmallTicketProductMap",
7818
7639
  value: function () {
7819
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order) {
7640
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
7820
7641
  var _this$products4,
7821
7642
  _this23 = this;
7822
7643
  var products, productIdSet, productIds, entries;
7823
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7824
- while (1) switch (_context79.prev = _context79.next) {
7644
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7645
+ while (1) switch (_context77.prev = _context77.next) {
7825
7646
  case 0:
7826
7647
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
7827
7648
  productIdSet = new Set();
@@ -7843,45 +7664,45 @@ var Server = /*#__PURE__*/function () {
7843
7664
  });
7844
7665
  productIds = Array.from(productIdSet);
7845
7666
  if (!(!productIds.length || typeof ((_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductById) !== 'function')) {
7846
- _context79.next = 6;
7667
+ _context77.next = 6;
7847
7668
  break;
7848
7669
  }
7849
- return _context79.abrupt("return", {});
7670
+ return _context77.abrupt("return", {});
7850
7671
  case 6:
7851
- _context79.next = 8;
7672
+ _context77.next = 8;
7852
7673
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7853
- var _ref80 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(id) {
7674
+ var _ref80 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(id) {
7854
7675
  var _this23$products, _this23$products$getP, product;
7855
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7856
- while (1) switch (_context78.prev = _context78.next) {
7676
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7677
+ while (1) switch (_context76.prev = _context76.next) {
7857
7678
  case 0:
7858
- _context78.prev = 0;
7859
- _context78.next = 3;
7679
+ _context76.prev = 0;
7680
+ _context76.next = 3;
7860
7681
  return (_this23$products = _this23.products) === null || _this23$products === void 0 || (_this23$products$getP = _this23$products.getProductById) === null || _this23$products$getP === void 0 ? void 0 : _this23$products$getP.call(_this23$products, Number(id));
7861
7682
  case 3:
7862
- product = _context78.sent;
7863
- return _context78.abrupt("return", product ? [String(id), product] : null);
7683
+ product = _context76.sent;
7684
+ return _context76.abrupt("return", product ? [String(id), product] : null);
7864
7685
  case 7:
7865
- _context78.prev = 7;
7866
- _context78.t0 = _context78["catch"](0);
7686
+ _context76.prev = 7;
7687
+ _context76.t0 = _context76["catch"](0);
7867
7688
  _this23.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7868
7689
  product_id: id,
7869
- error: _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0)
7690
+ error: _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0)
7870
7691
  });
7871
- return _context78.abrupt("return", null);
7692
+ return _context76.abrupt("return", null);
7872
7693
  case 11:
7873
7694
  case "end":
7874
- return _context78.stop();
7695
+ return _context76.stop();
7875
7696
  }
7876
- }, _callee78, null, [[0, 7]]);
7697
+ }, _callee76, null, [[0, 7]]);
7877
7698
  }));
7878
- return function (_x89) {
7699
+ return function (_x87) {
7879
7700
  return _ref80.apply(this, arguments);
7880
7701
  };
7881
7702
  }()));
7882
7703
  case 8:
7883
- entries = _context79.sent;
7884
- return _context79.abrupt("return", entries.reduce(function (map, entry) {
7704
+ entries = _context77.sent;
7705
+ return _context77.abrupt("return", entries.reduce(function (map, entry) {
7885
7706
  if (!entry) return map;
7886
7707
  var _entry = _slicedToArray(entry, 2),
7887
7708
  id = _entry[0],
@@ -7891,11 +7712,11 @@ var Server = /*#__PURE__*/function () {
7891
7712
  }, {}));
7892
7713
  case 10:
7893
7714
  case "end":
7894
- return _context79.stop();
7715
+ return _context77.stop();
7895
7716
  }
7896
- }, _callee79, this);
7717
+ }, _callee77, this);
7897
7718
  }));
7898
- function buildSmallTicketProductMap(_x88) {
7719
+ function buildSmallTicketProductMap(_x86) {
7899
7720
  return _buildSmallTicketProductMap.apply(this, arguments);
7900
7721
  }
7901
7722
  return buildSmallTicketProductMap;
@@ -7925,40 +7746,40 @@ var Server = /*#__PURE__*/function () {
7925
7746
  }, {
7926
7747
  key: "buildSalesDetailProductSnapshotMap",
7927
7748
  value: function () {
7928
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(order) {
7749
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order) {
7929
7750
  var _this$products5;
7930
7751
  var productIds, getSnapshots;
7931
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
7932
- while (1) switch (_context80.prev = _context80.next) {
7752
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7753
+ while (1) switch (_context78.prev = _context78.next) {
7933
7754
  case 0:
7934
7755
  productIds = this.collectSalesDetailProductIds(order);
7935
7756
  getSnapshots = (_this$products5 = this.products) === null || _this$products5 === void 0 ? void 0 : _this$products5.getProductSnapshotsByIds;
7936
7757
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
7937
- _context80.next = 4;
7758
+ _context78.next = 4;
7938
7759
  break;
7939
7760
  }
7940
- return _context80.abrupt("return", {});
7761
+ return _context78.abrupt("return", {});
7941
7762
  case 4:
7942
- _context80.prev = 4;
7943
- _context80.next = 7;
7763
+ _context78.prev = 4;
7764
+ _context78.next = 7;
7944
7765
  return getSnapshots.call(this.products, productIds);
7945
7766
  case 7:
7946
- return _context80.abrupt("return", _context80.sent);
7767
+ return _context78.abrupt("return", _context78.sent);
7947
7768
  case 10:
7948
- _context80.prev = 10;
7949
- _context80.t0 = _context80["catch"](4);
7769
+ _context78.prev = 10;
7770
+ _context78.t0 = _context78["catch"](4);
7950
7771
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
7951
7772
  product_ids: productIds,
7952
- error: _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0)
7773
+ error: _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0)
7953
7774
  });
7954
- return _context80.abrupt("return", {});
7775
+ return _context78.abrupt("return", {});
7955
7776
  case 14:
7956
7777
  case "end":
7957
- return _context80.stop();
7778
+ return _context78.stop();
7958
7779
  }
7959
- }, _callee80, this, [[4, 10]]);
7780
+ }, _callee78, this, [[4, 10]]);
7960
7781
  }));
7961
- function buildSalesDetailProductSnapshotMap(_x90) {
7782
+ function buildSalesDetailProductSnapshotMap(_x88) {
7962
7783
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
7963
7784
  }
7964
7785
  return buildSalesDetailProductSnapshotMap;
@@ -8014,28 +7835,28 @@ var Server = /*#__PURE__*/function () {
8014
7835
  }, {
8015
7836
  key: "withSalesDetailProductSnapshots",
8016
7837
  value: function () {
8017
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(order) {
7838
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order) {
8018
7839
  var _this24 = this;
8019
7840
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
8020
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8021
- while (1) switch (_context81.prev = _context81.next) {
7841
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7842
+ while (1) switch (_context79.prev = _context79.next) {
8022
7843
  case 0:
8023
7844
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
8024
7845
  if (products !== null && products !== void 0 && products.length) {
8025
- _context81.next = 3;
7846
+ _context79.next = 3;
8026
7847
  break;
8027
7848
  }
8028
- return _context81.abrupt("return", order);
7849
+ return _context79.abrupt("return", order);
8029
7850
  case 3:
8030
- _context81.next = 5;
7851
+ _context79.next = 5;
8031
7852
  return this.buildSalesDetailProductSnapshotMap(order);
8032
7853
  case 5:
8033
- snapshotMap = _context81.sent;
7854
+ snapshotMap = _context79.sent;
8034
7855
  if (Object.keys(snapshotMap).length) {
8035
- _context81.next = 8;
7856
+ _context79.next = 8;
8036
7857
  break;
8037
7858
  }
8038
- return _context81.abrupt("return", order);
7859
+ return _context79.abrupt("return", order);
8039
7860
  case 8:
8040
7861
  hasChanged = false;
8041
7862
  enrichedProducts = products.map(function (product) {
@@ -8045,22 +7866,22 @@ var Server = /*#__PURE__*/function () {
8045
7866
  return nextProduct;
8046
7867
  });
8047
7868
  if (hasChanged) {
8048
- _context81.next = 12;
7869
+ _context79.next = 12;
8049
7870
  break;
8050
7871
  }
8051
- return _context81.abrupt("return", order);
7872
+ return _context79.abrupt("return", order);
8052
7873
  case 12:
8053
7874
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
8054
7875
  products: enrichedProducts
8055
7876
  });
8056
- return _context81.abrupt("return", enrichedOrder);
7877
+ return _context79.abrupt("return", enrichedOrder);
8057
7878
  case 14:
8058
7879
  case "end":
8059
- return _context81.stop();
7880
+ return _context79.stop();
8060
7881
  }
8061
- }, _callee81, this);
7882
+ }, _callee79, this);
8062
7883
  }));
8063
- function withSalesDetailProductSnapshots(_x91) {
7884
+ function withSalesDetailProductSnapshots(_x89) {
8064
7885
  return _withSalesDetailProductSnapshots.apply(this, arguments);
8065
7886
  }
8066
7887
  return withSalesDetailProductSnapshots;
@@ -8191,31 +8012,31 @@ var Server = /*#__PURE__*/function () {
8191
8012
  }, {
8192
8013
  key: "enrichPaymentNamesByCode",
8193
8014
  value: function () {
8194
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(order) {
8015
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(order) {
8195
8016
  var _this27 = this;
8196
8017
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
8197
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8198
- while (1) switch (_context82.prev = _context82.next) {
8018
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8019
+ while (1) switch (_context80.prev = _context80.next) {
8199
8020
  case 0:
8200
8021
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
8201
8022
  hasMissingName = payments.some(function (payment) {
8202
8023
  return _this27.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this27.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
8203
8024
  });
8204
8025
  if (hasMissingName) {
8205
- _context82.next = 4;
8026
+ _context80.next = 4;
8206
8027
  break;
8207
8028
  }
8208
- return _context82.abrupt("return", order);
8029
+ return _context80.abrupt("return", order);
8209
8030
  case 4:
8210
- _context82.prev = 4;
8211
- _context82.next = 7;
8031
+ _context80.prev = 4;
8032
+ _context80.next = 7;
8212
8033
  return this.getPaymentRouteModule();
8213
8034
  case 7:
8214
- paymentModule = _context82.sent;
8215
- _context82.next = 10;
8035
+ paymentModule = _context80.sent;
8036
+ _context80.next = 10;
8216
8037
  return paymentModule.getPayMethodListAsync();
8217
8038
  case 10:
8218
- payMethods = _context82.sent;
8039
+ payMethods = _context80.sent;
8219
8040
  nameByCode = new Map();
8220
8041
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
8221
8042
  try {
@@ -8242,28 +8063,28 @@ var Server = /*#__PURE__*/function () {
8242
8063
  });
8243
8064
  });
8244
8065
  if (hasResolvedName) {
8245
- _context82.next = 18;
8066
+ _context80.next = 18;
8246
8067
  break;
8247
8068
  }
8248
- return _context82.abrupt("return", order);
8069
+ return _context80.abrupt("return", order);
8249
8070
  case 18:
8250
- return _context82.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
8071
+ return _context80.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
8251
8072
  payments: enrichedPayments
8252
8073
  }));
8253
8074
  case 21:
8254
- _context82.prev = 21;
8255
- _context82.t0 = _context82["catch"](4);
8075
+ _context80.prev = 21;
8076
+ _context80.t0 = _context80["catch"](4);
8256
8077
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
8257
- error: _context82.t0 instanceof Error ? _context82.t0.message : String(_context82.t0)
8078
+ error: _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0)
8258
8079
  });
8259
- return _context82.abrupt("return", order);
8080
+ return _context80.abrupt("return", order);
8260
8081
  case 25:
8261
8082
  case "end":
8262
- return _context82.stop();
8083
+ return _context80.stop();
8263
8084
  }
8264
- }, _callee82, this, [[4, 21]]);
8085
+ }, _callee80, this, [[4, 21]]);
8265
8086
  }));
8266
- function enrichPaymentNamesByCode(_x92) {
8087
+ function enrichPaymentNamesByCode(_x90) {
8267
8088
  return _enrichPaymentNamesByCode.apply(this, arguments);
8268
8089
  }
8269
8090
  return enrichPaymentNamesByCode;
@@ -8271,25 +8092,25 @@ var Server = /*#__PURE__*/function () {
8271
8092
  }, {
8272
8093
  key: "withLocalSmallTicketData",
8273
8094
  value: function () {
8274
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(order, options) {
8095
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(order, options) {
8275
8096
  var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref85, _ref86, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
8276
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8277
- while (1) switch (_context83.prev = _context83.next) {
8097
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8098
+ while (1) switch (_context81.prev = _context81.next) {
8278
8099
  case 0:
8279
8100
  mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
8280
8101
  if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
8281
- _context83.next = 3;
8102
+ _context81.next = 3;
8282
8103
  break;
8283
8104
  }
8284
- return _context83.abrupt("return", order);
8105
+ return _context81.abrupt("return", order);
8285
8106
  case 3:
8286
8107
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
8287
- _context83.next = 5;
8108
+ _context81.next = 5;
8288
8109
  break;
8289
8110
  }
8290
- return _context83.abrupt("return", order);
8111
+ return _context81.abrupt("return", order);
8291
8112
  case 5:
8292
- _context83.prev = 5;
8113
+ _context81.prev = 5;
8293
8114
  normalizedCollections = normalizeOrderCollections(order, {
8294
8115
  ensureUid: false
8295
8116
  });
@@ -8308,37 +8129,37 @@ var Server = /*#__PURE__*/function () {
8308
8129
  });
8309
8130
  }
8310
8131
  if (!(options !== null && options !== void 0 && options.refreshResourceReference)) {
8311
- _context83.next = 16;
8132
+ _context81.next = 16;
8312
8133
  break;
8313
8134
  }
8314
- _context83.next = 13;
8135
+ _context81.next = 13;
8315
8136
  return this.withCurrentReceiptResourceReference(normalizedOrder);
8316
8137
  case 13:
8317
- _context83.t0 = _context83.sent;
8318
- _context83.next = 17;
8138
+ _context81.t0 = _context81.sent;
8139
+ _context81.next = 17;
8319
8140
  break;
8320
8141
  case 16:
8321
- _context83.t0 = normalizedOrder;
8142
+ _context81.t0 = normalizedOrder;
8322
8143
  case 17:
8323
- receiptOrder = _context83.t0;
8324
- _context83.next = 20;
8144
+ receiptOrder = _context81.t0;
8145
+ _context81.next = 20;
8325
8146
  return this.enrichPaymentNamesByCode(receiptOrder);
8326
8147
  case 20:
8327
- enrichedOrder = _context83.sent;
8148
+ enrichedOrder = _context81.sent;
8328
8149
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
8329
- _context83.next = 25;
8150
+ _context81.next = 25;
8330
8151
  break;
8331
8152
  }
8332
- _context83.t1 = _options$productMap;
8333
- _context83.next = 28;
8153
+ _context81.t1 = _options$productMap;
8154
+ _context81.next = 28;
8334
8155
  break;
8335
8156
  case 25:
8336
- _context83.next = 27;
8157
+ _context81.next = 27;
8337
8158
  return this.buildSmallTicketProductMap(enrichedOrder);
8338
8159
  case 27:
8339
- _context83.t1 = _context83.sent;
8160
+ _context81.t1 = _context81.sent;
8340
8161
  case 28:
8341
- productMap = _context83.t1;
8162
+ productMap = _context81.t1;
8342
8163
  smallTicketData = buildSmallTicketData({
8343
8164
  order: enrichedOrder,
8344
8165
  shopInfo: this.getSmallTicketShopInfo(),
@@ -8347,31 +8168,31 @@ var Server = /*#__PURE__*/function () {
8347
8168
  includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
8348
8169
  templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
8349
8170
  });
8350
- return _context83.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
8171
+ return _context81.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
8351
8172
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
8352
8173
  small_ticket_data: smallTicketData
8353
8174
  })
8354
8175
  }));
8355
8176
  case 33:
8356
- _context83.prev = 33;
8357
- _context83.t2 = _context83["catch"](5);
8177
+ _context81.prev = 33;
8178
+ _context81.t2 = _context81["catch"](5);
8358
8179
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
8359
- error: _context83.t2 instanceof Error ? _context83.t2.message : String(_context83.t2)
8180
+ error: _context81.t2 instanceof Error ? _context81.t2.message : String(_context81.t2)
8360
8181
  });
8361
8182
  if (!mustApplyVisibility) {
8362
- _context83.next = 38;
8183
+ _context81.next = 38;
8363
8184
  break;
8364
8185
  }
8365
- throw _context83.t2;
8186
+ throw _context81.t2;
8366
8187
  case 38:
8367
- return _context83.abrupt("return", order);
8188
+ return _context81.abrupt("return", order);
8368
8189
  case 39:
8369
8190
  case "end":
8370
- return _context83.stop();
8191
+ return _context81.stop();
8371
8192
  }
8372
- }, _callee83, this, [[5, 33]]);
8193
+ }, _callee81, this, [[5, 33]]);
8373
8194
  }));
8374
- function withLocalSmallTicketData(_x93, _x94) {
8195
+ function withLocalSmallTicketData(_x91, _x92) {
8375
8196
  return _withLocalSmallTicketData.apply(this, arguments);
8376
8197
  }
8377
8198
  return withLocalSmallTicketData;
@@ -8386,37 +8207,37 @@ var Server = /*#__PURE__*/function () {
8386
8207
  }, {
8387
8208
  key: "fetchAndPersistSalesOrderByLookup",
8388
8209
  value: function () {
8389
- var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(lookup, data, title, paymentIdentityOrder, prepareExactOrderForPersist) {
8210
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(lookup, data, title, paymentIdentityOrder, prepareExactOrderForPersist) {
8390
8211
  var _this$order7, _this$order8, _this$app20;
8391
8212
  var backendPath, _this$order$getOrderB, _this$order9, _this$order$getLocalO, _this$order10, response, _response$code3, responseStatusCode, code, message, _fresh2, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref87, _backendError$code2, backendStatusCode, _code, _message2, _message3;
8392
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
8393
- while (1) switch (_context84.prev = _context84.next) {
8213
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8214
+ while (1) switch (_context82.prev = _context82.next) {
8394
8215
  case 0:
8395
8216
  if (!(!((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.getLocalOrderByLookup) || !((_this$order8 = this.order) !== null && _this$order8 !== void 0 && _this$order8.upsertOrdersFromRemote))) {
8396
- _context84.next = 3;
8217
+ _context82.next = 3;
8397
8218
  break;
8398
8219
  }
8399
8220
  this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
8400
- return _context84.abrupt("return", {
8221
+ return _context82.abrupt("return", {
8401
8222
  code: 500,
8402
8223
  message: 'Order 模块未注册',
8403
8224
  order: null
8404
8225
  });
8405
8226
  case 3:
8406
8227
  if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && (_this$app20 = _this$app20.request) !== null && _this$app20 !== void 0 && _this$app20.get) {
8407
- _context84.next = 6;
8228
+ _context82.next = 6;
8408
8229
  break;
8409
8230
  }
8410
8231
  this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
8411
- return _context84.abrupt("return", {
8232
+ return _context82.abrupt("return", {
8412
8233
  code: 500,
8413
8234
  message: 'app.request 不可用',
8414
8235
  order: null
8415
8236
  });
8416
8237
  case 6:
8417
8238
  backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
8418
- _context84.prev = 7;
8419
- _context84.next = 10;
8239
+ _context82.prev = 7;
8240
+ _context82.next = 10;
8420
8241
  return this.app.request.get(backendPath, {
8421
8242
  lookup_mode: 'multi'
8422
8243
  }, {
@@ -8424,9 +8245,9 @@ var Server = /*#__PURE__*/function () {
8424
8245
  customToast: function customToast() {}
8425
8246
  });
8426
8247
  case 10:
8427
- response = _context84.sent;
8248
+ response = _context82.sent;
8428
8249
  if (!this.isCheckoutResponseRejected(response)) {
8429
- _context84.next = 17;
8250
+ _context82.next = 17;
8430
8251
  break;
8431
8252
  }
8432
8253
  responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
@@ -8438,7 +8259,7 @@ var Server = /*#__PURE__*/function () {
8438
8259
  code: code,
8439
8260
  message: message
8440
8261
  });
8441
- return _context84.abrupt("return", {
8262
+ return _context82.abrupt("return", {
8442
8263
  code: code,
8443
8264
  message: message,
8444
8265
  order: null
@@ -8446,66 +8267,66 @@ var Server = /*#__PURE__*/function () {
8446
8267
  case 17:
8447
8268
  _fresh2 = this.extractOrderDataFromCheckoutResponse(response);
8448
8269
  if (!(!_fresh2 || _fresh2.order_id === undefined || _fresh2.order_id === null || String(_fresh2.order_id).trim() === '')) {
8449
- _context84.next = 21;
8270
+ _context82.next = 21;
8450
8271
  break;
8451
8272
  }
8452
8273
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
8453
8274
  lookup: lookup,
8454
8275
  backendPath: backendPath
8455
8276
  });
8456
- return _context84.abrupt("return", {
8277
+ return _context82.abrupt("return", {
8457
8278
  code: 500,
8458
8279
  message: '后端返回订单为空',
8459
8280
  order: null
8460
8281
  });
8461
8282
  case 21:
8462
8283
  if (!prepareExactOrderForPersist) {
8463
- _context84.next = 25;
8284
+ _context82.next = 25;
8464
8285
  break;
8465
8286
  }
8466
- _context84.t0 = (_this$order$getOrderB = (_this$order9 = this.order).getOrderByOrderId) === null || _this$order$getOrderB === void 0 ? void 0 : _this$order$getOrderB.call(_this$order9, lookup);
8467
- _context84.next = 36;
8287
+ _context82.t0 = (_this$order$getOrderB = (_this$order9 = this.order).getOrderByOrderId) === null || _this$order$getOrderB === void 0 ? void 0 : _this$order$getOrderB.call(_this$order9, lookup);
8288
+ _context82.next = 36;
8468
8289
  break;
8469
8290
  case 25:
8470
- _context84.t1 = (_this$order$getLocalO = (_this$order10 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order10, lookup);
8471
- if (_context84.t1) {
8472
- _context84.next = 35;
8291
+ _context82.t1 = (_this$order$getLocalO = (_this$order10 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order10, lookup);
8292
+ if (_context82.t1) {
8293
+ _context82.next = 35;
8473
8294
  break;
8474
8295
  }
8475
8296
  if (!this.shouldForceRemoteSalesDetail(data)) {
8476
- _context84.next = 33;
8297
+ _context82.next = 33;
8477
8298
  break;
8478
8299
  }
8479
- _context84.next = 30;
8300
+ _context82.next = 30;
8480
8301
  return this.order.getLocalOrderByLookup(lookup);
8481
8302
  case 30:
8482
- _context84.t2 = _context84.sent;
8483
- _context84.next = 34;
8303
+ _context82.t2 = _context82.sent;
8304
+ _context82.next = 34;
8484
8305
  break;
8485
8306
  case 33:
8486
- _context84.t2 = null;
8307
+ _context82.t2 = null;
8487
8308
  case 34:
8488
- _context84.t1 = _context84.t2;
8309
+ _context82.t1 = _context82.t2;
8489
8310
  case 35:
8490
- _context84.t0 = _context84.t1;
8311
+ _context82.t0 = _context82.t1;
8491
8312
  case 36:
8492
- localBeforeRefresh = _context84.t0;
8313
+ localBeforeRefresh = _context82.t0;
8493
8314
  orderToPersist = _fresh2;
8494
8315
  if (!paymentIdentityOrder) {
8495
- _context84.next = 49;
8316
+ _context82.next = 49;
8496
8317
  break;
8497
8318
  }
8498
8319
  if (!(String(_fresh2.order_id) !== String(paymentIdentityOrder.order_id) || _fresh2.external_sale_number && paymentIdentityOrder.external_sale_number && _fresh2.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(_fresh2.payments))) {
8499
- _context84.next = 41;
8320
+ _context82.next = 41;
8500
8321
  break;
8501
8322
  }
8502
8323
  throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
8503
8324
  case 41:
8504
8325
  if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
8505
- _context84.next = 43;
8326
+ _context82.next = 43;
8506
8327
  break;
8507
8328
  }
8508
- return _context84.abrupt("return", {
8329
+ return _context82.abrupt("return", {
8509
8330
  code: 200,
8510
8331
  message: '',
8511
8332
  order: localBeforeRefresh || paymentIdentityOrder
@@ -8527,7 +8348,7 @@ var Server = /*#__PURE__*/function () {
8527
8348
  return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
8528
8349
  });
8529
8350
  if (paymentIdsComplete) {
8530
- _context84.next = 48;
8351
+ _context82.next = 48;
8531
8352
  break;
8532
8353
  }
8533
8354
  throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
@@ -8540,61 +8361,61 @@ var Server = /*#__PURE__*/function () {
8540
8361
  case 49:
8541
8362
  if (prepareExactOrderForPersist) orderToPersist = prepareExactOrderForPersist(orderToPersist);
8542
8363
  if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
8543
- _context84.next = 57;
8364
+ _context82.next = 57;
8544
8365
  break;
8545
8366
  }
8546
8367
  if (!(String(_fresh2.order_id) !== String(localBeforeRefresh.order_id))) {
8547
- _context84.next = 53;
8368
+ _context82.next = 53;
8548
8369
  break;
8549
8370
  }
8550
8371
  throw new Error('远端订单身份不匹配,请重新刷新');
8551
8372
  case 53:
8552
- _context84.next = 55;
8373
+ _context82.next = 55;
8553
8374
  return this.order.completeLocalPaymentRefresh(orderToPersist);
8554
8375
  case 55:
8555
- _context84.next = 59;
8376
+ _context82.next = 59;
8556
8377
  break;
8557
8378
  case 57:
8558
- _context84.next = 59;
8379
+ _context82.next = 59;
8559
8380
  return this.order.upsertOrdersFromRemote([orderToPersist]);
8560
8381
  case 59:
8561
8382
  if (!prepareExactOrderForPersist) {
8562
- _context84.next = 65;
8383
+ _context82.next = 65;
8563
8384
  break;
8564
8385
  }
8565
- _context84.next = 62;
8386
+ _context82.next = 62;
8566
8387
  return this.order.getLocalOrderByLookup(lookup, {
8567
8388
  exactOrderId: true
8568
8389
  });
8569
8390
  case 62:
8570
- _context84.t3 = _context84.sent;
8571
- _context84.next = 68;
8391
+ _context82.t3 = _context82.sent;
8392
+ _context82.next = 68;
8572
8393
  break;
8573
8394
  case 65:
8574
- _context84.next = 67;
8395
+ _context82.next = 67;
8575
8396
  return this.order.getLocalOrderByLookup(lookup);
8576
8397
  case 67:
8577
- _context84.t3 = _context84.sent;
8398
+ _context82.t3 = _context82.sent;
8578
8399
  case 68:
8579
- savedOrder = _context84.t3;
8400
+ savedOrder = _context82.t3;
8580
8401
  if (!(!savedOrder && _fresh2.order_id !== undefined && _fresh2.order_id !== null && String(_fresh2.order_id) !== String(lookup))) {
8581
- _context84.next = 73;
8402
+ _context82.next = 73;
8582
8403
  break;
8583
8404
  }
8584
- _context84.next = 72;
8405
+ _context82.next = 72;
8585
8406
  return this.order.getLocalOrderByLookup(_fresh2.order_id);
8586
8407
  case 72:
8587
- savedOrder = _context84.sent;
8408
+ savedOrder = _context82.sent;
8588
8409
  case 73:
8589
8410
  if (savedOrder) {
8590
- _context84.next = 76;
8411
+ _context82.next = 76;
8591
8412
  break;
8592
8413
  }
8593
8414
  this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
8594
8415
  lookup: lookup,
8595
8416
  remote_order_id: _fresh2.order_id
8596
8417
  });
8597
- return _context84.abrupt("return", {
8418
+ return _context82.abrupt("return", {
8598
8419
  code: 500,
8599
8420
  message: '订单写入后回读失败',
8600
8421
  order: null
@@ -8604,54 +8425,54 @@ var Server = /*#__PURE__*/function () {
8604
8425
  lookup: lookup,
8605
8426
  remote_order_id: _fresh2.order_id
8606
8427
  });
8607
- return _context84.abrupt("return", {
8428
+ return _context82.abrupt("return", {
8608
8429
  code: 200,
8609
8430
  message: '',
8610
8431
  order: savedOrder
8611
8432
  });
8612
8433
  case 80:
8613
- _context84.prev = 80;
8614
- _context84.t4 = _context84["catch"](7);
8615
- backendError = this.extractBackendErrorResponse(_context84.t4);
8616
- errorRecord = _context84.t4;
8434
+ _context82.prev = 80;
8435
+ _context82.t4 = _context82["catch"](7);
8436
+ backendError = this.extractBackendErrorResponse(_context82.t4);
8437
+ errorRecord = _context82.t4;
8617
8438
  _responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
8618
8439
  if (!(backendError || _responseStatusCode !== undefined)) {
8619
- _context84.next = 91;
8440
+ _context82.next = 91;
8620
8441
  break;
8621
8442
  }
8622
8443
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
8623
8444
  _code = this.normalizeRemoteSalesOrderErrorCode((_ref87 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref87 !== void 0 ? _ref87 : _responseStatusCode);
8624
- _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context84.t4);
8445
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context82.t4);
8625
8446
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
8626
8447
  lookup: lookup,
8627
8448
  backendPath: backendPath,
8628
8449
  code: _code,
8629
8450
  message: _message2
8630
8451
  });
8631
- return _context84.abrupt("return", {
8452
+ return _context82.abrupt("return", {
8632
8453
  code: _code,
8633
8454
  message: _message2,
8634
8455
  order: null
8635
8456
  });
8636
8457
  case 91:
8637
- _message3 = this.getUnknownErrorMessage(_context84.t4);
8458
+ _message3 = this.getUnknownErrorMessage(_context82.t4);
8638
8459
  this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
8639
8460
  lookup: lookup,
8640
8461
  backendPath: backendPath,
8641
8462
  error: _message3
8642
8463
  });
8643
- return _context84.abrupt("return", {
8464
+ return _context82.abrupt("return", {
8644
8465
  code: 500,
8645
8466
  message: _message3,
8646
8467
  order: null
8647
8468
  });
8648
8469
  case 94:
8649
8470
  case "end":
8650
- return _context84.stop();
8471
+ return _context82.stop();
8651
8472
  }
8652
- }, _callee84, this, [[7, 80]]);
8473
+ }, _callee82, this, [[7, 80]]);
8653
8474
  }));
8654
- function fetchAndPersistSalesOrderByLookup(_x95, _x96, _x97, _x98, _x99) {
8475
+ function fetchAndPersistSalesOrderByLookup(_x93, _x94, _x95, _x96, _x97) {
8655
8476
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
8656
8477
  }
8657
8478
  return fetchAndPersistSalesOrderByLookup;
@@ -8713,22 +8534,22 @@ var Server = /*#__PURE__*/function () {
8713
8534
  }, {
8714
8535
  key: "handleUpdateLocalOrdersBatch",
8715
8536
  value: (function () {
8716
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(orderIds) {
8537
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(orderIds) {
8717
8538
  var _this$app21;
8718
8539
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, _fresh3, _message4, overwritten, inserted;
8719
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
8720
- while (1) switch (_context85.prev = _context85.next) {
8540
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8541
+ while (1) switch (_context83.prev = _context83.next) {
8721
8542
  case 0:
8722
8543
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
8723
8544
  count: orderIds.length,
8724
8545
  orderIds: orderIds
8725
8546
  });
8726
8547
  if (this.order) {
8727
- _context85.next = 4;
8548
+ _context83.next = 4;
8728
8549
  break;
8729
8550
  }
8730
8551
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
8731
- return _context85.abrupt("return", {
8552
+ return _context83.abrupt("return", {
8732
8553
  code: 500,
8733
8554
  status: false,
8734
8555
  message: 'Order 模块未注册',
@@ -8736,11 +8557,11 @@ var Server = /*#__PURE__*/function () {
8736
8557
  });
8737
8558
  case 4:
8738
8559
  if ((_this$app21 = this.app) !== null && _this$app21 !== void 0 && _this$app21.request) {
8739
- _context85.next = 7;
8560
+ _context83.next = 7;
8740
8561
  break;
8741
8562
  }
8742
8563
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
8743
- return _context85.abrupt("return", {
8564
+ return _context83.abrupt("return", {
8744
8565
  code: 500,
8745
8566
  status: false,
8746
8567
  message: 'app.request 不可用',
@@ -8763,21 +8584,21 @@ var Server = /*#__PURE__*/function () {
8763
8584
  _iterator13.f();
8764
8585
  }
8765
8586
  fetched = [];
8766
- _context85.prev = 11;
8767
- _context85.next = 14;
8587
+ _context83.prev = 11;
8588
+ _context83.next = 14;
8768
8589
  return this.order.fetchOrdersByHttp(orderIds);
8769
8590
  case 14:
8770
- fetched = _context85.sent;
8771
- _context85.next = 22;
8591
+ fetched = _context83.sent;
8592
+ _context83.next = 22;
8772
8593
  break;
8773
8594
  case 17:
8774
- _context85.prev = 17;
8775
- _context85.t0 = _context85["catch"](11);
8776
- message = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
8595
+ _context83.prev = 17;
8596
+ _context83.t0 = _context83["catch"](11);
8597
+ message = _context83.t0 instanceof Error ? _context83.t0.message : String(_context83.t0);
8777
8598
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
8778
8599
  message: message
8779
8600
  });
8780
- return _context85.abrupt("return", {
8601
+ return _context83.abrupt("return", {
8781
8602
  code: 500,
8782
8603
  status: false,
8783
8604
  message: message,
@@ -8787,36 +8608,36 @@ var Server = /*#__PURE__*/function () {
8787
8608
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
8788
8609
  fetchedMap = new Map();
8789
8610
  _iterator14 = _createForOfIteratorHelper(fetched);
8790
- _context85.prev = 24;
8611
+ _context83.prev = 24;
8791
8612
  _iterator14.s();
8792
8613
  case 26:
8793
8614
  if ((_step14 = _iterator14.n()).done) {
8794
- _context85.next = 34;
8615
+ _context83.next = 34;
8795
8616
  break;
8796
8617
  }
8797
8618
  order = _step14.value;
8798
8619
  oid = order === null || order === void 0 ? void 0 : order.order_id;
8799
8620
  if (!(oid === undefined || oid === null)) {
8800
- _context85.next = 31;
8621
+ _context83.next = 31;
8801
8622
  break;
8802
8623
  }
8803
- return _context85.abrupt("continue", 32);
8624
+ return _context83.abrupt("continue", 32);
8804
8625
  case 31:
8805
8626
  fetchedMap.set(String(oid), order);
8806
8627
  case 32:
8807
- _context85.next = 26;
8628
+ _context83.next = 26;
8808
8629
  break;
8809
8630
  case 34:
8810
- _context85.next = 39;
8631
+ _context83.next = 39;
8811
8632
  break;
8812
8633
  case 36:
8813
- _context85.prev = 36;
8814
- _context85.t1 = _context85["catch"](24);
8815
- _iterator14.e(_context85.t1);
8634
+ _context83.prev = 36;
8635
+ _context83.t1 = _context83["catch"](24);
8636
+ _iterator14.e(_context83.t1);
8816
8637
  case 39:
8817
- _context85.prev = 39;
8638
+ _context83.prev = 39;
8818
8639
  _iterator14.f();
8819
- return _context85.finish(39);
8640
+ return _context83.finish(39);
8820
8641
  case 42:
8821
8642
  freshOrders = [];
8822
8643
  succeedIds = [];
@@ -8842,23 +8663,23 @@ var Server = /*#__PURE__*/function () {
8842
8663
  _iterator15.f();
8843
8664
  }
8844
8665
  if (!(freshOrders.length > 0)) {
8845
- _context85.next = 58;
8666
+ _context83.next = 58;
8846
8667
  break;
8847
8668
  }
8848
- _context85.prev = 48;
8849
- _context85.next = 51;
8669
+ _context83.prev = 48;
8670
+ _context83.next = 51;
8850
8671
  return this.order.upsertOrdersFromRemote(freshOrders);
8851
8672
  case 51:
8852
- _context85.next = 58;
8673
+ _context83.next = 58;
8853
8674
  break;
8854
8675
  case 53:
8855
- _context85.prev = 53;
8856
- _context85.t2 = _context85["catch"](48);
8857
- _message4 = _context85.t2 instanceof Error ? _context85.t2.message : String(_context85.t2);
8676
+ _context83.prev = 53;
8677
+ _context83.t2 = _context83["catch"](48);
8678
+ _message4 = _context83.t2 instanceof Error ? _context83.t2.message : String(_context83.t2);
8858
8679
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
8859
8680
  message: _message4
8860
8681
  });
8861
- return _context85.abrupt("return", {
8682
+ return _context83.abrupt("return", {
8862
8683
  code: 500,
8863
8684
  status: false,
8864
8685
  message: _message4,
@@ -8877,7 +8698,7 @@ var Server = /*#__PURE__*/function () {
8877
8698
  insertedCount: inserted.length,
8878
8699
  failedCount: failed.length
8879
8700
  });
8880
- return _context85.abrupt("return", {
8701
+ return _context83.abrupt("return", {
8881
8702
  code: 200,
8882
8703
  status: true,
8883
8704
  message: '',
@@ -8889,11 +8710,11 @@ var Server = /*#__PURE__*/function () {
8889
8710
  });
8890
8711
  case 62:
8891
8712
  case "end":
8892
- return _context85.stop();
8713
+ return _context83.stop();
8893
8714
  }
8894
- }, _callee85, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8715
+ }, _callee83, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8895
8716
  }));
8896
- function handleUpdateLocalOrdersBatch(_x100) {
8717
+ function handleUpdateLocalOrdersBatch(_x98) {
8897
8718
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
8898
8719
  }
8899
8720
  return handleUpdateLocalOrdersBatch;
@@ -9262,16 +9083,16 @@ var Server = /*#__PURE__*/function () {
9262
9083
  }, {
9263
9084
  key: "recomputeAndNotifyFloorPlanQuery",
9264
9085
  value: (function () {
9265
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
9086
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
9266
9087
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
9267
- return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9268
- while (1) switch (_context86.prev = _context86.next) {
9088
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9089
+ while (1) switch (_context84.prev = _context84.next) {
9269
9090
  case 0:
9270
9091
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
9271
- _context86.next = 2;
9092
+ _context84.next = 2;
9272
9093
  break;
9273
9094
  }
9274
- return _context86.abrupt("return");
9095
+ return _context84.abrupt("return");
9275
9096
  case 2:
9276
9097
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
9277
9098
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -9301,9 +9122,9 @@ var Server = /*#__PURE__*/function () {
9301
9122
  }
9302
9123
  case 5:
9303
9124
  case "end":
9304
- return _context86.stop();
9125
+ return _context84.stop();
9305
9126
  }
9306
- }, _callee86, this);
9127
+ }, _callee84, this);
9307
9128
  }));
9308
9129
  function recomputeAndNotifyFloorPlanQuery() {
9309
9130
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -9333,20 +9154,20 @@ var Server = /*#__PURE__*/function () {
9333
9154
  * filter 逻辑暂为 mock,仅记录参数
9334
9155
  */
9335
9156
  function () {
9336
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(data) {
9157
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(data) {
9337
9158
  var rawList, result;
9338
- return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9339
- while (1) switch (_context87.prev = _context87.next) {
9159
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9160
+ while (1) switch (_context85.prev = _context85.next) {
9340
9161
  case 0:
9341
9162
  this.logInfo('computeOrderQueryResult: 开始过滤', {
9342
9163
  data: data
9343
9164
  });
9344
9165
  if (this.order) {
9345
- _context87.next = 4;
9166
+ _context85.next = 4;
9346
9167
  break;
9347
9168
  }
9348
9169
  this.logError('computeOrderQueryResult: Order 模块未注册');
9349
- return _context87.abrupt("return", {
9170
+ return _context85.abrupt("return", {
9350
9171
  code: 500,
9351
9172
  message: 'Order 模块未注册',
9352
9173
  data: {
@@ -9378,7 +9199,7 @@ var Server = /*#__PURE__*/function () {
9378
9199
  skip: result.skip,
9379
9200
  rejected: result.rejected
9380
9201
  });
9381
- return _context87.abrupt("return", {
9202
+ return _context85.abrupt("return", {
9382
9203
  code: 200,
9383
9204
  data: result,
9384
9205
  message: '',
@@ -9386,11 +9207,11 @@ var Server = /*#__PURE__*/function () {
9386
9207
  });
9387
9208
  case 10:
9388
9209
  case "end":
9389
- return _context87.stop();
9210
+ return _context85.stop();
9390
9211
  }
9391
- }, _callee87, this);
9212
+ }, _callee85, this);
9392
9213
  }));
9393
- function computeOrderQueryResult(_x101) {
9214
+ function computeOrderQueryResult(_x99) {
9394
9215
  return _computeOrderQueryResult.apply(this, arguments);
9395
9216
  }
9396
9217
  return computeOrderQueryResult;
@@ -9403,17 +9224,17 @@ var Server = /*#__PURE__*/function () {
9403
9224
  }, {
9404
9225
  key: "computeBookingQueryResult",
9405
9226
  value: (function () {
9406
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(data) {
9227
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(data) {
9407
9228
  var rawOrders, result;
9408
- return _regeneratorRuntime().wrap(function _callee88$(_context88) {
9409
- while (1) switch (_context88.prev = _context88.next) {
9229
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9230
+ while (1) switch (_context86.prev = _context86.next) {
9410
9231
  case 0:
9411
9232
  if (this.order) {
9412
- _context88.next = 3;
9233
+ _context86.next = 3;
9413
9234
  break;
9414
9235
  }
9415
9236
  this.logError('computeBookingQueryResult: Order 模块未注册');
9416
- return _context88.abrupt("return", {
9237
+ return _context86.abrupt("return", {
9417
9238
  code: 500,
9418
9239
  message: 'Order 模块未注册',
9419
9240
  data: {
@@ -9432,7 +9253,7 @@ var Server = /*#__PURE__*/function () {
9432
9253
  size: result.size,
9433
9254
  skip: result.skip
9434
9255
  });
9435
- return _context88.abrupt("return", {
9256
+ return _context86.abrupt("return", {
9436
9257
  code: 200,
9437
9258
  data: result,
9438
9259
  message: '',
@@ -9440,11 +9261,11 @@ var Server = /*#__PURE__*/function () {
9440
9261
  });
9441
9262
  case 8:
9442
9263
  case "end":
9443
- return _context88.stop();
9264
+ return _context86.stop();
9444
9265
  }
9445
- }, _callee88, this);
9266
+ }, _callee86, this);
9446
9267
  }));
9447
- function computeBookingQueryResult(_x102) {
9268
+ function computeBookingQueryResult(_x100) {
9448
9269
  return _computeBookingQueryResult.apply(this, arguments);
9449
9270
  }
9450
9271
  return computeBookingQueryResult;
@@ -9503,12 +9324,12 @@ var Server = /*#__PURE__*/function () {
9503
9324
  }, {
9504
9325
  key: "computeProductQueryResult",
9505
9326
  value: (function () {
9506
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89(context, options) {
9327
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(context, options) {
9507
9328
  var _menu_list_ids$length3,
9508
9329
  _this29 = this;
9509
9330
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, application_code, strategy_context, isVisibleProduct, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
9510
- return _regeneratorRuntime().wrap(function _callee89$(_context89) {
9511
- while (1) switch (_context89.prev = _context89.next) {
9331
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9332
+ while (1) switch (_context87.prev = _context87.next) {
9512
9333
  case 0:
9513
9334
  tTotal = performance.now();
9514
9335
  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, application_code = context.application_code, strategy_context = context.strategy_context; // 仅 Kiosk 查询额外按商品销售渠道过滤。
@@ -9537,10 +9358,10 @@ var Server = /*#__PURE__*/function () {
9537
9358
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
9538
9359
  startupPreloadTask = this.startupModulePreloadInFlight;
9539
9360
  if (!startupPreloadTask) {
9540
- _context89.next = 9;
9361
+ _context87.next = 9;
9541
9362
  break;
9542
9363
  }
9543
- _context89.next = 9;
9364
+ _context87.next = 9;
9544
9365
  return startupPreloadTask;
9545
9366
  case 9:
9546
9367
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -9552,28 +9373,28 @@ var Server = /*#__PURE__*/function () {
9552
9373
  strategy_context: strategy_context
9553
9374
  });
9554
9375
  if (this.products) {
9555
- _context89.next = 13;
9376
+ _context87.next = 13;
9556
9377
  break;
9557
9378
  }
9558
9379
  this.logError('computeProductQueryResult: Products 模块未注册');
9559
- return _context89.abrupt("return", {
9380
+ return _context87.abrupt("return", {
9560
9381
  message: 'Products 模块未注册',
9561
9382
  data: this.buildProductQueryResultPayload([], 0)
9562
9383
  });
9563
9384
  case 13:
9564
9385
  if (!(queryIds.length > 0)) {
9565
- _context89.next = 25;
9386
+ _context87.next = 25;
9566
9387
  break;
9567
9388
  }
9568
9389
  uniqueIds = Array.from(new Set(queryIds));
9569
9390
  _tPrice = performance.now();
9570
- _context89.next = 18;
9391
+ _context87.next = 18;
9571
9392
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9572
9393
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9573
9394
  productIds: uniqueIds
9574
9395
  });
9575
9396
  case 18:
9576
- productsWithPrice = _context89.sent;
9397
+ productsWithPrice = _context87.sent;
9577
9398
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
9578
9399
  count: productsWithPrice.length,
9579
9400
  ids: uniqueIds
@@ -9591,7 +9412,7 @@ var Server = /*#__PURE__*/function () {
9591
9412
  ids: uniqueIds,
9592
9413
  count: extensionFilteredProducts.length
9593
9414
  });
9594
- return _context89.abrupt("return", {
9415
+ return _context87.abrupt("return", {
9595
9416
  code: 200,
9596
9417
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
9597
9418
  message: '',
@@ -9599,17 +9420,17 @@ var Server = /*#__PURE__*/function () {
9599
9420
  });
9600
9421
  case 25:
9601
9422
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
9602
- _context89.next = 37;
9423
+ _context87.next = 37;
9603
9424
  break;
9604
9425
  }
9605
9426
  pid = Number(product_id);
9606
9427
  _tPrice2 = performance.now();
9607
- _context89.next = 30;
9428
+ _context87.next = 30;
9608
9429
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9609
9430
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9610
9431
  });
9611
9432
  case 30:
9612
- allProductsWithPrice = _context89.sent;
9433
+ allProductsWithPrice = _context87.sent;
9613
9434
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
9614
9435
  count: allProductsWithPrice.length,
9615
9436
  productId: pid
@@ -9627,7 +9448,7 @@ var Server = /*#__PURE__*/function () {
9627
9448
  productId: pid,
9628
9449
  found: !!item
9629
9450
  });
9630
- return _context89.abrupt("return", {
9451
+ return _context87.abrupt("return", {
9631
9452
  code: 200,
9632
9453
  data: item,
9633
9454
  message: item ? '' : '商品不存在或未发布',
@@ -9635,16 +9456,16 @@ var Server = /*#__PURE__*/function () {
9635
9456
  });
9636
9457
  case 37:
9637
9458
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
9638
- _context89.next = 57;
9459
+ _context87.next = 57;
9639
9460
  break;
9640
9461
  }
9641
9462
  _tPrice3 = performance.now();
9642
- _context89.next = 41;
9463
+ _context87.next = 41;
9643
9464
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9644
9465
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9645
9466
  });
9646
9467
  case 41:
9647
- _filteredProducts2 = _context89.sent;
9468
+ _filteredProducts2 = _context87.sent;
9648
9469
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
9649
9470
  count: _filteredProducts2.length,
9650
9471
  extension_type: extension_type
@@ -9681,7 +9502,7 @@ var Server = /*#__PURE__*/function () {
9681
9502
  filteredCount: _filteredProducts2.length,
9682
9503
  extension_type: extension_type
9683
9504
  });
9684
- return _context89.abrupt("return", {
9505
+ return _context87.abrupt("return", {
9685
9506
  code: 200,
9686
9507
  data: this.buildProductQueryResultPayload(_filteredProducts2),
9687
9508
  message: '',
@@ -9689,28 +9510,28 @@ var Server = /*#__PURE__*/function () {
9689
9510
  });
9690
9511
  case 57:
9691
9512
  if (this.menu) {
9692
- _context89.next = 60;
9513
+ _context87.next = 60;
9693
9514
  break;
9694
9515
  }
9695
9516
  this.logError('computeProductQueryResult: Menu 模块未注册');
9696
- return _context89.abrupt("return", {
9517
+ return _context87.abrupt("return", {
9697
9518
  message: 'Menu 模块未注册',
9698
9519
  data: this.buildProductQueryResultPayload([], 0)
9699
9520
  });
9700
9521
  case 60:
9701
9522
  if (this.schedule) {
9702
- _context89.next = 63;
9523
+ _context87.next = 63;
9703
9524
  break;
9704
9525
  }
9705
9526
  this.logError('computeProductQueryResult: Schedule 模块未注册');
9706
- return _context89.abrupt("return", {
9527
+ return _context87.abrupt("return", {
9707
9528
  message: 'Schedule 模块未注册',
9708
9529
  data: this.buildProductQueryResultPayload([], 0)
9709
9530
  });
9710
9531
  case 63:
9711
9532
  activeMenuList = [];
9712
9533
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
9713
- _context89.next = 76;
9534
+ _context87.next = 76;
9714
9535
  break;
9715
9536
  }
9716
9537
  tMenu = performance.now();
@@ -9721,18 +9542,18 @@ var Server = /*#__PURE__*/function () {
9721
9542
  });
9722
9543
  };
9723
9544
  activeMenuList = getActiveMenus();
9724
- _context89.t0 = !activeMenuList.length;
9725
- if (!_context89.t0) {
9726
- _context89.next = 73;
9545
+ _context87.t0 = !activeMenuList.length;
9546
+ if (!_context87.t0) {
9547
+ _context87.next = 73;
9727
9548
  break;
9728
9549
  }
9729
- _context89.next = 72;
9550
+ _context87.next = 72;
9730
9551
  return this.refreshMenuScheduleCacheAfterEmptyResult();
9731
9552
  case 72:
9732
- _context89.t0 = _context89.sent;
9553
+ _context87.t0 = _context87.sent;
9733
9554
  case 73:
9734
- if (!_context89.t0) {
9735
- _context89.next = 75;
9555
+ if (!_context87.t0) {
9556
+ _context87.next = 75;
9736
9557
  break;
9737
9558
  }
9738
9559
  activeMenuList = getActiveMenus();
@@ -9752,22 +9573,22 @@ var Server = /*#__PURE__*/function () {
9752
9573
  });
9753
9574
  tPrice = performance.now();
9754
9575
  if (!(scopedProductIds.length > 0)) {
9755
- _context89.next = 87;
9576
+ _context87.next = 87;
9756
9577
  break;
9757
9578
  }
9758
- _context89.next = 84;
9579
+ _context87.next = 84;
9759
9580
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9760
9581
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9761
9582
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
9762
9583
  });
9763
9584
  case 84:
9764
- _context89.t1 = _context89.sent;
9765
- _context89.next = 88;
9585
+ _context87.t1 = _context87.sent;
9586
+ _context87.next = 88;
9766
9587
  break;
9767
9588
  case 87:
9768
- _context89.t1 = [];
9589
+ _context87.t1 = [];
9769
9590
  case 88:
9770
- filteredProducts = _context89.t1;
9591
+ filteredProducts = _context87.t1;
9771
9592
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
9772
9593
  count: filteredProducts.length,
9773
9594
  scopedProductCount: scopedProductIds.length
@@ -9806,7 +9627,7 @@ var Server = /*#__PURE__*/function () {
9806
9627
  filteredCount: filteredProducts.length,
9807
9628
  activeMenuCount: activeMenuList.length
9808
9629
  });
9809
- return _context89.abrupt("return", {
9630
+ return _context87.abrupt("return", {
9810
9631
  code: 200,
9811
9632
  data: this.buildProductQueryResultPayload(filteredProducts),
9812
9633
  message: '',
@@ -9814,11 +9635,11 @@ var Server = /*#__PURE__*/function () {
9814
9635
  });
9815
9636
  case 104:
9816
9637
  case "end":
9817
- return _context89.stop();
9638
+ return _context87.stop();
9818
9639
  }
9819
- }, _callee89, this);
9640
+ }, _callee87, this);
9820
9641
  }));
9821
- function computeProductQueryResult(_x103, _x104) {
9642
+ function computeProductQueryResult(_x101, _x102) {
9822
9643
  return _computeProductQueryResult.apply(this, arguments);
9823
9644
  }
9824
9645
  return computeProductQueryResult;
@@ -9856,74 +9677,74 @@ var Server = /*#__PURE__*/function () {
9856
9677
  }, {
9857
9678
  key: "recomputeAndNotifyProductQuery",
9858
9679
  value: (function () {
9859
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee90(options) {
9680
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(options) {
9860
9681
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
9861
- return _regeneratorRuntime().wrap(function _callee90$(_context90) {
9862
- while (1) switch (_context90.prev = _context90.next) {
9682
+ return _regeneratorRuntime().wrap(function _callee88$(_context88) {
9683
+ while (1) switch (_context88.prev = _context88.next) {
9863
9684
  case 0:
9864
9685
  if (!(this.productQuerySubscribers.size === 0)) {
9865
- _context90.next = 2;
9686
+ _context88.next = 2;
9866
9687
  break;
9867
9688
  }
9868
- return _context90.abrupt("return");
9689
+ return _context88.abrupt("return");
9869
9690
  case 2:
9870
9691
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
9871
9692
  subscriberCount: this.productQuerySubscribers.size,
9872
9693
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9873
9694
  });
9874
9695
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
9875
- _context90.prev = 4;
9696
+ _context88.prev = 4;
9876
9697
  _iterator18.s();
9877
9698
  case 6:
9878
9699
  if ((_step18 = _iterator18.n()).done) {
9879
- _context90.next = 23;
9700
+ _context88.next = 23;
9880
9701
  break;
9881
9702
  }
9882
9703
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
9883
- _context90.prev = 8;
9884
- _context90.next = 11;
9704
+ _context88.prev = 8;
9705
+ _context88.next = 11;
9885
9706
  return this.computeProductQueryResult(subscriber.context, {
9886
9707
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9887
9708
  });
9888
9709
  case 11:
9889
- result = _context90.sent;
9890
- _context90.next = 14;
9710
+ result = _context88.sent;
9711
+ _context88.next = 14;
9891
9712
  return subscriber.callback(result);
9892
9713
  case 14:
9893
9714
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
9894
9715
  subscriberId: subscriberId
9895
9716
  });
9896
- _context90.next = 21;
9717
+ _context88.next = 21;
9897
9718
  break;
9898
9719
  case 17:
9899
- _context90.prev = 17;
9900
- _context90.t0 = _context90["catch"](8);
9901
- errorMessage = _context90.t0 instanceof Error ? _context90.t0.message : String(_context90.t0);
9720
+ _context88.prev = 17;
9721
+ _context88.t0 = _context88["catch"](8);
9722
+ errorMessage = _context88.t0 instanceof Error ? _context88.t0.message : String(_context88.t0);
9902
9723
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
9903
9724
  subscriberId: subscriberId,
9904
9725
  error: errorMessage
9905
9726
  });
9906
9727
  case 21:
9907
- _context90.next = 6;
9728
+ _context88.next = 6;
9908
9729
  break;
9909
9730
  case 23:
9910
- _context90.next = 28;
9731
+ _context88.next = 28;
9911
9732
  break;
9912
9733
  case 25:
9913
- _context90.prev = 25;
9914
- _context90.t1 = _context90["catch"](4);
9915
- _iterator18.e(_context90.t1);
9734
+ _context88.prev = 25;
9735
+ _context88.t1 = _context88["catch"](4);
9736
+ _iterator18.e(_context88.t1);
9916
9737
  case 28:
9917
- _context90.prev = 28;
9738
+ _context88.prev = 28;
9918
9739
  _iterator18.f();
9919
- return _context90.finish(28);
9740
+ return _context88.finish(28);
9920
9741
  case 31:
9921
9742
  case "end":
9922
- return _context90.stop();
9743
+ return _context88.stop();
9923
9744
  }
9924
- }, _callee90, this, [[4, 25, 28, 31], [8, 17]]);
9745
+ }, _callee88, this, [[4, 25, 28, 31], [8, 17]]);
9925
9746
  }));
9926
- function recomputeAndNotifyProductQuery(_x105) {
9747
+ function recomputeAndNotifyProductQuery(_x103) {
9927
9748
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
9928
9749
  }
9929
9750
  return recomputeAndNotifyProductQuery;
@@ -9935,16 +9756,16 @@ var Server = /*#__PURE__*/function () {
9935
9756
  }, {
9936
9757
  key: "recomputeAndNotifyOrderQuery",
9937
9758
  value: (function () {
9938
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee91() {
9759
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89() {
9939
9760
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
9940
- return _regeneratorRuntime().wrap(function _callee91$(_context91) {
9941
- while (1) switch (_context91.prev = _context91.next) {
9761
+ return _regeneratorRuntime().wrap(function _callee89$(_context89) {
9762
+ while (1) switch (_context89.prev = _context89.next) {
9942
9763
  case 0:
9943
9764
  if (!(this.orderQuerySubscribers.size === 0)) {
9944
- _context91.next = 2;
9765
+ _context89.next = 2;
9945
9766
  break;
9946
9767
  }
9947
- return _context91.abrupt("return");
9768
+ return _context89.abrupt("return");
9948
9769
  case 2:
9949
9770
  notifyStartAt = Date.now();
9950
9771
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -9952,20 +9773,20 @@ var Server = /*#__PURE__*/function () {
9952
9773
  notifyStartAt: new Date(notifyStartAt).toISOString()
9953
9774
  });
9954
9775
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
9955
- _context91.prev = 5;
9776
+ _context89.prev = 5;
9956
9777
  _iterator19.s();
9957
9778
  case 7:
9958
9779
  if ((_step19 = _iterator19.n()).done) {
9959
- _context91.next = 27;
9780
+ _context89.next = 27;
9960
9781
  break;
9961
9782
  }
9962
9783
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
9963
- _context91.prev = 9;
9784
+ _context89.prev = 9;
9964
9785
  computeStartAt = Date.now();
9965
- _context91.next = 13;
9786
+ _context89.next = 13;
9966
9787
  return this.computeOrderQueryResult(subscriber.context);
9967
9788
  case 13:
9968
- result = _context91.sent;
9789
+ result = _context89.sent;
9969
9790
  computeEndAt = Date.now();
9970
9791
  callbackStartAt = Date.now();
9971
9792
  subscriber.callback(result);
@@ -9976,30 +9797,30 @@ var Server = /*#__PURE__*/function () {
9976
9797
  callbackDurationMs: callbackEndAt - callbackStartAt,
9977
9798
  totalDurationMs: callbackEndAt - computeStartAt
9978
9799
  });
9979
- _context91.next = 25;
9800
+ _context89.next = 25;
9980
9801
  break;
9981
9802
  case 21:
9982
- _context91.prev = 21;
9983
- _context91.t0 = _context91["catch"](9);
9984
- errorMessage = _context91.t0 instanceof Error ? _context91.t0.message : String(_context91.t0);
9803
+ _context89.prev = 21;
9804
+ _context89.t0 = _context89["catch"](9);
9805
+ errorMessage = _context89.t0 instanceof Error ? _context89.t0.message : String(_context89.t0);
9985
9806
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
9986
9807
  subscriberId: subscriberId,
9987
9808
  error: errorMessage
9988
9809
  });
9989
9810
  case 25:
9990
- _context91.next = 7;
9811
+ _context89.next = 7;
9991
9812
  break;
9992
9813
  case 27:
9993
- _context91.next = 32;
9814
+ _context89.next = 32;
9994
9815
  break;
9995
9816
  case 29:
9996
- _context91.prev = 29;
9997
- _context91.t1 = _context91["catch"](5);
9998
- _iterator19.e(_context91.t1);
9817
+ _context89.prev = 29;
9818
+ _context89.t1 = _context89["catch"](5);
9819
+ _iterator19.e(_context89.t1);
9999
9820
  case 32:
10000
- _context91.prev = 32;
9821
+ _context89.prev = 32;
10001
9822
  _iterator19.f();
10002
- return _context91.finish(32);
9823
+ return _context89.finish(32);
10003
9824
  case 35:
10004
9825
  notifyEndAt = Date.now();
10005
9826
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -10008,9 +9829,9 @@ var Server = /*#__PURE__*/function () {
10008
9829
  });
10009
9830
  case 37:
10010
9831
  case "end":
10011
- return _context91.stop();
9832
+ return _context89.stop();
10012
9833
  }
10013
- }, _callee91, this, [[5, 29, 32, 35], [9, 21]]);
9834
+ }, _callee89, this, [[5, 29, 32, 35], [9, 21]]);
10014
9835
  }));
10015
9836
  function recomputeAndNotifyOrderQuery() {
10016
9837
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -10151,67 +9972,67 @@ var Server = /*#__PURE__*/function () {
10151
9972
  }, {
10152
9973
  key: "recomputeAndNotifyBookingQuery",
10153
9974
  value: (function () {
10154
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee92() {
9975
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee90() {
10155
9976
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
10156
- return _regeneratorRuntime().wrap(function _callee92$(_context92) {
10157
- while (1) switch (_context92.prev = _context92.next) {
9977
+ return _regeneratorRuntime().wrap(function _callee90$(_context90) {
9978
+ while (1) switch (_context90.prev = _context90.next) {
10158
9979
  case 0:
10159
9980
  if (!(this.bookingQuerySubscribers.size === 0)) {
10160
- _context92.next = 2;
9981
+ _context90.next = 2;
10161
9982
  break;
10162
9983
  }
10163
- return _context92.abrupt("return");
9984
+ return _context90.abrupt("return");
10164
9985
  case 2:
10165
9986
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
10166
9987
  subscriberCount: this.bookingQuerySubscribers.size
10167
9988
  });
10168
9989
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
10169
- _context92.prev = 4;
9990
+ _context90.prev = 4;
10170
9991
  _iterator21.s();
10171
9992
  case 6:
10172
9993
  if ((_step21 = _iterator21.n()).done) {
10173
- _context92.next = 22;
9994
+ _context90.next = 22;
10174
9995
  break;
10175
9996
  }
10176
9997
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
10177
- _context92.prev = 8;
10178
- _context92.next = 11;
9998
+ _context90.prev = 8;
9999
+ _context90.next = 11;
10179
10000
  return this.computeBookingQueryResult(subscriber.context);
10180
10001
  case 11:
10181
- result = _context92.sent;
10002
+ result = _context90.sent;
10182
10003
  subscriber.callback(result);
10183
10004
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
10184
10005
  subscriberId: subscriberId
10185
10006
  });
10186
- _context92.next = 20;
10007
+ _context90.next = 20;
10187
10008
  break;
10188
10009
  case 16:
10189
- _context92.prev = 16;
10190
- _context92.t0 = _context92["catch"](8);
10191
- errorMessage = _context92.t0 instanceof Error ? _context92.t0.message : String(_context92.t0);
10010
+ _context90.prev = 16;
10011
+ _context90.t0 = _context90["catch"](8);
10012
+ errorMessage = _context90.t0 instanceof Error ? _context90.t0.message : String(_context90.t0);
10192
10013
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
10193
10014
  subscriberId: subscriberId,
10194
10015
  error: errorMessage
10195
10016
  });
10196
10017
  case 20:
10197
- _context92.next = 6;
10018
+ _context90.next = 6;
10198
10019
  break;
10199
10020
  case 22:
10200
- _context92.next = 27;
10021
+ _context90.next = 27;
10201
10022
  break;
10202
10023
  case 24:
10203
- _context92.prev = 24;
10204
- _context92.t1 = _context92["catch"](4);
10205
- _iterator21.e(_context92.t1);
10024
+ _context90.prev = 24;
10025
+ _context90.t1 = _context90["catch"](4);
10026
+ _iterator21.e(_context90.t1);
10206
10027
  case 27:
10207
- _context92.prev = 27;
10028
+ _context90.prev = 27;
10208
10029
  _iterator21.f();
10209
- return _context92.finish(27);
10030
+ return _context90.finish(27);
10210
10031
  case 30:
10211
10032
  case "end":
10212
- return _context92.stop();
10033
+ return _context90.stop();
10213
10034
  }
10214
- }, _callee92, this, [[4, 24, 27, 30], [8, 16]]);
10035
+ }, _callee90, this, [[4, 24, 27, 30], [8, 16]]);
10215
10036
  }));
10216
10037
  function recomputeAndNotifyBookingQuery() {
10217
10038
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);