@pisell/pisellos 2.3.189 → 2.3.191

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