@pisell/pisellos 2.3.89 → 2.3.91

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.
@@ -2458,7 +2458,7 @@ var Server = /*#__PURE__*/function () {
2458
2458
  value: function () {
2459
2459
  var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2460
2460
  var _this$app6;
2461
- var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2461
+ var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, deviceHeaders, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2462
2462
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2463
2463
  while (1) switch (_context31.prev = _context31.next) {
2464
2464
  case 0:
@@ -2473,21 +2473,27 @@ var Server = /*#__PURE__*/function () {
2473
2473
  numberedData = _context31.sent;
2474
2474
  checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2475
2475
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2476
+ _context31.next = 11;
2477
+ return this.buildCheckoutDeviceHeaders(title);
2478
+ case 11:
2479
+ deviceHeaders = _context31.sent;
2476
2480
  if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
2477
- _context31.next = 11;
2481
+ _context31.next = 14;
2478
2482
  break;
2479
2483
  }
2480
2484
  throw new Error('app.request 不可用');
2481
- case 11:
2482
- _context31.next = 13;
2483
- return this.app.request.post(backendPath, remoteCheckoutData, {
2485
+ case 14:
2486
+ _context31.next = 16;
2487
+ return this.app.request.post(backendPath, remoteCheckoutData, _objectSpread({
2484
2488
  isShopApi: true,
2485
2489
  customToast: function customToast() {}
2486
- });
2487
- case 13:
2490
+ }, Object.keys(deviceHeaders).length > 0 ? {
2491
+ headers: deviceHeaders
2492
+ } : {}));
2493
+ case 16:
2488
2494
  response = _context31.sent;
2489
2495
  if (!this.isCheckoutResponseRejected(response)) {
2490
- _context31.next = 16;
2496
+ _context31.next = 19;
2491
2497
  break;
2492
2498
  }
2493
2499
  return _context31.abrupt("return", {
@@ -2498,13 +2504,13 @@ var Server = /*#__PURE__*/function () {
2498
2504
  normalizedResponse: this.normalizeCheckoutResponse(response),
2499
2505
  checkoutData: checkoutData
2500
2506
  });
2501
- case 16:
2507
+ case 19:
2502
2508
  fresh = this.extractOrderDataFromCheckoutResponse(response);
2503
2509
  externalSaleNumber = this.getCheckoutExternalSaleNumber(checkoutData, {
2504
2510
  external_sale_number: params.externalSaleNumber,
2505
2511
  data: checkoutData
2506
2512
  });
2507
- _context31.next = 20;
2513
+ _context31.next = 23;
2508
2514
  return this.persistSyncedCheckoutOrder({
2509
2515
  backendPath: backendPath,
2510
2516
  checkoutData: checkoutData,
@@ -2513,7 +2519,7 @@ var Server = /*#__PURE__*/function () {
2513
2519
  title: title,
2514
2520
  persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
2515
2521
  });
2516
- case 20:
2522
+ case 23:
2517
2523
  syncedOrder = _context31.sent;
2518
2524
  printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
2519
2525
  syncedOrder: syncedOrder,
@@ -2523,17 +2529,17 @@ var Server = /*#__PURE__*/function () {
2523
2529
  checkoutData: checkoutData,
2524
2530
  syncedOrder: printableSyncedOrder
2525
2531
  }))) {
2526
- _context31.next = 25;
2532
+ _context31.next = 28;
2527
2533
  break;
2528
2534
  }
2529
- _context31.next = 25;
2535
+ _context31.next = 28;
2530
2536
  return this.dispatchPrintOtherReceiptTask({
2531
2537
  checkoutData: checkoutData,
2532
2538
  syncedOrder: printableSyncedOrder,
2533
2539
  response: response,
2534
2540
  deviceId: params.deviceId
2535
2541
  });
2536
- case 25:
2542
+ case 28:
2537
2543
  return _context31.abrupt("return", {
2538
2544
  rejected: false,
2539
2545
  response: response,
@@ -2542,7 +2548,7 @@ var Server = /*#__PURE__*/function () {
2542
2548
  syncedOrder: syncedOrder,
2543
2549
  fresh: fresh
2544
2550
  });
2545
- case 26:
2551
+ case 29:
2546
2552
  case "end":
2547
2553
  return _context31.stop();
2548
2554
  }
@@ -2569,6 +2575,7 @@ var Server = /*#__PURE__*/function () {
2569
2575
  if (!next || _typeof(next) !== 'object') return next;
2570
2576
  var record = next;
2571
2577
  delete record[OS_FULFILLMENT_REF_MODE_FIELD];
2578
+ this.applyKioskCheckoutOperator(record);
2572
2579
  if (!Array.isArray(record.payments)) return next;
2573
2580
  var originalPayments = record.payments;
2574
2581
  var filteredPayments = originalPayments.filter(function (payment) {
@@ -2589,6 +2596,92 @@ var Server = /*#__PURE__*/function () {
2589
2596
  });
2590
2597
  return next;
2591
2598
  }
2599
+ }, {
2600
+ key: "buildCheckoutDeviceHeaders",
2601
+ value: function () {
2602
+ var _buildCheckoutDeviceHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(title) {
2603
+ var _this5 = this;
2604
+ var getAsyncIotDeviceInfo, deviceInfo, headers, assignHeader;
2605
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2606
+ while (1) switch (_context32.prev = _context32.next) {
2607
+ case 0:
2608
+ getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
2609
+ if (getAsyncIotDeviceInfo) {
2610
+ _context32.next = 3;
2611
+ break;
2612
+ }
2613
+ return _context32.abrupt("return", {});
2614
+ case 3:
2615
+ _context32.prev = 3;
2616
+ if (!(typeof getAsyncIotDeviceInfo === 'function')) {
2617
+ _context32.next = 10;
2618
+ break;
2619
+ }
2620
+ _context32.next = 7;
2621
+ return getAsyncIotDeviceInfo();
2622
+ case 7:
2623
+ _context32.t0 = _context32.sent;
2624
+ _context32.next = 11;
2625
+ break;
2626
+ case 10:
2627
+ _context32.t0 = getAsyncIotDeviceInfo;
2628
+ case 11:
2629
+ deviceInfo = _context32.t0;
2630
+ _context32.next = 18;
2631
+ break;
2632
+ case 14:
2633
+ _context32.prev = 14;
2634
+ _context32.t1 = _context32["catch"](3);
2635
+ this.logWarning("".concat(title, ": \u8BFB\u53D6 async_iot_device_info \u5931\u8D25\uFF0C\u8DF3\u8FC7 checkout \u8BBE\u5907\u8BF7\u6C42\u5934"), {
2636
+ error: this.getUnknownErrorMessage(_context32.t1)
2637
+ });
2638
+ return _context32.abrupt("return", {});
2639
+ case 18:
2640
+ if (!(!deviceInfo || _typeof(deviceInfo) !== 'object')) {
2641
+ _context32.next = 20;
2642
+ break;
2643
+ }
2644
+ return _context32.abrupt("return", {});
2645
+ case 20:
2646
+ headers = {};
2647
+ assignHeader = function assignHeader(key, value) {
2648
+ if (_this5.isBlankCheckoutValue(value)) return;
2649
+ headers[key] = String(value);
2650
+ };
2651
+ assignHeader('Device-ID', deviceInfo.id);
2652
+ assignHeader('Device-Type-Code', deviceInfo.type_code);
2653
+ assignHeader('Device-Model-Code', deviceInfo.model_code);
2654
+ return _context32.abrupt("return", headers);
2655
+ case 26:
2656
+ case "end":
2657
+ return _context32.stop();
2658
+ }
2659
+ }, _callee32, this, [[3, 14]]);
2660
+ }));
2661
+ function buildCheckoutDeviceHeaders(_x35) {
2662
+ return _buildCheckoutDeviceHeaders.apply(this, arguments);
2663
+ }
2664
+ return buildCheckoutDeviceHeaders;
2665
+ }()
2666
+ }, {
2667
+ key: "applyKioskCheckoutOperator",
2668
+ value: function applyKioskCheckoutOperator(record) {
2669
+ if (record.platform !== 'kiosk') return;
2670
+ record.operator_type = 'customer';
2671
+ record.operator_id = this.resolveKioskCheckoutOperatorId(record.customer_id);
2672
+ }
2673
+ }, {
2674
+ key: "resolveKioskCheckoutOperatorId",
2675
+ value: function resolveKioskCheckoutOperatorId(customerId) {
2676
+ if (customerId === undefined || customerId === null) return 1;
2677
+ if (typeof customerId === 'string') {
2678
+ var trimmed = customerId.trim();
2679
+ if (trimmed === '' || trimmed === '0' || trimmed === '1') return 1;
2680
+ return customerId;
2681
+ }
2682
+ if (customerId === 0 || customerId === 1) return 1;
2683
+ return customerId;
2684
+ }
2592
2685
  }, {
2593
2686
  key: "mergeCheckoutSyncPayments",
2594
2687
  value: function mergeCheckoutSyncPayments(checkoutData, fresh, title) {
@@ -2627,15 +2720,15 @@ var Server = /*#__PURE__*/function () {
2627
2720
  }, {
2628
2721
  key: "persistSyncedCheckoutOrder",
2629
2722
  value: function () {
2630
- var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2723
+ var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2631
2724
  var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
2632
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2633
- while (1) switch (_context32.prev = _context32.next) {
2725
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2726
+ while (1) switch (_context33.prev = _context33.next) {
2634
2727
  case 0:
2635
2728
  backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
2636
2729
  shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
2637
2730
  if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
2638
- _context32.next = 9;
2731
+ _context33.next = 9;
2639
2732
  break;
2640
2733
  }
2641
2734
  syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
@@ -2647,7 +2740,7 @@ var Server = /*#__PURE__*/function () {
2647
2740
  need_sync: 0,
2648
2741
  is_draft_order: 0
2649
2742
  });
2650
- _context32.next = 6;
2743
+ _context33.next = 6;
2651
2744
  return this.order.upsertOrdersFromRemote([syncedOrder], 'checkoutSync');
2652
2745
  case 6:
2653
2746
  this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
@@ -2657,21 +2750,21 @@ var Server = /*#__PURE__*/function () {
2657
2750
  mergedRemoteOrder: shouldMergeRemoteOrder,
2658
2751
  persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
2659
2752
  });
2660
- _context32.next = 19;
2753
+ _context33.next = 19;
2661
2754
  break;
2662
2755
  case 9:
2663
2756
  if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
2664
- _context32.next = 18;
2757
+ _context33.next = 18;
2665
2758
  break;
2666
2759
  }
2667
2760
  patch = this.buildCheckoutSyncSuccessPatch(fresh);
2668
- _context32.next = 13;
2761
+ _context33.next = 13;
2669
2762
  return this.order.markOrderSyncedByExternalSaleNumber({
2670
2763
  externalSaleNumber: externalSaleNumber,
2671
2764
  patch: patch
2672
2765
  });
2673
2766
  case 13:
2674
- result = _context32.sent;
2767
+ result = _context33.sent;
2675
2768
  syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
2676
2769
  external_sale_number: externalSaleNumber,
2677
2770
  need_sync: 0,
@@ -2683,7 +2776,7 @@ var Server = /*#__PURE__*/function () {
2683
2776
  hasRemoteOrder: !!fresh,
2684
2777
  mergedRemoteOrder: false
2685
2778
  });
2686
- _context32.next = 19;
2779
+ _context33.next = 19;
2687
2780
  break;
2688
2781
  case 18:
2689
2782
  this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
@@ -2692,14 +2785,14 @@ var Server = /*#__PURE__*/function () {
2692
2785
  order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
2693
2786
  });
2694
2787
  case 19:
2695
- return _context32.abrupt("return", syncedOrder);
2788
+ return _context33.abrupt("return", syncedOrder);
2696
2789
  case 20:
2697
2790
  case "end":
2698
- return _context32.stop();
2791
+ return _context33.stop();
2699
2792
  }
2700
- }, _callee32, this);
2793
+ }, _callee33, this);
2701
2794
  }));
2702
- function persistSyncedCheckoutOrder(_x35) {
2795
+ function persistSyncedCheckoutOrder(_x36) {
2703
2796
  return _persistSyncedCheckoutOrder.apply(this, arguments);
2704
2797
  }
2705
2798
  return persistSyncedCheckoutOrder;
@@ -2710,63 +2803,63 @@ var Server = /*#__PURE__*/function () {
2710
2803
  }, {
2711
2804
  key: "setupProductsQuotationPriceBridge",
2712
2805
  value: (function () {
2713
- var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2714
- var _this5 = this;
2806
+ var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2807
+ var _this6 = this;
2715
2808
  var _this$core$context, errorMessage;
2716
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2717
- while (1) switch (_context33.prev = _context33.next) {
2809
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2810
+ while (1) switch (_context34.prev = _context34.next) {
2718
2811
  case 0:
2719
2812
  if (this.products) {
2720
- _context33.next = 3;
2813
+ _context34.next = 3;
2721
2814
  break;
2722
2815
  }
2723
2816
  this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
2724
- return _context33.abrupt("return");
2817
+ return _context34.abrupt("return");
2725
2818
  case 3:
2726
2819
  if (this.schedule) {
2727
- _context33.next = 6;
2820
+ _context34.next = 6;
2728
2821
  break;
2729
2822
  }
2730
2823
  this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
2731
- return _context33.abrupt("return");
2824
+ return _context34.abrupt("return");
2732
2825
  case 6:
2733
- _context33.prev = 6;
2826
+ _context34.prev = 6;
2734
2827
  this.products.clearPriceCache();
2735
- _context33.next = 10;
2828
+ _context34.next = 10;
2736
2829
  return this.products.setupQuotationPriceBridge({
2737
2830
  scheduleModule: this.schedule,
2738
2831
  channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
2739
2832
  onQuotationUpdated: function onQuotationUpdated() {
2740
- void _this5.recomputeAndNotifyProductQuery();
2833
+ void _this6.recomputeAndNotifyProductQuery();
2741
2834
  }
2742
2835
  });
2743
2836
  case 10:
2744
2837
  // Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
2745
2838
  // 远端刷新转为后台校准,避免二次启动重复阻塞请求。
2746
2839
  void this.schedule.loadAllSchedule().then(function () {
2747
- var _this5$products;
2748
- (_this5$products = _this5.products) === null || _this5$products === void 0 || _this5$products.clearPriceCache();
2749
- void _this5.recomputeAndNotifyProductQuery();
2840
+ var _this6$products;
2841
+ (_this6$products = _this6.products) === null || _this6$products === void 0 || _this6$products.clearPriceCache();
2842
+ void _this6.recomputeAndNotifyProductQuery();
2750
2843
  }).catch(function (error) {
2751
- _this5.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
2844
+ _this6.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
2752
2845
  error: error instanceof Error ? error.message : String(error)
2753
2846
  });
2754
2847
  });
2755
2848
  this.logInfo('Products 报价单价格桥接初始化完成');
2756
- _context33.next = 18;
2849
+ _context34.next = 18;
2757
2850
  break;
2758
2851
  case 14:
2759
- _context33.prev = 14;
2760
- _context33.t0 = _context33["catch"](6);
2761
- errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
2852
+ _context34.prev = 14;
2853
+ _context34.t0 = _context34["catch"](6);
2854
+ errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2762
2855
  this.logError('Products 报价单价格桥接初始化失败', {
2763
2856
  error: errorMessage
2764
2857
  });
2765
2858
  case 18:
2766
2859
  case "end":
2767
- return _context33.stop();
2860
+ return _context34.stop();
2768
2861
  }
2769
- }, _callee33, this, [[6, 14]]);
2862
+ }, _callee34, this, [[6, 14]]);
2770
2863
  }));
2771
2864
  function setupProductsQuotationPriceBridge() {
2772
2865
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -2835,32 +2928,32 @@ var Server = /*#__PURE__*/function () {
2835
2928
  }, {
2836
2929
  key: "refreshProductsInBackground",
2837
2930
  value: (function () {
2838
- var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2931
+ var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2839
2932
  var options,
2840
2933
  trigger,
2841
2934
  startTime,
2842
2935
  duration,
2843
2936
  _duration2,
2844
2937
  errorMessage,
2845
- _args34 = arguments;
2846
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2847
- while (1) switch (_context34.prev = _context34.next) {
2938
+ _args35 = arguments;
2939
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2940
+ while (1) switch (_context35.prev = _context35.next) {
2848
2941
  case 0:
2849
- options = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
2942
+ options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
2850
2943
  if (this.products) {
2851
- _context34.next = 4;
2944
+ _context35.next = 4;
2852
2945
  break;
2853
2946
  }
2854
2947
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
2855
- return _context34.abrupt("return");
2948
+ return _context35.abrupt("return");
2856
2949
  case 4:
2857
2950
  trigger = options.trigger || 'background';
2858
2951
  this.logInfo('refreshProductsInBackground 开始', {
2859
2952
  trigger: trigger
2860
2953
  });
2861
2954
  startTime = Date.now();
2862
- _context34.prev = 7;
2863
- _context34.next = 10;
2955
+ _context35.prev = 7;
2956
+ _context35.next = 10;
2864
2957
  return this.products.silentRefresh({
2865
2958
  trigger: trigger
2866
2959
  });
@@ -2870,14 +2963,14 @@ var Server = /*#__PURE__*/function () {
2870
2963
  trigger: trigger,
2871
2964
  duration: "".concat(duration, "ms")
2872
2965
  });
2873
- _context34.next = 20;
2966
+ _context35.next = 20;
2874
2967
  break;
2875
2968
  case 14:
2876
- _context34.prev = 14;
2877
- _context34.t0 = _context34["catch"](7);
2969
+ _context35.prev = 14;
2970
+ _context35.t0 = _context35["catch"](7);
2878
2971
  _duration2 = Date.now() - startTime;
2879
- errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2880
- console.error('[Server] refreshProductsInBackground 失败:', _context34.t0);
2972
+ errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
2973
+ console.error('[Server] refreshProductsInBackground 失败:', _context35.t0);
2881
2974
  this.logError('refreshProductsInBackground 失败', {
2882
2975
  trigger: trigger,
2883
2976
  duration: "".concat(_duration2, "ms"),
@@ -2885,9 +2978,9 @@ var Server = /*#__PURE__*/function () {
2885
2978
  });
2886
2979
  case 20:
2887
2980
  case "end":
2888
- return _context34.stop();
2981
+ return _context35.stop();
2889
2982
  }
2890
- }, _callee34, this, [[7, 14]]);
2983
+ }, _callee35, this, [[7, 14]]);
2891
2984
  }));
2892
2985
  function refreshProductsInBackground() {
2893
2986
  return _refreshProductsInBackground.apply(this, arguments);
@@ -2903,32 +2996,32 @@ var Server = /*#__PURE__*/function () {
2903
2996
  }, {
2904
2997
  key: "refreshOrdersInBackground",
2905
2998
  value: (function () {
2906
- var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2999
+ var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2907
3000
  var options,
2908
3001
  trigger,
2909
3002
  startTime,
2910
3003
  duration,
2911
3004
  _duration3,
2912
3005
  errorMessage,
2913
- _args35 = arguments;
2914
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2915
- while (1) switch (_context35.prev = _context35.next) {
3006
+ _args36 = arguments;
3007
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3008
+ while (1) switch (_context36.prev = _context36.next) {
2916
3009
  case 0:
2917
- options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
3010
+ options = _args36.length > 0 && _args36[0] !== undefined ? _args36[0] : {};
2918
3011
  if (this.order) {
2919
- _context35.next = 4;
3012
+ _context36.next = 4;
2920
3013
  break;
2921
3014
  }
2922
3015
  this.logWarning('refreshOrdersInBackground: Order 模块未注册');
2923
- return _context35.abrupt("return");
3016
+ return _context36.abrupt("return");
2924
3017
  case 4:
2925
3018
  trigger = options.trigger || 'background';
2926
3019
  this.logInfo('refreshOrdersInBackground 开始', {
2927
3020
  trigger: trigger
2928
3021
  });
2929
3022
  startTime = Date.now();
2930
- _context35.prev = 7;
2931
- _context35.next = 10;
3023
+ _context36.prev = 7;
3024
+ _context36.next = 10;
2932
3025
  return this.order.silentRefresh({
2933
3026
  trigger: trigger
2934
3027
  });
@@ -2938,14 +3031,14 @@ var Server = /*#__PURE__*/function () {
2938
3031
  trigger: trigger,
2939
3032
  duration: "".concat(duration, "ms")
2940
3033
  });
2941
- _context35.next = 20;
3034
+ _context36.next = 20;
2942
3035
  break;
2943
3036
  case 14:
2944
- _context35.prev = 14;
2945
- _context35.t0 = _context35["catch"](7);
3037
+ _context36.prev = 14;
3038
+ _context36.t0 = _context36["catch"](7);
2946
3039
  _duration3 = Date.now() - startTime;
2947
- errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
2948
- console.error('[Server] refreshOrdersInBackground 失败:', _context35.t0);
3040
+ errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0);
3041
+ console.error('[Server] refreshOrdersInBackground 失败:', _context36.t0);
2949
3042
  this.logError('refreshOrdersInBackground 失败', {
2950
3043
  trigger: trigger,
2951
3044
  duration: "".concat(_duration3, "ms"),
@@ -2953,9 +3046,9 @@ var Server = /*#__PURE__*/function () {
2953
3046
  });
2954
3047
  case 20:
2955
3048
  case "end":
2956
- return _context35.stop();
3049
+ return _context36.stop();
2957
3050
  }
2958
- }, _callee35, this, [[7, 14]]);
3051
+ }, _callee36, this, [[7, 14]]);
2959
3052
  }));
2960
3053
  function refreshOrdersInBackground() {
2961
3054
  return _refreshOrdersInBackground.apply(this, arguments);
@@ -2971,23 +3064,23 @@ var Server = /*#__PURE__*/function () {
2971
3064
  }, {
2972
3065
  key: "checkRemoteOrderProductMembership",
2973
3066
  value: (function () {
2974
- var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId) {
3067
+ var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(orderId) {
2975
3068
  var normalizedOrderId, error, startTime, freshOrders, freshOrder;
2976
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2977
- while (1) switch (_context36.prev = _context36.next) {
3069
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3070
+ while (1) switch (_context37.prev = _context37.next) {
2978
3071
  case 0:
2979
3072
  normalizedOrderId = String(orderId !== null && orderId !== void 0 ? orderId : '').trim();
2980
3073
  if (!(!normalizedOrderId || normalizedOrderId.startsWith('local_order'))) {
2981
- _context36.next = 4;
3074
+ _context37.next = 4;
2982
3075
  break;
2983
3076
  }
2984
3077
  this.logInfo('checkRemoteOrderProductMembership: 跳过非正式订单', {
2985
3078
  orderId: orderId
2986
3079
  });
2987
- return _context36.abrupt("return");
3080
+ return _context37.abrupt("return");
2988
3081
  case 4:
2989
3082
  if (this.order) {
2990
- _context36.next = 8;
3083
+ _context37.next = 8;
2991
3084
  break;
2992
3085
  }
2993
3086
  error = new Error('Order 模块未注册');
@@ -3000,45 +3093,45 @@ var Server = /*#__PURE__*/function () {
3000
3093
  orderId: normalizedOrderId
3001
3094
  });
3002
3095
  startTime = Date.now();
3003
- _context36.prev = 10;
3004
- _context36.next = 13;
3096
+ _context37.prev = 10;
3097
+ _context37.next = 13;
3005
3098
  return this.order.fetchOrdersByHttp([normalizedOrderId]);
3006
3099
  case 13:
3007
- freshOrders = _context36.sent;
3100
+ freshOrders = _context37.sent;
3008
3101
  freshOrder = freshOrders.find(function (order) {
3009
3102
  return String(order === null || order === void 0 ? void 0 : order.order_id) === normalizedOrderId;
3010
3103
  });
3011
3104
  if (freshOrder) {
3012
- _context36.next = 17;
3105
+ _context37.next = 17;
3013
3106
  break;
3014
3107
  }
3015
3108
  throw new Error('Server 未返回目标订单最新快照');
3016
3109
  case 17:
3017
- _context36.next = 19;
3110
+ _context37.next = 19;
3018
3111
  return this.order.upsertOrdersFromRemote([freshOrder], 'manual.editOpenRemoteCheck');
3019
3112
  case 19:
3020
3113
  this.logInfo('checkRemoteOrderProductMembership 完成', {
3021
3114
  orderId: normalizedOrderId,
3022
3115
  duration: "".concat(Date.now() - startTime, "ms")
3023
3116
  });
3024
- _context36.next = 26;
3117
+ _context37.next = 26;
3025
3118
  break;
3026
3119
  case 22:
3027
- _context36.prev = 22;
3028
- _context36.t0 = _context36["catch"](10);
3120
+ _context37.prev = 22;
3121
+ _context37.t0 = _context37["catch"](10);
3029
3122
  this.logError('checkRemoteOrderProductMembership 失败', {
3030
3123
  orderId: normalizedOrderId,
3031
3124
  duration: "".concat(Date.now() - startTime, "ms"),
3032
- error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
3125
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3033
3126
  });
3034
- throw _context36.t0;
3127
+ throw _context37.t0;
3035
3128
  case 26:
3036
3129
  case "end":
3037
- return _context36.stop();
3130
+ return _context37.stop();
3038
3131
  }
3039
- }, _callee36, this, [[10, 22]]);
3132
+ }, _callee37, this, [[10, 22]]);
3040
3133
  }));
3041
- function checkRemoteOrderProductMembership(_x36) {
3134
+ function checkRemoteOrderProductMembership(_x37) {
3042
3135
  return _checkRemoteOrderProductMembership.apply(this, arguments);
3043
3136
  }
3044
3137
  return checkRemoteOrderProductMembership;
@@ -3051,10 +3144,10 @@ var Server = /*#__PURE__*/function () {
3051
3144
  }, {
3052
3145
  key: "clearAllIndexDB",
3053
3146
  value: (function () {
3054
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3147
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3055
3148
  var clearTasks, moduleNames, errorMessage;
3056
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3057
- while (1) switch (_context37.prev = _context37.next) {
3149
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3150
+ while (1) switch (_context38.prev = _context38.next) {
3058
3151
  case 0:
3059
3152
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
3060
3153
  clearTasks = [];
@@ -3088,40 +3181,40 @@ var Server = /*#__PURE__*/function () {
3088
3181
  moduleNames.push('FloorPlan');
3089
3182
  }
3090
3183
  if (!(clearTasks.length === 0)) {
3091
- _context37.next = 14;
3184
+ _context38.next = 14;
3092
3185
  break;
3093
3186
  }
3094
3187
  console.warn('[Server] 没有找到已注册的模块,无需清空');
3095
3188
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
3096
- return _context37.abrupt("return");
3189
+ return _context38.abrupt("return");
3097
3190
  case 14:
3098
3191
  this.logInfo('准备清空模块缓存', {
3099
3192
  moduleNames: moduleNames
3100
3193
  });
3101
- _context37.prev = 15;
3102
- _context37.next = 18;
3194
+ _context38.prev = 15;
3195
+ _context38.next = 18;
3103
3196
  return Promise.all(clearTasks);
3104
3197
  case 18:
3105
3198
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
3106
3199
  moduleNames: moduleNames
3107
3200
  });
3108
- _context37.next = 27;
3201
+ _context38.next = 27;
3109
3202
  break;
3110
3203
  case 21:
3111
- _context37.prev = 21;
3112
- _context37.t0 = _context37["catch"](15);
3113
- errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3114
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context37.t0);
3204
+ _context38.prev = 21;
3205
+ _context38.t0 = _context38["catch"](15);
3206
+ errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3207
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context38.t0);
3115
3208
  this.logError('清空 IndexedDB 缓存时发生错误', {
3116
3209
  moduleNames: moduleNames,
3117
3210
  error: errorMessage
3118
3211
  });
3119
- throw _context37.t0;
3212
+ throw _context38.t0;
3120
3213
  case 27:
3121
3214
  case "end":
3122
- return _context37.stop();
3215
+ return _context38.stop();
3123
3216
  }
3124
- }, _callee37, this, [[15, 21]]);
3217
+ }, _callee38, this, [[15, 21]]);
3125
3218
  }));
3126
3219
  function clearAllIndexDB() {
3127
3220
  return _clearAllIndexDB.apply(this, arguments);
@@ -3196,10 +3289,10 @@ var Server = /*#__PURE__*/function () {
3196
3289
  }, {
3197
3290
  key: "handleRoute",
3198
3291
  value: (function () {
3199
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(method, path, params) {
3292
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(method, path, params) {
3200
3293
  var startTime, handler, result, duration, _duration4, errorMessage;
3201
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3202
- while (1) switch (_context38.prev = _context38.next) {
3294
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3295
+ while (1) switch (_context39.prev = _context39.next) {
3203
3296
  case 0:
3204
3297
  startTime = Date.now();
3205
3298
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3210,7 +3303,7 @@ var Server = /*#__PURE__*/function () {
3210
3303
  });
3211
3304
  handler = this.getRouteHandler(method, path);
3212
3305
  if (handler) {
3213
- _context38.next = 6;
3306
+ _context39.next = 6;
3214
3307
  break;
3215
3308
  }
3216
3309
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3219,13 +3312,13 @@ var Server = /*#__PURE__*/function () {
3219
3312
  });
3220
3313
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
3221
3314
  case 6:
3222
- _context38.prev = 6;
3223
- _context38.next = 9;
3315
+ _context39.prev = 6;
3316
+ _context39.next = 9;
3224
3317
  return handler(_objectSpread(_objectSpread({}, params), {}, {
3225
3318
  path: path
3226
3319
  }));
3227
3320
  case 9:
3228
- result = _context38.sent;
3321
+ result = _context39.sent;
3229
3322
  duration = Date.now() - startTime;
3230
3323
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
3231
3324
  method: method.toUpperCase(),
@@ -3234,12 +3327,12 @@ var Server = /*#__PURE__*/function () {
3234
3327
  resultCode: result === null || result === void 0 ? void 0 : result.code,
3235
3328
  resultStatus: result === null || result === void 0 ? void 0 : result.status
3236
3329
  });
3237
- return _context38.abrupt("return", result);
3330
+ return _context39.abrupt("return", result);
3238
3331
  case 15:
3239
- _context38.prev = 15;
3240
- _context38.t0 = _context38["catch"](6);
3332
+ _context39.prev = 15;
3333
+ _context39.t0 = _context39["catch"](6);
3241
3334
  _duration4 = Date.now() - startTime;
3242
- errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3335
+ errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3243
3336
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
3244
3337
  method: method.toUpperCase(),
3245
3338
  path: path,
@@ -3247,15 +3340,15 @@ var Server = /*#__PURE__*/function () {
3247
3340
  error: errorMessage,
3248
3341
  data: params.data
3249
3342
  });
3250
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context38.t0);
3251
- throw _context38.t0;
3343
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context39.t0);
3344
+ throw _context39.t0;
3252
3345
  case 22:
3253
3346
  case "end":
3254
- return _context38.stop();
3347
+ return _context39.stop();
3255
3348
  }
3256
- }, _callee38, this, [[6, 15]]);
3349
+ }, _callee39, this, [[6, 15]]);
3257
3350
  }));
3258
- function handleRoute(_x37, _x38, _x39) {
3351
+ function handleRoute(_x38, _x39, _x40) {
3259
3352
  return _handleRoute.apply(this, arguments);
3260
3353
  }
3261
3354
  return handleRoute;
@@ -3267,10 +3360,10 @@ var Server = /*#__PURE__*/function () {
3267
3360
  }, {
3268
3361
  key: "getAllRoutes",
3269
3362
  value: function getAllRoutes() {
3270
- var _this6 = this;
3363
+ var _this7 = this;
3271
3364
  var routes = [];
3272
3365
  ['get', 'post', 'put', 'remove'].forEach(function (method) {
3273
- Object.keys(_this6.router[method]).forEach(function (path) {
3366
+ Object.keys(_this7.router[method]).forEach(function (path) {
3274
3367
  routes.push({
3275
3368
  method: method,
3276
3369
  path: path
@@ -3398,58 +3491,58 @@ var Server = /*#__PURE__*/function () {
3398
3491
  }, {
3399
3492
  key: "getPaymentRouteModule",
3400
3493
  value: function () {
3401
- var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3402
- var _this7 = this;
3403
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3404
- while (1) switch (_context40.prev = _context40.next) {
3494
+ var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3495
+ var _this8 = this;
3496
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3497
+ while (1) switch (_context41.prev = _context41.next) {
3405
3498
  case 0:
3406
3499
  if (!this.payment) {
3407
- _context40.next = 2;
3500
+ _context41.next = 2;
3408
3501
  break;
3409
3502
  }
3410
- return _context40.abrupt("return", this.payment);
3503
+ return _context41.abrupt("return", this.payment);
3411
3504
  case 2:
3412
3505
  if (!this.paymentRouteModule) {
3413
- _context40.next = 4;
3506
+ _context41.next = 4;
3414
3507
  break;
3415
3508
  }
3416
- return _context40.abrupt("return", this.paymentRouteModule);
3509
+ return _context41.abrupt("return", this.paymentRouteModule);
3417
3510
  case 4:
3418
3511
  if (!this.paymentRouteModuleInFlight) {
3419
- _context40.next = 6;
3512
+ _context41.next = 6;
3420
3513
  break;
3421
3514
  }
3422
- return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3515
+ return _context41.abrupt("return", this.paymentRouteModuleInFlight);
3423
3516
  case 6:
3424
- this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3517
+ this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3425
3518
  var module;
3426
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3427
- while (1) switch (_context39.prev = _context39.next) {
3519
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3520
+ while (1) switch (_context40.prev = _context40.next) {
3428
3521
  case 0:
3429
3522
  module = new PaymentServerModule('server_payment_route', '1.0.0');
3430
- _context39.next = 3;
3431
- return module.initialize(_this7.core, {
3523
+ _context40.next = 3;
3524
+ return module.initialize(_this8.core, {
3432
3525
  store: {
3433
3526
  payMethods: []
3434
3527
  }
3435
3528
  });
3436
3529
  case 3:
3437
- _this7.paymentRouteModule = module;
3438
- return _context39.abrupt("return", module);
3530
+ _this8.paymentRouteModule = module;
3531
+ return _context40.abrupt("return", module);
3439
3532
  case 5:
3440
3533
  case "end":
3441
- return _context39.stop();
3534
+ return _context40.stop();
3442
3535
  }
3443
- }, _callee39);
3536
+ }, _callee40);
3444
3537
  }))().finally(function () {
3445
- _this7.paymentRouteModuleInFlight = undefined;
3538
+ _this8.paymentRouteModuleInFlight = undefined;
3446
3539
  });
3447
- return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3540
+ return _context41.abrupt("return", this.paymentRouteModuleInFlight);
3448
3541
  case 8:
3449
3542
  case "end":
3450
- return _context40.stop();
3543
+ return _context41.stop();
3451
3544
  }
3452
- }, _callee40, this);
3545
+ }, _callee41, this);
3453
3546
  }));
3454
3547
  function getPaymentRouteModule() {
3455
3548
  return _getPaymentRouteModule.apply(this, arguments);
@@ -3459,19 +3552,19 @@ var Server = /*#__PURE__*/function () {
3459
3552
  }, {
3460
3553
  key: "fetchQuotationAvailableFromAPI",
3461
3554
  value: function () {
3462
- var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
3555
+ var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
3463
3556
  var _this$app7;
3464
3557
  var requester;
3465
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3466
- while (1) switch (_context41.prev = _context41.next) {
3558
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3559
+ while (1) switch (_context42.prev = _context42.next) {
3467
3560
  case 0:
3468
3561
  requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
3469
3562
  if (requester !== null && requester !== void 0 && requester.get) {
3470
- _context41.next = 4;
3563
+ _context42.next = 4;
3471
3564
  break;
3472
3565
  }
3473
3566
  this.logError('fetchQuotationAvailableFromAPI: request 不可用');
3474
- return _context41.abrupt("return", {
3567
+ return _context42.abrupt("return", {
3475
3568
  code: 500,
3476
3569
  message: 'request 不可用',
3477
3570
  data: {
@@ -3480,14 +3573,14 @@ var Server = /*#__PURE__*/function () {
3480
3573
  status: false
3481
3574
  });
3482
3575
  case 4:
3483
- return _context41.abrupt("return", requester.get('/shop/quotation/available', data));
3576
+ return _context42.abrupt("return", requester.get('/shop/quotation/available', data));
3484
3577
  case 5:
3485
3578
  case "end":
3486
- return _context41.stop();
3579
+ return _context42.stop();
3487
3580
  }
3488
- }, _callee41, this);
3581
+ }, _callee42, this);
3489
3582
  }));
3490
- function fetchQuotationAvailableFromAPI(_x40) {
3583
+ function fetchQuotationAvailableFromAPI(_x41) {
3491
3584
  return _fetchQuotationAvailableFromAPI.apply(this, arguments);
3492
3585
  }
3493
3586
  return fetchQuotationAvailableFromAPI;
@@ -3618,7 +3711,7 @@ var Server = /*#__PURE__*/function () {
3618
3711
  }, {
3619
3712
  key: "scheduleSubscriberTimePointReloads",
3620
3713
  value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3621
- var _this8 = this;
3714
+ var _this9 = this;
3622
3715
  var subscriber = this.productQuerySubscribers.get(subscriberId);
3623
3716
  if (!subscriber || !timePoints.length) return;
3624
3717
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
@@ -3639,7 +3732,7 @@ var Server = /*#__PURE__*/function () {
3639
3732
  setInterval(function () {
3640
3733
  var currentTime = dayjs().format('HH:mm');
3641
3734
  if (timePoints.includes(currentTime)) {
3642
- _this8.onScheduleTimePointTimerFire(subscriberId);
3735
+ _this9.onScheduleTimePointTimerFire(subscriberId);
3643
3736
  }
3644
3737
  }, 60000);
3645
3738
  if (timerIds.length > 0) {
@@ -3659,29 +3752,29 @@ var Server = /*#__PURE__*/function () {
3659
3752
  }, {
3660
3753
  key: "onScheduleTimePointTimerFire",
3661
3754
  value: (function () {
3662
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId, timerId) {
3755
+ var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId, timerId) {
3663
3756
  var subscriber;
3664
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3665
- while (1) switch (_context42.prev = _context42.next) {
3757
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3758
+ while (1) switch (_context43.prev = _context43.next) {
3666
3759
  case 0:
3667
3760
  timerId && this.removeScheduleTimerRef(subscriberId, timerId);
3668
3761
  if (this.productQuerySubscribers.has(subscriberId)) {
3669
- _context42.next = 3;
3762
+ _context43.next = 3;
3670
3763
  break;
3671
3764
  }
3672
- return _context42.abrupt("return");
3765
+ return _context43.abrupt("return");
3673
3766
  case 3:
3674
3767
  subscriber = this.productQuerySubscribers.get(subscriberId);
3675
3768
  this.refreshSubscriberScheduleAtExecution(subscriber);
3676
- _context42.next = 7;
3769
+ _context43.next = 7;
3677
3770
  return this.recomputeAndNotifySubscriber(subscriberId);
3678
3771
  case 7:
3679
3772
  case "end":
3680
- return _context42.stop();
3773
+ return _context43.stop();
3681
3774
  }
3682
- }, _callee42, this);
3775
+ }, _callee43, this);
3683
3776
  }));
3684
- function onScheduleTimePointTimerFire(_x41, _x42) {
3777
+ function onScheduleTimePointTimerFire(_x42, _x43) {
3685
3778
  return _onScheduleTimePointTimerFire.apply(this, arguments);
3686
3779
  }
3687
3780
  return onScheduleTimePointTimerFire;
@@ -3693,45 +3786,45 @@ var Server = /*#__PURE__*/function () {
3693
3786
  }, {
3694
3787
  key: "recomputeAndNotifySubscriber",
3695
3788
  value: (function () {
3696
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId) {
3789
+ var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(subscriberId) {
3697
3790
  var subscriber, result, errorMessage;
3698
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3699
- while (1) switch (_context43.prev = _context43.next) {
3791
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3792
+ while (1) switch (_context44.prev = _context44.next) {
3700
3793
  case 0:
3701
3794
  subscriber = this.productQuerySubscribers.get(subscriberId);
3702
3795
  if (subscriber) {
3703
- _context43.next = 3;
3796
+ _context44.next = 3;
3704
3797
  break;
3705
3798
  }
3706
- return _context43.abrupt("return");
3799
+ return _context44.abrupt("return");
3707
3800
  case 3:
3708
- _context43.prev = 3;
3709
- _context43.next = 6;
3801
+ _context44.prev = 3;
3802
+ _context44.next = 6;
3710
3803
  return this.computeProductQueryResult(subscriber.context);
3711
3804
  case 6:
3712
- result = _context43.sent;
3805
+ result = _context44.sent;
3713
3806
  subscriber.callback(result);
3714
3807
  this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3715
3808
  subscriberId: subscriberId,
3716
3809
  schedule_datetime: subscriber.context.schedule_datetime
3717
3810
  });
3718
- _context43.next = 15;
3811
+ _context44.next = 15;
3719
3812
  break;
3720
3813
  case 11:
3721
- _context43.prev = 11;
3722
- _context43.t0 = _context43["catch"](3);
3723
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3814
+ _context44.prev = 11;
3815
+ _context44.t0 = _context44["catch"](3);
3816
+ errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
3724
3817
  this.logError('recomputeAndNotifySubscriber: 推送失败', {
3725
3818
  subscriberId: subscriberId,
3726
3819
  error: errorMessage
3727
3820
  });
3728
3821
  case 15:
3729
3822
  case "end":
3730
- return _context43.stop();
3823
+ return _context44.stop();
3731
3824
  }
3732
- }, _callee43, this, [[3, 11]]);
3825
+ }, _callee44, this, [[3, 11]]);
3733
3826
  }));
3734
- function recomputeAndNotifySubscriber(_x43) {
3827
+ function recomputeAndNotifySubscriber(_x44) {
3735
3828
  return _recomputeAndNotifySubscriber.apply(this, arguments);
3736
3829
  }
3737
3830
  return recomputeAndNotifySubscriber;
@@ -3807,46 +3900,46 @@ var Server = /*#__PURE__*/function () {
3807
3900
  }, {
3808
3901
  key: "refreshMenuScheduleCacheAfterEmptyResult",
3809
3902
  value: (function () {
3810
- var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3811
- var _this9 = this;
3903
+ var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3904
+ var _this10 = this;
3812
3905
  var now;
3813
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3814
- while (1) switch (_context44.prev = _context44.next) {
3906
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3907
+ while (1) switch (_context45.prev = _context45.next) {
3815
3908
  case 0:
3816
3909
  if (!(!this.menu || !this.schedule)) {
3817
- _context44.next = 2;
3910
+ _context45.next = 2;
3818
3911
  break;
3819
3912
  }
3820
- return _context44.abrupt("return", false);
3913
+ return _context45.abrupt("return", false);
3821
3914
  case 2:
3822
3915
  now = Date.now();
3823
3916
  if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
3824
- _context44.next = 5;
3917
+ _context45.next = 5;
3825
3918
  break;
3826
3919
  }
3827
- return _context44.abrupt("return", false);
3920
+ return _context45.abrupt("return", false);
3828
3921
  case 5:
3829
3922
  if (!this.menuScheduleRefreshInFlight) {
3830
3923
  this.lastMenuScheduleRefreshAt = now;
3831
3924
  this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
3832
3925
  return undefined;
3833
3926
  }).catch(function (error) {
3834
- _this9.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3927
+ _this10.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3835
3928
  error: error instanceof Error ? error.message : String(error)
3836
3929
  });
3837
3930
  }).finally(function () {
3838
- _this9.menuScheduleRefreshInFlight = null;
3931
+ _this10.menuScheduleRefreshInFlight = null;
3839
3932
  });
3840
3933
  }
3841
- _context44.next = 8;
3934
+ _context45.next = 8;
3842
3935
  return this.menuScheduleRefreshInFlight;
3843
3936
  case 8:
3844
- return _context44.abrupt("return", true);
3937
+ return _context45.abrupt("return", true);
3845
3938
  case 9:
3846
3939
  case "end":
3847
- return _context44.stop();
3940
+ return _context45.stop();
3848
3941
  }
3849
- }, _callee44, this);
3942
+ }, _callee45, this);
3850
3943
  }));
3851
3944
  function refreshMenuScheduleCacheAfterEmptyResult() {
3852
3945
  return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
@@ -3864,16 +3957,16 @@ var Server = /*#__PURE__*/function () {
3864
3957
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3865
3958
  */
3866
3959
  function () {
3867
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3960
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(kind, backendPath, data, config) {
3868
3961
  var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3869
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3870
- while (1) switch (_context45.prev = _context45.next) {
3962
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3963
+ while (1) switch (_context46.prev = _context46.next) {
3871
3964
  case 0:
3872
3965
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3873
- _context45.next = 3;
3966
+ _context46.next = 3;
3874
3967
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3875
3968
  case 3:
3876
- result = _context45.sent;
3969
+ result = _context46.sent;
3877
3970
  _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3878
3971
  if (subscriberId && typeof callback === 'function') {
3879
3972
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
@@ -3905,14 +3998,14 @@ var Server = /*#__PURE__*/function () {
3905
3998
  visibleCount: visibleOrderIds.size
3906
3999
  });
3907
4000
  }
3908
- return _context45.abrupt("return", result);
4001
+ return _context46.abrupt("return", result);
3909
4002
  case 7:
3910
4003
  case "end":
3911
- return _context45.stop();
4004
+ return _context46.stop();
3912
4005
  }
3913
- }, _callee45, this);
4006
+ }, _callee46, this);
3914
4007
  }));
3915
- function handleSalesSearchRequest(_x44, _x45, _x46, _x47) {
4008
+ function handleSalesSearchRequest(_x45, _x46, _x47, _x48) {
3916
4009
  return _handleSalesSearchRequest.apply(this, arguments);
3917
4010
  }
3918
4011
  return handleSalesSearchRequest;
@@ -3927,20 +4020,20 @@ var Server = /*#__PURE__*/function () {
3927
4020
  }, {
3928
4021
  key: "fetchSalesSearchFromAPI",
3929
4022
  value: (function () {
3930
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
4023
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(backendPath, data) {
3931
4024
  var _this$app8;
3932
4025
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3933
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3934
- while (1) switch (_context46.prev = _context46.next) {
4026
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4027
+ while (1) switch (_context47.prev = _context47.next) {
3935
4028
  case 0:
3936
4029
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3937
- _context46.next = 3;
4030
+ _context47.next = 3;
3938
4031
  break;
3939
4032
  }
3940
4033
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3941
4034
  backendPath: backendPath
3942
4035
  });
3943
- return _context46.abrupt("return", {
4036
+ return _context47.abrupt("return", {
3944
4037
  code: 500,
3945
4038
  message: 'app.request 不可用',
3946
4039
  data: backendPath === '/shop/es/search' ? {
@@ -3952,29 +4045,29 @@ var Server = /*#__PURE__*/function () {
3952
4045
  status: false
3953
4046
  });
3954
4047
  case 3:
3955
- _context46.prev = 3;
3956
- _context46.next = 6;
4048
+ _context47.prev = 3;
4049
+ _context47.next = 6;
3957
4050
  return this.app.request.post(backendPath, data, {
3958
4051
  isShopApi: true
3959
4052
  });
3960
4053
  case 6:
3961
- response = _context46.sent;
4054
+ response = _context47.sent;
3962
4055
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3963
- return _context46.abrupt("return", {
4056
+ return _context47.abrupt("return", {
3964
4057
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3965
4058
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3966
4059
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3967
4060
  data: _payload
3968
4061
  });
3969
4062
  case 11:
3970
- _context46.prev = 11;
3971
- _context46.t0 = _context46["catch"](3);
3972
- errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4063
+ _context47.prev = 11;
4064
+ _context47.t0 = _context47["catch"](3);
4065
+ errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
3973
4066
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3974
4067
  backendPath: backendPath,
3975
4068
  error: errorMessage
3976
4069
  });
3977
- return _context46.abrupt("return", {
4070
+ return _context47.abrupt("return", {
3978
4071
  code: 500,
3979
4072
  message: errorMessage,
3980
4073
  data: backendPath === '/shop/es/search' ? {
@@ -3987,11 +4080,11 @@ var Server = /*#__PURE__*/function () {
3987
4080
  });
3988
4081
  case 16:
3989
4082
  case "end":
3990
- return _context46.stop();
4083
+ return _context47.stop();
3991
4084
  }
3992
- }, _callee46, this, [[3, 11]]);
4085
+ }, _callee47, this, [[3, 11]]);
3993
4086
  }));
3994
- function fetchSalesSearchFromAPI(_x48, _x49) {
4087
+ function fetchSalesSearchFromAPI(_x49, _x50) {
3995
4088
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3996
4089
  }
3997
4090
  return fetchSalesSearchFromAPI;
@@ -4021,10 +4114,10 @@ var Server = /*#__PURE__*/function () {
4021
4114
  }, {
4022
4115
  key: "stripSalesSearchPageParams",
4023
4116
  value: function stripSalesSearchPageParams(value) {
4024
- var _this10 = this;
4117
+ var _this11 = this;
4025
4118
  if (Array.isArray(value)) {
4026
4119
  return value.map(function (item) {
4027
- return _this10.stripSalesSearchPageParams(item);
4120
+ return _this11.stripSalesSearchPageParams(item);
4028
4121
  });
4029
4122
  }
4030
4123
  if (!value || _typeof(value) !== 'object') return value;
@@ -4062,12 +4155,12 @@ var Server = /*#__PURE__*/function () {
4062
4155
  key: "extractSalesSearchOrderIds",
4063
4156
  value: function extractSalesSearchOrderIds(kind, result) {
4064
4157
  var _this$findSalesSearch,
4065
- _this11 = this;
4158
+ _this12 = this;
4066
4159
  var data = this.extractSalesSearchResponseData(result);
4067
4160
  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;
4068
4161
  if (!Array.isArray(list)) return [];
4069
4162
  return list.map(function (item) {
4070
- return _this11.getSalesSearchOrderId(item);
4163
+ return _this12.getSalesSearchOrderId(item);
4071
4164
  }).filter(function (id) {
4072
4165
  return !!id;
4073
4166
  });
@@ -4234,11 +4327,11 @@ var Server = /*#__PURE__*/function () {
4234
4327
  }, {
4235
4328
  key: "stableSerialize",
4236
4329
  value: function stableSerialize(value) {
4237
- var _this12 = this;
4330
+ var _this13 = this;
4238
4331
  if (value === null || value === undefined) return 'null';
4239
4332
  if (Array.isArray(value)) {
4240
4333
  return "[".concat(value.map(function (item) {
4241
- return _this12.stableSerialize(item);
4334
+ return _this13.stableSerialize(item);
4242
4335
  }).join(','), "]");
4243
4336
  }
4244
4337
  if (_typeof(value) === 'object') {
@@ -4247,7 +4340,7 @@ var Server = /*#__PURE__*/function () {
4247
4340
  return obj[k] !== undefined;
4248
4341
  }).sort();
4249
4342
  return "{".concat(keys.map(function (k) {
4250
- return "".concat(JSON.stringify(k), ":").concat(_this12.stableSerialize(obj[k]));
4343
+ return "".concat(JSON.stringify(k), ":").concat(_this13.stableSerialize(obj[k]));
4251
4344
  }).join(','), "}");
4252
4345
  }
4253
4346
  return JSON.stringify(value);
@@ -4512,18 +4605,18 @@ var Server = /*#__PURE__*/function () {
4512
4605
  }, {
4513
4606
  key: "fetchOrderListFromAPI",
4514
4607
  value: (function () {
4515
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4608
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
4516
4609
  var _this$app9;
4517
4610
  var _response$data5, response, _payload2, list, count, errorMessage;
4518
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4519
- while (1) switch (_context47.prev = _context47.next) {
4611
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4612
+ while (1) switch (_context48.prev = _context48.next) {
4520
4613
  case 0:
4521
4614
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4522
- _context47.next = 3;
4615
+ _context48.next = 3;
4523
4616
  break;
4524
4617
  }
4525
4618
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4526
- return _context47.abrupt("return", {
4619
+ return _context48.abrupt("return", {
4527
4620
  code: 500,
4528
4621
  message: 'app.request 不可用',
4529
4622
  data: {
@@ -4533,17 +4626,17 @@ var Server = /*#__PURE__*/function () {
4533
4626
  status: false
4534
4627
  });
4535
4628
  case 3:
4536
- _context47.prev = 3;
4537
- _context47.next = 6;
4629
+ _context48.prev = 3;
4630
+ _context48.next = 6;
4538
4631
  return this.app.request.post('/shop/order/v2/list', data, {
4539
4632
  isShopApi: true
4540
4633
  });
4541
4634
  case 6:
4542
- response = _context47.sent;
4635
+ response = _context48.sent;
4543
4636
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4544
4637
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4545
4638
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4546
- return _context47.abrupt("return", {
4639
+ return _context48.abrupt("return", {
4547
4640
  code: 200,
4548
4641
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4549
4642
  list: list,
@@ -4553,13 +4646,13 @@ var Server = /*#__PURE__*/function () {
4553
4646
  status: true
4554
4647
  });
4555
4648
  case 13:
4556
- _context47.prev = 13;
4557
- _context47.t0 = _context47["catch"](3);
4558
- errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4649
+ _context48.prev = 13;
4650
+ _context48.t0 = _context48["catch"](3);
4651
+ errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4559
4652
  this.logError('fetchOrderListFromAPI: 请求失败', {
4560
4653
  error: errorMessage
4561
4654
  });
4562
- return _context47.abrupt("return", {
4655
+ return _context48.abrupt("return", {
4563
4656
  code: 500,
4564
4657
  message: errorMessage,
4565
4658
  data: {
@@ -4570,11 +4663,11 @@ var Server = /*#__PURE__*/function () {
4570
4663
  });
4571
4664
  case 18:
4572
4665
  case "end":
4573
- return _context47.stop();
4666
+ return _context48.stop();
4574
4667
  }
4575
- }, _callee47, this, [[3, 13]]);
4668
+ }, _callee48, this, [[3, 13]]);
4576
4669
  }));
4577
- function fetchOrderListFromAPI(_x50) {
4670
+ function fetchOrderListFromAPI(_x51) {
4578
4671
  return _fetchOrderListFromAPI.apply(this, arguments);
4579
4672
  }
4580
4673
  return fetchOrderListFromAPI;
@@ -4586,17 +4679,17 @@ var Server = /*#__PURE__*/function () {
4586
4679
  }, {
4587
4680
  key: "fetchBookingListFromAPI",
4588
4681
  value: (function () {
4589
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
4682
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(data) {
4590
4683
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4591
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4592
- while (1) switch (_context48.prev = _context48.next) {
4684
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4685
+ while (1) switch (_context49.prev = _context49.next) {
4593
4686
  case 0:
4594
4687
  if (this.order) {
4595
- _context48.next = 3;
4688
+ _context49.next = 3;
4596
4689
  break;
4597
4690
  }
4598
4691
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4599
- return _context48.abrupt("return", {
4692
+ return _context49.abrupt("return", {
4600
4693
  code: 500,
4601
4694
  message: 'Order 模块不可用',
4602
4695
  data: {
@@ -4606,18 +4699,18 @@ var Server = /*#__PURE__*/function () {
4606
4699
  status: false
4607
4700
  });
4608
4701
  case 3:
4609
- _context48.prev = 3;
4702
+ _context49.prev = 3;
4610
4703
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4611
4704
  withFields = this.resolveBookingSalesWith(data);
4612
4705
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4613
4706
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4614
4707
  if (!memoryCacheEnabled) {
4615
- _context48.next = 13;
4708
+ _context49.next = 13;
4616
4709
  break;
4617
4710
  }
4618
4711
  cached = this.readBookingRemoteCache(cacheKey);
4619
4712
  if (!cached) {
4620
- _context48.next = 13;
4713
+ _context49.next = 13;
4621
4714
  break;
4622
4715
  }
4623
4716
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4625,14 +4718,14 @@ var Server = /*#__PURE__*/function () {
4625
4718
  listCount: cached.bookingResult.count,
4626
4719
  withFields: cached.withFields
4627
4720
  });
4628
- return _context48.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4721
+ return _context49.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4629
4722
  cache_hit: true
4630
4723
  }));
4631
4724
  case 13:
4632
- _context48.next = 15;
4725
+ _context49.next = 15;
4633
4726
  return this.order.fetchOrdersBySSE(requestPayload);
4634
4727
  case 15:
4635
- rawList = _context48.sent;
4728
+ rawList = _context49.sent;
4636
4729
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4637
4730
  if (typeof globalThis !== 'undefined') {
4638
4731
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4679,15 +4772,15 @@ var Server = /*#__PURE__*/function () {
4679
4772
  cacheKey: cacheKey,
4680
4773
  withFields: withFields
4681
4774
  });
4682
- return _context48.abrupt("return", this.buildBookingResponse(bookingResult));
4775
+ return _context49.abrupt("return", this.buildBookingResponse(bookingResult));
4683
4776
  case 23:
4684
- _context48.prev = 23;
4685
- _context48.t0 = _context48["catch"](3);
4686
- errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4777
+ _context49.prev = 23;
4778
+ _context49.t0 = _context49["catch"](3);
4779
+ errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0);
4687
4780
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4688
4781
  error: errorMessage
4689
4782
  });
4690
- return _context48.abrupt("return", {
4783
+ return _context49.abrupt("return", {
4691
4784
  code: 500,
4692
4785
  message: errorMessage,
4693
4786
  data: {
@@ -4698,11 +4791,11 @@ var Server = /*#__PURE__*/function () {
4698
4791
  });
4699
4792
  case 28:
4700
4793
  case "end":
4701
- return _context48.stop();
4794
+ return _context49.stop();
4702
4795
  }
4703
- }, _callee48, this, [[3, 23]]);
4796
+ }, _callee49, this, [[3, 23]]);
4704
4797
  }));
4705
- function fetchBookingListFromAPI(_x51) {
4798
+ function fetchBookingListFromAPI(_x52) {
4706
4799
  return _fetchBookingListFromAPI.apply(this, arguments);
4707
4800
  }
4708
4801
  return fetchBookingListFromAPI;
@@ -4786,11 +4879,11 @@ var Server = /*#__PURE__*/function () {
4786
4879
  }, {
4787
4880
  key: "runLocalPaymentUpdateInQueue",
4788
4881
  value: function () {
4789
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
4790
- var _this13 = this;
4882
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(key, task, context) {
4883
+ var _this14 = this;
4791
4884
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4792
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4793
- while (1) switch (_context50.prev = _context50.next) {
4885
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4886
+ while (1) switch (_context51.prev = _context51.next) {
4794
4887
  case 0:
4795
4888
  queuedAt = Date.now();
4796
4889
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -4802,20 +4895,20 @@ var Server = /*#__PURE__*/function () {
4802
4895
  }));
4803
4896
  current = previous.catch(function () {
4804
4897
  return undefined;
4805
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4806
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4807
- while (1) switch (_context49.prev = _context49.next) {
4898
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4899
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4900
+ while (1) switch (_context50.prev = _context50.next) {
4808
4901
  case 0:
4809
- _this13.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4902
+ _this14.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4810
4903
  queue_key: key,
4811
4904
  queue_wait_ms: Date.now() - queuedAt
4812
4905
  }));
4813
- return _context49.abrupt("return", task());
4906
+ return _context50.abrupt("return", task());
4814
4907
  case 2:
4815
4908
  case "end":
4816
- return _context49.stop();
4909
+ return _context50.stop();
4817
4910
  }
4818
- }, _callee49);
4911
+ }, _callee50);
4819
4912
  })));
4820
4913
  tail = current.then(function () {
4821
4914
  return undefined;
@@ -4823,11 +4916,11 @@ var Server = /*#__PURE__*/function () {
4823
4916
  return undefined;
4824
4917
  });
4825
4918
  this.localPaymentUpdateQueues.set(key, tail);
4826
- _context50.prev = 7;
4827
- _context50.next = 10;
4919
+ _context51.prev = 7;
4920
+ _context51.next = 10;
4828
4921
  return current;
4829
4922
  case 10:
4830
- result = _context50.sent;
4923
+ result = _context51.sent;
4831
4924
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
4832
4925
  queue_key: key,
4833
4926
  total_duration_ms: Date.now() - queuedAt,
@@ -4835,19 +4928,19 @@ var Server = /*#__PURE__*/function () {
4835
4928
  result_status: result === null || result === void 0 ? void 0 : result.status,
4836
4929
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
4837
4930
  }));
4838
- return _context50.abrupt("return", result);
4931
+ return _context51.abrupt("return", result);
4839
4932
  case 15:
4840
- _context50.prev = 15;
4841
- _context50.t0 = _context50["catch"](7);
4933
+ _context51.prev = 15;
4934
+ _context51.t0 = _context51["catch"](7);
4842
4935
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
4843
4936
  queue_key: key,
4844
4937
  total_duration_ms: Date.now() - queuedAt,
4845
- error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
4846
- error_detail: this.normalizeUnknownError(_context50.t0)
4938
+ error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
4939
+ error_detail: this.normalizeUnknownError(_context51.t0)
4847
4940
  }));
4848
- throw _context50.t0;
4941
+ throw _context51.t0;
4849
4942
  case 19:
4850
- _context50.prev = 19;
4943
+ _context51.prev = 19;
4851
4944
  released = false;
4852
4945
  if (this.localPaymentUpdateQueues.get(key) === tail) {
4853
4946
  this.localPaymentUpdateQueues.delete(key);
@@ -4858,14 +4951,14 @@ var Server = /*#__PURE__*/function () {
4858
4951
  released: released,
4859
4952
  active_queue_count: this.localPaymentUpdateQueues.size
4860
4953
  }));
4861
- return _context50.finish(19);
4954
+ return _context51.finish(19);
4862
4955
  case 24:
4863
4956
  case "end":
4864
- return _context50.stop();
4957
+ return _context51.stop();
4865
4958
  }
4866
- }, _callee50, this, [[7, 15, 19, 24]]);
4959
+ }, _callee51, this, [[7, 15, 19, 24]]);
4867
4960
  }));
4868
- function runLocalPaymentUpdateInQueue(_x52, _x53, _x54) {
4961
+ function runLocalPaymentUpdateInQueue(_x53, _x54, _x55) {
4869
4962
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
4870
4963
  }
4871
4964
  return runLocalPaymentUpdateInQueue;
@@ -4873,11 +4966,11 @@ var Server = /*#__PURE__*/function () {
4873
4966
  }, {
4874
4967
  key: "processLocalPaymentUpdate",
4875
4968
  value: function () {
4876
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4969
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4877
4970
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
4878
4971
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
4879
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4880
- while (1) switch (_context51.prev = _context51.next) {
4972
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4973
+ while (1) switch (_context52.prev = _context52.next) {
4881
4974
  case 0:
4882
4975
  requestContext = {
4883
4976
  operation_id: params.operationId,
@@ -4890,11 +4983,11 @@ var Server = /*#__PURE__*/function () {
4890
4983
  };
4891
4984
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
4892
4985
  if (this.order) {
4893
- _context51.next = 5;
4986
+ _context52.next = 5;
4894
4987
  break;
4895
4988
  }
4896
4989
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
4897
- return _context51.abrupt("return", {
4990
+ return _context52.abrupt("return", {
4898
4991
  code: 500,
4899
4992
  status: false,
4900
4993
  message: 'Order 模块未注册',
@@ -4902,20 +4995,20 @@ var Server = /*#__PURE__*/function () {
4902
4995
  });
4903
4996
  case 5:
4904
4997
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
4905
- _context51.next = 8;
4998
+ _context52.next = 8;
4906
4999
  return this.order.getLocalPayment({
4907
5000
  saleId: params.saleId,
4908
5001
  paymentNumber: params.paymentNumber,
4909
5002
  operationId: params.operationId
4910
5003
  });
4911
5004
  case 8:
4912
- found = _context51.sent;
5005
+ found = _context52.sent;
4913
5006
  if (found) {
4914
- _context51.next = 12;
5007
+ _context52.next = 12;
4915
5008
  break;
4916
5009
  }
4917
5010
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
4918
- return _context51.abrupt("return", {
5011
+ return _context52.abrupt("return", {
4919
5012
  code: 404,
4920
5013
  status: false,
4921
5014
  message: '本地支付项不存在',
@@ -4964,13 +5057,13 @@ var Server = /*#__PURE__*/function () {
4964
5057
  });
4965
5058
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
4966
5059
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
4967
- _context51.next = 23;
5060
+ _context52.next = 23;
4968
5061
  break;
4969
5062
  }
4970
5063
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4971
5064
  idempotent_reason: 'ignore_failure_after_success'
4972
5065
  }));
4973
- return _context51.abrupt("return", {
5066
+ return _context52.abrupt("return", {
4974
5067
  code: 200,
4975
5068
  status: true,
4976
5069
  message: '',
@@ -4983,13 +5076,13 @@ var Server = /*#__PURE__*/function () {
4983
5076
  case 23:
4984
5077
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
4985
5078
  if (!alreadyRecordedFailure) {
4986
- _context51.next = 27;
5079
+ _context52.next = 27;
4987
5080
  break;
4988
5081
  }
4989
5082
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4990
5083
  idempotent_reason: 'failure_already_recorded'
4991
5084
  }));
4992
- return _context51.abrupt("return", {
5085
+ return _context52.abrupt("return", {
4993
5086
  code: 200,
4994
5087
  status: true,
4995
5088
  message: '',
@@ -5001,13 +5094,13 @@ var Server = /*#__PURE__*/function () {
5001
5094
  });
5002
5095
  case 27:
5003
5096
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
5004
- _context51.next = 30;
5097
+ _context52.next = 30;
5005
5098
  break;
5006
5099
  }
5007
5100
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
5008
5101
  idempotent_reason: 'success_already_committed'
5009
5102
  }));
5010
- return _context51.abrupt("return", {
5103
+ return _context52.abrupt("return", {
5011
5104
  code: 200,
5012
5105
  status: true,
5013
5106
  message: '',
@@ -5019,13 +5112,13 @@ var Server = /*#__PURE__*/function () {
5019
5112
  });
5020
5113
  case 30:
5021
5114
  if (!(params.status === 'success')) {
5022
- _context51.next = 33;
5115
+ _context52.next = 33;
5023
5116
  break;
5024
5117
  }
5025
5118
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
5026
5119
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
5027
5120
  }));
5028
- return _context51.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5121
+ return _context52.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5029
5122
  order: found.order,
5030
5123
  payment: found.payment,
5031
5124
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -5036,8 +5129,8 @@ var Server = /*#__PURE__*/function () {
5036
5129
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
5037
5130
  incoming_payment_update: incomingPaymentUpdate
5038
5131
  }));
5039
- _context51.prev = 34;
5040
- _context51.next = 37;
5132
+ _context52.prev = 34;
5133
+ _context52.next = 37;
5041
5134
  return this.order.updateLocalPayment({
5042
5135
  saleId: params.saleId,
5043
5136
  paymentNumber: params.paymentNumber,
@@ -5045,25 +5138,25 @@ var Server = /*#__PURE__*/function () {
5045
5138
  updates: incomingPaymentUpdate
5046
5139
  });
5047
5140
  case 37:
5048
- updated = _context51.sent;
5049
- _context51.next = 44;
5141
+ updated = _context52.sent;
5142
+ _context52.next = 44;
5050
5143
  break;
5051
5144
  case 40:
5052
- _context51.prev = 40;
5053
- _context51.t0 = _context51["catch"](34);
5145
+ _context52.prev = 40;
5146
+ _context52.t0 = _context52["catch"](34);
5054
5147
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
5055
5148
  incoming_payment_update: incomingPaymentUpdate,
5056
- error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
5057
- error_detail: this.normalizeUnknownError(_context51.t0)
5149
+ error: _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0),
5150
+ error_detail: this.normalizeUnknownError(_context52.t0)
5058
5151
  }));
5059
- throw _context51.t0;
5152
+ throw _context52.t0;
5060
5153
  case 44:
5061
5154
  if (updated) {
5062
- _context51.next = 47;
5155
+ _context52.next = 47;
5063
5156
  break;
5064
5157
  }
5065
5158
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
5066
- return _context51.abrupt("return", {
5159
+ return _context52.abrupt("return", {
5067
5160
  code: 404,
5068
5161
  status: false,
5069
5162
  message: '本地支付项不存在',
@@ -5074,7 +5167,7 @@ var Server = /*#__PURE__*/function () {
5074
5167
  previous_payment: updated.previousPayment,
5075
5168
  payment: updated.payment
5076
5169
  }));
5077
- return _context51.abrupt("return", {
5170
+ return _context52.abrupt("return", {
5078
5171
  code: 200,
5079
5172
  status: true,
5080
5173
  message: '',
@@ -5086,11 +5179,11 @@ var Server = /*#__PURE__*/function () {
5086
5179
  });
5087
5180
  case 49:
5088
5181
  case "end":
5089
- return _context51.stop();
5182
+ return _context52.stop();
5090
5183
  }
5091
- }, _callee51, this, [[34, 40]]);
5184
+ }, _callee52, this, [[34, 40]]);
5092
5185
  }));
5093
- function processLocalPaymentUpdate(_x55) {
5186
+ function processLocalPaymentUpdate(_x56) {
5094
5187
  return _processLocalPaymentUpdate.apply(this, arguments);
5095
5188
  }
5096
5189
  return processLocalPaymentUpdate;
@@ -5098,10 +5191,10 @@ var Server = /*#__PURE__*/function () {
5098
5191
  }, {
5099
5192
  key: "processSuccessfulLocalPayment",
5100
5193
  value: function () {
5101
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5194
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5102
5195
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
5103
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5104
- while (1) switch (_context52.prev = _context52.next) {
5196
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5197
+ while (1) switch (_context53.prev = _context53.next) {
5105
5198
  case 0:
5106
5199
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
5107
5200
  baseSales = new BaseSalesImpl(moduleName);
@@ -5120,13 +5213,13 @@ var Server = /*#__PURE__*/function () {
5120
5213
  payment: params.payment
5121
5214
  });
5122
5215
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
5123
- _context52.prev = 5;
5216
+ _context53.prev = 5;
5124
5217
  order = this.sanitizeLocalRecoveryOrder(params.order);
5125
5218
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5126
5219
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
5127
5220
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
5128
5221
  }));
5129
- _context52.next = 10;
5222
+ _context53.next = 10;
5130
5223
  return baseSales.initialize(this.core, {
5131
5224
  otherParams: {
5132
5225
  platform: order.platform,
@@ -5139,14 +5232,14 @@ var Server = /*#__PURE__*/function () {
5139
5232
  });
5140
5233
  case 10:
5141
5234
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
5142
- _context52.next = 13;
5235
+ _context53.next = 13;
5143
5236
  return baseSales.replaceTempOrder(order);
5144
5237
  case 13:
5145
5238
  this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
5146
5239
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5147
5240
  incoming_payment_update: params.paymentUpdate
5148
5241
  }));
5149
- _context52.next = 17;
5242
+ _context53.next = 17;
5150
5243
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
5151
5244
  submitWhenPaid: true,
5152
5245
  matchBy: params.matchBy,
@@ -5155,7 +5248,7 @@ var Server = /*#__PURE__*/function () {
5155
5248
  smallTicketDataFlag: 1
5156
5249
  });
5157
5250
  case 17:
5158
- result = _context52.sent;
5251
+ result = _context53.sent;
5159
5252
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5160
5253
  duration_ms: Date.now() - startedAt,
5161
5254
  payment: result.payment,
@@ -5177,7 +5270,7 @@ var Server = /*#__PURE__*/function () {
5177
5270
  } : null,
5178
5271
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
5179
5272
  }));
5180
- return _context52.abrupt("return", {
5273
+ return _context53.abrupt("return", {
5181
5274
  code: 200,
5182
5275
  status: true,
5183
5276
  message: '',
@@ -5189,48 +5282,48 @@ var Server = /*#__PURE__*/function () {
5189
5282
  }
5190
5283
  });
5191
5284
  case 22:
5192
- _context52.prev = 22;
5193
- _context52.t0 = _context52["catch"](5);
5194
- message = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
5285
+ _context53.prev = 22;
5286
+ _context53.t0 = _context53["catch"](5);
5287
+ message = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5195
5288
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5196
5289
  duration_ms: Date.now() - startedAt,
5197
5290
  error: message,
5198
- error_detail: this.normalizeUnknownError(_context52.t0)
5291
+ error_detail: this.normalizeUnknownError(_context53.t0)
5199
5292
  }));
5200
- return _context52.abrupt("return", {
5293
+ return _context53.abrupt("return", {
5201
5294
  code: 500,
5202
5295
  status: false,
5203
5296
  message: message,
5204
5297
  data: null
5205
5298
  });
5206
5299
  case 27:
5207
- _context52.prev = 27;
5208
- _context52.prev = 28;
5209
- _context52.next = 31;
5300
+ _context53.prev = 27;
5301
+ _context53.prev = 28;
5302
+ _context53.next = 31;
5210
5303
  return baseSales.destroy();
5211
5304
  case 31:
5212
5305
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5213
5306
  duration_ms: Date.now() - startedAt
5214
5307
  }));
5215
- _context52.next = 37;
5308
+ _context53.next = 37;
5216
5309
  break;
5217
5310
  case 34:
5218
- _context52.prev = 34;
5219
- _context52.t1 = _context52["catch"](28);
5311
+ _context53.prev = 34;
5312
+ _context53.t1 = _context53["catch"](28);
5220
5313
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5221
5314
  duration_ms: Date.now() - startedAt,
5222
- error: _context52.t1 instanceof Error ? _context52.t1.message : String(_context52.t1),
5223
- error_detail: this.normalizeUnknownError(_context52.t1)
5315
+ error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1),
5316
+ error_detail: this.normalizeUnknownError(_context53.t1)
5224
5317
  }));
5225
5318
  case 37:
5226
- return _context52.finish(27);
5319
+ return _context53.finish(27);
5227
5320
  case 38:
5228
5321
  case "end":
5229
- return _context52.stop();
5322
+ return _context53.stop();
5230
5323
  }
5231
- }, _callee52, this, [[5, 22, 27, 38], [28, 34]]);
5324
+ }, _callee53, this, [[5, 22, 27, 38], [28, 34]]);
5232
5325
  }));
5233
- function processSuccessfulLocalPayment(_x56) {
5326
+ function processSuccessfulLocalPayment(_x57) {
5234
5327
  return _processSuccessfulLocalPayment.apply(this, arguments);
5235
5328
  }
5236
5329
  return processSuccessfulLocalPayment;
@@ -5321,32 +5414,32 @@ var Server = /*#__PURE__*/function () {
5321
5414
  }, {
5322
5415
  key: "getShortNumberOrDeviceId",
5323
5416
  value: function () {
5324
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5417
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5325
5418
  var getAsyncIotDeviceInfo, res;
5326
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5327
- while (1) switch (_context53.prev = _context53.next) {
5419
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5420
+ while (1) switch (_context54.prev = _context54.next) {
5328
5421
  case 0:
5329
5422
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
5330
5423
  if (!getAsyncIotDeviceInfo) {
5331
- _context53.next = 7;
5424
+ _context54.next = 7;
5332
5425
  break;
5333
5426
  }
5334
- _context53.next = 4;
5427
+ _context54.next = 4;
5335
5428
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
5336
5429
  case 4:
5337
- res = _context53.sent;
5430
+ res = _context54.sent;
5338
5431
  if (!(res !== null && res !== void 0 && res.short_number)) {
5339
- _context53.next = 7;
5432
+ _context54.next = 7;
5340
5433
  break;
5341
5434
  }
5342
- return _context53.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5435
+ return _context54.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5343
5436
  case 7:
5344
- return _context53.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5437
+ return _context54.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5345
5438
  case 8:
5346
5439
  case "end":
5347
- return _context53.stop();
5440
+ return _context54.stop();
5348
5441
  }
5349
- }, _callee53, this);
5442
+ }, _callee54, this);
5350
5443
  }));
5351
5444
  function getShortNumberOrDeviceId() {
5352
5445
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -5406,12 +5499,12 @@ var Server = /*#__PURE__*/function () {
5406
5499
  }, {
5407
5500
  key: "buildCheckoutResourceIdentifierBuzzer",
5408
5501
  value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5409
- var _this14 = this;
5502
+ var _this15 = this;
5410
5503
  if (!Array.isArray(bookings)) return '';
5411
5504
  var values = [];
5412
5505
  var seen = new Set();
5413
5506
  var visitResource = function visitResource(resource) {
5414
- var identifier = _this14.getCheckoutResourceIdentifier(resource);
5507
+ var identifier = _this15.getCheckoutResourceIdentifier(resource);
5415
5508
  if (identifier && !seen.has(identifier)) {
5416
5509
  seen.add(identifier);
5417
5510
  values.push(identifier);
@@ -5459,16 +5552,16 @@ var Server = /*#__PURE__*/function () {
5459
5552
  }, {
5460
5553
  key: "normalizeCheckoutSubmitData",
5461
5554
  value: function () {
5462
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5555
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
5463
5556
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5464
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5465
- while (1) switch (_context54.prev = _context54.next) {
5557
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5558
+ while (1) switch (_context55.prev = _context55.next) {
5466
5559
  case 0:
5467
5560
  if (!(!data || _typeof(data) !== 'object')) {
5468
- _context54.next = 2;
5561
+ _context55.next = 2;
5469
5562
  break;
5470
5563
  }
5471
- return _context54.abrupt("return", data);
5564
+ return _context55.abrupt("return", data);
5472
5565
  case 2:
5473
5566
  next = _objectSpread({}, data);
5474
5567
  externalSaleNumber = next.external_sale_number;
@@ -5478,7 +5571,7 @@ var Server = /*#__PURE__*/function () {
5478
5571
  delete next.vouchers;
5479
5572
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5480
5573
  if (!hasCheckoutOrderNumbers) {
5481
- _context54.next = 11;
5574
+ _context55.next = 11;
5482
5575
  break;
5483
5576
  }
5484
5577
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -5488,10 +5581,10 @@ var Server = /*#__PURE__*/function () {
5488
5581
  shop_order_number: next.shop_order_number,
5489
5582
  shop_full_order_number: next.shop_full_order_number
5490
5583
  });
5491
- return _context54.abrupt("return", next);
5584
+ return _context55.abrupt("return", next);
5492
5585
  case 11:
5493
5586
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
5494
- _context54.next = 14;
5587
+ _context55.next = 14;
5495
5588
  break;
5496
5589
  }
5497
5590
  if (shouldClearLocalOrderId) {
@@ -5500,10 +5593,10 @@ var Server = /*#__PURE__*/function () {
5500
5593
  order_id: next.order_id
5501
5594
  });
5502
5595
  }
5503
- return _context54.abrupt("return", next);
5596
+ return _context55.abrupt("return", next);
5504
5597
  case 14:
5505
5598
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
5506
- _context54.next = 17;
5599
+ _context55.next = 17;
5507
5600
  break;
5508
5601
  }
5509
5602
  if (shouldClearLocalOrderId) {
@@ -5512,12 +5605,12 @@ var Server = /*#__PURE__*/function () {
5512
5605
  external_sale_number: externalSaleNumber
5513
5606
  });
5514
5607
  }
5515
- return _context54.abrupt("return", next);
5608
+ return _context55.abrupt("return", next);
5516
5609
  case 17:
5517
- _context54.prev = 17;
5610
+ _context55.prev = 17;
5518
5611
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
5519
5612
  if (localOrder) {
5520
- _context54.next = 22;
5613
+ _context55.next = 22;
5521
5614
  break;
5522
5615
  }
5523
5616
  if (shouldClearLocalOrderId) {
@@ -5527,7 +5620,7 @@ var Server = /*#__PURE__*/function () {
5527
5620
  localOrderFound: false
5528
5621
  });
5529
5622
  }
5530
- return _context54.abrupt("return", next);
5623
+ return _context55.abrupt("return", next);
5531
5624
  case 22:
5532
5625
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
5533
5626
  next.shop_order_number = localOrder.shop_order_number;
@@ -5544,23 +5637,23 @@ var Server = /*#__PURE__*/function () {
5544
5637
  shop_full_order_number: next.shop_full_order_number
5545
5638
  });
5546
5639
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5547
- return _context54.abrupt("return", next);
5640
+ return _context55.abrupt("return", next);
5548
5641
  case 28:
5549
- _context54.prev = 28;
5550
- _context54.t0 = _context54["catch"](17);
5642
+ _context55.prev = 28;
5643
+ _context55.t0 = _context55["catch"](17);
5551
5644
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
5552
5645
  external_sale_number: externalSaleNumber,
5553
- error: this.getUnknownErrorMessage(_context54.t0),
5554
- error_detail: this.normalizeUnknownError(_context54.t0)
5646
+ error: this.getUnknownErrorMessage(_context55.t0),
5647
+ error_detail: this.normalizeUnknownError(_context55.t0)
5555
5648
  });
5556
- return _context54.abrupt("return", next);
5649
+ return _context55.abrupt("return", next);
5557
5650
  case 32:
5558
5651
  case "end":
5559
- return _context54.stop();
5652
+ return _context55.stop();
5560
5653
  }
5561
- }, _callee54, this, [[17, 28]]);
5654
+ }, _callee55, this, [[17, 28]]);
5562
5655
  }));
5563
- function normalizeCheckoutSubmitData(_x57, _x58) {
5656
+ function normalizeCheckoutSubmitData(_x58, _x59) {
5564
5657
  return _normalizeCheckoutSubmitData.apply(this, arguments);
5565
5658
  }
5566
5659
  return normalizeCheckoutSubmitData;
@@ -5568,81 +5661,81 @@ var Server = /*#__PURE__*/function () {
5568
5661
  }, {
5569
5662
  key: "ensureCheckoutOrderNumbers",
5570
5663
  value: function () {
5571
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
5664
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(data, title) {
5572
5665
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
5573
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5574
- while (1) switch (_context55.prev = _context55.next) {
5666
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5667
+ while (1) switch (_context56.prev = _context56.next) {
5575
5668
  case 0:
5576
5669
  if (!(!data || _typeof(data) !== 'object')) {
5577
- _context55.next = 2;
5670
+ _context56.next = 2;
5578
5671
  break;
5579
5672
  }
5580
- return _context55.abrupt("return", data);
5673
+ return _context56.abrupt("return", data);
5581
5674
  case 2:
5582
5675
  next = _objectSpread({}, data);
5583
5676
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
5584
5677
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
5585
5678
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
5586
- _context55.next = 7;
5679
+ _context56.next = 7;
5587
5680
  break;
5588
5681
  }
5589
- return _context55.abrupt("return", next);
5682
+ return _context56.abrupt("return", next);
5590
5683
  case 7:
5591
5684
  idGenerator = this.getIdGeneratorPlugin();
5592
5685
  if (idGenerator) {
5593
- _context55.next = 11;
5686
+ _context56.next = 11;
5594
5687
  break;
5595
5688
  }
5596
5689
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
5597
5690
  needsShopOrderNumber: needsShopOrderNumber,
5598
5691
  needsShopFullOrderNumber: needsShopFullOrderNumber
5599
5692
  });
5600
- return _context55.abrupt("return", next);
5693
+ return _context56.abrupt("return", next);
5601
5694
  case 11:
5602
- _context55.prev = 11;
5695
+ _context56.prev = 11;
5603
5696
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
5604
- _context55.next = 16;
5697
+ _context56.next = 16;
5605
5698
  break;
5606
5699
  }
5607
- _context55.next = 15;
5700
+ _context56.next = 15;
5608
5701
  return idGenerator.generateShopOrderNumber({
5609
5702
  biz: next.business_code || 'ticket'
5610
5703
  });
5611
5704
  case 15:
5612
- next.shop_order_number = _context55.sent;
5705
+ next.shop_order_number = _context56.sent;
5613
5706
  case 16:
5614
5707
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
5615
- _context55.next = 20;
5708
+ _context56.next = 20;
5616
5709
  break;
5617
5710
  }
5618
- _context55.next = 19;
5711
+ _context56.next = 19;
5619
5712
  return idGenerator.generateReceiptId({
5620
5713
  biz: next.business_code || 'ticket'
5621
5714
  });
5622
5715
  case 19:
5623
- next.shop_full_order_number = _context55.sent;
5716
+ next.shop_full_order_number = _context56.sent;
5624
5717
  case 20:
5625
5718
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
5626
5719
  shop_order_number: next.shop_order_number,
5627
5720
  shop_full_order_number: next.shop_full_order_number
5628
5721
  });
5629
- _context55.next = 26;
5722
+ _context56.next = 26;
5630
5723
  break;
5631
5724
  case 23:
5632
- _context55.prev = 23;
5633
- _context55.t0 = _context55["catch"](11);
5725
+ _context56.prev = 23;
5726
+ _context56.t0 = _context56["catch"](11);
5634
5727
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
5635
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5728
+ error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5636
5729
  });
5637
5730
  case 26:
5638
- return _context55.abrupt("return", next);
5731
+ return _context56.abrupt("return", next);
5639
5732
  case 27:
5640
5733
  case "end":
5641
- return _context55.stop();
5734
+ return _context56.stop();
5642
5735
  }
5643
- }, _callee55, this, [[11, 23]]);
5736
+ }, _callee56, this, [[11, 23]]);
5644
5737
  }));
5645
- function ensureCheckoutOrderNumbers(_x59, _x60) {
5738
+ function ensureCheckoutOrderNumbers(_x60, _x61) {
5646
5739
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
5647
5740
  }
5648
5741
  return ensureCheckoutOrderNumbers;
@@ -5650,27 +5743,27 @@ var Server = /*#__PURE__*/function () {
5650
5743
  }, {
5651
5744
  key: "dispatchCheckoutSyncTask",
5652
5745
  value: function () {
5653
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5746
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5654
5747
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
5655
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5656
- while (1) switch (_context56.prev = _context56.next) {
5748
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5749
+ while (1) switch (_context57.prev = _context57.next) {
5657
5750
  case 0:
5658
5751
  this.registerDeviceTaskActions();
5659
5752
  deviceTask = this.getDeviceTaskPlugin();
5660
- _context56.next = 4;
5753
+ _context57.next = 4;
5661
5754
  return this.getShortNumberOrDeviceId();
5662
5755
  case 4:
5663
- debugDeviceId = _context56.sent;
5756
+ debugDeviceId = _context57.sent;
5664
5757
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
5665
5758
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5666
- _context56.next = 9;
5759
+ _context57.next = 9;
5667
5760
  break;
5668
5761
  }
5669
5762
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
5670
- return _context56.abrupt("return");
5763
+ return _context57.abrupt("return");
5671
5764
  case 9:
5672
- _context56.prev = 9;
5673
- _context56.next = 12;
5765
+ _context57.prev = 9;
5766
+ _context57.next = 12;
5674
5767
  return deviceTask.dispatch({
5675
5768
  action: 'sync_sales',
5676
5769
  device_id: debugDeviceId,
@@ -5688,27 +5781,27 @@ var Server = /*#__PURE__*/function () {
5688
5781
  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)
5689
5782
  });
5690
5783
  case 12:
5691
- result = _context56.sent;
5784
+ result = _context57.sent;
5692
5785
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
5693
5786
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
5694
5787
  status: result === null || result === void 0 ? void 0 : result.status,
5695
5788
  reused: result === null || result === void 0 ? void 0 : result.reused
5696
5789
  });
5697
- _context56.next = 19;
5790
+ _context57.next = 19;
5698
5791
  break;
5699
5792
  case 16:
5700
- _context56.prev = 16;
5701
- _context56.t0 = _context56["catch"](9);
5793
+ _context57.prev = 16;
5794
+ _context57.t0 = _context57["catch"](9);
5702
5795
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
5703
- error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5796
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5704
5797
  });
5705
5798
  case 19:
5706
5799
  case "end":
5707
- return _context56.stop();
5800
+ return _context57.stop();
5708
5801
  }
5709
- }, _callee56, this, [[9, 16]]);
5802
+ }, _callee57, this, [[9, 16]]);
5710
5803
  }));
5711
- function dispatchCheckoutSyncTask(_x61) {
5804
+ function dispatchCheckoutSyncTask(_x62) {
5712
5805
  return _dispatchCheckoutSyncTask.apply(this, arguments);
5713
5806
  }
5714
5807
  return dispatchCheckoutSyncTask;
@@ -5716,26 +5809,26 @@ var Server = /*#__PURE__*/function () {
5716
5809
  }, {
5717
5810
  key: "dispatchPrintOtherReceiptTask",
5718
5811
  value: function () {
5719
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5812
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5720
5813
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
5721
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5722
- while (1) switch (_context57.prev = _context57.next) {
5814
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5815
+ while (1) switch (_context58.prev = _context58.next) {
5723
5816
  case 0:
5724
5817
  deviceTask = this.getDeviceTaskPlugin();
5725
5818
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5726
- _context57.next = 4;
5819
+ _context58.next = 4;
5727
5820
  break;
5728
5821
  }
5729
5822
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
5730
- return _context57.abrupt("return");
5823
+ return _context58.abrupt("return");
5731
5824
  case 4:
5732
- _context57.prev = 4;
5825
+ _context58.prev = 4;
5733
5826
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
5734
- _context57.next = 8;
5827
+ _context58.next = 8;
5735
5828
  return this.getShortNumberOrDeviceId();
5736
5829
  case 8:
5737
- deviceId = _context57.sent;
5738
- _context57.next = 11;
5830
+ deviceId = _context58.sent;
5831
+ _context58.next = 11;
5739
5832
  return deviceTask.dispatch({
5740
5833
  action: 'print_all',
5741
5834
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -5763,21 +5856,21 @@ var Server = /*#__PURE__*/function () {
5763
5856
  source_id: printIdentity
5764
5857
  });
5765
5858
  case 11:
5766
- _context57.next = 16;
5859
+ _context58.next = 16;
5767
5860
  break;
5768
5861
  case 13:
5769
- _context57.prev = 13;
5770
- _context57.t0 = _context57["catch"](4);
5862
+ _context58.prev = 13;
5863
+ _context58.t0 = _context58["catch"](4);
5771
5864
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
5772
- error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5865
+ error: _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0)
5773
5866
  });
5774
5867
  case 16:
5775
5868
  case "end":
5776
- return _context57.stop();
5869
+ return _context58.stop();
5777
5870
  }
5778
- }, _callee57, this, [[4, 13]]);
5871
+ }, _callee58, this, [[4, 13]]);
5779
5872
  }));
5780
- function dispatchPrintOtherReceiptTask(_x62) {
5873
+ function dispatchPrintOtherReceiptTask(_x63) {
5781
5874
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
5782
5875
  }
5783
5876
  return dispatchPrintOtherReceiptTask;
@@ -5797,32 +5890,32 @@ var Server = /*#__PURE__*/function () {
5797
5890
  }, {
5798
5891
  key: "dispatchLocalReceiptPrint",
5799
5892
  value: function () {
5800
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5893
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5801
5894
  var _payment_info;
5802
5895
  var printableOrder;
5803
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5804
- while (1) switch (_context58.prev = _context58.next) {
5896
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5897
+ while (1) switch (_context59.prev = _context59.next) {
5805
5898
  case 0:
5806
5899
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
5807
- _context58.next = 2;
5900
+ _context59.next = 2;
5808
5901
  break;
5809
5902
  }
5810
- return _context58.abrupt("return", {
5903
+ return _context59.abrupt("return", {
5811
5904
  printed: false,
5812
5905
  order: params.order
5813
5906
  });
5814
5907
  case 2:
5815
- _context58.next = 4;
5908
+ _context59.next = 4;
5816
5909
  return this.withLocalSmallTicketData(params.order, {
5817
5910
  requireFullyPaid: params.requireFullyPaid
5818
5911
  });
5819
5912
  case 4:
5820
- printableOrder = _context58.sent;
5913
+ printableOrder = _context59.sent;
5821
5914
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
5822
- _context58.next = 7;
5915
+ _context59.next = 7;
5823
5916
  break;
5824
5917
  }
5825
- return _context58.abrupt("return", {
5918
+ return _context59.abrupt("return", {
5826
5919
  printed: false,
5827
5920
  order: printableOrder
5828
5921
  });
@@ -5832,7 +5925,7 @@ var Server = /*#__PURE__*/function () {
5832
5925
  printableOrder: printableOrder,
5833
5926
  response: params.response
5834
5927
  });
5835
- _context58.next = 10;
5928
+ _context59.next = 10;
5836
5929
  return this.dispatchPrintOtherReceiptTask({
5837
5930
  checkoutData: params.checkoutData,
5838
5931
  syncedOrder: printableOrder,
@@ -5841,17 +5934,17 @@ var Server = /*#__PURE__*/function () {
5841
5934
  isManualPrint: params.isManualPrint
5842
5935
  });
5843
5936
  case 10:
5844
- return _context58.abrupt("return", {
5937
+ return _context59.abrupt("return", {
5845
5938
  printed: true,
5846
5939
  order: printableOrder
5847
5940
  });
5848
5941
  case 11:
5849
5942
  case "end":
5850
- return _context58.stop();
5943
+ return _context59.stop();
5851
5944
  }
5852
- }, _callee58, this);
5945
+ }, _callee59, this);
5853
5946
  }));
5854
- function dispatchLocalReceiptPrint(_x63) {
5947
+ function dispatchLocalReceiptPrint(_x64) {
5855
5948
  return _dispatchLocalReceiptPrint.apply(this, arguments);
5856
5949
  }
5857
5950
  return dispatchLocalReceiptPrint;
@@ -5886,47 +5979,47 @@ var Server = /*#__PURE__*/function () {
5886
5979
  }, {
5887
5980
  key: "syncMachinecodeRedeemStatusToLocalOrder",
5888
5981
  value: function () {
5889
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data, ids, status) {
5982
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data, ids, status) {
5890
5983
  var _this$order3;
5891
5984
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
5892
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5893
- while (1) switch (_context59.prev = _context59.next) {
5985
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5986
+ while (1) switch (_context60.prev = _context60.next) {
5894
5987
  case 0:
5895
5988
  title = 'handleMachinecodeBatchMetadata';
5896
5989
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
5897
5990
  if (!(lookup === undefined)) {
5898
- _context59.next = 5;
5991
+ _context60.next = 5;
5899
5992
  break;
5900
5993
  }
5901
5994
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5902
5995
  batchSize: ids.length,
5903
5996
  status: status
5904
5997
  });
5905
- return _context59.abrupt("return");
5998
+ return _context60.abrupt("return");
5906
5999
  case 5:
5907
6000
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
5908
- _context59.next = 8;
6001
+ _context60.next = 8;
5909
6002
  break;
5910
6003
  }
5911
6004
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5912
6005
  lookup: lookup,
5913
6006
  status: status
5914
6007
  });
5915
- return _context59.abrupt("return");
6008
+ return _context60.abrupt("return");
5916
6009
  case 8:
5917
- _context59.next = 10;
6010
+ _context60.next = 10;
5918
6011
  return this.order.getLocalOrderByLookup(lookup);
5919
6012
  case 10:
5920
- localOrder = _context59.sent;
6013
+ localOrder = _context60.sent;
5921
6014
  if (localOrder) {
5922
- _context59.next = 14;
6015
+ _context60.next = 14;
5923
6016
  break;
5924
6017
  }
5925
6018
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5926
6019
  lookup: lookup,
5927
6020
  status: status
5928
6021
  });
5929
- return _context59.abrupt("return");
6022
+ return _context60.abrupt("return");
5930
6023
  case 14:
5931
6024
  voucherIdSet = new Set(ids.filter(function (id) {
5932
6025
  return id !== undefined && id !== null && id !== '';
@@ -5934,14 +6027,14 @@ var Server = /*#__PURE__*/function () {
5934
6027
  return String(id);
5935
6028
  }));
5936
6029
  if (!(voucherIdSet.size === 0)) {
5937
- _context59.next = 18;
6030
+ _context60.next = 18;
5938
6031
  break;
5939
6032
  }
5940
6033
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5941
6034
  lookup: lookup,
5942
6035
  status: status
5943
6036
  });
5944
- return _context59.abrupt("return");
6037
+ return _context60.abrupt("return");
5945
6038
  case 18:
5946
6039
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
5947
6040
  hasUpdatedVoucher = false;
@@ -5955,7 +6048,7 @@ var Server = /*#__PURE__*/function () {
5955
6048
  });
5956
6049
  });
5957
6050
  if (hasUpdatedVoucher) {
5958
- _context59.next = 24;
6051
+ _context60.next = 24;
5959
6052
  break;
5960
6053
  }
5961
6054
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -5963,13 +6056,13 @@ var Server = /*#__PURE__*/function () {
5963
6056
  voucher_ids: Array.from(voucherIdSet),
5964
6057
  status: status
5965
6058
  });
5966
- return _context59.abrupt("return");
6059
+ return _context60.abrupt("return");
5967
6060
  case 24:
5968
6061
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
5969
- _context59.next = 29;
6062
+ _context60.next = 29;
5970
6063
  break;
5971
6064
  }
5972
- _context59.next = 27;
6065
+ _context60.next = 27;
5973
6066
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
5974
6067
  vouchers: nextVouchers
5975
6068
  }));
@@ -5979,13 +6072,13 @@ var Server = /*#__PURE__*/function () {
5979
6072
  updatedCount: voucherIdSet.size,
5980
6073
  status: status
5981
6074
  });
5982
- return _context59.abrupt("return");
6075
+ return _context60.abrupt("return");
5983
6076
  case 29:
5984
6077
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
5985
- _context59.next = 34;
6078
+ _context60.next = 34;
5986
6079
  break;
5987
6080
  }
5988
- _context59.next = 32;
6081
+ _context60.next = 32;
5989
6082
  return this.order.markOrderSyncedByExternalSaleNumber({
5990
6083
  externalSaleNumber: data.external_sale_number,
5991
6084
  patch: {
@@ -5998,7 +6091,7 @@ var Server = /*#__PURE__*/function () {
5998
6091
  updatedCount: voucherIdSet.size,
5999
6092
  status: status
6000
6093
  });
6001
- return _context59.abrupt("return");
6094
+ return _context60.abrupt("return");
6002
6095
  case 34:
6003
6096
  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"), {
6004
6097
  lookup: lookup,
@@ -6006,11 +6099,11 @@ var Server = /*#__PURE__*/function () {
6006
6099
  });
6007
6100
  case 35:
6008
6101
  case "end":
6009
- return _context59.stop();
6102
+ return _context60.stop();
6010
6103
  }
6011
- }, _callee59, this);
6104
+ }, _callee60, this);
6012
6105
  }));
6013
- function syncMachinecodeRedeemStatusToLocalOrder(_x64, _x65, _x66) {
6106
+ function syncMachinecodeRedeemStatusToLocalOrder(_x65, _x66, _x67) {
6014
6107
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
6015
6108
  }
6016
6109
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -6018,10 +6111,10 @@ var Server = /*#__PURE__*/function () {
6018
6111
  }, {
6019
6112
  key: "handleOrderCheckoutSubmit",
6020
6113
  value: function () {
6021
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6114
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6022
6115
  var backendPath, data, title, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
6023
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6024
- while (1) switch (_context60.prev = _context60.next) {
6116
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6117
+ while (1) switch (_context61.prev = _context61.next) {
6025
6118
  case 0:
6026
6119
  backendPath = params.backendPath, data = params.data, title = params.title;
6027
6120
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -6031,25 +6124,25 @@ var Server = /*#__PURE__*/function () {
6031
6124
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6032
6125
  });
6033
6126
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
6034
- _context60.next = 4;
6127
+ _context61.next = 4;
6035
6128
  break;
6036
6129
  }
6037
- return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
6130
+ return _context61.abrupt("return", this.handleSyncCheckoutSubmit({
6038
6131
  backendPath: backendPath,
6039
6132
  data: data,
6040
6133
  title: title
6041
6134
  }));
6042
6135
  case 4:
6043
- _context60.next = 6;
6136
+ _context61.next = 6;
6044
6137
  return this.normalizeCheckoutSubmitData(data, title);
6045
6138
  case 6:
6046
- normalizedData = _context60.sent;
6047
- _context60.next = 9;
6139
+ normalizedData = _context61.sent;
6140
+ _context61.next = 9;
6048
6141
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6049
6142
  case 9:
6050
- numberedData = _context60.sent;
6143
+ numberedData = _context61.sent;
6051
6144
  checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6052
- _context60.next = 13;
6145
+ _context61.next = 13;
6053
6146
  return this.handlePendingSyncCheckoutOrder({
6054
6147
  backendPath: backendPath,
6055
6148
  data: checkoutData,
@@ -6057,17 +6150,17 @@ var Server = /*#__PURE__*/function () {
6057
6150
  reason: 'checkout 已转入设备任务同步'
6058
6151
  });
6059
6152
  case 13:
6060
- pendingResult = _context60.sent;
6153
+ pendingResult = _context61.sent;
6061
6154
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6062
- _context60.next = 21;
6155
+ _context61.next = 21;
6063
6156
  break;
6064
6157
  }
6065
6158
  pendingOrder = pendingResult.data;
6066
6159
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
6067
- _context60.next = 19;
6160
+ _context61.next = 19;
6068
6161
  break;
6069
6162
  }
6070
- _context60.next = 19;
6163
+ _context61.next = 19;
6071
6164
  return this.dispatchLocalReceiptPrint({
6072
6165
  checkoutData: checkoutData,
6073
6166
  order: pendingOrder,
@@ -6075,7 +6168,7 @@ var Server = /*#__PURE__*/function () {
6075
6168
  requireFullyPaid: true
6076
6169
  });
6077
6170
  case 19:
6078
- _context60.next = 21;
6171
+ _context61.next = 21;
6079
6172
  return this.dispatchCheckoutSyncTask({
6080
6173
  backendPath: backendPath,
6081
6174
  data: checkoutData,
@@ -6083,23 +6176,23 @@ var Server = /*#__PURE__*/function () {
6083
6176
  });
6084
6177
  case 21:
6085
6178
  if (pendingResult.data.order_id) {
6086
- _context60.next = 23;
6179
+ _context61.next = 23;
6087
6180
  break;
6088
6181
  }
6089
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6182
+ return _context61.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6090
6183
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6091
6184
  order_id: pendingResult.data.external_sale_number
6092
6185
  })
6093
6186
  }));
6094
6187
  case 23:
6095
- return _context60.abrupt("return", pendingResult);
6188
+ return _context61.abrupt("return", pendingResult);
6096
6189
  case 24:
6097
6190
  case "end":
6098
- return _context60.stop();
6191
+ return _context61.stop();
6099
6192
  }
6100
- }, _callee60, this);
6193
+ }, _callee61, this);
6101
6194
  }));
6102
- function handleOrderCheckoutSubmit(_x67) {
6195
+ function handleOrderCheckoutSubmit(_x68) {
6103
6196
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6104
6197
  }
6105
6198
  return handleOrderCheckoutSubmit;
@@ -6107,27 +6200,27 @@ var Server = /*#__PURE__*/function () {
6107
6200
  }, {
6108
6201
  key: "handleSyncCheckoutSubmit",
6109
6202
  value: function () {
6110
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6203
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6111
6204
  var _this$app16;
6112
6205
  var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6113
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6114
- while (1) switch (_context61.prev = _context61.next) {
6206
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6207
+ while (1) switch (_context62.prev = _context62.next) {
6115
6208
  case 0:
6116
6209
  backendPath = params.backendPath, data = params.data, title = params.title;
6117
6210
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
6118
- _context61.next = 4;
6211
+ _context62.next = 4;
6119
6212
  break;
6120
6213
  }
6121
6214
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6122
- return _context61.abrupt("return", {
6215
+ return _context62.abrupt("return", {
6123
6216
  code: 500,
6124
6217
  status: false,
6125
6218
  message: 'app.request 不可用',
6126
6219
  data: null
6127
6220
  });
6128
6221
  case 4:
6129
- _context61.prev = 4;
6130
- _context61.next = 7;
6222
+ _context62.prev = 4;
6223
+ _context62.next = 7;
6131
6224
  return this.runCheckoutSync({
6132
6225
  backendPath: backendPath,
6133
6226
  data: data,
@@ -6135,13 +6228,13 @@ var Server = /*#__PURE__*/function () {
6135
6228
  persistCheckoutDataWithResponse: true
6136
6229
  });
6137
6230
  case 7:
6138
- syncResult = _context61.sent;
6231
+ syncResult = _context62.sent;
6139
6232
  if (!syncResult.rejected) {
6140
- _context61.next = 11;
6233
+ _context62.next = 11;
6141
6234
  break;
6142
6235
  }
6143
6236
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6144
- return _context61.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6237
+ return _context62.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6145
6238
  status: false,
6146
6239
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
6147
6240
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -6150,10 +6243,10 @@ var Server = /*#__PURE__*/function () {
6150
6243
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6151
6244
  syncedOrder = syncResult.syncedOrder;
6152
6245
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
6153
- _context61.next = 16;
6246
+ _context62.next = 16;
6154
6247
  break;
6155
6248
  }
6156
- _context61.next = 16;
6249
+ _context62.next = 16;
6157
6250
  return this.dispatchLocalReceiptPrint({
6158
6251
  checkoutData: syncResult.checkoutData,
6159
6252
  order: syncedOrder,
@@ -6162,29 +6255,29 @@ var Server = /*#__PURE__*/function () {
6162
6255
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6163
6256
  });
6164
6257
  case 16:
6165
- return _context61.abrupt("return", response);
6258
+ return _context62.abrupt("return", response);
6166
6259
  case 19:
6167
- _context61.prev = 19;
6168
- _context61.t0 = _context61["catch"](4);
6169
- backendError = this.extractBackendErrorResponse(_context61.t0);
6260
+ _context62.prev = 19;
6261
+ _context62.t0 = _context62["catch"](4);
6262
+ backendError = this.extractBackendErrorResponse(_context62.t0);
6170
6263
  if (!backendError) {
6171
- _context61.next = 25;
6264
+ _context62.next = 25;
6172
6265
  break;
6173
6266
  }
6174
6267
  _normalized = this.normalizeCheckoutResponse(backendError);
6175
- return _context61.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6268
+ return _context62.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6176
6269
  status: false,
6177
6270
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6178
6271
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6179
6272
  }));
6180
6273
  case 25:
6181
- message = this.getUnknownErrorMessage(_context61.t0);
6274
+ message = this.getUnknownErrorMessage(_context62.t0);
6182
6275
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6183
6276
  backendPath: backendPath,
6184
6277
  error: message,
6185
- error_detail: this.normalizeUnknownError(_context61.t0)
6278
+ error_detail: this.normalizeUnknownError(_context62.t0)
6186
6279
  });
6187
- return _context61.abrupt("return", {
6280
+ return _context62.abrupt("return", {
6188
6281
  code: 500,
6189
6282
  status: false,
6190
6283
  message: message,
@@ -6192,11 +6285,11 @@ var Server = /*#__PURE__*/function () {
6192
6285
  });
6193
6286
  case 28:
6194
6287
  case "end":
6195
- return _context61.stop();
6288
+ return _context62.stop();
6196
6289
  }
6197
- }, _callee61, this, [[4, 19]]);
6290
+ }, _callee62, this, [[4, 19]]);
6198
6291
  }));
6199
- function handleSyncCheckoutSubmit(_x68) {
6292
+ function handleSyncCheckoutSubmit(_x69) {
6200
6293
  return _handleSyncCheckoutSubmit.apply(this, arguments);
6201
6294
  }
6202
6295
  return handleSyncCheckoutSubmit;
@@ -6204,10 +6297,10 @@ var Server = /*#__PURE__*/function () {
6204
6297
  }, {
6205
6298
  key: "handleOrderDraftSubmit",
6206
6299
  value: function () {
6207
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6300
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6208
6301
  var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6209
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6210
- while (1) switch (_context62.prev = _context62.next) {
6302
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6303
+ while (1) switch (_context63.prev = _context63.next) {
6211
6304
  case 0:
6212
6305
  data = params.data, title = params.title;
6213
6306
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -6215,10 +6308,10 @@ var Server = /*#__PURE__*/function () {
6215
6308
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6216
6309
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6217
6310
  });
6218
- _context62.next = 4;
6311
+ _context63.next = 4;
6219
6312
  return this.normalizeCheckoutSubmitData(data, title);
6220
6313
  case 4:
6221
- normalizedData = _context62.sent;
6314
+ normalizedData = _context63.sent;
6222
6315
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6223
6316
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6224
6317
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6228,26 +6321,26 @@ var Server = /*#__PURE__*/function () {
6228
6321
  is_draft_order: 1
6229
6322
  });
6230
6323
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6231
- _context62.next = 10;
6324
+ _context63.next = 10;
6232
6325
  break;
6233
6326
  }
6234
6327
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6235
- return _context62.abrupt("return", {
6328
+ return _context63.abrupt("return", {
6236
6329
  code: 500,
6237
6330
  status: false,
6238
6331
  message: 'Order 模块不支持本地草稿写入',
6239
6332
  data: null
6240
6333
  });
6241
6334
  case 10:
6242
- _context62.prev = 10;
6243
- _context62.next = 13;
6335
+ _context63.prev = 10;
6336
+ _context63.next = 13;
6244
6337
  return this.order.upsertLocalDraftOrders([draftOrder]);
6245
6338
  case 13:
6246
6339
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6247
6340
  order_id: draftOrder.order_id,
6248
6341
  external_sale_number: draftOrder.external_sale_number
6249
6342
  });
6250
- return _context62.abrupt("return", {
6343
+ return _context63.abrupt("return", {
6251
6344
  code: 200,
6252
6345
  status: true,
6253
6346
  message: '',
@@ -6259,13 +6352,13 @@ var Server = /*#__PURE__*/function () {
6259
6352
  })
6260
6353
  });
6261
6354
  case 17:
6262
- _context62.prev = 17;
6263
- _context62.t0 = _context62["catch"](10);
6264
- errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6355
+ _context63.prev = 17;
6356
+ _context63.t0 = _context63["catch"](10);
6357
+ errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
6265
6358
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6266
6359
  error: errorMessage
6267
6360
  });
6268
- return _context62.abrupt("return", {
6361
+ return _context63.abrupt("return", {
6269
6362
  code: 500,
6270
6363
  status: false,
6271
6364
  message: errorMessage,
@@ -6273,11 +6366,11 @@ var Server = /*#__PURE__*/function () {
6273
6366
  });
6274
6367
  case 22:
6275
6368
  case "end":
6276
- return _context62.stop();
6369
+ return _context63.stop();
6277
6370
  }
6278
- }, _callee62, this, [[10, 17]]);
6371
+ }, _callee63, this, [[10, 17]]);
6279
6372
  }));
6280
- function handleOrderDraftSubmit(_x69) {
6373
+ function handleOrderDraftSubmit(_x70) {
6281
6374
  return _handleOrderDraftSubmit.apply(this, arguments);
6282
6375
  }
6283
6376
  return handleOrderDraftSubmit;
@@ -6285,26 +6378,26 @@ var Server = /*#__PURE__*/function () {
6285
6378
  }, {
6286
6379
  key: "handlePendingSyncCheckoutOrder",
6287
6380
  value: function () {
6288
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6289
- var _this15 = this;
6381
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6382
+ var _this16 = this;
6290
6383
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6291
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6292
- while (1) switch (_context63.prev = _context63.next) {
6384
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6385
+ while (1) switch (_context64.prev = _context64.next) {
6293
6386
  case 0:
6294
6387
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
6295
- _context63.next = 3;
6388
+ _context64.next = 3;
6296
6389
  return this.buildPendingSyncCheckoutOrder(data);
6297
6390
  case 3:
6298
- pendingOrder = _context63.sent;
6391
+ pendingOrder = _context64.sent;
6299
6392
  if (pendingOrder) {
6300
- _context63.next = 7;
6393
+ _context64.next = 7;
6301
6394
  break;
6302
6395
  }
6303
6396
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
6304
6397
  backendPath: backendPath,
6305
6398
  reason: reason
6306
6399
  });
6307
- return _context63.abrupt("return", {
6400
+ return _context64.abrupt("return", {
6308
6401
  code: 500,
6309
6402
  status: false,
6310
6403
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -6312,22 +6405,22 @@ var Server = /*#__PURE__*/function () {
6312
6405
  });
6313
6406
  case 7:
6314
6407
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6315
- _context63.next = 10;
6408
+ _context64.next = 10;
6316
6409
  break;
6317
6410
  }
6318
6411
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6319
6412
  backendPath: backendPath,
6320
6413
  reason: reason
6321
6414
  });
6322
- return _context63.abrupt("return", {
6415
+ return _context64.abrupt("return", {
6323
6416
  code: 500,
6324
6417
  status: false,
6325
6418
  message: 'Order 模块不支持本地待同步写入',
6326
6419
  data: null
6327
6420
  });
6328
6421
  case 10:
6329
- _context63.prev = 10;
6330
- _context63.next = 13;
6422
+ _context64.prev = 10;
6423
+ _context64.next = 13;
6331
6424
  return this.order.upsertPendingSyncOrders([pendingOrder]);
6332
6425
  case 13:
6333
6426
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -6339,9 +6432,9 @@ var Server = /*#__PURE__*/function () {
6339
6432
  });
6340
6433
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6341
6434
  var _payment$metadata;
6342
- return sum + _this15.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6435
+ return sum + _this16.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6343
6436
  }, 0);
6344
- return _context63.abrupt("return", {
6437
+ return _context64.abrupt("return", {
6345
6438
  code: 200,
6346
6439
  status: true,
6347
6440
  message: '',
@@ -6356,15 +6449,15 @@ var Server = /*#__PURE__*/function () {
6356
6449
  })
6357
6450
  });
6358
6451
  case 18:
6359
- _context63.prev = 18;
6360
- _context63.t0 = _context63["catch"](10);
6361
- errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
6452
+ _context64.prev = 18;
6453
+ _context64.t0 = _context64["catch"](10);
6454
+ errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
6362
6455
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
6363
6456
  backendPath: backendPath,
6364
6457
  reason: reason,
6365
6458
  error: errorMessage
6366
6459
  });
6367
- return _context63.abrupt("return", {
6460
+ return _context64.abrupt("return", {
6368
6461
  code: 500,
6369
6462
  status: false,
6370
6463
  message: errorMessage,
@@ -6372,11 +6465,11 @@ var Server = /*#__PURE__*/function () {
6372
6465
  });
6373
6466
  case 23:
6374
6467
  case "end":
6375
- return _context63.stop();
6468
+ return _context64.stop();
6376
6469
  }
6377
- }, _callee63, this, [[10, 18]]);
6470
+ }, _callee64, this, [[10, 18]]);
6378
6471
  }));
6379
- function handlePendingSyncCheckoutOrder(_x70) {
6472
+ function handlePendingSyncCheckoutOrder(_x71) {
6380
6473
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
6381
6474
  }
6382
6475
  return handlePendingSyncCheckoutOrder;
@@ -6384,44 +6477,44 @@ var Server = /*#__PURE__*/function () {
6384
6477
  }, {
6385
6478
  key: "buildPendingSyncCheckoutOrder",
6386
6479
  value: function () {
6387
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6480
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(data) {
6388
6481
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6389
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6390
- while (1) switch (_context64.prev = _context64.next) {
6482
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6483
+ while (1) switch (_context65.prev = _context65.next) {
6391
6484
  case 0:
6392
6485
  if (!(!data || _typeof(data) !== 'object')) {
6393
- _context64.next = 2;
6486
+ _context65.next = 2;
6394
6487
  break;
6395
6488
  }
6396
- return _context64.abrupt("return", null);
6489
+ return _context65.abrupt("return", null);
6397
6490
  case 2:
6398
6491
  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 !== '';
6399
6492
  if (hasStorageKey) {
6400
- _context64.next = 5;
6493
+ _context65.next = 5;
6401
6494
  break;
6402
6495
  }
6403
- return _context64.abrupt("return", null);
6496
+ return _context65.abrupt("return", null);
6404
6497
  case 5:
6405
6498
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6406
6499
  need_sync: 1,
6407
6500
  is_draft_order: 0
6408
6501
  });
6409
- _context64.next = 8;
6502
+ _context65.next = 8;
6410
6503
  return this.buildSmallTicketProductMap(pendingOrder);
6411
6504
  case 8:
6412
- productMap = _context64.sent;
6505
+ productMap = _context65.sent;
6413
6506
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6414
- return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6507
+ return _context65.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6415
6508
  requireFullyPaid: true,
6416
6509
  productMap: productMap
6417
6510
  }));
6418
6511
  case 11:
6419
6512
  case "end":
6420
- return _context64.stop();
6513
+ return _context65.stop();
6421
6514
  }
6422
- }, _callee64, this);
6515
+ }, _callee65, this);
6423
6516
  }));
6424
- function buildPendingSyncCheckoutOrder(_x71) {
6517
+ function buildPendingSyncCheckoutOrder(_x72) {
6425
6518
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6426
6519
  }
6427
6520
  return buildPendingSyncCheckoutOrder;
@@ -6479,13 +6572,13 @@ var Server = /*#__PURE__*/function () {
6479
6572
  }, {
6480
6573
  key: "sumPaidOrderPayments",
6481
6574
  value: function sumPaidOrderPayments(payments) {
6482
- var _this16 = this;
6575
+ var _this17 = this;
6483
6576
  if (!Array.isArray(payments)) return 0;
6484
6577
  return payments.reduce(function (sum, payment) {
6485
6578
  var _payment$amount;
6486
6579
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6487
6580
  if (status !== 'paid') return sum;
6488
- return sum + _this16.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);
6581
+ return sum + _this17.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);
6489
6582
  }, 0);
6490
6583
  }
6491
6584
  }, {
@@ -6499,12 +6592,12 @@ var Server = /*#__PURE__*/function () {
6499
6592
  }, {
6500
6593
  key: "buildSmallTicketProductMap",
6501
6594
  value: function () {
6502
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6595
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6503
6596
  var _this$products3,
6504
- _this17 = this;
6597
+ _this18 = this;
6505
6598
  var products, productIdSet, productIds, entries;
6506
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6507
- while (1) switch (_context66.prev = _context66.next) {
6599
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6600
+ while (1) switch (_context67.prev = _context67.next) {
6508
6601
  case 0:
6509
6602
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
6510
6603
  productIdSet = new Set();
@@ -6526,45 +6619,45 @@ var Server = /*#__PURE__*/function () {
6526
6619
  });
6527
6620
  productIds = Array.from(productIdSet);
6528
6621
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
6529
- _context66.next = 6;
6622
+ _context67.next = 6;
6530
6623
  break;
6531
6624
  }
6532
- return _context66.abrupt("return", {});
6625
+ return _context67.abrupt("return", {});
6533
6626
  case 6:
6534
- _context66.next = 8;
6627
+ _context67.next = 8;
6535
6628
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6536
- var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6537
- var _this17$products, _this17$products$getP, product;
6538
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6539
- while (1) switch (_context65.prev = _context65.next) {
6629
+ var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(id) {
6630
+ var _this18$products, _this18$products$getP, product;
6631
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6632
+ while (1) switch (_context66.prev = _context66.next) {
6540
6633
  case 0:
6541
- _context65.prev = 0;
6542
- _context65.next = 3;
6543
- return (_this17$products = _this17.products) === null || _this17$products === void 0 || (_this17$products$getP = _this17$products.getProductById) === null || _this17$products$getP === void 0 ? void 0 : _this17$products$getP.call(_this17$products, Number(id));
6634
+ _context66.prev = 0;
6635
+ _context66.next = 3;
6636
+ return (_this18$products = _this18.products) === null || _this18$products === void 0 || (_this18$products$getP = _this18$products.getProductById) === null || _this18$products$getP === void 0 ? void 0 : _this18$products$getP.call(_this18$products, Number(id));
6544
6637
  case 3:
6545
- product = _context65.sent;
6546
- return _context65.abrupt("return", product ? [String(id), product] : null);
6638
+ product = _context66.sent;
6639
+ return _context66.abrupt("return", product ? [String(id), product] : null);
6547
6640
  case 7:
6548
- _context65.prev = 7;
6549
- _context65.t0 = _context65["catch"](0);
6550
- _this17.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6641
+ _context66.prev = 7;
6642
+ _context66.t0 = _context66["catch"](0);
6643
+ _this18.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6551
6644
  product_id: id,
6552
- error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6645
+ error: _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0)
6553
6646
  });
6554
- return _context65.abrupt("return", null);
6647
+ return _context66.abrupt("return", null);
6555
6648
  case 11:
6556
6649
  case "end":
6557
- return _context65.stop();
6650
+ return _context66.stop();
6558
6651
  }
6559
- }, _callee65, null, [[0, 7]]);
6652
+ }, _callee66, null, [[0, 7]]);
6560
6653
  }));
6561
- return function (_x73) {
6654
+ return function (_x74) {
6562
6655
  return _ref68.apply(this, arguments);
6563
6656
  };
6564
6657
  }()));
6565
6658
  case 8:
6566
- entries = _context66.sent;
6567
- return _context66.abrupt("return", entries.reduce(function (map, entry) {
6659
+ entries = _context67.sent;
6660
+ return _context67.abrupt("return", entries.reduce(function (map, entry) {
6568
6661
  if (!entry) return map;
6569
6662
  var _entry = _slicedToArray(entry, 2),
6570
6663
  id = _entry[0],
@@ -6574,11 +6667,11 @@ var Server = /*#__PURE__*/function () {
6574
6667
  }, {}));
6575
6668
  case 10:
6576
6669
  case "end":
6577
- return _context66.stop();
6670
+ return _context67.stop();
6578
6671
  }
6579
- }, _callee66, this);
6672
+ }, _callee67, this);
6580
6673
  }));
6581
- function buildSmallTicketProductMap(_x72) {
6674
+ function buildSmallTicketProductMap(_x73) {
6582
6675
  return _buildSmallTicketProductMap.apply(this, arguments);
6583
6676
  }
6584
6677
  return buildSmallTicketProductMap;
@@ -6608,40 +6701,40 @@ var Server = /*#__PURE__*/function () {
6608
6701
  }, {
6609
6702
  key: "buildSalesDetailProductSnapshotMap",
6610
6703
  value: function () {
6611
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6704
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6612
6705
  var _this$products4;
6613
6706
  var productIds, getSnapshots;
6614
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6615
- while (1) switch (_context67.prev = _context67.next) {
6707
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6708
+ while (1) switch (_context68.prev = _context68.next) {
6616
6709
  case 0:
6617
6710
  productIds = this.collectSalesDetailProductIds(order);
6618
6711
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
6619
6712
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
6620
- _context67.next = 4;
6713
+ _context68.next = 4;
6621
6714
  break;
6622
6715
  }
6623
- return _context67.abrupt("return", {});
6716
+ return _context68.abrupt("return", {});
6624
6717
  case 4:
6625
- _context67.prev = 4;
6626
- _context67.next = 7;
6718
+ _context68.prev = 4;
6719
+ _context68.next = 7;
6627
6720
  return getSnapshots.call(this.products, productIds);
6628
6721
  case 7:
6629
- return _context67.abrupt("return", _context67.sent);
6722
+ return _context68.abrupt("return", _context68.sent);
6630
6723
  case 10:
6631
- _context67.prev = 10;
6632
- _context67.t0 = _context67["catch"](4);
6724
+ _context68.prev = 10;
6725
+ _context68.t0 = _context68["catch"](4);
6633
6726
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
6634
6727
  product_ids: productIds,
6635
- error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
6728
+ error: _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0)
6636
6729
  });
6637
- return _context67.abrupt("return", {});
6730
+ return _context68.abrupt("return", {});
6638
6731
  case 14:
6639
6732
  case "end":
6640
- return _context67.stop();
6733
+ return _context68.stop();
6641
6734
  }
6642
- }, _callee67, this, [[4, 10]]);
6735
+ }, _callee68, this, [[4, 10]]);
6643
6736
  }));
6644
- function buildSalesDetailProductSnapshotMap(_x74) {
6737
+ function buildSalesDetailProductSnapshotMap(_x75) {
6645
6738
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6646
6739
  }
6647
6740
  return buildSalesDetailProductSnapshotMap;
@@ -6697,53 +6790,53 @@ var Server = /*#__PURE__*/function () {
6697
6790
  }, {
6698
6791
  key: "withSalesDetailProductSnapshots",
6699
6792
  value: function () {
6700
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6701
- var _this18 = this;
6793
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6794
+ var _this19 = this;
6702
6795
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6703
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6704
- while (1) switch (_context68.prev = _context68.next) {
6796
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6797
+ while (1) switch (_context69.prev = _context69.next) {
6705
6798
  case 0:
6706
6799
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
6707
6800
  if (products !== null && products !== void 0 && products.length) {
6708
- _context68.next = 3;
6801
+ _context69.next = 3;
6709
6802
  break;
6710
6803
  }
6711
- return _context68.abrupt("return", order);
6804
+ return _context69.abrupt("return", order);
6712
6805
  case 3:
6713
- _context68.next = 5;
6806
+ _context69.next = 5;
6714
6807
  return this.buildSalesDetailProductSnapshotMap(order);
6715
6808
  case 5:
6716
- snapshotMap = _context68.sent;
6809
+ snapshotMap = _context69.sent;
6717
6810
  if (Object.keys(snapshotMap).length) {
6718
- _context68.next = 8;
6811
+ _context69.next = 8;
6719
6812
  break;
6720
6813
  }
6721
- return _context68.abrupt("return", order);
6814
+ return _context69.abrupt("return", order);
6722
6815
  case 8:
6723
6816
  hasChanged = false;
6724
6817
  enrichedProducts = products.map(function (product) {
6725
- var productWithBundleSnapshots = _this18.withBundleCatalogSnapshots(product, snapshotMap);
6726
- var nextProduct = _this18.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6818
+ var productWithBundleSnapshots = _this19.withBundleCatalogSnapshots(product, snapshotMap);
6819
+ var nextProduct = _this19.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6727
6820
  if (nextProduct !== product) hasChanged = true;
6728
6821
  return nextProduct;
6729
6822
  });
6730
6823
  if (hasChanged) {
6731
- _context68.next = 12;
6824
+ _context69.next = 12;
6732
6825
  break;
6733
6826
  }
6734
- return _context68.abrupt("return", order);
6827
+ return _context69.abrupt("return", order);
6735
6828
  case 12:
6736
6829
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
6737
6830
  products: enrichedProducts
6738
6831
  });
6739
- return _context68.abrupt("return", enrichedOrder);
6832
+ return _context69.abrupt("return", enrichedOrder);
6740
6833
  case 14:
6741
6834
  case "end":
6742
- return _context68.stop();
6835
+ return _context69.stop();
6743
6836
  }
6744
- }, _callee68, this);
6837
+ }, _callee69, this);
6745
6838
  }));
6746
- function withSalesDetailProductSnapshots(_x75) {
6839
+ function withSalesDetailProductSnapshots(_x76) {
6747
6840
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6748
6841
  }
6749
6842
  return withSalesDetailProductSnapshots;
@@ -6751,13 +6844,13 @@ var Server = /*#__PURE__*/function () {
6751
6844
  }, {
6752
6845
  key: "withPendingSyncProductTitles",
6753
6846
  value: function withPendingSyncProductTitles(order, productMap) {
6754
- var _this19 = this;
6847
+ var _this20 = this;
6755
6848
  var products = Array.isArray(order.products) ? order.products : null;
6756
6849
  if (!(products !== null && products !== void 0 && products.length)) return order;
6757
6850
  return _objectSpread(_objectSpread({}, order), {}, {
6758
6851
  products: products.map(function (product) {
6759
6852
  return _objectSpread(_objectSpread({}, product), {}, {
6760
- product_title: _this19.buildProductTitleSnapshot(product, productMap)
6853
+ product_title: _this20.buildProductTitleSnapshot(product, productMap)
6761
6854
  });
6762
6855
  })
6763
6856
  });
@@ -6768,7 +6861,7 @@ var Server = /*#__PURE__*/function () {
6768
6861
  var _product$product_id4,
6769
6862
  _product$product,
6770
6863
  _fallbackProduct$prod,
6771
- _this20 = this;
6864
+ _this21 = this;
6772
6865
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6773
6866
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6774
6867
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6776,7 +6869,7 @@ var Server = /*#__PURE__*/function () {
6776
6869
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6777
6870
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6778
6871
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6779
- snapshot[key] = _this20.resolveProductTitleValue(ownTitle, key, currentLocale) || _this20.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6872
+ snapshot[key] = _this21.resolveProductTitleValue(ownTitle, key, currentLocale) || _this21.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6780
6873
  return snapshot;
6781
6874
  }, {});
6782
6875
  }
@@ -6874,31 +6967,31 @@ var Server = /*#__PURE__*/function () {
6874
6967
  }, {
6875
6968
  key: "enrichPaymentNamesByCode",
6876
6969
  value: function () {
6877
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6878
- var _this21 = this;
6970
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order) {
6971
+ var _this22 = this;
6879
6972
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6880
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6881
- while (1) switch (_context69.prev = _context69.next) {
6973
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6974
+ while (1) switch (_context70.prev = _context70.next) {
6882
6975
  case 0:
6883
6976
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6884
6977
  hasMissingName = payments.some(function (payment) {
6885
- return _this21.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this21.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6978
+ return _this22.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this22.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6886
6979
  });
6887
6980
  if (hasMissingName) {
6888
- _context69.next = 4;
6981
+ _context70.next = 4;
6889
6982
  break;
6890
6983
  }
6891
- return _context69.abrupt("return", order);
6984
+ return _context70.abrupt("return", order);
6892
6985
  case 4:
6893
- _context69.prev = 4;
6894
- _context69.next = 7;
6986
+ _context70.prev = 4;
6987
+ _context70.next = 7;
6895
6988
  return this.getPaymentRouteModule();
6896
6989
  case 7:
6897
- paymentModule = _context69.sent;
6898
- _context69.next = 10;
6990
+ paymentModule = _context70.sent;
6991
+ _context70.next = 10;
6899
6992
  return paymentModule.getPayMethodListAsync();
6900
6993
  case 10:
6901
- payMethods = _context69.sent;
6994
+ payMethods = _context70.sent;
6902
6995
  nameByCode = new Map();
6903
6996
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
6904
6997
  try {
@@ -6915,9 +7008,9 @@ var Server = /*#__PURE__*/function () {
6915
7008
  }
6916
7009
  hasResolvedName = false;
6917
7010
  enrichedPayments = payments.map(function (payment) {
6918
- if (!_this21.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6919
- if (!_this21.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6920
- var name = nameByCode.get(_this21.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7011
+ if (!_this22.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7012
+ if (!_this22.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7013
+ var name = nameByCode.get(_this22.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6921
7014
  if (!name) return payment;
6922
7015
  hasResolvedName = true;
6923
7016
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6925,28 +7018,28 @@ var Server = /*#__PURE__*/function () {
6925
7018
  });
6926
7019
  });
6927
7020
  if (hasResolvedName) {
6928
- _context69.next = 18;
7021
+ _context70.next = 18;
6929
7022
  break;
6930
7023
  }
6931
- return _context69.abrupt("return", order);
7024
+ return _context70.abrupt("return", order);
6932
7025
  case 18:
6933
- return _context69.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7026
+ return _context70.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6934
7027
  payments: enrichedPayments
6935
7028
  }));
6936
7029
  case 21:
6937
- _context69.prev = 21;
6938
- _context69.t0 = _context69["catch"](4);
7030
+ _context70.prev = 21;
7031
+ _context70.t0 = _context70["catch"](4);
6939
7032
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
6940
- error: _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0)
7033
+ error: _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0)
6941
7034
  });
6942
- return _context69.abrupt("return", order);
7035
+ return _context70.abrupt("return", order);
6943
7036
  case 25:
6944
7037
  case "end":
6945
- return _context69.stop();
7038
+ return _context70.stop();
6946
7039
  }
6947
- }, _callee69, this, [[4, 21]]);
7040
+ }, _callee70, this, [[4, 21]]);
6948
7041
  }));
6949
- function enrichPaymentNamesByCode(_x76) {
7042
+ function enrichPaymentNamesByCode(_x77) {
6950
7043
  return _enrichPaymentNamesByCode.apply(this, arguments);
6951
7044
  }
6952
7045
  return enrichPaymentNamesByCode;
@@ -6954,66 +7047,66 @@ var Server = /*#__PURE__*/function () {
6954
7047
  }, {
6955
7048
  key: "withLocalSmallTicketData",
6956
7049
  value: function () {
6957
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order, options) {
7050
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(order, options) {
6958
7051
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
6959
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6960
- while (1) switch (_context70.prev = _context70.next) {
7052
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7053
+ while (1) switch (_context71.prev = _context71.next) {
6961
7054
  case 0:
6962
7055
  if (this.shouldBuildSmallTicketData(order)) {
6963
- _context70.next = 2;
7056
+ _context71.next = 2;
6964
7057
  break;
6965
7058
  }
6966
- return _context70.abrupt("return", order);
7059
+ return _context71.abrupt("return", order);
6967
7060
  case 2:
6968
7061
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
6969
- _context70.next = 4;
7062
+ _context71.next = 4;
6970
7063
  break;
6971
7064
  }
6972
- return _context70.abrupt("return", order);
7065
+ return _context71.abrupt("return", order);
6973
7066
  case 4:
6974
- _context70.prev = 4;
6975
- _context70.next = 7;
7067
+ _context71.prev = 4;
7068
+ _context71.next = 7;
6976
7069
  return this.enrichPaymentNamesByCode(order);
6977
7070
  case 7:
6978
- enrichedOrder = _context70.sent;
7071
+ enrichedOrder = _context71.sent;
6979
7072
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
6980
- _context70.next = 12;
7073
+ _context71.next = 12;
6981
7074
  break;
6982
7075
  }
6983
- _context70.t0 = _options$productMap;
6984
- _context70.next = 15;
7076
+ _context71.t0 = _options$productMap;
7077
+ _context71.next = 15;
6985
7078
  break;
6986
7079
  case 12:
6987
- _context70.next = 14;
7080
+ _context71.next = 14;
6988
7081
  return this.buildSmallTicketProductMap(enrichedOrder);
6989
7082
  case 14:
6990
- _context70.t0 = _context70.sent;
7083
+ _context71.t0 = _context71.sent;
6991
7084
  case 15:
6992
- productMap = _context70.t0;
7085
+ productMap = _context71.t0;
6993
7086
  smallTicketData = buildSmallTicketData({
6994
7087
  order: enrichedOrder,
6995
7088
  shopInfo: this.getSmallTicketShopInfo(),
6996
7089
  productMap: productMap
6997
7090
  });
6998
- return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7091
+ return _context71.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6999
7092
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7000
7093
  small_ticket_data: smallTicketData
7001
7094
  })
7002
7095
  }));
7003
7096
  case 20:
7004
- _context70.prev = 20;
7005
- _context70.t1 = _context70["catch"](4);
7097
+ _context71.prev = 20;
7098
+ _context71.t1 = _context71["catch"](4);
7006
7099
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7007
- error: _context70.t1 instanceof Error ? _context70.t1.message : String(_context70.t1)
7100
+ error: _context71.t1 instanceof Error ? _context71.t1.message : String(_context71.t1)
7008
7101
  });
7009
- return _context70.abrupt("return", order);
7102
+ return _context71.abrupt("return", order);
7010
7103
  case 24:
7011
7104
  case "end":
7012
- return _context70.stop();
7105
+ return _context71.stop();
7013
7106
  }
7014
- }, _callee70, this, [[4, 20]]);
7107
+ }, _callee71, this, [[4, 20]]);
7015
7108
  }));
7016
- function withLocalSmallTicketData(_x77, _x78) {
7109
+ function withLocalSmallTicketData(_x78, _x79) {
7017
7110
  return _withLocalSmallTicketData.apply(this, arguments);
7018
7111
  }
7019
7112
  return withLocalSmallTicketData;
@@ -7075,22 +7168,22 @@ var Server = /*#__PURE__*/function () {
7075
7168
  }, {
7076
7169
  key: "handleUpdateLocalOrdersBatch",
7077
7170
  value: (function () {
7078
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
7171
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(orderIds) {
7079
7172
  var _this$app18;
7080
7173
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
7081
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7082
- while (1) switch (_context71.prev = _context71.next) {
7174
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7175
+ while (1) switch (_context72.prev = _context72.next) {
7083
7176
  case 0:
7084
7177
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
7085
7178
  count: orderIds.length,
7086
7179
  orderIds: orderIds
7087
7180
  });
7088
7181
  if (this.order) {
7089
- _context71.next = 4;
7182
+ _context72.next = 4;
7090
7183
  break;
7091
7184
  }
7092
7185
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
7093
- return _context71.abrupt("return", {
7186
+ return _context72.abrupt("return", {
7094
7187
  code: 500,
7095
7188
  status: false,
7096
7189
  message: 'Order 模块未注册',
@@ -7098,11 +7191,11 @@ var Server = /*#__PURE__*/function () {
7098
7191
  });
7099
7192
  case 4:
7100
7193
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
7101
- _context71.next = 7;
7194
+ _context72.next = 7;
7102
7195
  break;
7103
7196
  }
7104
7197
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
7105
- return _context71.abrupt("return", {
7198
+ return _context72.abrupt("return", {
7106
7199
  code: 500,
7107
7200
  status: false,
7108
7201
  message: 'app.request 不可用',
@@ -7125,21 +7218,21 @@ var Server = /*#__PURE__*/function () {
7125
7218
  _iterator13.f();
7126
7219
  }
7127
7220
  fetched = [];
7128
- _context71.prev = 11;
7129
- _context71.next = 14;
7221
+ _context72.prev = 11;
7222
+ _context72.next = 14;
7130
7223
  return this.order.fetchOrdersByHttp(orderIds);
7131
7224
  case 14:
7132
- fetched = _context71.sent;
7133
- _context71.next = 22;
7225
+ fetched = _context72.sent;
7226
+ _context72.next = 22;
7134
7227
  break;
7135
7228
  case 17:
7136
- _context71.prev = 17;
7137
- _context71.t0 = _context71["catch"](11);
7138
- message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7229
+ _context72.prev = 17;
7230
+ _context72.t0 = _context72["catch"](11);
7231
+ message = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7139
7232
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
7140
7233
  message: message
7141
7234
  });
7142
- return _context71.abrupt("return", {
7235
+ return _context72.abrupt("return", {
7143
7236
  code: 500,
7144
7237
  status: false,
7145
7238
  message: message,
@@ -7149,36 +7242,36 @@ var Server = /*#__PURE__*/function () {
7149
7242
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
7150
7243
  fetchedMap = new Map();
7151
7244
  _iterator14 = _createForOfIteratorHelper(fetched);
7152
- _context71.prev = 24;
7245
+ _context72.prev = 24;
7153
7246
  _iterator14.s();
7154
7247
  case 26:
7155
7248
  if ((_step14 = _iterator14.n()).done) {
7156
- _context71.next = 34;
7249
+ _context72.next = 34;
7157
7250
  break;
7158
7251
  }
7159
7252
  order = _step14.value;
7160
7253
  oid = order === null || order === void 0 ? void 0 : order.order_id;
7161
7254
  if (!(oid === undefined || oid === null)) {
7162
- _context71.next = 31;
7255
+ _context72.next = 31;
7163
7256
  break;
7164
7257
  }
7165
- return _context71.abrupt("continue", 32);
7258
+ return _context72.abrupt("continue", 32);
7166
7259
  case 31:
7167
7260
  fetchedMap.set(String(oid), order);
7168
7261
  case 32:
7169
- _context71.next = 26;
7262
+ _context72.next = 26;
7170
7263
  break;
7171
7264
  case 34:
7172
- _context71.next = 39;
7265
+ _context72.next = 39;
7173
7266
  break;
7174
7267
  case 36:
7175
- _context71.prev = 36;
7176
- _context71.t1 = _context71["catch"](24);
7177
- _iterator14.e(_context71.t1);
7268
+ _context72.prev = 36;
7269
+ _context72.t1 = _context72["catch"](24);
7270
+ _iterator14.e(_context72.t1);
7178
7271
  case 39:
7179
- _context71.prev = 39;
7272
+ _context72.prev = 39;
7180
7273
  _iterator14.f();
7181
- return _context71.finish(39);
7274
+ return _context72.finish(39);
7182
7275
  case 42:
7183
7276
  freshOrders = [];
7184
7277
  succeedIds = [];
@@ -7204,23 +7297,23 @@ var Server = /*#__PURE__*/function () {
7204
7297
  _iterator15.f();
7205
7298
  }
7206
7299
  if (!(freshOrders.length > 0)) {
7207
- _context71.next = 58;
7300
+ _context72.next = 58;
7208
7301
  break;
7209
7302
  }
7210
- _context71.prev = 48;
7211
- _context71.next = 51;
7303
+ _context72.prev = 48;
7304
+ _context72.next = 51;
7212
7305
  return this.order.upsertOrdersFromRemote(freshOrders);
7213
7306
  case 51:
7214
- _context71.next = 58;
7307
+ _context72.next = 58;
7215
7308
  break;
7216
7309
  case 53:
7217
- _context71.prev = 53;
7218
- _context71.t2 = _context71["catch"](48);
7219
- _message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
7310
+ _context72.prev = 53;
7311
+ _context72.t2 = _context72["catch"](48);
7312
+ _message2 = _context72.t2 instanceof Error ? _context72.t2.message : String(_context72.t2);
7220
7313
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
7221
7314
  message: _message2
7222
7315
  });
7223
- return _context71.abrupt("return", {
7316
+ return _context72.abrupt("return", {
7224
7317
  code: 500,
7225
7318
  status: false,
7226
7319
  message: _message2,
@@ -7239,7 +7332,7 @@ var Server = /*#__PURE__*/function () {
7239
7332
  insertedCount: inserted.length,
7240
7333
  failedCount: failed.length
7241
7334
  });
7242
- return _context71.abrupt("return", {
7335
+ return _context72.abrupt("return", {
7243
7336
  code: 200,
7244
7337
  status: true,
7245
7338
  message: '',
@@ -7251,11 +7344,11 @@ var Server = /*#__PURE__*/function () {
7251
7344
  });
7252
7345
  case 62:
7253
7346
  case "end":
7254
- return _context71.stop();
7347
+ return _context72.stop();
7255
7348
  }
7256
- }, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7349
+ }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7257
7350
  }));
7258
- function handleUpdateLocalOrdersBatch(_x79) {
7351
+ function handleUpdateLocalOrdersBatch(_x80) {
7259
7352
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7260
7353
  }
7261
7354
  return handleUpdateLocalOrdersBatch;
@@ -7499,10 +7592,10 @@ var Server = /*#__PURE__*/function () {
7499
7592
  value: function extractBackendErrorResponse(error) {
7500
7593
  var _error$response3,
7501
7594
  _error$response4,
7502
- _this22 = this;
7595
+ _this23 = this;
7503
7596
  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];
7504
7597
  return candidates.find(function (candidate) {
7505
- return _this22.isExplicitBackendErrorResponse(candidate);
7598
+ return _this23.isExplicitBackendErrorResponse(candidate);
7506
7599
  }) || null;
7507
7600
  }
7508
7601
  }, {
@@ -7621,16 +7714,16 @@ var Server = /*#__PURE__*/function () {
7621
7714
  }, {
7622
7715
  key: "recomputeAndNotifyFloorPlanQuery",
7623
7716
  value: (function () {
7624
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7717
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7625
7718
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7626
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7627
- while (1) switch (_context72.prev = _context72.next) {
7719
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7720
+ while (1) switch (_context73.prev = _context73.next) {
7628
7721
  case 0:
7629
7722
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7630
- _context72.next = 2;
7723
+ _context73.next = 2;
7631
7724
  break;
7632
7725
  }
7633
- return _context72.abrupt("return");
7726
+ return _context73.abrupt("return");
7634
7727
  case 2:
7635
7728
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7636
7729
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -7660,9 +7753,9 @@ var Server = /*#__PURE__*/function () {
7660
7753
  }
7661
7754
  case 5:
7662
7755
  case "end":
7663
- return _context72.stop();
7756
+ return _context73.stop();
7664
7757
  }
7665
- }, _callee72, this);
7758
+ }, _callee73, this);
7666
7759
  }));
7667
7760
  function recomputeAndNotifyFloorPlanQuery() {
7668
7761
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7692,20 +7785,20 @@ var Server = /*#__PURE__*/function () {
7692
7785
  * filter 逻辑暂为 mock,仅记录参数
7693
7786
  */
7694
7787
  function () {
7695
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7788
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7696
7789
  var rawList, result;
7697
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7698
- while (1) switch (_context73.prev = _context73.next) {
7790
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7791
+ while (1) switch (_context74.prev = _context74.next) {
7699
7792
  case 0:
7700
7793
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7701
7794
  data: data
7702
7795
  });
7703
7796
  if (this.order) {
7704
- _context73.next = 4;
7797
+ _context74.next = 4;
7705
7798
  break;
7706
7799
  }
7707
7800
  this.logError('computeOrderQueryResult: Order 模块未注册');
7708
- return _context73.abrupt("return", {
7801
+ return _context74.abrupt("return", {
7709
7802
  code: 500,
7710
7803
  message: 'Order 模块未注册',
7711
7804
  data: {
@@ -7735,7 +7828,7 @@ var Server = /*#__PURE__*/function () {
7735
7828
  skip: result.skip,
7736
7829
  rejected: result.rejected
7737
7830
  });
7738
- return _context73.abrupt("return", {
7831
+ return _context74.abrupt("return", {
7739
7832
  code: 200,
7740
7833
  data: result,
7741
7834
  message: '',
@@ -7743,11 +7836,11 @@ var Server = /*#__PURE__*/function () {
7743
7836
  });
7744
7837
  case 10:
7745
7838
  case "end":
7746
- return _context73.stop();
7839
+ return _context74.stop();
7747
7840
  }
7748
- }, _callee73, this);
7841
+ }, _callee74, this);
7749
7842
  }));
7750
- function computeOrderQueryResult(_x80) {
7843
+ function computeOrderQueryResult(_x81) {
7751
7844
  return _computeOrderQueryResult.apply(this, arguments);
7752
7845
  }
7753
7846
  return computeOrderQueryResult;
@@ -7760,17 +7853,17 @@ var Server = /*#__PURE__*/function () {
7760
7853
  }, {
7761
7854
  key: "computeBookingQueryResult",
7762
7855
  value: (function () {
7763
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7856
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data) {
7764
7857
  var rawOrders, result;
7765
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7766
- while (1) switch (_context74.prev = _context74.next) {
7858
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7859
+ while (1) switch (_context75.prev = _context75.next) {
7767
7860
  case 0:
7768
7861
  if (this.order) {
7769
- _context74.next = 3;
7862
+ _context75.next = 3;
7770
7863
  break;
7771
7864
  }
7772
7865
  this.logError('computeBookingQueryResult: Order 模块未注册');
7773
- return _context74.abrupt("return", {
7866
+ return _context75.abrupt("return", {
7774
7867
  code: 500,
7775
7868
  message: 'Order 模块未注册',
7776
7869
  data: {
@@ -7789,7 +7882,7 @@ var Server = /*#__PURE__*/function () {
7789
7882
  size: result.size,
7790
7883
  skip: result.skip
7791
7884
  });
7792
- return _context74.abrupt("return", {
7885
+ return _context75.abrupt("return", {
7793
7886
  code: 200,
7794
7887
  data: result,
7795
7888
  message: '',
@@ -7797,11 +7890,11 @@ var Server = /*#__PURE__*/function () {
7797
7890
  });
7798
7891
  case 8:
7799
7892
  case "end":
7800
- return _context74.stop();
7893
+ return _context75.stop();
7801
7894
  }
7802
- }, _callee74, this);
7895
+ }, _callee75, this);
7803
7896
  }));
7804
- function computeBookingQueryResult(_x81) {
7897
+ function computeBookingQueryResult(_x82) {
7805
7898
  return _computeBookingQueryResult.apply(this, arguments);
7806
7899
  }
7807
7900
  return computeBookingQueryResult;
@@ -7860,12 +7953,12 @@ var Server = /*#__PURE__*/function () {
7860
7953
  }, {
7861
7954
  key: "computeProductQueryResult",
7862
7955
  value: (function () {
7863
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
7956
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(context, options) {
7864
7957
  var _menu_list_ids$length3,
7865
- _this23 = this;
7958
+ _this24 = this;
7866
7959
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
7867
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7868
- while (1) switch (_context75.prev = _context75.next) {
7960
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7961
+ while (1) switch (_context76.prev = _context76.next) {
7869
7962
  case 0:
7870
7963
  tTotal = performance.now();
7871
7964
  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;
@@ -7891,10 +7984,10 @@ var Server = /*#__PURE__*/function () {
7891
7984
  // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
7892
7985
  startupPreloadTask = this.startupModulePreloadInFlight;
7893
7986
  if (!startupPreloadTask) {
7894
- _context75.next = 8;
7987
+ _context76.next = 8;
7895
7988
  break;
7896
7989
  }
7897
- _context75.next = 8;
7990
+ _context76.next = 8;
7898
7991
  return startupPreloadTask;
7899
7992
  case 8:
7900
7993
  // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
@@ -7906,28 +7999,28 @@ var Server = /*#__PURE__*/function () {
7906
7999
  strategy_context: strategy_context
7907
8000
  });
7908
8001
  if (this.products) {
7909
- _context75.next = 12;
8002
+ _context76.next = 12;
7910
8003
  break;
7911
8004
  }
7912
8005
  this.logError('computeProductQueryResult: Products 模块未注册');
7913
- return _context75.abrupt("return", {
8006
+ return _context76.abrupt("return", {
7914
8007
  message: 'Products 模块未注册',
7915
8008
  data: this.buildProductQueryResultPayload([], 0)
7916
8009
  });
7917
8010
  case 12:
7918
8011
  if (!(queryIds.length > 0)) {
7919
- _context75.next = 24;
8012
+ _context76.next = 24;
7920
8013
  break;
7921
8014
  }
7922
8015
  uniqueIds = Array.from(new Set(queryIds));
7923
8016
  _tPrice = performance.now();
7924
- _context75.next = 17;
8017
+ _context76.next = 17;
7925
8018
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7926
8019
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7927
8020
  productIds: uniqueIds
7928
8021
  });
7929
8022
  case 17:
7930
- productsWithPrice = _context75.sent;
8023
+ productsWithPrice = _context76.sent;
7931
8024
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7932
8025
  count: productsWithPrice.length,
7933
8026
  ids: uniqueIds
@@ -7947,7 +8040,7 @@ var Server = /*#__PURE__*/function () {
7947
8040
  ids: uniqueIds,
7948
8041
  count: extensionFilteredProducts.length
7949
8042
  });
7950
- return _context75.abrupt("return", {
8043
+ return _context76.abrupt("return", {
7951
8044
  code: 200,
7952
8045
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7953
8046
  message: '',
@@ -7955,17 +8048,17 @@ var Server = /*#__PURE__*/function () {
7955
8048
  });
7956
8049
  case 24:
7957
8050
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7958
- _context75.next = 36;
8051
+ _context76.next = 36;
7959
8052
  break;
7960
8053
  }
7961
8054
  pid = Number(product_id);
7962
8055
  _tPrice2 = performance.now();
7963
- _context75.next = 29;
8056
+ _context76.next = 29;
7964
8057
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7965
8058
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7966
8059
  });
7967
8060
  case 29:
7968
- allProductsWithPrice = _context75.sent;
8061
+ allProductsWithPrice = _context76.sent;
7969
8062
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7970
8063
  count: allProductsWithPrice.length,
7971
8064
  productId: pid
@@ -7985,7 +8078,7 @@ var Server = /*#__PURE__*/function () {
7985
8078
  productId: pid,
7986
8079
  found: !!item
7987
8080
  });
7988
- return _context75.abrupt("return", {
8081
+ return _context76.abrupt("return", {
7989
8082
  code: 200,
7990
8083
  data: item,
7991
8084
  message: item ? '' : '商品不存在或未发布',
@@ -7993,16 +8086,16 @@ var Server = /*#__PURE__*/function () {
7993
8086
  });
7994
8087
  case 36:
7995
8088
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7996
- _context75.next = 56;
8089
+ _context76.next = 56;
7997
8090
  break;
7998
8091
  }
7999
8092
  _tPrice3 = performance.now();
8000
- _context75.next = 40;
8093
+ _context76.next = 40;
8001
8094
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8002
8095
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8003
8096
  });
8004
8097
  case 40:
8005
- _filteredProducts2 = _context75.sent;
8098
+ _filteredProducts2 = _context76.sent;
8006
8099
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
8007
8100
  count: _filteredProducts2.length,
8008
8101
  extension_type: extension_type
@@ -8041,7 +8134,7 @@ var Server = /*#__PURE__*/function () {
8041
8134
  filteredCount: _filteredProducts2.length,
8042
8135
  extension_type: extension_type
8043
8136
  });
8044
- return _context75.abrupt("return", {
8137
+ return _context76.abrupt("return", {
8045
8138
  code: 200,
8046
8139
  data: this.buildProductQueryResultPayload(_filteredProducts2),
8047
8140
  message: '',
@@ -8049,50 +8142,50 @@ var Server = /*#__PURE__*/function () {
8049
8142
  });
8050
8143
  case 56:
8051
8144
  if (this.menu) {
8052
- _context75.next = 59;
8145
+ _context76.next = 59;
8053
8146
  break;
8054
8147
  }
8055
8148
  this.logError('computeProductQueryResult: Menu 模块未注册');
8056
- return _context75.abrupt("return", {
8149
+ return _context76.abrupt("return", {
8057
8150
  message: 'Menu 模块未注册',
8058
8151
  data: this.buildProductQueryResultPayload([], 0)
8059
8152
  });
8060
8153
  case 59:
8061
8154
  if (this.schedule) {
8062
- _context75.next = 62;
8155
+ _context76.next = 62;
8063
8156
  break;
8064
8157
  }
8065
8158
  this.logError('computeProductQueryResult: Schedule 模块未注册');
8066
- return _context75.abrupt("return", {
8159
+ return _context76.abrupt("return", {
8067
8160
  message: 'Schedule 模块未注册',
8068
8161
  data: this.buildProductQueryResultPayload([], 0)
8069
8162
  });
8070
8163
  case 62:
8071
8164
  activeMenuList = [];
8072
8165
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
8073
- _context75.next = 75;
8166
+ _context76.next = 75;
8074
8167
  break;
8075
8168
  }
8076
8169
  tMenu = performance.now();
8077
8170
  getActiveMenus = function getActiveMenus() {
8078
- return _this23.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8079
- var _this23$schedule;
8080
- return ((_this23$schedule = _this23.schedule) === null || _this23$schedule === void 0 ? void 0 : _this23$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8171
+ return _this24.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8172
+ var _this24$schedule;
8173
+ return ((_this24$schedule = _this24.schedule) === null || _this24$schedule === void 0 ? void 0 : _this24$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8081
8174
  });
8082
8175
  };
8083
8176
  activeMenuList = getActiveMenus();
8084
- _context75.t0 = !activeMenuList.length;
8085
- if (!_context75.t0) {
8086
- _context75.next = 72;
8177
+ _context76.t0 = !activeMenuList.length;
8178
+ if (!_context76.t0) {
8179
+ _context76.next = 72;
8087
8180
  break;
8088
8181
  }
8089
- _context75.next = 71;
8182
+ _context76.next = 71;
8090
8183
  return this.refreshMenuScheduleCacheAfterEmptyResult();
8091
8184
  case 71:
8092
- _context75.t0 = _context75.sent;
8185
+ _context76.t0 = _context76.sent;
8093
8186
  case 72:
8094
- if (!_context75.t0) {
8095
- _context75.next = 74;
8187
+ if (!_context76.t0) {
8188
+ _context76.next = 74;
8096
8189
  break;
8097
8190
  }
8098
8191
  activeMenuList = getActiveMenus();
@@ -8112,22 +8205,22 @@ var Server = /*#__PURE__*/function () {
8112
8205
  });
8113
8206
  tPrice = performance.now();
8114
8207
  if (!(scopedProductIds.length > 0)) {
8115
- _context75.next = 86;
8208
+ _context76.next = 86;
8116
8209
  break;
8117
8210
  }
8118
- _context75.next = 83;
8211
+ _context76.next = 83;
8119
8212
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8120
8213
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8121
8214
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
8122
8215
  });
8123
8216
  case 83:
8124
- _context75.t1 = _context75.sent;
8125
- _context75.next = 87;
8217
+ _context76.t1 = _context76.sent;
8218
+ _context76.next = 87;
8126
8219
  break;
8127
8220
  case 86:
8128
- _context75.t1 = [];
8221
+ _context76.t1 = [];
8129
8222
  case 87:
8130
- filteredProducts = _context75.t1;
8223
+ filteredProducts = _context76.t1;
8131
8224
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
8132
8225
  count: filteredProducts.length,
8133
8226
  scopedProductCount: scopedProductIds.length
@@ -8168,7 +8261,7 @@ var Server = /*#__PURE__*/function () {
8168
8261
  filteredCount: filteredProducts.length,
8169
8262
  activeMenuCount: activeMenuList.length
8170
8263
  });
8171
- return _context75.abrupt("return", {
8264
+ return _context76.abrupt("return", {
8172
8265
  code: 200,
8173
8266
  data: this.buildProductQueryResultPayload(filteredProducts),
8174
8267
  message: '',
@@ -8176,11 +8269,11 @@ var Server = /*#__PURE__*/function () {
8176
8269
  });
8177
8270
  case 103:
8178
8271
  case "end":
8179
- return _context75.stop();
8272
+ return _context76.stop();
8180
8273
  }
8181
- }, _callee75, this);
8274
+ }, _callee76, this);
8182
8275
  }));
8183
- function computeProductQueryResult(_x82, _x83) {
8276
+ function computeProductQueryResult(_x83, _x84) {
8184
8277
  return _computeProductQueryResult.apply(this, arguments);
8185
8278
  }
8186
8279
  return computeProductQueryResult;
@@ -8216,72 +8309,72 @@ var Server = /*#__PURE__*/function () {
8216
8309
  }, {
8217
8310
  key: "recomputeAndNotifyProductQuery",
8218
8311
  value: (function () {
8219
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
8312
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(options) {
8220
8313
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
8221
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8222
- while (1) switch (_context76.prev = _context76.next) {
8314
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8315
+ while (1) switch (_context77.prev = _context77.next) {
8223
8316
  case 0:
8224
8317
  if (!(this.productQuerySubscribers.size === 0)) {
8225
- _context76.next = 2;
8318
+ _context77.next = 2;
8226
8319
  break;
8227
8320
  }
8228
- return _context76.abrupt("return");
8321
+ return _context77.abrupt("return");
8229
8322
  case 2:
8230
8323
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
8231
8324
  subscriberCount: this.productQuerySubscribers.size,
8232
8325
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8233
8326
  });
8234
8327
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
8235
- _context76.prev = 4;
8328
+ _context77.prev = 4;
8236
8329
  _iterator18.s();
8237
8330
  case 6:
8238
8331
  if ((_step18 = _iterator18.n()).done) {
8239
- _context76.next = 22;
8332
+ _context77.next = 22;
8240
8333
  break;
8241
8334
  }
8242
8335
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
8243
- _context76.prev = 8;
8244
- _context76.next = 11;
8336
+ _context77.prev = 8;
8337
+ _context77.next = 11;
8245
8338
  return this.computeProductQueryResult(subscriber.context, {
8246
8339
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8247
8340
  });
8248
8341
  case 11:
8249
- result = _context76.sent;
8342
+ result = _context77.sent;
8250
8343
  subscriber.callback(result);
8251
8344
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
8252
8345
  subscriberId: subscriberId
8253
8346
  });
8254
- _context76.next = 20;
8347
+ _context77.next = 20;
8255
8348
  break;
8256
8349
  case 16:
8257
- _context76.prev = 16;
8258
- _context76.t0 = _context76["catch"](8);
8259
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8350
+ _context77.prev = 16;
8351
+ _context77.t0 = _context77["catch"](8);
8352
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8260
8353
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
8261
8354
  subscriberId: subscriberId,
8262
8355
  error: errorMessage
8263
8356
  });
8264
8357
  case 20:
8265
- _context76.next = 6;
8358
+ _context77.next = 6;
8266
8359
  break;
8267
8360
  case 22:
8268
- _context76.next = 27;
8361
+ _context77.next = 27;
8269
8362
  break;
8270
8363
  case 24:
8271
- _context76.prev = 24;
8272
- _context76.t1 = _context76["catch"](4);
8273
- _iterator18.e(_context76.t1);
8364
+ _context77.prev = 24;
8365
+ _context77.t1 = _context77["catch"](4);
8366
+ _iterator18.e(_context77.t1);
8274
8367
  case 27:
8275
- _context76.prev = 27;
8368
+ _context77.prev = 27;
8276
8369
  _iterator18.f();
8277
- return _context76.finish(27);
8370
+ return _context77.finish(27);
8278
8371
  case 30:
8279
8372
  case "end":
8280
- return _context76.stop();
8373
+ return _context77.stop();
8281
8374
  }
8282
- }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8375
+ }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8283
8376
  }));
8284
- function recomputeAndNotifyProductQuery(_x84) {
8377
+ function recomputeAndNotifyProductQuery(_x85) {
8285
8378
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8286
8379
  }
8287
8380
  return recomputeAndNotifyProductQuery;
@@ -8293,16 +8386,16 @@ var Server = /*#__PURE__*/function () {
8293
8386
  }, {
8294
8387
  key: "recomputeAndNotifyOrderQuery",
8295
8388
  value: (function () {
8296
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8389
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8297
8390
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8298
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8299
- while (1) switch (_context77.prev = _context77.next) {
8391
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8392
+ while (1) switch (_context78.prev = _context78.next) {
8300
8393
  case 0:
8301
8394
  if (!(this.orderQuerySubscribers.size === 0)) {
8302
- _context77.next = 2;
8395
+ _context78.next = 2;
8303
8396
  break;
8304
8397
  }
8305
- return _context77.abrupt("return");
8398
+ return _context78.abrupt("return");
8306
8399
  case 2:
8307
8400
  notifyStartAt = Date.now();
8308
8401
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -8310,20 +8403,20 @@ var Server = /*#__PURE__*/function () {
8310
8403
  notifyStartAt: new Date(notifyStartAt).toISOString()
8311
8404
  });
8312
8405
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8313
- _context77.prev = 5;
8406
+ _context78.prev = 5;
8314
8407
  _iterator19.s();
8315
8408
  case 7:
8316
8409
  if ((_step19 = _iterator19.n()).done) {
8317
- _context77.next = 27;
8410
+ _context78.next = 27;
8318
8411
  break;
8319
8412
  }
8320
8413
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8321
- _context77.prev = 9;
8414
+ _context78.prev = 9;
8322
8415
  computeStartAt = Date.now();
8323
- _context77.next = 13;
8416
+ _context78.next = 13;
8324
8417
  return this.computeOrderQueryResult(subscriber.context);
8325
8418
  case 13:
8326
- result = _context77.sent;
8419
+ result = _context78.sent;
8327
8420
  computeEndAt = Date.now();
8328
8421
  callbackStartAt = Date.now();
8329
8422
  subscriber.callback(result);
@@ -8334,30 +8427,30 @@ var Server = /*#__PURE__*/function () {
8334
8427
  callbackDurationMs: callbackEndAt - callbackStartAt,
8335
8428
  totalDurationMs: callbackEndAt - computeStartAt
8336
8429
  });
8337
- _context77.next = 25;
8430
+ _context78.next = 25;
8338
8431
  break;
8339
8432
  case 21:
8340
- _context77.prev = 21;
8341
- _context77.t0 = _context77["catch"](9);
8342
- errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8433
+ _context78.prev = 21;
8434
+ _context78.t0 = _context78["catch"](9);
8435
+ errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8343
8436
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
8344
8437
  subscriberId: subscriberId,
8345
8438
  error: errorMessage
8346
8439
  });
8347
8440
  case 25:
8348
- _context77.next = 7;
8441
+ _context78.next = 7;
8349
8442
  break;
8350
8443
  case 27:
8351
- _context77.next = 32;
8444
+ _context78.next = 32;
8352
8445
  break;
8353
8446
  case 29:
8354
- _context77.prev = 29;
8355
- _context77.t1 = _context77["catch"](5);
8356
- _iterator19.e(_context77.t1);
8447
+ _context78.prev = 29;
8448
+ _context78.t1 = _context78["catch"](5);
8449
+ _iterator19.e(_context78.t1);
8357
8450
  case 32:
8358
- _context77.prev = 32;
8451
+ _context78.prev = 32;
8359
8452
  _iterator19.f();
8360
- return _context77.finish(32);
8453
+ return _context78.finish(32);
8361
8454
  case 35:
8362
8455
  notifyEndAt = Date.now();
8363
8456
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8366,9 +8459,9 @@ var Server = /*#__PURE__*/function () {
8366
8459
  });
8367
8460
  case 37:
8368
8461
  case "end":
8369
- return _context77.stop();
8462
+ return _context78.stop();
8370
8463
  }
8371
- }, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
8464
+ }, _callee78, this, [[5, 29, 32, 35], [9, 21]]);
8372
8465
  }));
8373
8466
  function recomputeAndNotifyOrderQuery() {
8374
8467
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8386,7 +8479,7 @@ var Server = /*#__PURE__*/function () {
8386
8479
  }, {
8387
8480
  key: "notifySalesSearchSubscribers",
8388
8481
  value: function notifySalesSearchSubscribers(payload) {
8389
- var _this24 = this;
8482
+ var _this25 = this;
8390
8483
  if (this.salesSearchSubscribers.size === 0) return;
8391
8484
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8392
8485
  if (changedOrders.length === 0) {
@@ -8404,21 +8497,21 @@ var Server = /*#__PURE__*/function () {
8404
8497
  subscriber = _step20$value[1];
8405
8498
  try {
8406
8499
  var changedVisibleOrders = changedOrders.filter(function (order) {
8407
- var orderId = _this24.getSalesSearchOrderId(order);
8500
+ var orderId = _this25.getSalesSearchOrderId(order);
8408
8501
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8409
8502
  });
8410
8503
  if (changedVisibleOrders.length === 0) {
8411
8504
  return 1; // continue
8412
8505
  }
8413
- subscriber.callback(_this24.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8414
- _this24.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8506
+ subscriber.callback(_this25.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8507
+ _this25.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8415
8508
  subscriberId: subscriberId,
8416
8509
  kind: subscriber.kind,
8417
8510
  count: changedVisibleOrders.length
8418
8511
  });
8419
8512
  } catch (error) {
8420
8513
  var errorMessage = error instanceof Error ? error.message : String(error);
8421
- _this24.logError('notifySalesSearchSubscribers: 推送失败', {
8514
+ _this25.logError('notifySalesSearchSubscribers: 推送失败', {
8422
8515
  subscriberId: subscriberId,
8423
8516
  error: errorMessage
8424
8517
  });
@@ -8509,67 +8602,67 @@ var Server = /*#__PURE__*/function () {
8509
8602
  }, {
8510
8603
  key: "recomputeAndNotifyBookingQuery",
8511
8604
  value: (function () {
8512
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8605
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8513
8606
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8514
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8515
- while (1) switch (_context78.prev = _context78.next) {
8607
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8608
+ while (1) switch (_context79.prev = _context79.next) {
8516
8609
  case 0:
8517
8610
  if (!(this.bookingQuerySubscribers.size === 0)) {
8518
- _context78.next = 2;
8611
+ _context79.next = 2;
8519
8612
  break;
8520
8613
  }
8521
- return _context78.abrupt("return");
8614
+ return _context79.abrupt("return");
8522
8615
  case 2:
8523
8616
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8524
8617
  subscriberCount: this.bookingQuerySubscribers.size
8525
8618
  });
8526
8619
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8527
- _context78.prev = 4;
8620
+ _context79.prev = 4;
8528
8621
  _iterator21.s();
8529
8622
  case 6:
8530
8623
  if ((_step21 = _iterator21.n()).done) {
8531
- _context78.next = 22;
8624
+ _context79.next = 22;
8532
8625
  break;
8533
8626
  }
8534
8627
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8535
- _context78.prev = 8;
8536
- _context78.next = 11;
8628
+ _context79.prev = 8;
8629
+ _context79.next = 11;
8537
8630
  return this.computeBookingQueryResult(subscriber.context);
8538
8631
  case 11:
8539
- result = _context78.sent;
8632
+ result = _context79.sent;
8540
8633
  subscriber.callback(result);
8541
8634
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8542
8635
  subscriberId: subscriberId
8543
8636
  });
8544
- _context78.next = 20;
8637
+ _context79.next = 20;
8545
8638
  break;
8546
8639
  case 16:
8547
- _context78.prev = 16;
8548
- _context78.t0 = _context78["catch"](8);
8549
- errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8640
+ _context79.prev = 16;
8641
+ _context79.t0 = _context79["catch"](8);
8642
+ errorMessage = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
8550
8643
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8551
8644
  subscriberId: subscriberId,
8552
8645
  error: errorMessage
8553
8646
  });
8554
8647
  case 20:
8555
- _context78.next = 6;
8648
+ _context79.next = 6;
8556
8649
  break;
8557
8650
  case 22:
8558
- _context78.next = 27;
8651
+ _context79.next = 27;
8559
8652
  break;
8560
8653
  case 24:
8561
- _context78.prev = 24;
8562
- _context78.t1 = _context78["catch"](4);
8563
- _iterator21.e(_context78.t1);
8654
+ _context79.prev = 24;
8655
+ _context79.t1 = _context79["catch"](4);
8656
+ _iterator21.e(_context79.t1);
8564
8657
  case 27:
8565
- _context78.prev = 27;
8658
+ _context79.prev = 27;
8566
8659
  _iterator21.f();
8567
- return _context78.finish(27);
8660
+ return _context79.finish(27);
8568
8661
  case 30:
8569
8662
  case "end":
8570
- return _context78.stop();
8663
+ return _context79.stop();
8571
8664
  }
8572
- }, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
8665
+ }, _callee79, this, [[4, 24, 27, 30], [8, 16]]);
8573
8666
  }));
8574
8667
  function recomputeAndNotifyBookingQuery() {
8575
8668
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);