@pisell/pisellos 2.3.220 → 2.3.221

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.
@@ -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,23 +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
- });
1489
- 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:
1490
1480
  rebuiltOrder = _context22.sent;
1491
1481
  smallTicketData = (_payment_info = rebuiltOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data;
1492
1482
  if (hasSmallTicketData(smallTicketData)) {
1493
- _context22.next = 26;
1483
+ _context22.next = 24;
1494
1484
  break;
1495
1485
  }
1496
1486
  return _context22.abrupt("return", {
@@ -1501,7 +1491,7 @@ var Server = /*#__PURE__*/function () {
1501
1491
  small_ticket_data: null
1502
1492
  }
1503
1493
  });
1504
- case 26:
1494
+ case 24:
1505
1495
  return _context22.abrupt("return", {
1506
1496
  code: 200,
1507
1497
  status: true,
@@ -1518,8 +1508,8 @@ var Server = /*#__PURE__*/function () {
1518
1508
  })
1519
1509
  }
1520
1510
  });
1521
- case 29:
1522
- _context22.prev = 29;
1511
+ case 27:
1512
+ _context22.prev = 27;
1523
1513
  _context22.t0 = _context22["catch"](7);
1524
1514
  message = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1525
1515
  _this.logError('handleLocalOrderReceiptSnapshot: 生成失败', {
@@ -1534,11 +1524,11 @@ var Server = /*#__PURE__*/function () {
1534
1524
  small_ticket_data: null
1535
1525
  }
1536
1526
  });
1537
- case 34:
1527
+ case 32:
1538
1528
  case "end":
1539
1529
  return _context22.stop();
1540
1530
  }
1541
- }, _callee22, null, [[7, 29]]);
1531
+ }, _callee22, null, [[7, 27]]);
1542
1532
  }));
1543
1533
  return function (_x21) {
1544
1534
  return _ref52.apply(this, arguments);
@@ -3759,6 +3749,20 @@ var Server = /*#__PURE__*/function () {
3759
3749
  method: 'post',
3760
3750
  path: '/shop/local/print-order',
3761
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
+ }
3762
3766
  }, {
3763
3767
  method: 'post',
3764
3768
  path: '/shop/local/order-receipt-snapshot',
@@ -3779,13 +3783,13 @@ var Server = /*#__PURE__*/function () {
3779
3783
  method: 'post',
3780
3784
  path: '/shop/local/orderPaymentReadiness',
3781
3785
  handler: function () {
3782
- var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref65) {
3786
+ var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref67) {
3783
3787
  var _this9$order;
3784
3788
  var data;
3785
3789
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3786
3790
  while (1) switch (_context44.prev = _context44.next) {
3787
3791
  case 0:
3788
- data = _ref65.data;
3792
+ data = _ref67.data;
3789
3793
  _context44.next = 3;
3790
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);
3791
3795
  case 3:
@@ -4191,11 +4195,11 @@ var Server = /*#__PURE__*/function () {
4191
4195
  */
4192
4196
  }, {
4193
4197
  key: "syncProductQueryScheduleTimers",
4194
- value: function syncProductQueryScheduleTimers(_ref67) {
4198
+ value: function syncProductQueryScheduleTimers(_ref69) {
4195
4199
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
4196
- var subscriberId = _ref67.subscriberId,
4197
- menu_list_ids = _ref67.menu_list_ids,
4198
- strategy_context = _ref67.strategy_context;
4200
+ var subscriberId = _ref69.subscriberId,
4201
+ menu_list_ids = _ref69.menu_list_ids,
4202
+ strategy_context = _ref69.strategy_context;
4199
4203
  this.clearSubscriberScheduleTimers(subscriberId);
4200
4204
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
4201
4205
  return;
@@ -4372,7 +4376,7 @@ var Server = /*#__PURE__*/function () {
4372
4376
  */
4373
4377
  function () {
4374
4378
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(kind, backendPath, data, config) {
4375
- 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;
4376
4380
  return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4377
4381
  while (1) switch (_context52.prev = _context52.next) {
4378
4382
  case 0:
@@ -4381,7 +4385,7 @@ var Server = /*#__PURE__*/function () {
4381
4385
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
4382
4386
  case 3:
4383
4387
  result = _context52.sent;
4384
- _ref68 = config || {}, callback = _ref68.callback, subscriberId = _ref68.subscriberId, resetVisibleOrderIds = _ref68.resetVisibleOrderIds;
4388
+ _ref70 = config || {}, callback = _ref70.callback, subscriberId = _ref70.subscriberId, resetVisibleOrderIds = _ref70.resetVisibleOrderIds;
4385
4389
  if (subscriberId && typeof callback === 'function') {
4386
4390
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
4387
4391
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -6477,17 +6481,231 @@ var Server = /*#__PURE__*/function () {
6477
6481
  }, {
6478
6482
  key: "mergeLocalPrintOrderInput",
6479
6483
  value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
6480
- var _ref72, _localOrder$order_id, _ref73, _external_sale_number4;
6481
- var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref70) {
6482
- var _ref71 = _slicedToArray(_ref70, 2),
6483
- value = _ref71[1];
6484
+ var _ref74, _localOrder$order_id, _ref75, _external_sale_number4;
6485
+ var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref72) {
6486
+ var _ref73 = _slicedToArray(_ref72, 2),
6487
+ value = _ref73[1];
6484
6488
  return value !== undefined;
6485
6489
  }));
6486
6490
  return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
6487
- order_id: (_ref72 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref72 !== void 0 ? _ref72 : definedInput.orderId,
6488
- external_sale_number: (_ref73 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref73 !== void 0 ? _ref73 : definedInput.externalSaleNumber
6491
+ order_id: (_ref74 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref74 !== void 0 ? _ref74 : definedInput.orderId,
6492
+ external_sale_number: (_ref75 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref75 !== void 0 ? _ref75 : definedInput.externalSaleNumber
6489
6493
  });
6490
6494
  }
6495
+ }, {
6496
+ key: "loadCloudInvoiceOrder",
6497
+ value: function () {
6498
+ var _loadCloudInvoiceOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(orderId, shopId, assertCurrentShop) {
6499
+ var hasReceiptDetail, local, result, saved;
6500
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6501
+ while (1) switch (_context66.prev = _context66.next) {
6502
+ case 0:
6503
+ if (this.order) {
6504
+ _context66.next = 2;
6505
+ break;
6506
+ }
6507
+ throw new Error('Cloud invoice order service is unavailable');
6508
+ case 2:
6509
+ hasReceiptDetail = function hasReceiptDetail(order) {
6510
+ var _order$summary, _order$summary2;
6511
+ // Use the same amount fields as the receipt builder, including historical
6512
+ // top-level amounts. Zero is a valid total; a missing total in a list row is not.
6513
+ 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) {
6514
+ return value != null && value !== '';
6515
+ });
6516
+ 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));
6517
+ };
6518
+ _context66.next = 5;
6519
+ return this.order.getLocalOrderByLookup(orderId, {
6520
+ exactOrderId: true
6521
+ });
6522
+ case 5:
6523
+ local = _context66.sent;
6524
+ assertCurrentShop();
6525
+ if (!(local && String(local.order_id) === orderId)) {
6526
+ _context66.next = 12;
6527
+ break;
6528
+ }
6529
+ if (!(local.shop_id != null && String(local.shop_id) !== shopId)) {
6530
+ _context66.next = 10;
6531
+ break;
6532
+ }
6533
+ throw new Error('Cloud invoice order belongs to another shop');
6534
+ case 10:
6535
+ if (!(String(local.shop_id) === shopId && hasReceiptDetail(local))) {
6536
+ _context66.next = 12;
6537
+ break;
6538
+ }
6539
+ return _context66.abrupt("return", local);
6540
+ case 12:
6541
+ _context66.next = 14;
6542
+ return this.fetchAndPersistSalesOrderByLookup(orderId, {
6543
+ with: ['all']
6544
+ }, 'cloudOrderInvoice', undefined, function (fresh) {
6545
+ assertCurrentShop();
6546
+ if (String(fresh.order_id) !== orderId || fresh.shop_id != null && String(fresh.shop_id) !== shopId || !hasReceiptDetail(fresh)) {
6547
+ throw new Error('Cloud invoice order identity or detail is invalid');
6548
+ }
6549
+ // Some older shop-authenticated detail responses omit shop_id.
6550
+ return fresh.shop_id == null ? _objectSpread(_objectSpread({}, fresh), {}, {
6551
+ shop_id: Number(shopId)
6552
+ }) : fresh;
6553
+ });
6554
+ case 14:
6555
+ result = _context66.sent;
6556
+ assertCurrentShop();
6557
+ saved = result.order;
6558
+ if (!(!saved || String(saved.order_id) !== orderId || String(saved.shop_id) !== shopId || !hasReceiptDetail(saved))) {
6559
+ _context66.next = 19;
6560
+ break;
6561
+ }
6562
+ throw new Error(result.message || 'Cloud invoice order detail is unavailable');
6563
+ case 19:
6564
+ return _context66.abrupt("return", saved);
6565
+ case 20:
6566
+ case "end":
6567
+ return _context66.stop();
6568
+ }
6569
+ }, _callee66, this);
6570
+ }));
6571
+ function loadCloudInvoiceOrder(_x71, _x72, _x73) {
6572
+ return _loadCloudInvoiceOrder.apply(this, arguments);
6573
+ }
6574
+ return loadCloudInvoiceOrder;
6575
+ }()
6576
+ }, {
6577
+ key: "handleCloudOrderInvoice",
6578
+ value: function () {
6579
+ var _handleCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(input, submit) {
6580
+ var _this17 = this;
6581
+ var orderId, _this$getAppData, _this$getAppData2, _input$template_setti, _receipt$payment_info, shopId, tenantId, assertCurrentShop, order, businessCode, settings, receipt, smallTicketData, deviceTask, deviceId, message;
6582
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6583
+ while (1) switch (_context67.prev = _context67.next) {
6584
+ case 0:
6585
+ 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) : '';
6586
+ if (/^[1-9]\d*$/.test(orderId)) {
6587
+ _context67.next = 3;
6588
+ break;
6589
+ }
6590
+ return _context67.abrupt("return", {
6591
+ code: 400,
6592
+ status: false,
6593
+ message: 'Invalid cloud invoice order ID',
6594
+ data: null
6595
+ });
6596
+ case 3:
6597
+ _context67.prev = 3;
6598
+ shopId = String((_this$getAppData = this.getAppData('shop_id')) !== null && _this$getAppData !== void 0 ? _this$getAppData : '');
6599
+ tenantId = String((_this$getAppData2 = this.getAppData('tenant_id')) !== null && _this$getAppData2 !== void 0 ? _this$getAppData2 : '');
6600
+ if (!(!/^[1-9]\d*$/.test(shopId) || !Number.isSafeInteger(Number(shopId)))) {
6601
+ _context67.next = 8;
6602
+ break;
6603
+ }
6604
+ throw new Error('Cloud invoice shop is unavailable');
6605
+ case 8:
6606
+ assertCurrentShop = function assertCurrentShop() {
6607
+ var _this17$getAppData, _this17$getAppData2;
6608
+ if (String((_this17$getAppData = _this17.getAppData('shop_id')) !== null && _this17$getAppData !== void 0 ? _this17$getAppData : '') !== shopId || String((_this17$getAppData2 = _this17.getAppData('tenant_id')) !== null && _this17$getAppData2 !== void 0 ? _this17$getAppData2 : '') !== tenantId) {
6609
+ throw new Error('Cloud invoice shop context changed');
6610
+ }
6611
+ };
6612
+ _context67.next = 11;
6613
+ return this.loadCloudInvoiceOrder(orderId, shopId, assertCurrentShop);
6614
+ case 11:
6615
+ order = _context67.sent;
6616
+ businessCode = order.business_code.trim();
6617
+ if (submit) {
6618
+ _context67.next = 15;
6619
+ break;
6620
+ }
6621
+ return _context67.abrupt("return", {
6622
+ code: 200,
6623
+ status: true,
6624
+ message: '',
6625
+ data: {
6626
+ business_code: businessCode
6627
+ }
6628
+ });
6629
+ case 15:
6630
+ 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))) {
6631
+ _context67.next = 17;
6632
+ break;
6633
+ }
6634
+ throw new Error('Cloud invoice template is missing or belongs to another business');
6635
+ case 17:
6636
+ settings = this.normalizePrintInvoiceTemplateSettings(input.template_settings);
6637
+ _context67.next = 20;
6638
+ return this.rebuildOrderReceipt(order, settings);
6639
+ case 20:
6640
+ receipt = _context67.sent;
6641
+ smallTicketData = (_receipt$payment_info = receipt.payment_info) === null || _receipt$payment_info === void 0 ? void 0 : _receipt$payment_info.small_ticket_data;
6642
+ if (hasSmallTicketData(smallTicketData)) {
6643
+ _context67.next = 24;
6644
+ break;
6645
+ }
6646
+ throw new Error('Cloud invoice snapshot is unavailable');
6647
+ case 24:
6648
+ deviceTask = this.getDeviceTaskPlugin();
6649
+ if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6650
+ _context67.next = 27;
6651
+ break;
6652
+ }
6653
+ throw new Error('Print task service is unavailable');
6654
+ case 27:
6655
+ _context67.next = 29;
6656
+ return this.getShortNumberOrDeviceId();
6657
+ case 29:
6658
+ deviceId = _context67.sent;
6659
+ assertCurrentShop();
6660
+ _context67.next = 33;
6661
+ return deviceTask.dispatch({
6662
+ action: 'print_all',
6663
+ device_id: deviceId,
6664
+ name: 'PRINT_V1',
6665
+ source: 'server',
6666
+ source_type: 'order',
6667
+ source_id: order.order_id,
6668
+ payload: {
6669
+ type: '0',
6670
+ template_settings: settings,
6671
+ data: {
6672
+ order_id: order.order_id,
6673
+ small_ticket_data: smallTicketData
6674
+ }
6675
+ }
6676
+ });
6677
+ case 33:
6678
+ return _context67.abrupt("return", {
6679
+ code: 200,
6680
+ status: true,
6681
+ message: '',
6682
+ data: null
6683
+ });
6684
+ case 36:
6685
+ _context67.prev = 36;
6686
+ _context67.t0 = _context67["catch"](3);
6687
+ message = this.getUnknownErrorMessage(_context67.t0);
6688
+ this.logWarning('Cloud invoice request failed', {
6689
+ orderId: orderId,
6690
+ message: message
6691
+ });
6692
+ return _context67.abrupt("return", {
6693
+ code: 500,
6694
+ status: false,
6695
+ message: message,
6696
+ data: null
6697
+ });
6698
+ case 41:
6699
+ case "end":
6700
+ return _context67.stop();
6701
+ }
6702
+ }, _callee67, this, [[3, 36]]);
6703
+ }));
6704
+ function handleCloudOrderInvoice(_x74, _x75) {
6705
+ return _handleCloudOrderInvoice.apply(this, arguments);
6706
+ }
6707
+ return handleCloudOrderInvoice;
6708
+ }()
6491
6709
  }, {
6492
6710
  key: "normalizeRequestedReceiptLocales",
6493
6711
  value: function normalizeRequestedReceiptLocales(value) {
@@ -6498,6 +6716,21 @@ var Server = /*#__PURE__*/function () {
6498
6716
  return locale.trim();
6499
6717
  }).filter(Boolean)));
6500
6718
  }
6719
+ }, {
6720
+ key: "rebuildOrderReceipt",
6721
+ value: function rebuildOrderReceipt(order, templateSettings, locales) {
6722
+ var paymentInfo = _objectSpread({}, order.payment_info);
6723
+ delete paymentInfo.small_ticket_data;
6724
+ return this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, order), {}, {
6725
+ small_ticket_data_flag: 1,
6726
+ payment_info: paymentInfo
6727
+ }), {
6728
+ locales: locales,
6729
+ invoiceTemplateSettings: templateSettings,
6730
+ applyTemplateVisibility: true,
6731
+ includeReceiptKeys: templateSettings !== undefined
6732
+ });
6733
+ }
6501
6734
  }, {
6502
6735
  key: "resolveMachinecodeBatchMetadataLookup",
6503
6736
  value: function resolveMachinecodeBatchMetadataLookup(data) {
@@ -6509,57 +6742,57 @@ var Server = /*#__PURE__*/function () {
6509
6742
  }, {
6510
6743
  key: "syncMachinecodeRedeemStatusToLocalOrder",
6511
6744
  value: function () {
6512
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(data, ids, status) {
6745
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(data, ids, status) {
6513
6746
  var _this$order5, _data$order_id2;
6514
6747
  var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
6515
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6516
- while (1) switch (_context66.prev = _context66.next) {
6748
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6749
+ while (1) switch (_context68.prev = _context68.next) {
6517
6750
  case 0:
6518
6751
  title = 'handleMachinecodeBatchMetadata';
6519
6752
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
6520
6753
  if (!(lookup === undefined)) {
6521
- _context66.next = 5;
6754
+ _context68.next = 5;
6522
6755
  break;
6523
6756
  }
6524
6757
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6525
6758
  batchSize: ids.length,
6526
6759
  status: status
6527
6760
  });
6528
- return _context66.abrupt("return");
6761
+ return _context68.abrupt("return");
6529
6762
  case 5:
6530
6763
  if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
6531
- _context66.next = 8;
6764
+ _context68.next = 8;
6532
6765
  break;
6533
6766
  }
6534
6767
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6535
6768
  lookup: lookup,
6536
6769
  status: status
6537
6770
  });
6538
- return _context66.abrupt("return");
6771
+ return _context68.abrupt("return");
6539
6772
  case 8:
6540
- _context66.next = 10;
6773
+ _context68.next = 10;
6541
6774
  return this.order.getLocalOrderByLookup(lookup);
6542
6775
  case 10:
6543
- localOrder = _context66.sent;
6776
+ localOrder = _context68.sent;
6544
6777
  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;
6545
6778
  if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
6546
- _context66.next = 16;
6779
+ _context68.next = 16;
6547
6780
  break;
6548
6781
  }
6549
- _context66.next = 15;
6782
+ _context68.next = 15;
6550
6783
  return this.order.getLocalOrderByLookup(orderId);
6551
6784
  case 15:
6552
- localOrder = _context66.sent;
6785
+ localOrder = _context68.sent;
6553
6786
  case 16:
6554
6787
  if (localOrder) {
6555
- _context66.next = 19;
6788
+ _context68.next = 19;
6556
6789
  break;
6557
6790
  }
6558
6791
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6559
6792
  lookup: lookup,
6560
6793
  status: status
6561
6794
  });
6562
- return _context66.abrupt("return");
6795
+ return _context68.abrupt("return");
6563
6796
  case 19:
6564
6797
  voucherIdSet = new Set(ids.filter(function (id) {
6565
6798
  return id !== undefined && id !== null && id !== '';
@@ -6567,14 +6800,14 @@ var Server = /*#__PURE__*/function () {
6567
6800
  return String(id);
6568
6801
  }));
6569
6802
  if (!(voucherIdSet.size === 0)) {
6570
- _context66.next = 23;
6803
+ _context68.next = 23;
6571
6804
  break;
6572
6805
  }
6573
6806
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6574
6807
  lookup: lookup,
6575
6808
  status: status
6576
6809
  });
6577
- return _context66.abrupt("return");
6810
+ return _context68.abrupt("return");
6578
6811
  case 23:
6579
6812
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
6580
6813
  hasUpdatedVoucher = false;
@@ -6588,7 +6821,7 @@ var Server = /*#__PURE__*/function () {
6588
6821
  });
6589
6822
  });
6590
6823
  if (hasUpdatedVoucher) {
6591
- _context66.next = 29;
6824
+ _context68.next = 29;
6592
6825
  break;
6593
6826
  }
6594
6827
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -6596,13 +6829,13 @@ var Server = /*#__PURE__*/function () {
6596
6829
  voucher_ids: Array.from(voucherIdSet),
6597
6830
  status: status
6598
6831
  });
6599
- return _context66.abrupt("return");
6832
+ return _context68.abrupt("return");
6600
6833
  case 29:
6601
6834
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
6602
- _context66.next = 34;
6835
+ _context68.next = 34;
6603
6836
  break;
6604
6837
  }
6605
- _context66.next = 32;
6838
+ _context68.next = 32;
6606
6839
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
6607
6840
  vouchers: nextVouchers
6608
6841
  }));
@@ -6612,13 +6845,13 @@ var Server = /*#__PURE__*/function () {
6612
6845
  updatedCount: voucherIdSet.size,
6613
6846
  status: status
6614
6847
  });
6615
- return _context66.abrupt("return");
6848
+ return _context68.abrupt("return");
6616
6849
  case 34:
6617
6850
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
6618
- _context66.next = 39;
6851
+ _context68.next = 39;
6619
6852
  break;
6620
6853
  }
6621
- _context66.next = 37;
6854
+ _context68.next = 37;
6622
6855
  return this.order.markOrderSyncedByExternalSaleNumber({
6623
6856
  externalSaleNumber: data.external_sale_number,
6624
6857
  patch: {
@@ -6631,7 +6864,7 @@ var Server = /*#__PURE__*/function () {
6631
6864
  updatedCount: voucherIdSet.size,
6632
6865
  status: status
6633
6866
  });
6634
- return _context66.abrupt("return");
6867
+ return _context68.abrupt("return");
6635
6868
  case 39:
6636
6869
  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"), {
6637
6870
  lookup: lookup,
@@ -6639,11 +6872,11 @@ var Server = /*#__PURE__*/function () {
6639
6872
  });
6640
6873
  case 40:
6641
6874
  case "end":
6642
- return _context66.stop();
6875
+ return _context68.stop();
6643
6876
  }
6644
- }, _callee66, this);
6877
+ }, _callee68, this);
6645
6878
  }));
6646
- function syncMachinecodeRedeemStatusToLocalOrder(_x71, _x72, _x73) {
6879
+ function syncMachinecodeRedeemStatusToLocalOrder(_x76, _x77, _x78) {
6647
6880
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
6648
6881
  }
6649
6882
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -6651,30 +6884,30 @@ var Server = /*#__PURE__*/function () {
6651
6884
  }, {
6652
6885
  key: "handleOrderCheckoutSubmit",
6653
6886
  value: function () {
6654
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6887
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6655
6888
  var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
6656
6889
  var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
6657
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6658
- while (1) switch (_context67.prev = _context67.next) {
6890
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6891
+ while (1) switch (_context69.prev = _context69.next) {
6659
6892
  case 0:
6660
6893
  backendPath = params.backendPath, title = params.title;
6661
6894
  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);
6662
- _context67.t0 = lookup;
6663
- if (!_context67.t0) {
6664
- _context67.next = 7;
6895
+ _context69.t0 = lookup;
6896
+ if (!_context69.t0) {
6897
+ _context69.next = 7;
6665
6898
  break;
6666
6899
  }
6667
- _context67.next = 6;
6900
+ _context69.next = 6;
6668
6901
  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);
6669
6902
  case 6:
6670
- _context67.t0 = _context67.sent;
6903
+ _context69.t0 = _context69.sent;
6671
6904
  case 7:
6672
- localOrder = _context67.t0;
6905
+ localOrder = _context69.t0;
6673
6906
  if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
6674
- _context67.next = 10;
6907
+ _context69.next = 10;
6675
6908
  break;
6676
6909
  }
6677
- return _context67.abrupt("return", {
6910
+ return _context69.abrupt("return", {
6678
6911
  code: 409,
6679
6912
  status: false,
6680
6913
  message: PAYMENT_REFRESH_MESSAGE,
@@ -6698,10 +6931,10 @@ var Server = /*#__PURE__*/function () {
6698
6931
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6699
6932
  });
6700
6933
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
6701
- _context67.next = 19;
6934
+ _context69.next = 19;
6702
6935
  break;
6703
6936
  }
6704
- return _context67.abrupt("return", this.handleSyncCheckoutSubmit({
6937
+ return _context69.abrupt("return", this.handleSyncCheckoutSubmit({
6705
6938
  backendPath: backendPath,
6706
6939
  data: data,
6707
6940
  title: title,
@@ -6710,16 +6943,16 @@ var Server = /*#__PURE__*/function () {
6710
6943
  receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
6711
6944
  }));
6712
6945
  case 19:
6713
- _context67.next = 21;
6946
+ _context69.next = 21;
6714
6947
  return this.normalizeCheckoutSubmitData(data, title);
6715
6948
  case 21:
6716
- normalizedData = _context67.sent;
6717
- _context67.next = 24;
6949
+ normalizedData = _context69.sent;
6950
+ _context69.next = 24;
6718
6951
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6719
6952
  case 24:
6720
- numberedData = _context67.sent;
6953
+ numberedData = _context69.sent;
6721
6954
  checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
6722
- _context67.next = 28;
6955
+ _context69.next = 28;
6723
6956
  return this.handlePendingSyncCheckoutOrder({
6724
6957
  backendPath: backendPath,
6725
6958
  data: checkoutData,
@@ -6728,18 +6961,18 @@ var Server = /*#__PURE__*/function () {
6728
6961
  invoiceTemplateSettings: invoiceTemplateSettings
6729
6962
  });
6730
6963
  case 28:
6731
- pendingResult = _context67.sent;
6964
+ pendingResult = _context69.sent;
6732
6965
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6733
- _context67.next = 43;
6966
+ _context69.next = 43;
6734
6967
  break;
6735
6968
  }
6736
6969
  pendingOrder = pendingResult.data;
6737
6970
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
6738
- _context67.next = 41;
6971
+ _context69.next = 41;
6739
6972
  break;
6740
6973
  }
6741
- _context67.prev = 32;
6742
- _context67.next = 35;
6974
+ _context69.prev = 32;
6975
+ _context69.next = 35;
6743
6976
  return this.dispatchLocalReceiptPrint({
6744
6977
  checkoutData: checkoutData,
6745
6978
  order: pendingOrder,
@@ -6749,19 +6982,19 @@ var Server = /*#__PURE__*/function () {
6749
6982
  invoiceTemplateSettings: invoiceTemplateSettings
6750
6983
  });
6751
6984
  case 35:
6752
- _context67.next = 41;
6985
+ _context69.next = 41;
6753
6986
  break;
6754
6987
  case 37:
6755
- _context67.prev = 37;
6756
- _context67.t1 = _context67["catch"](32);
6988
+ _context69.prev = 37;
6989
+ _context69.t1 = _context69["catch"](32);
6757
6990
  // The sale is already persisted. A failed receipt must not cancel its
6758
6991
  // sync task or send an unfiltered fallback to the printer.
6759
- pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context67.t1);
6992
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context69.t1);
6760
6993
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
6761
6994
  error: pendingResult.receipt_print_error
6762
6995
  });
6763
6996
  case 41:
6764
- _context67.next = 43;
6997
+ _context69.next = 43;
6765
6998
  return this.dispatchCheckoutSyncTask({
6766
6999
  backendPath: backendPath,
6767
7000
  data: checkoutData,
@@ -6771,23 +7004,23 @@ var Server = /*#__PURE__*/function () {
6771
7004
  });
6772
7005
  case 43:
6773
7006
  if (pendingResult.data.order_id) {
6774
- _context67.next = 45;
7007
+ _context69.next = 45;
6775
7008
  break;
6776
7009
  }
6777
- return _context67.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
7010
+ return _context69.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6778
7011
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6779
7012
  order_id: pendingResult.data.external_sale_number
6780
7013
  })
6781
7014
  }));
6782
7015
  case 45:
6783
- return _context67.abrupt("return", pendingResult);
7016
+ return _context69.abrupt("return", pendingResult);
6784
7017
  case 46:
6785
7018
  case "end":
6786
- return _context67.stop();
7019
+ return _context69.stop();
6787
7020
  }
6788
- }, _callee67, this, [[32, 37]]);
7021
+ }, _callee69, this, [[32, 37]]);
6789
7022
  }));
6790
- function handleOrderCheckoutSubmit(_x74) {
7023
+ function handleOrderCheckoutSubmit(_x79) {
6791
7024
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6792
7025
  }
6793
7026
  return handleOrderCheckoutSubmit;
@@ -6795,27 +7028,27 @@ var Server = /*#__PURE__*/function () {
6795
7028
  }, {
6796
7029
  key: "handleSyncCheckoutSubmit",
6797
7030
  value: function () {
6798
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
7031
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6799
7032
  var _this$app17;
6800
7033
  var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6801
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6802
- while (1) switch (_context68.prev = _context68.next) {
7034
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7035
+ while (1) switch (_context70.prev = _context70.next) {
6803
7036
  case 0:
6804
7037
  backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
6805
7038
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post) {
6806
- _context68.next = 4;
7039
+ _context70.next = 4;
6807
7040
  break;
6808
7041
  }
6809
7042
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6810
- return _context68.abrupt("return", {
7043
+ return _context70.abrupt("return", {
6811
7044
  code: 500,
6812
7045
  status: false,
6813
7046
  message: 'app.request 不可用',
6814
7047
  data: null
6815
7048
  });
6816
7049
  case 4:
6817
- _context68.prev = 4;
6818
- _context68.next = 7;
7050
+ _context70.prev = 4;
7051
+ _context70.next = 7;
6819
7052
  return this.runCheckoutSync({
6820
7053
  backendPath: backendPath,
6821
7054
  data: data,
@@ -6825,13 +7058,13 @@ var Server = /*#__PURE__*/function () {
6825
7058
  invoiceTemplateSettings: invoiceTemplateSettings
6826
7059
  });
6827
7060
  case 7:
6828
- syncResult = _context68.sent;
7061
+ syncResult = _context70.sent;
6829
7062
  if (!syncResult.rejected) {
6830
- _context68.next = 11;
7063
+ _context70.next = 11;
6831
7064
  break;
6832
7065
  }
6833
7066
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6834
- return _context68.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
7067
+ return _context70.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6835
7068
  status: false,
6836
7069
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
6837
7070
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -6840,11 +7073,11 @@ var Server = /*#__PURE__*/function () {
6840
7073
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6841
7074
  syncedOrder = syncResult.syncedOrder;
6842
7075
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
6843
- _context68.next = 23;
7076
+ _context70.next = 23;
6844
7077
  break;
6845
7078
  }
6846
- _context68.prev = 14;
6847
- _context68.next = 17;
7079
+ _context70.prev = 14;
7080
+ _context70.next = 17;
6848
7081
  return this.dispatchLocalReceiptPrint({
6849
7082
  checkoutData: syncResult.checkoutData,
6850
7083
  order: syncedOrder,
@@ -6854,41 +7087,41 @@ var Server = /*#__PURE__*/function () {
6854
7087
  invoiceTemplateSettings: invoiceTemplateSettings
6855
7088
  });
6856
7089
  case 17:
6857
- _context68.next = 23;
7090
+ _context70.next = 23;
6858
7091
  break;
6859
7092
  case 19:
6860
- _context68.prev = 19;
6861
- _context68.t0 = _context68["catch"](14);
7093
+ _context70.prev = 19;
7094
+ _context70.t0 = _context70["catch"](14);
6862
7095
  // Checkout already succeeded remotely; report the receipt failure
6863
7096
  // separately instead of implying that payment/order creation failed.
6864
- response.receipt_print_error = this.getUnknownErrorMessage(_context68.t0);
7097
+ response.receipt_print_error = this.getUnknownErrorMessage(_context70.t0);
6865
7098
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
6866
7099
  error: response.receipt_print_error
6867
7100
  });
6868
7101
  case 23:
6869
- return _context68.abrupt("return", response);
7102
+ return _context70.abrupt("return", response);
6870
7103
  case 26:
6871
- _context68.prev = 26;
6872
- _context68.t1 = _context68["catch"](4);
6873
- backendError = this.extractBackendErrorResponse(_context68.t1);
7104
+ _context70.prev = 26;
7105
+ _context70.t1 = _context70["catch"](4);
7106
+ backendError = this.extractBackendErrorResponse(_context70.t1);
6874
7107
  if (!backendError) {
6875
- _context68.next = 32;
7108
+ _context70.next = 32;
6876
7109
  break;
6877
7110
  }
6878
7111
  _normalized = this.normalizeCheckoutResponse(backendError);
6879
- return _context68.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
7112
+ return _context70.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6880
7113
  status: false,
6881
7114
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6882
7115
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6883
7116
  }));
6884
7117
  case 32:
6885
- message = this.getUnknownErrorMessage(_context68.t1);
7118
+ message = this.getUnknownErrorMessage(_context70.t1);
6886
7119
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6887
7120
  backendPath: backendPath,
6888
7121
  error: message,
6889
- error_detail: this.normalizeUnknownError(_context68.t1)
7122
+ error_detail: this.normalizeUnknownError(_context70.t1)
6890
7123
  });
6891
- return _context68.abrupt("return", {
7124
+ return _context70.abrupt("return", {
6892
7125
  code: 500,
6893
7126
  status: false,
6894
7127
  message: message,
@@ -6896,11 +7129,11 @@ var Server = /*#__PURE__*/function () {
6896
7129
  });
6897
7130
  case 35:
6898
7131
  case "end":
6899
- return _context68.stop();
7132
+ return _context70.stop();
6900
7133
  }
6901
- }, _callee68, this, [[4, 26], [14, 19]]);
7134
+ }, _callee70, this, [[4, 26], [14, 19]]);
6902
7135
  }));
6903
- function handleSyncCheckoutSubmit(_x75) {
7136
+ function handleSyncCheckoutSubmit(_x80) {
6904
7137
  return _handleSyncCheckoutSubmit.apply(this, arguments);
6905
7138
  }
6906
7139
  return handleSyncCheckoutSubmit;
@@ -6908,10 +7141,10 @@ var Server = /*#__PURE__*/function () {
6908
7141
  }, {
6909
7142
  key: "handleOrderDraftSubmit",
6910
7143
  value: function () {
6911
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
7144
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
6912
7145
  var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6913
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6914
- while (1) switch (_context69.prev = _context69.next) {
7146
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7147
+ while (1) switch (_context71.prev = _context71.next) {
6915
7148
  case 0:
6916
7149
  title = params.title;
6917
7150
  extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
@@ -6925,10 +7158,10 @@ var Server = /*#__PURE__*/function () {
6925
7158
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6926
7159
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6927
7160
  });
6928
- _context69.next = 6;
7161
+ _context71.next = 6;
6929
7162
  return this.normalizeCheckoutSubmitData(data, title);
6930
7163
  case 6:
6931
- normalizedData = _context69.sent;
7164
+ normalizedData = _context71.sent;
6932
7165
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6933
7166
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6934
7167
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6938,26 +7171,26 @@ var Server = /*#__PURE__*/function () {
6938
7171
  is_draft_order: 1
6939
7172
  });
6940
7173
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6941
- _context69.next = 12;
7174
+ _context71.next = 12;
6942
7175
  break;
6943
7176
  }
6944
7177
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6945
- return _context69.abrupt("return", {
7178
+ return _context71.abrupt("return", {
6946
7179
  code: 500,
6947
7180
  status: false,
6948
7181
  message: 'Order 模块不支持本地草稿写入',
6949
7182
  data: null
6950
7183
  });
6951
7184
  case 12:
6952
- _context69.prev = 12;
6953
- _context69.next = 15;
7185
+ _context71.prev = 12;
7186
+ _context71.next = 15;
6954
7187
  return this.order.upsertLocalDraftOrders([draftOrder]);
6955
7188
  case 15:
6956
7189
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6957
7190
  order_id: draftOrder.order_id,
6958
7191
  external_sale_number: draftOrder.external_sale_number
6959
7192
  });
6960
- return _context69.abrupt("return", {
7193
+ return _context71.abrupt("return", {
6961
7194
  code: 200,
6962
7195
  status: true,
6963
7196
  message: '',
@@ -6969,13 +7202,13 @@ var Server = /*#__PURE__*/function () {
6969
7202
  })
6970
7203
  });
6971
7204
  case 19:
6972
- _context69.prev = 19;
6973
- _context69.t0 = _context69["catch"](12);
6974
- errorMessage = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
7205
+ _context71.prev = 19;
7206
+ _context71.t0 = _context71["catch"](12);
7207
+ errorMessage = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
6975
7208
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6976
7209
  error: errorMessage
6977
7210
  });
6978
- return _context69.abrupt("return", {
7211
+ return _context71.abrupt("return", {
6979
7212
  code: 500,
6980
7213
  status: false,
6981
7214
  message: errorMessage,
@@ -6983,11 +7216,11 @@ var Server = /*#__PURE__*/function () {
6983
7216
  });
6984
7217
  case 24:
6985
7218
  case "end":
6986
- return _context69.stop();
7219
+ return _context71.stop();
6987
7220
  }
6988
- }, _callee69, this, [[12, 19]]);
7221
+ }, _callee71, this, [[12, 19]]);
6989
7222
  }));
6990
- function handleOrderDraftSubmit(_x76) {
7223
+ function handleOrderDraftSubmit(_x81) {
6991
7224
  return _handleOrderDraftSubmit.apply(this, arguments);
6992
7225
  }
6993
7226
  return handleOrderDraftSubmit;
@@ -6995,26 +7228,26 @@ var Server = /*#__PURE__*/function () {
6995
7228
  }, {
6996
7229
  key: "handlePendingSyncCheckoutOrder",
6997
7230
  value: function () {
6998
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6999
- var _this17 = this;
7231
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7232
+ var _this18 = this;
7000
7233
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
7001
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7002
- while (1) switch (_context70.prev = _context70.next) {
7234
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7235
+ while (1) switch (_context72.prev = _context72.next) {
7003
7236
  case 0:
7004
7237
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
7005
- _context70.next = 3;
7238
+ _context72.next = 3;
7006
7239
  return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
7007
7240
  case 3:
7008
- pendingOrder = _context70.sent;
7241
+ pendingOrder = _context72.sent;
7009
7242
  if (pendingOrder) {
7010
- _context70.next = 7;
7243
+ _context72.next = 7;
7011
7244
  break;
7012
7245
  }
7013
7246
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
7014
7247
  backendPath: backendPath,
7015
7248
  reason: reason
7016
7249
  });
7017
- return _context70.abrupt("return", {
7250
+ return _context72.abrupt("return", {
7018
7251
  code: 500,
7019
7252
  status: false,
7020
7253
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -7022,22 +7255,22 @@ var Server = /*#__PURE__*/function () {
7022
7255
  });
7023
7256
  case 7:
7024
7257
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
7025
- _context70.next = 10;
7258
+ _context72.next = 10;
7026
7259
  break;
7027
7260
  }
7028
7261
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
7029
7262
  backendPath: backendPath,
7030
7263
  reason: reason
7031
7264
  });
7032
- return _context70.abrupt("return", {
7265
+ return _context72.abrupt("return", {
7033
7266
  code: 500,
7034
7267
  status: false,
7035
7268
  message: 'Order 模块不支持本地待同步写入',
7036
7269
  data: null
7037
7270
  });
7038
7271
  case 10:
7039
- _context70.prev = 10;
7040
- _context70.next = 13;
7272
+ _context72.prev = 10;
7273
+ _context72.next = 13;
7041
7274
  return this.order.upsertPendingSyncOrders([pendingOrder]);
7042
7275
  case 13:
7043
7276
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -7049,9 +7282,9 @@ var Server = /*#__PURE__*/function () {
7049
7282
  });
7050
7283
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
7051
7284
  var _payment$metadata;
7052
- return sum + _this17.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7285
+ return sum + _this18.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
7053
7286
  }, 0);
7054
- return _context70.abrupt("return", {
7287
+ return _context72.abrupt("return", {
7055
7288
  code: 200,
7056
7289
  status: true,
7057
7290
  message: '',
@@ -7066,15 +7299,15 @@ var Server = /*#__PURE__*/function () {
7066
7299
  })
7067
7300
  });
7068
7301
  case 18:
7069
- _context70.prev = 18;
7070
- _context70.t0 = _context70["catch"](10);
7071
- errorMessage = _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0);
7302
+ _context72.prev = 18;
7303
+ _context72.t0 = _context72["catch"](10);
7304
+ errorMessage = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7072
7305
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
7073
7306
  backendPath: backendPath,
7074
7307
  reason: reason,
7075
7308
  error: errorMessage
7076
7309
  });
7077
- return _context70.abrupt("return", {
7310
+ return _context72.abrupt("return", {
7078
7311
  code: 500,
7079
7312
  status: false,
7080
7313
  message: errorMessage,
@@ -7082,11 +7315,11 @@ var Server = /*#__PURE__*/function () {
7082
7315
  });
7083
7316
  case 23:
7084
7317
  case "end":
7085
- return _context70.stop();
7318
+ return _context72.stop();
7086
7319
  }
7087
- }, _callee70, this, [[10, 18]]);
7320
+ }, _callee72, this, [[10, 18]]);
7088
7321
  }));
7089
- function handlePendingSyncCheckoutOrder(_x77) {
7322
+ function handlePendingSyncCheckoutOrder(_x82) {
7090
7323
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
7091
7324
  }
7092
7325
  return handlePendingSyncCheckoutOrder;
@@ -7094,45 +7327,45 @@ var Server = /*#__PURE__*/function () {
7094
7327
  }, {
7095
7328
  key: "buildPendingSyncCheckoutOrder",
7096
7329
  value: function () {
7097
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(data, invoiceTemplateSettings) {
7330
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data, invoiceTemplateSettings) {
7098
7331
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
7099
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7100
- while (1) switch (_context71.prev = _context71.next) {
7332
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7333
+ while (1) switch (_context73.prev = _context73.next) {
7101
7334
  case 0:
7102
7335
  if (!(!data || _typeof(data) !== 'object')) {
7103
- _context71.next = 2;
7336
+ _context73.next = 2;
7104
7337
  break;
7105
7338
  }
7106
- return _context71.abrupt("return", null);
7339
+ return _context73.abrupt("return", null);
7107
7340
  case 2:
7108
7341
  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 !== '';
7109
7342
  if (hasStorageKey) {
7110
- _context71.next = 5;
7343
+ _context73.next = 5;
7111
7344
  break;
7112
7345
  }
7113
- return _context71.abrupt("return", null);
7346
+ return _context73.abrupt("return", null);
7114
7347
  case 5:
7115
7348
  pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
7116
7349
  need_sync: 1,
7117
7350
  is_draft_order: 0
7118
7351
  }));
7119
- _context71.next = 8;
7352
+ _context73.next = 8;
7120
7353
  return this.buildSmallTicketProductMap(pendingOrder);
7121
7354
  case 8:
7122
- productMap = _context71.sent;
7355
+ productMap = _context73.sent;
7123
7356
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
7124
- return _context71.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7357
+ return _context73.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7125
7358
  requireFullyPaid: true,
7126
7359
  productMap: productMap,
7127
7360
  invoiceTemplateSettings: invoiceTemplateSettings
7128
7361
  }));
7129
7362
  case 11:
7130
7363
  case "end":
7131
- return _context71.stop();
7364
+ return _context73.stop();
7132
7365
  }
7133
- }, _callee71, this);
7366
+ }, _callee73, this);
7134
7367
  }));
7135
- function buildPendingSyncCheckoutOrder(_x78, _x79) {
7368
+ function buildPendingSyncCheckoutOrder(_x83, _x84) {
7136
7369
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
7137
7370
  }
7138
7371
  return buildPendingSyncCheckoutOrder;
@@ -7169,11 +7402,11 @@ var Server = /*#__PURE__*/function () {
7169
7402
  }, {
7170
7403
  key: "shouldAutoPrintReceiptForPaymentStatus",
7171
7404
  value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
7172
- var _this18 = this;
7405
+ var _this19 = this;
7173
7406
  if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
7174
7407
  var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
7175
7408
  return statuses.some(function (status) {
7176
- return status === 'paid' ? _this18.isSalesOrderFullyPaid(order) : paymentStatus === status;
7409
+ return status === 'paid' ? _this19.isSalesOrderFullyPaid(order) : paymentStatus === status;
7177
7410
  });
7178
7411
  }
7179
7412
  }, {
@@ -7202,32 +7435,32 @@ var Server = /*#__PURE__*/function () {
7202
7435
  }, {
7203
7436
  key: "isSalesOrderFullyPaid",
7204
7437
  value: function isSalesOrderFullyPaid(order) {
7205
- var _order$summary$amount, _order$summary, _ref74, _ref75, _order$summary$expect, _order$summary2, _order$summary3;
7438
+ var _order$summary$amount, _order$summary3, _ref76, _ref77, _order$summary$expect, _order$summary4, _order$summary5;
7206
7439
  if (!order || _typeof(order) !== 'object') return false;
7207
7440
  var paymentStatus = String(order.payment_status || '').toLowerCase();
7208
7441
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
7209
7442
  if (paymentStatus === 'partially_paid' || paymentStatus === 'payment_processing' || paymentStatus === 'pending' || paymentStatus === 'unpaid') {
7210
7443
  return false;
7211
7444
  }
7212
- 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;
7445
+ 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;
7213
7446
  if (amountGap !== undefined && amountGap !== null && amountGap !== '') {
7214
7447
  return this.toAmountNumber(amountGap) <= 0;
7215
7448
  }
7216
7449
  var paidAmount = this.sumPaidOrderPayments(order.payments);
7217
- var targetAmount = this.toAmountNumber((_ref74 = (_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : order.expect_amount) !== null && _ref74 !== void 0 ? _ref74 : order.total_amount);
7450
+ var targetAmount = this.toAmountNumber((_ref76 = (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : order.expect_amount) !== null && _ref76 !== void 0 ? _ref76 : order.total_amount);
7218
7451
  if (targetAmount <= 0) return paidAmount > 0;
7219
7452
  return paidAmount >= targetAmount;
7220
7453
  }
7221
7454
  }, {
7222
7455
  key: "sumPaidOrderPayments",
7223
7456
  value: function sumPaidOrderPayments(payments) {
7224
- var _this19 = this;
7457
+ var _this20 = this;
7225
7458
  if (!Array.isArray(payments)) return 0;
7226
7459
  return payments.reduce(function (sum, payment) {
7227
7460
  var _payment$amount;
7228
7461
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
7229
7462
  if (status !== 'paid') return sum;
7230
- return sum + _this19.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);
7463
+ return sum + _this20.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);
7231
7464
  }, 0);
7232
7465
  }
7233
7466
  }, {
@@ -7241,12 +7474,12 @@ var Server = /*#__PURE__*/function () {
7241
7474
  }, {
7242
7475
  key: "buildSmallTicketProductMap",
7243
7476
  value: function () {
7244
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(order) {
7477
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7245
7478
  var _this$products4,
7246
- _this20 = this;
7479
+ _this21 = this;
7247
7480
  var products, productIdSet, productIds, entries;
7248
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7249
- while (1) switch (_context73.prev = _context73.next) {
7481
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7482
+ while (1) switch (_context75.prev = _context75.next) {
7250
7483
  case 0:
7251
7484
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
7252
7485
  productIdSet = new Set();
@@ -7258,8 +7491,8 @@ var Server = /*#__PURE__*/function () {
7258
7491
  }
7259
7492
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7260
7493
  product.product_bundle.forEach(function (bundle) {
7261
- var _ref76, _bundle$bundle_produc;
7262
- var bundleProductId = (_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7494
+ var _ref78, _bundle$bundle_produc;
7495
+ var bundleProductId = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7263
7496
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
7264
7497
  productIdSet.add(bundleProductId);
7265
7498
  }
@@ -7268,45 +7501,45 @@ var Server = /*#__PURE__*/function () {
7268
7501
  });
7269
7502
  productIds = Array.from(productIdSet);
7270
7503
  if (!(!productIds.length || typeof ((_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductById) !== 'function')) {
7271
- _context73.next = 6;
7504
+ _context75.next = 6;
7272
7505
  break;
7273
7506
  }
7274
- return _context73.abrupt("return", {});
7507
+ return _context75.abrupt("return", {});
7275
7508
  case 6:
7276
- _context73.next = 8;
7509
+ _context75.next = 8;
7277
7510
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7278
- var _ref77 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(id) {
7279
- var _this20$products, _this20$products$getP, product;
7280
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7281
- while (1) switch (_context72.prev = _context72.next) {
7511
+ var _ref79 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(id) {
7512
+ var _this21$products, _this21$products$getP, product;
7513
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7514
+ while (1) switch (_context74.prev = _context74.next) {
7282
7515
  case 0:
7283
- _context72.prev = 0;
7284
- _context72.next = 3;
7285
- return (_this20$products = _this20.products) === null || _this20$products === void 0 || (_this20$products$getP = _this20$products.getProductById) === null || _this20$products$getP === void 0 ? void 0 : _this20$products$getP.call(_this20$products, Number(id));
7516
+ _context74.prev = 0;
7517
+ _context74.next = 3;
7518
+ return (_this21$products = _this21.products) === null || _this21$products === void 0 || (_this21$products$getP = _this21$products.getProductById) === null || _this21$products$getP === void 0 ? void 0 : _this21$products$getP.call(_this21$products, Number(id));
7286
7519
  case 3:
7287
- product = _context72.sent;
7288
- return _context72.abrupt("return", product ? [String(id), product] : null);
7520
+ product = _context74.sent;
7521
+ return _context74.abrupt("return", product ? [String(id), product] : null);
7289
7522
  case 7:
7290
- _context72.prev = 7;
7291
- _context72.t0 = _context72["catch"](0);
7292
- _this20.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7523
+ _context74.prev = 7;
7524
+ _context74.t0 = _context74["catch"](0);
7525
+ _this21.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7293
7526
  product_id: id,
7294
- error: _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0)
7527
+ error: _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0)
7295
7528
  });
7296
- return _context72.abrupt("return", null);
7529
+ return _context74.abrupt("return", null);
7297
7530
  case 11:
7298
7531
  case "end":
7299
- return _context72.stop();
7532
+ return _context74.stop();
7300
7533
  }
7301
- }, _callee72, null, [[0, 7]]);
7534
+ }, _callee74, null, [[0, 7]]);
7302
7535
  }));
7303
- return function (_x81) {
7304
- return _ref77.apply(this, arguments);
7536
+ return function (_x86) {
7537
+ return _ref79.apply(this, arguments);
7305
7538
  };
7306
7539
  }()));
7307
7540
  case 8:
7308
- entries = _context73.sent;
7309
- return _context73.abrupt("return", entries.reduce(function (map, entry) {
7541
+ entries = _context75.sent;
7542
+ return _context75.abrupt("return", entries.reduce(function (map, entry) {
7310
7543
  if (!entry) return map;
7311
7544
  var _entry = _slicedToArray(entry, 2),
7312
7545
  id = _entry[0],
@@ -7316,11 +7549,11 @@ var Server = /*#__PURE__*/function () {
7316
7549
  }, {}));
7317
7550
  case 10:
7318
7551
  case "end":
7319
- return _context73.stop();
7552
+ return _context75.stop();
7320
7553
  }
7321
- }, _callee73, this);
7554
+ }, _callee75, this);
7322
7555
  }));
7323
- function buildSmallTicketProductMap(_x80) {
7556
+ function buildSmallTicketProductMap(_x85) {
7324
7557
  return _buildSmallTicketProductMap.apply(this, arguments);
7325
7558
  }
7326
7559
  return buildSmallTicketProductMap;
@@ -7340,8 +7573,8 @@ var Server = /*#__PURE__*/function () {
7340
7573
  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);
7341
7574
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7342
7575
  product.product_bundle.forEach(function (bundle) {
7343
- var _ref78, _bundle$bundle_produc2;
7344
- addProductId((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7576
+ var _ref80, _bundle$bundle_produc2;
7577
+ addProductId((_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7345
7578
  });
7346
7579
  }
7347
7580
  });
@@ -7350,40 +7583,40 @@ var Server = /*#__PURE__*/function () {
7350
7583
  }, {
7351
7584
  key: "buildSalesDetailProductSnapshotMap",
7352
7585
  value: function () {
7353
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7586
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
7354
7587
  var _this$products5;
7355
7588
  var productIds, getSnapshots;
7356
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7357
- while (1) switch (_context74.prev = _context74.next) {
7589
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7590
+ while (1) switch (_context76.prev = _context76.next) {
7358
7591
  case 0:
7359
7592
  productIds = this.collectSalesDetailProductIds(order);
7360
7593
  getSnapshots = (_this$products5 = this.products) === null || _this$products5 === void 0 ? void 0 : _this$products5.getProductSnapshotsByIds;
7361
7594
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
7362
- _context74.next = 4;
7595
+ _context76.next = 4;
7363
7596
  break;
7364
7597
  }
7365
- return _context74.abrupt("return", {});
7598
+ return _context76.abrupt("return", {});
7366
7599
  case 4:
7367
- _context74.prev = 4;
7368
- _context74.next = 7;
7600
+ _context76.prev = 4;
7601
+ _context76.next = 7;
7369
7602
  return getSnapshots.call(this.products, productIds);
7370
7603
  case 7:
7371
- return _context74.abrupt("return", _context74.sent);
7604
+ return _context76.abrupt("return", _context76.sent);
7372
7605
  case 10:
7373
- _context74.prev = 10;
7374
- _context74.t0 = _context74["catch"](4);
7606
+ _context76.prev = 10;
7607
+ _context76.t0 = _context76["catch"](4);
7375
7608
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
7376
7609
  product_ids: productIds,
7377
- error: _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0)
7610
+ error: _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0)
7378
7611
  });
7379
- return _context74.abrupt("return", {});
7612
+ return _context76.abrupt("return", {});
7380
7613
  case 14:
7381
7614
  case "end":
7382
- return _context74.stop();
7615
+ return _context76.stop();
7383
7616
  }
7384
- }, _callee74, this, [[4, 10]]);
7617
+ }, _callee76, this, [[4, 10]]);
7385
7618
  }));
7386
- function buildSalesDetailProductSnapshotMap(_x82) {
7619
+ function buildSalesDetailProductSnapshotMap(_x87) {
7387
7620
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
7388
7621
  }
7389
7622
  return buildSalesDetailProductSnapshotMap;
@@ -7417,9 +7650,9 @@ var Server = /*#__PURE__*/function () {
7417
7650
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
7418
7651
  var hasChanged = false;
7419
7652
  var productBundle = product.product_bundle.map(function (bundle) {
7420
- var _ref79, _bundle$bundle_produc3;
7653
+ var _ref81, _bundle$bundle_produc3;
7421
7654
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
7422
- var rawProductId = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7655
+ var rawProductId = (_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7423
7656
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
7424
7657
  var productId = Number(rawProductId);
7425
7658
  if (!Number.isFinite(productId)) return bundle;
@@ -7439,53 +7672,53 @@ var Server = /*#__PURE__*/function () {
7439
7672
  }, {
7440
7673
  key: "withSalesDetailProductSnapshots",
7441
7674
  value: function () {
7442
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7443
- var _this21 = this;
7675
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
7676
+ var _this22 = this;
7444
7677
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
7445
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7446
- while (1) switch (_context75.prev = _context75.next) {
7678
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7679
+ while (1) switch (_context77.prev = _context77.next) {
7447
7680
  case 0:
7448
7681
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
7449
7682
  if (products !== null && products !== void 0 && products.length) {
7450
- _context75.next = 3;
7683
+ _context77.next = 3;
7451
7684
  break;
7452
7685
  }
7453
- return _context75.abrupt("return", order);
7686
+ return _context77.abrupt("return", order);
7454
7687
  case 3:
7455
- _context75.next = 5;
7688
+ _context77.next = 5;
7456
7689
  return this.buildSalesDetailProductSnapshotMap(order);
7457
7690
  case 5:
7458
- snapshotMap = _context75.sent;
7691
+ snapshotMap = _context77.sent;
7459
7692
  if (Object.keys(snapshotMap).length) {
7460
- _context75.next = 8;
7693
+ _context77.next = 8;
7461
7694
  break;
7462
7695
  }
7463
- return _context75.abrupt("return", order);
7696
+ return _context77.abrupt("return", order);
7464
7697
  case 8:
7465
7698
  hasChanged = false;
7466
7699
  enrichedProducts = products.map(function (product) {
7467
- var productWithBundleSnapshots = _this21.withBundleCatalogSnapshots(product, snapshotMap);
7468
- var nextProduct = _this21.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7700
+ var productWithBundleSnapshots = _this22.withBundleCatalogSnapshots(product, snapshotMap);
7701
+ var nextProduct = _this22.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7469
7702
  if (nextProduct !== product) hasChanged = true;
7470
7703
  return nextProduct;
7471
7704
  });
7472
7705
  if (hasChanged) {
7473
- _context75.next = 12;
7706
+ _context77.next = 12;
7474
7707
  break;
7475
7708
  }
7476
- return _context75.abrupt("return", order);
7709
+ return _context77.abrupt("return", order);
7477
7710
  case 12:
7478
7711
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
7479
7712
  products: enrichedProducts
7480
7713
  });
7481
- return _context75.abrupt("return", enrichedOrder);
7714
+ return _context77.abrupt("return", enrichedOrder);
7482
7715
  case 14:
7483
7716
  case "end":
7484
- return _context75.stop();
7717
+ return _context77.stop();
7485
7718
  }
7486
- }, _callee75, this);
7719
+ }, _callee77, this);
7487
7720
  }));
7488
- function withSalesDetailProductSnapshots(_x83) {
7721
+ function withSalesDetailProductSnapshots(_x88) {
7489
7722
  return _withSalesDetailProductSnapshots.apply(this, arguments);
7490
7723
  }
7491
7724
  return withSalesDetailProductSnapshots;
@@ -7493,13 +7726,13 @@ var Server = /*#__PURE__*/function () {
7493
7726
  }, {
7494
7727
  key: "withPendingSyncProductTitles",
7495
7728
  value: function withPendingSyncProductTitles(order, productMap) {
7496
- var _this22 = this;
7729
+ var _this23 = this;
7497
7730
  var products = Array.isArray(order.products) ? order.products : null;
7498
7731
  if (!(products !== null && products !== void 0 && products.length)) return order;
7499
7732
  return _objectSpread(_objectSpread({}, order), {}, {
7500
7733
  products: products.map(function (product) {
7501
7734
  return _objectSpread(_objectSpread({}, product), {}, {
7502
- product_title: _this22.buildProductTitleSnapshot(product, productMap)
7735
+ product_title: _this23.buildProductTitleSnapshot(product, productMap)
7503
7736
  });
7504
7737
  })
7505
7738
  });
@@ -7510,7 +7743,7 @@ var Server = /*#__PURE__*/function () {
7510
7743
  var _product$product_id4,
7511
7744
  _product$product,
7512
7745
  _fallbackProduct$prod,
7513
- _this23 = this;
7746
+ _this24 = this;
7514
7747
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
7515
7748
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
7516
7749
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -7518,7 +7751,7 @@ var Server = /*#__PURE__*/function () {
7518
7751
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
7519
7752
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
7520
7753
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
7521
- snapshot[key] = _this23.resolveProductTitleValue(ownTitle, key, currentLocale) || _this23.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7754
+ snapshot[key] = _this24.resolveProductTitleValue(ownTitle, key, currentLocale) || _this24.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7522
7755
  return snapshot;
7523
7756
  }, {});
7524
7757
  }
@@ -7543,7 +7776,7 @@ var Server = /*#__PURE__*/function () {
7543
7776
  }, {
7544
7777
  key: "resolveProductTitleValue",
7545
7778
  value: function resolveProductTitleValue(value, key, currentLocale) {
7546
- var _ref80, _ref81, _value$key;
7779
+ var _ref82, _ref83, _value$key;
7547
7780
  if (value === undefined || value === null || value === '') return null;
7548
7781
  if (_typeof(value) !== 'object') {
7549
7782
  var title = String(value);
@@ -7553,7 +7786,7 @@ var Server = /*#__PURE__*/function () {
7553
7786
  }
7554
7787
  var normalizedKey = key.replace('-', '_');
7555
7788
  var dashedKey = key.replace('_', '-');
7556
- var rawValue = (_ref80 = (_ref81 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref81 !== void 0 ? _ref81 : value[dashedKey]) !== null && _ref80 !== void 0 ? _ref80 : key === 'auto' ? value.default : undefined;
7789
+ var rawValue = (_ref82 = (_ref83 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref83 !== void 0 ? _ref83 : value[dashedKey]) !== null && _ref82 !== void 0 ? _ref82 : key === 'auto' ? value.default : undefined;
7557
7790
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
7558
7791
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
7559
7792
  return String(rawValue);
@@ -7616,31 +7849,31 @@ var Server = /*#__PURE__*/function () {
7616
7849
  }, {
7617
7850
  key: "enrichPaymentNamesByCode",
7618
7851
  value: function () {
7619
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
7620
- var _this24 = this;
7852
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order) {
7853
+ var _this25 = this;
7621
7854
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
7622
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7623
- while (1) switch (_context76.prev = _context76.next) {
7855
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7856
+ while (1) switch (_context78.prev = _context78.next) {
7624
7857
  case 0:
7625
7858
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
7626
7859
  hasMissingName = payments.some(function (payment) {
7627
- return _this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7860
+ return _this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7628
7861
  });
7629
7862
  if (hasMissingName) {
7630
- _context76.next = 4;
7863
+ _context78.next = 4;
7631
7864
  break;
7632
7865
  }
7633
- return _context76.abrupt("return", order);
7866
+ return _context78.abrupt("return", order);
7634
7867
  case 4:
7635
- _context76.prev = 4;
7636
- _context76.next = 7;
7868
+ _context78.prev = 4;
7869
+ _context78.next = 7;
7637
7870
  return this.getPaymentRouteModule();
7638
7871
  case 7:
7639
- paymentModule = _context76.sent;
7640
- _context76.next = 10;
7872
+ paymentModule = _context78.sent;
7873
+ _context78.next = 10;
7641
7874
  return paymentModule.getPayMethodListAsync();
7642
7875
  case 10:
7643
- payMethods = _context76.sent;
7876
+ payMethods = _context78.sent;
7644
7877
  nameByCode = new Map();
7645
7878
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
7646
7879
  try {
@@ -7657,9 +7890,9 @@ var Server = /*#__PURE__*/function () {
7657
7890
  }
7658
7891
  hasResolvedName = false;
7659
7892
  enrichedPayments = payments.map(function (payment) {
7660
- if (!_this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7661
- if (!_this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7662
- var name = nameByCode.get(_this24.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7893
+ if (!_this25.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7894
+ if (!_this25.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7895
+ var name = nameByCode.get(_this25.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7663
7896
  if (!name) return payment;
7664
7897
  hasResolvedName = true;
7665
7898
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -7667,28 +7900,28 @@ var Server = /*#__PURE__*/function () {
7667
7900
  });
7668
7901
  });
7669
7902
  if (hasResolvedName) {
7670
- _context76.next = 18;
7903
+ _context78.next = 18;
7671
7904
  break;
7672
7905
  }
7673
- return _context76.abrupt("return", order);
7906
+ return _context78.abrupt("return", order);
7674
7907
  case 18:
7675
- return _context76.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7908
+ return _context78.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7676
7909
  payments: enrichedPayments
7677
7910
  }));
7678
7911
  case 21:
7679
- _context76.prev = 21;
7680
- _context76.t0 = _context76["catch"](4);
7912
+ _context78.prev = 21;
7913
+ _context78.t0 = _context78["catch"](4);
7681
7914
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
7682
- error: _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0)
7915
+ error: _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0)
7683
7916
  });
7684
- return _context76.abrupt("return", order);
7917
+ return _context78.abrupt("return", order);
7685
7918
  case 25:
7686
7919
  case "end":
7687
- return _context76.stop();
7920
+ return _context78.stop();
7688
7921
  }
7689
- }, _callee76, this, [[4, 21]]);
7922
+ }, _callee78, this, [[4, 21]]);
7690
7923
  }));
7691
- function enrichPaymentNamesByCode(_x84) {
7924
+ function enrichPaymentNamesByCode(_x89) {
7692
7925
  return _enrichPaymentNamesByCode.apply(this, arguments);
7693
7926
  }
7694
7927
  return enrichPaymentNamesByCode;
@@ -7696,25 +7929,25 @@ var Server = /*#__PURE__*/function () {
7696
7929
  }, {
7697
7930
  key: "withLocalSmallTicketData",
7698
7931
  value: function () {
7699
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order, options) {
7700
- var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref82, _ref83, _order_id, enrichedOrder, productMap, smallTicketData;
7701
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7702
- while (1) switch (_context77.prev = _context77.next) {
7932
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order, options) {
7933
+ var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref84, _ref85, _order_id, enrichedOrder, productMap, smallTicketData;
7934
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7935
+ while (1) switch (_context79.prev = _context79.next) {
7703
7936
  case 0:
7704
7937
  mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
7705
7938
  if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
7706
- _context77.next = 3;
7939
+ _context79.next = 3;
7707
7940
  break;
7708
7941
  }
7709
- return _context77.abrupt("return", order);
7942
+ return _context79.abrupt("return", order);
7710
7943
  case 3:
7711
7944
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
7712
- _context77.next = 5;
7945
+ _context79.next = 5;
7713
7946
  break;
7714
7947
  }
7715
- return _context77.abrupt("return", order);
7948
+ return _context79.abrupt("return", order);
7716
7949
  case 5:
7717
- _context77.prev = 5;
7950
+ _context79.prev = 5;
7718
7951
  normalizedCollections = normalizeOrderCollections(order, {
7719
7952
  ensureUid: false
7720
7953
  });
@@ -7728,28 +7961,28 @@ var Server = /*#__PURE__*/function () {
7728
7961
  return count > 0;
7729
7962
  })) {
7730
7963
  this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
7731
- order_identifier: (_ref82 = (_ref83 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref83 !== void 0 ? _ref83 : normalizedOrder.shop_order_number) !== null && _ref82 !== void 0 ? _ref82 : null,
7964
+ order_identifier: (_ref84 = (_ref85 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref85 !== void 0 ? _ref85 : normalizedOrder.shop_order_number) !== null && _ref84 !== void 0 ? _ref84 : null,
7732
7965
  collapsed_duplicate_counts: collapsedDuplicateCounts
7733
7966
  });
7734
7967
  }
7735
- _context77.next = 12;
7968
+ _context79.next = 12;
7736
7969
  return this.enrichPaymentNamesByCode(normalizedOrder);
7737
7970
  case 12:
7738
- enrichedOrder = _context77.sent;
7971
+ enrichedOrder = _context79.sent;
7739
7972
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7740
- _context77.next = 17;
7973
+ _context79.next = 17;
7741
7974
  break;
7742
7975
  }
7743
- _context77.t0 = _options$productMap;
7744
- _context77.next = 20;
7976
+ _context79.t0 = _options$productMap;
7977
+ _context79.next = 20;
7745
7978
  break;
7746
7979
  case 17:
7747
- _context77.next = 19;
7980
+ _context79.next = 19;
7748
7981
  return this.buildSmallTicketProductMap(enrichedOrder);
7749
7982
  case 19:
7750
- _context77.t0 = _context77.sent;
7983
+ _context79.t0 = _context79.sent;
7751
7984
  case 20:
7752
- productMap = _context77.t0;
7985
+ productMap = _context79.t0;
7753
7986
  smallTicketData = buildSmallTicketData({
7754
7987
  order: enrichedOrder,
7755
7988
  shopInfo: this.getSmallTicketShopInfo(),
@@ -7758,31 +7991,31 @@ var Server = /*#__PURE__*/function () {
7758
7991
  includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
7759
7992
  templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
7760
7993
  });
7761
- return _context77.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7994
+ return _context79.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7762
7995
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7763
7996
  small_ticket_data: smallTicketData
7764
7997
  })
7765
7998
  }));
7766
7999
  case 25:
7767
- _context77.prev = 25;
7768
- _context77.t1 = _context77["catch"](5);
8000
+ _context79.prev = 25;
8001
+ _context79.t1 = _context79["catch"](5);
7769
8002
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7770
- error: _context77.t1 instanceof Error ? _context77.t1.message : String(_context77.t1)
8003
+ error: _context79.t1 instanceof Error ? _context79.t1.message : String(_context79.t1)
7771
8004
  });
7772
8005
  if (!mustApplyVisibility) {
7773
- _context77.next = 30;
8006
+ _context79.next = 30;
7774
8007
  break;
7775
8008
  }
7776
- throw _context77.t1;
8009
+ throw _context79.t1;
7777
8010
  case 30:
7778
- return _context77.abrupt("return", order);
8011
+ return _context79.abrupt("return", order);
7779
8012
  case 31:
7780
8013
  case "end":
7781
- return _context77.stop();
8014
+ return _context79.stop();
7782
8015
  }
7783
- }, _callee77, this, [[5, 25]]);
8016
+ }, _callee79, this, [[5, 25]]);
7784
8017
  }));
7785
- function withLocalSmallTicketData(_x85, _x86) {
8018
+ function withLocalSmallTicketData(_x90, _x91) {
7786
8019
  return _withLocalSmallTicketData.apply(this, arguments);
7787
8020
  }
7788
8021
  return withLocalSmallTicketData;
@@ -7797,37 +8030,37 @@ var Server = /*#__PURE__*/function () {
7797
8030
  }, {
7798
8031
  key: "fetchAndPersistSalesOrderByLookup",
7799
8032
  value: function () {
7800
- var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(lookup, data, title, paymentIdentityOrder) {
8033
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(lookup, data, title, paymentIdentityOrder, prepareExactOrderForPersist) {
7801
8034
  var _this$order7, _this$order8, _this$app19;
7802
- 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, _ref84, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7803
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7804
- while (1) switch (_context78.prev = _context78.next) {
8035
+ 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, _ref86, _backendError$code2, backendStatusCode, _code, _message2, _message3;
8036
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8037
+ while (1) switch (_context80.prev = _context80.next) {
7805
8038
  case 0:
7806
8039
  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))) {
7807
- _context78.next = 3;
8040
+ _context80.next = 3;
7808
8041
  break;
7809
8042
  }
7810
8043
  this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7811
- return _context78.abrupt("return", {
8044
+ return _context80.abrupt("return", {
7812
8045
  code: 500,
7813
8046
  message: 'Order 模块未注册',
7814
8047
  order: null
7815
8048
  });
7816
8049
  case 3:
7817
8050
  if ((_this$app19 = this.app) !== null && _this$app19 !== void 0 && (_this$app19 = _this$app19.request) !== null && _this$app19 !== void 0 && _this$app19.get) {
7818
- _context78.next = 6;
8051
+ _context80.next = 6;
7819
8052
  break;
7820
8053
  }
7821
8054
  this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7822
- return _context78.abrupt("return", {
8055
+ return _context80.abrupt("return", {
7823
8056
  code: 500,
7824
8057
  message: 'app.request 不可用',
7825
8058
  order: null
7826
8059
  });
7827
8060
  case 6:
7828
8061
  backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
7829
- _context78.prev = 7;
7830
- _context78.next = 10;
8062
+ _context80.prev = 7;
8063
+ _context80.next = 10;
7831
8064
  return this.app.request.get(backendPath, {
7832
8065
  lookup_mode: 'multi'
7833
8066
  }, {
@@ -7835,9 +8068,9 @@ var Server = /*#__PURE__*/function () {
7835
8068
  customToast: function customToast() {}
7836
8069
  });
7837
8070
  case 10:
7838
- response = _context78.sent;
8071
+ response = _context80.sent;
7839
8072
  if (!this.isCheckoutResponseRejected(response)) {
7840
- _context78.next = 17;
8073
+ _context80.next = 17;
7841
8074
  break;
7842
8075
  }
7843
8076
  responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
@@ -7849,70 +8082,80 @@ var Server = /*#__PURE__*/function () {
7849
8082
  code: code,
7850
8083
  message: message
7851
8084
  });
7852
- return _context78.abrupt("return", {
8085
+ return _context80.abrupt("return", {
7853
8086
  code: code,
7854
8087
  message: message,
7855
8088
  order: null
7856
8089
  });
7857
8090
  case 17:
7858
- fresh = this.extractOrderDataFromCheckoutResponse(response);
7859
- if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
7860
- _context78.next = 21;
8091
+ _fresh2 = this.extractOrderDataFromCheckoutResponse(response);
8092
+ if (!(!_fresh2 || _fresh2.order_id === undefined || _fresh2.order_id === null || String(_fresh2.order_id).trim() === '')) {
8093
+ _context80.next = 21;
7861
8094
  break;
7862
8095
  }
7863
8096
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
7864
8097
  lookup: lookup,
7865
8098
  backendPath: backendPath
7866
8099
  });
7867
- return _context78.abrupt("return", {
8100
+ return _context80.abrupt("return", {
7868
8101
  code: 500,
7869
8102
  message: '后端返回订单为空',
7870
8103
  order: null
7871
8104
  });
7872
8105
  case 21:
7873
- _context78.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
7874
- if (_context78.t0) {
7875
- _context78.next = 31;
8106
+ if (!prepareExactOrderForPersist) {
8107
+ _context80.next = 25;
8108
+ break;
8109
+ }
8110
+ _context80.t0 = (_this$order$getOrderB = (_this$order9 = this.order).getOrderByOrderId) === null || _this$order$getOrderB === void 0 ? void 0 : _this$order$getOrderB.call(_this$order9, lookup);
8111
+ _context80.next = 36;
8112
+ break;
8113
+ case 25:
8114
+ _context80.t1 = (_this$order$getLocalO = (_this$order10 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order10, lookup);
8115
+ if (_context80.t1) {
8116
+ _context80.next = 35;
7876
8117
  break;
7877
8118
  }
7878
8119
  if (!this.shouldForceRemoteSalesDetail(data)) {
7879
- _context78.next = 29;
8120
+ _context80.next = 33;
7880
8121
  break;
7881
8122
  }
7882
- _context78.next = 26;
8123
+ _context80.next = 30;
7883
8124
  return this.order.getLocalOrderByLookup(lookup);
7884
- case 26:
7885
- _context78.t1 = _context78.sent;
7886
- _context78.next = 30;
7887
- break;
7888
- case 29:
7889
- _context78.t1 = null;
7890
8125
  case 30:
7891
- _context78.t0 = _context78.t1;
7892
- case 31:
7893
- localBeforeRefresh = _context78.t0;
7894
- orderToPersist = fresh;
8126
+ _context80.t2 = _context80.sent;
8127
+ _context80.next = 34;
8128
+ break;
8129
+ case 33:
8130
+ _context80.t2 = null;
8131
+ case 34:
8132
+ _context80.t1 = _context80.t2;
8133
+ case 35:
8134
+ _context80.t0 = _context80.t1;
8135
+ case 36:
8136
+ localBeforeRefresh = _context80.t0;
8137
+ orderToPersist = _fresh2;
7895
8138
  if (!paymentIdentityOrder) {
7896
- _context78.next = 44;
8139
+ _context80.next = 49;
7897
8140
  break;
7898
8141
  }
7899
- 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))) {
7900
- _context78.next = 36;
8142
+ 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))) {
8143
+ _context80.next = 41;
7901
8144
  break;
7902
8145
  }
7903
8146
  throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
7904
- case 36:
8147
+ case 41:
7905
8148
  if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
7906
- _context78.next = 38;
8149
+ _context80.next = 43;
7907
8150
  break;
7908
8151
  }
7909
- return _context78.abrupt("return", {
8152
+ return _context80.abrupt("return", {
7910
8153
  code: 200,
7911
8154
  message: '',
7912
8155
  order: localBeforeRefresh || paymentIdentityOrder
7913
8156
  });
7914
- case 38:
7915
- remotePayments = fresh.payments;
8157
+ case 43:
8158
+ remotePayments = _fresh2.payments;
7916
8159
  paidPayments = (localBeforeRefresh.payments || []).filter(function (payment) {
7917
8160
  return payment.status === 'paid';
7918
8161
  });
@@ -7928,115 +8171,131 @@ var Server = /*#__PURE__*/function () {
7928
8171
  return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
7929
8172
  });
7930
8173
  if (paymentIdsComplete) {
7931
- _context78.next = 43;
8174
+ _context80.next = 48;
7932
8175
  break;
7933
8176
  }
7934
8177
  throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
7935
- case 43:
7936
- orderToPersist = _objectSpread(_objectSpread({}, fresh), {}, {
8178
+ case 48:
8179
+ orderToPersist = _objectSpread(_objectSpread({}, _fresh2), {}, {
7937
8180
  payments: mergeOrderPaymentListsByIdentity(localBeforeRefresh.payments, remotePayments, {
7938
8181
  preserveUnmatchedExisting: true
7939
8182
  })
7940
8183
  });
7941
- case 44:
8184
+ case 49:
8185
+ if (prepareExactOrderForPersist) orderToPersist = prepareExactOrderForPersist(orderToPersist);
7942
8186
  if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
7943
- _context78.next = 51;
8187
+ _context80.next = 57;
7944
8188
  break;
7945
8189
  }
7946
- if (!(String(fresh.order_id) !== String(localBeforeRefresh.order_id))) {
7947
- _context78.next = 47;
8190
+ if (!(String(_fresh2.order_id) !== String(localBeforeRefresh.order_id))) {
8191
+ _context80.next = 53;
7948
8192
  break;
7949
8193
  }
7950
8194
  throw new Error('远端订单身份不匹配,请重新刷新');
7951
- case 47:
7952
- _context78.next = 49;
8195
+ case 53:
8196
+ _context80.next = 55;
7953
8197
  return this.order.completeLocalPaymentRefresh(orderToPersist);
7954
- case 49:
7955
- _context78.next = 53;
8198
+ case 55:
8199
+ _context80.next = 59;
7956
8200
  break;
7957
- case 51:
7958
- _context78.next = 53;
8201
+ case 57:
8202
+ _context80.next = 59;
7959
8203
  return this.order.upsertOrdersFromRemote([orderToPersist]);
7960
- case 53:
7961
- _context78.next = 55;
8204
+ case 59:
8205
+ if (!prepareExactOrderForPersist) {
8206
+ _context80.next = 65;
8207
+ break;
8208
+ }
8209
+ _context80.next = 62;
8210
+ return this.order.getLocalOrderByLookup(lookup, {
8211
+ exactOrderId: true
8212
+ });
8213
+ case 62:
8214
+ _context80.t3 = _context80.sent;
8215
+ _context80.next = 68;
8216
+ break;
8217
+ case 65:
8218
+ _context80.next = 67;
7962
8219
  return this.order.getLocalOrderByLookup(lookup);
7963
- case 55:
7964
- savedOrder = _context78.sent;
7965
- if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
7966
- _context78.next = 60;
8220
+ case 67:
8221
+ _context80.t3 = _context80.sent;
8222
+ case 68:
8223
+ savedOrder = _context80.t3;
8224
+ if (!(!savedOrder && _fresh2.order_id !== undefined && _fresh2.order_id !== null && String(_fresh2.order_id) !== String(lookup))) {
8225
+ _context80.next = 73;
7967
8226
  break;
7968
8227
  }
7969
- _context78.next = 59;
7970
- return this.order.getLocalOrderByLookup(fresh.order_id);
7971
- case 59:
7972
- savedOrder = _context78.sent;
7973
- case 60:
8228
+ _context80.next = 72;
8229
+ return this.order.getLocalOrderByLookup(_fresh2.order_id);
8230
+ case 72:
8231
+ savedOrder = _context80.sent;
8232
+ case 73:
7974
8233
  if (savedOrder) {
7975
- _context78.next = 63;
8234
+ _context80.next = 76;
7976
8235
  break;
7977
8236
  }
7978
8237
  this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
7979
8238
  lookup: lookup,
7980
- remote_order_id: fresh.order_id
8239
+ remote_order_id: _fresh2.order_id
7981
8240
  });
7982
- return _context78.abrupt("return", {
8241
+ return _context80.abrupt("return", {
7983
8242
  code: 500,
7984
8243
  message: '订单写入后回读失败',
7985
8244
  order: null
7986
8245
  });
7987
- case 63:
8246
+ case 76:
7988
8247
  this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
7989
8248
  lookup: lookup,
7990
- remote_order_id: fresh.order_id
8249
+ remote_order_id: _fresh2.order_id
7991
8250
  });
7992
- return _context78.abrupt("return", {
8251
+ return _context80.abrupt("return", {
7993
8252
  code: 200,
7994
8253
  message: '',
7995
8254
  order: savedOrder
7996
8255
  });
7997
- case 67:
7998
- _context78.prev = 67;
7999
- _context78.t2 = _context78["catch"](7);
8000
- backendError = this.extractBackendErrorResponse(_context78.t2);
8001
- errorRecord = _context78.t2;
8256
+ case 80:
8257
+ _context80.prev = 80;
8258
+ _context80.t4 = _context80["catch"](7);
8259
+ backendError = this.extractBackendErrorResponse(_context80.t4);
8260
+ errorRecord = _context80.t4;
8002
8261
  _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;
8003
8262
  if (!(backendError || _responseStatusCode !== undefined)) {
8004
- _context78.next = 78;
8263
+ _context80.next = 91;
8005
8264
  break;
8006
8265
  }
8007
8266
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
8008
- _code = this.normalizeRemoteSalesOrderErrorCode((_ref84 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref84 !== void 0 ? _ref84 : _responseStatusCode);
8009
- _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context78.t2);
8267
+ _code = this.normalizeRemoteSalesOrderErrorCode((_ref86 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref86 !== void 0 ? _ref86 : _responseStatusCode);
8268
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context80.t4);
8010
8269
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
8011
8270
  lookup: lookup,
8012
8271
  backendPath: backendPath,
8013
8272
  code: _code,
8014
8273
  message: _message2
8015
8274
  });
8016
- return _context78.abrupt("return", {
8275
+ return _context80.abrupt("return", {
8017
8276
  code: _code,
8018
8277
  message: _message2,
8019
8278
  order: null
8020
8279
  });
8021
- case 78:
8022
- _message3 = this.getUnknownErrorMessage(_context78.t2);
8280
+ case 91:
8281
+ _message3 = this.getUnknownErrorMessage(_context80.t4);
8023
8282
  this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
8024
8283
  lookup: lookup,
8025
8284
  backendPath: backendPath,
8026
8285
  error: _message3
8027
8286
  });
8028
- return _context78.abrupt("return", {
8287
+ return _context80.abrupt("return", {
8029
8288
  code: 500,
8030
8289
  message: _message3,
8031
8290
  order: null
8032
8291
  });
8033
- case 81:
8292
+ case 94:
8034
8293
  case "end":
8035
- return _context78.stop();
8294
+ return _context80.stop();
8036
8295
  }
8037
- }, _callee78, this, [[7, 67]]);
8296
+ }, _callee80, this, [[7, 80]]);
8038
8297
  }));
8039
- function fetchAndPersistSalesOrderByLookup(_x87, _x88, _x89, _x90) {
8298
+ function fetchAndPersistSalesOrderByLookup(_x92, _x93, _x94, _x95, _x96) {
8040
8299
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
8041
8300
  }
8042
8301
  return fetchAndPersistSalesOrderByLookup;
@@ -8098,22 +8357,22 @@ var Server = /*#__PURE__*/function () {
8098
8357
  }, {
8099
8358
  key: "handleUpdateLocalOrdersBatch",
8100
8359
  value: (function () {
8101
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(orderIds) {
8360
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(orderIds) {
8102
8361
  var _this$app20;
8103
- var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
8104
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8105
- while (1) switch (_context79.prev = _context79.next) {
8362
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, _fresh3, _message4, overwritten, inserted;
8363
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8364
+ while (1) switch (_context81.prev = _context81.next) {
8106
8365
  case 0:
8107
8366
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
8108
8367
  count: orderIds.length,
8109
8368
  orderIds: orderIds
8110
8369
  });
8111
8370
  if (this.order) {
8112
- _context79.next = 4;
8371
+ _context81.next = 4;
8113
8372
  break;
8114
8373
  }
8115
8374
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
8116
- return _context79.abrupt("return", {
8375
+ return _context81.abrupt("return", {
8117
8376
  code: 500,
8118
8377
  status: false,
8119
8378
  message: 'Order 模块未注册',
@@ -8121,11 +8380,11 @@ var Server = /*#__PURE__*/function () {
8121
8380
  });
8122
8381
  case 4:
8123
8382
  if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && _this$app20.request) {
8124
- _context79.next = 7;
8383
+ _context81.next = 7;
8125
8384
  break;
8126
8385
  }
8127
8386
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
8128
- return _context79.abrupt("return", {
8387
+ return _context81.abrupt("return", {
8129
8388
  code: 500,
8130
8389
  status: false,
8131
8390
  message: 'app.request 不可用',
@@ -8148,21 +8407,21 @@ var Server = /*#__PURE__*/function () {
8148
8407
  _iterator13.f();
8149
8408
  }
8150
8409
  fetched = [];
8151
- _context79.prev = 11;
8152
- _context79.next = 14;
8410
+ _context81.prev = 11;
8411
+ _context81.next = 14;
8153
8412
  return this.order.fetchOrdersByHttp(orderIds);
8154
8413
  case 14:
8155
- fetched = _context79.sent;
8156
- _context79.next = 22;
8414
+ fetched = _context81.sent;
8415
+ _context81.next = 22;
8157
8416
  break;
8158
8417
  case 17:
8159
- _context79.prev = 17;
8160
- _context79.t0 = _context79["catch"](11);
8161
- message = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
8418
+ _context81.prev = 17;
8419
+ _context81.t0 = _context81["catch"](11);
8420
+ message = _context81.t0 instanceof Error ? _context81.t0.message : String(_context81.t0);
8162
8421
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
8163
8422
  message: message
8164
8423
  });
8165
- return _context79.abrupt("return", {
8424
+ return _context81.abrupt("return", {
8166
8425
  code: 500,
8167
8426
  status: false,
8168
8427
  message: message,
@@ -8172,36 +8431,36 @@ var Server = /*#__PURE__*/function () {
8172
8431
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
8173
8432
  fetchedMap = new Map();
8174
8433
  _iterator14 = _createForOfIteratorHelper(fetched);
8175
- _context79.prev = 24;
8434
+ _context81.prev = 24;
8176
8435
  _iterator14.s();
8177
8436
  case 26:
8178
8437
  if ((_step14 = _iterator14.n()).done) {
8179
- _context79.next = 34;
8438
+ _context81.next = 34;
8180
8439
  break;
8181
8440
  }
8182
8441
  order = _step14.value;
8183
8442
  oid = order === null || order === void 0 ? void 0 : order.order_id;
8184
8443
  if (!(oid === undefined || oid === null)) {
8185
- _context79.next = 31;
8444
+ _context81.next = 31;
8186
8445
  break;
8187
8446
  }
8188
- return _context79.abrupt("continue", 32);
8447
+ return _context81.abrupt("continue", 32);
8189
8448
  case 31:
8190
8449
  fetchedMap.set(String(oid), order);
8191
8450
  case 32:
8192
- _context79.next = 26;
8451
+ _context81.next = 26;
8193
8452
  break;
8194
8453
  case 34:
8195
- _context79.next = 39;
8454
+ _context81.next = 39;
8196
8455
  break;
8197
8456
  case 36:
8198
- _context79.prev = 36;
8199
- _context79.t1 = _context79["catch"](24);
8200
- _iterator14.e(_context79.t1);
8457
+ _context81.prev = 36;
8458
+ _context81.t1 = _context81["catch"](24);
8459
+ _iterator14.e(_context81.t1);
8201
8460
  case 39:
8202
- _context79.prev = 39;
8461
+ _context81.prev = 39;
8203
8462
  _iterator14.f();
8204
- return _context79.finish(39);
8463
+ return _context81.finish(39);
8205
8464
  case 42:
8206
8465
  freshOrders = [];
8207
8466
  succeedIds = [];
@@ -8210,9 +8469,9 @@ var Server = /*#__PURE__*/function () {
8210
8469
  try {
8211
8470
  for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
8212
8471
  _id = _step15.value;
8213
- fresh = fetchedMap.get(_id);
8214
- if (fresh) {
8215
- freshOrders.push(fresh);
8472
+ _fresh3 = fetchedMap.get(_id);
8473
+ if (_fresh3) {
8474
+ freshOrders.push(_fresh3);
8216
8475
  succeedIds.push(_id);
8217
8476
  } else {
8218
8477
  failed.push({
@@ -8227,23 +8486,23 @@ var Server = /*#__PURE__*/function () {
8227
8486
  _iterator15.f();
8228
8487
  }
8229
8488
  if (!(freshOrders.length > 0)) {
8230
- _context79.next = 58;
8489
+ _context81.next = 58;
8231
8490
  break;
8232
8491
  }
8233
- _context79.prev = 48;
8234
- _context79.next = 51;
8492
+ _context81.prev = 48;
8493
+ _context81.next = 51;
8235
8494
  return this.order.upsertOrdersFromRemote(freshOrders);
8236
8495
  case 51:
8237
- _context79.next = 58;
8496
+ _context81.next = 58;
8238
8497
  break;
8239
8498
  case 53:
8240
- _context79.prev = 53;
8241
- _context79.t2 = _context79["catch"](48);
8242
- _message4 = _context79.t2 instanceof Error ? _context79.t2.message : String(_context79.t2);
8499
+ _context81.prev = 53;
8500
+ _context81.t2 = _context81["catch"](48);
8501
+ _message4 = _context81.t2 instanceof Error ? _context81.t2.message : String(_context81.t2);
8243
8502
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
8244
8503
  message: _message4
8245
8504
  });
8246
- return _context79.abrupt("return", {
8505
+ return _context81.abrupt("return", {
8247
8506
  code: 500,
8248
8507
  status: false,
8249
8508
  message: _message4,
@@ -8262,7 +8521,7 @@ var Server = /*#__PURE__*/function () {
8262
8521
  insertedCount: inserted.length,
8263
8522
  failedCount: failed.length
8264
8523
  });
8265
- return _context79.abrupt("return", {
8524
+ return _context81.abrupt("return", {
8266
8525
  code: 200,
8267
8526
  status: true,
8268
8527
  message: '',
@@ -8274,11 +8533,11 @@ var Server = /*#__PURE__*/function () {
8274
8533
  });
8275
8534
  case 62:
8276
8535
  case "end":
8277
- return _context79.stop();
8536
+ return _context81.stop();
8278
8537
  }
8279
- }, _callee79, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8538
+ }, _callee81, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8280
8539
  }));
8281
- function handleUpdateLocalOrdersBatch(_x91) {
8540
+ function handleUpdateLocalOrdersBatch(_x97) {
8282
8541
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
8283
8542
  }
8284
8543
  return handleUpdateLocalOrdersBatch;
@@ -8525,10 +8784,10 @@ var Server = /*#__PURE__*/function () {
8525
8784
  value: function extractBackendErrorResponse(error) {
8526
8785
  var _error$response3,
8527
8786
  _error$response4,
8528
- _this25 = this;
8787
+ _this26 = this;
8529
8788
  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];
8530
8789
  return candidates.find(function (candidate) {
8531
- return _this25.isExplicitBackendErrorResponse(candidate);
8790
+ return _this26.isExplicitBackendErrorResponse(candidate);
8532
8791
  }) || null;
8533
8792
  }
8534
8793
  }, {
@@ -8647,16 +8906,16 @@ var Server = /*#__PURE__*/function () {
8647
8906
  }, {
8648
8907
  key: "recomputeAndNotifyFloorPlanQuery",
8649
8908
  value: (function () {
8650
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80() {
8909
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82() {
8651
8910
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
8652
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8653
- while (1) switch (_context80.prev = _context80.next) {
8911
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8912
+ while (1) switch (_context82.prev = _context82.next) {
8654
8913
  case 0:
8655
8914
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
8656
- _context80.next = 2;
8915
+ _context82.next = 2;
8657
8916
  break;
8658
8917
  }
8659
- return _context80.abrupt("return");
8918
+ return _context82.abrupt("return");
8660
8919
  case 2:
8661
8920
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
8662
8921
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -8686,9 +8945,9 @@ var Server = /*#__PURE__*/function () {
8686
8945
  }
8687
8946
  case 5:
8688
8947
  case "end":
8689
- return _context80.stop();
8948
+ return _context82.stop();
8690
8949
  }
8691
- }, _callee80, this);
8950
+ }, _callee82, this);
8692
8951
  }));
8693
8952
  function recomputeAndNotifyFloorPlanQuery() {
8694
8953
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -8718,20 +8977,20 @@ var Server = /*#__PURE__*/function () {
8718
8977
  * filter 逻辑暂为 mock,仅记录参数
8719
8978
  */
8720
8979
  function () {
8721
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(data) {
8980
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(data) {
8722
8981
  var rawList, result;
8723
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8724
- while (1) switch (_context81.prev = _context81.next) {
8982
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8983
+ while (1) switch (_context83.prev = _context83.next) {
8725
8984
  case 0:
8726
8985
  this.logInfo('computeOrderQueryResult: 开始过滤', {
8727
8986
  data: data
8728
8987
  });
8729
8988
  if (this.order) {
8730
- _context81.next = 4;
8989
+ _context83.next = 4;
8731
8990
  break;
8732
8991
  }
8733
8992
  this.logError('computeOrderQueryResult: Order 模块未注册');
8734
- return _context81.abrupt("return", {
8993
+ return _context83.abrupt("return", {
8735
8994
  code: 500,
8736
8995
  message: 'Order 模块未注册',
8737
8996
  data: {
@@ -8763,7 +9022,7 @@ var Server = /*#__PURE__*/function () {
8763
9022
  skip: result.skip,
8764
9023
  rejected: result.rejected
8765
9024
  });
8766
- return _context81.abrupt("return", {
9025
+ return _context83.abrupt("return", {
8767
9026
  code: 200,
8768
9027
  data: result,
8769
9028
  message: '',
@@ -8771,11 +9030,11 @@ var Server = /*#__PURE__*/function () {
8771
9030
  });
8772
9031
  case 10:
8773
9032
  case "end":
8774
- return _context81.stop();
9033
+ return _context83.stop();
8775
9034
  }
8776
- }, _callee81, this);
9035
+ }, _callee83, this);
8777
9036
  }));
8778
- function computeOrderQueryResult(_x92) {
9037
+ function computeOrderQueryResult(_x98) {
8779
9038
  return _computeOrderQueryResult.apply(this, arguments);
8780
9039
  }
8781
9040
  return computeOrderQueryResult;
@@ -8788,17 +9047,17 @@ var Server = /*#__PURE__*/function () {
8788
9047
  }, {
8789
9048
  key: "computeBookingQueryResult",
8790
9049
  value: (function () {
8791
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(data) {
9050
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(data) {
8792
9051
  var rawOrders, result;
8793
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8794
- while (1) switch (_context82.prev = _context82.next) {
9052
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9053
+ while (1) switch (_context84.prev = _context84.next) {
8795
9054
  case 0:
8796
9055
  if (this.order) {
8797
- _context82.next = 3;
9056
+ _context84.next = 3;
8798
9057
  break;
8799
9058
  }
8800
9059
  this.logError('computeBookingQueryResult: Order 模块未注册');
8801
- return _context82.abrupt("return", {
9060
+ return _context84.abrupt("return", {
8802
9061
  code: 500,
8803
9062
  message: 'Order 模块未注册',
8804
9063
  data: {
@@ -8817,7 +9076,7 @@ var Server = /*#__PURE__*/function () {
8817
9076
  size: result.size,
8818
9077
  skip: result.skip
8819
9078
  });
8820
- return _context82.abrupt("return", {
9079
+ return _context84.abrupt("return", {
8821
9080
  code: 200,
8822
9081
  data: result,
8823
9082
  message: '',
@@ -8825,11 +9084,11 @@ var Server = /*#__PURE__*/function () {
8825
9084
  });
8826
9085
  case 8:
8827
9086
  case "end":
8828
- return _context82.stop();
9087
+ return _context84.stop();
8829
9088
  }
8830
- }, _callee82, this);
9089
+ }, _callee84, this);
8831
9090
  }));
8832
- function computeBookingQueryResult(_x93) {
9091
+ function computeBookingQueryResult(_x99) {
8833
9092
  return _computeBookingQueryResult.apply(this, arguments);
8834
9093
  }
8835
9094
  return computeBookingQueryResult;
@@ -8888,12 +9147,12 @@ var Server = /*#__PURE__*/function () {
8888
9147
  }, {
8889
9148
  key: "computeProductQueryResult",
8890
9149
  value: (function () {
8891
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(context, options) {
9150
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(context, options) {
8892
9151
  var _menu_list_ids$length3,
8893
- _this26 = this;
9152
+ _this27 = this;
8894
9153
  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;
8895
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8896
- while (1) switch (_context83.prev = _context83.next) {
9154
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9155
+ while (1) switch (_context85.prev = _context85.next) {
8897
9156
  case 0:
8898
9157
  tTotal = performance.now();
8899
9158
  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 查询额外按商品销售渠道过滤。
@@ -8922,10 +9181,10 @@ var Server = /*#__PURE__*/function () {
8922
9181
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
8923
9182
  startupPreloadTask = this.startupModulePreloadInFlight;
8924
9183
  if (!startupPreloadTask) {
8925
- _context83.next = 9;
9184
+ _context85.next = 9;
8926
9185
  break;
8927
9186
  }
8928
- _context83.next = 9;
9187
+ _context85.next = 9;
8929
9188
  return startupPreloadTask;
8930
9189
  case 9:
8931
9190
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -8937,28 +9196,28 @@ var Server = /*#__PURE__*/function () {
8937
9196
  strategy_context: strategy_context
8938
9197
  });
8939
9198
  if (this.products) {
8940
- _context83.next = 13;
9199
+ _context85.next = 13;
8941
9200
  break;
8942
9201
  }
8943
9202
  this.logError('computeProductQueryResult: Products 模块未注册');
8944
- return _context83.abrupt("return", {
9203
+ return _context85.abrupt("return", {
8945
9204
  message: 'Products 模块未注册',
8946
9205
  data: this.buildProductQueryResultPayload([], 0)
8947
9206
  });
8948
9207
  case 13:
8949
9208
  if (!(queryIds.length > 0)) {
8950
- _context83.next = 25;
9209
+ _context85.next = 25;
8951
9210
  break;
8952
9211
  }
8953
9212
  uniqueIds = Array.from(new Set(queryIds));
8954
9213
  _tPrice = performance.now();
8955
- _context83.next = 18;
9214
+ _context85.next = 18;
8956
9215
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8957
9216
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8958
9217
  productIds: uniqueIds
8959
9218
  });
8960
9219
  case 18:
8961
- productsWithPrice = _context83.sent;
9220
+ productsWithPrice = _context85.sent;
8962
9221
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
8963
9222
  count: productsWithPrice.length,
8964
9223
  ids: uniqueIds
@@ -8976,7 +9235,7 @@ var Server = /*#__PURE__*/function () {
8976
9235
  ids: uniqueIds,
8977
9236
  count: extensionFilteredProducts.length
8978
9237
  });
8979
- return _context83.abrupt("return", {
9238
+ return _context85.abrupt("return", {
8980
9239
  code: 200,
8981
9240
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
8982
9241
  message: '',
@@ -8984,17 +9243,17 @@ var Server = /*#__PURE__*/function () {
8984
9243
  });
8985
9244
  case 25:
8986
9245
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
8987
- _context83.next = 37;
9246
+ _context85.next = 37;
8988
9247
  break;
8989
9248
  }
8990
9249
  pid = Number(product_id);
8991
9250
  _tPrice2 = performance.now();
8992
- _context83.next = 30;
9251
+ _context85.next = 30;
8993
9252
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8994
9253
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8995
9254
  });
8996
9255
  case 30:
8997
- allProductsWithPrice = _context83.sent;
9256
+ allProductsWithPrice = _context85.sent;
8998
9257
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
8999
9258
  count: allProductsWithPrice.length,
9000
9259
  productId: pid
@@ -9012,7 +9271,7 @@ var Server = /*#__PURE__*/function () {
9012
9271
  productId: pid,
9013
9272
  found: !!item
9014
9273
  });
9015
- return _context83.abrupt("return", {
9274
+ return _context85.abrupt("return", {
9016
9275
  code: 200,
9017
9276
  data: item,
9018
9277
  message: item ? '' : '商品不存在或未发布',
@@ -9020,16 +9279,16 @@ var Server = /*#__PURE__*/function () {
9020
9279
  });
9021
9280
  case 37:
9022
9281
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
9023
- _context83.next = 57;
9282
+ _context85.next = 57;
9024
9283
  break;
9025
9284
  }
9026
9285
  _tPrice3 = performance.now();
9027
- _context83.next = 41;
9286
+ _context85.next = 41;
9028
9287
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9029
9288
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9030
9289
  });
9031
9290
  case 41:
9032
- _filteredProducts2 = _context83.sent;
9291
+ _filteredProducts2 = _context85.sent;
9033
9292
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
9034
9293
  count: _filteredProducts2.length,
9035
9294
  extension_type: extension_type
@@ -9066,7 +9325,7 @@ var Server = /*#__PURE__*/function () {
9066
9325
  filteredCount: _filteredProducts2.length,
9067
9326
  extension_type: extension_type
9068
9327
  });
9069
- return _context83.abrupt("return", {
9328
+ return _context85.abrupt("return", {
9070
9329
  code: 200,
9071
9330
  data: this.buildProductQueryResultPayload(_filteredProducts2),
9072
9331
  message: '',
@@ -9074,50 +9333,50 @@ var Server = /*#__PURE__*/function () {
9074
9333
  });
9075
9334
  case 57:
9076
9335
  if (this.menu) {
9077
- _context83.next = 60;
9336
+ _context85.next = 60;
9078
9337
  break;
9079
9338
  }
9080
9339
  this.logError('computeProductQueryResult: Menu 模块未注册');
9081
- return _context83.abrupt("return", {
9340
+ return _context85.abrupt("return", {
9082
9341
  message: 'Menu 模块未注册',
9083
9342
  data: this.buildProductQueryResultPayload([], 0)
9084
9343
  });
9085
9344
  case 60:
9086
9345
  if (this.schedule) {
9087
- _context83.next = 63;
9346
+ _context85.next = 63;
9088
9347
  break;
9089
9348
  }
9090
9349
  this.logError('computeProductQueryResult: Schedule 模块未注册');
9091
- return _context83.abrupt("return", {
9350
+ return _context85.abrupt("return", {
9092
9351
  message: 'Schedule 模块未注册',
9093
9352
  data: this.buildProductQueryResultPayload([], 0)
9094
9353
  });
9095
9354
  case 63:
9096
9355
  activeMenuList = [];
9097
9356
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
9098
- _context83.next = 76;
9357
+ _context85.next = 76;
9099
9358
  break;
9100
9359
  }
9101
9360
  tMenu = performance.now();
9102
9361
  getActiveMenus = function getActiveMenus() {
9103
- return _this26.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9104
- var _this26$schedule;
9105
- return ((_this26$schedule = _this26.schedule) === null || _this26$schedule === void 0 ? void 0 : _this26$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9362
+ return _this27.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9363
+ var _this27$schedule;
9364
+ return ((_this27$schedule = _this27.schedule) === null || _this27$schedule === void 0 ? void 0 : _this27$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9106
9365
  });
9107
9366
  };
9108
9367
  activeMenuList = getActiveMenus();
9109
- _context83.t0 = !activeMenuList.length;
9110
- if (!_context83.t0) {
9111
- _context83.next = 73;
9368
+ _context85.t0 = !activeMenuList.length;
9369
+ if (!_context85.t0) {
9370
+ _context85.next = 73;
9112
9371
  break;
9113
9372
  }
9114
- _context83.next = 72;
9373
+ _context85.next = 72;
9115
9374
  return this.refreshMenuScheduleCacheAfterEmptyResult();
9116
9375
  case 72:
9117
- _context83.t0 = _context83.sent;
9376
+ _context85.t0 = _context85.sent;
9118
9377
  case 73:
9119
- if (!_context83.t0) {
9120
- _context83.next = 75;
9378
+ if (!_context85.t0) {
9379
+ _context85.next = 75;
9121
9380
  break;
9122
9381
  }
9123
9382
  activeMenuList = getActiveMenus();
@@ -9137,22 +9396,22 @@ var Server = /*#__PURE__*/function () {
9137
9396
  });
9138
9397
  tPrice = performance.now();
9139
9398
  if (!(scopedProductIds.length > 0)) {
9140
- _context83.next = 87;
9399
+ _context85.next = 87;
9141
9400
  break;
9142
9401
  }
9143
- _context83.next = 84;
9402
+ _context85.next = 84;
9144
9403
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
9145
9404
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
9146
9405
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
9147
9406
  });
9148
9407
  case 84:
9149
- _context83.t1 = _context83.sent;
9150
- _context83.next = 88;
9408
+ _context85.t1 = _context85.sent;
9409
+ _context85.next = 88;
9151
9410
  break;
9152
9411
  case 87:
9153
- _context83.t1 = [];
9412
+ _context85.t1 = [];
9154
9413
  case 88:
9155
- filteredProducts = _context83.t1;
9414
+ filteredProducts = _context85.t1;
9156
9415
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
9157
9416
  count: filteredProducts.length,
9158
9417
  scopedProductCount: scopedProductIds.length
@@ -9191,7 +9450,7 @@ var Server = /*#__PURE__*/function () {
9191
9450
  filteredCount: filteredProducts.length,
9192
9451
  activeMenuCount: activeMenuList.length
9193
9452
  });
9194
- return _context83.abrupt("return", {
9453
+ return _context85.abrupt("return", {
9195
9454
  code: 200,
9196
9455
  data: this.buildProductQueryResultPayload(filteredProducts),
9197
9456
  message: '',
@@ -9199,11 +9458,11 @@ var Server = /*#__PURE__*/function () {
9199
9458
  });
9200
9459
  case 104:
9201
9460
  case "end":
9202
- return _context83.stop();
9461
+ return _context85.stop();
9203
9462
  }
9204
- }, _callee83, this);
9463
+ }, _callee85, this);
9205
9464
  }));
9206
- function computeProductQueryResult(_x94, _x95) {
9465
+ function computeProductQueryResult(_x100, _x101) {
9207
9466
  return _computeProductQueryResult.apply(this, arguments);
9208
9467
  }
9209
9468
  return computeProductQueryResult;
@@ -9241,74 +9500,74 @@ var Server = /*#__PURE__*/function () {
9241
9500
  }, {
9242
9501
  key: "recomputeAndNotifyProductQuery",
9243
9502
  value: (function () {
9244
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(options) {
9503
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(options) {
9245
9504
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
9246
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9247
- while (1) switch (_context84.prev = _context84.next) {
9505
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9506
+ while (1) switch (_context86.prev = _context86.next) {
9248
9507
  case 0:
9249
9508
  if (!(this.productQuerySubscribers.size === 0)) {
9250
- _context84.next = 2;
9509
+ _context86.next = 2;
9251
9510
  break;
9252
9511
  }
9253
- return _context84.abrupt("return");
9512
+ return _context86.abrupt("return");
9254
9513
  case 2:
9255
9514
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
9256
9515
  subscriberCount: this.productQuerySubscribers.size,
9257
9516
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9258
9517
  });
9259
9518
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
9260
- _context84.prev = 4;
9519
+ _context86.prev = 4;
9261
9520
  _iterator18.s();
9262
9521
  case 6:
9263
9522
  if ((_step18 = _iterator18.n()).done) {
9264
- _context84.next = 23;
9523
+ _context86.next = 23;
9265
9524
  break;
9266
9525
  }
9267
9526
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
9268
- _context84.prev = 8;
9269
- _context84.next = 11;
9527
+ _context86.prev = 8;
9528
+ _context86.next = 11;
9270
9529
  return this.computeProductQueryResult(subscriber.context, {
9271
9530
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9272
9531
  });
9273
9532
  case 11:
9274
- result = _context84.sent;
9275
- _context84.next = 14;
9533
+ result = _context86.sent;
9534
+ _context86.next = 14;
9276
9535
  return subscriber.callback(result);
9277
9536
  case 14:
9278
9537
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
9279
9538
  subscriberId: subscriberId
9280
9539
  });
9281
- _context84.next = 21;
9540
+ _context86.next = 21;
9282
9541
  break;
9283
9542
  case 17:
9284
- _context84.prev = 17;
9285
- _context84.t0 = _context84["catch"](8);
9286
- errorMessage = _context84.t0 instanceof Error ? _context84.t0.message : String(_context84.t0);
9543
+ _context86.prev = 17;
9544
+ _context86.t0 = _context86["catch"](8);
9545
+ errorMessage = _context86.t0 instanceof Error ? _context86.t0.message : String(_context86.t0);
9287
9546
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
9288
9547
  subscriberId: subscriberId,
9289
9548
  error: errorMessage
9290
9549
  });
9291
9550
  case 21:
9292
- _context84.next = 6;
9551
+ _context86.next = 6;
9293
9552
  break;
9294
9553
  case 23:
9295
- _context84.next = 28;
9554
+ _context86.next = 28;
9296
9555
  break;
9297
9556
  case 25:
9298
- _context84.prev = 25;
9299
- _context84.t1 = _context84["catch"](4);
9300
- _iterator18.e(_context84.t1);
9557
+ _context86.prev = 25;
9558
+ _context86.t1 = _context86["catch"](4);
9559
+ _iterator18.e(_context86.t1);
9301
9560
  case 28:
9302
- _context84.prev = 28;
9561
+ _context86.prev = 28;
9303
9562
  _iterator18.f();
9304
- return _context84.finish(28);
9563
+ return _context86.finish(28);
9305
9564
  case 31:
9306
9565
  case "end":
9307
- return _context84.stop();
9566
+ return _context86.stop();
9308
9567
  }
9309
- }, _callee84, this, [[4, 25, 28, 31], [8, 17]]);
9568
+ }, _callee86, this, [[4, 25, 28, 31], [8, 17]]);
9310
9569
  }));
9311
- function recomputeAndNotifyProductQuery(_x96) {
9570
+ function recomputeAndNotifyProductQuery(_x102) {
9312
9571
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
9313
9572
  }
9314
9573
  return recomputeAndNotifyProductQuery;
@@ -9320,16 +9579,16 @@ var Server = /*#__PURE__*/function () {
9320
9579
  }, {
9321
9580
  key: "recomputeAndNotifyOrderQuery",
9322
9581
  value: (function () {
9323
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85() {
9582
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87() {
9324
9583
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
9325
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9326
- while (1) switch (_context85.prev = _context85.next) {
9584
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
9585
+ while (1) switch (_context87.prev = _context87.next) {
9327
9586
  case 0:
9328
9587
  if (!(this.orderQuerySubscribers.size === 0)) {
9329
- _context85.next = 2;
9588
+ _context87.next = 2;
9330
9589
  break;
9331
9590
  }
9332
- return _context85.abrupt("return");
9591
+ return _context87.abrupt("return");
9333
9592
  case 2:
9334
9593
  notifyStartAt = Date.now();
9335
9594
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -9337,20 +9596,20 @@ var Server = /*#__PURE__*/function () {
9337
9596
  notifyStartAt: new Date(notifyStartAt).toISOString()
9338
9597
  });
9339
9598
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
9340
- _context85.prev = 5;
9599
+ _context87.prev = 5;
9341
9600
  _iterator19.s();
9342
9601
  case 7:
9343
9602
  if ((_step19 = _iterator19.n()).done) {
9344
- _context85.next = 27;
9603
+ _context87.next = 27;
9345
9604
  break;
9346
9605
  }
9347
9606
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
9348
- _context85.prev = 9;
9607
+ _context87.prev = 9;
9349
9608
  computeStartAt = Date.now();
9350
- _context85.next = 13;
9609
+ _context87.next = 13;
9351
9610
  return this.computeOrderQueryResult(subscriber.context);
9352
9611
  case 13:
9353
- result = _context85.sent;
9612
+ result = _context87.sent;
9354
9613
  computeEndAt = Date.now();
9355
9614
  callbackStartAt = Date.now();
9356
9615
  subscriber.callback(result);
@@ -9361,30 +9620,30 @@ var Server = /*#__PURE__*/function () {
9361
9620
  callbackDurationMs: callbackEndAt - callbackStartAt,
9362
9621
  totalDurationMs: callbackEndAt - computeStartAt
9363
9622
  });
9364
- _context85.next = 25;
9623
+ _context87.next = 25;
9365
9624
  break;
9366
9625
  case 21:
9367
- _context85.prev = 21;
9368
- _context85.t0 = _context85["catch"](9);
9369
- errorMessage = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
9626
+ _context87.prev = 21;
9627
+ _context87.t0 = _context87["catch"](9);
9628
+ errorMessage = _context87.t0 instanceof Error ? _context87.t0.message : String(_context87.t0);
9370
9629
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
9371
9630
  subscriberId: subscriberId,
9372
9631
  error: errorMessage
9373
9632
  });
9374
9633
  case 25:
9375
- _context85.next = 7;
9634
+ _context87.next = 7;
9376
9635
  break;
9377
9636
  case 27:
9378
- _context85.next = 32;
9637
+ _context87.next = 32;
9379
9638
  break;
9380
9639
  case 29:
9381
- _context85.prev = 29;
9382
- _context85.t1 = _context85["catch"](5);
9383
- _iterator19.e(_context85.t1);
9640
+ _context87.prev = 29;
9641
+ _context87.t1 = _context87["catch"](5);
9642
+ _iterator19.e(_context87.t1);
9384
9643
  case 32:
9385
- _context85.prev = 32;
9644
+ _context87.prev = 32;
9386
9645
  _iterator19.f();
9387
- return _context85.finish(32);
9646
+ return _context87.finish(32);
9388
9647
  case 35:
9389
9648
  notifyEndAt = Date.now();
9390
9649
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -9393,9 +9652,9 @@ var Server = /*#__PURE__*/function () {
9393
9652
  });
9394
9653
  case 37:
9395
9654
  case "end":
9396
- return _context85.stop();
9655
+ return _context87.stop();
9397
9656
  }
9398
- }, _callee85, this, [[5, 29, 32, 35], [9, 21]]);
9657
+ }, _callee87, this, [[5, 29, 32, 35], [9, 21]]);
9399
9658
  }));
9400
9659
  function recomputeAndNotifyOrderQuery() {
9401
9660
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -9413,7 +9672,7 @@ var Server = /*#__PURE__*/function () {
9413
9672
  }, {
9414
9673
  key: "notifySalesSearchSubscribers",
9415
9674
  value: function notifySalesSearchSubscribers(payload) {
9416
- var _this27 = this;
9675
+ var _this28 = this;
9417
9676
  if (this.salesSearchSubscribers.size === 0) return;
9418
9677
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
9419
9678
  if (changedOrders.length === 0) {
@@ -9431,21 +9690,21 @@ var Server = /*#__PURE__*/function () {
9431
9690
  subscriber = _step20$value[1];
9432
9691
  try {
9433
9692
  var changedVisibleOrders = changedOrders.filter(function (order) {
9434
- var orderId = _this27.getSalesSearchOrderId(order);
9693
+ var orderId = _this28.getSalesSearchOrderId(order);
9435
9694
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
9436
9695
  });
9437
9696
  if (changedVisibleOrders.length === 0) {
9438
9697
  return 1; // continue
9439
9698
  }
9440
- subscriber.callback(_this27.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9441
- _this27.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9699
+ subscriber.callback(_this28.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9700
+ _this28.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9442
9701
  subscriberId: subscriberId,
9443
9702
  kind: subscriber.kind,
9444
9703
  count: changedVisibleOrders.length
9445
9704
  });
9446
9705
  } catch (error) {
9447
9706
  var errorMessage = error instanceof Error ? error.message : String(error);
9448
- _this27.logError('notifySalesSearchSubscribers: 推送失败', {
9707
+ _this28.logError('notifySalesSearchSubscribers: 推送失败', {
9449
9708
  subscriberId: subscriberId,
9450
9709
  error: errorMessage
9451
9710
  });
@@ -9536,67 +9795,67 @@ var Server = /*#__PURE__*/function () {
9536
9795
  }, {
9537
9796
  key: "recomputeAndNotifyBookingQuery",
9538
9797
  value: (function () {
9539
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
9798
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88() {
9540
9799
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
9541
- return _regeneratorRuntime().wrap(function _callee86$(_context86) {
9542
- while (1) switch (_context86.prev = _context86.next) {
9800
+ return _regeneratorRuntime().wrap(function _callee88$(_context88) {
9801
+ while (1) switch (_context88.prev = _context88.next) {
9543
9802
  case 0:
9544
9803
  if (!(this.bookingQuerySubscribers.size === 0)) {
9545
- _context86.next = 2;
9804
+ _context88.next = 2;
9546
9805
  break;
9547
9806
  }
9548
- return _context86.abrupt("return");
9807
+ return _context88.abrupt("return");
9549
9808
  case 2:
9550
9809
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
9551
9810
  subscriberCount: this.bookingQuerySubscribers.size
9552
9811
  });
9553
9812
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
9554
- _context86.prev = 4;
9813
+ _context88.prev = 4;
9555
9814
  _iterator21.s();
9556
9815
  case 6:
9557
9816
  if ((_step21 = _iterator21.n()).done) {
9558
- _context86.next = 22;
9817
+ _context88.next = 22;
9559
9818
  break;
9560
9819
  }
9561
9820
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
9562
- _context86.prev = 8;
9563
- _context86.next = 11;
9821
+ _context88.prev = 8;
9822
+ _context88.next = 11;
9564
9823
  return this.computeBookingQueryResult(subscriber.context);
9565
9824
  case 11:
9566
- result = _context86.sent;
9825
+ result = _context88.sent;
9567
9826
  subscriber.callback(result);
9568
9827
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
9569
9828
  subscriberId: subscriberId
9570
9829
  });
9571
- _context86.next = 20;
9830
+ _context88.next = 20;
9572
9831
  break;
9573
9832
  case 16:
9574
- _context86.prev = 16;
9575
- _context86.t0 = _context86["catch"](8);
9576
- errorMessage = _context86.t0 instanceof Error ? _context86.t0.message : String(_context86.t0);
9833
+ _context88.prev = 16;
9834
+ _context88.t0 = _context88["catch"](8);
9835
+ errorMessage = _context88.t0 instanceof Error ? _context88.t0.message : String(_context88.t0);
9577
9836
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
9578
9837
  subscriberId: subscriberId,
9579
9838
  error: errorMessage
9580
9839
  });
9581
9840
  case 20:
9582
- _context86.next = 6;
9841
+ _context88.next = 6;
9583
9842
  break;
9584
9843
  case 22:
9585
- _context86.next = 27;
9844
+ _context88.next = 27;
9586
9845
  break;
9587
9846
  case 24:
9588
- _context86.prev = 24;
9589
- _context86.t1 = _context86["catch"](4);
9590
- _iterator21.e(_context86.t1);
9847
+ _context88.prev = 24;
9848
+ _context88.t1 = _context88["catch"](4);
9849
+ _iterator21.e(_context88.t1);
9591
9850
  case 27:
9592
- _context86.prev = 27;
9851
+ _context88.prev = 27;
9593
9852
  _iterator21.f();
9594
- return _context86.finish(27);
9853
+ return _context88.finish(27);
9595
9854
  case 30:
9596
9855
  case "end":
9597
- return _context86.stop();
9856
+ return _context88.stop();
9598
9857
  }
9599
- }, _callee86, this, [[4, 24, 27, 30], [8, 16]]);
9858
+ }, _callee88, this, [[4, 24, 27, 30], [8, 16]]);
9600
9859
  }));
9601
9860
  function recomputeAndNotifyBookingQuery() {
9602
9861
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);