@pisell/pisellos 2.3.190 → 2.3.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/index.d.ts +2 -2
  3. package/dist/modules/BookingContext/index.js +55 -25
  4. package/dist/modules/BookingContext/types.d.ts +2 -0
  5. package/dist/modules/Order/index.d.ts +13 -5
  6. package/dist/modules/Order/index.js +1053 -554
  7. package/dist/modules/Order/types.d.ts +20 -1
  8. package/dist/modules/Order/types.js +4 -0
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/ProductList/clientDataVariants.js +6 -2
  11. package/dist/modules/ProductList/index.d.ts +2 -0
  12. package/dist/modules/ProductList/index.js +125 -39
  13. package/dist/modules/ResourcePlanner/planner.js +5 -0
  14. package/dist/server/index.d.ts +3 -0
  15. package/dist/server/index.js +1105 -976
  16. package/dist/shared/receipt/small-ticket.js +33 -5
  17. package/dist/solution/BaseSales/index.d.ts +14 -3
  18. package/dist/solution/BaseSales/index.js +285 -195
  19. package/dist/solution/BookingByStep/index.d.ts +2 -2
  20. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  21. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
  22. package/dist/solution/UnifiedBookingSales/index.d.ts +49 -1
  23. package/dist/solution/UnifiedBookingSales/index.js +2276 -902
  24. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  25. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
  26. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  27. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
  28. package/dist/solution/UnifiedBookingSales/types.d.ts +64 -1
  29. package/dist/solution/UnifiedBookingSales/types.js +7 -1
  30. package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  31. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
  32. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  33. package/lib/modules/BookingContext/index.d.ts +2 -2
  34. package/lib/modules/BookingContext/index.js +42 -10
  35. package/lib/modules/BookingContext/types.d.ts +2 -0
  36. package/lib/modules/Order/index.d.ts +13 -5
  37. package/lib/modules/Order/index.js +208 -7
  38. package/lib/modules/Order/types.d.ts +20 -1
  39. package/lib/modules/Order/types.js +2 -0
  40. package/lib/modules/Product/index.d.ts +1 -1
  41. package/lib/modules/ProductList/clientDataVariants.js +6 -2
  42. package/lib/modules/ProductList/index.d.ts +2 -0
  43. package/lib/modules/ProductList/index.js +56 -0
  44. package/lib/modules/ResourcePlanner/planner.js +4 -0
  45. package/lib/server/index.d.ts +3 -0
  46. package/lib/server/index.js +86 -5
  47. package/lib/shared/receipt/small-ticket.js +30 -5
  48. package/lib/solution/BaseSales/index.d.ts +14 -3
  49. package/lib/solution/BaseSales/index.js +67 -2
  50. package/lib/solution/BookingByStep/index.d.ts +2 -2
  51. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  52. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
  53. package/lib/solution/UnifiedBookingSales/index.d.ts +49 -1
  54. package/lib/solution/UnifiedBookingSales/index.js +872 -55
  55. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  56. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
  57. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  58. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
  59. package/lib/solution/UnifiedBookingSales/types.d.ts +64 -1
  60. package/lib/solution/UnifiedBookingSales/types.js +4 -1
  61. package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  62. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
  63. package/package.json +1 -1
@@ -127,6 +127,7 @@ var Server = /*#__PURE__*/function () {
127
127
  _defineProperty(this, "salesSearchSubscribers", new Map());
128
128
  _defineProperty(this, "deviceTaskActionsRegistered", false);
129
129
  _defineProperty(this, "localPaymentUpdateQueues", new Map());
130
+ _defineProperty(this, "paymentIdentityRefreshes", new Map());
130
131
  _defineProperty(this, "floorPlanQuerySubscribers", new Map());
131
132
  // 模块注册表 - 定义所有可用的模块配置
132
133
  _defineProperty(this, "moduleRegistry", {
@@ -430,11 +431,14 @@ var Server = /*#__PURE__*/function () {
430
431
  schedule_date: schedule_date,
431
432
  schedule_datetime: scheduleDatetime
432
433
  });
433
- return _context4.abrupt("return", _this.computeProductQueryResult({
434
+ return _context4.abrupt("return", _this.computeProductQueryResult(_objectSpread({
434
435
  schedule_date: schedule_date,
435
436
  schedule_datetime: scheduleDatetime,
436
437
  product_id: productId
437
- }));
438
+ }, data && _typeof(data) === 'object' ? {
439
+ customer_id: data.customer_id,
440
+ strategy_context: data.strategy_context
441
+ } : {})));
438
442
  case 17:
439
443
  case "end":
440
444
  return _context4.stop();
@@ -1659,7 +1663,7 @@ var Server = /*#__PURE__*/function () {
1659
1663
  }());
1660
1664
  _defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
1661
1665
  var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref54) {
1662
- var url, data, path, requestPath, lookup, localOrder, _enrichedOrder, remoteResult, enrichedOrder;
1666
+ var url, data, path, requestPath, lookup, localOrder, refreshedOrder, _enrichedOrder, remoteResult, enrichedOrder;
1663
1667
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1664
1668
  while (1) switch (_context24.prev = _context24.next) {
1665
1669
  case 0:
@@ -1699,7 +1703,7 @@ var Server = /*#__PURE__*/function () {
1699
1703
  });
1700
1704
  case 10:
1701
1705
  if (_this.shouldForceRemoteSalesDetail(data)) {
1702
- _context24.next = 20;
1706
+ _context24.next = 23;
1703
1707
  break;
1704
1708
  }
1705
1709
  _context24.next = 13;
@@ -1707,12 +1711,16 @@ var Server = /*#__PURE__*/function () {
1707
1711
  case 13:
1708
1712
  localOrder = _context24.sent;
1709
1713
  if (!localOrder) {
1710
- _context24.next = 20;
1714
+ _context24.next = 23;
1711
1715
  break;
1712
1716
  }
1713
1717
  _context24.next = 17;
1714
- return _this.withSalesDetailProductSnapshots(localOrder);
1718
+ return _this.refreshMissingPaymentIds(localOrder, 'handleOrderSalesDetail');
1715
1719
  case 17:
1720
+ refreshedOrder = _context24.sent;
1721
+ _context24.next = 20;
1722
+ return _this.withSalesDetailProductSnapshots(refreshedOrder);
1723
+ case 20:
1716
1724
  _enrichedOrder = _context24.sent;
1717
1725
  _this.logInfo('handleOrderSalesDetail: 命中本地订单', {
1718
1726
  lookup: lookup
@@ -1723,13 +1731,13 @@ var Server = /*#__PURE__*/function () {
1723
1731
  message: '',
1724
1732
  data: _enrichedOrder
1725
1733
  });
1726
- case 20:
1727
- _context24.next = 22;
1734
+ case 23:
1735
+ _context24.next = 25;
1728
1736
  return _this.fetchAndPersistSalesOrderByLookup(lookup, data, 'handleOrderSalesDetail');
1729
- case 22:
1737
+ case 25:
1730
1738
  remoteResult = _context24.sent;
1731
1739
  if (remoteResult.order) {
1732
- _context24.next = 25;
1740
+ _context24.next = 28;
1733
1741
  break;
1734
1742
  }
1735
1743
  return _context24.abrupt("return", {
@@ -1738,10 +1746,10 @@ var Server = /*#__PURE__*/function () {
1738
1746
  message: remoteResult.message,
1739
1747
  data: null
1740
1748
  });
1741
- case 25:
1742
- _context24.next = 27;
1749
+ case 28:
1750
+ _context24.next = 30;
1743
1751
  return _this.withSalesDetailProductSnapshots(remoteResult.order);
1744
- case 27:
1752
+ case 30:
1745
1753
  enrichedOrder = _context24.sent;
1746
1754
  return _context24.abrupt("return", {
1747
1755
  code: 200,
@@ -1749,7 +1757,7 @@ var Server = /*#__PURE__*/function () {
1749
1757
  message: '',
1750
1758
  data: enrichedOrder
1751
1759
  });
1752
- case 29:
1760
+ case 32:
1753
1761
  case "end":
1754
1762
  return _context24.stop();
1755
1763
  }
@@ -2918,6 +2926,7 @@ var Server = /*#__PURE__*/function () {
2918
2926
  key: "persistSyncedCheckoutOrder",
2919
2927
  value: function () {
2920
2928
  var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2929
+ var _this6 = this;
2921
2930
  var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number, _external_sale_number2, _syncedOrder$order_id, _syncedOrder, patch, result;
2922
2931
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2923
2932
  while (1) switch (_context36.prev = _context36.next) {
@@ -2985,8 +2994,18 @@ var Server = /*#__PURE__*/function () {
2985
2994
  order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
2986
2995
  });
2987
2996
  case 20:
2997
+ if (syncedOrder) {
2998
+ // 不占用 sync_sales 的执行超时:慢速补取不能让已成功的 checkout 被再次提交。
2999
+ void this.refreshMissingPaymentIds(syncedOrder, title).catch(function (error) {
3000
+ var _syncedOrder2;
3001
+ _this6.logWarning("".concat(title, ": \u540E\u53F0\u8865\u9F50\u4ED8\u6B3E ID \u5931\u8D25"), {
3002
+ order_id: (_syncedOrder2 = syncedOrder) === null || _syncedOrder2 === void 0 ? void 0 : _syncedOrder2.order_id,
3003
+ error: _this6.getUnknownErrorMessage(error)
3004
+ });
3005
+ });
3006
+ }
2988
3007
  return _context36.abrupt("return", syncedOrder);
2989
- case 21:
3008
+ case 22:
2990
3009
  case "end":
2991
3010
  return _context36.stop();
2992
3011
  }
@@ -2997,69 +3016,131 @@ var Server = /*#__PURE__*/function () {
2997
3016
  }
2998
3017
  return persistSyncedCheckoutOrder;
2999
3018
  }()
3019
+ }, {
3020
+ key: "hasPaidPaymentWithoutId",
3021
+ value: function hasPaidPaymentWithoutId(order) {
3022
+ return ((order === null || order === void 0 ? void 0 : order.payments) || []).some(function (payment) {
3023
+ var _payment$order_paymen;
3024
+ var paymentId = (_payment$order_paymen = payment.order_payment_id) !== null && _payment$order_paymen !== void 0 ? _payment$order_paymen : payment.id;
3025
+ return payment.status === 'paid' && (paymentId === undefined || paymentId === null || String(paymentId).trim() === '');
3026
+ });
3027
+ }
3028
+ }, {
3029
+ key: "refreshMissingPaymentIds",
3030
+ value: function () {
3031
+ var _refreshMissingPaymentIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order, title) {
3032
+ var key, refresh, _this$order3, _this$order3$getLocal, result, refreshedOrder;
3033
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3034
+ while (1) switch (_context37.prev = _context37.next) {
3035
+ case 0:
3036
+ if (!(!this.hasPaidPaymentWithoutId(order) || !(Number(order.order_id) > 0) || Number(order.need_sync || 0) === 1 || Number(order.is_draft_order || 0) === 1)) {
3037
+ _context37.next = 2;
3038
+ break;
3039
+ }
3040
+ return _context37.abrupt("return", order);
3041
+ case 2:
3042
+ key = String(order.order_id);
3043
+ refresh = this.paymentIdentityRefreshes.get(key);
3044
+ if (!refresh) {
3045
+ // checkout 已成功,只补取付款身份;补取失败不能让 sync_sales 重试 checkout。
3046
+ refresh = this.fetchAndPersistSalesOrderByLookup(key, {
3047
+ forceRemote: true
3048
+ }, "".concat(title, ".paymentIdentityRefresh"), order);
3049
+ this.paymentIdentityRefreshes.set(key, refresh);
3050
+ }
3051
+ _context37.prev = 5;
3052
+ _context37.next = 8;
3053
+ return refresh;
3054
+ case 8:
3055
+ result = _context37.sent;
3056
+ refreshedOrder = result.order || ((_this$order3 = this.order) === null || _this$order3 === void 0 || (_this$order3$getLocal = _this$order3.getLocalOrderFromMemoryByLookup) === null || _this$order3$getLocal === void 0 ? void 0 : _this$order3$getLocal.call(_this$order3, key)) || order;
3057
+ if (this.hasPaidPaymentWithoutId(refreshedOrder)) {
3058
+ this.logWarning("".concat(title, ": \u4ED8\u6B3E ID \u5C1A\u672A\u8865\u9F50\uFF0C\u4E0B\u6B21\u8BFB\u53D6\u8BE6\u60C5\u91CD\u8BD5"), {
3059
+ order_id: order.order_id,
3060
+ code: result.code
3061
+ });
3062
+ }
3063
+ return _context37.abrupt("return", refreshedOrder);
3064
+ case 12:
3065
+ _context37.prev = 12;
3066
+ if (this.paymentIdentityRefreshes.get(key) === refresh) {
3067
+ this.paymentIdentityRefreshes.delete(key);
3068
+ }
3069
+ return _context37.finish(12);
3070
+ case 15:
3071
+ case "end":
3072
+ return _context37.stop();
3073
+ }
3074
+ }, _callee37, this, [[5,, 12, 15]]);
3075
+ }));
3076
+ function refreshMissingPaymentIds(_x39, _x40) {
3077
+ return _refreshMissingPaymentIds.apply(this, arguments);
3078
+ }
3079
+ return refreshMissingPaymentIds;
3080
+ }()
3000
3081
  /**
3001
3082
  * 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
3002
3083
  */
3003
3084
  }, {
3004
3085
  key: "setupProductsQuotationPriceBridge",
3005
3086
  value: (function () {
3006
- var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3007
- var _this6 = this;
3087
+ var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3088
+ var _this7 = this;
3008
3089
  var _this$core$context, errorMessage;
3009
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3010
- while (1) switch (_context37.prev = _context37.next) {
3090
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3091
+ while (1) switch (_context38.prev = _context38.next) {
3011
3092
  case 0:
3012
3093
  if (this.products) {
3013
- _context37.next = 3;
3094
+ _context38.next = 3;
3014
3095
  break;
3015
3096
  }
3016
3097
  this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
3017
- return _context37.abrupt("return");
3098
+ return _context38.abrupt("return");
3018
3099
  case 3:
3019
3100
  if (this.schedule) {
3020
- _context37.next = 6;
3101
+ _context38.next = 6;
3021
3102
  break;
3022
3103
  }
3023
3104
  this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
3024
- return _context37.abrupt("return");
3105
+ return _context38.abrupt("return");
3025
3106
  case 6:
3026
- _context37.prev = 6;
3107
+ _context38.prev = 6;
3027
3108
  this.products.clearPriceCache();
3028
- _context37.next = 10;
3109
+ _context38.next = 10;
3029
3110
  return this.products.setupQuotationPriceBridge({
3030
3111
  scheduleModule: this.schedule,
3031
3112
  channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
3032
3113
  onQuotationUpdated: function onQuotationUpdated() {
3033
- void _this6.recomputeAndNotifyProductQuery();
3114
+ void _this7.recomputeAndNotifyProductQuery();
3034
3115
  }
3035
3116
  });
3036
3117
  case 10:
3037
3118
  // Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
3038
3119
  // 远端刷新转为后台校准,避免二次启动重复阻塞请求。
3039
3120
  void this.schedule.loadAllSchedule().then(function () {
3040
- var _this6$products;
3041
- (_this6$products = _this6.products) === null || _this6$products === void 0 || _this6$products.clearPriceCache();
3042
- void _this6.recomputeAndNotifyProductQuery();
3121
+ var _this7$products;
3122
+ (_this7$products = _this7.products) === null || _this7$products === void 0 || _this7$products.clearPriceCache();
3123
+ void _this7.recomputeAndNotifyProductQuery();
3043
3124
  }).catch(function (error) {
3044
- _this6.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
3125
+ _this7.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
3045
3126
  error: error instanceof Error ? error.message : String(error)
3046
3127
  });
3047
3128
  });
3048
3129
  this.logInfo('Products 报价单价格桥接初始化完成');
3049
- _context37.next = 18;
3130
+ _context38.next = 18;
3050
3131
  break;
3051
3132
  case 14:
3052
- _context37.prev = 14;
3053
- _context37.t0 = _context37["catch"](6);
3054
- errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3133
+ _context38.prev = 14;
3134
+ _context38.t0 = _context38["catch"](6);
3135
+ errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3055
3136
  this.logError('Products 报价单价格桥接初始化失败', {
3056
3137
  error: errorMessage
3057
3138
  });
3058
3139
  case 18:
3059
3140
  case "end":
3060
- return _context37.stop();
3141
+ return _context38.stop();
3061
3142
  }
3062
- }, _callee37, this, [[6, 14]]);
3143
+ }, _callee38, this, [[6, 14]]);
3063
3144
  }));
3064
3145
  function setupProductsQuotationPriceBridge() {
3065
3146
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -3128,32 +3209,32 @@ var Server = /*#__PURE__*/function () {
3128
3209
  }, {
3129
3210
  key: "refreshProductsInBackground",
3130
3211
  value: (function () {
3131
- var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3212
+ var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3132
3213
  var options,
3133
3214
  trigger,
3134
3215
  startTime,
3135
3216
  duration,
3136
3217
  _duration2,
3137
3218
  errorMessage,
3138
- _args38 = arguments;
3139
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3140
- while (1) switch (_context38.prev = _context38.next) {
3219
+ _args39 = arguments;
3220
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3221
+ while (1) switch (_context39.prev = _context39.next) {
3141
3222
  case 0:
3142
- options = _args38.length > 0 && _args38[0] !== undefined ? _args38[0] : {};
3223
+ options = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : {};
3143
3224
  if (this.products) {
3144
- _context38.next = 4;
3225
+ _context39.next = 4;
3145
3226
  break;
3146
3227
  }
3147
3228
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
3148
- return _context38.abrupt("return");
3229
+ return _context39.abrupt("return");
3149
3230
  case 4:
3150
3231
  trigger = options.trigger || 'background';
3151
3232
  this.logInfo('refreshProductsInBackground 开始', {
3152
3233
  trigger: trigger
3153
3234
  });
3154
3235
  startTime = Date.now();
3155
- _context38.prev = 7;
3156
- _context38.next = 10;
3236
+ _context39.prev = 7;
3237
+ _context39.next = 10;
3157
3238
  return this.products.silentRefresh({
3158
3239
  trigger: trigger
3159
3240
  });
@@ -3163,14 +3244,14 @@ var Server = /*#__PURE__*/function () {
3163
3244
  trigger: trigger,
3164
3245
  duration: "".concat(duration, "ms")
3165
3246
  });
3166
- _context38.next = 20;
3247
+ _context39.next = 20;
3167
3248
  break;
3168
3249
  case 14:
3169
- _context38.prev = 14;
3170
- _context38.t0 = _context38["catch"](7);
3250
+ _context39.prev = 14;
3251
+ _context39.t0 = _context39["catch"](7);
3171
3252
  _duration2 = Date.now() - startTime;
3172
- errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3173
- console.error('[Server] refreshProductsInBackground 失败:', _context38.t0);
3253
+ errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3254
+ console.error('[Server] refreshProductsInBackground 失败:', _context39.t0);
3174
3255
  this.logError('refreshProductsInBackground 失败', {
3175
3256
  trigger: trigger,
3176
3257
  duration: "".concat(_duration2, "ms"),
@@ -3178,9 +3259,9 @@ var Server = /*#__PURE__*/function () {
3178
3259
  });
3179
3260
  case 20:
3180
3261
  case "end":
3181
- return _context38.stop();
3262
+ return _context39.stop();
3182
3263
  }
3183
- }, _callee38, this, [[7, 14]]);
3264
+ }, _callee39, this, [[7, 14]]);
3184
3265
  }));
3185
3266
  function refreshProductsInBackground() {
3186
3267
  return _refreshProductsInBackground.apply(this, arguments);
@@ -3196,32 +3277,32 @@ var Server = /*#__PURE__*/function () {
3196
3277
  }, {
3197
3278
  key: "refreshOrdersInBackground",
3198
3279
  value: (function () {
3199
- var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3280
+ var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3200
3281
  var options,
3201
3282
  trigger,
3202
3283
  startTime,
3203
3284
  duration,
3204
3285
  _duration3,
3205
3286
  errorMessage,
3206
- _args39 = arguments;
3207
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3208
- while (1) switch (_context39.prev = _context39.next) {
3287
+ _args40 = arguments;
3288
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3289
+ while (1) switch (_context40.prev = _context40.next) {
3209
3290
  case 0:
3210
- options = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : {};
3291
+ options = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : {};
3211
3292
  if (this.order) {
3212
- _context39.next = 4;
3293
+ _context40.next = 4;
3213
3294
  break;
3214
3295
  }
3215
3296
  this.logWarning('refreshOrdersInBackground: Order 模块未注册');
3216
- return _context39.abrupt("return");
3297
+ return _context40.abrupt("return");
3217
3298
  case 4:
3218
3299
  trigger = options.trigger || 'background';
3219
3300
  this.logInfo('refreshOrdersInBackground 开始', {
3220
3301
  trigger: trigger
3221
3302
  });
3222
3303
  startTime = Date.now();
3223
- _context39.prev = 7;
3224
- _context39.next = 10;
3304
+ _context40.prev = 7;
3305
+ _context40.next = 10;
3225
3306
  return this.order.silentRefresh({
3226
3307
  trigger: trigger
3227
3308
  });
@@ -3231,14 +3312,14 @@ var Server = /*#__PURE__*/function () {
3231
3312
  trigger: trigger,
3232
3313
  duration: "".concat(duration, "ms")
3233
3314
  });
3234
- _context39.next = 20;
3315
+ _context40.next = 20;
3235
3316
  break;
3236
3317
  case 14:
3237
- _context39.prev = 14;
3238
- _context39.t0 = _context39["catch"](7);
3318
+ _context40.prev = 14;
3319
+ _context40.t0 = _context40["catch"](7);
3239
3320
  _duration3 = Date.now() - startTime;
3240
- errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3241
- console.error('[Server] refreshOrdersInBackground 失败:', _context39.t0);
3321
+ errorMessage = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
3322
+ console.error('[Server] refreshOrdersInBackground 失败:', _context40.t0);
3242
3323
  this.logError('refreshOrdersInBackground 失败', {
3243
3324
  trigger: trigger,
3244
3325
  duration: "".concat(_duration3, "ms"),
@@ -3246,9 +3327,9 @@ var Server = /*#__PURE__*/function () {
3246
3327
  });
3247
3328
  case 20:
3248
3329
  case "end":
3249
- return _context39.stop();
3330
+ return _context40.stop();
3250
3331
  }
3251
- }, _callee39, this, [[7, 14]]);
3332
+ }, _callee40, this, [[7, 14]]);
3252
3333
  }));
3253
3334
  function refreshOrdersInBackground() {
3254
3335
  return _refreshOrdersInBackground.apply(this, arguments);
@@ -3264,23 +3345,23 @@ var Server = /*#__PURE__*/function () {
3264
3345
  }, {
3265
3346
  key: "checkRemoteOrderProductMembership",
3266
3347
  value: (function () {
3267
- var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(orderId) {
3348
+ var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(orderId) {
3268
3349
  var normalizedOrderId, error, startTime, freshOrders, freshOrder;
3269
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3270
- while (1) switch (_context40.prev = _context40.next) {
3350
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3351
+ while (1) switch (_context41.prev = _context41.next) {
3271
3352
  case 0:
3272
3353
  normalizedOrderId = String(orderId !== null && orderId !== void 0 ? orderId : '').trim();
3273
3354
  if (!(!normalizedOrderId || normalizedOrderId.startsWith('local_order'))) {
3274
- _context40.next = 4;
3355
+ _context41.next = 4;
3275
3356
  break;
3276
3357
  }
3277
3358
  this.logInfo('checkRemoteOrderProductMembership: 跳过非正式订单', {
3278
3359
  orderId: orderId
3279
3360
  });
3280
- return _context40.abrupt("return");
3361
+ return _context41.abrupt("return");
3281
3362
  case 4:
3282
3363
  if (this.order) {
3283
- _context40.next = 8;
3364
+ _context41.next = 8;
3284
3365
  break;
3285
3366
  }
3286
3367
  error = new Error('Order 模块未注册');
@@ -3293,45 +3374,45 @@ var Server = /*#__PURE__*/function () {
3293
3374
  orderId: normalizedOrderId
3294
3375
  });
3295
3376
  startTime = Date.now();
3296
- _context40.prev = 10;
3297
- _context40.next = 13;
3377
+ _context41.prev = 10;
3378
+ _context41.next = 13;
3298
3379
  return this.order.fetchOrdersByHttp([normalizedOrderId]);
3299
3380
  case 13:
3300
- freshOrders = _context40.sent;
3381
+ freshOrders = _context41.sent;
3301
3382
  freshOrder = freshOrders.find(function (order) {
3302
3383
  return String(order === null || order === void 0 ? void 0 : order.order_id) === normalizedOrderId;
3303
3384
  });
3304
3385
  if (freshOrder) {
3305
- _context40.next = 17;
3386
+ _context41.next = 17;
3306
3387
  break;
3307
3388
  }
3308
3389
  throw new Error('Server 未返回目标订单最新快照');
3309
3390
  case 17:
3310
- _context40.next = 19;
3391
+ _context41.next = 19;
3311
3392
  return this.order.upsertOrdersFromRemote([freshOrder], 'manual.editOpenRemoteCheck');
3312
3393
  case 19:
3313
3394
  this.logInfo('checkRemoteOrderProductMembership 完成', {
3314
3395
  orderId: normalizedOrderId,
3315
3396
  duration: "".concat(Date.now() - startTime, "ms")
3316
3397
  });
3317
- _context40.next = 26;
3398
+ _context41.next = 26;
3318
3399
  break;
3319
3400
  case 22:
3320
- _context40.prev = 22;
3321
- _context40.t0 = _context40["catch"](10);
3401
+ _context41.prev = 22;
3402
+ _context41.t0 = _context41["catch"](10);
3322
3403
  this.logError('checkRemoteOrderProductMembership 失败', {
3323
3404
  orderId: normalizedOrderId,
3324
3405
  duration: "".concat(Date.now() - startTime, "ms"),
3325
- error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3406
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
3326
3407
  });
3327
- throw _context40.t0;
3408
+ throw _context41.t0;
3328
3409
  case 26:
3329
3410
  case "end":
3330
- return _context40.stop();
3411
+ return _context41.stop();
3331
3412
  }
3332
- }, _callee40, this, [[10, 22]]);
3413
+ }, _callee41, this, [[10, 22]]);
3333
3414
  }));
3334
- function checkRemoteOrderProductMembership(_x39) {
3415
+ function checkRemoteOrderProductMembership(_x41) {
3335
3416
  return _checkRemoteOrderProductMembership.apply(this, arguments);
3336
3417
  }
3337
3418
  return checkRemoteOrderProductMembership;
@@ -3344,10 +3425,10 @@ var Server = /*#__PURE__*/function () {
3344
3425
  }, {
3345
3426
  key: "clearAllIndexDB",
3346
3427
  value: (function () {
3347
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3428
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3348
3429
  var clearTasks, moduleNames, errorMessage;
3349
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3350
- while (1) switch (_context41.prev = _context41.next) {
3430
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3431
+ while (1) switch (_context42.prev = _context42.next) {
3351
3432
  case 0:
3352
3433
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
3353
3434
  clearTasks = [];
@@ -3381,40 +3462,40 @@ var Server = /*#__PURE__*/function () {
3381
3462
  moduleNames.push('FloorPlan');
3382
3463
  }
3383
3464
  if (!(clearTasks.length === 0)) {
3384
- _context41.next = 14;
3465
+ _context42.next = 14;
3385
3466
  break;
3386
3467
  }
3387
3468
  console.warn('[Server] 没有找到已注册的模块,无需清空');
3388
3469
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
3389
- return _context41.abrupt("return");
3470
+ return _context42.abrupt("return");
3390
3471
  case 14:
3391
3472
  this.logInfo('准备清空模块缓存', {
3392
3473
  moduleNames: moduleNames
3393
3474
  });
3394
- _context41.prev = 15;
3395
- _context41.next = 18;
3475
+ _context42.prev = 15;
3476
+ _context42.next = 18;
3396
3477
  return Promise.all(clearTasks);
3397
3478
  case 18:
3398
3479
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
3399
3480
  moduleNames: moduleNames
3400
3481
  });
3401
- _context41.next = 27;
3482
+ _context42.next = 27;
3402
3483
  break;
3403
3484
  case 21:
3404
- _context41.prev = 21;
3405
- _context41.t0 = _context41["catch"](15);
3406
- errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
3407
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context41.t0);
3485
+ _context42.prev = 21;
3486
+ _context42.t0 = _context42["catch"](15);
3487
+ errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3488
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context42.t0);
3408
3489
  this.logError('清空 IndexedDB 缓存时发生错误', {
3409
3490
  moduleNames: moduleNames,
3410
3491
  error: errorMessage
3411
3492
  });
3412
- throw _context41.t0;
3493
+ throw _context42.t0;
3413
3494
  case 27:
3414
3495
  case "end":
3415
- return _context41.stop();
3496
+ return _context42.stop();
3416
3497
  }
3417
- }, _callee41, this, [[15, 21]]);
3498
+ }, _callee42, this, [[15, 21]]);
3418
3499
  }));
3419
3500
  function clearAllIndexDB() {
3420
3501
  return _clearAllIndexDB.apply(this, arguments);
@@ -3489,10 +3570,10 @@ var Server = /*#__PURE__*/function () {
3489
3570
  }, {
3490
3571
  key: "handleRoute",
3491
3572
  value: (function () {
3492
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(method, path, params) {
3573
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(method, path, params) {
3493
3574
  var startTime, handler, result, duration, _duration4, errorMessage;
3494
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3495
- while (1) switch (_context42.prev = _context42.next) {
3575
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3576
+ while (1) switch (_context43.prev = _context43.next) {
3496
3577
  case 0:
3497
3578
  startTime = Date.now();
3498
3579
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3503,7 +3584,7 @@ var Server = /*#__PURE__*/function () {
3503
3584
  });
3504
3585
  handler = this.getRouteHandler(method, path);
3505
3586
  if (handler) {
3506
- _context42.next = 6;
3587
+ _context43.next = 6;
3507
3588
  break;
3508
3589
  }
3509
3590
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3512,13 +3593,13 @@ var Server = /*#__PURE__*/function () {
3512
3593
  });
3513
3594
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
3514
3595
  case 6:
3515
- _context42.prev = 6;
3516
- _context42.next = 9;
3596
+ _context43.prev = 6;
3597
+ _context43.next = 9;
3517
3598
  return handler(_objectSpread(_objectSpread({}, params), {}, {
3518
3599
  path: path
3519
3600
  }));
3520
3601
  case 9:
3521
- result = _context42.sent;
3602
+ result = _context43.sent;
3522
3603
  duration = Date.now() - startTime;
3523
3604
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
3524
3605
  method: method.toUpperCase(),
@@ -3527,12 +3608,12 @@ var Server = /*#__PURE__*/function () {
3527
3608
  resultCode: result === null || result === void 0 ? void 0 : result.code,
3528
3609
  resultStatus: result === null || result === void 0 ? void 0 : result.status
3529
3610
  });
3530
- return _context42.abrupt("return", result);
3611
+ return _context43.abrupt("return", result);
3531
3612
  case 15:
3532
- _context42.prev = 15;
3533
- _context42.t0 = _context42["catch"](6);
3613
+ _context43.prev = 15;
3614
+ _context43.t0 = _context43["catch"](6);
3534
3615
  _duration4 = Date.now() - startTime;
3535
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3616
+ errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3536
3617
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
3537
3618
  method: method.toUpperCase(),
3538
3619
  path: path,
@@ -3540,15 +3621,15 @@ var Server = /*#__PURE__*/function () {
3540
3621
  error: errorMessage,
3541
3622
  data: params.data
3542
3623
  });
3543
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context42.t0);
3544
- throw _context42.t0;
3624
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context43.t0);
3625
+ throw _context43.t0;
3545
3626
  case 22:
3546
3627
  case "end":
3547
- return _context42.stop();
3628
+ return _context43.stop();
3548
3629
  }
3549
- }, _callee42, this, [[6, 15]]);
3630
+ }, _callee43, this, [[6, 15]]);
3550
3631
  }));
3551
- function handleRoute(_x40, _x41, _x42) {
3632
+ function handleRoute(_x42, _x43, _x44) {
3552
3633
  return _handleRoute.apply(this, arguments);
3553
3634
  }
3554
3635
  return handleRoute;
@@ -3560,10 +3641,10 @@ var Server = /*#__PURE__*/function () {
3560
3641
  }, {
3561
3642
  key: "getAllRoutes",
3562
3643
  value: function getAllRoutes() {
3563
- var _this7 = this;
3644
+ var _this8 = this;
3564
3645
  var routes = [];
3565
3646
  ['get', 'post', 'put', 'remove'].forEach(function (method) {
3566
- Object.keys(_this7.router[method]).forEach(function (path) {
3647
+ Object.keys(_this8.router[method]).forEach(function (path) {
3567
3648
  routes.push({
3568
3649
  method: method,
3569
3650
  path: path
@@ -3581,7 +3662,7 @@ var Server = /*#__PURE__*/function () {
3581
3662
  }, {
3582
3663
  key: "registerServerRoutes",
3583
3664
  value: function registerServerRoutes() {
3584
- var _this8 = this;
3665
+ var _this9 = this;
3585
3666
  this.registerRoutes([{
3586
3667
  method: 'post',
3587
3668
  path: '/shop/product/query',
@@ -3686,28 +3767,28 @@ var Server = /*#__PURE__*/function () {
3686
3767
  method: 'post',
3687
3768
  path: '/shop/local/orderPaymentReadiness',
3688
3769
  handler: function () {
3689
- var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(_ref64) {
3690
- var _this8$order;
3770
+ var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref64) {
3771
+ var _this9$order;
3691
3772
  var data;
3692
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3693
- while (1) switch (_context43.prev = _context43.next) {
3773
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3774
+ while (1) switch (_context44.prev = _context44.next) {
3694
3775
  case 0:
3695
3776
  data = _ref64.data;
3696
- _context43.next = 3;
3697
- return (_this8$order = _this8.order) === null || _this8$order === void 0 ? void 0 : _this8$order.getLocalOrderForPaymentReadiness(data === null || data === void 0 ? void 0 : data.sale_id);
3777
+ _context44.next = 3;
3778
+ return (_this9$order = _this9.order) === null || _this9$order === void 0 ? void 0 : _this9$order.getLocalOrderForPaymentReadiness(data === null || data === void 0 ? void 0 : data.sale_id);
3698
3779
  case 3:
3699
- _context43.t0 = _context43.sent;
3700
- return _context43.abrupt("return", {
3780
+ _context44.t0 = _context44.sent;
3781
+ return _context44.abrupt("return", {
3701
3782
  code: 200,
3702
- data: _context43.t0
3783
+ data: _context44.t0
3703
3784
  });
3704
3785
  case 5:
3705
3786
  case "end":
3706
- return _context43.stop();
3787
+ return _context44.stop();
3707
3788
  }
3708
- }, _callee43);
3789
+ }, _callee44);
3709
3790
  }));
3710
- function handler(_x43) {
3791
+ function handler(_x45) {
3711
3792
  return _handler.apply(this, arguments);
3712
3793
  }
3713
3794
  return handler;
@@ -3734,58 +3815,58 @@ var Server = /*#__PURE__*/function () {
3734
3815
  }, {
3735
3816
  key: "getPaymentRouteModule",
3736
3817
  value: function () {
3737
- var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3738
- var _this9 = this;
3739
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3740
- while (1) switch (_context45.prev = _context45.next) {
3818
+ var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3819
+ var _this10 = this;
3820
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3821
+ while (1) switch (_context46.prev = _context46.next) {
3741
3822
  case 0:
3742
3823
  if (!this.payment) {
3743
- _context45.next = 2;
3824
+ _context46.next = 2;
3744
3825
  break;
3745
3826
  }
3746
- return _context45.abrupt("return", this.payment);
3827
+ return _context46.abrupt("return", this.payment);
3747
3828
  case 2:
3748
3829
  if (!this.paymentRouteModule) {
3749
- _context45.next = 4;
3830
+ _context46.next = 4;
3750
3831
  break;
3751
3832
  }
3752
- return _context45.abrupt("return", this.paymentRouteModule);
3833
+ return _context46.abrupt("return", this.paymentRouteModule);
3753
3834
  case 4:
3754
3835
  if (!this.paymentRouteModuleInFlight) {
3755
- _context45.next = 6;
3836
+ _context46.next = 6;
3756
3837
  break;
3757
3838
  }
3758
- return _context45.abrupt("return", this.paymentRouteModuleInFlight);
3839
+ return _context46.abrupt("return", this.paymentRouteModuleInFlight);
3759
3840
  case 6:
3760
- this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3841
+ this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3761
3842
  var module;
3762
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3763
- while (1) switch (_context44.prev = _context44.next) {
3843
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3844
+ while (1) switch (_context45.prev = _context45.next) {
3764
3845
  case 0:
3765
3846
  module = new PaymentServerModule('server_payment_route', '1.0.0');
3766
- _context44.next = 3;
3767
- return module.initialize(_this9.core, {
3847
+ _context45.next = 3;
3848
+ return module.initialize(_this10.core, {
3768
3849
  store: {
3769
3850
  payMethods: []
3770
3851
  }
3771
3852
  });
3772
3853
  case 3:
3773
- _this9.paymentRouteModule = module;
3774
- return _context44.abrupt("return", module);
3854
+ _this10.paymentRouteModule = module;
3855
+ return _context45.abrupt("return", module);
3775
3856
  case 5:
3776
3857
  case "end":
3777
- return _context44.stop();
3858
+ return _context45.stop();
3778
3859
  }
3779
- }, _callee44);
3860
+ }, _callee45);
3780
3861
  }))().finally(function () {
3781
- _this9.paymentRouteModuleInFlight = undefined;
3862
+ _this10.paymentRouteModuleInFlight = undefined;
3782
3863
  });
3783
- return _context45.abrupt("return", this.paymentRouteModuleInFlight);
3864
+ return _context46.abrupt("return", this.paymentRouteModuleInFlight);
3784
3865
  case 8:
3785
3866
  case "end":
3786
- return _context45.stop();
3867
+ return _context46.stop();
3787
3868
  }
3788
- }, _callee45, this);
3869
+ }, _callee46, this);
3789
3870
  }));
3790
3871
  function getPaymentRouteModule() {
3791
3872
  return _getPaymentRouteModule.apply(this, arguments);
@@ -3795,19 +3876,19 @@ var Server = /*#__PURE__*/function () {
3795
3876
  }, {
3796
3877
  key: "fetchQuotationAvailableFromAPI",
3797
3878
  value: function () {
3798
- var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
3879
+ var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
3799
3880
  var _this$app6;
3800
3881
  var requester;
3801
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3802
- while (1) switch (_context46.prev = _context46.next) {
3882
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3883
+ while (1) switch (_context47.prev = _context47.next) {
3803
3884
  case 0:
3804
3885
  requester = ((_this$app6 = this.app) === null || _this$app6 === void 0 ? void 0 : _this$app6.request) || this.core.getPlugin('request');
3805
3886
  if (requester !== null && requester !== void 0 && requester.get) {
3806
- _context46.next = 4;
3887
+ _context47.next = 4;
3807
3888
  break;
3808
3889
  }
3809
3890
  this.logError('fetchQuotationAvailableFromAPI: request 不可用');
3810
- return _context46.abrupt("return", {
3891
+ return _context47.abrupt("return", {
3811
3892
  code: 500,
3812
3893
  message: 'request 不可用',
3813
3894
  data: {
@@ -3816,14 +3897,14 @@ var Server = /*#__PURE__*/function () {
3816
3897
  status: false
3817
3898
  });
3818
3899
  case 4:
3819
- return _context46.abrupt("return", requester.get('/shop/quotation/available', data));
3900
+ return _context47.abrupt("return", requester.get('/shop/quotation/available', data));
3820
3901
  case 5:
3821
3902
  case "end":
3822
- return _context46.stop();
3903
+ return _context47.stop();
3823
3904
  }
3824
- }, _callee46, this);
3905
+ }, _callee47, this);
3825
3906
  }));
3826
- function fetchQuotationAvailableFromAPI(_x44) {
3907
+ function fetchQuotationAvailableFromAPI(_x46) {
3827
3908
  return _fetchQuotationAvailableFromAPI.apply(this, arguments);
3828
3909
  }
3829
3910
  return fetchQuotationAvailableFromAPI;
@@ -3954,7 +4035,7 @@ var Server = /*#__PURE__*/function () {
3954
4035
  }, {
3955
4036
  key: "scheduleSubscriberTimePointReloads",
3956
4037
  value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3957
- var _this10 = this;
4038
+ var _this11 = this;
3958
4039
  var subscriber = this.productQuerySubscribers.get(subscriberId);
3959
4040
  if (!subscriber || !timePoints.length) return;
3960
4041
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
@@ -3975,7 +4056,7 @@ var Server = /*#__PURE__*/function () {
3975
4056
  setInterval(function () {
3976
4057
  var currentTime = dayjs().format('HH:mm');
3977
4058
  if (timePoints.includes(currentTime)) {
3978
- _this10.onScheduleTimePointTimerFire(subscriberId);
4059
+ _this11.onScheduleTimePointTimerFire(subscriberId);
3979
4060
  }
3980
4061
  }, 60000);
3981
4062
  if (timerIds.length > 0) {
@@ -3995,29 +4076,29 @@ var Server = /*#__PURE__*/function () {
3995
4076
  }, {
3996
4077
  key: "onScheduleTimePointTimerFire",
3997
4078
  value: (function () {
3998
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(subscriberId, timerId) {
4079
+ var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(subscriberId, timerId) {
3999
4080
  var subscriber;
4000
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4001
- while (1) switch (_context47.prev = _context47.next) {
4081
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4082
+ while (1) switch (_context48.prev = _context48.next) {
4002
4083
  case 0:
4003
4084
  timerId && this.removeScheduleTimerRef(subscriberId, timerId);
4004
4085
  if (this.productQuerySubscribers.has(subscriberId)) {
4005
- _context47.next = 3;
4086
+ _context48.next = 3;
4006
4087
  break;
4007
4088
  }
4008
- return _context47.abrupt("return");
4089
+ return _context48.abrupt("return");
4009
4090
  case 3:
4010
4091
  subscriber = this.productQuerySubscribers.get(subscriberId);
4011
4092
  this.refreshSubscriberScheduleAtExecution(subscriber);
4012
- _context47.next = 7;
4093
+ _context48.next = 7;
4013
4094
  return this.recomputeAndNotifySubscriber(subscriberId);
4014
4095
  case 7:
4015
4096
  case "end":
4016
- return _context47.stop();
4097
+ return _context48.stop();
4017
4098
  }
4018
- }, _callee47, this);
4099
+ }, _callee48, this);
4019
4100
  }));
4020
- function onScheduleTimePointTimerFire(_x45, _x46) {
4101
+ function onScheduleTimePointTimerFire(_x47, _x48) {
4021
4102
  return _onScheduleTimePointTimerFire.apply(this, arguments);
4022
4103
  }
4023
4104
  return onScheduleTimePointTimerFire;
@@ -4029,45 +4110,45 @@ var Server = /*#__PURE__*/function () {
4029
4110
  }, {
4030
4111
  key: "recomputeAndNotifySubscriber",
4031
4112
  value: (function () {
4032
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(subscriberId) {
4113
+ var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(subscriberId) {
4033
4114
  var subscriber, result, errorMessage;
4034
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4035
- while (1) switch (_context48.prev = _context48.next) {
4115
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4116
+ while (1) switch (_context49.prev = _context49.next) {
4036
4117
  case 0:
4037
4118
  subscriber = this.productQuerySubscribers.get(subscriberId);
4038
4119
  if (subscriber) {
4039
- _context48.next = 3;
4120
+ _context49.next = 3;
4040
4121
  break;
4041
4122
  }
4042
- return _context48.abrupt("return");
4123
+ return _context49.abrupt("return");
4043
4124
  case 3:
4044
- _context48.prev = 3;
4045
- _context48.next = 6;
4125
+ _context49.prev = 3;
4126
+ _context49.next = 6;
4046
4127
  return this.computeProductQueryResult(subscriber.context);
4047
4128
  case 6:
4048
- result = _context48.sent;
4129
+ result = _context49.sent;
4049
4130
  subscriber.callback(result);
4050
4131
  this.logInfo('recomputeAndNotifySubscriber: 已推送', {
4051
4132
  subscriberId: subscriberId,
4052
4133
  schedule_datetime: subscriber.context.schedule_datetime
4053
4134
  });
4054
- _context48.next = 15;
4135
+ _context49.next = 15;
4055
4136
  break;
4056
4137
  case 11:
4057
- _context48.prev = 11;
4058
- _context48.t0 = _context48["catch"](3);
4059
- errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4138
+ _context49.prev = 11;
4139
+ _context49.t0 = _context49["catch"](3);
4140
+ errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0);
4060
4141
  this.logError('recomputeAndNotifySubscriber: 推送失败', {
4061
4142
  subscriberId: subscriberId,
4062
4143
  error: errorMessage
4063
4144
  });
4064
4145
  case 15:
4065
4146
  case "end":
4066
- return _context48.stop();
4147
+ return _context49.stop();
4067
4148
  }
4068
- }, _callee48, this, [[3, 11]]);
4149
+ }, _callee49, this, [[3, 11]]);
4069
4150
  }));
4070
- function recomputeAndNotifySubscriber(_x47) {
4151
+ function recomputeAndNotifySubscriber(_x49) {
4071
4152
  return _recomputeAndNotifySubscriber.apply(this, arguments);
4072
4153
  }
4073
4154
  return recomputeAndNotifySubscriber;
@@ -4143,46 +4224,46 @@ var Server = /*#__PURE__*/function () {
4143
4224
  }, {
4144
4225
  key: "refreshMenuScheduleCacheAfterEmptyResult",
4145
4226
  value: (function () {
4146
- var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4147
- var _this11 = this;
4227
+ var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4228
+ var _this12 = this;
4148
4229
  var now;
4149
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4150
- while (1) switch (_context49.prev = _context49.next) {
4230
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4231
+ while (1) switch (_context50.prev = _context50.next) {
4151
4232
  case 0:
4152
4233
  if (!(!this.menu || !this.schedule)) {
4153
- _context49.next = 2;
4234
+ _context50.next = 2;
4154
4235
  break;
4155
4236
  }
4156
- return _context49.abrupt("return", false);
4237
+ return _context50.abrupt("return", false);
4157
4238
  case 2:
4158
4239
  now = Date.now();
4159
4240
  if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
4160
- _context49.next = 5;
4241
+ _context50.next = 5;
4161
4242
  break;
4162
4243
  }
4163
- return _context49.abrupt("return", false);
4244
+ return _context50.abrupt("return", false);
4164
4245
  case 5:
4165
4246
  if (!this.menuScheduleRefreshInFlight) {
4166
4247
  this.lastMenuScheduleRefreshAt = now;
4167
4248
  this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
4168
4249
  return undefined;
4169
4250
  }).catch(function (error) {
4170
- _this11.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
4251
+ _this12.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
4171
4252
  error: error instanceof Error ? error.message : String(error)
4172
4253
  });
4173
4254
  }).finally(function () {
4174
- _this11.menuScheduleRefreshInFlight = null;
4255
+ _this12.menuScheduleRefreshInFlight = null;
4175
4256
  });
4176
4257
  }
4177
- _context49.next = 8;
4258
+ _context50.next = 8;
4178
4259
  return this.menuScheduleRefreshInFlight;
4179
4260
  case 8:
4180
- return _context49.abrupt("return", true);
4261
+ return _context50.abrupt("return", true);
4181
4262
  case 9:
4182
4263
  case "end":
4183
- return _context49.stop();
4264
+ return _context50.stop();
4184
4265
  }
4185
- }, _callee49, this);
4266
+ }, _callee50, this);
4186
4267
  }));
4187
4268
  function refreshMenuScheduleCacheAfterEmptyResult() {
4188
4269
  return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
@@ -4200,16 +4281,16 @@ var Server = /*#__PURE__*/function () {
4200
4281
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
4201
4282
  */
4202
4283
  function () {
4203
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(kind, backendPath, data, config) {
4284
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(kind, backendPath, data, config) {
4204
4285
  var queryPayload, result, _ref67, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
4205
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4206
- while (1) switch (_context50.prev = _context50.next) {
4286
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4287
+ while (1) switch (_context51.prev = _context51.next) {
4207
4288
  case 0:
4208
4289
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
4209
- _context50.next = 3;
4290
+ _context51.next = 3;
4210
4291
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
4211
4292
  case 3:
4212
- result = _context50.sent;
4293
+ result = _context51.sent;
4213
4294
  _ref67 = config || {}, callback = _ref67.callback, subscriberId = _ref67.subscriberId, resetVisibleOrderIds = _ref67.resetVisibleOrderIds;
4214
4295
  if (subscriberId && typeof callback === 'function') {
4215
4296
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
@@ -4241,14 +4322,14 @@ var Server = /*#__PURE__*/function () {
4241
4322
  visibleCount: visibleOrderIds.size
4242
4323
  });
4243
4324
  }
4244
- return _context50.abrupt("return", result);
4325
+ return _context51.abrupt("return", result);
4245
4326
  case 7:
4246
4327
  case "end":
4247
- return _context50.stop();
4328
+ return _context51.stop();
4248
4329
  }
4249
- }, _callee50, this);
4330
+ }, _callee51, this);
4250
4331
  }));
4251
- function handleSalesSearchRequest(_x48, _x49, _x50, _x51) {
4332
+ function handleSalesSearchRequest(_x50, _x51, _x52, _x53) {
4252
4333
  return _handleSalesSearchRequest.apply(this, arguments);
4253
4334
  }
4254
4335
  return handleSalesSearchRequest;
@@ -4263,20 +4344,20 @@ var Server = /*#__PURE__*/function () {
4263
4344
  }, {
4264
4345
  key: "fetchSalesSearchFromAPI",
4265
4346
  value: (function () {
4266
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(backendPath, data) {
4347
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(backendPath, data) {
4267
4348
  var _this$app7;
4268
4349
  var _response$data3, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
4269
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4270
- while (1) switch (_context51.prev = _context51.next) {
4350
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4351
+ while (1) switch (_context52.prev = _context52.next) {
4271
4352
  case 0:
4272
4353
  if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
4273
- _context51.next = 3;
4354
+ _context52.next = 3;
4274
4355
  break;
4275
4356
  }
4276
4357
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
4277
4358
  backendPath: backendPath
4278
4359
  });
4279
- return _context51.abrupt("return", {
4360
+ return _context52.abrupt("return", {
4280
4361
  code: 500,
4281
4362
  message: 'app.request 不可用',
4282
4363
  data: backendPath === '/shop/es/search' ? {
@@ -4288,29 +4369,29 @@ var Server = /*#__PURE__*/function () {
4288
4369
  status: false
4289
4370
  });
4290
4371
  case 3:
4291
- _context51.prev = 3;
4292
- _context51.next = 6;
4372
+ _context52.prev = 3;
4373
+ _context52.next = 6;
4293
4374
  return this.app.request.post(backendPath, data, {
4294
4375
  isShopApi: true
4295
4376
  });
4296
4377
  case 6:
4297
- response = _context51.sent;
4378
+ response = _context52.sent;
4298
4379
  _payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
4299
- return _context51.abrupt("return", {
4380
+ return _context52.abrupt("return", {
4300
4381
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
4301
4382
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
4302
4383
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
4303
4384
  data: _payload
4304
4385
  });
4305
4386
  case 11:
4306
- _context51.prev = 11;
4307
- _context51.t0 = _context51["catch"](3);
4308
- errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
4387
+ _context52.prev = 11;
4388
+ _context52.t0 = _context52["catch"](3);
4389
+ errorMessage = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
4309
4390
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
4310
4391
  backendPath: backendPath,
4311
4392
  error: errorMessage
4312
4393
  });
4313
- return _context51.abrupt("return", {
4394
+ return _context52.abrupt("return", {
4314
4395
  code: 500,
4315
4396
  message: errorMessage,
4316
4397
  data: backendPath === '/shop/es/search' ? {
@@ -4323,11 +4404,11 @@ var Server = /*#__PURE__*/function () {
4323
4404
  });
4324
4405
  case 16:
4325
4406
  case "end":
4326
- return _context51.stop();
4407
+ return _context52.stop();
4327
4408
  }
4328
- }, _callee51, this, [[3, 11]]);
4409
+ }, _callee52, this, [[3, 11]]);
4329
4410
  }));
4330
- function fetchSalesSearchFromAPI(_x52, _x53) {
4411
+ function fetchSalesSearchFromAPI(_x54, _x55) {
4331
4412
  return _fetchSalesSearchFromAPI.apply(this, arguments);
4332
4413
  }
4333
4414
  return fetchSalesSearchFromAPI;
@@ -4357,10 +4438,10 @@ var Server = /*#__PURE__*/function () {
4357
4438
  }, {
4358
4439
  key: "stripSalesSearchPageParams",
4359
4440
  value: function stripSalesSearchPageParams(value) {
4360
- var _this12 = this;
4441
+ var _this13 = this;
4361
4442
  if (Array.isArray(value)) {
4362
4443
  return value.map(function (item) {
4363
- return _this12.stripSalesSearchPageParams(item);
4444
+ return _this13.stripSalesSearchPageParams(item);
4364
4445
  });
4365
4446
  }
4366
4447
  if (!value || _typeof(value) !== 'object') return value;
@@ -4398,12 +4479,12 @@ var Server = /*#__PURE__*/function () {
4398
4479
  key: "extractSalesSearchOrderIds",
4399
4480
  value: function extractSalesSearchOrderIds(kind, result) {
4400
4481
  var _this$findSalesSearch,
4401
- _this13 = this;
4482
+ _this14 = this;
4402
4483
  var data = this.extractSalesSearchResponseData(result);
4403
4484
  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;
4404
4485
  if (!Array.isArray(list)) return [];
4405
4486
  return list.map(function (item) {
4406
- return _this13.getSalesSearchOrderId(item);
4487
+ return _this14.getSalesSearchOrderId(item);
4407
4488
  }).filter(function (id) {
4408
4489
  return !!id;
4409
4490
  });
@@ -4572,11 +4653,11 @@ var Server = /*#__PURE__*/function () {
4572
4653
  }, {
4573
4654
  key: "stableSerialize",
4574
4655
  value: function stableSerialize(value) {
4575
- var _this14 = this;
4656
+ var _this15 = this;
4576
4657
  if (value === null || value === undefined) return 'null';
4577
4658
  if (Array.isArray(value)) {
4578
4659
  return "[".concat(value.map(function (item) {
4579
- return _this14.stableSerialize(item);
4660
+ return _this15.stableSerialize(item);
4580
4661
  }).join(','), "]");
4581
4662
  }
4582
4663
  if (_typeof(value) === 'object') {
@@ -4585,7 +4666,7 @@ var Server = /*#__PURE__*/function () {
4585
4666
  return obj[k] !== undefined;
4586
4667
  }).sort();
4587
4668
  return "{".concat(keys.map(function (k) {
4588
- return "".concat(JSON.stringify(k), ":").concat(_this14.stableSerialize(obj[k]));
4669
+ return "".concat(JSON.stringify(k), ":").concat(_this15.stableSerialize(obj[k]));
4589
4670
  }).join(','), "}");
4590
4671
  }
4591
4672
  return JSON.stringify(value);
@@ -4742,10 +4823,10 @@ var Server = /*#__PURE__*/function () {
4742
4823
  }, {
4743
4824
  key: "syncBookingRemoteCacheFromOrderChanges",
4744
4825
  value: function syncBookingRemoteCacheFromOrderChanges() {
4745
- var _this$order$getOrders, _this$order3, _this$order3$getOrder;
4826
+ var _this$order$getOrders, _this$order4, _this$order4$getOrder;
4746
4827
  if (this.bookingRemoteCache.size === 0) return;
4747
4828
  var syncStartAt = Date.now();
4748
- var latestOrders = (_this$order$getOrders = (_this$order3 = this.order) === null || _this$order3 === void 0 || (_this$order3$getOrder = _this$order3.getOrders) === null || _this$order3$getOrder === void 0 ? void 0 : _this$order3$getOrder.call(_this$order3)) !== null && _this$order$getOrders !== void 0 ? _this$order$getOrders : [];
4829
+ var latestOrders = (_this$order$getOrders = (_this$order4 = this.order) === null || _this$order4 === void 0 || (_this$order4$getOrder = _this$order4.getOrders) === null || _this$order4$getOrder === void 0 ? void 0 : _this$order4$getOrder.call(_this$order4)) !== null && _this$order$getOrders !== void 0 ? _this$order$getOrders : [];
4749
4830
  if (!Array.isArray(latestOrders) || latestOrders.length === 0) {
4750
4831
  this.markBookingRemoteCacheAllStale('orderStoreEmptyAfterChange');
4751
4832
  return;
@@ -4850,18 +4931,18 @@ var Server = /*#__PURE__*/function () {
4850
4931
  }, {
4851
4932
  key: "fetchOrderListFromAPI",
4852
4933
  value: (function () {
4853
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data) {
4934
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data) {
4854
4935
  var _this$app8;
4855
4936
  var _response$data4, response, _payload2, list, count, errorMessage;
4856
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4857
- while (1) switch (_context52.prev = _context52.next) {
4937
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4938
+ while (1) switch (_context53.prev = _context53.next) {
4858
4939
  case 0:
4859
4940
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
4860
- _context52.next = 3;
4941
+ _context53.next = 3;
4861
4942
  break;
4862
4943
  }
4863
4944
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4864
- return _context52.abrupt("return", {
4945
+ return _context53.abrupt("return", {
4865
4946
  code: 500,
4866
4947
  message: 'app.request 不可用',
4867
4948
  data: {
@@ -4871,19 +4952,19 @@ var Server = /*#__PURE__*/function () {
4871
4952
  status: false
4872
4953
  });
4873
4954
  case 3:
4874
- _context52.prev = 3;
4875
- _context52.next = 6;
4955
+ _context53.prev = 3;
4956
+ _context53.next = 6;
4876
4957
  return this.app.request.post('/shop/order/v2/list', _objectSpread(_objectSpread({}, data), {}, {
4877
4958
  with: _toConsumableArray(new Set([].concat(_toConsumableArray(Array.isArray(data.with) ? data.with : []), ['buzzer'])))
4878
4959
  }), {
4879
4960
  isShopApi: true
4880
4961
  });
4881
4962
  case 6:
4882
- response = _context52.sent;
4963
+ response = _context53.sent;
4883
4964
  _payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
4884
4965
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4885
4966
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4886
- return _context52.abrupt("return", {
4967
+ return _context53.abrupt("return", {
4887
4968
  code: 200,
4888
4969
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4889
4970
  list: list,
@@ -4893,13 +4974,13 @@ var Server = /*#__PURE__*/function () {
4893
4974
  status: true
4894
4975
  });
4895
4976
  case 13:
4896
- _context52.prev = 13;
4897
- _context52.t0 = _context52["catch"](3);
4898
- errorMessage = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
4977
+ _context53.prev = 13;
4978
+ _context53.t0 = _context53["catch"](3);
4979
+ errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
4899
4980
  this.logError('fetchOrderListFromAPI: 请求失败', {
4900
4981
  error: errorMessage
4901
4982
  });
4902
- return _context52.abrupt("return", {
4983
+ return _context53.abrupt("return", {
4903
4984
  code: 500,
4904
4985
  message: errorMessage,
4905
4986
  data: {
@@ -4910,11 +4991,11 @@ var Server = /*#__PURE__*/function () {
4910
4991
  });
4911
4992
  case 18:
4912
4993
  case "end":
4913
- return _context52.stop();
4994
+ return _context53.stop();
4914
4995
  }
4915
- }, _callee52, this, [[3, 13]]);
4996
+ }, _callee53, this, [[3, 13]]);
4916
4997
  }));
4917
- function fetchOrderListFromAPI(_x54) {
4998
+ function fetchOrderListFromAPI(_x56) {
4918
4999
  return _fetchOrderListFromAPI.apply(this, arguments);
4919
5000
  }
4920
5001
  return fetchOrderListFromAPI;
@@ -4926,17 +5007,17 @@ var Server = /*#__PURE__*/function () {
4926
5007
  }, {
4927
5008
  key: "fetchBookingListFromAPI",
4928
5009
  value: (function () {
4929
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data) {
5010
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
4930
5011
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4931
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4932
- while (1) switch (_context53.prev = _context53.next) {
5012
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5013
+ while (1) switch (_context54.prev = _context54.next) {
4933
5014
  case 0:
4934
5015
  if (this.order) {
4935
- _context53.next = 3;
5016
+ _context54.next = 3;
4936
5017
  break;
4937
5018
  }
4938
5019
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4939
- return _context53.abrupt("return", {
5020
+ return _context54.abrupt("return", {
4940
5021
  code: 500,
4941
5022
  message: 'Order 模块不可用',
4942
5023
  data: {
@@ -4946,18 +5027,18 @@ var Server = /*#__PURE__*/function () {
4946
5027
  status: false
4947
5028
  });
4948
5029
  case 3:
4949
- _context53.prev = 3;
5030
+ _context54.prev = 3;
4950
5031
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4951
5032
  withFields = this.resolveBookingSalesWith(data);
4952
5033
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4953
5034
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4954
5035
  if (!memoryCacheEnabled) {
4955
- _context53.next = 13;
5036
+ _context54.next = 13;
4956
5037
  break;
4957
5038
  }
4958
5039
  cached = this.readBookingRemoteCache(cacheKey);
4959
5040
  if (!cached) {
4960
- _context53.next = 13;
5041
+ _context54.next = 13;
4961
5042
  break;
4962
5043
  }
4963
5044
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4965,14 +5046,14 @@ var Server = /*#__PURE__*/function () {
4965
5046
  listCount: cached.bookingResult.count,
4966
5047
  withFields: cached.withFields
4967
5048
  });
4968
- return _context53.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
5049
+ return _context54.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4969
5050
  cache_hit: true
4970
5051
  }));
4971
5052
  case 13:
4972
- _context53.next = 15;
5053
+ _context54.next = 15;
4973
5054
  return this.order.fetchOrdersBySSE(requestPayload);
4974
5055
  case 15:
4975
- rawList = _context53.sent;
5056
+ rawList = _context54.sent;
4976
5057
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4977
5058
  if (typeof globalThis !== 'undefined') {
4978
5059
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -5019,15 +5100,15 @@ var Server = /*#__PURE__*/function () {
5019
5100
  cacheKey: cacheKey,
5020
5101
  withFields: withFields
5021
5102
  });
5022
- return _context53.abrupt("return", this.buildBookingResponse(bookingResult));
5103
+ return _context54.abrupt("return", this.buildBookingResponse(bookingResult));
5023
5104
  case 23:
5024
- _context53.prev = 23;
5025
- _context53.t0 = _context53["catch"](3);
5026
- errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5105
+ _context54.prev = 23;
5106
+ _context54.t0 = _context54["catch"](3);
5107
+ errorMessage = _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0);
5027
5108
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
5028
5109
  error: errorMessage
5029
5110
  });
5030
- return _context53.abrupt("return", {
5111
+ return _context54.abrupt("return", {
5031
5112
  code: 500,
5032
5113
  message: errorMessage,
5033
5114
  data: {
@@ -5038,11 +5119,11 @@ var Server = /*#__PURE__*/function () {
5038
5119
  });
5039
5120
  case 28:
5040
5121
  case "end":
5041
- return _context53.stop();
5122
+ return _context54.stop();
5042
5123
  }
5043
- }, _callee53, this, [[3, 23]]);
5124
+ }, _callee54, this, [[3, 23]]);
5044
5125
  }));
5045
- function fetchBookingListFromAPI(_x55) {
5126
+ function fetchBookingListFromAPI(_x57) {
5046
5127
  return _fetchBookingListFromAPI.apply(this, arguments);
5047
5128
  }
5048
5129
  return fetchBookingListFromAPI;
@@ -5126,11 +5207,11 @@ var Server = /*#__PURE__*/function () {
5126
5207
  }, {
5127
5208
  key: "runLocalPaymentUpdateInQueue",
5128
5209
  value: function () {
5129
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(key, task, context) {
5130
- var _this15 = this;
5210
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(key, task, context) {
5211
+ var _this16 = this;
5131
5212
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
5132
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5133
- while (1) switch (_context55.prev = _context55.next) {
5213
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5214
+ while (1) switch (_context56.prev = _context56.next) {
5134
5215
  case 0:
5135
5216
  queuedAt = Date.now();
5136
5217
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -5142,20 +5223,20 @@ var Server = /*#__PURE__*/function () {
5142
5223
  }));
5143
5224
  current = previous.catch(function () {
5144
5225
  return undefined;
5145
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5146
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5147
- while (1) switch (_context54.prev = _context54.next) {
5226
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5227
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5228
+ while (1) switch (_context55.prev = _context55.next) {
5148
5229
  case 0:
5149
- _this15.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
5230
+ _this16.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
5150
5231
  queue_key: key,
5151
5232
  queue_wait_ms: Date.now() - queuedAt
5152
5233
  }));
5153
- return _context54.abrupt("return", task());
5234
+ return _context55.abrupt("return", task());
5154
5235
  case 2:
5155
5236
  case "end":
5156
- return _context54.stop();
5237
+ return _context55.stop();
5157
5238
  }
5158
- }, _callee54);
5239
+ }, _callee55);
5159
5240
  })));
5160
5241
  tail = current.then(function () {
5161
5242
  return undefined;
@@ -5163,11 +5244,11 @@ var Server = /*#__PURE__*/function () {
5163
5244
  return undefined;
5164
5245
  });
5165
5246
  this.localPaymentUpdateQueues.set(key, tail);
5166
- _context55.prev = 7;
5167
- _context55.next = 10;
5247
+ _context56.prev = 7;
5248
+ _context56.next = 10;
5168
5249
  return current;
5169
5250
  case 10:
5170
- result = _context55.sent;
5251
+ result = _context56.sent;
5171
5252
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
5172
5253
  queue_key: key,
5173
5254
  total_duration_ms: Date.now() - queuedAt,
@@ -5175,19 +5256,19 @@ var Server = /*#__PURE__*/function () {
5175
5256
  result_status: result === null || result === void 0 ? void 0 : result.status,
5176
5257
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
5177
5258
  }));
5178
- return _context55.abrupt("return", result);
5259
+ return _context56.abrupt("return", result);
5179
5260
  case 15:
5180
- _context55.prev = 15;
5181
- _context55.t0 = _context55["catch"](7);
5261
+ _context56.prev = 15;
5262
+ _context56.t0 = _context56["catch"](7);
5182
5263
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
5183
5264
  queue_key: key,
5184
5265
  total_duration_ms: Date.now() - queuedAt,
5185
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0),
5186
- error_detail: this.normalizeUnknownError(_context55.t0)
5266
+ error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0),
5267
+ error_detail: this.normalizeUnknownError(_context56.t0)
5187
5268
  }));
5188
- throw _context55.t0;
5269
+ throw _context56.t0;
5189
5270
  case 19:
5190
- _context55.prev = 19;
5271
+ _context56.prev = 19;
5191
5272
  released = false;
5192
5273
  if (this.localPaymentUpdateQueues.get(key) === tail) {
5193
5274
  this.localPaymentUpdateQueues.delete(key);
@@ -5198,14 +5279,14 @@ var Server = /*#__PURE__*/function () {
5198
5279
  released: released,
5199
5280
  active_queue_count: this.localPaymentUpdateQueues.size
5200
5281
  }));
5201
- return _context55.finish(19);
5282
+ return _context56.finish(19);
5202
5283
  case 24:
5203
5284
  case "end":
5204
- return _context55.stop();
5285
+ return _context56.stop();
5205
5286
  }
5206
- }, _callee55, this, [[7, 15, 19, 24]]);
5287
+ }, _callee56, this, [[7, 15, 19, 24]]);
5207
5288
  }));
5208
- function runLocalPaymentUpdateInQueue(_x56, _x57, _x58) {
5289
+ function runLocalPaymentUpdateInQueue(_x58, _x59, _x60) {
5209
5290
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
5210
5291
  }
5211
5292
  return runLocalPaymentUpdateInQueue;
@@ -5213,11 +5294,11 @@ var Server = /*#__PURE__*/function () {
5213
5294
  }, {
5214
5295
  key: "processLocalPaymentUpdate",
5215
5296
  value: function () {
5216
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5297
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5217
5298
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
5218
5299
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
5219
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5220
- while (1) switch (_context56.prev = _context56.next) {
5300
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5301
+ while (1) switch (_context57.prev = _context57.next) {
5221
5302
  case 0:
5222
5303
  requestContext = {
5223
5304
  operation_id: params.operationId,
@@ -5230,11 +5311,11 @@ var Server = /*#__PURE__*/function () {
5230
5311
  };
5231
5312
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
5232
5313
  if (this.order) {
5233
- _context56.next = 5;
5314
+ _context57.next = 5;
5234
5315
  break;
5235
5316
  }
5236
5317
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
5237
- return _context56.abrupt("return", {
5318
+ return _context57.abrupt("return", {
5238
5319
  code: 500,
5239
5320
  status: false,
5240
5321
  message: 'Order 模块未注册',
@@ -5242,20 +5323,20 @@ var Server = /*#__PURE__*/function () {
5242
5323
  });
5243
5324
  case 5:
5244
5325
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
5245
- _context56.next = 8;
5326
+ _context57.next = 8;
5246
5327
  return this.order.getLocalPayment({
5247
5328
  saleId: params.saleId,
5248
5329
  paymentNumber: params.paymentNumber,
5249
5330
  operationId: params.operationId
5250
5331
  });
5251
5332
  case 8:
5252
- found = _context56.sent;
5333
+ found = _context57.sent;
5253
5334
  if (found) {
5254
- _context56.next = 12;
5335
+ _context57.next = 12;
5255
5336
  break;
5256
5337
  }
5257
5338
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
5258
- return _context56.abrupt("return", {
5339
+ return _context57.abrupt("return", {
5259
5340
  code: 404,
5260
5341
  status: false,
5261
5342
  message: '本地支付项不存在',
@@ -5304,13 +5385,13 @@ var Server = /*#__PURE__*/function () {
5304
5385
  });
5305
5386
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
5306
5387
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
5307
- _context56.next = 23;
5388
+ _context57.next = 23;
5308
5389
  break;
5309
5390
  }
5310
5391
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
5311
5392
  idempotent_reason: 'ignore_failure_after_success'
5312
5393
  }));
5313
- return _context56.abrupt("return", {
5394
+ return _context57.abrupt("return", {
5314
5395
  code: 200,
5315
5396
  status: true,
5316
5397
  message: '',
@@ -5323,13 +5404,13 @@ var Server = /*#__PURE__*/function () {
5323
5404
  case 23:
5324
5405
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
5325
5406
  if (!alreadyRecordedFailure) {
5326
- _context56.next = 27;
5407
+ _context57.next = 27;
5327
5408
  break;
5328
5409
  }
5329
5410
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
5330
5411
  idempotent_reason: 'failure_already_recorded'
5331
5412
  }));
5332
- return _context56.abrupt("return", {
5413
+ return _context57.abrupt("return", {
5333
5414
  code: 200,
5334
5415
  status: true,
5335
5416
  message: '',
@@ -5341,13 +5422,13 @@ var Server = /*#__PURE__*/function () {
5341
5422
  });
5342
5423
  case 27:
5343
5424
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
5344
- _context56.next = 30;
5425
+ _context57.next = 30;
5345
5426
  break;
5346
5427
  }
5347
5428
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
5348
5429
  idempotent_reason: 'success_already_committed'
5349
5430
  }));
5350
- return _context56.abrupt("return", {
5431
+ return _context57.abrupt("return", {
5351
5432
  code: 200,
5352
5433
  status: true,
5353
5434
  message: '',
@@ -5359,13 +5440,13 @@ var Server = /*#__PURE__*/function () {
5359
5440
  });
5360
5441
  case 30:
5361
5442
  if (!(params.status === 'success')) {
5362
- _context56.next = 33;
5443
+ _context57.next = 33;
5363
5444
  break;
5364
5445
  }
5365
5446
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
5366
5447
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
5367
5448
  }));
5368
- return _context56.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5449
+ return _context57.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5369
5450
  order: found.order,
5370
5451
  payment: found.payment,
5371
5452
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -5376,8 +5457,8 @@ var Server = /*#__PURE__*/function () {
5376
5457
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
5377
5458
  incoming_payment_update: incomingPaymentUpdate
5378
5459
  }));
5379
- _context56.prev = 34;
5380
- _context56.next = 37;
5460
+ _context57.prev = 34;
5461
+ _context57.next = 37;
5381
5462
  return this.order.updateLocalPayment({
5382
5463
  saleId: params.saleId,
5383
5464
  paymentNumber: params.paymentNumber,
@@ -5385,25 +5466,25 @@ var Server = /*#__PURE__*/function () {
5385
5466
  updates: incomingPaymentUpdate
5386
5467
  });
5387
5468
  case 37:
5388
- updated = _context56.sent;
5389
- _context56.next = 44;
5469
+ updated = _context57.sent;
5470
+ _context57.next = 44;
5390
5471
  break;
5391
5472
  case 40:
5392
- _context56.prev = 40;
5393
- _context56.t0 = _context56["catch"](34);
5473
+ _context57.prev = 40;
5474
+ _context57.t0 = _context57["catch"](34);
5394
5475
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
5395
5476
  incoming_payment_update: incomingPaymentUpdate,
5396
- error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0),
5397
- error_detail: this.normalizeUnknownError(_context56.t0)
5477
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0),
5478
+ error_detail: this.normalizeUnknownError(_context57.t0)
5398
5479
  }));
5399
- throw _context56.t0;
5480
+ throw _context57.t0;
5400
5481
  case 44:
5401
5482
  if (updated) {
5402
- _context56.next = 47;
5483
+ _context57.next = 47;
5403
5484
  break;
5404
5485
  }
5405
5486
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
5406
- return _context56.abrupt("return", {
5487
+ return _context57.abrupt("return", {
5407
5488
  code: 404,
5408
5489
  status: false,
5409
5490
  message: '本地支付项不存在',
@@ -5414,7 +5495,7 @@ var Server = /*#__PURE__*/function () {
5414
5495
  previous_payment: updated.previousPayment,
5415
5496
  payment: updated.payment
5416
5497
  }));
5417
- return _context56.abrupt("return", {
5498
+ return _context57.abrupt("return", {
5418
5499
  code: 200,
5419
5500
  status: true,
5420
5501
  message: '',
@@ -5426,11 +5507,11 @@ var Server = /*#__PURE__*/function () {
5426
5507
  });
5427
5508
  case 49:
5428
5509
  case "end":
5429
- return _context56.stop();
5510
+ return _context57.stop();
5430
5511
  }
5431
- }, _callee56, this, [[34, 40]]);
5512
+ }, _callee57, this, [[34, 40]]);
5432
5513
  }));
5433
- function processLocalPaymentUpdate(_x59) {
5514
+ function processLocalPaymentUpdate(_x61) {
5434
5515
  return _processLocalPaymentUpdate.apply(this, arguments);
5435
5516
  }
5436
5517
  return processLocalPaymentUpdate;
@@ -5438,10 +5519,10 @@ var Server = /*#__PURE__*/function () {
5438
5519
  }, {
5439
5520
  key: "processSuccessfulLocalPayment",
5440
5521
  value: function () {
5441
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5522
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5442
5523
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
5443
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5444
- while (1) switch (_context57.prev = _context57.next) {
5524
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5525
+ while (1) switch (_context58.prev = _context58.next) {
5445
5526
  case 0:
5446
5527
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
5447
5528
  baseSales = new BaseSalesImpl(moduleName);
@@ -5460,13 +5541,13 @@ var Server = /*#__PURE__*/function () {
5460
5541
  payment: params.payment
5461
5542
  });
5462
5543
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
5463
- _context57.prev = 5;
5544
+ _context58.prev = 5;
5464
5545
  order = this.sanitizeLocalRecoveryOrder(params.order);
5465
5546
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5466
5547
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
5467
5548
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
5468
5549
  }));
5469
- _context57.next = 10;
5550
+ _context58.next = 10;
5470
5551
  return baseSales.initialize(this.core, {
5471
5552
  otherParams: {
5472
5553
  platform: order.platform,
@@ -5479,14 +5560,14 @@ var Server = /*#__PURE__*/function () {
5479
5560
  });
5480
5561
  case 10:
5481
5562
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
5482
- _context57.next = 13;
5563
+ _context58.next = 13;
5483
5564
  return baseSales.replaceTempOrder(order);
5484
5565
  case 13:
5485
5566
  this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
5486
5567
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5487
5568
  incoming_payment_update: params.paymentUpdate
5488
5569
  }));
5489
- _context57.next = 17;
5570
+ _context58.next = 17;
5490
5571
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
5491
5572
  submitWhenPaid: true,
5492
5573
  matchBy: params.matchBy,
@@ -5495,7 +5576,7 @@ var Server = /*#__PURE__*/function () {
5495
5576
  smallTicketDataFlag: 1
5496
5577
  });
5497
5578
  case 17:
5498
- result = _context57.sent;
5579
+ result = _context58.sent;
5499
5580
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5500
5581
  duration_ms: Date.now() - startedAt,
5501
5582
  payment: result.payment,
@@ -5517,7 +5598,7 @@ var Server = /*#__PURE__*/function () {
5517
5598
  } : null,
5518
5599
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
5519
5600
  }));
5520
- return _context57.abrupt("return", {
5601
+ return _context58.abrupt("return", {
5521
5602
  code: 200,
5522
5603
  status: true,
5523
5604
  message: '',
@@ -5529,48 +5610,48 @@ var Server = /*#__PURE__*/function () {
5529
5610
  }
5530
5611
  });
5531
5612
  case 22:
5532
- _context57.prev = 22;
5533
- _context57.t0 = _context57["catch"](5);
5534
- message = _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0);
5613
+ _context58.prev = 22;
5614
+ _context58.t0 = _context58["catch"](5);
5615
+ message = _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0);
5535
5616
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5536
5617
  duration_ms: Date.now() - startedAt,
5537
5618
  error: message,
5538
- error_detail: this.normalizeUnknownError(_context57.t0)
5619
+ error_detail: this.normalizeUnknownError(_context58.t0)
5539
5620
  }));
5540
- return _context57.abrupt("return", {
5621
+ return _context58.abrupt("return", {
5541
5622
  code: 500,
5542
5623
  status: false,
5543
5624
  message: message,
5544
5625
  data: null
5545
5626
  });
5546
5627
  case 27:
5547
- _context57.prev = 27;
5548
- _context57.prev = 28;
5549
- _context57.next = 31;
5628
+ _context58.prev = 27;
5629
+ _context58.prev = 28;
5630
+ _context58.next = 31;
5550
5631
  return baseSales.destroy();
5551
5632
  case 31:
5552
5633
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5553
5634
  duration_ms: Date.now() - startedAt
5554
5635
  }));
5555
- _context57.next = 37;
5636
+ _context58.next = 37;
5556
5637
  break;
5557
5638
  case 34:
5558
- _context57.prev = 34;
5559
- _context57.t1 = _context57["catch"](28);
5639
+ _context58.prev = 34;
5640
+ _context58.t1 = _context58["catch"](28);
5560
5641
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5561
5642
  duration_ms: Date.now() - startedAt,
5562
- error: _context57.t1 instanceof Error ? _context57.t1.message : String(_context57.t1),
5563
- error_detail: this.normalizeUnknownError(_context57.t1)
5643
+ error: _context58.t1 instanceof Error ? _context58.t1.message : String(_context58.t1),
5644
+ error_detail: this.normalizeUnknownError(_context58.t1)
5564
5645
  }));
5565
5646
  case 37:
5566
- return _context57.finish(27);
5647
+ return _context58.finish(27);
5567
5648
  case 38:
5568
5649
  case "end":
5569
- return _context57.stop();
5650
+ return _context58.stop();
5570
5651
  }
5571
- }, _callee57, this, [[5, 22, 27, 38], [28, 34]]);
5652
+ }, _callee58, this, [[5, 22, 27, 38], [28, 34]]);
5572
5653
  }));
5573
- function processSuccessfulLocalPayment(_x60) {
5654
+ function processSuccessfulLocalPayment(_x62) {
5574
5655
  return _processSuccessfulLocalPayment.apply(this, arguments);
5575
5656
  }
5576
5657
  return processSuccessfulLocalPayment;
@@ -5661,32 +5742,32 @@ var Server = /*#__PURE__*/function () {
5661
5742
  }, {
5662
5743
  key: "getShortNumberOrDeviceId",
5663
5744
  value: function () {
5664
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
5745
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59() {
5665
5746
  var getAsyncIotDeviceInfo, res;
5666
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5667
- while (1) switch (_context58.prev = _context58.next) {
5747
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5748
+ while (1) switch (_context59.prev = _context59.next) {
5668
5749
  case 0:
5669
5750
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
5670
5751
  if (!getAsyncIotDeviceInfo) {
5671
- _context58.next = 7;
5752
+ _context59.next = 7;
5672
5753
  break;
5673
5754
  }
5674
- _context58.next = 4;
5755
+ _context59.next = 4;
5675
5756
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
5676
5757
  case 4:
5677
- res = _context58.sent;
5758
+ res = _context59.sent;
5678
5759
  if (!(res !== null && res !== void 0 && res.short_number)) {
5679
- _context58.next = 7;
5760
+ _context59.next = 7;
5680
5761
  break;
5681
5762
  }
5682
- return _context58.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5763
+ return _context59.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5683
5764
  case 7:
5684
- return _context58.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5765
+ return _context59.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5685
5766
  case 8:
5686
5767
  case "end":
5687
- return _context58.stop();
5768
+ return _context59.stop();
5688
5769
  }
5689
- }, _callee58, this);
5770
+ }, _callee59, this);
5690
5771
  }));
5691
5772
  function getShortNumberOrDeviceId() {
5692
5773
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -5823,12 +5904,12 @@ var Server = /*#__PURE__*/function () {
5823
5904
  }, {
5824
5905
  key: "buildCheckoutResourceIdentifierBuzzer",
5825
5906
  value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5826
- var _this16 = this;
5907
+ var _this17 = this;
5827
5908
  if (!Array.isArray(bookings)) return '';
5828
5909
  var values = [];
5829
5910
  var seen = new Set();
5830
5911
  var visitResource = function visitResource(resource, fallbackName) {
5831
- var identifier = _this16.getCheckoutResourceIdentifier(resource, fallbackName);
5912
+ var identifier = _this17.getCheckoutResourceIdentifier(resource, fallbackName);
5832
5913
  if (identifier && !seen.has(identifier)) {
5833
5914
  seen.add(identifier);
5834
5915
  values.push(identifier);
@@ -5880,16 +5961,16 @@ var Server = /*#__PURE__*/function () {
5880
5961
  }, {
5881
5962
  key: "normalizeCheckoutSubmitData",
5882
5963
  value: function () {
5883
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data, title) {
5964
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data, title) {
5884
5965
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5885
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5886
- while (1) switch (_context59.prev = _context59.next) {
5966
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5967
+ while (1) switch (_context60.prev = _context60.next) {
5887
5968
  case 0:
5888
5969
  if (!(!data || _typeof(data) !== 'object')) {
5889
- _context59.next = 2;
5970
+ _context60.next = 2;
5890
5971
  break;
5891
5972
  }
5892
- return _context59.abrupt("return", data);
5973
+ return _context60.abrupt("return", data);
5893
5974
  case 2:
5894
5975
  next = _objectSpread({}, data);
5895
5976
  externalSaleNumber = next.external_sale_number;
@@ -5899,7 +5980,7 @@ var Server = /*#__PURE__*/function () {
5899
5980
  delete next.vouchers;
5900
5981
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5901
5982
  if (!hasCheckoutOrderNumbers) {
5902
- _context59.next = 11;
5983
+ _context60.next = 11;
5903
5984
  break;
5904
5985
  }
5905
5986
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -5909,10 +5990,10 @@ var Server = /*#__PURE__*/function () {
5909
5990
  shop_order_number: next.shop_order_number,
5910
5991
  shop_full_order_number: next.shop_full_order_number
5911
5992
  });
5912
- return _context59.abrupt("return", next);
5993
+ return _context60.abrupt("return", next);
5913
5994
  case 11:
5914
5995
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
5915
- _context59.next = 14;
5996
+ _context60.next = 14;
5916
5997
  break;
5917
5998
  }
5918
5999
  if (shouldClearLocalOrderId) {
@@ -5921,10 +6002,10 @@ var Server = /*#__PURE__*/function () {
5921
6002
  order_id: next.order_id
5922
6003
  });
5923
6004
  }
5924
- return _context59.abrupt("return", next);
6005
+ return _context60.abrupt("return", next);
5925
6006
  case 14:
5926
6007
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
5927
- _context59.next = 17;
6008
+ _context60.next = 17;
5928
6009
  break;
5929
6010
  }
5930
6011
  if (shouldClearLocalOrderId) {
@@ -5933,12 +6014,12 @@ var Server = /*#__PURE__*/function () {
5933
6014
  external_sale_number: externalSaleNumber
5934
6015
  });
5935
6016
  }
5936
- return _context59.abrupt("return", next);
6017
+ return _context60.abrupt("return", next);
5937
6018
  case 17:
5938
- _context59.prev = 17;
6019
+ _context60.prev = 17;
5939
6020
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
5940
6021
  if (localOrder) {
5941
- _context59.next = 22;
6022
+ _context60.next = 22;
5942
6023
  break;
5943
6024
  }
5944
6025
  if (shouldClearLocalOrderId) {
@@ -5948,7 +6029,7 @@ var Server = /*#__PURE__*/function () {
5948
6029
  localOrderFound: false
5949
6030
  });
5950
6031
  }
5951
- return _context59.abrupt("return", next);
6032
+ return _context60.abrupt("return", next);
5952
6033
  case 22:
5953
6034
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
5954
6035
  next.shop_order_number = localOrder.shop_order_number;
@@ -5965,23 +6046,23 @@ var Server = /*#__PURE__*/function () {
5965
6046
  shop_full_order_number: next.shop_full_order_number
5966
6047
  });
5967
6048
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5968
- return _context59.abrupt("return", next);
6049
+ return _context60.abrupt("return", next);
5969
6050
  case 28:
5970
- _context59.prev = 28;
5971
- _context59.t0 = _context59["catch"](17);
6051
+ _context60.prev = 28;
6052
+ _context60.t0 = _context60["catch"](17);
5972
6053
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
5973
6054
  external_sale_number: externalSaleNumber,
5974
- error: this.getUnknownErrorMessage(_context59.t0),
5975
- error_detail: this.normalizeUnknownError(_context59.t0)
6055
+ error: this.getUnknownErrorMessage(_context60.t0),
6056
+ error_detail: this.normalizeUnknownError(_context60.t0)
5976
6057
  });
5977
- return _context59.abrupt("return", next);
6058
+ return _context60.abrupt("return", next);
5978
6059
  case 32:
5979
6060
  case "end":
5980
- return _context59.stop();
6061
+ return _context60.stop();
5981
6062
  }
5982
- }, _callee59, this, [[17, 28]]);
6063
+ }, _callee60, this, [[17, 28]]);
5983
6064
  }));
5984
- function normalizeCheckoutSubmitData(_x61, _x62) {
6065
+ function normalizeCheckoutSubmitData(_x63, _x64) {
5985
6066
  return _normalizeCheckoutSubmitData.apply(this, arguments);
5986
6067
  }
5987
6068
  return normalizeCheckoutSubmitData;
@@ -5989,81 +6070,81 @@ var Server = /*#__PURE__*/function () {
5989
6070
  }, {
5990
6071
  key: "ensureCheckoutOrderNumbers",
5991
6072
  value: function () {
5992
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data, title) {
6073
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(data, title) {
5993
6074
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
5994
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5995
- while (1) switch (_context60.prev = _context60.next) {
6075
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6076
+ while (1) switch (_context61.prev = _context61.next) {
5996
6077
  case 0:
5997
6078
  if (!(!data || _typeof(data) !== 'object')) {
5998
- _context60.next = 2;
6079
+ _context61.next = 2;
5999
6080
  break;
6000
6081
  }
6001
- return _context60.abrupt("return", data);
6082
+ return _context61.abrupt("return", data);
6002
6083
  case 2:
6003
6084
  next = _objectSpread({}, data);
6004
6085
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
6005
6086
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
6006
6087
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
6007
- _context60.next = 7;
6088
+ _context61.next = 7;
6008
6089
  break;
6009
6090
  }
6010
- return _context60.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6091
+ return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6011
6092
  case 7:
6012
6093
  idGenerator = this.getIdGeneratorPlugin();
6013
6094
  if (idGenerator) {
6014
- _context60.next = 11;
6095
+ _context61.next = 11;
6015
6096
  break;
6016
6097
  }
6017
6098
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
6018
6099
  needsShopOrderNumber: needsShopOrderNumber,
6019
6100
  needsShopFullOrderNumber: needsShopFullOrderNumber
6020
6101
  });
6021
- return _context60.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6102
+ return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6022
6103
  case 11:
6023
- _context60.prev = 11;
6104
+ _context61.prev = 11;
6024
6105
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
6025
- _context60.next = 16;
6106
+ _context61.next = 16;
6026
6107
  break;
6027
6108
  }
6028
- _context60.next = 15;
6109
+ _context61.next = 15;
6029
6110
  return idGenerator.generateShopOrderNumber({
6030
6111
  biz: next.business_code || 'ticket'
6031
6112
  });
6032
6113
  case 15:
6033
- next.shop_order_number = _context60.sent;
6114
+ next.shop_order_number = _context61.sent;
6034
6115
  case 16:
6035
6116
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
6036
- _context60.next = 20;
6117
+ _context61.next = 20;
6037
6118
  break;
6038
6119
  }
6039
- _context60.next = 19;
6120
+ _context61.next = 19;
6040
6121
  return idGenerator.generateReceiptId({
6041
6122
  biz: next.business_code || 'ticket'
6042
6123
  });
6043
6124
  case 19:
6044
- next.shop_full_order_number = _context60.sent;
6125
+ next.shop_full_order_number = _context61.sent;
6045
6126
  case 20:
6046
6127
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
6047
6128
  shop_order_number: next.shop_order_number,
6048
6129
  shop_full_order_number: next.shop_full_order_number
6049
6130
  });
6050
- _context60.next = 26;
6131
+ _context61.next = 26;
6051
6132
  break;
6052
6133
  case 23:
6053
- _context60.prev = 23;
6054
- _context60.t0 = _context60["catch"](11);
6134
+ _context61.prev = 23;
6135
+ _context61.t0 = _context61["catch"](11);
6055
6136
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
6056
- error: _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0)
6137
+ error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
6057
6138
  });
6058
6139
  case 26:
6059
- return _context60.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6140
+ return _context61.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
6060
6141
  case 27:
6061
6142
  case "end":
6062
- return _context60.stop();
6143
+ return _context61.stop();
6063
6144
  }
6064
- }, _callee60, this, [[11, 23]]);
6145
+ }, _callee61, this, [[11, 23]]);
6065
6146
  }));
6066
- function ensureCheckoutOrderNumbers(_x63, _x64) {
6147
+ function ensureCheckoutOrderNumbers(_x65, _x66) {
6067
6148
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
6068
6149
  }
6069
6150
  return ensureCheckoutOrderNumbers;
@@ -6110,27 +6191,27 @@ var Server = /*#__PURE__*/function () {
6110
6191
  }, {
6111
6192
  key: "dispatchCheckoutSyncTask",
6112
6193
  value: function () {
6113
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6194
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6114
6195
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
6115
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6116
- while (1) switch (_context61.prev = _context61.next) {
6196
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6197
+ while (1) switch (_context62.prev = _context62.next) {
6117
6198
  case 0:
6118
6199
  this.registerDeviceTaskActions();
6119
6200
  deviceTask = this.getDeviceTaskPlugin();
6120
- _context61.next = 4;
6201
+ _context62.next = 4;
6121
6202
  return this.getShortNumberOrDeviceId();
6122
6203
  case 4:
6123
- debugDeviceId = _context61.sent;
6204
+ debugDeviceId = _context62.sent;
6124
6205
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
6125
6206
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6126
- _context61.next = 9;
6207
+ _context62.next = 9;
6127
6208
  break;
6128
6209
  }
6129
6210
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
6130
- return _context61.abrupt("return");
6211
+ return _context62.abrupt("return");
6131
6212
  case 9:
6132
- _context61.prev = 9;
6133
- _context61.next = 12;
6213
+ _context62.prev = 9;
6214
+ _context62.next = 12;
6134
6215
  return deviceTask.dispatch({
6135
6216
  action: 'sync_sales',
6136
6217
  device_id: debugDeviceId,
@@ -6150,27 +6231,27 @@ var Server = /*#__PURE__*/function () {
6150
6231
  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)
6151
6232
  });
6152
6233
  case 12:
6153
- result = _context61.sent;
6234
+ result = _context62.sent;
6154
6235
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
6155
6236
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
6156
6237
  status: result === null || result === void 0 ? void 0 : result.status,
6157
6238
  reused: result === null || result === void 0 ? void 0 : result.reused
6158
6239
  });
6159
- _context61.next = 19;
6240
+ _context62.next = 19;
6160
6241
  break;
6161
6242
  case 16:
6162
- _context61.prev = 16;
6163
- _context61.t0 = _context61["catch"](9);
6243
+ _context62.prev = 16;
6244
+ _context62.t0 = _context62["catch"](9);
6164
6245
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
6165
- error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
6246
+ error: _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0)
6166
6247
  });
6167
6248
  case 19:
6168
6249
  case "end":
6169
- return _context61.stop();
6250
+ return _context62.stop();
6170
6251
  }
6171
- }, _callee61, this, [[9, 16]]);
6252
+ }, _callee62, this, [[9, 16]]);
6172
6253
  }));
6173
- function dispatchCheckoutSyncTask(_x65) {
6254
+ function dispatchCheckoutSyncTask(_x67) {
6174
6255
  return _dispatchCheckoutSyncTask.apply(this, arguments);
6175
6256
  }
6176
6257
  return dispatchCheckoutSyncTask;
@@ -6178,26 +6259,26 @@ var Server = /*#__PURE__*/function () {
6178
6259
  }, {
6179
6260
  key: "dispatchPrintOtherReceiptTask",
6180
6261
  value: function () {
6181
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6262
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6182
6263
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
6183
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6184
- while (1) switch (_context62.prev = _context62.next) {
6264
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6265
+ while (1) switch (_context63.prev = _context63.next) {
6185
6266
  case 0:
6186
6267
  deviceTask = this.getDeviceTaskPlugin();
6187
6268
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
6188
- _context62.next = 4;
6269
+ _context63.next = 4;
6189
6270
  break;
6190
6271
  }
6191
6272
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
6192
- return _context62.abrupt("return");
6273
+ return _context63.abrupt("return");
6193
6274
  case 4:
6194
- _context62.prev = 4;
6275
+ _context63.prev = 4;
6195
6276
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
6196
- _context62.next = 8;
6277
+ _context63.next = 8;
6197
6278
  return this.getShortNumberOrDeviceId();
6198
6279
  case 8:
6199
- deviceId = _context62.sent;
6200
- _context62.next = 11;
6280
+ deviceId = _context63.sent;
6281
+ _context63.next = 11;
6201
6282
  return deviceTask.dispatch({
6202
6283
  action: 'print_all',
6203
6284
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -6226,21 +6307,21 @@ var Server = /*#__PURE__*/function () {
6226
6307
  source_id: printIdentity
6227
6308
  });
6228
6309
  case 11:
6229
- _context62.next = 16;
6310
+ _context63.next = 16;
6230
6311
  break;
6231
6312
  case 13:
6232
- _context62.prev = 13;
6233
- _context62.t0 = _context62["catch"](4);
6313
+ _context63.prev = 13;
6314
+ _context63.t0 = _context63["catch"](4);
6234
6315
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
6235
- error: _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0)
6316
+ error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
6236
6317
  });
6237
6318
  case 16:
6238
6319
  case "end":
6239
- return _context62.stop();
6320
+ return _context63.stop();
6240
6321
  }
6241
- }, _callee62, this, [[4, 13]]);
6322
+ }, _callee63, this, [[4, 13]]);
6242
6323
  }));
6243
- function dispatchPrintOtherReceiptTask(_x66) {
6324
+ function dispatchPrintOtherReceiptTask(_x68) {
6244
6325
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
6245
6326
  }
6246
6327
  return dispatchPrintOtherReceiptTask;
@@ -6260,34 +6341,34 @@ var Server = /*#__PURE__*/function () {
6260
6341
  }, {
6261
6342
  key: "dispatchLocalReceiptPrint",
6262
6343
  value: function () {
6263
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6344
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6264
6345
  var _payment_info2;
6265
6346
  var printableOrder;
6266
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6267
- while (1) switch (_context63.prev = _context63.next) {
6347
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6348
+ while (1) switch (_context64.prev = _context64.next) {
6268
6349
  case 0:
6269
6350
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
6270
- _context63.next = 2;
6351
+ _context64.next = 2;
6271
6352
  break;
6272
6353
  }
6273
- return _context63.abrupt("return", {
6354
+ return _context64.abrupt("return", {
6274
6355
  printed: false,
6275
6356
  order: params.order
6276
6357
  });
6277
6358
  case 2:
6278
- _context63.next = 4;
6359
+ _context64.next = 4;
6279
6360
  return this.withLocalSmallTicketData(params.order, {
6280
6361
  requireFullyPaid: params.requireFullyPaid,
6281
6362
  invoiceTemplateSettings: params.invoiceTemplateSettings,
6282
6363
  applyTemplateVisibility: true
6283
6364
  });
6284
6365
  case 4:
6285
- printableOrder = _context63.sent;
6366
+ printableOrder = _context64.sent;
6286
6367
  if (hasSmallTicketData((_payment_info2 = printableOrder.payment_info) === null || _payment_info2 === void 0 ? void 0 : _payment_info2.small_ticket_data)) {
6287
- _context63.next = 7;
6368
+ _context64.next = 7;
6288
6369
  break;
6289
6370
  }
6290
- return _context63.abrupt("return", {
6371
+ return _context64.abrupt("return", {
6291
6372
  printed: false,
6292
6373
  order: printableOrder
6293
6374
  });
@@ -6297,7 +6378,7 @@ var Server = /*#__PURE__*/function () {
6297
6378
  printableOrder: printableOrder,
6298
6379
  response: params.response
6299
6380
  });
6300
- _context63.next = 10;
6381
+ _context64.next = 10;
6301
6382
  return this.dispatchPrintOtherReceiptTask({
6302
6383
  checkoutData: params.checkoutData,
6303
6384
  syncedOrder: printableOrder,
@@ -6308,17 +6389,17 @@ var Server = /*#__PURE__*/function () {
6308
6389
  invoiceTemplateSettings: params.invoiceTemplateSettings
6309
6390
  });
6310
6391
  case 10:
6311
- return _context63.abrupt("return", {
6392
+ return _context64.abrupt("return", {
6312
6393
  printed: true,
6313
6394
  order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
6314
6395
  });
6315
6396
  case 11:
6316
6397
  case "end":
6317
- return _context63.stop();
6398
+ return _context64.stop();
6318
6399
  }
6319
- }, _callee63, this);
6400
+ }, _callee64, this);
6320
6401
  }));
6321
- function dispatchLocalReceiptPrint(_x67) {
6402
+ function dispatchLocalReceiptPrint(_x69) {
6322
6403
  return _dispatchLocalReceiptPrint.apply(this, arguments);
6323
6404
  }
6324
6405
  return dispatchLocalReceiptPrint;
@@ -6377,47 +6458,47 @@ var Server = /*#__PURE__*/function () {
6377
6458
  }, {
6378
6459
  key: "syncMachinecodeRedeemStatusToLocalOrder",
6379
6460
  value: function () {
6380
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data, ids, status) {
6381
- var _this$order4;
6461
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(data, ids, status) {
6462
+ var _this$order5;
6382
6463
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
6383
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6384
- while (1) switch (_context64.prev = _context64.next) {
6464
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6465
+ while (1) switch (_context65.prev = _context65.next) {
6385
6466
  case 0:
6386
6467
  title = 'handleMachinecodeBatchMetadata';
6387
6468
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
6388
6469
  if (!(lookup === undefined)) {
6389
- _context64.next = 5;
6470
+ _context65.next = 5;
6390
6471
  break;
6391
6472
  }
6392
6473
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6393
6474
  batchSize: ids.length,
6394
6475
  status: status
6395
6476
  });
6396
- return _context64.abrupt("return");
6477
+ return _context65.abrupt("return");
6397
6478
  case 5:
6398
- if ((_this$order4 = this.order) !== null && _this$order4 !== void 0 && _this$order4.getLocalOrderByLookup) {
6399
- _context64.next = 8;
6479
+ if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
6480
+ _context65.next = 8;
6400
6481
  break;
6401
6482
  }
6402
6483
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6403
6484
  lookup: lookup,
6404
6485
  status: status
6405
6486
  });
6406
- return _context64.abrupt("return");
6487
+ return _context65.abrupt("return");
6407
6488
  case 8:
6408
- _context64.next = 10;
6489
+ _context65.next = 10;
6409
6490
  return this.order.getLocalOrderByLookup(lookup);
6410
6491
  case 10:
6411
- localOrder = _context64.sent;
6492
+ localOrder = _context65.sent;
6412
6493
  if (localOrder) {
6413
- _context64.next = 14;
6494
+ _context65.next = 14;
6414
6495
  break;
6415
6496
  }
6416
6497
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6417
6498
  lookup: lookup,
6418
6499
  status: status
6419
6500
  });
6420
- return _context64.abrupt("return");
6501
+ return _context65.abrupt("return");
6421
6502
  case 14:
6422
6503
  voucherIdSet = new Set(ids.filter(function (id) {
6423
6504
  return id !== undefined && id !== null && id !== '';
@@ -6425,14 +6506,14 @@ var Server = /*#__PURE__*/function () {
6425
6506
  return String(id);
6426
6507
  }));
6427
6508
  if (!(voucherIdSet.size === 0)) {
6428
- _context64.next = 18;
6509
+ _context65.next = 18;
6429
6510
  break;
6430
6511
  }
6431
6512
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
6432
6513
  lookup: lookup,
6433
6514
  status: status
6434
6515
  });
6435
- return _context64.abrupt("return");
6516
+ return _context65.abrupt("return");
6436
6517
  case 18:
6437
6518
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
6438
6519
  hasUpdatedVoucher = false;
@@ -6446,7 +6527,7 @@ var Server = /*#__PURE__*/function () {
6446
6527
  });
6447
6528
  });
6448
6529
  if (hasUpdatedVoucher) {
6449
- _context64.next = 24;
6530
+ _context65.next = 24;
6450
6531
  break;
6451
6532
  }
6452
6533
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -6454,13 +6535,13 @@ var Server = /*#__PURE__*/function () {
6454
6535
  voucher_ids: Array.from(voucherIdSet),
6455
6536
  status: status
6456
6537
  });
6457
- return _context64.abrupt("return");
6538
+ return _context65.abrupt("return");
6458
6539
  case 24:
6459
6540
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
6460
- _context64.next = 29;
6541
+ _context65.next = 29;
6461
6542
  break;
6462
6543
  }
6463
- _context64.next = 27;
6544
+ _context65.next = 27;
6464
6545
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
6465
6546
  vouchers: nextVouchers
6466
6547
  }));
@@ -6470,13 +6551,13 @@ var Server = /*#__PURE__*/function () {
6470
6551
  updatedCount: voucherIdSet.size,
6471
6552
  status: status
6472
6553
  });
6473
- return _context64.abrupt("return");
6554
+ return _context65.abrupt("return");
6474
6555
  case 29:
6475
6556
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
6476
- _context64.next = 34;
6557
+ _context65.next = 34;
6477
6558
  break;
6478
6559
  }
6479
- _context64.next = 32;
6560
+ _context65.next = 32;
6480
6561
  return this.order.markOrderSyncedByExternalSaleNumber({
6481
6562
  externalSaleNumber: data.external_sale_number,
6482
6563
  patch: {
@@ -6489,7 +6570,7 @@ var Server = /*#__PURE__*/function () {
6489
6570
  updatedCount: voucherIdSet.size,
6490
6571
  status: status
6491
6572
  });
6492
- return _context64.abrupt("return");
6573
+ return _context65.abrupt("return");
6493
6574
  case 34:
6494
6575
  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"), {
6495
6576
  lookup: lookup,
@@ -6497,11 +6578,11 @@ var Server = /*#__PURE__*/function () {
6497
6578
  });
6498
6579
  case 35:
6499
6580
  case "end":
6500
- return _context64.stop();
6581
+ return _context65.stop();
6501
6582
  }
6502
- }, _callee64, this);
6583
+ }, _callee65, this);
6503
6584
  }));
6504
- function syncMachinecodeRedeemStatusToLocalOrder(_x68, _x69, _x70) {
6585
+ function syncMachinecodeRedeemStatusToLocalOrder(_x70, _x71, _x72) {
6505
6586
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
6506
6587
  }
6507
6588
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -6509,30 +6590,30 @@ var Server = /*#__PURE__*/function () {
6509
6590
  }, {
6510
6591
  key: "handleOrderCheckoutSubmit",
6511
6592
  value: function () {
6512
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
6513
- var _params$data5, _params$data6, _this$order5, _this$order5$getLocal;
6593
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
6594
+ var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
6514
6595
  var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
6515
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6516
- while (1) switch (_context65.prev = _context65.next) {
6596
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6597
+ while (1) switch (_context66.prev = _context66.next) {
6517
6598
  case 0:
6518
6599
  backendPath = params.backendPath, title = params.title;
6519
6600
  lookup = ((_params$data5 = params.data) === null || _params$data5 === void 0 ? void 0 : _params$data5.order_id) || ((_params$data6 = params.data) === null || _params$data6 === void 0 ? void 0 : _params$data6.external_sale_number);
6520
- _context65.t0 = lookup;
6521
- if (!_context65.t0) {
6522
- _context65.next = 7;
6601
+ _context66.t0 = lookup;
6602
+ if (!_context66.t0) {
6603
+ _context66.next = 7;
6523
6604
  break;
6524
6605
  }
6525
- _context65.next = 6;
6526
- return (_this$order5 = this.order) === null || _this$order5 === void 0 || (_this$order5$getLocal = _this$order5.getLocalOrderByLookup) === null || _this$order5$getLocal === void 0 ? void 0 : _this$order5$getLocal.call(_this$order5, lookup);
6606
+ _context66.next = 6;
6607
+ return (_this$order6 = this.order) === null || _this$order6 === void 0 || (_this$order6$getLocal = _this$order6.getLocalOrderByLookup) === null || _this$order6$getLocal === void 0 ? void 0 : _this$order6$getLocal.call(_this$order6, lookup);
6527
6608
  case 6:
6528
- _context65.t0 = _context65.sent;
6609
+ _context66.t0 = _context66.sent;
6529
6610
  case 7:
6530
- localOrder = _context65.t0;
6611
+ localOrder = _context66.t0;
6531
6612
  if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
6532
- _context65.next = 10;
6613
+ _context66.next = 10;
6533
6614
  break;
6534
6615
  }
6535
- return _context65.abrupt("return", {
6616
+ return _context66.abrupt("return", {
6536
6617
  code: 409,
6537
6618
  status: false,
6538
6619
  message: PAYMENT_REFRESH_MESSAGE,
@@ -6555,10 +6636,10 @@ var Server = /*#__PURE__*/function () {
6555
6636
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6556
6637
  });
6557
6638
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
6558
- _context65.next = 18;
6639
+ _context66.next = 18;
6559
6640
  break;
6560
6641
  }
6561
- return _context65.abrupt("return", this.handleSyncCheckoutSubmit({
6642
+ return _context66.abrupt("return", this.handleSyncCheckoutSubmit({
6562
6643
  backendPath: backendPath,
6563
6644
  data: data,
6564
6645
  title: title,
@@ -6566,16 +6647,16 @@ var Server = /*#__PURE__*/function () {
6566
6647
  invoiceTemplateSettings: invoiceTemplateSettings
6567
6648
  }));
6568
6649
  case 18:
6569
- _context65.next = 20;
6650
+ _context66.next = 20;
6570
6651
  return this.normalizeCheckoutSubmitData(data, title);
6571
6652
  case 20:
6572
- normalizedData = _context65.sent;
6573
- _context65.next = 23;
6653
+ normalizedData = _context66.sent;
6654
+ _context66.next = 23;
6574
6655
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6575
6656
  case 23:
6576
- numberedData = _context65.sent;
6657
+ numberedData = _context66.sent;
6577
6658
  checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
6578
- _context65.next = 27;
6659
+ _context66.next = 27;
6579
6660
  return this.handlePendingSyncCheckoutOrder({
6580
6661
  backendPath: backendPath,
6581
6662
  data: checkoutData,
@@ -6584,18 +6665,18 @@ var Server = /*#__PURE__*/function () {
6584
6665
  invoiceTemplateSettings: invoiceTemplateSettings
6585
6666
  });
6586
6667
  case 27:
6587
- pendingResult = _context65.sent;
6668
+ pendingResult = _context66.sent;
6588
6669
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6589
- _context65.next = 42;
6670
+ _context66.next = 42;
6590
6671
  break;
6591
6672
  }
6592
6673
  pendingOrder = pendingResult.data;
6593
6674
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
6594
- _context65.next = 40;
6675
+ _context66.next = 40;
6595
6676
  break;
6596
6677
  }
6597
- _context65.prev = 31;
6598
- _context65.next = 34;
6678
+ _context66.prev = 31;
6679
+ _context66.next = 34;
6599
6680
  return this.dispatchLocalReceiptPrint({
6600
6681
  checkoutData: checkoutData,
6601
6682
  order: pendingOrder,
@@ -6605,19 +6686,19 @@ var Server = /*#__PURE__*/function () {
6605
6686
  invoiceTemplateSettings: invoiceTemplateSettings
6606
6687
  });
6607
6688
  case 34:
6608
- _context65.next = 40;
6689
+ _context66.next = 40;
6609
6690
  break;
6610
6691
  case 36:
6611
- _context65.prev = 36;
6612
- _context65.t1 = _context65["catch"](31);
6692
+ _context66.prev = 36;
6693
+ _context66.t1 = _context66["catch"](31);
6613
6694
  // The sale is already persisted. A failed receipt must not cancel its
6614
6695
  // sync task or send an unfiltered fallback to the printer.
6615
- pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context65.t1);
6696
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context66.t1);
6616
6697
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
6617
6698
  error: pendingResult.receipt_print_error
6618
6699
  });
6619
6700
  case 40:
6620
- _context65.next = 42;
6701
+ _context66.next = 42;
6621
6702
  return this.dispatchCheckoutSyncTask({
6622
6703
  backendPath: backendPath,
6623
6704
  data: checkoutData,
@@ -6627,23 +6708,23 @@ var Server = /*#__PURE__*/function () {
6627
6708
  });
6628
6709
  case 42:
6629
6710
  if (pendingResult.data.order_id) {
6630
- _context65.next = 44;
6711
+ _context66.next = 44;
6631
6712
  break;
6632
6713
  }
6633
- return _context65.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6714
+ return _context66.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6634
6715
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6635
6716
  order_id: pendingResult.data.external_sale_number
6636
6717
  })
6637
6718
  }));
6638
6719
  case 44:
6639
- return _context65.abrupt("return", pendingResult);
6720
+ return _context66.abrupt("return", pendingResult);
6640
6721
  case 45:
6641
6722
  case "end":
6642
- return _context65.stop();
6723
+ return _context66.stop();
6643
6724
  }
6644
- }, _callee65, this, [[31, 36]]);
6725
+ }, _callee66, this, [[31, 36]]);
6645
6726
  }));
6646
- function handleOrderCheckoutSubmit(_x71) {
6727
+ function handleOrderCheckoutSubmit(_x73) {
6647
6728
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6648
6729
  }
6649
6730
  return handleOrderCheckoutSubmit;
@@ -6651,27 +6732,27 @@ var Server = /*#__PURE__*/function () {
6651
6732
  }, {
6652
6733
  key: "handleSyncCheckoutSubmit",
6653
6734
  value: function () {
6654
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
6735
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6655
6736
  var _this$app15;
6656
6737
  var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6657
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6658
- while (1) switch (_context66.prev = _context66.next) {
6738
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6739
+ while (1) switch (_context67.prev = _context67.next) {
6659
6740
  case 0:
6660
6741
  backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
6661
6742
  if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
6662
- _context66.next = 4;
6743
+ _context67.next = 4;
6663
6744
  break;
6664
6745
  }
6665
6746
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6666
- return _context66.abrupt("return", {
6747
+ return _context67.abrupt("return", {
6667
6748
  code: 500,
6668
6749
  status: false,
6669
6750
  message: 'app.request 不可用',
6670
6751
  data: null
6671
6752
  });
6672
6753
  case 4:
6673
- _context66.prev = 4;
6674
- _context66.next = 7;
6754
+ _context67.prev = 4;
6755
+ _context67.next = 7;
6675
6756
  return this.runCheckoutSync({
6676
6757
  backendPath: backendPath,
6677
6758
  data: data,
@@ -6681,13 +6762,13 @@ var Server = /*#__PURE__*/function () {
6681
6762
  invoiceTemplateSettings: invoiceTemplateSettings
6682
6763
  });
6683
6764
  case 7:
6684
- syncResult = _context66.sent;
6765
+ syncResult = _context67.sent;
6685
6766
  if (!syncResult.rejected) {
6686
- _context66.next = 11;
6767
+ _context67.next = 11;
6687
6768
  break;
6688
6769
  }
6689
6770
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6690
- return _context66.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6771
+ return _context67.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6691
6772
  status: false,
6692
6773
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
6693
6774
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -6696,11 +6777,11 @@ var Server = /*#__PURE__*/function () {
6696
6777
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6697
6778
  syncedOrder = syncResult.syncedOrder;
6698
6779
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(syncedOrder))) {
6699
- _context66.next = 23;
6780
+ _context67.next = 23;
6700
6781
  break;
6701
6782
  }
6702
- _context66.prev = 14;
6703
- _context66.next = 17;
6783
+ _context67.prev = 14;
6784
+ _context67.next = 17;
6704
6785
  return this.dispatchLocalReceiptPrint({
6705
6786
  checkoutData: syncResult.checkoutData,
6706
6787
  order: syncedOrder,
@@ -6710,41 +6791,41 @@ var Server = /*#__PURE__*/function () {
6710
6791
  invoiceTemplateSettings: invoiceTemplateSettings
6711
6792
  });
6712
6793
  case 17:
6713
- _context66.next = 23;
6794
+ _context67.next = 23;
6714
6795
  break;
6715
6796
  case 19:
6716
- _context66.prev = 19;
6717
- _context66.t0 = _context66["catch"](14);
6797
+ _context67.prev = 19;
6798
+ _context67.t0 = _context67["catch"](14);
6718
6799
  // Checkout already succeeded remotely; report the receipt failure
6719
6800
  // separately instead of implying that payment/order creation failed.
6720
- response.receipt_print_error = this.getUnknownErrorMessage(_context66.t0);
6801
+ response.receipt_print_error = this.getUnknownErrorMessage(_context67.t0);
6721
6802
  this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
6722
6803
  error: response.receipt_print_error
6723
6804
  });
6724
6805
  case 23:
6725
- return _context66.abrupt("return", response);
6806
+ return _context67.abrupt("return", response);
6726
6807
  case 26:
6727
- _context66.prev = 26;
6728
- _context66.t1 = _context66["catch"](4);
6729
- backendError = this.extractBackendErrorResponse(_context66.t1);
6808
+ _context67.prev = 26;
6809
+ _context67.t1 = _context67["catch"](4);
6810
+ backendError = this.extractBackendErrorResponse(_context67.t1);
6730
6811
  if (!backendError) {
6731
- _context66.next = 32;
6812
+ _context67.next = 32;
6732
6813
  break;
6733
6814
  }
6734
6815
  _normalized = this.normalizeCheckoutResponse(backendError);
6735
- return _context66.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6816
+ return _context67.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6736
6817
  status: false,
6737
6818
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6738
6819
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6739
6820
  }));
6740
6821
  case 32:
6741
- message = this.getUnknownErrorMessage(_context66.t1);
6822
+ message = this.getUnknownErrorMessage(_context67.t1);
6742
6823
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6743
6824
  backendPath: backendPath,
6744
6825
  error: message,
6745
- error_detail: this.normalizeUnknownError(_context66.t1)
6826
+ error_detail: this.normalizeUnknownError(_context67.t1)
6746
6827
  });
6747
- return _context66.abrupt("return", {
6828
+ return _context67.abrupt("return", {
6748
6829
  code: 500,
6749
6830
  status: false,
6750
6831
  message: message,
@@ -6752,11 +6833,11 @@ var Server = /*#__PURE__*/function () {
6752
6833
  });
6753
6834
  case 35:
6754
6835
  case "end":
6755
- return _context66.stop();
6836
+ return _context67.stop();
6756
6837
  }
6757
- }, _callee66, this, [[4, 26], [14, 19]]);
6838
+ }, _callee67, this, [[4, 26], [14, 19]]);
6758
6839
  }));
6759
- function handleSyncCheckoutSubmit(_x72) {
6840
+ function handleSyncCheckoutSubmit(_x74) {
6760
6841
  return _handleSyncCheckoutSubmit.apply(this, arguments);
6761
6842
  }
6762
6843
  return handleSyncCheckoutSubmit;
@@ -6764,10 +6845,10 @@ var Server = /*#__PURE__*/function () {
6764
6845
  }, {
6765
6846
  key: "handleOrderDraftSubmit",
6766
6847
  value: function () {
6767
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6848
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6768
6849
  var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6769
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6770
- while (1) switch (_context67.prev = _context67.next) {
6850
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6851
+ while (1) switch (_context68.prev = _context68.next) {
6771
6852
  case 0:
6772
6853
  title = params.title;
6773
6854
  extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
@@ -6781,10 +6862,10 @@ var Server = /*#__PURE__*/function () {
6781
6862
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6782
6863
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6783
6864
  });
6784
- _context67.next = 6;
6865
+ _context68.next = 6;
6785
6866
  return this.normalizeCheckoutSubmitData(data, title);
6786
6867
  case 6:
6787
- normalizedData = _context67.sent;
6868
+ normalizedData = _context68.sent;
6788
6869
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6789
6870
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6790
6871
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6794,26 +6875,26 @@ var Server = /*#__PURE__*/function () {
6794
6875
  is_draft_order: 1
6795
6876
  });
6796
6877
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6797
- _context67.next = 12;
6878
+ _context68.next = 12;
6798
6879
  break;
6799
6880
  }
6800
6881
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6801
- return _context67.abrupt("return", {
6882
+ return _context68.abrupt("return", {
6802
6883
  code: 500,
6803
6884
  status: false,
6804
6885
  message: 'Order 模块不支持本地草稿写入',
6805
6886
  data: null
6806
6887
  });
6807
6888
  case 12:
6808
- _context67.prev = 12;
6809
- _context67.next = 15;
6889
+ _context68.prev = 12;
6890
+ _context68.next = 15;
6810
6891
  return this.order.upsertLocalDraftOrders([draftOrder]);
6811
6892
  case 15:
6812
6893
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6813
6894
  order_id: draftOrder.order_id,
6814
6895
  external_sale_number: draftOrder.external_sale_number
6815
6896
  });
6816
- return _context67.abrupt("return", {
6897
+ return _context68.abrupt("return", {
6817
6898
  code: 200,
6818
6899
  status: true,
6819
6900
  message: '',
@@ -6825,13 +6906,13 @@ var Server = /*#__PURE__*/function () {
6825
6906
  })
6826
6907
  });
6827
6908
  case 19:
6828
- _context67.prev = 19;
6829
- _context67.t0 = _context67["catch"](12);
6830
- errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
6909
+ _context68.prev = 19;
6910
+ _context68.t0 = _context68["catch"](12);
6911
+ errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
6831
6912
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6832
6913
  error: errorMessage
6833
6914
  });
6834
- return _context67.abrupt("return", {
6915
+ return _context68.abrupt("return", {
6835
6916
  code: 500,
6836
6917
  status: false,
6837
6918
  message: errorMessage,
@@ -6839,11 +6920,11 @@ var Server = /*#__PURE__*/function () {
6839
6920
  });
6840
6921
  case 24:
6841
6922
  case "end":
6842
- return _context67.stop();
6923
+ return _context68.stop();
6843
6924
  }
6844
- }, _callee67, this, [[12, 19]]);
6925
+ }, _callee68, this, [[12, 19]]);
6845
6926
  }));
6846
- function handleOrderDraftSubmit(_x73) {
6927
+ function handleOrderDraftSubmit(_x75) {
6847
6928
  return _handleOrderDraftSubmit.apply(this, arguments);
6848
6929
  }
6849
6930
  return handleOrderDraftSubmit;
@@ -6851,26 +6932,26 @@ var Server = /*#__PURE__*/function () {
6851
6932
  }, {
6852
6933
  key: "handlePendingSyncCheckoutOrder",
6853
6934
  value: function () {
6854
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6855
- var _this17 = this;
6935
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6936
+ var _this18 = this;
6856
6937
  var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6857
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6858
- while (1) switch (_context68.prev = _context68.next) {
6938
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6939
+ while (1) switch (_context69.prev = _context69.next) {
6859
6940
  case 0:
6860
6941
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
6861
- _context68.next = 3;
6942
+ _context69.next = 3;
6862
6943
  return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
6863
6944
  case 3:
6864
- pendingOrder = _context68.sent;
6945
+ pendingOrder = _context69.sent;
6865
6946
  if (pendingOrder) {
6866
- _context68.next = 7;
6947
+ _context69.next = 7;
6867
6948
  break;
6868
6949
  }
6869
6950
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
6870
6951
  backendPath: backendPath,
6871
6952
  reason: reason
6872
6953
  });
6873
- return _context68.abrupt("return", {
6954
+ return _context69.abrupt("return", {
6874
6955
  code: 500,
6875
6956
  status: false,
6876
6957
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -6878,22 +6959,22 @@ var Server = /*#__PURE__*/function () {
6878
6959
  });
6879
6960
  case 7:
6880
6961
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6881
- _context68.next = 10;
6962
+ _context69.next = 10;
6882
6963
  break;
6883
6964
  }
6884
6965
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6885
6966
  backendPath: backendPath,
6886
6967
  reason: reason
6887
6968
  });
6888
- return _context68.abrupt("return", {
6969
+ return _context69.abrupt("return", {
6889
6970
  code: 500,
6890
6971
  status: false,
6891
6972
  message: 'Order 模块不支持本地待同步写入',
6892
6973
  data: null
6893
6974
  });
6894
6975
  case 10:
6895
- _context68.prev = 10;
6896
- _context68.next = 13;
6976
+ _context69.prev = 10;
6977
+ _context69.next = 13;
6897
6978
  return this.order.upsertPendingSyncOrders([pendingOrder]);
6898
6979
  case 13:
6899
6980
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -6905,9 +6986,9 @@ var Server = /*#__PURE__*/function () {
6905
6986
  });
6906
6987
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6907
6988
  var _payment$metadata;
6908
- return sum + _this17.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6989
+ return sum + _this18.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6909
6990
  }, 0);
6910
- return _context68.abrupt("return", {
6991
+ return _context69.abrupt("return", {
6911
6992
  code: 200,
6912
6993
  status: true,
6913
6994
  message: '',
@@ -6922,15 +7003,15 @@ var Server = /*#__PURE__*/function () {
6922
7003
  })
6923
7004
  });
6924
7005
  case 18:
6925
- _context68.prev = 18;
6926
- _context68.t0 = _context68["catch"](10);
6927
- errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
7006
+ _context69.prev = 18;
7007
+ _context69.t0 = _context69["catch"](10);
7008
+ errorMessage = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
6928
7009
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
6929
7010
  backendPath: backendPath,
6930
7011
  reason: reason,
6931
7012
  error: errorMessage
6932
7013
  });
6933
- return _context68.abrupt("return", {
7014
+ return _context69.abrupt("return", {
6934
7015
  code: 500,
6935
7016
  status: false,
6936
7017
  message: errorMessage,
@@ -6938,11 +7019,11 @@ var Server = /*#__PURE__*/function () {
6938
7019
  });
6939
7020
  case 23:
6940
7021
  case "end":
6941
- return _context68.stop();
7022
+ return _context69.stop();
6942
7023
  }
6943
- }, _callee68, this, [[10, 18]]);
7024
+ }, _callee69, this, [[10, 18]]);
6944
7025
  }));
6945
- function handlePendingSyncCheckoutOrder(_x74) {
7026
+ function handlePendingSyncCheckoutOrder(_x76) {
6946
7027
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
6947
7028
  }
6948
7029
  return handlePendingSyncCheckoutOrder;
@@ -6950,45 +7031,45 @@ var Server = /*#__PURE__*/function () {
6950
7031
  }, {
6951
7032
  key: "buildPendingSyncCheckoutOrder",
6952
7033
  value: function () {
6953
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(data, invoiceTemplateSettings) {
7034
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(data, invoiceTemplateSettings) {
6954
7035
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6955
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6956
- while (1) switch (_context69.prev = _context69.next) {
7036
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7037
+ while (1) switch (_context70.prev = _context70.next) {
6957
7038
  case 0:
6958
7039
  if (!(!data || _typeof(data) !== 'object')) {
6959
- _context69.next = 2;
7040
+ _context70.next = 2;
6960
7041
  break;
6961
7042
  }
6962
- return _context69.abrupt("return", null);
7043
+ return _context70.abrupt("return", null);
6963
7044
  case 2:
6964
7045
  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 !== '';
6965
7046
  if (hasStorageKey) {
6966
- _context69.next = 5;
7047
+ _context70.next = 5;
6967
7048
  break;
6968
7049
  }
6969
- return _context69.abrupt("return", null);
7050
+ return _context70.abrupt("return", null);
6970
7051
  case 5:
6971
7052
  pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
6972
7053
  need_sync: 1,
6973
7054
  is_draft_order: 0
6974
7055
  }));
6975
- _context69.next = 8;
7056
+ _context70.next = 8;
6976
7057
  return this.buildSmallTicketProductMap(pendingOrder);
6977
7058
  case 8:
6978
- productMap = _context69.sent;
7059
+ productMap = _context70.sent;
6979
7060
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6980
- return _context69.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
7061
+ return _context70.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6981
7062
  requireFullyPaid: true,
6982
7063
  productMap: productMap,
6983
7064
  invoiceTemplateSettings: invoiceTemplateSettings
6984
7065
  }));
6985
7066
  case 11:
6986
7067
  case "end":
6987
- return _context69.stop();
7068
+ return _context70.stop();
6988
7069
  }
6989
- }, _callee69, this);
7070
+ }, _callee70, this);
6990
7071
  }));
6991
- function buildPendingSyncCheckoutOrder(_x75, _x76) {
7072
+ function buildPendingSyncCheckoutOrder(_x77, _x78) {
6992
7073
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6993
7074
  }
6994
7075
  return buildPendingSyncCheckoutOrder;
@@ -7065,13 +7146,13 @@ var Server = /*#__PURE__*/function () {
7065
7146
  }, {
7066
7147
  key: "sumPaidOrderPayments",
7067
7148
  value: function sumPaidOrderPayments(payments) {
7068
- var _this18 = this;
7149
+ var _this19 = this;
7069
7150
  if (!Array.isArray(payments)) return 0;
7070
7151
  return payments.reduce(function (sum, payment) {
7071
7152
  var _payment$amount;
7072
7153
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
7073
7154
  if (status !== 'paid') return sum;
7074
- return sum + _this18.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);
7155
+ return sum + _this19.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
7075
7156
  }, 0);
7076
7157
  }
7077
7158
  }, {
@@ -7085,12 +7166,12 @@ var Server = /*#__PURE__*/function () {
7085
7166
  }, {
7086
7167
  key: "buildSmallTicketProductMap",
7087
7168
  value: function () {
7088
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(order) {
7169
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
7089
7170
  var _this$products3,
7090
- _this19 = this;
7171
+ _this20 = this;
7091
7172
  var products, productIdSet, productIds, entries;
7092
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7093
- while (1) switch (_context71.prev = _context71.next) {
7173
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7174
+ while (1) switch (_context72.prev = _context72.next) {
7094
7175
  case 0:
7095
7176
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
7096
7177
  productIdSet = new Set();
@@ -7112,45 +7193,45 @@ var Server = /*#__PURE__*/function () {
7112
7193
  });
7113
7194
  productIds = Array.from(productIdSet);
7114
7195
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
7115
- _context71.next = 6;
7196
+ _context72.next = 6;
7116
7197
  break;
7117
7198
  }
7118
- return _context71.abrupt("return", {});
7199
+ return _context72.abrupt("return", {});
7119
7200
  case 6:
7120
- _context71.next = 8;
7201
+ _context72.next = 8;
7121
7202
  return Promise.all(productIds.map( /*#__PURE__*/function () {
7122
- var _ref76 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(id) {
7123
- var _this19$products, _this19$products$getP, product;
7124
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7125
- while (1) switch (_context70.prev = _context70.next) {
7203
+ var _ref76 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(id) {
7204
+ var _this20$products, _this20$products$getP, product;
7205
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7206
+ while (1) switch (_context71.prev = _context71.next) {
7126
7207
  case 0:
7127
- _context70.prev = 0;
7128
- _context70.next = 3;
7129
- return (_this19$products = _this19.products) === null || _this19$products === void 0 || (_this19$products$getP = _this19$products.getProductById) === null || _this19$products$getP === void 0 ? void 0 : _this19$products$getP.call(_this19$products, Number(id));
7208
+ _context71.prev = 0;
7209
+ _context71.next = 3;
7210
+ return (_this20$products = _this20.products) === null || _this20$products === void 0 || (_this20$products$getP = _this20$products.getProductById) === null || _this20$products$getP === void 0 ? void 0 : _this20$products$getP.call(_this20$products, Number(id));
7130
7211
  case 3:
7131
- product = _context70.sent;
7132
- return _context70.abrupt("return", product ? [String(id), product] : null);
7212
+ product = _context71.sent;
7213
+ return _context71.abrupt("return", product ? [String(id), product] : null);
7133
7214
  case 7:
7134
- _context70.prev = 7;
7135
- _context70.t0 = _context70["catch"](0);
7136
- _this19.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7215
+ _context71.prev = 7;
7216
+ _context71.t0 = _context71["catch"](0);
7217
+ _this20.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
7137
7218
  product_id: id,
7138
- error: _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0)
7219
+ error: _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0)
7139
7220
  });
7140
- return _context70.abrupt("return", null);
7221
+ return _context71.abrupt("return", null);
7141
7222
  case 11:
7142
7223
  case "end":
7143
- return _context70.stop();
7224
+ return _context71.stop();
7144
7225
  }
7145
- }, _callee70, null, [[0, 7]]);
7226
+ }, _callee71, null, [[0, 7]]);
7146
7227
  }));
7147
- return function (_x78) {
7228
+ return function (_x80) {
7148
7229
  return _ref76.apply(this, arguments);
7149
7230
  };
7150
7231
  }()));
7151
7232
  case 8:
7152
- entries = _context71.sent;
7153
- return _context71.abrupt("return", entries.reduce(function (map, entry) {
7233
+ entries = _context72.sent;
7234
+ return _context72.abrupt("return", entries.reduce(function (map, entry) {
7154
7235
  if (!entry) return map;
7155
7236
  var _entry = _slicedToArray(entry, 2),
7156
7237
  id = _entry[0],
@@ -7160,11 +7241,11 @@ var Server = /*#__PURE__*/function () {
7160
7241
  }, {}));
7161
7242
  case 10:
7162
7243
  case "end":
7163
- return _context71.stop();
7244
+ return _context72.stop();
7164
7245
  }
7165
- }, _callee71, this);
7246
+ }, _callee72, this);
7166
7247
  }));
7167
- function buildSmallTicketProductMap(_x77) {
7248
+ function buildSmallTicketProductMap(_x79) {
7168
7249
  return _buildSmallTicketProductMap.apply(this, arguments);
7169
7250
  }
7170
7251
  return buildSmallTicketProductMap;
@@ -7194,40 +7275,40 @@ var Server = /*#__PURE__*/function () {
7194
7275
  }, {
7195
7276
  key: "buildSalesDetailProductSnapshotMap",
7196
7277
  value: function () {
7197
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
7278
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(order) {
7198
7279
  var _this$products4;
7199
7280
  var productIds, getSnapshots;
7200
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7201
- while (1) switch (_context72.prev = _context72.next) {
7281
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7282
+ while (1) switch (_context73.prev = _context73.next) {
7202
7283
  case 0:
7203
7284
  productIds = this.collectSalesDetailProductIds(order);
7204
7285
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
7205
7286
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
7206
- _context72.next = 4;
7287
+ _context73.next = 4;
7207
7288
  break;
7208
7289
  }
7209
- return _context72.abrupt("return", {});
7290
+ return _context73.abrupt("return", {});
7210
7291
  case 4:
7211
- _context72.prev = 4;
7212
- _context72.next = 7;
7292
+ _context73.prev = 4;
7293
+ _context73.next = 7;
7213
7294
  return getSnapshots.call(this.products, productIds);
7214
7295
  case 7:
7215
- return _context72.abrupt("return", _context72.sent);
7296
+ return _context73.abrupt("return", _context73.sent);
7216
7297
  case 10:
7217
- _context72.prev = 10;
7218
- _context72.t0 = _context72["catch"](4);
7298
+ _context73.prev = 10;
7299
+ _context73.t0 = _context73["catch"](4);
7219
7300
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
7220
7301
  product_ids: productIds,
7221
- error: _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0)
7302
+ error: _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0)
7222
7303
  });
7223
- return _context72.abrupt("return", {});
7304
+ return _context73.abrupt("return", {});
7224
7305
  case 14:
7225
7306
  case "end":
7226
- return _context72.stop();
7307
+ return _context73.stop();
7227
7308
  }
7228
- }, _callee72, this, [[4, 10]]);
7309
+ }, _callee73, this, [[4, 10]]);
7229
7310
  }));
7230
- function buildSalesDetailProductSnapshotMap(_x79) {
7311
+ function buildSalesDetailProductSnapshotMap(_x81) {
7231
7312
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
7232
7313
  }
7233
7314
  return buildSalesDetailProductSnapshotMap;
@@ -7283,53 +7364,53 @@ var Server = /*#__PURE__*/function () {
7283
7364
  }, {
7284
7365
  key: "withSalesDetailProductSnapshots",
7285
7366
  value: function () {
7286
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(order) {
7287
- var _this20 = this;
7367
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7368
+ var _this21 = this;
7288
7369
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
7289
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7290
- while (1) switch (_context73.prev = _context73.next) {
7370
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7371
+ while (1) switch (_context74.prev = _context74.next) {
7291
7372
  case 0:
7292
7373
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
7293
7374
  if (products !== null && products !== void 0 && products.length) {
7294
- _context73.next = 3;
7375
+ _context74.next = 3;
7295
7376
  break;
7296
7377
  }
7297
- return _context73.abrupt("return", order);
7378
+ return _context74.abrupt("return", order);
7298
7379
  case 3:
7299
- _context73.next = 5;
7380
+ _context74.next = 5;
7300
7381
  return this.buildSalesDetailProductSnapshotMap(order);
7301
7382
  case 5:
7302
- snapshotMap = _context73.sent;
7383
+ snapshotMap = _context74.sent;
7303
7384
  if (Object.keys(snapshotMap).length) {
7304
- _context73.next = 8;
7385
+ _context74.next = 8;
7305
7386
  break;
7306
7387
  }
7307
- return _context73.abrupt("return", order);
7388
+ return _context74.abrupt("return", order);
7308
7389
  case 8:
7309
7390
  hasChanged = false;
7310
7391
  enrichedProducts = products.map(function (product) {
7311
- var productWithBundleSnapshots = _this20.withBundleCatalogSnapshots(product, snapshotMap);
7312
- var nextProduct = _this20.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7392
+ var productWithBundleSnapshots = _this21.withBundleCatalogSnapshots(product, snapshotMap);
7393
+ var nextProduct = _this21.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
7313
7394
  if (nextProduct !== product) hasChanged = true;
7314
7395
  return nextProduct;
7315
7396
  });
7316
7397
  if (hasChanged) {
7317
- _context73.next = 12;
7398
+ _context74.next = 12;
7318
7399
  break;
7319
7400
  }
7320
- return _context73.abrupt("return", order);
7401
+ return _context74.abrupt("return", order);
7321
7402
  case 12:
7322
7403
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
7323
7404
  products: enrichedProducts
7324
7405
  });
7325
- return _context73.abrupt("return", enrichedOrder);
7406
+ return _context74.abrupt("return", enrichedOrder);
7326
7407
  case 14:
7327
7408
  case "end":
7328
- return _context73.stop();
7409
+ return _context74.stop();
7329
7410
  }
7330
- }, _callee73, this);
7411
+ }, _callee74, this);
7331
7412
  }));
7332
- function withSalesDetailProductSnapshots(_x80) {
7413
+ function withSalesDetailProductSnapshots(_x82) {
7333
7414
  return _withSalesDetailProductSnapshots.apply(this, arguments);
7334
7415
  }
7335
7416
  return withSalesDetailProductSnapshots;
@@ -7337,13 +7418,13 @@ var Server = /*#__PURE__*/function () {
7337
7418
  }, {
7338
7419
  key: "withPendingSyncProductTitles",
7339
7420
  value: function withPendingSyncProductTitles(order, productMap) {
7340
- var _this21 = this;
7421
+ var _this22 = this;
7341
7422
  var products = Array.isArray(order.products) ? order.products : null;
7342
7423
  if (!(products !== null && products !== void 0 && products.length)) return order;
7343
7424
  return _objectSpread(_objectSpread({}, order), {}, {
7344
7425
  products: products.map(function (product) {
7345
7426
  return _objectSpread(_objectSpread({}, product), {}, {
7346
- product_title: _this21.buildProductTitleSnapshot(product, productMap)
7427
+ product_title: _this22.buildProductTitleSnapshot(product, productMap)
7347
7428
  });
7348
7429
  })
7349
7430
  });
@@ -7354,7 +7435,7 @@ var Server = /*#__PURE__*/function () {
7354
7435
  var _product$product_id4,
7355
7436
  _product$product,
7356
7437
  _fallbackProduct$prod,
7357
- _this22 = this;
7438
+ _this23 = this;
7358
7439
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
7359
7440
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
7360
7441
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -7362,7 +7443,7 @@ var Server = /*#__PURE__*/function () {
7362
7443
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
7363
7444
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
7364
7445
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
7365
- snapshot[key] = _this22.resolveProductTitleValue(ownTitle, key, currentLocale) || _this22.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7446
+ snapshot[key] = _this23.resolveProductTitleValue(ownTitle, key, currentLocale) || _this23.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
7366
7447
  return snapshot;
7367
7448
  }, {});
7368
7449
  }
@@ -7460,31 +7541,31 @@ var Server = /*#__PURE__*/function () {
7460
7541
  }, {
7461
7542
  key: "enrichPaymentNamesByCode",
7462
7543
  value: function () {
7463
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
7464
- var _this23 = this;
7544
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
7545
+ var _this24 = this;
7465
7546
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
7466
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7467
- while (1) switch (_context74.prev = _context74.next) {
7547
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7548
+ while (1) switch (_context75.prev = _context75.next) {
7468
7549
  case 0:
7469
7550
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
7470
7551
  hasMissingName = payments.some(function (payment) {
7471
- return _this23.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this23.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7552
+ return _this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7472
7553
  });
7473
7554
  if (hasMissingName) {
7474
- _context74.next = 4;
7555
+ _context75.next = 4;
7475
7556
  break;
7476
7557
  }
7477
- return _context74.abrupt("return", order);
7558
+ return _context75.abrupt("return", order);
7478
7559
  case 4:
7479
- _context74.prev = 4;
7480
- _context74.next = 7;
7560
+ _context75.prev = 4;
7561
+ _context75.next = 7;
7481
7562
  return this.getPaymentRouteModule();
7482
7563
  case 7:
7483
- paymentModule = _context74.sent;
7484
- _context74.next = 10;
7564
+ paymentModule = _context75.sent;
7565
+ _context75.next = 10;
7485
7566
  return paymentModule.getPayMethodListAsync();
7486
7567
  case 10:
7487
- payMethods = _context74.sent;
7568
+ payMethods = _context75.sent;
7488
7569
  nameByCode = new Map();
7489
7570
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
7490
7571
  try {
@@ -7501,9 +7582,9 @@ var Server = /*#__PURE__*/function () {
7501
7582
  }
7502
7583
  hasResolvedName = false;
7503
7584
  enrichedPayments = payments.map(function (payment) {
7504
- if (!_this23.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7505
- if (!_this23.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7506
- var name = nameByCode.get(_this23.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7585
+ if (!_this24.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7586
+ if (!_this24.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7587
+ var name = nameByCode.get(_this24.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7507
7588
  if (!name) return payment;
7508
7589
  hasResolvedName = true;
7509
7590
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -7511,28 +7592,28 @@ var Server = /*#__PURE__*/function () {
7511
7592
  });
7512
7593
  });
7513
7594
  if (hasResolvedName) {
7514
- _context74.next = 18;
7595
+ _context75.next = 18;
7515
7596
  break;
7516
7597
  }
7517
- return _context74.abrupt("return", order);
7598
+ return _context75.abrupt("return", order);
7518
7599
  case 18:
7519
- return _context74.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7600
+ return _context75.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7520
7601
  payments: enrichedPayments
7521
7602
  }));
7522
7603
  case 21:
7523
- _context74.prev = 21;
7524
- _context74.t0 = _context74["catch"](4);
7604
+ _context75.prev = 21;
7605
+ _context75.t0 = _context75["catch"](4);
7525
7606
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
7526
- error: _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0)
7607
+ error: _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0)
7527
7608
  });
7528
- return _context74.abrupt("return", order);
7609
+ return _context75.abrupt("return", order);
7529
7610
  case 25:
7530
7611
  case "end":
7531
- return _context74.stop();
7612
+ return _context75.stop();
7532
7613
  }
7533
- }, _callee74, this, [[4, 21]]);
7614
+ }, _callee75, this, [[4, 21]]);
7534
7615
  }));
7535
- function enrichPaymentNamesByCode(_x81) {
7616
+ function enrichPaymentNamesByCode(_x83) {
7536
7617
  return _enrichPaymentNamesByCode.apply(this, arguments);
7537
7618
  }
7538
7619
  return enrichPaymentNamesByCode;
@@ -7540,25 +7621,25 @@ var Server = /*#__PURE__*/function () {
7540
7621
  }, {
7541
7622
  key: "withLocalSmallTicketData",
7542
7623
  value: function () {
7543
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order, options) {
7624
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order, options) {
7544
7625
  var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref81, _ref82, _order_id, enrichedOrder, productMap, smallTicketData;
7545
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7546
- while (1) switch (_context75.prev = _context75.next) {
7626
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7627
+ while (1) switch (_context76.prev = _context76.next) {
7547
7628
  case 0:
7548
7629
  mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
7549
7630
  if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
7550
- _context75.next = 3;
7631
+ _context76.next = 3;
7551
7632
  break;
7552
7633
  }
7553
- return _context75.abrupt("return", order);
7634
+ return _context76.abrupt("return", order);
7554
7635
  case 3:
7555
7636
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
7556
- _context75.next = 5;
7637
+ _context76.next = 5;
7557
7638
  break;
7558
7639
  }
7559
- return _context75.abrupt("return", order);
7640
+ return _context76.abrupt("return", order);
7560
7641
  case 5:
7561
- _context75.prev = 5;
7642
+ _context76.prev = 5;
7562
7643
  normalizedCollections = normalizeOrderCollections(order, {
7563
7644
  ensureUid: false
7564
7645
  });
@@ -7576,24 +7657,24 @@ var Server = /*#__PURE__*/function () {
7576
7657
  collapsed_duplicate_counts: collapsedDuplicateCounts
7577
7658
  });
7578
7659
  }
7579
- _context75.next = 12;
7660
+ _context76.next = 12;
7580
7661
  return this.enrichPaymentNamesByCode(normalizedOrder);
7581
7662
  case 12:
7582
- enrichedOrder = _context75.sent;
7663
+ enrichedOrder = _context76.sent;
7583
7664
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7584
- _context75.next = 17;
7665
+ _context76.next = 17;
7585
7666
  break;
7586
7667
  }
7587
- _context75.t0 = _options$productMap;
7588
- _context75.next = 20;
7668
+ _context76.t0 = _options$productMap;
7669
+ _context76.next = 20;
7589
7670
  break;
7590
7671
  case 17:
7591
- _context75.next = 19;
7672
+ _context76.next = 19;
7592
7673
  return this.buildSmallTicketProductMap(enrichedOrder);
7593
7674
  case 19:
7594
- _context75.t0 = _context75.sent;
7675
+ _context76.t0 = _context76.sent;
7595
7676
  case 20:
7596
- productMap = _context75.t0;
7677
+ productMap = _context76.t0;
7597
7678
  smallTicketData = buildSmallTicketData({
7598
7679
  order: enrichedOrder,
7599
7680
  shopInfo: this.getSmallTicketShopInfo(),
@@ -7602,31 +7683,31 @@ var Server = /*#__PURE__*/function () {
7602
7683
  includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
7603
7684
  templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
7604
7685
  });
7605
- return _context75.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7686
+ return _context76.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7606
7687
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7607
7688
  small_ticket_data: smallTicketData
7608
7689
  })
7609
7690
  }));
7610
7691
  case 25:
7611
- _context75.prev = 25;
7612
- _context75.t1 = _context75["catch"](5);
7692
+ _context76.prev = 25;
7693
+ _context76.t1 = _context76["catch"](5);
7613
7694
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7614
- error: _context75.t1 instanceof Error ? _context75.t1.message : String(_context75.t1)
7695
+ error: _context76.t1 instanceof Error ? _context76.t1.message : String(_context76.t1)
7615
7696
  });
7616
7697
  if (!mustApplyVisibility) {
7617
- _context75.next = 30;
7698
+ _context76.next = 30;
7618
7699
  break;
7619
7700
  }
7620
- throw _context75.t1;
7701
+ throw _context76.t1;
7621
7702
  case 30:
7622
- return _context75.abrupt("return", order);
7703
+ return _context76.abrupt("return", order);
7623
7704
  case 31:
7624
7705
  case "end":
7625
- return _context75.stop();
7706
+ return _context76.stop();
7626
7707
  }
7627
- }, _callee75, this, [[5, 25]]);
7708
+ }, _callee76, this, [[5, 25]]);
7628
7709
  }));
7629
- function withLocalSmallTicketData(_x82, _x83) {
7710
+ function withLocalSmallTicketData(_x84, _x85) {
7630
7711
  return _withLocalSmallTicketData.apply(this, arguments);
7631
7712
  }
7632
7713
  return withLocalSmallTicketData;
@@ -7641,37 +7722,37 @@ var Server = /*#__PURE__*/function () {
7641
7722
  }, {
7642
7723
  key: "fetchAndPersistSalesOrderByLookup",
7643
7724
  value: function () {
7644
- var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(lookup, data, title) {
7645
- var _this$order6, _this$order7, _this$app17;
7646
- var backendPath, _this$order$getLocalO, _this$order8, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref83, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7647
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7648
- while (1) switch (_context76.prev = _context76.next) {
7725
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(lookup, data, title, paymentIdentityOrder) {
7726
+ var _this$order7, _this$order8, _this$app17;
7727
+ var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref83, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7728
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7729
+ while (1) switch (_context77.prev = _context77.next) {
7649
7730
  case 0:
7650
- if (!(!((_this$order6 = this.order) !== null && _this$order6 !== void 0 && _this$order6.getLocalOrderByLookup) || !((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.upsertOrdersFromRemote))) {
7651
- _context76.next = 3;
7731
+ if (!(!((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.getLocalOrderByLookup) || !((_this$order8 = this.order) !== null && _this$order8 !== void 0 && _this$order8.upsertOrdersFromRemote))) {
7732
+ _context77.next = 3;
7652
7733
  break;
7653
7734
  }
7654
7735
  this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7655
- return _context76.abrupt("return", {
7736
+ return _context77.abrupt("return", {
7656
7737
  code: 500,
7657
7738
  message: 'Order 模块未注册',
7658
7739
  order: null
7659
7740
  });
7660
7741
  case 3:
7661
7742
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.get) {
7662
- _context76.next = 6;
7743
+ _context77.next = 6;
7663
7744
  break;
7664
7745
  }
7665
7746
  this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7666
- return _context76.abrupt("return", {
7747
+ return _context77.abrupt("return", {
7667
7748
  code: 500,
7668
7749
  message: 'app.request 不可用',
7669
7750
  order: null
7670
7751
  });
7671
7752
  case 6:
7672
7753
  backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
7673
- _context76.prev = 7;
7674
- _context76.next = 10;
7754
+ _context77.prev = 7;
7755
+ _context77.next = 10;
7675
7756
  return this.app.request.get(backendPath, {
7676
7757
  lookup_mode: 'multi'
7677
7758
  }, {
@@ -7679,9 +7760,9 @@ var Server = /*#__PURE__*/function () {
7679
7760
  customToast: function customToast() {}
7680
7761
  });
7681
7762
  case 10:
7682
- response = _context76.sent;
7763
+ response = _context77.sent;
7683
7764
  if (!this.isCheckoutResponseRejected(response)) {
7684
- _context76.next = 17;
7765
+ _context77.next = 17;
7685
7766
  break;
7686
7767
  }
7687
7768
  responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
@@ -7693,7 +7774,7 @@ var Server = /*#__PURE__*/function () {
7693
7774
  code: code,
7694
7775
  message: message
7695
7776
  });
7696
- return _context76.abrupt("return", {
7777
+ return _context77.abrupt("return", {
7697
7778
  code: code,
7698
7779
  message: message,
7699
7780
  order: null
@@ -7701,138 +7782,186 @@ var Server = /*#__PURE__*/function () {
7701
7782
  case 17:
7702
7783
  fresh = this.extractOrderDataFromCheckoutResponse(response);
7703
7784
  if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
7704
- _context76.next = 21;
7785
+ _context77.next = 21;
7705
7786
  break;
7706
7787
  }
7707
7788
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
7708
7789
  lookup: lookup,
7709
7790
  backendPath: backendPath
7710
7791
  });
7711
- return _context76.abrupt("return", {
7792
+ return _context77.abrupt("return", {
7712
7793
  code: 500,
7713
7794
  message: '后端返回订单为空',
7714
7795
  order: null
7715
7796
  });
7716
7797
  case 21:
7717
- _context76.t0 = (_this$order$getLocalO = (_this$order8 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order8, lookup);
7718
- if (_context76.t0) {
7719
- _context76.next = 31;
7798
+ _context77.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
7799
+ if (_context77.t0) {
7800
+ _context77.next = 31;
7720
7801
  break;
7721
7802
  }
7722
7803
  if (!this.shouldForceRemoteSalesDetail(data)) {
7723
- _context76.next = 29;
7804
+ _context77.next = 29;
7724
7805
  break;
7725
7806
  }
7726
- _context76.next = 26;
7807
+ _context77.next = 26;
7727
7808
  return this.order.getLocalOrderByLookup(lookup);
7728
7809
  case 26:
7729
- _context76.t1 = _context76.sent;
7730
- _context76.next = 30;
7810
+ _context77.t1 = _context77.sent;
7811
+ _context77.next = 30;
7731
7812
  break;
7732
7813
  case 29:
7733
- _context76.t1 = null;
7814
+ _context77.t1 = null;
7734
7815
  case 30:
7735
- _context76.t0 = _context76.t1;
7816
+ _context77.t0 = _context77.t1;
7736
7817
  case 31:
7737
- localBeforeRefresh = _context76.t0;
7818
+ localBeforeRefresh = _context77.t0;
7819
+ orderToPersist = fresh;
7820
+ if (!paymentIdentityOrder) {
7821
+ _context77.next = 44;
7822
+ break;
7823
+ }
7824
+ if (!(String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments))) {
7825
+ _context77.next = 36;
7826
+ break;
7827
+ }
7828
+ throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
7829
+ case 36:
7830
+ if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
7831
+ _context77.next = 38;
7832
+ break;
7833
+ }
7834
+ return _context77.abrupt("return", {
7835
+ code: 200,
7836
+ message: '',
7837
+ order: localBeforeRefresh || paymentIdentityOrder
7838
+ });
7839
+ case 38:
7840
+ remotePayments = fresh.payments;
7841
+ paidPayments = (localBeforeRefresh.payments || []).filter(function (payment) {
7842
+ return payment.status === 'paid';
7843
+ });
7844
+ paymentIdsComplete = paidPayments.every(function (payment) {
7845
+ var _matches$0$order_paym, _matches$, _matches$2;
7846
+ var localKeys = new Set(getOrderPaymentIdentityKeys(payment));
7847
+ var matches = remotePayments.filter(function (remotePayment) {
7848
+ return getOrderPaymentIdentityKeys(remotePayment).some(function (key) {
7849
+ return localKeys.has(key);
7850
+ });
7851
+ });
7852
+ var paymentId = (_matches$0$order_paym = (_matches$ = matches[0]) === null || _matches$ === void 0 ? void 0 : _matches$.order_payment_id) !== null && _matches$0$order_paym !== void 0 ? _matches$0$order_paym : (_matches$2 = matches[0]) === null || _matches$2 === void 0 ? void 0 : _matches$2.id;
7853
+ return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
7854
+ });
7855
+ if (paymentIdsComplete) {
7856
+ _context77.next = 43;
7857
+ break;
7858
+ }
7859
+ throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
7860
+ case 43:
7861
+ orderToPersist = _objectSpread(_objectSpread({}, fresh), {}, {
7862
+ payments: mergeOrderPaymentListsByIdentity(localBeforeRefresh.payments, remotePayments, {
7863
+ preserveUnmatchedExisting: true
7864
+ })
7865
+ });
7866
+ case 44:
7738
7867
  if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
7739
- _context76.next = 39;
7868
+ _context77.next = 51;
7740
7869
  break;
7741
7870
  }
7742
7871
  if (!(String(fresh.order_id) !== String(localBeforeRefresh.order_id))) {
7743
- _context76.next = 35;
7872
+ _context77.next = 47;
7744
7873
  break;
7745
7874
  }
7746
7875
  throw new Error('远端订单身份不匹配,请重新刷新');
7747
- case 35:
7748
- _context76.next = 37;
7749
- return this.order.completeLocalPaymentRefresh(fresh);
7750
- case 37:
7751
- _context76.next = 41;
7876
+ case 47:
7877
+ _context77.next = 49;
7878
+ return this.order.completeLocalPaymentRefresh(orderToPersist);
7879
+ case 49:
7880
+ _context77.next = 53;
7752
7881
  break;
7753
- case 39:
7754
- _context76.next = 41;
7755
- return this.order.upsertOrdersFromRemote([fresh]);
7756
- case 41:
7757
- _context76.next = 43;
7882
+ case 51:
7883
+ _context77.next = 53;
7884
+ return this.order.upsertOrdersFromRemote([orderToPersist]);
7885
+ case 53:
7886
+ _context77.next = 55;
7758
7887
  return this.order.getLocalOrderByLookup(lookup);
7759
- case 43:
7760
- savedOrder = _context76.sent;
7888
+ case 55:
7889
+ savedOrder = _context77.sent;
7761
7890
  if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
7762
- _context76.next = 48;
7891
+ _context77.next = 60;
7763
7892
  break;
7764
7893
  }
7765
- _context76.next = 47;
7894
+ _context77.next = 59;
7766
7895
  return this.order.getLocalOrderByLookup(fresh.order_id);
7767
- case 47:
7768
- savedOrder = _context76.sent;
7769
- case 48:
7896
+ case 59:
7897
+ savedOrder = _context77.sent;
7898
+ case 60:
7770
7899
  if (savedOrder) {
7771
- _context76.next = 51;
7900
+ _context77.next = 63;
7772
7901
  break;
7773
7902
  }
7774
7903
  this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
7775
7904
  lookup: lookup,
7776
7905
  remote_order_id: fresh.order_id
7777
7906
  });
7778
- return _context76.abrupt("return", {
7907
+ return _context77.abrupt("return", {
7779
7908
  code: 500,
7780
7909
  message: '订单写入后回读失败',
7781
7910
  order: null
7782
7911
  });
7783
- case 51:
7912
+ case 63:
7784
7913
  this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
7785
7914
  lookup: lookup,
7786
7915
  remote_order_id: fresh.order_id
7787
7916
  });
7788
- return _context76.abrupt("return", {
7917
+ return _context77.abrupt("return", {
7789
7918
  code: 200,
7790
7919
  message: '',
7791
7920
  order: savedOrder
7792
7921
  });
7793
- case 55:
7794
- _context76.prev = 55;
7795
- _context76.t2 = _context76["catch"](7);
7796
- backendError = this.extractBackendErrorResponse(_context76.t2);
7797
- errorRecord = _context76.t2;
7922
+ case 67:
7923
+ _context77.prev = 67;
7924
+ _context77.t2 = _context77["catch"](7);
7925
+ backendError = this.extractBackendErrorResponse(_context77.t2);
7926
+ errorRecord = _context77.t2;
7798
7927
  _responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
7799
7928
  if (!(backendError || _responseStatusCode !== undefined)) {
7800
- _context76.next = 66;
7929
+ _context77.next = 78;
7801
7930
  break;
7802
7931
  }
7803
7932
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
7804
7933
  _code = this.normalizeRemoteSalesOrderErrorCode((_ref83 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref83 !== void 0 ? _ref83 : _responseStatusCode);
7805
- _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context76.t2);
7934
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context77.t2);
7806
7935
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
7807
7936
  lookup: lookup,
7808
7937
  backendPath: backendPath,
7809
7938
  code: _code,
7810
7939
  message: _message2
7811
7940
  });
7812
- return _context76.abrupt("return", {
7941
+ return _context77.abrupt("return", {
7813
7942
  code: _code,
7814
7943
  message: _message2,
7815
7944
  order: null
7816
7945
  });
7817
- case 66:
7818
- _message3 = this.getUnknownErrorMessage(_context76.t2);
7946
+ case 78:
7947
+ _message3 = this.getUnknownErrorMessage(_context77.t2);
7819
7948
  this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
7820
7949
  lookup: lookup,
7821
7950
  backendPath: backendPath,
7822
7951
  error: _message3
7823
7952
  });
7824
- return _context76.abrupt("return", {
7953
+ return _context77.abrupt("return", {
7825
7954
  code: 500,
7826
7955
  message: _message3,
7827
7956
  order: null
7828
7957
  });
7829
- case 69:
7958
+ case 81:
7830
7959
  case "end":
7831
- return _context76.stop();
7960
+ return _context77.stop();
7832
7961
  }
7833
- }, _callee76, this, [[7, 55]]);
7962
+ }, _callee77, this, [[7, 67]]);
7834
7963
  }));
7835
- function fetchAndPersistSalesOrderByLookup(_x84, _x85, _x86) {
7964
+ function fetchAndPersistSalesOrderByLookup(_x86, _x87, _x88, _x89) {
7836
7965
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
7837
7966
  }
7838
7967
  return fetchAndPersistSalesOrderByLookup;
@@ -7894,22 +8023,22 @@ var Server = /*#__PURE__*/function () {
7894
8023
  }, {
7895
8024
  key: "handleUpdateLocalOrdersBatch",
7896
8025
  value: (function () {
7897
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(orderIds) {
8026
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(orderIds) {
7898
8027
  var _this$app18;
7899
8028
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
7900
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7901
- while (1) switch (_context77.prev = _context77.next) {
8029
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8030
+ while (1) switch (_context78.prev = _context78.next) {
7902
8031
  case 0:
7903
8032
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
7904
8033
  count: orderIds.length,
7905
8034
  orderIds: orderIds
7906
8035
  });
7907
8036
  if (this.order) {
7908
- _context77.next = 4;
8037
+ _context78.next = 4;
7909
8038
  break;
7910
8039
  }
7911
8040
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
7912
- return _context77.abrupt("return", {
8041
+ return _context78.abrupt("return", {
7913
8042
  code: 500,
7914
8043
  status: false,
7915
8044
  message: 'Order 模块未注册',
@@ -7917,11 +8046,11 @@ var Server = /*#__PURE__*/function () {
7917
8046
  });
7918
8047
  case 4:
7919
8048
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
7920
- _context77.next = 7;
8049
+ _context78.next = 7;
7921
8050
  break;
7922
8051
  }
7923
8052
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
7924
- return _context77.abrupt("return", {
8053
+ return _context78.abrupt("return", {
7925
8054
  code: 500,
7926
8055
  status: false,
7927
8056
  message: 'app.request 不可用',
@@ -7944,21 +8073,21 @@ var Server = /*#__PURE__*/function () {
7944
8073
  _iterator13.f();
7945
8074
  }
7946
8075
  fetched = [];
7947
- _context77.prev = 11;
7948
- _context77.next = 14;
8076
+ _context78.prev = 11;
8077
+ _context78.next = 14;
7949
8078
  return this.order.fetchOrdersByHttp(orderIds);
7950
8079
  case 14:
7951
- fetched = _context77.sent;
7952
- _context77.next = 22;
8080
+ fetched = _context78.sent;
8081
+ _context78.next = 22;
7953
8082
  break;
7954
8083
  case 17:
7955
- _context77.prev = 17;
7956
- _context77.t0 = _context77["catch"](11);
7957
- message = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8084
+ _context78.prev = 17;
8085
+ _context78.t0 = _context78["catch"](11);
8086
+ message = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
7958
8087
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
7959
8088
  message: message
7960
8089
  });
7961
- return _context77.abrupt("return", {
8090
+ return _context78.abrupt("return", {
7962
8091
  code: 500,
7963
8092
  status: false,
7964
8093
  message: message,
@@ -7968,36 +8097,36 @@ var Server = /*#__PURE__*/function () {
7968
8097
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
7969
8098
  fetchedMap = new Map();
7970
8099
  _iterator14 = _createForOfIteratorHelper(fetched);
7971
- _context77.prev = 24;
8100
+ _context78.prev = 24;
7972
8101
  _iterator14.s();
7973
8102
  case 26:
7974
8103
  if ((_step14 = _iterator14.n()).done) {
7975
- _context77.next = 34;
8104
+ _context78.next = 34;
7976
8105
  break;
7977
8106
  }
7978
8107
  order = _step14.value;
7979
8108
  oid = order === null || order === void 0 ? void 0 : order.order_id;
7980
8109
  if (!(oid === undefined || oid === null)) {
7981
- _context77.next = 31;
8110
+ _context78.next = 31;
7982
8111
  break;
7983
8112
  }
7984
- return _context77.abrupt("continue", 32);
8113
+ return _context78.abrupt("continue", 32);
7985
8114
  case 31:
7986
8115
  fetchedMap.set(String(oid), order);
7987
8116
  case 32:
7988
- _context77.next = 26;
8117
+ _context78.next = 26;
7989
8118
  break;
7990
8119
  case 34:
7991
- _context77.next = 39;
8120
+ _context78.next = 39;
7992
8121
  break;
7993
8122
  case 36:
7994
- _context77.prev = 36;
7995
- _context77.t1 = _context77["catch"](24);
7996
- _iterator14.e(_context77.t1);
8123
+ _context78.prev = 36;
8124
+ _context78.t1 = _context78["catch"](24);
8125
+ _iterator14.e(_context78.t1);
7997
8126
  case 39:
7998
- _context77.prev = 39;
8127
+ _context78.prev = 39;
7999
8128
  _iterator14.f();
8000
- return _context77.finish(39);
8129
+ return _context78.finish(39);
8001
8130
  case 42:
8002
8131
  freshOrders = [];
8003
8132
  succeedIds = [];
@@ -8023,23 +8152,23 @@ var Server = /*#__PURE__*/function () {
8023
8152
  _iterator15.f();
8024
8153
  }
8025
8154
  if (!(freshOrders.length > 0)) {
8026
- _context77.next = 58;
8155
+ _context78.next = 58;
8027
8156
  break;
8028
8157
  }
8029
- _context77.prev = 48;
8030
- _context77.next = 51;
8158
+ _context78.prev = 48;
8159
+ _context78.next = 51;
8031
8160
  return this.order.upsertOrdersFromRemote(freshOrders);
8032
8161
  case 51:
8033
- _context77.next = 58;
8162
+ _context78.next = 58;
8034
8163
  break;
8035
8164
  case 53:
8036
- _context77.prev = 53;
8037
- _context77.t2 = _context77["catch"](48);
8038
- _message4 = _context77.t2 instanceof Error ? _context77.t2.message : String(_context77.t2);
8165
+ _context78.prev = 53;
8166
+ _context78.t2 = _context78["catch"](48);
8167
+ _message4 = _context78.t2 instanceof Error ? _context78.t2.message : String(_context78.t2);
8039
8168
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
8040
8169
  message: _message4
8041
8170
  });
8042
- return _context77.abrupt("return", {
8171
+ return _context78.abrupt("return", {
8043
8172
  code: 500,
8044
8173
  status: false,
8045
8174
  message: _message4,
@@ -8058,7 +8187,7 @@ var Server = /*#__PURE__*/function () {
8058
8187
  insertedCount: inserted.length,
8059
8188
  failedCount: failed.length
8060
8189
  });
8061
- return _context77.abrupt("return", {
8190
+ return _context78.abrupt("return", {
8062
8191
  code: 200,
8063
8192
  status: true,
8064
8193
  message: '',
@@ -8070,11 +8199,11 @@ var Server = /*#__PURE__*/function () {
8070
8199
  });
8071
8200
  case 62:
8072
8201
  case "end":
8073
- return _context77.stop();
8202
+ return _context78.stop();
8074
8203
  }
8075
- }, _callee77, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8204
+ }, _callee78, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
8076
8205
  }));
8077
- function handleUpdateLocalOrdersBatch(_x87) {
8206
+ function handleUpdateLocalOrdersBatch(_x90) {
8078
8207
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
8079
8208
  }
8080
8209
  return handleUpdateLocalOrdersBatch;
@@ -8321,10 +8450,10 @@ var Server = /*#__PURE__*/function () {
8321
8450
  value: function extractBackendErrorResponse(error) {
8322
8451
  var _error$response3,
8323
8452
  _error$response4,
8324
- _this24 = this;
8453
+ _this25 = this;
8325
8454
  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];
8326
8455
  return candidates.find(function (candidate) {
8327
- return _this24.isExplicitBackendErrorResponse(candidate);
8456
+ return _this25.isExplicitBackendErrorResponse(candidate);
8328
8457
  }) || null;
8329
8458
  }
8330
8459
  }, {
@@ -8443,16 +8572,16 @@ var Server = /*#__PURE__*/function () {
8443
8572
  }, {
8444
8573
  key: "recomputeAndNotifyFloorPlanQuery",
8445
8574
  value: (function () {
8446
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8575
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8447
8576
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
8448
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8449
- while (1) switch (_context78.prev = _context78.next) {
8577
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8578
+ while (1) switch (_context79.prev = _context79.next) {
8450
8579
  case 0:
8451
8580
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
8452
- _context78.next = 2;
8581
+ _context79.next = 2;
8453
8582
  break;
8454
8583
  }
8455
- return _context78.abrupt("return");
8584
+ return _context79.abrupt("return");
8456
8585
  case 2:
8457
8586
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
8458
8587
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -8482,9 +8611,9 @@ var Server = /*#__PURE__*/function () {
8482
8611
  }
8483
8612
  case 5:
8484
8613
  case "end":
8485
- return _context78.stop();
8614
+ return _context79.stop();
8486
8615
  }
8487
- }, _callee78, this);
8616
+ }, _callee79, this);
8488
8617
  }));
8489
8618
  function recomputeAndNotifyFloorPlanQuery() {
8490
8619
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -8514,20 +8643,20 @@ var Server = /*#__PURE__*/function () {
8514
8643
  * filter 逻辑暂为 mock,仅记录参数
8515
8644
  */
8516
8645
  function () {
8517
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(data) {
8646
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(data) {
8518
8647
  var rawList, result;
8519
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8520
- while (1) switch (_context79.prev = _context79.next) {
8648
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8649
+ while (1) switch (_context80.prev = _context80.next) {
8521
8650
  case 0:
8522
8651
  this.logInfo('computeOrderQueryResult: 开始过滤', {
8523
8652
  data: data
8524
8653
  });
8525
8654
  if (this.order) {
8526
- _context79.next = 4;
8655
+ _context80.next = 4;
8527
8656
  break;
8528
8657
  }
8529
8658
  this.logError('computeOrderQueryResult: Order 模块未注册');
8530
- return _context79.abrupt("return", {
8659
+ return _context80.abrupt("return", {
8531
8660
  code: 500,
8532
8661
  message: 'Order 模块未注册',
8533
8662
  data: {
@@ -8559,7 +8688,7 @@ var Server = /*#__PURE__*/function () {
8559
8688
  skip: result.skip,
8560
8689
  rejected: result.rejected
8561
8690
  });
8562
- return _context79.abrupt("return", {
8691
+ return _context80.abrupt("return", {
8563
8692
  code: 200,
8564
8693
  data: result,
8565
8694
  message: '',
@@ -8567,11 +8696,11 @@ var Server = /*#__PURE__*/function () {
8567
8696
  });
8568
8697
  case 10:
8569
8698
  case "end":
8570
- return _context79.stop();
8699
+ return _context80.stop();
8571
8700
  }
8572
- }, _callee79, this);
8701
+ }, _callee80, this);
8573
8702
  }));
8574
- function computeOrderQueryResult(_x88) {
8703
+ function computeOrderQueryResult(_x91) {
8575
8704
  return _computeOrderQueryResult.apply(this, arguments);
8576
8705
  }
8577
8706
  return computeOrderQueryResult;
@@ -8584,17 +8713,17 @@ var Server = /*#__PURE__*/function () {
8584
8713
  }, {
8585
8714
  key: "computeBookingQueryResult",
8586
8715
  value: (function () {
8587
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(data) {
8716
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(data) {
8588
8717
  var rawOrders, result;
8589
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
8590
- while (1) switch (_context80.prev = _context80.next) {
8718
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8719
+ while (1) switch (_context81.prev = _context81.next) {
8591
8720
  case 0:
8592
8721
  if (this.order) {
8593
- _context80.next = 3;
8722
+ _context81.next = 3;
8594
8723
  break;
8595
8724
  }
8596
8725
  this.logError('computeBookingQueryResult: Order 模块未注册');
8597
- return _context80.abrupt("return", {
8726
+ return _context81.abrupt("return", {
8598
8727
  code: 500,
8599
8728
  message: 'Order 模块未注册',
8600
8729
  data: {
@@ -8613,7 +8742,7 @@ var Server = /*#__PURE__*/function () {
8613
8742
  size: result.size,
8614
8743
  skip: result.skip
8615
8744
  });
8616
- return _context80.abrupt("return", {
8745
+ return _context81.abrupt("return", {
8617
8746
  code: 200,
8618
8747
  data: result,
8619
8748
  message: '',
@@ -8621,11 +8750,11 @@ var Server = /*#__PURE__*/function () {
8621
8750
  });
8622
8751
  case 8:
8623
8752
  case "end":
8624
- return _context80.stop();
8753
+ return _context81.stop();
8625
8754
  }
8626
- }, _callee80, this);
8755
+ }, _callee81, this);
8627
8756
  }));
8628
- function computeBookingQueryResult(_x89) {
8757
+ function computeBookingQueryResult(_x92) {
8629
8758
  return _computeBookingQueryResult.apply(this, arguments);
8630
8759
  }
8631
8760
  return computeBookingQueryResult;
@@ -8684,12 +8813,12 @@ var Server = /*#__PURE__*/function () {
8684
8813
  }, {
8685
8814
  key: "computeProductQueryResult",
8686
8815
  value: (function () {
8687
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(context, options) {
8816
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(context, options) {
8688
8817
  var _menu_list_ids$length3,
8689
- _this25 = this;
8818
+ _this26 = this;
8690
8819
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
8691
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
8692
- while (1) switch (_context81.prev = _context81.next) {
8820
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
8821
+ while (1) switch (_context82.prev = _context82.next) {
8693
8822
  case 0:
8694
8823
  tTotal = performance.now();
8695
8824
  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;
@@ -8715,10 +8844,10 @@ var Server = /*#__PURE__*/function () {
8715
8844
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
8716
8845
  startupPreloadTask = this.startupModulePreloadInFlight;
8717
8846
  if (!startupPreloadTask) {
8718
- _context81.next = 8;
8847
+ _context82.next = 8;
8719
8848
  break;
8720
8849
  }
8721
- _context81.next = 8;
8850
+ _context82.next = 8;
8722
8851
  return startupPreloadTask;
8723
8852
  case 8:
8724
8853
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -8730,28 +8859,28 @@ var Server = /*#__PURE__*/function () {
8730
8859
  strategy_context: strategy_context
8731
8860
  });
8732
8861
  if (this.products) {
8733
- _context81.next = 12;
8862
+ _context82.next = 12;
8734
8863
  break;
8735
8864
  }
8736
8865
  this.logError('computeProductQueryResult: Products 模块未注册');
8737
- return _context81.abrupt("return", {
8866
+ return _context82.abrupt("return", {
8738
8867
  message: 'Products 模块未注册',
8739
8868
  data: this.buildProductQueryResultPayload([], 0)
8740
8869
  });
8741
8870
  case 12:
8742
8871
  if (!(queryIds.length > 0)) {
8743
- _context81.next = 24;
8872
+ _context82.next = 24;
8744
8873
  break;
8745
8874
  }
8746
8875
  uniqueIds = Array.from(new Set(queryIds));
8747
8876
  _tPrice = performance.now();
8748
- _context81.next = 17;
8877
+ _context82.next = 17;
8749
8878
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8750
8879
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8751
8880
  productIds: uniqueIds
8752
8881
  });
8753
8882
  case 17:
8754
- productsWithPrice = _context81.sent;
8883
+ productsWithPrice = _context82.sent;
8755
8884
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
8756
8885
  count: productsWithPrice.length,
8757
8886
  ids: uniqueIds
@@ -8771,7 +8900,7 @@ var Server = /*#__PURE__*/function () {
8771
8900
  ids: uniqueIds,
8772
8901
  count: extensionFilteredProducts.length
8773
8902
  });
8774
- return _context81.abrupt("return", {
8903
+ return _context82.abrupt("return", {
8775
8904
  code: 200,
8776
8905
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
8777
8906
  message: '',
@@ -8779,17 +8908,17 @@ var Server = /*#__PURE__*/function () {
8779
8908
  });
8780
8909
  case 24:
8781
8910
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
8782
- _context81.next = 36;
8911
+ _context82.next = 36;
8783
8912
  break;
8784
8913
  }
8785
8914
  pid = Number(product_id);
8786
8915
  _tPrice2 = performance.now();
8787
- _context81.next = 29;
8916
+ _context82.next = 29;
8788
8917
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8789
8918
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8790
8919
  });
8791
8920
  case 29:
8792
- allProductsWithPrice = _context81.sent;
8921
+ allProductsWithPrice = _context82.sent;
8793
8922
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
8794
8923
  count: allProductsWithPrice.length,
8795
8924
  productId: pid
@@ -8809,7 +8938,7 @@ var Server = /*#__PURE__*/function () {
8809
8938
  productId: pid,
8810
8939
  found: !!item
8811
8940
  });
8812
- return _context81.abrupt("return", {
8941
+ return _context82.abrupt("return", {
8813
8942
  code: 200,
8814
8943
  data: item,
8815
8944
  message: item ? '' : '商品不存在或未发布',
@@ -8817,16 +8946,16 @@ var Server = /*#__PURE__*/function () {
8817
8946
  });
8818
8947
  case 36:
8819
8948
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
8820
- _context81.next = 56;
8949
+ _context82.next = 56;
8821
8950
  break;
8822
8951
  }
8823
8952
  _tPrice3 = performance.now();
8824
- _context81.next = 40;
8953
+ _context82.next = 40;
8825
8954
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8826
8955
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8827
8956
  });
8828
8957
  case 40:
8829
- _filteredProducts2 = _context81.sent;
8958
+ _filteredProducts2 = _context82.sent;
8830
8959
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
8831
8960
  count: _filteredProducts2.length,
8832
8961
  extension_type: extension_type
@@ -8865,7 +8994,7 @@ var Server = /*#__PURE__*/function () {
8865
8994
  filteredCount: _filteredProducts2.length,
8866
8995
  extension_type: extension_type
8867
8996
  });
8868
- return _context81.abrupt("return", {
8997
+ return _context82.abrupt("return", {
8869
8998
  code: 200,
8870
8999
  data: this.buildProductQueryResultPayload(_filteredProducts2),
8871
9000
  message: '',
@@ -8873,50 +9002,50 @@ var Server = /*#__PURE__*/function () {
8873
9002
  });
8874
9003
  case 56:
8875
9004
  if (this.menu) {
8876
- _context81.next = 59;
9005
+ _context82.next = 59;
8877
9006
  break;
8878
9007
  }
8879
9008
  this.logError('computeProductQueryResult: Menu 模块未注册');
8880
- return _context81.abrupt("return", {
9009
+ return _context82.abrupt("return", {
8881
9010
  message: 'Menu 模块未注册',
8882
9011
  data: this.buildProductQueryResultPayload([], 0)
8883
9012
  });
8884
9013
  case 59:
8885
9014
  if (this.schedule) {
8886
- _context81.next = 62;
9015
+ _context82.next = 62;
8887
9016
  break;
8888
9017
  }
8889
9018
  this.logError('computeProductQueryResult: Schedule 模块未注册');
8890
- return _context81.abrupt("return", {
9019
+ return _context82.abrupt("return", {
8891
9020
  message: 'Schedule 模块未注册',
8892
9021
  data: this.buildProductQueryResultPayload([], 0)
8893
9022
  });
8894
9023
  case 62:
8895
9024
  activeMenuList = [];
8896
9025
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
8897
- _context81.next = 75;
9026
+ _context82.next = 75;
8898
9027
  break;
8899
9028
  }
8900
9029
  tMenu = performance.now();
8901
9030
  getActiveMenus = function getActiveMenus() {
8902
- return _this25.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8903
- var _this25$schedule;
8904
- return ((_this25$schedule = _this25.schedule) === null || _this25$schedule === void 0 ? void 0 : _this25$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
9031
+ return _this26.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
9032
+ var _this26$schedule;
9033
+ return ((_this26$schedule = _this26.schedule) === null || _this26$schedule === void 0 ? void 0 : _this26$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8905
9034
  });
8906
9035
  };
8907
9036
  activeMenuList = getActiveMenus();
8908
- _context81.t0 = !activeMenuList.length;
8909
- if (!_context81.t0) {
8910
- _context81.next = 72;
9037
+ _context82.t0 = !activeMenuList.length;
9038
+ if (!_context82.t0) {
9039
+ _context82.next = 72;
8911
9040
  break;
8912
9041
  }
8913
- _context81.next = 71;
9042
+ _context82.next = 71;
8914
9043
  return this.refreshMenuScheduleCacheAfterEmptyResult();
8915
9044
  case 71:
8916
- _context81.t0 = _context81.sent;
9045
+ _context82.t0 = _context82.sent;
8917
9046
  case 72:
8918
- if (!_context81.t0) {
8919
- _context81.next = 74;
9047
+ if (!_context82.t0) {
9048
+ _context82.next = 74;
8920
9049
  break;
8921
9050
  }
8922
9051
  activeMenuList = getActiveMenus();
@@ -8936,22 +9065,22 @@ var Server = /*#__PURE__*/function () {
8936
9065
  });
8937
9066
  tPrice = performance.now();
8938
9067
  if (!(scopedProductIds.length > 0)) {
8939
- _context81.next = 86;
9068
+ _context82.next = 86;
8940
9069
  break;
8941
9070
  }
8942
- _context81.next = 83;
9071
+ _context82.next = 83;
8943
9072
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8944
9073
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8945
9074
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
8946
9075
  });
8947
9076
  case 83:
8948
- _context81.t1 = _context81.sent;
8949
- _context81.next = 87;
9077
+ _context82.t1 = _context82.sent;
9078
+ _context82.next = 87;
8950
9079
  break;
8951
9080
  case 86:
8952
- _context81.t1 = [];
9081
+ _context82.t1 = [];
8953
9082
  case 87:
8954
- filteredProducts = _context81.t1;
9083
+ filteredProducts = _context82.t1;
8955
9084
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
8956
9085
  count: filteredProducts.length,
8957
9086
  scopedProductCount: scopedProductIds.length
@@ -8992,7 +9121,7 @@ var Server = /*#__PURE__*/function () {
8992
9121
  filteredCount: filteredProducts.length,
8993
9122
  activeMenuCount: activeMenuList.length
8994
9123
  });
8995
- return _context81.abrupt("return", {
9124
+ return _context82.abrupt("return", {
8996
9125
  code: 200,
8997
9126
  data: this.buildProductQueryResultPayload(filteredProducts),
8998
9127
  message: '',
@@ -9000,11 +9129,11 @@ var Server = /*#__PURE__*/function () {
9000
9129
  });
9001
9130
  case 103:
9002
9131
  case "end":
9003
- return _context81.stop();
9132
+ return _context82.stop();
9004
9133
  }
9005
- }, _callee81, this);
9134
+ }, _callee82, this);
9006
9135
  }));
9007
- function computeProductQueryResult(_x90, _x91) {
9136
+ function computeProductQueryResult(_x93, _x94) {
9008
9137
  return _computeProductQueryResult.apply(this, arguments);
9009
9138
  }
9010
9139
  return computeProductQueryResult;
@@ -9042,74 +9171,74 @@ var Server = /*#__PURE__*/function () {
9042
9171
  }, {
9043
9172
  key: "recomputeAndNotifyProductQuery",
9044
9173
  value: (function () {
9045
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(options) {
9174
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(options) {
9046
9175
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
9047
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
9048
- while (1) switch (_context82.prev = _context82.next) {
9176
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
9177
+ while (1) switch (_context83.prev = _context83.next) {
9049
9178
  case 0:
9050
9179
  if (!(this.productQuerySubscribers.size === 0)) {
9051
- _context82.next = 2;
9180
+ _context83.next = 2;
9052
9181
  break;
9053
9182
  }
9054
- return _context82.abrupt("return");
9183
+ return _context83.abrupt("return");
9055
9184
  case 2:
9056
9185
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
9057
9186
  subscriberCount: this.productQuerySubscribers.size,
9058
9187
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9059
9188
  });
9060
9189
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
9061
- _context82.prev = 4;
9190
+ _context83.prev = 4;
9062
9191
  _iterator18.s();
9063
9192
  case 6:
9064
9193
  if ((_step18 = _iterator18.n()).done) {
9065
- _context82.next = 23;
9194
+ _context83.next = 23;
9066
9195
  break;
9067
9196
  }
9068
9197
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
9069
- _context82.prev = 8;
9070
- _context82.next = 11;
9198
+ _context83.prev = 8;
9199
+ _context83.next = 11;
9071
9200
  return this.computeProductQueryResult(subscriber.context, {
9072
9201
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
9073
9202
  });
9074
9203
  case 11:
9075
- result = _context82.sent;
9076
- _context82.next = 14;
9204
+ result = _context83.sent;
9205
+ _context83.next = 14;
9077
9206
  return subscriber.callback(result);
9078
9207
  case 14:
9079
9208
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
9080
9209
  subscriberId: subscriberId
9081
9210
  });
9082
- _context82.next = 21;
9211
+ _context83.next = 21;
9083
9212
  break;
9084
9213
  case 17:
9085
- _context82.prev = 17;
9086
- _context82.t0 = _context82["catch"](8);
9087
- errorMessage = _context82.t0 instanceof Error ? _context82.t0.message : String(_context82.t0);
9214
+ _context83.prev = 17;
9215
+ _context83.t0 = _context83["catch"](8);
9216
+ errorMessage = _context83.t0 instanceof Error ? _context83.t0.message : String(_context83.t0);
9088
9217
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
9089
9218
  subscriberId: subscriberId,
9090
9219
  error: errorMessage
9091
9220
  });
9092
9221
  case 21:
9093
- _context82.next = 6;
9222
+ _context83.next = 6;
9094
9223
  break;
9095
9224
  case 23:
9096
- _context82.next = 28;
9225
+ _context83.next = 28;
9097
9226
  break;
9098
9227
  case 25:
9099
- _context82.prev = 25;
9100
- _context82.t1 = _context82["catch"](4);
9101
- _iterator18.e(_context82.t1);
9228
+ _context83.prev = 25;
9229
+ _context83.t1 = _context83["catch"](4);
9230
+ _iterator18.e(_context83.t1);
9102
9231
  case 28:
9103
- _context82.prev = 28;
9232
+ _context83.prev = 28;
9104
9233
  _iterator18.f();
9105
- return _context82.finish(28);
9234
+ return _context83.finish(28);
9106
9235
  case 31:
9107
9236
  case "end":
9108
- return _context82.stop();
9237
+ return _context83.stop();
9109
9238
  }
9110
- }, _callee82, this, [[4, 25, 28, 31], [8, 17]]);
9239
+ }, _callee83, this, [[4, 25, 28, 31], [8, 17]]);
9111
9240
  }));
9112
- function recomputeAndNotifyProductQuery(_x92) {
9241
+ function recomputeAndNotifyProductQuery(_x95) {
9113
9242
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
9114
9243
  }
9115
9244
  return recomputeAndNotifyProductQuery;
@@ -9121,16 +9250,16 @@ var Server = /*#__PURE__*/function () {
9121
9250
  }, {
9122
9251
  key: "recomputeAndNotifyOrderQuery",
9123
9252
  value: (function () {
9124
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83() {
9253
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
9125
9254
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
9126
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
9127
- while (1) switch (_context83.prev = _context83.next) {
9255
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9256
+ while (1) switch (_context84.prev = _context84.next) {
9128
9257
  case 0:
9129
9258
  if (!(this.orderQuerySubscribers.size === 0)) {
9130
- _context83.next = 2;
9259
+ _context84.next = 2;
9131
9260
  break;
9132
9261
  }
9133
- return _context83.abrupt("return");
9262
+ return _context84.abrupt("return");
9134
9263
  case 2:
9135
9264
  notifyStartAt = Date.now();
9136
9265
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -9138,20 +9267,20 @@ var Server = /*#__PURE__*/function () {
9138
9267
  notifyStartAt: new Date(notifyStartAt).toISOString()
9139
9268
  });
9140
9269
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
9141
- _context83.prev = 5;
9270
+ _context84.prev = 5;
9142
9271
  _iterator19.s();
9143
9272
  case 7:
9144
9273
  if ((_step19 = _iterator19.n()).done) {
9145
- _context83.next = 27;
9274
+ _context84.next = 27;
9146
9275
  break;
9147
9276
  }
9148
9277
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
9149
- _context83.prev = 9;
9278
+ _context84.prev = 9;
9150
9279
  computeStartAt = Date.now();
9151
- _context83.next = 13;
9280
+ _context84.next = 13;
9152
9281
  return this.computeOrderQueryResult(subscriber.context);
9153
9282
  case 13:
9154
- result = _context83.sent;
9283
+ result = _context84.sent;
9155
9284
  computeEndAt = Date.now();
9156
9285
  callbackStartAt = Date.now();
9157
9286
  subscriber.callback(result);
@@ -9162,30 +9291,30 @@ var Server = /*#__PURE__*/function () {
9162
9291
  callbackDurationMs: callbackEndAt - callbackStartAt,
9163
9292
  totalDurationMs: callbackEndAt - computeStartAt
9164
9293
  });
9165
- _context83.next = 25;
9294
+ _context84.next = 25;
9166
9295
  break;
9167
9296
  case 21:
9168
- _context83.prev = 21;
9169
- _context83.t0 = _context83["catch"](9);
9170
- errorMessage = _context83.t0 instanceof Error ? _context83.t0.message : String(_context83.t0);
9297
+ _context84.prev = 21;
9298
+ _context84.t0 = _context84["catch"](9);
9299
+ errorMessage = _context84.t0 instanceof Error ? _context84.t0.message : String(_context84.t0);
9171
9300
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
9172
9301
  subscriberId: subscriberId,
9173
9302
  error: errorMessage
9174
9303
  });
9175
9304
  case 25:
9176
- _context83.next = 7;
9305
+ _context84.next = 7;
9177
9306
  break;
9178
9307
  case 27:
9179
- _context83.next = 32;
9308
+ _context84.next = 32;
9180
9309
  break;
9181
9310
  case 29:
9182
- _context83.prev = 29;
9183
- _context83.t1 = _context83["catch"](5);
9184
- _iterator19.e(_context83.t1);
9311
+ _context84.prev = 29;
9312
+ _context84.t1 = _context84["catch"](5);
9313
+ _iterator19.e(_context84.t1);
9185
9314
  case 32:
9186
- _context83.prev = 32;
9315
+ _context84.prev = 32;
9187
9316
  _iterator19.f();
9188
- return _context83.finish(32);
9317
+ return _context84.finish(32);
9189
9318
  case 35:
9190
9319
  notifyEndAt = Date.now();
9191
9320
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -9194,9 +9323,9 @@ var Server = /*#__PURE__*/function () {
9194
9323
  });
9195
9324
  case 37:
9196
9325
  case "end":
9197
- return _context83.stop();
9326
+ return _context84.stop();
9198
9327
  }
9199
- }, _callee83, this, [[5, 29, 32, 35], [9, 21]]);
9328
+ }, _callee84, this, [[5, 29, 32, 35], [9, 21]]);
9200
9329
  }));
9201
9330
  function recomputeAndNotifyOrderQuery() {
9202
9331
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -9214,7 +9343,7 @@ var Server = /*#__PURE__*/function () {
9214
9343
  }, {
9215
9344
  key: "notifySalesSearchSubscribers",
9216
9345
  value: function notifySalesSearchSubscribers(payload) {
9217
- var _this26 = this;
9346
+ var _this27 = this;
9218
9347
  if (this.salesSearchSubscribers.size === 0) return;
9219
9348
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
9220
9349
  if (changedOrders.length === 0) {
@@ -9232,21 +9361,21 @@ var Server = /*#__PURE__*/function () {
9232
9361
  subscriber = _step20$value[1];
9233
9362
  try {
9234
9363
  var changedVisibleOrders = changedOrders.filter(function (order) {
9235
- var orderId = _this26.getSalesSearchOrderId(order);
9364
+ var orderId = _this27.getSalesSearchOrderId(order);
9236
9365
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
9237
9366
  });
9238
9367
  if (changedVisibleOrders.length === 0) {
9239
9368
  return 1; // continue
9240
9369
  }
9241
- subscriber.callback(_this26.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9242
- _this26.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9370
+ subscriber.callback(_this27.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
9371
+ _this27.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
9243
9372
  subscriberId: subscriberId,
9244
9373
  kind: subscriber.kind,
9245
9374
  count: changedVisibleOrders.length
9246
9375
  });
9247
9376
  } catch (error) {
9248
9377
  var errorMessage = error instanceof Error ? error.message : String(error);
9249
- _this26.logError('notifySalesSearchSubscribers: 推送失败', {
9378
+ _this27.logError('notifySalesSearchSubscribers: 推送失败', {
9250
9379
  subscriberId: subscriberId,
9251
9380
  error: errorMessage
9252
9381
  });
@@ -9337,67 +9466,67 @@ var Server = /*#__PURE__*/function () {
9337
9466
  }, {
9338
9467
  key: "recomputeAndNotifyBookingQuery",
9339
9468
  value: (function () {
9340
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
9469
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85() {
9341
9470
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
9342
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
9343
- while (1) switch (_context84.prev = _context84.next) {
9471
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
9472
+ while (1) switch (_context85.prev = _context85.next) {
9344
9473
  case 0:
9345
9474
  if (!(this.bookingQuerySubscribers.size === 0)) {
9346
- _context84.next = 2;
9475
+ _context85.next = 2;
9347
9476
  break;
9348
9477
  }
9349
- return _context84.abrupt("return");
9478
+ return _context85.abrupt("return");
9350
9479
  case 2:
9351
9480
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
9352
9481
  subscriberCount: this.bookingQuerySubscribers.size
9353
9482
  });
9354
9483
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
9355
- _context84.prev = 4;
9484
+ _context85.prev = 4;
9356
9485
  _iterator21.s();
9357
9486
  case 6:
9358
9487
  if ((_step21 = _iterator21.n()).done) {
9359
- _context84.next = 22;
9488
+ _context85.next = 22;
9360
9489
  break;
9361
9490
  }
9362
9491
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
9363
- _context84.prev = 8;
9364
- _context84.next = 11;
9492
+ _context85.prev = 8;
9493
+ _context85.next = 11;
9365
9494
  return this.computeBookingQueryResult(subscriber.context);
9366
9495
  case 11:
9367
- result = _context84.sent;
9496
+ result = _context85.sent;
9368
9497
  subscriber.callback(result);
9369
9498
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
9370
9499
  subscriberId: subscriberId
9371
9500
  });
9372
- _context84.next = 20;
9501
+ _context85.next = 20;
9373
9502
  break;
9374
9503
  case 16:
9375
- _context84.prev = 16;
9376
- _context84.t0 = _context84["catch"](8);
9377
- errorMessage = _context84.t0 instanceof Error ? _context84.t0.message : String(_context84.t0);
9504
+ _context85.prev = 16;
9505
+ _context85.t0 = _context85["catch"](8);
9506
+ errorMessage = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
9378
9507
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
9379
9508
  subscriberId: subscriberId,
9380
9509
  error: errorMessage
9381
9510
  });
9382
9511
  case 20:
9383
- _context84.next = 6;
9512
+ _context85.next = 6;
9384
9513
  break;
9385
9514
  case 22:
9386
- _context84.next = 27;
9515
+ _context85.next = 27;
9387
9516
  break;
9388
9517
  case 24:
9389
- _context84.prev = 24;
9390
- _context84.t1 = _context84["catch"](4);
9391
- _iterator21.e(_context84.t1);
9518
+ _context85.prev = 24;
9519
+ _context85.t1 = _context85["catch"](4);
9520
+ _iterator21.e(_context85.t1);
9392
9521
  case 27:
9393
- _context84.prev = 27;
9522
+ _context85.prev = 27;
9394
9523
  _iterator21.f();
9395
- return _context84.finish(27);
9524
+ return _context85.finish(27);
9396
9525
  case 30:
9397
9526
  case "end":
9398
- return _context84.stop();
9527
+ return _context85.stop();
9399
9528
  }
9400
- }, _callee84, this, [[4, 24, 27, 30], [8, 16]]);
9529
+ }, _callee85, this, [[4, 24, 27, 30], [8, 16]]);
9401
9530
  }));
9402
9531
  function recomputeAndNotifyBookingQuery() {
9403
9532
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);