@pisell/pisellos 0.10.95 → 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.
Files changed (31) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/OpenData/index.d.ts +3 -0
  3. package/dist/modules/OpenData/index.js +160 -84
  4. package/dist/modules/Order/index.d.ts +1 -1
  5. package/dist/server/index.d.ts +3 -0
  6. package/dist/server/index.js +857 -598
  7. package/dist/server/modules/order/index.d.ts +1 -0
  8. package/dist/server/modules/order/index.js +51 -51
  9. package/dist/solution/BookingByStep/index.d.ts +2 -2
  10. package/dist/solution/BookingTicket/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +16 -16
  12. package/dist/solution/Sales/index.d.ts +2 -1
  13. package/dist/solution/Sales/index.js +123 -49
  14. package/dist/solution/Sales/types.d.ts +6 -0
  15. package/dist/solution/Sales/types.js +2 -0
  16. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  17. package/lib/modules/OpenData/index.d.ts +3 -0
  18. package/lib/modules/OpenData/index.js +51 -18
  19. package/lib/modules/Order/index.d.ts +1 -1
  20. package/lib/server/index.d.ts +3 -0
  21. package/lib/server/index.js +155 -18
  22. package/lib/server/modules/order/index.d.ts +1 -0
  23. package/lib/server/modules/order/index.js +4 -3
  24. package/lib/solution/BookingByStep/index.d.ts +2 -2
  25. package/lib/solution/BookingTicket/index.d.ts +1 -1
  26. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +16 -16
  27. package/lib/solution/Sales/index.d.ts +2 -1
  28. package/lib/solution/Sales/index.js +28 -1
  29. package/lib/solution/Sales/types.d.ts +6 -0
  30. package/lib/solution/Sales/types.js +1 -0
  31. package/package.json +1 -1
@@ -789,7 +789,7 @@ var Server = /*#__PURE__*/function () {
789
789
  _defineProperty(this, "handleUpdateLocalOrder", /*#__PURE__*/function () {
790
790
  var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref32) {
791
791
  var _data$order_id, _ref34, _this$app;
792
- var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response, fresh, exists, _yield$_this$order$ov, overwritten, errorMessage;
792
+ var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response, _fresh, exists, _yield$_this$order$ov, overwritten, errorMessage;
793
793
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
794
794
  while (1) switch (_context13.prev = _context13.next) {
795
795
  case 0:
@@ -863,8 +863,8 @@ var Server = /*#__PURE__*/function () {
863
863
  });
864
864
  case 22:
865
865
  response = _context13.sent;
866
- fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
867
- if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
866
+ _fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
867
+ if (!(!_fresh || _typeof(_fresh) !== 'object' || _fresh.order_id == null)) {
868
868
  _context13.next = 27;
869
869
  break;
870
870
  }
@@ -885,7 +885,7 @@ var Server = /*#__PURE__*/function () {
885
885
  break;
886
886
  }
887
887
  _context13.next = 31;
888
- return _this.order.overwriteExistingOrder(fresh);
888
+ return _this.order.overwriteExistingOrder(_fresh);
889
889
  case 31:
890
890
  _yield$_this$order$ov = _context13.sent;
891
891
  overwritten = _yield$_this$order$ov.overwritten;
@@ -905,7 +905,7 @@ var Server = /*#__PURE__*/function () {
905
905
  });
906
906
  case 35:
907
907
  _context13.next = 37;
908
- return _this.order.upsertOrdersFromRemote([fresh]);
908
+ return _this.order.upsertOrdersFromRemote([_fresh]);
909
909
  case 37:
910
910
  _this.logInfo('handleUpdateLocalOrder: 本地合并新订单完成', {
911
911
  orderId: orderId
@@ -1411,7 +1411,7 @@ var Server = /*#__PURE__*/function () {
1411
1411
  _defineProperty(this, "handleLocalOrderReceiptSnapshot", /*#__PURE__*/function () {
1412
1412
  var _ref52 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref51) {
1413
1413
  var _this$order2;
1414
- var data, input, lookup, _payment_info, sourceOrder, remoteResult, paymentInfo, rebuiltOrder, smallTicketData, message;
1414
+ var data, input, lookup, _payment_info, sourceOrder, remoteResult, rebuiltOrder, smallTicketData, message;
1415
1415
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1416
1416
  while (1) switch (_context22.prev = _context22.next) {
1417
1417
  case 0:
@@ -1474,24 +1474,13 @@ var Server = /*#__PURE__*/function () {
1474
1474
  case 17:
1475
1475
  sourceOrder = remoteResult.order;
1476
1476
  case 18:
1477
- paymentInfo = _objectSpread({}, sourceOrder.payment_info || {});
1478
- delete paymentInfo.small_ticket_data;
1479
- _context22.next = 22;
1480
- return _this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, sourceOrder), {}, {
1481
- small_ticket_data_flag: 1,
1482
- payment_info: paymentInfo
1483
- }), {
1484
- locales: _this.normalizeRequestedReceiptLocales(input.locales),
1485
- invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
1486
- applyTemplateVisibility: true,
1487
- includeReceiptKeys: input.template_settings !== undefined,
1488
- refreshResourceReference: true
1489
- });
1490
- case 22:
1477
+ _context22.next = 20;
1478
+ return _this.rebuildOrderReceipt(sourceOrder, input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings), _this.normalizeRequestedReceiptLocales(input.locales));
1479
+ case 20:
1491
1480
  rebuiltOrder = _context22.sent;
1492
1481
  smallTicketData = (_payment_info = rebuiltOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data;
1493
1482
  if (hasSmallTicketData(smallTicketData)) {
1494
- _context22.next = 26;
1483
+ _context22.next = 24;
1495
1484
  break;
1496
1485
  }
1497
1486
  return _context22.abrupt("return", {
@@ -1502,7 +1491,7 @@ var Server = /*#__PURE__*/function () {
1502
1491
  small_ticket_data: null
1503
1492
  }
1504
1493
  });
1505
- case 26:
1494
+ case 24:
1506
1495
  return _context22.abrupt("return", {
1507
1496
  code: 200,
1508
1497
  status: true,
@@ -1519,8 +1508,8 @@ var Server = /*#__PURE__*/function () {
1519
1508
  })
1520
1509
  }
1521
1510
  });
1522
- case 29:
1523
- _context22.prev = 29;
1511
+ case 27:
1512
+ _context22.prev = 27;
1524
1513
  _context22.t0 = _context22["catch"](7);
1525
1514
  message = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1526
1515
  _this.logError('handleLocalOrderReceiptSnapshot: 生成失败', {
@@ -1535,11 +1524,11 @@ var Server = /*#__PURE__*/function () {
1535
1524
  small_ticket_data: null
1536
1525
  }
1537
1526
  });
1538
- case 34:
1527
+ case 32:
1539
1528
  case "end":
1540
1529
  return _context22.stop();
1541
1530
  }
1542
- }, _callee22, null, [[7, 29]]);
1531
+ }, _callee22, null, [[7, 27]]);
1543
1532
  }));
1544
1533
  return function (_x21) {
1545
1534
  return _ref52.apply(this, arguments);
@@ -3760,6 +3749,20 @@ var Server = /*#__PURE__*/function () {
3760
3749
  method: 'post',
3761
3750
  path: '/shop/local/print-order',
3762
3751
  handler: this.handleLocalPrintOrder.bind(this)
3752
+ }, {
3753
+ method: 'post',
3754
+ path: '/shop/local/cloud-order-invoice/lookup',
3755
+ handler: function handler(_ref65) {
3756
+ var data = _ref65.data;
3757
+ return _this9.handleCloudOrderInvoice(data, false);
3758
+ }
3759
+ }, {
3760
+ method: 'post',
3761
+ path: '/shop/local/cloud-order-invoice/submit',
3762
+ handler: function handler(_ref66) {
3763
+ var data = _ref66.data;
3764
+ return _this9.handleCloudOrderInvoice(data, true);
3765
+ }
3763
3766
  }, {
3764
3767
  method: 'post',
3765
3768
  path: '/shop/local/order-receipt-snapshot',
@@ -3780,13 +3783,13 @@ var Server = /*#__PURE__*/function () {
3780
3783
  method: 'post',
3781
3784
  path: '/shop/local/orderPaymentReadiness',
3782
3785
  handler: function () {
3783
- var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref65) {
3786
+ var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref67) {
3784
3787
  var _this9$order;
3785
3788
  var data;
3786
3789
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3787
3790
  while (1) switch (_context44.prev = _context44.next) {
3788
3791
  case 0:
3789
- data = _ref65.data;
3792
+ data = _ref67.data;
3790
3793
  _context44.next = 3;
3791
3794
  return (_this9$order = _this9.order) === null || _this9$order === void 0 ? void 0 : _this9$order.getLocalOrderForPaymentReadiness(data === null || data === void 0 ? void 0 : data.sale_id);
3792
3795
  case 3:
@@ -4192,11 +4195,11 @@ var Server = /*#__PURE__*/function () {
4192
4195
  */
4193
4196
  }, {
4194
4197
  key: "syncProductQueryScheduleTimers",
4195
- value: function syncProductQueryScheduleTimers(_ref67) {
4198
+ value: function syncProductQueryScheduleTimers(_ref69) {
4196
4199
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
4197
- var subscriberId = _ref67.subscriberId,
4198
- menu_list_ids = _ref67.menu_list_ids,
4199
- strategy_context = _ref67.strategy_context;
4200
+ var subscriberId = _ref69.subscriberId,
4201
+ menu_list_ids = _ref69.menu_list_ids,
4202
+ strategy_context = _ref69.strategy_context;
4200
4203
  this.clearSubscriberScheduleTimers(subscriberId);
4201
4204
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
4202
4205
  return;
@@ -4373,7 +4376,7 @@ var Server = /*#__PURE__*/function () {
4373
4376
  */
4374
4377
  function () {
4375
4378
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(kind, backendPath, data, config) {
4376
- var queryPayload, result, _ref68, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
4379
+ var queryPayload, result, _ref70, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
4377
4380
  return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4378
4381
  while (1) switch (_context52.prev = _context52.next) {
4379
4382
  case 0:
@@ -4382,7 +4385,7 @@ var Server = /*#__PURE__*/function () {
4382
4385
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
4383
4386
  case 3:
4384
4387
  result = _context52.sent;
4385
- _ref68 = config || {}, callback = _ref68.callback, subscriberId = _ref68.subscriberId, resetVisibleOrderIds = _ref68.resetVisibleOrderIds;
4388
+ _ref70 = config || {}, callback = _ref70.callback, subscriberId = _ref70.subscriberId, resetVisibleOrderIds = _ref70.resetVisibleOrderIds;
4386
4389
  if (subscriberId && typeof callback === 'function') {
4387
4390
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
4388
4391
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -6640,17 +6643,231 @@ var Server = /*#__PURE__*/function () {
6640
6643
  }, {
6641
6644
  key: "mergeLocalPrintOrderInput",
6642
6645
  value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
6643
- var _ref73, _localOrder$order_id, _ref74, _external_sale_number4;
6644
- var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref71) {
6645
- var _ref72 = _slicedToArray(_ref71, 2),
6646
- value = _ref72[1];
6646
+ var _ref75, _localOrder$order_id, _ref76, _external_sale_number4;
6647
+ var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref73) {
6648
+ var _ref74 = _slicedToArray(_ref73, 2),
6649
+ value = _ref74[1];
6647
6650
  return value !== undefined;
6648
6651
  }));
6649
6652
  return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
6650
- order_id: (_ref73 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref73 !== void 0 ? _ref73 : definedInput.orderId,
6651
- external_sale_number: (_ref74 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref74 !== void 0 ? _ref74 : definedInput.externalSaleNumber
6653
+ order_id: (_ref75 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref75 !== void 0 ? _ref75 : definedInput.orderId,
6654
+ external_sale_number: (_ref76 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref76 !== void 0 ? _ref76 : definedInput.externalSaleNumber
6652
6655
  });
6653
6656
  }
6657
+ }, {
6658
+ key: "loadCloudInvoiceOrder",
6659
+ value: function () {
6660
+ var _loadCloudInvoiceOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(orderId, shopId, assertCurrentShop) {
6661
+ var hasReceiptDetail, local, result, saved;
6662
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6663
+ while (1) switch (_context68.prev = _context68.next) {
6664
+ case 0:
6665
+ if (this.order) {
6666
+ _context68.next = 2;
6667
+ break;
6668
+ }
6669
+ throw new Error('Cloud invoice order service is unavailable');
6670
+ case 2:
6671
+ hasReceiptDetail = function hasReceiptDetail(order) {
6672
+ var _order$summary, _order$summary2;
6673
+ // Use the same amount fields as the receipt builder, including historical
6674
+ // top-level amounts. Zero is a valid total; a missing total in a list row is not.
6675
+ var total = [(_order$summary = order.summary) === null || _order$summary === void 0 ? void 0 : _order$summary.expect_amount, order.expect_amount, (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.total_amount, order.total_amount].find(function (value) {
6676
+ return value != null && value !== '';
6677
+ });
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));
6679
+ };
6680
+ _context68.next = 5;
6681
+ return this.order.getLocalOrderByLookup(orderId, {
6682
+ exactOrderId: true
6683
+ });
6684
+ case 5:
6685
+ local = _context68.sent;
6686
+ assertCurrentShop();
6687
+ if (!(local && String(local.order_id) === orderId)) {
6688
+ _context68.next = 12;
6689
+ break;
6690
+ }
6691
+ if (!(local.shop_id != null && String(local.shop_id) !== shopId)) {
6692
+ _context68.next = 10;
6693
+ break;
6694
+ }
6695
+ throw new Error('Cloud invoice order belongs to another shop');
6696
+ case 10:
6697
+ if (!(String(local.shop_id) === shopId && hasReceiptDetail(local))) {
6698
+ _context68.next = 12;
6699
+ break;
6700
+ }
6701
+ return _context68.abrupt("return", local);
6702
+ case 12:
6703
+ _context68.next = 14;
6704
+ return this.fetchAndPersistSalesOrderByLookup(orderId, {
6705
+ with: ['all']
6706
+ }, 'cloudOrderInvoice', undefined, function (fresh) {
6707
+ assertCurrentShop();
6708
+ if (String(fresh.order_id) !== orderId || fresh.shop_id != null && String(fresh.shop_id) !== shopId || !hasReceiptDetail(fresh)) {
6709
+ throw new Error('Cloud invoice order identity or detail is invalid');
6710
+ }
6711
+ // Some older shop-authenticated detail responses omit shop_id.
6712
+ return fresh.shop_id == null ? _objectSpread(_objectSpread({}, fresh), {}, {
6713
+ shop_id: Number(shopId)
6714
+ }) : fresh;
6715
+ });
6716
+ case 14:
6717
+ result = _context68.sent;
6718
+ assertCurrentShop();
6719
+ saved = result.order;
6720
+ if (!(!saved || String(saved.order_id) !== orderId || String(saved.shop_id) !== shopId || !hasReceiptDetail(saved))) {
6721
+ _context68.next = 19;
6722
+ break;
6723
+ }
6724
+ throw new Error(result.message || 'Cloud invoice order detail is unavailable');
6725
+ case 19:
6726
+ return _context68.abrupt("return", saved);
6727
+ case 20:
6728
+ case "end":
6729
+ return _context68.stop();
6730
+ }
6731
+ }, _callee68, this);
6732
+ }));
6733
+ function loadCloudInvoiceOrder(_x72, _x73, _x74) {
6734
+ return _loadCloudInvoiceOrder.apply(this, arguments);
6735
+ }
6736
+ return loadCloudInvoiceOrder;
6737
+ }()
6738
+ }, {
6739
+ key: "handleCloudOrderInvoice",
6740
+ value: function () {
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) {
6746
+ case 0:
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;
6750
+ break;
6751
+ }
6752
+ return _context69.abrupt("return", {
6753
+ code: 400,
6754
+ status: false,
6755
+ message: 'Invalid cloud invoice order ID',
6756
+ data: null
6757
+ });
6758
+ case 3:
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;
6764
+ break;
6765
+ }
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);
6776
+ case 11:
6777
+ order = _context69.sent;
6778
+ businessCode = order.business_code.trim();
6779
+ if (submit) {
6780
+ _context69.next = 15;
6781
+ break;
6782
+ }
6783
+ return _context69.abrupt("return", {
6784
+ code: 200,
6785
+ status: true,
6786
+ message: '',
6787
+ data: {
6788
+ business_code: businessCode
6789
+ }
6790
+ });
6791
+ case 15:
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))) {
6793
+ _context69.next = 17;
6794
+ break;
6795
+ }
6796
+ throw new Error('Cloud invoice template is missing or belongs to another business');
6797
+ case 17:
6798
+ settings = this.normalizePrintInvoiceTemplateSettings(input.template_settings);
6799
+ _context69.next = 20;
6800
+ return this.rebuildOrderReceipt(order, settings);
6801
+ case 20:
6802
+ receipt = _context69.sent;
6803
+ smallTicketData = (_receipt$payment_info = receipt.payment_info) === null || _receipt$payment_info === void 0 ? void 0 : _receipt$payment_info.small_ticket_data;
6804
+ if (hasSmallTicketData(smallTicketData)) {
6805
+ _context69.next = 24;
6806
+ break;
6807
+ }
6808
+ throw new Error('Cloud invoice snapshot is unavailable');
6809
+ case 24:
6810
+ deviceTask = this.getDeviceTaskPlugin();
6811
+ if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6812
+ _context69.next = 27;
6813
+ break;
6814
+ }
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;
6823
+ return deviceTask.dispatch({
6824
+ action: 'print_all',
6825
+ device_id: deviceId,
6826
+ name: 'PRINT_V1',
6827
+ source: 'server',
6828
+ source_type: 'order',
6829
+ source_id: order.order_id,
6830
+ payload: {
6831
+ type: '0',
6832
+ template_settings: settings,
6833
+ data: {
6834
+ order_id: order.order_id,
6835
+ small_ticket_data: smallTicketData
6836
+ }
6837
+ }
6838
+ });
6839
+ case 33:
6840
+ return _context69.abrupt("return", {
6841
+ code: 200,
6842
+ status: true,
6843
+ message: '',
6844
+ data: null
6845
+ });
6846
+ case 36:
6847
+ _context69.prev = 36;
6848
+ _context69.t0 = _context69["catch"](3);
6849
+ message = this.getUnknownErrorMessage(_context69.t0);
6850
+ this.logWarning('Cloud invoice request failed', {
6851
+ orderId: orderId,
6852
+ message: message
6853
+ });
6854
+ return _context69.abrupt("return", {
6855
+ code: 500,
6856
+ status: false,
6857
+ message: message,
6858
+ data: null
6859
+ });
6860
+ case 41:
6861
+ case "end":
6862
+ return _context69.stop();
6863
+ }
6864
+ }, _callee69, this, [[3, 36]]);
6865
+ }));
6866
+ function handleCloudOrderInvoice(_x75, _x76) {
6867
+ return _handleCloudOrderInvoice.apply(this, arguments);
6868
+ }
6869
+ return handleCloudOrderInvoice;
6870
+ }()
6654
6871
  }, {
6655
6872
  key: "normalizeRequestedReceiptLocales",
6656
6873
  value: function normalizeRequestedReceiptLocales(value) {
@@ -6661,6 +6878,22 @@ var Server = /*#__PURE__*/function () {
6661
6878
  return locale.trim();
6662
6879
  }).filter(Boolean)));
6663
6880
  }
6881
+ }, {
6882
+ key: "rebuildOrderReceipt",
6883
+ value: function rebuildOrderReceipt(order, templateSettings, locales) {
6884
+ var paymentInfo = _objectSpread({}, order.payment_info);
6885
+ delete paymentInfo.small_ticket_data;
6886
+ return this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, order), {}, {
6887
+ small_ticket_data_flag: 1,
6888
+ payment_info: paymentInfo
6889
+ }), {
6890
+ locales: locales,
6891
+ invoiceTemplateSettings: templateSettings,
6892
+ applyTemplateVisibility: true,
6893
+ includeReceiptKeys: templateSettings !== undefined,
6894
+ refreshResourceReference: true
6895
+ });
6896
+ }
6664
6897
  }, {
6665
6898
  key: "resolveMachinecodeBatchMetadataLookup",
6666
6899
  value: function resolveMachinecodeBatchMetadataLookup(data) {
@@ -6672,57 +6905,57 @@ var Server = /*#__PURE__*/function () {
6672
6905
  }, {
6673
6906
  key: "syncMachinecodeRedeemStatusToLocalOrder",
6674
6907
  value: function () {
6675
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(data, ids, status) {
6908
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(data, ids, status) {
6676
6909
  var _this$order5, _data$order_id2;
6677
6910
  var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
6678
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6679
- while (1) switch (_context68.prev = _context68.next) {
6911
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6912
+ while (1) switch (_context70.prev = _context70.next) {
6680
6913
  case 0:
6681
6914
  title = 'handleMachinecodeBatchMetadata';
6682
6915
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
6683
6916
  if (!(lookup === undefined)) {
6684
- _context68.next = 5;
6917
+ _context70.next = 5;
6685
6918
  break;
6686
6919
  }
6687
6920
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6688
6921
  batchSize: ids.length,
6689
6922
  status: status
6690
6923
  });
6691
- return _context68.abrupt("return");
6924
+ return _context70.abrupt("return");
6692
6925
  case 5:
6693
6926
  if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
6694
- _context68.next = 8;
6927
+ _context70.next = 8;
6695
6928
  break;
6696
6929
  }
6697
6930
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6698
6931
  lookup: lookup,
6699
6932
  status: status
6700
6933
  });
6701
- return _context68.abrupt("return");
6934
+ return _context70.abrupt("return");
6702
6935
  case 8:
6703
- _context68.next = 10;
6936
+ _context70.next = 10;
6704
6937
  return this.order.getLocalOrderByLookup(lookup);
6705
6938
  case 10:
6706
- localOrder = _context68.sent;
6939
+ localOrder = _context70.sent;
6707
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;
6708
6941
  if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
6709
- _context68.next = 16;
6942
+ _context70.next = 16;
6710
6943
  break;
6711
6944
  }
6712
- _context68.next = 15;
6945
+ _context70.next = 15;
6713
6946
  return this.order.getLocalOrderByLookup(orderId);
6714
6947
  case 15:
6715
- localOrder = _context68.sent;
6948
+ localOrder = _context70.sent;
6716
6949
  case 16:
6717
6950
  if (localOrder) {
6718
- _context68.next = 19;
6951
+ _context70.next = 19;
6719
6952
  break;
6720
6953
  }
6721
6954
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6722
6955
  lookup: lookup,
6723
6956
  status: status
6724
6957
  });
6725
- return _context68.abrupt("return");
6958
+ return _context70.abrupt("return");
6726
6959
  case 19:
6727
6960
  voucherIdSet = new Set(ids.filter(function (id) {
6728
6961
  return id !== undefined && id !== null && id !== '';
@@ -6730,14 +6963,14 @@ var Server = /*#__PURE__*/function () {
6730
6963
  return String(id);
6731
6964
  }));
6732
6965
  if (!(voucherIdSet.size === 0)) {
6733
- _context68.next = 23;
6966
+ _context70.next = 23;
6734
6967
  break;
6735
6968
  }
6736
6969
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6737
6970
  lookup: lookup,
6738
6971
  status: status
6739
6972
  });
6740
- return _context68.abrupt("return");
6973
+ return _context70.abrupt("return");
6741
6974
  case 23:
6742
6975
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
6743
6976
  hasUpdatedVoucher = false;
@@ -6751,7 +6984,7 @@ var Server = /*#__PURE__*/function () {
6751
6984
  });
6752
6985
  });
6753
6986
  if (hasUpdatedVoucher) {
6754
- _context68.next = 29;
6987
+ _context70.next = 29;
6755
6988
  break;
6756
6989
  }
6757
6990
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -6759,13 +6992,13 @@ var Server = /*#__PURE__*/function () {
6759
6992
  voucher_ids: Array.from(voucherIdSet),
6760
6993
  status: status
6761
6994
  });
6762
- return _context68.abrupt("return");
6995
+ return _context70.abrupt("return");
6763
6996
  case 29:
6764
6997
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
6765
- _context68.next = 34;
6998
+ _context70.next = 34;
6766
6999
  break;
6767
7000
  }
6768
- _context68.next = 32;
7001
+ _context70.next = 32;
6769
7002
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
6770
7003
  vouchers: nextVouchers
6771
7004
  }));
@@ -6775,13 +7008,13 @@ var Server = /*#__PURE__*/function () {
6775
7008
  updatedCount: voucherIdSet.size,
6776
7009
  status: status
6777
7010
  });
6778
- return _context68.abrupt("return");
7011
+ return _context70.abrupt("return");
6779
7012
  case 34:
6780
7013
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
6781
- _context68.next = 39;
7014
+ _context70.next = 39;
6782
7015
  break;
6783
7016
  }
6784
- _context68.next = 37;
7017
+ _context70.next = 37;
6785
7018
  return this.order.markOrderSyncedByExternalSaleNumber({
6786
7019
  externalSaleNumber: data.external_sale_number,
6787
7020
  patch: {
@@ -6794,7 +7027,7 @@ var Server = /*#__PURE__*/function () {
6794
7027
  updatedCount: voucherIdSet.size,
6795
7028
  status: status
6796
7029
  });
6797
- return _context68.abrupt("return");
7030
+ return _context70.abrupt("return");
6798
7031
  case 39:
6799
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"), {
6800
7033
  lookup: lookup,
@@ -6802,11 +7035,11 @@ var Server = /*#__PURE__*/function () {
6802
7035
  });
6803
7036
  case 40:
6804
7037
  case "end":
6805
- return _context68.stop();
7038
+ return _context70.stop();
6806
7039
  }
6807
- }, _callee68, this);
7040
+ }, _callee70, this);
6808
7041
  }));
6809
- function syncMachinecodeRedeemStatusToLocalOrder(_x72, _x73, _x74) {
7042
+ function syncMachinecodeRedeemStatusToLocalOrder(_x77, _x78, _x79) {
6810
7043
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
6811
7044
  }
6812
7045
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -6814,30 +7047,30 @@ var Server = /*#__PURE__*/function () {
6814
7047
  }, {
6815
7048
  key: "handleOrderCheckoutSubmit",
6816
7049
  value: function () {
6817
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
7050
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
6818
7051
  var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
6819
7052
  var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
6820
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6821
- while (1) switch (_context69.prev = _context69.next) {
7053
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7054
+ while (1) switch (_context71.prev = _context71.next) {
6822
7055
  case 0:
6823
7056
  backendPath = params.backendPath, title = params.title;
6824
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);
6825
- _context69.t0 = lookup;
6826
- if (!_context69.t0) {
6827
- _context69.next = 7;
7058
+ _context71.t0 = lookup;
7059
+ if (!_context71.t0) {
7060
+ _context71.next = 7;
6828
7061
  break;
6829
7062
  }
6830
- _context69.next = 6;
7063
+ _context71.next = 6;
6831
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);
6832
7065
  case 6:
6833
- _context69.t0 = _context69.sent;
7066
+ _context71.t0 = _context71.sent;
6834
7067
  case 7:
6835
- localOrder = _context69.t0;
7068
+ localOrder = _context71.t0;
6836
7069
  if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
6837
- _context69.next = 10;
7070
+ _context71.next = 10;
6838
7071
  break;
6839
7072
  }
6840
- return _context69.abrupt("return", {
7073
+ return _context71.abrupt("return", {
6841
7074
  code: 409,
6842
7075
  status: false,
6843
7076
  message: PAYMENT_REFRESH_MESSAGE,
@@ -6861,10 +7094,10 @@ var Server = /*#__PURE__*/function () {
6861
7094
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6862
7095
  });
6863
7096
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
6864
- _context69.next = 19;
7097
+ _context71.next = 19;
6865
7098
  break;
6866
7099
  }
6867
- return _context69.abrupt("return", this.handleSyncCheckoutSubmit({
7100
+ return _context71.abrupt("return", this.handleSyncCheckoutSubmit({
6868
7101
  backendPath: backendPath,
6869
7102
  data: data,
6870
7103
  title: title,
@@ -6873,16 +7106,16 @@ var Server = /*#__PURE__*/function () {
6873
7106
  receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
6874
7107
  }));
6875
7108
  case 19:
6876
- _context69.next = 21;
7109
+ _context71.next = 21;
6877
7110
  return this.normalizeCheckoutSubmitData(data, title);
6878
7111
  case 21:
6879
- normalizedData = _context69.sent;
6880
- _context69.next = 24;
7112
+ normalizedData = _context71.sent;
7113
+ _context71.next = 24;
6881
7114
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6882
7115
  case 24:
6883
- numberedData = _context69.sent;
7116
+ numberedData = _context71.sent;
6884
7117
  checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
6885
- _context69.next = 28;
7118
+ _context71.next = 28;
6886
7119
  return this.handlePendingSyncCheckoutOrder({
6887
7120
  backendPath: backendPath,
6888
7121
  data: checkoutData,
@@ -6891,18 +7124,18 @@ var Server = /*#__PURE__*/function () {
6891
7124
  invoiceTemplateSettings: invoiceTemplateSettings
6892
7125
  });
6893
7126
  case 28:
6894
- pendingResult = _context69.sent;
7127
+ pendingResult = _context71.sent;
6895
7128
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6896
- _context69.next = 43;
7129
+ _context71.next = 43;
6897
7130
  break;
6898
7131
  }
6899
7132
  pendingOrder = pendingResult.data;
6900
7133
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
6901
- _context69.next = 41;
7134
+ _context71.next = 41;
6902
7135
  break;
6903
7136
  }
6904
- _context69.prev = 32;
6905
- _context69.next = 35;
7137
+ _context71.prev = 32;
7138
+ _context71.next = 35;
6906
7139
  return this.dispatchLocalReceiptPrint({
6907
7140
  checkoutData: checkoutData,
6908
7141
  order: pendingOrder,
@@ -6912,19 +7145,19 @@ var Server = /*#__PURE__*/function () {
6912
7145
  invoiceTemplateSettings: invoiceTemplateSettings
6913
7146
  });
6914
7147
  case 35:
6915
- _context69.next = 41;
7148
+ _context71.next = 41;
6916
7149
  break;
6917
7150
  case 37:
6918
- _context69.prev = 37;
6919
- _context69.t1 = _context69["catch"](32);
7151
+ _context71.prev = 37;
7152
+ _context71.t1 = _context71["catch"](32);
6920
7153
  // The sale is already persisted. A failed receipt must not cancel its
6921
7154
  // sync task or send an unfiltered fallback to the printer.
6922
- pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context69.t1);
7155
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context71.t1);
6923
7156
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
6924
7157
  error: pendingResult.receipt_print_error
6925
7158
  });
6926
7159
  case 41:
6927
- _context69.next = 43;
7160
+ _context71.next = 43;
6928
7161
  return this.dispatchCheckoutSyncTask({
6929
7162
  backendPath: backendPath,
6930
7163
  data: checkoutData,
@@ -6934,23 +7167,23 @@ var Server = /*#__PURE__*/function () {
6934
7167
  });
6935
7168
  case 43:
6936
7169
  if (pendingResult.data.order_id) {
6937
- _context69.next = 45;
7170
+ _context71.next = 45;
6938
7171
  break;
6939
7172
  }
6940
- return _context69.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
7173
+ return _context71.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6941
7174
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6942
7175
  order_id: pendingResult.data.external_sale_number
6943
7176
  })
6944
7177
  }));
6945
7178
  case 45:
6946
- return _context69.abrupt("return", pendingResult);
7179
+ return _context71.abrupt("return", pendingResult);
6947
7180
  case 46:
6948
7181
  case "end":
6949
- return _context69.stop();
7182
+ return _context71.stop();
6950
7183
  }
6951
- }, _callee69, this, [[32, 37]]);
7184
+ }, _callee71, this, [[32, 37]]);
6952
7185
  }));
6953
- function handleOrderCheckoutSubmit(_x75) {
7186
+ function handleOrderCheckoutSubmit(_x80) {
6954
7187
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6955
7188
  }
6956
7189
  return handleOrderCheckoutSubmit;
@@ -6958,27 +7191,27 @@ var Server = /*#__PURE__*/function () {
6958
7191
  }, {
6959
7192
  key: "handleSyncCheckoutSubmit",
6960
7193
  value: function () {
6961
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
7194
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
6962
7195
  var _this$app18;
6963
7196
  var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6964
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6965
- while (1) switch (_context70.prev = _context70.next) {
7197
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7198
+ while (1) switch (_context72.prev = _context72.next) {
6966
7199
  case 0:
6967
7200
  backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
6968
7201
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && (_this$app18 = _this$app18.request) !== null && _this$app18 !== void 0 && _this$app18.post) {
6969
- _context70.next = 4;
7202
+ _context72.next = 4;
6970
7203
  break;
6971
7204
  }
6972
7205
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6973
- return _context70.abrupt("return", {
7206
+ return _context72.abrupt("return", {
6974
7207
  code: 500,
6975
7208
  status: false,
6976
7209
  message: 'app.request 不可用',
6977
7210
  data: null
6978
7211
  });
6979
7212
  case 4:
6980
- _context70.prev = 4;
6981
- _context70.next = 7;
7213
+ _context72.prev = 4;
7214
+ _context72.next = 7;
6982
7215
  return this.runCheckoutSync({
6983
7216
  backendPath: backendPath,
6984
7217
  data: data,
@@ -6988,13 +7221,13 @@ var Server = /*#__PURE__*/function () {
6988
7221
  invoiceTemplateSettings: invoiceTemplateSettings
6989
7222
  });
6990
7223
  case 7:
6991
- syncResult = _context70.sent;
7224
+ syncResult = _context72.sent;
6992
7225
  if (!syncResult.rejected) {
6993
- _context70.next = 11;
7226
+ _context72.next = 11;
6994
7227
  break;
6995
7228
  }
6996
7229
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6997
- return _context70.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
7230
+ return _context72.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6998
7231
  status: false,
6999
7232
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
7000
7233
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -7003,11 +7236,11 @@ var Server = /*#__PURE__*/function () {
7003
7236
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
7004
7237
  syncedOrder = syncResult.syncedOrder;
7005
7238
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
7006
- _context70.next = 23;
7239
+ _context72.next = 23;
7007
7240
  break;
7008
7241
  }
7009
- _context70.prev = 14;
7010
- _context70.next = 17;
7242
+ _context72.prev = 14;
7243
+ _context72.next = 17;
7011
7244
  return this.dispatchLocalReceiptPrint({
7012
7245
  checkoutData: syncResult.checkoutData,
7013
7246
  order: syncedOrder,
@@ -7017,41 +7250,41 @@ var Server = /*#__PURE__*/function () {
7017
7250
  invoiceTemplateSettings: invoiceTemplateSettings
7018
7251
  });
7019
7252
  case 17:
7020
- _context70.next = 23;
7253
+ _context72.next = 23;
7021
7254
  break;
7022
7255
  case 19:
7023
- _context70.prev = 19;
7024
- _context70.t0 = _context70["catch"](14);
7256
+ _context72.prev = 19;
7257
+ _context72.t0 = _context72["catch"](14);
7025
7258
  // Checkout already succeeded remotely; report the receipt failure
7026
7259
  // separately instead of implying that payment/order creation failed.
7027
- response.receipt_print_error = this.getUnknownErrorMessage(_context70.t0);
7260
+ response.receipt_print_error = this.getUnknownErrorMessage(_context72.t0);
7028
7261
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
7029
7262
  error: response.receipt_print_error
7030
7263
  });
7031
7264
  case 23:
7032
- return _context70.abrupt("return", response);
7265
+ return _context72.abrupt("return", response);
7033
7266
  case 26:
7034
- _context70.prev = 26;
7035
- _context70.t1 = _context70["catch"](4);
7036
- backendError = this.extractBackendErrorResponse(_context70.t1);
7267
+ _context72.prev = 26;
7268
+ _context72.t1 = _context72["catch"](4);
7269
+ backendError = this.extractBackendErrorResponse(_context72.t1);
7037
7270
  if (!backendError) {
7038
- _context70.next = 32;
7271
+ _context72.next = 32;
7039
7272
  break;
7040
7273
  }
7041
7274
  _normalized = this.normalizeCheckoutResponse(backendError);
7042
- return _context70.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
7275
+ return _context72.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
7043
7276
  status: false,
7044
7277
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
7045
7278
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
7046
7279
  }));
7047
7280
  case 32:
7048
- message = this.getUnknownErrorMessage(_context70.t1);
7281
+ message = this.getUnknownErrorMessage(_context72.t1);
7049
7282
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
7050
7283
  backendPath: backendPath,
7051
7284
  error: message,
7052
- error_detail: this.normalizeUnknownError(_context70.t1)
7285
+ error_detail: this.normalizeUnknownError(_context72.t1)
7053
7286
  });
7054
- return _context70.abrupt("return", {
7287
+ return _context72.abrupt("return", {
7055
7288
  code: 500,
7056
7289
  status: false,
7057
7290
  message: message,
@@ -7059,11 +7292,11 @@ var Server = /*#__PURE__*/function () {
7059
7292
  });
7060
7293
  case 35:
7061
7294
  case "end":
7062
- return _context70.stop();
7295
+ return _context72.stop();
7063
7296
  }
7064
- }, _callee70, this, [[4, 26], [14, 19]]);
7297
+ }, _callee72, this, [[4, 26], [14, 19]]);
7065
7298
  }));
7066
- function handleSyncCheckoutSubmit(_x76) {
7299
+ function handleSyncCheckoutSubmit(_x81) {
7067
7300
  return _handleSyncCheckoutSubmit.apply(this, arguments);
7068
7301
  }
7069
7302
  return handleSyncCheckoutSubmit;
@@ -7071,10 +7304,10 @@ var Server = /*#__PURE__*/function () {
7071
7304
  }, {
7072
7305
  key: "handleOrderDraftSubmit",
7073
7306
  value: function () {
7074
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
7307
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
7075
7308
  var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
7076
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7077
- while (1) switch (_context71.prev = _context71.next) {
7309
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7310
+ while (1) switch (_context73.prev = _context73.next) {
7078
7311
  case 0:
7079
7312
  title = params.title;
7080
7313
  extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
@@ -7088,10 +7321,10 @@ var Server = /*#__PURE__*/function () {
7088
7321
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
7089
7322
  order_number: data === null || data === void 0 ? void 0 : data.order_number
7090
7323
  });
7091
- _context71.next = 6;
7324
+ _context73.next = 6;
7092
7325
  return this.normalizeCheckoutSubmitData(data, title);
7093
7326
  case 6:
7094
- normalizedData = _context71.sent;
7327
+ normalizedData = _context73.sent;
7095
7328
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
7096
7329
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
7097
7330
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -7101,26 +7334,26 @@ var Server = /*#__PURE__*/function () {
7101
7334
  is_draft_order: 1
7102
7335
  });
7103
7336
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
7104
- _context71.next = 12;
7337
+ _context73.next = 12;
7105
7338
  break;
7106
7339
  }
7107
7340
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
7108
- return _context71.abrupt("return", {
7341
+ return _context73.abrupt("return", {
7109
7342
  code: 500,
7110
7343
  status: false,
7111
7344
  message: 'Order 模块不支持本地草稿写入',
7112
7345
  data: null
7113
7346
  });
7114
7347
  case 12:
7115
- _context71.prev = 12;
7116
- _context71.next = 15;
7348
+ _context73.prev = 12;
7349
+ _context73.next = 15;
7117
7350
  return this.order.upsertLocalDraftOrders([draftOrder]);
7118
7351
  case 15:
7119
7352
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
7120
7353
  order_id: draftOrder.order_id,
7121
7354
  external_sale_number: draftOrder.external_sale_number
7122
7355
  });
7123
- return _context71.abrupt("return", {
7356
+ return _context73.abrupt("return", {
7124
7357
  code: 200,
7125
7358
  status: true,
7126
7359
  message: '',
@@ -7132,13 +7365,13 @@ var Server = /*#__PURE__*/function () {
7132
7365
  })
7133
7366
  });
7134
7367
  case 19:
7135
- _context71.prev = 19;
7136
- _context71.t0 = _context71["catch"](12);
7137
- errorMessage = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7368
+ _context73.prev = 19;
7369
+ _context73.t0 = _context73["catch"](12);
7370
+ errorMessage = _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0);
7138
7371
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
7139
7372
  error: errorMessage
7140
7373
  });
7141
- return _context71.abrupt("return", {
7374
+ return _context73.abrupt("return", {
7142
7375
  code: 500,
7143
7376
  status: false,
7144
7377
  message: errorMessage,
@@ -7146,11 +7379,11 @@ var Server = /*#__PURE__*/function () {
7146
7379
  });
7147
7380
  case 24:
7148
7381
  case "end":
7149
- return _context71.stop();
7382
+ return _context73.stop();
7150
7383
  }
7151
- }, _callee71, this, [[12, 19]]);
7384
+ }, _callee73, this, [[12, 19]]);
7152
7385
  }));
7153
- function handleOrderDraftSubmit(_x77) {
7386
+ function handleOrderDraftSubmit(_x82) {
7154
7387
  return _handleOrderDraftSubmit.apply(this, arguments);
7155
7388
  }
7156
7389
  return handleOrderDraftSubmit;
@@ -7158,26 +7391,26 @@ var Server = /*#__PURE__*/function () {
7158
7391
  }, {
7159
7392
  key: "handlePendingSyncCheckoutOrder",
7160
7393
  value: function () {
7161
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7162
- var _this19 = this;
7394
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7395
+ var _this20 = this;
7163
7396
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
7164
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7165
- while (1) switch (_context72.prev = _context72.next) {
7397
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7398
+ while (1) switch (_context74.prev = _context74.next) {
7166
7399
  case 0:
7167
7400
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
7168
- _context72.next = 3;
7401
+ _context74.next = 3;
7169
7402
  return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
7170
7403
  case 3:
7171
- pendingOrder = _context72.sent;
7404
+ pendingOrder = _context74.sent;
7172
7405
  if (pendingOrder) {
7173
- _context72.next = 7;
7406
+ _context74.next = 7;
7174
7407
  break;
7175
7408
  }
7176
7409
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
7177
7410
  backendPath: backendPath,
7178
7411
  reason: reason
7179
7412
  });
7180
- return _context72.abrupt("return", {
7413
+ return _context74.abrupt("return", {
7181
7414
  code: 500,
7182
7415
  status: false,
7183
7416
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -7185,22 +7418,22 @@ var Server = /*#__PURE__*/function () {
7185
7418
  });
7186
7419
  case 7:
7187
7420
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
7188
- _context72.next = 10;
7421
+ _context74.next = 10;
7189
7422
  break;
7190
7423
  }
7191
7424
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
7192
7425
  backendPath: backendPath,
7193
7426
  reason: reason
7194
7427
  });
7195
- return _context72.abrupt("return", {
7428
+ return _context74.abrupt("return", {
7196
7429
  code: 500,
7197
7430
  status: false,
7198
7431
  message: 'Order 模块不支持本地待同步写入',
7199
7432
  data: null
7200
7433
  });
7201
7434
  case 10:
7202
- _context72.prev = 10;
7203
- _context72.next = 13;
7435
+ _context74.prev = 10;
7436
+ _context74.next = 13;
7204
7437
  return this.order.upsertPendingSyncOrders([pendingOrder]);
7205
7438
  case 13:
7206
7439
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -7212,9 +7445,9 @@ var Server = /*#__PURE__*/function () {
7212
7445
  });
7213
7446
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
7214
7447
  var _payment$metadata;
7215
- return sum + _this19.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
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);
7216
7449
  }, 0);
7217
- return _context72.abrupt("return", {
7450
+ return _context74.abrupt("return", {
7218
7451
  code: 200,
7219
7452
  status: true,
7220
7453
  message: '',
@@ -7229,15 +7462,15 @@ var Server = /*#__PURE__*/function () {
7229
7462
  })
7230
7463
  });
7231
7464
  case 18:
7232
- _context72.prev = 18;
7233
- _context72.t0 = _context72["catch"](10);
7234
- errorMessage = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7465
+ _context74.prev = 18;
7466
+ _context74.t0 = _context74["catch"](10);
7467
+ errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
7235
7468
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
7236
7469
  backendPath: backendPath,
7237
7470
  reason: reason,
7238
7471
  error: errorMessage
7239
7472
  });
7240
- return _context72.abrupt("return", {
7473
+ return _context74.abrupt("return", {
7241
7474
  code: 500,
7242
7475
  status: false,
7243
7476
  message: errorMessage,
@@ -7245,11 +7478,11 @@ var Server = /*#__PURE__*/function () {
7245
7478
  });
7246
7479
  case 23:
7247
7480
  case "end":
7248
- return _context72.stop();
7481
+ return _context74.stop();
7249
7482
  }
7250
- }, _callee72, this, [[10, 18]]);
7483
+ }, _callee74, this, [[10, 18]]);
7251
7484
  }));
7252
- function handlePendingSyncCheckoutOrder(_x78) {
7485
+ function handlePendingSyncCheckoutOrder(_x83) {
7253
7486
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
7254
7487
  }
7255
7488
  return handlePendingSyncCheckoutOrder;
@@ -7257,45 +7490,45 @@ var Server = /*#__PURE__*/function () {
7257
7490
  }, {
7258
7491
  key: "buildPendingSyncCheckoutOrder",
7259
7492
  value: function () {
7260
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data, invoiceTemplateSettings) {
7493
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data, invoiceTemplateSettings) {
7261
7494
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
7262
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7263
- while (1) switch (_context73.prev = _context73.next) {
7495
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7496
+ while (1) switch (_context75.prev = _context75.next) {
7264
7497
  case 0:
7265
7498
  if (!(!data || _typeof(data) !== 'object')) {
7266
- _context73.next = 2;
7499
+ _context75.next = 2;
7267
7500
  break;
7268
7501
  }
7269
- return _context73.abrupt("return", null);
7502
+ return _context75.abrupt("return", null);
7270
7503
  case 2:
7271
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 !== '';
7272
7505
  if (hasStorageKey) {
7273
- _context73.next = 5;
7506
+ _context75.next = 5;
7274
7507
  break;
7275
7508
  }
7276
- return _context73.abrupt("return", null);
7509
+ return _context75.abrupt("return", null);
7277
7510
  case 5:
7278
7511
  pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
7279
7512
  need_sync: 1,
7280
7513
  is_draft_order: 0
7281
7514
  }));
7282
- _context73.next = 8;
7515
+ _context75.next = 8;
7283
7516
  return this.buildSmallTicketProductMap(pendingOrder);
7284
7517
  case 8:
7285
- productMap = _context73.sent;
7518
+ productMap = _context75.sent;
7286
7519
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
7287
- return _context73.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7520
+ return _context75.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7288
7521
  requireFullyPaid: true,
7289
7522
  productMap: productMap,
7290
7523
  invoiceTemplateSettings: invoiceTemplateSettings
7291
7524
  }));
7292
7525
  case 11:
7293
7526
  case "end":
7294
- return _context73.stop();
7527
+ return _context75.stop();
7295
7528
  }
7296
- }, _callee73, this);
7529
+ }, _callee75, this);
7297
7530
  }));
7298
- function buildPendingSyncCheckoutOrder(_x79, _x80) {
7531
+ function buildPendingSyncCheckoutOrder(_x84, _x85) {
7299
7532
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
7300
7533
  }
7301
7534
  return buildPendingSyncCheckoutOrder;
@@ -7332,11 +7565,11 @@ var Server = /*#__PURE__*/function () {
7332
7565
  }, {
7333
7566
  key: "shouldAutoPrintReceiptForPaymentStatus",
7334
7567
  value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
7335
- var _this20 = this;
7568
+ var _this21 = this;
7336
7569
  if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
7337
7570
  var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
7338
7571
  return statuses.some(function (status) {
7339
- return status === 'paid' ? _this20.isSalesOrderFullyPaid(order) : paymentStatus === status;
7572
+ return status === 'paid' ? _this21.isSalesOrderFullyPaid(order) : paymentStatus === status;
7340
7573
  });
7341
7574
  }
7342
7575
  }, {
@@ -7365,32 +7598,32 @@ var Server = /*#__PURE__*/function () {
7365
7598
  }, {
7366
7599
  key: "isSalesOrderFullyPaid",
7367
7600
  value: function isSalesOrderFullyPaid(order) {
7368
- var _order$summary$amount, _order$summary, _ref75, _ref76, _order$summary$expect, _order$summary2, _order$summary3;
7601
+ var _order$summary$amount, _order$summary3, _ref77, _ref78, _order$summary$expect, _order$summary4, _order$summary5;
7369
7602
  if (!order || _typeof(order) !== 'object') return false;
7370
7603
  var paymentStatus = String(order.payment_status || '').toLowerCase();
7371
7604
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
7372
7605
  if (paymentStatus === 'partially_paid' || paymentStatus === 'payment_processing' || paymentStatus === 'pending' || paymentStatus === 'unpaid') {
7373
7606
  return false;
7374
7607
  }
7375
- var amountGap = (_order$summary$amount = (_order$summary = order.summary) === null || _order$summary === void 0 ? void 0 : _order$summary.amount_gap) !== null && _order$summary$amount !== void 0 ? _order$summary$amount : order.amount_gap;
7608
+ var amountGap = (_order$summary$amount = (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.amount_gap) !== null && _order$summary$amount !== void 0 ? _order$summary$amount : order.amount_gap;
7376
7609
  if (amountGap !== undefined && amountGap !== null && amountGap !== '') {
7377
7610
  return this.toAmountNumber(amountGap) <= 0;
7378
7611
  }
7379
7612
  var paidAmount = this.sumPaidOrderPayments(order.payments);
7380
- var targetAmount = this.toAmountNumber((_ref75 = (_ref76 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref76 !== void 0 ? _ref76 : order.expect_amount) !== null && _ref75 !== void 0 ? _ref75 : order.total_amount);
7613
+ var targetAmount = this.toAmountNumber((_ref77 = (_ref78 = (_order$summary$expect = (_order$summary4 = order.summary) === null || _order$summary4 === void 0 ? void 0 : _order$summary4.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary5 = order.summary) === null || _order$summary5 === void 0 ? void 0 : _order$summary5.total_amount) !== null && _ref78 !== void 0 ? _ref78 : order.expect_amount) !== null && _ref77 !== void 0 ? _ref77 : order.total_amount);
7381
7614
  if (targetAmount <= 0) return paidAmount > 0;
7382
7615
  return paidAmount >= targetAmount;
7383
7616
  }
7384
7617
  }, {
7385
7618
  key: "sumPaidOrderPayments",
7386
7619
  value: function sumPaidOrderPayments(payments) {
7387
- var _this21 = this;
7620
+ var _this22 = this;
7388
7621
  if (!Array.isArray(payments)) return 0;
7389
7622
  return payments.reduce(function (sum, payment) {
7390
7623
  var _payment$amount;
7391
7624
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
7392
7625
  if (status !== 'paid') return sum;
7393
- return sum + _this21.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
7626
+ return sum + _this22.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
7394
7627
  }, 0);
7395
7628
  }
7396
7629
  }, {
@@ -7404,12 +7637,12 @@ var Server = /*#__PURE__*/function () {
7404
7637
  }, {
7405
7638
  key: "buildSmallTicketProductMap",
7406
7639
  value: function () {
7407
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7640
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
7408
7641
  var _this$products4,
7409
- _this22 = this;
7642
+ _this23 = this;
7410
7643
  var products, productIdSet, productIds, entries;
7411
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7412
- while (1) switch (_context75.prev = _context75.next) {
7644
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7645
+ while (1) switch (_context77.prev = _context77.next) {
7413
7646
  case 0:
7414
7647
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
7415
7648
  productIdSet = new Set();
@@ -7421,8 +7654,8 @@ var Server = /*#__PURE__*/function () {
7421
7654
  }
7422
7655
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7423
7656
  product.product_bundle.forEach(function (bundle) {
7424
- var _ref77, _bundle$bundle_produc;
7425
- var bundleProductId = (_ref77 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref77 !== void 0 ? _ref77 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7657
+ var _ref79, _bundle$bundle_produc;
7658
+ var bundleProductId = (_ref79 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7426
7659
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
7427
7660
  productIdSet.add(bundleProductId);
7428
7661
  }
@@ -7431,45 +7664,45 @@ var Server = /*#__PURE__*/function () {
7431
7664
  });
7432
7665
  productIds = Array.from(productIdSet);
7433
7666
  if (!(!productIds.length || typeof ((_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductById) !== 'function')) {
7434
- _context75.next = 6;
7667
+ _context77.next = 6;
7435
7668
  break;
7436
7669
  }
7437
- return _context75.abrupt("return", {});
7670
+ return _context77.abrupt("return", {});
7438
7671
  case 6:
7439
- _context75.next = 8;
7672
+ _context77.next = 8;
7440
7673
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7441
- var _ref78 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(id) {
7442
- var _this22$products, _this22$products$getP, product;
7443
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7444
- while (1) switch (_context74.prev = _context74.next) {
7674
+ var _ref80 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(id) {
7675
+ var _this23$products, _this23$products$getP, product;
7676
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7677
+ while (1) switch (_context76.prev = _context76.next) {
7445
7678
  case 0:
7446
- _context74.prev = 0;
7447
- _context74.next = 3;
7448
- return (_this22$products = _this22.products) === null || _this22$products === void 0 || (_this22$products$getP = _this22$products.getProductById) === null || _this22$products$getP === void 0 ? void 0 : _this22$products$getP.call(_this22$products, Number(id));
7679
+ _context76.prev = 0;
7680
+ _context76.next = 3;
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));
7449
7682
  case 3:
7450
- product = _context74.sent;
7451
- return _context74.abrupt("return", product ? [String(id), product] : null);
7683
+ product = _context76.sent;
7684
+ return _context76.abrupt("return", product ? [String(id), product] : null);
7452
7685
  case 7:
7453
- _context74.prev = 7;
7454
- _context74.t0 = _context74["catch"](0);
7455
- _this22.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7686
+ _context76.prev = 7;
7687
+ _context76.t0 = _context76["catch"](0);
7688
+ _this23.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7456
7689
  product_id: id,
7457
- error: _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0)
7690
+ error: _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0)
7458
7691
  });
7459
- return _context74.abrupt("return", null);
7692
+ return _context76.abrupt("return", null);
7460
7693
  case 11:
7461
7694
  case "end":
7462
- return _context74.stop();
7695
+ return _context76.stop();
7463
7696
  }
7464
- }, _callee74, null, [[0, 7]]);
7697
+ }, _callee76, null, [[0, 7]]);
7465
7698
  }));
7466
- return function (_x82) {
7467
- return _ref78.apply(this, arguments);
7699
+ return function (_x87) {
7700
+ return _ref80.apply(this, arguments);
7468
7701
  };
7469
7702
  }()));
7470
7703
  case 8:
7471
- entries = _context75.sent;
7472
- return _context75.abrupt("return", entries.reduce(function (map, entry) {
7704
+ entries = _context77.sent;
7705
+ return _context77.abrupt("return", entries.reduce(function (map, entry) {
7473
7706
  if (!entry) return map;
7474
7707
  var _entry = _slicedToArray(entry, 2),
7475
7708
  id = _entry[0],
@@ -7479,11 +7712,11 @@ var Server = /*#__PURE__*/function () {
7479
7712
  }, {}));
7480
7713
  case 10:
7481
7714
  case "end":
7482
- return _context75.stop();
7715
+ return _context77.stop();
7483
7716
  }
7484
- }, _callee75, this);
7717
+ }, _callee77, this);
7485
7718
  }));
7486
- function buildSmallTicketProductMap(_x81) {
7719
+ function buildSmallTicketProductMap(_x86) {
7487
7720
  return _buildSmallTicketProductMap.apply(this, arguments);
7488
7721
  }
7489
7722
  return buildSmallTicketProductMap;
@@ -7503,8 +7736,8 @@ var Server = /*#__PURE__*/function () {
7503
7736
  addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
7504
7737
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7505
7738
  product.product_bundle.forEach(function (bundle) {
7506
- var _ref79, _bundle$bundle_produc2;
7507
- addProductId((_ref79 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7739
+ var _ref81, _bundle$bundle_produc2;
7740
+ addProductId((_ref81 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref81 !== void 0 ? _ref81 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7508
7741
  });
7509
7742
  }
7510
7743
  });
@@ -7513,40 +7746,40 @@ var Server = /*#__PURE__*/function () {
7513
7746
  }, {
7514
7747
  key: "buildSalesDetailProductSnapshotMap",
7515
7748
  value: function () {
7516
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
7749
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order) {
7517
7750
  var _this$products5;
7518
7751
  var productIds, getSnapshots;
7519
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7520
- while (1) switch (_context76.prev = _context76.next) {
7752
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7753
+ while (1) switch (_context78.prev = _context78.next) {
7521
7754
  case 0:
7522
7755
  productIds = this.collectSalesDetailProductIds(order);
7523
7756
  getSnapshots = (_this$products5 = this.products) === null || _this$products5 === void 0 ? void 0 : _this$products5.getProductSnapshotsByIds;
7524
7757
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
7525
- _context76.next = 4;
7758
+ _context78.next = 4;
7526
7759
  break;
7527
7760
  }
7528
- return _context76.abrupt("return", {});
7761
+ return _context78.abrupt("return", {});
7529
7762
  case 4:
7530
- _context76.prev = 4;
7531
- _context76.next = 7;
7763
+ _context78.prev = 4;
7764
+ _context78.next = 7;
7532
7765
  return getSnapshots.call(this.products, productIds);
7533
7766
  case 7:
7534
- return _context76.abrupt("return", _context76.sent);
7767
+ return _context78.abrupt("return", _context78.sent);
7535
7768
  case 10:
7536
- _context76.prev = 10;
7537
- _context76.t0 = _context76["catch"](4);
7769
+ _context78.prev = 10;
7770
+ _context78.t0 = _context78["catch"](4);
7538
7771
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
7539
7772
  product_ids: productIds,
7540
- error: _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0)
7773
+ error: _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0)
7541
7774
  });
7542
- return _context76.abrupt("return", {});
7775
+ return _context78.abrupt("return", {});
7543
7776
  case 14:
7544
7777
  case "end":
7545
- return _context76.stop();
7778
+ return _context78.stop();
7546
7779
  }
7547
- }, _callee76, this, [[4, 10]]);
7780
+ }, _callee78, this, [[4, 10]]);
7548
7781
  }));
7549
- function buildSalesDetailProductSnapshotMap(_x83) {
7782
+ function buildSalesDetailProductSnapshotMap(_x88) {
7550
7783
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
7551
7784
  }
7552
7785
  return buildSalesDetailProductSnapshotMap;
@@ -7580,9 +7813,9 @@ var Server = /*#__PURE__*/function () {
7580
7813
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
7581
7814
  var hasChanged = false;
7582
7815
  var productBundle = product.product_bundle.map(function (bundle) {
7583
- var _ref80, _bundle$bundle_produc3;
7816
+ var _ref82, _bundle$bundle_produc3;
7584
7817
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
7585
- var rawProductId = (_ref80 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref80 !== void 0 ? _ref80 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7818
+ var rawProductId = (_ref82 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7586
7819
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
7587
7820
  var productId = Number(rawProductId);
7588
7821
  if (!Number.isFinite(productId)) return bundle;
@@ -7602,53 +7835,53 @@ var Server = /*#__PURE__*/function () {
7602
7835
  }, {
7603
7836
  key: "withSalesDetailProductSnapshots",
7604
7837
  value: function () {
7605
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
7606
- var _this23 = this;
7838
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order) {
7839
+ var _this24 = this;
7607
7840
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
7608
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7609
- while (1) switch (_context77.prev = _context77.next) {
7841
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7842
+ while (1) switch (_context79.prev = _context79.next) {
7610
7843
  case 0:
7611
7844
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
7612
7845
  if (products !== null && products !== void 0 && products.length) {
7613
- _context77.next = 3;
7846
+ _context79.next = 3;
7614
7847
  break;
7615
7848
  }
7616
- return _context77.abrupt("return", order);
7849
+ return _context79.abrupt("return", order);
7617
7850
  case 3:
7618
- _context77.next = 5;
7851
+ _context79.next = 5;
7619
7852
  return this.buildSalesDetailProductSnapshotMap(order);
7620
7853
  case 5:
7621
- snapshotMap = _context77.sent;
7854
+ snapshotMap = _context79.sent;
7622
7855
  if (Object.keys(snapshotMap).length) {
7623
- _context77.next = 8;
7856
+ _context79.next = 8;
7624
7857
  break;
7625
7858
  }
7626
- return _context77.abrupt("return", order);
7859
+ return _context79.abrupt("return", order);
7627
7860
  case 8:
7628
7861
  hasChanged = false;
7629
7862
  enrichedProducts = products.map(function (product) {
7630
- var productWithBundleSnapshots = _this23.withBundleCatalogSnapshots(product, snapshotMap);
7631
- var nextProduct = _this23.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7863
+ var productWithBundleSnapshots = _this24.withBundleCatalogSnapshots(product, snapshotMap);
7864
+ var nextProduct = _this24.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7632
7865
  if (nextProduct !== product) hasChanged = true;
7633
7866
  return nextProduct;
7634
7867
  });
7635
7868
  if (hasChanged) {
7636
- _context77.next = 12;
7869
+ _context79.next = 12;
7637
7870
  break;
7638
7871
  }
7639
- return _context77.abrupt("return", order);
7872
+ return _context79.abrupt("return", order);
7640
7873
  case 12:
7641
7874
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
7642
7875
  products: enrichedProducts
7643
7876
  });
7644
- return _context77.abrupt("return", enrichedOrder);
7877
+ return _context79.abrupt("return", enrichedOrder);
7645
7878
  case 14:
7646
7879
  case "end":
7647
- return _context77.stop();
7880
+ return _context79.stop();
7648
7881
  }
7649
- }, _callee77, this);
7882
+ }, _callee79, this);
7650
7883
  }));
7651
- function withSalesDetailProductSnapshots(_x84) {
7884
+ function withSalesDetailProductSnapshots(_x89) {
7652
7885
  return _withSalesDetailProductSnapshots.apply(this, arguments);
7653
7886
  }
7654
7887
  return withSalesDetailProductSnapshots;
@@ -7656,13 +7889,13 @@ var Server = /*#__PURE__*/function () {
7656
7889
  }, {
7657
7890
  key: "withPendingSyncProductTitles",
7658
7891
  value: function withPendingSyncProductTitles(order, productMap) {
7659
- var _this24 = this;
7892
+ var _this25 = this;
7660
7893
  var products = Array.isArray(order.products) ? order.products : null;
7661
7894
  if (!(products !== null && products !== void 0 && products.length)) return order;
7662
7895
  return _objectSpread(_objectSpread({}, order), {}, {
7663
7896
  products: products.map(function (product) {
7664
7897
  return _objectSpread(_objectSpread({}, product), {}, {
7665
- product_title: _this24.buildProductTitleSnapshot(product, productMap)
7898
+ product_title: _this25.buildProductTitleSnapshot(product, productMap)
7666
7899
  });
7667
7900
  })
7668
7901
  });
@@ -7673,7 +7906,7 @@ var Server = /*#__PURE__*/function () {
7673
7906
  var _product$product_id4,
7674
7907
  _product$product,
7675
7908
  _fallbackProduct$prod,
7676
- _this25 = this;
7909
+ _this26 = this;
7677
7910
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
7678
7911
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
7679
7912
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -7681,7 +7914,7 @@ var Server = /*#__PURE__*/function () {
7681
7914
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
7682
7915
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
7683
7916
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
7684
- snapshot[key] = _this25.resolveProductTitleValue(ownTitle, key, currentLocale) || _this25.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7917
+ snapshot[key] = _this26.resolveProductTitleValue(ownTitle, key, currentLocale) || _this26.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7685
7918
  return snapshot;
7686
7919
  }, {});
7687
7920
  }
@@ -7706,7 +7939,7 @@ var Server = /*#__PURE__*/function () {
7706
7939
  }, {
7707
7940
  key: "resolveProductTitleValue",
7708
7941
  value: function resolveProductTitleValue(value, key, currentLocale) {
7709
- var _ref81, _ref82, _value$key;
7942
+ var _ref83, _ref84, _value$key;
7710
7943
  if (value === undefined || value === null || value === '') return null;
7711
7944
  if (_typeof(value) !== 'object') {
7712
7945
  var title = String(value);
@@ -7716,7 +7949,7 @@ var Server = /*#__PURE__*/function () {
7716
7949
  }
7717
7950
  var normalizedKey = key.replace('-', '_');
7718
7951
  var dashedKey = key.replace('_', '-');
7719
- var rawValue = (_ref81 = (_ref82 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref82 !== void 0 ? _ref82 : value[dashedKey]) !== null && _ref81 !== void 0 ? _ref81 : key === 'auto' ? value.default : undefined;
7952
+ var rawValue = (_ref83 = (_ref84 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref84 !== void 0 ? _ref84 : value[dashedKey]) !== null && _ref83 !== void 0 ? _ref83 : key === 'auto' ? value.default : undefined;
7720
7953
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
7721
7954
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
7722
7955
  return String(rawValue);
@@ -7779,31 +8012,31 @@ var Server = /*#__PURE__*/function () {
7779
8012
  }, {
7780
8013
  key: "enrichPaymentNamesByCode",
7781
8014
  value: function () {
7782
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order) {
7783
- var _this26 = this;
8015
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(order) {
8016
+ var _this27 = this;
7784
8017
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
7785
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7786
- while (1) switch (_context78.prev = _context78.next) {
8018
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8019
+ while (1) switch (_context80.prev = _context80.next) {
7787
8020
  case 0:
7788
8021
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
7789
8022
  hasMissingName = payments.some(function (payment) {
7790
- return _this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
8023
+ return _this27.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this27.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7791
8024
  });
7792
8025
  if (hasMissingName) {
7793
- _context78.next = 4;
8026
+ _context80.next = 4;
7794
8027
  break;
7795
8028
  }
7796
- return _context78.abrupt("return", order);
8029
+ return _context80.abrupt("return", order);
7797
8030
  case 4:
7798
- _context78.prev = 4;
7799
- _context78.next = 7;
8031
+ _context80.prev = 4;
8032
+ _context80.next = 7;
7800
8033
  return this.getPaymentRouteModule();
7801
8034
  case 7:
7802
- paymentModule = _context78.sent;
7803
- _context78.next = 10;
8035
+ paymentModule = _context80.sent;
8036
+ _context80.next = 10;
7804
8037
  return paymentModule.getPayMethodListAsync();
7805
8038
  case 10:
7806
- payMethods = _context78.sent;
8039
+ payMethods = _context80.sent;
7807
8040
  nameByCode = new Map();
7808
8041
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
7809
8042
  try {
@@ -7820,9 +8053,9 @@ var Server = /*#__PURE__*/function () {
7820
8053
  }
7821
8054
  hasResolvedName = false;
7822
8055
  enrichedPayments = payments.map(function (payment) {
7823
- if (!_this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7824
- if (!_this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7825
- var name = nameByCode.get(_this26.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
8056
+ if (!_this27.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
8057
+ if (!_this27.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
8058
+ var name = nameByCode.get(_this27.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7826
8059
  if (!name) return payment;
7827
8060
  hasResolvedName = true;
7828
8061
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -7830,28 +8063,28 @@ var Server = /*#__PURE__*/function () {
7830
8063
  });
7831
8064
  });
7832
8065
  if (hasResolvedName) {
7833
- _context78.next = 18;
8066
+ _context80.next = 18;
7834
8067
  break;
7835
8068
  }
7836
- return _context78.abrupt("return", order);
8069
+ return _context80.abrupt("return", order);
7837
8070
  case 18:
7838
- return _context78.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
8071
+ return _context80.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7839
8072
  payments: enrichedPayments
7840
8073
  }));
7841
8074
  case 21:
7842
- _context78.prev = 21;
7843
- _context78.t0 = _context78["catch"](4);
8075
+ _context80.prev = 21;
8076
+ _context80.t0 = _context80["catch"](4);
7844
8077
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
7845
- error: _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0)
8078
+ error: _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0)
7846
8079
  });
7847
- return _context78.abrupt("return", order);
8080
+ return _context80.abrupt("return", order);
7848
8081
  case 25:
7849
8082
  case "end":
7850
- return _context78.stop();
8083
+ return _context80.stop();
7851
8084
  }
7852
- }, _callee78, this, [[4, 21]]);
8085
+ }, _callee80, this, [[4, 21]]);
7853
8086
  }));
7854
- function enrichPaymentNamesByCode(_x85) {
8087
+ function enrichPaymentNamesByCode(_x90) {
7855
8088
  return _enrichPaymentNamesByCode.apply(this, arguments);
7856
8089
  }
7857
8090
  return enrichPaymentNamesByCode;
@@ -7859,25 +8092,25 @@ var Server = /*#__PURE__*/function () {
7859
8092
  }, {
7860
8093
  key: "withLocalSmallTicketData",
7861
8094
  value: function () {
7862
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order, options) {
7863
- var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref83, _ref84, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
7864
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7865
- while (1) switch (_context79.prev = _context79.next) {
8095
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(order, options) {
8096
+ var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref85, _ref86, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
8097
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8098
+ while (1) switch (_context81.prev = _context81.next) {
7866
8099
  case 0:
7867
8100
  mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
7868
8101
  if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
7869
- _context79.next = 3;
8102
+ _context81.next = 3;
7870
8103
  break;
7871
8104
  }
7872
- return _context79.abrupt("return", order);
8105
+ return _context81.abrupt("return", order);
7873
8106
  case 3:
7874
8107
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
7875
- _context79.next = 5;
8108
+ _context81.next = 5;
7876
8109
  break;
7877
8110
  }
7878
- return _context79.abrupt("return", order);
8111
+ return _context81.abrupt("return", order);
7879
8112
  case 5:
7880
- _context79.prev = 5;
8113
+ _context81.prev = 5;
7881
8114
  normalizedCollections = normalizeOrderCollections(order, {
7882
8115
  ensureUid: false
7883
8116
  });
@@ -7891,42 +8124,42 @@ var Server = /*#__PURE__*/function () {
7891
8124
  return count > 0;
7892
8125
  })) {
7893
8126
  this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
7894
- order_identifier: (_ref83 = (_ref84 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref84 !== void 0 ? _ref84 : normalizedOrder.shop_order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
8127
+ order_identifier: (_ref85 = (_ref86 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref86 !== void 0 ? _ref86 : normalizedOrder.shop_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
7895
8128
  collapsed_duplicate_counts: collapsedDuplicateCounts
7896
8129
  });
7897
8130
  }
7898
8131
  if (!(options !== null && options !== void 0 && options.refreshResourceReference)) {
7899
- _context79.next = 16;
8132
+ _context81.next = 16;
7900
8133
  break;
7901
8134
  }
7902
- _context79.next = 13;
8135
+ _context81.next = 13;
7903
8136
  return this.withCurrentReceiptResourceReference(normalizedOrder);
7904
8137
  case 13:
7905
- _context79.t0 = _context79.sent;
7906
- _context79.next = 17;
8138
+ _context81.t0 = _context81.sent;
8139
+ _context81.next = 17;
7907
8140
  break;
7908
8141
  case 16:
7909
- _context79.t0 = normalizedOrder;
8142
+ _context81.t0 = normalizedOrder;
7910
8143
  case 17:
7911
- receiptOrder = _context79.t0;
7912
- _context79.next = 20;
8144
+ receiptOrder = _context81.t0;
8145
+ _context81.next = 20;
7913
8146
  return this.enrichPaymentNamesByCode(receiptOrder);
7914
8147
  case 20:
7915
- enrichedOrder = _context79.sent;
8148
+ enrichedOrder = _context81.sent;
7916
8149
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7917
- _context79.next = 25;
8150
+ _context81.next = 25;
7918
8151
  break;
7919
8152
  }
7920
- _context79.t1 = _options$productMap;
7921
- _context79.next = 28;
8153
+ _context81.t1 = _options$productMap;
8154
+ _context81.next = 28;
7922
8155
  break;
7923
8156
  case 25:
7924
- _context79.next = 27;
8157
+ _context81.next = 27;
7925
8158
  return this.buildSmallTicketProductMap(enrichedOrder);
7926
8159
  case 27:
7927
- _context79.t1 = _context79.sent;
8160
+ _context81.t1 = _context81.sent;
7928
8161
  case 28:
7929
- productMap = _context79.t1;
8162
+ productMap = _context81.t1;
7930
8163
  smallTicketData = buildSmallTicketData({
7931
8164
  order: enrichedOrder,
7932
8165
  shopInfo: this.getSmallTicketShopInfo(),
@@ -7935,31 +8168,31 @@ var Server = /*#__PURE__*/function () {
7935
8168
  includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
7936
8169
  templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
7937
8170
  });
7938
- return _context79.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
8171
+ return _context81.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7939
8172
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7940
8173
  small_ticket_data: smallTicketData
7941
8174
  })
7942
8175
  }));
7943
8176
  case 33:
7944
- _context79.prev = 33;
7945
- _context79.t2 = _context79["catch"](5);
8177
+ _context81.prev = 33;
8178
+ _context81.t2 = _context81["catch"](5);
7946
8179
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7947
- error: _context79.t2 instanceof Error ? _context79.t2.message : String(_context79.t2)
8180
+ error: _context81.t2 instanceof Error ? _context81.t2.message : String(_context81.t2)
7948
8181
  });
7949
8182
  if (!mustApplyVisibility) {
7950
- _context79.next = 38;
8183
+ _context81.next = 38;
7951
8184
  break;
7952
8185
  }
7953
- throw _context79.t2;
8186
+ throw _context81.t2;
7954
8187
  case 38:
7955
- return _context79.abrupt("return", order);
8188
+ return _context81.abrupt("return", order);
7956
8189
  case 39:
7957
8190
  case "end":
7958
- return _context79.stop();
8191
+ return _context81.stop();
7959
8192
  }
7960
- }, _callee79, this, [[5, 33]]);
8193
+ }, _callee81, this, [[5, 33]]);
7961
8194
  }));
7962
- function withLocalSmallTicketData(_x86, _x87) {
8195
+ function withLocalSmallTicketData(_x91, _x92) {
7963
8196
  return _withLocalSmallTicketData.apply(this, arguments);
7964
8197
  }
7965
8198
  return withLocalSmallTicketData;
@@ -7974,37 +8207,37 @@ var Server = /*#__PURE__*/function () {
7974
8207
  }, {
7975
8208
  key: "fetchAndPersistSalesOrderByLookup",
7976
8209
  value: function () {
7977
- var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(lookup, data, title, paymentIdentityOrder) {
8210
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(lookup, data, title, paymentIdentityOrder, prepareExactOrderForPersist) {
7978
8211
  var _this$order7, _this$order8, _this$app20;
7979
- var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref85, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7980
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
7981
- while (1) switch (_context80.prev = _context80.next) {
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;
8213
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8214
+ while (1) switch (_context82.prev = _context82.next) {
7982
8215
  case 0:
7983
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))) {
7984
- _context80.next = 3;
8217
+ _context82.next = 3;
7985
8218
  break;
7986
8219
  }
7987
8220
  this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7988
- return _context80.abrupt("return", {
8221
+ return _context82.abrupt("return", {
7989
8222
  code: 500,
7990
8223
  message: 'Order 模块未注册',
7991
8224
  order: null
7992
8225
  });
7993
8226
  case 3:
7994
8227
  if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && (_this$app20 = _this$app20.request) !== null && _this$app20 !== void 0 && _this$app20.get) {
7995
- _context80.next = 6;
8228
+ _context82.next = 6;
7996
8229
  break;
7997
8230
  }
7998
8231
  this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7999
- return _context80.abrupt("return", {
8232
+ return _context82.abrupt("return", {
8000
8233
  code: 500,
8001
8234
  message: 'app.request 不可用',
8002
8235
  order: null
8003
8236
  });
8004
8237
  case 6:
8005
8238
  backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
8006
- _context80.prev = 7;
8007
- _context80.next = 10;
8239
+ _context82.prev = 7;
8240
+ _context82.next = 10;
8008
8241
  return this.app.request.get(backendPath, {
8009
8242
  lookup_mode: 'multi'
8010
8243
  }, {
@@ -8012,9 +8245,9 @@ var Server = /*#__PURE__*/function () {
8012
8245
  customToast: function customToast() {}
8013
8246
  });
8014
8247
  case 10:
8015
- response = _context80.sent;
8248
+ response = _context82.sent;
8016
8249
  if (!this.isCheckoutResponseRejected(response)) {
8017
- _context80.next = 17;
8250
+ _context82.next = 17;
8018
8251
  break;
8019
8252
  }
8020
8253
  responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
@@ -8026,70 +8259,80 @@ var Server = /*#__PURE__*/function () {
8026
8259
  code: code,
8027
8260
  message: message
8028
8261
  });
8029
- return _context80.abrupt("return", {
8262
+ return _context82.abrupt("return", {
8030
8263
  code: code,
8031
8264
  message: message,
8032
8265
  order: null
8033
8266
  });
8034
8267
  case 17:
8035
- fresh = this.extractOrderDataFromCheckoutResponse(response);
8036
- if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
8037
- _context80.next = 21;
8268
+ _fresh2 = this.extractOrderDataFromCheckoutResponse(response);
8269
+ if (!(!_fresh2 || _fresh2.order_id === undefined || _fresh2.order_id === null || String(_fresh2.order_id).trim() === '')) {
8270
+ _context82.next = 21;
8038
8271
  break;
8039
8272
  }
8040
8273
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
8041
8274
  lookup: lookup,
8042
8275
  backendPath: backendPath
8043
8276
  });
8044
- return _context80.abrupt("return", {
8277
+ return _context82.abrupt("return", {
8045
8278
  code: 500,
8046
8279
  message: '后端返回订单为空',
8047
8280
  order: null
8048
8281
  });
8049
8282
  case 21:
8050
- _context80.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
8051
- if (_context80.t0) {
8052
- _context80.next = 31;
8283
+ if (!prepareExactOrderForPersist) {
8284
+ _context82.next = 25;
8285
+ break;
8286
+ }
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;
8289
+ break;
8290
+ case 25:
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;
8053
8294
  break;
8054
8295
  }
8055
8296
  if (!this.shouldForceRemoteSalesDetail(data)) {
8056
- _context80.next = 29;
8297
+ _context82.next = 33;
8057
8298
  break;
8058
8299
  }
8059
- _context80.next = 26;
8300
+ _context82.next = 30;
8060
8301
  return this.order.getLocalOrderByLookup(lookup);
8061
- case 26:
8062
- _context80.t1 = _context80.sent;
8063
- _context80.next = 30;
8064
- break;
8065
- case 29:
8066
- _context80.t1 = null;
8067
8302
  case 30:
8068
- _context80.t0 = _context80.t1;
8069
- case 31:
8070
- localBeforeRefresh = _context80.t0;
8071
- orderToPersist = fresh;
8303
+ _context82.t2 = _context82.sent;
8304
+ _context82.next = 34;
8305
+ break;
8306
+ case 33:
8307
+ _context82.t2 = null;
8308
+ case 34:
8309
+ _context82.t1 = _context82.t2;
8310
+ case 35:
8311
+ _context82.t0 = _context82.t1;
8312
+ case 36:
8313
+ localBeforeRefresh = _context82.t0;
8314
+ orderToPersist = _fresh2;
8072
8315
  if (!paymentIdentityOrder) {
8073
- _context80.next = 44;
8316
+ _context82.next = 49;
8074
8317
  break;
8075
8318
  }
8076
- if (!(String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments))) {
8077
- _context80.next = 36;
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))) {
8320
+ _context82.next = 41;
8078
8321
  break;
8079
8322
  }
8080
8323
  throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
8081
- case 36:
8324
+ case 41:
8082
8325
  if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
8083
- _context80.next = 38;
8326
+ _context82.next = 43;
8084
8327
  break;
8085
8328
  }
8086
- return _context80.abrupt("return", {
8329
+ return _context82.abrupt("return", {
8087
8330
  code: 200,
8088
8331
  message: '',
8089
8332
  order: localBeforeRefresh || paymentIdentityOrder
8090
8333
  });
8091
- case 38:
8092
- remotePayments = fresh.payments;
8334
+ case 43:
8335
+ remotePayments = _fresh2.payments;
8093
8336
  paidPayments = (localBeforeRefresh.payments || []).filter(function (payment) {
8094
8337
  return payment.status === 'paid';
8095
8338
  });
@@ -8105,115 +8348,131 @@ var Server = /*#__PURE__*/function () {
8105
8348
  return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
8106
8349
  });
8107
8350
  if (paymentIdsComplete) {
8108
- _context80.next = 43;
8351
+ _context82.next = 48;
8109
8352
  break;
8110
8353
  }
8111
8354
  throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
8112
- case 43:
8113
- orderToPersist = _objectSpread(_objectSpread({}, fresh), {}, {
8355
+ case 48:
8356
+ orderToPersist = _objectSpread(_objectSpread({}, _fresh2), {}, {
8114
8357
  payments: mergeOrderPaymentListsByIdentity(localBeforeRefresh.payments, remotePayments, {
8115
8358
  preserveUnmatchedExisting: true
8116
8359
  })
8117
8360
  });
8118
- case 44:
8361
+ case 49:
8362
+ if (prepareExactOrderForPersist) orderToPersist = prepareExactOrderForPersist(orderToPersist);
8119
8363
  if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
8120
- _context80.next = 51;
8364
+ _context82.next = 57;
8121
8365
  break;
8122
8366
  }
8123
- if (!(String(fresh.order_id) !== String(localBeforeRefresh.order_id))) {
8124
- _context80.next = 47;
8367
+ if (!(String(_fresh2.order_id) !== String(localBeforeRefresh.order_id))) {
8368
+ _context82.next = 53;
8125
8369
  break;
8126
8370
  }
8127
8371
  throw new Error('远端订单身份不匹配,请重新刷新');
8128
- case 47:
8129
- _context80.next = 49;
8372
+ case 53:
8373
+ _context82.next = 55;
8130
8374
  return this.order.completeLocalPaymentRefresh(orderToPersist);
8131
- case 49:
8132
- _context80.next = 53;
8375
+ case 55:
8376
+ _context82.next = 59;
8133
8377
  break;
8134
- case 51:
8135
- _context80.next = 53;
8378
+ case 57:
8379
+ _context82.next = 59;
8136
8380
  return this.order.upsertOrdersFromRemote([orderToPersist]);
8137
- case 53:
8138
- _context80.next = 55;
8381
+ case 59:
8382
+ if (!prepareExactOrderForPersist) {
8383
+ _context82.next = 65;
8384
+ break;
8385
+ }
8386
+ _context82.next = 62;
8387
+ return this.order.getLocalOrderByLookup(lookup, {
8388
+ exactOrderId: true
8389
+ });
8390
+ case 62:
8391
+ _context82.t3 = _context82.sent;
8392
+ _context82.next = 68;
8393
+ break;
8394
+ case 65:
8395
+ _context82.next = 67;
8139
8396
  return this.order.getLocalOrderByLookup(lookup);
8140
- case 55:
8141
- savedOrder = _context80.sent;
8142
- if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
8143
- _context80.next = 60;
8397
+ case 67:
8398
+ _context82.t3 = _context82.sent;
8399
+ case 68:
8400
+ savedOrder = _context82.t3;
8401
+ if (!(!savedOrder && _fresh2.order_id !== undefined && _fresh2.order_id !== null && String(_fresh2.order_id) !== String(lookup))) {
8402
+ _context82.next = 73;
8144
8403
  break;
8145
8404
  }
8146
- _context80.next = 59;
8147
- return this.order.getLocalOrderByLookup(fresh.order_id);
8148
- case 59:
8149
- savedOrder = _context80.sent;
8150
- case 60:
8405
+ _context82.next = 72;
8406
+ return this.order.getLocalOrderByLookup(_fresh2.order_id);
8407
+ case 72:
8408
+ savedOrder = _context82.sent;
8409
+ case 73:
8151
8410
  if (savedOrder) {
8152
- _context80.next = 63;
8411
+ _context82.next = 76;
8153
8412
  break;
8154
8413
  }
8155
8414
  this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
8156
8415
  lookup: lookup,
8157
- remote_order_id: fresh.order_id
8416
+ remote_order_id: _fresh2.order_id
8158
8417
  });
8159
- return _context80.abrupt("return", {
8418
+ return _context82.abrupt("return", {
8160
8419
  code: 500,
8161
8420
  message: '订单写入后回读失败',
8162
8421
  order: null
8163
8422
  });
8164
- case 63:
8423
+ case 76:
8165
8424
  this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
8166
8425
  lookup: lookup,
8167
- remote_order_id: fresh.order_id
8426
+ remote_order_id: _fresh2.order_id
8168
8427
  });
8169
- return _context80.abrupt("return", {
8428
+ return _context82.abrupt("return", {
8170
8429
  code: 200,
8171
8430
  message: '',
8172
8431
  order: savedOrder
8173
8432
  });
8174
- case 67:
8175
- _context80.prev = 67;
8176
- _context80.t2 = _context80["catch"](7);
8177
- backendError = this.extractBackendErrorResponse(_context80.t2);
8178
- errorRecord = _context80.t2;
8433
+ case 80:
8434
+ _context82.prev = 80;
8435
+ _context82.t4 = _context82["catch"](7);
8436
+ backendError = this.extractBackendErrorResponse(_context82.t4);
8437
+ errorRecord = _context82.t4;
8179
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;
8180
8439
  if (!(backendError || _responseStatusCode !== undefined)) {
8181
- _context80.next = 78;
8440
+ _context82.next = 91;
8182
8441
  break;
8183
8442
  }
8184
8443
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
8185
- _code = this.normalizeRemoteSalesOrderErrorCode((_ref85 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref85 !== void 0 ? _ref85 : _responseStatusCode);
8186
- _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context80.t2);
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);
8445
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context82.t4);
8187
8446
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
8188
8447
  lookup: lookup,
8189
8448
  backendPath: backendPath,
8190
8449
  code: _code,
8191
8450
  message: _message2
8192
8451
  });
8193
- return _context80.abrupt("return", {
8452
+ return _context82.abrupt("return", {
8194
8453
  code: _code,
8195
8454
  message: _message2,
8196
8455
  order: null
8197
8456
  });
8198
- case 78:
8199
- _message3 = this.getUnknownErrorMessage(_context80.t2);
8457
+ case 91:
8458
+ _message3 = this.getUnknownErrorMessage(_context82.t4);
8200
8459
  this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
8201
8460
  lookup: lookup,
8202
8461
  backendPath: backendPath,
8203
8462
  error: _message3
8204
8463
  });
8205
- return _context80.abrupt("return", {
8464
+ return _context82.abrupt("return", {
8206
8465
  code: 500,
8207
8466
  message: _message3,
8208
8467
  order: null
8209
8468
  });
8210
- case 81:
8469
+ case 94:
8211
8470
  case "end":
8212
- return _context80.stop();
8471
+ return _context82.stop();
8213
8472
  }
8214
- }, _callee80, this, [[7, 67]]);
8473
+ }, _callee82, this, [[7, 80]]);
8215
8474
  }));
8216
- function fetchAndPersistSalesOrderByLookup(_x88, _x89, _x90, _x91) {
8475
+ function fetchAndPersistSalesOrderByLookup(_x93, _x94, _x95, _x96, _x97) {
8217
8476
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
8218
8477
  }
8219
8478
  return fetchAndPersistSalesOrderByLookup;
@@ -8275,22 +8534,22 @@ var Server = /*#__PURE__*/function () {
8275
8534
  }, {
8276
8535
  key: "handleUpdateLocalOrdersBatch",
8277
8536
  value: (function () {
8278
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(orderIds) {
8537
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(orderIds) {
8279
8538
  var _this$app21;
8280
- var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
8281
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8282
- while (1) switch (_context81.prev = _context81.next) {
8539
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, _fresh3, _message4, overwritten, inserted;
8540
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8541
+ while (1) switch (_context83.prev = _context83.next) {
8283
8542
  case 0:
8284
8543
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
8285
8544
  count: orderIds.length,
8286
8545
  orderIds: orderIds
8287
8546
  });
8288
8547
  if (this.order) {
8289
- _context81.next = 4;
8548
+ _context83.next = 4;
8290
8549
  break;
8291
8550
  }
8292
8551
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
8293
- return _context81.abrupt("return", {
8552
+ return _context83.abrupt("return", {
8294
8553
  code: 500,
8295
8554
  status: false,
8296
8555
  message: 'Order 模块未注册',
@@ -8298,11 +8557,11 @@ var Server = /*#__PURE__*/function () {
8298
8557
  });
8299
8558
  case 4:
8300
8559
  if ((_this$app21 = this.app) !== null && _this$app21 !== void 0 && _this$app21.request) {
8301
- _context81.next = 7;
8560
+ _context83.next = 7;
8302
8561
  break;
8303
8562
  }
8304
8563
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
8305
- return _context81.abrupt("return", {
8564
+ return _context83.abrupt("return", {
8306
8565
  code: 500,
8307
8566
  status: false,
8308
8567
  message: 'app.request 不可用',
@@ -8325,21 +8584,21 @@ var Server = /*#__PURE__*/function () {
8325
8584
  _iterator13.f();
8326
8585
  }
8327
8586
  fetched = [];
8328
- _context81.prev = 11;
8329
- _context81.next = 14;
8587
+ _context83.prev = 11;
8588
+ _context83.next = 14;
8330
8589
  return this.order.fetchOrdersByHttp(orderIds);
8331
8590
  case 14:
8332
- fetched = _context81.sent;
8333
- _context81.next = 22;
8591
+ fetched = _context83.sent;
8592
+ _context83.next = 22;
8334
8593
  break;
8335
8594
  case 17:
8336
- _context81.prev = 17;
8337
- _context81.t0 = _context81["catch"](11);
8338
- message = _context81.t0 instanceof Error ? _context81.t0.message : String(_context81.t0);
8595
+ _context83.prev = 17;
8596
+ _context83.t0 = _context83["catch"](11);
8597
+ message = _context83.t0 instanceof Error ? _context83.t0.message : String(_context83.t0);
8339
8598
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
8340
8599
  message: message
8341
8600
  });
8342
- return _context81.abrupt("return", {
8601
+ return _context83.abrupt("return", {
8343
8602
  code: 500,
8344
8603
  status: false,
8345
8604
  message: message,
@@ -8349,36 +8608,36 @@ var Server = /*#__PURE__*/function () {
8349
8608
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
8350
8609
  fetchedMap = new Map();
8351
8610
  _iterator14 = _createForOfIteratorHelper(fetched);
8352
- _context81.prev = 24;
8611
+ _context83.prev = 24;
8353
8612
  _iterator14.s();
8354
8613
  case 26:
8355
8614
  if ((_step14 = _iterator14.n()).done) {
8356
- _context81.next = 34;
8615
+ _context83.next = 34;
8357
8616
  break;
8358
8617
  }
8359
8618
  order = _step14.value;
8360
8619
  oid = order === null || order === void 0 ? void 0 : order.order_id;
8361
8620
  if (!(oid === undefined || oid === null)) {
8362
- _context81.next = 31;
8621
+ _context83.next = 31;
8363
8622
  break;
8364
8623
  }
8365
- return _context81.abrupt("continue", 32);
8624
+ return _context83.abrupt("continue", 32);
8366
8625
  case 31:
8367
8626
  fetchedMap.set(String(oid), order);
8368
8627
  case 32:
8369
- _context81.next = 26;
8628
+ _context83.next = 26;
8370
8629
  break;
8371
8630
  case 34:
8372
- _context81.next = 39;
8631
+ _context83.next = 39;
8373
8632
  break;
8374
8633
  case 36:
8375
- _context81.prev = 36;
8376
- _context81.t1 = _context81["catch"](24);
8377
- _iterator14.e(_context81.t1);
8634
+ _context83.prev = 36;
8635
+ _context83.t1 = _context83["catch"](24);
8636
+ _iterator14.e(_context83.t1);
8378
8637
  case 39:
8379
- _context81.prev = 39;
8638
+ _context83.prev = 39;
8380
8639
  _iterator14.f();
8381
- return _context81.finish(39);
8640
+ return _context83.finish(39);
8382
8641
  case 42:
8383
8642
  freshOrders = [];
8384
8643
  succeedIds = [];
@@ -8387,9 +8646,9 @@ var Server = /*#__PURE__*/function () {
8387
8646
  try {
8388
8647
  for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
8389
8648
  _id = _step15.value;
8390
- fresh = fetchedMap.get(_id);
8391
- if (fresh) {
8392
- freshOrders.push(fresh);
8649
+ _fresh3 = fetchedMap.get(_id);
8650
+ if (_fresh3) {
8651
+ freshOrders.push(_fresh3);
8393
8652
  succeedIds.push(_id);
8394
8653
  } else {
8395
8654
  failed.push({
@@ -8404,23 +8663,23 @@ var Server = /*#__PURE__*/function () {
8404
8663
  _iterator15.f();
8405
8664
  }
8406
8665
  if (!(freshOrders.length > 0)) {
8407
- _context81.next = 58;
8666
+ _context83.next = 58;
8408
8667
  break;
8409
8668
  }
8410
- _context81.prev = 48;
8411
- _context81.next = 51;
8669
+ _context83.prev = 48;
8670
+ _context83.next = 51;
8412
8671
  return this.order.upsertOrdersFromRemote(freshOrders);
8413
8672
  case 51:
8414
- _context81.next = 58;
8673
+ _context83.next = 58;
8415
8674
  break;
8416
8675
  case 53:
8417
- _context81.prev = 53;
8418
- _context81.t2 = _context81["catch"](48);
8419
- _message4 = _context81.t2 instanceof Error ? _context81.t2.message : String(_context81.t2);
8676
+ _context83.prev = 53;
8677
+ _context83.t2 = _context83["catch"](48);
8678
+ _message4 = _context83.t2 instanceof Error ? _context83.t2.message : String(_context83.t2);
8420
8679
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
8421
8680
  message: _message4
8422
8681
  });
8423
- return _context81.abrupt("return", {
8682
+ return _context83.abrupt("return", {
8424
8683
  code: 500,
8425
8684
  status: false,
8426
8685
  message: _message4,
@@ -8439,7 +8698,7 @@ var Server = /*#__PURE__*/function () {
8439
8698
  insertedCount: inserted.length,
8440
8699
  failedCount: failed.length
8441
8700
  });
8442
- return _context81.abrupt("return", {
8701
+ return _context83.abrupt("return", {
8443
8702
  code: 200,
8444
8703
  status: true,
8445
8704
  message: '',
@@ -8451,11 +8710,11 @@ var Server = /*#__PURE__*/function () {
8451
8710
  });
8452
8711
  case 62:
8453
8712
  case "end":
8454
- return _context81.stop();
8713
+ return _context83.stop();
8455
8714
  }
8456
- }, _callee81, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8715
+ }, _callee83, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8457
8716
  }));
8458
- function handleUpdateLocalOrdersBatch(_x92) {
8717
+ function handleUpdateLocalOrdersBatch(_x98) {
8459
8718
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
8460
8719
  }
8461
8720
  return handleUpdateLocalOrdersBatch;
@@ -8702,10 +8961,10 @@ var Server = /*#__PURE__*/function () {
8702
8961
  value: function extractBackendErrorResponse(error) {
8703
8962
  var _error$response3,
8704
8963
  _error$response4,
8705
- _this27 = this;
8964
+ _this28 = this;
8706
8965
  var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
8707
8966
  return candidates.find(function (candidate) {
8708
- return _this27.isExplicitBackendErrorResponse(candidate);
8967
+ return _this28.isExplicitBackendErrorResponse(candidate);
8709
8968
  }) || null;
8710
8969
  }
8711
8970
  }, {
@@ -8824,16 +9083,16 @@ var Server = /*#__PURE__*/function () {
8824
9083
  }, {
8825
9084
  key: "recomputeAndNotifyFloorPlanQuery",
8826
9085
  value: (function () {
8827
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82() {
9086
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
8828
9087
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
8829
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8830
- while (1) switch (_context82.prev = _context82.next) {
9088
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9089
+ while (1) switch (_context84.prev = _context84.next) {
8831
9090
  case 0:
8832
9091
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
8833
- _context82.next = 2;
9092
+ _context84.next = 2;
8834
9093
  break;
8835
9094
  }
8836
- return _context82.abrupt("return");
9095
+ return _context84.abrupt("return");
8837
9096
  case 2:
8838
9097
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
8839
9098
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -8863,9 +9122,9 @@ var Server = /*#__PURE__*/function () {
8863
9122
  }
8864
9123
  case 5:
8865
9124
  case "end":
8866
- return _context82.stop();
9125
+ return _context84.stop();
8867
9126
  }
8868
- }, _callee82, this);
9127
+ }, _callee84, this);
8869
9128
  }));
8870
9129
  function recomputeAndNotifyFloorPlanQuery() {
8871
9130
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -8895,20 +9154,20 @@ var Server = /*#__PURE__*/function () {
8895
9154
  * filter 逻辑暂为 mock,仅记录参数
8896
9155
  */
8897
9156
  function () {
8898
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(data) {
9157
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(data) {
8899
9158
  var rawList, result;
8900
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8901
- while (1) switch (_context83.prev = _context83.next) {
9159
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9160
+ while (1) switch (_context85.prev = _context85.next) {
8902
9161
  case 0:
8903
9162
  this.logInfo('computeOrderQueryResult: 开始过滤', {
8904
9163
  data: data
8905
9164
  });
8906
9165
  if (this.order) {
8907
- _context83.next = 4;
9166
+ _context85.next = 4;
8908
9167
  break;
8909
9168
  }
8910
9169
  this.logError('computeOrderQueryResult: Order 模块未注册');
8911
- return _context83.abrupt("return", {
9170
+ return _context85.abrupt("return", {
8912
9171
  code: 500,
8913
9172
  message: 'Order 模块未注册',
8914
9173
  data: {
@@ -8940,7 +9199,7 @@ var Server = /*#__PURE__*/function () {
8940
9199
  skip: result.skip,
8941
9200
  rejected: result.rejected
8942
9201
  });
8943
- return _context83.abrupt("return", {
9202
+ return _context85.abrupt("return", {
8944
9203
  code: 200,
8945
9204
  data: result,
8946
9205
  message: '',
@@ -8948,11 +9207,11 @@ var Server = /*#__PURE__*/function () {
8948
9207
  });
8949
9208
  case 10:
8950
9209
  case "end":
8951
- return _context83.stop();
9210
+ return _context85.stop();
8952
9211
  }
8953
- }, _callee83, this);
9212
+ }, _callee85, this);
8954
9213
  }));
8955
- function computeOrderQueryResult(_x93) {
9214
+ function computeOrderQueryResult(_x99) {
8956
9215
  return _computeOrderQueryResult.apply(this, arguments);
8957
9216
  }
8958
9217
  return computeOrderQueryResult;
@@ -8965,17 +9224,17 @@ var Server = /*#__PURE__*/function () {
8965
9224
  }, {
8966
9225
  key: "computeBookingQueryResult",
8967
9226
  value: (function () {
8968
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(data) {
9227
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(data) {
8969
9228
  var rawOrders, result;
8970
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
8971
- while (1) switch (_context84.prev = _context84.next) {
9229
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9230
+ while (1) switch (_context86.prev = _context86.next) {
8972
9231
  case 0:
8973
9232
  if (this.order) {
8974
- _context84.next = 3;
9233
+ _context86.next = 3;
8975
9234
  break;
8976
9235
  }
8977
9236
  this.logError('computeBookingQueryResult: Order 模块未注册');
8978
- return _context84.abrupt("return", {
9237
+ return _context86.abrupt("return", {
8979
9238
  code: 500,
8980
9239
  message: 'Order 模块未注册',
8981
9240
  data: {
@@ -8994,7 +9253,7 @@ var Server = /*#__PURE__*/function () {
8994
9253
  size: result.size,
8995
9254
  skip: result.skip
8996
9255
  });
8997
- return _context84.abrupt("return", {
9256
+ return _context86.abrupt("return", {
8998
9257
  code: 200,
8999
9258
  data: result,
9000
9259
  message: '',
@@ -9002,11 +9261,11 @@ var Server = /*#__PURE__*/function () {
9002
9261
  });
9003
9262
  case 8:
9004
9263
  case "end":
9005
- return _context84.stop();
9264
+ return _context86.stop();
9006
9265
  }
9007
- }, _callee84, this);
9266
+ }, _callee86, this);
9008
9267
  }));
9009
- function computeBookingQueryResult(_x94) {
9268
+ function computeBookingQueryResult(_x100) {
9010
9269
  return _computeBookingQueryResult.apply(this, arguments);
9011
9270
  }
9012
9271
  return computeBookingQueryResult;
@@ -9065,12 +9324,12 @@ var Server = /*#__PURE__*/function () {
9065
9324
  }, {
9066
9325
  key: "computeProductQueryResult",
9067
9326
  value: (function () {
9068
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(context, options) {
9327
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(context, options) {
9069
9328
  var _menu_list_ids$length3,
9070
- _this28 = this;
9329
+ _this29 = this;
9071
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;
9072
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9073
- while (1) switch (_context85.prev = _context85.next) {
9331
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9332
+ while (1) switch (_context87.prev = _context87.next) {
9074
9333
  case 0:
9075
9334
  tTotal = performance.now();
9076
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 查询额外按商品销售渠道过滤。
@@ -9099,10 +9358,10 @@ var Server = /*#__PURE__*/function () {
9099
9358
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
9100
9359
  startupPreloadTask = this.startupModulePreloadInFlight;
9101
9360
  if (!startupPreloadTask) {
9102
- _context85.next = 9;
9361
+ _context87.next = 9;
9103
9362
  break;
9104
9363
  }
9105
- _context85.next = 9;
9364
+ _context87.next = 9;
9106
9365
  return startupPreloadTask;
9107
9366
  case 9:
9108
9367
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -9114,28 +9373,28 @@ var Server = /*#__PURE__*/function () {
9114
9373
  strategy_context: strategy_context
9115
9374
  });
9116
9375
  if (this.products) {
9117
- _context85.next = 13;
9376
+ _context87.next = 13;
9118
9377
  break;
9119
9378
  }
9120
9379
  this.logError('computeProductQueryResult: Products 模块未注册');
9121
- return _context85.abrupt("return", {
9380
+ return _context87.abrupt("return", {
9122
9381
  message: 'Products 模块未注册',
9123
9382
  data: this.buildProductQueryResultPayload([], 0)
9124
9383
  });
9125
9384
  case 13:
9126
9385
  if (!(queryIds.length > 0)) {
9127
- _context85.next = 25;
9386
+ _context87.next = 25;
9128
9387
  break;
9129
9388
  }
9130
9389
  uniqueIds = Array.from(new Set(queryIds));
9131
9390
  _tPrice = performance.now();
9132
- _context85.next = 18;
9391
+ _context87.next = 18;
9133
9392
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9134
9393
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9135
9394
  productIds: uniqueIds
9136
9395
  });
9137
9396
  case 18:
9138
- productsWithPrice = _context85.sent;
9397
+ productsWithPrice = _context87.sent;
9139
9398
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
9140
9399
  count: productsWithPrice.length,
9141
9400
  ids: uniqueIds
@@ -9153,7 +9412,7 @@ var Server = /*#__PURE__*/function () {
9153
9412
  ids: uniqueIds,
9154
9413
  count: extensionFilteredProducts.length
9155
9414
  });
9156
- return _context85.abrupt("return", {
9415
+ return _context87.abrupt("return", {
9157
9416
  code: 200,
9158
9417
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
9159
9418
  message: '',
@@ -9161,17 +9420,17 @@ var Server = /*#__PURE__*/function () {
9161
9420
  });
9162
9421
  case 25:
9163
9422
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
9164
- _context85.next = 37;
9423
+ _context87.next = 37;
9165
9424
  break;
9166
9425
  }
9167
9426
  pid = Number(product_id);
9168
9427
  _tPrice2 = performance.now();
9169
- _context85.next = 30;
9428
+ _context87.next = 30;
9170
9429
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9171
9430
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9172
9431
  });
9173
9432
  case 30:
9174
- allProductsWithPrice = _context85.sent;
9433
+ allProductsWithPrice = _context87.sent;
9175
9434
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
9176
9435
  count: allProductsWithPrice.length,
9177
9436
  productId: pid
@@ -9189,7 +9448,7 @@ var Server = /*#__PURE__*/function () {
9189
9448
  productId: pid,
9190
9449
  found: !!item
9191
9450
  });
9192
- return _context85.abrupt("return", {
9451
+ return _context87.abrupt("return", {
9193
9452
  code: 200,
9194
9453
  data: item,
9195
9454
  message: item ? '' : '商品不存在或未发布',
@@ -9197,16 +9456,16 @@ var Server = /*#__PURE__*/function () {
9197
9456
  });
9198
9457
  case 37:
9199
9458
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
9200
- _context85.next = 57;
9459
+ _context87.next = 57;
9201
9460
  break;
9202
9461
  }
9203
9462
  _tPrice3 = performance.now();
9204
- _context85.next = 41;
9463
+ _context87.next = 41;
9205
9464
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9206
9465
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9207
9466
  });
9208
9467
  case 41:
9209
- _filteredProducts2 = _context85.sent;
9468
+ _filteredProducts2 = _context87.sent;
9210
9469
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
9211
9470
  count: _filteredProducts2.length,
9212
9471
  extension_type: extension_type
@@ -9243,7 +9502,7 @@ var Server = /*#__PURE__*/function () {
9243
9502
  filteredCount: _filteredProducts2.length,
9244
9503
  extension_type: extension_type
9245
9504
  });
9246
- return _context85.abrupt("return", {
9505
+ return _context87.abrupt("return", {
9247
9506
  code: 200,
9248
9507
  data: this.buildProductQueryResultPayload(_filteredProducts2),
9249
9508
  message: '',
@@ -9251,50 +9510,50 @@ var Server = /*#__PURE__*/function () {
9251
9510
  });
9252
9511
  case 57:
9253
9512
  if (this.menu) {
9254
- _context85.next = 60;
9513
+ _context87.next = 60;
9255
9514
  break;
9256
9515
  }
9257
9516
  this.logError('computeProductQueryResult: Menu 模块未注册');
9258
- return _context85.abrupt("return", {
9517
+ return _context87.abrupt("return", {
9259
9518
  message: 'Menu 模块未注册',
9260
9519
  data: this.buildProductQueryResultPayload([], 0)
9261
9520
  });
9262
9521
  case 60:
9263
9522
  if (this.schedule) {
9264
- _context85.next = 63;
9523
+ _context87.next = 63;
9265
9524
  break;
9266
9525
  }
9267
9526
  this.logError('computeProductQueryResult: Schedule 模块未注册');
9268
- return _context85.abrupt("return", {
9527
+ return _context87.abrupt("return", {
9269
9528
  message: 'Schedule 模块未注册',
9270
9529
  data: this.buildProductQueryResultPayload([], 0)
9271
9530
  });
9272
9531
  case 63:
9273
9532
  activeMenuList = [];
9274
9533
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
9275
- _context85.next = 76;
9534
+ _context87.next = 76;
9276
9535
  break;
9277
9536
  }
9278
9537
  tMenu = performance.now();
9279
9538
  getActiveMenus = function getActiveMenus() {
9280
- return _this28.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9281
- var _this28$schedule;
9282
- return ((_this28$schedule = _this28.schedule) === null || _this28$schedule === void 0 ? void 0 : _this28$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9539
+ return _this29.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9540
+ var _this29$schedule;
9541
+ return ((_this29$schedule = _this29.schedule) === null || _this29$schedule === void 0 ? void 0 : _this29$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9283
9542
  });
9284
9543
  };
9285
9544
  activeMenuList = getActiveMenus();
9286
- _context85.t0 = !activeMenuList.length;
9287
- if (!_context85.t0) {
9288
- _context85.next = 73;
9545
+ _context87.t0 = !activeMenuList.length;
9546
+ if (!_context87.t0) {
9547
+ _context87.next = 73;
9289
9548
  break;
9290
9549
  }
9291
- _context85.next = 72;
9550
+ _context87.next = 72;
9292
9551
  return this.refreshMenuScheduleCacheAfterEmptyResult();
9293
9552
  case 72:
9294
- _context85.t0 = _context85.sent;
9553
+ _context87.t0 = _context87.sent;
9295
9554
  case 73:
9296
- if (!_context85.t0) {
9297
- _context85.next = 75;
9555
+ if (!_context87.t0) {
9556
+ _context87.next = 75;
9298
9557
  break;
9299
9558
  }
9300
9559
  activeMenuList = getActiveMenus();
@@ -9314,22 +9573,22 @@ var Server = /*#__PURE__*/function () {
9314
9573
  });
9315
9574
  tPrice = performance.now();
9316
9575
  if (!(scopedProductIds.length > 0)) {
9317
- _context85.next = 87;
9576
+ _context87.next = 87;
9318
9577
  break;
9319
9578
  }
9320
- _context85.next = 84;
9579
+ _context87.next = 84;
9321
9580
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9322
9581
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9323
9582
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
9324
9583
  });
9325
9584
  case 84:
9326
- _context85.t1 = _context85.sent;
9327
- _context85.next = 88;
9585
+ _context87.t1 = _context87.sent;
9586
+ _context87.next = 88;
9328
9587
  break;
9329
9588
  case 87:
9330
- _context85.t1 = [];
9589
+ _context87.t1 = [];
9331
9590
  case 88:
9332
- filteredProducts = _context85.t1;
9591
+ filteredProducts = _context87.t1;
9333
9592
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
9334
9593
  count: filteredProducts.length,
9335
9594
  scopedProductCount: scopedProductIds.length
@@ -9368,7 +9627,7 @@ var Server = /*#__PURE__*/function () {
9368
9627
  filteredCount: filteredProducts.length,
9369
9628
  activeMenuCount: activeMenuList.length
9370
9629
  });
9371
- return _context85.abrupt("return", {
9630
+ return _context87.abrupt("return", {
9372
9631
  code: 200,
9373
9632
  data: this.buildProductQueryResultPayload(filteredProducts),
9374
9633
  message: '',
@@ -9376,11 +9635,11 @@ var Server = /*#__PURE__*/function () {
9376
9635
  });
9377
9636
  case 104:
9378
9637
  case "end":
9379
- return _context85.stop();
9638
+ return _context87.stop();
9380
9639
  }
9381
- }, _callee85, this);
9640
+ }, _callee87, this);
9382
9641
  }));
9383
- function computeProductQueryResult(_x95, _x96) {
9642
+ function computeProductQueryResult(_x101, _x102) {
9384
9643
  return _computeProductQueryResult.apply(this, arguments);
9385
9644
  }
9386
9645
  return computeProductQueryResult;
@@ -9418,74 +9677,74 @@ var Server = /*#__PURE__*/function () {
9418
9677
  }, {
9419
9678
  key: "recomputeAndNotifyProductQuery",
9420
9679
  value: (function () {
9421
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(options) {
9680
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(options) {
9422
9681
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
9423
- return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9424
- while (1) switch (_context86.prev = _context86.next) {
9682
+ return _regeneratorRuntime().wrap(function _callee88$(_context88) {
9683
+ while (1) switch (_context88.prev = _context88.next) {
9425
9684
  case 0:
9426
9685
  if (!(this.productQuerySubscribers.size === 0)) {
9427
- _context86.next = 2;
9686
+ _context88.next = 2;
9428
9687
  break;
9429
9688
  }
9430
- return _context86.abrupt("return");
9689
+ return _context88.abrupt("return");
9431
9690
  case 2:
9432
9691
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
9433
9692
  subscriberCount: this.productQuerySubscribers.size,
9434
9693
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9435
9694
  });
9436
9695
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
9437
- _context86.prev = 4;
9696
+ _context88.prev = 4;
9438
9697
  _iterator18.s();
9439
9698
  case 6:
9440
9699
  if ((_step18 = _iterator18.n()).done) {
9441
- _context86.next = 23;
9700
+ _context88.next = 23;
9442
9701
  break;
9443
9702
  }
9444
9703
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
9445
- _context86.prev = 8;
9446
- _context86.next = 11;
9704
+ _context88.prev = 8;
9705
+ _context88.next = 11;
9447
9706
  return this.computeProductQueryResult(subscriber.context, {
9448
9707
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9449
9708
  });
9450
9709
  case 11:
9451
- result = _context86.sent;
9452
- _context86.next = 14;
9710
+ result = _context88.sent;
9711
+ _context88.next = 14;
9453
9712
  return subscriber.callback(result);
9454
9713
  case 14:
9455
9714
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
9456
9715
  subscriberId: subscriberId
9457
9716
  });
9458
- _context86.next = 21;
9717
+ _context88.next = 21;
9459
9718
  break;
9460
9719
  case 17:
9461
- _context86.prev = 17;
9462
- _context86.t0 = _context86["catch"](8);
9463
- errorMessage = _context86.t0 instanceof Error ? _context86.t0.message : String(_context86.t0);
9720
+ _context88.prev = 17;
9721
+ _context88.t0 = _context88["catch"](8);
9722
+ errorMessage = _context88.t0 instanceof Error ? _context88.t0.message : String(_context88.t0);
9464
9723
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
9465
9724
  subscriberId: subscriberId,
9466
9725
  error: errorMessage
9467
9726
  });
9468
9727
  case 21:
9469
- _context86.next = 6;
9728
+ _context88.next = 6;
9470
9729
  break;
9471
9730
  case 23:
9472
- _context86.next = 28;
9731
+ _context88.next = 28;
9473
9732
  break;
9474
9733
  case 25:
9475
- _context86.prev = 25;
9476
- _context86.t1 = _context86["catch"](4);
9477
- _iterator18.e(_context86.t1);
9734
+ _context88.prev = 25;
9735
+ _context88.t1 = _context88["catch"](4);
9736
+ _iterator18.e(_context88.t1);
9478
9737
  case 28:
9479
- _context86.prev = 28;
9738
+ _context88.prev = 28;
9480
9739
  _iterator18.f();
9481
- return _context86.finish(28);
9740
+ return _context88.finish(28);
9482
9741
  case 31:
9483
9742
  case "end":
9484
- return _context86.stop();
9743
+ return _context88.stop();
9485
9744
  }
9486
- }, _callee86, this, [[4, 25, 28, 31], [8, 17]]);
9745
+ }, _callee88, this, [[4, 25, 28, 31], [8, 17]]);
9487
9746
  }));
9488
- function recomputeAndNotifyProductQuery(_x97) {
9747
+ function recomputeAndNotifyProductQuery(_x103) {
9489
9748
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
9490
9749
  }
9491
9750
  return recomputeAndNotifyProductQuery;
@@ -9497,16 +9756,16 @@ var Server = /*#__PURE__*/function () {
9497
9756
  }, {
9498
9757
  key: "recomputeAndNotifyOrderQuery",
9499
9758
  value: (function () {
9500
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87() {
9759
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89() {
9501
9760
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
9502
- return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9503
- while (1) switch (_context87.prev = _context87.next) {
9761
+ return _regeneratorRuntime().wrap(function _callee89$(_context89) {
9762
+ while (1) switch (_context89.prev = _context89.next) {
9504
9763
  case 0:
9505
9764
  if (!(this.orderQuerySubscribers.size === 0)) {
9506
- _context87.next = 2;
9765
+ _context89.next = 2;
9507
9766
  break;
9508
9767
  }
9509
- return _context87.abrupt("return");
9768
+ return _context89.abrupt("return");
9510
9769
  case 2:
9511
9770
  notifyStartAt = Date.now();
9512
9771
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -9514,20 +9773,20 @@ var Server = /*#__PURE__*/function () {
9514
9773
  notifyStartAt: new Date(notifyStartAt).toISOString()
9515
9774
  });
9516
9775
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
9517
- _context87.prev = 5;
9776
+ _context89.prev = 5;
9518
9777
  _iterator19.s();
9519
9778
  case 7:
9520
9779
  if ((_step19 = _iterator19.n()).done) {
9521
- _context87.next = 27;
9780
+ _context89.next = 27;
9522
9781
  break;
9523
9782
  }
9524
9783
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
9525
- _context87.prev = 9;
9784
+ _context89.prev = 9;
9526
9785
  computeStartAt = Date.now();
9527
- _context87.next = 13;
9786
+ _context89.next = 13;
9528
9787
  return this.computeOrderQueryResult(subscriber.context);
9529
9788
  case 13:
9530
- result = _context87.sent;
9789
+ result = _context89.sent;
9531
9790
  computeEndAt = Date.now();
9532
9791
  callbackStartAt = Date.now();
9533
9792
  subscriber.callback(result);
@@ -9538,30 +9797,30 @@ var Server = /*#__PURE__*/function () {
9538
9797
  callbackDurationMs: callbackEndAt - callbackStartAt,
9539
9798
  totalDurationMs: callbackEndAt - computeStartAt
9540
9799
  });
9541
- _context87.next = 25;
9800
+ _context89.next = 25;
9542
9801
  break;
9543
9802
  case 21:
9544
- _context87.prev = 21;
9545
- _context87.t0 = _context87["catch"](9);
9546
- errorMessage = _context87.t0 instanceof Error ? _context87.t0.message : String(_context87.t0);
9803
+ _context89.prev = 21;
9804
+ _context89.t0 = _context89["catch"](9);
9805
+ errorMessage = _context89.t0 instanceof Error ? _context89.t0.message : String(_context89.t0);
9547
9806
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
9548
9807
  subscriberId: subscriberId,
9549
9808
  error: errorMessage
9550
9809
  });
9551
9810
  case 25:
9552
- _context87.next = 7;
9811
+ _context89.next = 7;
9553
9812
  break;
9554
9813
  case 27:
9555
- _context87.next = 32;
9814
+ _context89.next = 32;
9556
9815
  break;
9557
9816
  case 29:
9558
- _context87.prev = 29;
9559
- _context87.t1 = _context87["catch"](5);
9560
- _iterator19.e(_context87.t1);
9817
+ _context89.prev = 29;
9818
+ _context89.t1 = _context89["catch"](5);
9819
+ _iterator19.e(_context89.t1);
9561
9820
  case 32:
9562
- _context87.prev = 32;
9821
+ _context89.prev = 32;
9563
9822
  _iterator19.f();
9564
- return _context87.finish(32);
9823
+ return _context89.finish(32);
9565
9824
  case 35:
9566
9825
  notifyEndAt = Date.now();
9567
9826
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -9570,9 +9829,9 @@ var Server = /*#__PURE__*/function () {
9570
9829
  });
9571
9830
  case 37:
9572
9831
  case "end":
9573
- return _context87.stop();
9832
+ return _context89.stop();
9574
9833
  }
9575
- }, _callee87, this, [[5, 29, 32, 35], [9, 21]]);
9834
+ }, _callee89, this, [[5, 29, 32, 35], [9, 21]]);
9576
9835
  }));
9577
9836
  function recomputeAndNotifyOrderQuery() {
9578
9837
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -9590,7 +9849,7 @@ var Server = /*#__PURE__*/function () {
9590
9849
  }, {
9591
9850
  key: "notifySalesSearchSubscribers",
9592
9851
  value: function notifySalesSearchSubscribers(payload) {
9593
- var _this29 = this;
9852
+ var _this30 = this;
9594
9853
  if (this.salesSearchSubscribers.size === 0) return;
9595
9854
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
9596
9855
  if (changedOrders.length === 0) {
@@ -9608,21 +9867,21 @@ var Server = /*#__PURE__*/function () {
9608
9867
  subscriber = _step20$value[1];
9609
9868
  try {
9610
9869
  var changedVisibleOrders = changedOrders.filter(function (order) {
9611
- var orderId = _this29.getSalesSearchOrderId(order);
9870
+ var orderId = _this30.getSalesSearchOrderId(order);
9612
9871
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
9613
9872
  });
9614
9873
  if (changedVisibleOrders.length === 0) {
9615
9874
  return 1; // continue
9616
9875
  }
9617
- subscriber.callback(_this29.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9618
- _this29.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9876
+ subscriber.callback(_this30.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9877
+ _this30.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9619
9878
  subscriberId: subscriberId,
9620
9879
  kind: subscriber.kind,
9621
9880
  count: changedVisibleOrders.length
9622
9881
  });
9623
9882
  } catch (error) {
9624
9883
  var errorMessage = error instanceof Error ? error.message : String(error);
9625
- _this29.logError('notifySalesSearchSubscribers: 推送失败', {
9884
+ _this30.logError('notifySalesSearchSubscribers: 推送失败', {
9626
9885
  subscriberId: subscriberId,
9627
9886
  error: errorMessage
9628
9887
  });
@@ -9713,67 +9972,67 @@ var Server = /*#__PURE__*/function () {
9713
9972
  }, {
9714
9973
  key: "recomputeAndNotifyBookingQuery",
9715
9974
  value: (function () {
9716
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88() {
9975
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee90() {
9717
9976
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
9718
- return _regeneratorRuntime().wrap(function _callee88$(_context88) {
9719
- while (1) switch (_context88.prev = _context88.next) {
9977
+ return _regeneratorRuntime().wrap(function _callee90$(_context90) {
9978
+ while (1) switch (_context90.prev = _context90.next) {
9720
9979
  case 0:
9721
9980
  if (!(this.bookingQuerySubscribers.size === 0)) {
9722
- _context88.next = 2;
9981
+ _context90.next = 2;
9723
9982
  break;
9724
9983
  }
9725
- return _context88.abrupt("return");
9984
+ return _context90.abrupt("return");
9726
9985
  case 2:
9727
9986
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
9728
9987
  subscriberCount: this.bookingQuerySubscribers.size
9729
9988
  });
9730
9989
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
9731
- _context88.prev = 4;
9990
+ _context90.prev = 4;
9732
9991
  _iterator21.s();
9733
9992
  case 6:
9734
9993
  if ((_step21 = _iterator21.n()).done) {
9735
- _context88.next = 22;
9994
+ _context90.next = 22;
9736
9995
  break;
9737
9996
  }
9738
9997
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
9739
- _context88.prev = 8;
9740
- _context88.next = 11;
9998
+ _context90.prev = 8;
9999
+ _context90.next = 11;
9741
10000
  return this.computeBookingQueryResult(subscriber.context);
9742
10001
  case 11:
9743
- result = _context88.sent;
10002
+ result = _context90.sent;
9744
10003
  subscriber.callback(result);
9745
10004
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
9746
10005
  subscriberId: subscriberId
9747
10006
  });
9748
- _context88.next = 20;
10007
+ _context90.next = 20;
9749
10008
  break;
9750
10009
  case 16:
9751
- _context88.prev = 16;
9752
- _context88.t0 = _context88["catch"](8);
9753
- errorMessage = _context88.t0 instanceof Error ? _context88.t0.message : String(_context88.t0);
10010
+ _context90.prev = 16;
10011
+ _context90.t0 = _context90["catch"](8);
10012
+ errorMessage = _context90.t0 instanceof Error ? _context90.t0.message : String(_context90.t0);
9754
10013
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
9755
10014
  subscriberId: subscriberId,
9756
10015
  error: errorMessage
9757
10016
  });
9758
10017
  case 20:
9759
- _context88.next = 6;
10018
+ _context90.next = 6;
9760
10019
  break;
9761
10020
  case 22:
9762
- _context88.next = 27;
10021
+ _context90.next = 27;
9763
10022
  break;
9764
10023
  case 24:
9765
- _context88.prev = 24;
9766
- _context88.t1 = _context88["catch"](4);
9767
- _iterator21.e(_context88.t1);
10024
+ _context90.prev = 24;
10025
+ _context90.t1 = _context90["catch"](4);
10026
+ _iterator21.e(_context90.t1);
9768
10027
  case 27:
9769
- _context88.prev = 27;
10028
+ _context90.prev = 27;
9770
10029
  _iterator21.f();
9771
- return _context88.finish(27);
10030
+ return _context90.finish(27);
9772
10031
  case 30:
9773
10032
  case "end":
9774
- return _context88.stop();
10033
+ return _context90.stop();
9775
10034
  }
9776
- }, _callee88, this, [[4, 24, 27, 30], [8, 16]]);
10035
+ }, _callee90, this, [[4, 24, 27, 30], [8, 16]]);
9777
10036
  }));
9778
10037
  function recomputeAndNotifyBookingQuery() {
9779
10038
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);