@pisell/pisellos 2.3.57 → 2.3.59

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 (34) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -65
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/modules/Quotation/index.d.ts +6 -0
  5. package/dist/modules/Quotation/index.js +75 -19
  6. package/dist/modules/Rules/index.js +14 -7
  7. package/dist/plugins/request.d.ts +1 -0
  8. package/dist/server/index.d.ts +15 -0
  9. package/dist/server/index.js +970 -842
  10. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  11. package/dist/server/modules/floor-plan/index.js +240 -98
  12. package/dist/server/modules/order/index.d.ts +7 -5
  13. package/dist/server/modules/order/index.js +185 -80
  14. package/dist/server/modules/order/types.d.ts +1 -1
  15. package/dist/server/modules/products/index.d.ts +2 -0
  16. package/dist/server/modules/products/index.js +17 -3
  17. package/dist/server/modules/resource/index.js +21 -13
  18. package/lib/core/index.d.ts +7 -0
  19. package/lib/core/index.js +20 -2
  20. package/lib/modules/Quotation/index.d.ts +6 -0
  21. package/lib/modules/Quotation/index.js +49 -5
  22. package/lib/modules/Rules/index.js +20 -5
  23. package/lib/plugins/request.d.ts +1 -0
  24. package/lib/server/index.d.ts +15 -0
  25. package/lib/server/index.js +120 -15
  26. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  27. package/lib/server/modules/floor-plan/index.js +54 -6
  28. package/lib/server/modules/order/index.d.ts +7 -5
  29. package/lib/server/modules/order/index.js +114 -26
  30. package/lib/server/modules/order/types.d.ts +1 -1
  31. package/lib/server/modules/products/index.d.ts +2 -0
  32. package/lib/server/modules/products/index.js +15 -4
  33. package/lib/server/modules/resource/index.js +7 -2
  34. package/package.json +1 -1
@@ -33,6 +33,7 @@ import { FloorPlanModule } from "./modules/floor-plan";
33
33
  import { FloorPlanHooks } from "./modules/floor-plan/types";
34
34
  import { PaymentServerModule } from "./modules/payment";
35
35
  import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
36
+ import { sortTimePoints } from "./utils/time";
36
37
  import { ProductsHooks } from "./modules/products/types";
37
38
  import { perfMark } from "./utils/product";
38
39
  import { OrderModule } from "./modules/order";
@@ -58,6 +59,7 @@ import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPending
58
59
  /** 平面图 GET 查询订阅者(列表 / id 详情 / code 详情) */
59
60
 
60
61
  var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', 'kitchen', 'original'];
62
+ var AUTO_PRINT_STORAGE_KEY = 'auto_print';
61
63
 
62
64
  /**
63
65
  * Server 类
@@ -336,7 +338,11 @@ var Server = /*#__PURE__*/function () {
336
338
  case 9:
337
339
  result = _context3.sent;
338
340
  if (subscriberId && typeof callback === 'function') {
339
- _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
341
+ _this.syncProductQueryScheduleTimers({
342
+ subscriberId: subscriberId,
343
+ menu_list_ids: menu_list_ids,
344
+ strategy_context: strategy_context
345
+ });
340
346
  }
341
347
  return _context3.abrupt("return", result);
342
348
  case 12:
@@ -1679,7 +1685,7 @@ var Server = /*#__PURE__*/function () {
1679
1685
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1680
1686
  var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
1681
1687
  var _menu_list_ids$length;
1682
- var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1688
+ var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1683
1689
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1684
1690
  while (1) switch (_context24.prev = _context24.next) {
1685
1691
  case 0:
@@ -1735,8 +1741,7 @@ var Server = /*#__PURE__*/function () {
1735
1741
  });
1736
1742
  case 16:
1737
1743
  _context24.prev = 16;
1738
- // 1. 获取餐牌列表
1739
- menuList = _this.menu.getMenuByIds(menu_list_ids);
1744
+ _this$getMenuSchedule = _this.getMenuScheduleTimePoints(menu_list_ids), menuList = _this$getMenuSchedule.menuList, scheduleIds = _this$getMenuSchedule.scheduleIds, scheduleList = _this$getMenuSchedule.scheduleList, timePoints = _this$getMenuSchedule.timePoints;
1740
1745
  console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
1741
1746
  _this.logInfo('handleGetScheduleTimePoints: 获取到餐牌列表', {
1742
1747
  requestedCount: menu_list_ids.length,
@@ -1744,15 +1749,12 @@ var Server = /*#__PURE__*/function () {
1744
1749
  menu_list_ids: menu_list_ids,
1745
1750
  menuList: menuList
1746
1751
  });
1747
-
1748
- // 2. 提取所有的 schedule IDs
1749
- scheduleIds = extractScheduleIdsFromMenus(menuList);
1750
1752
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
1751
1753
  _this.logInfo('handleGetScheduleTimePoints: 提取到日程 IDs', {
1752
1754
  scheduleCount: scheduleIds.length
1753
1755
  });
1754
1756
  if (!(scheduleIds.length === 0)) {
1755
- _context24.next = 26;
1757
+ _context24.next = 25;
1756
1758
  break;
1757
1759
  }
1758
1760
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
@@ -1764,17 +1766,12 @@ var Server = /*#__PURE__*/function () {
1764
1766
  data: [],
1765
1767
  status: true
1766
1768
  });
1767
- case 26:
1768
- // 3. 获取日程详情
1769
- scheduleList = _this.schedule.getScheduleByIds(scheduleIds);
1769
+ case 25:
1770
1770
  console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
1771
1771
  _this.logInfo('handleGetScheduleTimePoints: 获取到日程详情', {
1772
1772
  requestedCount: scheduleIds.length,
1773
1773
  foundCount: scheduleList.length
1774
1774
  });
1775
-
1776
- // 4. 提取时间点
1777
- timePoints = extractTimePointsFromSchedules(scheduleList);
1778
1775
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
1779
1776
  _this.logInfo('handleGetScheduleTimePoints 处理完成', {
1780
1777
  menuListIdsCount: menu_list_ids.length,
@@ -1788,8 +1785,8 @@ var Server = /*#__PURE__*/function () {
1788
1785
  data: timePoints,
1789
1786
  status: true
1790
1787
  });
1791
- case 35:
1792
- _context24.prev = 35;
1788
+ case 32:
1789
+ _context24.prev = 32;
1793
1790
  _context24.t0 = _context24["catch"](16);
1794
1791
  errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : '未知错误';
1795
1792
  console.error('[Server] 获取日程时间点失败:', _context24.t0);
@@ -1803,11 +1800,11 @@ var Server = /*#__PURE__*/function () {
1803
1800
  data: [],
1804
1801
  status: false
1805
1802
  });
1806
- case 41:
1803
+ case 38:
1807
1804
  case "end":
1808
1805
  return _context24.stop();
1809
1806
  }
1810
- }, _callee24, null, [[16, 35]]);
1807
+ }, _callee24, null, [[16, 32]]);
1811
1808
  }));
1812
1809
  return function (_x24) {
1813
1810
  return _ref59.apply(this, arguments);
@@ -2720,6 +2717,7 @@ var Server = /*#__PURE__*/function () {
2720
2717
  key: "setupProductsQuotationPriceBridge",
2721
2718
  value: (function () {
2722
2719
  var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2720
+ var _this5 = this;
2723
2721
  var _this$core$context, errorMessage;
2724
2722
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2725
2723
  while (1) switch (_context33.prev = _context33.next) {
@@ -2739,31 +2737,42 @@ var Server = /*#__PURE__*/function () {
2739
2737
  return _context33.abrupt("return");
2740
2738
  case 6:
2741
2739
  _context33.prev = 6;
2742
- _context33.next = 9;
2743
- return this.schedule.loadAllSchedule();
2744
- case 9:
2745
2740
  this.products.clearPriceCache();
2746
- _context33.next = 12;
2741
+ _context33.next = 10;
2747
2742
  return this.products.setupQuotationPriceBridge({
2748
2743
  scheduleModule: this.schedule,
2749
- channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
2744
+ channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
2745
+ onQuotationUpdated: function onQuotationUpdated() {
2746
+ void _this5.recomputeAndNotifyProductQuery();
2747
+ }
2748
+ });
2749
+ case 10:
2750
+ // Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
2751
+ // 远端刷新转为后台校准,避免二次启动重复阻塞请求。
2752
+ void this.schedule.loadAllSchedule().then(function () {
2753
+ var _this5$products;
2754
+ (_this5$products = _this5.products) === null || _this5$products === void 0 || _this5$products.clearPriceCache();
2755
+ void _this5.recomputeAndNotifyProductQuery();
2756
+ }).catch(function (error) {
2757
+ _this5.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
2758
+ error: error instanceof Error ? error.message : String(error)
2759
+ });
2750
2760
  });
2751
- case 12:
2752
2761
  this.logInfo('Products 报价单价格桥接初始化完成');
2753
- _context33.next = 19;
2762
+ _context33.next = 18;
2754
2763
  break;
2755
- case 15:
2756
- _context33.prev = 15;
2764
+ case 14:
2765
+ _context33.prev = 14;
2757
2766
  _context33.t0 = _context33["catch"](6);
2758
2767
  errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
2759
2768
  this.logError('Products 报价单价格桥接初始化失败', {
2760
2769
  error: errorMessage
2761
2770
  });
2762
- case 19:
2771
+ case 18:
2763
2772
  case "end":
2764
2773
  return _context33.stop();
2765
2774
  }
2766
- }, _callee33, this, [[6, 15]]);
2775
+ }, _callee33, this, [[6, 14]]);
2767
2776
  }));
2768
2777
  function setupProductsQuotationPriceBridge() {
2769
2778
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -2931,6 +2940,87 @@ var Server = /*#__PURE__*/function () {
2931
2940
  }
2932
2941
  return refreshOrdersInBackground;
2933
2942
  }()
2943
+ /**
2944
+ * 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
2945
+ * 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,
2946
+ * UI 可复用 order:onRemoteProductMembershipChanged 处理冲突。
2947
+ */
2948
+ )
2949
+ }, {
2950
+ key: "checkRemoteOrderProductMembership",
2951
+ value: (function () {
2952
+ var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId) {
2953
+ var normalizedOrderId, error, startTime, freshOrders, freshOrder;
2954
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2955
+ while (1) switch (_context36.prev = _context36.next) {
2956
+ case 0:
2957
+ normalizedOrderId = String(orderId !== null && orderId !== void 0 ? orderId : '').trim();
2958
+ if (!(!normalizedOrderId || normalizedOrderId.startsWith('local_order'))) {
2959
+ _context36.next = 4;
2960
+ break;
2961
+ }
2962
+ this.logInfo('checkRemoteOrderProductMembership: 跳过非正式订单', {
2963
+ orderId: orderId
2964
+ });
2965
+ return _context36.abrupt("return");
2966
+ case 4:
2967
+ if (this.order) {
2968
+ _context36.next = 8;
2969
+ break;
2970
+ }
2971
+ error = new Error('Order 模块未注册');
2972
+ this.logWarning('checkRemoteOrderProductMembership: Order 模块未注册', {
2973
+ orderId: normalizedOrderId
2974
+ });
2975
+ throw error;
2976
+ case 8:
2977
+ this.logInfo('checkRemoteOrderProductMembership 开始', {
2978
+ orderId: normalizedOrderId
2979
+ });
2980
+ startTime = Date.now();
2981
+ _context36.prev = 10;
2982
+ _context36.next = 13;
2983
+ return this.order.fetchOrdersByHttp([normalizedOrderId]);
2984
+ case 13:
2985
+ freshOrders = _context36.sent;
2986
+ freshOrder = freshOrders.find(function (order) {
2987
+ return String(order === null || order === void 0 ? void 0 : order.order_id) === normalizedOrderId;
2988
+ });
2989
+ if (freshOrder) {
2990
+ _context36.next = 17;
2991
+ break;
2992
+ }
2993
+ throw new Error('Server 未返回目标订单最新快照');
2994
+ case 17:
2995
+ _context36.next = 19;
2996
+ return this.order.upsertOrdersFromRemote([freshOrder], 'manual.editOpenRemoteCheck');
2997
+ case 19:
2998
+ this.logInfo('checkRemoteOrderProductMembership 完成', {
2999
+ orderId: normalizedOrderId,
3000
+ duration: "".concat(Date.now() - startTime, "ms")
3001
+ });
3002
+ _context36.next = 26;
3003
+ break;
3004
+ case 22:
3005
+ _context36.prev = 22;
3006
+ _context36.t0 = _context36["catch"](10);
3007
+ this.logError('checkRemoteOrderProductMembership 失败', {
3008
+ orderId: normalizedOrderId,
3009
+ duration: "".concat(Date.now() - startTime, "ms"),
3010
+ error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
3011
+ });
3012
+ throw _context36.t0;
3013
+ case 26:
3014
+ case "end":
3015
+ return _context36.stop();
3016
+ }
3017
+ }, _callee36, this, [[10, 22]]);
3018
+ }));
3019
+ function checkRemoteOrderProductMembership(_x36) {
3020
+ return _checkRemoteOrderProductMembership.apply(this, arguments);
3021
+ }
3022
+ return checkRemoteOrderProductMembership;
3023
+ }()
2934
3024
  /**
2935
3025
  * 清空所有server模块的IndexedDB缓存
2936
3026
  * @returns Promise<void>
@@ -2939,10 +3029,10 @@ var Server = /*#__PURE__*/function () {
2939
3029
  }, {
2940
3030
  key: "clearAllIndexDB",
2941
3031
  value: (function () {
2942
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
3032
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2943
3033
  var clearTasks, moduleNames, errorMessage;
2944
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2945
- while (1) switch (_context36.prev = _context36.next) {
3034
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3035
+ while (1) switch (_context37.prev = _context37.next) {
2946
3036
  case 0:
2947
3037
  console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
2948
3038
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
@@ -2977,41 +3067,41 @@ var Server = /*#__PURE__*/function () {
2977
3067
  moduleNames.push('FloorPlan');
2978
3068
  }
2979
3069
  if (!(clearTasks.length === 0)) {
2980
- _context36.next = 15;
3070
+ _context37.next = 15;
2981
3071
  break;
2982
3072
  }
2983
3073
  console.warn('[Server] 没有找到已注册的模块,无需清空');
2984
3074
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
2985
- return _context36.abrupt("return");
3075
+ return _context37.abrupt("return");
2986
3076
  case 15:
2987
3077
  this.logInfo('准备清空模块缓存', {
2988
3078
  moduleNames: moduleNames
2989
3079
  });
2990
- _context36.prev = 16;
2991
- _context36.next = 19;
3080
+ _context37.prev = 16;
3081
+ _context37.next = 19;
2992
3082
  return Promise.all(clearTasks);
2993
3083
  case 19:
2994
3084
  console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
2995
3085
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
2996
3086
  moduleNames: moduleNames
2997
3087
  });
2998
- _context36.next = 29;
3088
+ _context37.next = 29;
2999
3089
  break;
3000
3090
  case 23:
3001
- _context36.prev = 23;
3002
- _context36.t0 = _context36["catch"](16);
3003
- errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0);
3004
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context36.t0);
3091
+ _context37.prev = 23;
3092
+ _context37.t0 = _context37["catch"](16);
3093
+ errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3094
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context37.t0);
3005
3095
  this.logError('清空 IndexedDB 缓存时发生错误', {
3006
3096
  moduleNames: moduleNames,
3007
3097
  error: errorMessage
3008
3098
  });
3009
- throw _context36.t0;
3099
+ throw _context37.t0;
3010
3100
  case 29:
3011
3101
  case "end":
3012
- return _context36.stop();
3102
+ return _context37.stop();
3013
3103
  }
3014
- }, _callee36, this, [[16, 23]]);
3104
+ }, _callee37, this, [[16, 23]]);
3015
3105
  }));
3016
3106
  function clearAllIndexDB() {
3017
3107
  return _clearAllIndexDB.apply(this, arguments);
@@ -3086,10 +3176,10 @@ var Server = /*#__PURE__*/function () {
3086
3176
  }, {
3087
3177
  key: "handleRoute",
3088
3178
  value: (function () {
3089
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(method, path, params) {
3179
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(method, path, params) {
3090
3180
  var startTime, handler, result, duration, _duration4, errorMessage;
3091
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3092
- while (1) switch (_context37.prev = _context37.next) {
3181
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3182
+ while (1) switch (_context38.prev = _context38.next) {
3093
3183
  case 0:
3094
3184
  startTime = Date.now();
3095
3185
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3100,7 +3190,7 @@ var Server = /*#__PURE__*/function () {
3100
3190
  });
3101
3191
  handler = this.getRouteHandler(method, path);
3102
3192
  if (handler) {
3103
- _context37.next = 6;
3193
+ _context38.next = 6;
3104
3194
  break;
3105
3195
  }
3106
3196
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3109,13 +3199,13 @@ var Server = /*#__PURE__*/function () {
3109
3199
  });
3110
3200
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
3111
3201
  case 6:
3112
- _context37.prev = 6;
3113
- _context37.next = 9;
3202
+ _context38.prev = 6;
3203
+ _context38.next = 9;
3114
3204
  return handler(_objectSpread(_objectSpread({}, params), {}, {
3115
3205
  path: path
3116
3206
  }));
3117
3207
  case 9:
3118
- result = _context37.sent;
3208
+ result = _context38.sent;
3119
3209
  duration = Date.now() - startTime;
3120
3210
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
3121
3211
  method: method.toUpperCase(),
@@ -3124,12 +3214,12 @@ var Server = /*#__PURE__*/function () {
3124
3214
  resultCode: result === null || result === void 0 ? void 0 : result.code,
3125
3215
  resultStatus: result === null || result === void 0 ? void 0 : result.status
3126
3216
  });
3127
- return _context37.abrupt("return", result);
3217
+ return _context38.abrupt("return", result);
3128
3218
  case 15:
3129
- _context37.prev = 15;
3130
- _context37.t0 = _context37["catch"](6);
3219
+ _context38.prev = 15;
3220
+ _context38.t0 = _context38["catch"](6);
3131
3221
  _duration4 = Date.now() - startTime;
3132
- errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3222
+ errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3133
3223
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
3134
3224
  method: method.toUpperCase(),
3135
3225
  path: path,
@@ -3137,15 +3227,15 @@ var Server = /*#__PURE__*/function () {
3137
3227
  error: errorMessage,
3138
3228
  data: params.data
3139
3229
  });
3140
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context37.t0);
3141
- throw _context37.t0;
3230
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context38.t0);
3231
+ throw _context38.t0;
3142
3232
  case 22:
3143
3233
  case "end":
3144
- return _context37.stop();
3234
+ return _context38.stop();
3145
3235
  }
3146
- }, _callee37, this, [[6, 15]]);
3236
+ }, _callee38, this, [[6, 15]]);
3147
3237
  }));
3148
- function handleRoute(_x36, _x37, _x38) {
3238
+ function handleRoute(_x37, _x38, _x39) {
3149
3239
  return _handleRoute.apply(this, arguments);
3150
3240
  }
3151
3241
  return handleRoute;
@@ -3157,10 +3247,10 @@ var Server = /*#__PURE__*/function () {
3157
3247
  }, {
3158
3248
  key: "getAllRoutes",
3159
3249
  value: function getAllRoutes() {
3160
- var _this5 = this;
3250
+ var _this6 = this;
3161
3251
  var routes = [];
3162
3252
  ['get', 'post', 'put', 'remove'].forEach(function (method) {
3163
- Object.keys(_this5.router[method]).forEach(function (path) {
3253
+ Object.keys(_this6.router[method]).forEach(function (path) {
3164
3254
  routes.push({
3165
3255
  method: method,
3166
3256
  path: path
@@ -3289,58 +3379,58 @@ var Server = /*#__PURE__*/function () {
3289
3379
  }, {
3290
3380
  key: "getPaymentRouteModule",
3291
3381
  value: function () {
3292
- var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3293
- var _this6 = this;
3294
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3295
- while (1) switch (_context39.prev = _context39.next) {
3382
+ var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3383
+ var _this7 = this;
3384
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3385
+ while (1) switch (_context40.prev = _context40.next) {
3296
3386
  case 0:
3297
3387
  if (!this.payment) {
3298
- _context39.next = 2;
3388
+ _context40.next = 2;
3299
3389
  break;
3300
3390
  }
3301
- return _context39.abrupt("return", this.payment);
3391
+ return _context40.abrupt("return", this.payment);
3302
3392
  case 2:
3303
3393
  if (!this.paymentRouteModule) {
3304
- _context39.next = 4;
3394
+ _context40.next = 4;
3305
3395
  break;
3306
3396
  }
3307
- return _context39.abrupt("return", this.paymentRouteModule);
3397
+ return _context40.abrupt("return", this.paymentRouteModule);
3308
3398
  case 4:
3309
3399
  if (!this.paymentRouteModuleInFlight) {
3310
- _context39.next = 6;
3400
+ _context40.next = 6;
3311
3401
  break;
3312
3402
  }
3313
- return _context39.abrupt("return", this.paymentRouteModuleInFlight);
3403
+ return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3314
3404
  case 6:
3315
- this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3405
+ this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3316
3406
  var module;
3317
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3318
- while (1) switch (_context38.prev = _context38.next) {
3407
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3408
+ while (1) switch (_context39.prev = _context39.next) {
3319
3409
  case 0:
3320
3410
  module = new PaymentServerModule('server_payment_route', '1.0.0');
3321
- _context38.next = 3;
3322
- return module.initialize(_this6.core, {
3411
+ _context39.next = 3;
3412
+ return module.initialize(_this7.core, {
3323
3413
  store: {
3324
3414
  payMethods: []
3325
3415
  }
3326
3416
  });
3327
3417
  case 3:
3328
- _this6.paymentRouteModule = module;
3329
- return _context38.abrupt("return", module);
3418
+ _this7.paymentRouteModule = module;
3419
+ return _context39.abrupt("return", module);
3330
3420
  case 5:
3331
3421
  case "end":
3332
- return _context38.stop();
3422
+ return _context39.stop();
3333
3423
  }
3334
- }, _callee38);
3424
+ }, _callee39);
3335
3425
  }))().finally(function () {
3336
- _this6.paymentRouteModuleInFlight = undefined;
3426
+ _this7.paymentRouteModuleInFlight = undefined;
3337
3427
  });
3338
- return _context39.abrupt("return", this.paymentRouteModuleInFlight);
3428
+ return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3339
3429
  case 8:
3340
3430
  case "end":
3341
- return _context39.stop();
3431
+ return _context40.stop();
3342
3432
  }
3343
- }, _callee39, this);
3433
+ }, _callee40, this);
3344
3434
  }));
3345
3435
  function getPaymentRouteModule() {
3346
3436
  return _getPaymentRouteModule.apply(this, arguments);
@@ -3350,19 +3440,19 @@ var Server = /*#__PURE__*/function () {
3350
3440
  }, {
3351
3441
  key: "fetchQuotationAvailableFromAPI",
3352
3442
  value: function () {
3353
- var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
3443
+ var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
3354
3444
  var _this$app7;
3355
3445
  var requester;
3356
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3357
- while (1) switch (_context40.prev = _context40.next) {
3446
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3447
+ while (1) switch (_context41.prev = _context41.next) {
3358
3448
  case 0:
3359
3449
  requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
3360
3450
  if (requester !== null && requester !== void 0 && requester.get) {
3361
- _context40.next = 4;
3451
+ _context41.next = 4;
3362
3452
  break;
3363
3453
  }
3364
3454
  this.logError('fetchQuotationAvailableFromAPI: request 不可用');
3365
- return _context40.abrupt("return", {
3455
+ return _context41.abrupt("return", {
3366
3456
  code: 500,
3367
3457
  message: 'request 不可用',
3368
3458
  data: {
@@ -3371,14 +3461,14 @@ var Server = /*#__PURE__*/function () {
3371
3461
  status: false
3372
3462
  });
3373
3463
  case 4:
3374
- return _context40.abrupt("return", requester.get('/shop/quotation/available', data));
3464
+ return _context41.abrupt("return", requester.get('/shop/quotation/available', data));
3375
3465
  case 5:
3376
3466
  case "end":
3377
- return _context40.stop();
3467
+ return _context41.stop();
3378
3468
  }
3379
- }, _callee40, this);
3469
+ }, _callee41, this);
3380
3470
  }));
3381
- function fetchQuotationAvailableFromAPI(_x39) {
3471
+ function fetchQuotationAvailableFromAPI(_x40) {
3382
3472
  return _fetchQuotationAvailableFromAPI.apply(this, arguments);
3383
3473
  }
3384
3474
  return fetchQuotationAvailableFromAPI;
@@ -3509,7 +3599,7 @@ var Server = /*#__PURE__*/function () {
3509
3599
  }, {
3510
3600
  key: "scheduleSubscriberTimePointReloads",
3511
3601
  value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3512
- var _this7 = this;
3602
+ var _this8 = this;
3513
3603
  var subscriber = this.productQuerySubscribers.get(subscriberId);
3514
3604
  if (!subscriber || !timePoints.length) return;
3515
3605
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
@@ -3530,7 +3620,7 @@ var Server = /*#__PURE__*/function () {
3530
3620
  setInterval(function () {
3531
3621
  var currentTime = dayjs().format('hh:mm');
3532
3622
  if (timePoints.includes(currentTime)) {
3533
- _this7.onScheduleTimePointTimerFire(subscriberId);
3623
+ _this8.onScheduleTimePointTimerFire(subscriberId);
3534
3624
  }
3535
3625
  }, 60000);
3536
3626
  if (timerIds.length > 0) {
@@ -3550,29 +3640,29 @@ var Server = /*#__PURE__*/function () {
3550
3640
  }, {
3551
3641
  key: "onScheduleTimePointTimerFire",
3552
3642
  value: (function () {
3553
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(subscriberId, timerId) {
3643
+ var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId, timerId) {
3554
3644
  var subscriber;
3555
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3556
- while (1) switch (_context41.prev = _context41.next) {
3645
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3646
+ while (1) switch (_context42.prev = _context42.next) {
3557
3647
  case 0:
3558
3648
  timerId && this.removeScheduleTimerRef(subscriberId, timerId);
3559
3649
  if (this.productQuerySubscribers.has(subscriberId)) {
3560
- _context41.next = 3;
3650
+ _context42.next = 3;
3561
3651
  break;
3562
3652
  }
3563
- return _context41.abrupt("return");
3653
+ return _context42.abrupt("return");
3564
3654
  case 3:
3565
3655
  subscriber = this.productQuerySubscribers.get(subscriberId);
3566
3656
  this.refreshSubscriberScheduleAtExecution(subscriber);
3567
- _context41.next = 7;
3657
+ _context42.next = 7;
3568
3658
  return this.recomputeAndNotifySubscriber(subscriberId);
3569
3659
  case 7:
3570
3660
  case "end":
3571
- return _context41.stop();
3661
+ return _context42.stop();
3572
3662
  }
3573
- }, _callee41, this);
3663
+ }, _callee42, this);
3574
3664
  }));
3575
- function onScheduleTimePointTimerFire(_x40, _x41) {
3665
+ function onScheduleTimePointTimerFire(_x41, _x42) {
3576
3666
  return _onScheduleTimePointTimerFire.apply(this, arguments);
3577
3667
  }
3578
3668
  return onScheduleTimePointTimerFire;
@@ -3584,62 +3674,92 @@ var Server = /*#__PURE__*/function () {
3584
3674
  }, {
3585
3675
  key: "recomputeAndNotifySubscriber",
3586
3676
  value: (function () {
3587
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId) {
3677
+ var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId) {
3588
3678
  var subscriber, result, errorMessage;
3589
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3590
- while (1) switch (_context42.prev = _context42.next) {
3679
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3680
+ while (1) switch (_context43.prev = _context43.next) {
3591
3681
  case 0:
3592
3682
  subscriber = this.productQuerySubscribers.get(subscriberId);
3593
3683
  if (subscriber) {
3594
- _context42.next = 3;
3684
+ _context43.next = 3;
3595
3685
  break;
3596
3686
  }
3597
- return _context42.abrupt("return");
3687
+ return _context43.abrupt("return");
3598
3688
  case 3:
3599
- _context42.prev = 3;
3600
- _context42.next = 6;
3689
+ _context43.prev = 3;
3690
+ _context43.next = 6;
3601
3691
  return this.computeProductQueryResult(subscriber.context);
3602
3692
  case 6:
3603
- result = _context42.sent;
3693
+ result = _context43.sent;
3604
3694
  subscriber.callback(result);
3605
3695
  this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3606
3696
  subscriberId: subscriberId,
3607
3697
  schedule_datetime: subscriber.context.schedule_datetime
3608
3698
  });
3609
- _context42.next = 15;
3699
+ _context43.next = 15;
3610
3700
  break;
3611
3701
  case 11:
3612
- _context42.prev = 11;
3613
- _context42.t0 = _context42["catch"](3);
3614
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3702
+ _context43.prev = 11;
3703
+ _context43.t0 = _context43["catch"](3);
3704
+ errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3615
3705
  this.logError('recomputeAndNotifySubscriber: 推送失败', {
3616
3706
  subscriberId: subscriberId,
3617
3707
  error: errorMessage
3618
3708
  });
3619
3709
  case 15:
3620
3710
  case "end":
3621
- return _context42.stop();
3711
+ return _context43.stop();
3622
3712
  }
3623
- }, _callee42, this, [[3, 11]]);
3713
+ }, _callee43, this, [[3, 11]]);
3624
3714
  }));
3625
- function recomputeAndNotifySubscriber(_x42) {
3715
+ function recomputeAndNotifySubscriber(_x43) {
3626
3716
  return _recomputeAndNotifySubscriber.apply(this, arguments);
3627
3717
  }
3628
3718
  return recomputeAndNotifySubscriber;
3629
3719
  }()
3630
3720
  /**
3631
- * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3721
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
3722
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
3632
3723
  */
3633
3724
  )
3725
+ }, {
3726
+ key: "getMenuScheduleTimePoints",
3727
+ value: function getMenuScheduleTimePoints(menuListIds) {
3728
+ var _this$menu$getMenuByI, _this$menu, _this$schedule$getSch, _this$schedule;
3729
+ var menuList = (_this$menu$getMenuByI = (_this$menu = this.menu) === null || _this$menu === void 0 ? void 0 : _this$menu.getMenuByIds(menuListIds)) !== null && _this$menu$getMenuByI !== void 0 ? _this$menu$getMenuByI : [];
3730
+ var scheduleIds = extractScheduleIdsFromMenus(menuList);
3731
+ var scheduleList = scheduleIds.length > 0 ? (_this$schedule$getSch = (_this$schedule = this.schedule) === null || _this$schedule === void 0 ? void 0 : _this$schedule.getScheduleByIds(scheduleIds)) !== null && _this$schedule$getSch !== void 0 ? _this$schedule$getSch : [] : [];
3732
+ var timePoints = extractTimePointsFromSchedules(scheduleList);
3733
+ return {
3734
+ menuList: menuList,
3735
+ scheduleIds: scheduleIds,
3736
+ scheduleList: scheduleList,
3737
+ timePoints: timePoints
3738
+ };
3739
+ }
3740
+
3741
+ /**
3742
+ * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3743
+ */
3634
3744
  }, {
3635
3745
  key: "syncProductQueryScheduleTimers",
3636
- value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3746
+ value: function syncProductQueryScheduleTimers(_ref61) {
3637
3747
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
3748
+ var subscriberId = _ref61.subscriberId,
3749
+ menu_list_ids = _ref61.menu_list_ids,
3750
+ strategy_context = _ref61.strategy_context;
3638
3751
  this.clearSubscriberScheduleTimers(subscriberId);
3639
3752
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3640
3753
  return;
3641
3754
  }
3642
- var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3755
+ var productTimePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3756
+ var menuListIds = Array.isArray(menu_list_ids) ? Array.from(new Set(menu_list_ids.map(function (id) {
3757
+ return Number(id);
3758
+ }).filter(function (id) {
3759
+ return Number.isFinite(id);
3760
+ }))) : [];
3761
+ var menuTimePoints = this.getMenuScheduleTimePoints(menuListIds).timePoints;
3762
+ var timePoints = sortTimePoints(Array.from(new Set([].concat(_toConsumableArray(productTimePoints), _toConsumableArray(menuTimePoints)))));
3643
3763
  if (timePoints.length > 0) {
3644
3764
  this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3645
3765
  }
@@ -3668,46 +3788,46 @@ var Server = /*#__PURE__*/function () {
3668
3788
  }, {
3669
3789
  key: "refreshMenuScheduleCacheAfterEmptyResult",
3670
3790
  value: (function () {
3671
- var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3672
- var _this8 = this;
3791
+ var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3792
+ var _this9 = this;
3673
3793
  var now;
3674
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3675
- while (1) switch (_context43.prev = _context43.next) {
3794
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3795
+ while (1) switch (_context44.prev = _context44.next) {
3676
3796
  case 0:
3677
3797
  if (!(!this.menu || !this.schedule)) {
3678
- _context43.next = 2;
3798
+ _context44.next = 2;
3679
3799
  break;
3680
3800
  }
3681
- return _context43.abrupt("return", false);
3801
+ return _context44.abrupt("return", false);
3682
3802
  case 2:
3683
3803
  now = Date.now();
3684
3804
  if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
3685
- _context43.next = 5;
3805
+ _context44.next = 5;
3686
3806
  break;
3687
3807
  }
3688
- return _context43.abrupt("return", false);
3808
+ return _context44.abrupt("return", false);
3689
3809
  case 5:
3690
3810
  if (!this.menuScheduleRefreshInFlight) {
3691
3811
  this.lastMenuScheduleRefreshAt = now;
3692
3812
  this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
3693
3813
  return undefined;
3694
3814
  }).catch(function (error) {
3695
- _this8.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3815
+ _this9.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3696
3816
  error: error instanceof Error ? error.message : String(error)
3697
3817
  });
3698
3818
  }).finally(function () {
3699
- _this8.menuScheduleRefreshInFlight = null;
3819
+ _this9.menuScheduleRefreshInFlight = null;
3700
3820
  });
3701
3821
  }
3702
- _context43.next = 8;
3822
+ _context44.next = 8;
3703
3823
  return this.menuScheduleRefreshInFlight;
3704
3824
  case 8:
3705
- return _context43.abrupt("return", true);
3825
+ return _context44.abrupt("return", true);
3706
3826
  case 9:
3707
3827
  case "end":
3708
- return _context43.stop();
3828
+ return _context44.stop();
3709
3829
  }
3710
- }, _callee43, this);
3830
+ }, _callee44, this);
3711
3831
  }));
3712
3832
  function refreshMenuScheduleCacheAfterEmptyResult() {
3713
3833
  return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
@@ -3725,17 +3845,17 @@ var Server = /*#__PURE__*/function () {
3725
3845
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3726
3846
  */
3727
3847
  function () {
3728
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(kind, backendPath, data, config) {
3729
- var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3730
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3731
- while (1) switch (_context44.prev = _context44.next) {
3848
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3849
+ var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3850
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3851
+ while (1) switch (_context45.prev = _context45.next) {
3732
3852
  case 0:
3733
3853
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3734
- _context44.next = 3;
3854
+ _context45.next = 3;
3735
3855
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3736
3856
  case 3:
3737
- result = _context44.sent;
3738
- _ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
3857
+ result = _context45.sent;
3858
+ _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3739
3859
  if (subscriberId && typeof callback === 'function') {
3740
3860
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3741
3861
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -3766,14 +3886,14 @@ var Server = /*#__PURE__*/function () {
3766
3886
  visibleCount: visibleOrderIds.size
3767
3887
  });
3768
3888
  }
3769
- return _context44.abrupt("return", result);
3889
+ return _context45.abrupt("return", result);
3770
3890
  case 7:
3771
3891
  case "end":
3772
- return _context44.stop();
3892
+ return _context45.stop();
3773
3893
  }
3774
- }, _callee44, this);
3894
+ }, _callee45, this);
3775
3895
  }));
3776
- function handleSalesSearchRequest(_x43, _x44, _x45, _x46) {
3896
+ function handleSalesSearchRequest(_x44, _x45, _x46, _x47) {
3777
3897
  return _handleSalesSearchRequest.apply(this, arguments);
3778
3898
  }
3779
3899
  return handleSalesSearchRequest;
@@ -3788,20 +3908,20 @@ var Server = /*#__PURE__*/function () {
3788
3908
  }, {
3789
3909
  key: "fetchSalesSearchFromAPI",
3790
3910
  value: (function () {
3791
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(backendPath, data) {
3911
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
3792
3912
  var _this$app8;
3793
3913
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3794
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3795
- while (1) switch (_context45.prev = _context45.next) {
3914
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3915
+ while (1) switch (_context46.prev = _context46.next) {
3796
3916
  case 0:
3797
3917
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3798
- _context45.next = 3;
3918
+ _context46.next = 3;
3799
3919
  break;
3800
3920
  }
3801
3921
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3802
3922
  backendPath: backendPath
3803
3923
  });
3804
- return _context45.abrupt("return", {
3924
+ return _context46.abrupt("return", {
3805
3925
  code: 500,
3806
3926
  message: 'app.request 不可用',
3807
3927
  data: backendPath === '/shop/es/search' ? {
@@ -3813,29 +3933,29 @@ var Server = /*#__PURE__*/function () {
3813
3933
  status: false
3814
3934
  });
3815
3935
  case 3:
3816
- _context45.prev = 3;
3817
- _context45.next = 6;
3936
+ _context46.prev = 3;
3937
+ _context46.next = 6;
3818
3938
  return this.app.request.post(backendPath, data, {
3819
3939
  isShopApi: true
3820
3940
  });
3821
3941
  case 6:
3822
- response = _context45.sent;
3942
+ response = _context46.sent;
3823
3943
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3824
- return _context45.abrupt("return", {
3944
+ return _context46.abrupt("return", {
3825
3945
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3826
3946
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3827
3947
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3828
3948
  data: _payload
3829
3949
  });
3830
3950
  case 11:
3831
- _context45.prev = 11;
3832
- _context45.t0 = _context45["catch"](3);
3833
- errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
3951
+ _context46.prev = 11;
3952
+ _context46.t0 = _context46["catch"](3);
3953
+ errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
3834
3954
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3835
3955
  backendPath: backendPath,
3836
3956
  error: errorMessage
3837
3957
  });
3838
- return _context45.abrupt("return", {
3958
+ return _context46.abrupt("return", {
3839
3959
  code: 500,
3840
3960
  message: errorMessage,
3841
3961
  data: backendPath === '/shop/es/search' ? {
@@ -3848,11 +3968,11 @@ var Server = /*#__PURE__*/function () {
3848
3968
  });
3849
3969
  case 16:
3850
3970
  case "end":
3851
- return _context45.stop();
3971
+ return _context46.stop();
3852
3972
  }
3853
- }, _callee45, this, [[3, 11]]);
3973
+ }, _callee46, this, [[3, 11]]);
3854
3974
  }));
3855
- function fetchSalesSearchFromAPI(_x47, _x48) {
3975
+ function fetchSalesSearchFromAPI(_x48, _x49) {
3856
3976
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3857
3977
  }
3858
3978
  return fetchSalesSearchFromAPI;
@@ -3882,10 +4002,10 @@ var Server = /*#__PURE__*/function () {
3882
4002
  }, {
3883
4003
  key: "stripSalesSearchPageParams",
3884
4004
  value: function stripSalesSearchPageParams(value) {
3885
- var _this9 = this;
4005
+ var _this10 = this;
3886
4006
  if (Array.isArray(value)) {
3887
4007
  return value.map(function (item) {
3888
- return _this9.stripSalesSearchPageParams(item);
4008
+ return _this10.stripSalesSearchPageParams(item);
3889
4009
  });
3890
4010
  }
3891
4011
  if (!value || _typeof(value) !== 'object') return value;
@@ -3923,12 +4043,12 @@ var Server = /*#__PURE__*/function () {
3923
4043
  key: "extractSalesSearchOrderIds",
3924
4044
  value: function extractSalesSearchOrderIds(kind, result) {
3925
4045
  var _this$findSalesSearch,
3926
- _this10 = this;
4046
+ _this11 = this;
3927
4047
  var data = this.extractSalesSearchResponseData(result);
3928
4048
  var list = kind === 'aggregate' ? (_this$findSalesSearch = this.findSalesSearchAggregateGroup(data)) === null || _this$findSalesSearch === void 0 ? void 0 : _this$findSalesSearch.list : data === null || data === void 0 ? void 0 : data.list;
3929
4049
  if (!Array.isArray(list)) return [];
3930
4050
  return list.map(function (item) {
3931
- return _this10.getSalesSearchOrderId(item);
4051
+ return _this11.getSalesSearchOrderId(item);
3932
4052
  }).filter(function (id) {
3933
4053
  return !!id;
3934
4054
  });
@@ -4095,11 +4215,11 @@ var Server = /*#__PURE__*/function () {
4095
4215
  }, {
4096
4216
  key: "stableSerialize",
4097
4217
  value: function stableSerialize(value) {
4098
- var _this11 = this;
4218
+ var _this12 = this;
4099
4219
  if (value === null || value === undefined) return 'null';
4100
4220
  if (Array.isArray(value)) {
4101
4221
  return "[".concat(value.map(function (item) {
4102
- return _this11.stableSerialize(item);
4222
+ return _this12.stableSerialize(item);
4103
4223
  }).join(','), "]");
4104
4224
  }
4105
4225
  if (_typeof(value) === 'object') {
@@ -4108,7 +4228,7 @@ var Server = /*#__PURE__*/function () {
4108
4228
  return obj[k] !== undefined;
4109
4229
  }).sort();
4110
4230
  return "{".concat(keys.map(function (k) {
4111
- return "".concat(JSON.stringify(k), ":").concat(_this11.stableSerialize(obj[k]));
4231
+ return "".concat(JSON.stringify(k), ":").concat(_this12.stableSerialize(obj[k]));
4112
4232
  }).join(','), "}");
4113
4233
  }
4114
4234
  return JSON.stringify(value);
@@ -4373,18 +4493,18 @@ var Server = /*#__PURE__*/function () {
4373
4493
  }, {
4374
4494
  key: "fetchOrderListFromAPI",
4375
4495
  value: (function () {
4376
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4496
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4377
4497
  var _this$app9;
4378
4498
  var _response$data5, response, _payload2, list, count, errorMessage;
4379
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4380
- while (1) switch (_context46.prev = _context46.next) {
4499
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4500
+ while (1) switch (_context47.prev = _context47.next) {
4381
4501
  case 0:
4382
4502
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4383
- _context46.next = 3;
4503
+ _context47.next = 3;
4384
4504
  break;
4385
4505
  }
4386
4506
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4387
- return _context46.abrupt("return", {
4507
+ return _context47.abrupt("return", {
4388
4508
  code: 500,
4389
4509
  message: 'app.request 不可用',
4390
4510
  data: {
@@ -4394,17 +4514,17 @@ var Server = /*#__PURE__*/function () {
4394
4514
  status: false
4395
4515
  });
4396
4516
  case 3:
4397
- _context46.prev = 3;
4398
- _context46.next = 6;
4517
+ _context47.prev = 3;
4518
+ _context47.next = 6;
4399
4519
  return this.app.request.post('/shop/order/v2/list', data, {
4400
4520
  isShopApi: true
4401
4521
  });
4402
4522
  case 6:
4403
- response = _context46.sent;
4523
+ response = _context47.sent;
4404
4524
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4405
4525
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4406
4526
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4407
- return _context46.abrupt("return", {
4527
+ return _context47.abrupt("return", {
4408
4528
  code: 200,
4409
4529
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4410
4530
  list: list,
@@ -4414,13 +4534,13 @@ var Server = /*#__PURE__*/function () {
4414
4534
  status: true
4415
4535
  });
4416
4536
  case 13:
4417
- _context46.prev = 13;
4418
- _context46.t0 = _context46["catch"](3);
4419
- errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4537
+ _context47.prev = 13;
4538
+ _context47.t0 = _context47["catch"](3);
4539
+ errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4420
4540
  this.logError('fetchOrderListFromAPI: 请求失败', {
4421
4541
  error: errorMessage
4422
4542
  });
4423
- return _context46.abrupt("return", {
4543
+ return _context47.abrupt("return", {
4424
4544
  code: 500,
4425
4545
  message: errorMessage,
4426
4546
  data: {
@@ -4431,11 +4551,11 @@ var Server = /*#__PURE__*/function () {
4431
4551
  });
4432
4552
  case 18:
4433
4553
  case "end":
4434
- return _context46.stop();
4554
+ return _context47.stop();
4435
4555
  }
4436
- }, _callee46, this, [[3, 13]]);
4556
+ }, _callee47, this, [[3, 13]]);
4437
4557
  }));
4438
- function fetchOrderListFromAPI(_x49) {
4558
+ function fetchOrderListFromAPI(_x50) {
4439
4559
  return _fetchOrderListFromAPI.apply(this, arguments);
4440
4560
  }
4441
4561
  return fetchOrderListFromAPI;
@@ -4447,17 +4567,17 @@ var Server = /*#__PURE__*/function () {
4447
4567
  }, {
4448
4568
  key: "fetchBookingListFromAPI",
4449
4569
  value: (function () {
4450
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4570
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
4451
4571
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4452
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4453
- while (1) switch (_context47.prev = _context47.next) {
4572
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4573
+ while (1) switch (_context48.prev = _context48.next) {
4454
4574
  case 0:
4455
4575
  if (this.order) {
4456
- _context47.next = 3;
4576
+ _context48.next = 3;
4457
4577
  break;
4458
4578
  }
4459
4579
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4460
- return _context47.abrupt("return", {
4580
+ return _context48.abrupt("return", {
4461
4581
  code: 500,
4462
4582
  message: 'Order 模块不可用',
4463
4583
  data: {
@@ -4467,18 +4587,18 @@ var Server = /*#__PURE__*/function () {
4467
4587
  status: false
4468
4588
  });
4469
4589
  case 3:
4470
- _context47.prev = 3;
4590
+ _context48.prev = 3;
4471
4591
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4472
4592
  withFields = this.resolveBookingSalesWith(data);
4473
4593
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4474
4594
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4475
4595
  if (!memoryCacheEnabled) {
4476
- _context47.next = 13;
4596
+ _context48.next = 13;
4477
4597
  break;
4478
4598
  }
4479
4599
  cached = this.readBookingRemoteCache(cacheKey);
4480
4600
  if (!cached) {
4481
- _context47.next = 13;
4601
+ _context48.next = 13;
4482
4602
  break;
4483
4603
  }
4484
4604
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4486,14 +4606,14 @@ var Server = /*#__PURE__*/function () {
4486
4606
  listCount: cached.bookingResult.count,
4487
4607
  withFields: cached.withFields
4488
4608
  });
4489
- return _context47.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4609
+ return _context48.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4490
4610
  cache_hit: true
4491
4611
  }));
4492
4612
  case 13:
4493
- _context47.next = 15;
4613
+ _context48.next = 15;
4494
4614
  return this.order.fetchOrdersBySSE(requestPayload);
4495
4615
  case 15:
4496
- rawList = _context47.sent;
4616
+ rawList = _context48.sent;
4497
4617
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4498
4618
  if (typeof globalThis !== 'undefined') {
4499
4619
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4540,15 +4660,15 @@ var Server = /*#__PURE__*/function () {
4540
4660
  cacheKey: cacheKey,
4541
4661
  withFields: withFields
4542
4662
  });
4543
- return _context47.abrupt("return", this.buildBookingResponse(bookingResult));
4663
+ return _context48.abrupt("return", this.buildBookingResponse(bookingResult));
4544
4664
  case 23:
4545
- _context47.prev = 23;
4546
- _context47.t0 = _context47["catch"](3);
4547
- errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4665
+ _context48.prev = 23;
4666
+ _context48.t0 = _context48["catch"](3);
4667
+ errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4548
4668
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4549
4669
  error: errorMessage
4550
4670
  });
4551
- return _context47.abrupt("return", {
4671
+ return _context48.abrupt("return", {
4552
4672
  code: 500,
4553
4673
  message: errorMessage,
4554
4674
  data: {
@@ -4559,11 +4679,11 @@ var Server = /*#__PURE__*/function () {
4559
4679
  });
4560
4680
  case 28:
4561
4681
  case "end":
4562
- return _context47.stop();
4682
+ return _context48.stop();
4563
4683
  }
4564
- }, _callee47, this, [[3, 23]]);
4684
+ }, _callee48, this, [[3, 23]]);
4565
4685
  }));
4566
- function fetchBookingListFromAPI(_x50) {
4686
+ function fetchBookingListFromAPI(_x51) {
4567
4687
  return _fetchBookingListFromAPI.apply(this, arguments);
4568
4688
  }
4569
4689
  return fetchBookingListFromAPI;
@@ -4647,11 +4767,11 @@ var Server = /*#__PURE__*/function () {
4647
4767
  }, {
4648
4768
  key: "runLocalPaymentUpdateInQueue",
4649
4769
  value: function () {
4650
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(key, task, context) {
4651
- var _this12 = this;
4770
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
4771
+ var _this13 = this;
4652
4772
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4653
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4654
- while (1) switch (_context49.prev = _context49.next) {
4773
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4774
+ while (1) switch (_context50.prev = _context50.next) {
4655
4775
  case 0:
4656
4776
  queuedAt = Date.now();
4657
4777
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -4663,20 +4783,20 @@ var Server = /*#__PURE__*/function () {
4663
4783
  }));
4664
4784
  current = previous.catch(function () {
4665
4785
  return undefined;
4666
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4667
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4668
- while (1) switch (_context48.prev = _context48.next) {
4786
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4787
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4788
+ while (1) switch (_context49.prev = _context49.next) {
4669
4789
  case 0:
4670
- _this12.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4790
+ _this13.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4671
4791
  queue_key: key,
4672
4792
  queue_wait_ms: Date.now() - queuedAt
4673
4793
  }));
4674
- return _context48.abrupt("return", task());
4794
+ return _context49.abrupt("return", task());
4675
4795
  case 2:
4676
4796
  case "end":
4677
- return _context48.stop();
4797
+ return _context49.stop();
4678
4798
  }
4679
- }, _callee48);
4799
+ }, _callee49);
4680
4800
  })));
4681
4801
  tail = current.then(function () {
4682
4802
  return undefined;
@@ -4684,11 +4804,11 @@ var Server = /*#__PURE__*/function () {
4684
4804
  return undefined;
4685
4805
  });
4686
4806
  this.localPaymentUpdateQueues.set(key, tail);
4687
- _context49.prev = 7;
4688
- _context49.next = 10;
4807
+ _context50.prev = 7;
4808
+ _context50.next = 10;
4689
4809
  return current;
4690
4810
  case 10:
4691
- result = _context49.sent;
4811
+ result = _context50.sent;
4692
4812
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
4693
4813
  queue_key: key,
4694
4814
  total_duration_ms: Date.now() - queuedAt,
@@ -4696,19 +4816,19 @@ var Server = /*#__PURE__*/function () {
4696
4816
  result_status: result === null || result === void 0 ? void 0 : result.status,
4697
4817
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
4698
4818
  }));
4699
- return _context49.abrupt("return", result);
4819
+ return _context50.abrupt("return", result);
4700
4820
  case 15:
4701
- _context49.prev = 15;
4702
- _context49.t0 = _context49["catch"](7);
4821
+ _context50.prev = 15;
4822
+ _context50.t0 = _context50["catch"](7);
4703
4823
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
4704
4824
  queue_key: key,
4705
4825
  total_duration_ms: Date.now() - queuedAt,
4706
- error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0),
4707
- error_detail: this.normalizeUnknownError(_context49.t0)
4826
+ error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
4827
+ error_detail: this.normalizeUnknownError(_context50.t0)
4708
4828
  }));
4709
- throw _context49.t0;
4829
+ throw _context50.t0;
4710
4830
  case 19:
4711
- _context49.prev = 19;
4831
+ _context50.prev = 19;
4712
4832
  released = false;
4713
4833
  if (this.localPaymentUpdateQueues.get(key) === tail) {
4714
4834
  this.localPaymentUpdateQueues.delete(key);
@@ -4719,14 +4839,14 @@ var Server = /*#__PURE__*/function () {
4719
4839
  released: released,
4720
4840
  active_queue_count: this.localPaymentUpdateQueues.size
4721
4841
  }));
4722
- return _context49.finish(19);
4842
+ return _context50.finish(19);
4723
4843
  case 24:
4724
4844
  case "end":
4725
- return _context49.stop();
4845
+ return _context50.stop();
4726
4846
  }
4727
- }, _callee49, this, [[7, 15, 19, 24]]);
4847
+ }, _callee50, this, [[7, 15, 19, 24]]);
4728
4848
  }));
4729
- function runLocalPaymentUpdateInQueue(_x51, _x52, _x53) {
4849
+ function runLocalPaymentUpdateInQueue(_x52, _x53, _x54) {
4730
4850
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
4731
4851
  }
4732
4852
  return runLocalPaymentUpdateInQueue;
@@ -4734,11 +4854,11 @@ var Server = /*#__PURE__*/function () {
4734
4854
  }, {
4735
4855
  key: "processLocalPaymentUpdate",
4736
4856
  value: function () {
4737
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4857
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4738
4858
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
4739
4859
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
4740
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4741
- while (1) switch (_context50.prev = _context50.next) {
4860
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4861
+ while (1) switch (_context51.prev = _context51.next) {
4742
4862
  case 0:
4743
4863
  requestContext = {
4744
4864
  operation_id: params.operationId,
@@ -4751,11 +4871,11 @@ var Server = /*#__PURE__*/function () {
4751
4871
  };
4752
4872
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
4753
4873
  if (this.order) {
4754
- _context50.next = 5;
4874
+ _context51.next = 5;
4755
4875
  break;
4756
4876
  }
4757
4877
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
4758
- return _context50.abrupt("return", {
4878
+ return _context51.abrupt("return", {
4759
4879
  code: 500,
4760
4880
  status: false,
4761
4881
  message: 'Order 模块未注册',
@@ -4763,20 +4883,20 @@ var Server = /*#__PURE__*/function () {
4763
4883
  });
4764
4884
  case 5:
4765
4885
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
4766
- _context50.next = 8;
4886
+ _context51.next = 8;
4767
4887
  return this.order.getLocalPayment({
4768
4888
  saleId: params.saleId,
4769
4889
  paymentNumber: params.paymentNumber,
4770
4890
  operationId: params.operationId
4771
4891
  });
4772
4892
  case 8:
4773
- found = _context50.sent;
4893
+ found = _context51.sent;
4774
4894
  if (found) {
4775
- _context50.next = 12;
4895
+ _context51.next = 12;
4776
4896
  break;
4777
4897
  }
4778
4898
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
4779
- return _context50.abrupt("return", {
4899
+ return _context51.abrupt("return", {
4780
4900
  code: 404,
4781
4901
  status: false,
4782
4902
  message: '本地支付项不存在',
@@ -4825,13 +4945,13 @@ var Server = /*#__PURE__*/function () {
4825
4945
  });
4826
4946
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
4827
4947
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
4828
- _context50.next = 23;
4948
+ _context51.next = 23;
4829
4949
  break;
4830
4950
  }
4831
4951
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4832
4952
  idempotent_reason: 'ignore_failure_after_success'
4833
4953
  }));
4834
- return _context50.abrupt("return", {
4954
+ return _context51.abrupt("return", {
4835
4955
  code: 200,
4836
4956
  status: true,
4837
4957
  message: '',
@@ -4844,13 +4964,13 @@ var Server = /*#__PURE__*/function () {
4844
4964
  case 23:
4845
4965
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
4846
4966
  if (!alreadyRecordedFailure) {
4847
- _context50.next = 27;
4967
+ _context51.next = 27;
4848
4968
  break;
4849
4969
  }
4850
4970
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4851
4971
  idempotent_reason: 'failure_already_recorded'
4852
4972
  }));
4853
- return _context50.abrupt("return", {
4973
+ return _context51.abrupt("return", {
4854
4974
  code: 200,
4855
4975
  status: true,
4856
4976
  message: '',
@@ -4862,13 +4982,13 @@ var Server = /*#__PURE__*/function () {
4862
4982
  });
4863
4983
  case 27:
4864
4984
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
4865
- _context50.next = 30;
4985
+ _context51.next = 30;
4866
4986
  break;
4867
4987
  }
4868
4988
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4869
4989
  idempotent_reason: 'success_already_committed'
4870
4990
  }));
4871
- return _context50.abrupt("return", {
4991
+ return _context51.abrupt("return", {
4872
4992
  code: 200,
4873
4993
  status: true,
4874
4994
  message: '',
@@ -4880,13 +5000,13 @@ var Server = /*#__PURE__*/function () {
4880
5000
  });
4881
5001
  case 30:
4882
5002
  if (!(params.status === 'success')) {
4883
- _context50.next = 33;
5003
+ _context51.next = 33;
4884
5004
  break;
4885
5005
  }
4886
5006
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4887
5007
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
4888
5008
  }));
4889
- return _context50.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5009
+ return _context51.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4890
5010
  order: found.order,
4891
5011
  payment: found.payment,
4892
5012
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -4897,8 +5017,8 @@ var Server = /*#__PURE__*/function () {
4897
5017
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4898
5018
  incoming_payment_update: incomingPaymentUpdate
4899
5019
  }));
4900
- _context50.prev = 34;
4901
- _context50.next = 37;
5020
+ _context51.prev = 34;
5021
+ _context51.next = 37;
4902
5022
  return this.order.updateLocalPayment({
4903
5023
  saleId: params.saleId,
4904
5024
  paymentNumber: params.paymentNumber,
@@ -4906,25 +5026,25 @@ var Server = /*#__PURE__*/function () {
4906
5026
  updates: incomingPaymentUpdate
4907
5027
  });
4908
5028
  case 37:
4909
- updated = _context50.sent;
4910
- _context50.next = 44;
5029
+ updated = _context51.sent;
5030
+ _context51.next = 44;
4911
5031
  break;
4912
5032
  case 40:
4913
- _context50.prev = 40;
4914
- _context50.t0 = _context50["catch"](34);
5033
+ _context51.prev = 40;
5034
+ _context51.t0 = _context51["catch"](34);
4915
5035
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
4916
5036
  incoming_payment_update: incomingPaymentUpdate,
4917
- error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
4918
- error_detail: this.normalizeUnknownError(_context50.t0)
5037
+ error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
5038
+ error_detail: this.normalizeUnknownError(_context51.t0)
4919
5039
  }));
4920
- throw _context50.t0;
5040
+ throw _context51.t0;
4921
5041
  case 44:
4922
5042
  if (updated) {
4923
- _context50.next = 47;
5043
+ _context51.next = 47;
4924
5044
  break;
4925
5045
  }
4926
5046
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
4927
- return _context50.abrupt("return", {
5047
+ return _context51.abrupt("return", {
4928
5048
  code: 404,
4929
5049
  status: false,
4930
5050
  message: '本地支付项不存在',
@@ -4935,7 +5055,7 @@ var Server = /*#__PURE__*/function () {
4935
5055
  previous_payment: updated.previousPayment,
4936
5056
  payment: updated.payment
4937
5057
  }));
4938
- return _context50.abrupt("return", {
5058
+ return _context51.abrupt("return", {
4939
5059
  code: 200,
4940
5060
  status: true,
4941
5061
  message: '',
@@ -4947,11 +5067,11 @@ var Server = /*#__PURE__*/function () {
4947
5067
  });
4948
5068
  case 49:
4949
5069
  case "end":
4950
- return _context50.stop();
5070
+ return _context51.stop();
4951
5071
  }
4952
- }, _callee50, this, [[34, 40]]);
5072
+ }, _callee51, this, [[34, 40]]);
4953
5073
  }));
4954
- function processLocalPaymentUpdate(_x54) {
5074
+ function processLocalPaymentUpdate(_x55) {
4955
5075
  return _processLocalPaymentUpdate.apply(this, arguments);
4956
5076
  }
4957
5077
  return processLocalPaymentUpdate;
@@ -4959,10 +5079,10 @@ var Server = /*#__PURE__*/function () {
4959
5079
  }, {
4960
5080
  key: "processSuccessfulLocalPayment",
4961
5081
  value: function () {
4962
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5082
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4963
5083
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
4964
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4965
- while (1) switch (_context51.prev = _context51.next) {
5084
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5085
+ while (1) switch (_context52.prev = _context52.next) {
4966
5086
  case 0:
4967
5087
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
4968
5088
  baseSales = new BaseSalesImpl(moduleName);
@@ -4981,13 +5101,13 @@ var Server = /*#__PURE__*/function () {
4981
5101
  payment: params.payment
4982
5102
  });
4983
5103
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
4984
- _context51.prev = 5;
5104
+ _context52.prev = 5;
4985
5105
  order = this.sanitizeLocalRecoveryOrder(params.order);
4986
5106
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4987
5107
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
4988
5108
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
4989
5109
  }));
4990
- _context51.next = 10;
5110
+ _context52.next = 10;
4991
5111
  return baseSales.initialize(this.core, {
4992
5112
  otherParams: {
4993
5113
  platform: order.platform,
@@ -5000,14 +5120,14 @@ var Server = /*#__PURE__*/function () {
5000
5120
  });
5001
5121
  case 10:
5002
5122
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
5003
- _context51.next = 13;
5123
+ _context52.next = 13;
5004
5124
  return baseSales.replaceTempOrder(order);
5005
5125
  case 13:
5006
5126
  this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
5007
5127
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5008
5128
  incoming_payment_update: params.paymentUpdate
5009
5129
  }));
5010
- _context51.next = 17;
5130
+ _context52.next = 17;
5011
5131
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
5012
5132
  submitWhenPaid: true,
5013
5133
  matchBy: params.matchBy,
@@ -5016,7 +5136,7 @@ var Server = /*#__PURE__*/function () {
5016
5136
  smallTicketDataFlag: 1
5017
5137
  });
5018
5138
  case 17:
5019
- result = _context51.sent;
5139
+ result = _context52.sent;
5020
5140
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5021
5141
  duration_ms: Date.now() - startedAt,
5022
5142
  payment: result.payment,
@@ -5038,7 +5158,7 @@ var Server = /*#__PURE__*/function () {
5038
5158
  } : null,
5039
5159
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
5040
5160
  }));
5041
- return _context51.abrupt("return", {
5161
+ return _context52.abrupt("return", {
5042
5162
  code: 200,
5043
5163
  status: true,
5044
5164
  message: '',
@@ -5050,48 +5170,48 @@ var Server = /*#__PURE__*/function () {
5050
5170
  }
5051
5171
  });
5052
5172
  case 22:
5053
- _context51.prev = 22;
5054
- _context51.t0 = _context51["catch"](5);
5055
- message = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
5173
+ _context52.prev = 22;
5174
+ _context52.t0 = _context52["catch"](5);
5175
+ message = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
5056
5176
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5057
5177
  duration_ms: Date.now() - startedAt,
5058
5178
  error: message,
5059
- error_detail: this.normalizeUnknownError(_context51.t0)
5179
+ error_detail: this.normalizeUnknownError(_context52.t0)
5060
5180
  }));
5061
- return _context51.abrupt("return", {
5181
+ return _context52.abrupt("return", {
5062
5182
  code: 500,
5063
5183
  status: false,
5064
5184
  message: message,
5065
5185
  data: null
5066
5186
  });
5067
5187
  case 27:
5068
- _context51.prev = 27;
5069
- _context51.prev = 28;
5070
- _context51.next = 31;
5188
+ _context52.prev = 27;
5189
+ _context52.prev = 28;
5190
+ _context52.next = 31;
5071
5191
  return baseSales.destroy();
5072
5192
  case 31:
5073
5193
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5074
5194
  duration_ms: Date.now() - startedAt
5075
5195
  }));
5076
- _context51.next = 37;
5196
+ _context52.next = 37;
5077
5197
  break;
5078
5198
  case 34:
5079
- _context51.prev = 34;
5080
- _context51.t1 = _context51["catch"](28);
5199
+ _context52.prev = 34;
5200
+ _context52.t1 = _context52["catch"](28);
5081
5201
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5082
5202
  duration_ms: Date.now() - startedAt,
5083
- error: _context51.t1 instanceof Error ? _context51.t1.message : String(_context51.t1),
5084
- error_detail: this.normalizeUnknownError(_context51.t1)
5203
+ error: _context52.t1 instanceof Error ? _context52.t1.message : String(_context52.t1),
5204
+ error_detail: this.normalizeUnknownError(_context52.t1)
5085
5205
  }));
5086
5206
  case 37:
5087
- return _context51.finish(27);
5207
+ return _context52.finish(27);
5088
5208
  case 38:
5089
5209
  case "end":
5090
- return _context51.stop();
5210
+ return _context52.stop();
5091
5211
  }
5092
- }, _callee51, this, [[5, 22, 27, 38], [28, 34]]);
5212
+ }, _callee52, this, [[5, 22, 27, 38], [28, 34]]);
5093
5213
  }));
5094
- function processSuccessfulLocalPayment(_x55) {
5214
+ function processSuccessfulLocalPayment(_x56) {
5095
5215
  return _processSuccessfulLocalPayment.apply(this, arguments);
5096
5216
  }
5097
5217
  return processSuccessfulLocalPayment;
@@ -5182,32 +5302,32 @@ var Server = /*#__PURE__*/function () {
5182
5302
  }, {
5183
5303
  key: "getShortNumberOrDeviceId",
5184
5304
  value: function () {
5185
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5305
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5186
5306
  var getAsyncIotDeviceInfo, res;
5187
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5188
- while (1) switch (_context52.prev = _context52.next) {
5307
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5308
+ while (1) switch (_context53.prev = _context53.next) {
5189
5309
  case 0:
5190
5310
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
5191
5311
  if (!getAsyncIotDeviceInfo) {
5192
- _context52.next = 7;
5312
+ _context53.next = 7;
5193
5313
  break;
5194
5314
  }
5195
- _context52.next = 4;
5315
+ _context53.next = 4;
5196
5316
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
5197
5317
  case 4:
5198
- res = _context52.sent;
5318
+ res = _context53.sent;
5199
5319
  if (!(res !== null && res !== void 0 && res.short_number)) {
5200
- _context52.next = 7;
5320
+ _context53.next = 7;
5201
5321
  break;
5202
5322
  }
5203
- return _context52.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5323
+ return _context53.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5204
5324
  case 7:
5205
- return _context52.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5325
+ return _context53.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5206
5326
  case 8:
5207
5327
  case "end":
5208
- return _context52.stop();
5328
+ return _context53.stop();
5209
5329
  }
5210
- }, _callee52, this);
5330
+ }, _callee53, this);
5211
5331
  }));
5212
5332
  function getShortNumberOrDeviceId() {
5213
5333
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -5234,16 +5354,16 @@ var Server = /*#__PURE__*/function () {
5234
5354
  }, {
5235
5355
  key: "normalizeCheckoutSubmitData",
5236
5356
  value: function () {
5237
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data, title) {
5357
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5238
5358
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5239
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5240
- while (1) switch (_context53.prev = _context53.next) {
5359
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5360
+ while (1) switch (_context54.prev = _context54.next) {
5241
5361
  case 0:
5242
5362
  if (!(!data || _typeof(data) !== 'object')) {
5243
- _context53.next = 2;
5363
+ _context54.next = 2;
5244
5364
  break;
5245
5365
  }
5246
- return _context53.abrupt("return", data);
5366
+ return _context54.abrupt("return", data);
5247
5367
  case 2:
5248
5368
  next = _objectSpread({}, data);
5249
5369
  externalSaleNumber = next.external_sale_number;
@@ -5253,7 +5373,7 @@ var Server = /*#__PURE__*/function () {
5253
5373
  delete next.vouchers;
5254
5374
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5255
5375
  if (!hasCheckoutOrderNumbers) {
5256
- _context53.next = 11;
5376
+ _context54.next = 11;
5257
5377
  break;
5258
5378
  }
5259
5379
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -5263,10 +5383,10 @@ var Server = /*#__PURE__*/function () {
5263
5383
  shop_order_number: next.shop_order_number,
5264
5384
  shop_full_order_number: next.shop_full_order_number
5265
5385
  });
5266
- return _context53.abrupt("return", next);
5386
+ return _context54.abrupt("return", next);
5267
5387
  case 11:
5268
5388
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
5269
- _context53.next = 14;
5389
+ _context54.next = 14;
5270
5390
  break;
5271
5391
  }
5272
5392
  if (shouldClearLocalOrderId) {
@@ -5275,10 +5395,10 @@ var Server = /*#__PURE__*/function () {
5275
5395
  order_id: next.order_id
5276
5396
  });
5277
5397
  }
5278
- return _context53.abrupt("return", next);
5398
+ return _context54.abrupt("return", next);
5279
5399
  case 14:
5280
5400
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
5281
- _context53.next = 17;
5401
+ _context54.next = 17;
5282
5402
  break;
5283
5403
  }
5284
5404
  if (shouldClearLocalOrderId) {
@@ -5287,12 +5407,12 @@ var Server = /*#__PURE__*/function () {
5287
5407
  external_sale_number: externalSaleNumber
5288
5408
  });
5289
5409
  }
5290
- return _context53.abrupt("return", next);
5410
+ return _context54.abrupt("return", next);
5291
5411
  case 17:
5292
- _context53.prev = 17;
5412
+ _context54.prev = 17;
5293
5413
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
5294
5414
  if (localOrder) {
5295
- _context53.next = 22;
5415
+ _context54.next = 22;
5296
5416
  break;
5297
5417
  }
5298
5418
  if (shouldClearLocalOrderId) {
@@ -5302,7 +5422,7 @@ var Server = /*#__PURE__*/function () {
5302
5422
  localOrderFound: false
5303
5423
  });
5304
5424
  }
5305
- return _context53.abrupt("return", next);
5425
+ return _context54.abrupt("return", next);
5306
5426
  case 22:
5307
5427
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
5308
5428
  next.shop_order_number = localOrder.shop_order_number;
@@ -5319,23 +5439,23 @@ var Server = /*#__PURE__*/function () {
5319
5439
  shop_full_order_number: next.shop_full_order_number
5320
5440
  });
5321
5441
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5322
- return _context53.abrupt("return", next);
5442
+ return _context54.abrupt("return", next);
5323
5443
  case 28:
5324
- _context53.prev = 28;
5325
- _context53.t0 = _context53["catch"](17);
5444
+ _context54.prev = 28;
5445
+ _context54.t0 = _context54["catch"](17);
5326
5446
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
5327
5447
  external_sale_number: externalSaleNumber,
5328
- error: this.getUnknownErrorMessage(_context53.t0),
5329
- error_detail: this.normalizeUnknownError(_context53.t0)
5448
+ error: this.getUnknownErrorMessage(_context54.t0),
5449
+ error_detail: this.normalizeUnknownError(_context54.t0)
5330
5450
  });
5331
- return _context53.abrupt("return", next);
5451
+ return _context54.abrupt("return", next);
5332
5452
  case 32:
5333
5453
  case "end":
5334
- return _context53.stop();
5454
+ return _context54.stop();
5335
5455
  }
5336
- }, _callee53, this, [[17, 28]]);
5456
+ }, _callee54, this, [[17, 28]]);
5337
5457
  }));
5338
- function normalizeCheckoutSubmitData(_x56, _x57) {
5458
+ function normalizeCheckoutSubmitData(_x57, _x58) {
5339
5459
  return _normalizeCheckoutSubmitData.apply(this, arguments);
5340
5460
  }
5341
5461
  return normalizeCheckoutSubmitData;
@@ -5343,81 +5463,81 @@ var Server = /*#__PURE__*/function () {
5343
5463
  }, {
5344
5464
  key: "ensureCheckoutOrderNumbers",
5345
5465
  value: function () {
5346
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5466
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
5347
5467
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
5348
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5349
- while (1) switch (_context54.prev = _context54.next) {
5468
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5469
+ while (1) switch (_context55.prev = _context55.next) {
5350
5470
  case 0:
5351
5471
  if (!(!data || _typeof(data) !== 'object')) {
5352
- _context54.next = 2;
5472
+ _context55.next = 2;
5353
5473
  break;
5354
5474
  }
5355
- return _context54.abrupt("return", data);
5475
+ return _context55.abrupt("return", data);
5356
5476
  case 2:
5357
5477
  next = _objectSpread({}, data);
5358
5478
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
5359
5479
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
5360
5480
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
5361
- _context54.next = 7;
5481
+ _context55.next = 7;
5362
5482
  break;
5363
5483
  }
5364
- return _context54.abrupt("return", next);
5484
+ return _context55.abrupt("return", next);
5365
5485
  case 7:
5366
5486
  idGenerator = this.getIdGeneratorPlugin();
5367
5487
  if (idGenerator) {
5368
- _context54.next = 11;
5488
+ _context55.next = 11;
5369
5489
  break;
5370
5490
  }
5371
5491
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
5372
5492
  needsShopOrderNumber: needsShopOrderNumber,
5373
5493
  needsShopFullOrderNumber: needsShopFullOrderNumber
5374
5494
  });
5375
- return _context54.abrupt("return", next);
5495
+ return _context55.abrupt("return", next);
5376
5496
  case 11:
5377
- _context54.prev = 11;
5497
+ _context55.prev = 11;
5378
5498
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
5379
- _context54.next = 16;
5499
+ _context55.next = 16;
5380
5500
  break;
5381
5501
  }
5382
- _context54.next = 15;
5502
+ _context55.next = 15;
5383
5503
  return idGenerator.generateShopOrderNumber({
5384
5504
  biz: next.business_code || 'ticket'
5385
5505
  });
5386
5506
  case 15:
5387
- next.shop_order_number = _context54.sent;
5507
+ next.shop_order_number = _context55.sent;
5388
5508
  case 16:
5389
5509
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
5390
- _context54.next = 20;
5510
+ _context55.next = 20;
5391
5511
  break;
5392
5512
  }
5393
- _context54.next = 19;
5513
+ _context55.next = 19;
5394
5514
  return idGenerator.generateReceiptId({
5395
5515
  biz: next.business_code || 'ticket'
5396
5516
  });
5397
5517
  case 19:
5398
- next.shop_full_order_number = _context54.sent;
5518
+ next.shop_full_order_number = _context55.sent;
5399
5519
  case 20:
5400
5520
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
5401
5521
  shop_order_number: next.shop_order_number,
5402
5522
  shop_full_order_number: next.shop_full_order_number
5403
5523
  });
5404
- _context54.next = 26;
5524
+ _context55.next = 26;
5405
5525
  break;
5406
5526
  case 23:
5407
- _context54.prev = 23;
5408
- _context54.t0 = _context54["catch"](11);
5527
+ _context55.prev = 23;
5528
+ _context55.t0 = _context55["catch"](11);
5409
5529
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
5410
- error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0)
5530
+ error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5411
5531
  });
5412
5532
  case 26:
5413
- return _context54.abrupt("return", next);
5533
+ return _context55.abrupt("return", next);
5414
5534
  case 27:
5415
5535
  case "end":
5416
- return _context54.stop();
5536
+ return _context55.stop();
5417
5537
  }
5418
- }, _callee54, this, [[11, 23]]);
5538
+ }, _callee55, this, [[11, 23]]);
5419
5539
  }));
5420
- function ensureCheckoutOrderNumbers(_x58, _x59) {
5540
+ function ensureCheckoutOrderNumbers(_x59, _x60) {
5421
5541
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
5422
5542
  }
5423
5543
  return ensureCheckoutOrderNumbers;
@@ -5425,27 +5545,27 @@ var Server = /*#__PURE__*/function () {
5425
5545
  }, {
5426
5546
  key: "dispatchCheckoutSyncTask",
5427
5547
  value: function () {
5428
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5548
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5429
5549
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
5430
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5431
- while (1) switch (_context55.prev = _context55.next) {
5550
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5551
+ while (1) switch (_context56.prev = _context56.next) {
5432
5552
  case 0:
5433
5553
  this.registerDeviceTaskActions();
5434
5554
  deviceTask = this.getDeviceTaskPlugin();
5435
- _context55.next = 4;
5555
+ _context56.next = 4;
5436
5556
  return this.getShortNumberOrDeviceId();
5437
5557
  case 4:
5438
- debugDeviceId = _context55.sent;
5558
+ debugDeviceId = _context56.sent;
5439
5559
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
5440
5560
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5441
- _context55.next = 9;
5561
+ _context56.next = 9;
5442
5562
  break;
5443
5563
  }
5444
5564
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
5445
- return _context55.abrupt("return");
5565
+ return _context56.abrupt("return");
5446
5566
  case 9:
5447
- _context55.prev = 9;
5448
- _context55.next = 12;
5567
+ _context56.prev = 9;
5568
+ _context56.next = 12;
5449
5569
  return deviceTask.dispatch({
5450
5570
  action: 'sync_sales',
5451
5571
  device_id: debugDeviceId,
@@ -5463,27 +5583,27 @@ var Server = /*#__PURE__*/function () {
5463
5583
  source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
5464
5584
  });
5465
5585
  case 12:
5466
- result = _context55.sent;
5586
+ result = _context56.sent;
5467
5587
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
5468
5588
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
5469
5589
  status: result === null || result === void 0 ? void 0 : result.status,
5470
5590
  reused: result === null || result === void 0 ? void 0 : result.reused
5471
5591
  });
5472
- _context55.next = 19;
5592
+ _context56.next = 19;
5473
5593
  break;
5474
5594
  case 16:
5475
- _context55.prev = 16;
5476
- _context55.t0 = _context55["catch"](9);
5595
+ _context56.prev = 16;
5596
+ _context56.t0 = _context56["catch"](9);
5477
5597
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
5478
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5598
+ error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5479
5599
  });
5480
5600
  case 19:
5481
5601
  case "end":
5482
- return _context55.stop();
5602
+ return _context56.stop();
5483
5603
  }
5484
- }, _callee55, this, [[9, 16]]);
5604
+ }, _callee56, this, [[9, 16]]);
5485
5605
  }));
5486
- function dispatchCheckoutSyncTask(_x60) {
5606
+ function dispatchCheckoutSyncTask(_x61) {
5487
5607
  return _dispatchCheckoutSyncTask.apply(this, arguments);
5488
5608
  }
5489
5609
  return dispatchCheckoutSyncTask;
@@ -5491,26 +5611,26 @@ var Server = /*#__PURE__*/function () {
5491
5611
  }, {
5492
5612
  key: "dispatchPrintOtherReceiptTask",
5493
5613
  value: function () {
5494
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5614
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5495
5615
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
5496
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5497
- while (1) switch (_context56.prev = _context56.next) {
5616
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5617
+ while (1) switch (_context57.prev = _context57.next) {
5498
5618
  case 0:
5499
5619
  deviceTask = this.getDeviceTaskPlugin();
5500
5620
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5501
- _context56.next = 4;
5621
+ _context57.next = 4;
5502
5622
  break;
5503
5623
  }
5504
5624
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
5505
- return _context56.abrupt("return");
5625
+ return _context57.abrupt("return");
5506
5626
  case 4:
5507
- _context56.prev = 4;
5627
+ _context57.prev = 4;
5508
5628
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
5509
- _context56.next = 8;
5629
+ _context57.next = 8;
5510
5630
  return this.getShortNumberOrDeviceId();
5511
5631
  case 8:
5512
- deviceId = _context56.sent;
5513
- _context56.next = 11;
5632
+ deviceId = _context57.sent;
5633
+ _context57.next = 11;
5514
5634
  return deviceTask.dispatch({
5515
5635
  action: 'print_all',
5516
5636
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -5537,21 +5657,21 @@ var Server = /*#__PURE__*/function () {
5537
5657
  source_id: printIdentity
5538
5658
  });
5539
5659
  case 11:
5540
- _context56.next = 16;
5660
+ _context57.next = 16;
5541
5661
  break;
5542
5662
  case 13:
5543
- _context56.prev = 13;
5544
- _context56.t0 = _context56["catch"](4);
5663
+ _context57.prev = 13;
5664
+ _context57.t0 = _context57["catch"](4);
5545
5665
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
5546
- error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5666
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5547
5667
  });
5548
5668
  case 16:
5549
5669
  case "end":
5550
- return _context56.stop();
5670
+ return _context57.stop();
5551
5671
  }
5552
- }, _callee56, this, [[4, 13]]);
5672
+ }, _callee57, this, [[4, 13]]);
5553
5673
  }));
5554
- function dispatchPrintOtherReceiptTask(_x61) {
5674
+ function dispatchPrintOtherReceiptTask(_x62) {
5555
5675
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
5556
5676
  }
5557
5677
  return dispatchPrintOtherReceiptTask;
@@ -5571,32 +5691,32 @@ var Server = /*#__PURE__*/function () {
5571
5691
  }, {
5572
5692
  key: "dispatchLocalReceiptPrint",
5573
5693
  value: function () {
5574
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5694
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5575
5695
  var _payment_info;
5576
5696
  var printableOrder;
5577
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5578
- while (1) switch (_context57.prev = _context57.next) {
5697
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5698
+ while (1) switch (_context58.prev = _context58.next) {
5579
5699
  case 0:
5580
5700
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
5581
- _context57.next = 2;
5701
+ _context58.next = 2;
5582
5702
  break;
5583
5703
  }
5584
- return _context57.abrupt("return", {
5704
+ return _context58.abrupt("return", {
5585
5705
  printed: false,
5586
5706
  order: params.order
5587
5707
  });
5588
5708
  case 2:
5589
- _context57.next = 4;
5709
+ _context58.next = 4;
5590
5710
  return this.withLocalSmallTicketData(params.order, {
5591
5711
  requireFullyPaid: params.requireFullyPaid
5592
5712
  });
5593
5713
  case 4:
5594
- printableOrder = _context57.sent;
5714
+ printableOrder = _context58.sent;
5595
5715
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
5596
- _context57.next = 7;
5716
+ _context58.next = 7;
5597
5717
  break;
5598
5718
  }
5599
- return _context57.abrupt("return", {
5719
+ return _context58.abrupt("return", {
5600
5720
  printed: false,
5601
5721
  order: printableOrder
5602
5722
  });
@@ -5606,7 +5726,7 @@ var Server = /*#__PURE__*/function () {
5606
5726
  printableOrder: printableOrder,
5607
5727
  response: params.response
5608
5728
  });
5609
- _context57.next = 10;
5729
+ _context58.next = 10;
5610
5730
  return this.dispatchPrintOtherReceiptTask({
5611
5731
  checkoutData: params.checkoutData,
5612
5732
  syncedOrder: printableOrder,
@@ -5615,17 +5735,17 @@ var Server = /*#__PURE__*/function () {
5615
5735
  isManualPrint: params.isManualPrint
5616
5736
  });
5617
5737
  case 10:
5618
- return _context57.abrupt("return", {
5738
+ return _context58.abrupt("return", {
5619
5739
  printed: true,
5620
5740
  order: printableOrder
5621
5741
  });
5622
5742
  case 11:
5623
5743
  case "end":
5624
- return _context57.stop();
5744
+ return _context58.stop();
5625
5745
  }
5626
- }, _callee57, this);
5746
+ }, _callee58, this);
5627
5747
  }));
5628
- function dispatchLocalReceiptPrint(_x62) {
5748
+ function dispatchLocalReceiptPrint(_x63) {
5629
5749
  return _dispatchLocalReceiptPrint.apply(this, arguments);
5630
5750
  }
5631
5751
  return dispatchLocalReceiptPrint;
@@ -5660,47 +5780,47 @@ var Server = /*#__PURE__*/function () {
5660
5780
  }, {
5661
5781
  key: "syncMachinecodeRedeemStatusToLocalOrder",
5662
5782
  value: function () {
5663
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(data, ids, status) {
5783
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data, ids, status) {
5664
5784
  var _this$order3;
5665
5785
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
5666
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5667
- while (1) switch (_context58.prev = _context58.next) {
5786
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5787
+ while (1) switch (_context59.prev = _context59.next) {
5668
5788
  case 0:
5669
5789
  title = 'handleMachinecodeBatchMetadata';
5670
5790
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
5671
5791
  if (!(lookup === undefined)) {
5672
- _context58.next = 5;
5792
+ _context59.next = 5;
5673
5793
  break;
5674
5794
  }
5675
5795
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5676
5796
  batchSize: ids.length,
5677
5797
  status: status
5678
5798
  });
5679
- return _context58.abrupt("return");
5799
+ return _context59.abrupt("return");
5680
5800
  case 5:
5681
5801
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
5682
- _context58.next = 8;
5802
+ _context59.next = 8;
5683
5803
  break;
5684
5804
  }
5685
5805
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5686
5806
  lookup: lookup,
5687
5807
  status: status
5688
5808
  });
5689
- return _context58.abrupt("return");
5809
+ return _context59.abrupt("return");
5690
5810
  case 8:
5691
- _context58.next = 10;
5811
+ _context59.next = 10;
5692
5812
  return this.order.getLocalOrderByLookup(lookup);
5693
5813
  case 10:
5694
- localOrder = _context58.sent;
5814
+ localOrder = _context59.sent;
5695
5815
  if (localOrder) {
5696
- _context58.next = 14;
5816
+ _context59.next = 14;
5697
5817
  break;
5698
5818
  }
5699
5819
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5700
5820
  lookup: lookup,
5701
5821
  status: status
5702
5822
  });
5703
- return _context58.abrupt("return");
5823
+ return _context59.abrupt("return");
5704
5824
  case 14:
5705
5825
  voucherIdSet = new Set(ids.filter(function (id) {
5706
5826
  return id !== undefined && id !== null && id !== '';
@@ -5708,14 +5828,14 @@ var Server = /*#__PURE__*/function () {
5708
5828
  return String(id);
5709
5829
  }));
5710
5830
  if (!(voucherIdSet.size === 0)) {
5711
- _context58.next = 18;
5831
+ _context59.next = 18;
5712
5832
  break;
5713
5833
  }
5714
5834
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5715
5835
  lookup: lookup,
5716
5836
  status: status
5717
5837
  });
5718
- return _context58.abrupt("return");
5838
+ return _context59.abrupt("return");
5719
5839
  case 18:
5720
5840
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
5721
5841
  hasUpdatedVoucher = false;
@@ -5729,7 +5849,7 @@ var Server = /*#__PURE__*/function () {
5729
5849
  });
5730
5850
  });
5731
5851
  if (hasUpdatedVoucher) {
5732
- _context58.next = 24;
5852
+ _context59.next = 24;
5733
5853
  break;
5734
5854
  }
5735
5855
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -5737,13 +5857,13 @@ var Server = /*#__PURE__*/function () {
5737
5857
  voucher_ids: Array.from(voucherIdSet),
5738
5858
  status: status
5739
5859
  });
5740
- return _context58.abrupt("return");
5860
+ return _context59.abrupt("return");
5741
5861
  case 24:
5742
5862
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
5743
- _context58.next = 29;
5863
+ _context59.next = 29;
5744
5864
  break;
5745
5865
  }
5746
- _context58.next = 27;
5866
+ _context59.next = 27;
5747
5867
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
5748
5868
  vouchers: nextVouchers
5749
5869
  }));
@@ -5753,13 +5873,13 @@ var Server = /*#__PURE__*/function () {
5753
5873
  updatedCount: voucherIdSet.size,
5754
5874
  status: status
5755
5875
  });
5756
- return _context58.abrupt("return");
5876
+ return _context59.abrupt("return");
5757
5877
  case 29:
5758
5878
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
5759
- _context58.next = 34;
5879
+ _context59.next = 34;
5760
5880
  break;
5761
5881
  }
5762
- _context58.next = 32;
5882
+ _context59.next = 32;
5763
5883
  return this.order.markOrderSyncedByExternalSaleNumber({
5764
5884
  externalSaleNumber: data.external_sale_number,
5765
5885
  patch: {
@@ -5772,7 +5892,7 @@ var Server = /*#__PURE__*/function () {
5772
5892
  updatedCount: voucherIdSet.size,
5773
5893
  status: status
5774
5894
  });
5775
- return _context58.abrupt("return");
5895
+ return _context59.abrupt("return");
5776
5896
  case 34:
5777
5897
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5778
5898
  lookup: lookup,
@@ -5780,11 +5900,11 @@ var Server = /*#__PURE__*/function () {
5780
5900
  });
5781
5901
  case 35:
5782
5902
  case "end":
5783
- return _context58.stop();
5903
+ return _context59.stop();
5784
5904
  }
5785
- }, _callee58, this);
5905
+ }, _callee59, this);
5786
5906
  }));
5787
- function syncMachinecodeRedeemStatusToLocalOrder(_x63, _x64, _x65) {
5907
+ function syncMachinecodeRedeemStatusToLocalOrder(_x64, _x65, _x66) {
5788
5908
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
5789
5909
  }
5790
5910
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -5792,10 +5912,10 @@ var Server = /*#__PURE__*/function () {
5792
5912
  }, {
5793
5913
  key: "handleOrderCheckoutSubmit",
5794
5914
  value: function () {
5795
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5796
- var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
5797
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5798
- while (1) switch (_context59.prev = _context59.next) {
5915
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5916
+ var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
5917
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5918
+ while (1) switch (_context60.prev = _context60.next) {
5799
5919
  case 0:
5800
5920
  backendPath = params.backendPath, data = params.data, title = params.title;
5801
5921
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5805,24 +5925,24 @@ var Server = /*#__PURE__*/function () {
5805
5925
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5806
5926
  });
5807
5927
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5808
- _context59.next = 4;
5928
+ _context60.next = 4;
5809
5929
  break;
5810
5930
  }
5811
- return _context59.abrupt("return", this.handleSyncCheckoutSubmit({
5931
+ return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
5812
5932
  backendPath: backendPath,
5813
5933
  data: data,
5814
5934
  title: title
5815
5935
  }));
5816
5936
  case 4:
5817
- _context59.next = 6;
5937
+ _context60.next = 6;
5818
5938
  return this.normalizeCheckoutSubmitData(data, title);
5819
5939
  case 6:
5820
- normalizedData = _context59.sent;
5821
- _context59.next = 9;
5940
+ normalizedData = _context60.sent;
5941
+ _context60.next = 9;
5822
5942
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
5823
5943
  case 9:
5824
- checkoutData = _context59.sent;
5825
- _context59.next = 12;
5944
+ checkoutData = _context60.sent;
5945
+ _context60.next = 12;
5826
5946
  return this.handlePendingSyncCheckoutOrder({
5827
5947
  backendPath: backendPath,
5828
5948
  data: checkoutData,
@@ -5830,53 +5950,51 @@ var Server = /*#__PURE__*/function () {
5830
5950
  reason: 'checkout 已转入设备任务同步'
5831
5951
  });
5832
5952
  case 12:
5833
- pendingResult = _context59.sent;
5953
+ pendingResult = _context60.sent;
5834
5954
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5835
- _context59.next = 22;
5955
+ _context60.next = 20;
5836
5956
  break;
5837
5957
  }
5838
5958
  pendingOrder = pendingResult.data;
5839
- platform = (_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 ? void 0 : _this$core$context2.getPlatform();
5840
- isAndroid = platform === 'android';
5841
- if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
5842
- // TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
5843
- isAndroid ? checkoutData.type === 'virtual' : true))) {
5844
- _context59.next = 20;
5959
+ if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
5960
+ _context60.next = 18;
5845
5961
  break;
5846
5962
  }
5847
- _context59.next = 20;
5963
+ _context60.next = 18;
5848
5964
  return this.dispatchLocalReceiptPrint({
5849
5965
  checkoutData: checkoutData,
5850
5966
  order: pendingOrder,
5851
5967
  response: pendingResult,
5852
- requireFullyPaid: true
5968
+ requireFullyPaid: true,
5969
+ // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
5970
+ isManualPrint: true
5853
5971
  });
5854
- case 20:
5855
- _context59.next = 22;
5972
+ case 18:
5973
+ _context60.next = 20;
5856
5974
  return this.dispatchCheckoutSyncTask({
5857
5975
  backendPath: backendPath,
5858
5976
  data: checkoutData,
5859
5977
  title: title
5860
5978
  });
5861
- case 22:
5979
+ case 20:
5862
5980
  if (pendingResult.data.order_id) {
5863
- _context59.next = 24;
5981
+ _context60.next = 22;
5864
5982
  break;
5865
5983
  }
5866
- return _context59.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5984
+ return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5867
5985
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
5868
5986
  order_id: pendingResult.data.external_sale_number
5869
5987
  })
5870
5988
  }));
5871
- case 24:
5872
- return _context59.abrupt("return", pendingResult);
5873
- case 25:
5989
+ case 22:
5990
+ return _context60.abrupt("return", pendingResult);
5991
+ case 23:
5874
5992
  case "end":
5875
- return _context59.stop();
5993
+ return _context60.stop();
5876
5994
  }
5877
- }, _callee59, this);
5995
+ }, _callee60, this);
5878
5996
  }));
5879
- function handleOrderCheckoutSubmit(_x66) {
5997
+ function handleOrderCheckoutSubmit(_x67) {
5880
5998
  return _handleOrderCheckoutSubmit.apply(this, arguments);
5881
5999
  }
5882
6000
  return handleOrderCheckoutSubmit;
@@ -5884,27 +6002,27 @@ var Server = /*#__PURE__*/function () {
5884
6002
  }, {
5885
6003
  key: "handleSyncCheckoutSubmit",
5886
6004
  value: function () {
5887
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6005
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5888
6006
  var _this$app16;
5889
6007
  var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
5890
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5891
- while (1) switch (_context60.prev = _context60.next) {
6008
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6009
+ while (1) switch (_context61.prev = _context61.next) {
5892
6010
  case 0:
5893
6011
  backendPath = params.backendPath, data = params.data, title = params.title;
5894
6012
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
5895
- _context60.next = 4;
6013
+ _context61.next = 4;
5896
6014
  break;
5897
6015
  }
5898
6016
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
5899
- return _context60.abrupt("return", {
6017
+ return _context61.abrupt("return", {
5900
6018
  code: 500,
5901
6019
  status: false,
5902
6020
  message: 'app.request 不可用',
5903
6021
  data: null
5904
6022
  });
5905
6023
  case 4:
5906
- _context60.prev = 4;
5907
- _context60.next = 7;
6024
+ _context61.prev = 4;
6025
+ _context61.next = 7;
5908
6026
  return this.runCheckoutSync({
5909
6027
  backendPath: backendPath,
5910
6028
  data: data,
@@ -5912,13 +6030,13 @@ var Server = /*#__PURE__*/function () {
5912
6030
  persistCheckoutDataWithResponse: true
5913
6031
  });
5914
6032
  case 7:
5915
- syncResult = _context60.sent;
6033
+ syncResult = _context61.sent;
5916
6034
  if (!syncResult.rejected) {
5917
- _context60.next = 11;
6035
+ _context61.next = 11;
5918
6036
  break;
5919
6037
  }
5920
6038
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
5921
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6039
+ return _context61.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5922
6040
  status: false,
5923
6041
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
5924
6042
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -5927,10 +6045,10 @@ var Server = /*#__PURE__*/function () {
5927
6045
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
5928
6046
  syncedOrder = syncResult.syncedOrder;
5929
6047
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
5930
- _context60.next = 16;
6048
+ _context61.next = 16;
5931
6049
  break;
5932
6050
  }
5933
- _context60.next = 16;
6051
+ _context61.next = 16;
5934
6052
  return this.dispatchLocalReceiptPrint({
5935
6053
  checkoutData: syncResult.checkoutData,
5936
6054
  order: syncedOrder,
@@ -5940,29 +6058,29 @@ var Server = /*#__PURE__*/function () {
5940
6058
  isManualPrint: true
5941
6059
  });
5942
6060
  case 16:
5943
- return _context60.abrupt("return", response);
6061
+ return _context61.abrupt("return", response);
5944
6062
  case 19:
5945
- _context60.prev = 19;
5946
- _context60.t0 = _context60["catch"](4);
5947
- backendError = this.extractBackendErrorResponse(_context60.t0);
6063
+ _context61.prev = 19;
6064
+ _context61.t0 = _context61["catch"](4);
6065
+ backendError = this.extractBackendErrorResponse(_context61.t0);
5948
6066
  if (!backendError) {
5949
- _context60.next = 25;
6067
+ _context61.next = 25;
5950
6068
  break;
5951
6069
  }
5952
6070
  _normalized = this.normalizeCheckoutResponse(backendError);
5953
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6071
+ return _context61.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5954
6072
  status: false,
5955
6073
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
5956
6074
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
5957
6075
  }));
5958
6076
  case 25:
5959
- message = this.getUnknownErrorMessage(_context60.t0);
6077
+ message = this.getUnknownErrorMessage(_context61.t0);
5960
6078
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
5961
6079
  backendPath: backendPath,
5962
6080
  error: message,
5963
- error_detail: this.normalizeUnknownError(_context60.t0)
6081
+ error_detail: this.normalizeUnknownError(_context61.t0)
5964
6082
  });
5965
- return _context60.abrupt("return", {
6083
+ return _context61.abrupt("return", {
5966
6084
  code: 500,
5967
6085
  status: false,
5968
6086
  message: message,
@@ -5970,11 +6088,11 @@ var Server = /*#__PURE__*/function () {
5970
6088
  });
5971
6089
  case 28:
5972
6090
  case "end":
5973
- return _context60.stop();
6091
+ return _context61.stop();
5974
6092
  }
5975
- }, _callee60, this, [[4, 19]]);
6093
+ }, _callee61, this, [[4, 19]]);
5976
6094
  }));
5977
- function handleSyncCheckoutSubmit(_x67) {
6095
+ function handleSyncCheckoutSubmit(_x68) {
5978
6096
  return _handleSyncCheckoutSubmit.apply(this, arguments);
5979
6097
  }
5980
6098
  return handleSyncCheckoutSubmit;
@@ -5982,10 +6100,10 @@ var Server = /*#__PURE__*/function () {
5982
6100
  }, {
5983
6101
  key: "handleOrderDraftSubmit",
5984
6102
  value: function () {
5985
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6103
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
5986
6104
  var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
5987
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5988
- while (1) switch (_context61.prev = _context61.next) {
6105
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6106
+ while (1) switch (_context62.prev = _context62.next) {
5989
6107
  case 0:
5990
6108
  data = params.data, title = params.title;
5991
6109
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5993,10 +6111,10 @@ var Server = /*#__PURE__*/function () {
5993
6111
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
5994
6112
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5995
6113
  });
5996
- _context61.next = 4;
6114
+ _context62.next = 4;
5997
6115
  return this.normalizeCheckoutSubmitData(data, title);
5998
6116
  case 4:
5999
- normalizedData = _context61.sent;
6117
+ normalizedData = _context62.sent;
6000
6118
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6001
6119
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6002
6120
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6006,26 +6124,26 @@ var Server = /*#__PURE__*/function () {
6006
6124
  is_draft_order: 1
6007
6125
  });
6008
6126
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6009
- _context61.next = 10;
6127
+ _context62.next = 10;
6010
6128
  break;
6011
6129
  }
6012
6130
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6013
- return _context61.abrupt("return", {
6131
+ return _context62.abrupt("return", {
6014
6132
  code: 500,
6015
6133
  status: false,
6016
6134
  message: 'Order 模块不支持本地草稿写入',
6017
6135
  data: null
6018
6136
  });
6019
6137
  case 10:
6020
- _context61.prev = 10;
6021
- _context61.next = 13;
6138
+ _context62.prev = 10;
6139
+ _context62.next = 13;
6022
6140
  return this.order.upsertLocalDraftOrders([draftOrder]);
6023
6141
  case 13:
6024
6142
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6025
6143
  order_id: draftOrder.order_id,
6026
6144
  external_sale_number: draftOrder.external_sale_number
6027
6145
  });
6028
- return _context61.abrupt("return", {
6146
+ return _context62.abrupt("return", {
6029
6147
  code: 200,
6030
6148
  status: true,
6031
6149
  message: '',
@@ -6037,13 +6155,13 @@ var Server = /*#__PURE__*/function () {
6037
6155
  })
6038
6156
  });
6039
6157
  case 17:
6040
- _context61.prev = 17;
6041
- _context61.t0 = _context61["catch"](10);
6042
- errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
6158
+ _context62.prev = 17;
6159
+ _context62.t0 = _context62["catch"](10);
6160
+ errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6043
6161
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6044
6162
  error: errorMessage
6045
6163
  });
6046
- return _context61.abrupt("return", {
6164
+ return _context62.abrupt("return", {
6047
6165
  code: 500,
6048
6166
  status: false,
6049
6167
  message: errorMessage,
@@ -6051,11 +6169,11 @@ var Server = /*#__PURE__*/function () {
6051
6169
  });
6052
6170
  case 22:
6053
6171
  case "end":
6054
- return _context61.stop();
6172
+ return _context62.stop();
6055
6173
  }
6056
- }, _callee61, this, [[10, 17]]);
6174
+ }, _callee62, this, [[10, 17]]);
6057
6175
  }));
6058
- function handleOrderDraftSubmit(_x68) {
6176
+ function handleOrderDraftSubmit(_x69) {
6059
6177
  return _handleOrderDraftSubmit.apply(this, arguments);
6060
6178
  }
6061
6179
  return handleOrderDraftSubmit;
@@ -6063,26 +6181,26 @@ var Server = /*#__PURE__*/function () {
6063
6181
  }, {
6064
6182
  key: "handlePendingSyncCheckoutOrder",
6065
6183
  value: function () {
6066
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6067
- var _this13 = this;
6184
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6185
+ var _this14 = this;
6068
6186
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6069
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6070
- while (1) switch (_context62.prev = _context62.next) {
6187
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6188
+ while (1) switch (_context63.prev = _context63.next) {
6071
6189
  case 0:
6072
6190
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
6073
- _context62.next = 3;
6191
+ _context63.next = 3;
6074
6192
  return this.buildPendingSyncCheckoutOrder(data);
6075
6193
  case 3:
6076
- pendingOrder = _context62.sent;
6194
+ pendingOrder = _context63.sent;
6077
6195
  if (pendingOrder) {
6078
- _context62.next = 7;
6196
+ _context63.next = 7;
6079
6197
  break;
6080
6198
  }
6081
6199
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
6082
6200
  backendPath: backendPath,
6083
6201
  reason: reason
6084
6202
  });
6085
- return _context62.abrupt("return", {
6203
+ return _context63.abrupt("return", {
6086
6204
  code: 500,
6087
6205
  status: false,
6088
6206
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -6090,22 +6208,22 @@ var Server = /*#__PURE__*/function () {
6090
6208
  });
6091
6209
  case 7:
6092
6210
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6093
- _context62.next = 10;
6211
+ _context63.next = 10;
6094
6212
  break;
6095
6213
  }
6096
6214
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6097
6215
  backendPath: backendPath,
6098
6216
  reason: reason
6099
6217
  });
6100
- return _context62.abrupt("return", {
6218
+ return _context63.abrupt("return", {
6101
6219
  code: 500,
6102
6220
  status: false,
6103
6221
  message: 'Order 模块不支持本地待同步写入',
6104
6222
  data: null
6105
6223
  });
6106
6224
  case 10:
6107
- _context62.prev = 10;
6108
- _context62.next = 13;
6225
+ _context63.prev = 10;
6226
+ _context63.next = 13;
6109
6227
  return this.order.upsertPendingSyncOrders([pendingOrder]);
6110
6228
  case 13:
6111
6229
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -6117,9 +6235,9 @@ var Server = /*#__PURE__*/function () {
6117
6235
  });
6118
6236
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6119
6237
  var _payment$metadata;
6120
- 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);
6238
+ 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);
6121
6239
  }, 0);
6122
- return _context62.abrupt("return", {
6240
+ return _context63.abrupt("return", {
6123
6241
  code: 200,
6124
6242
  status: true,
6125
6243
  message: '',
@@ -6134,15 +6252,15 @@ var Server = /*#__PURE__*/function () {
6134
6252
  })
6135
6253
  });
6136
6254
  case 18:
6137
- _context62.prev = 18;
6138
- _context62.t0 = _context62["catch"](10);
6139
- errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6255
+ _context63.prev = 18;
6256
+ _context63.t0 = _context63["catch"](10);
6257
+ errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
6140
6258
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
6141
6259
  backendPath: backendPath,
6142
6260
  reason: reason,
6143
6261
  error: errorMessage
6144
6262
  });
6145
- return _context62.abrupt("return", {
6263
+ return _context63.abrupt("return", {
6146
6264
  code: 500,
6147
6265
  status: false,
6148
6266
  message: errorMessage,
@@ -6150,11 +6268,11 @@ var Server = /*#__PURE__*/function () {
6150
6268
  });
6151
6269
  case 23:
6152
6270
  case "end":
6153
- return _context62.stop();
6271
+ return _context63.stop();
6154
6272
  }
6155
- }, _callee62, this, [[10, 18]]);
6273
+ }, _callee63, this, [[10, 18]]);
6156
6274
  }));
6157
- function handlePendingSyncCheckoutOrder(_x69) {
6275
+ function handlePendingSyncCheckoutOrder(_x70) {
6158
6276
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
6159
6277
  }
6160
6278
  return handlePendingSyncCheckoutOrder;
@@ -6162,55 +6280,65 @@ var Server = /*#__PURE__*/function () {
6162
6280
  }, {
6163
6281
  key: "buildPendingSyncCheckoutOrder",
6164
6282
  value: function () {
6165
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
6283
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6166
6284
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6167
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6168
- while (1) switch (_context63.prev = _context63.next) {
6285
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6286
+ while (1) switch (_context64.prev = _context64.next) {
6169
6287
  case 0:
6170
6288
  if (!(!data || _typeof(data) !== 'object')) {
6171
- _context63.next = 2;
6289
+ _context64.next = 2;
6172
6290
  break;
6173
6291
  }
6174
- return _context63.abrupt("return", null);
6292
+ return _context64.abrupt("return", null);
6175
6293
  case 2:
6176
6294
  hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
6177
6295
  if (hasStorageKey) {
6178
- _context63.next = 5;
6296
+ _context64.next = 5;
6179
6297
  break;
6180
6298
  }
6181
- return _context63.abrupt("return", null);
6299
+ return _context64.abrupt("return", null);
6182
6300
  case 5:
6183
6301
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6184
6302
  need_sync: 1,
6185
6303
  is_draft_order: 0
6186
6304
  });
6187
- _context63.next = 8;
6305
+ _context64.next = 8;
6188
6306
  return this.buildSmallTicketProductMap(pendingOrder);
6189
6307
  case 8:
6190
- productMap = _context63.sent;
6308
+ productMap = _context64.sent;
6191
6309
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6192
- return _context63.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6310
+ return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6193
6311
  requireFullyPaid: true,
6194
6312
  productMap: productMap
6195
6313
  }));
6196
6314
  case 11:
6197
6315
  case "end":
6198
- return _context63.stop();
6316
+ return _context64.stop();
6199
6317
  }
6200
- }, _callee63, this);
6318
+ }, _callee64, this);
6201
6319
  }));
6202
- function buildPendingSyncCheckoutOrder(_x70) {
6320
+ function buildPendingSyncCheckoutOrder(_x71) {
6203
6321
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6204
6322
  }
6205
6323
  return buildPendingSyncCheckoutOrder;
6206
6324
  }()
6325
+ /**
6326
+ * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
6327
+ */
6328
+ }, {
6329
+ key: "shouldAutoPrintCheckoutReceipt",
6330
+ value: function shouldAutoPrintCheckoutReceipt() {
6331
+ var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
6332
+ 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;
6333
+ 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)) === 'true';
6334
+ }
6207
6335
  }, {
6208
6336
  key: "shouldBuildSmallTicketData",
6209
6337
  value: function shouldBuildSmallTicketData(order) {
6210
- var _ref63, _order$small_ticket_d;
6338
+ var _ref64, _order$small_ticket_d;
6211
6339
  if (!order || _typeof(order) !== 'object') return false;
6212
6340
  // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6213
- return Number((_ref63 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref63 !== void 0 ? _ref63 : 0) === 1;
6341
+ 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;
6214
6342
  }
6215
6343
  }, {
6216
6344
  key: "shouldPrintSyncedOrder",
@@ -6228,7 +6356,7 @@ var Server = /*#__PURE__*/function () {
6228
6356
  }, {
6229
6357
  key: "isSalesOrderFullyPaid",
6230
6358
  value: function isSalesOrderFullyPaid(order) {
6231
- var _order$summary$amount, _order$summary, _ref64, _ref65, _order$summary$expect, _order$summary2, _order$summary3;
6359
+ var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
6232
6360
  if (!order || _typeof(order) !== 'object') return false;
6233
6361
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6234
6362
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6240,20 +6368,20 @@ var Server = /*#__PURE__*/function () {
6240
6368
  return this.toAmountNumber(amountGap) <= 0;
6241
6369
  }
6242
6370
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6243
- var targetAmount = this.toAmountNumber((_ref64 = (_ref65 = (_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 && _ref65 !== void 0 ? _ref65 : order.expect_amount) !== null && _ref64 !== void 0 ? _ref64 : order.total_amount);
6371
+ 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);
6244
6372
  if (targetAmount <= 0) return paidAmount > 0;
6245
6373
  return paidAmount >= targetAmount;
6246
6374
  }
6247
6375
  }, {
6248
6376
  key: "sumPaidOrderPayments",
6249
6377
  value: function sumPaidOrderPayments(payments) {
6250
- var _this14 = this;
6378
+ var _this15 = this;
6251
6379
  if (!Array.isArray(payments)) return 0;
6252
6380
  return payments.reduce(function (sum, payment) {
6253
6381
  var _payment$amount;
6254
6382
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6255
6383
  if (status !== 'paid') return sum;
6256
- 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);
6384
+ 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);
6257
6385
  }, 0);
6258
6386
  }
6259
6387
  }, {
@@ -6267,12 +6395,12 @@ var Server = /*#__PURE__*/function () {
6267
6395
  }, {
6268
6396
  key: "buildSmallTicketProductMap",
6269
6397
  value: function () {
6270
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
6398
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6271
6399
  var _this$products3,
6272
- _this15 = this;
6400
+ _this16 = this;
6273
6401
  var products, productIdSet, productIds, entries;
6274
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6275
- while (1) switch (_context65.prev = _context65.next) {
6402
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6403
+ while (1) switch (_context66.prev = _context66.next) {
6276
6404
  case 0:
6277
6405
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
6278
6406
  productIdSet = new Set();
@@ -6284,8 +6412,8 @@ var Server = /*#__PURE__*/function () {
6284
6412
  }
6285
6413
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6286
6414
  product.product_bundle.forEach(function (bundle) {
6287
- var _ref66, _bundle$bundle_produc;
6288
- var bundleProductId = (_ref66 = (_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 && _ref66 !== void 0 ? _ref66 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6415
+ var _ref67, _bundle$bundle_produc;
6416
+ 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;
6289
6417
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6290
6418
  productIdSet.add(bundleProductId);
6291
6419
  }
@@ -6294,45 +6422,45 @@ var Server = /*#__PURE__*/function () {
6294
6422
  });
6295
6423
  productIds = Array.from(productIdSet);
6296
6424
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
6297
- _context65.next = 6;
6425
+ _context66.next = 6;
6298
6426
  break;
6299
6427
  }
6300
- return _context65.abrupt("return", {});
6428
+ return _context66.abrupt("return", {});
6301
6429
  case 6:
6302
- _context65.next = 8;
6430
+ _context66.next = 8;
6303
6431
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6304
- var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(id) {
6305
- var _this15$products, _this15$products$getP, product;
6306
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6307
- while (1) switch (_context64.prev = _context64.next) {
6432
+ var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6433
+ var _this16$products, _this16$products$getP, product;
6434
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6435
+ while (1) switch (_context65.prev = _context65.next) {
6308
6436
  case 0:
6309
- _context64.prev = 0;
6310
- _context64.next = 3;
6311
- 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));
6437
+ _context65.prev = 0;
6438
+ _context65.next = 3;
6439
+ 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));
6312
6440
  case 3:
6313
- product = _context64.sent;
6314
- return _context64.abrupt("return", product ? [String(id), product] : null);
6441
+ product = _context65.sent;
6442
+ return _context65.abrupt("return", product ? [String(id), product] : null);
6315
6443
  case 7:
6316
- _context64.prev = 7;
6317
- _context64.t0 = _context64["catch"](0);
6318
- _this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6444
+ _context65.prev = 7;
6445
+ _context65.t0 = _context65["catch"](0);
6446
+ _this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6319
6447
  product_id: id,
6320
- error: _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0)
6448
+ error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6321
6449
  });
6322
- return _context64.abrupt("return", null);
6450
+ return _context65.abrupt("return", null);
6323
6451
  case 11:
6324
6452
  case "end":
6325
- return _context64.stop();
6453
+ return _context65.stop();
6326
6454
  }
6327
- }, _callee64, null, [[0, 7]]);
6455
+ }, _callee65, null, [[0, 7]]);
6328
6456
  }));
6329
- return function (_x72) {
6330
- return _ref67.apply(this, arguments);
6457
+ return function (_x73) {
6458
+ return _ref68.apply(this, arguments);
6331
6459
  };
6332
6460
  }()));
6333
6461
  case 8:
6334
- entries = _context65.sent;
6335
- return _context65.abrupt("return", entries.reduce(function (map, entry) {
6462
+ entries = _context66.sent;
6463
+ return _context66.abrupt("return", entries.reduce(function (map, entry) {
6336
6464
  if (!entry) return map;
6337
6465
  var _entry = _slicedToArray(entry, 2),
6338
6466
  id = _entry[0],
@@ -6342,11 +6470,11 @@ var Server = /*#__PURE__*/function () {
6342
6470
  }, {}));
6343
6471
  case 10:
6344
6472
  case "end":
6345
- return _context65.stop();
6473
+ return _context66.stop();
6346
6474
  }
6347
- }, _callee65, this);
6475
+ }, _callee66, this);
6348
6476
  }));
6349
- function buildSmallTicketProductMap(_x71) {
6477
+ function buildSmallTicketProductMap(_x72) {
6350
6478
  return _buildSmallTicketProductMap.apply(this, arguments);
6351
6479
  }
6352
6480
  return buildSmallTicketProductMap;
@@ -6366,8 +6494,8 @@ var Server = /*#__PURE__*/function () {
6366
6494
  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);
6367
6495
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6368
6496
  product.product_bundle.forEach(function (bundle) {
6369
- var _ref68, _bundle$bundle_produc2;
6370
- addProductId((_ref68 = (_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 && _ref68 !== void 0 ? _ref68 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6497
+ var _ref69, _bundle$bundle_produc2;
6498
+ 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);
6371
6499
  });
6372
6500
  }
6373
6501
  });
@@ -6376,40 +6504,40 @@ var Server = /*#__PURE__*/function () {
6376
6504
  }, {
6377
6505
  key: "buildSalesDetailProductSnapshotMap",
6378
6506
  value: function () {
6379
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6507
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6380
6508
  var _this$products4;
6381
6509
  var productIds, getSnapshots;
6382
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6383
- while (1) switch (_context66.prev = _context66.next) {
6510
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6511
+ while (1) switch (_context67.prev = _context67.next) {
6384
6512
  case 0:
6385
6513
  productIds = this.collectSalesDetailProductIds(order);
6386
6514
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
6387
6515
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
6388
- _context66.next = 4;
6516
+ _context67.next = 4;
6389
6517
  break;
6390
6518
  }
6391
- return _context66.abrupt("return", {});
6519
+ return _context67.abrupt("return", {});
6392
6520
  case 4:
6393
- _context66.prev = 4;
6394
- _context66.next = 7;
6521
+ _context67.prev = 4;
6522
+ _context67.next = 7;
6395
6523
  return getSnapshots.call(this.products, productIds);
6396
6524
  case 7:
6397
- return _context66.abrupt("return", _context66.sent);
6525
+ return _context67.abrupt("return", _context67.sent);
6398
6526
  case 10:
6399
- _context66.prev = 10;
6400
- _context66.t0 = _context66["catch"](4);
6527
+ _context67.prev = 10;
6528
+ _context67.t0 = _context67["catch"](4);
6401
6529
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
6402
6530
  product_ids: productIds,
6403
- error: _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0)
6531
+ error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
6404
6532
  });
6405
- return _context66.abrupt("return", {});
6533
+ return _context67.abrupt("return", {});
6406
6534
  case 14:
6407
6535
  case "end":
6408
- return _context66.stop();
6536
+ return _context67.stop();
6409
6537
  }
6410
- }, _callee66, this, [[4, 10]]);
6538
+ }, _callee67, this, [[4, 10]]);
6411
6539
  }));
6412
- function buildSalesDetailProductSnapshotMap(_x73) {
6540
+ function buildSalesDetailProductSnapshotMap(_x74) {
6413
6541
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6414
6542
  }
6415
6543
  return buildSalesDetailProductSnapshotMap;
@@ -6443,9 +6571,9 @@ var Server = /*#__PURE__*/function () {
6443
6571
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
6444
6572
  var hasChanged = false;
6445
6573
  var productBundle = product.product_bundle.map(function (bundle) {
6446
- var _ref69, _bundle$bundle_produc3;
6574
+ var _ref70, _bundle$bundle_produc3;
6447
6575
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
6448
- var rawProductId = (_ref69 = (_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 && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6576
+ 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;
6449
6577
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
6450
6578
  var productId = Number(rawProductId);
6451
6579
  if (!Number.isFinite(productId)) return bundle;
@@ -6465,53 +6593,53 @@ var Server = /*#__PURE__*/function () {
6465
6593
  }, {
6466
6594
  key: "withSalesDetailProductSnapshots",
6467
6595
  value: function () {
6468
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6469
- var _this16 = this;
6596
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6597
+ var _this17 = this;
6470
6598
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6471
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6472
- while (1) switch (_context67.prev = _context67.next) {
6599
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6600
+ while (1) switch (_context68.prev = _context68.next) {
6473
6601
  case 0:
6474
6602
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
6475
6603
  if (products !== null && products !== void 0 && products.length) {
6476
- _context67.next = 3;
6604
+ _context68.next = 3;
6477
6605
  break;
6478
6606
  }
6479
- return _context67.abrupt("return", order);
6607
+ return _context68.abrupt("return", order);
6480
6608
  case 3:
6481
- _context67.next = 5;
6609
+ _context68.next = 5;
6482
6610
  return this.buildSalesDetailProductSnapshotMap(order);
6483
6611
  case 5:
6484
- snapshotMap = _context67.sent;
6612
+ snapshotMap = _context68.sent;
6485
6613
  if (Object.keys(snapshotMap).length) {
6486
- _context67.next = 8;
6614
+ _context68.next = 8;
6487
6615
  break;
6488
6616
  }
6489
- return _context67.abrupt("return", order);
6617
+ return _context68.abrupt("return", order);
6490
6618
  case 8:
6491
6619
  hasChanged = false;
6492
6620
  enrichedProducts = products.map(function (product) {
6493
- var productWithBundleSnapshots = _this16.withBundleCatalogSnapshots(product, snapshotMap);
6494
- var nextProduct = _this16.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6621
+ var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
6622
+ var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6495
6623
  if (nextProduct !== product) hasChanged = true;
6496
6624
  return nextProduct;
6497
6625
  });
6498
6626
  if (hasChanged) {
6499
- _context67.next = 12;
6627
+ _context68.next = 12;
6500
6628
  break;
6501
6629
  }
6502
- return _context67.abrupt("return", order);
6630
+ return _context68.abrupt("return", order);
6503
6631
  case 12:
6504
6632
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
6505
6633
  products: enrichedProducts
6506
6634
  });
6507
- return _context67.abrupt("return", enrichedOrder);
6635
+ return _context68.abrupt("return", enrichedOrder);
6508
6636
  case 14:
6509
6637
  case "end":
6510
- return _context67.stop();
6638
+ return _context68.stop();
6511
6639
  }
6512
- }, _callee67, this);
6640
+ }, _callee68, this);
6513
6641
  }));
6514
- function withSalesDetailProductSnapshots(_x74) {
6642
+ function withSalesDetailProductSnapshots(_x75) {
6515
6643
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6516
6644
  }
6517
6645
  return withSalesDetailProductSnapshots;
@@ -6519,13 +6647,13 @@ var Server = /*#__PURE__*/function () {
6519
6647
  }, {
6520
6648
  key: "withPendingSyncProductTitles",
6521
6649
  value: function withPendingSyncProductTitles(order, productMap) {
6522
- var _this17 = this;
6650
+ var _this18 = this;
6523
6651
  var products = Array.isArray(order.products) ? order.products : null;
6524
6652
  if (!(products !== null && products !== void 0 && products.length)) return order;
6525
6653
  return _objectSpread(_objectSpread({}, order), {}, {
6526
6654
  products: products.map(function (product) {
6527
6655
  return _objectSpread(_objectSpread({}, product), {}, {
6528
- product_title: _this17.buildProductTitleSnapshot(product, productMap)
6656
+ product_title: _this18.buildProductTitleSnapshot(product, productMap)
6529
6657
  });
6530
6658
  })
6531
6659
  });
@@ -6536,7 +6664,7 @@ var Server = /*#__PURE__*/function () {
6536
6664
  var _product$product_id4,
6537
6665
  _product$product,
6538
6666
  _fallbackProduct$prod,
6539
- _this18 = this;
6667
+ _this19 = this;
6540
6668
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6541
6669
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6542
6670
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6544,7 +6672,7 @@ var Server = /*#__PURE__*/function () {
6544
6672
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6545
6673
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6546
6674
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6547
- snapshot[key] = _this18.resolveProductTitleValue(ownTitle, key, currentLocale) || _this18.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6675
+ snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6548
6676
  return snapshot;
6549
6677
  }, {});
6550
6678
  }
@@ -6569,7 +6697,7 @@ var Server = /*#__PURE__*/function () {
6569
6697
  }, {
6570
6698
  key: "resolveProductTitleValue",
6571
6699
  value: function resolveProductTitleValue(value, key, currentLocale) {
6572
- var _ref70, _ref71, _value$key;
6700
+ var _ref71, _ref72, _value$key;
6573
6701
  if (value === undefined || value === null || value === '') return null;
6574
6702
  if (_typeof(value) !== 'object') {
6575
6703
  var title = String(value);
@@ -6579,7 +6707,7 @@ var Server = /*#__PURE__*/function () {
6579
6707
  }
6580
6708
  var normalizedKey = key.replace('-', '_');
6581
6709
  var dashedKey = key.replace('_', '-');
6582
- var rawValue = (_ref70 = (_ref71 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref71 !== void 0 ? _ref71 : value[dashedKey]) !== null && _ref70 !== void 0 ? _ref70 : key === 'auto' ? value.default : undefined;
6710
+ 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;
6583
6711
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
6584
6712
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
6585
6713
  return String(rawValue);
@@ -6642,31 +6770,31 @@ var Server = /*#__PURE__*/function () {
6642
6770
  }, {
6643
6771
  key: "enrichPaymentNamesByCode",
6644
6772
  value: function () {
6645
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6646
- var _this19 = this;
6773
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6774
+ var _this20 = this;
6647
6775
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6648
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6649
- while (1) switch (_context68.prev = _context68.next) {
6776
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6777
+ while (1) switch (_context69.prev = _context69.next) {
6650
6778
  case 0:
6651
6779
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6652
6780
  hasMissingName = payments.some(function (payment) {
6653
- return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6781
+ return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6654
6782
  });
6655
6783
  if (hasMissingName) {
6656
- _context68.next = 4;
6784
+ _context69.next = 4;
6657
6785
  break;
6658
6786
  }
6659
- return _context68.abrupt("return", order);
6787
+ return _context69.abrupt("return", order);
6660
6788
  case 4:
6661
- _context68.prev = 4;
6662
- _context68.next = 7;
6789
+ _context69.prev = 4;
6790
+ _context69.next = 7;
6663
6791
  return this.getPaymentRouteModule();
6664
6792
  case 7:
6665
- paymentModule = _context68.sent;
6666
- _context68.next = 10;
6793
+ paymentModule = _context69.sent;
6794
+ _context69.next = 10;
6667
6795
  return paymentModule.getPayMethodListAsync();
6668
6796
  case 10:
6669
- payMethods = _context68.sent;
6797
+ payMethods = _context69.sent;
6670
6798
  nameByCode = new Map();
6671
6799
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
6672
6800
  try {
@@ -6683,9 +6811,9 @@ var Server = /*#__PURE__*/function () {
6683
6811
  }
6684
6812
  hasResolvedName = false;
6685
6813
  enrichedPayments = payments.map(function (payment) {
6686
- if (!_this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6687
- if (!_this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6688
- var name = nameByCode.get(_this19.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6814
+ if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6815
+ if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6816
+ var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6689
6817
  if (!name) return payment;
6690
6818
  hasResolvedName = true;
6691
6819
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6693,28 +6821,28 @@ var Server = /*#__PURE__*/function () {
6693
6821
  });
6694
6822
  });
6695
6823
  if (hasResolvedName) {
6696
- _context68.next = 18;
6824
+ _context69.next = 18;
6697
6825
  break;
6698
6826
  }
6699
- return _context68.abrupt("return", order);
6827
+ return _context69.abrupt("return", order);
6700
6828
  case 18:
6701
- return _context68.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6829
+ return _context69.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6702
6830
  payments: enrichedPayments
6703
6831
  }));
6704
6832
  case 21:
6705
- _context68.prev = 21;
6706
- _context68.t0 = _context68["catch"](4);
6833
+ _context69.prev = 21;
6834
+ _context69.t0 = _context69["catch"](4);
6707
6835
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
6708
- error: _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0)
6836
+ error: _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0)
6709
6837
  });
6710
- return _context68.abrupt("return", order);
6838
+ return _context69.abrupt("return", order);
6711
6839
  case 25:
6712
6840
  case "end":
6713
- return _context68.stop();
6841
+ return _context69.stop();
6714
6842
  }
6715
- }, _callee68, this, [[4, 21]]);
6843
+ }, _callee69, this, [[4, 21]]);
6716
6844
  }));
6717
- function enrichPaymentNamesByCode(_x75) {
6845
+ function enrichPaymentNamesByCode(_x76) {
6718
6846
  return _enrichPaymentNamesByCode.apply(this, arguments);
6719
6847
  }
6720
6848
  return enrichPaymentNamesByCode;
@@ -6722,66 +6850,66 @@ var Server = /*#__PURE__*/function () {
6722
6850
  }, {
6723
6851
  key: "withLocalSmallTicketData",
6724
6852
  value: function () {
6725
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order, options) {
6853
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order, options) {
6726
6854
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
6727
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6728
- while (1) switch (_context69.prev = _context69.next) {
6855
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6856
+ while (1) switch (_context70.prev = _context70.next) {
6729
6857
  case 0:
6730
6858
  if (this.shouldBuildSmallTicketData(order)) {
6731
- _context69.next = 2;
6859
+ _context70.next = 2;
6732
6860
  break;
6733
6861
  }
6734
- return _context69.abrupt("return", order);
6862
+ return _context70.abrupt("return", order);
6735
6863
  case 2:
6736
6864
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
6737
- _context69.next = 4;
6865
+ _context70.next = 4;
6738
6866
  break;
6739
6867
  }
6740
- return _context69.abrupt("return", order);
6868
+ return _context70.abrupt("return", order);
6741
6869
  case 4:
6742
- _context69.prev = 4;
6743
- _context69.next = 7;
6870
+ _context70.prev = 4;
6871
+ _context70.next = 7;
6744
6872
  return this.enrichPaymentNamesByCode(order);
6745
6873
  case 7:
6746
- enrichedOrder = _context69.sent;
6874
+ enrichedOrder = _context70.sent;
6747
6875
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
6748
- _context69.next = 12;
6876
+ _context70.next = 12;
6749
6877
  break;
6750
6878
  }
6751
- _context69.t0 = _options$productMap;
6752
- _context69.next = 15;
6879
+ _context70.t0 = _options$productMap;
6880
+ _context70.next = 15;
6753
6881
  break;
6754
6882
  case 12:
6755
- _context69.next = 14;
6883
+ _context70.next = 14;
6756
6884
  return this.buildSmallTicketProductMap(enrichedOrder);
6757
6885
  case 14:
6758
- _context69.t0 = _context69.sent;
6886
+ _context70.t0 = _context70.sent;
6759
6887
  case 15:
6760
- productMap = _context69.t0;
6888
+ productMap = _context70.t0;
6761
6889
  smallTicketData = buildSmallTicketData({
6762
6890
  order: enrichedOrder,
6763
6891
  shopInfo: this.getSmallTicketShopInfo(),
6764
6892
  productMap: productMap
6765
6893
  });
6766
- return _context69.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6894
+ return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6767
6895
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
6768
6896
  small_ticket_data: smallTicketData
6769
6897
  })
6770
6898
  }));
6771
6899
  case 20:
6772
- _context69.prev = 20;
6773
- _context69.t1 = _context69["catch"](4);
6900
+ _context70.prev = 20;
6901
+ _context70.t1 = _context70["catch"](4);
6774
6902
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
6775
- error: _context69.t1 instanceof Error ? _context69.t1.message : String(_context69.t1)
6903
+ error: _context70.t1 instanceof Error ? _context70.t1.message : String(_context70.t1)
6776
6904
  });
6777
- return _context69.abrupt("return", order);
6905
+ return _context70.abrupt("return", order);
6778
6906
  case 24:
6779
6907
  case "end":
6780
- return _context69.stop();
6908
+ return _context70.stop();
6781
6909
  }
6782
- }, _callee69, this, [[4, 20]]);
6910
+ }, _callee70, this, [[4, 20]]);
6783
6911
  }));
6784
- function withLocalSmallTicketData(_x76, _x77) {
6912
+ function withLocalSmallTicketData(_x77, _x78) {
6785
6913
  return _withLocalSmallTicketData.apply(this, arguments);
6786
6914
  }
6787
6915
  return withLocalSmallTicketData;
@@ -6843,34 +6971,34 @@ var Server = /*#__PURE__*/function () {
6843
6971
  }, {
6844
6972
  key: "handleUpdateLocalOrdersBatch",
6845
6973
  value: (function () {
6846
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(orderIds) {
6847
- var _this$app17;
6974
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
6975
+ var _this$app18;
6848
6976
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6849
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6850
- while (1) switch (_context70.prev = _context70.next) {
6977
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6978
+ while (1) switch (_context71.prev = _context71.next) {
6851
6979
  case 0:
6852
6980
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
6853
6981
  count: orderIds.length,
6854
6982
  orderIds: orderIds
6855
6983
  });
6856
6984
  if (this.order) {
6857
- _context70.next = 4;
6985
+ _context71.next = 4;
6858
6986
  break;
6859
6987
  }
6860
6988
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
6861
- return _context70.abrupt("return", {
6989
+ return _context71.abrupt("return", {
6862
6990
  code: 500,
6863
6991
  status: false,
6864
6992
  message: 'Order 模块未注册',
6865
6993
  data: null
6866
6994
  });
6867
6995
  case 4:
6868
- if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
6869
- _context70.next = 7;
6996
+ if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
6997
+ _context71.next = 7;
6870
6998
  break;
6871
6999
  }
6872
7000
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
6873
- return _context70.abrupt("return", {
7001
+ return _context71.abrupt("return", {
6874
7002
  code: 500,
6875
7003
  status: false,
6876
7004
  message: 'app.request 不可用',
@@ -6893,21 +7021,21 @@ var Server = /*#__PURE__*/function () {
6893
7021
  _iterator13.f();
6894
7022
  }
6895
7023
  fetched = [];
6896
- _context70.prev = 11;
6897
- _context70.next = 14;
7024
+ _context71.prev = 11;
7025
+ _context71.next = 14;
6898
7026
  return this.order.fetchOrdersByHttp(orderIds);
6899
7027
  case 14:
6900
- fetched = _context70.sent;
6901
- _context70.next = 22;
7028
+ fetched = _context71.sent;
7029
+ _context71.next = 22;
6902
7030
  break;
6903
7031
  case 17:
6904
- _context70.prev = 17;
6905
- _context70.t0 = _context70["catch"](11);
6906
- message = _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0);
7032
+ _context71.prev = 17;
7033
+ _context71.t0 = _context71["catch"](11);
7034
+ message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
6907
7035
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
6908
7036
  message: message
6909
7037
  });
6910
- return _context70.abrupt("return", {
7038
+ return _context71.abrupt("return", {
6911
7039
  code: 500,
6912
7040
  status: false,
6913
7041
  message: message,
@@ -6917,36 +7045,36 @@ var Server = /*#__PURE__*/function () {
6917
7045
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
6918
7046
  fetchedMap = new Map();
6919
7047
  _iterator14 = _createForOfIteratorHelper(fetched);
6920
- _context70.prev = 24;
7048
+ _context71.prev = 24;
6921
7049
  _iterator14.s();
6922
7050
  case 26:
6923
7051
  if ((_step14 = _iterator14.n()).done) {
6924
- _context70.next = 34;
7052
+ _context71.next = 34;
6925
7053
  break;
6926
7054
  }
6927
7055
  order = _step14.value;
6928
7056
  oid = order === null || order === void 0 ? void 0 : order.order_id;
6929
7057
  if (!(oid === undefined || oid === null)) {
6930
- _context70.next = 31;
7058
+ _context71.next = 31;
6931
7059
  break;
6932
7060
  }
6933
- return _context70.abrupt("continue", 32);
7061
+ return _context71.abrupt("continue", 32);
6934
7062
  case 31:
6935
7063
  fetchedMap.set(String(oid), order);
6936
7064
  case 32:
6937
- _context70.next = 26;
7065
+ _context71.next = 26;
6938
7066
  break;
6939
7067
  case 34:
6940
- _context70.next = 39;
7068
+ _context71.next = 39;
6941
7069
  break;
6942
7070
  case 36:
6943
- _context70.prev = 36;
6944
- _context70.t1 = _context70["catch"](24);
6945
- _iterator14.e(_context70.t1);
7071
+ _context71.prev = 36;
7072
+ _context71.t1 = _context71["catch"](24);
7073
+ _iterator14.e(_context71.t1);
6946
7074
  case 39:
6947
- _context70.prev = 39;
7075
+ _context71.prev = 39;
6948
7076
  _iterator14.f();
6949
- return _context70.finish(39);
7077
+ return _context71.finish(39);
6950
7078
  case 42:
6951
7079
  freshOrders = [];
6952
7080
  succeedIds = [];
@@ -6972,23 +7100,23 @@ var Server = /*#__PURE__*/function () {
6972
7100
  _iterator15.f();
6973
7101
  }
6974
7102
  if (!(freshOrders.length > 0)) {
6975
- _context70.next = 58;
7103
+ _context71.next = 58;
6976
7104
  break;
6977
7105
  }
6978
- _context70.prev = 48;
6979
- _context70.next = 51;
7106
+ _context71.prev = 48;
7107
+ _context71.next = 51;
6980
7108
  return this.order.upsertOrdersFromRemote(freshOrders);
6981
7109
  case 51:
6982
- _context70.next = 58;
7110
+ _context71.next = 58;
6983
7111
  break;
6984
7112
  case 53:
6985
- _context70.prev = 53;
6986
- _context70.t2 = _context70["catch"](48);
6987
- _message2 = _context70.t2 instanceof Error ? _context70.t2.message : String(_context70.t2);
7113
+ _context71.prev = 53;
7114
+ _context71.t2 = _context71["catch"](48);
7115
+ _message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
6988
7116
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
6989
7117
  message: _message2
6990
7118
  });
6991
- return _context70.abrupt("return", {
7119
+ return _context71.abrupt("return", {
6992
7120
  code: 500,
6993
7121
  status: false,
6994
7122
  message: _message2,
@@ -7007,7 +7135,7 @@ var Server = /*#__PURE__*/function () {
7007
7135
  insertedCount: inserted.length,
7008
7136
  failedCount: failed.length
7009
7137
  });
7010
- return _context70.abrupt("return", {
7138
+ return _context71.abrupt("return", {
7011
7139
  code: 200,
7012
7140
  status: true,
7013
7141
  message: '',
@@ -7019,11 +7147,11 @@ var Server = /*#__PURE__*/function () {
7019
7147
  });
7020
7148
  case 62:
7021
7149
  case "end":
7022
- return _context70.stop();
7150
+ return _context71.stop();
7023
7151
  }
7024
- }, _callee70, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7152
+ }, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7025
7153
  }));
7026
- function handleUpdateLocalOrdersBatch(_x78) {
7154
+ function handleUpdateLocalOrdersBatch(_x79) {
7027
7155
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7028
7156
  }
7029
7157
  return handleUpdateLocalOrdersBatch;
@@ -7267,10 +7395,10 @@ var Server = /*#__PURE__*/function () {
7267
7395
  value: function extractBackendErrorResponse(error) {
7268
7396
  var _error$response3,
7269
7397
  _error$response4,
7270
- _this20 = this;
7398
+ _this21 = this;
7271
7399
  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];
7272
7400
  return candidates.find(function (candidate) {
7273
- return _this20.isExplicitBackendErrorResponse(candidate);
7401
+ return _this21.isExplicitBackendErrorResponse(candidate);
7274
7402
  }) || null;
7275
7403
  }
7276
7404
  }, {
@@ -7389,16 +7517,16 @@ var Server = /*#__PURE__*/function () {
7389
7517
  }, {
7390
7518
  key: "recomputeAndNotifyFloorPlanQuery",
7391
7519
  value: (function () {
7392
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71() {
7520
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7393
7521
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7394
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7395
- while (1) switch (_context71.prev = _context71.next) {
7522
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7523
+ while (1) switch (_context72.prev = _context72.next) {
7396
7524
  case 0:
7397
7525
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7398
- _context71.next = 2;
7526
+ _context72.next = 2;
7399
7527
  break;
7400
7528
  }
7401
- return _context71.abrupt("return");
7529
+ return _context72.abrupt("return");
7402
7530
  case 2:
7403
7531
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7404
7532
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -7428,9 +7556,9 @@ var Server = /*#__PURE__*/function () {
7428
7556
  }
7429
7557
  case 5:
7430
7558
  case "end":
7431
- return _context71.stop();
7559
+ return _context72.stop();
7432
7560
  }
7433
- }, _callee71, this);
7561
+ }, _callee72, this);
7434
7562
  }));
7435
7563
  function recomputeAndNotifyFloorPlanQuery() {
7436
7564
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7460,21 +7588,21 @@ var Server = /*#__PURE__*/function () {
7460
7588
  * filter 逻辑暂为 mock,仅记录参数
7461
7589
  */
7462
7590
  function () {
7463
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data) {
7591
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7464
7592
  var rawList, result;
7465
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7466
- while (1) switch (_context72.prev = _context72.next) {
7593
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7594
+ while (1) switch (_context73.prev = _context73.next) {
7467
7595
  case 0:
7468
7596
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7469
7597
  data: data
7470
7598
  });
7471
7599
  console.log('[Server] computeOrderQueryResult', data);
7472
7600
  if (this.order) {
7473
- _context72.next = 5;
7601
+ _context73.next = 5;
7474
7602
  break;
7475
7603
  }
7476
7604
  this.logError('computeOrderQueryResult: Order 模块未注册');
7477
- return _context72.abrupt("return", {
7605
+ return _context73.abrupt("return", {
7478
7606
  code: 500,
7479
7607
  message: 'Order 模块未注册',
7480
7608
  data: {
@@ -7504,7 +7632,7 @@ var Server = /*#__PURE__*/function () {
7504
7632
  skip: result.skip,
7505
7633
  rejected: result.rejected
7506
7634
  });
7507
- return _context72.abrupt("return", {
7635
+ return _context73.abrupt("return", {
7508
7636
  code: 200,
7509
7637
  data: result,
7510
7638
  message: '',
@@ -7512,11 +7640,11 @@ var Server = /*#__PURE__*/function () {
7512
7640
  });
7513
7641
  case 11:
7514
7642
  case "end":
7515
- return _context72.stop();
7643
+ return _context73.stop();
7516
7644
  }
7517
- }, _callee72, this);
7645
+ }, _callee73, this);
7518
7646
  }));
7519
- function computeOrderQueryResult(_x79) {
7647
+ function computeOrderQueryResult(_x80) {
7520
7648
  return _computeOrderQueryResult.apply(this, arguments);
7521
7649
  }
7522
7650
  return computeOrderQueryResult;
@@ -7529,17 +7657,17 @@ var Server = /*#__PURE__*/function () {
7529
7657
  }, {
7530
7658
  key: "computeBookingQueryResult",
7531
7659
  value: (function () {
7532
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7660
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7533
7661
  var rawOrders, result;
7534
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7535
- while (1) switch (_context73.prev = _context73.next) {
7662
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7663
+ while (1) switch (_context74.prev = _context74.next) {
7536
7664
  case 0:
7537
7665
  if (this.order) {
7538
- _context73.next = 3;
7666
+ _context74.next = 3;
7539
7667
  break;
7540
7668
  }
7541
7669
  this.logError('computeBookingQueryResult: Order 模块未注册');
7542
- return _context73.abrupt("return", {
7670
+ return _context74.abrupt("return", {
7543
7671
  code: 500,
7544
7672
  message: 'Order 模块未注册',
7545
7673
  data: {
@@ -7558,7 +7686,7 @@ var Server = /*#__PURE__*/function () {
7558
7686
  size: result.size,
7559
7687
  skip: result.skip
7560
7688
  });
7561
- return _context73.abrupt("return", {
7689
+ return _context74.abrupt("return", {
7562
7690
  code: 200,
7563
7691
  data: result,
7564
7692
  message: '',
@@ -7566,11 +7694,11 @@ var Server = /*#__PURE__*/function () {
7566
7694
  });
7567
7695
  case 8:
7568
7696
  case "end":
7569
- return _context73.stop();
7697
+ return _context74.stop();
7570
7698
  }
7571
- }, _callee73, this);
7699
+ }, _callee74, this);
7572
7700
  }));
7573
- function computeBookingQueryResult(_x80) {
7701
+ function computeBookingQueryResult(_x81) {
7574
7702
  return _computeBookingQueryResult.apply(this, arguments);
7575
7703
  }
7576
7704
  return computeBookingQueryResult;
@@ -7629,12 +7757,12 @@ var Server = /*#__PURE__*/function () {
7629
7757
  }, {
7630
7758
  key: "computeProductQueryResult",
7631
7759
  value: (function () {
7632
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(context, options) {
7760
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
7633
7761
  var _menu_list_ids$length3,
7634
- _this21 = this;
7762
+ _this22 = this;
7635
7763
  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;
7636
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7637
- while (1) switch (_context74.prev = _context74.next) {
7764
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7765
+ while (1) switch (_context75.prev = _context75.next) {
7638
7766
  case 0:
7639
7767
  tTotal = performance.now();
7640
7768
  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;
@@ -7661,28 +7789,28 @@ var Server = /*#__PURE__*/function () {
7661
7789
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7662
7790
  });
7663
7791
  if (this.products) {
7664
- _context74.next = 8;
7792
+ _context75.next = 8;
7665
7793
  break;
7666
7794
  }
7667
7795
  this.logError('computeProductQueryResult: Products 模块未注册');
7668
- return _context74.abrupt("return", {
7796
+ return _context75.abrupt("return", {
7669
7797
  message: 'Products 模块未注册',
7670
7798
  data: this.buildProductQueryResultPayload([], 0)
7671
7799
  });
7672
7800
  case 8:
7673
7801
  if (!(queryIds.length > 0)) {
7674
- _context74.next = 20;
7802
+ _context75.next = 20;
7675
7803
  break;
7676
7804
  }
7677
7805
  uniqueIds = Array.from(new Set(queryIds));
7678
7806
  _tPrice = performance.now();
7679
- _context74.next = 13;
7807
+ _context75.next = 13;
7680
7808
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7681
7809
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7682
7810
  productIds: uniqueIds
7683
7811
  });
7684
7812
  case 13:
7685
- productsWithPrice = _context74.sent;
7813
+ productsWithPrice = _context75.sent;
7686
7814
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7687
7815
  count: productsWithPrice.length,
7688
7816
  ids: uniqueIds
@@ -7702,7 +7830,7 @@ var Server = /*#__PURE__*/function () {
7702
7830
  ids: uniqueIds,
7703
7831
  count: extensionFilteredProducts.length
7704
7832
  });
7705
- return _context74.abrupt("return", {
7833
+ return _context75.abrupt("return", {
7706
7834
  code: 200,
7707
7835
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7708
7836
  message: '',
@@ -7710,17 +7838,17 @@ var Server = /*#__PURE__*/function () {
7710
7838
  });
7711
7839
  case 20:
7712
7840
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7713
- _context74.next = 32;
7841
+ _context75.next = 32;
7714
7842
  break;
7715
7843
  }
7716
7844
  pid = Number(product_id);
7717
7845
  _tPrice2 = performance.now();
7718
- _context74.next = 25;
7846
+ _context75.next = 25;
7719
7847
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7720
7848
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7721
7849
  });
7722
7850
  case 25:
7723
- allProductsWithPrice = _context74.sent;
7851
+ allProductsWithPrice = _context75.sent;
7724
7852
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7725
7853
  count: allProductsWithPrice.length,
7726
7854
  productId: pid
@@ -7740,7 +7868,7 @@ var Server = /*#__PURE__*/function () {
7740
7868
  productId: pid,
7741
7869
  found: !!item
7742
7870
  });
7743
- return _context74.abrupt("return", {
7871
+ return _context75.abrupt("return", {
7744
7872
  code: 200,
7745
7873
  data: item,
7746
7874
  message: item ? '' : '商品不存在或未发布',
@@ -7748,16 +7876,16 @@ var Server = /*#__PURE__*/function () {
7748
7876
  });
7749
7877
  case 32:
7750
7878
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7751
- _context74.next = 52;
7879
+ _context75.next = 52;
7752
7880
  break;
7753
7881
  }
7754
7882
  _tPrice3 = performance.now();
7755
- _context74.next = 36;
7883
+ _context75.next = 36;
7756
7884
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7757
7885
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7758
7886
  });
7759
7887
  case 36:
7760
- _filteredProducts2 = _context74.sent;
7888
+ _filteredProducts2 = _context75.sent;
7761
7889
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7762
7890
  count: _filteredProducts2.length,
7763
7891
  extension_type: extension_type
@@ -7796,7 +7924,7 @@ var Server = /*#__PURE__*/function () {
7796
7924
  filteredCount: _filteredProducts2.length,
7797
7925
  extension_type: extension_type
7798
7926
  });
7799
- return _context74.abrupt("return", {
7927
+ return _context75.abrupt("return", {
7800
7928
  code: 200,
7801
7929
  data: this.buildProductQueryResultPayload(_filteredProducts2),
7802
7930
  message: '',
@@ -7804,50 +7932,50 @@ var Server = /*#__PURE__*/function () {
7804
7932
  });
7805
7933
  case 52:
7806
7934
  if (this.menu) {
7807
- _context74.next = 55;
7935
+ _context75.next = 55;
7808
7936
  break;
7809
7937
  }
7810
7938
  this.logError('computeProductQueryResult: Menu 模块未注册');
7811
- return _context74.abrupt("return", {
7939
+ return _context75.abrupt("return", {
7812
7940
  message: 'Menu 模块未注册',
7813
7941
  data: this.buildProductQueryResultPayload([], 0)
7814
7942
  });
7815
7943
  case 55:
7816
7944
  if (this.schedule) {
7817
- _context74.next = 58;
7945
+ _context75.next = 58;
7818
7946
  break;
7819
7947
  }
7820
7948
  this.logError('computeProductQueryResult: Schedule 模块未注册');
7821
- return _context74.abrupt("return", {
7949
+ return _context75.abrupt("return", {
7822
7950
  message: 'Schedule 模块未注册',
7823
7951
  data: this.buildProductQueryResultPayload([], 0)
7824
7952
  });
7825
7953
  case 58:
7826
7954
  activeMenuList = [];
7827
7955
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
7828
- _context74.next = 71;
7956
+ _context75.next = 71;
7829
7957
  break;
7830
7958
  }
7831
7959
  tMenu = performance.now();
7832
7960
  getActiveMenus = function getActiveMenus() {
7833
- return _this21.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7834
- var _this21$schedule;
7835
- return ((_this21$schedule = _this21.schedule) === null || _this21$schedule === void 0 ? void 0 : _this21$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7961
+ return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7962
+ var _this22$schedule;
7963
+ return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7836
7964
  });
7837
7965
  };
7838
7966
  activeMenuList = getActiveMenus();
7839
- _context74.t0 = !activeMenuList.length;
7840
- if (!_context74.t0) {
7841
- _context74.next = 68;
7967
+ _context75.t0 = !activeMenuList.length;
7968
+ if (!_context75.t0) {
7969
+ _context75.next = 68;
7842
7970
  break;
7843
7971
  }
7844
- _context74.next = 67;
7972
+ _context75.next = 67;
7845
7973
  return this.refreshMenuScheduleCacheAfterEmptyResult();
7846
7974
  case 67:
7847
- _context74.t0 = _context74.sent;
7975
+ _context75.t0 = _context75.sent;
7848
7976
  case 68:
7849
- if (!_context74.t0) {
7850
- _context74.next = 70;
7977
+ if (!_context75.t0) {
7978
+ _context75.next = 70;
7851
7979
  break;
7852
7980
  }
7853
7981
  activeMenuList = getActiveMenus();
@@ -7867,22 +7995,22 @@ var Server = /*#__PURE__*/function () {
7867
7995
  });
7868
7996
  tPrice = performance.now();
7869
7997
  if (!(scopedProductIds.length > 0)) {
7870
- _context74.next = 82;
7998
+ _context75.next = 82;
7871
7999
  break;
7872
8000
  }
7873
- _context74.next = 79;
8001
+ _context75.next = 79;
7874
8002
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7875
8003
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7876
8004
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
7877
8005
  });
7878
8006
  case 79:
7879
- _context74.t1 = _context74.sent;
7880
- _context74.next = 83;
8007
+ _context75.t1 = _context75.sent;
8008
+ _context75.next = 83;
7881
8009
  break;
7882
8010
  case 82:
7883
- _context74.t1 = [];
8011
+ _context75.t1 = [];
7884
8012
  case 83:
7885
- filteredProducts = _context74.t1;
8013
+ filteredProducts = _context75.t1;
7886
8014
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
7887
8015
  count: filteredProducts.length,
7888
8016
  scopedProductCount: scopedProductIds.length
@@ -7923,7 +8051,7 @@ var Server = /*#__PURE__*/function () {
7923
8051
  filteredCount: filteredProducts.length,
7924
8052
  activeMenuCount: activeMenuList.length
7925
8053
  });
7926
- return _context74.abrupt("return", {
8054
+ return _context75.abrupt("return", {
7927
8055
  code: 200,
7928
8056
  data: this.buildProductQueryResultPayload(filteredProducts),
7929
8057
  message: '',
@@ -7931,11 +8059,11 @@ var Server = /*#__PURE__*/function () {
7931
8059
  });
7932
8060
  case 99:
7933
8061
  case "end":
7934
- return _context74.stop();
8062
+ return _context75.stop();
7935
8063
  }
7936
- }, _callee74, this);
8064
+ }, _callee75, this);
7937
8065
  }));
7938
- function computeProductQueryResult(_x81, _x82) {
8066
+ function computeProductQueryResult(_x82, _x83) {
7939
8067
  return _computeProductQueryResult.apply(this, arguments);
7940
8068
  }
7941
8069
  return computeProductQueryResult;
@@ -7949,14 +8077,14 @@ var Server = /*#__PURE__*/function () {
7949
8077
  }, {
7950
8078
  key: "buildProductFormatterContext",
7951
8079
  value: function buildProductFormatterContext(context) {
7952
- var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context5;
8080
+ var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context5;
7953
8081
  var scheduleModule = this.getSchedule();
7954
8082
  return {
7955
8083
  scheduleModule: scheduleModule,
7956
8084
  schedule_datetime: context.schedule_datetime,
7957
8085
  customer_id: context.customer_id,
7958
8086
  strategy_context: context.strategy_context,
7959
- menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
8087
+ menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
7960
8088
  scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
7961
8089
  dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
7962
8090
  };
@@ -7971,72 +8099,72 @@ var Server = /*#__PURE__*/function () {
7971
8099
  }, {
7972
8100
  key: "recomputeAndNotifyProductQuery",
7973
8101
  value: (function () {
7974
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(options) {
8102
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
7975
8103
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
7976
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7977
- while (1) switch (_context75.prev = _context75.next) {
8104
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8105
+ while (1) switch (_context76.prev = _context76.next) {
7978
8106
  case 0:
7979
8107
  if (!(this.productQuerySubscribers.size === 0)) {
7980
- _context75.next = 2;
8108
+ _context76.next = 2;
7981
8109
  break;
7982
8110
  }
7983
- return _context75.abrupt("return");
8111
+ return _context76.abrupt("return");
7984
8112
  case 2:
7985
8113
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
7986
8114
  subscriberCount: this.productQuerySubscribers.size,
7987
8115
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7988
8116
  });
7989
8117
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
7990
- _context75.prev = 4;
8118
+ _context76.prev = 4;
7991
8119
  _iterator18.s();
7992
8120
  case 6:
7993
8121
  if ((_step18 = _iterator18.n()).done) {
7994
- _context75.next = 22;
8122
+ _context76.next = 22;
7995
8123
  break;
7996
8124
  }
7997
8125
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
7998
- _context75.prev = 8;
7999
- _context75.next = 11;
8126
+ _context76.prev = 8;
8127
+ _context76.next = 11;
8000
8128
  return this.computeProductQueryResult(subscriber.context, {
8001
8129
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8002
8130
  });
8003
8131
  case 11:
8004
- result = _context75.sent;
8132
+ result = _context76.sent;
8005
8133
  subscriber.callback(result);
8006
8134
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
8007
8135
  subscriberId: subscriberId
8008
8136
  });
8009
- _context75.next = 20;
8137
+ _context76.next = 20;
8010
8138
  break;
8011
8139
  case 16:
8012
- _context75.prev = 16;
8013
- _context75.t0 = _context75["catch"](8);
8014
- errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
8140
+ _context76.prev = 16;
8141
+ _context76.t0 = _context76["catch"](8);
8142
+ errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8015
8143
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
8016
8144
  subscriberId: subscriberId,
8017
8145
  error: errorMessage
8018
8146
  });
8019
8147
  case 20:
8020
- _context75.next = 6;
8148
+ _context76.next = 6;
8021
8149
  break;
8022
8150
  case 22:
8023
- _context75.next = 27;
8151
+ _context76.next = 27;
8024
8152
  break;
8025
8153
  case 24:
8026
- _context75.prev = 24;
8027
- _context75.t1 = _context75["catch"](4);
8028
- _iterator18.e(_context75.t1);
8154
+ _context76.prev = 24;
8155
+ _context76.t1 = _context76["catch"](4);
8156
+ _iterator18.e(_context76.t1);
8029
8157
  case 27:
8030
- _context75.prev = 27;
8158
+ _context76.prev = 27;
8031
8159
  _iterator18.f();
8032
- return _context75.finish(27);
8160
+ return _context76.finish(27);
8033
8161
  case 30:
8034
8162
  case "end":
8035
- return _context75.stop();
8163
+ return _context76.stop();
8036
8164
  }
8037
- }, _callee75, this, [[4, 24, 27, 30], [8, 16]]);
8165
+ }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8038
8166
  }));
8039
- function recomputeAndNotifyProductQuery(_x83) {
8167
+ function recomputeAndNotifyProductQuery(_x84) {
8040
8168
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8041
8169
  }
8042
8170
  return recomputeAndNotifyProductQuery;
@@ -8048,16 +8176,16 @@ var Server = /*#__PURE__*/function () {
8048
8176
  }, {
8049
8177
  key: "recomputeAndNotifyOrderQuery",
8050
8178
  value: (function () {
8051
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
8179
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8052
8180
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8053
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8054
- while (1) switch (_context76.prev = _context76.next) {
8181
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8182
+ while (1) switch (_context77.prev = _context77.next) {
8055
8183
  case 0:
8056
8184
  if (!(this.orderQuerySubscribers.size === 0)) {
8057
- _context76.next = 2;
8185
+ _context77.next = 2;
8058
8186
  break;
8059
8187
  }
8060
- return _context76.abrupt("return");
8188
+ return _context77.abrupt("return");
8061
8189
  case 2:
8062
8190
  notifyStartAt = Date.now();
8063
8191
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -8065,20 +8193,20 @@ var Server = /*#__PURE__*/function () {
8065
8193
  notifyStartAt: new Date(notifyStartAt).toISOString()
8066
8194
  });
8067
8195
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8068
- _context76.prev = 5;
8196
+ _context77.prev = 5;
8069
8197
  _iterator19.s();
8070
8198
  case 7:
8071
8199
  if ((_step19 = _iterator19.n()).done) {
8072
- _context76.next = 27;
8200
+ _context77.next = 27;
8073
8201
  break;
8074
8202
  }
8075
8203
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8076
- _context76.prev = 9;
8204
+ _context77.prev = 9;
8077
8205
  computeStartAt = Date.now();
8078
- _context76.next = 13;
8206
+ _context77.next = 13;
8079
8207
  return this.computeOrderQueryResult(subscriber.context);
8080
8208
  case 13:
8081
- result = _context76.sent;
8209
+ result = _context77.sent;
8082
8210
  computeEndAt = Date.now();
8083
8211
  callbackStartAt = Date.now();
8084
8212
  subscriber.callback(result);
@@ -8089,30 +8217,30 @@ var Server = /*#__PURE__*/function () {
8089
8217
  callbackDurationMs: callbackEndAt - callbackStartAt,
8090
8218
  totalDurationMs: callbackEndAt - computeStartAt
8091
8219
  });
8092
- _context76.next = 25;
8220
+ _context77.next = 25;
8093
8221
  break;
8094
8222
  case 21:
8095
- _context76.prev = 21;
8096
- _context76.t0 = _context76["catch"](9);
8097
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8223
+ _context77.prev = 21;
8224
+ _context77.t0 = _context77["catch"](9);
8225
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8098
8226
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
8099
8227
  subscriberId: subscriberId,
8100
8228
  error: errorMessage
8101
8229
  });
8102
8230
  case 25:
8103
- _context76.next = 7;
8231
+ _context77.next = 7;
8104
8232
  break;
8105
8233
  case 27:
8106
- _context76.next = 32;
8234
+ _context77.next = 32;
8107
8235
  break;
8108
8236
  case 29:
8109
- _context76.prev = 29;
8110
- _context76.t1 = _context76["catch"](5);
8111
- _iterator19.e(_context76.t1);
8237
+ _context77.prev = 29;
8238
+ _context77.t1 = _context77["catch"](5);
8239
+ _iterator19.e(_context77.t1);
8112
8240
  case 32:
8113
- _context76.prev = 32;
8241
+ _context77.prev = 32;
8114
8242
  _iterator19.f();
8115
- return _context76.finish(32);
8243
+ return _context77.finish(32);
8116
8244
  case 35:
8117
8245
  notifyEndAt = Date.now();
8118
8246
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8121,9 +8249,9 @@ var Server = /*#__PURE__*/function () {
8121
8249
  });
8122
8250
  case 37:
8123
8251
  case "end":
8124
- return _context76.stop();
8252
+ return _context77.stop();
8125
8253
  }
8126
- }, _callee76, this, [[5, 29, 32, 35], [9, 21]]);
8254
+ }, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
8127
8255
  }));
8128
8256
  function recomputeAndNotifyOrderQuery() {
8129
8257
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8141,7 +8269,7 @@ var Server = /*#__PURE__*/function () {
8141
8269
  }, {
8142
8270
  key: "notifySalesSearchSubscribers",
8143
8271
  value: function notifySalesSearchSubscribers(payload) {
8144
- var _this22 = this;
8272
+ var _this23 = this;
8145
8273
  if (this.salesSearchSubscribers.size === 0) return;
8146
8274
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8147
8275
  if (changedOrders.length === 0) {
@@ -8159,21 +8287,21 @@ var Server = /*#__PURE__*/function () {
8159
8287
  subscriber = _step20$value[1];
8160
8288
  try {
8161
8289
  var changedVisibleOrders = changedOrders.filter(function (order) {
8162
- var orderId = _this22.getSalesSearchOrderId(order);
8290
+ var orderId = _this23.getSalesSearchOrderId(order);
8163
8291
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8164
8292
  });
8165
8293
  if (changedVisibleOrders.length === 0) {
8166
8294
  return 1; // continue
8167
8295
  }
8168
- subscriber.callback(_this22.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8169
- _this22.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8296
+ subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8297
+ _this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8170
8298
  subscriberId: subscriberId,
8171
8299
  kind: subscriber.kind,
8172
8300
  count: changedVisibleOrders.length
8173
8301
  });
8174
8302
  } catch (error) {
8175
8303
  var errorMessage = error instanceof Error ? error.message : String(error);
8176
- _this22.logError('notifySalesSearchSubscribers: 推送失败', {
8304
+ _this23.logError('notifySalesSearchSubscribers: 推送失败', {
8177
8305
  subscriberId: subscriberId,
8178
8306
  error: errorMessage
8179
8307
  });
@@ -8264,67 +8392,67 @@ var Server = /*#__PURE__*/function () {
8264
8392
  }, {
8265
8393
  key: "recomputeAndNotifyBookingQuery",
8266
8394
  value: (function () {
8267
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8395
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8268
8396
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8269
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8270
- while (1) switch (_context77.prev = _context77.next) {
8397
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8398
+ while (1) switch (_context78.prev = _context78.next) {
8271
8399
  case 0:
8272
8400
  if (!(this.bookingQuerySubscribers.size === 0)) {
8273
- _context77.next = 2;
8401
+ _context78.next = 2;
8274
8402
  break;
8275
8403
  }
8276
- return _context77.abrupt("return");
8404
+ return _context78.abrupt("return");
8277
8405
  case 2:
8278
8406
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8279
8407
  subscriberCount: this.bookingQuerySubscribers.size
8280
8408
  });
8281
8409
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8282
- _context77.prev = 4;
8410
+ _context78.prev = 4;
8283
8411
  _iterator21.s();
8284
8412
  case 6:
8285
8413
  if ((_step21 = _iterator21.n()).done) {
8286
- _context77.next = 22;
8414
+ _context78.next = 22;
8287
8415
  break;
8288
8416
  }
8289
8417
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8290
- _context77.prev = 8;
8291
- _context77.next = 11;
8418
+ _context78.prev = 8;
8419
+ _context78.next = 11;
8292
8420
  return this.computeBookingQueryResult(subscriber.context);
8293
8421
  case 11:
8294
- result = _context77.sent;
8422
+ result = _context78.sent;
8295
8423
  subscriber.callback(result);
8296
8424
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8297
8425
  subscriberId: subscriberId
8298
8426
  });
8299
- _context77.next = 20;
8427
+ _context78.next = 20;
8300
8428
  break;
8301
8429
  case 16:
8302
- _context77.prev = 16;
8303
- _context77.t0 = _context77["catch"](8);
8304
- errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8430
+ _context78.prev = 16;
8431
+ _context78.t0 = _context78["catch"](8);
8432
+ errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8305
8433
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8306
8434
  subscriberId: subscriberId,
8307
8435
  error: errorMessage
8308
8436
  });
8309
8437
  case 20:
8310
- _context77.next = 6;
8438
+ _context78.next = 6;
8311
8439
  break;
8312
8440
  case 22:
8313
- _context77.next = 27;
8441
+ _context78.next = 27;
8314
8442
  break;
8315
8443
  case 24:
8316
- _context77.prev = 24;
8317
- _context77.t1 = _context77["catch"](4);
8318
- _iterator21.e(_context77.t1);
8444
+ _context78.prev = 24;
8445
+ _context78.t1 = _context78["catch"](4);
8446
+ _iterator21.e(_context78.t1);
8319
8447
  case 27:
8320
- _context77.prev = 27;
8448
+ _context78.prev = 27;
8321
8449
  _iterator21.f();
8322
- return _context77.finish(27);
8450
+ return _context78.finish(27);
8323
8451
  case 30:
8324
8452
  case "end":
8325
- return _context77.stop();
8453
+ return _context78.stop();
8326
8454
  }
8327
- }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8455
+ }, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
8328
8456
  }));
8329
8457
  function recomputeAndNotifyBookingQuery() {
8330
8458
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);