@pisell/pisellos 2.3.24 → 2.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/modules/Discount/index.d.ts +2 -5
  4. package/dist/modules/Discount/index.js +7 -30
  5. package/dist/modules/Discount/types.d.ts +0 -4
  6. package/dist/modules/Order/index.d.ts +4 -2
  7. package/dist/modules/Order/index.js +725 -647
  8. package/dist/modules/Order/types.d.ts +0 -2
  9. package/dist/modules/Product/types.d.ts +0 -22
  10. package/dist/modules/ProductList/index.d.ts +1 -1
  11. package/dist/modules/ProductList/index.js +2 -4
  12. package/dist/modules/ProductList/types.d.ts +0 -2
  13. package/dist/server/index.d.ts +0 -50
  14. package/dist/server/index.js +749 -995
  15. package/dist/server/modules/products/index.d.ts +7 -26
  16. package/dist/server/modules/products/index.js +76 -167
  17. package/dist/server/modules/products/types.d.ts +0 -14
  18. package/dist/solution/BaseSales/index.d.ts +0 -2
  19. package/dist/solution/BaseSales/index.js +50 -36
  20. package/dist/solution/BookingByStep/index.d.ts +1 -1
  21. package/dist/solution/BookingTicket/index.d.ts +1 -13
  22. package/dist/solution/BookingTicket/index.js +21 -5
  23. package/dist/solution/BookingTicket/types.d.ts +0 -2
  24. package/dist/solution/ShopDiscount/index.js +14 -15
  25. package/lib/model/strategy/adapter/index.d.ts +0 -4
  26. package/lib/model/strategy/adapter/index.js +2 -13
  27. package/lib/modules/Discount/index.d.ts +2 -5
  28. package/lib/modules/Discount/index.js +3 -23
  29. package/lib/modules/Discount/types.d.ts +0 -4
  30. package/lib/modules/Order/index.d.ts +4 -2
  31. package/lib/modules/Order/index.js +80 -34
  32. package/lib/modules/Order/types.d.ts +0 -2
  33. package/lib/modules/Product/types.d.ts +0 -22
  34. package/lib/modules/ProductList/index.d.ts +1 -1
  35. package/lib/modules/ProductList/index.js +2 -4
  36. package/lib/modules/ProductList/types.d.ts +0 -2
  37. package/lib/server/index.d.ts +0 -50
  38. package/lib/server/index.js +29 -206
  39. package/lib/server/modules/products/index.d.ts +7 -26
  40. package/lib/server/modules/products/index.js +35 -114
  41. package/lib/server/modules/products/types.d.ts +0 -14
  42. package/lib/solution/BaseSales/index.d.ts +0 -2
  43. package/lib/solution/BaseSales/index.js +22 -12
  44. package/lib/solution/BookingByStep/index.d.ts +1 -1
  45. package/lib/solution/BookingTicket/index.d.ts +1 -13
  46. package/lib/solution/BookingTicket/index.js +18 -1
  47. package/lib/solution/BookingTicket/types.d.ts +0 -2
  48. package/lib/solution/ShopDiscount/index.js +1 -2
  49. package/package.json +1 -1
  50. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  51. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  52. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  53. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  54. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  55. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  56. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  57. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  58. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  59. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  60. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  61. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  62. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  63. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  64. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  65. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  66. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  67. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  68. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  69. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -93,8 +93,6 @@ var Server = /*#__PURE__*/function () {
93
93
  });
94
94
  // ---- 商品查询订阅者 ----
95
95
  _defineProperty(this, "productQuerySubscribers", new Map());
96
- /** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
97
- _defineProperty(this, "productQueryScheduleTimers", new Map());
98
96
  // ---- 订单 / 预约列表查询订阅者 ----
99
97
  _defineProperty(this, "orderQuerySubscribers", new Map());
100
98
  _defineProperty(this, "bookingQuerySubscribers", new Map());
@@ -273,13 +271,13 @@ var Server = /*#__PURE__*/function () {
273
271
  */
274
272
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
275
273
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
276
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
274
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
277
275
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
278
276
  while (1) switch (_context3.prev = _context3.next) {
279
277
  case 0:
280
278
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
281
279
  console.log('[Server] handleProductQuery:', url, method, data, config);
282
- menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
280
+ menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type;
283
281
  _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
284
282
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
285
283
  menu_list_ids: menu_list_ids,
@@ -287,8 +285,7 @@ var Server = /*#__PURE__*/function () {
287
285
  schedule_datetime: schedule_datetime,
288
286
  schedule_date: schedule_date,
289
287
  customer_id: customer_id,
290
- extension_type: extension_type,
291
- strategyContextKeys: strategy_context ? Object.keys(strategy_context) : []
288
+ extension_type: extension_type
292
289
  });
293
290
 
294
291
  // 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
@@ -301,8 +298,7 @@ var Server = /*#__PURE__*/function () {
301
298
  schedule_date: schedule_date,
302
299
  schedule_datetime: schedule_datetime,
303
300
  customer_id: customer_id,
304
- extension_type: extension_type,
305
- strategy_context: strategy_context
301
+ extension_type: extension_type
306
302
  }
307
303
  });
308
304
  _this.logInfo('handleProductQuery: 已注册订阅者', {
@@ -310,23 +306,15 @@ var Server = /*#__PURE__*/function () {
310
306
  totalSubscribers: _this.productQuerySubscribers.size
311
307
  });
312
308
  }
313
- _context3.next = 8;
314
- return _this.computeProductQueryResult({
309
+ return _context3.abrupt("return", _this.computeProductQueryResult({
315
310
  menu_list_ids: menu_list_ids,
316
311
  ids: ids,
317
312
  schedule_date: schedule_date,
318
313
  schedule_datetime: schedule_datetime,
319
314
  customer_id: customer_id,
320
- extension_type: extension_type,
321
- strategy_context: strategy_context
322
- });
323
- case 8:
324
- result = _context3.sent;
325
- if (subscriberId && typeof callback === 'function') {
326
- _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
327
- }
328
- return _context3.abrupt("return", result);
329
- case 11:
315
+ extension_type: extension_type
316
+ }));
317
+ case 7:
330
318
  case "end":
331
319
  return _context3.stop();
332
320
  }
@@ -3128,7 +3116,6 @@ var Server = /*#__PURE__*/function () {
3128
3116
  key: "removeProductQuerySubscriber",
3129
3117
  value: function removeProductQuerySubscriber(subscriberId) {
3130
3118
  if (subscriberId) {
3131
- this.clearSubscriberScheduleTimers(subscriberId);
3132
3119
  this.productQuerySubscribers.delete(subscriberId);
3133
3120
  this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
3134
3121
  subscriberId: subscriberId,
@@ -3136,243 +3123,6 @@ var Server = /*#__PURE__*/function () {
3136
3123
  });
3137
3124
  }
3138
3125
  }
3139
-
3140
- /**
3141
- * 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
3142
- */
3143
- }, {
3144
- key: "buildProductQueryResultPayload",
3145
- value: function buildProductQueryResultPayload(list, count) {
3146
- var _this$products$getLas, _this$products, _this$products$getLas2;
3147
- return {
3148
- list: list,
3149
- count: count !== null && count !== void 0 ? count : list.length,
3150
- schedule_time_points: (_this$products$getLas = (_this$products = this.products) === null || _this$products === void 0 || (_this$products$getLas2 = _this$products.getLastScheduleTimePoints) === null || _this$products$getLas2 === void 0 ? void 0 : _this$products$getLas2.call(_this$products)) !== null && _this$products$getLas !== void 0 ? _this$products$getLas : []
3151
- };
3152
- }
3153
-
3154
- /**
3155
- * 是否启用商品 query 订阅的 schedule 时间点定时重算。
3156
- * strategy_context.enable_schedule_reload === false 时关闭。
3157
- */
3158
- }, {
3159
- key: "shouldScheduleProductQueryReload",
3160
- value: function shouldScheduleProductQueryReload(strategy_context) {
3161
- return (strategy_context === null || strategy_context === void 0 ? void 0 : strategy_context.enable_schedule_reload) !== false;
3162
- }
3163
-
3164
- /**
3165
- * 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
3166
- */
3167
- }, {
3168
- key: "clearSubscriberScheduleTimers",
3169
- value: function clearSubscriberScheduleTimers(subscriberId) {
3170
- var timers = this.productQueryScheduleTimers.get(subscriberId);
3171
- if (timers !== null && timers !== void 0 && timers.length) {
3172
- timers.forEach(function (timerId) {
3173
- return clearTimeout(timerId);
3174
- });
3175
- }
3176
- this.productQueryScheduleTimers.delete(subscriberId);
3177
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3178
- if (subscriber) {
3179
- subscriber.scheduleTimerIds = [];
3180
- }
3181
- }
3182
-
3183
- /**
3184
- * 从 productQueryScheduleTimers 移除已触发的 timer 引用。
3185
- */
3186
- }, {
3187
- key: "removeScheduleTimerRef",
3188
- value: function removeScheduleTimerRef(subscriberId, timerId) {
3189
- var timers = this.productQueryScheduleTimers.get(subscriberId);
3190
- if (!(timers !== null && timers !== void 0 && timers.length)) return;
3191
- var next = timers.filter(function (id) {
3192
- return id !== timerId;
3193
- });
3194
- if (next.length === 0) {
3195
- this.productQueryScheduleTimers.delete(subscriberId);
3196
- } else {
3197
- this.productQueryScheduleTimers.set(subscriberId, next);
3198
- }
3199
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3200
- if (subscriber) {
3201
- subscriber.scheduleTimerIds = next;
3202
- }
3203
- }
3204
-
3205
- /**
3206
- * 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
3207
- */
3208
- }, {
3209
- key: "computeScheduleTimePointDelayMs",
3210
- value: function computeScheduleTimePointDelayMs(scheduleDate, timePoint) {
3211
- var parts = timePoint.split(':');
3212
- if (parts.length < 2) return -1;
3213
- var hours = parseInt(parts[0], 10);
3214
- var minutes = parseInt(parts[1], 10);
3215
- if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return -1;
3216
- var target = dayjs(scheduleDate).hour(hours).minute(minutes).second(4).millisecond(0);
3217
- var delayMs = target.diff(dayjs());
3218
- return delayMs >= 0 ? delayMs : -1;
3219
- }
3220
-
3221
- /**
3222
- * 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
3223
- */
3224
- }, {
3225
- key: "refreshSubscriberScheduleAtExecution",
3226
- value: function refreshSubscriberScheduleAtExecution(subscriber) {
3227
- var executedAt = dayjs();
3228
- var bookingDate = subscriber.context.schedule_date || executedAt.format('YYYY-MM-DD');
3229
- subscriber.context.schedule_date = bookingDate;
3230
- subscriber.context.schedule_datetime = "".concat(bookingDate, " ").concat(executedAt.format('HH:mm:ss'));
3231
- }
3232
-
3233
- /**
3234
- * 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
3235
- * 必须先 clearSubscriberScheduleTimers,再调用本方法。
3236
- */
3237
- }, {
3238
- key: "scheduleSubscriberTimePointReloads",
3239
- value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3240
- var _this7 = this;
3241
- var subscriber = this.productQuerySubscribers.get(subscriberId);
3242
- if (!subscriber || !timePoints.length) return;
3243
- var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
3244
- var timerIds = [];
3245
- var _iterator5 = _createForOfIteratorHelper(timePoints),
3246
- _step5;
3247
- try {
3248
- var _loop = function _loop() {
3249
- var timePoint = _step5.value;
3250
- var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
3251
- if (delayMs < 0) return 1; // continue
3252
- var timerId = setTimeout(function () {
3253
- void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
3254
- }, delayMs);
3255
- timerIds.push(timerId);
3256
- };
3257
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3258
- if (_loop()) continue;
3259
- }
3260
- } catch (err) {
3261
- _iterator5.e(err);
3262
- } finally {
3263
- _iterator5.f();
3264
- }
3265
- if (timerIds.length > 0) {
3266
- this.productQueryScheduleTimers.set(subscriberId, timerIds);
3267
- subscriber.scheduleTimerIds = timerIds;
3268
- this.logInfo('scheduleSubscriberTimePointReloads: 已注册定时器', {
3269
- subscriberId: subscriberId,
3270
- timerCount: timerIds.length,
3271
- timePoints: timePoints
3272
- });
3273
- }
3274
- }
3275
-
3276
- /**
3277
- * schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
3278
- */
3279
- }, {
3280
- key: "onScheduleTimePointTimerFire",
3281
- value: (function () {
3282
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(subscriberId, timerId) {
3283
- var subscriber;
3284
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3285
- while (1) switch (_context38.prev = _context38.next) {
3286
- case 0:
3287
- this.removeScheduleTimerRef(subscriberId, timerId);
3288
- if (this.productQuerySubscribers.has(subscriberId)) {
3289
- _context38.next = 3;
3290
- break;
3291
- }
3292
- return _context38.abrupt("return");
3293
- case 3:
3294
- subscriber = this.productQuerySubscribers.get(subscriberId);
3295
- this.refreshSubscriberScheduleAtExecution(subscriber);
3296
- _context38.next = 7;
3297
- return this.recomputeAndNotifySubscriber(subscriberId);
3298
- case 7:
3299
- case "end":
3300
- return _context38.stop();
3301
- }
3302
- }, _callee38, this);
3303
- }));
3304
- function onScheduleTimePointTimerFire(_x37, _x38) {
3305
- return _onScheduleTimePointTimerFire.apply(this, arguments);
3306
- }
3307
- return onScheduleTimePointTimerFire;
3308
- }()
3309
- /**
3310
- * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
3311
- */
3312
- )
3313
- }, {
3314
- key: "recomputeAndNotifySubscriber",
3315
- value: (function () {
3316
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(subscriberId) {
3317
- var subscriber, result, errorMessage;
3318
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3319
- while (1) switch (_context39.prev = _context39.next) {
3320
- case 0:
3321
- subscriber = this.productQuerySubscribers.get(subscriberId);
3322
- if (subscriber) {
3323
- _context39.next = 3;
3324
- break;
3325
- }
3326
- return _context39.abrupt("return");
3327
- case 3:
3328
- _context39.prev = 3;
3329
- _context39.next = 6;
3330
- return this.computeProductQueryResult(subscriber.context);
3331
- case 6:
3332
- result = _context39.sent;
3333
- subscriber.callback(result);
3334
- this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3335
- subscriberId: subscriberId,
3336
- schedule_datetime: subscriber.context.schedule_datetime
3337
- });
3338
- _context39.next = 15;
3339
- break;
3340
- case 11:
3341
- _context39.prev = 11;
3342
- _context39.t0 = _context39["catch"](3);
3343
- errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3344
- this.logError('recomputeAndNotifySubscriber: 推送失败', {
3345
- subscriberId: subscriberId,
3346
- error: errorMessage
3347
- });
3348
- case 15:
3349
- case "end":
3350
- return _context39.stop();
3351
- }
3352
- }, _callee39, this, [[3, 11]]);
3353
- }));
3354
- function recomputeAndNotifySubscriber(_x39) {
3355
- return _recomputeAndNotifySubscriber.apply(this, arguments);
3356
- }
3357
- return recomputeAndNotifySubscriber;
3358
- }()
3359
- /**
3360
- * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3361
- */
3362
- )
3363
- }, {
3364
- key: "syncProductQueryScheduleTimers",
3365
- value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3366
- var _this$products$getLas3, _this$products2, _this$products2$getLa;
3367
- this.clearSubscriberScheduleTimers(subscriberId);
3368
- if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3369
- return;
3370
- }
3371
- var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3372
- if (timePoints.length > 0) {
3373
- this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3374
- }
3375
- }
3376
3126
  }, {
3377
3127
  key: "handleSalesSearchRequest",
3378
3128
  value: (
@@ -3384,32 +3134,32 @@ var Server = /*#__PURE__*/function () {
3384
3134
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3385
3135
  */
3386
3136
  function () {
3387
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(kind, backendPath, data, config) {
3388
- var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3389
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3390
- while (1) switch (_context40.prev = _context40.next) {
3137
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(kind, backendPath, data, config) {
3138
+ var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3139
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3140
+ while (1) switch (_context38.prev = _context38.next) {
3391
3141
  case 0:
3392
3142
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3393
- _context40.next = 3;
3143
+ _context38.next = 3;
3394
3144
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3395
3145
  case 3:
3396
- result = _context40.sent;
3146
+ result = _context38.sent;
3397
3147
  _ref55 = config || {}, callback = _ref55.callback, subscriberId = _ref55.subscriberId, resetVisibleOrderIds = _ref55.resetVisibleOrderIds;
3398
3148
  if (subscriberId && typeof callback === 'function') {
3399
3149
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3400
3150
  existing = this.salesSearchSubscribers.get(subscriberId);
3401
3151
  shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
3402
3152
  visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
3403
- _iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3153
+ _iterator5 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3404
3154
  try {
3405
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3406
- orderId = _step6.value;
3155
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3156
+ orderId = _step5.value;
3407
3157
  visibleOrderIds.add(orderId);
3408
3158
  }
3409
3159
  } catch (err) {
3410
- _iterator6.e(err);
3160
+ _iterator5.e(err);
3411
3161
  } finally {
3412
- _iterator6.f();
3162
+ _iterator5.f();
3413
3163
  }
3414
3164
  this.salesSearchSubscribers.set(subscriberId, {
3415
3165
  callback: callback,
@@ -3425,14 +3175,14 @@ var Server = /*#__PURE__*/function () {
3425
3175
  visibleCount: visibleOrderIds.size
3426
3176
  });
3427
3177
  }
3428
- return _context40.abrupt("return", result);
3178
+ return _context38.abrupt("return", result);
3429
3179
  case 7:
3430
3180
  case "end":
3431
- return _context40.stop();
3181
+ return _context38.stop();
3432
3182
  }
3433
- }, _callee40, this);
3183
+ }, _callee38, this);
3434
3184
  }));
3435
- function handleSalesSearchRequest(_x40, _x41, _x42, _x43) {
3185
+ function handleSalesSearchRequest(_x37, _x38, _x39, _x40) {
3436
3186
  return _handleSalesSearchRequest.apply(this, arguments);
3437
3187
  }
3438
3188
  return handleSalesSearchRequest;
@@ -3447,20 +3197,20 @@ var Server = /*#__PURE__*/function () {
3447
3197
  }, {
3448
3198
  key: "fetchSalesSearchFromAPI",
3449
3199
  value: (function () {
3450
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(backendPath, data) {
3200
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(backendPath, data) {
3451
3201
  var _this$app8;
3452
3202
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3453
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3454
- while (1) switch (_context41.prev = _context41.next) {
3203
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3204
+ while (1) switch (_context39.prev = _context39.next) {
3455
3205
  case 0:
3456
3206
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3457
- _context41.next = 3;
3207
+ _context39.next = 3;
3458
3208
  break;
3459
3209
  }
3460
3210
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3461
3211
  backendPath: backendPath
3462
3212
  });
3463
- return _context41.abrupt("return", {
3213
+ return _context39.abrupt("return", {
3464
3214
  code: 500,
3465
3215
  message: 'app.request 不可用',
3466
3216
  data: backendPath === '/shop/es/search' ? {
@@ -3472,29 +3222,29 @@ var Server = /*#__PURE__*/function () {
3472
3222
  status: false
3473
3223
  });
3474
3224
  case 3:
3475
- _context41.prev = 3;
3476
- _context41.next = 6;
3225
+ _context39.prev = 3;
3226
+ _context39.next = 6;
3477
3227
  return this.app.request.post(backendPath, data, {
3478
3228
  isShopApi: true
3479
3229
  });
3480
3230
  case 6:
3481
- response = _context41.sent;
3231
+ response = _context39.sent;
3482
3232
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3483
- return _context41.abrupt("return", {
3233
+ return _context39.abrupt("return", {
3484
3234
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3485
3235
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3486
3236
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3487
3237
  data: _payload
3488
3238
  });
3489
3239
  case 11:
3490
- _context41.prev = 11;
3491
- _context41.t0 = _context41["catch"](3);
3492
- errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
3240
+ _context39.prev = 11;
3241
+ _context39.t0 = _context39["catch"](3);
3242
+ errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3493
3243
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3494
3244
  backendPath: backendPath,
3495
3245
  error: errorMessage
3496
3246
  });
3497
- return _context41.abrupt("return", {
3247
+ return _context39.abrupt("return", {
3498
3248
  code: 500,
3499
3249
  message: errorMessage,
3500
3250
  data: backendPath === '/shop/es/search' ? {
@@ -3507,11 +3257,11 @@ var Server = /*#__PURE__*/function () {
3507
3257
  });
3508
3258
  case 16:
3509
3259
  case "end":
3510
- return _context41.stop();
3260
+ return _context39.stop();
3511
3261
  }
3512
- }, _callee41, this, [[3, 11]]);
3262
+ }, _callee39, this, [[3, 11]]);
3513
3263
  }));
3514
- function fetchSalesSearchFromAPI(_x44, _x45) {
3264
+ function fetchSalesSearchFromAPI(_x41, _x42) {
3515
3265
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3516
3266
  }
3517
3267
  return fetchSalesSearchFromAPI;
@@ -3541,10 +3291,10 @@ var Server = /*#__PURE__*/function () {
3541
3291
  }, {
3542
3292
  key: "stripSalesSearchPageParams",
3543
3293
  value: function stripSalesSearchPageParams(value) {
3544
- var _this8 = this;
3294
+ var _this7 = this;
3545
3295
  if (Array.isArray(value)) {
3546
3296
  return value.map(function (item) {
3547
- return _this8.stripSalesSearchPageParams(item);
3297
+ return _this7.stripSalesSearchPageParams(item);
3548
3298
  });
3549
3299
  }
3550
3300
  if (!value || _typeof(value) !== 'object') return value;
@@ -3582,12 +3332,12 @@ var Server = /*#__PURE__*/function () {
3582
3332
  key: "extractSalesSearchOrderIds",
3583
3333
  value: function extractSalesSearchOrderIds(kind, result) {
3584
3334
  var _this$findSalesSearch,
3585
- _this9 = this;
3335
+ _this8 = this;
3586
3336
  var data = this.extractSalesSearchResponseData(result);
3587
3337
  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;
3588
3338
  if (!Array.isArray(list)) return [];
3589
3339
  return list.map(function (item) {
3590
- return _this9.getSalesSearchOrderId(item);
3340
+ return _this8.getSalesSearchOrderId(item);
3591
3341
  }).filter(function (id) {
3592
3342
  return !!id;
3593
3343
  });
@@ -3754,11 +3504,11 @@ var Server = /*#__PURE__*/function () {
3754
3504
  }, {
3755
3505
  key: "stableSerialize",
3756
3506
  value: function stableSerialize(value) {
3757
- var _this10 = this;
3507
+ var _this9 = this;
3758
3508
  if (value === null || value === undefined) return 'null';
3759
3509
  if (Array.isArray(value)) {
3760
3510
  return "[".concat(value.map(function (item) {
3761
- return _this10.stableSerialize(item);
3511
+ return _this9.stableSerialize(item);
3762
3512
  }).join(','), "]");
3763
3513
  }
3764
3514
  if (_typeof(value) === 'object') {
@@ -3767,7 +3517,7 @@ var Server = /*#__PURE__*/function () {
3767
3517
  return obj[k] !== undefined;
3768
3518
  }).sort();
3769
3519
  return "{".concat(keys.map(function (k) {
3770
- return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
3520
+ return "".concat(JSON.stringify(k), ":").concat(_this9.stableSerialize(obj[k]));
3771
3521
  }).join(','), "}");
3772
3522
  }
3773
3523
  return JSON.stringify(value);
@@ -3816,22 +3566,22 @@ var Server = /*#__PURE__*/function () {
3816
3566
  }
3817
3567
  var oldestKey = null;
3818
3568
  var oldestTime = Number.POSITIVE_INFINITY;
3819
- var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3820
- _step7;
3569
+ var _iterator6 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3570
+ _step6;
3821
3571
  try {
3822
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3823
- var _step7$value = _slicedToArray(_step7.value, 2),
3824
- _key3 = _step7$value[0],
3825
- cache = _step7$value[1];
3572
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3573
+ var _step6$value = _slicedToArray(_step6.value, 2),
3574
+ _key3 = _step6$value[0],
3575
+ cache = _step6$value[1];
3826
3576
  if (cache.updatedAt < oldestTime) {
3827
3577
  oldestTime = cache.updatedAt;
3828
3578
  oldestKey = _key3;
3829
3579
  }
3830
3580
  }
3831
3581
  } catch (err) {
3832
- _iterator7.e(err);
3582
+ _iterator6.e(err);
3833
3583
  } finally {
3834
- _iterator7.f();
3584
+ _iterator6.f();
3835
3585
  }
3836
3586
  if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
3837
3587
  }
@@ -3847,17 +3597,17 @@ var Server = /*#__PURE__*/function () {
3847
3597
  key: "markBookingRemoteCacheAllStale",
3848
3598
  value: function markBookingRemoteCacheAllStale(reason) {
3849
3599
  if (this.bookingRemoteCache.size === 0) return;
3850
- var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
3851
- _step8;
3600
+ var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
3601
+ _step7;
3852
3602
  try {
3853
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3854
- var entry = _step8.value;
3603
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3604
+ var entry = _step7.value;
3855
3605
  entry.stale = true;
3856
3606
  }
3857
3607
  } catch (err) {
3858
- _iterator8.e(err);
3608
+ _iterator7.e(err);
3859
3609
  } finally {
3860
- _iterator8.f();
3610
+ _iterator7.f();
3861
3611
  }
3862
3612
  this.logWarning('bookingRemoteCache: 全量标记失效', {
3863
3613
  reason: reason,
@@ -3883,13 +3633,13 @@ var Server = /*#__PURE__*/function () {
3883
3633
  key: "notifyBookingRemoteSubscribersByCacheKey",
3884
3634
  value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
3885
3635
  if (this.bookingRemoteQuerySubscribers.size === 0) return;
3886
- var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
3887
- _step9;
3636
+ var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
3637
+ _step8;
3888
3638
  try {
3889
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3890
- var _step9$value = _slicedToArray(_step9.value, 2),
3891
- subscriberId = _step9$value[0],
3892
- subscriber = _step9$value[1];
3639
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3640
+ var _step8$value = _slicedToArray(_step8.value, 2),
3641
+ subscriberId = _step8$value[0],
3642
+ subscriber = _step8$value[1];
3893
3643
  if (subscriber.cacheKey !== cacheKey) continue;
3894
3644
  try {
3895
3645
  var callbackStartAt = Date.now();
@@ -3916,9 +3666,9 @@ var Server = /*#__PURE__*/function () {
3916
3666
  }
3917
3667
  }
3918
3668
  } catch (err) {
3919
- _iterator9.e(err);
3669
+ _iterator8.e(err);
3920
3670
  } finally {
3921
- _iterator9.f();
3671
+ _iterator8.f();
3922
3672
  }
3923
3673
  }
3924
3674
  }, {
@@ -3933,13 +3683,13 @@ var Server = /*#__PURE__*/function () {
3933
3683
  return;
3934
3684
  }
3935
3685
  var syncedEntryCount = 0;
3936
- var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3937
- _step10;
3686
+ var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3687
+ _step9;
3938
3688
  try {
3939
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3940
- var _step10$value = _slicedToArray(_step10.value, 2),
3941
- cacheKey = _step10$value[0],
3942
- entry = _step10$value[1];
3689
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3690
+ var _step9$value = _slicedToArray(_step9.value, 2),
3691
+ cacheKey = _step9$value[0],
3692
+ entry = _step9$value[1];
3943
3693
  if (entry.stale) {
3944
3694
  this.bookingRemoteCache.delete(cacheKey);
3945
3695
  continue;
@@ -3947,25 +3697,25 @@ var Server = /*#__PURE__*/function () {
3947
3697
  try {
3948
3698
  var queryPayload = entry.queryPayload;
3949
3699
  var orderMap = new Map();
3950
- var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
3951
- _step11;
3700
+ var _iterator10 = _createForOfIteratorHelper(entry.rawOrders),
3701
+ _step10;
3952
3702
  try {
3953
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3954
- var order = _step11.value;
3703
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3704
+ var order = _step10.value;
3955
3705
  var _key4 = this.toOrderIdKey(order);
3956
3706
  if (_key4) orderMap.set(_key4, order);
3957
3707
  }
3958
3708
  } catch (err) {
3959
- _iterator11.e(err);
3709
+ _iterator10.e(err);
3960
3710
  } finally {
3961
- _iterator11.f();
3711
+ _iterator10.f();
3962
3712
  }
3963
3713
  var changed = false;
3964
- var _iterator12 = _createForOfIteratorHelper(latestOrders),
3965
- _step12;
3714
+ var _iterator11 = _createForOfIteratorHelper(latestOrders),
3715
+ _step11;
3966
3716
  try {
3967
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3968
- var latest = _step12.value;
3717
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3718
+ var latest = _step11.value;
3969
3719
  var _key5 = this.toOrderIdKey(latest);
3970
3720
  if (!_key5) continue;
3971
3721
  if (orderMap.has(_key5)) {
@@ -3977,9 +3727,9 @@ var Server = /*#__PURE__*/function () {
3977
3727
  changed = true;
3978
3728
  }
3979
3729
  } catch (err) {
3980
- _iterator12.e(err);
3730
+ _iterator11.e(err);
3981
3731
  } finally {
3982
- _iterator12.f();
3732
+ _iterator11.f();
3983
3733
  }
3984
3734
  if (!changed) continue;
3985
3735
  var mergedOrders = _toConsumableArray(orderMap.values());
@@ -4012,9 +3762,9 @@ var Server = /*#__PURE__*/function () {
4012
3762
  }
4013
3763
  }
4014
3764
  } catch (err) {
4015
- _iterator10.e(err);
3765
+ _iterator9.e(err);
4016
3766
  } finally {
4017
- _iterator10.f();
3767
+ _iterator9.f();
4018
3768
  }
4019
3769
  var syncEndAt = Date.now();
4020
3770
  if (syncedEntryCount > 0) {
@@ -4032,18 +3782,18 @@ var Server = /*#__PURE__*/function () {
4032
3782
  }, {
4033
3783
  key: "fetchOrderListFromAPI",
4034
3784
  value: (function () {
4035
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
3785
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
4036
3786
  var _this$app9;
4037
3787
  var _response$data5, response, _payload2, list, count, errorMessage;
4038
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4039
- while (1) switch (_context42.prev = _context42.next) {
3788
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3789
+ while (1) switch (_context40.prev = _context40.next) {
4040
3790
  case 0:
4041
3791
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4042
- _context42.next = 3;
3792
+ _context40.next = 3;
4043
3793
  break;
4044
3794
  }
4045
3795
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4046
- return _context42.abrupt("return", {
3796
+ return _context40.abrupt("return", {
4047
3797
  code: 500,
4048
3798
  message: 'app.request 不可用',
4049
3799
  data: {
@@ -4053,17 +3803,17 @@ var Server = /*#__PURE__*/function () {
4053
3803
  status: false
4054
3804
  });
4055
3805
  case 3:
4056
- _context42.prev = 3;
4057
- _context42.next = 6;
3806
+ _context40.prev = 3;
3807
+ _context40.next = 6;
4058
3808
  return this.app.request.post('/shop/order/v2/list', data, {
4059
3809
  isShopApi: true
4060
3810
  });
4061
3811
  case 6:
4062
- response = _context42.sent;
3812
+ response = _context40.sent;
4063
3813
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4064
3814
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4065
3815
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4066
- return _context42.abrupt("return", {
3816
+ return _context40.abrupt("return", {
4067
3817
  code: 200,
4068
3818
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4069
3819
  list: list,
@@ -4073,13 +3823,13 @@ var Server = /*#__PURE__*/function () {
4073
3823
  status: true
4074
3824
  });
4075
3825
  case 13:
4076
- _context42.prev = 13;
4077
- _context42.t0 = _context42["catch"](3);
4078
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3826
+ _context40.prev = 13;
3827
+ _context40.t0 = _context40["catch"](3);
3828
+ errorMessage = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
4079
3829
  this.logError('fetchOrderListFromAPI: 请求失败', {
4080
3830
  error: errorMessage
4081
3831
  });
4082
- return _context42.abrupt("return", {
3832
+ return _context40.abrupt("return", {
4083
3833
  code: 500,
4084
3834
  message: errorMessage,
4085
3835
  data: {
@@ -4090,11 +3840,11 @@ var Server = /*#__PURE__*/function () {
4090
3840
  });
4091
3841
  case 18:
4092
3842
  case "end":
4093
- return _context42.stop();
3843
+ return _context40.stop();
4094
3844
  }
4095
- }, _callee42, this, [[3, 13]]);
3845
+ }, _callee40, this, [[3, 13]]);
4096
3846
  }));
4097
- function fetchOrderListFromAPI(_x46) {
3847
+ function fetchOrderListFromAPI(_x43) {
4098
3848
  return _fetchOrderListFromAPI.apply(this, arguments);
4099
3849
  }
4100
3850
  return fetchOrderListFromAPI;
@@ -4106,17 +3856,17 @@ var Server = /*#__PURE__*/function () {
4106
3856
  }, {
4107
3857
  key: "fetchBookingListFromAPI",
4108
3858
  value: (function () {
4109
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
3859
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
4110
3860
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4111
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4112
- while (1) switch (_context43.prev = _context43.next) {
3861
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3862
+ while (1) switch (_context41.prev = _context41.next) {
4113
3863
  case 0:
4114
3864
  if (this.order) {
4115
- _context43.next = 3;
3865
+ _context41.next = 3;
4116
3866
  break;
4117
3867
  }
4118
3868
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4119
- return _context43.abrupt("return", {
3869
+ return _context41.abrupt("return", {
4120
3870
  code: 500,
4121
3871
  message: 'Order 模块不可用',
4122
3872
  data: {
@@ -4126,18 +3876,18 @@ var Server = /*#__PURE__*/function () {
4126
3876
  status: false
4127
3877
  });
4128
3878
  case 3:
4129
- _context43.prev = 3;
3879
+ _context41.prev = 3;
4130
3880
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4131
3881
  withFields = this.resolveBookingSalesWith(data);
4132
3882
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4133
3883
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4134
3884
  if (!memoryCacheEnabled) {
4135
- _context43.next = 13;
3885
+ _context41.next = 13;
4136
3886
  break;
4137
3887
  }
4138
3888
  cached = this.readBookingRemoteCache(cacheKey);
4139
3889
  if (!cached) {
4140
- _context43.next = 13;
3890
+ _context41.next = 13;
4141
3891
  break;
4142
3892
  }
4143
3893
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4145,14 +3895,14 @@ var Server = /*#__PURE__*/function () {
4145
3895
  listCount: cached.bookingResult.count,
4146
3896
  withFields: cached.withFields
4147
3897
  });
4148
- return _context43.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
3898
+ return _context41.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4149
3899
  cache_hit: true
4150
3900
  }));
4151
3901
  case 13:
4152
- _context43.next = 15;
3902
+ _context41.next = 15;
4153
3903
  return this.order.fetchOrdersBySSE(requestPayload);
4154
3904
  case 15:
4155
- rawList = _context43.sent;
3905
+ rawList = _context41.sent;
4156
3906
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4157
3907
  if (typeof globalThis !== 'undefined') {
4158
3908
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4199,15 +3949,15 @@ var Server = /*#__PURE__*/function () {
4199
3949
  cacheKey: cacheKey,
4200
3950
  withFields: withFields
4201
3951
  });
4202
- return _context43.abrupt("return", this.buildBookingResponse(bookingResult));
3952
+ return _context41.abrupt("return", this.buildBookingResponse(bookingResult));
4203
3953
  case 23:
4204
- _context43.prev = 23;
4205
- _context43.t0 = _context43["catch"](3);
4206
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3954
+ _context41.prev = 23;
3955
+ _context41.t0 = _context41["catch"](3);
3956
+ errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
4207
3957
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4208
3958
  error: errorMessage
4209
3959
  });
4210
- return _context43.abrupt("return", {
3960
+ return _context41.abrupt("return", {
4211
3961
  code: 500,
4212
3962
  message: errorMessage,
4213
3963
  data: {
@@ -4218,11 +3968,11 @@ var Server = /*#__PURE__*/function () {
4218
3968
  });
4219
3969
  case 28:
4220
3970
  case "end":
4221
- return _context43.stop();
3971
+ return _context41.stop();
4222
3972
  }
4223
- }, _callee43, this, [[3, 23]]);
3973
+ }, _callee41, this, [[3, 23]]);
4224
3974
  }));
4225
- function fetchBookingListFromAPI(_x47) {
3975
+ function fetchBookingListFromAPI(_x44) {
4226
3976
  return _fetchBookingListFromAPI.apply(this, arguments);
4227
3977
  }
4228
3978
  return fetchBookingListFromAPI;
@@ -4298,32 +4048,32 @@ var Server = /*#__PURE__*/function () {
4298
4048
  }, {
4299
4049
  key: "getShortNumberOrDeviceId",
4300
4050
  value: function () {
4301
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4051
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
4302
4052
  var getAsyncIotDeviceInfo, res;
4303
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4304
- while (1) switch (_context44.prev = _context44.next) {
4053
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4054
+ while (1) switch (_context42.prev = _context42.next) {
4305
4055
  case 0:
4306
4056
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
4307
4057
  if (!getAsyncIotDeviceInfo) {
4308
- _context44.next = 7;
4058
+ _context42.next = 7;
4309
4059
  break;
4310
4060
  }
4311
- _context44.next = 4;
4061
+ _context42.next = 4;
4312
4062
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
4313
4063
  case 4:
4314
- res = _context44.sent;
4064
+ res = _context42.sent;
4315
4065
  if (!(res !== null && res !== void 0 && res.short_number)) {
4316
- _context44.next = 7;
4066
+ _context42.next = 7;
4317
4067
  break;
4318
4068
  }
4319
- return _context44.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
4069
+ return _context42.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
4320
4070
  case 7:
4321
- return _context44.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
4071
+ return _context42.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
4322
4072
  case 8:
4323
4073
  case "end":
4324
- return _context44.stop();
4074
+ return _context42.stop();
4325
4075
  }
4326
- }, _callee44, this);
4076
+ }, _callee42, this);
4327
4077
  }));
4328
4078
  function getShortNumberOrDeviceId() {
4329
4079
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -4350,16 +4100,16 @@ var Server = /*#__PURE__*/function () {
4350
4100
  }, {
4351
4101
  key: "normalizeCheckoutSubmitData",
4352
4102
  value: function () {
4353
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data, title) {
4103
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data, title) {
4354
4104
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
4355
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4356
- while (1) switch (_context45.prev = _context45.next) {
4105
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4106
+ while (1) switch (_context43.prev = _context43.next) {
4357
4107
  case 0:
4358
4108
  if (!(!data || _typeof(data) !== 'object')) {
4359
- _context45.next = 2;
4109
+ _context43.next = 2;
4360
4110
  break;
4361
4111
  }
4362
- return _context45.abrupt("return", data);
4112
+ return _context43.abrupt("return", data);
4363
4113
  case 2:
4364
4114
  next = _objectSpread({}, data);
4365
4115
  externalSaleNumber = next.external_sale_number;
@@ -4369,7 +4119,7 @@ var Server = /*#__PURE__*/function () {
4369
4119
  delete next.vouchers;
4370
4120
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
4371
4121
  if (!hasCheckoutOrderNumbers) {
4372
- _context45.next = 11;
4122
+ _context43.next = 11;
4373
4123
  break;
4374
4124
  }
4375
4125
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -4379,10 +4129,10 @@ var Server = /*#__PURE__*/function () {
4379
4129
  shop_order_number: next.shop_order_number,
4380
4130
  shop_full_order_number: next.shop_full_order_number
4381
4131
  });
4382
- return _context45.abrupt("return", next);
4132
+ return _context43.abrupt("return", next);
4383
4133
  case 11:
4384
4134
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
4385
- _context45.next = 14;
4135
+ _context43.next = 14;
4386
4136
  break;
4387
4137
  }
4388
4138
  if (shouldClearLocalOrderId) {
@@ -4391,10 +4141,10 @@ var Server = /*#__PURE__*/function () {
4391
4141
  order_id: next.order_id
4392
4142
  });
4393
4143
  }
4394
- return _context45.abrupt("return", next);
4144
+ return _context43.abrupt("return", next);
4395
4145
  case 14:
4396
4146
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
4397
- _context45.next = 17;
4147
+ _context43.next = 17;
4398
4148
  break;
4399
4149
  }
4400
4150
  if (shouldClearLocalOrderId) {
@@ -4403,12 +4153,12 @@ var Server = /*#__PURE__*/function () {
4403
4153
  external_sale_number: externalSaleNumber
4404
4154
  });
4405
4155
  }
4406
- return _context45.abrupt("return", next);
4156
+ return _context43.abrupt("return", next);
4407
4157
  case 17:
4408
- _context45.prev = 17;
4158
+ _context43.prev = 17;
4409
4159
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
4410
4160
  if (localOrder) {
4411
- _context45.next = 22;
4161
+ _context43.next = 22;
4412
4162
  break;
4413
4163
  }
4414
4164
  if (shouldClearLocalOrderId) {
@@ -4418,7 +4168,7 @@ var Server = /*#__PURE__*/function () {
4418
4168
  localOrderFound: false
4419
4169
  });
4420
4170
  }
4421
- return _context45.abrupt("return", next);
4171
+ return _context43.abrupt("return", next);
4422
4172
  case 22:
4423
4173
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
4424
4174
  next.shop_order_number = localOrder.shop_order_number;
@@ -4435,23 +4185,23 @@ var Server = /*#__PURE__*/function () {
4435
4185
  shop_full_order_number: next.shop_full_order_number
4436
4186
  });
4437
4187
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
4438
- return _context45.abrupt("return", next);
4188
+ return _context43.abrupt("return", next);
4439
4189
  case 28:
4440
- _context45.prev = 28;
4441
- _context45.t0 = _context45["catch"](17);
4190
+ _context43.prev = 28;
4191
+ _context43.t0 = _context43["catch"](17);
4442
4192
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
4443
4193
  external_sale_number: externalSaleNumber,
4444
- error: this.getUnknownErrorMessage(_context45.t0),
4445
- error_detail: this.normalizeUnknownError(_context45.t0)
4194
+ error: this.getUnknownErrorMessage(_context43.t0),
4195
+ error_detail: this.normalizeUnknownError(_context43.t0)
4446
4196
  });
4447
- return _context45.abrupt("return", next);
4197
+ return _context43.abrupt("return", next);
4448
4198
  case 32:
4449
4199
  case "end":
4450
- return _context45.stop();
4200
+ return _context43.stop();
4451
4201
  }
4452
- }, _callee45, this, [[17, 28]]);
4202
+ }, _callee43, this, [[17, 28]]);
4453
4203
  }));
4454
- function normalizeCheckoutSubmitData(_x48, _x49) {
4204
+ function normalizeCheckoutSubmitData(_x45, _x46) {
4455
4205
  return _normalizeCheckoutSubmitData.apply(this, arguments);
4456
4206
  }
4457
4207
  return normalizeCheckoutSubmitData;
@@ -4459,81 +4209,81 @@ var Server = /*#__PURE__*/function () {
4459
4209
  }, {
4460
4210
  key: "ensureCheckoutOrderNumbers",
4461
4211
  value: function () {
4462
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data, title) {
4212
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data, title) {
4463
4213
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
4464
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4465
- while (1) switch (_context46.prev = _context46.next) {
4214
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4215
+ while (1) switch (_context44.prev = _context44.next) {
4466
4216
  case 0:
4467
4217
  if (!(!data || _typeof(data) !== 'object')) {
4468
- _context46.next = 2;
4218
+ _context44.next = 2;
4469
4219
  break;
4470
4220
  }
4471
- return _context46.abrupt("return", data);
4221
+ return _context44.abrupt("return", data);
4472
4222
  case 2:
4473
4223
  next = _objectSpread({}, data);
4474
4224
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
4475
4225
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
4476
4226
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
4477
- _context46.next = 7;
4227
+ _context44.next = 7;
4478
4228
  break;
4479
4229
  }
4480
- return _context46.abrupt("return", next);
4230
+ return _context44.abrupt("return", next);
4481
4231
  case 7:
4482
4232
  idGenerator = this.getIdGeneratorPlugin();
4483
4233
  if (idGenerator) {
4484
- _context46.next = 11;
4234
+ _context44.next = 11;
4485
4235
  break;
4486
4236
  }
4487
4237
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
4488
4238
  needsShopOrderNumber: needsShopOrderNumber,
4489
4239
  needsShopFullOrderNumber: needsShopFullOrderNumber
4490
4240
  });
4491
- return _context46.abrupt("return", next);
4241
+ return _context44.abrupt("return", next);
4492
4242
  case 11:
4493
- _context46.prev = 11;
4243
+ _context44.prev = 11;
4494
4244
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
4495
- _context46.next = 16;
4245
+ _context44.next = 16;
4496
4246
  break;
4497
4247
  }
4498
- _context46.next = 15;
4248
+ _context44.next = 15;
4499
4249
  return idGenerator.generateShopOrderNumber({
4500
4250
  biz: next.business_code || 'ticket'
4501
4251
  });
4502
4252
  case 15:
4503
- next.shop_order_number = _context46.sent;
4253
+ next.shop_order_number = _context44.sent;
4504
4254
  case 16:
4505
4255
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
4506
- _context46.next = 20;
4256
+ _context44.next = 20;
4507
4257
  break;
4508
4258
  }
4509
- _context46.next = 19;
4259
+ _context44.next = 19;
4510
4260
  return idGenerator.generateReceiptId({
4511
4261
  biz: next.business_code || 'ticket'
4512
4262
  });
4513
4263
  case 19:
4514
- next.shop_full_order_number = _context46.sent;
4264
+ next.shop_full_order_number = _context44.sent;
4515
4265
  case 20:
4516
4266
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
4517
4267
  shop_order_number: next.shop_order_number,
4518
4268
  shop_full_order_number: next.shop_full_order_number
4519
4269
  });
4520
- _context46.next = 26;
4270
+ _context44.next = 26;
4521
4271
  break;
4522
4272
  case 23:
4523
- _context46.prev = 23;
4524
- _context46.t0 = _context46["catch"](11);
4273
+ _context44.prev = 23;
4274
+ _context44.t0 = _context44["catch"](11);
4525
4275
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
4526
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4276
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4527
4277
  });
4528
4278
  case 26:
4529
- return _context46.abrupt("return", next);
4279
+ return _context44.abrupt("return", next);
4530
4280
  case 27:
4531
4281
  case "end":
4532
- return _context46.stop();
4282
+ return _context44.stop();
4533
4283
  }
4534
- }, _callee46, this, [[11, 23]]);
4284
+ }, _callee44, this, [[11, 23]]);
4535
4285
  }));
4536
- function ensureCheckoutOrderNumbers(_x50, _x51) {
4286
+ function ensureCheckoutOrderNumbers(_x47, _x48) {
4537
4287
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
4538
4288
  }
4539
4289
  return ensureCheckoutOrderNumbers;
@@ -4541,27 +4291,27 @@ var Server = /*#__PURE__*/function () {
4541
4291
  }, {
4542
4292
  key: "dispatchCheckoutSyncTask",
4543
4293
  value: function () {
4544
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4294
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
4545
4295
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
4546
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4547
- while (1) switch (_context47.prev = _context47.next) {
4296
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4297
+ while (1) switch (_context45.prev = _context45.next) {
4548
4298
  case 0:
4549
4299
  this.registerDeviceTaskActions();
4550
4300
  deviceTask = this.getDeviceTaskPlugin();
4551
- _context47.next = 4;
4301
+ _context45.next = 4;
4552
4302
  return this.getShortNumberOrDeviceId();
4553
4303
  case 4:
4554
- debugDeviceId = _context47.sent;
4304
+ debugDeviceId = _context45.sent;
4555
4305
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
4556
4306
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
4557
- _context47.next = 9;
4307
+ _context45.next = 9;
4558
4308
  break;
4559
4309
  }
4560
4310
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
4561
- return _context47.abrupt("return");
4311
+ return _context45.abrupt("return");
4562
4312
  case 9:
4563
- _context47.prev = 9;
4564
- _context47.next = 12;
4313
+ _context45.prev = 9;
4314
+ _context45.next = 12;
4565
4315
  return deviceTask.dispatch({
4566
4316
  action: 'sync_sales',
4567
4317
  device_id: debugDeviceId,
@@ -4579,27 +4329,27 @@ var Server = /*#__PURE__*/function () {
4579
4329
  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)
4580
4330
  });
4581
4331
  case 12:
4582
- result = _context47.sent;
4332
+ result = _context45.sent;
4583
4333
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
4584
4334
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
4585
4335
  status: result === null || result === void 0 ? void 0 : result.status,
4586
4336
  reused: result === null || result === void 0 ? void 0 : result.reused
4587
4337
  });
4588
- _context47.next = 19;
4338
+ _context45.next = 19;
4589
4339
  break;
4590
4340
  case 16:
4591
- _context47.prev = 16;
4592
- _context47.t0 = _context47["catch"](9);
4341
+ _context45.prev = 16;
4342
+ _context45.t0 = _context45["catch"](9);
4593
4343
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
4594
- error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4344
+ error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4595
4345
  });
4596
4346
  case 19:
4597
4347
  case "end":
4598
- return _context47.stop();
4348
+ return _context45.stop();
4599
4349
  }
4600
- }, _callee47, this, [[9, 16]]);
4350
+ }, _callee45, this, [[9, 16]]);
4601
4351
  }));
4602
- function dispatchCheckoutSyncTask(_x52) {
4352
+ function dispatchCheckoutSyncTask(_x49) {
4603
4353
  return _dispatchCheckoutSyncTask.apply(this, arguments);
4604
4354
  }
4605
4355
  return dispatchCheckoutSyncTask;
@@ -4607,26 +4357,26 @@ var Server = /*#__PURE__*/function () {
4607
4357
  }, {
4608
4358
  key: "dispatchPrintOtherReceiptTask",
4609
4359
  value: function () {
4610
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4360
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
4611
4361
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
4612
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4613
- while (1) switch (_context48.prev = _context48.next) {
4362
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4363
+ while (1) switch (_context46.prev = _context46.next) {
4614
4364
  case 0:
4615
4365
  deviceTask = this.getDeviceTaskPlugin();
4616
4366
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
4617
- _context48.next = 4;
4367
+ _context46.next = 4;
4618
4368
  break;
4619
4369
  }
4620
4370
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
4621
- return _context48.abrupt("return");
4371
+ return _context46.abrupt("return");
4622
4372
  case 4:
4623
- _context48.prev = 4;
4373
+ _context46.prev = 4;
4624
4374
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
4625
- _context48.next = 8;
4375
+ _context46.next = 8;
4626
4376
  return this.getShortNumberOrDeviceId();
4627
4377
  case 8:
4628
- deviceId = _context48.sent;
4629
- _context48.next = 11;
4378
+ deviceId = _context46.sent;
4379
+ _context46.next = 11;
4630
4380
  return deviceTask.dispatch({
4631
4381
  action: 'print_all',
4632
4382
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -4653,21 +4403,21 @@ var Server = /*#__PURE__*/function () {
4653
4403
  source_id: printIdentity
4654
4404
  });
4655
4405
  case 11:
4656
- _context48.next = 16;
4406
+ _context46.next = 16;
4657
4407
  break;
4658
4408
  case 13:
4659
- _context48.prev = 13;
4660
- _context48.t0 = _context48["catch"](4);
4409
+ _context46.prev = 13;
4410
+ _context46.t0 = _context46["catch"](4);
4661
4411
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
4662
- error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
4412
+ error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
4663
4413
  });
4664
4414
  case 16:
4665
4415
  case "end":
4666
- return _context48.stop();
4416
+ return _context46.stop();
4667
4417
  }
4668
- }, _callee48, this, [[4, 13]]);
4418
+ }, _callee46, this, [[4, 13]]);
4669
4419
  }));
4670
- function dispatchPrintOtherReceiptTask(_x53) {
4420
+ function dispatchPrintOtherReceiptTask(_x50) {
4671
4421
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
4672
4422
  }
4673
4423
  return dispatchPrintOtherReceiptTask;
@@ -4687,32 +4437,32 @@ var Server = /*#__PURE__*/function () {
4687
4437
  }, {
4688
4438
  key: "dispatchLocalReceiptPrint",
4689
4439
  value: function () {
4690
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4440
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4691
4441
  var _payment_info;
4692
4442
  var printableOrder;
4693
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4694
- while (1) switch (_context49.prev = _context49.next) {
4443
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4444
+ while (1) switch (_context47.prev = _context47.next) {
4695
4445
  case 0:
4696
4446
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
4697
- _context49.next = 2;
4447
+ _context47.next = 2;
4698
4448
  break;
4699
4449
  }
4700
- return _context49.abrupt("return", {
4450
+ return _context47.abrupt("return", {
4701
4451
  printed: false,
4702
4452
  order: params.order
4703
4453
  });
4704
4454
  case 2:
4705
- _context49.next = 4;
4455
+ _context47.next = 4;
4706
4456
  return this.withLocalSmallTicketData(params.order, {
4707
4457
  requireFullyPaid: params.requireFullyPaid
4708
4458
  });
4709
4459
  case 4:
4710
- printableOrder = _context49.sent;
4460
+ printableOrder = _context47.sent;
4711
4461
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
4712
- _context49.next = 7;
4462
+ _context47.next = 7;
4713
4463
  break;
4714
4464
  }
4715
- return _context49.abrupt("return", {
4465
+ return _context47.abrupt("return", {
4716
4466
  printed: false,
4717
4467
  order: printableOrder
4718
4468
  });
@@ -4722,7 +4472,7 @@ var Server = /*#__PURE__*/function () {
4722
4472
  printableOrder: printableOrder,
4723
4473
  response: params.response
4724
4474
  });
4725
- _context49.next = 10;
4475
+ _context47.next = 10;
4726
4476
  return this.dispatchPrintOtherReceiptTask({
4727
4477
  checkoutData: params.checkoutData,
4728
4478
  syncedOrder: printableOrder,
@@ -4731,17 +4481,17 @@ var Server = /*#__PURE__*/function () {
4731
4481
  isManualPrint: params.isManualPrint
4732
4482
  });
4733
4483
  case 10:
4734
- return _context49.abrupt("return", {
4484
+ return _context47.abrupt("return", {
4735
4485
  printed: true,
4736
4486
  order: printableOrder
4737
4487
  });
4738
4488
  case 11:
4739
4489
  case "end":
4740
- return _context49.stop();
4490
+ return _context47.stop();
4741
4491
  }
4742
- }, _callee49, this);
4492
+ }, _callee47, this);
4743
4493
  }));
4744
- function dispatchLocalReceiptPrint(_x54) {
4494
+ function dispatchLocalReceiptPrint(_x51) {
4745
4495
  return _dispatchLocalReceiptPrint.apply(this, arguments);
4746
4496
  }
4747
4497
  return dispatchLocalReceiptPrint;
@@ -4776,47 +4526,47 @@ var Server = /*#__PURE__*/function () {
4776
4526
  }, {
4777
4527
  key: "syncMachinecodeRedeemStatusToLocalOrder",
4778
4528
  value: function () {
4779
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data, ids, status) {
4529
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data, ids, status) {
4780
4530
  var _this$order3;
4781
4531
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
4782
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4783
- while (1) switch (_context50.prev = _context50.next) {
4532
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4533
+ while (1) switch (_context48.prev = _context48.next) {
4784
4534
  case 0:
4785
4535
  title = 'handleMachinecodeBatchMetadata';
4786
4536
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
4787
4537
  if (!(lookup === undefined)) {
4788
- _context50.next = 5;
4538
+ _context48.next = 5;
4789
4539
  break;
4790
4540
  }
4791
4541
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4792
4542
  batchSize: ids.length,
4793
4543
  status: status
4794
4544
  });
4795
- return _context50.abrupt("return");
4545
+ return _context48.abrupt("return");
4796
4546
  case 5:
4797
4547
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
4798
- _context50.next = 8;
4548
+ _context48.next = 8;
4799
4549
  break;
4800
4550
  }
4801
4551
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4802
4552
  lookup: lookup,
4803
4553
  status: status
4804
4554
  });
4805
- return _context50.abrupt("return");
4555
+ return _context48.abrupt("return");
4806
4556
  case 8:
4807
- _context50.next = 10;
4557
+ _context48.next = 10;
4808
4558
  return this.order.getLocalOrderByLookup(lookup);
4809
4559
  case 10:
4810
- localOrder = _context50.sent;
4560
+ localOrder = _context48.sent;
4811
4561
  if (localOrder) {
4812
- _context50.next = 14;
4562
+ _context48.next = 14;
4813
4563
  break;
4814
4564
  }
4815
4565
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4816
4566
  lookup: lookup,
4817
4567
  status: status
4818
4568
  });
4819
- return _context50.abrupt("return");
4569
+ return _context48.abrupt("return");
4820
4570
  case 14:
4821
4571
  voucherIdSet = new Set(ids.filter(function (id) {
4822
4572
  return id !== undefined && id !== null && id !== '';
@@ -4824,14 +4574,14 @@ var Server = /*#__PURE__*/function () {
4824
4574
  return String(id);
4825
4575
  }));
4826
4576
  if (!(voucherIdSet.size === 0)) {
4827
- _context50.next = 18;
4577
+ _context48.next = 18;
4828
4578
  break;
4829
4579
  }
4830
4580
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
4831
4581
  lookup: lookup,
4832
4582
  status: status
4833
4583
  });
4834
- return _context50.abrupt("return");
4584
+ return _context48.abrupt("return");
4835
4585
  case 18:
4836
4586
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
4837
4587
  hasUpdatedVoucher = false;
@@ -4845,7 +4595,7 @@ var Server = /*#__PURE__*/function () {
4845
4595
  });
4846
4596
  });
4847
4597
  if (hasUpdatedVoucher) {
4848
- _context50.next = 24;
4598
+ _context48.next = 24;
4849
4599
  break;
4850
4600
  }
4851
4601
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -4853,13 +4603,13 @@ var Server = /*#__PURE__*/function () {
4853
4603
  voucher_ids: Array.from(voucherIdSet),
4854
4604
  status: status
4855
4605
  });
4856
- return _context50.abrupt("return");
4606
+ return _context48.abrupt("return");
4857
4607
  case 24:
4858
4608
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
4859
- _context50.next = 29;
4609
+ _context48.next = 29;
4860
4610
  break;
4861
4611
  }
4862
- _context50.next = 27;
4612
+ _context48.next = 27;
4863
4613
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
4864
4614
  vouchers: nextVouchers
4865
4615
  }));
@@ -4869,13 +4619,13 @@ var Server = /*#__PURE__*/function () {
4869
4619
  updatedCount: voucherIdSet.size,
4870
4620
  status: status
4871
4621
  });
4872
- return _context50.abrupt("return");
4622
+ return _context48.abrupt("return");
4873
4623
  case 29:
4874
4624
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
4875
- _context50.next = 34;
4625
+ _context48.next = 34;
4876
4626
  break;
4877
4627
  }
4878
- _context50.next = 32;
4628
+ _context48.next = 32;
4879
4629
  return this.order.markOrderSyncedByExternalSaleNumber({
4880
4630
  externalSaleNumber: data.external_sale_number,
4881
4631
  patch: {
@@ -4888,7 +4638,7 @@ var Server = /*#__PURE__*/function () {
4888
4638
  updatedCount: voucherIdSet.size,
4889
4639
  status: status
4890
4640
  });
4891
- return _context50.abrupt("return");
4641
+ return _context48.abrupt("return");
4892
4642
  case 34:
4893
4643
  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"), {
4894
4644
  lookup: lookup,
@@ -4896,11 +4646,11 @@ var Server = /*#__PURE__*/function () {
4896
4646
  });
4897
4647
  case 35:
4898
4648
  case "end":
4899
- return _context50.stop();
4649
+ return _context48.stop();
4900
4650
  }
4901
- }, _callee50, this);
4651
+ }, _callee48, this);
4902
4652
  }));
4903
- function syncMachinecodeRedeemStatusToLocalOrder(_x55, _x56, _x57) {
4653
+ function syncMachinecodeRedeemStatusToLocalOrder(_x52, _x53, _x54) {
4904
4654
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
4905
4655
  }
4906
4656
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -4908,10 +4658,10 @@ var Server = /*#__PURE__*/function () {
4908
4658
  }, {
4909
4659
  key: "handleOrderCheckoutSubmit",
4910
4660
  value: function () {
4911
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4661
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4912
4662
  var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
4913
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4914
- while (1) switch (_context51.prev = _context51.next) {
4663
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4664
+ while (1) switch (_context49.prev = _context49.next) {
4915
4665
  case 0:
4916
4666
  backendPath = params.backendPath, data = params.data, title = params.title;
4917
4667
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -4921,24 +4671,24 @@ var Server = /*#__PURE__*/function () {
4921
4671
  order_number: data === null || data === void 0 ? void 0 : data.order_number
4922
4672
  });
4923
4673
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
4924
- _context51.next = 4;
4674
+ _context49.next = 4;
4925
4675
  break;
4926
4676
  }
4927
- return _context51.abrupt("return", this.handleSyncCheckoutSubmit({
4677
+ return _context49.abrupt("return", this.handleSyncCheckoutSubmit({
4928
4678
  backendPath: backendPath,
4929
4679
  data: data,
4930
4680
  title: title
4931
4681
  }));
4932
4682
  case 4:
4933
- _context51.next = 6;
4683
+ _context49.next = 6;
4934
4684
  return this.normalizeCheckoutSubmitData(data, title);
4935
4685
  case 6:
4936
- normalizedData = _context51.sent;
4937
- _context51.next = 9;
4686
+ normalizedData = _context49.sent;
4687
+ _context49.next = 9;
4938
4688
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
4939
4689
  case 9:
4940
- checkoutData = _context51.sent;
4941
- _context51.next = 12;
4690
+ checkoutData = _context49.sent;
4691
+ _context49.next = 12;
4942
4692
  return this.handlePendingSyncCheckoutOrder({
4943
4693
  backendPath: backendPath,
4944
4694
  data: checkoutData,
@@ -4946,9 +4696,9 @@ var Server = /*#__PURE__*/function () {
4946
4696
  reason: 'checkout 已转入设备任务同步'
4947
4697
  });
4948
4698
  case 12:
4949
- pendingResult = _context51.sent;
4699
+ pendingResult = _context49.sent;
4950
4700
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
4951
- _context51.next = 20;
4701
+ _context49.next = 20;
4952
4702
  break;
4953
4703
  }
4954
4704
  pendingOrder = pendingResult.data;
@@ -4956,10 +4706,10 @@ var Server = /*#__PURE__*/function () {
4956
4706
  // TODO 这里先加个兼容,只有 type 为 virtual 才走打印
4957
4707
  // 后期需要迁移到 picoding ,根据工作流配置
4958
4708
  checkoutData.type === 'virtual')) {
4959
- _context51.next = 18;
4709
+ _context49.next = 18;
4960
4710
  break;
4961
4711
  }
4962
- _context51.next = 18;
4712
+ _context49.next = 18;
4963
4713
  return this.dispatchLocalReceiptPrint({
4964
4714
  checkoutData: checkoutData,
4965
4715
  order: pendingOrder,
@@ -4967,7 +4717,7 @@ var Server = /*#__PURE__*/function () {
4967
4717
  requireFullyPaid: true
4968
4718
  });
4969
4719
  case 18:
4970
- _context51.next = 20;
4720
+ _context49.next = 20;
4971
4721
  return this.dispatchCheckoutSyncTask({
4972
4722
  backendPath: backendPath,
4973
4723
  data: checkoutData,
@@ -4975,23 +4725,23 @@ var Server = /*#__PURE__*/function () {
4975
4725
  });
4976
4726
  case 20:
4977
4727
  if (pendingResult.data.order_id) {
4978
- _context51.next = 22;
4728
+ _context49.next = 22;
4979
4729
  break;
4980
4730
  }
4981
- return _context51.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4731
+ return _context49.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
4982
4732
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
4983
4733
  order_id: pendingResult.data.external_sale_number
4984
4734
  })
4985
4735
  }));
4986
4736
  case 22:
4987
- return _context51.abrupt("return", pendingResult);
4737
+ return _context49.abrupt("return", pendingResult);
4988
4738
  case 23:
4989
4739
  case "end":
4990
- return _context51.stop();
4740
+ return _context49.stop();
4991
4741
  }
4992
- }, _callee51, this);
4742
+ }, _callee49, this);
4993
4743
  }));
4994
- function handleOrderCheckoutSubmit(_x58) {
4744
+ function handleOrderCheckoutSubmit(_x55) {
4995
4745
  return _handleOrderCheckoutSubmit.apply(this, arguments);
4996
4746
  }
4997
4747
  return handleOrderCheckoutSubmit;
@@ -4999,27 +4749,27 @@ var Server = /*#__PURE__*/function () {
4999
4749
  }, {
5000
4750
  key: "handleSyncCheckoutSubmit",
5001
4751
  value: function () {
5002
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4752
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
5003
4753
  var _this$app16;
5004
4754
  var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
5005
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5006
- while (1) switch (_context52.prev = _context52.next) {
4755
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4756
+ while (1) switch (_context50.prev = _context50.next) {
5007
4757
  case 0:
5008
4758
  backendPath = params.backendPath, data = params.data, title = params.title;
5009
4759
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
5010
- _context52.next = 4;
4760
+ _context50.next = 4;
5011
4761
  break;
5012
4762
  }
5013
4763
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
5014
- return _context52.abrupt("return", {
4764
+ return _context50.abrupt("return", {
5015
4765
  code: 500,
5016
4766
  status: false,
5017
4767
  message: 'app.request 不可用',
5018
4768
  data: null
5019
4769
  });
5020
4770
  case 4:
5021
- _context52.prev = 4;
5022
- _context52.next = 7;
4771
+ _context50.prev = 4;
4772
+ _context50.next = 7;
5023
4773
  return this.runCheckoutSync({
5024
4774
  backendPath: backendPath,
5025
4775
  data: data,
@@ -5027,41 +4777,41 @@ var Server = /*#__PURE__*/function () {
5027
4777
  persistCheckoutDataWithResponse: true
5028
4778
  });
5029
4779
  case 7:
5030
- syncResult = _context52.sent;
4780
+ syncResult = _context50.sent;
5031
4781
  if (!syncResult.rejected) {
5032
- _context52.next = 11;
4782
+ _context50.next = 11;
5033
4783
  break;
5034
4784
  }
5035
4785
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
5036
- return _context52.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
4786
+ return _context50.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5037
4787
  status: false,
5038
4788
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
5039
4789
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
5040
4790
  }));
5041
4791
  case 11:
5042
- return _context52.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
4792
+ return _context50.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
5043
4793
  case 14:
5044
- _context52.prev = 14;
5045
- _context52.t0 = _context52["catch"](4);
5046
- backendError = this.extractBackendErrorResponse(_context52.t0);
4794
+ _context50.prev = 14;
4795
+ _context50.t0 = _context50["catch"](4);
4796
+ backendError = this.extractBackendErrorResponse(_context50.t0);
5047
4797
  if (!backendError) {
5048
- _context52.next = 20;
4798
+ _context50.next = 20;
5049
4799
  break;
5050
4800
  }
5051
4801
  _normalized = this.normalizeCheckoutResponse(backendError);
5052
- return _context52.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
4802
+ return _context50.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5053
4803
  status: false,
5054
4804
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
5055
4805
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
5056
4806
  }));
5057
4807
  case 20:
5058
- message = this.getUnknownErrorMessage(_context52.t0);
4808
+ message = this.getUnknownErrorMessage(_context50.t0);
5059
4809
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
5060
4810
  backendPath: backendPath,
5061
4811
  error: message,
5062
- error_detail: this.normalizeUnknownError(_context52.t0)
4812
+ error_detail: this.normalizeUnknownError(_context50.t0)
5063
4813
  });
5064
- return _context52.abrupt("return", {
4814
+ return _context50.abrupt("return", {
5065
4815
  code: 500,
5066
4816
  status: false,
5067
4817
  message: message,
@@ -5069,11 +4819,11 @@ var Server = /*#__PURE__*/function () {
5069
4819
  });
5070
4820
  case 23:
5071
4821
  case "end":
5072
- return _context52.stop();
4822
+ return _context50.stop();
5073
4823
  }
5074
- }, _callee52, this, [[4, 14]]);
4824
+ }, _callee50, this, [[4, 14]]);
5075
4825
  }));
5076
- function handleSyncCheckoutSubmit(_x59) {
4826
+ function handleSyncCheckoutSubmit(_x56) {
5077
4827
  return _handleSyncCheckoutSubmit.apply(this, arguments);
5078
4828
  }
5079
4829
  return handleSyncCheckoutSubmit;
@@ -5081,26 +4831,26 @@ var Server = /*#__PURE__*/function () {
5081
4831
  }, {
5082
4832
  key: "handlePendingSyncCheckoutOrder",
5083
4833
  value: function () {
5084
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5085
- var _this11 = this;
4834
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4835
+ var _this10 = this;
5086
4836
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
5087
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5088
- while (1) switch (_context53.prev = _context53.next) {
4837
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4838
+ while (1) switch (_context51.prev = _context51.next) {
5089
4839
  case 0:
5090
4840
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
5091
- _context53.next = 3;
4841
+ _context51.next = 3;
5092
4842
  return this.buildPendingSyncCheckoutOrder(data);
5093
4843
  case 3:
5094
- pendingOrder = _context53.sent;
4844
+ pendingOrder = _context51.sent;
5095
4845
  if (pendingOrder) {
5096
- _context53.next = 7;
4846
+ _context51.next = 7;
5097
4847
  break;
5098
4848
  }
5099
4849
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
5100
4850
  backendPath: backendPath,
5101
4851
  reason: reason
5102
4852
  });
5103
- return _context53.abrupt("return", {
4853
+ return _context51.abrupt("return", {
5104
4854
  code: 500,
5105
4855
  status: false,
5106
4856
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -5108,22 +4858,22 @@ var Server = /*#__PURE__*/function () {
5108
4858
  });
5109
4859
  case 7:
5110
4860
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
5111
- _context53.next = 10;
4861
+ _context51.next = 10;
5112
4862
  break;
5113
4863
  }
5114
4864
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
5115
4865
  backendPath: backendPath,
5116
4866
  reason: reason
5117
4867
  });
5118
- return _context53.abrupt("return", {
4868
+ return _context51.abrupt("return", {
5119
4869
  code: 500,
5120
4870
  status: false,
5121
4871
  message: 'Order 模块不支持本地待同步写入',
5122
4872
  data: null
5123
4873
  });
5124
4874
  case 10:
5125
- _context53.prev = 10;
5126
- _context53.next = 13;
4875
+ _context51.prev = 10;
4876
+ _context51.next = 13;
5127
4877
  return this.order.upsertPendingSyncOrders([pendingOrder]);
5128
4878
  case 13:
5129
4879
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -5135,9 +4885,9 @@ var Server = /*#__PURE__*/function () {
5135
4885
  });
5136
4886
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
5137
4887
  var _payment$metadata;
5138
- return sum + _this11.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
4888
+ return sum + _this10.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
5139
4889
  }, 0);
5140
- return _context53.abrupt("return", {
4890
+ return _context51.abrupt("return", {
5141
4891
  code: 200,
5142
4892
  status: true,
5143
4893
  message: '',
@@ -5152,15 +4902,15 @@ var Server = /*#__PURE__*/function () {
5152
4902
  })
5153
4903
  });
5154
4904
  case 18:
5155
- _context53.prev = 18;
5156
- _context53.t0 = _context53["catch"](10);
5157
- errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
4905
+ _context51.prev = 18;
4906
+ _context51.t0 = _context51["catch"](10);
4907
+ errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
5158
4908
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
5159
4909
  backendPath: backendPath,
5160
4910
  reason: reason,
5161
4911
  error: errorMessage
5162
4912
  });
5163
- return _context53.abrupt("return", {
4913
+ return _context51.abrupt("return", {
5164
4914
  code: 500,
5165
4915
  status: false,
5166
4916
  message: errorMessage,
@@ -5168,11 +4918,11 @@ var Server = /*#__PURE__*/function () {
5168
4918
  });
5169
4919
  case 23:
5170
4920
  case "end":
5171
- return _context53.stop();
4921
+ return _context51.stop();
5172
4922
  }
5173
- }, _callee53, this, [[10, 18]]);
4923
+ }, _callee51, this, [[10, 18]]);
5174
4924
  }));
5175
- function handlePendingSyncCheckoutOrder(_x60) {
4925
+ function handlePendingSyncCheckoutOrder(_x57) {
5176
4926
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
5177
4927
  }
5178
4928
  return handlePendingSyncCheckoutOrder;
@@ -5180,43 +4930,43 @@ var Server = /*#__PURE__*/function () {
5180
4930
  }, {
5181
4931
  key: "buildPendingSyncCheckoutOrder",
5182
4932
  value: function () {
5183
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
4933
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data) {
5184
4934
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
5185
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5186
- while (1) switch (_context54.prev = _context54.next) {
4935
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4936
+ while (1) switch (_context52.prev = _context52.next) {
5187
4937
  case 0:
5188
4938
  if (!(!data || _typeof(data) !== 'object')) {
5189
- _context54.next = 2;
4939
+ _context52.next = 2;
5190
4940
  break;
5191
4941
  }
5192
- return _context54.abrupt("return", null);
4942
+ return _context52.abrupt("return", null);
5193
4943
  case 2:
5194
4944
  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 !== '';
5195
4945
  if (hasStorageKey) {
5196
- _context54.next = 5;
4946
+ _context52.next = 5;
5197
4947
  break;
5198
4948
  }
5199
- return _context54.abrupt("return", null);
4949
+ return _context52.abrupt("return", null);
5200
4950
  case 5:
5201
4951
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
5202
4952
  need_sync: 1
5203
4953
  });
5204
- _context54.next = 8;
4954
+ _context52.next = 8;
5205
4955
  return this.buildSmallTicketProductMap(pendingOrder);
5206
4956
  case 8:
5207
- productMap = _context54.sent;
4957
+ productMap = _context52.sent;
5208
4958
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
5209
- return _context54.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
4959
+ return _context52.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
5210
4960
  requireFullyPaid: true,
5211
4961
  productMap: productMap
5212
4962
  }));
5213
4963
  case 11:
5214
4964
  case "end":
5215
- return _context54.stop();
4965
+ return _context52.stop();
5216
4966
  }
5217
- }, _callee54, this);
4967
+ }, _callee52, this);
5218
4968
  }));
5219
- function buildPendingSyncCheckoutOrder(_x61) {
4969
+ function buildPendingSyncCheckoutOrder(_x58) {
5220
4970
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
5221
4971
  }
5222
4972
  return buildPendingSyncCheckoutOrder;
@@ -5264,13 +5014,13 @@ var Server = /*#__PURE__*/function () {
5264
5014
  }, {
5265
5015
  key: "sumPaidOrderPayments",
5266
5016
  value: function sumPaidOrderPayments(payments) {
5267
- var _this12 = this;
5017
+ var _this11 = this;
5268
5018
  if (!Array.isArray(payments)) return 0;
5269
5019
  return payments.reduce(function (sum, payment) {
5270
5020
  var _payment$amount;
5271
5021
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
5272
5022
  if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
5273
- return sum + _this12.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);
5023
+ return sum + _this11.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);
5274
5024
  }, 0);
5275
5025
  }
5276
5026
  }, {
@@ -5284,12 +5034,12 @@ var Server = /*#__PURE__*/function () {
5284
5034
  }, {
5285
5035
  key: "buildSmallTicketProductMap",
5286
5036
  value: function () {
5287
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
5288
- var _this$products3,
5289
- _this13 = this;
5037
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order) {
5038
+ var _this$products,
5039
+ _this12 = this;
5290
5040
  var products, productIdSet, productIds, entries;
5291
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5292
- while (1) switch (_context56.prev = _context56.next) {
5041
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5042
+ while (1) switch (_context54.prev = _context54.next) {
5293
5043
  case 0:
5294
5044
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
5295
5045
  productIdSet = new Set();
@@ -5310,46 +5060,46 @@ var Server = /*#__PURE__*/function () {
5310
5060
  }
5311
5061
  });
5312
5062
  productIds = Array.from(productIdSet);
5313
- if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
5314
- _context56.next = 6;
5063
+ if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
5064
+ _context54.next = 6;
5315
5065
  break;
5316
5066
  }
5317
- return _context56.abrupt("return", {});
5067
+ return _context54.abrupt("return", {});
5318
5068
  case 6:
5319
- _context56.next = 8;
5069
+ _context54.next = 8;
5320
5070
  return Promise.all(productIds.map( /*#__PURE__*/function () {
5321
- var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(id) {
5322
- var _this13$products, _this13$products$getP, product;
5323
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5324
- while (1) switch (_context55.prev = _context55.next) {
5071
+ var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(id) {
5072
+ var _this12$products, _this12$products$getP, product;
5073
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5074
+ while (1) switch (_context53.prev = _context53.next) {
5325
5075
  case 0:
5326
- _context55.prev = 0;
5327
- _context55.next = 3;
5328
- return (_this13$products = _this13.products) === null || _this13$products === void 0 || (_this13$products$getP = _this13$products.getProductById) === null || _this13$products$getP === void 0 ? void 0 : _this13$products$getP.call(_this13$products, Number(id));
5076
+ _context53.prev = 0;
5077
+ _context53.next = 3;
5078
+ return (_this12$products = _this12.products) === null || _this12$products === void 0 || (_this12$products$getP = _this12$products.getProductById) === null || _this12$products$getP === void 0 ? void 0 : _this12$products$getP.call(_this12$products, Number(id));
5329
5079
  case 3:
5330
- product = _context55.sent;
5331
- return _context55.abrupt("return", product ? [String(id), product] : null);
5080
+ product = _context53.sent;
5081
+ return _context53.abrupt("return", product ? [String(id), product] : null);
5332
5082
  case 7:
5333
- _context55.prev = 7;
5334
- _context55.t0 = _context55["catch"](0);
5335
- _this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
5083
+ _context53.prev = 7;
5084
+ _context53.t0 = _context53["catch"](0);
5085
+ _this12.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
5336
5086
  product_id: id,
5337
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5087
+ error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
5338
5088
  });
5339
- return _context55.abrupt("return", null);
5089
+ return _context53.abrupt("return", null);
5340
5090
  case 11:
5341
5091
  case "end":
5342
- return _context55.stop();
5092
+ return _context53.stop();
5343
5093
  }
5344
- }, _callee55, null, [[0, 7]]);
5094
+ }, _callee53, null, [[0, 7]]);
5345
5095
  }));
5346
- return function (_x63) {
5096
+ return function (_x60) {
5347
5097
  return _ref60.apply(this, arguments);
5348
5098
  };
5349
5099
  }()));
5350
5100
  case 8:
5351
- entries = _context56.sent;
5352
- return _context56.abrupt("return", entries.reduce(function (map, entry) {
5101
+ entries = _context54.sent;
5102
+ return _context54.abrupt("return", entries.reduce(function (map, entry) {
5353
5103
  if (!entry) return map;
5354
5104
  var _entry = _slicedToArray(entry, 2),
5355
5105
  id = _entry[0],
@@ -5359,11 +5109,11 @@ var Server = /*#__PURE__*/function () {
5359
5109
  }, {}));
5360
5110
  case 10:
5361
5111
  case "end":
5362
- return _context56.stop();
5112
+ return _context54.stop();
5363
5113
  }
5364
- }, _callee56, this);
5114
+ }, _callee54, this);
5365
5115
  }));
5366
- function buildSmallTicketProductMap(_x62) {
5116
+ function buildSmallTicketProductMap(_x59) {
5367
5117
  return _buildSmallTicketProductMap.apply(this, arguments);
5368
5118
  }
5369
5119
  return buildSmallTicketProductMap;
@@ -5393,40 +5143,40 @@ var Server = /*#__PURE__*/function () {
5393
5143
  }, {
5394
5144
  key: "buildSalesDetailProductSnapshotMap",
5395
5145
  value: function () {
5396
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
5397
- var _this$products4;
5146
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
5147
+ var _this$products2;
5398
5148
  var productIds, getSnapshots;
5399
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5400
- while (1) switch (_context57.prev = _context57.next) {
5149
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5150
+ while (1) switch (_context55.prev = _context55.next) {
5401
5151
  case 0:
5402
5152
  productIds = this.collectSalesDetailProductIds(order);
5403
- getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
5153
+ getSnapshots = (_this$products2 = this.products) === null || _this$products2 === void 0 ? void 0 : _this$products2.getProductSnapshotsByIds;
5404
5154
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
5405
- _context57.next = 4;
5155
+ _context55.next = 4;
5406
5156
  break;
5407
5157
  }
5408
- return _context57.abrupt("return", {});
5158
+ return _context55.abrupt("return", {});
5409
5159
  case 4:
5410
- _context57.prev = 4;
5411
- _context57.next = 7;
5160
+ _context55.prev = 4;
5161
+ _context55.next = 7;
5412
5162
  return getSnapshots.call(this.products, productIds);
5413
5163
  case 7:
5414
- return _context57.abrupt("return", _context57.sent);
5164
+ return _context55.abrupt("return", _context55.sent);
5415
5165
  case 10:
5416
- _context57.prev = 10;
5417
- _context57.t0 = _context57["catch"](4);
5166
+ _context55.prev = 10;
5167
+ _context55.t0 = _context55["catch"](4);
5418
5168
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
5419
5169
  product_ids: productIds,
5420
- error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5170
+ error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5421
5171
  });
5422
- return _context57.abrupt("return", {});
5172
+ return _context55.abrupt("return", {});
5423
5173
  case 14:
5424
5174
  case "end":
5425
- return _context57.stop();
5175
+ return _context55.stop();
5426
5176
  }
5427
- }, _callee57, this, [[4, 10]]);
5177
+ }, _callee55, this, [[4, 10]]);
5428
5178
  }));
5429
- function buildSalesDetailProductSnapshotMap(_x64) {
5179
+ function buildSalesDetailProductSnapshotMap(_x61) {
5430
5180
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
5431
5181
  }
5432
5182
  return buildSalesDetailProductSnapshotMap;
@@ -5482,53 +5232,53 @@ var Server = /*#__PURE__*/function () {
5482
5232
  }, {
5483
5233
  key: "withSalesDetailProductSnapshots",
5484
5234
  value: function () {
5485
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order) {
5486
- var _this14 = this;
5235
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
5236
+ var _this13 = this;
5487
5237
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
5488
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5489
- while (1) switch (_context58.prev = _context58.next) {
5238
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5239
+ while (1) switch (_context56.prev = _context56.next) {
5490
5240
  case 0:
5491
5241
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
5492
5242
  if (products !== null && products !== void 0 && products.length) {
5493
- _context58.next = 3;
5243
+ _context56.next = 3;
5494
5244
  break;
5495
5245
  }
5496
- return _context58.abrupt("return", order);
5246
+ return _context56.abrupt("return", order);
5497
5247
  case 3:
5498
- _context58.next = 5;
5248
+ _context56.next = 5;
5499
5249
  return this.buildSalesDetailProductSnapshotMap(order);
5500
5250
  case 5:
5501
- snapshotMap = _context58.sent;
5251
+ snapshotMap = _context56.sent;
5502
5252
  if (Object.keys(snapshotMap).length) {
5503
- _context58.next = 8;
5253
+ _context56.next = 8;
5504
5254
  break;
5505
5255
  }
5506
- return _context58.abrupt("return", order);
5256
+ return _context56.abrupt("return", order);
5507
5257
  case 8:
5508
5258
  hasChanged = false;
5509
5259
  enrichedProducts = products.map(function (product) {
5510
- var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
5511
- var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
5260
+ var productWithBundleSnapshots = _this13.withBundleCatalogSnapshots(product, snapshotMap);
5261
+ var nextProduct = _this13.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
5512
5262
  if (nextProduct !== product) hasChanged = true;
5513
5263
  return nextProduct;
5514
5264
  });
5515
5265
  if (hasChanged) {
5516
- _context58.next = 12;
5266
+ _context56.next = 12;
5517
5267
  break;
5518
5268
  }
5519
- return _context58.abrupt("return", order);
5269
+ return _context56.abrupt("return", order);
5520
5270
  case 12:
5521
5271
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
5522
5272
  products: enrichedProducts
5523
5273
  });
5524
- return _context58.abrupt("return", enrichedOrder);
5274
+ return _context56.abrupt("return", enrichedOrder);
5525
5275
  case 14:
5526
5276
  case "end":
5527
- return _context58.stop();
5277
+ return _context56.stop();
5528
5278
  }
5529
- }, _callee58, this);
5279
+ }, _callee56, this);
5530
5280
  }));
5531
- function withSalesDetailProductSnapshots(_x65) {
5281
+ function withSalesDetailProductSnapshots(_x62) {
5532
5282
  return _withSalesDetailProductSnapshots.apply(this, arguments);
5533
5283
  }
5534
5284
  return withSalesDetailProductSnapshots;
@@ -5536,13 +5286,13 @@ var Server = /*#__PURE__*/function () {
5536
5286
  }, {
5537
5287
  key: "withPendingSyncProductTitles",
5538
5288
  value: function withPendingSyncProductTitles(order, productMap) {
5539
- var _this15 = this;
5289
+ var _this14 = this;
5540
5290
  var products = Array.isArray(order.products) ? order.products : null;
5541
5291
  if (!(products !== null && products !== void 0 && products.length)) return order;
5542
5292
  return _objectSpread(_objectSpread({}, order), {}, {
5543
5293
  products: products.map(function (product) {
5544
5294
  return _objectSpread(_objectSpread({}, product), {}, {
5545
- product_title: _this15.buildProductTitleSnapshot(product, productMap)
5295
+ product_title: _this14.buildProductTitleSnapshot(product, productMap)
5546
5296
  });
5547
5297
  })
5548
5298
  });
@@ -5553,7 +5303,7 @@ var Server = /*#__PURE__*/function () {
5553
5303
  var _product$product_id4,
5554
5304
  _product$product,
5555
5305
  _fallbackProduct$prod,
5556
- _this16 = this;
5306
+ _this15 = this;
5557
5307
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
5558
5308
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
5559
5309
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -5561,7 +5311,7 @@ var Server = /*#__PURE__*/function () {
5561
5311
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
5562
5312
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
5563
5313
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
5564
- snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
5314
+ snapshot[key] = _this15.resolveProductTitleValue(ownTitle, key, currentLocale) || _this15.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
5565
5315
  return snapshot;
5566
5316
  }, {});
5567
5317
  }
@@ -5659,50 +5409,50 @@ var Server = /*#__PURE__*/function () {
5659
5409
  }, {
5660
5410
  key: "enrichPaymentNamesByCode",
5661
5411
  value: function () {
5662
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(order) {
5663
- var _this17 = this;
5664
- var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
5665
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5666
- while (1) switch (_context59.prev = _context59.next) {
5412
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
5413
+ var _this16 = this;
5414
+ var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
5415
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5416
+ while (1) switch (_context57.prev = _context57.next) {
5667
5417
  case 0:
5668
5418
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
5669
5419
  hasMissingName = payments.some(function (payment) {
5670
- return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
5420
+ return _this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
5671
5421
  });
5672
5422
  if (hasMissingName) {
5673
- _context59.next = 4;
5423
+ _context57.next = 4;
5674
5424
  break;
5675
5425
  }
5676
- return _context59.abrupt("return", order);
5426
+ return _context57.abrupt("return", order);
5677
5427
  case 4:
5678
- _context59.prev = 4;
5679
- _context59.next = 7;
5428
+ _context57.prev = 4;
5429
+ _context57.next = 7;
5680
5430
  return this.getPaymentRouteModule();
5681
5431
  case 7:
5682
- paymentModule = _context59.sent;
5683
- _context59.next = 10;
5432
+ paymentModule = _context57.sent;
5433
+ _context57.next = 10;
5684
5434
  return paymentModule.getPayMethodListAsync();
5685
5435
  case 10:
5686
- payMethods = _context59.sent;
5436
+ payMethods = _context57.sent;
5687
5437
  nameByCode = new Map();
5688
- _iterator13 = _createForOfIteratorHelper(payMethods || []);
5438
+ _iterator12 = _createForOfIteratorHelper(payMethods || []);
5689
5439
  try {
5690
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
5691
- method = _step13.value;
5440
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
5441
+ method = _step12.value;
5692
5442
  codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
5693
5443
  name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
5694
5444
  if (codeKey && name) nameByCode.set(codeKey, name);
5695
5445
  }
5696
5446
  } catch (err) {
5697
- _iterator13.e(err);
5447
+ _iterator12.e(err);
5698
5448
  } finally {
5699
- _iterator13.f();
5449
+ _iterator12.f();
5700
5450
  }
5701
5451
  hasResolvedName = false;
5702
5452
  enrichedPayments = payments.map(function (payment) {
5703
- if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
5704
- if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
5705
- var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
5453
+ if (!_this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
5454
+ if (!_this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
5455
+ var name = nameByCode.get(_this16.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
5706
5456
  if (!name) return payment;
5707
5457
  hasResolvedName = true;
5708
5458
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -5710,28 +5460,28 @@ var Server = /*#__PURE__*/function () {
5710
5460
  });
5711
5461
  });
5712
5462
  if (hasResolvedName) {
5713
- _context59.next = 18;
5463
+ _context57.next = 18;
5714
5464
  break;
5715
5465
  }
5716
- return _context59.abrupt("return", order);
5466
+ return _context57.abrupt("return", order);
5717
5467
  case 18:
5718
- return _context59.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
5468
+ return _context57.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
5719
5469
  payments: enrichedPayments
5720
5470
  }));
5721
5471
  case 21:
5722
- _context59.prev = 21;
5723
- _context59.t0 = _context59["catch"](4);
5472
+ _context57.prev = 21;
5473
+ _context57.t0 = _context57["catch"](4);
5724
5474
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
5725
- error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
5475
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5726
5476
  });
5727
- return _context59.abrupt("return", order);
5477
+ return _context57.abrupt("return", order);
5728
5478
  case 25:
5729
5479
  case "end":
5730
- return _context59.stop();
5480
+ return _context57.stop();
5731
5481
  }
5732
- }, _callee59, this, [[4, 21]]);
5482
+ }, _callee57, this, [[4, 21]]);
5733
5483
  }));
5734
- function enrichPaymentNamesByCode(_x66) {
5484
+ function enrichPaymentNamesByCode(_x63) {
5735
5485
  return _enrichPaymentNamesByCode.apply(this, arguments);
5736
5486
  }
5737
5487
  return enrichPaymentNamesByCode;
@@ -5739,66 +5489,66 @@ var Server = /*#__PURE__*/function () {
5739
5489
  }, {
5740
5490
  key: "withLocalSmallTicketData",
5741
5491
  value: function () {
5742
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order, options) {
5492
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order, options) {
5743
5493
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
5744
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5745
- while (1) switch (_context60.prev = _context60.next) {
5494
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5495
+ while (1) switch (_context58.prev = _context58.next) {
5746
5496
  case 0:
5747
5497
  if (this.shouldBuildSmallTicketData(order)) {
5748
- _context60.next = 2;
5498
+ _context58.next = 2;
5749
5499
  break;
5750
5500
  }
5751
- return _context60.abrupt("return", order);
5501
+ return _context58.abrupt("return", order);
5752
5502
  case 2:
5753
5503
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
5754
- _context60.next = 4;
5504
+ _context58.next = 4;
5755
5505
  break;
5756
5506
  }
5757
- return _context60.abrupt("return", order);
5507
+ return _context58.abrupt("return", order);
5758
5508
  case 4:
5759
- _context60.prev = 4;
5760
- _context60.next = 7;
5509
+ _context58.prev = 4;
5510
+ _context58.next = 7;
5761
5511
  return this.enrichPaymentNamesByCode(order);
5762
5512
  case 7:
5763
- enrichedOrder = _context60.sent;
5513
+ enrichedOrder = _context58.sent;
5764
5514
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
5765
- _context60.next = 12;
5515
+ _context58.next = 12;
5766
5516
  break;
5767
5517
  }
5768
- _context60.t0 = _options$productMap;
5769
- _context60.next = 15;
5518
+ _context58.t0 = _options$productMap;
5519
+ _context58.next = 15;
5770
5520
  break;
5771
5521
  case 12:
5772
- _context60.next = 14;
5522
+ _context58.next = 14;
5773
5523
  return this.buildSmallTicketProductMap(enrichedOrder);
5774
5524
  case 14:
5775
- _context60.t0 = _context60.sent;
5525
+ _context58.t0 = _context58.sent;
5776
5526
  case 15:
5777
- productMap = _context60.t0;
5527
+ productMap = _context58.t0;
5778
5528
  smallTicketData = buildSmallTicketData({
5779
5529
  order: enrichedOrder,
5780
5530
  shopInfo: this.getSmallTicketShopInfo(),
5781
5531
  productMap: productMap
5782
5532
  });
5783
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
5533
+ return _context58.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
5784
5534
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
5785
5535
  small_ticket_data: smallTicketData
5786
5536
  })
5787
5537
  }));
5788
5538
  case 20:
5789
- _context60.prev = 20;
5790
- _context60.t1 = _context60["catch"](4);
5539
+ _context58.prev = 20;
5540
+ _context58.t1 = _context58["catch"](4);
5791
5541
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
5792
- error: _context60.t1 instanceof Error ? _context60.t1.message : String(_context60.t1)
5542
+ error: _context58.t1 instanceof Error ? _context58.t1.message : String(_context58.t1)
5793
5543
  });
5794
- return _context60.abrupt("return", order);
5544
+ return _context58.abrupt("return", order);
5795
5545
  case 24:
5796
5546
  case "end":
5797
- return _context60.stop();
5547
+ return _context58.stop();
5798
5548
  }
5799
- }, _callee60, this, [[4, 20]]);
5549
+ }, _callee58, this, [[4, 20]]);
5800
5550
  }));
5801
- function withLocalSmallTicketData(_x67, _x68) {
5551
+ function withLocalSmallTicketData(_x64, _x65) {
5802
5552
  return _withLocalSmallTicketData.apply(this, arguments);
5803
5553
  }
5804
5554
  return withLocalSmallTicketData;
@@ -5860,22 +5610,22 @@ var Server = /*#__PURE__*/function () {
5860
5610
  }, {
5861
5611
  key: "handleUpdateLocalOrdersBatch",
5862
5612
  value: (function () {
5863
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(orderIds) {
5613
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(orderIds) {
5864
5614
  var _this$app17;
5865
- var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
5866
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5867
- while (1) switch (_context61.prev = _context61.next) {
5615
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
5616
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5617
+ while (1) switch (_context59.prev = _context59.next) {
5868
5618
  case 0:
5869
5619
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
5870
5620
  count: orderIds.length,
5871
5621
  orderIds: orderIds
5872
5622
  });
5873
5623
  if (this.order) {
5874
- _context61.next = 4;
5624
+ _context59.next = 4;
5875
5625
  break;
5876
5626
  }
5877
5627
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
5878
- return _context61.abrupt("return", {
5628
+ return _context59.abrupt("return", {
5879
5629
  code: 500,
5880
5630
  status: false,
5881
5631
  message: 'Order 模块未注册',
@@ -5883,11 +5633,11 @@ var Server = /*#__PURE__*/function () {
5883
5633
  });
5884
5634
  case 4:
5885
5635
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
5886
- _context61.next = 7;
5636
+ _context59.next = 7;
5887
5637
  break;
5888
5638
  }
5889
5639
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
5890
- return _context61.abrupt("return", {
5640
+ return _context59.abrupt("return", {
5891
5641
  code: 500,
5892
5642
  status: false,
5893
5643
  message: 'app.request 不可用',
@@ -5896,35 +5646,35 @@ var Server = /*#__PURE__*/function () {
5896
5646
  case 7:
5897
5647
  // 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
5898
5648
  existedBefore = new Map();
5899
- _iterator14 = _createForOfIteratorHelper(orderIds);
5649
+ _iterator13 = _createForOfIteratorHelper(orderIds);
5900
5650
  try {
5901
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
5902
- id = _step14.value;
5651
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
5652
+ id = _step13.value;
5903
5653
  existedBefore.set(id, !!this.order.getOrderByOrderId(id));
5904
5654
  }
5905
5655
 
5906
5656
  // 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
5907
5657
  } catch (err) {
5908
- _iterator14.e(err);
5658
+ _iterator13.e(err);
5909
5659
  } finally {
5910
- _iterator14.f();
5660
+ _iterator13.f();
5911
5661
  }
5912
5662
  fetched = [];
5913
- _context61.prev = 11;
5914
- _context61.next = 14;
5663
+ _context59.prev = 11;
5664
+ _context59.next = 14;
5915
5665
  return this.order.fetchOrdersByHttp(orderIds);
5916
5666
  case 14:
5917
- fetched = _context61.sent;
5918
- _context61.next = 22;
5667
+ fetched = _context59.sent;
5668
+ _context59.next = 22;
5919
5669
  break;
5920
5670
  case 17:
5921
- _context61.prev = 17;
5922
- _context61.t0 = _context61["catch"](11);
5923
- message = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
5671
+ _context59.prev = 17;
5672
+ _context59.t0 = _context59["catch"](11);
5673
+ message = _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0);
5924
5674
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
5925
5675
  message: message
5926
5676
  });
5927
- return _context61.abrupt("return", {
5677
+ return _context59.abrupt("return", {
5928
5678
  code: 500,
5929
5679
  status: false,
5930
5680
  message: message,
@@ -5933,45 +5683,45 @@ var Server = /*#__PURE__*/function () {
5933
5683
  case 22:
5934
5684
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
5935
5685
  fetchedMap = new Map();
5936
- _iterator15 = _createForOfIteratorHelper(fetched);
5937
- _context61.prev = 24;
5938
- _iterator15.s();
5686
+ _iterator14 = _createForOfIteratorHelper(fetched);
5687
+ _context59.prev = 24;
5688
+ _iterator14.s();
5939
5689
  case 26:
5940
- if ((_step15 = _iterator15.n()).done) {
5941
- _context61.next = 34;
5690
+ if ((_step14 = _iterator14.n()).done) {
5691
+ _context59.next = 34;
5942
5692
  break;
5943
5693
  }
5944
- order = _step15.value;
5694
+ order = _step14.value;
5945
5695
  oid = order === null || order === void 0 ? void 0 : order.order_id;
5946
5696
  if (!(oid === undefined || oid === null)) {
5947
- _context61.next = 31;
5697
+ _context59.next = 31;
5948
5698
  break;
5949
5699
  }
5950
- return _context61.abrupt("continue", 32);
5700
+ return _context59.abrupt("continue", 32);
5951
5701
  case 31:
5952
5702
  fetchedMap.set(String(oid), order);
5953
5703
  case 32:
5954
- _context61.next = 26;
5704
+ _context59.next = 26;
5955
5705
  break;
5956
5706
  case 34:
5957
- _context61.next = 39;
5707
+ _context59.next = 39;
5958
5708
  break;
5959
5709
  case 36:
5960
- _context61.prev = 36;
5961
- _context61.t1 = _context61["catch"](24);
5962
- _iterator15.e(_context61.t1);
5710
+ _context59.prev = 36;
5711
+ _context59.t1 = _context59["catch"](24);
5712
+ _iterator14.e(_context59.t1);
5963
5713
  case 39:
5964
- _context61.prev = 39;
5965
- _iterator15.f();
5966
- return _context61.finish(39);
5714
+ _context59.prev = 39;
5715
+ _iterator14.f();
5716
+ return _context59.finish(39);
5967
5717
  case 42:
5968
5718
  freshOrders = [];
5969
5719
  succeedIds = [];
5970
5720
  failed = [];
5971
- _iterator16 = _createForOfIteratorHelper(orderIds);
5721
+ _iterator15 = _createForOfIteratorHelper(orderIds);
5972
5722
  try {
5973
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5974
- _id = _step16.value;
5723
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
5724
+ _id = _step15.value;
5975
5725
  fresh = fetchedMap.get(_id);
5976
5726
  if (fresh) {
5977
5727
  freshOrders.push(fresh);
@@ -5984,28 +5734,28 @@ var Server = /*#__PURE__*/function () {
5984
5734
  }
5985
5735
  }
5986
5736
  } catch (err) {
5987
- _iterator16.e(err);
5737
+ _iterator15.e(err);
5988
5738
  } finally {
5989
- _iterator16.f();
5739
+ _iterator15.f();
5990
5740
  }
5991
5741
  if (!(freshOrders.length > 0)) {
5992
- _context61.next = 58;
5742
+ _context59.next = 58;
5993
5743
  break;
5994
5744
  }
5995
- _context61.prev = 48;
5996
- _context61.next = 51;
5745
+ _context59.prev = 48;
5746
+ _context59.next = 51;
5997
5747
  return this.order.upsertOrdersFromRemote(freshOrders);
5998
5748
  case 51:
5999
- _context61.next = 58;
5749
+ _context59.next = 58;
6000
5750
  break;
6001
5751
  case 53:
6002
- _context61.prev = 53;
6003
- _context61.t2 = _context61["catch"](48);
6004
- _message2 = _context61.t2 instanceof Error ? _context61.t2.message : String(_context61.t2);
5752
+ _context59.prev = 53;
5753
+ _context59.t2 = _context59["catch"](48);
5754
+ _message2 = _context59.t2 instanceof Error ? _context59.t2.message : String(_context59.t2);
6005
5755
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
6006
5756
  message: _message2
6007
5757
  });
6008
- return _context61.abrupt("return", {
5758
+ return _context59.abrupt("return", {
6009
5759
  code: 500,
6010
5760
  status: false,
6011
5761
  message: _message2,
@@ -6024,7 +5774,7 @@ var Server = /*#__PURE__*/function () {
6024
5774
  insertedCount: inserted.length,
6025
5775
  failedCount: failed.length
6026
5776
  });
6027
- return _context61.abrupt("return", {
5777
+ return _context59.abrupt("return", {
6028
5778
  code: 200,
6029
5779
  status: true,
6030
5780
  message: '',
@@ -6036,11 +5786,11 @@ var Server = /*#__PURE__*/function () {
6036
5786
  });
6037
5787
  case 62:
6038
5788
  case "end":
6039
- return _context61.stop();
5789
+ return _context59.stop();
6040
5790
  }
6041
- }, _callee61, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
5791
+ }, _callee59, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
6042
5792
  }));
6043
- function handleUpdateLocalOrdersBatch(_x69) {
5793
+ function handleUpdateLocalOrdersBatch(_x66) {
6044
5794
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
6045
5795
  }
6046
5796
  return handleUpdateLocalOrdersBatch;
@@ -6061,11 +5811,11 @@ var Server = /*#__PURE__*/function () {
6061
5811
  var queryIndex = url.indexOf('?');
6062
5812
  if (queryIndex < 0) return null;
6063
5813
  var query = url.slice(queryIndex + 1);
6064
- var _iterator17 = _createForOfIteratorHelper(query.split('&')),
6065
- _step17;
5814
+ var _iterator16 = _createForOfIteratorHelper(query.split('&')),
5815
+ _step16;
6066
5816
  try {
6067
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6068
- var pair = _step17.value;
5817
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
5818
+ var pair = _step16.value;
6069
5819
  if (!pair) continue;
6070
5820
  var _pair$split = pair.split('='),
6071
5821
  _pair$split2 = _slicedToArray(_pair$split, 2),
@@ -6081,9 +5831,9 @@ var Server = /*#__PURE__*/function () {
6081
5831
  }
6082
5832
  }
6083
5833
  } catch (err) {
6084
- _iterator17.e(err);
5834
+ _iterator16.e(err);
6085
5835
  } finally {
6086
- _iterator17.f();
5836
+ _iterator16.f();
6087
5837
  }
6088
5838
  return null;
6089
5839
  }
@@ -6282,10 +6032,10 @@ var Server = /*#__PURE__*/function () {
6282
6032
  value: function extractBackendErrorResponse(error) {
6283
6033
  var _error$response3,
6284
6034
  _error$response4,
6285
- _this18 = this;
6035
+ _this17 = this;
6286
6036
  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];
6287
6037
  return candidates.find(function (candidate) {
6288
- return _this18.isExplicitBackendErrorResponse(candidate);
6038
+ return _this17.isExplicitBackendErrorResponse(candidate);
6289
6039
  }) || null;
6290
6040
  }
6291
6041
  }, {
@@ -6404,24 +6154,24 @@ var Server = /*#__PURE__*/function () {
6404
6154
  }, {
6405
6155
  key: "recomputeAndNotifyFloorPlanQuery",
6406
6156
  value: (function () {
6407
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
6408
- var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
6409
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6410
- while (1) switch (_context62.prev = _context62.next) {
6157
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
6158
+ var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
6159
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6160
+ while (1) switch (_context60.prev = _context60.next) {
6411
6161
  case 0:
6412
6162
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
6413
- _context62.next = 2;
6163
+ _context60.next = 2;
6414
6164
  break;
6415
6165
  }
6416
- return _context62.abrupt("return");
6166
+ return _context60.abrupt("return");
6417
6167
  case 2:
6418
6168
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
6419
6169
  subscriberCount: this.floorPlanQuerySubscribers.size
6420
6170
  });
6421
- _iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
6171
+ _iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
6422
6172
  try {
6423
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
6424
- _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
6173
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6174
+ _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
6425
6175
  try {
6426
6176
  result = this.computeFloorPlanQueryResult(sub.context);
6427
6177
  sub.callback(result);
@@ -6437,15 +6187,15 @@ var Server = /*#__PURE__*/function () {
6437
6187
  }
6438
6188
  }
6439
6189
  } catch (err) {
6440
- _iterator18.e(err);
6190
+ _iterator17.e(err);
6441
6191
  } finally {
6442
- _iterator18.f();
6192
+ _iterator17.f();
6443
6193
  }
6444
6194
  case 5:
6445
6195
  case "end":
6446
- return _context62.stop();
6196
+ return _context60.stop();
6447
6197
  }
6448
- }, _callee62, this);
6198
+ }, _callee60, this);
6449
6199
  }));
6450
6200
  function recomputeAndNotifyFloorPlanQuery() {
6451
6201
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -6475,21 +6225,21 @@ var Server = /*#__PURE__*/function () {
6475
6225
  * filter 逻辑暂为 mock,仅记录参数
6476
6226
  */
6477
6227
  function () {
6478
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
6228
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(data) {
6479
6229
  var rawList, result;
6480
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6481
- while (1) switch (_context63.prev = _context63.next) {
6230
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6231
+ while (1) switch (_context61.prev = _context61.next) {
6482
6232
  case 0:
6483
6233
  this.logInfo('computeOrderQueryResult: 开始过滤', {
6484
6234
  data: data
6485
6235
  });
6486
6236
  console.log('[Server] computeOrderQueryResult', data);
6487
6237
  if (this.order) {
6488
- _context63.next = 5;
6238
+ _context61.next = 5;
6489
6239
  break;
6490
6240
  }
6491
6241
  this.logError('computeOrderQueryResult: Order 模块未注册');
6492
- return _context63.abrupt("return", {
6242
+ return _context61.abrupt("return", {
6493
6243
  code: 500,
6494
6244
  message: 'Order 模块未注册',
6495
6245
  data: {
@@ -6513,7 +6263,7 @@ var Server = /*#__PURE__*/function () {
6513
6263
  skip: result.skip,
6514
6264
  rejected: result.rejected
6515
6265
  });
6516
- return _context63.abrupt("return", {
6266
+ return _context61.abrupt("return", {
6517
6267
  code: 200,
6518
6268
  data: result,
6519
6269
  message: '',
@@ -6521,11 +6271,11 @@ var Server = /*#__PURE__*/function () {
6521
6271
  });
6522
6272
  case 10:
6523
6273
  case "end":
6524
- return _context63.stop();
6274
+ return _context61.stop();
6525
6275
  }
6526
- }, _callee63, this);
6276
+ }, _callee61, this);
6527
6277
  }));
6528
- function computeOrderQueryResult(_x70) {
6278
+ function computeOrderQueryResult(_x67) {
6529
6279
  return _computeOrderQueryResult.apply(this, arguments);
6530
6280
  }
6531
6281
  return computeOrderQueryResult;
@@ -6538,17 +6288,17 @@ var Server = /*#__PURE__*/function () {
6538
6288
  }, {
6539
6289
  key: "computeBookingQueryResult",
6540
6290
  value: (function () {
6541
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6291
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
6542
6292
  var rawOrders, result;
6543
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6544
- while (1) switch (_context64.prev = _context64.next) {
6293
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6294
+ while (1) switch (_context62.prev = _context62.next) {
6545
6295
  case 0:
6546
6296
  if (this.order) {
6547
- _context64.next = 3;
6297
+ _context62.next = 3;
6548
6298
  break;
6549
6299
  }
6550
6300
  this.logError('computeBookingQueryResult: Order 模块未注册');
6551
- return _context64.abrupt("return", {
6301
+ return _context62.abrupt("return", {
6552
6302
  code: 500,
6553
6303
  message: 'Order 模块未注册',
6554
6304
  data: {
@@ -6567,7 +6317,7 @@ var Server = /*#__PURE__*/function () {
6567
6317
  size: result.size,
6568
6318
  skip: result.skip
6569
6319
  });
6570
- return _context64.abrupt("return", {
6320
+ return _context62.abrupt("return", {
6571
6321
  code: 200,
6572
6322
  data: result,
6573
6323
  message: '',
@@ -6575,11 +6325,11 @@ var Server = /*#__PURE__*/function () {
6575
6325
  });
6576
6326
  case 8:
6577
6327
  case "end":
6578
- return _context64.stop();
6328
+ return _context62.stop();
6579
6329
  }
6580
- }, _callee64, this);
6330
+ }, _callee62, this);
6581
6331
  }));
6582
- function computeBookingQueryResult(_x71) {
6332
+ function computeBookingQueryResult(_x68) {
6583
6333
  return _computeBookingQueryResult.apply(this, arguments);
6584
6334
  }
6585
6335
  return computeBookingQueryResult;
@@ -6638,26 +6388,20 @@ var Server = /*#__PURE__*/function () {
6638
6388
  }, {
6639
6389
  key: "computeProductQueryResult",
6640
6390
  value: (function () {
6641
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(context, options) {
6391
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(context, options) {
6642
6392
  var _menu_list_ids$length3,
6643
- _this19 = this;
6644
- var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
6645
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6646
- while (1) switch (_context65.prev = _context65.next) {
6393
+ _this18 = this;
6394
+ var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
6395
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6396
+ while (1) switch (_context63.prev = _context63.next) {
6647
6397
  case 0:
6648
6398
  tTotal = performance.now();
6649
- 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;
6399
+ 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;
6650
6400
  queryIds = Array.isArray(ids) ? ids.map(function (id) {
6651
6401
  return Number(id);
6652
6402
  }).filter(function (id) {
6653
6403
  return Number.isFinite(id);
6654
6404
  }) : [];
6655
- formatterContext = this.buildProductFormatterContext({
6656
- schedule_date: schedule_date,
6657
- schedule_datetime: schedule_datetime,
6658
- customer_id: customer_id,
6659
- strategy_context: strategy_context
6660
- });
6661
6405
  this.logInfo('computeProductQueryResult 开始', {
6662
6406
  menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
6663
6407
  ids: queryIds,
@@ -6666,32 +6410,38 @@ var Server = /*#__PURE__*/function () {
6666
6410
  customer_id: customer_id,
6667
6411
  extension_type: extension_type,
6668
6412
  product_id: product_id,
6669
- strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
6670
6413
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6671
6414
  });
6672
6415
  if (this.products) {
6673
- _context65.next = 8;
6416
+ _context63.next = 7;
6674
6417
  break;
6675
6418
  }
6676
6419
  this.logError('computeProductQueryResult: Products 模块未注册');
6677
- return _context65.abrupt("return", {
6420
+ return _context63.abrupt("return", {
6678
6421
  message: 'Products 模块未注册',
6679
- data: this.buildProductQueryResultPayload([], 0)
6422
+ data: {
6423
+ list: [],
6424
+ count: 0
6425
+ }
6680
6426
  });
6681
- case 8:
6427
+ case 7:
6682
6428
  if (!(queryIds.length > 0)) {
6683
- _context65.next = 20;
6429
+ _context63.next = 19;
6684
6430
  break;
6685
6431
  }
6686
6432
  uniqueIds = Array.from(new Set(queryIds));
6687
6433
  _tPrice = performance.now();
6688
- _context65.next = 13;
6689
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6434
+ _context63.next = 12;
6435
+ return this.products.getProductsWithPrice(schedule_date, {
6436
+ scheduleModule: this.getSchedule(),
6437
+ schedule_datetime: schedule_datetime,
6438
+ customer_id: customer_id
6439
+ }, {
6690
6440
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
6691
6441
  productIds: uniqueIds
6692
6442
  });
6693
- case 13:
6694
- productsWithPrice = _context65.sent;
6443
+ case 12:
6444
+ productsWithPrice = _context63.sent;
6695
6445
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
6696
6446
  count: productsWithPrice.length,
6697
6447
  ids: uniqueIds
@@ -6711,25 +6461,30 @@ var Server = /*#__PURE__*/function () {
6711
6461
  ids: uniqueIds,
6712
6462
  count: extensionFilteredProducts.length
6713
6463
  });
6714
- return _context65.abrupt("return", {
6464
+ return _context63.abrupt("return", {
6715
6465
  code: 200,
6716
- data: this.buildProductQueryResultPayload(extensionFilteredProducts),
6466
+ data: {
6467
+ list: extensionFilteredProducts,
6468
+ count: extensionFilteredProducts.length
6469
+ },
6717
6470
  message: '',
6718
6471
  status: true
6719
6472
  });
6720
- case 20:
6473
+ case 19:
6721
6474
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
6722
- _context65.next = 32;
6475
+ _context63.next = 31;
6723
6476
  break;
6724
6477
  }
6725
6478
  pid = Number(product_id);
6726
6479
  _tPrice2 = performance.now();
6727
- _context65.next = 25;
6728
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6480
+ _context63.next = 24;
6481
+ return this.products.getProductsWithPrice(schedule_date, {
6482
+ scheduleModule: this.getSchedule()
6483
+ }, {
6729
6484
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6730
6485
  });
6731
- case 25:
6732
- allProductsWithPrice = _context65.sent;
6486
+ case 24:
6487
+ allProductsWithPrice = _context63.sent;
6733
6488
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
6734
6489
  count: allProductsWithPrice.length,
6735
6490
  productId: pid
@@ -6749,24 +6504,28 @@ var Server = /*#__PURE__*/function () {
6749
6504
  productId: pid,
6750
6505
  found: !!item
6751
6506
  });
6752
- return _context65.abrupt("return", {
6507
+ return _context63.abrupt("return", {
6753
6508
  code: 200,
6754
6509
  data: item,
6755
6510
  message: item ? '' : '商品不存在或未发布',
6756
6511
  status: true
6757
6512
  });
6758
- case 32:
6513
+ case 31:
6759
6514
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
6760
- _context65.next = 52;
6515
+ _context63.next = 51;
6761
6516
  break;
6762
6517
  }
6763
6518
  _tPrice3 = performance.now();
6764
- _context65.next = 36;
6765
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6519
+ _context63.next = 35;
6520
+ return this.products.getProductsWithPrice(schedule_date, {
6521
+ scheduleModule: this.getSchedule(),
6522
+ schedule_datetime: schedule_datetime,
6523
+ customer_id: customer_id
6524
+ }, {
6766
6525
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6767
6526
  });
6768
- case 36:
6769
- _filteredProducts2 = _context65.sent;
6527
+ case 35:
6528
+ _filteredProducts2 = _context63.sent;
6770
6529
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
6771
6530
  count: _filteredProducts2.length,
6772
6531
  extension_type: extension_type
@@ -6805,40 +6564,49 @@ var Server = /*#__PURE__*/function () {
6805
6564
  filteredCount: _filteredProducts2.length,
6806
6565
  extension_type: extension_type
6807
6566
  });
6808
- return _context65.abrupt("return", {
6567
+ return _context63.abrupt("return", {
6809
6568
  code: 200,
6810
- data: this.buildProductQueryResultPayload(_filteredProducts2),
6569
+ data: {
6570
+ list: _filteredProducts2,
6571
+ count: _filteredProducts2.length
6572
+ },
6811
6573
  message: '',
6812
6574
  status: true
6813
6575
  });
6814
- case 52:
6576
+ case 51:
6815
6577
  if (this.menu) {
6816
- _context65.next = 55;
6578
+ _context63.next = 54;
6817
6579
  break;
6818
6580
  }
6819
6581
  this.logError('computeProductQueryResult: Menu 模块未注册');
6820
- return _context65.abrupt("return", {
6582
+ return _context63.abrupt("return", {
6821
6583
  message: 'Menu 模块未注册',
6822
- data: this.buildProductQueryResultPayload([], 0)
6584
+ data: {
6585
+ list: [],
6586
+ count: 0
6587
+ }
6823
6588
  });
6824
- case 55:
6589
+ case 54:
6825
6590
  if (this.schedule) {
6826
- _context65.next = 58;
6591
+ _context63.next = 57;
6827
6592
  break;
6828
6593
  }
6829
6594
  this.logError('computeProductQueryResult: Schedule 模块未注册');
6830
- return _context65.abrupt("return", {
6595
+ return _context63.abrupt("return", {
6831
6596
  message: 'Schedule 模块未注册',
6832
- data: this.buildProductQueryResultPayload([], 0)
6597
+ data: {
6598
+ list: [],
6599
+ count: 0
6600
+ }
6833
6601
  });
6834
- case 58:
6602
+ case 57:
6835
6603
  activeMenuList = [];
6836
6604
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
6837
6605
  tMenu = performance.now();
6838
6606
  menuList = this.menu.getMenuByIds(menu_list_ids);
6839
6607
  activeMenuList = menuList.filter(function (menu) {
6840
- var _this19$schedule;
6841
- return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6608
+ var _this18$schedule;
6609
+ return ((_this18$schedule = _this18.schedule) === null || _this18$schedule === void 0 ? void 0 : _this18$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
6842
6610
  });
6843
6611
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
6844
6612
  totalMenu: menuList.length,
@@ -6855,22 +6623,26 @@ var Server = /*#__PURE__*/function () {
6855
6623
  });
6856
6624
  tPrice = performance.now();
6857
6625
  if (!(scopedProductIds.length > 0)) {
6858
- _context65.next = 71;
6626
+ _context63.next = 70;
6859
6627
  break;
6860
6628
  }
6861
- _context65.next = 68;
6862
- return this.products.getProductsWithPrice(schedule_date, formatterContext, {
6629
+ _context63.next = 67;
6630
+ return this.products.getProductsWithPrice(schedule_date, {
6631
+ scheduleModule: this.getSchedule(),
6632
+ schedule_datetime: schedule_datetime,
6633
+ customer_id: customer_id
6634
+ }, {
6863
6635
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
6864
6636
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
6865
6637
  });
6866
- case 68:
6867
- _context65.t0 = _context65.sent;
6868
- _context65.next = 72;
6638
+ case 67:
6639
+ _context63.t0 = _context63.sent;
6640
+ _context63.next = 71;
6869
6641
  break;
6642
+ case 70:
6643
+ _context63.t0 = [];
6870
6644
  case 71:
6871
- _context65.t0 = [];
6872
- case 72:
6873
- filteredProducts = _context65.t0;
6645
+ filteredProducts = _context63.t0;
6874
6646
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
6875
6647
  count: filteredProducts.length,
6876
6648
  scopedProductCount: scopedProductIds.length
@@ -6911,120 +6683,102 @@ var Server = /*#__PURE__*/function () {
6911
6683
  filteredCount: filteredProducts.length,
6912
6684
  activeMenuCount: activeMenuList.length
6913
6685
  });
6914
- return _context65.abrupt("return", {
6686
+ return _context63.abrupt("return", {
6915
6687
  code: 200,
6916
- data: this.buildProductQueryResultPayload(filteredProducts),
6688
+ data: {
6689
+ list: filteredProducts,
6690
+ count: filteredProducts.length
6691
+ },
6917
6692
  message: '',
6918
6693
  status: true
6919
6694
  });
6920
- case 88:
6695
+ case 87:
6921
6696
  case "end":
6922
- return _context65.stop();
6697
+ return _context63.stop();
6923
6698
  }
6924
- }, _callee65, this);
6699
+ }, _callee63, this);
6925
6700
  }));
6926
- function computeProductQueryResult(_x72, _x73) {
6701
+ function computeProductQueryResult(_x69, _x70) {
6927
6702
  return _computeProductQueryResult.apply(this, arguments);
6928
6703
  }
6929
6704
  return computeProductQueryResult;
6930
6705
  }()
6931
- /**
6932
- * 构建商品格式化上下文。
6933
- *
6934
- * 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
6935
- */
6936
- )
6937
- }, {
6938
- key: "buildProductFormatterContext",
6939
- value: function buildProductFormatterContext(context) {
6940
- var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context4;
6941
- var scheduleModule = this.getSchedule();
6942
- return {
6943
- scheduleModule: scheduleModule,
6944
- schedule_datetime: context.schedule_datetime,
6945
- customer_id: context.customer_id,
6946
- strategy_context: context.strategy_context,
6947
- menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
6948
- scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
6949
- dataVariantEvaluator: (_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.dataVariantEvaluator
6950
- };
6951
- }
6952
-
6953
6706
  /**
6954
6707
  * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
6955
6708
  * 由 ProductsModule 的 onProductsSyncCompleted 事件触发
6956
6709
  * @param options 可选参数
6957
6710
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
6958
6711
  */
6712
+ )
6959
6713
  }, {
6960
6714
  key: "recomputeAndNotifyProductQuery",
6961
6715
  value: (function () {
6962
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(options) {
6963
- var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
6964
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6965
- while (1) switch (_context66.prev = _context66.next) {
6716
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(options) {
6717
+ var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
6718
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6719
+ while (1) switch (_context64.prev = _context64.next) {
6966
6720
  case 0:
6967
6721
  if (!(this.productQuerySubscribers.size === 0)) {
6968
- _context66.next = 2;
6722
+ _context64.next = 2;
6969
6723
  break;
6970
6724
  }
6971
- return _context66.abrupt("return");
6725
+ return _context64.abrupt("return");
6972
6726
  case 2:
6973
6727
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
6974
6728
  subscriberCount: this.productQuerySubscribers.size,
6975
6729
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6976
6730
  });
6977
- _iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6978
- _context66.prev = 4;
6979
- _iterator19.s();
6731
+ _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
6732
+ _context64.prev = 4;
6733
+ _iterator18.s();
6980
6734
  case 6:
6981
- if ((_step19 = _iterator19.n()).done) {
6982
- _context66.next = 22;
6735
+ if ((_step18 = _iterator18.n()).done) {
6736
+ _context64.next = 22;
6983
6737
  break;
6984
6738
  }
6985
- _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
6986
- _context66.prev = 8;
6987
- _context66.next = 11;
6739
+ _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
6740
+ _context64.prev = 8;
6741
+ _context64.next = 11;
6988
6742
  return this.computeProductQueryResult(subscriber.context, {
6989
6743
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
6990
6744
  });
6991
6745
  case 11:
6992
- result = _context66.sent;
6746
+ result = _context64.sent;
6993
6747
  subscriber.callback(result);
6994
6748
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
6995
6749
  subscriberId: subscriberId
6996
6750
  });
6997
- _context66.next = 20;
6751
+ _context64.next = 20;
6998
6752
  break;
6999
6753
  case 16:
7000
- _context66.prev = 16;
7001
- _context66.t0 = _context66["catch"](8);
7002
- errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
6754
+ _context64.prev = 16;
6755
+ _context64.t0 = _context64["catch"](8);
6756
+ errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
7003
6757
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
7004
6758
  subscriberId: subscriberId,
7005
6759
  error: errorMessage
7006
6760
  });
7007
6761
  case 20:
7008
- _context66.next = 6;
6762
+ _context64.next = 6;
7009
6763
  break;
7010
6764
  case 22:
7011
- _context66.next = 27;
6765
+ _context64.next = 27;
7012
6766
  break;
7013
6767
  case 24:
7014
- _context66.prev = 24;
7015
- _context66.t1 = _context66["catch"](4);
7016
- _iterator19.e(_context66.t1);
6768
+ _context64.prev = 24;
6769
+ _context64.t1 = _context64["catch"](4);
6770
+ _iterator18.e(_context64.t1);
7017
6771
  case 27:
7018
- _context66.prev = 27;
7019
- _iterator19.f();
7020
- return _context66.finish(27);
6772
+ _context64.prev = 27;
6773
+ _iterator18.f();
6774
+ return _context64.finish(27);
7021
6775
  case 30:
7022
6776
  case "end":
7023
- return _context66.stop();
6777
+ return _context64.stop();
7024
6778
  }
7025
- }, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
6779
+ }, _callee64, this, [[4, 24, 27, 30], [8, 16]]);
7026
6780
  }));
7027
- function recomputeAndNotifyProductQuery(_x74) {
6781
+ function recomputeAndNotifyProductQuery(_x71) {
7028
6782
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
7029
6783
  }
7030
6784
  return recomputeAndNotifyProductQuery;
@@ -7036,37 +6790,37 @@ var Server = /*#__PURE__*/function () {
7036
6790
  }, {
7037
6791
  key: "recomputeAndNotifyOrderQuery",
7038
6792
  value: (function () {
7039
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
7040
- var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
7041
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
7042
- while (1) switch (_context67.prev = _context67.next) {
6793
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
6794
+ var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
6795
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6796
+ while (1) switch (_context65.prev = _context65.next) {
7043
6797
  case 0:
7044
6798
  if (!(this.orderQuerySubscribers.size === 0)) {
7045
- _context67.next = 2;
6799
+ _context65.next = 2;
7046
6800
  break;
7047
6801
  }
7048
- return _context67.abrupt("return");
6802
+ return _context65.abrupt("return");
7049
6803
  case 2:
7050
6804
  notifyStartAt = Date.now();
7051
6805
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
7052
6806
  subscriberCount: this.orderQuerySubscribers.size,
7053
6807
  notifyStartAt: new Date(notifyStartAt).toISOString()
7054
6808
  });
7055
- _iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
7056
- _context67.prev = 5;
7057
- _iterator20.s();
6809
+ _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
6810
+ _context65.prev = 5;
6811
+ _iterator19.s();
7058
6812
  case 7:
7059
- if ((_step20 = _iterator20.n()).done) {
7060
- _context67.next = 27;
6813
+ if ((_step19 = _iterator19.n()).done) {
6814
+ _context65.next = 27;
7061
6815
  break;
7062
6816
  }
7063
- _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
7064
- _context67.prev = 9;
6817
+ _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
6818
+ _context65.prev = 9;
7065
6819
  computeStartAt = Date.now();
7066
- _context67.next = 13;
6820
+ _context65.next = 13;
7067
6821
  return this.computeOrderQueryResult(subscriber.context);
7068
6822
  case 13:
7069
- result = _context67.sent;
6823
+ result = _context65.sent;
7070
6824
  computeEndAt = Date.now();
7071
6825
  callbackStartAt = Date.now();
7072
6826
  subscriber.callback(result);
@@ -7077,30 +6831,30 @@ var Server = /*#__PURE__*/function () {
7077
6831
  callbackDurationMs: callbackEndAt - callbackStartAt,
7078
6832
  totalDurationMs: callbackEndAt - computeStartAt
7079
6833
  });
7080
- _context67.next = 25;
6834
+ _context65.next = 25;
7081
6835
  break;
7082
6836
  case 21:
7083
- _context67.prev = 21;
7084
- _context67.t0 = _context67["catch"](9);
7085
- errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
6837
+ _context65.prev = 21;
6838
+ _context65.t0 = _context65["catch"](9);
6839
+ errorMessage = _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0);
7086
6840
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
7087
6841
  subscriberId: subscriberId,
7088
6842
  error: errorMessage
7089
6843
  });
7090
6844
  case 25:
7091
- _context67.next = 7;
6845
+ _context65.next = 7;
7092
6846
  break;
7093
6847
  case 27:
7094
- _context67.next = 32;
6848
+ _context65.next = 32;
7095
6849
  break;
7096
6850
  case 29:
7097
- _context67.prev = 29;
7098
- _context67.t1 = _context67["catch"](5);
7099
- _iterator20.e(_context67.t1);
6851
+ _context65.prev = 29;
6852
+ _context65.t1 = _context65["catch"](5);
6853
+ _iterator19.e(_context65.t1);
7100
6854
  case 32:
7101
- _context67.prev = 32;
7102
- _iterator20.f();
7103
- return _context67.finish(32);
6855
+ _context65.prev = 32;
6856
+ _iterator19.f();
6857
+ return _context65.finish(32);
7104
6858
  case 35:
7105
6859
  notifyEndAt = Date.now();
7106
6860
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -7109,9 +6863,9 @@ var Server = /*#__PURE__*/function () {
7109
6863
  });
7110
6864
  case 37:
7111
6865
  case "end":
7112
- return _context67.stop();
6866
+ return _context65.stop();
7113
6867
  }
7114
- }, _callee67, this, [[5, 29, 32, 35], [9, 21]]);
6868
+ }, _callee65, this, [[5, 29, 32, 35], [9, 21]]);
7115
6869
  }));
7116
6870
  function recomputeAndNotifyOrderQuery() {
7117
6871
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -7129,7 +6883,7 @@ var Server = /*#__PURE__*/function () {
7129
6883
  }, {
7130
6884
  key: "notifySalesSearchSubscribers",
7131
6885
  value: function notifySalesSearchSubscribers(payload) {
7132
- var _this20 = this;
6886
+ var _this19 = this;
7133
6887
  if (this.salesSearchSubscribers.size === 0) return;
7134
6888
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
7135
6889
  if (changedOrders.length === 0) {
@@ -7138,42 +6892,42 @@ var Server = /*#__PURE__*/function () {
7138
6892
  // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
7139
6893
  // 导致模块被销毁 ,checkout 弹窗永远无法关闭
7140
6894
  if (window.isPaymentModalPluginOpen) return;
7141
- var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
7142
- _step21;
6895
+ var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
6896
+ _step20;
7143
6897
  try {
7144
- var _loop2 = function _loop2() {
7145
- var _step21$value = _slicedToArray(_step21.value, 2),
7146
- subscriberId = _step21$value[0],
7147
- subscriber = _step21$value[1];
6898
+ var _loop = function _loop() {
6899
+ var _step20$value = _slicedToArray(_step20.value, 2),
6900
+ subscriberId = _step20$value[0],
6901
+ subscriber = _step20$value[1];
7148
6902
  try {
7149
6903
  var changedVisibleOrders = changedOrders.filter(function (order) {
7150
- var orderId = _this20.getSalesSearchOrderId(order);
6904
+ var orderId = _this19.getSalesSearchOrderId(order);
7151
6905
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
7152
6906
  });
7153
6907
  if (changedVisibleOrders.length === 0) {
7154
6908
  return 1; // continue
7155
6909
  }
7156
- subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
7157
- _this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
6910
+ subscriber.callback(_this19.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
6911
+ _this19.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
7158
6912
  subscriberId: subscriberId,
7159
6913
  kind: subscriber.kind,
7160
6914
  count: changedVisibleOrders.length
7161
6915
  });
7162
6916
  } catch (error) {
7163
6917
  var errorMessage = error instanceof Error ? error.message : String(error);
7164
- _this20.logError('notifySalesSearchSubscribers: 推送失败', {
6918
+ _this19.logError('notifySalesSearchSubscribers: 推送失败', {
7165
6919
  subscriberId: subscriberId,
7166
6920
  error: errorMessage
7167
6921
  });
7168
6922
  }
7169
6923
  };
7170
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
7171
- if (_loop2()) continue;
6924
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
6925
+ if (_loop()) continue;
7172
6926
  }
7173
6927
  } catch (err) {
7174
- _iterator21.e(err);
6928
+ _iterator20.e(err);
7175
6929
  } finally {
7176
- _iterator21.f();
6930
+ _iterator20.f();
7177
6931
  }
7178
6932
  }
7179
6933
 
@@ -7252,67 +7006,67 @@ var Server = /*#__PURE__*/function () {
7252
7006
  }, {
7253
7007
  key: "recomputeAndNotifyBookingQuery",
7254
7008
  value: (function () {
7255
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
7256
- var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
7257
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
7258
- while (1) switch (_context68.prev = _context68.next) {
7009
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
7010
+ var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
7011
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
7012
+ while (1) switch (_context66.prev = _context66.next) {
7259
7013
  case 0:
7260
7014
  if (!(this.bookingQuerySubscribers.size === 0)) {
7261
- _context68.next = 2;
7015
+ _context66.next = 2;
7262
7016
  break;
7263
7017
  }
7264
- return _context68.abrupt("return");
7018
+ return _context66.abrupt("return");
7265
7019
  case 2:
7266
7020
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
7267
7021
  subscriberCount: this.bookingQuerySubscribers.size
7268
7022
  });
7269
- _iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
7270
- _context68.prev = 4;
7271
- _iterator22.s();
7023
+ _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
7024
+ _context66.prev = 4;
7025
+ _iterator21.s();
7272
7026
  case 6:
7273
- if ((_step22 = _iterator22.n()).done) {
7274
- _context68.next = 22;
7027
+ if ((_step21 = _iterator21.n()).done) {
7028
+ _context66.next = 22;
7275
7029
  break;
7276
7030
  }
7277
- _step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
7278
- _context68.prev = 8;
7279
- _context68.next = 11;
7031
+ _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
7032
+ _context66.prev = 8;
7033
+ _context66.next = 11;
7280
7034
  return this.computeBookingQueryResult(subscriber.context);
7281
7035
  case 11:
7282
- result = _context68.sent;
7036
+ result = _context66.sent;
7283
7037
  subscriber.callback(result);
7284
7038
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
7285
7039
  subscriberId: subscriberId
7286
7040
  });
7287
- _context68.next = 20;
7041
+ _context66.next = 20;
7288
7042
  break;
7289
7043
  case 16:
7290
- _context68.prev = 16;
7291
- _context68.t0 = _context68["catch"](8);
7292
- errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
7044
+ _context66.prev = 16;
7045
+ _context66.t0 = _context66["catch"](8);
7046
+ errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
7293
7047
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
7294
7048
  subscriberId: subscriberId,
7295
7049
  error: errorMessage
7296
7050
  });
7297
7051
  case 20:
7298
- _context68.next = 6;
7052
+ _context66.next = 6;
7299
7053
  break;
7300
7054
  case 22:
7301
- _context68.next = 27;
7055
+ _context66.next = 27;
7302
7056
  break;
7303
7057
  case 24:
7304
- _context68.prev = 24;
7305
- _context68.t1 = _context68["catch"](4);
7306
- _iterator22.e(_context68.t1);
7058
+ _context66.prev = 24;
7059
+ _context66.t1 = _context66["catch"](4);
7060
+ _iterator21.e(_context66.t1);
7307
7061
  case 27:
7308
- _context68.prev = 27;
7309
- _iterator22.f();
7310
- return _context68.finish(27);
7062
+ _context66.prev = 27;
7063
+ _iterator21.f();
7064
+ return _context66.finish(27);
7311
7065
  case 30:
7312
7066
  case "end":
7313
- return _context68.stop();
7067
+ return _context66.stop();
7314
7068
  }
7315
- }, _callee68, this, [[4, 24, 27, 30], [8, 16]]);
7069
+ }, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
7316
7070
  }));
7317
7071
  function recomputeAndNotifyBookingQuery() {
7318
7072
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -7342,11 +7096,11 @@ var Server = /*#__PURE__*/function () {
7342
7096
  var allowedProductIds = new Set();
7343
7097
  var allowedCollectionIds = new Set();
7344
7098
  var hasProductAll = false;
7345
- var _iterator23 = _createForOfIteratorHelper(activeMenuList),
7346
- _step23;
7099
+ var _iterator22 = _createForOfIteratorHelper(activeMenuList),
7100
+ _step22;
7347
7101
  try {
7348
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
7349
- var menu = _step23.value;
7102
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
7103
+ var menu = _step22.value;
7350
7104
  var config = menu.partyroom_package;
7351
7105
  if (!config) {
7352
7106
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -7406,9 +7160,9 @@ var Server = /*#__PURE__*/function () {
7406
7160
 
7407
7161
  // 如果有餐牌允许所有商品,返回所有商品
7408
7162
  } catch (err) {
7409
- _iterator23.e(err);
7163
+ _iterator22.e(err);
7410
7164
  } finally {
7411
- _iterator23.f();
7165
+ _iterator22.f();
7412
7166
  }
7413
7167
  if (hasProductAll) {
7414
7168
  this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');