@pisell/pisellos 2.3.53 → 2.3.55

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 (149) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Discount/index.d.ts +1 -0
  3. package/dist/modules/Discount/index.js +40 -11
  4. package/dist/modules/Discount/types.d.ts +1 -0
  5. package/dist/modules/Holder/index.d.ts +48 -0
  6. package/dist/modules/Holder/index.js +640 -0
  7. package/dist/modules/Holder/types.d.ts +123 -0
  8. package/dist/modules/Holder/types.js +1 -0
  9. package/dist/modules/Holder/utils.d.ts +13 -0
  10. package/dist/modules/Holder/utils.js +34 -0
  11. package/dist/modules/OpenData/index.js +2 -2
  12. package/dist/modules/Order/index.d.ts +4 -2
  13. package/dist/modules/Order/index.js +66 -34
  14. package/dist/modules/Order/types.d.ts +9 -0
  15. package/dist/modules/Order/utils.d.ts +10 -0
  16. package/dist/modules/Order/utils.js +35 -3
  17. package/dist/modules/Product/types.d.ts +1 -0
  18. package/dist/modules/ProductList/index.js +34 -15
  19. package/dist/modules/Quotation/index.d.ts +1 -1
  20. package/dist/modules/Quotation/index.js +2 -2
  21. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  22. package/dist/modules/ResourcePlanner/index.js +181 -0
  23. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  24. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  25. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  26. package/dist/modules/ResourcePlanner/types.js +1 -0
  27. package/dist/modules/Rules/index.js +47 -13
  28. package/dist/modules/SalesSummary/index.js +12 -13
  29. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  30. package/dist/modules/ScanOrderLogger/index.js +15 -2
  31. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  32. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  33. package/dist/modules/Schedule/index.d.ts +3 -1
  34. package/dist/modules/Schedule/index.js +21 -16
  35. package/dist/modules/Summary/utils.js +38 -13
  36. package/dist/modules/index.d.ts +2 -0
  37. package/dist/modules/index.js +3 -1
  38. package/dist/plugins/window.d.ts +1 -0
  39. package/dist/server/index.d.ts +14 -0
  40. package/dist/server/index.js +907 -793
  41. package/dist/solution/BaseSales/index.d.ts +7 -0
  42. package/dist/solution/BaseSales/index.js +64 -42
  43. package/dist/solution/BaseSales/utils/cartPromotion.js +4 -1
  44. package/dist/solution/BookingByStep/index.d.ts +17 -2
  45. package/dist/solution/BookingByStep/index.js +294 -215
  46. package/dist/solution/BookingByStep/types.d.ts +2 -1
  47. package/dist/solution/BookingByStep/types.js +3 -1
  48. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  49. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  50. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  51. package/dist/solution/BookingTicket/index.d.ts +14 -2
  52. package/dist/solution/BookingTicket/index.js +2 -2
  53. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  54. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  55. package/dist/solution/ScanOrder/index.d.ts +26 -14
  56. package/dist/solution/ScanOrder/index.js +1142 -739
  57. package/dist/solution/ScanOrder/types.d.ts +21 -1
  58. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  59. package/dist/solution/ScanOrder/utils.js +66 -25
  60. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  61. package/dist/solution/ShopDiscount/index.js +125 -87
  62. package/dist/solution/UnifiedBookingSales/index.d.ts +179 -0
  63. package/dist/solution/UnifiedBookingSales/index.js +1892 -0
  64. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  65. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  66. package/dist/solution/VenueBooking/index.d.ts +39 -11
  67. package/dist/solution/VenueBooking/index.js +1167 -841
  68. package/dist/solution/VenueBooking/types.d.ts +3 -0
  69. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  70. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  71. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  72. package/dist/solution/index.d.ts +1 -0
  73. package/dist/solution/index.js +2 -1
  74. package/dist/types/index.d.ts +1 -0
  75. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  76. package/lib/modules/Discount/index.d.ts +1 -0
  77. package/lib/modules/Discount/index.js +9 -0
  78. package/lib/modules/Discount/types.d.ts +1 -0
  79. package/lib/modules/Holder/index.d.ts +48 -0
  80. package/lib/modules/Holder/index.js +402 -0
  81. package/lib/modules/Holder/types.d.ts +123 -0
  82. package/lib/modules/Holder/types.js +17 -0
  83. package/lib/modules/Holder/utils.d.ts +13 -0
  84. package/lib/modules/Holder/utils.js +71 -0
  85. package/lib/modules/OpenData/index.js +1 -1
  86. package/lib/modules/Order/index.d.ts +4 -2
  87. package/lib/modules/Order/index.js +30 -13
  88. package/lib/modules/Order/types.d.ts +9 -0
  89. package/lib/modules/Order/utils.d.ts +10 -0
  90. package/lib/modules/Order/utils.js +36 -5
  91. package/lib/modules/Product/types.d.ts +1 -0
  92. package/lib/modules/ProductList/index.js +48 -31
  93. package/lib/modules/Quotation/index.d.ts +1 -1
  94. package/lib/modules/Quotation/index.js +2 -2
  95. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  96. package/lib/modules/ResourcePlanner/index.js +148 -0
  97. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  98. package/lib/modules/ResourcePlanner/planner.js +933 -0
  99. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  100. package/lib/modules/ResourcePlanner/types.js +17 -0
  101. package/lib/modules/Rules/index.js +33 -16
  102. package/lib/modules/SalesSummary/index.js +6 -7
  103. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  104. package/lib/modules/ScanOrderLogger/index.js +13 -1
  105. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  106. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  107. package/lib/modules/Schedule/index.d.ts +3 -1
  108. package/lib/modules/Schedule/index.js +10 -8
  109. package/lib/modules/Summary/utils.js +21 -1
  110. package/lib/modules/index.d.ts +2 -0
  111. package/lib/modules/index.js +5 -1
  112. package/lib/plugins/window.d.ts +1 -0
  113. package/lib/server/index.d.ts +14 -0
  114. package/lib/server/index.js +72 -15
  115. package/lib/solution/BaseSales/index.d.ts +7 -0
  116. package/lib/solution/BaseSales/index.js +24 -8
  117. package/lib/solution/BaseSales/utils/cartPromotion.js +3 -0
  118. package/lib/solution/BookingByStep/index.d.ts +17 -2
  119. package/lib/solution/BookingByStep/index.js +60 -18
  120. package/lib/solution/BookingByStep/types.d.ts +2 -1
  121. package/lib/solution/BookingByStep/types.js +5 -0
  122. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  123. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  124. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  125. package/lib/solution/BookingTicket/index.d.ts +14 -2
  126. package/lib/solution/BookingTicket/index.js +10 -2
  127. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  128. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  129. package/lib/solution/ScanOrder/index.d.ts +26 -14
  130. package/lib/solution/ScanOrder/index.js +449 -182
  131. package/lib/solution/ScanOrder/types.d.ts +21 -1
  132. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  133. package/lib/solution/ScanOrder/utils.js +31 -0
  134. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  135. package/lib/solution/ShopDiscount/index.js +14 -0
  136. package/lib/solution/UnifiedBookingSales/index.d.ts +179 -0
  137. package/lib/solution/UnifiedBookingSales/index.js +1085 -0
  138. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  139. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  140. package/lib/solution/VenueBooking/index.d.ts +39 -11
  141. package/lib/solution/VenueBooking/index.js +322 -110
  142. package/lib/solution/VenueBooking/types.d.ts +3 -0
  143. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  144. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  145. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  146. package/lib/solution/index.d.ts +1 -0
  147. package/lib/solution/index.js +3 -1
  148. package/lib/types/index.d.ts +1 -0
  149. package/package.json +1 -1
@@ -99,6 +99,10 @@ var Server = /*#__PURE__*/function () {
99
99
  _defineProperty(this, "productQuerySubscribers", new Map());
100
100
  /** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
101
101
  _defineProperty(this, "productQueryScheduleTimers", new Map());
102
+ /** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
103
+ _defineProperty(this, "menuScheduleRefreshInFlight", null);
104
+ _defineProperty(this, "lastMenuScheduleRefreshAt", 0);
105
+ _defineProperty(this, "MENU_SCHEDULE_REFRESH_COOLDOWN_MS", 30 * 1000);
102
106
  // ---- 订单 / 预约列表查询订阅者 ----
103
107
  _defineProperty(this, "orderQuerySubscribers", new Map());
104
108
  _defineProperty(this, "bookingQuerySubscribers", new Map());
@@ -278,13 +282,17 @@ var Server = /*#__PURE__*/function () {
278
282
  */
279
283
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
280
284
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
281
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
285
+ var url, method, data, config, menu_list_ids, customer_id, ids, extension_type, strategy_context, _this$resolveProductQ, schedule_date, schedule_datetime, _ref7, callback, subscriberId, result;
282
286
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
283
287
  while (1) switch (_context3.prev = _context3.next) {
284
288
  case 0:
285
289
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
286
290
  console.log('[Server] handleProductQuery:', url, method, data, config);
287
- 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;
291
+ menu_list_ids = data.menu_list_ids, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
292
+ _this$resolveProductQ = _this.resolveProductQueryScheduleContext({
293
+ schedule_date: data.schedule_date,
294
+ schedule_datetime: data.schedule_datetime
295
+ }), schedule_date = _this$resolveProductQ.schedule_date, schedule_datetime = _this$resolveProductQ.schedule_datetime;
288
296
  _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
289
297
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
290
298
  menu_list_ids: menu_list_ids,
@@ -315,7 +323,7 @@ var Server = /*#__PURE__*/function () {
315
323
  totalSubscribers: _this.productQuerySubscribers.size
316
324
  });
317
325
  }
318
- _context3.next = 8;
326
+ _context3.next = 9;
319
327
  return _this.computeProductQueryResult({
320
328
  menu_list_ids: menu_list_ids,
321
329
  ids: ids,
@@ -325,13 +333,13 @@ var Server = /*#__PURE__*/function () {
325
333
  extension_type: extension_type,
326
334
  strategy_context: strategy_context
327
335
  });
328
- case 8:
336
+ case 9:
329
337
  result = _context3.sent;
330
338
  if (subscriberId && typeof callback === 'function') {
331
339
  _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
332
340
  }
333
341
  return _context3.abrupt("return", result);
334
- case 11:
342
+ case 12:
335
343
  case "end":
336
344
  return _context3.stop();
337
345
  }
@@ -3506,26 +3514,25 @@ var Server = /*#__PURE__*/function () {
3506
3514
  if (!subscriber || !timePoints.length) return;
3507
3515
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
3508
3516
  var timerIds = [];
3509
- var _iterator5 = _createForOfIteratorHelper(timePoints),
3510
- _step5;
3511
- try {
3512
- var _loop = function _loop() {
3513
- var timePoint = _step5.value;
3514
- var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
3515
- if (delayMs < 0) return 1; // continue
3516
- var timerId = setTimeout(function () {
3517
- void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
3518
- }, delayMs);
3519
- timerIds.push(timerId);
3520
- };
3521
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3522
- if (_loop()) continue;
3517
+
3518
+ // ['07:00', '13:00', '15:00', '17:00']
3519
+ // for (const timePoint of timePoints) {
3520
+ // let delayMs = this.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
3521
+ // if (delayMs < 0) {
3522
+ // delayMs = this.computeScheduleTimePointDelayMs(dayjs(scheduleDate).add(1, 'day').format('YYYY-MM-DD'), timePoint);
3523
+ // };
3524
+
3525
+ // const timerId = setTimeout(() => {
3526
+ // void this.onScheduleTimePointTimerFire(subscriberId, timerId);
3527
+ // }, delayMs);
3528
+ // timerIds.push(timerId);
3529
+ // }
3530
+ setInterval(function () {
3531
+ var currentTime = dayjs().format('hh:mm');
3532
+ if (timePoints.includes(currentTime)) {
3533
+ _this7.onScheduleTimePointTimerFire(subscriberId);
3523
3534
  }
3524
- } catch (err) {
3525
- _iterator5.e(err);
3526
- } finally {
3527
- _iterator5.f();
3528
- }
3535
+ }, 60000);
3529
3536
  if (timerIds.length > 0) {
3530
3537
  this.productQueryScheduleTimers.set(subscriberId, timerIds);
3531
3538
  subscriber.scheduleTimerIds = timerIds;
@@ -3548,7 +3555,7 @@ var Server = /*#__PURE__*/function () {
3548
3555
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3549
3556
  while (1) switch (_context41.prev = _context41.next) {
3550
3557
  case 0:
3551
- this.removeScheduleTimerRef(subscriberId, timerId);
3558
+ timerId && this.removeScheduleTimerRef(subscriberId, timerId);
3552
3559
  if (this.productQuerySubscribers.has(subscriberId)) {
3553
3560
  _context41.next = 3;
3554
3561
  break;
@@ -3637,6 +3644,76 @@ var Server = /*#__PURE__*/function () {
3637
3644
  this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3638
3645
  }
3639
3646
  }
3647
+ }, {
3648
+ key: "resolveProductQueryScheduleContext",
3649
+ value:
3650
+ /**
3651
+ * ProductList callers such as standalone retail pages do not always have a selected schedule.
3652
+ * In that case query against the current local time so menu availability can still be evaluated.
3653
+ */
3654
+ function resolveProductQueryScheduleContext(params) {
3655
+ var now = dayjs();
3656
+ var schedule_datetime = typeof params.schedule_datetime === 'string' && params.schedule_datetime.trim() ? params.schedule_datetime : now.format('YYYY-MM-DD HH:mm:ss');
3657
+ var schedule_date = typeof params.schedule_date === 'string' && params.schedule_date.trim() ? params.schedule_date : dayjs(schedule_datetime).isValid() ? dayjs(schedule_datetime).format('YYYY-MM-DD') : now.format('YYYY-MM-DD');
3658
+ return {
3659
+ schedule_date: schedule_date,
3660
+ schedule_datetime: schedule_datetime
3661
+ };
3662
+ }
3663
+
3664
+ /**
3665
+ * OpenData 的关联餐牌可能已更新,而 server_menu/server_schedule 仍命中本地持久化缓存。
3666
+ * 仅在当前筛选没有任何生效餐牌时刷新一次,并由调用方重新计算筛选结果。
3667
+ */
3668
+ }, {
3669
+ key: "refreshMenuScheduleCacheAfterEmptyResult",
3670
+ value: (function () {
3671
+ var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3672
+ var _this8 = this;
3673
+ var now;
3674
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3675
+ while (1) switch (_context43.prev = _context43.next) {
3676
+ case 0:
3677
+ if (!(!this.menu || !this.schedule)) {
3678
+ _context43.next = 2;
3679
+ break;
3680
+ }
3681
+ return _context43.abrupt("return", false);
3682
+ case 2:
3683
+ now = Date.now();
3684
+ if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
3685
+ _context43.next = 5;
3686
+ break;
3687
+ }
3688
+ return _context43.abrupt("return", false);
3689
+ case 5:
3690
+ if (!this.menuScheduleRefreshInFlight) {
3691
+ this.lastMenuScheduleRefreshAt = now;
3692
+ this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
3693
+ return undefined;
3694
+ }).catch(function (error) {
3695
+ _this8.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3696
+ error: error instanceof Error ? error.message : String(error)
3697
+ });
3698
+ }).finally(function () {
3699
+ _this8.menuScheduleRefreshInFlight = null;
3700
+ });
3701
+ }
3702
+ _context43.next = 8;
3703
+ return this.menuScheduleRefreshInFlight;
3704
+ case 8:
3705
+ return _context43.abrupt("return", true);
3706
+ case 9:
3707
+ case "end":
3708
+ return _context43.stop();
3709
+ }
3710
+ }, _callee43, this);
3711
+ }));
3712
+ function refreshMenuScheduleCacheAfterEmptyResult() {
3713
+ return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
3714
+ }
3715
+ return refreshMenuScheduleCacheAfterEmptyResult;
3716
+ }())
3640
3717
  }, {
3641
3718
  key: "handleSalesSearchRequest",
3642
3719
  value: (
@@ -3648,32 +3725,32 @@ var Server = /*#__PURE__*/function () {
3648
3725
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3649
3726
  */
3650
3727
  function () {
3651
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(kind, backendPath, data, config) {
3652
- var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3653
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3654
- while (1) switch (_context43.prev = _context43.next) {
3728
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(kind, backendPath, data, config) {
3729
+ var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3730
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3731
+ while (1) switch (_context44.prev = _context44.next) {
3655
3732
  case 0:
3656
3733
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3657
- _context43.next = 3;
3734
+ _context44.next = 3;
3658
3735
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3659
3736
  case 3:
3660
- result = _context43.sent;
3737
+ result = _context44.sent;
3661
3738
  _ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
3662
3739
  if (subscriberId && typeof callback === 'function') {
3663
3740
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3664
3741
  existing = this.salesSearchSubscribers.get(subscriberId);
3665
3742
  shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
3666
3743
  visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
3667
- _iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3744
+ _iterator5 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
3668
3745
  try {
3669
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3670
- orderId = _step6.value;
3746
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3747
+ orderId = _step5.value;
3671
3748
  visibleOrderIds.add(orderId);
3672
3749
  }
3673
3750
  } catch (err) {
3674
- _iterator6.e(err);
3751
+ _iterator5.e(err);
3675
3752
  } finally {
3676
- _iterator6.f();
3753
+ _iterator5.f();
3677
3754
  }
3678
3755
  this.salesSearchSubscribers.set(subscriberId, {
3679
3756
  callback: callback,
@@ -3689,12 +3766,12 @@ var Server = /*#__PURE__*/function () {
3689
3766
  visibleCount: visibleOrderIds.size
3690
3767
  });
3691
3768
  }
3692
- return _context43.abrupt("return", result);
3769
+ return _context44.abrupt("return", result);
3693
3770
  case 7:
3694
3771
  case "end":
3695
- return _context43.stop();
3772
+ return _context44.stop();
3696
3773
  }
3697
- }, _callee43, this);
3774
+ }, _callee44, this);
3698
3775
  }));
3699
3776
  function handleSalesSearchRequest(_x43, _x44, _x45, _x46) {
3700
3777
  return _handleSalesSearchRequest.apply(this, arguments);
@@ -3711,20 +3788,20 @@ var Server = /*#__PURE__*/function () {
3711
3788
  }, {
3712
3789
  key: "fetchSalesSearchFromAPI",
3713
3790
  value: (function () {
3714
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(backendPath, data) {
3791
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(backendPath, data) {
3715
3792
  var _this$app8;
3716
3793
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3717
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3718
- while (1) switch (_context44.prev = _context44.next) {
3794
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3795
+ while (1) switch (_context45.prev = _context45.next) {
3719
3796
  case 0:
3720
3797
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3721
- _context44.next = 3;
3798
+ _context45.next = 3;
3722
3799
  break;
3723
3800
  }
3724
3801
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3725
3802
  backendPath: backendPath
3726
3803
  });
3727
- return _context44.abrupt("return", {
3804
+ return _context45.abrupt("return", {
3728
3805
  code: 500,
3729
3806
  message: 'app.request 不可用',
3730
3807
  data: backendPath === '/shop/es/search' ? {
@@ -3736,29 +3813,29 @@ var Server = /*#__PURE__*/function () {
3736
3813
  status: false
3737
3814
  });
3738
3815
  case 3:
3739
- _context44.prev = 3;
3740
- _context44.next = 6;
3816
+ _context45.prev = 3;
3817
+ _context45.next = 6;
3741
3818
  return this.app.request.post(backendPath, data, {
3742
3819
  isShopApi: true
3743
3820
  });
3744
3821
  case 6:
3745
- response = _context44.sent;
3822
+ response = _context45.sent;
3746
3823
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3747
- return _context44.abrupt("return", {
3824
+ return _context45.abrupt("return", {
3748
3825
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3749
3826
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3750
3827
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3751
3828
  data: _payload
3752
3829
  });
3753
3830
  case 11:
3754
- _context44.prev = 11;
3755
- _context44.t0 = _context44["catch"](3);
3756
- errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
3831
+ _context45.prev = 11;
3832
+ _context45.t0 = _context45["catch"](3);
3833
+ errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
3757
3834
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3758
3835
  backendPath: backendPath,
3759
3836
  error: errorMessage
3760
3837
  });
3761
- return _context44.abrupt("return", {
3838
+ return _context45.abrupt("return", {
3762
3839
  code: 500,
3763
3840
  message: errorMessage,
3764
3841
  data: backendPath === '/shop/es/search' ? {
@@ -3771,9 +3848,9 @@ var Server = /*#__PURE__*/function () {
3771
3848
  });
3772
3849
  case 16:
3773
3850
  case "end":
3774
- return _context44.stop();
3851
+ return _context45.stop();
3775
3852
  }
3776
- }, _callee44, this, [[3, 11]]);
3853
+ }, _callee45, this, [[3, 11]]);
3777
3854
  }));
3778
3855
  function fetchSalesSearchFromAPI(_x47, _x48) {
3779
3856
  return _fetchSalesSearchFromAPI.apply(this, arguments);
@@ -3805,10 +3882,10 @@ var Server = /*#__PURE__*/function () {
3805
3882
  }, {
3806
3883
  key: "stripSalesSearchPageParams",
3807
3884
  value: function stripSalesSearchPageParams(value) {
3808
- var _this8 = this;
3885
+ var _this9 = this;
3809
3886
  if (Array.isArray(value)) {
3810
3887
  return value.map(function (item) {
3811
- return _this8.stripSalesSearchPageParams(item);
3888
+ return _this9.stripSalesSearchPageParams(item);
3812
3889
  });
3813
3890
  }
3814
3891
  if (!value || _typeof(value) !== 'object') return value;
@@ -3846,12 +3923,12 @@ var Server = /*#__PURE__*/function () {
3846
3923
  key: "extractSalesSearchOrderIds",
3847
3924
  value: function extractSalesSearchOrderIds(kind, result) {
3848
3925
  var _this$findSalesSearch,
3849
- _this9 = this;
3926
+ _this10 = this;
3850
3927
  var data = this.extractSalesSearchResponseData(result);
3851
3928
  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;
3852
3929
  if (!Array.isArray(list)) return [];
3853
3930
  return list.map(function (item) {
3854
- return _this9.getSalesSearchOrderId(item);
3931
+ return _this10.getSalesSearchOrderId(item);
3855
3932
  }).filter(function (id) {
3856
3933
  return !!id;
3857
3934
  });
@@ -4018,11 +4095,11 @@ var Server = /*#__PURE__*/function () {
4018
4095
  }, {
4019
4096
  key: "stableSerialize",
4020
4097
  value: function stableSerialize(value) {
4021
- var _this10 = this;
4098
+ var _this11 = this;
4022
4099
  if (value === null || value === undefined) return 'null';
4023
4100
  if (Array.isArray(value)) {
4024
4101
  return "[".concat(value.map(function (item) {
4025
- return _this10.stableSerialize(item);
4102
+ return _this11.stableSerialize(item);
4026
4103
  }).join(','), "]");
4027
4104
  }
4028
4105
  if (_typeof(value) === 'object') {
@@ -4031,7 +4108,7 @@ var Server = /*#__PURE__*/function () {
4031
4108
  return obj[k] !== undefined;
4032
4109
  }).sort();
4033
4110
  return "{".concat(keys.map(function (k) {
4034
- return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
4111
+ return "".concat(JSON.stringify(k), ":").concat(_this11.stableSerialize(obj[k]));
4035
4112
  }).join(','), "}");
4036
4113
  }
4037
4114
  return JSON.stringify(value);
@@ -4080,22 +4157,22 @@ var Server = /*#__PURE__*/function () {
4080
4157
  }
4081
4158
  var oldestKey = null;
4082
4159
  var oldestTime = Number.POSITIVE_INFINITY;
4083
- var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4084
- _step7;
4160
+ var _iterator6 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4161
+ _step6;
4085
4162
  try {
4086
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
4087
- var _step7$value = _slicedToArray(_step7.value, 2),
4088
- _key3 = _step7$value[0],
4089
- cache = _step7$value[1];
4163
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
4164
+ var _step6$value = _slicedToArray(_step6.value, 2),
4165
+ _key3 = _step6$value[0],
4166
+ cache = _step6$value[1];
4090
4167
  if (cache.updatedAt < oldestTime) {
4091
4168
  oldestTime = cache.updatedAt;
4092
4169
  oldestKey = _key3;
4093
4170
  }
4094
4171
  }
4095
4172
  } catch (err) {
4096
- _iterator7.e(err);
4173
+ _iterator6.e(err);
4097
4174
  } finally {
4098
- _iterator7.f();
4175
+ _iterator6.f();
4099
4176
  }
4100
4177
  if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
4101
4178
  }
@@ -4111,17 +4188,17 @@ var Server = /*#__PURE__*/function () {
4111
4188
  key: "markBookingRemoteCacheAllStale",
4112
4189
  value: function markBookingRemoteCacheAllStale(reason) {
4113
4190
  if (this.bookingRemoteCache.size === 0) return;
4114
- var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
4115
- _step8;
4191
+ var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
4192
+ _step7;
4116
4193
  try {
4117
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
4118
- var entry = _step8.value;
4194
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
4195
+ var entry = _step7.value;
4119
4196
  entry.stale = true;
4120
4197
  }
4121
4198
  } catch (err) {
4122
- _iterator8.e(err);
4199
+ _iterator7.e(err);
4123
4200
  } finally {
4124
- _iterator8.f();
4201
+ _iterator7.f();
4125
4202
  }
4126
4203
  this.logWarning('bookingRemoteCache: 全量标记失效', {
4127
4204
  reason: reason,
@@ -4147,13 +4224,13 @@ var Server = /*#__PURE__*/function () {
4147
4224
  key: "notifyBookingRemoteSubscribersByCacheKey",
4148
4225
  value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
4149
4226
  if (this.bookingRemoteQuerySubscribers.size === 0) return;
4150
- var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
4151
- _step9;
4227
+ var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
4228
+ _step8;
4152
4229
  try {
4153
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
4154
- var _step9$value = _slicedToArray(_step9.value, 2),
4155
- subscriberId = _step9$value[0],
4156
- subscriber = _step9$value[1];
4230
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
4231
+ var _step8$value = _slicedToArray(_step8.value, 2),
4232
+ subscriberId = _step8$value[0],
4233
+ subscriber = _step8$value[1];
4157
4234
  if (subscriber.cacheKey !== cacheKey) continue;
4158
4235
  try {
4159
4236
  var callbackStartAt = Date.now();
@@ -4180,9 +4257,9 @@ var Server = /*#__PURE__*/function () {
4180
4257
  }
4181
4258
  }
4182
4259
  } catch (err) {
4183
- _iterator9.e(err);
4260
+ _iterator8.e(err);
4184
4261
  } finally {
4185
- _iterator9.f();
4262
+ _iterator8.f();
4186
4263
  }
4187
4264
  }
4188
4265
  }, {
@@ -4197,13 +4274,13 @@ var Server = /*#__PURE__*/function () {
4197
4274
  return;
4198
4275
  }
4199
4276
  var syncedEntryCount = 0;
4200
- var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4201
- _step10;
4277
+ var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
4278
+ _step9;
4202
4279
  try {
4203
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
4204
- var _step10$value = _slicedToArray(_step10.value, 2),
4205
- cacheKey = _step10$value[0],
4206
- entry = _step10$value[1];
4280
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
4281
+ var _step9$value = _slicedToArray(_step9.value, 2),
4282
+ cacheKey = _step9$value[0],
4283
+ entry = _step9$value[1];
4207
4284
  if (entry.stale) {
4208
4285
  this.bookingRemoteCache.delete(cacheKey);
4209
4286
  continue;
@@ -4211,25 +4288,25 @@ var Server = /*#__PURE__*/function () {
4211
4288
  try {
4212
4289
  var queryPayload = entry.queryPayload;
4213
4290
  var orderMap = new Map();
4214
- var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
4215
- _step11;
4291
+ var _iterator10 = _createForOfIteratorHelper(entry.rawOrders),
4292
+ _step10;
4216
4293
  try {
4217
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
4218
- var order = _step11.value;
4294
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
4295
+ var order = _step10.value;
4219
4296
  var _key4 = this.toOrderIdKey(order);
4220
4297
  if (_key4) orderMap.set(_key4, order);
4221
4298
  }
4222
4299
  } catch (err) {
4223
- _iterator11.e(err);
4300
+ _iterator10.e(err);
4224
4301
  } finally {
4225
- _iterator11.f();
4302
+ _iterator10.f();
4226
4303
  }
4227
4304
  var changed = false;
4228
- var _iterator12 = _createForOfIteratorHelper(latestOrders),
4229
- _step12;
4305
+ var _iterator11 = _createForOfIteratorHelper(latestOrders),
4306
+ _step11;
4230
4307
  try {
4231
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
4232
- var latest = _step12.value;
4308
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
4309
+ var latest = _step11.value;
4233
4310
  var _key5 = this.toOrderIdKey(latest);
4234
4311
  if (!_key5) continue;
4235
4312
  if (orderMap.has(_key5)) {
@@ -4241,9 +4318,9 @@ var Server = /*#__PURE__*/function () {
4241
4318
  changed = true;
4242
4319
  }
4243
4320
  } catch (err) {
4244
- _iterator12.e(err);
4321
+ _iterator11.e(err);
4245
4322
  } finally {
4246
- _iterator12.f();
4323
+ _iterator11.f();
4247
4324
  }
4248
4325
  if (!changed) continue;
4249
4326
  var mergedOrders = _toConsumableArray(orderMap.values());
@@ -4276,9 +4353,9 @@ var Server = /*#__PURE__*/function () {
4276
4353
  }
4277
4354
  }
4278
4355
  } catch (err) {
4279
- _iterator10.e(err);
4356
+ _iterator9.e(err);
4280
4357
  } finally {
4281
- _iterator10.f();
4358
+ _iterator9.f();
4282
4359
  }
4283
4360
  var syncEndAt = Date.now();
4284
4361
  if (syncedEntryCount > 0) {
@@ -4296,18 +4373,18 @@ var Server = /*#__PURE__*/function () {
4296
4373
  }, {
4297
4374
  key: "fetchOrderListFromAPI",
4298
4375
  value: (function () {
4299
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data) {
4376
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4300
4377
  var _this$app9;
4301
4378
  var _response$data5, response, _payload2, list, count, errorMessage;
4302
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4303
- while (1) switch (_context45.prev = _context45.next) {
4379
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4380
+ while (1) switch (_context46.prev = _context46.next) {
4304
4381
  case 0:
4305
4382
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4306
- _context45.next = 3;
4383
+ _context46.next = 3;
4307
4384
  break;
4308
4385
  }
4309
4386
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4310
- return _context45.abrupt("return", {
4387
+ return _context46.abrupt("return", {
4311
4388
  code: 500,
4312
4389
  message: 'app.request 不可用',
4313
4390
  data: {
@@ -4317,17 +4394,17 @@ var Server = /*#__PURE__*/function () {
4317
4394
  status: false
4318
4395
  });
4319
4396
  case 3:
4320
- _context45.prev = 3;
4321
- _context45.next = 6;
4397
+ _context46.prev = 3;
4398
+ _context46.next = 6;
4322
4399
  return this.app.request.post('/shop/order/v2/list', data, {
4323
4400
  isShopApi: true
4324
4401
  });
4325
4402
  case 6:
4326
- response = _context45.sent;
4403
+ response = _context46.sent;
4327
4404
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4328
4405
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4329
4406
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4330
- return _context45.abrupt("return", {
4407
+ return _context46.abrupt("return", {
4331
4408
  code: 200,
4332
4409
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4333
4410
  list: list,
@@ -4337,13 +4414,13 @@ var Server = /*#__PURE__*/function () {
4337
4414
  status: true
4338
4415
  });
4339
4416
  case 13:
4340
- _context45.prev = 13;
4341
- _context45.t0 = _context45["catch"](3);
4342
- errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
4417
+ _context46.prev = 13;
4418
+ _context46.t0 = _context46["catch"](3);
4419
+ errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4343
4420
  this.logError('fetchOrderListFromAPI: 请求失败', {
4344
4421
  error: errorMessage
4345
4422
  });
4346
- return _context45.abrupt("return", {
4423
+ return _context46.abrupt("return", {
4347
4424
  code: 500,
4348
4425
  message: errorMessage,
4349
4426
  data: {
@@ -4354,9 +4431,9 @@ var Server = /*#__PURE__*/function () {
4354
4431
  });
4355
4432
  case 18:
4356
4433
  case "end":
4357
- return _context45.stop();
4434
+ return _context46.stop();
4358
4435
  }
4359
- }, _callee45, this, [[3, 13]]);
4436
+ }, _callee46, this, [[3, 13]]);
4360
4437
  }));
4361
4438
  function fetchOrderListFromAPI(_x49) {
4362
4439
  return _fetchOrderListFromAPI.apply(this, arguments);
@@ -4370,17 +4447,17 @@ var Server = /*#__PURE__*/function () {
4370
4447
  }, {
4371
4448
  key: "fetchBookingListFromAPI",
4372
4449
  value: (function () {
4373
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4450
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4374
4451
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4375
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4376
- while (1) switch (_context46.prev = _context46.next) {
4452
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4453
+ while (1) switch (_context47.prev = _context47.next) {
4377
4454
  case 0:
4378
4455
  if (this.order) {
4379
- _context46.next = 3;
4456
+ _context47.next = 3;
4380
4457
  break;
4381
4458
  }
4382
4459
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4383
- return _context46.abrupt("return", {
4460
+ return _context47.abrupt("return", {
4384
4461
  code: 500,
4385
4462
  message: 'Order 模块不可用',
4386
4463
  data: {
@@ -4390,18 +4467,18 @@ var Server = /*#__PURE__*/function () {
4390
4467
  status: false
4391
4468
  });
4392
4469
  case 3:
4393
- _context46.prev = 3;
4470
+ _context47.prev = 3;
4394
4471
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4395
4472
  withFields = this.resolveBookingSalesWith(data);
4396
4473
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4397
4474
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4398
4475
  if (!memoryCacheEnabled) {
4399
- _context46.next = 13;
4476
+ _context47.next = 13;
4400
4477
  break;
4401
4478
  }
4402
4479
  cached = this.readBookingRemoteCache(cacheKey);
4403
4480
  if (!cached) {
4404
- _context46.next = 13;
4481
+ _context47.next = 13;
4405
4482
  break;
4406
4483
  }
4407
4484
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4409,14 +4486,14 @@ var Server = /*#__PURE__*/function () {
4409
4486
  listCount: cached.bookingResult.count,
4410
4487
  withFields: cached.withFields
4411
4488
  });
4412
- return _context46.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4489
+ return _context47.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4413
4490
  cache_hit: true
4414
4491
  }));
4415
4492
  case 13:
4416
- _context46.next = 15;
4493
+ _context47.next = 15;
4417
4494
  return this.order.fetchOrdersBySSE(requestPayload);
4418
4495
  case 15:
4419
- rawList = _context46.sent;
4496
+ rawList = _context47.sent;
4420
4497
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4421
4498
  if (typeof globalThis !== 'undefined') {
4422
4499
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4463,15 +4540,15 @@ var Server = /*#__PURE__*/function () {
4463
4540
  cacheKey: cacheKey,
4464
4541
  withFields: withFields
4465
4542
  });
4466
- return _context46.abrupt("return", this.buildBookingResponse(bookingResult));
4543
+ return _context47.abrupt("return", this.buildBookingResponse(bookingResult));
4467
4544
  case 23:
4468
- _context46.prev = 23;
4469
- _context46.t0 = _context46["catch"](3);
4470
- errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4545
+ _context47.prev = 23;
4546
+ _context47.t0 = _context47["catch"](3);
4547
+ errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4471
4548
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4472
4549
  error: errorMessage
4473
4550
  });
4474
- return _context46.abrupt("return", {
4551
+ return _context47.abrupt("return", {
4475
4552
  code: 500,
4476
4553
  message: errorMessage,
4477
4554
  data: {
@@ -4482,9 +4559,9 @@ var Server = /*#__PURE__*/function () {
4482
4559
  });
4483
4560
  case 28:
4484
4561
  case "end":
4485
- return _context46.stop();
4562
+ return _context47.stop();
4486
4563
  }
4487
- }, _callee46, this, [[3, 23]]);
4564
+ }, _callee47, this, [[3, 23]]);
4488
4565
  }));
4489
4566
  function fetchBookingListFromAPI(_x50) {
4490
4567
  return _fetchBookingListFromAPI.apply(this, arguments);
@@ -4570,11 +4647,11 @@ var Server = /*#__PURE__*/function () {
4570
4647
  }, {
4571
4648
  key: "runLocalPaymentUpdateInQueue",
4572
4649
  value: function () {
4573
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(key, task, context) {
4574
- var _this11 = this;
4650
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(key, task, context) {
4651
+ var _this12 = this;
4575
4652
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4576
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4577
- while (1) switch (_context48.prev = _context48.next) {
4653
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4654
+ while (1) switch (_context49.prev = _context49.next) {
4578
4655
  case 0:
4579
4656
  queuedAt = Date.now();
4580
4657
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -4586,20 +4663,20 @@ var Server = /*#__PURE__*/function () {
4586
4663
  }));
4587
4664
  current = previous.catch(function () {
4588
4665
  return undefined;
4589
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4590
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4591
- while (1) switch (_context47.prev = _context47.next) {
4666
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4667
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4668
+ while (1) switch (_context48.prev = _context48.next) {
4592
4669
  case 0:
4593
- _this11.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4670
+ _this12.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4594
4671
  queue_key: key,
4595
4672
  queue_wait_ms: Date.now() - queuedAt
4596
4673
  }));
4597
- return _context47.abrupt("return", task());
4674
+ return _context48.abrupt("return", task());
4598
4675
  case 2:
4599
4676
  case "end":
4600
- return _context47.stop();
4677
+ return _context48.stop();
4601
4678
  }
4602
- }, _callee47);
4679
+ }, _callee48);
4603
4680
  })));
4604
4681
  tail = current.then(function () {
4605
4682
  return undefined;
@@ -4607,11 +4684,11 @@ var Server = /*#__PURE__*/function () {
4607
4684
  return undefined;
4608
4685
  });
4609
4686
  this.localPaymentUpdateQueues.set(key, tail);
4610
- _context48.prev = 7;
4611
- _context48.next = 10;
4687
+ _context49.prev = 7;
4688
+ _context49.next = 10;
4612
4689
  return current;
4613
4690
  case 10:
4614
- result = _context48.sent;
4691
+ result = _context49.sent;
4615
4692
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
4616
4693
  queue_key: key,
4617
4694
  total_duration_ms: Date.now() - queuedAt,
@@ -4619,19 +4696,19 @@ var Server = /*#__PURE__*/function () {
4619
4696
  result_status: result === null || result === void 0 ? void 0 : result.status,
4620
4697
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
4621
4698
  }));
4622
- return _context48.abrupt("return", result);
4699
+ return _context49.abrupt("return", result);
4623
4700
  case 15:
4624
- _context48.prev = 15;
4625
- _context48.t0 = _context48["catch"](7);
4701
+ _context49.prev = 15;
4702
+ _context49.t0 = _context49["catch"](7);
4626
4703
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
4627
4704
  queue_key: key,
4628
4705
  total_duration_ms: Date.now() - queuedAt,
4629
- error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0),
4630
- error_detail: this.normalizeUnknownError(_context48.t0)
4706
+ error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0),
4707
+ error_detail: this.normalizeUnknownError(_context49.t0)
4631
4708
  }));
4632
- throw _context48.t0;
4709
+ throw _context49.t0;
4633
4710
  case 19:
4634
- _context48.prev = 19;
4711
+ _context49.prev = 19;
4635
4712
  released = false;
4636
4713
  if (this.localPaymentUpdateQueues.get(key) === tail) {
4637
4714
  this.localPaymentUpdateQueues.delete(key);
@@ -4642,12 +4719,12 @@ var Server = /*#__PURE__*/function () {
4642
4719
  released: released,
4643
4720
  active_queue_count: this.localPaymentUpdateQueues.size
4644
4721
  }));
4645
- return _context48.finish(19);
4722
+ return _context49.finish(19);
4646
4723
  case 24:
4647
4724
  case "end":
4648
- return _context48.stop();
4725
+ return _context49.stop();
4649
4726
  }
4650
- }, _callee48, this, [[7, 15, 19, 24]]);
4727
+ }, _callee49, this, [[7, 15, 19, 24]]);
4651
4728
  }));
4652
4729
  function runLocalPaymentUpdateInQueue(_x51, _x52, _x53) {
4653
4730
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
@@ -4657,11 +4734,11 @@ var Server = /*#__PURE__*/function () {
4657
4734
  }, {
4658
4735
  key: "processLocalPaymentUpdate",
4659
4736
  value: function () {
4660
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4737
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4661
4738
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
4662
4739
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
4663
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4664
- while (1) switch (_context49.prev = _context49.next) {
4740
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4741
+ while (1) switch (_context50.prev = _context50.next) {
4665
4742
  case 0:
4666
4743
  requestContext = {
4667
4744
  operation_id: params.operationId,
@@ -4674,11 +4751,11 @@ var Server = /*#__PURE__*/function () {
4674
4751
  };
4675
4752
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
4676
4753
  if (this.order) {
4677
- _context49.next = 5;
4754
+ _context50.next = 5;
4678
4755
  break;
4679
4756
  }
4680
4757
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
4681
- return _context49.abrupt("return", {
4758
+ return _context50.abrupt("return", {
4682
4759
  code: 500,
4683
4760
  status: false,
4684
4761
  message: 'Order 模块未注册',
@@ -4686,20 +4763,20 @@ var Server = /*#__PURE__*/function () {
4686
4763
  });
4687
4764
  case 5:
4688
4765
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
4689
- _context49.next = 8;
4766
+ _context50.next = 8;
4690
4767
  return this.order.getLocalPayment({
4691
4768
  saleId: params.saleId,
4692
4769
  paymentNumber: params.paymentNumber,
4693
4770
  operationId: params.operationId
4694
4771
  });
4695
4772
  case 8:
4696
- found = _context49.sent;
4773
+ found = _context50.sent;
4697
4774
  if (found) {
4698
- _context49.next = 12;
4775
+ _context50.next = 12;
4699
4776
  break;
4700
4777
  }
4701
4778
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
4702
- return _context49.abrupt("return", {
4779
+ return _context50.abrupt("return", {
4703
4780
  code: 404,
4704
4781
  status: false,
4705
4782
  message: '本地支付项不存在',
@@ -4748,13 +4825,13 @@ var Server = /*#__PURE__*/function () {
4748
4825
  });
4749
4826
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
4750
4827
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
4751
- _context49.next = 23;
4828
+ _context50.next = 23;
4752
4829
  break;
4753
4830
  }
4754
4831
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4755
4832
  idempotent_reason: 'ignore_failure_after_success'
4756
4833
  }));
4757
- return _context49.abrupt("return", {
4834
+ return _context50.abrupt("return", {
4758
4835
  code: 200,
4759
4836
  status: true,
4760
4837
  message: '',
@@ -4767,13 +4844,13 @@ var Server = /*#__PURE__*/function () {
4767
4844
  case 23:
4768
4845
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
4769
4846
  if (!alreadyRecordedFailure) {
4770
- _context49.next = 27;
4847
+ _context50.next = 27;
4771
4848
  break;
4772
4849
  }
4773
4850
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4774
4851
  idempotent_reason: 'failure_already_recorded'
4775
4852
  }));
4776
- return _context49.abrupt("return", {
4853
+ return _context50.abrupt("return", {
4777
4854
  code: 200,
4778
4855
  status: true,
4779
4856
  message: '',
@@ -4785,13 +4862,13 @@ var Server = /*#__PURE__*/function () {
4785
4862
  });
4786
4863
  case 27:
4787
4864
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
4788
- _context49.next = 30;
4865
+ _context50.next = 30;
4789
4866
  break;
4790
4867
  }
4791
4868
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4792
4869
  idempotent_reason: 'success_already_committed'
4793
4870
  }));
4794
- return _context49.abrupt("return", {
4871
+ return _context50.abrupt("return", {
4795
4872
  code: 200,
4796
4873
  status: true,
4797
4874
  message: '',
@@ -4803,13 +4880,13 @@ var Server = /*#__PURE__*/function () {
4803
4880
  });
4804
4881
  case 30:
4805
4882
  if (!(params.status === 'success')) {
4806
- _context49.next = 33;
4883
+ _context50.next = 33;
4807
4884
  break;
4808
4885
  }
4809
4886
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4810
4887
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
4811
4888
  }));
4812
- return _context49.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4889
+ return _context50.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4813
4890
  order: found.order,
4814
4891
  payment: found.payment,
4815
4892
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -4820,8 +4897,8 @@ var Server = /*#__PURE__*/function () {
4820
4897
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4821
4898
  incoming_payment_update: incomingPaymentUpdate
4822
4899
  }));
4823
- _context49.prev = 34;
4824
- _context49.next = 37;
4900
+ _context50.prev = 34;
4901
+ _context50.next = 37;
4825
4902
  return this.order.updateLocalPayment({
4826
4903
  saleId: params.saleId,
4827
4904
  paymentNumber: params.paymentNumber,
@@ -4829,25 +4906,25 @@ var Server = /*#__PURE__*/function () {
4829
4906
  updates: incomingPaymentUpdate
4830
4907
  });
4831
4908
  case 37:
4832
- updated = _context49.sent;
4833
- _context49.next = 44;
4909
+ updated = _context50.sent;
4910
+ _context50.next = 44;
4834
4911
  break;
4835
4912
  case 40:
4836
- _context49.prev = 40;
4837
- _context49.t0 = _context49["catch"](34);
4913
+ _context50.prev = 40;
4914
+ _context50.t0 = _context50["catch"](34);
4838
4915
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
4839
4916
  incoming_payment_update: incomingPaymentUpdate,
4840
- error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0),
4841
- error_detail: this.normalizeUnknownError(_context49.t0)
4917
+ error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
4918
+ error_detail: this.normalizeUnknownError(_context50.t0)
4842
4919
  }));
4843
- throw _context49.t0;
4920
+ throw _context50.t0;
4844
4921
  case 44:
4845
4922
  if (updated) {
4846
- _context49.next = 47;
4923
+ _context50.next = 47;
4847
4924
  break;
4848
4925
  }
4849
4926
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
4850
- return _context49.abrupt("return", {
4927
+ return _context50.abrupt("return", {
4851
4928
  code: 404,
4852
4929
  status: false,
4853
4930
  message: '本地支付项不存在',
@@ -4858,7 +4935,7 @@ var Server = /*#__PURE__*/function () {
4858
4935
  previous_payment: updated.previousPayment,
4859
4936
  payment: updated.payment
4860
4937
  }));
4861
- return _context49.abrupt("return", {
4938
+ return _context50.abrupt("return", {
4862
4939
  code: 200,
4863
4940
  status: true,
4864
4941
  message: '',
@@ -4870,9 +4947,9 @@ var Server = /*#__PURE__*/function () {
4870
4947
  });
4871
4948
  case 49:
4872
4949
  case "end":
4873
- return _context49.stop();
4950
+ return _context50.stop();
4874
4951
  }
4875
- }, _callee49, this, [[34, 40]]);
4952
+ }, _callee50, this, [[34, 40]]);
4876
4953
  }));
4877
4954
  function processLocalPaymentUpdate(_x54) {
4878
4955
  return _processLocalPaymentUpdate.apply(this, arguments);
@@ -4882,10 +4959,10 @@ var Server = /*#__PURE__*/function () {
4882
4959
  }, {
4883
4960
  key: "processSuccessfulLocalPayment",
4884
4961
  value: function () {
4885
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4962
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4886
4963
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
4887
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4888
- while (1) switch (_context50.prev = _context50.next) {
4964
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4965
+ while (1) switch (_context51.prev = _context51.next) {
4889
4966
  case 0:
4890
4967
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
4891
4968
  baseSales = new BaseSalesImpl(moduleName);
@@ -4904,13 +4981,13 @@ var Server = /*#__PURE__*/function () {
4904
4981
  payment: params.payment
4905
4982
  });
4906
4983
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
4907
- _context50.prev = 5;
4984
+ _context51.prev = 5;
4908
4985
  order = this.sanitizeLocalRecoveryOrder(params.order);
4909
4986
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4910
4987
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
4911
4988
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
4912
4989
  }));
4913
- _context50.next = 10;
4990
+ _context51.next = 10;
4914
4991
  return baseSales.initialize(this.core, {
4915
4992
  otherParams: {
4916
4993
  platform: order.platform,
@@ -4923,14 +5000,14 @@ var Server = /*#__PURE__*/function () {
4923
5000
  });
4924
5001
  case 10:
4925
5002
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
4926
- _context50.next = 13;
5003
+ _context51.next = 13;
4927
5004
  return baseSales.replaceTempOrder(order);
4928
5005
  case 13:
4929
5006
  this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
4930
5007
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4931
5008
  incoming_payment_update: params.paymentUpdate
4932
5009
  }));
4933
- _context50.next = 17;
5010
+ _context51.next = 17;
4934
5011
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
4935
5012
  submitWhenPaid: true,
4936
5013
  matchBy: params.matchBy,
@@ -4939,7 +5016,7 @@ var Server = /*#__PURE__*/function () {
4939
5016
  smallTicketDataFlag: 1
4940
5017
  });
4941
5018
  case 17:
4942
- result = _context50.sent;
5019
+ result = _context51.sent;
4943
5020
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4944
5021
  duration_ms: Date.now() - startedAt,
4945
5022
  payment: result.payment,
@@ -4961,7 +5038,7 @@ var Server = /*#__PURE__*/function () {
4961
5038
  } : null,
4962
5039
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
4963
5040
  }));
4964
- return _context50.abrupt("return", {
5041
+ return _context51.abrupt("return", {
4965
5042
  code: 200,
4966
5043
  status: true,
4967
5044
  message: '',
@@ -4973,46 +5050,46 @@ var Server = /*#__PURE__*/function () {
4973
5050
  }
4974
5051
  });
4975
5052
  case 22:
4976
- _context50.prev = 22;
4977
- _context50.t0 = _context50["catch"](5);
4978
- message = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
5053
+ _context51.prev = 22;
5054
+ _context51.t0 = _context51["catch"](5);
5055
+ message = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
4979
5056
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4980
5057
  duration_ms: Date.now() - startedAt,
4981
5058
  error: message,
4982
- error_detail: this.normalizeUnknownError(_context50.t0)
5059
+ error_detail: this.normalizeUnknownError(_context51.t0)
4983
5060
  }));
4984
- return _context50.abrupt("return", {
5061
+ return _context51.abrupt("return", {
4985
5062
  code: 500,
4986
5063
  status: false,
4987
5064
  message: message,
4988
5065
  data: null
4989
5066
  });
4990
5067
  case 27:
4991
- _context50.prev = 27;
4992
- _context50.prev = 28;
4993
- _context50.next = 31;
5068
+ _context51.prev = 27;
5069
+ _context51.prev = 28;
5070
+ _context51.next = 31;
4994
5071
  return baseSales.destroy();
4995
5072
  case 31:
4996
5073
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
4997
5074
  duration_ms: Date.now() - startedAt
4998
5075
  }));
4999
- _context50.next = 37;
5076
+ _context51.next = 37;
5000
5077
  break;
5001
5078
  case 34:
5002
- _context50.prev = 34;
5003
- _context50.t1 = _context50["catch"](28);
5079
+ _context51.prev = 34;
5080
+ _context51.t1 = _context51["catch"](28);
5004
5081
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5005
5082
  duration_ms: Date.now() - startedAt,
5006
- error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1),
5007
- error_detail: this.normalizeUnknownError(_context50.t1)
5083
+ error: _context51.t1 instanceof Error ? _context51.t1.message : String(_context51.t1),
5084
+ error_detail: this.normalizeUnknownError(_context51.t1)
5008
5085
  }));
5009
5086
  case 37:
5010
- return _context50.finish(27);
5087
+ return _context51.finish(27);
5011
5088
  case 38:
5012
5089
  case "end":
5013
- return _context50.stop();
5090
+ return _context51.stop();
5014
5091
  }
5015
- }, _callee50, this, [[5, 22, 27, 38], [28, 34]]);
5092
+ }, _callee51, this, [[5, 22, 27, 38], [28, 34]]);
5016
5093
  }));
5017
5094
  function processSuccessfulLocalPayment(_x55) {
5018
5095
  return _processSuccessfulLocalPayment.apply(this, arguments);
@@ -5105,32 +5182,32 @@ var Server = /*#__PURE__*/function () {
5105
5182
  }, {
5106
5183
  key: "getShortNumberOrDeviceId",
5107
5184
  value: function () {
5108
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
5185
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5109
5186
  var getAsyncIotDeviceInfo, res;
5110
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5111
- while (1) switch (_context51.prev = _context51.next) {
5187
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5188
+ while (1) switch (_context52.prev = _context52.next) {
5112
5189
  case 0:
5113
5190
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
5114
5191
  if (!getAsyncIotDeviceInfo) {
5115
- _context51.next = 7;
5192
+ _context52.next = 7;
5116
5193
  break;
5117
5194
  }
5118
- _context51.next = 4;
5195
+ _context52.next = 4;
5119
5196
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
5120
5197
  case 4:
5121
- res = _context51.sent;
5198
+ res = _context52.sent;
5122
5199
  if (!(res !== null && res !== void 0 && res.short_number)) {
5123
- _context51.next = 7;
5200
+ _context52.next = 7;
5124
5201
  break;
5125
5202
  }
5126
- return _context51.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5203
+ return _context52.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5127
5204
  case 7:
5128
- return _context51.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5205
+ return _context52.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5129
5206
  case 8:
5130
5207
  case "end":
5131
- return _context51.stop();
5208
+ return _context52.stop();
5132
5209
  }
5133
- }, _callee51, this);
5210
+ }, _callee52, this);
5134
5211
  }));
5135
5212
  function getShortNumberOrDeviceId() {
5136
5213
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -5157,16 +5234,16 @@ var Server = /*#__PURE__*/function () {
5157
5234
  }, {
5158
5235
  key: "normalizeCheckoutSubmitData",
5159
5236
  value: function () {
5160
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data, title) {
5237
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data, title) {
5161
5238
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5162
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5163
- while (1) switch (_context52.prev = _context52.next) {
5239
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5240
+ while (1) switch (_context53.prev = _context53.next) {
5164
5241
  case 0:
5165
5242
  if (!(!data || _typeof(data) !== 'object')) {
5166
- _context52.next = 2;
5243
+ _context53.next = 2;
5167
5244
  break;
5168
5245
  }
5169
- return _context52.abrupt("return", data);
5246
+ return _context53.abrupt("return", data);
5170
5247
  case 2:
5171
5248
  next = _objectSpread({}, data);
5172
5249
  externalSaleNumber = next.external_sale_number;
@@ -5176,7 +5253,7 @@ var Server = /*#__PURE__*/function () {
5176
5253
  delete next.vouchers;
5177
5254
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5178
5255
  if (!hasCheckoutOrderNumbers) {
5179
- _context52.next = 11;
5256
+ _context53.next = 11;
5180
5257
  break;
5181
5258
  }
5182
5259
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -5186,10 +5263,10 @@ var Server = /*#__PURE__*/function () {
5186
5263
  shop_order_number: next.shop_order_number,
5187
5264
  shop_full_order_number: next.shop_full_order_number
5188
5265
  });
5189
- return _context52.abrupt("return", next);
5266
+ return _context53.abrupt("return", next);
5190
5267
  case 11:
5191
5268
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
5192
- _context52.next = 14;
5269
+ _context53.next = 14;
5193
5270
  break;
5194
5271
  }
5195
5272
  if (shouldClearLocalOrderId) {
@@ -5198,10 +5275,10 @@ var Server = /*#__PURE__*/function () {
5198
5275
  order_id: next.order_id
5199
5276
  });
5200
5277
  }
5201
- return _context52.abrupt("return", next);
5278
+ return _context53.abrupt("return", next);
5202
5279
  case 14:
5203
5280
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
5204
- _context52.next = 17;
5281
+ _context53.next = 17;
5205
5282
  break;
5206
5283
  }
5207
5284
  if (shouldClearLocalOrderId) {
@@ -5210,12 +5287,12 @@ var Server = /*#__PURE__*/function () {
5210
5287
  external_sale_number: externalSaleNumber
5211
5288
  });
5212
5289
  }
5213
- return _context52.abrupt("return", next);
5290
+ return _context53.abrupt("return", next);
5214
5291
  case 17:
5215
- _context52.prev = 17;
5292
+ _context53.prev = 17;
5216
5293
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
5217
5294
  if (localOrder) {
5218
- _context52.next = 22;
5295
+ _context53.next = 22;
5219
5296
  break;
5220
5297
  }
5221
5298
  if (shouldClearLocalOrderId) {
@@ -5225,7 +5302,7 @@ var Server = /*#__PURE__*/function () {
5225
5302
  localOrderFound: false
5226
5303
  });
5227
5304
  }
5228
- return _context52.abrupt("return", next);
5305
+ return _context53.abrupt("return", next);
5229
5306
  case 22:
5230
5307
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
5231
5308
  next.shop_order_number = localOrder.shop_order_number;
@@ -5242,21 +5319,21 @@ var Server = /*#__PURE__*/function () {
5242
5319
  shop_full_order_number: next.shop_full_order_number
5243
5320
  });
5244
5321
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5245
- return _context52.abrupt("return", next);
5322
+ return _context53.abrupt("return", next);
5246
5323
  case 28:
5247
- _context52.prev = 28;
5248
- _context52.t0 = _context52["catch"](17);
5324
+ _context53.prev = 28;
5325
+ _context53.t0 = _context53["catch"](17);
5249
5326
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
5250
5327
  external_sale_number: externalSaleNumber,
5251
- error: this.getUnknownErrorMessage(_context52.t0),
5252
- error_detail: this.normalizeUnknownError(_context52.t0)
5328
+ error: this.getUnknownErrorMessage(_context53.t0),
5329
+ error_detail: this.normalizeUnknownError(_context53.t0)
5253
5330
  });
5254
- return _context52.abrupt("return", next);
5331
+ return _context53.abrupt("return", next);
5255
5332
  case 32:
5256
5333
  case "end":
5257
- return _context52.stop();
5334
+ return _context53.stop();
5258
5335
  }
5259
- }, _callee52, this, [[17, 28]]);
5336
+ }, _callee53, this, [[17, 28]]);
5260
5337
  }));
5261
5338
  function normalizeCheckoutSubmitData(_x56, _x57) {
5262
5339
  return _normalizeCheckoutSubmitData.apply(this, arguments);
@@ -5266,79 +5343,79 @@ var Server = /*#__PURE__*/function () {
5266
5343
  }, {
5267
5344
  key: "ensureCheckoutOrderNumbers",
5268
5345
  value: function () {
5269
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data, title) {
5346
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5270
5347
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
5271
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5272
- while (1) switch (_context53.prev = _context53.next) {
5348
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5349
+ while (1) switch (_context54.prev = _context54.next) {
5273
5350
  case 0:
5274
5351
  if (!(!data || _typeof(data) !== 'object')) {
5275
- _context53.next = 2;
5352
+ _context54.next = 2;
5276
5353
  break;
5277
5354
  }
5278
- return _context53.abrupt("return", data);
5355
+ return _context54.abrupt("return", data);
5279
5356
  case 2:
5280
5357
  next = _objectSpread({}, data);
5281
5358
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
5282
5359
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
5283
5360
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
5284
- _context53.next = 7;
5361
+ _context54.next = 7;
5285
5362
  break;
5286
5363
  }
5287
- return _context53.abrupt("return", next);
5364
+ return _context54.abrupt("return", next);
5288
5365
  case 7:
5289
5366
  idGenerator = this.getIdGeneratorPlugin();
5290
5367
  if (idGenerator) {
5291
- _context53.next = 11;
5368
+ _context54.next = 11;
5292
5369
  break;
5293
5370
  }
5294
5371
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
5295
5372
  needsShopOrderNumber: needsShopOrderNumber,
5296
5373
  needsShopFullOrderNumber: needsShopFullOrderNumber
5297
5374
  });
5298
- return _context53.abrupt("return", next);
5375
+ return _context54.abrupt("return", next);
5299
5376
  case 11:
5300
- _context53.prev = 11;
5377
+ _context54.prev = 11;
5301
5378
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
5302
- _context53.next = 16;
5379
+ _context54.next = 16;
5303
5380
  break;
5304
5381
  }
5305
- _context53.next = 15;
5382
+ _context54.next = 15;
5306
5383
  return idGenerator.generateShopOrderNumber({
5307
5384
  biz: next.business_code || 'ticket'
5308
5385
  });
5309
5386
  case 15:
5310
- next.shop_order_number = _context53.sent;
5387
+ next.shop_order_number = _context54.sent;
5311
5388
  case 16:
5312
5389
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
5313
- _context53.next = 20;
5390
+ _context54.next = 20;
5314
5391
  break;
5315
5392
  }
5316
- _context53.next = 19;
5393
+ _context54.next = 19;
5317
5394
  return idGenerator.generateReceiptId({
5318
5395
  biz: next.business_code || 'ticket'
5319
5396
  });
5320
5397
  case 19:
5321
- next.shop_full_order_number = _context53.sent;
5398
+ next.shop_full_order_number = _context54.sent;
5322
5399
  case 20:
5323
5400
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
5324
5401
  shop_order_number: next.shop_order_number,
5325
5402
  shop_full_order_number: next.shop_full_order_number
5326
5403
  });
5327
- _context53.next = 26;
5404
+ _context54.next = 26;
5328
5405
  break;
5329
5406
  case 23:
5330
- _context53.prev = 23;
5331
- _context53.t0 = _context53["catch"](11);
5407
+ _context54.prev = 23;
5408
+ _context54.t0 = _context54["catch"](11);
5332
5409
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
5333
- error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
5410
+ error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0)
5334
5411
  });
5335
5412
  case 26:
5336
- return _context53.abrupt("return", next);
5413
+ return _context54.abrupt("return", next);
5337
5414
  case 27:
5338
5415
  case "end":
5339
- return _context53.stop();
5416
+ return _context54.stop();
5340
5417
  }
5341
- }, _callee53, this, [[11, 23]]);
5418
+ }, _callee54, this, [[11, 23]]);
5342
5419
  }));
5343
5420
  function ensureCheckoutOrderNumbers(_x58, _x59) {
5344
5421
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
@@ -5348,27 +5425,27 @@ var Server = /*#__PURE__*/function () {
5348
5425
  }, {
5349
5426
  key: "dispatchCheckoutSyncTask",
5350
5427
  value: function () {
5351
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5428
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5352
5429
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
5353
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5354
- while (1) switch (_context54.prev = _context54.next) {
5430
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5431
+ while (1) switch (_context55.prev = _context55.next) {
5355
5432
  case 0:
5356
5433
  this.registerDeviceTaskActions();
5357
5434
  deviceTask = this.getDeviceTaskPlugin();
5358
- _context54.next = 4;
5435
+ _context55.next = 4;
5359
5436
  return this.getShortNumberOrDeviceId();
5360
5437
  case 4:
5361
- debugDeviceId = _context54.sent;
5438
+ debugDeviceId = _context55.sent;
5362
5439
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
5363
5440
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5364
- _context54.next = 9;
5441
+ _context55.next = 9;
5365
5442
  break;
5366
5443
  }
5367
5444
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
5368
- return _context54.abrupt("return");
5445
+ return _context55.abrupt("return");
5369
5446
  case 9:
5370
- _context54.prev = 9;
5371
- _context54.next = 12;
5447
+ _context55.prev = 9;
5448
+ _context55.next = 12;
5372
5449
  return deviceTask.dispatch({
5373
5450
  action: 'sync_sales',
5374
5451
  device_id: debugDeviceId,
@@ -5386,25 +5463,25 @@ var Server = /*#__PURE__*/function () {
5386
5463
  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)
5387
5464
  });
5388
5465
  case 12:
5389
- result = _context54.sent;
5466
+ result = _context55.sent;
5390
5467
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
5391
5468
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
5392
5469
  status: result === null || result === void 0 ? void 0 : result.status,
5393
5470
  reused: result === null || result === void 0 ? void 0 : result.reused
5394
5471
  });
5395
- _context54.next = 19;
5472
+ _context55.next = 19;
5396
5473
  break;
5397
5474
  case 16:
5398
- _context54.prev = 16;
5399
- _context54.t0 = _context54["catch"](9);
5475
+ _context55.prev = 16;
5476
+ _context55.t0 = _context55["catch"](9);
5400
5477
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
5401
- error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0)
5478
+ error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5402
5479
  });
5403
5480
  case 19:
5404
5481
  case "end":
5405
- return _context54.stop();
5482
+ return _context55.stop();
5406
5483
  }
5407
- }, _callee54, this, [[9, 16]]);
5484
+ }, _callee55, this, [[9, 16]]);
5408
5485
  }));
5409
5486
  function dispatchCheckoutSyncTask(_x60) {
5410
5487
  return _dispatchCheckoutSyncTask.apply(this, arguments);
@@ -5414,26 +5491,26 @@ var Server = /*#__PURE__*/function () {
5414
5491
  }, {
5415
5492
  key: "dispatchPrintOtherReceiptTask",
5416
5493
  value: function () {
5417
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5494
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5418
5495
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
5419
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5420
- while (1) switch (_context55.prev = _context55.next) {
5496
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5497
+ while (1) switch (_context56.prev = _context56.next) {
5421
5498
  case 0:
5422
5499
  deviceTask = this.getDeviceTaskPlugin();
5423
5500
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5424
- _context55.next = 4;
5501
+ _context56.next = 4;
5425
5502
  break;
5426
5503
  }
5427
5504
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
5428
- return _context55.abrupt("return");
5505
+ return _context56.abrupt("return");
5429
5506
  case 4:
5430
- _context55.prev = 4;
5507
+ _context56.prev = 4;
5431
5508
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
5432
- _context55.next = 8;
5509
+ _context56.next = 8;
5433
5510
  return this.getShortNumberOrDeviceId();
5434
5511
  case 8:
5435
- deviceId = _context55.sent;
5436
- _context55.next = 11;
5512
+ deviceId = _context56.sent;
5513
+ _context56.next = 11;
5437
5514
  return deviceTask.dispatch({
5438
5515
  action: 'print_all',
5439
5516
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -5460,19 +5537,19 @@ var Server = /*#__PURE__*/function () {
5460
5537
  source_id: printIdentity
5461
5538
  });
5462
5539
  case 11:
5463
- _context55.next = 16;
5540
+ _context56.next = 16;
5464
5541
  break;
5465
5542
  case 13:
5466
- _context55.prev = 13;
5467
- _context55.t0 = _context55["catch"](4);
5543
+ _context56.prev = 13;
5544
+ _context56.t0 = _context56["catch"](4);
5468
5545
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
5469
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5546
+ error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5470
5547
  });
5471
5548
  case 16:
5472
5549
  case "end":
5473
- return _context55.stop();
5550
+ return _context56.stop();
5474
5551
  }
5475
- }, _callee55, this, [[4, 13]]);
5552
+ }, _callee56, this, [[4, 13]]);
5476
5553
  }));
5477
5554
  function dispatchPrintOtherReceiptTask(_x61) {
5478
5555
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
@@ -5494,32 +5571,32 @@ var Server = /*#__PURE__*/function () {
5494
5571
  }, {
5495
5572
  key: "dispatchLocalReceiptPrint",
5496
5573
  value: function () {
5497
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5574
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5498
5575
  var _payment_info;
5499
5576
  var printableOrder;
5500
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5501
- while (1) switch (_context56.prev = _context56.next) {
5577
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5578
+ while (1) switch (_context57.prev = _context57.next) {
5502
5579
  case 0:
5503
5580
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
5504
- _context56.next = 2;
5581
+ _context57.next = 2;
5505
5582
  break;
5506
5583
  }
5507
- return _context56.abrupt("return", {
5584
+ return _context57.abrupt("return", {
5508
5585
  printed: false,
5509
5586
  order: params.order
5510
5587
  });
5511
5588
  case 2:
5512
- _context56.next = 4;
5589
+ _context57.next = 4;
5513
5590
  return this.withLocalSmallTicketData(params.order, {
5514
5591
  requireFullyPaid: params.requireFullyPaid
5515
5592
  });
5516
5593
  case 4:
5517
- printableOrder = _context56.sent;
5594
+ printableOrder = _context57.sent;
5518
5595
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
5519
- _context56.next = 7;
5596
+ _context57.next = 7;
5520
5597
  break;
5521
5598
  }
5522
- return _context56.abrupt("return", {
5599
+ return _context57.abrupt("return", {
5523
5600
  printed: false,
5524
5601
  order: printableOrder
5525
5602
  });
@@ -5529,7 +5606,7 @@ var Server = /*#__PURE__*/function () {
5529
5606
  printableOrder: printableOrder,
5530
5607
  response: params.response
5531
5608
  });
5532
- _context56.next = 10;
5609
+ _context57.next = 10;
5533
5610
  return this.dispatchPrintOtherReceiptTask({
5534
5611
  checkoutData: params.checkoutData,
5535
5612
  syncedOrder: printableOrder,
@@ -5538,15 +5615,15 @@ var Server = /*#__PURE__*/function () {
5538
5615
  isManualPrint: params.isManualPrint
5539
5616
  });
5540
5617
  case 10:
5541
- return _context56.abrupt("return", {
5618
+ return _context57.abrupt("return", {
5542
5619
  printed: true,
5543
5620
  order: printableOrder
5544
5621
  });
5545
5622
  case 11:
5546
5623
  case "end":
5547
- return _context56.stop();
5624
+ return _context57.stop();
5548
5625
  }
5549
- }, _callee56, this);
5626
+ }, _callee57, this);
5550
5627
  }));
5551
5628
  function dispatchLocalReceiptPrint(_x62) {
5552
5629
  return _dispatchLocalReceiptPrint.apply(this, arguments);
@@ -5583,47 +5660,47 @@ var Server = /*#__PURE__*/function () {
5583
5660
  }, {
5584
5661
  key: "syncMachinecodeRedeemStatusToLocalOrder",
5585
5662
  value: function () {
5586
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data, ids, status) {
5663
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(data, ids, status) {
5587
5664
  var _this$order3;
5588
5665
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
5589
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5590
- while (1) switch (_context57.prev = _context57.next) {
5666
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5667
+ while (1) switch (_context58.prev = _context58.next) {
5591
5668
  case 0:
5592
5669
  title = 'handleMachinecodeBatchMetadata';
5593
5670
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
5594
5671
  if (!(lookup === undefined)) {
5595
- _context57.next = 5;
5672
+ _context58.next = 5;
5596
5673
  break;
5597
5674
  }
5598
5675
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5599
5676
  batchSize: ids.length,
5600
5677
  status: status
5601
5678
  });
5602
- return _context57.abrupt("return");
5679
+ return _context58.abrupt("return");
5603
5680
  case 5:
5604
5681
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
5605
- _context57.next = 8;
5682
+ _context58.next = 8;
5606
5683
  break;
5607
5684
  }
5608
5685
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5609
5686
  lookup: lookup,
5610
5687
  status: status
5611
5688
  });
5612
- return _context57.abrupt("return");
5689
+ return _context58.abrupt("return");
5613
5690
  case 8:
5614
- _context57.next = 10;
5691
+ _context58.next = 10;
5615
5692
  return this.order.getLocalOrderByLookup(lookup);
5616
5693
  case 10:
5617
- localOrder = _context57.sent;
5694
+ localOrder = _context58.sent;
5618
5695
  if (localOrder) {
5619
- _context57.next = 14;
5696
+ _context58.next = 14;
5620
5697
  break;
5621
5698
  }
5622
5699
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5623
5700
  lookup: lookup,
5624
5701
  status: status
5625
5702
  });
5626
- return _context57.abrupt("return");
5703
+ return _context58.abrupt("return");
5627
5704
  case 14:
5628
5705
  voucherIdSet = new Set(ids.filter(function (id) {
5629
5706
  return id !== undefined && id !== null && id !== '';
@@ -5631,14 +5708,14 @@ var Server = /*#__PURE__*/function () {
5631
5708
  return String(id);
5632
5709
  }));
5633
5710
  if (!(voucherIdSet.size === 0)) {
5634
- _context57.next = 18;
5711
+ _context58.next = 18;
5635
5712
  break;
5636
5713
  }
5637
5714
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5638
5715
  lookup: lookup,
5639
5716
  status: status
5640
5717
  });
5641
- return _context57.abrupt("return");
5718
+ return _context58.abrupt("return");
5642
5719
  case 18:
5643
5720
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
5644
5721
  hasUpdatedVoucher = false;
@@ -5652,7 +5729,7 @@ var Server = /*#__PURE__*/function () {
5652
5729
  });
5653
5730
  });
5654
5731
  if (hasUpdatedVoucher) {
5655
- _context57.next = 24;
5732
+ _context58.next = 24;
5656
5733
  break;
5657
5734
  }
5658
5735
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -5660,13 +5737,13 @@ var Server = /*#__PURE__*/function () {
5660
5737
  voucher_ids: Array.from(voucherIdSet),
5661
5738
  status: status
5662
5739
  });
5663
- return _context57.abrupt("return");
5740
+ return _context58.abrupt("return");
5664
5741
  case 24:
5665
5742
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
5666
- _context57.next = 29;
5743
+ _context58.next = 29;
5667
5744
  break;
5668
5745
  }
5669
- _context57.next = 27;
5746
+ _context58.next = 27;
5670
5747
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
5671
5748
  vouchers: nextVouchers
5672
5749
  }));
@@ -5676,13 +5753,13 @@ var Server = /*#__PURE__*/function () {
5676
5753
  updatedCount: voucherIdSet.size,
5677
5754
  status: status
5678
5755
  });
5679
- return _context57.abrupt("return");
5756
+ return _context58.abrupt("return");
5680
5757
  case 29:
5681
5758
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
5682
- _context57.next = 34;
5759
+ _context58.next = 34;
5683
5760
  break;
5684
5761
  }
5685
- _context57.next = 32;
5762
+ _context58.next = 32;
5686
5763
  return this.order.markOrderSyncedByExternalSaleNumber({
5687
5764
  externalSaleNumber: data.external_sale_number,
5688
5765
  patch: {
@@ -5695,7 +5772,7 @@ var Server = /*#__PURE__*/function () {
5695
5772
  updatedCount: voucherIdSet.size,
5696
5773
  status: status
5697
5774
  });
5698
- return _context57.abrupt("return");
5775
+ return _context58.abrupt("return");
5699
5776
  case 34:
5700
5777
  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"), {
5701
5778
  lookup: lookup,
@@ -5703,9 +5780,9 @@ var Server = /*#__PURE__*/function () {
5703
5780
  });
5704
5781
  case 35:
5705
5782
  case "end":
5706
- return _context57.stop();
5783
+ return _context58.stop();
5707
5784
  }
5708
- }, _callee57, this);
5785
+ }, _callee58, this);
5709
5786
  }));
5710
5787
  function syncMachinecodeRedeemStatusToLocalOrder(_x63, _x64, _x65) {
5711
5788
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
@@ -5715,10 +5792,10 @@ var Server = /*#__PURE__*/function () {
5715
5792
  }, {
5716
5793
  key: "handleOrderCheckoutSubmit",
5717
5794
  value: function () {
5718
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5795
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5719
5796
  var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
5720
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5721
- while (1) switch (_context58.prev = _context58.next) {
5797
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5798
+ while (1) switch (_context59.prev = _context59.next) {
5722
5799
  case 0:
5723
5800
  backendPath = params.backendPath, data = params.data, title = params.title;
5724
5801
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5728,24 +5805,24 @@ var Server = /*#__PURE__*/function () {
5728
5805
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5729
5806
  });
5730
5807
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5731
- _context58.next = 4;
5808
+ _context59.next = 4;
5732
5809
  break;
5733
5810
  }
5734
- return _context58.abrupt("return", this.handleSyncCheckoutSubmit({
5811
+ return _context59.abrupt("return", this.handleSyncCheckoutSubmit({
5735
5812
  backendPath: backendPath,
5736
5813
  data: data,
5737
5814
  title: title
5738
5815
  }));
5739
5816
  case 4:
5740
- _context58.next = 6;
5817
+ _context59.next = 6;
5741
5818
  return this.normalizeCheckoutSubmitData(data, title);
5742
5819
  case 6:
5743
- normalizedData = _context58.sent;
5744
- _context58.next = 9;
5820
+ normalizedData = _context59.sent;
5821
+ _context59.next = 9;
5745
5822
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
5746
5823
  case 9:
5747
- checkoutData = _context58.sent;
5748
- _context58.next = 12;
5824
+ checkoutData = _context59.sent;
5825
+ _context59.next = 12;
5749
5826
  return this.handlePendingSyncCheckoutOrder({
5750
5827
  backendPath: backendPath,
5751
5828
  data: checkoutData,
@@ -5753,9 +5830,9 @@ var Server = /*#__PURE__*/function () {
5753
5830
  reason: 'checkout 已转入设备任务同步'
5754
5831
  });
5755
5832
  case 12:
5756
- pendingResult = _context58.sent;
5833
+ pendingResult = _context59.sent;
5757
5834
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5758
- _context58.next = 22;
5835
+ _context59.next = 22;
5759
5836
  break;
5760
5837
  }
5761
5838
  pendingOrder = pendingResult.data;
@@ -5764,10 +5841,10 @@ var Server = /*#__PURE__*/function () {
5764
5841
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
5765
5842
  // TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
5766
5843
  isAndroid ? checkoutData.type === 'virtual' : true))) {
5767
- _context58.next = 20;
5844
+ _context59.next = 20;
5768
5845
  break;
5769
5846
  }
5770
- _context58.next = 20;
5847
+ _context59.next = 20;
5771
5848
  return this.dispatchLocalReceiptPrint({
5772
5849
  checkoutData: checkoutData,
5773
5850
  order: pendingOrder,
@@ -5775,7 +5852,7 @@ var Server = /*#__PURE__*/function () {
5775
5852
  requireFullyPaid: true
5776
5853
  });
5777
5854
  case 20:
5778
- _context58.next = 22;
5855
+ _context59.next = 22;
5779
5856
  return this.dispatchCheckoutSyncTask({
5780
5857
  backendPath: backendPath,
5781
5858
  data: checkoutData,
@@ -5783,21 +5860,21 @@ var Server = /*#__PURE__*/function () {
5783
5860
  });
5784
5861
  case 22:
5785
5862
  if (pendingResult.data.order_id) {
5786
- _context58.next = 24;
5863
+ _context59.next = 24;
5787
5864
  break;
5788
5865
  }
5789
- return _context58.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5866
+ return _context59.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
5790
5867
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
5791
5868
  order_id: pendingResult.data.external_sale_number
5792
5869
  })
5793
5870
  }));
5794
5871
  case 24:
5795
- return _context58.abrupt("return", pendingResult);
5872
+ return _context59.abrupt("return", pendingResult);
5796
5873
  case 25:
5797
5874
  case "end":
5798
- return _context58.stop();
5875
+ return _context59.stop();
5799
5876
  }
5800
- }, _callee58, this);
5877
+ }, _callee59, this);
5801
5878
  }));
5802
5879
  function handleOrderCheckoutSubmit(_x66) {
5803
5880
  return _handleOrderCheckoutSubmit.apply(this, arguments);
@@ -5807,27 +5884,27 @@ var Server = /*#__PURE__*/function () {
5807
5884
  }, {
5808
5885
  key: "handleSyncCheckoutSubmit",
5809
5886
  value: function () {
5810
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5887
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5811
5888
  var _this$app16;
5812
- var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
5813
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5814
- while (1) switch (_context59.prev = _context59.next) {
5889
+ var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
5890
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5891
+ while (1) switch (_context60.prev = _context60.next) {
5815
5892
  case 0:
5816
5893
  backendPath = params.backendPath, data = params.data, title = params.title;
5817
5894
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
5818
- _context59.next = 4;
5895
+ _context60.next = 4;
5819
5896
  break;
5820
5897
  }
5821
5898
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
5822
- return _context59.abrupt("return", {
5899
+ return _context60.abrupt("return", {
5823
5900
  code: 500,
5824
5901
  status: false,
5825
5902
  message: 'app.request 不可用',
5826
5903
  data: null
5827
5904
  });
5828
5905
  case 4:
5829
- _context59.prev = 4;
5830
- _context59.next = 7;
5906
+ _context60.prev = 4;
5907
+ _context60.next = 7;
5831
5908
  return this.runCheckoutSync({
5832
5909
  backendPath: backendPath,
5833
5910
  data: data,
@@ -5835,51 +5912,67 @@ var Server = /*#__PURE__*/function () {
5835
5912
  persistCheckoutDataWithResponse: true
5836
5913
  });
5837
5914
  case 7:
5838
- syncResult = _context59.sent;
5915
+ syncResult = _context60.sent;
5839
5916
  if (!syncResult.rejected) {
5840
- _context59.next = 11;
5917
+ _context60.next = 11;
5841
5918
  break;
5842
5919
  }
5843
5920
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
5844
- return _context59.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5921
+ return _context60.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
5845
5922
  status: false,
5846
5923
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
5847
5924
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
5848
5925
  }));
5849
5926
  case 11:
5850
- return _context59.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
5851
- case 14:
5852
- _context59.prev = 14;
5853
- _context59.t0 = _context59["catch"](4);
5854
- backendError = this.extractBackendErrorResponse(_context59.t0);
5927
+ response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
5928
+ syncedOrder = syncResult.syncedOrder;
5929
+ if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
5930
+ _context60.next = 16;
5931
+ break;
5932
+ }
5933
+ _context60.next = 16;
5934
+ return this.dispatchLocalReceiptPrint({
5935
+ checkoutData: syncResult.checkoutData,
5936
+ order: syncedOrder,
5937
+ response: syncResult.normalizedResponse,
5938
+ requireFullyPaid: true,
5939
+ // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
5940
+ isManualPrint: true
5941
+ });
5942
+ case 16:
5943
+ return _context60.abrupt("return", response);
5944
+ case 19:
5945
+ _context60.prev = 19;
5946
+ _context60.t0 = _context60["catch"](4);
5947
+ backendError = this.extractBackendErrorResponse(_context60.t0);
5855
5948
  if (!backendError) {
5856
- _context59.next = 20;
5949
+ _context60.next = 25;
5857
5950
  break;
5858
5951
  }
5859
5952
  _normalized = this.normalizeCheckoutResponse(backendError);
5860
- return _context59.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5953
+ return _context60.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
5861
5954
  status: false,
5862
5955
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
5863
5956
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
5864
5957
  }));
5865
- case 20:
5866
- message = this.getUnknownErrorMessage(_context59.t0);
5958
+ case 25:
5959
+ message = this.getUnknownErrorMessage(_context60.t0);
5867
5960
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
5868
5961
  backendPath: backendPath,
5869
5962
  error: message,
5870
- error_detail: this.normalizeUnknownError(_context59.t0)
5963
+ error_detail: this.normalizeUnknownError(_context60.t0)
5871
5964
  });
5872
- return _context59.abrupt("return", {
5965
+ return _context60.abrupt("return", {
5873
5966
  code: 500,
5874
5967
  status: false,
5875
5968
  message: message,
5876
5969
  data: null
5877
5970
  });
5878
- case 23:
5971
+ case 28:
5879
5972
  case "end":
5880
- return _context59.stop();
5973
+ return _context60.stop();
5881
5974
  }
5882
- }, _callee59, this, [[4, 14]]);
5975
+ }, _callee60, this, [[4, 19]]);
5883
5976
  }));
5884
5977
  function handleSyncCheckoutSubmit(_x67) {
5885
5978
  return _handleSyncCheckoutSubmit.apply(this, arguments);
@@ -5889,10 +5982,10 @@ var Server = /*#__PURE__*/function () {
5889
5982
  }, {
5890
5983
  key: "handleOrderDraftSubmit",
5891
5984
  value: function () {
5892
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5985
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5893
5986
  var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
5894
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5895
- while (1) switch (_context60.prev = _context60.next) {
5987
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5988
+ while (1) switch (_context61.prev = _context61.next) {
5896
5989
  case 0:
5897
5990
  data = params.data, title = params.title;
5898
5991
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5900,10 +5993,10 @@ var Server = /*#__PURE__*/function () {
5900
5993
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
5901
5994
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5902
5995
  });
5903
- _context60.next = 4;
5996
+ _context61.next = 4;
5904
5997
  return this.normalizeCheckoutSubmitData(data, title);
5905
5998
  case 4:
5906
- normalizedData = _context60.sent;
5999
+ normalizedData = _context61.sent;
5907
6000
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
5908
6001
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
5909
6002
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -5913,26 +6006,26 @@ var Server = /*#__PURE__*/function () {
5913
6006
  is_draft_order: 1
5914
6007
  });
5915
6008
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
5916
- _context60.next = 10;
6009
+ _context61.next = 10;
5917
6010
  break;
5918
6011
  }
5919
6012
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
5920
- return _context60.abrupt("return", {
6013
+ return _context61.abrupt("return", {
5921
6014
  code: 500,
5922
6015
  status: false,
5923
6016
  message: 'Order 模块不支持本地草稿写入',
5924
6017
  data: null
5925
6018
  });
5926
6019
  case 10:
5927
- _context60.prev = 10;
5928
- _context60.next = 13;
6020
+ _context61.prev = 10;
6021
+ _context61.next = 13;
5929
6022
  return this.order.upsertLocalDraftOrders([draftOrder]);
5930
6023
  case 13:
5931
6024
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
5932
6025
  order_id: draftOrder.order_id,
5933
6026
  external_sale_number: draftOrder.external_sale_number
5934
6027
  });
5935
- return _context60.abrupt("return", {
6028
+ return _context61.abrupt("return", {
5936
6029
  code: 200,
5937
6030
  status: true,
5938
6031
  message: '',
@@ -5944,13 +6037,13 @@ var Server = /*#__PURE__*/function () {
5944
6037
  })
5945
6038
  });
5946
6039
  case 17:
5947
- _context60.prev = 17;
5948
- _context60.t0 = _context60["catch"](10);
5949
- errorMessage = _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0);
6040
+ _context61.prev = 17;
6041
+ _context61.t0 = _context61["catch"](10);
6042
+ errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
5950
6043
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
5951
6044
  error: errorMessage
5952
6045
  });
5953
- return _context60.abrupt("return", {
6046
+ return _context61.abrupt("return", {
5954
6047
  code: 500,
5955
6048
  status: false,
5956
6049
  message: errorMessage,
@@ -5958,9 +6051,9 @@ var Server = /*#__PURE__*/function () {
5958
6051
  });
5959
6052
  case 22:
5960
6053
  case "end":
5961
- return _context60.stop();
6054
+ return _context61.stop();
5962
6055
  }
5963
- }, _callee60, this, [[10, 17]]);
6056
+ }, _callee61, this, [[10, 17]]);
5964
6057
  }));
5965
6058
  function handleOrderDraftSubmit(_x68) {
5966
6059
  return _handleOrderDraftSubmit.apply(this, arguments);
@@ -5970,26 +6063,26 @@ var Server = /*#__PURE__*/function () {
5970
6063
  }, {
5971
6064
  key: "handlePendingSyncCheckoutOrder",
5972
6065
  value: function () {
5973
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5974
- var _this12 = this;
6066
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6067
+ var _this13 = this;
5975
6068
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
5976
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5977
- while (1) switch (_context61.prev = _context61.next) {
6069
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6070
+ while (1) switch (_context62.prev = _context62.next) {
5978
6071
  case 0:
5979
6072
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
5980
- _context61.next = 3;
6073
+ _context62.next = 3;
5981
6074
  return this.buildPendingSyncCheckoutOrder(data);
5982
6075
  case 3:
5983
- pendingOrder = _context61.sent;
6076
+ pendingOrder = _context62.sent;
5984
6077
  if (pendingOrder) {
5985
- _context61.next = 7;
6078
+ _context62.next = 7;
5986
6079
  break;
5987
6080
  }
5988
6081
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
5989
6082
  backendPath: backendPath,
5990
6083
  reason: reason
5991
6084
  });
5992
- return _context61.abrupt("return", {
6085
+ return _context62.abrupt("return", {
5993
6086
  code: 500,
5994
6087
  status: false,
5995
6088
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -5997,22 +6090,22 @@ var Server = /*#__PURE__*/function () {
5997
6090
  });
5998
6091
  case 7:
5999
6092
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6000
- _context61.next = 10;
6093
+ _context62.next = 10;
6001
6094
  break;
6002
6095
  }
6003
6096
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6004
6097
  backendPath: backendPath,
6005
6098
  reason: reason
6006
6099
  });
6007
- return _context61.abrupt("return", {
6100
+ return _context62.abrupt("return", {
6008
6101
  code: 500,
6009
6102
  status: false,
6010
6103
  message: 'Order 模块不支持本地待同步写入',
6011
6104
  data: null
6012
6105
  });
6013
6106
  case 10:
6014
- _context61.prev = 10;
6015
- _context61.next = 13;
6107
+ _context62.prev = 10;
6108
+ _context62.next = 13;
6016
6109
  return this.order.upsertPendingSyncOrders([pendingOrder]);
6017
6110
  case 13:
6018
6111
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -6024,9 +6117,9 @@ var Server = /*#__PURE__*/function () {
6024
6117
  });
6025
6118
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6026
6119
  var _payment$metadata;
6027
- 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);
6120
+ return sum + _this13.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6028
6121
  }, 0);
6029
- return _context61.abrupt("return", {
6122
+ return _context62.abrupt("return", {
6030
6123
  code: 200,
6031
6124
  status: true,
6032
6125
  message: '',
@@ -6041,15 +6134,15 @@ var Server = /*#__PURE__*/function () {
6041
6134
  })
6042
6135
  });
6043
6136
  case 18:
6044
- _context61.prev = 18;
6045
- _context61.t0 = _context61["catch"](10);
6046
- errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
6137
+ _context62.prev = 18;
6138
+ _context62.t0 = _context62["catch"](10);
6139
+ errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6047
6140
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
6048
6141
  backendPath: backendPath,
6049
6142
  reason: reason,
6050
6143
  error: errorMessage
6051
6144
  });
6052
- return _context61.abrupt("return", {
6145
+ return _context62.abrupt("return", {
6053
6146
  code: 500,
6054
6147
  status: false,
6055
6148
  message: errorMessage,
@@ -6057,9 +6150,9 @@ var Server = /*#__PURE__*/function () {
6057
6150
  });
6058
6151
  case 23:
6059
6152
  case "end":
6060
- return _context61.stop();
6153
+ return _context62.stop();
6061
6154
  }
6062
- }, _callee61, this, [[10, 18]]);
6155
+ }, _callee62, this, [[10, 18]]);
6063
6156
  }));
6064
6157
  function handlePendingSyncCheckoutOrder(_x69) {
6065
6158
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
@@ -6069,42 +6162,42 @@ var Server = /*#__PURE__*/function () {
6069
6162
  }, {
6070
6163
  key: "buildPendingSyncCheckoutOrder",
6071
6164
  value: function () {
6072
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
6165
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
6073
6166
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6074
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6075
- while (1) switch (_context62.prev = _context62.next) {
6167
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6168
+ while (1) switch (_context63.prev = _context63.next) {
6076
6169
  case 0:
6077
6170
  if (!(!data || _typeof(data) !== 'object')) {
6078
- _context62.next = 2;
6171
+ _context63.next = 2;
6079
6172
  break;
6080
6173
  }
6081
- return _context62.abrupt("return", null);
6174
+ return _context63.abrupt("return", null);
6082
6175
  case 2:
6083
6176
  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 !== '';
6084
6177
  if (hasStorageKey) {
6085
- _context62.next = 5;
6178
+ _context63.next = 5;
6086
6179
  break;
6087
6180
  }
6088
- return _context62.abrupt("return", null);
6181
+ return _context63.abrupt("return", null);
6089
6182
  case 5:
6090
6183
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6091
6184
  need_sync: 1,
6092
6185
  is_draft_order: 0
6093
6186
  });
6094
- _context62.next = 8;
6187
+ _context63.next = 8;
6095
6188
  return this.buildSmallTicketProductMap(pendingOrder);
6096
6189
  case 8:
6097
- productMap = _context62.sent;
6190
+ productMap = _context63.sent;
6098
6191
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6099
- return _context62.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6192
+ return _context63.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6100
6193
  requireFullyPaid: true,
6101
6194
  productMap: productMap
6102
6195
  }));
6103
6196
  case 11:
6104
6197
  case "end":
6105
- return _context62.stop();
6198
+ return _context63.stop();
6106
6199
  }
6107
- }, _callee62, this);
6200
+ }, _callee63, this);
6108
6201
  }));
6109
6202
  function buildPendingSyncCheckoutOrder(_x70) {
6110
6203
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
@@ -6154,13 +6247,13 @@ var Server = /*#__PURE__*/function () {
6154
6247
  }, {
6155
6248
  key: "sumPaidOrderPayments",
6156
6249
  value: function sumPaidOrderPayments(payments) {
6157
- var _this13 = this;
6250
+ var _this14 = this;
6158
6251
  if (!Array.isArray(payments)) return 0;
6159
6252
  return payments.reduce(function (sum, payment) {
6160
6253
  var _payment$amount;
6161
6254
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6162
6255
  if (status !== 'paid') return sum;
6163
- 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);
6256
+ return sum + _this14.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);
6164
6257
  }, 0);
6165
6258
  }
6166
6259
  }, {
@@ -6174,12 +6267,12 @@ var Server = /*#__PURE__*/function () {
6174
6267
  }, {
6175
6268
  key: "buildSmallTicketProductMap",
6176
6269
  value: function () {
6177
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(order) {
6270
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
6178
6271
  var _this$products3,
6179
- _this14 = this;
6272
+ _this15 = this;
6180
6273
  var products, productIdSet, productIds, entries;
6181
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6182
- while (1) switch (_context64.prev = _context64.next) {
6274
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6275
+ while (1) switch (_context65.prev = _context65.next) {
6183
6276
  case 0:
6184
6277
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
6185
6278
  productIdSet = new Set();
@@ -6201,45 +6294,45 @@ var Server = /*#__PURE__*/function () {
6201
6294
  });
6202
6295
  productIds = Array.from(productIdSet);
6203
6296
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
6204
- _context64.next = 6;
6297
+ _context65.next = 6;
6205
6298
  break;
6206
6299
  }
6207
- return _context64.abrupt("return", {});
6300
+ return _context65.abrupt("return", {});
6208
6301
  case 6:
6209
- _context64.next = 8;
6302
+ _context65.next = 8;
6210
6303
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6211
- var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(id) {
6212
- var _this14$products, _this14$products$getP, product;
6213
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6214
- while (1) switch (_context63.prev = _context63.next) {
6304
+ var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(id) {
6305
+ var _this15$products, _this15$products$getP, product;
6306
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6307
+ while (1) switch (_context64.prev = _context64.next) {
6215
6308
  case 0:
6216
- _context63.prev = 0;
6217
- _context63.next = 3;
6218
- 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));
6309
+ _context64.prev = 0;
6310
+ _context64.next = 3;
6311
+ return (_this15$products = _this15.products) === null || _this15$products === void 0 || (_this15$products$getP = _this15$products.getProductById) === null || _this15$products$getP === void 0 ? void 0 : _this15$products$getP.call(_this15$products, Number(id));
6219
6312
  case 3:
6220
- product = _context63.sent;
6221
- return _context63.abrupt("return", product ? [String(id), product] : null);
6313
+ product = _context64.sent;
6314
+ return _context64.abrupt("return", product ? [String(id), product] : null);
6222
6315
  case 7:
6223
- _context63.prev = 7;
6224
- _context63.t0 = _context63["catch"](0);
6225
- _this14.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6316
+ _context64.prev = 7;
6317
+ _context64.t0 = _context64["catch"](0);
6318
+ _this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6226
6319
  product_id: id,
6227
- error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
6320
+ error: _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0)
6228
6321
  });
6229
- return _context63.abrupt("return", null);
6322
+ return _context64.abrupt("return", null);
6230
6323
  case 11:
6231
6324
  case "end":
6232
- return _context63.stop();
6325
+ return _context64.stop();
6233
6326
  }
6234
- }, _callee63, null, [[0, 7]]);
6327
+ }, _callee64, null, [[0, 7]]);
6235
6328
  }));
6236
6329
  return function (_x72) {
6237
6330
  return _ref67.apply(this, arguments);
6238
6331
  };
6239
6332
  }()));
6240
6333
  case 8:
6241
- entries = _context64.sent;
6242
- return _context64.abrupt("return", entries.reduce(function (map, entry) {
6334
+ entries = _context65.sent;
6335
+ return _context65.abrupt("return", entries.reduce(function (map, entry) {
6243
6336
  if (!entry) return map;
6244
6337
  var _entry = _slicedToArray(entry, 2),
6245
6338
  id = _entry[0],
@@ -6249,9 +6342,9 @@ var Server = /*#__PURE__*/function () {
6249
6342
  }, {}));
6250
6343
  case 10:
6251
6344
  case "end":
6252
- return _context64.stop();
6345
+ return _context65.stop();
6253
6346
  }
6254
- }, _callee64, this);
6347
+ }, _callee65, this);
6255
6348
  }));
6256
6349
  function buildSmallTicketProductMap(_x71) {
6257
6350
  return _buildSmallTicketProductMap.apply(this, arguments);
@@ -6283,38 +6376,38 @@ var Server = /*#__PURE__*/function () {
6283
6376
  }, {
6284
6377
  key: "buildSalesDetailProductSnapshotMap",
6285
6378
  value: function () {
6286
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
6379
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6287
6380
  var _this$products4;
6288
6381
  var productIds, getSnapshots;
6289
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6290
- while (1) switch (_context65.prev = _context65.next) {
6382
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6383
+ while (1) switch (_context66.prev = _context66.next) {
6291
6384
  case 0:
6292
6385
  productIds = this.collectSalesDetailProductIds(order);
6293
6386
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
6294
6387
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
6295
- _context65.next = 4;
6388
+ _context66.next = 4;
6296
6389
  break;
6297
6390
  }
6298
- return _context65.abrupt("return", {});
6391
+ return _context66.abrupt("return", {});
6299
6392
  case 4:
6300
- _context65.prev = 4;
6301
- _context65.next = 7;
6393
+ _context66.prev = 4;
6394
+ _context66.next = 7;
6302
6395
  return getSnapshots.call(this.products, productIds);
6303
6396
  case 7:
6304
- return _context65.abrupt("return", _context65.sent);
6397
+ return _context66.abrupt("return", _context66.sent);
6305
6398
  case 10:
6306
- _context65.prev = 10;
6307
- _context65.t0 = _context65["catch"](4);
6399
+ _context66.prev = 10;
6400
+ _context66.t0 = _context66["catch"](4);
6308
6401
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
6309
6402
  product_ids: productIds,
6310
- error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6403
+ error: _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0)
6311
6404
  });
6312
- return _context65.abrupt("return", {});
6405
+ return _context66.abrupt("return", {});
6313
6406
  case 14:
6314
6407
  case "end":
6315
- return _context65.stop();
6408
+ return _context66.stop();
6316
6409
  }
6317
- }, _callee65, this, [[4, 10]]);
6410
+ }, _callee66, this, [[4, 10]]);
6318
6411
  }));
6319
6412
  function buildSalesDetailProductSnapshotMap(_x73) {
6320
6413
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
@@ -6372,51 +6465,51 @@ var Server = /*#__PURE__*/function () {
6372
6465
  }, {
6373
6466
  key: "withSalesDetailProductSnapshots",
6374
6467
  value: function () {
6375
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6376
- var _this15 = this;
6468
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6469
+ var _this16 = this;
6377
6470
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6378
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6379
- while (1) switch (_context66.prev = _context66.next) {
6471
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6472
+ while (1) switch (_context67.prev = _context67.next) {
6380
6473
  case 0:
6381
6474
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
6382
6475
  if (products !== null && products !== void 0 && products.length) {
6383
- _context66.next = 3;
6476
+ _context67.next = 3;
6384
6477
  break;
6385
6478
  }
6386
- return _context66.abrupt("return", order);
6479
+ return _context67.abrupt("return", order);
6387
6480
  case 3:
6388
- _context66.next = 5;
6481
+ _context67.next = 5;
6389
6482
  return this.buildSalesDetailProductSnapshotMap(order);
6390
6483
  case 5:
6391
- snapshotMap = _context66.sent;
6484
+ snapshotMap = _context67.sent;
6392
6485
  if (Object.keys(snapshotMap).length) {
6393
- _context66.next = 8;
6486
+ _context67.next = 8;
6394
6487
  break;
6395
6488
  }
6396
- return _context66.abrupt("return", order);
6489
+ return _context67.abrupt("return", order);
6397
6490
  case 8:
6398
6491
  hasChanged = false;
6399
6492
  enrichedProducts = products.map(function (product) {
6400
- var productWithBundleSnapshots = _this15.withBundleCatalogSnapshots(product, snapshotMap);
6401
- var nextProduct = _this15.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6493
+ var productWithBundleSnapshots = _this16.withBundleCatalogSnapshots(product, snapshotMap);
6494
+ var nextProduct = _this16.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6402
6495
  if (nextProduct !== product) hasChanged = true;
6403
6496
  return nextProduct;
6404
6497
  });
6405
6498
  if (hasChanged) {
6406
- _context66.next = 12;
6499
+ _context67.next = 12;
6407
6500
  break;
6408
6501
  }
6409
- return _context66.abrupt("return", order);
6502
+ return _context67.abrupt("return", order);
6410
6503
  case 12:
6411
6504
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
6412
6505
  products: enrichedProducts
6413
6506
  });
6414
- return _context66.abrupt("return", enrichedOrder);
6507
+ return _context67.abrupt("return", enrichedOrder);
6415
6508
  case 14:
6416
6509
  case "end":
6417
- return _context66.stop();
6510
+ return _context67.stop();
6418
6511
  }
6419
- }, _callee66, this);
6512
+ }, _callee67, this);
6420
6513
  }));
6421
6514
  function withSalesDetailProductSnapshots(_x74) {
6422
6515
  return _withSalesDetailProductSnapshots.apply(this, arguments);
@@ -6426,13 +6519,13 @@ var Server = /*#__PURE__*/function () {
6426
6519
  }, {
6427
6520
  key: "withPendingSyncProductTitles",
6428
6521
  value: function withPendingSyncProductTitles(order, productMap) {
6429
- var _this16 = this;
6522
+ var _this17 = this;
6430
6523
  var products = Array.isArray(order.products) ? order.products : null;
6431
6524
  if (!(products !== null && products !== void 0 && products.length)) return order;
6432
6525
  return _objectSpread(_objectSpread({}, order), {}, {
6433
6526
  products: products.map(function (product) {
6434
6527
  return _objectSpread(_objectSpread({}, product), {}, {
6435
- product_title: _this16.buildProductTitleSnapshot(product, productMap)
6528
+ product_title: _this17.buildProductTitleSnapshot(product, productMap)
6436
6529
  });
6437
6530
  })
6438
6531
  });
@@ -6443,7 +6536,7 @@ var Server = /*#__PURE__*/function () {
6443
6536
  var _product$product_id4,
6444
6537
  _product$product,
6445
6538
  _fallbackProduct$prod,
6446
- _this17 = this;
6539
+ _this18 = this;
6447
6540
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6448
6541
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6449
6542
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6451,7 +6544,7 @@ var Server = /*#__PURE__*/function () {
6451
6544
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6452
6545
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6453
6546
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6454
- snapshot[key] = _this17.resolveProductTitleValue(ownTitle, key, currentLocale) || _this17.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6547
+ snapshot[key] = _this18.resolveProductTitleValue(ownTitle, key, currentLocale) || _this18.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6455
6548
  return snapshot;
6456
6549
  }, {});
6457
6550
  }
@@ -6549,50 +6642,50 @@ var Server = /*#__PURE__*/function () {
6549
6642
  }, {
6550
6643
  key: "enrichPaymentNamesByCode",
6551
6644
  value: function () {
6552
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6553
- var _this18 = this;
6554
- var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
6555
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6556
- while (1) switch (_context67.prev = _context67.next) {
6645
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6646
+ var _this19 = this;
6647
+ var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6648
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6649
+ while (1) switch (_context68.prev = _context68.next) {
6557
6650
  case 0:
6558
6651
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6559
6652
  hasMissingName = payments.some(function (payment) {
6560
- return _this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6653
+ return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6561
6654
  });
6562
6655
  if (hasMissingName) {
6563
- _context67.next = 4;
6656
+ _context68.next = 4;
6564
6657
  break;
6565
6658
  }
6566
- return _context67.abrupt("return", order);
6659
+ return _context68.abrupt("return", order);
6567
6660
  case 4:
6568
- _context67.prev = 4;
6569
- _context67.next = 7;
6661
+ _context68.prev = 4;
6662
+ _context68.next = 7;
6570
6663
  return this.getPaymentRouteModule();
6571
6664
  case 7:
6572
- paymentModule = _context67.sent;
6573
- _context67.next = 10;
6665
+ paymentModule = _context68.sent;
6666
+ _context68.next = 10;
6574
6667
  return paymentModule.getPayMethodListAsync();
6575
6668
  case 10:
6576
- payMethods = _context67.sent;
6669
+ payMethods = _context68.sent;
6577
6670
  nameByCode = new Map();
6578
- _iterator13 = _createForOfIteratorHelper(payMethods || []);
6671
+ _iterator12 = _createForOfIteratorHelper(payMethods || []);
6579
6672
  try {
6580
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
6581
- method = _step13.value;
6673
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
6674
+ method = _step12.value;
6582
6675
  codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
6583
6676
  name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
6584
6677
  if (codeKey && name) nameByCode.set(codeKey, name);
6585
6678
  }
6586
6679
  } catch (err) {
6587
- _iterator13.e(err);
6680
+ _iterator12.e(err);
6588
6681
  } finally {
6589
- _iterator13.f();
6682
+ _iterator12.f();
6590
6683
  }
6591
6684
  hasResolvedName = false;
6592
6685
  enrichedPayments = payments.map(function (payment) {
6593
- if (!_this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6594
- if (!_this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6595
- var name = nameByCode.get(_this18.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6686
+ if (!_this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6687
+ if (!_this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6688
+ var name = nameByCode.get(_this19.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6596
6689
  if (!name) return payment;
6597
6690
  hasResolvedName = true;
6598
6691
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6600,26 +6693,26 @@ var Server = /*#__PURE__*/function () {
6600
6693
  });
6601
6694
  });
6602
6695
  if (hasResolvedName) {
6603
- _context67.next = 18;
6696
+ _context68.next = 18;
6604
6697
  break;
6605
6698
  }
6606
- return _context67.abrupt("return", order);
6699
+ return _context68.abrupt("return", order);
6607
6700
  case 18:
6608
- return _context67.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6701
+ return _context68.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6609
6702
  payments: enrichedPayments
6610
6703
  }));
6611
6704
  case 21:
6612
- _context67.prev = 21;
6613
- _context67.t0 = _context67["catch"](4);
6705
+ _context68.prev = 21;
6706
+ _context68.t0 = _context68["catch"](4);
6614
6707
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
6615
- error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
6708
+ error: _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0)
6616
6709
  });
6617
- return _context67.abrupt("return", order);
6710
+ return _context68.abrupt("return", order);
6618
6711
  case 25:
6619
6712
  case "end":
6620
- return _context67.stop();
6713
+ return _context68.stop();
6621
6714
  }
6622
- }, _callee67, this, [[4, 21]]);
6715
+ }, _callee68, this, [[4, 21]]);
6623
6716
  }));
6624
6717
  function enrichPaymentNamesByCode(_x75) {
6625
6718
  return _enrichPaymentNamesByCode.apply(this, arguments);
@@ -6629,64 +6722,64 @@ var Server = /*#__PURE__*/function () {
6629
6722
  }, {
6630
6723
  key: "withLocalSmallTicketData",
6631
6724
  value: function () {
6632
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order, options) {
6725
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order, options) {
6633
6726
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
6634
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6635
- while (1) switch (_context68.prev = _context68.next) {
6727
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6728
+ while (1) switch (_context69.prev = _context69.next) {
6636
6729
  case 0:
6637
6730
  if (this.shouldBuildSmallTicketData(order)) {
6638
- _context68.next = 2;
6731
+ _context69.next = 2;
6639
6732
  break;
6640
6733
  }
6641
- return _context68.abrupt("return", order);
6734
+ return _context69.abrupt("return", order);
6642
6735
  case 2:
6643
6736
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
6644
- _context68.next = 4;
6737
+ _context69.next = 4;
6645
6738
  break;
6646
6739
  }
6647
- return _context68.abrupt("return", order);
6740
+ return _context69.abrupt("return", order);
6648
6741
  case 4:
6649
- _context68.prev = 4;
6650
- _context68.next = 7;
6742
+ _context69.prev = 4;
6743
+ _context69.next = 7;
6651
6744
  return this.enrichPaymentNamesByCode(order);
6652
6745
  case 7:
6653
- enrichedOrder = _context68.sent;
6746
+ enrichedOrder = _context69.sent;
6654
6747
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
6655
- _context68.next = 12;
6748
+ _context69.next = 12;
6656
6749
  break;
6657
6750
  }
6658
- _context68.t0 = _options$productMap;
6659
- _context68.next = 15;
6751
+ _context69.t0 = _options$productMap;
6752
+ _context69.next = 15;
6660
6753
  break;
6661
6754
  case 12:
6662
- _context68.next = 14;
6755
+ _context69.next = 14;
6663
6756
  return this.buildSmallTicketProductMap(enrichedOrder);
6664
6757
  case 14:
6665
- _context68.t0 = _context68.sent;
6758
+ _context69.t0 = _context69.sent;
6666
6759
  case 15:
6667
- productMap = _context68.t0;
6760
+ productMap = _context69.t0;
6668
6761
  smallTicketData = buildSmallTicketData({
6669
6762
  order: enrichedOrder,
6670
6763
  shopInfo: this.getSmallTicketShopInfo(),
6671
6764
  productMap: productMap
6672
6765
  });
6673
- return _context68.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6766
+ return _context69.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6674
6767
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
6675
6768
  small_ticket_data: smallTicketData
6676
6769
  })
6677
6770
  }));
6678
6771
  case 20:
6679
- _context68.prev = 20;
6680
- _context68.t1 = _context68["catch"](4);
6772
+ _context69.prev = 20;
6773
+ _context69.t1 = _context69["catch"](4);
6681
6774
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
6682
- error: _context68.t1 instanceof Error ? _context68.t1.message : String(_context68.t1)
6775
+ error: _context69.t1 instanceof Error ? _context69.t1.message : String(_context69.t1)
6683
6776
  });
6684
- return _context68.abrupt("return", order);
6777
+ return _context69.abrupt("return", order);
6685
6778
  case 24:
6686
6779
  case "end":
6687
- return _context68.stop();
6780
+ return _context69.stop();
6688
6781
  }
6689
- }, _callee68, this, [[4, 20]]);
6782
+ }, _callee69, this, [[4, 20]]);
6690
6783
  }));
6691
6784
  function withLocalSmallTicketData(_x76, _x77) {
6692
6785
  return _withLocalSmallTicketData.apply(this, arguments);
@@ -6750,22 +6843,22 @@ var Server = /*#__PURE__*/function () {
6750
6843
  }, {
6751
6844
  key: "handleUpdateLocalOrdersBatch",
6752
6845
  value: (function () {
6753
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(orderIds) {
6846
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(orderIds) {
6754
6847
  var _this$app17;
6755
- var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
6756
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6757
- while (1) switch (_context69.prev = _context69.next) {
6848
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6849
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6850
+ while (1) switch (_context70.prev = _context70.next) {
6758
6851
  case 0:
6759
6852
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
6760
6853
  count: orderIds.length,
6761
6854
  orderIds: orderIds
6762
6855
  });
6763
6856
  if (this.order) {
6764
- _context69.next = 4;
6857
+ _context70.next = 4;
6765
6858
  break;
6766
6859
  }
6767
6860
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
6768
- return _context69.abrupt("return", {
6861
+ return _context70.abrupt("return", {
6769
6862
  code: 500,
6770
6863
  status: false,
6771
6864
  message: 'Order 模块未注册',
@@ -6773,11 +6866,11 @@ var Server = /*#__PURE__*/function () {
6773
6866
  });
6774
6867
  case 4:
6775
6868
  if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
6776
- _context69.next = 7;
6869
+ _context70.next = 7;
6777
6870
  break;
6778
6871
  }
6779
6872
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
6780
- return _context69.abrupt("return", {
6873
+ return _context70.abrupt("return", {
6781
6874
  code: 500,
6782
6875
  status: false,
6783
6876
  message: 'app.request 不可用',
@@ -6786,35 +6879,35 @@ var Server = /*#__PURE__*/function () {
6786
6879
  case 7:
6787
6880
  // 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
6788
6881
  existedBefore = new Map();
6789
- _iterator14 = _createForOfIteratorHelper(orderIds);
6882
+ _iterator13 = _createForOfIteratorHelper(orderIds);
6790
6883
  try {
6791
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
6792
- id = _step14.value;
6884
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
6885
+ id = _step13.value;
6793
6886
  existedBefore.set(id, !!this.order.getOrderByOrderId(id));
6794
6887
  }
6795
6888
 
6796
6889
  // 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
6797
6890
  } catch (err) {
6798
- _iterator14.e(err);
6891
+ _iterator13.e(err);
6799
6892
  } finally {
6800
- _iterator14.f();
6893
+ _iterator13.f();
6801
6894
  }
6802
6895
  fetched = [];
6803
- _context69.prev = 11;
6804
- _context69.next = 14;
6896
+ _context70.prev = 11;
6897
+ _context70.next = 14;
6805
6898
  return this.order.fetchOrdersByHttp(orderIds);
6806
6899
  case 14:
6807
- fetched = _context69.sent;
6808
- _context69.next = 22;
6900
+ fetched = _context70.sent;
6901
+ _context70.next = 22;
6809
6902
  break;
6810
6903
  case 17:
6811
- _context69.prev = 17;
6812
- _context69.t0 = _context69["catch"](11);
6813
- message = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
6904
+ _context70.prev = 17;
6905
+ _context70.t0 = _context70["catch"](11);
6906
+ message = _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0);
6814
6907
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
6815
6908
  message: message
6816
6909
  });
6817
- return _context69.abrupt("return", {
6910
+ return _context70.abrupt("return", {
6818
6911
  code: 500,
6819
6912
  status: false,
6820
6913
  message: message,
@@ -6823,45 +6916,45 @@ var Server = /*#__PURE__*/function () {
6823
6916
  case 22:
6824
6917
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
6825
6918
  fetchedMap = new Map();
6826
- _iterator15 = _createForOfIteratorHelper(fetched);
6827
- _context69.prev = 24;
6828
- _iterator15.s();
6919
+ _iterator14 = _createForOfIteratorHelper(fetched);
6920
+ _context70.prev = 24;
6921
+ _iterator14.s();
6829
6922
  case 26:
6830
- if ((_step15 = _iterator15.n()).done) {
6831
- _context69.next = 34;
6923
+ if ((_step14 = _iterator14.n()).done) {
6924
+ _context70.next = 34;
6832
6925
  break;
6833
6926
  }
6834
- order = _step15.value;
6927
+ order = _step14.value;
6835
6928
  oid = order === null || order === void 0 ? void 0 : order.order_id;
6836
6929
  if (!(oid === undefined || oid === null)) {
6837
- _context69.next = 31;
6930
+ _context70.next = 31;
6838
6931
  break;
6839
6932
  }
6840
- return _context69.abrupt("continue", 32);
6933
+ return _context70.abrupt("continue", 32);
6841
6934
  case 31:
6842
6935
  fetchedMap.set(String(oid), order);
6843
6936
  case 32:
6844
- _context69.next = 26;
6937
+ _context70.next = 26;
6845
6938
  break;
6846
6939
  case 34:
6847
- _context69.next = 39;
6940
+ _context70.next = 39;
6848
6941
  break;
6849
6942
  case 36:
6850
- _context69.prev = 36;
6851
- _context69.t1 = _context69["catch"](24);
6852
- _iterator15.e(_context69.t1);
6943
+ _context70.prev = 36;
6944
+ _context70.t1 = _context70["catch"](24);
6945
+ _iterator14.e(_context70.t1);
6853
6946
  case 39:
6854
- _context69.prev = 39;
6855
- _iterator15.f();
6856
- return _context69.finish(39);
6947
+ _context70.prev = 39;
6948
+ _iterator14.f();
6949
+ return _context70.finish(39);
6857
6950
  case 42:
6858
6951
  freshOrders = [];
6859
6952
  succeedIds = [];
6860
6953
  failed = [];
6861
- _iterator16 = _createForOfIteratorHelper(orderIds);
6954
+ _iterator15 = _createForOfIteratorHelper(orderIds);
6862
6955
  try {
6863
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
6864
- _id = _step16.value;
6956
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
6957
+ _id = _step15.value;
6865
6958
  fresh = fetchedMap.get(_id);
6866
6959
  if (fresh) {
6867
6960
  freshOrders.push(fresh);
@@ -6874,28 +6967,28 @@ var Server = /*#__PURE__*/function () {
6874
6967
  }
6875
6968
  }
6876
6969
  } catch (err) {
6877
- _iterator16.e(err);
6970
+ _iterator15.e(err);
6878
6971
  } finally {
6879
- _iterator16.f();
6972
+ _iterator15.f();
6880
6973
  }
6881
6974
  if (!(freshOrders.length > 0)) {
6882
- _context69.next = 58;
6975
+ _context70.next = 58;
6883
6976
  break;
6884
6977
  }
6885
- _context69.prev = 48;
6886
- _context69.next = 51;
6978
+ _context70.prev = 48;
6979
+ _context70.next = 51;
6887
6980
  return this.order.upsertOrdersFromRemote(freshOrders);
6888
6981
  case 51:
6889
- _context69.next = 58;
6982
+ _context70.next = 58;
6890
6983
  break;
6891
6984
  case 53:
6892
- _context69.prev = 53;
6893
- _context69.t2 = _context69["catch"](48);
6894
- _message2 = _context69.t2 instanceof Error ? _context69.t2.message : String(_context69.t2);
6985
+ _context70.prev = 53;
6986
+ _context70.t2 = _context70["catch"](48);
6987
+ _message2 = _context70.t2 instanceof Error ? _context70.t2.message : String(_context70.t2);
6895
6988
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
6896
6989
  message: _message2
6897
6990
  });
6898
- return _context69.abrupt("return", {
6991
+ return _context70.abrupt("return", {
6899
6992
  code: 500,
6900
6993
  status: false,
6901
6994
  message: _message2,
@@ -6914,7 +7007,7 @@ var Server = /*#__PURE__*/function () {
6914
7007
  insertedCount: inserted.length,
6915
7008
  failedCount: failed.length
6916
7009
  });
6917
- return _context69.abrupt("return", {
7010
+ return _context70.abrupt("return", {
6918
7011
  code: 200,
6919
7012
  status: true,
6920
7013
  message: '',
@@ -6926,9 +7019,9 @@ var Server = /*#__PURE__*/function () {
6926
7019
  });
6927
7020
  case 62:
6928
7021
  case "end":
6929
- return _context69.stop();
7022
+ return _context70.stop();
6930
7023
  }
6931
- }, _callee69, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7024
+ }, _callee70, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
6932
7025
  }));
6933
7026
  function handleUpdateLocalOrdersBatch(_x78) {
6934
7027
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
@@ -6951,11 +7044,11 @@ var Server = /*#__PURE__*/function () {
6951
7044
  var queryIndex = url.indexOf('?');
6952
7045
  if (queryIndex < 0) return null;
6953
7046
  var query = url.slice(queryIndex + 1);
6954
- var _iterator17 = _createForOfIteratorHelper(query.split('&')),
6955
- _step17;
7047
+ var _iterator16 = _createForOfIteratorHelper(query.split('&')),
7048
+ _step16;
6956
7049
  try {
6957
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
6958
- var pair = _step17.value;
7050
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
7051
+ var pair = _step16.value;
6959
7052
  if (!pair) continue;
6960
7053
  var _pair$split = pair.split('='),
6961
7054
  _pair$split2 = _slicedToArray(_pair$split, 2),
@@ -6971,9 +7064,9 @@ var Server = /*#__PURE__*/function () {
6971
7064
  }
6972
7065
  }
6973
7066
  } catch (err) {
6974
- _iterator17.e(err);
7067
+ _iterator16.e(err);
6975
7068
  } finally {
6976
- _iterator17.f();
7069
+ _iterator16.f();
6977
7070
  }
6978
7071
  return null;
6979
7072
  }
@@ -7174,10 +7267,10 @@ var Server = /*#__PURE__*/function () {
7174
7267
  value: function extractBackendErrorResponse(error) {
7175
7268
  var _error$response3,
7176
7269
  _error$response4,
7177
- _this19 = this;
7270
+ _this20 = this;
7178
7271
  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];
7179
7272
  return candidates.find(function (candidate) {
7180
- return _this19.isExplicitBackendErrorResponse(candidate);
7273
+ return _this20.isExplicitBackendErrorResponse(candidate);
7181
7274
  }) || null;
7182
7275
  }
7183
7276
  }, {
@@ -7296,24 +7389,24 @@ var Server = /*#__PURE__*/function () {
7296
7389
  }, {
7297
7390
  key: "recomputeAndNotifyFloorPlanQuery",
7298
7391
  value: (function () {
7299
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70() {
7300
- var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
7301
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7302
- while (1) switch (_context70.prev = _context70.next) {
7392
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71() {
7393
+ var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7394
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7395
+ while (1) switch (_context71.prev = _context71.next) {
7303
7396
  case 0:
7304
7397
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7305
- _context70.next = 2;
7398
+ _context71.next = 2;
7306
7399
  break;
7307
7400
  }
7308
- return _context70.abrupt("return");
7401
+ return _context71.abrupt("return");
7309
7402
  case 2:
7310
7403
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7311
7404
  subscriberCount: this.floorPlanQuerySubscribers.size
7312
7405
  });
7313
- _iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
7406
+ _iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
7314
7407
  try {
7315
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
7316
- _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
7408
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
7409
+ _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
7317
7410
  try {
7318
7411
  result = this.computeFloorPlanQueryResult(sub.context);
7319
7412
  sub.callback(result);
@@ -7329,15 +7422,15 @@ var Server = /*#__PURE__*/function () {
7329
7422
  }
7330
7423
  }
7331
7424
  } catch (err) {
7332
- _iterator18.e(err);
7425
+ _iterator17.e(err);
7333
7426
  } finally {
7334
- _iterator18.f();
7427
+ _iterator17.f();
7335
7428
  }
7336
7429
  case 5:
7337
7430
  case "end":
7338
- return _context70.stop();
7431
+ return _context71.stop();
7339
7432
  }
7340
- }, _callee70, this);
7433
+ }, _callee71, this);
7341
7434
  }));
7342
7435
  function recomputeAndNotifyFloorPlanQuery() {
7343
7436
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7367,21 +7460,21 @@ var Server = /*#__PURE__*/function () {
7367
7460
  * filter 逻辑暂为 mock,仅记录参数
7368
7461
  */
7369
7462
  function () {
7370
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(data) {
7463
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data) {
7371
7464
  var rawList, result;
7372
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7373
- while (1) switch (_context71.prev = _context71.next) {
7465
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7466
+ while (1) switch (_context72.prev = _context72.next) {
7374
7467
  case 0:
7375
7468
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7376
7469
  data: data
7377
7470
  });
7378
7471
  console.log('[Server] computeOrderQueryResult', data);
7379
7472
  if (this.order) {
7380
- _context71.next = 5;
7473
+ _context72.next = 5;
7381
7474
  break;
7382
7475
  }
7383
7476
  this.logError('computeOrderQueryResult: Order 模块未注册');
7384
- return _context71.abrupt("return", {
7477
+ return _context72.abrupt("return", {
7385
7478
  code: 500,
7386
7479
  message: 'Order 模块未注册',
7387
7480
  data: {
@@ -7411,7 +7504,7 @@ var Server = /*#__PURE__*/function () {
7411
7504
  skip: result.skip,
7412
7505
  rejected: result.rejected
7413
7506
  });
7414
- return _context71.abrupt("return", {
7507
+ return _context72.abrupt("return", {
7415
7508
  code: 200,
7416
7509
  data: result,
7417
7510
  message: '',
@@ -7419,9 +7512,9 @@ var Server = /*#__PURE__*/function () {
7419
7512
  });
7420
7513
  case 11:
7421
7514
  case "end":
7422
- return _context71.stop();
7515
+ return _context72.stop();
7423
7516
  }
7424
- }, _callee71, this);
7517
+ }, _callee72, this);
7425
7518
  }));
7426
7519
  function computeOrderQueryResult(_x79) {
7427
7520
  return _computeOrderQueryResult.apply(this, arguments);
@@ -7436,17 +7529,17 @@ var Server = /*#__PURE__*/function () {
7436
7529
  }, {
7437
7530
  key: "computeBookingQueryResult",
7438
7531
  value: (function () {
7439
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data) {
7532
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7440
7533
  var rawOrders, result;
7441
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7442
- while (1) switch (_context72.prev = _context72.next) {
7534
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7535
+ while (1) switch (_context73.prev = _context73.next) {
7443
7536
  case 0:
7444
7537
  if (this.order) {
7445
- _context72.next = 3;
7538
+ _context73.next = 3;
7446
7539
  break;
7447
7540
  }
7448
7541
  this.logError('computeBookingQueryResult: Order 模块未注册');
7449
- return _context72.abrupt("return", {
7542
+ return _context73.abrupt("return", {
7450
7543
  code: 500,
7451
7544
  message: 'Order 模块未注册',
7452
7545
  data: {
@@ -7465,7 +7558,7 @@ var Server = /*#__PURE__*/function () {
7465
7558
  size: result.size,
7466
7559
  skip: result.skip
7467
7560
  });
7468
- return _context72.abrupt("return", {
7561
+ return _context73.abrupt("return", {
7469
7562
  code: 200,
7470
7563
  data: result,
7471
7564
  message: '',
@@ -7473,9 +7566,9 @@ var Server = /*#__PURE__*/function () {
7473
7566
  });
7474
7567
  case 8:
7475
7568
  case "end":
7476
- return _context72.stop();
7569
+ return _context73.stop();
7477
7570
  }
7478
- }, _callee72, this);
7571
+ }, _callee73, this);
7479
7572
  }));
7480
7573
  function computeBookingQueryResult(_x80) {
7481
7574
  return _computeBookingQueryResult.apply(this, arguments);
@@ -7536,12 +7629,12 @@ var Server = /*#__PURE__*/function () {
7536
7629
  }, {
7537
7630
  key: "computeProductQueryResult",
7538
7631
  value: (function () {
7539
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(context, options) {
7632
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(context, options) {
7540
7633
  var _menu_list_ids$length3,
7541
- _this20 = this;
7542
- 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;
7543
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7544
- while (1) switch (_context73.prev = _context73.next) {
7634
+ _this21 = this;
7635
+ 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, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
7636
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7637
+ while (1) switch (_context74.prev = _context74.next) {
7545
7638
  case 0:
7546
7639
  tTotal = performance.now();
7547
7640
  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;
@@ -7568,28 +7661,28 @@ var Server = /*#__PURE__*/function () {
7568
7661
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7569
7662
  });
7570
7663
  if (this.products) {
7571
- _context73.next = 8;
7664
+ _context74.next = 8;
7572
7665
  break;
7573
7666
  }
7574
7667
  this.logError('computeProductQueryResult: Products 模块未注册');
7575
- return _context73.abrupt("return", {
7668
+ return _context74.abrupt("return", {
7576
7669
  message: 'Products 模块未注册',
7577
7670
  data: this.buildProductQueryResultPayload([], 0)
7578
7671
  });
7579
7672
  case 8:
7580
7673
  if (!(queryIds.length > 0)) {
7581
- _context73.next = 20;
7674
+ _context74.next = 20;
7582
7675
  break;
7583
7676
  }
7584
7677
  uniqueIds = Array.from(new Set(queryIds));
7585
7678
  _tPrice = performance.now();
7586
- _context73.next = 13;
7679
+ _context74.next = 13;
7587
7680
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7588
7681
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7589
7682
  productIds: uniqueIds
7590
7683
  });
7591
7684
  case 13:
7592
- productsWithPrice = _context73.sent;
7685
+ productsWithPrice = _context74.sent;
7593
7686
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7594
7687
  count: productsWithPrice.length,
7595
7688
  ids: uniqueIds
@@ -7609,7 +7702,7 @@ var Server = /*#__PURE__*/function () {
7609
7702
  ids: uniqueIds,
7610
7703
  count: extensionFilteredProducts.length
7611
7704
  });
7612
- return _context73.abrupt("return", {
7705
+ return _context74.abrupt("return", {
7613
7706
  code: 200,
7614
7707
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7615
7708
  message: '',
@@ -7617,17 +7710,17 @@ var Server = /*#__PURE__*/function () {
7617
7710
  });
7618
7711
  case 20:
7619
7712
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7620
- _context73.next = 32;
7713
+ _context74.next = 32;
7621
7714
  break;
7622
7715
  }
7623
7716
  pid = Number(product_id);
7624
7717
  _tPrice2 = performance.now();
7625
- _context73.next = 25;
7718
+ _context74.next = 25;
7626
7719
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7627
7720
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7628
7721
  });
7629
7722
  case 25:
7630
- allProductsWithPrice = _context73.sent;
7723
+ allProductsWithPrice = _context74.sent;
7631
7724
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7632
7725
  count: allProductsWithPrice.length,
7633
7726
  productId: pid
@@ -7647,7 +7740,7 @@ var Server = /*#__PURE__*/function () {
7647
7740
  productId: pid,
7648
7741
  found: !!item
7649
7742
  });
7650
- return _context73.abrupt("return", {
7743
+ return _context74.abrupt("return", {
7651
7744
  code: 200,
7652
7745
  data: item,
7653
7746
  message: item ? '' : '商品不存在或未发布',
@@ -7655,16 +7748,16 @@ var Server = /*#__PURE__*/function () {
7655
7748
  });
7656
7749
  case 32:
7657
7750
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7658
- _context73.next = 52;
7751
+ _context74.next = 52;
7659
7752
  break;
7660
7753
  }
7661
7754
  _tPrice3 = performance.now();
7662
- _context73.next = 36;
7755
+ _context74.next = 36;
7663
7756
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7664
7757
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7665
7758
  });
7666
7759
  case 36:
7667
- _filteredProducts2 = _context73.sent;
7760
+ _filteredProducts2 = _context74.sent;
7668
7761
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7669
7762
  count: _filteredProducts2.length,
7670
7763
  extension_type: extension_type
@@ -7703,7 +7796,7 @@ var Server = /*#__PURE__*/function () {
7703
7796
  filteredCount: _filteredProducts2.length,
7704
7797
  extension_type: extension_type
7705
7798
  });
7706
- return _context73.abrupt("return", {
7799
+ return _context74.abrupt("return", {
7707
7800
  code: 200,
7708
7801
  data: this.buildProductQueryResultPayload(_filteredProducts2),
7709
7802
  message: '',
@@ -7711,38 +7804,59 @@ var Server = /*#__PURE__*/function () {
7711
7804
  });
7712
7805
  case 52:
7713
7806
  if (this.menu) {
7714
- _context73.next = 55;
7807
+ _context74.next = 55;
7715
7808
  break;
7716
7809
  }
7717
7810
  this.logError('computeProductQueryResult: Menu 模块未注册');
7718
- return _context73.abrupt("return", {
7811
+ return _context74.abrupt("return", {
7719
7812
  message: 'Menu 模块未注册',
7720
7813
  data: this.buildProductQueryResultPayload([], 0)
7721
7814
  });
7722
7815
  case 55:
7723
7816
  if (this.schedule) {
7724
- _context73.next = 58;
7817
+ _context74.next = 58;
7725
7818
  break;
7726
7819
  }
7727
7820
  this.logError('computeProductQueryResult: Schedule 模块未注册');
7728
- return _context73.abrupt("return", {
7821
+ return _context74.abrupt("return", {
7729
7822
  message: 'Schedule 模块未注册',
7730
7823
  data: this.buildProductQueryResultPayload([], 0)
7731
7824
  });
7732
7825
  case 58:
7733
7826
  activeMenuList = [];
7734
- if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
7735
- tMenu = performance.now();
7736
- menuList = this.menu.getMenuByIds(menu_list_ids);
7737
- activeMenuList = menuList.filter(function (menu) {
7738
- var _this20$schedule;
7739
- return ((_this20$schedule = _this20.schedule) === null || _this20$schedule === void 0 ? void 0 : _this20$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7740
- });
7741
- perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
7742
- totalMenu: menuList.length,
7743
- activeMenu: activeMenuList.length
7827
+ if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
7828
+ _context74.next = 71;
7829
+ break;
7830
+ }
7831
+ tMenu = performance.now();
7832
+ getActiveMenus = function getActiveMenus() {
7833
+ return _this21.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7834
+ var _this21$schedule;
7835
+ return ((_this21$schedule = _this21.schedule) === null || _this21$schedule === void 0 ? void 0 : _this21$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7744
7836
  });
7837
+ };
7838
+ activeMenuList = getActiveMenus();
7839
+ _context74.t0 = !activeMenuList.length;
7840
+ if (!_context74.t0) {
7841
+ _context74.next = 68;
7842
+ break;
7745
7843
  }
7844
+ _context74.next = 67;
7845
+ return this.refreshMenuScheduleCacheAfterEmptyResult();
7846
+ case 67:
7847
+ _context74.t0 = _context74.sent;
7848
+ case 68:
7849
+ if (!_context74.t0) {
7850
+ _context74.next = 70;
7851
+ break;
7852
+ }
7853
+ activeMenuList = getActiveMenus();
7854
+ case 70:
7855
+ perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
7856
+ totalMenu: menu_list_ids.length,
7857
+ activeMenu: activeMenuList.length
7858
+ });
7859
+ case 71:
7746
7860
  tFilter = performance.now();
7747
7861
  productScope = this.getProductScopeByMenuConfig(activeMenuList);
7748
7862
  scopedProductIds = this.products.getProductIdsByScope(productScope);
@@ -7753,22 +7867,22 @@ var Server = /*#__PURE__*/function () {
7753
7867
  });
7754
7868
  tPrice = performance.now();
7755
7869
  if (!(scopedProductIds.length > 0)) {
7756
- _context73.next = 71;
7870
+ _context74.next = 82;
7757
7871
  break;
7758
7872
  }
7759
- _context73.next = 68;
7873
+ _context74.next = 79;
7760
7874
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7761
7875
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7762
7876
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
7763
7877
  });
7764
- case 68:
7765
- _context73.t0 = _context73.sent;
7766
- _context73.next = 72;
7878
+ case 79:
7879
+ _context74.t1 = _context74.sent;
7880
+ _context74.next = 83;
7767
7881
  break;
7768
- case 71:
7769
- _context73.t0 = [];
7770
- case 72:
7771
- filteredProducts = _context73.t0;
7882
+ case 82:
7883
+ _context74.t1 = [];
7884
+ case 83:
7885
+ filteredProducts = _context74.t1;
7772
7886
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
7773
7887
  count: filteredProducts.length,
7774
7888
  scopedProductCount: scopedProductIds.length
@@ -7809,17 +7923,17 @@ var Server = /*#__PURE__*/function () {
7809
7923
  filteredCount: filteredProducts.length,
7810
7924
  activeMenuCount: activeMenuList.length
7811
7925
  });
7812
- return _context73.abrupt("return", {
7926
+ return _context74.abrupt("return", {
7813
7927
  code: 200,
7814
7928
  data: this.buildProductQueryResultPayload(filteredProducts),
7815
7929
  message: '',
7816
7930
  status: true
7817
7931
  });
7818
- case 88:
7932
+ case 99:
7819
7933
  case "end":
7820
- return _context73.stop();
7934
+ return _context74.stop();
7821
7935
  }
7822
- }, _callee73, this);
7936
+ }, _callee74, this);
7823
7937
  }));
7824
7938
  function computeProductQueryResult(_x81, _x82) {
7825
7939
  return _computeProductQueryResult.apply(this, arguments);
@@ -7857,70 +7971,70 @@ var Server = /*#__PURE__*/function () {
7857
7971
  }, {
7858
7972
  key: "recomputeAndNotifyProductQuery",
7859
7973
  value: (function () {
7860
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(options) {
7861
- var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
7862
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7863
- while (1) switch (_context74.prev = _context74.next) {
7974
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(options) {
7975
+ var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
7976
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7977
+ while (1) switch (_context75.prev = _context75.next) {
7864
7978
  case 0:
7865
7979
  if (!(this.productQuerySubscribers.size === 0)) {
7866
- _context74.next = 2;
7980
+ _context75.next = 2;
7867
7981
  break;
7868
7982
  }
7869
- return _context74.abrupt("return");
7983
+ return _context75.abrupt("return");
7870
7984
  case 2:
7871
7985
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
7872
7986
  subscriberCount: this.productQuerySubscribers.size,
7873
7987
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7874
7988
  });
7875
- _iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
7876
- _context74.prev = 4;
7877
- _iterator19.s();
7989
+ _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
7990
+ _context75.prev = 4;
7991
+ _iterator18.s();
7878
7992
  case 6:
7879
- if ((_step19 = _iterator19.n()).done) {
7880
- _context74.next = 22;
7993
+ if ((_step18 = _iterator18.n()).done) {
7994
+ _context75.next = 22;
7881
7995
  break;
7882
7996
  }
7883
- _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
7884
- _context74.prev = 8;
7885
- _context74.next = 11;
7997
+ _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
7998
+ _context75.prev = 8;
7999
+ _context75.next = 11;
7886
8000
  return this.computeProductQueryResult(subscriber.context, {
7887
8001
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7888
8002
  });
7889
8003
  case 11:
7890
- result = _context74.sent;
8004
+ result = _context75.sent;
7891
8005
  subscriber.callback(result);
7892
8006
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
7893
8007
  subscriberId: subscriberId
7894
8008
  });
7895
- _context74.next = 20;
8009
+ _context75.next = 20;
7896
8010
  break;
7897
8011
  case 16:
7898
- _context74.prev = 16;
7899
- _context74.t0 = _context74["catch"](8);
7900
- errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
8012
+ _context75.prev = 16;
8013
+ _context75.t0 = _context75["catch"](8);
8014
+ errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
7901
8015
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
7902
8016
  subscriberId: subscriberId,
7903
8017
  error: errorMessage
7904
8018
  });
7905
8019
  case 20:
7906
- _context74.next = 6;
8020
+ _context75.next = 6;
7907
8021
  break;
7908
8022
  case 22:
7909
- _context74.next = 27;
8023
+ _context75.next = 27;
7910
8024
  break;
7911
8025
  case 24:
7912
- _context74.prev = 24;
7913
- _context74.t1 = _context74["catch"](4);
7914
- _iterator19.e(_context74.t1);
8026
+ _context75.prev = 24;
8027
+ _context75.t1 = _context75["catch"](4);
8028
+ _iterator18.e(_context75.t1);
7915
8029
  case 27:
7916
- _context74.prev = 27;
7917
- _iterator19.f();
7918
- return _context74.finish(27);
8030
+ _context75.prev = 27;
8031
+ _iterator18.f();
8032
+ return _context75.finish(27);
7919
8033
  case 30:
7920
8034
  case "end":
7921
- return _context74.stop();
8035
+ return _context75.stop();
7922
8036
  }
7923
- }, _callee74, this, [[4, 24, 27, 30], [8, 16]]);
8037
+ }, _callee75, this, [[4, 24, 27, 30], [8, 16]]);
7924
8038
  }));
7925
8039
  function recomputeAndNotifyProductQuery(_x83) {
7926
8040
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
@@ -7934,37 +8048,37 @@ var Server = /*#__PURE__*/function () {
7934
8048
  }, {
7935
8049
  key: "recomputeAndNotifyOrderQuery",
7936
8050
  value: (function () {
7937
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75() {
7938
- var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
7939
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7940
- while (1) switch (_context75.prev = _context75.next) {
8051
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
8052
+ var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8053
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8054
+ while (1) switch (_context76.prev = _context76.next) {
7941
8055
  case 0:
7942
8056
  if (!(this.orderQuerySubscribers.size === 0)) {
7943
- _context75.next = 2;
8057
+ _context76.next = 2;
7944
8058
  break;
7945
8059
  }
7946
- return _context75.abrupt("return");
8060
+ return _context76.abrupt("return");
7947
8061
  case 2:
7948
8062
  notifyStartAt = Date.now();
7949
8063
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
7950
8064
  subscriberCount: this.orderQuerySubscribers.size,
7951
8065
  notifyStartAt: new Date(notifyStartAt).toISOString()
7952
8066
  });
7953
- _iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
7954
- _context75.prev = 5;
7955
- _iterator20.s();
8067
+ _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8068
+ _context76.prev = 5;
8069
+ _iterator19.s();
7956
8070
  case 7:
7957
- if ((_step20 = _iterator20.n()).done) {
7958
- _context75.next = 27;
8071
+ if ((_step19 = _iterator19.n()).done) {
8072
+ _context76.next = 27;
7959
8073
  break;
7960
8074
  }
7961
- _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
7962
- _context75.prev = 9;
8075
+ _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8076
+ _context76.prev = 9;
7963
8077
  computeStartAt = Date.now();
7964
- _context75.next = 13;
8078
+ _context76.next = 13;
7965
8079
  return this.computeOrderQueryResult(subscriber.context);
7966
8080
  case 13:
7967
- result = _context75.sent;
8081
+ result = _context76.sent;
7968
8082
  computeEndAt = Date.now();
7969
8083
  callbackStartAt = Date.now();
7970
8084
  subscriber.callback(result);
@@ -7975,30 +8089,30 @@ var Server = /*#__PURE__*/function () {
7975
8089
  callbackDurationMs: callbackEndAt - callbackStartAt,
7976
8090
  totalDurationMs: callbackEndAt - computeStartAt
7977
8091
  });
7978
- _context75.next = 25;
8092
+ _context76.next = 25;
7979
8093
  break;
7980
8094
  case 21:
7981
- _context75.prev = 21;
7982
- _context75.t0 = _context75["catch"](9);
7983
- errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
8095
+ _context76.prev = 21;
8096
+ _context76.t0 = _context76["catch"](9);
8097
+ errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
7984
8098
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
7985
8099
  subscriberId: subscriberId,
7986
8100
  error: errorMessage
7987
8101
  });
7988
8102
  case 25:
7989
- _context75.next = 7;
8103
+ _context76.next = 7;
7990
8104
  break;
7991
8105
  case 27:
7992
- _context75.next = 32;
8106
+ _context76.next = 32;
7993
8107
  break;
7994
8108
  case 29:
7995
- _context75.prev = 29;
7996
- _context75.t1 = _context75["catch"](5);
7997
- _iterator20.e(_context75.t1);
8109
+ _context76.prev = 29;
8110
+ _context76.t1 = _context76["catch"](5);
8111
+ _iterator19.e(_context76.t1);
7998
8112
  case 32:
7999
- _context75.prev = 32;
8000
- _iterator20.f();
8001
- return _context75.finish(32);
8113
+ _context76.prev = 32;
8114
+ _iterator19.f();
8115
+ return _context76.finish(32);
8002
8116
  case 35:
8003
8117
  notifyEndAt = Date.now();
8004
8118
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8007,9 +8121,9 @@ var Server = /*#__PURE__*/function () {
8007
8121
  });
8008
8122
  case 37:
8009
8123
  case "end":
8010
- return _context75.stop();
8124
+ return _context76.stop();
8011
8125
  }
8012
- }, _callee75, this, [[5, 29, 32, 35], [9, 21]]);
8126
+ }, _callee76, this, [[5, 29, 32, 35], [9, 21]]);
8013
8127
  }));
8014
8128
  function recomputeAndNotifyOrderQuery() {
8015
8129
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8027,7 +8141,7 @@ var Server = /*#__PURE__*/function () {
8027
8141
  }, {
8028
8142
  key: "notifySalesSearchSubscribers",
8029
8143
  value: function notifySalesSearchSubscribers(payload) {
8030
- var _this21 = this;
8144
+ var _this22 = this;
8031
8145
  if (this.salesSearchSubscribers.size === 0) return;
8032
8146
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8033
8147
  if (changedOrders.length === 0) {
@@ -8036,42 +8150,42 @@ var Server = /*#__PURE__*/function () {
8036
8150
  // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
8037
8151
  // 导致模块被销毁 ,checkout 弹窗永远无法关闭
8038
8152
  if (window.isPaymentModalPluginOpen) return;
8039
- var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
8040
- _step21;
8153
+ var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
8154
+ _step20;
8041
8155
  try {
8042
- var _loop2 = function _loop2() {
8043
- var _step21$value = _slicedToArray(_step21.value, 2),
8044
- subscriberId = _step21$value[0],
8045
- subscriber = _step21$value[1];
8156
+ var _loop = function _loop() {
8157
+ var _step20$value = _slicedToArray(_step20.value, 2),
8158
+ subscriberId = _step20$value[0],
8159
+ subscriber = _step20$value[1];
8046
8160
  try {
8047
8161
  var changedVisibleOrders = changedOrders.filter(function (order) {
8048
- var orderId = _this21.getSalesSearchOrderId(order);
8162
+ var orderId = _this22.getSalesSearchOrderId(order);
8049
8163
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8050
8164
  });
8051
8165
  if (changedVisibleOrders.length === 0) {
8052
8166
  return 1; // continue
8053
8167
  }
8054
- subscriber.callback(_this21.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8055
- _this21.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8168
+ subscriber.callback(_this22.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8169
+ _this22.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8056
8170
  subscriberId: subscriberId,
8057
8171
  kind: subscriber.kind,
8058
8172
  count: changedVisibleOrders.length
8059
8173
  });
8060
8174
  } catch (error) {
8061
8175
  var errorMessage = error instanceof Error ? error.message : String(error);
8062
- _this21.logError('notifySalesSearchSubscribers: 推送失败', {
8176
+ _this22.logError('notifySalesSearchSubscribers: 推送失败', {
8063
8177
  subscriberId: subscriberId,
8064
8178
  error: errorMessage
8065
8179
  });
8066
8180
  }
8067
8181
  };
8068
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
8069
- if (_loop2()) continue;
8182
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
8183
+ if (_loop()) continue;
8070
8184
  }
8071
8185
  } catch (err) {
8072
- _iterator21.e(err);
8186
+ _iterator20.e(err);
8073
8187
  } finally {
8074
- _iterator21.f();
8188
+ _iterator20.f();
8075
8189
  }
8076
8190
  }
8077
8191
 
@@ -8150,67 +8264,67 @@ var Server = /*#__PURE__*/function () {
8150
8264
  }, {
8151
8265
  key: "recomputeAndNotifyBookingQuery",
8152
8266
  value: (function () {
8153
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
8154
- var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
8155
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8156
- while (1) switch (_context76.prev = _context76.next) {
8267
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8268
+ var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8269
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8270
+ while (1) switch (_context77.prev = _context77.next) {
8157
8271
  case 0:
8158
8272
  if (!(this.bookingQuerySubscribers.size === 0)) {
8159
- _context76.next = 2;
8273
+ _context77.next = 2;
8160
8274
  break;
8161
8275
  }
8162
- return _context76.abrupt("return");
8276
+ return _context77.abrupt("return");
8163
8277
  case 2:
8164
8278
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8165
8279
  subscriberCount: this.bookingQuerySubscribers.size
8166
8280
  });
8167
- _iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8168
- _context76.prev = 4;
8169
- _iterator22.s();
8281
+ _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8282
+ _context77.prev = 4;
8283
+ _iterator21.s();
8170
8284
  case 6:
8171
- if ((_step22 = _iterator22.n()).done) {
8172
- _context76.next = 22;
8285
+ if ((_step21 = _iterator21.n()).done) {
8286
+ _context77.next = 22;
8173
8287
  break;
8174
8288
  }
8175
- _step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
8176
- _context76.prev = 8;
8177
- _context76.next = 11;
8289
+ _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8290
+ _context77.prev = 8;
8291
+ _context77.next = 11;
8178
8292
  return this.computeBookingQueryResult(subscriber.context);
8179
8293
  case 11:
8180
- result = _context76.sent;
8294
+ result = _context77.sent;
8181
8295
  subscriber.callback(result);
8182
8296
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8183
8297
  subscriberId: subscriberId
8184
8298
  });
8185
- _context76.next = 20;
8299
+ _context77.next = 20;
8186
8300
  break;
8187
8301
  case 16:
8188
- _context76.prev = 16;
8189
- _context76.t0 = _context76["catch"](8);
8190
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8302
+ _context77.prev = 16;
8303
+ _context77.t0 = _context77["catch"](8);
8304
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8191
8305
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8192
8306
  subscriberId: subscriberId,
8193
8307
  error: errorMessage
8194
8308
  });
8195
8309
  case 20:
8196
- _context76.next = 6;
8310
+ _context77.next = 6;
8197
8311
  break;
8198
8312
  case 22:
8199
- _context76.next = 27;
8313
+ _context77.next = 27;
8200
8314
  break;
8201
8315
  case 24:
8202
- _context76.prev = 24;
8203
- _context76.t1 = _context76["catch"](4);
8204
- _iterator22.e(_context76.t1);
8316
+ _context77.prev = 24;
8317
+ _context77.t1 = _context77["catch"](4);
8318
+ _iterator21.e(_context77.t1);
8205
8319
  case 27:
8206
- _context76.prev = 27;
8207
- _iterator22.f();
8208
- return _context76.finish(27);
8320
+ _context77.prev = 27;
8321
+ _iterator21.f();
8322
+ return _context77.finish(27);
8209
8323
  case 30:
8210
8324
  case "end":
8211
- return _context76.stop();
8325
+ return _context77.stop();
8212
8326
  }
8213
- }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8327
+ }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8214
8328
  }));
8215
8329
  function recomputeAndNotifyBookingQuery() {
8216
8330
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -8240,11 +8354,11 @@ var Server = /*#__PURE__*/function () {
8240
8354
  var allowedProductIds = new Set();
8241
8355
  var allowedCollectionIds = new Set();
8242
8356
  var hasProductAll = false;
8243
- var _iterator23 = _createForOfIteratorHelper(activeMenuList),
8244
- _step23;
8357
+ var _iterator22 = _createForOfIteratorHelper(activeMenuList),
8358
+ _step22;
8245
8359
  try {
8246
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
8247
- var menu = _step23.value;
8360
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
8361
+ var menu = _step22.value;
8248
8362
  var config = menu.partyroom_package;
8249
8363
  if (!config) {
8250
8364
  console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
@@ -8304,9 +8418,9 @@ var Server = /*#__PURE__*/function () {
8304
8418
 
8305
8419
  // 如果有餐牌允许所有商品,返回所有商品
8306
8420
  } catch (err) {
8307
- _iterator23.e(err);
8421
+ _iterator22.e(err);
8308
8422
  } finally {
8309
- _iterator23.f();
8423
+ _iterator22.f();
8310
8424
  }
8311
8425
  if (hasProductAll) {
8312
8426
  this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');