@pisell/pisellos 2.3.28 → 2.3.29

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