@pisell/pisellos 2.3.30 → 2.3.32

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 (73) 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 +2 -1
  18. package/dist/modules/Order/index.js +25 -11
  19. package/dist/modules/Order/types.d.ts +2 -0
  20. package/dist/modules/Product/index.d.ts +1 -1
  21. package/dist/modules/Product/types.d.ts +22 -0
  22. package/dist/modules/ProductList/index.d.ts +1 -1
  23. package/dist/modules/ProductList/index.js +4 -2
  24. package/dist/modules/ProductList/types.d.ts +2 -0
  25. package/dist/server/index.d.ts +50 -0
  26. package/dist/server/index.js +1095 -849
  27. package/dist/server/modules/order/index.d.ts +8 -3
  28. package/dist/server/modules/order/index.js +765 -675
  29. package/dist/server/modules/products/index.d.ts +26 -7
  30. package/dist/server/modules/products/index.js +167 -76
  31. package/dist/server/modules/products/types.d.ts +14 -0
  32. package/dist/solution/BaseSales/index.d.ts +2 -0
  33. package/dist/solution/BaseSales/index.js +23 -13
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/types.d.ts +2 -0
  36. package/dist/solution/ShopDiscount/index.js +15 -14
  37. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  38. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  39. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  40. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  41. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  42. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  43. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  44. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  45. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  46. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  47. package/lib/model/strategy/adapter/index.d.ts +4 -0
  48. package/lib/model/strategy/adapter/index.js +13 -2
  49. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  50. package/lib/modules/Discount/index.d.ts +5 -2
  51. package/lib/modules/Discount/index.js +23 -3
  52. package/lib/modules/Discount/types.d.ts +4 -0
  53. package/lib/modules/Order/index.d.ts +2 -1
  54. package/lib/modules/Order/index.js +13 -1
  55. package/lib/modules/Order/types.d.ts +2 -0
  56. package/lib/modules/Product/index.d.ts +1 -1
  57. package/lib/modules/Product/types.d.ts +22 -0
  58. package/lib/modules/ProductList/index.d.ts +1 -1
  59. package/lib/modules/ProductList/index.js +4 -2
  60. package/lib/modules/ProductList/types.d.ts +2 -0
  61. package/lib/server/index.d.ts +50 -0
  62. package/lib/server/index.js +206 -29
  63. package/lib/server/modules/order/index.d.ts +8 -3
  64. package/lib/server/modules/order/index.js +152 -43
  65. package/lib/server/modules/products/index.d.ts +26 -7
  66. package/lib/server/modules/products/index.js +114 -35
  67. package/lib/server/modules/products/types.d.ts +14 -0
  68. package/lib/solution/BaseSales/index.d.ts +2 -0
  69. package/lib/solution/BaseSales/index.js +12 -3
  70. package/lib/solution/BookingByStep/index.d.ts +1 -1
  71. package/lib/solution/BookingTicket/types.d.ts +2 -0
  72. package/lib/solution/ShopDiscount/index.js +2 -1
  73. package/package.json +1 -1
@@ -95,6 +95,8 @@ var Server = /*#__PURE__*/function () {
95
95
  });
96
96
  // ---- 商品查询订阅者 ----
97
97
  _defineProperty(this, "productQuerySubscribers", new Map());
98
+ /** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
99
+ _defineProperty(this, "productQueryScheduleTimers", new Map());
98
100
  // ---- 订单 / 预约列表查询订阅者 ----
99
101
  _defineProperty(this, "orderQuerySubscribers", new Map());
100
102
  _defineProperty(this, "bookingQuerySubscribers", new Map());
@@ -274,13 +276,13 @@ var Server = /*#__PURE__*/function () {
274
276
  */
275
277
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
276
278
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
277
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
279
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
278
280
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
279
281
  while (1) switch (_context3.prev = _context3.next) {
280
282
  case 0:
281
283
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
282
284
  console.log('[Server] handleProductQuery:', url, method, data, config);
283
- 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;
285
+ 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;
284
286
  _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
285
287
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
286
288
  menu_list_ids: menu_list_ids,
@@ -288,7 +290,8 @@ var Server = /*#__PURE__*/function () {
288
290
  schedule_datetime: schedule_datetime,
289
291
  schedule_date: schedule_date,
290
292
  customer_id: customer_id,
291
- extension_type: extension_type
293
+ extension_type: extension_type,
294
+ strategyContextKeys: strategy_context ? Object.keys(strategy_context) : []
292
295
  });
293
296
 
294
297
  // 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
@@ -301,7 +304,8 @@ var Server = /*#__PURE__*/function () {
301
304
  schedule_date: schedule_date,
302
305
  schedule_datetime: schedule_datetime,
303
306
  customer_id: customer_id,
304
- extension_type: extension_type
307
+ extension_type: extension_type,
308
+ strategy_context: strategy_context
305
309
  }
306
310
  });
307
311
  _this.logInfo('handleProductQuery: 已注册订阅者', {
@@ -309,15 +313,23 @@ var Server = /*#__PURE__*/function () {
309
313
  totalSubscribers: _this.productQuerySubscribers.size
310
314
  });
311
315
  }
312
- return _context3.abrupt("return", _this.computeProductQueryResult({
316
+ _context3.next = 8;
317
+ return _this.computeProductQueryResult({
313
318
  menu_list_ids: menu_list_ids,
314
319
  ids: ids,
315
320
  schedule_date: schedule_date,
316
321
  schedule_datetime: schedule_datetime,
317
322
  customer_id: customer_id,
318
- extension_type: extension_type
319
- }));
320
- case 7:
323
+ extension_type: extension_type,
324
+ strategy_context: strategy_context
325
+ });
326
+ case 8:
327
+ result = _context3.sent;
328
+ if (subscriberId && typeof callback === 'function') {
329
+ _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
330
+ }
331
+ return _context3.abrupt("return", result);
332
+ case 11:
321
333
  case "end":
322
334
  return _context3.stop();
323
335
  }
@@ -3317,6 +3329,7 @@ var Server = /*#__PURE__*/function () {
3317
3329
  key: "removeProductQuerySubscriber",
3318
3330
  value: function removeProductQuerySubscriber(subscriberId) {
3319
3331
  if (subscriberId) {
3332
+ this.clearSubscriberScheduleTimers(subscriberId);
3320
3333
  this.productQuerySubscribers.delete(subscriberId);
3321
3334
  this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
3322
3335
  subscriberId: subscriberId,
@@ -3324,6 +3337,243 @@ var Server = /*#__PURE__*/function () {
3324
3337
  });
3325
3338
  }
3326
3339
  }
3340
+
3341
+ /**
3342
+ * 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
3343
+ */
3344
+ }, {
3345
+ key: "buildProductQueryResultPayload",
3346
+ value: function buildProductQueryResultPayload(list, count) {
3347
+ var _this$products$getLas, _this$products, _this$products$getLas2;
3348
+ return {
3349
+ list: list,
3350
+ count: count !== null && count !== void 0 ? count : list.length,
3351
+ 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 : []
3352
+ };
3353
+ }
3354
+
3355
+ /**
3356
+ * 是否启用商品 query 订阅的 schedule 时间点定时重算。
3357
+ * strategy_context.enable_schedule_reload === false 时关闭。
3358
+ */
3359
+ }, {
3360
+ key: "shouldScheduleProductQueryReload",
3361
+ value: function shouldScheduleProductQueryReload(strategy_context) {
3362
+ return (strategy_context === null || strategy_context === void 0 ? void 0 : strategy_context.enable_schedule_reload) !== false;
3363
+ }
3364
+
3365
+ /**
3366
+ * 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
3367
+ */
3368
+ }, {
3369
+ key: "clearSubscriberScheduleTimers",
3370
+ value: function clearSubscriberScheduleTimers(subscriberId) {
3371
+ var timers = this.productQueryScheduleTimers.get(subscriberId);
3372
+ if (timers !== null && timers !== void 0 && timers.length) {
3373
+ timers.forEach(function (timerId) {
3374
+ return clearTimeout(timerId);
3375
+ });
3376
+ }
3377
+ this.productQueryScheduleTimers.delete(subscriberId);
3378
+ var subscriber = this.productQuerySubscribers.get(subscriberId);
3379
+ if (subscriber) {
3380
+ subscriber.scheduleTimerIds = [];
3381
+ }
3382
+ }
3383
+
3384
+ /**
3385
+ * 从 productQueryScheduleTimers 移除已触发的 timer 引用。
3386
+ */
3387
+ }, {
3388
+ key: "removeScheduleTimerRef",
3389
+ value: function removeScheduleTimerRef(subscriberId, timerId) {
3390
+ var timers = this.productQueryScheduleTimers.get(subscriberId);
3391
+ if (!(timers !== null && timers !== void 0 && timers.length)) return;
3392
+ var next = timers.filter(function (id) {
3393
+ return id !== timerId;
3394
+ });
3395
+ if (next.length === 0) {
3396
+ this.productQueryScheduleTimers.delete(subscriberId);
3397
+ } else {
3398
+ this.productQueryScheduleTimers.set(subscriberId, next);
3399
+ }
3400
+ var subscriber = this.productQuerySubscribers.get(subscriberId);
3401
+ if (subscriber) {
3402
+ subscriber.scheduleTimerIds = next;
3403
+ }
3404
+ }
3405
+
3406
+ /**
3407
+ * 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
3408
+ */
3409
+ }, {
3410
+ key: "computeScheduleTimePointDelayMs",
3411
+ value: function computeScheduleTimePointDelayMs(scheduleDate, timePoint) {
3412
+ var parts = timePoint.split(':');
3413
+ if (parts.length < 2) return -1;
3414
+ var hours = parseInt(parts[0], 10);
3415
+ var minutes = parseInt(parts[1], 10);
3416
+ if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return -1;
3417
+ var target = dayjs(scheduleDate).hour(hours).minute(minutes).second(4).millisecond(0);
3418
+ var delayMs = target.diff(dayjs());
3419
+ return delayMs >= 0 ? delayMs : -1;
3420
+ }
3421
+
3422
+ /**
3423
+ * 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
3424
+ */
3425
+ }, {
3426
+ key: "refreshSubscriberScheduleAtExecution",
3427
+ value: function refreshSubscriberScheduleAtExecution(subscriber) {
3428
+ var executedAt = dayjs();
3429
+ var bookingDate = subscriber.context.schedule_date || executedAt.format('YYYY-MM-DD');
3430
+ subscriber.context.schedule_date = bookingDate;
3431
+ subscriber.context.schedule_datetime = "".concat(bookingDate, " ").concat(executedAt.format('HH:mm:ss'));
3432
+ }
3433
+
3434
+ /**
3435
+ * 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
3436
+ * 必须先 clearSubscriberScheduleTimers,再调用本方法。
3437
+ */
3438
+ }, {
3439
+ key: "scheduleSubscriberTimePointReloads",
3440
+ value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3441
+ var _this7 = this;
3442
+ var subscriber = this.productQuerySubscribers.get(subscriberId);
3443
+ if (!subscriber || !timePoints.length) return;
3444
+ var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
3445
+ var timerIds = [];
3446
+ var _iterator5 = _createForOfIteratorHelper(timePoints),
3447
+ _step5;
3448
+ try {
3449
+ var _loop = function _loop() {
3450
+ var timePoint = _step5.value;
3451
+ var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
3452
+ if (delayMs < 0) return 1; // continue
3453
+ var timerId = setTimeout(function () {
3454
+ void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
3455
+ }, delayMs);
3456
+ timerIds.push(timerId);
3457
+ };
3458
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3459
+ if (_loop()) continue;
3460
+ }
3461
+ } catch (err) {
3462
+ _iterator5.e(err);
3463
+ } finally {
3464
+ _iterator5.f();
3465
+ }
3466
+ if (timerIds.length > 0) {
3467
+ this.productQueryScheduleTimers.set(subscriberId, timerIds);
3468
+ subscriber.scheduleTimerIds = timerIds;
3469
+ this.logInfo('scheduleSubscriberTimePointReloads: 已注册定时器', {
3470
+ subscriberId: subscriberId,
3471
+ timerCount: timerIds.length,
3472
+ timePoints: timePoints
3473
+ });
3474
+ }
3475
+ }
3476
+
3477
+ /**
3478
+ * schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
3479
+ */
3480
+ }, {
3481
+ key: "onScheduleTimePointTimerFire",
3482
+ value: (function () {
3483
+ var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(subscriberId, timerId) {
3484
+ var subscriber;
3485
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3486
+ while (1) switch (_context41.prev = _context41.next) {
3487
+ case 0:
3488
+ this.removeScheduleTimerRef(subscriberId, timerId);
3489
+ if (this.productQuerySubscribers.has(subscriberId)) {
3490
+ _context41.next = 3;
3491
+ break;
3492
+ }
3493
+ return _context41.abrupt("return");
3494
+ case 3:
3495
+ subscriber = this.productQuerySubscribers.get(subscriberId);
3496
+ this.refreshSubscriberScheduleAtExecution(subscriber);
3497
+ _context41.next = 7;
3498
+ return this.recomputeAndNotifySubscriber(subscriberId);
3499
+ case 7:
3500
+ case "end":
3501
+ return _context41.stop();
3502
+ }
3503
+ }, _callee41, this);
3504
+ }));
3505
+ function onScheduleTimePointTimerFire(_x40, _x41) {
3506
+ return _onScheduleTimePointTimerFire.apply(this, arguments);
3507
+ }
3508
+ return onScheduleTimePointTimerFire;
3509
+ }()
3510
+ /**
3511
+ * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
3512
+ */
3513
+ )
3514
+ }, {
3515
+ key: "recomputeAndNotifySubscriber",
3516
+ value: (function () {
3517
+ var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId) {
3518
+ var subscriber, result, errorMessage;
3519
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3520
+ while (1) switch (_context42.prev = _context42.next) {
3521
+ case 0:
3522
+ subscriber = this.productQuerySubscribers.get(subscriberId);
3523
+ if (subscriber) {
3524
+ _context42.next = 3;
3525
+ break;
3526
+ }
3527
+ return _context42.abrupt("return");
3528
+ case 3:
3529
+ _context42.prev = 3;
3530
+ _context42.next = 6;
3531
+ return this.computeProductQueryResult(subscriber.context);
3532
+ case 6:
3533
+ result = _context42.sent;
3534
+ subscriber.callback(result);
3535
+ this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3536
+ subscriberId: subscriberId,
3537
+ schedule_datetime: subscriber.context.schedule_datetime
3538
+ });
3539
+ _context42.next = 15;
3540
+ break;
3541
+ case 11:
3542
+ _context42.prev = 11;
3543
+ _context42.t0 = _context42["catch"](3);
3544
+ errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3545
+ this.logError('recomputeAndNotifySubscriber: 推送失败', {
3546
+ subscriberId: subscriberId,
3547
+ error: errorMessage
3548
+ });
3549
+ case 15:
3550
+ case "end":
3551
+ return _context42.stop();
3552
+ }
3553
+ }, _callee42, this, [[3, 11]]);
3554
+ }));
3555
+ function recomputeAndNotifySubscriber(_x42) {
3556
+ return _recomputeAndNotifySubscriber.apply(this, arguments);
3557
+ }
3558
+ return recomputeAndNotifySubscriber;
3559
+ }()
3560
+ /**
3561
+ * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3562
+ */
3563
+ )
3564
+ }, {
3565
+ key: "syncProductQueryScheduleTimers",
3566
+ value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3567
+ var _this$products$getLas3, _this$products2, _this$products2$getLa;
3568
+ this.clearSubscriberScheduleTimers(subscriberId);
3569
+ if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3570
+ return;
3571
+ }
3572
+ 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 : [];
3573
+ if (timePoints.length > 0) {
3574
+ this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3575
+ }
3576
+ }
3327
3577
  }, {
3328
3578
  key: "handleSalesSearchRequest",
3329
3579
  value: (
@@ -3335,32 +3585,32 @@ var Server = /*#__PURE__*/function () {
3335
3585
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3336
3586
  */
3337
3587
  function () {
3338
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(kind, backendPath, data, config) {
3339
- var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3340
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3341
- while (1) switch (_context41.prev = _context41.next) {
3588
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(kind, backendPath, data, config) {
3589
+ var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3590
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3591
+ while (1) switch (_context43.prev = _context43.next) {
3342
3592
  case 0:
3343
3593
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3344
- _context41.next = 3;
3594
+ _context43.next = 3;
3345
3595
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3346
3596
  case 3:
3347
- result = _context41.sent;
3597
+ result = _context43.sent;
3348
3598
  _ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
3349
3599
  if (subscriberId && typeof callback === 'function') {
3350
3600
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3351
3601
  existing = this.salesSearchSubscribers.get(subscriberId);
3352
3602
  shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
3353
3603
  visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
3354
- _iterator5 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3604
+ _iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3355
3605
  try {
3356
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3357
- orderId = _step5.value;
3606
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3607
+ orderId = _step6.value;
3358
3608
  visibleOrderIds.add(orderId);
3359
3609
  }
3360
3610
  } catch (err) {
3361
- _iterator5.e(err);
3611
+ _iterator6.e(err);
3362
3612
  } finally {
3363
- _iterator5.f();
3613
+ _iterator6.f();
3364
3614
  }
3365
3615
  this.salesSearchSubscribers.set(subscriberId, {
3366
3616
  callback: callback,
@@ -3376,14 +3626,14 @@ var Server = /*#__PURE__*/function () {
3376
3626
  visibleCount: visibleOrderIds.size
3377
3627
  });
3378
3628
  }
3379
- return _context41.abrupt("return", result);
3629
+ return _context43.abrupt("return", result);
3380
3630
  case 7:
3381
3631
  case "end":
3382
- return _context41.stop();
3632
+ return _context43.stop();
3383
3633
  }
3384
- }, _callee41, this);
3634
+ }, _callee43, this);
3385
3635
  }));
3386
- function handleSalesSearchRequest(_x40, _x41, _x42, _x43) {
3636
+ function handleSalesSearchRequest(_x43, _x44, _x45, _x46) {
3387
3637
  return _handleSalesSearchRequest.apply(this, arguments);
3388
3638
  }
3389
3639
  return handleSalesSearchRequest;
@@ -3398,20 +3648,20 @@ var Server = /*#__PURE__*/function () {
3398
3648
  }, {
3399
3649
  key: "fetchSalesSearchFromAPI",
3400
3650
  value: (function () {
3401
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(backendPath, data) {
3651
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(backendPath, data) {
3402
3652
  var _this$app8;
3403
3653
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3404
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3405
- while (1) switch (_context42.prev = _context42.next) {
3654
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3655
+ while (1) switch (_context44.prev = _context44.next) {
3406
3656
  case 0:
3407
3657
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3408
- _context42.next = 3;
3658
+ _context44.next = 3;
3409
3659
  break;
3410
3660
  }
3411
3661
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3412
3662
  backendPath: backendPath
3413
3663
  });
3414
- return _context42.abrupt("return", {
3664
+ return _context44.abrupt("return", {
3415
3665
  code: 500,
3416
3666
  message: 'app.request 不可用',
3417
3667
  data: backendPath === '/shop/es/search' ? {
@@ -3423,29 +3673,29 @@ var Server = /*#__PURE__*/function () {
3423
3673
  status: false
3424
3674
  });
3425
3675
  case 3:
3426
- _context42.prev = 3;
3427
- _context42.next = 6;
3676
+ _context44.prev = 3;
3677
+ _context44.next = 6;
3428
3678
  return this.app.request.post(backendPath, data, {
3429
3679
  isShopApi: true
3430
3680
  });
3431
3681
  case 6:
3432
- response = _context42.sent;
3682
+ response = _context44.sent;
3433
3683
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3434
- return _context42.abrupt("return", {
3684
+ return _context44.abrupt("return", {
3435
3685
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3436
3686
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3437
3687
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3438
3688
  data: _payload
3439
3689
  });
3440
3690
  case 11:
3441
- _context42.prev = 11;
3442
- _context42.t0 = _context42["catch"](3);
3443
- errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
3691
+ _context44.prev = 11;
3692
+ _context44.t0 = _context44["catch"](3);
3693
+ errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
3444
3694
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3445
3695
  backendPath: backendPath,
3446
3696
  error: errorMessage
3447
3697
  });
3448
- return _context42.abrupt("return", {
3698
+ return _context44.abrupt("return", {
3449
3699
  code: 500,
3450
3700
  message: errorMessage,
3451
3701
  data: backendPath === '/shop/es/search' ? {
@@ -3458,11 +3708,11 @@ var Server = /*#__PURE__*/function () {
3458
3708
  });
3459
3709
  case 16:
3460
3710
  case "end":
3461
- return _context42.stop();
3711
+ return _context44.stop();
3462
3712
  }
3463
- }, _callee42, this, [[3, 11]]);
3713
+ }, _callee44, this, [[3, 11]]);
3464
3714
  }));
3465
- function fetchSalesSearchFromAPI(_x44, _x45) {
3715
+ function fetchSalesSearchFromAPI(_x47, _x48) {
3466
3716
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3467
3717
  }
3468
3718
  return fetchSalesSearchFromAPI;
@@ -3492,10 +3742,10 @@ var Server = /*#__PURE__*/function () {
3492
3742
  }, {
3493
3743
  key: "stripSalesSearchPageParams",
3494
3744
  value: function stripSalesSearchPageParams(value) {
3495
- var _this7 = this;
3745
+ var _this8 = this;
3496
3746
  if (Array.isArray(value)) {
3497
3747
  return value.map(function (item) {
3498
- return _this7.stripSalesSearchPageParams(item);
3748
+ return _this8.stripSalesSearchPageParams(item);
3499
3749
  });
3500
3750
  }
3501
3751
  if (!value || _typeof(value) !== 'object') return value;
@@ -3533,12 +3783,12 @@ var Server = /*#__PURE__*/function () {
3533
3783
  key: "extractSalesSearchOrderIds",
3534
3784
  value: function extractSalesSearchOrderIds(kind, result) {
3535
3785
  var _this$findSalesSearch,
3536
- _this8 = this;
3786
+ _this9 = this;
3537
3787
  var data = this.extractSalesSearchResponseData(result);
3538
3788
  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;
3539
3789
  if (!Array.isArray(list)) return [];
3540
3790
  return list.map(function (item) {
3541
- return _this8.getSalesSearchOrderId(item);
3791
+ return _this9.getSalesSearchOrderId(item);
3542
3792
  }).filter(function (id) {
3543
3793
  return !!id;
3544
3794
  });
@@ -3705,11 +3955,11 @@ var Server = /*#__PURE__*/function () {
3705
3955
  }, {
3706
3956
  key: "stableSerialize",
3707
3957
  value: function stableSerialize(value) {
3708
- var _this9 = this;
3958
+ var _this10 = this;
3709
3959
  if (value === null || value === undefined) return 'null';
3710
3960
  if (Array.isArray(value)) {
3711
3961
  return "[".concat(value.map(function (item) {
3712
- return _this9.stableSerialize(item);
3962
+ return _this10.stableSerialize(item);
3713
3963
  }).join(','), "]");
3714
3964
  }
3715
3965
  if (_typeof(value) === 'object') {
@@ -3718,7 +3968,7 @@ var Server = /*#__PURE__*/function () {
3718
3968
  return obj[k] !== undefined;
3719
3969
  }).sort();
3720
3970
  return "{".concat(keys.map(function (k) {
3721
- return "".concat(JSON.stringify(k), ":").concat(_this9.stableSerialize(obj[k]));
3971
+ return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
3722
3972
  }).join(','), "}");
3723
3973
  }
3724
3974
  return JSON.stringify(value);
@@ -3767,22 +4017,22 @@ var Server = /*#__PURE__*/function () {
3767
4017
  }
3768
4018
  var oldestKey = null;
3769
4019
  var oldestTime = Number.POSITIVE_INFINITY;
3770
- var _iterator6 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3771
- _step6;
4020
+ var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4021
+ _step7;
3772
4022
  try {
3773
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3774
- var _step6$value = _slicedToArray(_step6.value, 2),
3775
- _key3 = _step6$value[0],
3776
- cache = _step6$value[1];
4023
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
4024
+ var _step7$value = _slicedToArray(_step7.value, 2),
4025
+ _key3 = _step7$value[0],
4026
+ cache = _step7$value[1];
3777
4027
  if (cache.updatedAt < oldestTime) {
3778
4028
  oldestTime = cache.updatedAt;
3779
4029
  oldestKey = _key3;
3780
4030
  }
3781
4031
  }
3782
4032
  } catch (err) {
3783
- _iterator6.e(err);
4033
+ _iterator7.e(err);
3784
4034
  } finally {
3785
- _iterator6.f();
4035
+ _iterator7.f();
3786
4036
  }
3787
4037
  if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
3788
4038
  }
@@ -3798,17 +4048,17 @@ var Server = /*#__PURE__*/function () {
3798
4048
  key: "markBookingRemoteCacheAllStale",
3799
4049
  value: function markBookingRemoteCacheAllStale(reason) {
3800
4050
  if (this.bookingRemoteCache.size === 0) return;
3801
- var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
3802
- _step7;
4051
+ var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
4052
+ _step8;
3803
4053
  try {
3804
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3805
- var entry = _step7.value;
4054
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
4055
+ var entry = _step8.value;
3806
4056
  entry.stale = true;
3807
4057
  }
3808
4058
  } catch (err) {
3809
- _iterator7.e(err);
4059
+ _iterator8.e(err);
3810
4060
  } finally {
3811
- _iterator7.f();
4061
+ _iterator8.f();
3812
4062
  }
3813
4063
  this.logWarning('bookingRemoteCache: 全量标记失效', {
3814
4064
  reason: reason,
@@ -3834,13 +4084,13 @@ var Server = /*#__PURE__*/function () {
3834
4084
  key: "notifyBookingRemoteSubscribersByCacheKey",
3835
4085
  value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
3836
4086
  if (this.bookingRemoteQuerySubscribers.size === 0) return;
3837
- var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
3838
- _step8;
4087
+ var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
4088
+ _step9;
3839
4089
  try {
3840
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3841
- var _step8$value = _slicedToArray(_step8.value, 2),
3842
- subscriberId = _step8$value[0],
3843
- subscriber = _step8$value[1];
4090
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
4091
+ var _step9$value = _slicedToArray(_step9.value, 2),
4092
+ subscriberId = _step9$value[0],
4093
+ subscriber = _step9$value[1];
3844
4094
  if (subscriber.cacheKey !== cacheKey) continue;
3845
4095
  try {
3846
4096
  var callbackStartAt = Date.now();
@@ -3867,9 +4117,9 @@ var Server = /*#__PURE__*/function () {
3867
4117
  }
3868
4118
  }
3869
4119
  } catch (err) {
3870
- _iterator8.e(err);
4120
+ _iterator9.e(err);
3871
4121
  } finally {
3872
- _iterator8.f();
4122
+ _iterator9.f();
3873
4123
  }
3874
4124
  }
3875
4125
  }, {
@@ -3884,13 +4134,13 @@ var Server = /*#__PURE__*/function () {
3884
4134
  return;
3885
4135
  }
3886
4136
  var syncedEntryCount = 0;
3887
- var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
3888
- _step9;
4137
+ var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4138
+ _step10;
3889
4139
  try {
3890
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3891
- var _step9$value = _slicedToArray(_step9.value, 2),
3892
- cacheKey = _step9$value[0],
3893
- entry = _step9$value[1];
4140
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
4141
+ var _step10$value = _slicedToArray(_step10.value, 2),
4142
+ cacheKey = _step10$value[0],
4143
+ entry = _step10$value[1];
3894
4144
  if (entry.stale) {
3895
4145
  this.bookingRemoteCache.delete(cacheKey);
3896
4146
  continue;
@@ -3898,25 +4148,25 @@ var Server = /*#__PURE__*/function () {
3898
4148
  try {
3899
4149
  var queryPayload = entry.queryPayload;
3900
4150
  var orderMap = new Map();
3901
- var _iterator10 = _createForOfIteratorHelper(entry.rawOrders),
3902
- _step10;
4151
+ var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
4152
+ _step11;
3903
4153
  try {
3904
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3905
- var order = _step10.value;
4154
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
4155
+ var order = _step11.value;
3906
4156
  var _key4 = this.toOrderIdKey(order);
3907
4157
  if (_key4) orderMap.set(_key4, order);
3908
4158
  }
3909
4159
  } catch (err) {
3910
- _iterator10.e(err);
4160
+ _iterator11.e(err);
3911
4161
  } finally {
3912
- _iterator10.f();
4162
+ _iterator11.f();
3913
4163
  }
3914
4164
  var changed = false;
3915
- var _iterator11 = _createForOfIteratorHelper(latestOrders),
3916
- _step11;
4165
+ var _iterator12 = _createForOfIteratorHelper(latestOrders),
4166
+ _step12;
3917
4167
  try {
3918
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3919
- var latest = _step11.value;
4168
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
4169
+ var latest = _step12.value;
3920
4170
  var _key5 = this.toOrderIdKey(latest);
3921
4171
  if (!_key5) continue;
3922
4172
  if (orderMap.has(_key5)) {
@@ -3928,9 +4178,9 @@ var Server = /*#__PURE__*/function () {
3928
4178
  changed = true;
3929
4179
  }
3930
4180
  } catch (err) {
3931
- _iterator11.e(err);
4181
+ _iterator12.e(err);
3932
4182
  } finally {
3933
- _iterator11.f();
4183
+ _iterator12.f();
3934
4184
  }
3935
4185
  if (!changed) continue;
3936
4186
  var mergedOrders = _toConsumableArray(orderMap.values());
@@ -3963,9 +4213,9 @@ var Server = /*#__PURE__*/function () {
3963
4213
  }
3964
4214
  }
3965
4215
  } catch (err) {
3966
- _iterator9.e(err);
4216
+ _iterator10.e(err);
3967
4217
  } finally {
3968
- _iterator9.f();
4218
+ _iterator10.f();
3969
4219
  }
3970
4220
  var syncEndAt = Date.now();
3971
4221
  if (syncedEntryCount > 0) {
@@ -3983,18 +4233,18 @@ var Server = /*#__PURE__*/function () {
3983
4233
  }, {
3984
4234
  key: "fetchOrderListFromAPI",
3985
4235
  value: (function () {
3986
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
4236
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data) {
3987
4237
  var _this$app9;
3988
4238
  var _response$data5, response, _payload2, list, count, errorMessage;
3989
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3990
- while (1) switch (_context43.prev = _context43.next) {
4239
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4240
+ while (1) switch (_context45.prev = _context45.next) {
3991
4241
  case 0:
3992
4242
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
3993
- _context43.next = 3;
4243
+ _context45.next = 3;
3994
4244
  break;
3995
4245
  }
3996
4246
  this.logError('fetchOrderListFromAPI: app.request 不可用');
3997
- return _context43.abrupt("return", {
4247
+ return _context45.abrupt("return", {
3998
4248
  code: 500,
3999
4249
  message: 'app.request 不可用',
4000
4250
  data: {
@@ -4004,17 +4254,17 @@ var Server = /*#__PURE__*/function () {
4004
4254
  status: false
4005
4255
  });
4006
4256
  case 3:
4007
- _context43.prev = 3;
4008
- _context43.next = 6;
4257
+ _context45.prev = 3;
4258
+ _context45.next = 6;
4009
4259
  return this.app.request.post('/shop/order/v2/list', data, {
4010
4260
  isShopApi: true
4011
4261
  });
4012
4262
  case 6:
4013
- response = _context43.sent;
4263
+ response = _context45.sent;
4014
4264
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4015
4265
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4016
4266
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4017
- return _context43.abrupt("return", {
4267
+ return _context45.abrupt("return", {
4018
4268
  code: 200,
4019
4269
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4020
4270
  list: list,
@@ -4024,13 +4274,13 @@ var Server = /*#__PURE__*/function () {
4024
4274
  status: true
4025
4275
  });
4026
4276
  case 13:
4027
- _context43.prev = 13;
4028
- _context43.t0 = _context43["catch"](3);
4029
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
4277
+ _context45.prev = 13;
4278
+ _context45.t0 = _context45["catch"](3);
4279
+ errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
4030
4280
  this.logError('fetchOrderListFromAPI: 请求失败', {
4031
4281
  error: errorMessage
4032
4282
  });
4033
- return _context43.abrupt("return", {
4283
+ return _context45.abrupt("return", {
4034
4284
  code: 500,
4035
4285
  message: errorMessage,
4036
4286
  data: {
@@ -4041,11 +4291,11 @@ var Server = /*#__PURE__*/function () {
4041
4291
  });
4042
4292
  case 18:
4043
4293
  case "end":
4044
- return _context43.stop();
4294
+ return _context45.stop();
4045
4295
  }
4046
- }, _callee43, this, [[3, 13]]);
4296
+ }, _callee45, this, [[3, 13]]);
4047
4297
  }));
4048
- function fetchOrderListFromAPI(_x46) {
4298
+ function fetchOrderListFromAPI(_x49) {
4049
4299
  return _fetchOrderListFromAPI.apply(this, arguments);
4050
4300
  }
4051
4301
  return fetchOrderListFromAPI;
@@ -4057,17 +4307,17 @@ var Server = /*#__PURE__*/function () {
4057
4307
  }, {
4058
4308
  key: "fetchBookingListFromAPI",
4059
4309
  value: (function () {
4060
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data) {
4310
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4061
4311
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4062
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4063
- while (1) switch (_context44.prev = _context44.next) {
4312
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4313
+ while (1) switch (_context46.prev = _context46.next) {
4064
4314
  case 0:
4065
4315
  if (this.order) {
4066
- _context44.next = 3;
4316
+ _context46.next = 3;
4067
4317
  break;
4068
4318
  }
4069
4319
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4070
- return _context44.abrupt("return", {
4320
+ return _context46.abrupt("return", {
4071
4321
  code: 500,
4072
4322
  message: 'Order 模块不可用',
4073
4323
  data: {
@@ -4077,18 +4327,18 @@ var Server = /*#__PURE__*/function () {
4077
4327
  status: false
4078
4328
  });
4079
4329
  case 3:
4080
- _context44.prev = 3;
4330
+ _context46.prev = 3;
4081
4331
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4082
4332
  withFields = this.resolveBookingSalesWith(data);
4083
4333
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4084
4334
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4085
4335
  if (!memoryCacheEnabled) {
4086
- _context44.next = 13;
4336
+ _context46.next = 13;
4087
4337
  break;
4088
4338
  }
4089
4339
  cached = this.readBookingRemoteCache(cacheKey);
4090
4340
  if (!cached) {
4091
- _context44.next = 13;
4341
+ _context46.next = 13;
4092
4342
  break;
4093
4343
  }
4094
4344
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4096,14 +4346,14 @@ var Server = /*#__PURE__*/function () {
4096
4346
  listCount: cached.bookingResult.count,
4097
4347
  withFields: cached.withFields
4098
4348
  });
4099
- return _context44.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4349
+ return _context46.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4100
4350
  cache_hit: true
4101
4351
  }));
4102
4352
  case 13:
4103
- _context44.next = 15;
4353
+ _context46.next = 15;
4104
4354
  return this.order.fetchOrdersBySSE(requestPayload);
4105
4355
  case 15:
4106
- rawList = _context44.sent;
4356
+ rawList = _context46.sent;
4107
4357
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4108
4358
  if (typeof globalThis !== 'undefined') {
4109
4359
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4150,15 +4400,15 @@ var Server = /*#__PURE__*/function () {
4150
4400
  cacheKey: cacheKey,
4151
4401
  withFields: withFields
4152
4402
  });
4153
- return _context44.abrupt("return", this.buildBookingResponse(bookingResult));
4403
+ return _context46.abrupt("return", this.buildBookingResponse(bookingResult));
4154
4404
  case 23:
4155
- _context44.prev = 23;
4156
- _context44.t0 = _context44["catch"](3);
4157
- errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
4405
+ _context46.prev = 23;
4406
+ _context46.t0 = _context46["catch"](3);
4407
+ errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4158
4408
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4159
4409
  error: errorMessage
4160
4410
  });
4161
- return _context44.abrupt("return", {
4411
+ return _context46.abrupt("return", {
4162
4412
  code: 500,
4163
4413
  message: errorMessage,
4164
4414
  data: {
@@ -4169,11 +4419,11 @@ var Server = /*#__PURE__*/function () {
4169
4419
  });
4170
4420
  case 28:
4171
4421
  case "end":
4172
- return _context44.stop();
4422
+ return _context46.stop();
4173
4423
  }
4174
- }, _callee44, this, [[3, 23]]);
4424
+ }, _callee46, this, [[3, 23]]);
4175
4425
  }));
4176
- function fetchBookingListFromAPI(_x47) {
4426
+ function fetchBookingListFromAPI(_x50) {
4177
4427
  return _fetchBookingListFromAPI.apply(this, arguments);
4178
4428
  }
4179
4429
  return fetchBookingListFromAPI;
@@ -4257,11 +4507,11 @@ var Server = /*#__PURE__*/function () {
4257
4507
  }, {
4258
4508
  key: "runLocalPaymentUpdateInQueue",
4259
4509
  value: function () {
4260
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(key, task, context) {
4261
- var _this10 = this;
4510
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(key, task, context) {
4511
+ var _this11 = this;
4262
4512
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4263
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4264
- while (1) switch (_context46.prev = _context46.next) {
4513
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4514
+ while (1) switch (_context48.prev = _context48.next) {
4265
4515
  case 0:
4266
4516
  queuedAt = Date.now();
4267
4517
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -4273,20 +4523,20 @@ var Server = /*#__PURE__*/function () {
4273
4523
  }));
4274
4524
  current = previous.catch(function () {
4275
4525
  return undefined;
4276
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
4277
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4278
- while (1) switch (_context45.prev = _context45.next) {
4526
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4527
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4528
+ while (1) switch (_context47.prev = _context47.next) {
4279
4529
  case 0:
4280
- _this10.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4530
+ _this11.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4281
4531
  queue_key: key,
4282
4532
  queue_wait_ms: Date.now() - queuedAt
4283
4533
  }));
4284
- return _context45.abrupt("return", task());
4534
+ return _context47.abrupt("return", task());
4285
4535
  case 2:
4286
4536
  case "end":
4287
- return _context45.stop();
4537
+ return _context47.stop();
4288
4538
  }
4289
- }, _callee45);
4539
+ }, _callee47);
4290
4540
  })));
4291
4541
  tail = current.then(function () {
4292
4542
  return undefined;
@@ -4294,11 +4544,11 @@ var Server = /*#__PURE__*/function () {
4294
4544
  return undefined;
4295
4545
  });
4296
4546
  this.localPaymentUpdateQueues.set(key, tail);
4297
- _context46.prev = 7;
4298
- _context46.next = 10;
4547
+ _context48.prev = 7;
4548
+ _context48.next = 10;
4299
4549
  return current;
4300
4550
  case 10:
4301
- result = _context46.sent;
4551
+ result = _context48.sent;
4302
4552
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
4303
4553
  queue_key: key,
4304
4554
  total_duration_ms: Date.now() - queuedAt,
@@ -4306,19 +4556,19 @@ var Server = /*#__PURE__*/function () {
4306
4556
  result_status: result === null || result === void 0 ? void 0 : result.status,
4307
4557
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
4308
4558
  }));
4309
- return _context46.abrupt("return", result);
4559
+ return _context48.abrupt("return", result);
4310
4560
  case 15:
4311
- _context46.prev = 15;
4312
- _context46.t0 = _context46["catch"](7);
4561
+ _context48.prev = 15;
4562
+ _context48.t0 = _context48["catch"](7);
4313
4563
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
4314
4564
  queue_key: key,
4315
4565
  total_duration_ms: Date.now() - queuedAt,
4316
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0),
4317
- error_detail: this.normalizeUnknownError(_context46.t0)
4566
+ error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0),
4567
+ error_detail: this.normalizeUnknownError(_context48.t0)
4318
4568
  }));
4319
- throw _context46.t0;
4569
+ throw _context48.t0;
4320
4570
  case 19:
4321
- _context46.prev = 19;
4571
+ _context48.prev = 19;
4322
4572
  released = false;
4323
4573
  if (this.localPaymentUpdateQueues.get(key) === tail) {
4324
4574
  this.localPaymentUpdateQueues.delete(key);
@@ -4329,14 +4579,14 @@ var Server = /*#__PURE__*/function () {
4329
4579
  released: released,
4330
4580
  active_queue_count: this.localPaymentUpdateQueues.size
4331
4581
  }));
4332
- return _context46.finish(19);
4582
+ return _context48.finish(19);
4333
4583
  case 24:
4334
4584
  case "end":
4335
- return _context46.stop();
4585
+ return _context48.stop();
4336
4586
  }
4337
- }, _callee46, this, [[7, 15, 19, 24]]);
4587
+ }, _callee48, this, [[7, 15, 19, 24]]);
4338
4588
  }));
4339
- function runLocalPaymentUpdateInQueue(_x48, _x49, _x50) {
4589
+ function runLocalPaymentUpdateInQueue(_x51, _x52, _x53) {
4340
4590
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
4341
4591
  }
4342
4592
  return runLocalPaymentUpdateInQueue;
@@ -4344,11 +4594,11 @@ var Server = /*#__PURE__*/function () {
4344
4594
  }, {
4345
4595
  key: "processLocalPaymentUpdate",
4346
4596
  value: function () {
4347
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
4597
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4348
4598
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
4349
4599
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
4350
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4351
- while (1) switch (_context47.prev = _context47.next) {
4600
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4601
+ while (1) switch (_context49.prev = _context49.next) {
4352
4602
  case 0:
4353
4603
  requestContext = {
4354
4604
  operation_id: params.operationId,
@@ -4361,11 +4611,11 @@ var Server = /*#__PURE__*/function () {
4361
4611
  };
4362
4612
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
4363
4613
  if (this.order) {
4364
- _context47.next = 5;
4614
+ _context49.next = 5;
4365
4615
  break;
4366
4616
  }
4367
4617
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
4368
- return _context47.abrupt("return", {
4618
+ return _context49.abrupt("return", {
4369
4619
  code: 500,
4370
4620
  status: false,
4371
4621
  message: 'Order 模块未注册',
@@ -4373,20 +4623,20 @@ var Server = /*#__PURE__*/function () {
4373
4623
  });
4374
4624
  case 5:
4375
4625
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
4376
- _context47.next = 8;
4626
+ _context49.next = 8;
4377
4627
  return this.order.getLocalPayment({
4378
4628
  saleId: params.saleId,
4379
4629
  paymentNumber: params.paymentNumber,
4380
4630
  operationId: params.operationId
4381
4631
  });
4382
4632
  case 8:
4383
- found = _context47.sent;
4633
+ found = _context49.sent;
4384
4634
  if (found) {
4385
- _context47.next = 12;
4635
+ _context49.next = 12;
4386
4636
  break;
4387
4637
  }
4388
4638
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
4389
- return _context47.abrupt("return", {
4639
+ return _context49.abrupt("return", {
4390
4640
  code: 404,
4391
4641
  status: false,
4392
4642
  message: '本地支付项不存在',
@@ -4435,13 +4685,13 @@ var Server = /*#__PURE__*/function () {
4435
4685
  });
4436
4686
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
4437
4687
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
4438
- _context47.next = 23;
4688
+ _context49.next = 23;
4439
4689
  break;
4440
4690
  }
4441
4691
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4442
4692
  idempotent_reason: 'ignore_failure_after_success'
4443
4693
  }));
4444
- return _context47.abrupt("return", {
4694
+ return _context49.abrupt("return", {
4445
4695
  code: 200,
4446
4696
  status: true,
4447
4697
  message: '',
@@ -4454,13 +4704,13 @@ var Server = /*#__PURE__*/function () {
4454
4704
  case 23:
4455
4705
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
4456
4706
  if (!alreadyRecordedFailure) {
4457
- _context47.next = 27;
4707
+ _context49.next = 27;
4458
4708
  break;
4459
4709
  }
4460
4710
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4461
4711
  idempotent_reason: 'failure_already_recorded'
4462
4712
  }));
4463
- return _context47.abrupt("return", {
4713
+ return _context49.abrupt("return", {
4464
4714
  code: 200,
4465
4715
  status: true,
4466
4716
  message: '',
@@ -4472,13 +4722,13 @@ var Server = /*#__PURE__*/function () {
4472
4722
  });
4473
4723
  case 27:
4474
4724
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
4475
- _context47.next = 30;
4725
+ _context49.next = 30;
4476
4726
  break;
4477
4727
  }
4478
4728
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4479
4729
  idempotent_reason: 'success_already_committed'
4480
4730
  }));
4481
- return _context47.abrupt("return", {
4731
+ return _context49.abrupt("return", {
4482
4732
  code: 200,
4483
4733
  status: true,
4484
4734
  message: '',
@@ -4490,13 +4740,13 @@ var Server = /*#__PURE__*/function () {
4490
4740
  });
4491
4741
  case 30:
4492
4742
  if (!(params.status === 'success')) {
4493
- _context47.next = 33;
4743
+ _context49.next = 33;
4494
4744
  break;
4495
4745
  }
4496
4746
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4497
4747
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
4498
4748
  }));
4499
- return _context47.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4749
+ return _context49.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4500
4750
  order: found.order,
4501
4751
  payment: found.payment,
4502
4752
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -4507,8 +4757,8 @@ var Server = /*#__PURE__*/function () {
4507
4757
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4508
4758
  incoming_payment_update: incomingPaymentUpdate
4509
4759
  }));
4510
- _context47.prev = 34;
4511
- _context47.next = 37;
4760
+ _context49.prev = 34;
4761
+ _context49.next = 37;
4512
4762
  return this.order.updateLocalPayment({
4513
4763
  saleId: params.saleId,
4514
4764
  paymentNumber: params.paymentNumber,
@@ -4516,25 +4766,25 @@ var Server = /*#__PURE__*/function () {
4516
4766
  updates: incomingPaymentUpdate
4517
4767
  });
4518
4768
  case 37:
4519
- updated = _context47.sent;
4520
- _context47.next = 44;
4769
+ updated = _context49.sent;
4770
+ _context49.next = 44;
4521
4771
  break;
4522
4772
  case 40:
4523
- _context47.prev = 40;
4524
- _context47.t0 = _context47["catch"](34);
4773
+ _context49.prev = 40;
4774
+ _context49.t0 = _context49["catch"](34);
4525
4775
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
4526
4776
  incoming_payment_update: incomingPaymentUpdate,
4527
- error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0),
4528
- error_detail: this.normalizeUnknownError(_context47.t0)
4777
+ error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0),
4778
+ error_detail: this.normalizeUnknownError(_context49.t0)
4529
4779
  }));
4530
- throw _context47.t0;
4780
+ throw _context49.t0;
4531
4781
  case 44:
4532
4782
  if (updated) {
4533
- _context47.next = 47;
4783
+ _context49.next = 47;
4534
4784
  break;
4535
4785
  }
4536
4786
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
4537
- return _context47.abrupt("return", {
4787
+ return _context49.abrupt("return", {
4538
4788
  code: 404,
4539
4789
  status: false,
4540
4790
  message: '本地支付项不存在',
@@ -4545,7 +4795,7 @@ var Server = /*#__PURE__*/function () {
4545
4795
  previous_payment: updated.previousPayment,
4546
4796
  payment: updated.payment
4547
4797
  }));
4548
- return _context47.abrupt("return", {
4798
+ return _context49.abrupt("return", {
4549
4799
  code: 200,
4550
4800
  status: true,
4551
4801
  message: '',
@@ -4557,11 +4807,11 @@ var Server = /*#__PURE__*/function () {
4557
4807
  });
4558
4808
  case 49:
4559
4809
  case "end":
4560
- return _context47.stop();
4810
+ return _context49.stop();
4561
4811
  }
4562
- }, _callee47, this, [[34, 40]]);
4812
+ }, _callee49, this, [[34, 40]]);
4563
4813
  }));
4564
- function processLocalPaymentUpdate(_x51) {
4814
+ function processLocalPaymentUpdate(_x54) {
4565
4815
  return _processLocalPaymentUpdate.apply(this, arguments);
4566
4816
  }
4567
4817
  return processLocalPaymentUpdate;
@@ -4569,10 +4819,10 @@ var Server = /*#__PURE__*/function () {
4569
4819
  }, {
4570
4820
  key: "processSuccessfulLocalPayment",
4571
4821
  value: function () {
4572
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4822
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4573
4823
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
4574
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4575
- while (1) switch (_context48.prev = _context48.next) {
4824
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4825
+ while (1) switch (_context50.prev = _context50.next) {
4576
4826
  case 0:
4577
4827
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
4578
4828
  baseSales = new BaseSalesImpl(moduleName);
@@ -4591,13 +4841,13 @@ var Server = /*#__PURE__*/function () {
4591
4841
  payment: params.payment
4592
4842
  });
4593
4843
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
4594
- _context48.prev = 5;
4844
+ _context50.prev = 5;
4595
4845
  order = this.sanitizeLocalRecoveryOrder(params.order);
4596
4846
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4597
4847
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
4598
4848
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
4599
4849
  }));
4600
- _context48.next = 10;
4850
+ _context50.next = 10;
4601
4851
  return baseSales.initialize(this.core, {
4602
4852
  otherParams: {
4603
4853
  platform: order.platform,
@@ -4610,7 +4860,7 @@ var Server = /*#__PURE__*/function () {
4610
4860
  });
4611
4861
  case 10:
4612
4862
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
4613
- _context48.next = 13;
4863
+ _context50.next = 13;
4614
4864
  return baseSales.loadSalesDetail({
4615
4865
  externalSaleNumber: String(params.saleId),
4616
4866
  preloadedSalesDetail: order
@@ -4620,7 +4870,7 @@ var Server = /*#__PURE__*/function () {
4620
4870
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4621
4871
  incoming_payment_update: params.paymentUpdate
4622
4872
  }));
4623
- _context48.next = 17;
4873
+ _context50.next = 17;
4624
4874
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
4625
4875
  submitWhenPaid: true,
4626
4876
  matchBy: params.matchBy,
@@ -4629,7 +4879,7 @@ var Server = /*#__PURE__*/function () {
4629
4879
  smallTicketDataFlag: 1
4630
4880
  });
4631
4881
  case 17:
4632
- result = _context48.sent;
4882
+ result = _context50.sent;
4633
4883
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4634
4884
  duration_ms: Date.now() - startedAt,
4635
4885
  payment: result.payment,
@@ -4651,7 +4901,7 @@ var Server = /*#__PURE__*/function () {
4651
4901
  } : null,
4652
4902
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
4653
4903
  }));
4654
- return _context48.abrupt("return", {
4904
+ return _context50.abrupt("return", {
4655
4905
  code: 200,
4656
4906
  status: true,
4657
4907
  message: '',
@@ -4663,48 +4913,48 @@ var Server = /*#__PURE__*/function () {
4663
4913
  }
4664
4914
  });
4665
4915
  case 22:
4666
- _context48.prev = 22;
4667
- _context48.t0 = _context48["catch"](5);
4668
- message = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4916
+ _context50.prev = 22;
4917
+ _context50.t0 = _context50["catch"](5);
4918
+ message = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
4669
4919
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4670
4920
  duration_ms: Date.now() - startedAt,
4671
4921
  error: message,
4672
- error_detail: this.normalizeUnknownError(_context48.t0)
4922
+ error_detail: this.normalizeUnknownError(_context50.t0)
4673
4923
  }));
4674
- return _context48.abrupt("return", {
4924
+ return _context50.abrupt("return", {
4675
4925
  code: 500,
4676
4926
  status: false,
4677
4927
  message: message,
4678
4928
  data: null
4679
4929
  });
4680
4930
  case 27:
4681
- _context48.prev = 27;
4682
- _context48.prev = 28;
4683
- _context48.next = 31;
4931
+ _context50.prev = 27;
4932
+ _context50.prev = 28;
4933
+ _context50.next = 31;
4684
4934
  return baseSales.destroy();
4685
4935
  case 31:
4686
4936
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4687
4937
  duration_ms: Date.now() - startedAt
4688
4938
  }));
4689
- _context48.next = 37;
4939
+ _context50.next = 37;
4690
4940
  break;
4691
4941
  case 34:
4692
- _context48.prev = 34;
4693
- _context48.t1 = _context48["catch"](28);
4942
+ _context50.prev = 34;
4943
+ _context50.t1 = _context50["catch"](28);
4694
4944
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4695
4945
  duration_ms: Date.now() - startedAt,
4696
- error: _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1),
4697
- error_detail: this.normalizeUnknownError(_context48.t1)
4946
+ error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1),
4947
+ error_detail: this.normalizeUnknownError(_context50.t1)
4698
4948
  }));
4699
4949
  case 37:
4700
- return _context48.finish(27);
4950
+ return _context50.finish(27);
4701
4951
  case 38:
4702
4952
  case "end":
4703
- return _context48.stop();
4953
+ return _context50.stop();
4704
4954
  }
4705
- }, _callee48, this, [[5, 22, 27, 38], [28, 34]]);
4955
+ }, _callee50, this, [[5, 22, 27, 38], [28, 34]]);
4706
4956
  }));
4707
- function processSuccessfulLocalPayment(_x52) {
4957
+ function processSuccessfulLocalPayment(_x55) {
4708
4958
  return _processSuccessfulLocalPayment.apply(this, arguments);
4709
4959
  }
4710
4960
  return processSuccessfulLocalPayment;
@@ -4790,32 +5040,32 @@ var Server = /*#__PURE__*/function () {
4790
5040
  }, {
4791
5041
  key: "getShortNumberOrDeviceId",
4792
5042
  value: function () {
4793
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
5043
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
4794
5044
  var getAsyncIotDeviceInfo, res;
4795
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4796
- while (1) switch (_context49.prev = _context49.next) {
5045
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5046
+ while (1) switch (_context51.prev = _context51.next) {
4797
5047
  case 0:
4798
5048
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
4799
5049
  if (!getAsyncIotDeviceInfo) {
4800
- _context49.next = 7;
5050
+ _context51.next = 7;
4801
5051
  break;
4802
5052
  }
4803
- _context49.next = 4;
5053
+ _context51.next = 4;
4804
5054
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
4805
5055
  case 4:
4806
- res = _context49.sent;
5056
+ res = _context51.sent;
4807
5057
  if (!(res !== null && res !== void 0 && res.short_number)) {
4808
- _context49.next = 7;
5058
+ _context51.next = 7;
4809
5059
  break;
4810
5060
  }
4811
- return _context49.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5061
+ return _context51.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
4812
5062
  case 7:
4813
- return _context49.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5063
+ return _context51.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
4814
5064
  case 8:
4815
5065
  case "end":
4816
- return _context49.stop();
5066
+ return _context51.stop();
4817
5067
  }
4818
- }, _callee49, this);
5068
+ }, _callee51, this);
4819
5069
  }));
4820
5070
  function getShortNumberOrDeviceId() {
4821
5071
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -4842,16 +5092,16 @@ var Server = /*#__PURE__*/function () {
4842
5092
  }, {
4843
5093
  key: "normalizeCheckoutSubmitData",
4844
5094
  value: function () {
4845
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data, title) {
5095
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data, title) {
4846
5096
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
4847
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4848
- while (1) switch (_context50.prev = _context50.next) {
5097
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5098
+ while (1) switch (_context52.prev = _context52.next) {
4849
5099
  case 0:
4850
5100
  if (!(!data || _typeof(data) !== 'object')) {
4851
- _context50.next = 2;
5101
+ _context52.next = 2;
4852
5102
  break;
4853
5103
  }
4854
- return _context50.abrupt("return", data);
5104
+ return _context52.abrupt("return", data);
4855
5105
  case 2:
4856
5106
  next = _objectSpread({}, data);
4857
5107
  externalSaleNumber = next.external_sale_number;
@@ -4861,7 +5111,7 @@ var Server = /*#__PURE__*/function () {
4861
5111
  delete next.vouchers;
4862
5112
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
4863
5113
  if (!hasCheckoutOrderNumbers) {
4864
- _context50.next = 11;
5114
+ _context52.next = 11;
4865
5115
  break;
4866
5116
  }
4867
5117
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -4871,10 +5121,10 @@ var Server = /*#__PURE__*/function () {
4871
5121
  shop_order_number: next.shop_order_number,
4872
5122
  shop_full_order_number: next.shop_full_order_number
4873
5123
  });
4874
- return _context50.abrupt("return", next);
5124
+ return _context52.abrupt("return", next);
4875
5125
  case 11:
4876
5126
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
4877
- _context50.next = 14;
5127
+ _context52.next = 14;
4878
5128
  break;
4879
5129
  }
4880
5130
  if (shouldClearLocalOrderId) {
@@ -4883,10 +5133,10 @@ var Server = /*#__PURE__*/function () {
4883
5133
  order_id: next.order_id
4884
5134
  });
4885
5135
  }
4886
- return _context50.abrupt("return", next);
5136
+ return _context52.abrupt("return", next);
4887
5137
  case 14:
4888
5138
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
4889
- _context50.next = 17;
5139
+ _context52.next = 17;
4890
5140
  break;
4891
5141
  }
4892
5142
  if (shouldClearLocalOrderId) {
@@ -4895,12 +5145,12 @@ var Server = /*#__PURE__*/function () {
4895
5145
  external_sale_number: externalSaleNumber
4896
5146
  });
4897
5147
  }
4898
- return _context50.abrupt("return", next);
5148
+ return _context52.abrupt("return", next);
4899
5149
  case 17:
4900
- _context50.prev = 17;
5150
+ _context52.prev = 17;
4901
5151
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
4902
5152
  if (localOrder) {
4903
- _context50.next = 22;
5153
+ _context52.next = 22;
4904
5154
  break;
4905
5155
  }
4906
5156
  if (shouldClearLocalOrderId) {
@@ -4910,7 +5160,7 @@ var Server = /*#__PURE__*/function () {
4910
5160
  localOrderFound: false
4911
5161
  });
4912
5162
  }
4913
- return _context50.abrupt("return", next);
5163
+ return _context52.abrupt("return", next);
4914
5164
  case 22:
4915
5165
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
4916
5166
  next.shop_order_number = localOrder.shop_order_number;
@@ -4927,23 +5177,23 @@ var Server = /*#__PURE__*/function () {
4927
5177
  shop_full_order_number: next.shop_full_order_number
4928
5178
  });
4929
5179
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
4930
- return _context50.abrupt("return", next);
5180
+ return _context52.abrupt("return", next);
4931
5181
  case 28:
4932
- _context50.prev = 28;
4933
- _context50.t0 = _context50["catch"](17);
5182
+ _context52.prev = 28;
5183
+ _context52.t0 = _context52["catch"](17);
4934
5184
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
4935
5185
  external_sale_number: externalSaleNumber,
4936
- error: this.getUnknownErrorMessage(_context50.t0),
4937
- error_detail: this.normalizeUnknownError(_context50.t0)
5186
+ error: this.getUnknownErrorMessage(_context52.t0),
5187
+ error_detail: this.normalizeUnknownError(_context52.t0)
4938
5188
  });
4939
- return _context50.abrupt("return", next);
5189
+ return _context52.abrupt("return", next);
4940
5190
  case 32:
4941
5191
  case "end":
4942
- return _context50.stop();
5192
+ return _context52.stop();
4943
5193
  }
4944
- }, _callee50, this, [[17, 28]]);
5194
+ }, _callee52, this, [[17, 28]]);
4945
5195
  }));
4946
- function normalizeCheckoutSubmitData(_x53, _x54) {
5196
+ function normalizeCheckoutSubmitData(_x56, _x57) {
4947
5197
  return _normalizeCheckoutSubmitData.apply(this, arguments);
4948
5198
  }
4949
5199
  return normalizeCheckoutSubmitData;
@@ -4951,81 +5201,81 @@ var Server = /*#__PURE__*/function () {
4951
5201
  }, {
4952
5202
  key: "ensureCheckoutOrderNumbers",
4953
5203
  value: function () {
4954
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(data, title) {
5204
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data, title) {
4955
5205
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
4956
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4957
- while (1) switch (_context51.prev = _context51.next) {
5206
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5207
+ while (1) switch (_context53.prev = _context53.next) {
4958
5208
  case 0:
4959
5209
  if (!(!data || _typeof(data) !== 'object')) {
4960
- _context51.next = 2;
5210
+ _context53.next = 2;
4961
5211
  break;
4962
5212
  }
4963
- return _context51.abrupt("return", data);
5213
+ return _context53.abrupt("return", data);
4964
5214
  case 2:
4965
5215
  next = _objectSpread({}, data);
4966
5216
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
4967
5217
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
4968
5218
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
4969
- _context51.next = 7;
5219
+ _context53.next = 7;
4970
5220
  break;
4971
5221
  }
4972
- return _context51.abrupt("return", next);
5222
+ return _context53.abrupt("return", next);
4973
5223
  case 7:
4974
5224
  idGenerator = this.getIdGeneratorPlugin();
4975
5225
  if (idGenerator) {
4976
- _context51.next = 11;
5226
+ _context53.next = 11;
4977
5227
  break;
4978
5228
  }
4979
5229
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
4980
5230
  needsShopOrderNumber: needsShopOrderNumber,
4981
5231
  needsShopFullOrderNumber: needsShopFullOrderNumber
4982
5232
  });
4983
- return _context51.abrupt("return", next);
5233
+ return _context53.abrupt("return", next);
4984
5234
  case 11:
4985
- _context51.prev = 11;
5235
+ _context53.prev = 11;
4986
5236
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
4987
- _context51.next = 16;
5237
+ _context53.next = 16;
4988
5238
  break;
4989
5239
  }
4990
- _context51.next = 15;
5240
+ _context53.next = 15;
4991
5241
  return idGenerator.generateShopOrderNumber({
4992
5242
  biz: next.business_code || 'ticket'
4993
5243
  });
4994
5244
  case 15:
4995
- next.shop_order_number = _context51.sent;
5245
+ next.shop_order_number = _context53.sent;
4996
5246
  case 16:
4997
5247
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
4998
- _context51.next = 20;
5248
+ _context53.next = 20;
4999
5249
  break;
5000
5250
  }
5001
- _context51.next = 19;
5251
+ _context53.next = 19;
5002
5252
  return idGenerator.generateReceiptId({
5003
5253
  biz: next.business_code || 'ticket'
5004
5254
  });
5005
5255
  case 19:
5006
- next.shop_full_order_number = _context51.sent;
5256
+ next.shop_full_order_number = _context53.sent;
5007
5257
  case 20:
5008
5258
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
5009
5259
  shop_order_number: next.shop_order_number,
5010
5260
  shop_full_order_number: next.shop_full_order_number
5011
5261
  });
5012
- _context51.next = 26;
5262
+ _context53.next = 26;
5013
5263
  break;
5014
5264
  case 23:
5015
- _context51.prev = 23;
5016
- _context51.t0 = _context51["catch"](11);
5265
+ _context53.prev = 23;
5266
+ _context53.t0 = _context53["catch"](11);
5017
5267
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
5018
- error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
5268
+ error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
5019
5269
  });
5020
5270
  case 26:
5021
- return _context51.abrupt("return", next);
5271
+ return _context53.abrupt("return", next);
5022
5272
  case 27:
5023
5273
  case "end":
5024
- return _context51.stop();
5274
+ return _context53.stop();
5025
5275
  }
5026
- }, _callee51, this, [[11, 23]]);
5276
+ }, _callee53, this, [[11, 23]]);
5027
5277
  }));
5028
- function ensureCheckoutOrderNumbers(_x55, _x56) {
5278
+ function ensureCheckoutOrderNumbers(_x58, _x59) {
5029
5279
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
5030
5280
  }
5031
5281
  return ensureCheckoutOrderNumbers;
@@ -5033,27 +5283,27 @@ var Server = /*#__PURE__*/function () {
5033
5283
  }, {
5034
5284
  key: "dispatchCheckoutSyncTask",
5035
5285
  value: function () {
5036
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5286
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5037
5287
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
5038
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5039
- while (1) switch (_context52.prev = _context52.next) {
5288
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5289
+ while (1) switch (_context54.prev = _context54.next) {
5040
5290
  case 0:
5041
5291
  this.registerDeviceTaskActions();
5042
5292
  deviceTask = this.getDeviceTaskPlugin();
5043
- _context52.next = 4;
5293
+ _context54.next = 4;
5044
5294
  return this.getShortNumberOrDeviceId();
5045
5295
  case 4:
5046
- debugDeviceId = _context52.sent;
5296
+ debugDeviceId = _context54.sent;
5047
5297
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
5048
5298
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5049
- _context52.next = 9;
5299
+ _context54.next = 9;
5050
5300
  break;
5051
5301
  }
5052
5302
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
5053
- return _context52.abrupt("return");
5303
+ return _context54.abrupt("return");
5054
5304
  case 9:
5055
- _context52.prev = 9;
5056
- _context52.next = 12;
5305
+ _context54.prev = 9;
5306
+ _context54.next = 12;
5057
5307
  return deviceTask.dispatch({
5058
5308
  action: 'sync_sales',
5059
5309
  device_id: debugDeviceId,
@@ -5071,27 +5321,27 @@ var Server = /*#__PURE__*/function () {
5071
5321
  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)
5072
5322
  });
5073
5323
  case 12:
5074
- result = _context52.sent;
5324
+ result = _context54.sent;
5075
5325
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
5076
5326
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
5077
5327
  status: result === null || result === void 0 ? void 0 : result.status,
5078
5328
  reused: result === null || result === void 0 ? void 0 : result.reused
5079
5329
  });
5080
- _context52.next = 19;
5330
+ _context54.next = 19;
5081
5331
  break;
5082
5332
  case 16:
5083
- _context52.prev = 16;
5084
- _context52.t0 = _context52["catch"](9);
5333
+ _context54.prev = 16;
5334
+ _context54.t0 = _context54["catch"](9);
5085
5335
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
5086
- error: _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0)
5336
+ error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0)
5087
5337
  });
5088
5338
  case 19:
5089
5339
  case "end":
5090
- return _context52.stop();
5340
+ return _context54.stop();
5091
5341
  }
5092
- }, _callee52, this, [[9, 16]]);
5342
+ }, _callee54, this, [[9, 16]]);
5093
5343
  }));
5094
- function dispatchCheckoutSyncTask(_x57) {
5344
+ function dispatchCheckoutSyncTask(_x60) {
5095
5345
  return _dispatchCheckoutSyncTask.apply(this, arguments);
5096
5346
  }
5097
5347
  return dispatchCheckoutSyncTask;
@@ -5099,26 +5349,26 @@ var Server = /*#__PURE__*/function () {
5099
5349
  }, {
5100
5350
  key: "dispatchPrintOtherReceiptTask",
5101
5351
  value: function () {
5102
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5352
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5103
5353
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
5104
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5105
- while (1) switch (_context53.prev = _context53.next) {
5354
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5355
+ while (1) switch (_context55.prev = _context55.next) {
5106
5356
  case 0:
5107
5357
  deviceTask = this.getDeviceTaskPlugin();
5108
5358
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5109
- _context53.next = 4;
5359
+ _context55.next = 4;
5110
5360
  break;
5111
5361
  }
5112
5362
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
5113
- return _context53.abrupt("return");
5363
+ return _context55.abrupt("return");
5114
5364
  case 4:
5115
- _context53.prev = 4;
5365
+ _context55.prev = 4;
5116
5366
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
5117
- _context53.next = 8;
5367
+ _context55.next = 8;
5118
5368
  return this.getShortNumberOrDeviceId();
5119
5369
  case 8:
5120
- deviceId = _context53.sent;
5121
- _context53.next = 11;
5370
+ deviceId = _context55.sent;
5371
+ _context55.next = 11;
5122
5372
  return deviceTask.dispatch({
5123
5373
  action: 'print_all',
5124
5374
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -5145,21 +5395,21 @@ var Server = /*#__PURE__*/function () {
5145
5395
  source_id: printIdentity
5146
5396
  });
5147
5397
  case 11:
5148
- _context53.next = 16;
5398
+ _context55.next = 16;
5149
5399
  break;
5150
5400
  case 13:
5151
- _context53.prev = 13;
5152
- _context53.t0 = _context53["catch"](4);
5401
+ _context55.prev = 13;
5402
+ _context55.t0 = _context55["catch"](4);
5153
5403
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
5154
- error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
5404
+ error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5155
5405
  });
5156
5406
  case 16:
5157
5407
  case "end":
5158
- return _context53.stop();
5408
+ return _context55.stop();
5159
5409
  }
5160
- }, _callee53, this, [[4, 13]]);
5410
+ }, _callee55, this, [[4, 13]]);
5161
5411
  }));
5162
- function dispatchPrintOtherReceiptTask(_x58) {
5412
+ function dispatchPrintOtherReceiptTask(_x61) {
5163
5413
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
5164
5414
  }
5165
5415
  return dispatchPrintOtherReceiptTask;
@@ -5179,32 +5429,32 @@ var Server = /*#__PURE__*/function () {
5179
5429
  }, {
5180
5430
  key: "dispatchLocalReceiptPrint",
5181
5431
  value: function () {
5182
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5432
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5183
5433
  var _payment_info;
5184
5434
  var printableOrder;
5185
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5186
- while (1) switch (_context54.prev = _context54.next) {
5435
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5436
+ while (1) switch (_context56.prev = _context56.next) {
5187
5437
  case 0:
5188
5438
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
5189
- _context54.next = 2;
5439
+ _context56.next = 2;
5190
5440
  break;
5191
5441
  }
5192
- return _context54.abrupt("return", {
5442
+ return _context56.abrupt("return", {
5193
5443
  printed: false,
5194
5444
  order: params.order
5195
5445
  });
5196
5446
  case 2:
5197
- _context54.next = 4;
5447
+ _context56.next = 4;
5198
5448
  return this.withLocalSmallTicketData(params.order, {
5199
5449
  requireFullyPaid: params.requireFullyPaid
5200
5450
  });
5201
5451
  case 4:
5202
- printableOrder = _context54.sent;
5452
+ printableOrder = _context56.sent;
5203
5453
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
5204
- _context54.next = 7;
5454
+ _context56.next = 7;
5205
5455
  break;
5206
5456
  }
5207
- return _context54.abrupt("return", {
5457
+ return _context56.abrupt("return", {
5208
5458
  printed: false,
5209
5459
  order: printableOrder
5210
5460
  });
@@ -5214,7 +5464,7 @@ var Server = /*#__PURE__*/function () {
5214
5464
  printableOrder: printableOrder,
5215
5465
  response: params.response
5216
5466
  });
5217
- _context54.next = 10;
5467
+ _context56.next = 10;
5218
5468
  return this.dispatchPrintOtherReceiptTask({
5219
5469
  checkoutData: params.checkoutData,
5220
5470
  syncedOrder: printableOrder,
@@ -5223,17 +5473,17 @@ var Server = /*#__PURE__*/function () {
5223
5473
  isManualPrint: params.isManualPrint
5224
5474
  });
5225
5475
  case 10:
5226
- return _context54.abrupt("return", {
5476
+ return _context56.abrupt("return", {
5227
5477
  printed: true,
5228
5478
  order: printableOrder
5229
5479
  });
5230
5480
  case 11:
5231
5481
  case "end":
5232
- return _context54.stop();
5482
+ return _context56.stop();
5233
5483
  }
5234
- }, _callee54, this);
5484
+ }, _callee56, this);
5235
5485
  }));
5236
- function dispatchLocalReceiptPrint(_x59) {
5486
+ function dispatchLocalReceiptPrint(_x62) {
5237
5487
  return _dispatchLocalReceiptPrint.apply(this, arguments);
5238
5488
  }
5239
5489
  return dispatchLocalReceiptPrint;
@@ -5268,47 +5518,47 @@ var Server = /*#__PURE__*/function () {
5268
5518
  }, {
5269
5519
  key: "syncMachinecodeRedeemStatusToLocalOrder",
5270
5520
  value: function () {
5271
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, ids, status) {
5521
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data, ids, status) {
5272
5522
  var _this$order3;
5273
5523
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
5274
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5275
- while (1) switch (_context55.prev = _context55.next) {
5524
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5525
+ while (1) switch (_context57.prev = _context57.next) {
5276
5526
  case 0:
5277
5527
  title = 'handleMachinecodeBatchMetadata';
5278
5528
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
5279
5529
  if (!(lookup === undefined)) {
5280
- _context55.next = 5;
5530
+ _context57.next = 5;
5281
5531
  break;
5282
5532
  }
5283
5533
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5284
5534
  batchSize: ids.length,
5285
5535
  status: status
5286
5536
  });
5287
- return _context55.abrupt("return");
5537
+ return _context57.abrupt("return");
5288
5538
  case 5:
5289
5539
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
5290
- _context55.next = 8;
5540
+ _context57.next = 8;
5291
5541
  break;
5292
5542
  }
5293
5543
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5294
5544
  lookup: lookup,
5295
5545
  status: status
5296
5546
  });
5297
- return _context55.abrupt("return");
5547
+ return _context57.abrupt("return");
5298
5548
  case 8:
5299
- _context55.next = 10;
5549
+ _context57.next = 10;
5300
5550
  return this.order.getLocalOrderByLookup(lookup);
5301
5551
  case 10:
5302
- localOrder = _context55.sent;
5552
+ localOrder = _context57.sent;
5303
5553
  if (localOrder) {
5304
- _context55.next = 14;
5554
+ _context57.next = 14;
5305
5555
  break;
5306
5556
  }
5307
5557
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5308
5558
  lookup: lookup,
5309
5559
  status: status
5310
5560
  });
5311
- return _context55.abrupt("return");
5561
+ return _context57.abrupt("return");
5312
5562
  case 14:
5313
5563
  voucherIdSet = new Set(ids.filter(function (id) {
5314
5564
  return id !== undefined && id !== null && id !== '';
@@ -5316,14 +5566,14 @@ var Server = /*#__PURE__*/function () {
5316
5566
  return String(id);
5317
5567
  }));
5318
5568
  if (!(voucherIdSet.size === 0)) {
5319
- _context55.next = 18;
5569
+ _context57.next = 18;
5320
5570
  break;
5321
5571
  }
5322
5572
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5323
5573
  lookup: lookup,
5324
5574
  status: status
5325
5575
  });
5326
- return _context55.abrupt("return");
5576
+ return _context57.abrupt("return");
5327
5577
  case 18:
5328
5578
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
5329
5579
  hasUpdatedVoucher = false;
@@ -5337,7 +5587,7 @@ var Server = /*#__PURE__*/function () {
5337
5587
  });
5338
5588
  });
5339
5589
  if (hasUpdatedVoucher) {
5340
- _context55.next = 24;
5590
+ _context57.next = 24;
5341
5591
  break;
5342
5592
  }
5343
5593
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -5345,13 +5595,13 @@ var Server = /*#__PURE__*/function () {
5345
5595
  voucher_ids: Array.from(voucherIdSet),
5346
5596
  status: status
5347
5597
  });
5348
- return _context55.abrupt("return");
5598
+ return _context57.abrupt("return");
5349
5599
  case 24:
5350
5600
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
5351
- _context55.next = 29;
5601
+ _context57.next = 29;
5352
5602
  break;
5353
5603
  }
5354
- _context55.next = 27;
5604
+ _context57.next = 27;
5355
5605
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
5356
5606
  vouchers: nextVouchers
5357
5607
  }));
@@ -5361,13 +5611,13 @@ var Server = /*#__PURE__*/function () {
5361
5611
  updatedCount: voucherIdSet.size,
5362
5612
  status: status
5363
5613
  });
5364
- return _context55.abrupt("return");
5614
+ return _context57.abrupt("return");
5365
5615
  case 29:
5366
5616
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
5367
- _context55.next = 34;
5617
+ _context57.next = 34;
5368
5618
  break;
5369
5619
  }
5370
- _context55.next = 32;
5620
+ _context57.next = 32;
5371
5621
  return this.order.markOrderSyncedByExternalSaleNumber({
5372
5622
  externalSaleNumber: data.external_sale_number,
5373
5623
  patch: {
@@ -5380,7 +5630,7 @@ var Server = /*#__PURE__*/function () {
5380
5630
  updatedCount: voucherIdSet.size,
5381
5631
  status: status
5382
5632
  });
5383
- return _context55.abrupt("return");
5633
+ return _context57.abrupt("return");
5384
5634
  case 34:
5385
5635
  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"), {
5386
5636
  lookup: lookup,
@@ -5388,11 +5638,11 @@ var Server = /*#__PURE__*/function () {
5388
5638
  });
5389
5639
  case 35:
5390
5640
  case "end":
5391
- return _context55.stop();
5641
+ return _context57.stop();
5392
5642
  }
5393
- }, _callee55, this);
5643
+ }, _callee57, this);
5394
5644
  }));
5395
- function syncMachinecodeRedeemStatusToLocalOrder(_x60, _x61, _x62) {
5645
+ function syncMachinecodeRedeemStatusToLocalOrder(_x63, _x64, _x65) {
5396
5646
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
5397
5647
  }
5398
5648
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -5400,10 +5650,10 @@ var Server = /*#__PURE__*/function () {
5400
5650
  }, {
5401
5651
  key: "handleOrderCheckoutSubmit",
5402
5652
  value: function () {
5403
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5653
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5404
5654
  var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
5405
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5406
- while (1) switch (_context56.prev = _context56.next) {
5655
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5656
+ while (1) switch (_context58.prev = _context58.next) {
5407
5657
  case 0:
5408
5658
  backendPath = params.backendPath, data = params.data, title = params.title;
5409
5659
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5413,24 +5663,24 @@ var Server = /*#__PURE__*/function () {
5413
5663
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5414
5664
  });
5415
5665
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5416
- _context56.next = 4;
5666
+ _context58.next = 4;
5417
5667
  break;
5418
5668
  }
5419
- return _context56.abrupt("return", this.handleSyncCheckoutSubmit({
5669
+ return _context58.abrupt("return", this.handleSyncCheckoutSubmit({
5420
5670
  backendPath: backendPath,
5421
5671
  data: data,
5422
5672
  title: title
5423
5673
  }));
5424
5674
  case 4:
5425
- _context56.next = 6;
5675
+ _context58.next = 6;
5426
5676
  return this.normalizeCheckoutSubmitData(data, title);
5427
5677
  case 6:
5428
- normalizedData = _context56.sent;
5429
- _context56.next = 9;
5678
+ normalizedData = _context58.sent;
5679
+ _context58.next = 9;
5430
5680
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
5431
5681
  case 9:
5432
- checkoutData = _context56.sent;
5433
- _context56.next = 12;
5682
+ checkoutData = _context58.sent;
5683
+ _context58.next = 12;
5434
5684
  return this.handlePendingSyncCheckoutOrder({
5435
5685
  backendPath: backendPath,
5436
5686
  data: checkoutData,
@@ -5438,9 +5688,9 @@ var Server = /*#__PURE__*/function () {
5438
5688
  reason: 'checkout 已转入设备任务同步'
5439
5689
  });
5440
5690
  case 12:
5441
- pendingResult = _context56.sent;
5691
+ pendingResult = _context58.sent;
5442
5692
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5443
- _context56.next = 20;
5693
+ _context58.next = 20;
5444
5694
  break;
5445
5695
  }
5446
5696
  pendingOrder = pendingResult.data;
@@ -5448,10 +5698,10 @@ var Server = /*#__PURE__*/function () {
5448
5698
  // TODO 这里先加个兼容,只有 type 为 virtual 才走打印
5449
5699
  // 后期需要迁移到 picoding ,根据工作流配置
5450
5700
  checkoutData.type === 'virtual')) {
5451
- _context56.next = 18;
5701
+ _context58.next = 18;
5452
5702
  break;
5453
5703
  }
5454
- _context56.next = 18;
5704
+ _context58.next = 18;
5455
5705
  return this.dispatchLocalReceiptPrint({
5456
5706
  checkoutData: checkoutData,
5457
5707
  order: pendingOrder,
@@ -5459,7 +5709,7 @@ var Server = /*#__PURE__*/function () {
5459
5709
  requireFullyPaid: true
5460
5710
  });
5461
5711
  case 18:
5462
- _context56.next = 20;
5712
+ _context58.next = 20;
5463
5713
  return this.dispatchCheckoutSyncTask({
5464
5714
  backendPath: backendPath,
5465
5715
  data: checkoutData,
@@ -5467,23 +5717,23 @@ var Server = /*#__PURE__*/function () {
5467
5717
  });
5468
5718
  case 20:
5469
5719
  if (pendingResult.data.order_id) {
5470
- _context56.next = 22;
5720
+ _context58.next = 22;
5471
5721
  break;
5472
5722
  }
5473
- return _context56.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5723
+ return _context58.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5474
5724
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
5475
5725
  order_id: pendingResult.data.external_sale_number
5476
5726
  })
5477
5727
  }));
5478
5728
  case 22:
5479
- return _context56.abrupt("return", pendingResult);
5729
+ return _context58.abrupt("return", pendingResult);
5480
5730
  case 23:
5481
5731
  case "end":
5482
- return _context56.stop();
5732
+ return _context58.stop();
5483
5733
  }
5484
- }, _callee56, this);
5734
+ }, _callee58, this);
5485
5735
  }));
5486
- function handleOrderCheckoutSubmit(_x63) {
5736
+ function handleOrderCheckoutSubmit(_x66) {
5487
5737
  return _handleOrderCheckoutSubmit.apply(this, arguments);
5488
5738
  }
5489
5739
  return handleOrderCheckoutSubmit;
@@ -5491,27 +5741,27 @@ var Server = /*#__PURE__*/function () {
5491
5741
  }, {
5492
5742
  key: "handleSyncCheckoutSubmit",
5493
5743
  value: function () {
5494
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5744
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5495
5745
  var _this$app16;
5496
5746
  var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
5497
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5498
- while (1) switch (_context57.prev = _context57.next) {
5747
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5748
+ while (1) switch (_context59.prev = _context59.next) {
5499
5749
  case 0:
5500
5750
  backendPath = params.backendPath, data = params.data, title = params.title;
5501
5751
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
5502
- _context57.next = 4;
5752
+ _context59.next = 4;
5503
5753
  break;
5504
5754
  }
5505
5755
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
5506
- return _context57.abrupt("return", {
5756
+ return _context59.abrupt("return", {
5507
5757
  code: 500,
5508
5758
  status: false,
5509
5759
  message: 'app.request 不可用',
5510
5760
  data: null
5511
5761
  });
5512
5762
  case 4:
5513
- _context57.prev = 4;
5514
- _context57.next = 7;
5763
+ _context59.prev = 4;
5764
+ _context59.next = 7;
5515
5765
  return this.runCheckoutSync({
5516
5766
  backendPath: backendPath,
5517
5767
  data: data,
@@ -5519,41 +5769,41 @@ var Server = /*#__PURE__*/function () {
5519
5769
  persistCheckoutDataWithResponse: true
5520
5770
  });
5521
5771
  case 7:
5522
- syncResult = _context57.sent;
5772
+ syncResult = _context59.sent;
5523
5773
  if (!syncResult.rejected) {
5524
- _context57.next = 11;
5774
+ _context59.next = 11;
5525
5775
  break;
5526
5776
  }
5527
5777
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
5528
- return _context57.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5778
+ return _context59.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5529
5779
  status: false,
5530
5780
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
5531
5781
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
5532
5782
  }));
5533
5783
  case 11:
5534
- return _context57.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
5784
+ return _context59.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
5535
5785
  case 14:
5536
- _context57.prev = 14;
5537
- _context57.t0 = _context57["catch"](4);
5538
- backendError = this.extractBackendErrorResponse(_context57.t0);
5786
+ _context59.prev = 14;
5787
+ _context59.t0 = _context59["catch"](4);
5788
+ backendError = this.extractBackendErrorResponse(_context59.t0);
5539
5789
  if (!backendError) {
5540
- _context57.next = 20;
5790
+ _context59.next = 20;
5541
5791
  break;
5542
5792
  }
5543
5793
  _normalized = this.normalizeCheckoutResponse(backendError);
5544
- return _context57.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5794
+ return _context59.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5545
5795
  status: false,
5546
5796
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
5547
5797
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
5548
5798
  }));
5549
5799
  case 20:
5550
- message = this.getUnknownErrorMessage(_context57.t0);
5800
+ message = this.getUnknownErrorMessage(_context59.t0);
5551
5801
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
5552
5802
  backendPath: backendPath,
5553
5803
  error: message,
5554
- error_detail: this.normalizeUnknownError(_context57.t0)
5804
+ error_detail: this.normalizeUnknownError(_context59.t0)
5555
5805
  });
5556
- return _context57.abrupt("return", {
5806
+ return _context59.abrupt("return", {
5557
5807
  code: 500,
5558
5808
  status: false,
5559
5809
  message: message,
@@ -5561,11 +5811,11 @@ var Server = /*#__PURE__*/function () {
5561
5811
  });
5562
5812
  case 23:
5563
5813
  case "end":
5564
- return _context57.stop();
5814
+ return _context59.stop();
5565
5815
  }
5566
- }, _callee57, this, [[4, 14]]);
5816
+ }, _callee59, this, [[4, 14]]);
5567
5817
  }));
5568
- function handleSyncCheckoutSubmit(_x64) {
5818
+ function handleSyncCheckoutSubmit(_x67) {
5569
5819
  return _handleSyncCheckoutSubmit.apply(this, arguments);
5570
5820
  }
5571
5821
  return handleSyncCheckoutSubmit;
@@ -5573,10 +5823,10 @@ var Server = /*#__PURE__*/function () {
5573
5823
  }, {
5574
5824
  key: "handleOrderDraftSubmit",
5575
5825
  value: function () {
5576
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5826
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5577
5827
  var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
5578
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5579
- while (1) switch (_context58.prev = _context58.next) {
5828
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5829
+ while (1) switch (_context60.prev = _context60.next) {
5580
5830
  case 0:
5581
5831
  data = params.data, title = params.title;
5582
5832
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5584,10 +5834,10 @@ var Server = /*#__PURE__*/function () {
5584
5834
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
5585
5835
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5586
5836
  });
5587
- _context58.next = 4;
5837
+ _context60.next = 4;
5588
5838
  return this.normalizeCheckoutSubmitData(data, title);
5589
5839
  case 4:
5590
- normalizedData = _context58.sent;
5840
+ normalizedData = _context60.sent;
5591
5841
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
5592
5842
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
5593
5843
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -5597,26 +5847,26 @@ var Server = /*#__PURE__*/function () {
5597
5847
  is_draft_order: 1
5598
5848
  });
5599
5849
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
5600
- _context58.next = 10;
5850
+ _context60.next = 10;
5601
5851
  break;
5602
5852
  }
5603
5853
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
5604
- return _context58.abrupt("return", {
5854
+ return _context60.abrupt("return", {
5605
5855
  code: 500,
5606
5856
  status: false,
5607
5857
  message: 'Order 模块不支持本地草稿写入',
5608
5858
  data: null
5609
5859
  });
5610
5860
  case 10:
5611
- _context58.prev = 10;
5612
- _context58.next = 13;
5861
+ _context60.prev = 10;
5862
+ _context60.next = 13;
5613
5863
  return this.order.upsertLocalDraftOrders([draftOrder]);
5614
5864
  case 13:
5615
5865
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
5616
5866
  order_id: draftOrder.order_id,
5617
5867
  external_sale_number: draftOrder.external_sale_number
5618
5868
  });
5619
- return _context58.abrupt("return", {
5869
+ return _context60.abrupt("return", {
5620
5870
  code: 200,
5621
5871
  status: true,
5622
5872
  message: '',
@@ -5628,13 +5878,13 @@ var Server = /*#__PURE__*/function () {
5628
5878
  })
5629
5879
  });
5630
5880
  case 17:
5631
- _context58.prev = 17;
5632
- _context58.t0 = _context58["catch"](10);
5633
- errorMessage = _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0);
5881
+ _context60.prev = 17;
5882
+ _context60.t0 = _context60["catch"](10);
5883
+ errorMessage = _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0);
5634
5884
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
5635
5885
  error: errorMessage
5636
5886
  });
5637
- return _context58.abrupt("return", {
5887
+ return _context60.abrupt("return", {
5638
5888
  code: 500,
5639
5889
  status: false,
5640
5890
  message: errorMessage,
@@ -5642,11 +5892,11 @@ var Server = /*#__PURE__*/function () {
5642
5892
  });
5643
5893
  case 22:
5644
5894
  case "end":
5645
- return _context58.stop();
5895
+ return _context60.stop();
5646
5896
  }
5647
- }, _callee58, this, [[10, 17]]);
5897
+ }, _callee60, this, [[10, 17]]);
5648
5898
  }));
5649
- function handleOrderDraftSubmit(_x65) {
5899
+ function handleOrderDraftSubmit(_x68) {
5650
5900
  return _handleOrderDraftSubmit.apply(this, arguments);
5651
5901
  }
5652
5902
  return handleOrderDraftSubmit;
@@ -5654,26 +5904,26 @@ var Server = /*#__PURE__*/function () {
5654
5904
  }, {
5655
5905
  key: "handlePendingSyncCheckoutOrder",
5656
5906
  value: function () {
5657
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5658
- var _this11 = this;
5907
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5908
+ var _this12 = this;
5659
5909
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
5660
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5661
- while (1) switch (_context59.prev = _context59.next) {
5910
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5911
+ while (1) switch (_context61.prev = _context61.next) {
5662
5912
  case 0:
5663
5913
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
5664
- _context59.next = 3;
5914
+ _context61.next = 3;
5665
5915
  return this.buildPendingSyncCheckoutOrder(data);
5666
5916
  case 3:
5667
- pendingOrder = _context59.sent;
5917
+ pendingOrder = _context61.sent;
5668
5918
  if (pendingOrder) {
5669
- _context59.next = 7;
5919
+ _context61.next = 7;
5670
5920
  break;
5671
5921
  }
5672
5922
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
5673
5923
  backendPath: backendPath,
5674
5924
  reason: reason
5675
5925
  });
5676
- return _context59.abrupt("return", {
5926
+ return _context61.abrupt("return", {
5677
5927
  code: 500,
5678
5928
  status: false,
5679
5929
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -5681,22 +5931,22 @@ var Server = /*#__PURE__*/function () {
5681
5931
  });
5682
5932
  case 7:
5683
5933
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
5684
- _context59.next = 10;
5934
+ _context61.next = 10;
5685
5935
  break;
5686
5936
  }
5687
5937
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
5688
5938
  backendPath: backendPath,
5689
5939
  reason: reason
5690
5940
  });
5691
- return _context59.abrupt("return", {
5941
+ return _context61.abrupt("return", {
5692
5942
  code: 500,
5693
5943
  status: false,
5694
5944
  message: 'Order 模块不支持本地待同步写入',
5695
5945
  data: null
5696
5946
  });
5697
5947
  case 10:
5698
- _context59.prev = 10;
5699
- _context59.next = 13;
5948
+ _context61.prev = 10;
5949
+ _context61.next = 13;
5700
5950
  return this.order.upsertPendingSyncOrders([pendingOrder]);
5701
5951
  case 13:
5702
5952
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -5708,9 +5958,9 @@ var Server = /*#__PURE__*/function () {
5708
5958
  });
5709
5959
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
5710
5960
  var _payment$metadata;
5711
- 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);
5961
+ return sum + _this12.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
5712
5962
  }, 0);
5713
- return _context59.abrupt("return", {
5963
+ return _context61.abrupt("return", {
5714
5964
  code: 200,
5715
5965
  status: true,
5716
5966
  message: '',
@@ -5725,15 +5975,15 @@ var Server = /*#__PURE__*/function () {
5725
5975
  })
5726
5976
  });
5727
5977
  case 18:
5728
- _context59.prev = 18;
5729
- _context59.t0 = _context59["catch"](10);
5730
- errorMessage = _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0);
5978
+ _context61.prev = 18;
5979
+ _context61.t0 = _context61["catch"](10);
5980
+ errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
5731
5981
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
5732
5982
  backendPath: backendPath,
5733
5983
  reason: reason,
5734
5984
  error: errorMessage
5735
5985
  });
5736
- return _context59.abrupt("return", {
5986
+ return _context61.abrupt("return", {
5737
5987
  code: 500,
5738
5988
  status: false,
5739
5989
  message: errorMessage,
@@ -5741,11 +5991,11 @@ var Server = /*#__PURE__*/function () {
5741
5991
  });
5742
5992
  case 23:
5743
5993
  case "end":
5744
- return _context59.stop();
5994
+ return _context61.stop();
5745
5995
  }
5746
- }, _callee59, this, [[10, 18]]);
5996
+ }, _callee61, this, [[10, 18]]);
5747
5997
  }));
5748
- function handlePendingSyncCheckoutOrder(_x66) {
5998
+ function handlePendingSyncCheckoutOrder(_x69) {
5749
5999
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
5750
6000
  }
5751
6001
  return handlePendingSyncCheckoutOrder;
@@ -5753,44 +6003,44 @@ var Server = /*#__PURE__*/function () {
5753
6003
  }, {
5754
6004
  key: "buildPendingSyncCheckoutOrder",
5755
6005
  value: function () {
5756
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data) {
6006
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
5757
6007
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
5758
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5759
- while (1) switch (_context60.prev = _context60.next) {
6008
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6009
+ while (1) switch (_context62.prev = _context62.next) {
5760
6010
  case 0:
5761
6011
  if (!(!data || _typeof(data) !== 'object')) {
5762
- _context60.next = 2;
6012
+ _context62.next = 2;
5763
6013
  break;
5764
6014
  }
5765
- return _context60.abrupt("return", null);
6015
+ return _context62.abrupt("return", null);
5766
6016
  case 2:
5767
6017
  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 !== '';
5768
6018
  if (hasStorageKey) {
5769
- _context60.next = 5;
6019
+ _context62.next = 5;
5770
6020
  break;
5771
6021
  }
5772
- return _context60.abrupt("return", null);
6022
+ return _context62.abrupt("return", null);
5773
6023
  case 5:
5774
6024
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
5775
6025
  need_sync: 1,
5776
6026
  is_draft_order: 0
5777
6027
  });
5778
- _context60.next = 8;
6028
+ _context62.next = 8;
5779
6029
  return this.buildSmallTicketProductMap(pendingOrder);
5780
6030
  case 8:
5781
- productMap = _context60.sent;
6031
+ productMap = _context62.sent;
5782
6032
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
5783
- return _context60.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6033
+ return _context62.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
5784
6034
  requireFullyPaid: true,
5785
6035
  productMap: productMap
5786
6036
  }));
5787
6037
  case 11:
5788
6038
  case "end":
5789
- return _context60.stop();
6039
+ return _context62.stop();
5790
6040
  }
5791
- }, _callee60, this);
6041
+ }, _callee62, this);
5792
6042
  }));
5793
- function buildPendingSyncCheckoutOrder(_x67) {
6043
+ function buildPendingSyncCheckoutOrder(_x70) {
5794
6044
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
5795
6045
  }
5796
6046
  return buildPendingSyncCheckoutOrder;
@@ -5838,13 +6088,13 @@ var Server = /*#__PURE__*/function () {
5838
6088
  }, {
5839
6089
  key: "sumPaidOrderPayments",
5840
6090
  value: function sumPaidOrderPayments(payments) {
5841
- var _this12 = this;
6091
+ var _this13 = this;
5842
6092
  if (!Array.isArray(payments)) return 0;
5843
6093
  return payments.reduce(function (sum, payment) {
5844
6094
  var _payment$amount;
5845
6095
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
5846
6096
  if (status !== 'paid') return sum;
5847
- 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);
6097
+ return sum + _this13.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);
5848
6098
  }, 0);
5849
6099
  }
5850
6100
  }, {
@@ -5858,12 +6108,12 @@ var Server = /*#__PURE__*/function () {
5858
6108
  }, {
5859
6109
  key: "buildSmallTicketProductMap",
5860
6110
  value: function () {
5861
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(order) {
5862
- var _this$products,
5863
- _this13 = this;
6111
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(order) {
6112
+ var _this$products3,
6113
+ _this14 = this;
5864
6114
  var products, productIdSet, productIds, entries;
5865
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
5866
- while (1) switch (_context62.prev = _context62.next) {
6115
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6116
+ while (1) switch (_context64.prev = _context64.next) {
5867
6117
  case 0:
5868
6118
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
5869
6119
  productIdSet = new Set();
@@ -5884,46 +6134,46 @@ var Server = /*#__PURE__*/function () {
5884
6134
  }
5885
6135
  });
5886
6136
  productIds = Array.from(productIdSet);
5887
- if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
5888
- _context62.next = 6;
6137
+ if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
6138
+ _context64.next = 6;
5889
6139
  break;
5890
6140
  }
5891
- return _context62.abrupt("return", {});
6141
+ return _context64.abrupt("return", {});
5892
6142
  case 6:
5893
- _context62.next = 8;
6143
+ _context64.next = 8;
5894
6144
  return Promise.all(productIds.map( /*#__PURE__*/function () {
5895
- var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(id) {
5896
- var _this13$products, _this13$products$getP, product;
5897
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5898
- while (1) switch (_context61.prev = _context61.next) {
6145
+ var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(id) {
6146
+ var _this14$products, _this14$products$getP, product;
6147
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6148
+ while (1) switch (_context63.prev = _context63.next) {
5899
6149
  case 0:
5900
- _context61.prev = 0;
5901
- _context61.next = 3;
5902
- 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));
6150
+ _context63.prev = 0;
6151
+ _context63.next = 3;
6152
+ return (_this14$products = _this14.products) === null || _this14$products === void 0 || (_this14$products$getP = _this14$products.getProductById) === null || _this14$products$getP === void 0 ? void 0 : _this14$products$getP.call(_this14$products, Number(id));
5903
6153
  case 3:
5904
- product = _context61.sent;
5905
- return _context61.abrupt("return", product ? [String(id), product] : null);
6154
+ product = _context63.sent;
6155
+ return _context63.abrupt("return", product ? [String(id), product] : null);
5906
6156
  case 7:
5907
- _context61.prev = 7;
5908
- _context61.t0 = _context61["catch"](0);
5909
- _this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6157
+ _context63.prev = 7;
6158
+ _context63.t0 = _context63["catch"](0);
6159
+ _this14.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
5910
6160
  product_id: id,
5911
- error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
6161
+ error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
5912
6162
  });
5913
- return _context61.abrupt("return", null);
6163
+ return _context63.abrupt("return", null);
5914
6164
  case 11:
5915
6165
  case "end":
5916
- return _context61.stop();
6166
+ return _context63.stop();
5917
6167
  }
5918
- }, _callee61, null, [[0, 7]]);
6168
+ }, _callee63, null, [[0, 7]]);
5919
6169
  }));
5920
- return function (_x69) {
6170
+ return function (_x72) {
5921
6171
  return _ref67.apply(this, arguments);
5922
6172
  };
5923
6173
  }()));
5924
6174
  case 8:
5925
- entries = _context62.sent;
5926
- return _context62.abrupt("return", entries.reduce(function (map, entry) {
6175
+ entries = _context64.sent;
6176
+ return _context64.abrupt("return", entries.reduce(function (map, entry) {
5927
6177
  if (!entry) return map;
5928
6178
  var _entry = _slicedToArray(entry, 2),
5929
6179
  id = _entry[0],
@@ -5933,11 +6183,11 @@ var Server = /*#__PURE__*/function () {
5933
6183
  }, {}));
5934
6184
  case 10:
5935
6185
  case "end":
5936
- return _context62.stop();
6186
+ return _context64.stop();
5937
6187
  }
5938
- }, _callee62, this);
6188
+ }, _callee64, this);
5939
6189
  }));
5940
- function buildSmallTicketProductMap(_x68) {
6190
+ function buildSmallTicketProductMap(_x71) {
5941
6191
  return _buildSmallTicketProductMap.apply(this, arguments);
5942
6192
  }
5943
6193
  return buildSmallTicketProductMap;
@@ -5967,40 +6217,40 @@ var Server = /*#__PURE__*/function () {
5967
6217
  }, {
5968
6218
  key: "buildSalesDetailProductSnapshotMap",
5969
6219
  value: function () {
5970
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(order) {
5971
- var _this$products2;
6220
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
6221
+ var _this$products4;
5972
6222
  var productIds, getSnapshots;
5973
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
5974
- while (1) switch (_context63.prev = _context63.next) {
6223
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6224
+ while (1) switch (_context65.prev = _context65.next) {
5975
6225
  case 0:
5976
6226
  productIds = this.collectSalesDetailProductIds(order);
5977
- getSnapshots = (_this$products2 = this.products) === null || _this$products2 === void 0 ? void 0 : _this$products2.getProductSnapshotsByIds;
6227
+ getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
5978
6228
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
5979
- _context63.next = 4;
6229
+ _context65.next = 4;
5980
6230
  break;
5981
6231
  }
5982
- return _context63.abrupt("return", {});
6232
+ return _context65.abrupt("return", {});
5983
6233
  case 4:
5984
- _context63.prev = 4;
5985
- _context63.next = 7;
6234
+ _context65.prev = 4;
6235
+ _context65.next = 7;
5986
6236
  return getSnapshots.call(this.products, productIds);
5987
6237
  case 7:
5988
- return _context63.abrupt("return", _context63.sent);
6238
+ return _context65.abrupt("return", _context65.sent);
5989
6239
  case 10:
5990
- _context63.prev = 10;
5991
- _context63.t0 = _context63["catch"](4);
6240
+ _context65.prev = 10;
6241
+ _context65.t0 = _context65["catch"](4);
5992
6242
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
5993
6243
  product_ids: productIds,
5994
- error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
6244
+ error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
5995
6245
  });
5996
- return _context63.abrupt("return", {});
6246
+ return _context65.abrupt("return", {});
5997
6247
  case 14:
5998
6248
  case "end":
5999
- return _context63.stop();
6249
+ return _context65.stop();
6000
6250
  }
6001
- }, _callee63, this, [[4, 10]]);
6251
+ }, _callee65, this, [[4, 10]]);
6002
6252
  }));
6003
- function buildSalesDetailProductSnapshotMap(_x70) {
6253
+ function buildSalesDetailProductSnapshotMap(_x73) {
6004
6254
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6005
6255
  }
6006
6256
  return buildSalesDetailProductSnapshotMap;
@@ -6056,53 +6306,53 @@ var Server = /*#__PURE__*/function () {
6056
6306
  }, {
6057
6307
  key: "withSalesDetailProductSnapshots",
6058
6308
  value: function () {
6059
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(order) {
6060
- var _this14 = this;
6309
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6310
+ var _this15 = this;
6061
6311
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6062
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6063
- while (1) switch (_context64.prev = _context64.next) {
6312
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6313
+ while (1) switch (_context66.prev = _context66.next) {
6064
6314
  case 0:
6065
6315
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
6066
6316
  if (products !== null && products !== void 0 && products.length) {
6067
- _context64.next = 3;
6317
+ _context66.next = 3;
6068
6318
  break;
6069
6319
  }
6070
- return _context64.abrupt("return", order);
6320
+ return _context66.abrupt("return", order);
6071
6321
  case 3:
6072
- _context64.next = 5;
6322
+ _context66.next = 5;
6073
6323
  return this.buildSalesDetailProductSnapshotMap(order);
6074
6324
  case 5:
6075
- snapshotMap = _context64.sent;
6325
+ snapshotMap = _context66.sent;
6076
6326
  if (Object.keys(snapshotMap).length) {
6077
- _context64.next = 8;
6327
+ _context66.next = 8;
6078
6328
  break;
6079
6329
  }
6080
- return _context64.abrupt("return", order);
6330
+ return _context66.abrupt("return", order);
6081
6331
  case 8:
6082
6332
  hasChanged = false;
6083
6333
  enrichedProducts = products.map(function (product) {
6084
- var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
6085
- var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6334
+ var productWithBundleSnapshots = _this15.withBundleCatalogSnapshots(product, snapshotMap);
6335
+ var nextProduct = _this15.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6086
6336
  if (nextProduct !== product) hasChanged = true;
6087
6337
  return nextProduct;
6088
6338
  });
6089
6339
  if (hasChanged) {
6090
- _context64.next = 12;
6340
+ _context66.next = 12;
6091
6341
  break;
6092
6342
  }
6093
- return _context64.abrupt("return", order);
6343
+ return _context66.abrupt("return", order);
6094
6344
  case 12:
6095
6345
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
6096
6346
  products: enrichedProducts
6097
6347
  });
6098
- return _context64.abrupt("return", enrichedOrder);
6348
+ return _context66.abrupt("return", enrichedOrder);
6099
6349
  case 14:
6100
6350
  case "end":
6101
- return _context64.stop();
6351
+ return _context66.stop();
6102
6352
  }
6103
- }, _callee64, this);
6353
+ }, _callee66, this);
6104
6354
  }));
6105
- function withSalesDetailProductSnapshots(_x71) {
6355
+ function withSalesDetailProductSnapshots(_x74) {
6106
6356
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6107
6357
  }
6108
6358
  return withSalesDetailProductSnapshots;
@@ -6110,13 +6360,13 @@ var Server = /*#__PURE__*/function () {
6110
6360
  }, {
6111
6361
  key: "withPendingSyncProductTitles",
6112
6362
  value: function withPendingSyncProductTitles(order, productMap) {
6113
- var _this15 = this;
6363
+ var _this16 = this;
6114
6364
  var products = Array.isArray(order.products) ? order.products : null;
6115
6365
  if (!(products !== null && products !== void 0 && products.length)) return order;
6116
6366
  return _objectSpread(_objectSpread({}, order), {}, {
6117
6367
  products: products.map(function (product) {
6118
6368
  return _objectSpread(_objectSpread({}, product), {}, {
6119
- product_title: _this15.buildProductTitleSnapshot(product, productMap)
6369
+ product_title: _this16.buildProductTitleSnapshot(product, productMap)
6120
6370
  });
6121
6371
  })
6122
6372
  });
@@ -6127,7 +6377,7 @@ var Server = /*#__PURE__*/function () {
6127
6377
  var _product$product_id4,
6128
6378
  _product$product,
6129
6379
  _fallbackProduct$prod,
6130
- _this16 = this;
6380
+ _this17 = this;
6131
6381
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6132
6382
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6133
6383
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6135,7 +6385,7 @@ var Server = /*#__PURE__*/function () {
6135
6385
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6136
6386
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6137
6387
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6138
- snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6388
+ snapshot[key] = _this17.resolveProductTitleValue(ownTitle, key, currentLocale) || _this17.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6139
6389
  return snapshot;
6140
6390
  }, {});
6141
6391
  }
@@ -6233,50 +6483,50 @@ var Server = /*#__PURE__*/function () {
6233
6483
  }, {
6234
6484
  key: "enrichPaymentNamesByCode",
6235
6485
  value: function () {
6236
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
6237
- var _this17 = this;
6238
- var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6239
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6240
- while (1) switch (_context65.prev = _context65.next) {
6486
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6487
+ var _this18 = this;
6488
+ var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
6489
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6490
+ while (1) switch (_context67.prev = _context67.next) {
6241
6491
  case 0:
6242
6492
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6243
6493
  hasMissingName = payments.some(function (payment) {
6244
- return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6494
+ return _this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6245
6495
  });
6246
6496
  if (hasMissingName) {
6247
- _context65.next = 4;
6497
+ _context67.next = 4;
6248
6498
  break;
6249
6499
  }
6250
- return _context65.abrupt("return", order);
6500
+ return _context67.abrupt("return", order);
6251
6501
  case 4:
6252
- _context65.prev = 4;
6253
- _context65.next = 7;
6502
+ _context67.prev = 4;
6503
+ _context67.next = 7;
6254
6504
  return this.getPaymentRouteModule();
6255
6505
  case 7:
6256
- paymentModule = _context65.sent;
6257
- _context65.next = 10;
6506
+ paymentModule = _context67.sent;
6507
+ _context67.next = 10;
6258
6508
  return paymentModule.getPayMethodListAsync();
6259
6509
  case 10:
6260
- payMethods = _context65.sent;
6510
+ payMethods = _context67.sent;
6261
6511
  nameByCode = new Map();
6262
- _iterator12 = _createForOfIteratorHelper(payMethods || []);
6512
+ _iterator13 = _createForOfIteratorHelper(payMethods || []);
6263
6513
  try {
6264
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
6265
- method = _step12.value;
6514
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
6515
+ method = _step13.value;
6266
6516
  codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
6267
6517
  name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
6268
6518
  if (codeKey && name) nameByCode.set(codeKey, name);
6269
6519
  }
6270
6520
  } catch (err) {
6271
- _iterator12.e(err);
6521
+ _iterator13.e(err);
6272
6522
  } finally {
6273
- _iterator12.f();
6523
+ _iterator13.f();
6274
6524
  }
6275
6525
  hasResolvedName = false;
6276
6526
  enrichedPayments = payments.map(function (payment) {
6277
- if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6278
- if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6279
- var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6527
+ if (!_this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6528
+ if (!_this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6529
+ var name = nameByCode.get(_this18.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6280
6530
  if (!name) return payment;
6281
6531
  hasResolvedName = true;
6282
6532
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6284,28 +6534,28 @@ var Server = /*#__PURE__*/function () {
6284
6534
  });
6285
6535
  });
6286
6536
  if (hasResolvedName) {
6287
- _context65.next = 18;
6537
+ _context67.next = 18;
6288
6538
  break;
6289
6539
  }
6290
- return _context65.abrupt("return", order);
6540
+ return _context67.abrupt("return", order);
6291
6541
  case 18:
6292
- return _context65.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6542
+ return _context67.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6293
6543
  payments: enrichedPayments
6294
6544
  }));
6295
6545
  case 21:
6296
- _context65.prev = 21;
6297
- _context65.t0 = _context65["catch"](4);
6546
+ _context67.prev = 21;
6547
+ _context67.t0 = _context67["catch"](4);
6298
6548
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
6299
- error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6549
+ error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
6300
6550
  });
6301
- return _context65.abrupt("return", order);
6551
+ return _context67.abrupt("return", order);
6302
6552
  case 25:
6303
6553
  case "end":
6304
- return _context65.stop();
6554
+ return _context67.stop();
6305
6555
  }
6306
- }, _callee65, this, [[4, 21]]);
6556
+ }, _callee67, this, [[4, 21]]);
6307
6557
  }));
6308
- function enrichPaymentNamesByCode(_x72) {
6558
+ function enrichPaymentNamesByCode(_x75) {
6309
6559
  return _enrichPaymentNamesByCode.apply(this, arguments);
6310
6560
  }
6311
6561
  return enrichPaymentNamesByCode;
@@ -6313,66 +6563,66 @@ var Server = /*#__PURE__*/function () {
6313
6563
  }, {
6314
6564
  key: "withLocalSmallTicketData",
6315
6565
  value: function () {
6316
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order, options) {
6566
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order, options) {
6317
6567
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
6318
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6319
- while (1) switch (_context66.prev = _context66.next) {
6568
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6569
+ while (1) switch (_context68.prev = _context68.next) {
6320
6570
  case 0:
6321
6571
  if (this.shouldBuildSmallTicketData(order)) {
6322
- _context66.next = 2;
6572
+ _context68.next = 2;
6323
6573
  break;
6324
6574
  }
6325
- return _context66.abrupt("return", order);
6575
+ return _context68.abrupt("return", order);
6326
6576
  case 2:
6327
6577
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
6328
- _context66.next = 4;
6578
+ _context68.next = 4;
6329
6579
  break;
6330
6580
  }
6331
- return _context66.abrupt("return", order);
6581
+ return _context68.abrupt("return", order);
6332
6582
  case 4:
6333
- _context66.prev = 4;
6334
- _context66.next = 7;
6583
+ _context68.prev = 4;
6584
+ _context68.next = 7;
6335
6585
  return this.enrichPaymentNamesByCode(order);
6336
6586
  case 7:
6337
- enrichedOrder = _context66.sent;
6587
+ enrichedOrder = _context68.sent;
6338
6588
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
6339
- _context66.next = 12;
6589
+ _context68.next = 12;
6340
6590
  break;
6341
6591
  }
6342
- _context66.t0 = _options$productMap;
6343
- _context66.next = 15;
6592
+ _context68.t0 = _options$productMap;
6593
+ _context68.next = 15;
6344
6594
  break;
6345
6595
  case 12:
6346
- _context66.next = 14;
6596
+ _context68.next = 14;
6347
6597
  return this.buildSmallTicketProductMap(enrichedOrder);
6348
6598
  case 14:
6349
- _context66.t0 = _context66.sent;
6599
+ _context68.t0 = _context68.sent;
6350
6600
  case 15:
6351
- productMap = _context66.t0;
6601
+ productMap = _context68.t0;
6352
6602
  smallTicketData = buildSmallTicketData({
6353
6603
  order: enrichedOrder,
6354
6604
  shopInfo: this.getSmallTicketShopInfo(),
6355
6605
  productMap: productMap
6356
6606
  });
6357
- return _context66.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6607
+ return _context68.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6358
6608
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
6359
6609
  small_ticket_data: smallTicketData
6360
6610
  })
6361
6611
  }));
6362
6612
  case 20:
6363
- _context66.prev = 20;
6364
- _context66.t1 = _context66["catch"](4);
6613
+ _context68.prev = 20;
6614
+ _context68.t1 = _context68["catch"](4);
6365
6615
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
6366
- error: _context66.t1 instanceof Error ? _context66.t1.message : String(_context66.t1)
6616
+ error: _context68.t1 instanceof Error ? _context68.t1.message : String(_context68.t1)
6367
6617
  });
6368
- return _context66.abrupt("return", order);
6618
+ return _context68.abrupt("return", order);
6369
6619
  case 24:
6370
6620
  case "end":
6371
- return _context66.stop();
6621
+ return _context68.stop();
6372
6622
  }
6373
- }, _callee66, this, [[4, 20]]);
6623
+ }, _callee68, this, [[4, 20]]);
6374
6624
  }));
6375
- function withLocalSmallTicketData(_x73, _x74) {
6625
+ function withLocalSmallTicketData(_x76, _x77) {
6376
6626
  return _withLocalSmallTicketData.apply(this, arguments);
6377
6627
  }
6378
6628
  return withLocalSmallTicketData;
@@ -6434,22 +6684,22 @@ var Server = /*#__PURE__*/function () {
6434
6684
  }, {
6435
6685
  key: "handleUpdateLocalOrdersBatch",
6436
6686
  value: (function () {
6437
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(orderIds) {
6687
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(orderIds) {
6438
6688
  var _this$app17;
6439
- var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6440
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6441
- while (1) switch (_context67.prev = _context67.next) {
6689
+ var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
6690
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6691
+ while (1) switch (_context69.prev = _context69.next) {
6442
6692
  case 0:
6443
6693
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
6444
6694
  count: orderIds.length,
6445
6695
  orderIds: orderIds
6446
6696
  });
6447
6697
  if (this.order) {
6448
- _context67.next = 4;
6698
+ _context69.next = 4;
6449
6699
  break;
6450
6700
  }
6451
6701
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
6452
- return _context67.abrupt("return", {
6702
+ return _context69.abrupt("return", {
6453
6703
  code: 500,
6454
6704
  status: false,
6455
6705
  message: 'Order 模块未注册',
@@ -6457,11 +6707,11 @@ var Server = /*#__PURE__*/function () {
6457
6707
  });
6458
6708
  case 4:
6459
6709
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
6460
- _context67.next = 7;
6710
+ _context69.next = 7;
6461
6711
  break;
6462
6712
  }
6463
6713
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
6464
- return _context67.abrupt("return", {
6714
+ return _context69.abrupt("return", {
6465
6715
  code: 500,
6466
6716
  status: false,
6467
6717
  message: 'app.request 不可用',
@@ -6470,35 +6720,35 @@ var Server = /*#__PURE__*/function () {
6470
6720
  case 7:
6471
6721
  // 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
6472
6722
  existedBefore = new Map();
6473
- _iterator13 = _createForOfIteratorHelper(orderIds);
6723
+ _iterator14 = _createForOfIteratorHelper(orderIds);
6474
6724
  try {
6475
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
6476
- id = _step13.value;
6725
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
6726
+ id = _step14.value;
6477
6727
  existedBefore.set(id, !!this.order.getOrderByOrderId(id));
6478
6728
  }
6479
6729
 
6480
6730
  // 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
6481
6731
  } catch (err) {
6482
- _iterator13.e(err);
6732
+ _iterator14.e(err);
6483
6733
  } finally {
6484
- _iterator13.f();
6734
+ _iterator14.f();
6485
6735
  }
6486
6736
  fetched = [];
6487
- _context67.prev = 11;
6488
- _context67.next = 14;
6737
+ _context69.prev = 11;
6738
+ _context69.next = 14;
6489
6739
  return this.order.fetchOrdersByHttp(orderIds);
6490
6740
  case 14:
6491
- fetched = _context67.sent;
6492
- _context67.next = 22;
6741
+ fetched = _context69.sent;
6742
+ _context69.next = 22;
6493
6743
  break;
6494
6744
  case 17:
6495
- _context67.prev = 17;
6496
- _context67.t0 = _context67["catch"](11);
6497
- message = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
6745
+ _context69.prev = 17;
6746
+ _context69.t0 = _context69["catch"](11);
6747
+ message = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
6498
6748
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
6499
6749
  message: message
6500
6750
  });
6501
- return _context67.abrupt("return", {
6751
+ return _context69.abrupt("return", {
6502
6752
  code: 500,
6503
6753
  status: false,
6504
6754
  message: message,
@@ -6507,45 +6757,45 @@ var Server = /*#__PURE__*/function () {
6507
6757
  case 22:
6508
6758
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
6509
6759
  fetchedMap = new Map();
6510
- _iterator14 = _createForOfIteratorHelper(fetched);
6511
- _context67.prev = 24;
6512
- _iterator14.s();
6760
+ _iterator15 = _createForOfIteratorHelper(fetched);
6761
+ _context69.prev = 24;
6762
+ _iterator15.s();
6513
6763
  case 26:
6514
- if ((_step14 = _iterator14.n()).done) {
6515
- _context67.next = 34;
6764
+ if ((_step15 = _iterator15.n()).done) {
6765
+ _context69.next = 34;
6516
6766
  break;
6517
6767
  }
6518
- order = _step14.value;
6768
+ order = _step15.value;
6519
6769
  oid = order === null || order === void 0 ? void 0 : order.order_id;
6520
6770
  if (!(oid === undefined || oid === null)) {
6521
- _context67.next = 31;
6771
+ _context69.next = 31;
6522
6772
  break;
6523
6773
  }
6524
- return _context67.abrupt("continue", 32);
6774
+ return _context69.abrupt("continue", 32);
6525
6775
  case 31:
6526
6776
  fetchedMap.set(String(oid), order);
6527
6777
  case 32:
6528
- _context67.next = 26;
6778
+ _context69.next = 26;
6529
6779
  break;
6530
6780
  case 34:
6531
- _context67.next = 39;
6781
+ _context69.next = 39;
6532
6782
  break;
6533
6783
  case 36:
6534
- _context67.prev = 36;
6535
- _context67.t1 = _context67["catch"](24);
6536
- _iterator14.e(_context67.t1);
6784
+ _context69.prev = 36;
6785
+ _context69.t1 = _context69["catch"](24);
6786
+ _iterator15.e(_context69.t1);
6537
6787
  case 39:
6538
- _context67.prev = 39;
6539
- _iterator14.f();
6540
- return _context67.finish(39);
6788
+ _context69.prev = 39;
6789
+ _iterator15.f();
6790
+ return _context69.finish(39);
6541
6791
  case 42:
6542
6792
  freshOrders = [];
6543
6793
  succeedIds = [];
6544
6794
  failed = [];
6545
- _iterator15 = _createForOfIteratorHelper(orderIds);
6795
+ _iterator16 = _createForOfIteratorHelper(orderIds);
6546
6796
  try {
6547
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
6548
- _id = _step15.value;
6797
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
6798
+ _id = _step16.value;
6549
6799
  fresh = fetchedMap.get(_id);
6550
6800
  if (fresh) {
6551
6801
  freshOrders.push(fresh);
@@ -6558,28 +6808,28 @@ var Server = /*#__PURE__*/function () {
6558
6808
  }
6559
6809
  }
6560
6810
  } catch (err) {
6561
- _iterator15.e(err);
6811
+ _iterator16.e(err);
6562
6812
  } finally {
6563
- _iterator15.f();
6813
+ _iterator16.f();
6564
6814
  }
6565
6815
  if (!(freshOrders.length > 0)) {
6566
- _context67.next = 58;
6816
+ _context69.next = 58;
6567
6817
  break;
6568
6818
  }
6569
- _context67.prev = 48;
6570
- _context67.next = 51;
6819
+ _context69.prev = 48;
6820
+ _context69.next = 51;
6571
6821
  return this.order.upsertOrdersFromRemote(freshOrders);
6572
6822
  case 51:
6573
- _context67.next = 58;
6823
+ _context69.next = 58;
6574
6824
  break;
6575
6825
  case 53:
6576
- _context67.prev = 53;
6577
- _context67.t2 = _context67["catch"](48);
6578
- _message2 = _context67.t2 instanceof Error ? _context67.t2.message : String(_context67.t2);
6826
+ _context69.prev = 53;
6827
+ _context69.t2 = _context69["catch"](48);
6828
+ _message2 = _context69.t2 instanceof Error ? _context69.t2.message : String(_context69.t2);
6579
6829
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
6580
6830
  message: _message2
6581
6831
  });
6582
- return _context67.abrupt("return", {
6832
+ return _context69.abrupt("return", {
6583
6833
  code: 500,
6584
6834
  status: false,
6585
6835
  message: _message2,
@@ -6598,7 +6848,7 @@ var Server = /*#__PURE__*/function () {
6598
6848
  insertedCount: inserted.length,
6599
6849
  failedCount: failed.length
6600
6850
  });
6601
- return _context67.abrupt("return", {
6851
+ return _context69.abrupt("return", {
6602
6852
  code: 200,
6603
6853
  status: true,
6604
6854
  message: '',
@@ -6610,11 +6860,11 @@ var Server = /*#__PURE__*/function () {
6610
6860
  });
6611
6861
  case 62:
6612
6862
  case "end":
6613
- return _context67.stop();
6863
+ return _context69.stop();
6614
6864
  }
6615
- }, _callee67, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
6865
+ }, _callee69, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
6616
6866
  }));
6617
- function handleUpdateLocalOrdersBatch(_x75) {
6867
+ function handleUpdateLocalOrdersBatch(_x78) {
6618
6868
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
6619
6869
  }
6620
6870
  return handleUpdateLocalOrdersBatch;
@@ -6635,11 +6885,11 @@ var Server = /*#__PURE__*/function () {
6635
6885
  var queryIndex = url.indexOf('?');
6636
6886
  if (queryIndex < 0) return null;
6637
6887
  var query = url.slice(queryIndex + 1);
6638
- var _iterator16 = _createForOfIteratorHelper(query.split('&')),
6639
- _step16;
6888
+ var _iterator17 = _createForOfIteratorHelper(query.split('&')),
6889
+ _step17;
6640
6890
  try {
6641
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
6642
- var pair = _step16.value;
6891
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6892
+ var pair = _step17.value;
6643
6893
  if (!pair) continue;
6644
6894
  var _pair$split = pair.split('='),
6645
6895
  _pair$split2 = _slicedToArray(_pair$split, 2),
@@ -6655,9 +6905,9 @@ var Server = /*#__PURE__*/function () {
6655
6905
  }
6656
6906
  }
6657
6907
  } catch (err) {
6658
- _iterator16.e(err);
6908
+ _iterator17.e(err);
6659
6909
  } finally {
6660
- _iterator16.f();
6910
+ _iterator17.f();
6661
6911
  }
6662
6912
  return null;
6663
6913
  }
@@ -6858,10 +7108,10 @@ var Server = /*#__PURE__*/function () {
6858
7108
  value: function extractBackendErrorResponse(error) {
6859
7109
  var _error$response3,
6860
7110
  _error$response4,
6861
- _this18 = this;
7111
+ _this19 = this;
6862
7112
  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];
6863
7113
  return candidates.find(function (candidate) {
6864
- return _this18.isExplicitBackendErrorResponse(candidate);
7114
+ return _this19.isExplicitBackendErrorResponse(candidate);
6865
7115
  }) || null;
6866
7116
  }
6867
7117
  }, {
@@ -6980,24 +7230,24 @@ var Server = /*#__PURE__*/function () {
6980
7230
  }, {
6981
7231
  key: "recomputeAndNotifyFloorPlanQuery",
6982
7232
  value: (function () {
6983
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
6984
- var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
6985
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6986
- while (1) switch (_context68.prev = _context68.next) {
7233
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70() {
7234
+ var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
7235
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7236
+ while (1) switch (_context70.prev = _context70.next) {
6987
7237
  case 0:
6988
7238
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
6989
- _context68.next = 2;
7239
+ _context70.next = 2;
6990
7240
  break;
6991
7241
  }
6992
- return _context68.abrupt("return");
7242
+ return _context70.abrupt("return");
6993
7243
  case 2:
6994
7244
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
6995
7245
  subscriberCount: this.floorPlanQuerySubscribers.size
6996
7246
  });
6997
- _iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
7247
+ _iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
6998
7248
  try {
6999
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
7000
- _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
7249
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
7250
+ _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
7001
7251
  try {
7002
7252
  result = this.computeFloorPlanQueryResult(sub.context);
7003
7253
  sub.callback(result);
@@ -7013,15 +7263,15 @@ var Server = /*#__PURE__*/function () {
7013
7263
  }
7014
7264
  }
7015
7265
  } catch (err) {
7016
- _iterator17.e(err);
7266
+ _iterator18.e(err);
7017
7267
  } finally {
7018
- _iterator17.f();
7268
+ _iterator18.f();
7019
7269
  }
7020
7270
  case 5:
7021
7271
  case "end":
7022
- return _context68.stop();
7272
+ return _context70.stop();
7023
7273
  }
7024
- }, _callee68, this);
7274
+ }, _callee70, this);
7025
7275
  }));
7026
7276
  function recomputeAndNotifyFloorPlanQuery() {
7027
7277
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7051,21 +7301,21 @@ var Server = /*#__PURE__*/function () {
7051
7301
  * filter 逻辑暂为 mock,仅记录参数
7052
7302
  */
7053
7303
  function () {
7054
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(data) {
7304
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(data) {
7055
7305
  var rawList, result;
7056
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
7057
- while (1) switch (_context69.prev = _context69.next) {
7306
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7307
+ while (1) switch (_context71.prev = _context71.next) {
7058
7308
  case 0:
7059
7309
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7060
7310
  data: data
7061
7311
  });
7062
7312
  console.log('[Server] computeOrderQueryResult', data);
7063
7313
  if (this.order) {
7064
- _context69.next = 5;
7314
+ _context71.next = 5;
7065
7315
  break;
7066
7316
  }
7067
7317
  this.logError('computeOrderQueryResult: Order 模块未注册');
7068
- return _context69.abrupt("return", {
7318
+ return _context71.abrupt("return", {
7069
7319
  code: 500,
7070
7320
  message: 'Order 模块未注册',
7071
7321
  data: {
@@ -7089,7 +7339,7 @@ var Server = /*#__PURE__*/function () {
7089
7339
  skip: result.skip,
7090
7340
  rejected: result.rejected
7091
7341
  });
7092
- return _context69.abrupt("return", {
7342
+ return _context71.abrupt("return", {
7093
7343
  code: 200,
7094
7344
  data: result,
7095
7345
  message: '',
@@ -7097,11 +7347,11 @@ var Server = /*#__PURE__*/function () {
7097
7347
  });
7098
7348
  case 10:
7099
7349
  case "end":
7100
- return _context69.stop();
7350
+ return _context71.stop();
7101
7351
  }
7102
- }, _callee69, this);
7352
+ }, _callee71, this);
7103
7353
  }));
7104
- function computeOrderQueryResult(_x76) {
7354
+ function computeOrderQueryResult(_x79) {
7105
7355
  return _computeOrderQueryResult.apply(this, arguments);
7106
7356
  }
7107
7357
  return computeOrderQueryResult;
@@ -7114,17 +7364,17 @@ var Server = /*#__PURE__*/function () {
7114
7364
  }, {
7115
7365
  key: "computeBookingQueryResult",
7116
7366
  value: (function () {
7117
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(data) {
7367
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data) {
7118
7368
  var rawOrders, result;
7119
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7120
- while (1) switch (_context70.prev = _context70.next) {
7369
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7370
+ while (1) switch (_context72.prev = _context72.next) {
7121
7371
  case 0:
7122
7372
  if (this.order) {
7123
- _context70.next = 3;
7373
+ _context72.next = 3;
7124
7374
  break;
7125
7375
  }
7126
7376
  this.logError('computeBookingQueryResult: Order 模块未注册');
7127
- return _context70.abrupt("return", {
7377
+ return _context72.abrupt("return", {
7128
7378
  code: 500,
7129
7379
  message: 'Order 模块未注册',
7130
7380
  data: {
@@ -7143,7 +7393,7 @@ var Server = /*#__PURE__*/function () {
7143
7393
  size: result.size,
7144
7394
  skip: result.skip
7145
7395
  });
7146
- return _context70.abrupt("return", {
7396
+ return _context72.abrupt("return", {
7147
7397
  code: 200,
7148
7398
  data: result,
7149
7399
  message: '',
@@ -7151,11 +7401,11 @@ var Server = /*#__PURE__*/function () {
7151
7401
  });
7152
7402
  case 8:
7153
7403
  case "end":
7154
- return _context70.stop();
7404
+ return _context72.stop();
7155
7405
  }
7156
- }, _callee70, this);
7406
+ }, _callee72, this);
7157
7407
  }));
7158
- function computeBookingQueryResult(_x77) {
7408
+ function computeBookingQueryResult(_x80) {
7159
7409
  return _computeBookingQueryResult.apply(this, arguments);
7160
7410
  }
7161
7411
  return computeBookingQueryResult;
@@ -7214,20 +7464,26 @@ var Server = /*#__PURE__*/function () {
7214
7464
  }, {
7215
7465
  key: "computeProductQueryResult",
7216
7466
  value: (function () {
7217
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(context, options) {
7467
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(context, options) {
7218
7468
  var _menu_list_ids$length3,
7219
- _this19 = this;
7220
- 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;
7221
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7222
- while (1) switch (_context71.prev = _context71.next) {
7469
+ _this20 = this;
7470
+ 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;
7471
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7472
+ while (1) switch (_context73.prev = _context73.next) {
7223
7473
  case 0:
7224
7474
  tTotal = performance.now();
7225
- 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;
7475
+ 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;
7226
7476
  queryIds = Array.isArray(ids) ? ids.map(function (id) {
7227
7477
  return Number(id);
7228
7478
  }).filter(function (id) {
7229
7479
  return Number.isFinite(id);
7230
7480
  }) : [];
7481
+ formatterContext = this.buildProductFormatterContext({
7482
+ schedule_date: schedule_date,
7483
+ schedule_datetime: schedule_datetime,
7484
+ customer_id: customer_id,
7485
+ strategy_context: strategy_context
7486
+ });
7231
7487
  this.logInfo('computeProductQueryResult 开始', {
7232
7488
  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,
7233
7489
  ids: queryIds,
@@ -7236,38 +7492,32 @@ var Server = /*#__PURE__*/function () {
7236
7492
  customer_id: customer_id,
7237
7493
  extension_type: extension_type,
7238
7494
  product_id: product_id,
7495
+ strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
7239
7496
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7240
7497
  });
7241
7498
  if (this.products) {
7242
- _context71.next = 7;
7499
+ _context73.next = 8;
7243
7500
  break;
7244
7501
  }
7245
7502
  this.logError('computeProductQueryResult: Products 模块未注册');
7246
- return _context71.abrupt("return", {
7503
+ return _context73.abrupt("return", {
7247
7504
  message: 'Products 模块未注册',
7248
- data: {
7249
- list: [],
7250
- count: 0
7251
- }
7505
+ data: this.buildProductQueryResultPayload([], 0)
7252
7506
  });
7253
- case 7:
7507
+ case 8:
7254
7508
  if (!(queryIds.length > 0)) {
7255
- _context71.next = 19;
7509
+ _context73.next = 20;
7256
7510
  break;
7257
7511
  }
7258
7512
  uniqueIds = Array.from(new Set(queryIds));
7259
7513
  _tPrice = performance.now();
7260
- _context71.next = 12;
7261
- return this.products.getProductsWithPrice(schedule_date, {
7262
- scheduleModule: this.getSchedule(),
7263
- schedule_datetime: schedule_datetime,
7264
- customer_id: customer_id
7265
- }, {
7514
+ _context73.next = 13;
7515
+ return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7266
7516
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7267
7517
  productIds: uniqueIds
7268
7518
  });
7269
- case 12:
7270
- productsWithPrice = _context71.sent;
7519
+ case 13:
7520
+ productsWithPrice = _context73.sent;
7271
7521
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7272
7522
  count: productsWithPrice.length,
7273
7523
  ids: uniqueIds
@@ -7287,30 +7537,25 @@ var Server = /*#__PURE__*/function () {
7287
7537
  ids: uniqueIds,
7288
7538
  count: extensionFilteredProducts.length
7289
7539
  });
7290
- return _context71.abrupt("return", {
7540
+ return _context73.abrupt("return", {
7291
7541
  code: 200,
7292
- data: {
7293
- list: extensionFilteredProducts,
7294
- count: extensionFilteredProducts.length
7295
- },
7542
+ data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7296
7543
  message: '',
7297
7544
  status: true
7298
7545
  });
7299
- case 19:
7546
+ case 20:
7300
7547
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7301
- _context71.next = 31;
7548
+ _context73.next = 32;
7302
7549
  break;
7303
7550
  }
7304
7551
  pid = Number(product_id);
7305
7552
  _tPrice2 = performance.now();
7306
- _context71.next = 24;
7307
- return this.products.getProductsWithPrice(schedule_date, {
7308
- scheduleModule: this.getSchedule()
7309
- }, {
7553
+ _context73.next = 25;
7554
+ return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7310
7555
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7311
7556
  });
7312
- case 24:
7313
- allProductsWithPrice = _context71.sent;
7557
+ case 25:
7558
+ allProductsWithPrice = _context73.sent;
7314
7559
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7315
7560
  count: allProductsWithPrice.length,
7316
7561
  productId: pid
@@ -7330,28 +7575,24 @@ var Server = /*#__PURE__*/function () {
7330
7575
  productId: pid,
7331
7576
  found: !!item
7332
7577
  });
7333
- return _context71.abrupt("return", {
7578
+ return _context73.abrupt("return", {
7334
7579
  code: 200,
7335
7580
  data: item,
7336
7581
  message: item ? '' : '商品不存在或未发布',
7337
7582
  status: true
7338
7583
  });
7339
- case 31:
7584
+ case 32:
7340
7585
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7341
- _context71.next = 51;
7586
+ _context73.next = 52;
7342
7587
  break;
7343
7588
  }
7344
7589
  _tPrice3 = performance.now();
7345
- _context71.next = 35;
7346
- return this.products.getProductsWithPrice(schedule_date, {
7347
- scheduleModule: this.getSchedule(),
7348
- schedule_datetime: schedule_datetime,
7349
- customer_id: customer_id
7350
- }, {
7590
+ _context73.next = 36;
7591
+ return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7351
7592
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7352
7593
  });
7353
- case 35:
7354
- _filteredProducts2 = _context71.sent;
7594
+ case 36:
7595
+ _filteredProducts2 = _context73.sent;
7355
7596
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7356
7597
  count: _filteredProducts2.length,
7357
7598
  extension_type: extension_type
@@ -7390,49 +7631,40 @@ var Server = /*#__PURE__*/function () {
7390
7631
  filteredCount: _filteredProducts2.length,
7391
7632
  extension_type: extension_type
7392
7633
  });
7393
- return _context71.abrupt("return", {
7634
+ return _context73.abrupt("return", {
7394
7635
  code: 200,
7395
- data: {
7396
- list: _filteredProducts2,
7397
- count: _filteredProducts2.length
7398
- },
7636
+ data: this.buildProductQueryResultPayload(_filteredProducts2),
7399
7637
  message: '',
7400
7638
  status: true
7401
7639
  });
7402
- case 51:
7640
+ case 52:
7403
7641
  if (this.menu) {
7404
- _context71.next = 54;
7642
+ _context73.next = 55;
7405
7643
  break;
7406
7644
  }
7407
7645
  this.logError('computeProductQueryResult: Menu 模块未注册');
7408
- return _context71.abrupt("return", {
7646
+ return _context73.abrupt("return", {
7409
7647
  message: 'Menu 模块未注册',
7410
- data: {
7411
- list: [],
7412
- count: 0
7413
- }
7648
+ data: this.buildProductQueryResultPayload([], 0)
7414
7649
  });
7415
- case 54:
7650
+ case 55:
7416
7651
  if (this.schedule) {
7417
- _context71.next = 57;
7652
+ _context73.next = 58;
7418
7653
  break;
7419
7654
  }
7420
7655
  this.logError('computeProductQueryResult: Schedule 模块未注册');
7421
- return _context71.abrupt("return", {
7656
+ return _context73.abrupt("return", {
7422
7657
  message: 'Schedule 模块未注册',
7423
- data: {
7424
- list: [],
7425
- count: 0
7426
- }
7658
+ data: this.buildProductQueryResultPayload([], 0)
7427
7659
  });
7428
- case 57:
7660
+ case 58:
7429
7661
  activeMenuList = [];
7430
7662
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
7431
7663
  tMenu = performance.now();
7432
7664
  menuList = this.menu.getMenuByIds(menu_list_ids);
7433
7665
  activeMenuList = menuList.filter(function (menu) {
7434
- var _this19$schedule;
7435
- return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7666
+ var _this20$schedule;
7667
+ return ((_this20$schedule = _this20.schedule) === null || _this20$schedule === void 0 ? void 0 : _this20$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7436
7668
  });
7437
7669
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
7438
7670
  totalMenu: menuList.length,
@@ -7449,26 +7681,22 @@ var Server = /*#__PURE__*/function () {
7449
7681
  });
7450
7682
  tPrice = performance.now();
7451
7683
  if (!(scopedProductIds.length > 0)) {
7452
- _context71.next = 70;
7684
+ _context73.next = 71;
7453
7685
  break;
7454
7686
  }
7455
- _context71.next = 67;
7456
- return this.products.getProductsWithPrice(schedule_date, {
7457
- scheduleModule: this.getSchedule(),
7458
- schedule_datetime: schedule_datetime,
7459
- customer_id: customer_id
7460
- }, {
7687
+ _context73.next = 68;
7688
+ return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7461
7689
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7462
7690
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
7463
7691
  });
7464
- case 67:
7465
- _context71.t0 = _context71.sent;
7466
- _context71.next = 71;
7692
+ case 68:
7693
+ _context73.t0 = _context73.sent;
7694
+ _context73.next = 72;
7467
7695
  break;
7468
- case 70:
7469
- _context71.t0 = [];
7470
7696
  case 71:
7471
- filteredProducts = _context71.t0;
7697
+ _context73.t0 = [];
7698
+ case 72:
7699
+ filteredProducts = _context73.t0;
7472
7700
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
7473
7701
  count: filteredProducts.length,
7474
7702
  scopedProductCount: scopedProductIds.length
@@ -7509,102 +7737,120 @@ var Server = /*#__PURE__*/function () {
7509
7737
  filteredCount: filteredProducts.length,
7510
7738
  activeMenuCount: activeMenuList.length
7511
7739
  });
7512
- return _context71.abrupt("return", {
7740
+ return _context73.abrupt("return", {
7513
7741
  code: 200,
7514
- data: {
7515
- list: filteredProducts,
7516
- count: filteredProducts.length
7517
- },
7742
+ data: this.buildProductQueryResultPayload(filteredProducts),
7518
7743
  message: '',
7519
7744
  status: true
7520
7745
  });
7521
- case 87:
7746
+ case 88:
7522
7747
  case "end":
7523
- return _context71.stop();
7748
+ return _context73.stop();
7524
7749
  }
7525
- }, _callee71, this);
7750
+ }, _callee73, this);
7526
7751
  }));
7527
- function computeProductQueryResult(_x78, _x79) {
7752
+ function computeProductQueryResult(_x81, _x82) {
7528
7753
  return _computeProductQueryResult.apply(this, arguments);
7529
7754
  }
7530
7755
  return computeProductQueryResult;
7531
7756
  }()
7757
+ /**
7758
+ * 构建商品格式化上下文。
7759
+ *
7760
+ * 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
7761
+ */
7762
+ )
7763
+ }, {
7764
+ key: "buildProductFormatterContext",
7765
+ value: function buildProductFormatterContext(context) {
7766
+ var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context4;
7767
+ var scheduleModule = this.getSchedule();
7768
+ return {
7769
+ scheduleModule: scheduleModule,
7770
+ schedule_datetime: context.schedule_datetime,
7771
+ customer_id: context.customer_id,
7772
+ strategy_context: context.strategy_context,
7773
+ 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)) || [],
7774
+ scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
7775
+ dataVariantEvaluator: (_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.dataVariantEvaluator
7776
+ };
7777
+ }
7778
+
7532
7779
  /**
7533
7780
  * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
7534
7781
  * 由 ProductsModule 的 onProductsSyncCompleted 事件触发
7535
7782
  * @param options 可选参数
7536
7783
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
7537
7784
  */
7538
- )
7539
7785
  }, {
7540
7786
  key: "recomputeAndNotifyProductQuery",
7541
7787
  value: (function () {
7542
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(options) {
7543
- var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
7544
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7545
- while (1) switch (_context72.prev = _context72.next) {
7788
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(options) {
7789
+ var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
7790
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7791
+ while (1) switch (_context74.prev = _context74.next) {
7546
7792
  case 0:
7547
7793
  if (!(this.productQuerySubscribers.size === 0)) {
7548
- _context72.next = 2;
7794
+ _context74.next = 2;
7549
7795
  break;
7550
7796
  }
7551
- return _context72.abrupt("return");
7797
+ return _context74.abrupt("return");
7552
7798
  case 2:
7553
7799
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
7554
7800
  subscriberCount: this.productQuerySubscribers.size,
7555
7801
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7556
7802
  });
7557
- _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
7558
- _context72.prev = 4;
7559
- _iterator18.s();
7803
+ _iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
7804
+ _context74.prev = 4;
7805
+ _iterator19.s();
7560
7806
  case 6:
7561
- if ((_step18 = _iterator18.n()).done) {
7562
- _context72.next = 22;
7807
+ if ((_step19 = _iterator19.n()).done) {
7808
+ _context74.next = 22;
7563
7809
  break;
7564
7810
  }
7565
- _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
7566
- _context72.prev = 8;
7567
- _context72.next = 11;
7811
+ _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
7812
+ _context74.prev = 8;
7813
+ _context74.next = 11;
7568
7814
  return this.computeProductQueryResult(subscriber.context, {
7569
7815
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7570
7816
  });
7571
7817
  case 11:
7572
- result = _context72.sent;
7818
+ result = _context74.sent;
7573
7819
  subscriber.callback(result);
7574
7820
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
7575
7821
  subscriberId: subscriberId
7576
7822
  });
7577
- _context72.next = 20;
7823
+ _context74.next = 20;
7578
7824
  break;
7579
7825
  case 16:
7580
- _context72.prev = 16;
7581
- _context72.t0 = _context72["catch"](8);
7582
- errorMessage = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7826
+ _context74.prev = 16;
7827
+ _context74.t0 = _context74["catch"](8);
7828
+ errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
7583
7829
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
7584
7830
  subscriberId: subscriberId,
7585
7831
  error: errorMessage
7586
7832
  });
7587
7833
  case 20:
7588
- _context72.next = 6;
7834
+ _context74.next = 6;
7589
7835
  break;
7590
7836
  case 22:
7591
- _context72.next = 27;
7837
+ _context74.next = 27;
7592
7838
  break;
7593
7839
  case 24:
7594
- _context72.prev = 24;
7595
- _context72.t1 = _context72["catch"](4);
7596
- _iterator18.e(_context72.t1);
7840
+ _context74.prev = 24;
7841
+ _context74.t1 = _context74["catch"](4);
7842
+ _iterator19.e(_context74.t1);
7597
7843
  case 27:
7598
- _context72.prev = 27;
7599
- _iterator18.f();
7600
- return _context72.finish(27);
7844
+ _context74.prev = 27;
7845
+ _iterator19.f();
7846
+ return _context74.finish(27);
7601
7847
  case 30:
7602
7848
  case "end":
7603
- return _context72.stop();
7849
+ return _context74.stop();
7604
7850
  }
7605
- }, _callee72, this, [[4, 24, 27, 30], [8, 16]]);
7851
+ }, _callee74, this, [[4, 24, 27, 30], [8, 16]]);
7606
7852
  }));
7607
- function recomputeAndNotifyProductQuery(_x80) {
7853
+ function recomputeAndNotifyProductQuery(_x83) {
7608
7854
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
7609
7855
  }
7610
7856
  return recomputeAndNotifyProductQuery;
@@ -7616,37 +7862,37 @@ var Server = /*#__PURE__*/function () {
7616
7862
  }, {
7617
7863
  key: "recomputeAndNotifyOrderQuery",
7618
7864
  value: (function () {
7619
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7620
- var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
7621
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7622
- while (1) switch (_context73.prev = _context73.next) {
7865
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75() {
7866
+ var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
7867
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7868
+ while (1) switch (_context75.prev = _context75.next) {
7623
7869
  case 0:
7624
7870
  if (!(this.orderQuerySubscribers.size === 0)) {
7625
- _context73.next = 2;
7871
+ _context75.next = 2;
7626
7872
  break;
7627
7873
  }
7628
- return _context73.abrupt("return");
7874
+ return _context75.abrupt("return");
7629
7875
  case 2:
7630
7876
  notifyStartAt = Date.now();
7631
7877
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
7632
7878
  subscriberCount: this.orderQuerySubscribers.size,
7633
7879
  notifyStartAt: new Date(notifyStartAt).toISOString()
7634
7880
  });
7635
- _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
7636
- _context73.prev = 5;
7637
- _iterator19.s();
7881
+ _iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
7882
+ _context75.prev = 5;
7883
+ _iterator20.s();
7638
7884
  case 7:
7639
- if ((_step19 = _iterator19.n()).done) {
7640
- _context73.next = 27;
7885
+ if ((_step20 = _iterator20.n()).done) {
7886
+ _context75.next = 27;
7641
7887
  break;
7642
7888
  }
7643
- _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
7644
- _context73.prev = 9;
7889
+ _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
7890
+ _context75.prev = 9;
7645
7891
  computeStartAt = Date.now();
7646
- _context73.next = 13;
7892
+ _context75.next = 13;
7647
7893
  return this.computeOrderQueryResult(subscriber.context);
7648
7894
  case 13:
7649
- result = _context73.sent;
7895
+ result = _context75.sent;
7650
7896
  computeEndAt = Date.now();
7651
7897
  callbackStartAt = Date.now();
7652
7898
  subscriber.callback(result);
@@ -7657,30 +7903,30 @@ var Server = /*#__PURE__*/function () {
7657
7903
  callbackDurationMs: callbackEndAt - callbackStartAt,
7658
7904
  totalDurationMs: callbackEndAt - computeStartAt
7659
7905
  });
7660
- _context73.next = 25;
7906
+ _context75.next = 25;
7661
7907
  break;
7662
7908
  case 21:
7663
- _context73.prev = 21;
7664
- _context73.t0 = _context73["catch"](9);
7665
- errorMessage = _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0);
7909
+ _context75.prev = 21;
7910
+ _context75.t0 = _context75["catch"](9);
7911
+ errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
7666
7912
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
7667
7913
  subscriberId: subscriberId,
7668
7914
  error: errorMessage
7669
7915
  });
7670
7916
  case 25:
7671
- _context73.next = 7;
7917
+ _context75.next = 7;
7672
7918
  break;
7673
7919
  case 27:
7674
- _context73.next = 32;
7920
+ _context75.next = 32;
7675
7921
  break;
7676
7922
  case 29:
7677
- _context73.prev = 29;
7678
- _context73.t1 = _context73["catch"](5);
7679
- _iterator19.e(_context73.t1);
7923
+ _context75.prev = 29;
7924
+ _context75.t1 = _context75["catch"](5);
7925
+ _iterator20.e(_context75.t1);
7680
7926
  case 32:
7681
- _context73.prev = 32;
7682
- _iterator19.f();
7683
- return _context73.finish(32);
7927
+ _context75.prev = 32;
7928
+ _iterator20.f();
7929
+ return _context75.finish(32);
7684
7930
  case 35:
7685
7931
  notifyEndAt = Date.now();
7686
7932
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -7689,9 +7935,9 @@ var Server = /*#__PURE__*/function () {
7689
7935
  });
7690
7936
  case 37:
7691
7937
  case "end":
7692
- return _context73.stop();
7938
+ return _context75.stop();
7693
7939
  }
7694
- }, _callee73, this, [[5, 29, 32, 35], [9, 21]]);
7940
+ }, _callee75, this, [[5, 29, 32, 35], [9, 21]]);
7695
7941
  }));
7696
7942
  function recomputeAndNotifyOrderQuery() {
7697
7943
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -7709,7 +7955,7 @@ var Server = /*#__PURE__*/function () {
7709
7955
  }, {
7710
7956
  key: "notifySalesSearchSubscribers",
7711
7957
  value: function notifySalesSearchSubscribers(payload) {
7712
- var _this20 = this;
7958
+ var _this21 = this;
7713
7959
  if (this.salesSearchSubscribers.size === 0) return;
7714
7960
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
7715
7961
  if (changedOrders.length === 0) {
@@ -7718,42 +7964,42 @@ var Server = /*#__PURE__*/function () {
7718
7964
  // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
7719
7965
  // 导致模块被销毁 ,checkout 弹窗永远无法关闭
7720
7966
  if (window.isPaymentModalPluginOpen) return;
7721
- var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
7722
- _step20;
7967
+ var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
7968
+ _step21;
7723
7969
  try {
7724
- var _loop = function _loop() {
7725
- var _step20$value = _slicedToArray(_step20.value, 2),
7726
- subscriberId = _step20$value[0],
7727
- subscriber = _step20$value[1];
7970
+ var _loop2 = function _loop2() {
7971
+ var _step21$value = _slicedToArray(_step21.value, 2),
7972
+ subscriberId = _step21$value[0],
7973
+ subscriber = _step21$value[1];
7728
7974
  try {
7729
7975
  var changedVisibleOrders = changedOrders.filter(function (order) {
7730
- var orderId = _this20.getSalesSearchOrderId(order);
7976
+ var orderId = _this21.getSalesSearchOrderId(order);
7731
7977
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
7732
7978
  });
7733
7979
  if (changedVisibleOrders.length === 0) {
7734
7980
  return 1; // continue
7735
7981
  }
7736
- subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
7737
- _this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
7982
+ subscriber.callback(_this21.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
7983
+ _this21.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
7738
7984
  subscriberId: subscriberId,
7739
7985
  kind: subscriber.kind,
7740
7986
  count: changedVisibleOrders.length
7741
7987
  });
7742
7988
  } catch (error) {
7743
7989
  var errorMessage = error instanceof Error ? error.message : String(error);
7744
- _this20.logError('notifySalesSearchSubscribers: 推送失败', {
7990
+ _this21.logError('notifySalesSearchSubscribers: 推送失败', {
7745
7991
  subscriberId: subscriberId,
7746
7992
  error: errorMessage
7747
7993
  });
7748
7994
  }
7749
7995
  };
7750
- for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
7751
- if (_loop()) continue;
7996
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
7997
+ if (_loop2()) continue;
7752
7998
  }
7753
7999
  } catch (err) {
7754
- _iterator20.e(err);
8000
+ _iterator21.e(err);
7755
8001
  } finally {
7756
- _iterator20.f();
8002
+ _iterator21.f();
7757
8003
  }
7758
8004
  }
7759
8005
 
@@ -7832,67 +8078,67 @@ var Server = /*#__PURE__*/function () {
7832
8078
  }, {
7833
8079
  key: "recomputeAndNotifyBookingQuery",
7834
8080
  value: (function () {
7835
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74() {
7836
- var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
7837
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7838
- while (1) switch (_context74.prev = _context74.next) {
8081
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
8082
+ var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
8083
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8084
+ while (1) switch (_context76.prev = _context76.next) {
7839
8085
  case 0:
7840
8086
  if (!(this.bookingQuerySubscribers.size === 0)) {
7841
- _context74.next = 2;
8087
+ _context76.next = 2;
7842
8088
  break;
7843
8089
  }
7844
- return _context74.abrupt("return");
8090
+ return _context76.abrupt("return");
7845
8091
  case 2:
7846
8092
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
7847
8093
  subscriberCount: this.bookingQuerySubscribers.size
7848
8094
  });
7849
- _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
7850
- _context74.prev = 4;
7851
- _iterator21.s();
8095
+ _iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8096
+ _context76.prev = 4;
8097
+ _iterator22.s();
7852
8098
  case 6:
7853
- if ((_step21 = _iterator21.n()).done) {
7854
- _context74.next = 22;
8099
+ if ((_step22 = _iterator22.n()).done) {
8100
+ _context76.next = 22;
7855
8101
  break;
7856
8102
  }
7857
- _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
7858
- _context74.prev = 8;
7859
- _context74.next = 11;
8103
+ _step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
8104
+ _context76.prev = 8;
8105
+ _context76.next = 11;
7860
8106
  return this.computeBookingQueryResult(subscriber.context);
7861
8107
  case 11:
7862
- result = _context74.sent;
8108
+ result = _context76.sent;
7863
8109
  subscriber.callback(result);
7864
8110
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
7865
8111
  subscriberId: subscriberId
7866
8112
  });
7867
- _context74.next = 20;
8113
+ _context76.next = 20;
7868
8114
  break;
7869
8115
  case 16:
7870
- _context74.prev = 16;
7871
- _context74.t0 = _context74["catch"](8);
7872
- errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
8116
+ _context76.prev = 16;
8117
+ _context76.t0 = _context76["catch"](8);
8118
+ errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
7873
8119
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
7874
8120
  subscriberId: subscriberId,
7875
8121
  error: errorMessage
7876
8122
  });
7877
8123
  case 20:
7878
- _context74.next = 6;
8124
+ _context76.next = 6;
7879
8125
  break;
7880
8126
  case 22:
7881
- _context74.next = 27;
8127
+ _context76.next = 27;
7882
8128
  break;
7883
8129
  case 24:
7884
- _context74.prev = 24;
7885
- _context74.t1 = _context74["catch"](4);
7886
- _iterator21.e(_context74.t1);
8130
+ _context76.prev = 24;
8131
+ _context76.t1 = _context76["catch"](4);
8132
+ _iterator22.e(_context76.t1);
7887
8133
  case 27:
7888
- _context74.prev = 27;
7889
- _iterator21.f();
7890
- return _context74.finish(27);
8134
+ _context76.prev = 27;
8135
+ _iterator22.f();
8136
+ return _context76.finish(27);
7891
8137
  case 30:
7892
8138
  case "end":
7893
- return _context74.stop();
8139
+ return _context76.stop();
7894
8140
  }
7895
- }, _callee74, this, [[4, 24, 27, 30], [8, 16]]);
8141
+ }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
7896
8142
  }));
7897
8143
  function recomputeAndNotifyBookingQuery() {
7898
8144
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -7922,11 +8168,11 @@ var Server = /*#__PURE__*/function () {
7922
8168
  var allowedProductIds = new Set();
7923
8169
  var allowedCollectionIds = new Set();
7924
8170
  var hasProductAll = false;
7925
- var _iterator22 = _createForOfIteratorHelper(activeMenuList),
7926
- _step22;
8171
+ var _iterator23 = _createForOfIteratorHelper(activeMenuList),
8172
+ _step23;
7927
8173
  try {
7928
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
7929
- var menu = _step22.value;
8174
+ for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
8175
+ var menu = _step23.value;
7930
8176
  var config = menu.partyroom_package;
7931
8177
  if (!config) {
7932
8178
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -7986,9 +8232,9 @@ var Server = /*#__PURE__*/function () {
7986
8232
 
7987
8233
  // 如果有餐牌允许所有商品,返回所有商品
7988
8234
  } catch (err) {
7989
- _iterator22.e(err);
8235
+ _iterator23.e(err);
7990
8236
  } finally {
7991
- _iterator22.f();
8237
+ _iterator23.f();
7992
8238
  }
7993
8239
  if (hasProductAll) {
7994
8240
  this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');