@pisell/pisellos 0.10.16 → 0.10.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/OpenData/index.d.ts +5 -2
  3. package/dist/modules/OpenData/index.js +27 -12
  4. package/dist/modules/OpenData/types.d.ts +42 -0
  5. package/dist/modules/OpenData/types.js +7 -1
  6. package/dist/modules/OpenData/utils.d.ts +15 -1
  7. package/dist/modules/OpenData/utils.js +85 -0
  8. package/dist/modules/Order/index.d.ts +3 -1
  9. package/dist/modules/Order/index.js +68 -44
  10. package/dist/modules/Order/types.d.ts +3 -0
  11. package/dist/modules/Order/types.js +1 -0
  12. package/dist/modules/ProductList/index.js +96 -74
  13. package/dist/modules/Rules/index.js +11 -8
  14. package/dist/modules/SalesSummary/index.js +6 -4
  15. package/dist/server/index.d.ts +11 -0
  16. package/dist/server/index.js +845 -481
  17. package/dist/server/modules/order/index.d.ts +8 -0
  18. package/dist/server/modules/order/index.js +251 -215
  19. package/dist/server/utils/small-ticket.d.ts +9 -1
  20. package/dist/server/utils/small-ticket.js +117 -43
  21. package/dist/solution/BaseSales/index.d.ts +7 -0
  22. package/dist/solution/BaseSales/index.js +251 -144
  23. package/dist/solution/BookingByStep/index.d.ts +2 -2
  24. package/dist/solution/BookingTicket/index.d.ts +14 -19
  25. package/dist/solution/BookingTicket/index.js +545 -429
  26. package/dist/solution/Sales/index.d.ts +20 -4
  27. package/dist/solution/Sales/index.js +348 -75
  28. package/dist/solution/Sales/types.d.ts +10 -0
  29. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  30. package/dist/solution/UnifiedBookingSales/index.js +495 -422
  31. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
  32. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  33. package/lib/modules/OpenData/index.d.ts +5 -2
  34. package/lib/modules/OpenData/index.js +50 -3
  35. package/lib/modules/OpenData/types.d.ts +42 -0
  36. package/lib/modules/OpenData/types.js +9 -1
  37. package/lib/modules/OpenData/utils.d.ts +15 -1
  38. package/lib/modules/OpenData/utils.js +85 -0
  39. package/lib/modules/Order/index.d.ts +3 -1
  40. package/lib/modules/Order/index.js +41 -21
  41. package/lib/modules/Order/types.d.ts +3 -0
  42. package/lib/modules/Order/types.js +1 -0
  43. package/lib/modules/ProductList/index.js +9 -6
  44. package/lib/modules/Rules/index.js +8 -6
  45. package/lib/modules/SalesSummary/index.js +3 -1
  46. package/lib/server/index.d.ts +11 -0
  47. package/lib/server/index.js +395 -96
  48. package/lib/server/modules/order/index.d.ts +8 -0
  49. package/lib/server/modules/order/index.js +23 -0
  50. package/lib/server/utils/small-ticket.d.ts +9 -1
  51. package/lib/server/utils/small-ticket.js +107 -35
  52. package/lib/solution/BaseSales/index.d.ts +7 -0
  53. package/lib/solution/BaseSales/index.js +125 -28
  54. package/lib/solution/BookingByStep/index.d.ts +2 -2
  55. package/lib/solution/BookingTicket/index.d.ts +14 -19
  56. package/lib/solution/BookingTicket/index.js +70 -17
  57. package/lib/solution/Sales/index.d.ts +20 -4
  58. package/lib/solution/Sales/index.js +183 -15
  59. package/lib/solution/Sales/types.d.ts +10 -0
  60. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  61. package/lib/solution/UnifiedBookingSales/index.js +41 -15
  62. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
  63. package/package.json +1 -1
@@ -43,6 +43,10 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
44
  import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../modules/OpenData";
47
+ var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
48
+ var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
49
+ var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
46
50
 
47
51
  // 重新导出类型供外部使用
48
52
 
@@ -68,7 +72,7 @@ var AUTO_PRINT_STORAGE_KEY = 'auto_print';
68
72
  var Server = /*#__PURE__*/function () {
69
73
  function Server(core) {
70
74
  var _this = this,
71
- _this$app4;
75
+ _this$app3;
72
76
  _classCallCheck(this, Server);
73
77
  _defineProperty(this, "core", void 0);
74
78
  _defineProperty(this, "app", void 0);
@@ -1136,15 +1140,30 @@ var Server = /*#__PURE__*/function () {
1136
1140
  }());
1137
1141
  _defineProperty(this, "handleLocalPrintOrder", /*#__PURE__*/function () {
1138
1142
  var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref44) {
1139
- var data, _this$getLocalPrintOr, _need_sync, inputOrder, shouldLookup, lookup, sourceOrder, _this$order, _ref46, _localOrder$order_id, _ref47, _external_sale_number, localOrder, checkoutData, printableOrder, printResult, message;
1143
+ var data, _extractedRequestTemp, _nestedOrderTemplateS, _extractedRequest$inv, _extractedRequestTemp2, _this$getLocalPrintOr, _need_sync, extractedRequest, extractedRequestTemplateSettings, requestOrder, nestedOrder, nestedOrderTemplateSettings, inputOrder, invoiceLayoutConfig, invoiceTemplateSettings, shouldLookup, lookup, sourceOrder, _this$order, localOrder, remoteResult, checkoutData, printableOrder, printResult, message;
1140
1144
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1141
1145
  while (1) switch (_context19.prev = _context19.next) {
1142
1146
  case 0:
1143
1147
  data = _ref44.data;
1144
1148
  _context19.prev = 1;
1145
- inputOrder = data !== null && data !== void 0 && data.order && _typeof(data.order) === 'object' ? data.order : data;
1149
+ extractedRequest = _this.extractInvoiceLayoutConfig(data, {
1150
+ includePublicInvoice: true
1151
+ });
1152
+ extractedRequestTemplateSettings = _this.extractInvoiceTemplateSettings(extractedRequest.data, {
1153
+ includePublicTemplateSettings: true
1154
+ });
1155
+ requestOrder = (_extractedRequestTemp = extractedRequestTemplateSettings.data) === null || _extractedRequestTemp === void 0 ? void 0 : _extractedRequestTemp.order;
1156
+ nestedOrder = requestOrder && _typeof(requestOrder) === 'object' ? _this.extractInvoiceLayoutConfig(requestOrder, {
1157
+ includePublicInvoice: true
1158
+ }) : null;
1159
+ nestedOrderTemplateSettings = nestedOrder ? _this.extractInvoiceTemplateSettings(nestedOrder.data, {
1160
+ includePublicTemplateSettings: true
1161
+ }) : null;
1162
+ inputOrder = (_nestedOrderTemplateS = nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.data) !== null && _nestedOrderTemplateS !== void 0 ? _nestedOrderTemplateS : extractedRequestTemplateSettings.data;
1163
+ invoiceLayoutConfig = (_extractedRequest$inv = extractedRequest.invoiceLayoutConfig) !== null && _extractedRequest$inv !== void 0 ? _extractedRequest$inv : nestedOrder === null || nestedOrder === void 0 ? void 0 : nestedOrder.invoiceLayoutConfig;
1164
+ invoiceTemplateSettings = _this.normalizePrintInvoiceTemplateSettings((_extractedRequestTemp2 = extractedRequestTemplateSettings.invoiceTemplateSettings) !== null && _extractedRequestTemp2 !== void 0 ? _extractedRequestTemp2 : nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.invoiceTemplateSettings);
1146
1165
  if (!(!inputOrder || _typeof(inputOrder) !== 'object')) {
1147
- _context19.next = 5;
1166
+ _context19.next = 12;
1148
1167
  break;
1149
1168
  }
1150
1169
  return _context19.abrupt("return", {
@@ -1156,21 +1175,21 @@ var Server = /*#__PURE__*/function () {
1156
1175
  order: null
1157
1176
  }
1158
1177
  });
1159
- case 5:
1160
- shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(data);
1178
+ case 12:
1179
+ shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(extractedRequest.data);
1161
1180
  _this.logInfo('handleLocalPrintOrder: 是否需要查找本地订单', {
1162
1181
  shouldLookup: shouldLookup,
1163
1182
  inputOrder: inputOrder,
1164
1183
  data: data
1165
1184
  });
1166
- lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(data) : undefined;
1185
+ lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(extractedRequest.data) : undefined;
1167
1186
  sourceOrder = inputOrder;
1168
1187
  if (!shouldLookup) {
1169
- _context19.next = 20;
1188
+ _context19.next = 32;
1170
1189
  break;
1171
1190
  }
1172
1191
  if (!(lookup === undefined)) {
1173
- _context19.next = 12;
1192
+ _context19.next = 19;
1174
1193
  break;
1175
1194
  }
1176
1195
  return _context19.abrupt("return", {
@@ -1182,9 +1201,9 @@ var Server = /*#__PURE__*/function () {
1182
1201
  order: null
1183
1202
  }
1184
1203
  });
1185
- case 12:
1204
+ case 19:
1186
1205
  if ((_this$order = _this.order) !== null && _this$order !== void 0 && _this$order.getLocalOrderByLookup) {
1187
- _context19.next = 14;
1206
+ _context19.next = 21;
1188
1207
  break;
1189
1208
  }
1190
1209
  return _context19.abrupt("return", {
@@ -1196,35 +1215,44 @@ var Server = /*#__PURE__*/function () {
1196
1215
  order: null
1197
1216
  }
1198
1217
  });
1199
- case 14:
1200
- _context19.next = 16;
1218
+ case 21:
1219
+ _context19.next = 23;
1201
1220
  return _this.order.getLocalOrderByLookup(lookup);
1202
- case 16:
1221
+ case 23:
1203
1222
  localOrder = _context19.sent;
1204
1223
  if (localOrder) {
1205
- _context19.next = 19;
1224
+ _context19.next = 31;
1225
+ break;
1226
+ }
1227
+ _context19.next = 27;
1228
+ return _this.fetchAndPersistSalesOrderByLookup(lookup, {
1229
+ with: ['all']
1230
+ }, 'handleLocalPrintOrder');
1231
+ case 27:
1232
+ remoteResult = _context19.sent;
1233
+ if (remoteResult.order) {
1234
+ _context19.next = 30;
1206
1235
  break;
1207
1236
  }
1208
1237
  return _context19.abrupt("return", {
1209
- code: 404,
1238
+ code: remoteResult.code,
1210
1239
  status: false,
1211
- message: '订单不存在',
1240
+ message: remoteResult.message,
1212
1241
  data: {
1213
1242
  printed: false,
1214
1243
  order: null
1215
1244
  }
1216
1245
  });
1217
- case 19:
1218
- sourceOrder = _objectSpread(_objectSpread(_objectSpread({}, localOrder), inputOrder), {}, {
1219
- order_id: (_ref46 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : inputOrder.order_id) !== null && _ref46 !== void 0 ? _ref46 : inputOrder.orderId,
1220
- external_sale_number: (_ref47 = (_external_sale_number = localOrder.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : inputOrder.external_sale_number) !== null && _ref47 !== void 0 ? _ref47 : inputOrder.externalSaleNumber
1221
- });
1222
- case 20:
1223
- _context19.next = 22;
1246
+ case 30:
1247
+ localOrder = remoteResult.order;
1248
+ case 31:
1249
+ sourceOrder = _this.mergeLocalPrintOrderInput(localOrder, inputOrder);
1250
+ case 32:
1251
+ _context19.next = 34;
1224
1252
  return _this.ensureCheckoutOrderNumbers(_objectSpread(_objectSpread({}, sourceOrder), {}, {
1225
1253
  small_ticket_data_flag: 1
1226
1254
  }), 'handleLocalPrintOrder');
1227
- case 22:
1255
+ case 34:
1228
1256
  checkoutData = _context19.sent;
1229
1257
  printableOrder = _objectSpread(_objectSpread({}, checkoutData), {}, {
1230
1258
  need_sync: (_need_sync = checkoutData.need_sync) !== null && _need_sync !== void 0 ? _need_sync : 1
@@ -1233,15 +1261,17 @@ var Server = /*#__PURE__*/function () {
1233
1261
  checkoutData: checkoutData,
1234
1262
  printableOrder: printableOrder
1235
1263
  });
1236
- _context19.next = 27;
1264
+ _context19.next = 39;
1237
1265
  return _this.dispatchLocalReceiptPrint({
1238
1266
  checkoutData: checkoutData,
1239
1267
  order: printableOrder,
1240
1268
  response: null,
1241
1269
  requireFullyPaid: false,
1242
- isManualPrint: true
1270
+ isManualPrint: true,
1271
+ invoiceLayoutConfig: invoiceLayoutConfig,
1272
+ invoiceTemplateSettings: invoiceTemplateSettings
1243
1273
  });
1244
- case 27:
1274
+ case 39:
1245
1275
  printResult = _context19.sent;
1246
1276
  return _context19.abrupt("return", {
1247
1277
  code: 200,
@@ -1252,8 +1282,8 @@ var Server = /*#__PURE__*/function () {
1252
1282
  order: printResult.order
1253
1283
  }
1254
1284
  });
1255
- case 31:
1256
- _context19.prev = 31;
1285
+ case 43:
1286
+ _context19.prev = 43;
1257
1287
  _context19.t0 = _context19["catch"](1);
1258
1288
  message = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
1259
1289
  _this.logError('handleLocalPrintOrder: 本地打印小票失败', {
@@ -1268,24 +1298,24 @@ var Server = /*#__PURE__*/function () {
1268
1298
  order: null
1269
1299
  }
1270
1300
  });
1271
- case 36:
1301
+ case 48:
1272
1302
  case "end":
1273
1303
  return _context19.stop();
1274
1304
  }
1275
- }, _callee19, null, [[1, 31]]);
1305
+ }, _callee19, null, [[1, 43]]);
1276
1306
  }));
1277
1307
  return function (_x19) {
1278
1308
  return _ref45.apply(this, arguments);
1279
1309
  };
1280
1310
  }());
1281
1311
  _defineProperty(this, "handleMachinecodeBatchMeta", /*#__PURE__*/function () {
1282
- var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref48) {
1312
+ var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref46) {
1283
1313
  var _this$resolveMachinec, _this$app2;
1284
1314
  var data, title, backendPath, ids, status, message, _response$code, _response$status, _response$message, _response$data2, response, backendError, _backendError$code, _backendError$status, _backendError$message, _backendError$data, _message;
1285
1315
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1286
1316
  while (1) switch (_context20.prev = _context20.next) {
1287
1317
  case 0:
1288
- data = _ref48.data;
1318
+ data = _ref46.data;
1289
1319
  title = 'handleMachinecodeBatchMeta';
1290
1320
  backendPath = '/shop/machinecode/batch';
1291
1321
  ids = Array.isArray(data === null || data === void 0 ? void 0 : data.ids) ? data.ids : [];
@@ -1404,17 +1434,16 @@ var Server = /*#__PURE__*/function () {
1404
1434
  }, _callee20, null, [[10, 15], [23, 30]]);
1405
1435
  }));
1406
1436
  return function (_x20) {
1407
- return _ref49.apply(this, arguments);
1437
+ return _ref47.apply(this, arguments);
1408
1438
  };
1409
1439
  }());
1410
1440
  _defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
1411
- var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref50) {
1412
- var _this$app3;
1413
- var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
1441
+ var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref48) {
1442
+ var url, data, path, requestPath, lookup, localOrder, _enrichedOrder, remoteResult, enrichedOrder;
1414
1443
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1415
1444
  while (1) switch (_context21.prev = _context21.next) {
1416
1445
  case 0:
1417
- url = _ref50.url, data = _ref50.data, path = _ref50.path;
1446
+ url = _ref48.url, data = _ref48.data, path = _ref48.path;
1418
1447
  requestPath = _this.parseRequestPath(url, path);
1419
1448
  lookup = _this.extractOrderSalesDetailLookup(requestPath);
1420
1449
  _this.logInfo('handleOrderSalesDetail: 开始处理', {
@@ -1464,7 +1493,7 @@ var Server = /*#__PURE__*/function () {
1464
1493
  _context21.next = 17;
1465
1494
  return _this.withSalesDetailProductSnapshots(localOrder);
1466
1495
  case 17:
1467
- enrichedOrder = _context21.sent;
1496
+ _enrichedOrder = _context21.sent;
1468
1497
  _this.logInfo('handleOrderSalesDetail: 命中本地订单', {
1469
1498
  lookup: lookup
1470
1499
  });
@@ -1472,117 +1501,54 @@ var Server = /*#__PURE__*/function () {
1472
1501
  code: 200,
1473
1502
  status: true,
1474
1503
  message: '',
1475
- data: enrichedOrder
1504
+ data: _enrichedOrder
1476
1505
  });
1477
1506
  case 20:
1478
- if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
1479
- _context21.next = 23;
1507
+ _context21.next = 22;
1508
+ return _this.fetchAndPersistSalesOrderByLookup(lookup, data, 'handleOrderSalesDetail');
1509
+ case 22:
1510
+ remoteResult = _context21.sent;
1511
+ if (remoteResult.order) {
1512
+ _context21.next = 25;
1480
1513
  break;
1481
1514
  }
1482
- _this.logError('handleOrderSalesDetail: app.request 不可用');
1483
1515
  return _context21.abrupt("return", {
1484
- code: 500,
1516
+ code: remoteResult.code,
1485
1517
  status: false,
1486
- message: 'app.request 不可用',
1518
+ message: remoteResult.message,
1487
1519
  data: null
1488
1520
  });
1489
- case 23:
1490
- backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
1491
- _context21.prev = 24;
1521
+ case 25:
1492
1522
  _context21.next = 27;
1493
- return _this.app.request.get(backendPath, {
1494
- lookup_mode: 'multi'
1495
- }, {
1496
- isShopApi: true,
1497
- customToast: function customToast() {}
1498
- });
1523
+ return _this.withSalesDetailProductSnapshots(remoteResult.order);
1499
1524
  case 27:
1500
- response = _context21.sent;
1501
- fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
1502
- if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
1503
- _context21.next = 32;
1504
- break;
1505
- }
1506
- _this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
1507
- lookup: lookup,
1508
- backendPath: backendPath
1509
- });
1510
- return _context21.abrupt("return", {
1511
- code: 500,
1512
- status: false,
1513
- message: '后端返回订单为空',
1514
- data: null
1515
- });
1516
- case 32:
1517
- _context21.next = 34;
1518
- return _this.order.upsertOrdersFromRemote([fresh]);
1519
- case 34:
1520
- _context21.next = 36;
1521
- return _this.order.getLocalOrderByLookup(lookup);
1522
- case 36:
1523
- savedOrder = _context21.sent;
1524
- if (savedOrder) {
1525
- _context21.next = 40;
1526
- break;
1527
- }
1528
- _this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
1529
- lookup: lookup
1530
- });
1531
- return _context21.abrupt("return", {
1532
- code: 500,
1533
- status: false,
1534
- message: '订单写入后回读失败',
1535
- data: null
1536
- });
1537
- case 40:
1538
- _this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
1539
- lookup: lookup
1540
- });
1541
- _context21.next = 43;
1542
- return _this.withSalesDetailProductSnapshots(savedOrder);
1543
- case 43:
1544
- _enrichedOrder = _context21.sent;
1525
+ enrichedOrder = _context21.sent;
1545
1526
  return _context21.abrupt("return", {
1546
1527
  code: 200,
1547
1528
  status: true,
1548
1529
  message: '',
1549
- data: _enrichedOrder
1550
- });
1551
- case 47:
1552
- _context21.prev = 47;
1553
- _context21.t0 = _context21["catch"](24);
1554
- errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1555
- _this.logInfo('handleOrderSalesDetail: 请求失败', {
1556
- lookup: lookup,
1557
- backendPath: backendPath,
1558
- error: errorMessage
1559
- });
1560
- return _context21.abrupt("return", {
1561
- code: 500,
1562
- status: false,
1563
- message: errorMessage,
1564
- data: null
1530
+ data: enrichedOrder
1565
1531
  });
1566
- case 52:
1532
+ case 29:
1567
1533
  case "end":
1568
1534
  return _context21.stop();
1569
1535
  }
1570
- }, _callee21, null, [[24, 47]]);
1536
+ }, _callee21);
1571
1537
  }));
1572
1538
  return function (_x21) {
1573
- return _ref51.apply(this, arguments);
1539
+ return _ref49.apply(this, arguments);
1574
1540
  };
1575
1541
  }());
1576
1542
  /**
1577
1543
  * GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
1578
1544
  */
1579
1545
  _defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
1580
- var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref52) {
1581
- var url, data, config, routePath, base, path, _subscriberId, _ref54, callback, subscriberId, ctx;
1546
+ var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref50) {
1547
+ var url, data, config, routePath, base, path, _subscriberId, _ref52, callback, subscriberId, ctx;
1582
1548
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1583
1549
  while (1) switch (_context22.prev = _context22.next) {
1584
1550
  case 0:
1585
- url = _ref52.url, data = _ref52.data, config = _ref52.config, routePath = _ref52.path;
1551
+ url = _ref50.url, data = _ref50.data, config = _ref50.config, routePath = _ref50.path;
1586
1552
  base = '/shop/schedule/floor-plan';
1587
1553
  path = _this.parseRequestPath(url, routePath);
1588
1554
  if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
@@ -1603,7 +1569,7 @@ var Server = /*#__PURE__*/function () {
1603
1569
  status: true
1604
1570
  });
1605
1571
  case 7:
1606
- _ref54 = config || {}, callback = _ref54.callback, subscriberId = _ref54.subscriberId;
1572
+ _ref52 = config || {}, callback = _ref52.callback, subscriberId = _ref52.subscriberId;
1607
1573
  ctx = _this.resolveFloorPlanQueryContext(path, base);
1608
1574
  if (ctx) {
1609
1575
  _context22.next = 11;
@@ -1635,20 +1601,20 @@ var Server = /*#__PURE__*/function () {
1635
1601
  }, _callee22);
1636
1602
  }));
1637
1603
  return function (_x22) {
1638
- return _ref53.apply(this, arguments);
1604
+ return _ref51.apply(this, arguments);
1639
1605
  };
1640
1606
  }());
1641
1607
  /**
1642
1608
  * 取消预约列表查询订阅(HTTP 路由入口)
1643
1609
  */
1644
1610
  _defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
1645
- var _ref56 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref55) {
1646
- var data, _ref57, subscriberId;
1611
+ var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref53) {
1612
+ var data, _ref55, subscriberId;
1647
1613
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1648
1614
  while (1) switch (_context23.prev = _context23.next) {
1649
1615
  case 0:
1650
- data = _ref55.data;
1651
- _ref57 = data || {}, subscriberId = _ref57.subscriberId;
1616
+ data = _ref53.data;
1617
+ _ref55 = data || {}, subscriberId = _ref55.subscriberId;
1652
1618
  if (subscriberId) {
1653
1619
  _this.bookingQuerySubscribers.delete(subscriberId);
1654
1620
  _this.bookingRemoteQuerySubscribers.delete(subscriberId);
@@ -1670,7 +1636,7 @@ var Server = /*#__PURE__*/function () {
1670
1636
  }, _callee23);
1671
1637
  }));
1672
1638
  return function (_x23) {
1673
- return _ref56.apply(this, arguments);
1639
+ return _ref54.apply(this, arguments);
1674
1640
  };
1675
1641
  }());
1676
1642
  /**
@@ -1678,13 +1644,13 @@ var Server = /*#__PURE__*/function () {
1678
1644
  * 通过餐牌ID列表获取所有相关日程的时间段点
1679
1645
  */
1680
1646
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1681
- var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
1647
+ var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref56) {
1682
1648
  var _menu_list_ids$length;
1683
1649
  var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1684
1650
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1685
1651
  while (1) switch (_context24.prev = _context24.next) {
1686
1652
  case 0:
1687
- url = _ref58.url, method = _ref58.method, data = _ref58.data, config = _ref58.config;
1653
+ url = _ref56.url, method = _ref56.method, data = _ref56.data, config = _ref56.config;
1688
1654
  menu_list_ids = data.menu_list_ids;
1689
1655
  _this.logInfo('handleGetScheduleTimePoints 开始处理', {
1690
1656
  menuListIdsCount: (_menu_list_ids$length = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length !== void 0 ? _menu_list_ids$length : 0,
@@ -1797,13 +1763,13 @@ var Server = /*#__PURE__*/function () {
1797
1763
  }, _callee24, null, [[15, 27]]);
1798
1764
  }));
1799
1765
  return function (_x24) {
1800
- return _ref59.apply(this, arguments);
1766
+ return _ref57.apply(this, arguments);
1801
1767
  };
1802
1768
  }());
1803
1769
  this.core = core;
1804
1770
  var appPlugin = core.getPlugin('app');
1805
1771
  this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
1806
- this.logger = ((_this$app4 = this.app) === null || _this$app4 === void 0 ? void 0 : _this$app4.logger) || null;
1772
+ this.logger = ((_this$app3 = this.app) === null || _this$app3 === void 0 ? void 0 : _this$app3.logger) || null;
1807
1773
  this.logInfo('Server 初始化', {
1808
1774
  hasApp: !!this.app,
1809
1775
  hasLogger: !!this.logger
@@ -2359,42 +2325,53 @@ var Server = /*#__PURE__*/function () {
2359
2325
  key: "handleSyncSalesTask",
2360
2326
  value: function () {
2361
2327
  var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(ctx) {
2362
- var _ctx$task, _this$app5;
2363
- var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
2328
+ var _ctx$task, _payload$invoice, _payload$template_set, _this$app4;
2329
+ var payload, backendPath, extractedInvoice, extractedTemplateSettings, data, rawInvoiceLayoutConfig, invoiceLayoutConfig, invoiceTemplateSettings, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
2364
2330
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2365
2331
  while (1) switch (_context30.prev = _context30.next) {
2366
2332
  case 0:
2367
2333
  payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
2368
2334
  backendPath = payload.backendPath;
2369
- data = payload.data;
2335
+ extractedInvoice = this.extractInvoiceLayoutConfig(payload.data, {
2336
+ includePublicInvoice: true
2337
+ });
2338
+ extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
2339
+ includePublicTemplateSettings: true
2340
+ });
2341
+ data = extractedTemplateSettings.data;
2342
+ rawInvoiceLayoutConfig = (_payload$invoice = payload.invoice) !== null && _payload$invoice !== void 0 ? _payload$invoice : extractedInvoice.invoiceLayoutConfig;
2343
+ invoiceLayoutConfig = rawInvoiceLayoutConfig === undefined || rawInvoiceLayoutConfig === null ? undefined : this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig);
2344
+ invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings((_payload$template_set = payload.template_settings) !== null && _payload$template_set !== void 0 ? _payload$template_set : extractedTemplateSettings.invoiceTemplateSettings);
2370
2345
  title = payload.title || 'sync_sales';
2371
2346
  if (!(!backendPath || !data)) {
2372
- _context30.next = 6;
2347
+ _context30.next = 11;
2373
2348
  break;
2374
2349
  }
2375
2350
  return _context30.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
2376
- case 6:
2377
- if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && _this$app5.request) {
2378
- _context30.next = 9;
2351
+ case 11:
2352
+ if ((_this$app4 = this.app) !== null && _this$app4 !== void 0 && _this$app4.request) {
2353
+ _context30.next = 14;
2379
2354
  break;
2380
2355
  }
2381
2356
  this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
2382
2357
  return _context30.abrupt("return", this.taskTimeout('app.request 不可用'));
2383
- case 9:
2384
- _context30.prev = 9;
2385
- _context30.next = 12;
2358
+ case 14:
2359
+ _context30.prev = 14;
2360
+ _context30.next = 17;
2386
2361
  return this.runCheckoutSync({
2387
2362
  backendPath: backendPath,
2388
2363
  data: data,
2389
2364
  title: title,
2390
2365
  externalSaleNumber: payload.external_sale_number,
2391
2366
  deviceId: (_ctx$task2 = ctx.task) === null || _ctx$task2 === void 0 ? void 0 : _ctx$task2.device_id,
2392
- persistCheckoutDataWithResponse: false
2367
+ persistCheckoutDataWithResponse: false,
2368
+ invoiceLayoutConfig: invoiceLayoutConfig,
2369
+ invoiceTemplateSettings: invoiceTemplateSettings
2393
2370
  });
2394
- case 12:
2371
+ case 17:
2395
2372
  syncResult = _context30.sent;
2396
2373
  if (!syncResult.rejected) {
2397
- _context30.next = 16;
2374
+ _context30.next = 21;
2398
2375
  break;
2399
2376
  }
2400
2377
  this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
@@ -2402,17 +2379,17 @@ var Server = /*#__PURE__*/function () {
2402
2379
  response: syncResult.errorResponse
2403
2380
  });
2404
2381
  return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
2405
- case 16:
2382
+ case 21:
2406
2383
  return _context30.abrupt("return", this.taskOk({
2407
2384
  order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
2408
2385
  response: syncResult.normalizedResponse
2409
2386
  }));
2410
- case 19:
2411
- _context30.prev = 19;
2412
- _context30.t0 = _context30["catch"](9);
2387
+ case 24:
2388
+ _context30.prev = 24;
2389
+ _context30.t0 = _context30["catch"](14);
2413
2390
  backendError = this.extractBackendErrorResponse(_context30.t0);
2414
2391
  if (!backendError) {
2415
- _context30.next = 26;
2392
+ _context30.next = 31;
2416
2393
  break;
2417
2394
  }
2418
2395
  message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
@@ -2421,7 +2398,7 @@ var Server = /*#__PURE__*/function () {
2421
2398
  backendError: backendError
2422
2399
  });
2423
2400
  return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
2424
- case 26:
2401
+ case 31:
2425
2402
  errorMessage = this.getUnknownErrorMessage(_context30.t0);
2426
2403
  this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
2427
2404
  backendPath: backendPath,
@@ -2429,11 +2406,11 @@ var Server = /*#__PURE__*/function () {
2429
2406
  error_detail: this.normalizeUnknownError(_context30.t0)
2430
2407
  });
2431
2408
  return _context30.abrupt("return", this.taskTimeout(errorMessage));
2432
- case 29:
2409
+ case 34:
2433
2410
  case "end":
2434
2411
  return _context30.stop();
2435
2412
  }
2436
- }, _callee30, this, [[9, 19]]);
2413
+ }, _callee30, this, [[14, 24]]);
2437
2414
  }));
2438
2415
  function handleSyncSalesTask(_x33) {
2439
2416
  return _handleSyncSalesTask.apply(this, arguments);
@@ -2444,8 +2421,8 @@ var Server = /*#__PURE__*/function () {
2444
2421
  key: "runCheckoutSync",
2445
2422
  value: function () {
2446
2423
  var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2447
- var _this$app6;
2448
- var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2424
+ var _this$app5;
2425
+ var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2449
2426
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2450
2427
  while (1) switch (_context31.prev = _context31.next) {
2451
2428
  case 0:
@@ -2457,23 +2434,24 @@ var Server = /*#__PURE__*/function () {
2457
2434
  _context31.next = 6;
2458
2435
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
2459
2436
  case 6:
2460
- checkoutData = _context31.sent;
2437
+ numberedData = _context31.sent;
2438
+ checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2461
2439
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2462
- if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
2463
- _context31.next = 10;
2440
+ if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
2441
+ _context31.next = 11;
2464
2442
  break;
2465
2443
  }
2466
2444
  throw new Error('app.request 不可用');
2467
- case 10:
2468
- _context31.next = 12;
2445
+ case 11:
2446
+ _context31.next = 13;
2469
2447
  return this.app.request.post(backendPath, remoteCheckoutData, {
2470
2448
  isShopApi: true,
2471
2449
  customToast: function customToast() {}
2472
2450
  });
2473
- case 12:
2451
+ case 13:
2474
2452
  response = _context31.sent;
2475
2453
  if (!this.isCheckoutResponseRejected(response)) {
2476
- _context31.next = 15;
2454
+ _context31.next = 16;
2477
2455
  break;
2478
2456
  }
2479
2457
  return _context31.abrupt("return", {
@@ -2484,13 +2462,13 @@ var Server = /*#__PURE__*/function () {
2484
2462
  normalizedResponse: this.normalizeCheckoutResponse(response),
2485
2463
  checkoutData: checkoutData
2486
2464
  });
2487
- case 15:
2465
+ case 16:
2488
2466
  fresh = this.extractOrderDataFromCheckoutResponse(response);
2489
2467
  externalSaleNumber = this.getCheckoutExternalSaleNumber(checkoutData, {
2490
2468
  external_sale_number: params.externalSaleNumber,
2491
2469
  data: checkoutData
2492
2470
  });
2493
- _context31.next = 19;
2471
+ _context31.next = 20;
2494
2472
  return this.persistSyncedCheckoutOrder({
2495
2473
  backendPath: backendPath,
2496
2474
  checkoutData: checkoutData,
@@ -2499,7 +2477,7 @@ var Server = /*#__PURE__*/function () {
2499
2477
  title: title,
2500
2478
  persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
2501
2479
  });
2502
- case 19:
2480
+ case 20:
2503
2481
  syncedOrder = _context31.sent;
2504
2482
  printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
2505
2483
  syncedOrder: syncedOrder,
@@ -2509,17 +2487,19 @@ var Server = /*#__PURE__*/function () {
2509
2487
  checkoutData: checkoutData,
2510
2488
  syncedOrder: printableSyncedOrder
2511
2489
  }))) {
2512
- _context31.next = 24;
2490
+ _context31.next = 25;
2513
2491
  break;
2514
2492
  }
2515
- _context31.next = 24;
2493
+ _context31.next = 25;
2516
2494
  return this.dispatchPrintOtherReceiptTask({
2517
2495
  checkoutData: checkoutData,
2518
2496
  syncedOrder: printableSyncedOrder,
2519
2497
  response: response,
2520
- deviceId: params.deviceId
2498
+ deviceId: params.deviceId,
2499
+ invoiceLayoutConfig: params.invoiceLayoutConfig,
2500
+ invoiceTemplateSettings: params.invoiceTemplateSettings
2521
2501
  });
2522
- case 24:
2502
+ case 25:
2523
2503
  return _context31.abrupt("return", {
2524
2504
  rejected: false,
2525
2505
  response: response,
@@ -2528,7 +2508,7 @@ var Server = /*#__PURE__*/function () {
2528
2508
  syncedOrder: syncedOrder,
2529
2509
  fresh: fresh
2530
2510
  });
2531
- case 25:
2511
+ case 26:
2532
2512
  case "end":
2533
2513
  return _context31.stop();
2534
2514
  }
@@ -2554,6 +2534,8 @@ var Server = /*#__PURE__*/function () {
2554
2534
  var next = cloneDeep(this.omitCheckoutSyncMode(data));
2555
2535
  if (!next || _typeof(next) !== 'object') return next;
2556
2536
  var record = next;
2537
+ delete record[OS_FULFILLMENT_REF_MODE_FIELD];
2538
+ delete record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
2557
2539
  if (!Array.isArray(record.payments)) return next;
2558
2540
  var originalPayments = record.payments;
2559
2541
  var filteredPayments = originalPayments.filter(function (payment) {
@@ -2613,7 +2595,7 @@ var Server = /*#__PURE__*/function () {
2613
2595
  key: "persistSyncedCheckoutOrder",
2614
2596
  value: function () {
2615
2597
  var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2616
- var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
2598
+ var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number, _external_sale_number2, _syncedOrder$order_id, _syncedOrder, patch, result;
2617
2599
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2618
2600
  while (1) switch (_context32.prev = _context32.next) {
2619
2601
  case 0:
@@ -2624,11 +2606,11 @@ var Server = /*#__PURE__*/function () {
2624
2606
  break;
2625
2607
  }
2626
2608
  syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
2627
- external_sale_number: (_external_sale_number2 = fresh.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : externalSaleNumber,
2609
+ external_sale_number: (_external_sale_number = fresh.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : externalSaleNumber,
2628
2610
  need_sync: 0,
2629
2611
  is_draft_order: 0
2630
2612
  }) : _objectSpread(_objectSpread({}, this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
2631
- external_sale_number: (_external_sale_number3 = fresh.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : externalSaleNumber,
2613
+ external_sale_number: (_external_sale_number2 = fresh.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : externalSaleNumber,
2632
2614
  need_sync: 0,
2633
2615
  is_draft_order: 0
2634
2616
  });
@@ -3405,12 +3387,12 @@ var Server = /*#__PURE__*/function () {
3405
3387
  key: "fetchQuotationAvailableFromAPI",
3406
3388
  value: function () {
3407
3389
  var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
3408
- var _this$app7;
3390
+ var _this$app6;
3409
3391
  var requester;
3410
3392
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3411
3393
  while (1) switch (_context41.prev = _context41.next) {
3412
3394
  case 0:
3413
- requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
3395
+ requester = ((_this$app6 = this.app) === null || _this$app6 === void 0 ? void 0 : _this$app6.request) || this.core.getPlugin('request');
3414
3396
  if (requester !== null && requester !== void 0 && requester.get) {
3415
3397
  _context41.next = 4;
3416
3398
  break;
@@ -3707,11 +3689,11 @@ var Server = /*#__PURE__*/function () {
3707
3689
  */
3708
3690
  }, {
3709
3691
  key: "syncProductQueryScheduleTimers",
3710
- value: function syncProductQueryScheduleTimers(_ref61) {
3692
+ value: function syncProductQueryScheduleTimers(_ref59) {
3711
3693
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
3712
- var subscriberId = _ref61.subscriberId,
3713
- menu_list_ids = _ref61.menu_list_ids,
3714
- strategy_context = _ref61.strategy_context;
3694
+ var subscriberId = _ref59.subscriberId,
3695
+ menu_list_ids = _ref59.menu_list_ids,
3696
+ strategy_context = _ref59.strategy_context;
3715
3697
  this.clearSubscriberScheduleTimers(subscriberId);
3716
3698
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3717
3699
  return;
@@ -3810,7 +3792,7 @@ var Server = /*#__PURE__*/function () {
3810
3792
  */
3811
3793
  function () {
3812
3794
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3813
- var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3795
+ var queryPayload, result, _ref60, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3814
3796
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3815
3797
  while (1) switch (_context45.prev = _context45.next) {
3816
3798
  case 0:
@@ -3819,7 +3801,7 @@ var Server = /*#__PURE__*/function () {
3819
3801
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3820
3802
  case 3:
3821
3803
  result = _context45.sent;
3822
- _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3804
+ _ref60 = config || {}, callback = _ref60.callback, subscriberId = _ref60.subscriberId, resetVisibleOrderIds = _ref60.resetVisibleOrderIds;
3823
3805
  if (subscriberId && typeof callback === 'function') {
3824
3806
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3825
3807
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -3873,12 +3855,12 @@ var Server = /*#__PURE__*/function () {
3873
3855
  key: "fetchSalesSearchFromAPI",
3874
3856
  value: (function () {
3875
3857
  var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
3876
- var _this$app8;
3877
- var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3858
+ var _this$app7;
3859
+ var _response$data3, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3878
3860
  return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3879
3861
  while (1) switch (_context46.prev = _context46.next) {
3880
3862
  case 0:
3881
- if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3863
+ if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
3882
3864
  _context46.next = 3;
3883
3865
  break;
3884
3866
  }
@@ -3904,7 +3886,7 @@ var Server = /*#__PURE__*/function () {
3904
3886
  });
3905
3887
  case 6:
3906
3888
  response = _context46.sent;
3907
- _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3889
+ _payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
3908
3890
  return _context46.abrupt("return", {
3909
3891
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3910
3892
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
@@ -4458,12 +4440,12 @@ var Server = /*#__PURE__*/function () {
4458
4440
  key: "fetchOrderListFromAPI",
4459
4441
  value: (function () {
4460
4442
  var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4461
- var _this$app9;
4462
- var _response$data5, response, _payload2, list, count, errorMessage;
4443
+ var _this$app8;
4444
+ var _response$data4, response, _payload2, list, count, errorMessage;
4463
4445
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4464
4446
  while (1) switch (_context47.prev = _context47.next) {
4465
4447
  case 0:
4466
- if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4448
+ if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
4467
4449
  _context47.next = 3;
4468
4450
  break;
4469
4451
  }
@@ -4485,7 +4467,7 @@ var Server = /*#__PURE__*/function () {
4485
4467
  });
4486
4468
  case 6:
4487
4469
  response = _context47.sent;
4488
- _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4470
+ _payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
4489
4471
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4490
4472
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4491
4473
  return _context47.abrupt("return", {
@@ -4660,11 +4642,11 @@ var Server = /*#__PURE__*/function () {
4660
4642
  }, {
4661
4643
  key: "buildLocalPaymentOrderLogContext",
4662
4644
  value: function buildLocalPaymentOrderLogContext(order) {
4663
- var _order$order_id2, _external_sale_number4, _order_number, _shop_order_number, _shop_full_order_numb, _status, _payment_status, _platform, _business_code, _order_sales_channel, _sales_channel, _type;
4645
+ var _order$order_id2, _external_sale_number3, _order_number, _shop_order_number, _shop_full_order_numb, _status, _payment_status, _platform, _business_code, _order_sales_channel, _sales_channel, _type;
4664
4646
  if (!order) return {};
4665
4647
  return {
4666
4648
  order_id: (_order$order_id2 = order.order_id) !== null && _order$order_id2 !== void 0 ? _order$order_id2 : null,
4667
- external_sale_number: (_external_sale_number4 = order.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : null,
4649
+ external_sale_number: (_external_sale_number3 = order.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : null,
4668
4650
  order_number: (_order_number = order.order_number) !== null && _order_number !== void 0 ? _order_number : null,
4669
4651
  shop_order_number: (_shop_order_number = order.shop_order_number) !== null && _shop_order_number !== void 0 ? _shop_order_number : null,
4670
4652
  shop_full_order_number: (_shop_full_order_numb = order.shop_full_order_number) !== null && _shop_full_order_numb !== void 0 ? _shop_full_order_numb : null,
@@ -5198,24 +5180,24 @@ var Server = /*#__PURE__*/function () {
5198
5180
  }, {
5199
5181
  key: "getDeviceTaskPlugin",
5200
5182
  value: function getDeviceTaskPlugin() {
5201
- var _this$app10, _this$app10$getPlugin;
5202
- return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'deviceTask')) || null;
5183
+ var _this$app9, _this$app9$getPlugin;
5184
+ return ((_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getPlugin = _this$app9.getPlugin) === null || _this$app9$getPlugin === void 0 ? void 0 : _this$app9$getPlugin.call(_this$app9, 'deviceTask')) || null;
5203
5185
  }
5204
5186
  }, {
5205
5187
  key: "getIdGeneratorPlugin",
5206
5188
  value: function getIdGeneratorPlugin() {
5207
- var _this$app11, _this$app11$getPlugin;
5208
- return ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getPlugin = _this$app11.getPlugin) === null || _this$app11$getPlugin === void 0 ? void 0 : _this$app11$getPlugin.call(_this$app11, 'idGenerator')) || null;
5189
+ var _this$app10, _this$app10$getPlugin;
5190
+ return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'idGenerator')) || null;
5209
5191
  }
5210
5192
  }, {
5211
5193
  key: "getAppData",
5212
5194
  value: function getAppData(key) {
5213
- var _this$core$getPlugin, _this$core$getPlugin$, _this$app12, _this$app12$getData, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2, _this$app15, _this$app15$getStore, _this$app15$getStore$, _this$app15$getStore$2;
5195
+ var _this$core$getPlugin, _this$core$getPlugin$, _this$app11, _this$app11$getData, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2;
5214
5196
  var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
5215
5197
  if (typeof getData === 'function') return getData(key);
5216
- var directValue = (_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12$getData = _this$app12.getData) === null || _this$app12$getData === void 0 ? void 0 : _this$app12$getData.call(_this$app12, key);
5198
+ var directValue = (_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getData = _this$app11.getData) === null || _this$app11$getData === void 0 ? void 0 : _this$app11$getData.call(_this$app11, key);
5217
5199
  if (directValue !== undefined) return directValue;
5218
- var coreData = ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.models) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.call(_this$app14$getStore$2, 'core', 'core')) || ((_this$app15 = this.app) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.data) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.store) === null || _this$app15 === void 0 || (_this$app15$getStore = _this$app15.getStore) === null || _this$app15$getStore === void 0 || (_this$app15$getStore$ = (_this$app15$getStore$2 = _this$app15$getStore.call(_this$app15)).getDataByModel) === null || _this$app15$getStore$ === void 0 || (_this$app15$getStore$ = _this$app15$getStore$.call(_this$app15$getStore$2, 'core')) === null || _this$app15$getStore$ === void 0 ? void 0 : _this$app15$getStore$.core);
5200
+ var coreData = ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.models) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 || (_this$app14$getStore$ = _this$app14$getStore$.call(_this$app14$getStore$2, 'core')) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.core);
5219
5201
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
5220
5202
  }
5221
5203
  }, {
@@ -5315,6 +5297,173 @@ var Server = /*#__PURE__*/function () {
5315
5297
  value: function isLocalCheckoutOrderId(orderId) {
5316
5298
  return typeof orderId === 'string' && orderId.startsWith('LOCAL_');
5317
5299
  }
5300
+ }, {
5301
+ key: "normalizePrintInvoiceLayoutConfig",
5302
+ value: function normalizePrintInvoiceLayoutConfig(value) {
5303
+ if (value === undefined || value === null) {
5304
+ return getDefaultInvoiceLayoutConfig();
5305
+ }
5306
+ var parsed = value;
5307
+ if (typeof parsed === 'string') {
5308
+ try {
5309
+ parsed = JSON.parse(parsed);
5310
+ } catch (_unused2) {
5311
+ return getDefaultInvoiceLayoutConfig();
5312
+ }
5313
+ }
5314
+ if (!parsed || _typeof(parsed) !== 'object' || Array.isArray(parsed)) {
5315
+ return getDefaultInvoiceLayoutConfig();
5316
+ }
5317
+ var record = parsed;
5318
+ if (!Array.isArray(record.module)) {
5319
+ return getDefaultInvoiceLayoutConfig();
5320
+ }
5321
+ return _objectSpread(_objectSpread({}, typeof record.locale === 'string' ? {
5322
+ locale: record.locale
5323
+ } : {}), {}, {
5324
+ module: record.module.map(function (moduleConfig) {
5325
+ return moduleConfig && _typeof(moduleConfig) === 'object' && !Array.isArray(moduleConfig) ? _objectSpread({}, moduleConfig) : moduleConfig;
5326
+ })
5327
+ });
5328
+ }
5329
+ }, {
5330
+ key: "extractInvoiceLayoutConfig",
5331
+ value: function extractInvoiceLayoutConfig(data, options) {
5332
+ var _record$invoice;
5333
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
5334
+ return {
5335
+ data: data
5336
+ };
5337
+ }
5338
+ var record = data;
5339
+ var rawInvoiceLayoutConfig = options !== null && options !== void 0 && options.includePublicInvoice ? (_record$invoice = record.invoice) !== null && _record$invoice !== void 0 ? _record$invoice : record[OS_INVOICE_LAYOUT_CONFIG_FIELD] : record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
5340
+ var next = _objectSpread({}, record);
5341
+ delete next[OS_INVOICE_LAYOUT_CONFIG_FIELD];
5342
+ if (options !== null && options !== void 0 && options.includePublicInvoice) delete next.invoice;
5343
+ return _objectSpread({
5344
+ data: next
5345
+ }, rawInvoiceLayoutConfig !== undefined && rawInvoiceLayoutConfig !== null ? {
5346
+ invoiceLayoutConfig: this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig)
5347
+ } : {});
5348
+ }
5349
+ }, {
5350
+ key: "normalizePrintInvoiceTemplateSettings",
5351
+ value: function normalizePrintInvoiceTemplateSettings(value) {
5352
+ if (value === undefined || value === null) {
5353
+ return getDefaultInvoiceTemplateSettings();
5354
+ }
5355
+ return normalizeRawInvoiceTemplateSettings(value);
5356
+ }
5357
+ }, {
5358
+ key: "extractInvoiceTemplateSettings",
5359
+ value: function extractInvoiceTemplateSettings(data, options) {
5360
+ var _record$template_sett;
5361
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
5362
+ return {
5363
+ data: data
5364
+ };
5365
+ }
5366
+ var record = data;
5367
+ var rawInvoiceTemplateSettings = options !== null && options !== void 0 && options.includePublicTemplateSettings ? (_record$template_sett = record.template_settings) !== null && _record$template_sett !== void 0 ? _record$template_sett : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD] : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
5368
+ var next = _objectSpread({}, record);
5369
+ delete next[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
5370
+ if (options !== null && options !== void 0 && options.includePublicTemplateSettings) delete next.template_settings;
5371
+ return _objectSpread({
5372
+ data: next
5373
+ }, rawInvoiceTemplateSettings !== undefined && rawInvoiceTemplateSettings !== null ? {
5374
+ invoiceTemplateSettings: this.normalizePrintInvoiceTemplateSettings(rawInvoiceTemplateSettings)
5375
+ } : {});
5376
+ }
5377
+ }, {
5378
+ key: "applyCheckoutFulfillmentBuzzer",
5379
+ value: function applyCheckoutFulfillmentBuzzer(data, title) {
5380
+ if (!data || _typeof(data) !== 'object') return data;
5381
+ var next = _objectSpread({}, data);
5382
+ var refMode = String(next[OS_FULFILLMENT_REF_MODE_FIELD] || '').trim();
5383
+ delete next[OS_FULFILLMENT_REF_MODE_FIELD];
5384
+ if (!refMode) return next;
5385
+ if (refMode === 'manual_input') {
5386
+ this.logInfo("".concat(title, ": fulfillment ref mode \u4FDD\u7559\u624B\u52A8 buzzer"), {
5387
+ fulfillment_ref_mode: refMode,
5388
+ has_buzzer: !this.isBlankCheckoutValue(next.buzzer)
5389
+ });
5390
+ return next;
5391
+ }
5392
+ if (refMode === 'resource_identifier') {
5393
+ next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
5394
+ } else if (refMode === 'sale_number') {
5395
+ next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
5396
+ } else if (refMode === 'short_number') {
5397
+ next.buzzer = this.isBlankCheckoutValue(next.shop_full_order_number) ? '' : String(next.shop_full_order_number);
5398
+ } else {
5399
+ this.logWarning("".concat(title, ": \u672A\u8BC6\u522B\u7684 fulfillment ref mode\uFF0C\u8DF3\u8FC7 buzzer \u81EA\u52A8\u586B\u5145"), {
5400
+ fulfillment_ref_mode: refMode
5401
+ });
5402
+ return next;
5403
+ }
5404
+ this.logInfo("".concat(title, ": fulfillment ref mode \u5DF2\u586B\u5145 buzzer"), {
5405
+ fulfillment_ref_mode: refMode,
5406
+ buzzer: next.buzzer
5407
+ });
5408
+ return next;
5409
+ }
5410
+ }, {
5411
+ key: "buildCheckoutResourceIdentifierBuzzer",
5412
+ value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5413
+ var _this13 = this;
5414
+ if (!Array.isArray(bookings)) return '';
5415
+ var values = [];
5416
+ var seen = new Set();
5417
+ var visitResource = function visitResource(resource, fallbackName) {
5418
+ var identifier = _this13.getCheckoutResourceIdentifier(resource, fallbackName);
5419
+ if (identifier && !seen.has(identifier)) {
5420
+ seen.add(identifier);
5421
+ values.push(identifier);
5422
+ }
5423
+ if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
5424
+ resource.children.forEach(function (child) {
5425
+ return visitResource(child);
5426
+ });
5427
+ }
5428
+ };
5429
+ bookings.forEach(function (booking) {
5430
+ if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
5431
+ booking.resources.forEach(function (resource, index) {
5432
+ visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
5433
+ });
5434
+ }
5435
+ });
5436
+ return values.join(',');
5437
+ }
5438
+ }, {
5439
+ key: "getCheckoutResourceIdentifier",
5440
+ value: function getCheckoutResourceIdentifier(resource, fallbackName) {
5441
+ var _resource$metadata, _resource$metadata2;
5442
+ if (!resource || _typeof(resource) !== 'object') return '';
5443
+ var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
5444
+ for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
5445
+ var candidate = _candidates[_i2];
5446
+ var value = this.stringifyCheckoutResourceIdentifier(candidate);
5447
+ if (value) return value;
5448
+ }
5449
+ return '';
5450
+ }
5451
+ }, {
5452
+ key: "stringifyCheckoutResourceIdentifier",
5453
+ value: function stringifyCheckoutResourceIdentifier(value) {
5454
+ if (value === undefined || value === null) return '';
5455
+ if (typeof value === 'string' || typeof value === 'number') {
5456
+ return String(value).trim();
5457
+ }
5458
+ if (_typeof(value) !== 'object' || Array.isArray(value)) return '';
5459
+ var localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
5460
+ for (var _i3 = 0, _localeCandidates = localeCandidates; _i3 < _localeCandidates.length; _i3++) {
5461
+ var candidate = _localeCandidates[_i3];
5462
+ var normalized = this.stringifyCheckoutResourceIdentifier(candidate);
5463
+ if (normalized) return normalized;
5464
+ }
5465
+ return '';
5466
+ }
5318
5467
  }, {
5319
5468
  key: "normalizeCheckoutSubmitData",
5320
5469
  value: function () {
@@ -5536,6 +5685,8 @@ var Server = /*#__PURE__*/function () {
5536
5685
  payload: {
5537
5686
  backendPath: params.backendPath,
5538
5687
  data: params.data,
5688
+ invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
5689
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5539
5690
  external_sale_number: (_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.external_sale_number,
5540
5691
  title: params.title
5541
5692
  },
@@ -5603,12 +5754,14 @@ var Server = /*#__PURE__*/function () {
5603
5754
  data: params.receiptOnly ? {
5604
5755
  order_id: printIdentity,
5605
5756
  small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
5757
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5606
5758
  skip_wristband: true,
5607
5759
  skip_voucher: true
5608
5760
  } : {
5609
5761
  order_id: printIdentity,
5610
5762
  machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
5611
5763
  machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2,
5764
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5612
5765
  skip_receipt: true
5613
5766
  }
5614
5767
  },
@@ -5696,7 +5849,9 @@ var Server = /*#__PURE__*/function () {
5696
5849
  syncedOrder: printableOrder,
5697
5850
  response: params.response,
5698
5851
  receiptOnly: true,
5699
- isManualPrint: params.isManualPrint
5852
+ isManualPrint: params.isManualPrint,
5853
+ invoiceLayoutConfig: params.invoiceLayoutConfig,
5854
+ invoiceTemplateSettings: params.invoiceTemplateSettings
5700
5855
  });
5701
5856
  case 10:
5702
5857
  return _context58.abrupt("return", {
@@ -5733,6 +5888,20 @@ var Server = /*#__PURE__*/function () {
5733
5888
  }
5734
5889
  return undefined;
5735
5890
  }
5891
+ }, {
5892
+ key: "mergeLocalPrintOrderInput",
5893
+ value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
5894
+ var _ref64, _localOrder$order_id, _ref65, _external_sale_number4;
5895
+ var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref62) {
5896
+ var _ref63 = _slicedToArray(_ref62, 2),
5897
+ value = _ref63[1];
5898
+ return value !== undefined;
5899
+ }));
5900
+ return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
5901
+ order_id: (_ref64 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref64 !== void 0 ? _ref64 : definedInput.orderId,
5902
+ external_sale_number: (_ref65 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref65 !== void 0 ? _ref65 : definedInput.externalSaleNumber
5903
+ });
5904
+ }
5736
5905
  }, {
5737
5906
  key: "resolveMachinecodeBatchMetadataLookup",
5738
5907
  value: function resolveMachinecodeBatchMetadataLookup(data) {
@@ -5877,11 +6046,20 @@ var Server = /*#__PURE__*/function () {
5877
6046
  key: "handleOrderCheckoutSubmit",
5878
6047
  value: function () {
5879
6048
  var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5880
- var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
6049
+ var backendPath, title, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
5881
6050
  return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5882
6051
  while (1) switch (_context60.prev = _context60.next) {
5883
6052
  case 0:
5884
- backendPath = params.backendPath, data = params.data, title = params.title;
6053
+ backendPath = params.backendPath, title = params.title;
6054
+ extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
6055
+ includePublicInvoice: true
6056
+ });
6057
+ extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
6058
+ includePublicTemplateSettings: true
6059
+ });
6060
+ data = extractedTemplateSettings.data;
6061
+ invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
6062
+ invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
5885
6063
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
5886
6064
  backendPath: backendPath,
5887
6065
  order_id: data === null || data === void 0 ? void 0 : data.order_id,
@@ -5889,58 +6067,65 @@ var Server = /*#__PURE__*/function () {
5889
6067
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5890
6068
  });
5891
6069
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5892
- _context60.next = 4;
6070
+ _context60.next = 9;
5893
6071
  break;
5894
6072
  }
5895
6073
  return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
5896
6074
  backendPath: backendPath,
5897
6075
  data: data,
5898
- title: title
6076
+ title: title,
6077
+ invoiceLayoutConfig: invoiceLayoutConfig,
6078
+ invoiceTemplateSettings: invoiceTemplateSettings
5899
6079
  }));
5900
- case 4:
5901
- _context60.next = 6;
6080
+ case 9:
6081
+ _context60.next = 11;
5902
6082
  return this.normalizeCheckoutSubmitData(data, title);
5903
- case 6:
6083
+ case 11:
5904
6084
  normalizedData = _context60.sent;
5905
- _context60.next = 9;
6085
+ _context60.next = 14;
5906
6086
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
5907
- case 9:
5908
- checkoutData = _context60.sent;
5909
- _context60.next = 12;
6087
+ case 14:
6088
+ numberedData = _context60.sent;
6089
+ checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6090
+ _context60.next = 18;
5910
6091
  return this.handlePendingSyncCheckoutOrder({
5911
6092
  backendPath: backendPath,
5912
6093
  data: checkoutData,
5913
6094
  title: title,
5914
6095
  reason: 'checkout 已转入设备任务同步'
5915
6096
  });
5916
- case 12:
6097
+ case 18:
5917
6098
  pendingResult = _context60.sent;
5918
6099
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5919
- _context60.next = 20;
6100
+ _context60.next = 26;
5920
6101
  break;
5921
6102
  }
5922
6103
  pendingOrder = pendingResult.data;
5923
6104
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
5924
- _context60.next = 18;
6105
+ _context60.next = 24;
5925
6106
  break;
5926
6107
  }
5927
- _context60.next = 18;
6108
+ _context60.next = 24;
5928
6109
  return this.dispatchLocalReceiptPrint({
5929
6110
  checkoutData: checkoutData,
5930
6111
  order: pendingOrder,
5931
6112
  response: pendingResult,
5932
- requireFullyPaid: true
6113
+ requireFullyPaid: true,
6114
+ invoiceLayoutConfig: invoiceLayoutConfig,
6115
+ invoiceTemplateSettings: invoiceTemplateSettings
5933
6116
  });
5934
- case 18:
5935
- _context60.next = 20;
6117
+ case 24:
6118
+ _context60.next = 26;
5936
6119
  return this.dispatchCheckoutSyncTask({
5937
6120
  backendPath: backendPath,
5938
6121
  data: checkoutData,
5939
- title: title
6122
+ title: title,
6123
+ invoiceLayoutConfig: invoiceLayoutConfig,
6124
+ invoiceTemplateSettings: invoiceTemplateSettings
5940
6125
  });
5941
- case 20:
6126
+ case 26:
5942
6127
  if (pendingResult.data.order_id) {
5943
- _context60.next = 22;
6128
+ _context60.next = 28;
5944
6129
  break;
5945
6130
  }
5946
6131
  return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
@@ -5948,9 +6133,9 @@ var Server = /*#__PURE__*/function () {
5948
6133
  order_id: pendingResult.data.external_sale_number
5949
6134
  })
5950
6135
  }));
5951
- case 22:
6136
+ case 28:
5952
6137
  return _context60.abrupt("return", pendingResult);
5953
- case 23:
6138
+ case 29:
5954
6139
  case "end":
5955
6140
  return _context60.stop();
5956
6141
  }
@@ -5965,13 +6150,13 @@ var Server = /*#__PURE__*/function () {
5965
6150
  key: "handleSyncCheckoutSubmit",
5966
6151
  value: function () {
5967
6152
  var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5968
- var _this$app16;
5969
- var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6153
+ var _this$app15;
6154
+ var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
5970
6155
  return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5971
6156
  while (1) switch (_context61.prev = _context61.next) {
5972
6157
  case 0:
5973
- backendPath = params.backendPath, data = params.data, title = params.title;
5974
- if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
6158
+ backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
6159
+ if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
5975
6160
  _context61.next = 4;
5976
6161
  break;
5977
6162
  }
@@ -5989,7 +6174,9 @@ var Server = /*#__PURE__*/function () {
5989
6174
  backendPath: backendPath,
5990
6175
  data: data,
5991
6176
  title: title,
5992
- persistCheckoutDataWithResponse: true
6177
+ persistCheckoutDataWithResponse: true,
6178
+ invoiceLayoutConfig: invoiceLayoutConfig,
6179
+ invoiceTemplateSettings: invoiceTemplateSettings
5993
6180
  });
5994
6181
  case 7:
5995
6182
  syncResult = _context61.sent;
@@ -6015,7 +6202,9 @@ var Server = /*#__PURE__*/function () {
6015
6202
  checkoutData: syncResult.checkoutData,
6016
6203
  order: syncedOrder,
6017
6204
  response: syncResult.normalizedResponse,
6018
- requireFullyPaid: true
6205
+ requireFullyPaid: true,
6206
+ invoiceLayoutConfig: invoiceLayoutConfig,
6207
+ invoiceTemplateSettings: invoiceTemplateSettings
6019
6208
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6020
6209
  });
6021
6210
  case 16:
@@ -6062,19 +6251,25 @@ var Server = /*#__PURE__*/function () {
6062
6251
  key: "handleOrderDraftSubmit",
6063
6252
  value: function () {
6064
6253
  var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6065
- var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6254
+ var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6066
6255
  return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6067
6256
  while (1) switch (_context62.prev = _context62.next) {
6068
6257
  case 0:
6069
- data = params.data, title = params.title;
6258
+ title = params.title;
6259
+ extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
6260
+ includePublicInvoice: true
6261
+ });
6262
+ _this$extractInvoiceT = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
6263
+ includePublicTemplateSettings: true
6264
+ }), data = _this$extractInvoiceT.data;
6070
6265
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
6071
6266
  order_id: data === null || data === void 0 ? void 0 : data.order_id,
6072
6267
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6073
6268
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6074
6269
  });
6075
- _context62.next = 4;
6270
+ _context62.next = 6;
6076
6271
  return this.normalizeCheckoutSubmitData(data, title);
6077
- case 4:
6272
+ case 6:
6078
6273
  normalizedData = _context62.sent;
6079
6274
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6080
6275
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
@@ -6085,7 +6280,7 @@ var Server = /*#__PURE__*/function () {
6085
6280
  is_draft_order: 1
6086
6281
  });
6087
6282
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6088
- _context62.next = 10;
6283
+ _context62.next = 12;
6089
6284
  break;
6090
6285
  }
6091
6286
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
@@ -6095,11 +6290,11 @@ var Server = /*#__PURE__*/function () {
6095
6290
  message: 'Order 模块不支持本地草稿写入',
6096
6291
  data: null
6097
6292
  });
6098
- case 10:
6099
- _context62.prev = 10;
6100
- _context62.next = 13;
6293
+ case 12:
6294
+ _context62.prev = 12;
6295
+ _context62.next = 15;
6101
6296
  return this.order.upsertLocalDraftOrders([draftOrder]);
6102
- case 13:
6297
+ case 15:
6103
6298
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6104
6299
  order_id: draftOrder.order_id,
6105
6300
  external_sale_number: draftOrder.external_sale_number
@@ -6115,9 +6310,9 @@ var Server = /*#__PURE__*/function () {
6115
6310
  payment_status: draftOrder === null || draftOrder === void 0 ? void 0 : draftOrder.payment_status
6116
6311
  })
6117
6312
  });
6118
- case 17:
6119
- _context62.prev = 17;
6120
- _context62.t0 = _context62["catch"](10);
6313
+ case 19:
6314
+ _context62.prev = 19;
6315
+ _context62.t0 = _context62["catch"](12);
6121
6316
  errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6122
6317
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6123
6318
  error: errorMessage
@@ -6128,11 +6323,11 @@ var Server = /*#__PURE__*/function () {
6128
6323
  message: errorMessage,
6129
6324
  data: null
6130
6325
  });
6131
- case 22:
6326
+ case 24:
6132
6327
  case "end":
6133
6328
  return _context62.stop();
6134
6329
  }
6135
- }, _callee62, this, [[10, 17]]);
6330
+ }, _callee62, this, [[12, 19]]);
6136
6331
  }));
6137
6332
  function handleOrderDraftSubmit(_x69) {
6138
6333
  return _handleOrderDraftSubmit.apply(this, arguments);
@@ -6143,7 +6338,7 @@ var Server = /*#__PURE__*/function () {
6143
6338
  key: "handlePendingSyncCheckoutOrder",
6144
6339
  value: function () {
6145
6340
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6146
- var _this13 = this;
6341
+ var _this14 = this;
6147
6342
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6148
6343
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6149
6344
  while (1) switch (_context63.prev = _context63.next) {
@@ -6196,7 +6391,7 @@ var Server = /*#__PURE__*/function () {
6196
6391
  });
6197
6392
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6198
6393
  var _payment$metadata;
6199
- return sum + _this13.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6394
+ return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6200
6395
  }, 0);
6201
6396
  return _context63.abrupt("return", {
6202
6397
  code: 200,
@@ -6289,17 +6484,17 @@ var Server = /*#__PURE__*/function () {
6289
6484
  }, {
6290
6485
  key: "shouldAutoPrintCheckoutReceipt",
6291
6486
  value: function shouldAutoPrintCheckoutReceipt() {
6292
- var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
6487
+ var _this$core$context2, _this$core$context2$g, _this$app16, _this$app16$getStorag;
6293
6488
  if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
6294
- return ((_this$app17 = this.app) === null || _this$app17 === void 0 || (_this$app17 = _this$app17.storage) === null || _this$app17 === void 0 || (_this$app17$getStorag = _this$app17.getStorage) === null || _this$app17$getStorag === void 0 ? void 0 : _this$app17$getStorag.call(_this$app17, AUTO_PRINT_STORAGE_KEY)) !== 'false';
6489
+ return ((_this$app16 = this.app) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.storage) === null || _this$app16 === void 0 || (_this$app16$getStorag = _this$app16.getStorage) === null || _this$app16$getStorag === void 0 ? void 0 : _this$app16$getStorag.call(_this$app16, AUTO_PRINT_STORAGE_KEY)) !== 'false';
6295
6490
  }
6296
6491
  }, {
6297
6492
  key: "shouldBuildSmallTicketData",
6298
6493
  value: function shouldBuildSmallTicketData(order) {
6299
- var _ref64, _order$small_ticket_d;
6494
+ var _ref66, _order$small_ticket_d;
6300
6495
  if (!order || _typeof(order) !== 'object') return false;
6301
6496
  // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6302
- return Number((_ref64 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref64 !== void 0 ? _ref64 : 0) === 1;
6497
+ return Number((_ref66 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref66 !== void 0 ? _ref66 : 0) === 1;
6303
6498
  }
6304
6499
  }, {
6305
6500
  key: "shouldPrintSyncedOrder",
@@ -6317,7 +6512,7 @@ var Server = /*#__PURE__*/function () {
6317
6512
  }, {
6318
6513
  key: "isSalesOrderFullyPaid",
6319
6514
  value: function isSalesOrderFullyPaid(order) {
6320
- var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
6515
+ var _order$summary$amount, _order$summary, _ref67, _ref68, _order$summary$expect, _order$summary2, _order$summary3;
6321
6516
  if (!order || _typeof(order) !== 'object') return false;
6322
6517
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6323
6518
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6329,20 +6524,20 @@ var Server = /*#__PURE__*/function () {
6329
6524
  return this.toAmountNumber(amountGap) <= 0;
6330
6525
  }
6331
6526
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6332
- var targetAmount = this.toAmountNumber((_ref65 = (_ref66 = (_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 && _ref66 !== void 0 ? _ref66 : order.expect_amount) !== null && _ref65 !== void 0 ? _ref65 : order.total_amount);
6527
+ var targetAmount = this.toAmountNumber((_ref67 = (_ref68 = (_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 && _ref68 !== void 0 ? _ref68 : order.expect_amount) !== null && _ref67 !== void 0 ? _ref67 : order.total_amount);
6333
6528
  if (targetAmount <= 0) return paidAmount > 0;
6334
6529
  return paidAmount >= targetAmount;
6335
6530
  }
6336
6531
  }, {
6337
6532
  key: "sumPaidOrderPayments",
6338
6533
  value: function sumPaidOrderPayments(payments) {
6339
- var _this14 = this;
6534
+ var _this15 = this;
6340
6535
  if (!Array.isArray(payments)) return 0;
6341
6536
  return payments.reduce(function (sum, payment) {
6342
6537
  var _payment$amount;
6343
6538
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6344
6539
  if (status !== 'paid') return sum;
6345
- return sum + _this14.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);
6540
+ return sum + _this15.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);
6346
6541
  }, 0);
6347
6542
  }
6348
6543
  }, {
@@ -6358,7 +6553,7 @@ var Server = /*#__PURE__*/function () {
6358
6553
  value: function () {
6359
6554
  var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6360
6555
  var _this$products3,
6361
- _this15 = this;
6556
+ _this16 = this;
6362
6557
  var products, productIdSet, productIds, entries;
6363
6558
  return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6364
6559
  while (1) switch (_context66.prev = _context66.next) {
@@ -6373,8 +6568,8 @@ var Server = /*#__PURE__*/function () {
6373
6568
  }
6374
6569
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6375
6570
  product.product_bundle.forEach(function (bundle) {
6376
- var _ref67, _bundle$bundle_produc;
6377
- var bundleProductId = (_ref67 = (_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 && _ref67 !== void 0 ? _ref67 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6571
+ var _ref69, _bundle$bundle_produc;
6572
+ var bundleProductId = (_ref69 = (_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 && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6378
6573
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6379
6574
  productIdSet.add(bundleProductId);
6380
6575
  }
@@ -6390,21 +6585,21 @@ var Server = /*#__PURE__*/function () {
6390
6585
  case 6:
6391
6586
  _context66.next = 8;
6392
6587
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6393
- var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6394
- var _this15$products, _this15$products$getP, product;
6588
+ var _ref70 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6589
+ var _this16$products, _this16$products$getP, product;
6395
6590
  return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6396
6591
  while (1) switch (_context65.prev = _context65.next) {
6397
6592
  case 0:
6398
6593
  _context65.prev = 0;
6399
6594
  _context65.next = 3;
6400
- return (_this15$products = _this15.products) === null || _this15$products === void 0 || (_this15$products$getP = _this15$products.getProductById) === null || _this15$products$getP === void 0 ? void 0 : _this15$products$getP.call(_this15$products, Number(id));
6595
+ return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
6401
6596
  case 3:
6402
6597
  product = _context65.sent;
6403
6598
  return _context65.abrupt("return", product ? [String(id), product] : null);
6404
6599
  case 7:
6405
6600
  _context65.prev = 7;
6406
6601
  _context65.t0 = _context65["catch"](0);
6407
- _this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6602
+ _this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6408
6603
  product_id: id,
6409
6604
  error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6410
6605
  });
@@ -6416,7 +6611,7 @@ var Server = /*#__PURE__*/function () {
6416
6611
  }, _callee65, null, [[0, 7]]);
6417
6612
  }));
6418
6613
  return function (_x73) {
6419
- return _ref68.apply(this, arguments);
6614
+ return _ref70.apply(this, arguments);
6420
6615
  };
6421
6616
  }()));
6422
6617
  case 8:
@@ -6455,8 +6650,8 @@ var Server = /*#__PURE__*/function () {
6455
6650
  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);
6456
6651
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6457
6652
  product.product_bundle.forEach(function (bundle) {
6458
- var _ref69, _bundle$bundle_produc2;
6459
- addProductId((_ref69 = (_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 && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6653
+ var _ref71, _bundle$bundle_produc2;
6654
+ addProductId((_ref71 = (_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 && _ref71 !== void 0 ? _ref71 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6460
6655
  });
6461
6656
  }
6462
6657
  });
@@ -6532,9 +6727,9 @@ var Server = /*#__PURE__*/function () {
6532
6727
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
6533
6728
  var hasChanged = false;
6534
6729
  var productBundle = product.product_bundle.map(function (bundle) {
6535
- var _ref70, _bundle$bundle_produc3;
6730
+ var _ref72, _bundle$bundle_produc3;
6536
6731
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
6537
- var rawProductId = (_ref70 = (_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 && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6732
+ var rawProductId = (_ref72 = (_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 && _ref72 !== void 0 ? _ref72 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6538
6733
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
6539
6734
  var productId = Number(rawProductId);
6540
6735
  if (!Number.isFinite(productId)) return bundle;
@@ -6555,7 +6750,7 @@ var Server = /*#__PURE__*/function () {
6555
6750
  key: "withSalesDetailProductSnapshots",
6556
6751
  value: function () {
6557
6752
  var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6558
- var _this16 = this;
6753
+ var _this17 = this;
6559
6754
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6560
6755
  return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6561
6756
  while (1) switch (_context68.prev = _context68.next) {
@@ -6579,8 +6774,8 @@ var Server = /*#__PURE__*/function () {
6579
6774
  case 8:
6580
6775
  hasChanged = false;
6581
6776
  enrichedProducts = products.map(function (product) {
6582
- var productWithBundleSnapshots = _this16.withBundleCatalogSnapshots(product, snapshotMap);
6583
- var nextProduct = _this16.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6777
+ var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
6778
+ var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6584
6779
  if (nextProduct !== product) hasChanged = true;
6585
6780
  return nextProduct;
6586
6781
  });
@@ -6608,13 +6803,13 @@ var Server = /*#__PURE__*/function () {
6608
6803
  }, {
6609
6804
  key: "withPendingSyncProductTitles",
6610
6805
  value: function withPendingSyncProductTitles(order, productMap) {
6611
- var _this17 = this;
6806
+ var _this18 = this;
6612
6807
  var products = Array.isArray(order.products) ? order.products : null;
6613
6808
  if (!(products !== null && products !== void 0 && products.length)) return order;
6614
6809
  return _objectSpread(_objectSpread({}, order), {}, {
6615
6810
  products: products.map(function (product) {
6616
6811
  return _objectSpread(_objectSpread({}, product), {}, {
6617
- product_title: _this17.buildProductTitleSnapshot(product, productMap)
6812
+ product_title: _this18.buildProductTitleSnapshot(product, productMap)
6618
6813
  });
6619
6814
  })
6620
6815
  });
@@ -6625,7 +6820,7 @@ var Server = /*#__PURE__*/function () {
6625
6820
  var _product$product_id4,
6626
6821
  _product$product,
6627
6822
  _fallbackProduct$prod,
6628
- _this18 = this;
6823
+ _this19 = this;
6629
6824
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6630
6825
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6631
6826
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6633,7 +6828,7 @@ var Server = /*#__PURE__*/function () {
6633
6828
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6634
6829
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6635
6830
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6636
- snapshot[key] = _this18.resolveProductTitleValue(ownTitle, key, currentLocale) || _this18.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6831
+ snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6637
6832
  return snapshot;
6638
6833
  }, {});
6639
6834
  }
@@ -6658,7 +6853,7 @@ var Server = /*#__PURE__*/function () {
6658
6853
  }, {
6659
6854
  key: "resolveProductTitleValue",
6660
6855
  value: function resolveProductTitleValue(value, key, currentLocale) {
6661
- var _ref71, _ref72, _value$key;
6856
+ var _ref73, _ref74, _value$key;
6662
6857
  if (value === undefined || value === null || value === '') return null;
6663
6858
  if (_typeof(value) !== 'object') {
6664
6859
  var title = String(value);
@@ -6668,7 +6863,7 @@ var Server = /*#__PURE__*/function () {
6668
6863
  }
6669
6864
  var normalizedKey = key.replace('-', '_');
6670
6865
  var dashedKey = key.replace('_', '-');
6671
- var rawValue = (_ref71 = (_ref72 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref72 !== void 0 ? _ref72 : value[dashedKey]) !== null && _ref71 !== void 0 ? _ref71 : key === 'auto' ? value.default : undefined;
6866
+ var rawValue = (_ref73 = (_ref74 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref74 !== void 0 ? _ref74 : value[dashedKey]) !== null && _ref73 !== void 0 ? _ref73 : key === 'auto' ? value.default : undefined;
6672
6867
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
6673
6868
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
6674
6869
  return String(rawValue);
@@ -6695,8 +6890,8 @@ var Server = /*#__PURE__*/function () {
6695
6890
  if (value === undefined || value === null || value === '') return null;
6696
6891
  if (_typeof(value) !== 'object') return String(value);
6697
6892
  var preferredKeys = ['auto', 'en', 'original', 'zh-CN', 'zh_CN', 'zh-HK', 'zh_HK', 'kitchen', 'ja', 'pt', 'default'];
6698
- for (var _i2 = 0, _preferredKeys = preferredKeys; _i2 < _preferredKeys.length; _i2++) {
6699
- var _key6 = _preferredKeys[_i2];
6893
+ for (var _i4 = 0, _preferredKeys = preferredKeys; _i4 < _preferredKeys.length; _i4++) {
6894
+ var _key6 = _preferredKeys[_i4];
6700
6895
  var rawValue = value[_key6];
6701
6896
  if (rawValue !== undefined && rawValue !== null && rawValue !== '') return String(rawValue);
6702
6897
  }
@@ -6732,14 +6927,14 @@ var Server = /*#__PURE__*/function () {
6732
6927
  key: "enrichPaymentNamesByCode",
6733
6928
  value: function () {
6734
6929
  var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6735
- var _this19 = this;
6930
+ var _this20 = this;
6736
6931
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6737
6932
  return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6738
6933
  while (1) switch (_context69.prev = _context69.next) {
6739
6934
  case 0:
6740
6935
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6741
6936
  hasMissingName = payments.some(function (payment) {
6742
- return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6937
+ return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6743
6938
  });
6744
6939
  if (hasMissingName) {
6745
6940
  _context69.next = 4;
@@ -6772,9 +6967,9 @@ var Server = /*#__PURE__*/function () {
6772
6967
  }
6773
6968
  hasResolvedName = false;
6774
6969
  enrichedPayments = payments.map(function (payment) {
6775
- if (!_this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6776
- if (!_this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6777
- var name = nameByCode.get(_this19.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6970
+ if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6971
+ if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6972
+ var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6778
6973
  if (!name) return payment;
6779
6974
  hasResolvedName = true;
6780
6975
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6875,6 +7070,175 @@ var Server = /*#__PURE__*/function () {
6875
7070
  }
6876
7071
  return withLocalSmallTicketData;
6877
7072
  }()
7073
+ }, {
7074
+ key: "normalizeRemoteSalesOrderErrorCode",
7075
+ value: function normalizeRemoteSalesOrderErrorCode(value) {
7076
+ if (value === undefined || value === null || value === '') return 500;
7077
+ var code = typeof value === 'number' ? value : Number(value);
7078
+ return Number.isFinite(code) ? code : 500;
7079
+ }
7080
+ }, {
7081
+ key: "fetchAndPersistSalesOrderByLookup",
7082
+ value: function () {
7083
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(lookup, data, title) {
7084
+ var _this$order4, _this$order5, _this$app17;
7085
+ var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref75, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7086
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7087
+ while (1) switch (_context71.prev = _context71.next) {
7088
+ case 0:
7089
+ if (!(!((_this$order4 = this.order) !== null && _this$order4 !== void 0 && _this$order4.getLocalOrderByLookup) || !((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.upsertOrdersFromRemote))) {
7090
+ _context71.next = 3;
7091
+ break;
7092
+ }
7093
+ this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7094
+ return _context71.abrupt("return", {
7095
+ code: 500,
7096
+ message: 'Order 模块未注册',
7097
+ order: null
7098
+ });
7099
+ case 3:
7100
+ if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.get) {
7101
+ _context71.next = 6;
7102
+ break;
7103
+ }
7104
+ this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7105
+ return _context71.abrupt("return", {
7106
+ code: 500,
7107
+ message: 'app.request 不可用',
7108
+ order: null
7109
+ });
7110
+ case 6:
7111
+ backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
7112
+ _context71.prev = 7;
7113
+ _context71.next = 10;
7114
+ return this.app.request.get(backendPath, {
7115
+ lookup_mode: 'multi'
7116
+ }, {
7117
+ isShopApi: true,
7118
+ customToast: function customToast() {}
7119
+ });
7120
+ case 10:
7121
+ response = _context71.sent;
7122
+ if (!this.isCheckoutResponseRejected(response)) {
7123
+ _context71.next = 17;
7124
+ break;
7125
+ }
7126
+ responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
7127
+ code = this.normalizeRemoteSalesOrderErrorCode((_response$code3 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code3 !== void 0 ? _response$code3 : responseStatusCode);
7128
+ message = (response === null || response === void 0 ? void 0 : response.message) || '后端拒绝订单查询';
7129
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u62D2\u7EDD\u8BA2\u5355\u67E5\u8BE2"), {
7130
+ lookup: lookup,
7131
+ backendPath: backendPath,
7132
+ code: code,
7133
+ message: message
7134
+ });
7135
+ return _context71.abrupt("return", {
7136
+ code: code,
7137
+ message: message,
7138
+ order: null
7139
+ });
7140
+ case 17:
7141
+ fresh = this.extractOrderDataFromCheckoutResponse(response);
7142
+ if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
7143
+ _context71.next = 21;
7144
+ break;
7145
+ }
7146
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
7147
+ lookup: lookup,
7148
+ backendPath: backendPath
7149
+ });
7150
+ return _context71.abrupt("return", {
7151
+ code: 500,
7152
+ message: '后端返回订单为空',
7153
+ order: null
7154
+ });
7155
+ case 21:
7156
+ _context71.next = 23;
7157
+ return this.order.upsertOrdersFromRemote([fresh]);
7158
+ case 23:
7159
+ _context71.next = 25;
7160
+ return this.order.getLocalOrderByLookup(lookup);
7161
+ case 25:
7162
+ savedOrder = _context71.sent;
7163
+ if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
7164
+ _context71.next = 30;
7165
+ break;
7166
+ }
7167
+ _context71.next = 29;
7168
+ return this.order.getLocalOrderByLookup(fresh.order_id);
7169
+ case 29:
7170
+ savedOrder = _context71.sent;
7171
+ case 30:
7172
+ if (savedOrder) {
7173
+ _context71.next = 33;
7174
+ break;
7175
+ }
7176
+ this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
7177
+ lookup: lookup,
7178
+ remote_order_id: fresh.order_id
7179
+ });
7180
+ return _context71.abrupt("return", {
7181
+ code: 500,
7182
+ message: '订单写入后回读失败',
7183
+ order: null
7184
+ });
7185
+ case 33:
7186
+ this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
7187
+ lookup: lookup,
7188
+ remote_order_id: fresh.order_id
7189
+ });
7190
+ return _context71.abrupt("return", {
7191
+ code: 200,
7192
+ message: '',
7193
+ order: savedOrder
7194
+ });
7195
+ case 37:
7196
+ _context71.prev = 37;
7197
+ _context71.t0 = _context71["catch"](7);
7198
+ backendError = this.extractBackendErrorResponse(_context71.t0);
7199
+ errorRecord = _context71.t0;
7200
+ _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;
7201
+ if (!(backendError || _responseStatusCode !== undefined)) {
7202
+ _context71.next = 48;
7203
+ break;
7204
+ }
7205
+ backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
7206
+ _code = this.normalizeRemoteSalesOrderErrorCode((_ref75 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref75 !== void 0 ? _ref75 : _responseStatusCode);
7207
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context71.t0);
7208
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
7209
+ lookup: lookup,
7210
+ backendPath: backendPath,
7211
+ code: _code,
7212
+ message: _message2
7213
+ });
7214
+ return _context71.abrupt("return", {
7215
+ code: _code,
7216
+ message: _message2,
7217
+ order: null
7218
+ });
7219
+ case 48:
7220
+ _message3 = this.getUnknownErrorMessage(_context71.t0);
7221
+ this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
7222
+ lookup: lookup,
7223
+ backendPath: backendPath,
7224
+ error: _message3
7225
+ });
7226
+ return _context71.abrupt("return", {
7227
+ code: 500,
7228
+ message: _message3,
7229
+ order: null
7230
+ });
7231
+ case 51:
7232
+ case "end":
7233
+ return _context71.stop();
7234
+ }
7235
+ }, _callee71, this, [[7, 37]]);
7236
+ }));
7237
+ function fetchAndPersistSalesOrderByLookup(_x79, _x80, _x81) {
7238
+ return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
7239
+ }
7240
+ return fetchAndPersistSalesOrderByLookup;
7241
+ }()
6878
7242
  }, {
6879
7243
  key: "parseOrderIdsParam",
6880
7244
  value:
@@ -6912,8 +7276,8 @@ var Server = /*#__PURE__*/function () {
6912
7276
  pushRaw(this.extractQueryParam(url, 'order_ids'));
6913
7277
  var seen = new Set();
6914
7278
  var result = [];
6915
- for (var _i3 = 0, _collected = collected; _i3 < _collected.length; _i3++) {
6916
- var id = _collected[_i3];
7279
+ for (var _i5 = 0, _collected = collected; _i5 < _collected.length; _i5++) {
7280
+ var id = _collected[_i5];
6917
7281
  if (seen.has(id)) continue;
6918
7282
  seen.add(id);
6919
7283
  result.push(id);
@@ -6932,22 +7296,22 @@ var Server = /*#__PURE__*/function () {
6932
7296
  }, {
6933
7297
  key: "handleUpdateLocalOrdersBatch",
6934
7298
  value: (function () {
6935
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
7299
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(orderIds) {
6936
7300
  var _this$app18;
6937
- var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6938
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6939
- while (1) switch (_context71.prev = _context71.next) {
7301
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
7302
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7303
+ while (1) switch (_context72.prev = _context72.next) {
6940
7304
  case 0:
6941
7305
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
6942
7306
  count: orderIds.length,
6943
7307
  orderIds: orderIds
6944
7308
  });
6945
7309
  if (this.order) {
6946
- _context71.next = 4;
7310
+ _context72.next = 4;
6947
7311
  break;
6948
7312
  }
6949
7313
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
6950
- return _context71.abrupt("return", {
7314
+ return _context72.abrupt("return", {
6951
7315
  code: 500,
6952
7316
  status: false,
6953
7317
  message: 'Order 模块未注册',
@@ -6955,11 +7319,11 @@ var Server = /*#__PURE__*/function () {
6955
7319
  });
6956
7320
  case 4:
6957
7321
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
6958
- _context71.next = 7;
7322
+ _context72.next = 7;
6959
7323
  break;
6960
7324
  }
6961
7325
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
6962
- return _context71.abrupt("return", {
7326
+ return _context72.abrupt("return", {
6963
7327
  code: 500,
6964
7328
  status: false,
6965
7329
  message: 'app.request 不可用',
@@ -6982,21 +7346,21 @@ var Server = /*#__PURE__*/function () {
6982
7346
  _iterator13.f();
6983
7347
  }
6984
7348
  fetched = [];
6985
- _context71.prev = 11;
6986
- _context71.next = 14;
7349
+ _context72.prev = 11;
7350
+ _context72.next = 14;
6987
7351
  return this.order.fetchOrdersByHttp(orderIds);
6988
7352
  case 14:
6989
- fetched = _context71.sent;
6990
- _context71.next = 22;
7353
+ fetched = _context72.sent;
7354
+ _context72.next = 22;
6991
7355
  break;
6992
7356
  case 17:
6993
- _context71.prev = 17;
6994
- _context71.t0 = _context71["catch"](11);
6995
- message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7357
+ _context72.prev = 17;
7358
+ _context72.t0 = _context72["catch"](11);
7359
+ message = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
6996
7360
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
6997
7361
  message: message
6998
7362
  });
6999
- return _context71.abrupt("return", {
7363
+ return _context72.abrupt("return", {
7000
7364
  code: 500,
7001
7365
  status: false,
7002
7366
  message: message,
@@ -7006,36 +7370,36 @@ var Server = /*#__PURE__*/function () {
7006
7370
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
7007
7371
  fetchedMap = new Map();
7008
7372
  _iterator14 = _createForOfIteratorHelper(fetched);
7009
- _context71.prev = 24;
7373
+ _context72.prev = 24;
7010
7374
  _iterator14.s();
7011
7375
  case 26:
7012
7376
  if ((_step14 = _iterator14.n()).done) {
7013
- _context71.next = 34;
7377
+ _context72.next = 34;
7014
7378
  break;
7015
7379
  }
7016
7380
  order = _step14.value;
7017
7381
  oid = order === null || order === void 0 ? void 0 : order.order_id;
7018
7382
  if (!(oid === undefined || oid === null)) {
7019
- _context71.next = 31;
7383
+ _context72.next = 31;
7020
7384
  break;
7021
7385
  }
7022
- return _context71.abrupt("continue", 32);
7386
+ return _context72.abrupt("continue", 32);
7023
7387
  case 31:
7024
7388
  fetchedMap.set(String(oid), order);
7025
7389
  case 32:
7026
- _context71.next = 26;
7390
+ _context72.next = 26;
7027
7391
  break;
7028
7392
  case 34:
7029
- _context71.next = 39;
7393
+ _context72.next = 39;
7030
7394
  break;
7031
7395
  case 36:
7032
- _context71.prev = 36;
7033
- _context71.t1 = _context71["catch"](24);
7034
- _iterator14.e(_context71.t1);
7396
+ _context72.prev = 36;
7397
+ _context72.t1 = _context72["catch"](24);
7398
+ _iterator14.e(_context72.t1);
7035
7399
  case 39:
7036
- _context71.prev = 39;
7400
+ _context72.prev = 39;
7037
7401
  _iterator14.f();
7038
- return _context71.finish(39);
7402
+ return _context72.finish(39);
7039
7403
  case 42:
7040
7404
  freshOrders = [];
7041
7405
  succeedIds = [];
@@ -7061,26 +7425,26 @@ var Server = /*#__PURE__*/function () {
7061
7425
  _iterator15.f();
7062
7426
  }
7063
7427
  if (!(freshOrders.length > 0)) {
7064
- _context71.next = 58;
7428
+ _context72.next = 58;
7065
7429
  break;
7066
7430
  }
7067
- _context71.prev = 48;
7068
- _context71.next = 51;
7431
+ _context72.prev = 48;
7432
+ _context72.next = 51;
7069
7433
  return this.order.upsertOrdersFromRemote(freshOrders);
7070
7434
  case 51:
7071
- _context71.next = 58;
7435
+ _context72.next = 58;
7072
7436
  break;
7073
7437
  case 53:
7074
- _context71.prev = 53;
7075
- _context71.t2 = _context71["catch"](48);
7076
- _message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
7438
+ _context72.prev = 53;
7439
+ _context72.t2 = _context72["catch"](48);
7440
+ _message4 = _context72.t2 instanceof Error ? _context72.t2.message : String(_context72.t2);
7077
7441
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
7078
- message: _message2
7442
+ message: _message4
7079
7443
  });
7080
- return _context71.abrupt("return", {
7444
+ return _context72.abrupt("return", {
7081
7445
  code: 500,
7082
7446
  status: false,
7083
- message: _message2,
7447
+ message: _message4,
7084
7448
  data: null
7085
7449
  });
7086
7450
  case 58:
@@ -7096,7 +7460,7 @@ var Server = /*#__PURE__*/function () {
7096
7460
  insertedCount: inserted.length,
7097
7461
  failedCount: failed.length
7098
7462
  });
7099
- return _context71.abrupt("return", {
7463
+ return _context72.abrupt("return", {
7100
7464
  code: 200,
7101
7465
  status: true,
7102
7466
  message: '',
@@ -7108,11 +7472,11 @@ var Server = /*#__PURE__*/function () {
7108
7472
  });
7109
7473
  case 62:
7110
7474
  case "end":
7111
- return _context71.stop();
7475
+ return _context72.stop();
7112
7476
  }
7113
- }, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7477
+ }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7114
7478
  }));
7115
- function handleUpdateLocalOrdersBatch(_x79) {
7479
+ function handleUpdateLocalOrdersBatch(_x82) {
7116
7480
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7117
7481
  }
7118
7482
  return handleUpdateLocalOrdersBatch;
@@ -7129,7 +7493,7 @@ var Server = /*#__PURE__*/function () {
7129
7493
  var target = url.startsWith('http') ? new URL(url) : new URL(url, 'http://placeholder.local');
7130
7494
  var value = target.searchParams.get(key);
7131
7495
  return value !== null && value !== void 0 ? value : null;
7132
- } catch (_unused2) {
7496
+ } catch (_unused3) {
7133
7497
  var queryIndex = url.indexOf('?');
7134
7498
  if (queryIndex < 0) return null;
7135
7499
  var query = url.slice(queryIndex + 1);
@@ -7148,7 +7512,7 @@ var Server = /*#__PURE__*/function () {
7148
7512
  if (decodeURIComponent(rawKey) === key) {
7149
7513
  return decodeURIComponent(rawValue);
7150
7514
  }
7151
- } catch (_unused3) {
7515
+ } catch (_unused4) {
7152
7516
  if (rawKey === key) return rawValue;
7153
7517
  }
7154
7518
  }
@@ -7189,10 +7553,10 @@ var Server = /*#__PURE__*/function () {
7189
7553
  }, {
7190
7554
  key: "extractOrderDataFromCheckoutResponse",
7191
7555
  value: function extractOrderDataFromCheckoutResponse(response) {
7192
- var _response$data6, _response$data7;
7193
- var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
7194
- for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
7195
- var candidate = _candidates[_i4];
7556
+ var _response$data5, _response$data6;
7557
+ var candidates = [response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5.order, response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
7558
+ for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
7559
+ var candidate = _candidates2[_i6];
7196
7560
  if (!candidate || _typeof(candidate) !== 'object') continue;
7197
7561
  if (candidate.order_id !== undefined && candidate.order_id !== null) {
7198
7562
  return candidate;
@@ -7312,7 +7676,7 @@ var Server = /*#__PURE__*/function () {
7312
7676
  if (typeof normalized === 'string') return normalized;
7313
7677
  try {
7314
7678
  return JSON.stringify(normalized);
7315
- } catch (_unused4) {
7679
+ } catch (_unused5) {
7316
7680
  return String(error);
7317
7681
  }
7318
7682
  }
@@ -7347,7 +7711,7 @@ var Server = /*#__PURE__*/function () {
7347
7711
  seen.add(current);
7348
7712
  return current;
7349
7713
  }));
7350
- } catch (_unused5) {
7714
+ } catch (_unused6) {
7351
7715
  return String(value);
7352
7716
  }
7353
7717
  }
@@ -7356,10 +7720,10 @@ var Server = /*#__PURE__*/function () {
7356
7720
  value: function extractBackendErrorResponse(error) {
7357
7721
  var _error$response3,
7358
7722
  _error$response4,
7359
- _this20 = this;
7723
+ _this21 = this;
7360
7724
  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];
7361
7725
  return candidates.find(function (candidate) {
7362
- return _this20.isExplicitBackendErrorResponse(candidate);
7726
+ return _this21.isExplicitBackendErrorResponse(candidate);
7363
7727
  }) || null;
7364
7728
  }
7365
7729
  }, {
@@ -7380,7 +7744,7 @@ var Server = /*#__PURE__*/function () {
7380
7744
  try {
7381
7745
  var pathname = url.startsWith('http') ? new URL(url).pathname : noQuery;
7382
7746
  return pathname.replace(/\/$/, '') || pathname;
7383
- } catch (_unused6) {
7747
+ } catch (_unused7) {
7384
7748
  return noQuery.replace(/\/$/, '');
7385
7749
  }
7386
7750
  }
@@ -7478,16 +7842,16 @@ var Server = /*#__PURE__*/function () {
7478
7842
  }, {
7479
7843
  key: "recomputeAndNotifyFloorPlanQuery",
7480
7844
  value: (function () {
7481
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7845
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7482
7846
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7483
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7484
- while (1) switch (_context72.prev = _context72.next) {
7847
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7848
+ while (1) switch (_context73.prev = _context73.next) {
7485
7849
  case 0:
7486
7850
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7487
- _context72.next = 2;
7851
+ _context73.next = 2;
7488
7852
  break;
7489
7853
  }
7490
- return _context72.abrupt("return");
7854
+ return _context73.abrupt("return");
7491
7855
  case 2:
7492
7856
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7493
7857
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -7517,9 +7881,9 @@ var Server = /*#__PURE__*/function () {
7517
7881
  }
7518
7882
  case 5:
7519
7883
  case "end":
7520
- return _context72.stop();
7884
+ return _context73.stop();
7521
7885
  }
7522
- }, _callee72, this);
7886
+ }, _callee73, this);
7523
7887
  }));
7524
7888
  function recomputeAndNotifyFloorPlanQuery() {
7525
7889
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7549,20 +7913,20 @@ var Server = /*#__PURE__*/function () {
7549
7913
  * filter 逻辑暂为 mock,仅记录参数
7550
7914
  */
7551
7915
  function () {
7552
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7916
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7553
7917
  var rawList, result;
7554
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7555
- while (1) switch (_context73.prev = _context73.next) {
7918
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7919
+ while (1) switch (_context74.prev = _context74.next) {
7556
7920
  case 0:
7557
7921
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7558
7922
  data: data
7559
7923
  });
7560
7924
  if (this.order) {
7561
- _context73.next = 4;
7925
+ _context74.next = 4;
7562
7926
  break;
7563
7927
  }
7564
7928
  this.logError('computeOrderQueryResult: Order 模块未注册');
7565
- return _context73.abrupt("return", {
7929
+ return _context74.abrupt("return", {
7566
7930
  code: 500,
7567
7931
  message: 'Order 模块未注册',
7568
7932
  data: {
@@ -7592,7 +7956,7 @@ var Server = /*#__PURE__*/function () {
7592
7956
  skip: result.skip,
7593
7957
  rejected: result.rejected
7594
7958
  });
7595
- return _context73.abrupt("return", {
7959
+ return _context74.abrupt("return", {
7596
7960
  code: 200,
7597
7961
  data: result,
7598
7962
  message: '',
@@ -7600,11 +7964,11 @@ var Server = /*#__PURE__*/function () {
7600
7964
  });
7601
7965
  case 10:
7602
7966
  case "end":
7603
- return _context73.stop();
7967
+ return _context74.stop();
7604
7968
  }
7605
- }, _callee73, this);
7969
+ }, _callee74, this);
7606
7970
  }));
7607
- function computeOrderQueryResult(_x80) {
7971
+ function computeOrderQueryResult(_x83) {
7608
7972
  return _computeOrderQueryResult.apply(this, arguments);
7609
7973
  }
7610
7974
  return computeOrderQueryResult;
@@ -7617,17 +7981,17 @@ var Server = /*#__PURE__*/function () {
7617
7981
  }, {
7618
7982
  key: "computeBookingQueryResult",
7619
7983
  value: (function () {
7620
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7984
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data) {
7621
7985
  var rawOrders, result;
7622
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7623
- while (1) switch (_context74.prev = _context74.next) {
7986
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7987
+ while (1) switch (_context75.prev = _context75.next) {
7624
7988
  case 0:
7625
7989
  if (this.order) {
7626
- _context74.next = 3;
7990
+ _context75.next = 3;
7627
7991
  break;
7628
7992
  }
7629
7993
  this.logError('computeBookingQueryResult: Order 模块未注册');
7630
- return _context74.abrupt("return", {
7994
+ return _context75.abrupt("return", {
7631
7995
  code: 500,
7632
7996
  message: 'Order 模块未注册',
7633
7997
  data: {
@@ -7646,7 +8010,7 @@ var Server = /*#__PURE__*/function () {
7646
8010
  size: result.size,
7647
8011
  skip: result.skip
7648
8012
  });
7649
- return _context74.abrupt("return", {
8013
+ return _context75.abrupt("return", {
7650
8014
  code: 200,
7651
8015
  data: result,
7652
8016
  message: '',
@@ -7654,11 +8018,11 @@ var Server = /*#__PURE__*/function () {
7654
8018
  });
7655
8019
  case 8:
7656
8020
  case "end":
7657
- return _context74.stop();
8021
+ return _context75.stop();
7658
8022
  }
7659
- }, _callee74, this);
8023
+ }, _callee75, this);
7660
8024
  }));
7661
- function computeBookingQueryResult(_x81) {
8025
+ function computeBookingQueryResult(_x84) {
7662
8026
  return _computeBookingQueryResult.apply(this, arguments);
7663
8027
  }
7664
8028
  return computeBookingQueryResult;
@@ -7717,12 +8081,12 @@ var Server = /*#__PURE__*/function () {
7717
8081
  }, {
7718
8082
  key: "computeProductQueryResult",
7719
8083
  value: (function () {
7720
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
8084
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(context, options) {
7721
8085
  var _menu_list_ids$length3,
7722
- _this21 = this;
8086
+ _this22 = this;
7723
8087
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, 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;
7724
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7725
- while (1) switch (_context75.prev = _context75.next) {
8088
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8089
+ while (1) switch (_context76.prev = _context76.next) {
7726
8090
  case 0:
7727
8091
  tTotal = performance.now();
7728
8092
  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, strategy_context = context.strategy_context;
@@ -7749,28 +8113,28 @@ var Server = /*#__PURE__*/function () {
7749
8113
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7750
8114
  });
7751
8115
  if (this.products) {
7752
- _context75.next = 8;
8116
+ _context76.next = 8;
7753
8117
  break;
7754
8118
  }
7755
8119
  this.logError('computeProductQueryResult: Products 模块未注册');
7756
- return _context75.abrupt("return", {
8120
+ return _context76.abrupt("return", {
7757
8121
  message: 'Products 模块未注册',
7758
8122
  data: this.buildProductQueryResultPayload([], 0)
7759
8123
  });
7760
8124
  case 8:
7761
8125
  if (!(queryIds.length > 0)) {
7762
- _context75.next = 20;
8126
+ _context76.next = 20;
7763
8127
  break;
7764
8128
  }
7765
8129
  uniqueIds = Array.from(new Set(queryIds));
7766
8130
  _tPrice = performance.now();
7767
- _context75.next = 13;
8131
+ _context76.next = 13;
7768
8132
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7769
8133
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7770
8134
  productIds: uniqueIds
7771
8135
  });
7772
8136
  case 13:
7773
- productsWithPrice = _context75.sent;
8137
+ productsWithPrice = _context76.sent;
7774
8138
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7775
8139
  count: productsWithPrice.length,
7776
8140
  ids: uniqueIds
@@ -7790,7 +8154,7 @@ var Server = /*#__PURE__*/function () {
7790
8154
  ids: uniqueIds,
7791
8155
  count: extensionFilteredProducts.length
7792
8156
  });
7793
- return _context75.abrupt("return", {
8157
+ return _context76.abrupt("return", {
7794
8158
  code: 200,
7795
8159
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7796
8160
  message: '',
@@ -7798,17 +8162,17 @@ var Server = /*#__PURE__*/function () {
7798
8162
  });
7799
8163
  case 20:
7800
8164
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7801
- _context75.next = 32;
8165
+ _context76.next = 32;
7802
8166
  break;
7803
8167
  }
7804
8168
  pid = Number(product_id);
7805
8169
  _tPrice2 = performance.now();
7806
- _context75.next = 25;
8170
+ _context76.next = 25;
7807
8171
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7808
8172
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7809
8173
  });
7810
8174
  case 25:
7811
- allProductsWithPrice = _context75.sent;
8175
+ allProductsWithPrice = _context76.sent;
7812
8176
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7813
8177
  count: allProductsWithPrice.length,
7814
8178
  productId: pid
@@ -7828,7 +8192,7 @@ var Server = /*#__PURE__*/function () {
7828
8192
  productId: pid,
7829
8193
  found: !!item
7830
8194
  });
7831
- return _context75.abrupt("return", {
8195
+ return _context76.abrupt("return", {
7832
8196
  code: 200,
7833
8197
  data: item,
7834
8198
  message: item ? '' : '商品不存在或未发布',
@@ -7836,16 +8200,16 @@ var Server = /*#__PURE__*/function () {
7836
8200
  });
7837
8201
  case 32:
7838
8202
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7839
- _context75.next = 52;
8203
+ _context76.next = 52;
7840
8204
  break;
7841
8205
  }
7842
8206
  _tPrice3 = performance.now();
7843
- _context75.next = 36;
8207
+ _context76.next = 36;
7844
8208
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7845
8209
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7846
8210
  });
7847
8211
  case 36:
7848
- _filteredProducts2 = _context75.sent;
8212
+ _filteredProducts2 = _context76.sent;
7849
8213
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7850
8214
  count: _filteredProducts2.length,
7851
8215
  extension_type: extension_type
@@ -7884,7 +8248,7 @@ var Server = /*#__PURE__*/function () {
7884
8248
  filteredCount: _filteredProducts2.length,
7885
8249
  extension_type: extension_type
7886
8250
  });
7887
- return _context75.abrupt("return", {
8251
+ return _context76.abrupt("return", {
7888
8252
  code: 200,
7889
8253
  data: this.buildProductQueryResultPayload(_filteredProducts2),
7890
8254
  message: '',
@@ -7892,50 +8256,50 @@ var Server = /*#__PURE__*/function () {
7892
8256
  });
7893
8257
  case 52:
7894
8258
  if (this.menu) {
7895
- _context75.next = 55;
8259
+ _context76.next = 55;
7896
8260
  break;
7897
8261
  }
7898
8262
  this.logError('computeProductQueryResult: Menu 模块未注册');
7899
- return _context75.abrupt("return", {
8263
+ return _context76.abrupt("return", {
7900
8264
  message: 'Menu 模块未注册',
7901
8265
  data: this.buildProductQueryResultPayload([], 0)
7902
8266
  });
7903
8267
  case 55:
7904
8268
  if (this.schedule) {
7905
- _context75.next = 58;
8269
+ _context76.next = 58;
7906
8270
  break;
7907
8271
  }
7908
8272
  this.logError('computeProductQueryResult: Schedule 模块未注册');
7909
- return _context75.abrupt("return", {
8273
+ return _context76.abrupt("return", {
7910
8274
  message: 'Schedule 模块未注册',
7911
8275
  data: this.buildProductQueryResultPayload([], 0)
7912
8276
  });
7913
8277
  case 58:
7914
8278
  activeMenuList = [];
7915
8279
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
7916
- _context75.next = 71;
8280
+ _context76.next = 71;
7917
8281
  break;
7918
8282
  }
7919
8283
  tMenu = performance.now();
7920
8284
  getActiveMenus = function getActiveMenus() {
7921
- return _this21.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7922
- var _this21$schedule;
7923
- return ((_this21$schedule = _this21.schedule) === null || _this21$schedule === void 0 ? void 0 : _this21$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8285
+ return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8286
+ var _this22$schedule;
8287
+ return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7924
8288
  });
7925
8289
  };
7926
8290
  activeMenuList = getActiveMenus();
7927
- _context75.t0 = !activeMenuList.length;
7928
- if (!_context75.t0) {
7929
- _context75.next = 68;
8291
+ _context76.t0 = !activeMenuList.length;
8292
+ if (!_context76.t0) {
8293
+ _context76.next = 68;
7930
8294
  break;
7931
8295
  }
7932
- _context75.next = 67;
8296
+ _context76.next = 67;
7933
8297
  return this.refreshMenuScheduleCacheAfterEmptyResult();
7934
8298
  case 67:
7935
- _context75.t0 = _context75.sent;
8299
+ _context76.t0 = _context76.sent;
7936
8300
  case 68:
7937
- if (!_context75.t0) {
7938
- _context75.next = 70;
8301
+ if (!_context76.t0) {
8302
+ _context76.next = 70;
7939
8303
  break;
7940
8304
  }
7941
8305
  activeMenuList = getActiveMenus();
@@ -7955,22 +8319,22 @@ var Server = /*#__PURE__*/function () {
7955
8319
  });
7956
8320
  tPrice = performance.now();
7957
8321
  if (!(scopedProductIds.length > 0)) {
7958
- _context75.next = 82;
8322
+ _context76.next = 82;
7959
8323
  break;
7960
8324
  }
7961
- _context75.next = 79;
8325
+ _context76.next = 79;
7962
8326
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7963
8327
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7964
8328
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
7965
8329
  });
7966
8330
  case 79:
7967
- _context75.t1 = _context75.sent;
7968
- _context75.next = 83;
8331
+ _context76.t1 = _context76.sent;
8332
+ _context76.next = 83;
7969
8333
  break;
7970
8334
  case 82:
7971
- _context75.t1 = [];
8335
+ _context76.t1 = [];
7972
8336
  case 83:
7973
- filteredProducts = _context75.t1;
8337
+ filteredProducts = _context76.t1;
7974
8338
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
7975
8339
  count: filteredProducts.length,
7976
8340
  scopedProductCount: scopedProductIds.length
@@ -8011,7 +8375,7 @@ var Server = /*#__PURE__*/function () {
8011
8375
  filteredCount: filteredProducts.length,
8012
8376
  activeMenuCount: activeMenuList.length
8013
8377
  });
8014
- return _context75.abrupt("return", {
8378
+ return _context76.abrupt("return", {
8015
8379
  code: 200,
8016
8380
  data: this.buildProductQueryResultPayload(filteredProducts),
8017
8381
  message: '',
@@ -8019,11 +8383,11 @@ var Server = /*#__PURE__*/function () {
8019
8383
  });
8020
8384
  case 99:
8021
8385
  case "end":
8022
- return _context75.stop();
8386
+ return _context76.stop();
8023
8387
  }
8024
- }, _callee75, this);
8388
+ }, _callee76, this);
8025
8389
  }));
8026
- function computeProductQueryResult(_x82, _x83) {
8390
+ function computeProductQueryResult(_x85, _x86) {
8027
8391
  return _computeProductQueryResult.apply(this, arguments);
8028
8392
  }
8029
8393
  return computeProductQueryResult;
@@ -8059,72 +8423,72 @@ var Server = /*#__PURE__*/function () {
8059
8423
  }, {
8060
8424
  key: "recomputeAndNotifyProductQuery",
8061
8425
  value: (function () {
8062
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
8426
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(options) {
8063
8427
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
8064
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8065
- while (1) switch (_context76.prev = _context76.next) {
8428
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8429
+ while (1) switch (_context77.prev = _context77.next) {
8066
8430
  case 0:
8067
8431
  if (!(this.productQuerySubscribers.size === 0)) {
8068
- _context76.next = 2;
8432
+ _context77.next = 2;
8069
8433
  break;
8070
8434
  }
8071
- return _context76.abrupt("return");
8435
+ return _context77.abrupt("return");
8072
8436
  case 2:
8073
8437
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
8074
8438
  subscriberCount: this.productQuerySubscribers.size,
8075
8439
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8076
8440
  });
8077
8441
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
8078
- _context76.prev = 4;
8442
+ _context77.prev = 4;
8079
8443
  _iterator18.s();
8080
8444
  case 6:
8081
8445
  if ((_step18 = _iterator18.n()).done) {
8082
- _context76.next = 22;
8446
+ _context77.next = 22;
8083
8447
  break;
8084
8448
  }
8085
8449
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
8086
- _context76.prev = 8;
8087
- _context76.next = 11;
8450
+ _context77.prev = 8;
8451
+ _context77.next = 11;
8088
8452
  return this.computeProductQueryResult(subscriber.context, {
8089
8453
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8090
8454
  });
8091
8455
  case 11:
8092
- result = _context76.sent;
8456
+ result = _context77.sent;
8093
8457
  subscriber.callback(result);
8094
8458
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
8095
8459
  subscriberId: subscriberId
8096
8460
  });
8097
- _context76.next = 20;
8461
+ _context77.next = 20;
8098
8462
  break;
8099
8463
  case 16:
8100
- _context76.prev = 16;
8101
- _context76.t0 = _context76["catch"](8);
8102
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8464
+ _context77.prev = 16;
8465
+ _context77.t0 = _context77["catch"](8);
8466
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8103
8467
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
8104
8468
  subscriberId: subscriberId,
8105
8469
  error: errorMessage
8106
8470
  });
8107
8471
  case 20:
8108
- _context76.next = 6;
8472
+ _context77.next = 6;
8109
8473
  break;
8110
8474
  case 22:
8111
- _context76.next = 27;
8475
+ _context77.next = 27;
8112
8476
  break;
8113
8477
  case 24:
8114
- _context76.prev = 24;
8115
- _context76.t1 = _context76["catch"](4);
8116
- _iterator18.e(_context76.t1);
8478
+ _context77.prev = 24;
8479
+ _context77.t1 = _context77["catch"](4);
8480
+ _iterator18.e(_context77.t1);
8117
8481
  case 27:
8118
- _context76.prev = 27;
8482
+ _context77.prev = 27;
8119
8483
  _iterator18.f();
8120
- return _context76.finish(27);
8484
+ return _context77.finish(27);
8121
8485
  case 30:
8122
8486
  case "end":
8123
- return _context76.stop();
8487
+ return _context77.stop();
8124
8488
  }
8125
- }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8489
+ }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8126
8490
  }));
8127
- function recomputeAndNotifyProductQuery(_x84) {
8491
+ function recomputeAndNotifyProductQuery(_x87) {
8128
8492
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8129
8493
  }
8130
8494
  return recomputeAndNotifyProductQuery;
@@ -8136,16 +8500,16 @@ var Server = /*#__PURE__*/function () {
8136
8500
  }, {
8137
8501
  key: "recomputeAndNotifyOrderQuery",
8138
8502
  value: (function () {
8139
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8503
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8140
8504
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8141
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8142
- while (1) switch (_context77.prev = _context77.next) {
8505
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8506
+ while (1) switch (_context78.prev = _context78.next) {
8143
8507
  case 0:
8144
8508
  if (!(this.orderQuerySubscribers.size === 0)) {
8145
- _context77.next = 2;
8509
+ _context78.next = 2;
8146
8510
  break;
8147
8511
  }
8148
- return _context77.abrupt("return");
8512
+ return _context78.abrupt("return");
8149
8513
  case 2:
8150
8514
  notifyStartAt = Date.now();
8151
8515
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -8153,20 +8517,20 @@ var Server = /*#__PURE__*/function () {
8153
8517
  notifyStartAt: new Date(notifyStartAt).toISOString()
8154
8518
  });
8155
8519
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8156
- _context77.prev = 5;
8520
+ _context78.prev = 5;
8157
8521
  _iterator19.s();
8158
8522
  case 7:
8159
8523
  if ((_step19 = _iterator19.n()).done) {
8160
- _context77.next = 27;
8524
+ _context78.next = 27;
8161
8525
  break;
8162
8526
  }
8163
8527
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8164
- _context77.prev = 9;
8528
+ _context78.prev = 9;
8165
8529
  computeStartAt = Date.now();
8166
- _context77.next = 13;
8530
+ _context78.next = 13;
8167
8531
  return this.computeOrderQueryResult(subscriber.context);
8168
8532
  case 13:
8169
- result = _context77.sent;
8533
+ result = _context78.sent;
8170
8534
  computeEndAt = Date.now();
8171
8535
  callbackStartAt = Date.now();
8172
8536
  subscriber.callback(result);
@@ -8177,30 +8541,30 @@ var Server = /*#__PURE__*/function () {
8177
8541
  callbackDurationMs: callbackEndAt - callbackStartAt,
8178
8542
  totalDurationMs: callbackEndAt - computeStartAt
8179
8543
  });
8180
- _context77.next = 25;
8544
+ _context78.next = 25;
8181
8545
  break;
8182
8546
  case 21:
8183
- _context77.prev = 21;
8184
- _context77.t0 = _context77["catch"](9);
8185
- errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8547
+ _context78.prev = 21;
8548
+ _context78.t0 = _context78["catch"](9);
8549
+ errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8186
8550
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
8187
8551
  subscriberId: subscriberId,
8188
8552
  error: errorMessage
8189
8553
  });
8190
8554
  case 25:
8191
- _context77.next = 7;
8555
+ _context78.next = 7;
8192
8556
  break;
8193
8557
  case 27:
8194
- _context77.next = 32;
8558
+ _context78.next = 32;
8195
8559
  break;
8196
8560
  case 29:
8197
- _context77.prev = 29;
8198
- _context77.t1 = _context77["catch"](5);
8199
- _iterator19.e(_context77.t1);
8561
+ _context78.prev = 29;
8562
+ _context78.t1 = _context78["catch"](5);
8563
+ _iterator19.e(_context78.t1);
8200
8564
  case 32:
8201
- _context77.prev = 32;
8565
+ _context78.prev = 32;
8202
8566
  _iterator19.f();
8203
- return _context77.finish(32);
8567
+ return _context78.finish(32);
8204
8568
  case 35:
8205
8569
  notifyEndAt = Date.now();
8206
8570
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8209,9 +8573,9 @@ var Server = /*#__PURE__*/function () {
8209
8573
  });
8210
8574
  case 37:
8211
8575
  case "end":
8212
- return _context77.stop();
8576
+ return _context78.stop();
8213
8577
  }
8214
- }, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
8578
+ }, _callee78, this, [[5, 29, 32, 35], [9, 21]]);
8215
8579
  }));
8216
8580
  function recomputeAndNotifyOrderQuery() {
8217
8581
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8229,7 +8593,7 @@ var Server = /*#__PURE__*/function () {
8229
8593
  }, {
8230
8594
  key: "notifySalesSearchSubscribers",
8231
8595
  value: function notifySalesSearchSubscribers(payload) {
8232
- var _this22 = this;
8596
+ var _this23 = this;
8233
8597
  if (this.salesSearchSubscribers.size === 0) return;
8234
8598
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8235
8599
  if (changedOrders.length === 0) {
@@ -8247,21 +8611,21 @@ var Server = /*#__PURE__*/function () {
8247
8611
  subscriber = _step20$value[1];
8248
8612
  try {
8249
8613
  var changedVisibleOrders = changedOrders.filter(function (order) {
8250
- var orderId = _this22.getSalesSearchOrderId(order);
8614
+ var orderId = _this23.getSalesSearchOrderId(order);
8251
8615
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8252
8616
  });
8253
8617
  if (changedVisibleOrders.length === 0) {
8254
8618
  return 1; // continue
8255
8619
  }
8256
- subscriber.callback(_this22.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8257
- _this22.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8620
+ subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8621
+ _this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8258
8622
  subscriberId: subscriberId,
8259
8623
  kind: subscriber.kind,
8260
8624
  count: changedVisibleOrders.length
8261
8625
  });
8262
8626
  } catch (error) {
8263
8627
  var errorMessage = error instanceof Error ? error.message : String(error);
8264
- _this22.logError('notifySalesSearchSubscribers: 推送失败', {
8628
+ _this23.logError('notifySalesSearchSubscribers: 推送失败', {
8265
8629
  subscriberId: subscriberId,
8266
8630
  error: errorMessage
8267
8631
  });
@@ -8352,67 +8716,67 @@ var Server = /*#__PURE__*/function () {
8352
8716
  }, {
8353
8717
  key: "recomputeAndNotifyBookingQuery",
8354
8718
  value: (function () {
8355
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8719
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8356
8720
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8357
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8358
- while (1) switch (_context78.prev = _context78.next) {
8721
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8722
+ while (1) switch (_context79.prev = _context79.next) {
8359
8723
  case 0:
8360
8724
  if (!(this.bookingQuerySubscribers.size === 0)) {
8361
- _context78.next = 2;
8725
+ _context79.next = 2;
8362
8726
  break;
8363
8727
  }
8364
- return _context78.abrupt("return");
8728
+ return _context79.abrupt("return");
8365
8729
  case 2:
8366
8730
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8367
8731
  subscriberCount: this.bookingQuerySubscribers.size
8368
8732
  });
8369
8733
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8370
- _context78.prev = 4;
8734
+ _context79.prev = 4;
8371
8735
  _iterator21.s();
8372
8736
  case 6:
8373
8737
  if ((_step21 = _iterator21.n()).done) {
8374
- _context78.next = 22;
8738
+ _context79.next = 22;
8375
8739
  break;
8376
8740
  }
8377
8741
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8378
- _context78.prev = 8;
8379
- _context78.next = 11;
8742
+ _context79.prev = 8;
8743
+ _context79.next = 11;
8380
8744
  return this.computeBookingQueryResult(subscriber.context);
8381
8745
  case 11:
8382
- result = _context78.sent;
8746
+ result = _context79.sent;
8383
8747
  subscriber.callback(result);
8384
8748
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8385
8749
  subscriberId: subscriberId
8386
8750
  });
8387
- _context78.next = 20;
8751
+ _context79.next = 20;
8388
8752
  break;
8389
8753
  case 16:
8390
- _context78.prev = 16;
8391
- _context78.t0 = _context78["catch"](8);
8392
- errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8754
+ _context79.prev = 16;
8755
+ _context79.t0 = _context79["catch"](8);
8756
+ errorMessage = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
8393
8757
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8394
8758
  subscriberId: subscriberId,
8395
8759
  error: errorMessage
8396
8760
  });
8397
8761
  case 20:
8398
- _context78.next = 6;
8762
+ _context79.next = 6;
8399
8763
  break;
8400
8764
  case 22:
8401
- _context78.next = 27;
8765
+ _context79.next = 27;
8402
8766
  break;
8403
8767
  case 24:
8404
- _context78.prev = 24;
8405
- _context78.t1 = _context78["catch"](4);
8406
- _iterator21.e(_context78.t1);
8768
+ _context79.prev = 24;
8769
+ _context79.t1 = _context79["catch"](4);
8770
+ _iterator21.e(_context79.t1);
8407
8771
  case 27:
8408
- _context78.prev = 27;
8772
+ _context79.prev = 27;
8409
8773
  _iterator21.f();
8410
- return _context78.finish(27);
8774
+ return _context79.finish(27);
8411
8775
  case 30:
8412
8776
  case "end":
8413
- return _context78.stop();
8777
+ return _context79.stop();
8414
8778
  }
8415
- }, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
8779
+ }, _callee79, this, [[4, 24, 27, 30], [8, 16]]);
8416
8780
  }));
8417
8781
  function recomputeAndNotifyBookingQuery() {
8418
8782
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -8551,7 +8915,7 @@ var Server = /*#__PURE__*/function () {
8551
8915
  metadata: metadata || {}
8552
8916
  });
8553
8917
  }
8554
- } catch (_unused7) {
8918
+ } catch (_unused8) {
8555
8919
  // 日志记录失败不影响主流程
8556
8920
  }
8557
8921
  }
@@ -8572,7 +8936,7 @@ var Server = /*#__PURE__*/function () {
8572
8936
  metadata: metadata || {}
8573
8937
  });
8574
8938
  }
8575
- } catch (_unused8) {
8939
+ } catch (_unused9) {
8576
8940
  // 日志记录失败不影响主流程
8577
8941
  }
8578
8942
  }
@@ -8593,7 +8957,7 @@ var Server = /*#__PURE__*/function () {
8593
8957
  metadata: metadata || {}
8594
8958
  });
8595
8959
  }
8596
- } catch (_unused9) {
8960
+ } catch (_unused10) {
8597
8961
  // 日志记录失败不影响主流程
8598
8962
  }
8599
8963
  }