@pisell/pisellos 2.2.291 → 2.2.293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +108 -65
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  8. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  9. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  10. package/dist/modules/BookingContext/index.d.ts +3 -0
  11. package/dist/modules/BookingContext/index.js +42 -13
  12. package/dist/modules/BookingContext/types.d.ts +4 -4
  13. package/dist/modules/BookingContext/types.js +3 -3
  14. package/dist/modules/OpenData/types.d.ts +1 -0
  15. package/dist/modules/Order/index.d.ts +18 -3
  16. package/dist/modules/Order/index.js +885 -485
  17. package/dist/modules/Order/salesNotes.d.ts +31 -0
  18. package/dist/modules/Order/salesNotes.js +492 -0
  19. package/dist/modules/Order/types.d.ts +93 -5
  20. package/dist/modules/Order/types.js +5 -0
  21. package/dist/modules/Order/utils.d.ts +12 -0
  22. package/dist/modules/Order/utils.js +96 -31
  23. package/dist/modules/Product/types.d.ts +2 -0
  24. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  25. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  26. package/dist/modules/ProductList/index.d.ts +18 -3
  27. package/dist/modules/ProductList/index.js +220 -38
  28. package/dist/modules/ProductList/types.d.ts +10 -0
  29. package/dist/modules/Quotation/index.d.ts +22 -0
  30. package/dist/modules/Quotation/index.js +293 -28
  31. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  32. package/dist/modules/ResourcePlanner/index.js +1 -180
  33. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  34. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  35. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  36. package/dist/modules/ResourcePlanner/planner.js +2111 -958
  37. package/dist/modules/ResourcePlanner/types.d.ts +359 -187
  38. package/dist/modules/ResourcePlanner/types.js +33 -1
  39. package/dist/plugins/request.d.ts +1 -0
  40. package/dist/server/index.d.ts +17 -2
  41. package/dist/server/index.js +1134 -932
  42. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  43. package/dist/server/modules/floor-plan/index.js +240 -98
  44. package/dist/server/modules/menu/index.js +48 -23
  45. package/dist/server/modules/order/index.d.ts +17 -7
  46. package/dist/server/modules/order/index.js +419 -207
  47. package/dist/server/modules/products/index.d.ts +10 -4
  48. package/dist/server/modules/products/index.js +177 -84
  49. package/dist/server/modules/resource/index.js +21 -13
  50. package/dist/server/utils/product.d.ts +1 -1
  51. package/dist/server/utils/product.js +186 -22
  52. package/dist/server/utils/small-ticket.d.ts +9 -1
  53. package/dist/server/utils/small-ticket.js +131 -84
  54. package/dist/solution/BaseSales/index.d.ts +26 -3
  55. package/dist/solution/BaseSales/index.js +1384 -905
  56. package/dist/solution/BaseSales/types.d.ts +2 -0
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  58. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
  59. package/dist/solution/BaseSales/utils.js +6 -3
  60. package/dist/solution/BookingByStep/index.d.ts +4 -4
  61. package/dist/solution/BookingTicket/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.js +4 -2
  63. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  64. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
  65. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  66. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  67. package/dist/solution/RegisterAndLogin/config.js +95 -40
  68. package/dist/solution/RegisterAndLogin/index.js +4 -1
  69. package/dist/solution/ScanOrder/index.d.ts +1 -0
  70. package/dist/solution/ScanOrder/index.js +31 -27
  71. package/dist/solution/ScanOrder/types.d.ts +2 -0
  72. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  73. package/dist/solution/ScanOrder/utils.js +8 -3
  74. package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
  75. package/dist/solution/UnifiedBookingSales/index.js +3877 -963
  76. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  77. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  78. package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
  79. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  80. package/dist/solution/VenueBooking/index.d.ts +3 -0
  81. package/dist/solution/VenueBooking/index.js +549 -497
  82. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  83. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  84. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  85. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  86. package/dist/utils/platform.d.ts +8 -0
  87. package/dist/utils/platform.js +15 -0
  88. package/lib/core/index.d.ts +7 -0
  89. package/lib/core/index.js +20 -2
  90. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  92. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  93. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  94. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  95. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  96. package/lib/modules/BookingContext/index.d.ts +3 -0
  97. package/lib/modules/BookingContext/index.js +35 -8
  98. package/lib/modules/BookingContext/types.d.ts +4 -4
  99. package/lib/modules/BookingContext/types.js +3 -3
  100. package/lib/modules/OpenData/types.d.ts +1 -0
  101. package/lib/modules/Order/index.d.ts +18 -3
  102. package/lib/modules/Order/index.js +325 -28
  103. package/lib/modules/Order/salesNotes.d.ts +31 -0
  104. package/lib/modules/Order/salesNotes.js +382 -0
  105. package/lib/modules/Order/types.d.ts +93 -5
  106. package/lib/modules/Order/types.js +4 -0
  107. package/lib/modules/Order/utils.d.ts +12 -0
  108. package/lib/modules/Order/utils.js +85 -16
  109. package/lib/modules/Product/types.d.ts +2 -0
  110. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  111. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  112. package/lib/modules/ProductList/index.d.ts +18 -3
  113. package/lib/modules/ProductList/index.js +137 -8
  114. package/lib/modules/ProductList/types.d.ts +10 -0
  115. package/lib/modules/Quotation/index.d.ts +22 -0
  116. package/lib/modules/Quotation/index.js +158 -11
  117. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  118. package/lib/modules/ResourcePlanner/index.js +9 -129
  119. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  120. package/lib/modules/ResourcePlanner/localClock.js +205 -0
  121. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  122. package/lib/modules/ResourcePlanner/planner.js +1807 -783
  123. package/lib/modules/ResourcePlanner/types.d.ts +359 -187
  124. package/lib/modules/ResourcePlanner/types.js +13 -1
  125. package/lib/plugins/request.d.ts +1 -0
  126. package/lib/server/index.d.ts +17 -2
  127. package/lib/server/index.js +149 -21
  128. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  129. package/lib/server/modules/floor-plan/index.js +60 -7
  130. package/lib/server/modules/menu/index.js +26 -4
  131. package/lib/server/modules/order/index.d.ts +17 -7
  132. package/lib/server/modules/order/index.js +194 -57
  133. package/lib/server/modules/products/index.d.ts +10 -4
  134. package/lib/server/modules/products/index.js +93 -23
  135. package/lib/server/modules/resource/index.js +12 -2
  136. package/lib/server/utils/product.d.ts +1 -1
  137. package/lib/server/utils/product.js +163 -3
  138. package/lib/server/utils/small-ticket.d.ts +9 -1
  139. package/lib/server/utils/small-ticket.js +123 -79
  140. package/lib/solution/BaseSales/index.d.ts +26 -3
  141. package/lib/solution/BaseSales/index.js +396 -70
  142. package/lib/solution/BaseSales/types.d.ts +2 -0
  143. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  144. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
  145. package/lib/solution/BaseSales/utils.js +3 -0
  146. package/lib/solution/BookingByStep/index.d.ts +4 -4
  147. package/lib/solution/BookingTicket/index.d.ts +1 -1
  148. package/lib/solution/BookingTicket/index.js +2 -1
  149. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  150. package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
  151. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  152. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  153. package/lib/solution/RegisterAndLogin/config.js +49 -8
  154. package/lib/solution/RegisterAndLogin/index.js +4 -1
  155. package/lib/solution/ScanOrder/index.d.ts +1 -0
  156. package/lib/solution/ScanOrder/index.js +5 -1
  157. package/lib/solution/ScanOrder/types.d.ts +2 -0
  158. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  159. package/lib/solution/ScanOrder/utils.js +4 -0
  160. package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
  161. package/lib/solution/UnifiedBookingSales/index.js +2592 -424
  162. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  163. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
  164. package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
  165. package/lib/solution/UnifiedBookingSales/types.js +4 -6
  166. package/lib/solution/VenueBooking/index.d.ts +3 -0
  167. package/lib/solution/VenueBooking/index.js +33 -9
  168. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  169. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  170. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  171. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  172. package/lib/utils/platform.d.ts +8 -0
  173. package/lib/utils/platform.js +22 -0
  174. package/package.json +1 -1
@@ -43,6 +43,7 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
44
  import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
+ import { finalizeSalesNotesForCheckout } from "../modules/Order/salesNotes";
46
47
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
47
48
 
48
49
  // 重新导出类型供外部使用
@@ -104,6 +105,8 @@ var Server = /*#__PURE__*/function () {
104
105
  _defineProperty(this, "productQueryScheduleTimers", new Map());
105
106
  /** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
106
107
  _defineProperty(this, "menuScheduleRefreshInFlight", null);
108
+ /** 启动阶段模块预加载任务;预渲染商品查询复用该任务,避免缓存尚未 ready 时误触发远端自愈。 */
109
+ _defineProperty(this, "startupModulePreloadInFlight", null);
107
110
  _defineProperty(this, "lastMenuScheduleRefreshAt", 0);
108
111
  _defineProperty(this, "MENU_SCHEDULE_REFRESH_COOLDOWN_MS", 30 * 1000);
109
112
  // ---- 订单 / 预约列表查询订阅者 ----
@@ -2246,6 +2249,7 @@ var Server = /*#__PURE__*/function () {
2246
2249
  options,
2247
2250
  startTime,
2248
2251
  registeredModules,
2252
+ preloadTask,
2249
2253
  duration,
2250
2254
  _args29 = arguments;
2251
2255
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
@@ -2270,22 +2274,31 @@ var Server = /*#__PURE__*/function () {
2270
2274
  case 8:
2271
2275
  registeredModules = _context29.sent;
2272
2276
  if (!autoPreload) {
2273
- _context29.next = 14;
2277
+ _context29.next = 20;
2274
2278
  break;
2275
2279
  }
2276
- _context29.next = 12;
2277
- return this.preloadModulesData(registeredModules, options);
2278
- case 12:
2280
+ preloadTask = this.preloadModulesData(registeredModules, options);
2281
+ this.startupModulePreloadInFlight = preloadTask;
2282
+ _context29.prev = 12;
2279
2283
  _context29.next = 15;
2284
+ return preloadTask;
2285
+ case 15:
2286
+ _context29.prev = 15;
2287
+ if (this.startupModulePreloadInFlight === preloadTask) {
2288
+ this.startupModulePreloadInFlight = null;
2289
+ }
2290
+ return _context29.finish(15);
2291
+ case 18:
2292
+ _context29.next = 21;
2280
2293
  break;
2281
- case 14:
2294
+ case 20:
2282
2295
  this.logInfo('跳过自动预加载', {
2283
2296
  autoPreload: autoPreload
2284
2297
  });
2285
- case 15:
2286
- _context29.next = 17;
2298
+ case 21:
2299
+ _context29.next = 23;
2287
2300
  return this.setupProductsQuotationPriceBridge();
2288
- case 17:
2301
+ case 23:
2289
2302
  // 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
2290
2303
  this.core.effects.on(ProductsHooks.onProductsSyncCompleted, function (payload) {
2291
2304
  _this3.recomputeAndNotifyProductQuery({
@@ -2311,11 +2324,11 @@ var Server = /*#__PURE__*/function () {
2311
2324
  registeredModuleCount: registeredModules.length
2312
2325
  });
2313
2326
  return _context29.abrupt("return", registeredModules);
2314
- case 23:
2327
+ case 29:
2315
2328
  case "end":
2316
2329
  return _context29.stop();
2317
2330
  }
2318
- }, _callee29, this);
2331
+ }, _callee29, this, [[12,, 15, 18]]);
2319
2332
  }));
2320
2333
  function initialize(_x32) {
2321
2334
  return _initialize.apply(this, arguments);
@@ -2446,7 +2459,7 @@ var Server = /*#__PURE__*/function () {
2446
2459
  value: function () {
2447
2460
  var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2448
2461
  var _this$app6;
2449
- var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2462
+ var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, deviceHeaders, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2450
2463
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2451
2464
  while (1) switch (_context31.prev = _context31.next) {
2452
2465
  case 0:
@@ -2461,21 +2474,27 @@ var Server = /*#__PURE__*/function () {
2461
2474
  numberedData = _context31.sent;
2462
2475
  checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2463
2476
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2477
+ _context31.next = 11;
2478
+ return this.buildCheckoutDeviceHeaders(title);
2479
+ case 11:
2480
+ deviceHeaders = _context31.sent;
2464
2481
  if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
2465
- _context31.next = 11;
2482
+ _context31.next = 14;
2466
2483
  break;
2467
2484
  }
2468
2485
  throw new Error('app.request 不可用');
2469
- case 11:
2470
- _context31.next = 13;
2471
- return this.app.request.post(backendPath, remoteCheckoutData, {
2486
+ case 14:
2487
+ _context31.next = 16;
2488
+ return this.app.request.post(backendPath, remoteCheckoutData, _objectSpread({
2472
2489
  isShopApi: true,
2473
2490
  customToast: function customToast() {}
2474
- });
2475
- case 13:
2491
+ }, Object.keys(deviceHeaders).length > 0 ? {
2492
+ headers: deviceHeaders
2493
+ } : {}));
2494
+ case 16:
2476
2495
  response = _context31.sent;
2477
2496
  if (!this.isCheckoutResponseRejected(response)) {
2478
- _context31.next = 16;
2497
+ _context31.next = 19;
2479
2498
  break;
2480
2499
  }
2481
2500
  return _context31.abrupt("return", {
@@ -2486,13 +2505,13 @@ var Server = /*#__PURE__*/function () {
2486
2505
  normalizedResponse: this.normalizeCheckoutResponse(response),
2487
2506
  checkoutData: checkoutData
2488
2507
  });
2489
- case 16:
2508
+ case 19:
2490
2509
  fresh = this.extractOrderDataFromCheckoutResponse(response);
2491
2510
  externalSaleNumber = this.getCheckoutExternalSaleNumber(checkoutData, {
2492
2511
  external_sale_number: params.externalSaleNumber,
2493
2512
  data: checkoutData
2494
2513
  });
2495
- _context31.next = 20;
2514
+ _context31.next = 23;
2496
2515
  return this.persistSyncedCheckoutOrder({
2497
2516
  backendPath: backendPath,
2498
2517
  checkoutData: checkoutData,
@@ -2501,7 +2520,7 @@ var Server = /*#__PURE__*/function () {
2501
2520
  title: title,
2502
2521
  persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
2503
2522
  });
2504
- case 20:
2523
+ case 23:
2505
2524
  syncedOrder = _context31.sent;
2506
2525
  printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
2507
2526
  syncedOrder: syncedOrder,
@@ -2511,17 +2530,17 @@ var Server = /*#__PURE__*/function () {
2511
2530
  checkoutData: checkoutData,
2512
2531
  syncedOrder: printableSyncedOrder
2513
2532
  }))) {
2514
- _context31.next = 25;
2533
+ _context31.next = 28;
2515
2534
  break;
2516
2535
  }
2517
- _context31.next = 25;
2536
+ _context31.next = 28;
2518
2537
  return this.dispatchPrintOtherReceiptTask({
2519
2538
  checkoutData: checkoutData,
2520
2539
  syncedOrder: printableSyncedOrder,
2521
2540
  response: response,
2522
2541
  deviceId: params.deviceId
2523
2542
  });
2524
- case 25:
2543
+ case 28:
2525
2544
  return _context31.abrupt("return", {
2526
2545
  rejected: false,
2527
2546
  response: response,
@@ -2530,7 +2549,7 @@ var Server = /*#__PURE__*/function () {
2530
2549
  syncedOrder: syncedOrder,
2531
2550
  fresh: fresh
2532
2551
  });
2533
- case 26:
2552
+ case 29:
2534
2553
  case "end":
2535
2554
  return _context31.stop();
2536
2555
  }
@@ -2557,6 +2576,7 @@ var Server = /*#__PURE__*/function () {
2557
2576
  if (!next || _typeof(next) !== 'object') return next;
2558
2577
  var record = next;
2559
2578
  delete record[OS_FULFILLMENT_REF_MODE_FIELD];
2579
+ this.applyKioskCheckoutOperator(record);
2560
2580
  if (!Array.isArray(record.payments)) return next;
2561
2581
  var originalPayments = record.payments;
2562
2582
  var filteredPayments = originalPayments.filter(function (payment) {
@@ -2577,6 +2597,92 @@ var Server = /*#__PURE__*/function () {
2577
2597
  });
2578
2598
  return next;
2579
2599
  }
2600
+ }, {
2601
+ key: "buildCheckoutDeviceHeaders",
2602
+ value: function () {
2603
+ var _buildCheckoutDeviceHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(title) {
2604
+ var _this5 = this;
2605
+ var getAsyncIotDeviceInfo, deviceInfo, headers, assignHeader;
2606
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2607
+ while (1) switch (_context32.prev = _context32.next) {
2608
+ case 0:
2609
+ getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
2610
+ if (getAsyncIotDeviceInfo) {
2611
+ _context32.next = 3;
2612
+ break;
2613
+ }
2614
+ return _context32.abrupt("return", {});
2615
+ case 3:
2616
+ _context32.prev = 3;
2617
+ if (!(typeof getAsyncIotDeviceInfo === 'function')) {
2618
+ _context32.next = 10;
2619
+ break;
2620
+ }
2621
+ _context32.next = 7;
2622
+ return getAsyncIotDeviceInfo();
2623
+ case 7:
2624
+ _context32.t0 = _context32.sent;
2625
+ _context32.next = 11;
2626
+ break;
2627
+ case 10:
2628
+ _context32.t0 = getAsyncIotDeviceInfo;
2629
+ case 11:
2630
+ deviceInfo = _context32.t0;
2631
+ _context32.next = 18;
2632
+ break;
2633
+ case 14:
2634
+ _context32.prev = 14;
2635
+ _context32.t1 = _context32["catch"](3);
2636
+ this.logWarning("".concat(title, ": \u8BFB\u53D6 async_iot_device_info \u5931\u8D25\uFF0C\u8DF3\u8FC7 checkout \u8BBE\u5907\u8BF7\u6C42\u5934"), {
2637
+ error: this.getUnknownErrorMessage(_context32.t1)
2638
+ });
2639
+ return _context32.abrupt("return", {});
2640
+ case 18:
2641
+ if (!(!deviceInfo || _typeof(deviceInfo) !== 'object')) {
2642
+ _context32.next = 20;
2643
+ break;
2644
+ }
2645
+ return _context32.abrupt("return", {});
2646
+ case 20:
2647
+ headers = {};
2648
+ assignHeader = function assignHeader(key, value) {
2649
+ if (_this5.isBlankCheckoutValue(value)) return;
2650
+ headers[key] = String(value);
2651
+ };
2652
+ assignHeader('Device-ID', deviceInfo.id);
2653
+ assignHeader('Device-Type-Code', deviceInfo.type_code);
2654
+ assignHeader('Device-Model-Code', deviceInfo.model_code);
2655
+ return _context32.abrupt("return", headers);
2656
+ case 26:
2657
+ case "end":
2658
+ return _context32.stop();
2659
+ }
2660
+ }, _callee32, this, [[3, 14]]);
2661
+ }));
2662
+ function buildCheckoutDeviceHeaders(_x35) {
2663
+ return _buildCheckoutDeviceHeaders.apply(this, arguments);
2664
+ }
2665
+ return buildCheckoutDeviceHeaders;
2666
+ }()
2667
+ }, {
2668
+ key: "applyKioskCheckoutOperator",
2669
+ value: function applyKioskCheckoutOperator(record) {
2670
+ if (record.platform !== 'kiosk') return;
2671
+ record.operator_type = 'customer';
2672
+ record.operator_id = this.resolveKioskCheckoutOperatorId(record.customer_id);
2673
+ }
2674
+ }, {
2675
+ key: "resolveKioskCheckoutOperatorId",
2676
+ value: function resolveKioskCheckoutOperatorId(customerId) {
2677
+ if (customerId === undefined || customerId === null) return 1;
2678
+ if (typeof customerId === 'string') {
2679
+ var trimmed = customerId.trim();
2680
+ if (trimmed === '' || trimmed === '0' || trimmed === '1') return 1;
2681
+ return customerId;
2682
+ }
2683
+ if (customerId === 0 || customerId === 1) return 1;
2684
+ return customerId;
2685
+ }
2580
2686
  }, {
2581
2687
  key: "mergeCheckoutSyncPayments",
2582
2688
  value: function mergeCheckoutSyncPayments(checkoutData, fresh, title) {
@@ -2615,15 +2721,15 @@ var Server = /*#__PURE__*/function () {
2615
2721
  }, {
2616
2722
  key: "persistSyncedCheckoutOrder",
2617
2723
  value: function () {
2618
- var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2724
+ var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2619
2725
  var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
2620
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2621
- while (1) switch (_context32.prev = _context32.next) {
2726
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2727
+ while (1) switch (_context33.prev = _context33.next) {
2622
2728
  case 0:
2623
2729
  backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
2624
2730
  shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
2625
2731
  if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
2626
- _context32.next = 9;
2732
+ _context33.next = 9;
2627
2733
  break;
2628
2734
  }
2629
2735
  syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
@@ -2635,7 +2741,7 @@ var Server = /*#__PURE__*/function () {
2635
2741
  need_sync: 0,
2636
2742
  is_draft_order: 0
2637
2743
  });
2638
- _context32.next = 6;
2744
+ _context33.next = 6;
2639
2745
  return this.order.upsertOrdersFromRemote([syncedOrder], 'checkoutSync');
2640
2746
  case 6:
2641
2747
  this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
@@ -2645,21 +2751,21 @@ var Server = /*#__PURE__*/function () {
2645
2751
  mergedRemoteOrder: shouldMergeRemoteOrder,
2646
2752
  persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
2647
2753
  });
2648
- _context32.next = 19;
2754
+ _context33.next = 19;
2649
2755
  break;
2650
2756
  case 9:
2651
2757
  if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
2652
- _context32.next = 18;
2758
+ _context33.next = 18;
2653
2759
  break;
2654
2760
  }
2655
2761
  patch = this.buildCheckoutSyncSuccessPatch(fresh);
2656
- _context32.next = 13;
2762
+ _context33.next = 13;
2657
2763
  return this.order.markOrderSyncedByExternalSaleNumber({
2658
2764
  externalSaleNumber: externalSaleNumber,
2659
2765
  patch: patch
2660
2766
  });
2661
2767
  case 13:
2662
- result = _context32.sent;
2768
+ result = _context33.sent;
2663
2769
  syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
2664
2770
  external_sale_number: externalSaleNumber,
2665
2771
  need_sync: 0,
@@ -2671,7 +2777,7 @@ var Server = /*#__PURE__*/function () {
2671
2777
  hasRemoteOrder: !!fresh,
2672
2778
  mergedRemoteOrder: false
2673
2779
  });
2674
- _context32.next = 19;
2780
+ _context33.next = 19;
2675
2781
  break;
2676
2782
  case 18:
2677
2783
  this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
@@ -2680,14 +2786,14 @@ var Server = /*#__PURE__*/function () {
2680
2786
  order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
2681
2787
  });
2682
2788
  case 19:
2683
- return _context32.abrupt("return", syncedOrder);
2789
+ return _context33.abrupt("return", syncedOrder);
2684
2790
  case 20:
2685
2791
  case "end":
2686
- return _context32.stop();
2792
+ return _context33.stop();
2687
2793
  }
2688
- }, _callee32, this);
2794
+ }, _callee33, this);
2689
2795
  }));
2690
- function persistSyncedCheckoutOrder(_x35) {
2796
+ function persistSyncedCheckoutOrder(_x36) {
2691
2797
  return _persistSyncedCheckoutOrder.apply(this, arguments);
2692
2798
  }
2693
2799
  return persistSyncedCheckoutOrder;
@@ -2698,51 +2804,63 @@ var Server = /*#__PURE__*/function () {
2698
2804
  }, {
2699
2805
  key: "setupProductsQuotationPriceBridge",
2700
2806
  value: (function () {
2701
- var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2807
+ var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2808
+ var _this6 = this;
2702
2809
  var _this$core$context, errorMessage;
2703
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2704
- while (1) switch (_context33.prev = _context33.next) {
2810
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2811
+ while (1) switch (_context34.prev = _context34.next) {
2705
2812
  case 0:
2706
2813
  if (this.products) {
2707
- _context33.next = 3;
2814
+ _context34.next = 3;
2708
2815
  break;
2709
2816
  }
2710
2817
  this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
2711
- return _context33.abrupt("return");
2818
+ return _context34.abrupt("return");
2712
2819
  case 3:
2713
2820
  if (this.schedule) {
2714
- _context33.next = 6;
2821
+ _context34.next = 6;
2715
2822
  break;
2716
2823
  }
2717
2824
  this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
2718
- return _context33.abrupt("return");
2825
+ return _context34.abrupt("return");
2719
2826
  case 6:
2720
- _context33.prev = 6;
2721
- _context33.next = 9;
2722
- return this.schedule.loadAllSchedule();
2723
- case 9:
2827
+ _context34.prev = 6;
2724
2828
  this.products.clearPriceCache();
2725
- _context33.next = 12;
2829
+ _context34.next = 10;
2726
2830
  return this.products.setupQuotationPriceBridge({
2727
2831
  scheduleModule: this.schedule,
2728
- channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
2832
+ channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
2833
+ onQuotationUpdated: function onQuotationUpdated() {
2834
+ void _this6.recomputeAndNotifyProductQuery();
2835
+ }
2836
+ });
2837
+ case 10:
2838
+ // Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
2839
+ // 远端刷新转为后台校准,避免二次启动重复阻塞请求。
2840
+ void this.schedule.loadAllSchedule().then(function () {
2841
+ var _this6$products;
2842
+ (_this6$products = _this6.products) === null || _this6$products === void 0 || _this6$products.clearPriceCache();
2843
+ void _this6.recomputeAndNotifyProductQuery();
2844
+ }).catch(function (error) {
2845
+ _this6.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
2846
+ error: error instanceof Error ? error.message : String(error)
2847
+ });
2729
2848
  });
2730
- case 12:
2731
2849
  this.logInfo('Products 报价单价格桥接初始化完成');
2732
- _context33.next = 19;
2850
+ _context34.next = 18;
2733
2851
  break;
2734
- case 15:
2735
- _context33.prev = 15;
2736
- _context33.t0 = _context33["catch"](6);
2737
- errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
2852
+ case 14:
2853
+ _context34.prev = 14;
2854
+ _context34.t0 = _context34["catch"](6);
2855
+ errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2738
2856
  this.logError('Products 报价单价格桥接初始化失败', {
2739
2857
  error: errorMessage
2740
2858
  });
2741
- case 19:
2859
+ case 18:
2742
2860
  case "end":
2743
- return _context33.stop();
2861
+ return _context34.stop();
2744
2862
  }
2745
- }, _callee33, this, [[6, 15]]);
2863
+ }, _callee34, this, [[6, 14]]);
2746
2864
  }));
2747
2865
  function setupProductsQuotationPriceBridge() {
2748
2866
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -2811,45 +2929,59 @@ var Server = /*#__PURE__*/function () {
2811
2929
  }, {
2812
2930
  key: "refreshProductsInBackground",
2813
2931
  value: (function () {
2814
- var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2815
- var startTime, duration, _duration2, errorMessage;
2816
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2817
- while (1) switch (_context34.prev = _context34.next) {
2932
+ var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2933
+ var options,
2934
+ trigger,
2935
+ startTime,
2936
+ duration,
2937
+ _duration2,
2938
+ errorMessage,
2939
+ _args35 = arguments;
2940
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2941
+ while (1) switch (_context35.prev = _context35.next) {
2818
2942
  case 0:
2943
+ options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
2819
2944
  if (this.products) {
2820
- _context34.next = 3;
2945
+ _context35.next = 4;
2821
2946
  break;
2822
2947
  }
2823
2948
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
2824
- return _context34.abrupt("return");
2825
- case 3:
2826
- this.logInfo('refreshProductsInBackground 开始');
2949
+ return _context35.abrupt("return");
2950
+ case 4:
2951
+ trigger = options.trigger || 'background';
2952
+ this.logInfo('refreshProductsInBackground 开始', {
2953
+ trigger: trigger
2954
+ });
2827
2955
  startTime = Date.now();
2828
- _context34.prev = 5;
2829
- _context34.next = 8;
2830
- return this.products.silentRefresh();
2831
- case 8:
2956
+ _context35.prev = 7;
2957
+ _context35.next = 10;
2958
+ return this.products.silentRefresh({
2959
+ trigger: trigger
2960
+ });
2961
+ case 10:
2832
2962
  duration = Date.now() - startTime;
2833
2963
  this.logInfo('refreshProductsInBackground 完成', {
2964
+ trigger: trigger,
2834
2965
  duration: "".concat(duration, "ms")
2835
2966
  });
2836
- _context34.next = 18;
2967
+ _context35.next = 20;
2837
2968
  break;
2838
- case 12:
2839
- _context34.prev = 12;
2840
- _context34.t0 = _context34["catch"](5);
2969
+ case 14:
2970
+ _context35.prev = 14;
2971
+ _context35.t0 = _context35["catch"](7);
2841
2972
  _duration2 = Date.now() - startTime;
2842
- errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2843
- console.error('[Server] refreshProductsInBackground 失败:', _context34.t0);
2973
+ errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
2974
+ console.error('[Server] refreshProductsInBackground 失败:', _context35.t0);
2844
2975
  this.logError('refreshProductsInBackground 失败', {
2976
+ trigger: trigger,
2845
2977
  duration: "".concat(_duration2, "ms"),
2846
2978
  error: errorMessage
2847
2979
  });
2848
- case 18:
2980
+ case 20:
2849
2981
  case "end":
2850
- return _context34.stop();
2982
+ return _context35.stop();
2851
2983
  }
2852
- }, _callee34, this, [[5, 12]]);
2984
+ }, _callee35, this, [[7, 14]]);
2853
2985
  }));
2854
2986
  function refreshProductsInBackground() {
2855
2987
  return _refreshProductsInBackground.apply(this, arguments);
@@ -2865,45 +2997,59 @@ var Server = /*#__PURE__*/function () {
2865
2997
  }, {
2866
2998
  key: "refreshOrdersInBackground",
2867
2999
  value: (function () {
2868
- var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2869
- var startTime, duration, _duration3, errorMessage;
2870
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2871
- while (1) switch (_context35.prev = _context35.next) {
3000
+ var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
3001
+ var options,
3002
+ trigger,
3003
+ startTime,
3004
+ duration,
3005
+ _duration3,
3006
+ errorMessage,
3007
+ _args36 = arguments;
3008
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3009
+ while (1) switch (_context36.prev = _context36.next) {
2872
3010
  case 0:
3011
+ options = _args36.length > 0 && _args36[0] !== undefined ? _args36[0] : {};
2873
3012
  if (this.order) {
2874
- _context35.next = 3;
3013
+ _context36.next = 4;
2875
3014
  break;
2876
3015
  }
2877
3016
  this.logWarning('refreshOrdersInBackground: Order 模块未注册');
2878
- return _context35.abrupt("return");
2879
- case 3:
2880
- this.logInfo('refreshOrdersInBackground 开始');
3017
+ return _context36.abrupt("return");
3018
+ case 4:
3019
+ trigger = options.trigger || 'background';
3020
+ this.logInfo('refreshOrdersInBackground 开始', {
3021
+ trigger: trigger
3022
+ });
2881
3023
  startTime = Date.now();
2882
- _context35.prev = 5;
2883
- _context35.next = 8;
2884
- return this.order.silentRefresh();
2885
- case 8:
3024
+ _context36.prev = 7;
3025
+ _context36.next = 10;
3026
+ return this.order.silentRefresh({
3027
+ trigger: trigger
3028
+ });
3029
+ case 10:
2886
3030
  duration = Date.now() - startTime;
2887
3031
  this.logInfo('refreshOrdersInBackground 完成', {
3032
+ trigger: trigger,
2888
3033
  duration: "".concat(duration, "ms")
2889
3034
  });
2890
- _context35.next = 18;
3035
+ _context36.next = 20;
2891
3036
  break;
2892
- case 12:
2893
- _context35.prev = 12;
2894
- _context35.t0 = _context35["catch"](5);
3037
+ case 14:
3038
+ _context36.prev = 14;
3039
+ _context36.t0 = _context36["catch"](7);
2895
3040
  _duration3 = Date.now() - startTime;
2896
- errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
2897
- console.error('[Server] refreshOrdersInBackground 失败:', _context35.t0);
3041
+ errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0);
3042
+ console.error('[Server] refreshOrdersInBackground 失败:', _context36.t0);
2898
3043
  this.logError('refreshOrdersInBackground 失败', {
3044
+ trigger: trigger,
2899
3045
  duration: "".concat(_duration3, "ms"),
2900
3046
  error: errorMessage
2901
3047
  });
2902
- case 18:
3048
+ case 20:
2903
3049
  case "end":
2904
- return _context35.stop();
3050
+ return _context36.stop();
2905
3051
  }
2906
- }, _callee35, this, [[5, 12]]);
3052
+ }, _callee36, this, [[7, 14]]);
2907
3053
  }));
2908
3054
  function refreshOrdersInBackground() {
2909
3055
  return _refreshOrdersInBackground.apply(this, arguments);
@@ -2919,23 +3065,23 @@ var Server = /*#__PURE__*/function () {
2919
3065
  }, {
2920
3066
  key: "checkRemoteOrderProductMembership",
2921
3067
  value: (function () {
2922
- var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId) {
3068
+ var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(orderId) {
2923
3069
  var normalizedOrderId, error, startTime, freshOrders, freshOrder;
2924
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2925
- while (1) switch (_context36.prev = _context36.next) {
3070
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3071
+ while (1) switch (_context37.prev = _context37.next) {
2926
3072
  case 0:
2927
3073
  normalizedOrderId = String(orderId !== null && orderId !== void 0 ? orderId : '').trim();
2928
3074
  if (!(!normalizedOrderId || normalizedOrderId.startsWith('local_order'))) {
2929
- _context36.next = 4;
3075
+ _context37.next = 4;
2930
3076
  break;
2931
3077
  }
2932
3078
  this.logInfo('checkRemoteOrderProductMembership: 跳过非正式订单', {
2933
3079
  orderId: orderId
2934
3080
  });
2935
- return _context36.abrupt("return");
3081
+ return _context37.abrupt("return");
2936
3082
  case 4:
2937
3083
  if (this.order) {
2938
- _context36.next = 8;
3084
+ _context37.next = 8;
2939
3085
  break;
2940
3086
  }
2941
3087
  error = new Error('Order 模块未注册');
@@ -2948,45 +3094,45 @@ var Server = /*#__PURE__*/function () {
2948
3094
  orderId: normalizedOrderId
2949
3095
  });
2950
3096
  startTime = Date.now();
2951
- _context36.prev = 10;
2952
- _context36.next = 13;
3097
+ _context37.prev = 10;
3098
+ _context37.next = 13;
2953
3099
  return this.order.fetchOrdersByHttp([normalizedOrderId]);
2954
3100
  case 13:
2955
- freshOrders = _context36.sent;
3101
+ freshOrders = _context37.sent;
2956
3102
  freshOrder = freshOrders.find(function (order) {
2957
3103
  return String(order === null || order === void 0 ? void 0 : order.order_id) === normalizedOrderId;
2958
3104
  });
2959
3105
  if (freshOrder) {
2960
- _context36.next = 17;
3106
+ _context37.next = 17;
2961
3107
  break;
2962
3108
  }
2963
3109
  throw new Error('Server 未返回目标订单最新快照');
2964
3110
  case 17:
2965
- _context36.next = 19;
3111
+ _context37.next = 19;
2966
3112
  return this.order.upsertOrdersFromRemote([freshOrder], 'manual.editOpenRemoteCheck');
2967
3113
  case 19:
2968
3114
  this.logInfo('checkRemoteOrderProductMembership 完成', {
2969
3115
  orderId: normalizedOrderId,
2970
3116
  duration: "".concat(Date.now() - startTime, "ms")
2971
3117
  });
2972
- _context36.next = 26;
3118
+ _context37.next = 26;
2973
3119
  break;
2974
3120
  case 22:
2975
- _context36.prev = 22;
2976
- _context36.t0 = _context36["catch"](10);
3121
+ _context37.prev = 22;
3122
+ _context37.t0 = _context37["catch"](10);
2977
3123
  this.logError('checkRemoteOrderProductMembership 失败', {
2978
3124
  orderId: normalizedOrderId,
2979
3125
  duration: "".concat(Date.now() - startTime, "ms"),
2980
- error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
3126
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
2981
3127
  });
2982
- throw _context36.t0;
3128
+ throw _context37.t0;
2983
3129
  case 26:
2984
3130
  case "end":
2985
- return _context36.stop();
3131
+ return _context37.stop();
2986
3132
  }
2987
- }, _callee36, this, [[10, 22]]);
3133
+ }, _callee37, this, [[10, 22]]);
2988
3134
  }));
2989
- function checkRemoteOrderProductMembership(_x36) {
3135
+ function checkRemoteOrderProductMembership(_x37) {
2990
3136
  return _checkRemoteOrderProductMembership.apply(this, arguments);
2991
3137
  }
2992
3138
  return checkRemoteOrderProductMembership;
@@ -2999,10 +3145,10 @@ var Server = /*#__PURE__*/function () {
2999
3145
  }, {
3000
3146
  key: "clearAllIndexDB",
3001
3147
  value: (function () {
3002
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3148
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3003
3149
  var clearTasks, moduleNames, errorMessage;
3004
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3005
- while (1) switch (_context37.prev = _context37.next) {
3150
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3151
+ while (1) switch (_context38.prev = _context38.next) {
3006
3152
  case 0:
3007
3153
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
3008
3154
  clearTasks = [];
@@ -3036,40 +3182,40 @@ var Server = /*#__PURE__*/function () {
3036
3182
  moduleNames.push('FloorPlan');
3037
3183
  }
3038
3184
  if (!(clearTasks.length === 0)) {
3039
- _context37.next = 14;
3185
+ _context38.next = 14;
3040
3186
  break;
3041
3187
  }
3042
3188
  console.warn('[Server] 没有找到已注册的模块,无需清空');
3043
3189
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
3044
- return _context37.abrupt("return");
3190
+ return _context38.abrupt("return");
3045
3191
  case 14:
3046
3192
  this.logInfo('准备清空模块缓存', {
3047
3193
  moduleNames: moduleNames
3048
3194
  });
3049
- _context37.prev = 15;
3050
- _context37.next = 18;
3195
+ _context38.prev = 15;
3196
+ _context38.next = 18;
3051
3197
  return Promise.all(clearTasks);
3052
3198
  case 18:
3053
3199
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
3054
3200
  moduleNames: moduleNames
3055
3201
  });
3056
- _context37.next = 27;
3202
+ _context38.next = 27;
3057
3203
  break;
3058
3204
  case 21:
3059
- _context37.prev = 21;
3060
- _context37.t0 = _context37["catch"](15);
3061
- errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3062
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context37.t0);
3205
+ _context38.prev = 21;
3206
+ _context38.t0 = _context38["catch"](15);
3207
+ errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3208
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context38.t0);
3063
3209
  this.logError('清空 IndexedDB 缓存时发生错误', {
3064
3210
  moduleNames: moduleNames,
3065
3211
  error: errorMessage
3066
3212
  });
3067
- throw _context37.t0;
3213
+ throw _context38.t0;
3068
3214
  case 27:
3069
3215
  case "end":
3070
- return _context37.stop();
3216
+ return _context38.stop();
3071
3217
  }
3072
- }, _callee37, this, [[15, 21]]);
3218
+ }, _callee38, this, [[15, 21]]);
3073
3219
  }));
3074
3220
  function clearAllIndexDB() {
3075
3221
  return _clearAllIndexDB.apply(this, arguments);
@@ -3144,10 +3290,10 @@ var Server = /*#__PURE__*/function () {
3144
3290
  }, {
3145
3291
  key: "handleRoute",
3146
3292
  value: (function () {
3147
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(method, path, params) {
3293
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(method, path, params) {
3148
3294
  var startTime, handler, result, duration, _duration4, errorMessage;
3149
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3150
- while (1) switch (_context38.prev = _context38.next) {
3295
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3296
+ while (1) switch (_context39.prev = _context39.next) {
3151
3297
  case 0:
3152
3298
  startTime = Date.now();
3153
3299
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3158,7 +3304,7 @@ var Server = /*#__PURE__*/function () {
3158
3304
  });
3159
3305
  handler = this.getRouteHandler(method, path);
3160
3306
  if (handler) {
3161
- _context38.next = 6;
3307
+ _context39.next = 6;
3162
3308
  break;
3163
3309
  }
3164
3310
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -3167,13 +3313,13 @@ var Server = /*#__PURE__*/function () {
3167
3313
  });
3168
3314
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
3169
3315
  case 6:
3170
- _context38.prev = 6;
3171
- _context38.next = 9;
3316
+ _context39.prev = 6;
3317
+ _context39.next = 9;
3172
3318
  return handler(_objectSpread(_objectSpread({}, params), {}, {
3173
3319
  path: path
3174
3320
  }));
3175
3321
  case 9:
3176
- result = _context38.sent;
3322
+ result = _context39.sent;
3177
3323
  duration = Date.now() - startTime;
3178
3324
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
3179
3325
  method: method.toUpperCase(),
@@ -3182,12 +3328,12 @@ var Server = /*#__PURE__*/function () {
3182
3328
  resultCode: result === null || result === void 0 ? void 0 : result.code,
3183
3329
  resultStatus: result === null || result === void 0 ? void 0 : result.status
3184
3330
  });
3185
- return _context38.abrupt("return", result);
3331
+ return _context39.abrupt("return", result);
3186
3332
  case 15:
3187
- _context38.prev = 15;
3188
- _context38.t0 = _context38["catch"](6);
3333
+ _context39.prev = 15;
3334
+ _context39.t0 = _context39["catch"](6);
3189
3335
  _duration4 = Date.now() - startTime;
3190
- errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3336
+ errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
3191
3337
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
3192
3338
  method: method.toUpperCase(),
3193
3339
  path: path,
@@ -3195,15 +3341,15 @@ var Server = /*#__PURE__*/function () {
3195
3341
  error: errorMessage,
3196
3342
  data: params.data
3197
3343
  });
3198
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context38.t0);
3199
- throw _context38.t0;
3344
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context39.t0);
3345
+ throw _context39.t0;
3200
3346
  case 22:
3201
3347
  case "end":
3202
- return _context38.stop();
3348
+ return _context39.stop();
3203
3349
  }
3204
- }, _callee38, this, [[6, 15]]);
3350
+ }, _callee39, this, [[6, 15]]);
3205
3351
  }));
3206
- function handleRoute(_x37, _x38, _x39) {
3352
+ function handleRoute(_x38, _x39, _x40) {
3207
3353
  return _handleRoute.apply(this, arguments);
3208
3354
  }
3209
3355
  return handleRoute;
@@ -3215,10 +3361,10 @@ var Server = /*#__PURE__*/function () {
3215
3361
  }, {
3216
3362
  key: "getAllRoutes",
3217
3363
  value: function getAllRoutes() {
3218
- var _this5 = this;
3364
+ var _this7 = this;
3219
3365
  var routes = [];
3220
3366
  ['get', 'post', 'put', 'remove'].forEach(function (method) {
3221
- Object.keys(_this5.router[method]).forEach(function (path) {
3367
+ Object.keys(_this7.router[method]).forEach(function (path) {
3222
3368
  routes.push({
3223
3369
  method: method,
3224
3370
  path: path
@@ -3346,58 +3492,58 @@ var Server = /*#__PURE__*/function () {
3346
3492
  }, {
3347
3493
  key: "getPaymentRouteModule",
3348
3494
  value: function () {
3349
- var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3350
- var _this6 = this;
3351
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3352
- while (1) switch (_context40.prev = _context40.next) {
3495
+ var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3496
+ var _this8 = this;
3497
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3498
+ while (1) switch (_context41.prev = _context41.next) {
3353
3499
  case 0:
3354
3500
  if (!this.payment) {
3355
- _context40.next = 2;
3501
+ _context41.next = 2;
3356
3502
  break;
3357
3503
  }
3358
- return _context40.abrupt("return", this.payment);
3504
+ return _context41.abrupt("return", this.payment);
3359
3505
  case 2:
3360
3506
  if (!this.paymentRouteModule) {
3361
- _context40.next = 4;
3507
+ _context41.next = 4;
3362
3508
  break;
3363
3509
  }
3364
- return _context40.abrupt("return", this.paymentRouteModule);
3510
+ return _context41.abrupt("return", this.paymentRouteModule);
3365
3511
  case 4:
3366
3512
  if (!this.paymentRouteModuleInFlight) {
3367
- _context40.next = 6;
3513
+ _context41.next = 6;
3368
3514
  break;
3369
3515
  }
3370
- return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3516
+ return _context41.abrupt("return", this.paymentRouteModuleInFlight);
3371
3517
  case 6:
3372
- this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3518
+ this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3373
3519
  var module;
3374
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3375
- while (1) switch (_context39.prev = _context39.next) {
3520
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3521
+ while (1) switch (_context40.prev = _context40.next) {
3376
3522
  case 0:
3377
3523
  module = new PaymentServerModule('server_payment_route', '1.0.0');
3378
- _context39.next = 3;
3379
- return module.initialize(_this6.core, {
3524
+ _context40.next = 3;
3525
+ return module.initialize(_this8.core, {
3380
3526
  store: {
3381
3527
  payMethods: []
3382
3528
  }
3383
3529
  });
3384
3530
  case 3:
3385
- _this6.paymentRouteModule = module;
3386
- return _context39.abrupt("return", module);
3531
+ _this8.paymentRouteModule = module;
3532
+ return _context40.abrupt("return", module);
3387
3533
  case 5:
3388
3534
  case "end":
3389
- return _context39.stop();
3535
+ return _context40.stop();
3390
3536
  }
3391
- }, _callee39);
3537
+ }, _callee40);
3392
3538
  }))().finally(function () {
3393
- _this6.paymentRouteModuleInFlight = undefined;
3539
+ _this8.paymentRouteModuleInFlight = undefined;
3394
3540
  });
3395
- return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3541
+ return _context41.abrupt("return", this.paymentRouteModuleInFlight);
3396
3542
  case 8:
3397
3543
  case "end":
3398
- return _context40.stop();
3544
+ return _context41.stop();
3399
3545
  }
3400
- }, _callee40, this);
3546
+ }, _callee41, this);
3401
3547
  }));
3402
3548
  function getPaymentRouteModule() {
3403
3549
  return _getPaymentRouteModule.apply(this, arguments);
@@ -3407,19 +3553,19 @@ var Server = /*#__PURE__*/function () {
3407
3553
  }, {
3408
3554
  key: "fetchQuotationAvailableFromAPI",
3409
3555
  value: function () {
3410
- var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
3556
+ var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
3411
3557
  var _this$app7;
3412
3558
  var requester;
3413
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3414
- while (1) switch (_context41.prev = _context41.next) {
3559
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3560
+ while (1) switch (_context42.prev = _context42.next) {
3415
3561
  case 0:
3416
3562
  requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
3417
3563
  if (requester !== null && requester !== void 0 && requester.get) {
3418
- _context41.next = 4;
3564
+ _context42.next = 4;
3419
3565
  break;
3420
3566
  }
3421
3567
  this.logError('fetchQuotationAvailableFromAPI: request 不可用');
3422
- return _context41.abrupt("return", {
3568
+ return _context42.abrupt("return", {
3423
3569
  code: 500,
3424
3570
  message: 'request 不可用',
3425
3571
  data: {
@@ -3428,14 +3574,14 @@ var Server = /*#__PURE__*/function () {
3428
3574
  status: false
3429
3575
  });
3430
3576
  case 4:
3431
- return _context41.abrupt("return", requester.get('/shop/quotation/available', data));
3577
+ return _context42.abrupt("return", requester.get('/shop/quotation/available', data));
3432
3578
  case 5:
3433
3579
  case "end":
3434
- return _context41.stop();
3580
+ return _context42.stop();
3435
3581
  }
3436
- }, _callee41, this);
3582
+ }, _callee42, this);
3437
3583
  }));
3438
- function fetchQuotationAvailableFromAPI(_x40) {
3584
+ function fetchQuotationAvailableFromAPI(_x41) {
3439
3585
  return _fetchQuotationAvailableFromAPI.apply(this, arguments);
3440
3586
  }
3441
3587
  return fetchQuotationAvailableFromAPI;
@@ -3566,7 +3712,7 @@ var Server = /*#__PURE__*/function () {
3566
3712
  }, {
3567
3713
  key: "scheduleSubscriberTimePointReloads",
3568
3714
  value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3569
- var _this7 = this;
3715
+ var _this9 = this;
3570
3716
  var subscriber = this.productQuerySubscribers.get(subscriberId);
3571
3717
  if (!subscriber || !timePoints.length) return;
3572
3718
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
@@ -3585,9 +3731,9 @@ var Server = /*#__PURE__*/function () {
3585
3731
  // timerIds.push(timerId);
3586
3732
  // }
3587
3733
  setInterval(function () {
3588
- var currentTime = dayjs().format('hh:mm');
3734
+ var currentTime = dayjs().format('HH:mm');
3589
3735
  if (timePoints.includes(currentTime)) {
3590
- _this7.onScheduleTimePointTimerFire(subscriberId);
3736
+ _this9.onScheduleTimePointTimerFire(subscriberId);
3591
3737
  }
3592
3738
  }, 60000);
3593
3739
  if (timerIds.length > 0) {
@@ -3607,29 +3753,29 @@ var Server = /*#__PURE__*/function () {
3607
3753
  }, {
3608
3754
  key: "onScheduleTimePointTimerFire",
3609
3755
  value: (function () {
3610
- var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId, timerId) {
3756
+ var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId, timerId) {
3611
3757
  var subscriber;
3612
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3613
- while (1) switch (_context42.prev = _context42.next) {
3758
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3759
+ while (1) switch (_context43.prev = _context43.next) {
3614
3760
  case 0:
3615
3761
  timerId && this.removeScheduleTimerRef(subscriberId, timerId);
3616
3762
  if (this.productQuerySubscribers.has(subscriberId)) {
3617
- _context42.next = 3;
3763
+ _context43.next = 3;
3618
3764
  break;
3619
3765
  }
3620
- return _context42.abrupt("return");
3766
+ return _context43.abrupt("return");
3621
3767
  case 3:
3622
3768
  subscriber = this.productQuerySubscribers.get(subscriberId);
3623
3769
  this.refreshSubscriberScheduleAtExecution(subscriber);
3624
- _context42.next = 7;
3770
+ _context43.next = 7;
3625
3771
  return this.recomputeAndNotifySubscriber(subscriberId);
3626
3772
  case 7:
3627
3773
  case "end":
3628
- return _context42.stop();
3774
+ return _context43.stop();
3629
3775
  }
3630
- }, _callee42, this);
3776
+ }, _callee43, this);
3631
3777
  }));
3632
- function onScheduleTimePointTimerFire(_x41, _x42) {
3778
+ function onScheduleTimePointTimerFire(_x42, _x43) {
3633
3779
  return _onScheduleTimePointTimerFire.apply(this, arguments);
3634
3780
  }
3635
3781
  return onScheduleTimePointTimerFire;
@@ -3641,45 +3787,45 @@ var Server = /*#__PURE__*/function () {
3641
3787
  }, {
3642
3788
  key: "recomputeAndNotifySubscriber",
3643
3789
  value: (function () {
3644
- var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId) {
3790
+ var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(subscriberId) {
3645
3791
  var subscriber, result, errorMessage;
3646
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3647
- while (1) switch (_context43.prev = _context43.next) {
3792
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3793
+ while (1) switch (_context44.prev = _context44.next) {
3648
3794
  case 0:
3649
3795
  subscriber = this.productQuerySubscribers.get(subscriberId);
3650
3796
  if (subscriber) {
3651
- _context43.next = 3;
3797
+ _context44.next = 3;
3652
3798
  break;
3653
3799
  }
3654
- return _context43.abrupt("return");
3800
+ return _context44.abrupt("return");
3655
3801
  case 3:
3656
- _context43.prev = 3;
3657
- _context43.next = 6;
3802
+ _context44.prev = 3;
3803
+ _context44.next = 6;
3658
3804
  return this.computeProductQueryResult(subscriber.context);
3659
3805
  case 6:
3660
- result = _context43.sent;
3806
+ result = _context44.sent;
3661
3807
  subscriber.callback(result);
3662
3808
  this.logInfo('recomputeAndNotifySubscriber: 已推送', {
3663
3809
  subscriberId: subscriberId,
3664
3810
  schedule_datetime: subscriber.context.schedule_datetime
3665
3811
  });
3666
- _context43.next = 15;
3812
+ _context44.next = 15;
3667
3813
  break;
3668
3814
  case 11:
3669
- _context43.prev = 11;
3670
- _context43.t0 = _context43["catch"](3);
3671
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
3815
+ _context44.prev = 11;
3816
+ _context44.t0 = _context44["catch"](3);
3817
+ errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
3672
3818
  this.logError('recomputeAndNotifySubscriber: 推送失败', {
3673
3819
  subscriberId: subscriberId,
3674
3820
  error: errorMessage
3675
3821
  });
3676
3822
  case 15:
3677
3823
  case "end":
3678
- return _context43.stop();
3824
+ return _context44.stop();
3679
3825
  }
3680
- }, _callee43, this, [[3, 11]]);
3826
+ }, _callee44, this, [[3, 11]]);
3681
3827
  }));
3682
- function recomputeAndNotifySubscriber(_x43) {
3828
+ function recomputeAndNotifySubscriber(_x44) {
3683
3829
  return _recomputeAndNotifySubscriber.apply(this, arguments);
3684
3830
  }
3685
3831
  return recomputeAndNotifySubscriber;
@@ -3755,46 +3901,46 @@ var Server = /*#__PURE__*/function () {
3755
3901
  }, {
3756
3902
  key: "refreshMenuScheduleCacheAfterEmptyResult",
3757
3903
  value: (function () {
3758
- var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3759
- var _this8 = this;
3904
+ var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3905
+ var _this10 = this;
3760
3906
  var now;
3761
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3762
- while (1) switch (_context44.prev = _context44.next) {
3907
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3908
+ while (1) switch (_context45.prev = _context45.next) {
3763
3909
  case 0:
3764
3910
  if (!(!this.menu || !this.schedule)) {
3765
- _context44.next = 2;
3911
+ _context45.next = 2;
3766
3912
  break;
3767
3913
  }
3768
- return _context44.abrupt("return", false);
3914
+ return _context45.abrupt("return", false);
3769
3915
  case 2:
3770
3916
  now = Date.now();
3771
3917
  if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
3772
- _context44.next = 5;
3918
+ _context45.next = 5;
3773
3919
  break;
3774
3920
  }
3775
- return _context44.abrupt("return", false);
3921
+ return _context45.abrupt("return", false);
3776
3922
  case 5:
3777
3923
  if (!this.menuScheduleRefreshInFlight) {
3778
3924
  this.lastMenuScheduleRefreshAt = now;
3779
3925
  this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
3780
3926
  return undefined;
3781
3927
  }).catch(function (error) {
3782
- _this8.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3928
+ _this10.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3783
3929
  error: error instanceof Error ? error.message : String(error)
3784
3930
  });
3785
3931
  }).finally(function () {
3786
- _this8.menuScheduleRefreshInFlight = null;
3932
+ _this10.menuScheduleRefreshInFlight = null;
3787
3933
  });
3788
3934
  }
3789
- _context44.next = 8;
3935
+ _context45.next = 8;
3790
3936
  return this.menuScheduleRefreshInFlight;
3791
3937
  case 8:
3792
- return _context44.abrupt("return", true);
3938
+ return _context45.abrupt("return", true);
3793
3939
  case 9:
3794
3940
  case "end":
3795
- return _context44.stop();
3941
+ return _context45.stop();
3796
3942
  }
3797
- }, _callee44, this);
3943
+ }, _callee45, this);
3798
3944
  }));
3799
3945
  function refreshMenuScheduleCacheAfterEmptyResult() {
3800
3946
  return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
@@ -3812,16 +3958,16 @@ var Server = /*#__PURE__*/function () {
3812
3958
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
3813
3959
  */
3814
3960
  function () {
3815
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3961
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(kind, backendPath, data, config) {
3816
3962
  var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3817
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3818
- while (1) switch (_context45.prev = _context45.next) {
3963
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3964
+ while (1) switch (_context46.prev = _context46.next) {
3819
3965
  case 0:
3820
3966
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
3821
- _context45.next = 3;
3967
+ _context46.next = 3;
3822
3968
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3823
3969
  case 3:
3824
- result = _context45.sent;
3970
+ result = _context46.sent;
3825
3971
  _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3826
3972
  if (subscriberId && typeof callback === 'function') {
3827
3973
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
@@ -3853,14 +3999,14 @@ var Server = /*#__PURE__*/function () {
3853
3999
  visibleCount: visibleOrderIds.size
3854
4000
  });
3855
4001
  }
3856
- return _context45.abrupt("return", result);
4002
+ return _context46.abrupt("return", result);
3857
4003
  case 7:
3858
4004
  case "end":
3859
- return _context45.stop();
4005
+ return _context46.stop();
3860
4006
  }
3861
- }, _callee45, this);
4007
+ }, _callee46, this);
3862
4008
  }));
3863
- function handleSalesSearchRequest(_x44, _x45, _x46, _x47) {
4009
+ function handleSalesSearchRequest(_x45, _x46, _x47, _x48) {
3864
4010
  return _handleSalesSearchRequest.apply(this, arguments);
3865
4011
  }
3866
4012
  return handleSalesSearchRequest;
@@ -3875,20 +4021,20 @@ var Server = /*#__PURE__*/function () {
3875
4021
  }, {
3876
4022
  key: "fetchSalesSearchFromAPI",
3877
4023
  value: (function () {
3878
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
4024
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(backendPath, data) {
3879
4025
  var _this$app8;
3880
4026
  var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3881
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3882
- while (1) switch (_context46.prev = _context46.next) {
4027
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4028
+ while (1) switch (_context47.prev = _context47.next) {
3883
4029
  case 0:
3884
4030
  if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3885
- _context46.next = 3;
4031
+ _context47.next = 3;
3886
4032
  break;
3887
4033
  }
3888
4034
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
3889
4035
  backendPath: backendPath
3890
4036
  });
3891
- return _context46.abrupt("return", {
4037
+ return _context47.abrupt("return", {
3892
4038
  code: 500,
3893
4039
  message: 'app.request 不可用',
3894
4040
  data: backendPath === '/shop/es/search' ? {
@@ -3900,29 +4046,29 @@ var Server = /*#__PURE__*/function () {
3900
4046
  status: false
3901
4047
  });
3902
4048
  case 3:
3903
- _context46.prev = 3;
3904
- _context46.next = 6;
4049
+ _context47.prev = 3;
4050
+ _context47.next = 6;
3905
4051
  return this.app.request.post(backendPath, data, {
3906
4052
  isShopApi: true
3907
4053
  });
3908
4054
  case 6:
3909
- response = _context46.sent;
4055
+ response = _context47.sent;
3910
4056
  _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3911
- return _context46.abrupt("return", {
4057
+ return _context47.abrupt("return", {
3912
4058
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3913
4059
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
3914
4060
  message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
3915
4061
  data: _payload
3916
4062
  });
3917
4063
  case 11:
3918
- _context46.prev = 11;
3919
- _context46.t0 = _context46["catch"](3);
3920
- errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
4064
+ _context47.prev = 11;
4065
+ _context47.t0 = _context47["catch"](3);
4066
+ errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
3921
4067
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
3922
4068
  backendPath: backendPath,
3923
4069
  error: errorMessage
3924
4070
  });
3925
- return _context46.abrupt("return", {
4071
+ return _context47.abrupt("return", {
3926
4072
  code: 500,
3927
4073
  message: errorMessage,
3928
4074
  data: backendPath === '/shop/es/search' ? {
@@ -3935,11 +4081,11 @@ var Server = /*#__PURE__*/function () {
3935
4081
  });
3936
4082
  case 16:
3937
4083
  case "end":
3938
- return _context46.stop();
4084
+ return _context47.stop();
3939
4085
  }
3940
- }, _callee46, this, [[3, 11]]);
4086
+ }, _callee47, this, [[3, 11]]);
3941
4087
  }));
3942
- function fetchSalesSearchFromAPI(_x48, _x49) {
4088
+ function fetchSalesSearchFromAPI(_x49, _x50) {
3943
4089
  return _fetchSalesSearchFromAPI.apply(this, arguments);
3944
4090
  }
3945
4091
  return fetchSalesSearchFromAPI;
@@ -3969,10 +4115,10 @@ var Server = /*#__PURE__*/function () {
3969
4115
  }, {
3970
4116
  key: "stripSalesSearchPageParams",
3971
4117
  value: function stripSalesSearchPageParams(value) {
3972
- var _this9 = this;
4118
+ var _this11 = this;
3973
4119
  if (Array.isArray(value)) {
3974
4120
  return value.map(function (item) {
3975
- return _this9.stripSalesSearchPageParams(item);
4121
+ return _this11.stripSalesSearchPageParams(item);
3976
4122
  });
3977
4123
  }
3978
4124
  if (!value || _typeof(value) !== 'object') return value;
@@ -4010,12 +4156,12 @@ var Server = /*#__PURE__*/function () {
4010
4156
  key: "extractSalesSearchOrderIds",
4011
4157
  value: function extractSalesSearchOrderIds(kind, result) {
4012
4158
  var _this$findSalesSearch,
4013
- _this10 = this;
4159
+ _this12 = this;
4014
4160
  var data = this.extractSalesSearchResponseData(result);
4015
4161
  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;
4016
4162
  if (!Array.isArray(list)) return [];
4017
4163
  return list.map(function (item) {
4018
- return _this10.getSalesSearchOrderId(item);
4164
+ return _this12.getSalesSearchOrderId(item);
4019
4165
  }).filter(function (id) {
4020
4166
  return !!id;
4021
4167
  });
@@ -4182,11 +4328,11 @@ var Server = /*#__PURE__*/function () {
4182
4328
  }, {
4183
4329
  key: "stableSerialize",
4184
4330
  value: function stableSerialize(value) {
4185
- var _this11 = this;
4331
+ var _this13 = this;
4186
4332
  if (value === null || value === undefined) return 'null';
4187
4333
  if (Array.isArray(value)) {
4188
4334
  return "[".concat(value.map(function (item) {
4189
- return _this11.stableSerialize(item);
4335
+ return _this13.stableSerialize(item);
4190
4336
  }).join(','), "]");
4191
4337
  }
4192
4338
  if (_typeof(value) === 'object') {
@@ -4195,7 +4341,7 @@ var Server = /*#__PURE__*/function () {
4195
4341
  return obj[k] !== undefined;
4196
4342
  }).sort();
4197
4343
  return "{".concat(keys.map(function (k) {
4198
- return "".concat(JSON.stringify(k), ":").concat(_this11.stableSerialize(obj[k]));
4344
+ return "".concat(JSON.stringify(k), ":").concat(_this13.stableSerialize(obj[k]));
4199
4345
  }).join(','), "}");
4200
4346
  }
4201
4347
  return JSON.stringify(value);
@@ -4460,18 +4606,18 @@ var Server = /*#__PURE__*/function () {
4460
4606
  }, {
4461
4607
  key: "fetchOrderListFromAPI",
4462
4608
  value: (function () {
4463
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4609
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
4464
4610
  var _this$app9;
4465
4611
  var _response$data5, response, _payload2, list, count, errorMessage;
4466
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4467
- while (1) switch (_context47.prev = _context47.next) {
4612
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4613
+ while (1) switch (_context48.prev = _context48.next) {
4468
4614
  case 0:
4469
4615
  if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4470
- _context47.next = 3;
4616
+ _context48.next = 3;
4471
4617
  break;
4472
4618
  }
4473
4619
  this.logError('fetchOrderListFromAPI: app.request 不可用');
4474
- return _context47.abrupt("return", {
4620
+ return _context48.abrupt("return", {
4475
4621
  code: 500,
4476
4622
  message: 'app.request 不可用',
4477
4623
  data: {
@@ -4481,17 +4627,17 @@ var Server = /*#__PURE__*/function () {
4481
4627
  status: false
4482
4628
  });
4483
4629
  case 3:
4484
- _context47.prev = 3;
4485
- _context47.next = 6;
4630
+ _context48.prev = 3;
4631
+ _context48.next = 6;
4486
4632
  return this.app.request.post('/shop/order/v2/list', data, {
4487
4633
  isShopApi: true
4488
4634
  });
4489
4635
  case 6:
4490
- response = _context47.sent;
4636
+ response = _context48.sent;
4491
4637
  _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4492
4638
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4493
4639
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4494
- return _context47.abrupt("return", {
4640
+ return _context48.abrupt("return", {
4495
4641
  code: 200,
4496
4642
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
4497
4643
  list: list,
@@ -4501,13 +4647,13 @@ var Server = /*#__PURE__*/function () {
4501
4647
  status: true
4502
4648
  });
4503
4649
  case 13:
4504
- _context47.prev = 13;
4505
- _context47.t0 = _context47["catch"](3);
4506
- errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
4650
+ _context48.prev = 13;
4651
+ _context48.t0 = _context48["catch"](3);
4652
+ errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4507
4653
  this.logError('fetchOrderListFromAPI: 请求失败', {
4508
4654
  error: errorMessage
4509
4655
  });
4510
- return _context47.abrupt("return", {
4656
+ return _context48.abrupt("return", {
4511
4657
  code: 500,
4512
4658
  message: errorMessage,
4513
4659
  data: {
@@ -4518,11 +4664,11 @@ var Server = /*#__PURE__*/function () {
4518
4664
  });
4519
4665
  case 18:
4520
4666
  case "end":
4521
- return _context47.stop();
4667
+ return _context48.stop();
4522
4668
  }
4523
- }, _callee47, this, [[3, 13]]);
4669
+ }, _callee48, this, [[3, 13]]);
4524
4670
  }));
4525
- function fetchOrderListFromAPI(_x50) {
4671
+ function fetchOrderListFromAPI(_x51) {
4526
4672
  return _fetchOrderListFromAPI.apply(this, arguments);
4527
4673
  }
4528
4674
  return fetchOrderListFromAPI;
@@ -4534,17 +4680,17 @@ var Server = /*#__PURE__*/function () {
4534
4680
  }, {
4535
4681
  key: "fetchBookingListFromAPI",
4536
4682
  value: (function () {
4537
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
4683
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(data) {
4538
4684
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
4539
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4540
- while (1) switch (_context48.prev = _context48.next) {
4685
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4686
+ while (1) switch (_context49.prev = _context49.next) {
4541
4687
  case 0:
4542
4688
  if (this.order) {
4543
- _context48.next = 3;
4689
+ _context49.next = 3;
4544
4690
  break;
4545
4691
  }
4546
4692
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
4547
- return _context48.abrupt("return", {
4693
+ return _context49.abrupt("return", {
4548
4694
  code: 500,
4549
4695
  message: 'Order 模块不可用',
4550
4696
  data: {
@@ -4554,18 +4700,18 @@ var Server = /*#__PURE__*/function () {
4554
4700
  status: false
4555
4701
  });
4556
4702
  case 3:
4557
- _context48.prev = 3;
4703
+ _context49.prev = 3;
4558
4704
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
4559
4705
  withFields = this.resolveBookingSalesWith(data);
4560
4706
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
4561
4707
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
4562
4708
  if (!memoryCacheEnabled) {
4563
- _context48.next = 13;
4709
+ _context49.next = 13;
4564
4710
  break;
4565
4711
  }
4566
4712
  cached = this.readBookingRemoteCache(cacheKey);
4567
4713
  if (!cached) {
4568
- _context48.next = 13;
4714
+ _context49.next = 13;
4569
4715
  break;
4570
4716
  }
4571
4717
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -4573,14 +4719,14 @@ var Server = /*#__PURE__*/function () {
4573
4719
  listCount: cached.bookingResult.count,
4574
4720
  withFields: cached.withFields
4575
4721
  });
4576
- return _context48.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4722
+ return _context49.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
4577
4723
  cache_hit: true
4578
4724
  }));
4579
4725
  case 13:
4580
- _context48.next = 15;
4726
+ _context49.next = 15;
4581
4727
  return this.order.fetchOrdersBySSE(requestPayload);
4582
4728
  case 15:
4583
- rawList = _context48.sent;
4729
+ rawList = _context49.sent;
4584
4730
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
4585
4731
  if (typeof globalThis !== 'undefined') {
4586
4732
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -4627,15 +4773,15 @@ var Server = /*#__PURE__*/function () {
4627
4773
  cacheKey: cacheKey,
4628
4774
  withFields: withFields
4629
4775
  });
4630
- return _context48.abrupt("return", this.buildBookingResponse(bookingResult));
4776
+ return _context49.abrupt("return", this.buildBookingResponse(bookingResult));
4631
4777
  case 23:
4632
- _context48.prev = 23;
4633
- _context48.t0 = _context48["catch"](3);
4634
- errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4778
+ _context49.prev = 23;
4779
+ _context49.t0 = _context49["catch"](3);
4780
+ errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0);
4635
4781
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
4636
4782
  error: errorMessage
4637
4783
  });
4638
- return _context48.abrupt("return", {
4784
+ return _context49.abrupt("return", {
4639
4785
  code: 500,
4640
4786
  message: errorMessage,
4641
4787
  data: {
@@ -4646,11 +4792,11 @@ var Server = /*#__PURE__*/function () {
4646
4792
  });
4647
4793
  case 28:
4648
4794
  case "end":
4649
- return _context48.stop();
4795
+ return _context49.stop();
4650
4796
  }
4651
- }, _callee48, this, [[3, 23]]);
4797
+ }, _callee49, this, [[3, 23]]);
4652
4798
  }));
4653
- function fetchBookingListFromAPI(_x51) {
4799
+ function fetchBookingListFromAPI(_x52) {
4654
4800
  return _fetchBookingListFromAPI.apply(this, arguments);
4655
4801
  }
4656
4802
  return fetchBookingListFromAPI;
@@ -4734,11 +4880,11 @@ var Server = /*#__PURE__*/function () {
4734
4880
  }, {
4735
4881
  key: "runLocalPaymentUpdateInQueue",
4736
4882
  value: function () {
4737
- var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
4738
- var _this12 = this;
4883
+ var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(key, task, context) {
4884
+ var _this14 = this;
4739
4885
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4740
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4741
- while (1) switch (_context50.prev = _context50.next) {
4886
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4887
+ while (1) switch (_context51.prev = _context51.next) {
4742
4888
  case 0:
4743
4889
  queuedAt = Date.now();
4744
4890
  hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -4750,20 +4896,20 @@ var Server = /*#__PURE__*/function () {
4750
4896
  }));
4751
4897
  current = previous.catch(function () {
4752
4898
  return undefined;
4753
- }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4754
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4755
- while (1) switch (_context49.prev = _context49.next) {
4899
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4900
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4901
+ while (1) switch (_context50.prev = _context50.next) {
4756
4902
  case 0:
4757
- _this12.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4903
+ _this14.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4758
4904
  queue_key: key,
4759
4905
  queue_wait_ms: Date.now() - queuedAt
4760
4906
  }));
4761
- return _context49.abrupt("return", task());
4907
+ return _context50.abrupt("return", task());
4762
4908
  case 2:
4763
4909
  case "end":
4764
- return _context49.stop();
4910
+ return _context50.stop();
4765
4911
  }
4766
- }, _callee49);
4912
+ }, _callee50);
4767
4913
  })));
4768
4914
  tail = current.then(function () {
4769
4915
  return undefined;
@@ -4771,11 +4917,11 @@ var Server = /*#__PURE__*/function () {
4771
4917
  return undefined;
4772
4918
  });
4773
4919
  this.localPaymentUpdateQueues.set(key, tail);
4774
- _context50.prev = 7;
4775
- _context50.next = 10;
4920
+ _context51.prev = 7;
4921
+ _context51.next = 10;
4776
4922
  return current;
4777
4923
  case 10:
4778
- result = _context50.sent;
4924
+ result = _context51.sent;
4779
4925
  this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
4780
4926
  queue_key: key,
4781
4927
  total_duration_ms: Date.now() - queuedAt,
@@ -4783,19 +4929,19 @@ var Server = /*#__PURE__*/function () {
4783
4929
  result_status: result === null || result === void 0 ? void 0 : result.status,
4784
4930
  payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
4785
4931
  }));
4786
- return _context50.abrupt("return", result);
4932
+ return _context51.abrupt("return", result);
4787
4933
  case 15:
4788
- _context50.prev = 15;
4789
- _context50.t0 = _context50["catch"](7);
4934
+ _context51.prev = 15;
4935
+ _context51.t0 = _context51["catch"](7);
4790
4936
  this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
4791
4937
  queue_key: key,
4792
4938
  total_duration_ms: Date.now() - queuedAt,
4793
- error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
4794
- error_detail: this.normalizeUnknownError(_context50.t0)
4939
+ error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
4940
+ error_detail: this.normalizeUnknownError(_context51.t0)
4795
4941
  }));
4796
- throw _context50.t0;
4942
+ throw _context51.t0;
4797
4943
  case 19:
4798
- _context50.prev = 19;
4944
+ _context51.prev = 19;
4799
4945
  released = false;
4800
4946
  if (this.localPaymentUpdateQueues.get(key) === tail) {
4801
4947
  this.localPaymentUpdateQueues.delete(key);
@@ -4806,14 +4952,14 @@ var Server = /*#__PURE__*/function () {
4806
4952
  released: released,
4807
4953
  active_queue_count: this.localPaymentUpdateQueues.size
4808
4954
  }));
4809
- return _context50.finish(19);
4955
+ return _context51.finish(19);
4810
4956
  case 24:
4811
4957
  case "end":
4812
- return _context50.stop();
4958
+ return _context51.stop();
4813
4959
  }
4814
- }, _callee50, this, [[7, 15, 19, 24]]);
4960
+ }, _callee51, this, [[7, 15, 19, 24]]);
4815
4961
  }));
4816
- function runLocalPaymentUpdateInQueue(_x52, _x53, _x54) {
4962
+ function runLocalPaymentUpdateInQueue(_x53, _x54, _x55) {
4817
4963
  return _runLocalPaymentUpdateInQueue.apply(this, arguments);
4818
4964
  }
4819
4965
  return runLocalPaymentUpdateInQueue;
@@ -4821,11 +4967,11 @@ var Server = /*#__PURE__*/function () {
4821
4967
  }, {
4822
4968
  key: "processLocalPaymentUpdate",
4823
4969
  value: function () {
4824
- var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4970
+ var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4825
4971
  var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
4826
4972
  var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
4827
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4828
- while (1) switch (_context51.prev = _context51.next) {
4973
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4974
+ while (1) switch (_context52.prev = _context52.next) {
4829
4975
  case 0:
4830
4976
  requestContext = {
4831
4977
  operation_id: params.operationId,
@@ -4838,11 +4984,11 @@ var Server = /*#__PURE__*/function () {
4838
4984
  };
4839
4985
  this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
4840
4986
  if (this.order) {
4841
- _context51.next = 5;
4987
+ _context52.next = 5;
4842
4988
  break;
4843
4989
  }
4844
4990
  this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
4845
- return _context51.abrupt("return", {
4991
+ return _context52.abrupt("return", {
4846
4992
  code: 500,
4847
4993
  status: false,
4848
4994
  message: 'Order 模块未注册',
@@ -4850,20 +4996,20 @@ var Server = /*#__PURE__*/function () {
4850
4996
  });
4851
4997
  case 5:
4852
4998
  this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
4853
- _context51.next = 8;
4999
+ _context52.next = 8;
4854
5000
  return this.order.getLocalPayment({
4855
5001
  saleId: params.saleId,
4856
5002
  paymentNumber: params.paymentNumber,
4857
5003
  operationId: params.operationId
4858
5004
  });
4859
5005
  case 8:
4860
- found = _context51.sent;
5006
+ found = _context52.sent;
4861
5007
  if (found) {
4862
- _context51.next = 12;
5008
+ _context52.next = 12;
4863
5009
  break;
4864
5010
  }
4865
5011
  this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
4866
- return _context51.abrupt("return", {
5012
+ return _context52.abrupt("return", {
4867
5013
  code: 404,
4868
5014
  status: false,
4869
5015
  message: '本地支付项不存在',
@@ -4912,13 +5058,13 @@ var Server = /*#__PURE__*/function () {
4912
5058
  });
4913
5059
  this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
4914
5060
  if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
4915
- _context51.next = 23;
5061
+ _context52.next = 23;
4916
5062
  break;
4917
5063
  }
4918
5064
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4919
5065
  idempotent_reason: 'ignore_failure_after_success'
4920
5066
  }));
4921
- return _context51.abrupt("return", {
5067
+ return _context52.abrupt("return", {
4922
5068
  code: 200,
4923
5069
  status: true,
4924
5070
  message: '',
@@ -4931,13 +5077,13 @@ var Server = /*#__PURE__*/function () {
4931
5077
  case 23:
4932
5078
  alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
4933
5079
  if (!alreadyRecordedFailure) {
4934
- _context51.next = 27;
5080
+ _context52.next = 27;
4935
5081
  break;
4936
5082
  }
4937
5083
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4938
5084
  idempotent_reason: 'failure_already_recorded'
4939
5085
  }));
4940
- return _context51.abrupt("return", {
5086
+ return _context52.abrupt("return", {
4941
5087
  code: 200,
4942
5088
  status: true,
4943
5089
  message: '',
@@ -4949,13 +5095,13 @@ var Server = /*#__PURE__*/function () {
4949
5095
  });
4950
5096
  case 27:
4951
5097
  if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
4952
- _context51.next = 30;
5098
+ _context52.next = 30;
4953
5099
  break;
4954
5100
  }
4955
5101
  this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
4956
5102
  idempotent_reason: 'success_already_committed'
4957
5103
  }));
4958
- return _context51.abrupt("return", {
5104
+ return _context52.abrupt("return", {
4959
5105
  code: 200,
4960
5106
  status: true,
4961
5107
  message: '',
@@ -4967,13 +5113,13 @@ var Server = /*#__PURE__*/function () {
4967
5113
  });
4968
5114
  case 30:
4969
5115
  if (!(params.status === 'success')) {
4970
- _context51.next = 33;
5116
+ _context52.next = 33;
4971
5117
  break;
4972
5118
  }
4973
5119
  this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4974
5120
  force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
4975
5121
  }));
4976
- return _context51.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
5122
+ return _context52.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
4977
5123
  order: found.order,
4978
5124
  payment: found.payment,
4979
5125
  matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
@@ -4984,8 +5130,8 @@ var Server = /*#__PURE__*/function () {
4984
5130
  this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
4985
5131
  incoming_payment_update: incomingPaymentUpdate
4986
5132
  }));
4987
- _context51.prev = 34;
4988
- _context51.next = 37;
5133
+ _context52.prev = 34;
5134
+ _context52.next = 37;
4989
5135
  return this.order.updateLocalPayment({
4990
5136
  saleId: params.saleId,
4991
5137
  paymentNumber: params.paymentNumber,
@@ -4993,25 +5139,25 @@ var Server = /*#__PURE__*/function () {
4993
5139
  updates: incomingPaymentUpdate
4994
5140
  });
4995
5141
  case 37:
4996
- updated = _context51.sent;
4997
- _context51.next = 44;
5142
+ updated = _context52.sent;
5143
+ _context52.next = 44;
4998
5144
  break;
4999
5145
  case 40:
5000
- _context51.prev = 40;
5001
- _context51.t0 = _context51["catch"](34);
5146
+ _context52.prev = 40;
5147
+ _context52.t0 = _context52["catch"](34);
5002
5148
  this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
5003
5149
  incoming_payment_update: incomingPaymentUpdate,
5004
- error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
5005
- error_detail: this.normalizeUnknownError(_context51.t0)
5150
+ error: _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0),
5151
+ error_detail: this.normalizeUnknownError(_context52.t0)
5006
5152
  }));
5007
- throw _context51.t0;
5153
+ throw _context52.t0;
5008
5154
  case 44:
5009
5155
  if (updated) {
5010
- _context51.next = 47;
5156
+ _context52.next = 47;
5011
5157
  break;
5012
5158
  }
5013
5159
  this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
5014
- return _context51.abrupt("return", {
5160
+ return _context52.abrupt("return", {
5015
5161
  code: 404,
5016
5162
  status: false,
5017
5163
  message: '本地支付项不存在',
@@ -5022,7 +5168,7 @@ var Server = /*#__PURE__*/function () {
5022
5168
  previous_payment: updated.previousPayment,
5023
5169
  payment: updated.payment
5024
5170
  }));
5025
- return _context51.abrupt("return", {
5171
+ return _context52.abrupt("return", {
5026
5172
  code: 200,
5027
5173
  status: true,
5028
5174
  message: '',
@@ -5034,11 +5180,11 @@ var Server = /*#__PURE__*/function () {
5034
5180
  });
5035
5181
  case 49:
5036
5182
  case "end":
5037
- return _context51.stop();
5183
+ return _context52.stop();
5038
5184
  }
5039
- }, _callee51, this, [[34, 40]]);
5185
+ }, _callee52, this, [[34, 40]]);
5040
5186
  }));
5041
- function processLocalPaymentUpdate(_x55) {
5187
+ function processLocalPaymentUpdate(_x56) {
5042
5188
  return _processLocalPaymentUpdate.apply(this, arguments);
5043
5189
  }
5044
5190
  return processLocalPaymentUpdate;
@@ -5046,10 +5192,10 @@ var Server = /*#__PURE__*/function () {
5046
5192
  }, {
5047
5193
  key: "processSuccessfulLocalPayment",
5048
5194
  value: function () {
5049
- var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5195
+ var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5050
5196
  var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
5051
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5052
- while (1) switch (_context52.prev = _context52.next) {
5197
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5198
+ while (1) switch (_context53.prev = _context53.next) {
5053
5199
  case 0:
5054
5200
  moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
5055
5201
  baseSales = new BaseSalesImpl(moduleName);
@@ -5068,13 +5214,13 @@ var Server = /*#__PURE__*/function () {
5068
5214
  payment: params.payment
5069
5215
  });
5070
5216
  this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
5071
- _context52.prev = 5;
5217
+ _context53.prev = 5;
5072
5218
  order = this.sanitizeLocalRecoveryOrder(params.order);
5073
5219
  this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5074
5220
  sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
5075
5221
  removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
5076
5222
  }));
5077
- _context52.next = 10;
5223
+ _context53.next = 10;
5078
5224
  return baseSales.initialize(this.core, {
5079
5225
  otherParams: {
5080
5226
  platform: order.platform,
@@ -5087,14 +5233,14 @@ var Server = /*#__PURE__*/function () {
5087
5233
  });
5088
5234
  case 10:
5089
5235
  this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
5090
- _context52.next = 13;
5236
+ _context53.next = 13;
5091
5237
  return baseSales.replaceTempOrder(order);
5092
5238
  case 13:
5093
5239
  this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
5094
5240
  this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5095
5241
  incoming_payment_update: params.paymentUpdate
5096
5242
  }));
5097
- _context52.next = 17;
5243
+ _context53.next = 17;
5098
5244
  return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
5099
5245
  submitWhenPaid: true,
5100
5246
  matchBy: params.matchBy,
@@ -5103,7 +5249,7 @@ var Server = /*#__PURE__*/function () {
5103
5249
  smallTicketDataFlag: 1
5104
5250
  });
5105
5251
  case 17:
5106
- result = _context52.sent;
5252
+ result = _context53.sent;
5107
5253
  this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5108
5254
  duration_ms: Date.now() - startedAt,
5109
5255
  payment: result.payment,
@@ -5125,7 +5271,7 @@ var Server = /*#__PURE__*/function () {
5125
5271
  } : null,
5126
5272
  draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
5127
5273
  }));
5128
- return _context52.abrupt("return", {
5274
+ return _context53.abrupt("return", {
5129
5275
  code: 200,
5130
5276
  status: true,
5131
5277
  message: '',
@@ -5137,48 +5283,48 @@ var Server = /*#__PURE__*/function () {
5137
5283
  }
5138
5284
  });
5139
5285
  case 22:
5140
- _context52.prev = 22;
5141
- _context52.t0 = _context52["catch"](5);
5142
- message = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
5286
+ _context53.prev = 22;
5287
+ _context53.t0 = _context53["catch"](5);
5288
+ message = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5143
5289
  this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5144
5290
  duration_ms: Date.now() - startedAt,
5145
5291
  error: message,
5146
- error_detail: this.normalizeUnknownError(_context52.t0)
5292
+ error_detail: this.normalizeUnknownError(_context53.t0)
5147
5293
  }));
5148
- return _context52.abrupt("return", {
5294
+ return _context53.abrupt("return", {
5149
5295
  code: 500,
5150
5296
  status: false,
5151
5297
  message: message,
5152
5298
  data: null
5153
5299
  });
5154
5300
  case 27:
5155
- _context52.prev = 27;
5156
- _context52.prev = 28;
5157
- _context52.next = 31;
5301
+ _context53.prev = 27;
5302
+ _context53.prev = 28;
5303
+ _context53.next = 31;
5158
5304
  return baseSales.destroy();
5159
5305
  case 31:
5160
5306
  this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5161
5307
  duration_ms: Date.now() - startedAt
5162
5308
  }));
5163
- _context52.next = 37;
5309
+ _context53.next = 37;
5164
5310
  break;
5165
5311
  case 34:
5166
- _context52.prev = 34;
5167
- _context52.t1 = _context52["catch"](28);
5312
+ _context53.prev = 34;
5313
+ _context53.t1 = _context53["catch"](28);
5168
5314
  this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
5169
5315
  duration_ms: Date.now() - startedAt,
5170
- error: _context52.t1 instanceof Error ? _context52.t1.message : String(_context52.t1),
5171
- error_detail: this.normalizeUnknownError(_context52.t1)
5316
+ error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1),
5317
+ error_detail: this.normalizeUnknownError(_context53.t1)
5172
5318
  }));
5173
5319
  case 37:
5174
- return _context52.finish(27);
5320
+ return _context53.finish(27);
5175
5321
  case 38:
5176
5322
  case "end":
5177
- return _context52.stop();
5323
+ return _context53.stop();
5178
5324
  }
5179
- }, _callee52, this, [[5, 22, 27, 38], [28, 34]]);
5325
+ }, _callee53, this, [[5, 22, 27, 38], [28, 34]]);
5180
5326
  }));
5181
- function processSuccessfulLocalPayment(_x56) {
5327
+ function processSuccessfulLocalPayment(_x57) {
5182
5328
  return _processSuccessfulLocalPayment.apply(this, arguments);
5183
5329
  }
5184
5330
  return processSuccessfulLocalPayment;
@@ -5269,32 +5415,32 @@ var Server = /*#__PURE__*/function () {
5269
5415
  }, {
5270
5416
  key: "getShortNumberOrDeviceId",
5271
5417
  value: function () {
5272
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5418
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5273
5419
  var getAsyncIotDeviceInfo, res;
5274
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5275
- while (1) switch (_context53.prev = _context53.next) {
5420
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5421
+ while (1) switch (_context54.prev = _context54.next) {
5276
5422
  case 0:
5277
5423
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
5278
5424
  if (!getAsyncIotDeviceInfo) {
5279
- _context53.next = 7;
5425
+ _context54.next = 7;
5280
5426
  break;
5281
5427
  }
5282
- _context53.next = 4;
5428
+ _context54.next = 4;
5283
5429
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
5284
5430
  case 4:
5285
- res = _context53.sent;
5431
+ res = _context54.sent;
5286
5432
  if (!(res !== null && res !== void 0 && res.short_number)) {
5287
- _context53.next = 7;
5433
+ _context54.next = 7;
5288
5434
  break;
5289
5435
  }
5290
- return _context53.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5436
+ return _context54.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
5291
5437
  case 7:
5292
- return _context53.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5438
+ return _context54.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
5293
5439
  case 8:
5294
5440
  case "end":
5295
- return _context53.stop();
5441
+ return _context54.stop();
5296
5442
  }
5297
- }, _callee53, this);
5443
+ }, _callee54, this);
5298
5444
  }));
5299
5445
  function getShortNumberOrDeviceId() {
5300
5446
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -5354,12 +5500,12 @@ var Server = /*#__PURE__*/function () {
5354
5500
  }, {
5355
5501
  key: "buildCheckoutResourceIdentifierBuzzer",
5356
5502
  value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5357
- var _this13 = this;
5503
+ var _this15 = this;
5358
5504
  if (!Array.isArray(bookings)) return '';
5359
5505
  var values = [];
5360
5506
  var seen = new Set();
5361
5507
  var visitResource = function visitResource(resource, fallbackName) {
5362
- var identifier = _this13.getCheckoutResourceIdentifier(resource, fallbackName);
5508
+ var identifier = _this15.getCheckoutResourceIdentifier(resource, fallbackName);
5363
5509
  if (identifier && !seen.has(identifier)) {
5364
5510
  seen.add(identifier);
5365
5511
  values.push(identifier);
@@ -5411,16 +5557,16 @@ var Server = /*#__PURE__*/function () {
5411
5557
  }, {
5412
5558
  key: "normalizeCheckoutSubmitData",
5413
5559
  value: function () {
5414
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5560
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
5415
5561
  var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5416
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5417
- while (1) switch (_context54.prev = _context54.next) {
5562
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5563
+ while (1) switch (_context55.prev = _context55.next) {
5418
5564
  case 0:
5419
5565
  if (!(!data || _typeof(data) !== 'object')) {
5420
- _context54.next = 2;
5566
+ _context55.next = 2;
5421
5567
  break;
5422
5568
  }
5423
- return _context54.abrupt("return", data);
5569
+ return _context55.abrupt("return", data);
5424
5570
  case 2:
5425
5571
  next = _objectSpread({}, data);
5426
5572
  externalSaleNumber = next.external_sale_number;
@@ -5430,7 +5576,7 @@ var Server = /*#__PURE__*/function () {
5430
5576
  delete next.vouchers;
5431
5577
  hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5432
5578
  if (!hasCheckoutOrderNumbers) {
5433
- _context54.next = 11;
5579
+ _context55.next = 11;
5434
5580
  break;
5435
5581
  }
5436
5582
  this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
@@ -5440,10 +5586,10 @@ var Server = /*#__PURE__*/function () {
5440
5586
  shop_order_number: next.shop_order_number,
5441
5587
  shop_full_order_number: next.shop_full_order_number
5442
5588
  });
5443
- return _context54.abrupt("return", next);
5589
+ return _context55.abrupt("return", next);
5444
5590
  case 11:
5445
5591
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
5446
- _context54.next = 14;
5592
+ _context55.next = 14;
5447
5593
  break;
5448
5594
  }
5449
5595
  if (shouldClearLocalOrderId) {
@@ -5452,10 +5598,10 @@ var Server = /*#__PURE__*/function () {
5452
5598
  order_id: next.order_id
5453
5599
  });
5454
5600
  }
5455
- return _context54.abrupt("return", next);
5601
+ return _context55.abrupt("return", next);
5456
5602
  case 14:
5457
5603
  if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
5458
- _context54.next = 17;
5604
+ _context55.next = 17;
5459
5605
  break;
5460
5606
  }
5461
5607
  if (shouldClearLocalOrderId) {
@@ -5464,12 +5610,12 @@ var Server = /*#__PURE__*/function () {
5464
5610
  external_sale_number: externalSaleNumber
5465
5611
  });
5466
5612
  }
5467
- return _context54.abrupt("return", next);
5613
+ return _context55.abrupt("return", next);
5468
5614
  case 17:
5469
- _context54.prev = 17;
5615
+ _context55.prev = 17;
5470
5616
  localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
5471
5617
  if (localOrder) {
5472
- _context54.next = 22;
5618
+ _context55.next = 22;
5473
5619
  break;
5474
5620
  }
5475
5621
  if (shouldClearLocalOrderId) {
@@ -5479,7 +5625,7 @@ var Server = /*#__PURE__*/function () {
5479
5625
  localOrderFound: false
5480
5626
  });
5481
5627
  }
5482
- return _context54.abrupt("return", next);
5628
+ return _context55.abrupt("return", next);
5483
5629
  case 22:
5484
5630
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
5485
5631
  next.shop_order_number = localOrder.shop_order_number;
@@ -5496,23 +5642,23 @@ var Server = /*#__PURE__*/function () {
5496
5642
  shop_full_order_number: next.shop_full_order_number
5497
5643
  });
5498
5644
  // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5499
- return _context54.abrupt("return", next);
5645
+ return _context55.abrupt("return", next);
5500
5646
  case 28:
5501
- _context54.prev = 28;
5502
- _context54.t0 = _context54["catch"](17);
5647
+ _context55.prev = 28;
5648
+ _context55.t0 = _context55["catch"](17);
5503
5649
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
5504
5650
  external_sale_number: externalSaleNumber,
5505
- error: this.getUnknownErrorMessage(_context54.t0),
5506
- error_detail: this.normalizeUnknownError(_context54.t0)
5651
+ error: this.getUnknownErrorMessage(_context55.t0),
5652
+ error_detail: this.normalizeUnknownError(_context55.t0)
5507
5653
  });
5508
- return _context54.abrupt("return", next);
5654
+ return _context55.abrupt("return", next);
5509
5655
  case 32:
5510
5656
  case "end":
5511
- return _context54.stop();
5657
+ return _context55.stop();
5512
5658
  }
5513
- }, _callee54, this, [[17, 28]]);
5659
+ }, _callee55, this, [[17, 28]]);
5514
5660
  }));
5515
- function normalizeCheckoutSubmitData(_x57, _x58) {
5661
+ function normalizeCheckoutSubmitData(_x58, _x59) {
5516
5662
  return _normalizeCheckoutSubmitData.apply(this, arguments);
5517
5663
  }
5518
5664
  return normalizeCheckoutSubmitData;
@@ -5520,109 +5666,148 @@ var Server = /*#__PURE__*/function () {
5520
5666
  }, {
5521
5667
  key: "ensureCheckoutOrderNumbers",
5522
5668
  value: function () {
5523
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
5669
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(data, title) {
5524
5670
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
5525
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5526
- while (1) switch (_context55.prev = _context55.next) {
5671
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5672
+ while (1) switch (_context56.prev = _context56.next) {
5527
5673
  case 0:
5528
5674
  if (!(!data || _typeof(data) !== 'object')) {
5529
- _context55.next = 2;
5675
+ _context56.next = 2;
5530
5676
  break;
5531
5677
  }
5532
- return _context55.abrupt("return", data);
5678
+ return _context56.abrupt("return", data);
5533
5679
  case 2:
5534
5680
  next = _objectSpread({}, data);
5535
5681
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
5536
5682
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
5537
5683
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
5538
- _context55.next = 7;
5684
+ _context56.next = 7;
5539
5685
  break;
5540
5686
  }
5541
- return _context55.abrupt("return", next);
5687
+ return _context56.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
5542
5688
  case 7:
5543
5689
  idGenerator = this.getIdGeneratorPlugin();
5544
5690
  if (idGenerator) {
5545
- _context55.next = 11;
5691
+ _context56.next = 11;
5546
5692
  break;
5547
5693
  }
5548
5694
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
5549
5695
  needsShopOrderNumber: needsShopOrderNumber,
5550
5696
  needsShopFullOrderNumber: needsShopFullOrderNumber
5551
5697
  });
5552
- return _context55.abrupt("return", next);
5698
+ return _context56.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
5553
5699
  case 11:
5554
- _context55.prev = 11;
5700
+ _context56.prev = 11;
5555
5701
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
5556
- _context55.next = 16;
5702
+ _context56.next = 16;
5557
5703
  break;
5558
5704
  }
5559
- _context55.next = 15;
5705
+ _context56.next = 15;
5560
5706
  return idGenerator.generateShopOrderNumber({
5561
5707
  biz: next.business_code || 'ticket'
5562
5708
  });
5563
5709
  case 15:
5564
- next.shop_order_number = _context55.sent;
5710
+ next.shop_order_number = _context56.sent;
5565
5711
  case 16:
5566
5712
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
5567
- _context55.next = 20;
5713
+ _context56.next = 20;
5568
5714
  break;
5569
5715
  }
5570
- _context55.next = 19;
5716
+ _context56.next = 19;
5571
5717
  return idGenerator.generateReceiptId({
5572
5718
  biz: next.business_code || 'ticket'
5573
5719
  });
5574
5720
  case 19:
5575
- next.shop_full_order_number = _context55.sent;
5721
+ next.shop_full_order_number = _context56.sent;
5576
5722
  case 20:
5577
5723
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
5578
5724
  shop_order_number: next.shop_order_number,
5579
5725
  shop_full_order_number: next.shop_full_order_number
5580
5726
  });
5581
- _context55.next = 26;
5727
+ _context56.next = 26;
5582
5728
  break;
5583
5729
  case 23:
5584
- _context55.prev = 23;
5585
- _context55.t0 = _context55["catch"](11);
5730
+ _context56.prev = 23;
5731
+ _context56.t0 = _context56["catch"](11);
5586
5732
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
5587
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
5733
+ error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5588
5734
  });
5589
5735
  case 26:
5590
- return _context55.abrupt("return", next);
5736
+ return _context56.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
5591
5737
  case 27:
5592
5738
  case "end":
5593
- return _context55.stop();
5739
+ return _context56.stop();
5594
5740
  }
5595
- }, _callee55, this, [[11, 23]]);
5741
+ }, _callee56, this, [[11, 23]]);
5596
5742
  }));
5597
- function ensureCheckoutOrderNumbers(_x59, _x60) {
5743
+ function ensureCheckoutOrderNumbers(_x60, _x61) {
5598
5744
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
5599
5745
  }
5600
5746
  return ensureCheckoutOrderNumbers;
5601
5747
  }()
5748
+ /**
5749
+ * Notes 允许在本地草稿阶段暂存空订单目标;checkout 的统一出口负责用最终
5750
+ * shop_order_number 完成绑定并校验,保证后端请求、pending、设备任务和打印
5751
+ * 都使用同一份完整快照。
5752
+ */
5753
+ }, {
5754
+ key: "finalizeCheckoutSalesNotes",
5755
+ value: function finalizeCheckoutSalesNotes(data, title) {
5756
+ var _data$shop_order_numb;
5757
+ if (!data || _typeof(data) !== 'object') return data;
5758
+ if (!Object.prototype.hasOwnProperty.call(data, 'notes')) return data;
5759
+ if (data.notes === undefined || data.notes === null) return data;
5760
+ if (!Array.isArray(data.notes)) {
5761
+ throw new Error('[Order Notes] checkout notes 必须为数组');
5762
+ }
5763
+ if (data.notes.length === 0) return data;
5764
+ var productTargetUuids = (Array.isArray(data.products) ? data.products : []).map(function (product) {
5765
+ var _product$metadata$uni, _product$metadata;
5766
+ return (_product$metadata$uni = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product === null || product === void 0 ? void 0 : product.unique_identification_number;
5767
+ }).filter(function (targetUuid) {
5768
+ return targetUuid !== undefined && targetUuid !== null && String(targetUuid).trim().length > 0;
5769
+ }).map(function (targetUuid) {
5770
+ return String(targetUuid);
5771
+ });
5772
+ var shopOrderNumber = String((_data$shop_order_numb = data.shop_order_number) !== null && _data$shop_order_numb !== void 0 ? _data$shop_order_numb : '').trim();
5773
+ var notes = finalizeSalesNotesForCheckout({
5774
+ notes: data.notes,
5775
+ shopOrderNumber: shopOrderNumber,
5776
+ productTargetUuids: productTargetUuids
5777
+ });
5778
+ this.logInfo("".concat(title, ": checkout Notes \u5DF2\u7ED1\u5B9A\u8BA2\u5355\u53F7"), {
5779
+ shop_order_number: shopOrderNumber,
5780
+ note_count: notes.length
5781
+ });
5782
+ return _objectSpread(_objectSpread({}, data), {}, {
5783
+ shop_order_number: shopOrderNumber,
5784
+ notes: notes
5785
+ });
5786
+ }
5602
5787
  }, {
5603
5788
  key: "dispatchCheckoutSyncTask",
5604
5789
  value: function () {
5605
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5790
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5606
5791
  var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
5607
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5608
- while (1) switch (_context56.prev = _context56.next) {
5792
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5793
+ while (1) switch (_context57.prev = _context57.next) {
5609
5794
  case 0:
5610
5795
  this.registerDeviceTaskActions();
5611
5796
  deviceTask = this.getDeviceTaskPlugin();
5612
- _context56.next = 4;
5797
+ _context57.next = 4;
5613
5798
  return this.getShortNumberOrDeviceId();
5614
5799
  case 4:
5615
- debugDeviceId = _context56.sent;
5800
+ debugDeviceId = _context57.sent;
5616
5801
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
5617
5802
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5618
- _context56.next = 9;
5803
+ _context57.next = 9;
5619
5804
  break;
5620
5805
  }
5621
5806
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
5622
- return _context56.abrupt("return");
5807
+ return _context57.abrupt("return");
5623
5808
  case 9:
5624
- _context56.prev = 9;
5625
- _context56.next = 12;
5809
+ _context57.prev = 9;
5810
+ _context57.next = 12;
5626
5811
  return deviceTask.dispatch({
5627
5812
  action: 'sync_sales',
5628
5813
  device_id: debugDeviceId,
@@ -5640,27 +5825,27 @@ var Server = /*#__PURE__*/function () {
5640
5825
  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)
5641
5826
  });
5642
5827
  case 12:
5643
- result = _context56.sent;
5828
+ result = _context57.sent;
5644
5829
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
5645
5830
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
5646
5831
  status: result === null || result === void 0 ? void 0 : result.status,
5647
5832
  reused: result === null || result === void 0 ? void 0 : result.reused
5648
5833
  });
5649
- _context56.next = 19;
5834
+ _context57.next = 19;
5650
5835
  break;
5651
5836
  case 16:
5652
- _context56.prev = 16;
5653
- _context56.t0 = _context56["catch"](9);
5837
+ _context57.prev = 16;
5838
+ _context57.t0 = _context57["catch"](9);
5654
5839
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
5655
- error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
5840
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5656
5841
  });
5657
5842
  case 19:
5658
5843
  case "end":
5659
- return _context56.stop();
5844
+ return _context57.stop();
5660
5845
  }
5661
- }, _callee56, this, [[9, 16]]);
5846
+ }, _callee57, this, [[9, 16]]);
5662
5847
  }));
5663
- function dispatchCheckoutSyncTask(_x61) {
5848
+ function dispatchCheckoutSyncTask(_x62) {
5664
5849
  return _dispatchCheckoutSyncTask.apply(this, arguments);
5665
5850
  }
5666
5851
  return dispatchCheckoutSyncTask;
@@ -5668,26 +5853,26 @@ var Server = /*#__PURE__*/function () {
5668
5853
  }, {
5669
5854
  key: "dispatchPrintOtherReceiptTask",
5670
5855
  value: function () {
5671
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5856
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5672
5857
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
5673
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5674
- while (1) switch (_context57.prev = _context57.next) {
5858
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5859
+ while (1) switch (_context58.prev = _context58.next) {
5675
5860
  case 0:
5676
5861
  deviceTask = this.getDeviceTaskPlugin();
5677
5862
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
5678
- _context57.next = 4;
5863
+ _context58.next = 4;
5679
5864
  break;
5680
5865
  }
5681
5866
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
5682
- return _context57.abrupt("return");
5867
+ return _context58.abrupt("return");
5683
5868
  case 4:
5684
- _context57.prev = 4;
5869
+ _context58.prev = 4;
5685
5870
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
5686
- _context57.next = 8;
5871
+ _context58.next = 8;
5687
5872
  return this.getShortNumberOrDeviceId();
5688
5873
  case 8:
5689
- deviceId = _context57.sent;
5690
- _context57.next = 11;
5874
+ deviceId = _context58.sent;
5875
+ _context58.next = 11;
5691
5876
  return deviceTask.dispatch({
5692
5877
  action: 'print_all',
5693
5878
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -5697,7 +5882,8 @@ var Server = /*#__PURE__*/function () {
5697
5882
  order_id: printIdentity,
5698
5883
  small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
5699
5884
  skip_wristband: true,
5700
- skip_voucher: true
5885
+ skip_voucher: true,
5886
+ skip_discount: true
5701
5887
  } : {
5702
5888
  order_id: printIdentity,
5703
5889
  machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
@@ -5714,21 +5900,21 @@ var Server = /*#__PURE__*/function () {
5714
5900
  source_id: printIdentity
5715
5901
  });
5716
5902
  case 11:
5717
- _context57.next = 16;
5903
+ _context58.next = 16;
5718
5904
  break;
5719
5905
  case 13:
5720
- _context57.prev = 13;
5721
- _context57.t0 = _context57["catch"](4);
5906
+ _context58.prev = 13;
5907
+ _context58.t0 = _context58["catch"](4);
5722
5908
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
5723
- error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5909
+ error: _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0)
5724
5910
  });
5725
5911
  case 16:
5726
5912
  case "end":
5727
- return _context57.stop();
5913
+ return _context58.stop();
5728
5914
  }
5729
- }, _callee57, this, [[4, 13]]);
5915
+ }, _callee58, this, [[4, 13]]);
5730
5916
  }));
5731
- function dispatchPrintOtherReceiptTask(_x62) {
5917
+ function dispatchPrintOtherReceiptTask(_x63) {
5732
5918
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
5733
5919
  }
5734
5920
  return dispatchPrintOtherReceiptTask;
@@ -5748,32 +5934,32 @@ var Server = /*#__PURE__*/function () {
5748
5934
  }, {
5749
5935
  key: "dispatchLocalReceiptPrint",
5750
5936
  value: function () {
5751
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5937
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
5752
5938
  var _payment_info;
5753
5939
  var printableOrder;
5754
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
5755
- while (1) switch (_context58.prev = _context58.next) {
5940
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5941
+ while (1) switch (_context59.prev = _context59.next) {
5756
5942
  case 0:
5757
5943
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
5758
- _context58.next = 2;
5944
+ _context59.next = 2;
5759
5945
  break;
5760
5946
  }
5761
- return _context58.abrupt("return", {
5947
+ return _context59.abrupt("return", {
5762
5948
  printed: false,
5763
5949
  order: params.order
5764
5950
  });
5765
5951
  case 2:
5766
- _context58.next = 4;
5952
+ _context59.next = 4;
5767
5953
  return this.withLocalSmallTicketData(params.order, {
5768
5954
  requireFullyPaid: params.requireFullyPaid
5769
5955
  });
5770
5956
  case 4:
5771
- printableOrder = _context58.sent;
5957
+ printableOrder = _context59.sent;
5772
5958
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
5773
- _context58.next = 7;
5959
+ _context59.next = 7;
5774
5960
  break;
5775
5961
  }
5776
- return _context58.abrupt("return", {
5962
+ return _context59.abrupt("return", {
5777
5963
  printed: false,
5778
5964
  order: printableOrder
5779
5965
  });
@@ -5783,7 +5969,7 @@ var Server = /*#__PURE__*/function () {
5783
5969
  printableOrder: printableOrder,
5784
5970
  response: params.response
5785
5971
  });
5786
- _context58.next = 10;
5972
+ _context59.next = 10;
5787
5973
  return this.dispatchPrintOtherReceiptTask({
5788
5974
  checkoutData: params.checkoutData,
5789
5975
  syncedOrder: printableOrder,
@@ -5792,17 +5978,17 @@ var Server = /*#__PURE__*/function () {
5792
5978
  isManualPrint: params.isManualPrint
5793
5979
  });
5794
5980
  case 10:
5795
- return _context58.abrupt("return", {
5981
+ return _context59.abrupt("return", {
5796
5982
  printed: true,
5797
5983
  order: printableOrder
5798
5984
  });
5799
5985
  case 11:
5800
5986
  case "end":
5801
- return _context58.stop();
5987
+ return _context59.stop();
5802
5988
  }
5803
- }, _callee58, this);
5989
+ }, _callee59, this);
5804
5990
  }));
5805
- function dispatchLocalReceiptPrint(_x63) {
5991
+ function dispatchLocalReceiptPrint(_x64) {
5806
5992
  return _dispatchLocalReceiptPrint.apply(this, arguments);
5807
5993
  }
5808
5994
  return dispatchLocalReceiptPrint;
@@ -5837,47 +6023,47 @@ var Server = /*#__PURE__*/function () {
5837
6023
  }, {
5838
6024
  key: "syncMachinecodeRedeemStatusToLocalOrder",
5839
6025
  value: function () {
5840
- var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data, ids, status) {
6026
+ var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(data, ids, status) {
5841
6027
  var _this$order3;
5842
6028
  var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
5843
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
5844
- while (1) switch (_context59.prev = _context59.next) {
6029
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6030
+ while (1) switch (_context60.prev = _context60.next) {
5845
6031
  case 0:
5846
6032
  title = 'handleMachinecodeBatchMetadata';
5847
6033
  lookup = this.resolveMachinecodeBatchMetadataLookup(data);
5848
6034
  if (!(lookup === undefined)) {
5849
- _context59.next = 5;
6035
+ _context60.next = 5;
5850
6036
  break;
5851
6037
  }
5852
6038
  this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5853
6039
  batchSize: ids.length,
5854
6040
  status: status
5855
6041
  });
5856
- return _context59.abrupt("return");
6042
+ return _context60.abrupt("return");
5857
6043
  case 5:
5858
6044
  if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
5859
- _context59.next = 8;
6045
+ _context60.next = 8;
5860
6046
  break;
5861
6047
  }
5862
6048
  this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5863
6049
  lookup: lookup,
5864
6050
  status: status
5865
6051
  });
5866
- return _context59.abrupt("return");
6052
+ return _context60.abrupt("return");
5867
6053
  case 8:
5868
- _context59.next = 10;
6054
+ _context60.next = 10;
5869
6055
  return this.order.getLocalOrderByLookup(lookup);
5870
6056
  case 10:
5871
- localOrder = _context59.sent;
6057
+ localOrder = _context60.sent;
5872
6058
  if (localOrder) {
5873
- _context59.next = 14;
6059
+ _context60.next = 14;
5874
6060
  break;
5875
6061
  }
5876
6062
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5877
6063
  lookup: lookup,
5878
6064
  status: status
5879
6065
  });
5880
- return _context59.abrupt("return");
6066
+ return _context60.abrupt("return");
5881
6067
  case 14:
5882
6068
  voucherIdSet = new Set(ids.filter(function (id) {
5883
6069
  return id !== undefined && id !== null && id !== '';
@@ -5885,14 +6071,14 @@ var Server = /*#__PURE__*/function () {
5885
6071
  return String(id);
5886
6072
  }));
5887
6073
  if (!(voucherIdSet.size === 0)) {
5888
- _context59.next = 18;
6074
+ _context60.next = 18;
5889
6075
  break;
5890
6076
  }
5891
6077
  this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
5892
6078
  lookup: lookup,
5893
6079
  status: status
5894
6080
  });
5895
- return _context59.abrupt("return");
6081
+ return _context60.abrupt("return");
5896
6082
  case 18:
5897
6083
  vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
5898
6084
  hasUpdatedVoucher = false;
@@ -5906,7 +6092,7 @@ var Server = /*#__PURE__*/function () {
5906
6092
  });
5907
6093
  });
5908
6094
  if (hasUpdatedVoucher) {
5909
- _context59.next = 24;
6095
+ _context60.next = 24;
5910
6096
  break;
5911
6097
  }
5912
6098
  this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
@@ -5914,13 +6100,13 @@ var Server = /*#__PURE__*/function () {
5914
6100
  voucher_ids: Array.from(voucherIdSet),
5915
6101
  status: status
5916
6102
  });
5917
- return _context59.abrupt("return");
6103
+ return _context60.abrupt("return");
5918
6104
  case 24:
5919
6105
  if (!(typeof this.order.overwriteExistingOrder === 'function')) {
5920
- _context59.next = 29;
6106
+ _context60.next = 29;
5921
6107
  break;
5922
6108
  }
5923
- _context59.next = 27;
6109
+ _context60.next = 27;
5924
6110
  return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
5925
6111
  vouchers: nextVouchers
5926
6112
  }));
@@ -5930,13 +6116,13 @@ var Server = /*#__PURE__*/function () {
5930
6116
  updatedCount: voucherIdSet.size,
5931
6117
  status: status
5932
6118
  });
5933
- return _context59.abrupt("return");
6119
+ return _context60.abrupt("return");
5934
6120
  case 29:
5935
6121
  if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
5936
- _context59.next = 34;
6122
+ _context60.next = 34;
5937
6123
  break;
5938
6124
  }
5939
- _context59.next = 32;
6125
+ _context60.next = 32;
5940
6126
  return this.order.markOrderSyncedByExternalSaleNumber({
5941
6127
  externalSaleNumber: data.external_sale_number,
5942
6128
  patch: {
@@ -5949,7 +6135,7 @@ var Server = /*#__PURE__*/function () {
5949
6135
  updatedCount: voucherIdSet.size,
5950
6136
  status: status
5951
6137
  });
5952
- return _context59.abrupt("return");
6138
+ return _context60.abrupt("return");
5953
6139
  case 34:
5954
6140
  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"), {
5955
6141
  lookup: lookup,
@@ -5957,11 +6143,11 @@ var Server = /*#__PURE__*/function () {
5957
6143
  });
5958
6144
  case 35:
5959
6145
  case "end":
5960
- return _context59.stop();
6146
+ return _context60.stop();
5961
6147
  }
5962
- }, _callee59, this);
6148
+ }, _callee60, this);
5963
6149
  }));
5964
- function syncMachinecodeRedeemStatusToLocalOrder(_x64, _x65, _x66) {
6150
+ function syncMachinecodeRedeemStatusToLocalOrder(_x65, _x66, _x67) {
5965
6151
  return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
5966
6152
  }
5967
6153
  return syncMachinecodeRedeemStatusToLocalOrder;
@@ -5969,10 +6155,10 @@ var Server = /*#__PURE__*/function () {
5969
6155
  }, {
5970
6156
  key: "handleOrderCheckoutSubmit",
5971
6157
  value: function () {
5972
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6158
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5973
6159
  var backendPath, data, title, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
5974
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5975
- while (1) switch (_context60.prev = _context60.next) {
6160
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6161
+ while (1) switch (_context61.prev = _context61.next) {
5976
6162
  case 0:
5977
6163
  backendPath = params.backendPath, data = params.data, title = params.title;
5978
6164
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -5982,25 +6168,25 @@ var Server = /*#__PURE__*/function () {
5982
6168
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5983
6169
  });
5984
6170
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5985
- _context60.next = 4;
6171
+ _context61.next = 4;
5986
6172
  break;
5987
6173
  }
5988
- return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
6174
+ return _context61.abrupt("return", this.handleSyncCheckoutSubmit({
5989
6175
  backendPath: backendPath,
5990
6176
  data: data,
5991
6177
  title: title
5992
6178
  }));
5993
6179
  case 4:
5994
- _context60.next = 6;
6180
+ _context61.next = 6;
5995
6181
  return this.normalizeCheckoutSubmitData(data, title);
5996
6182
  case 6:
5997
- normalizedData = _context60.sent;
5998
- _context60.next = 9;
6183
+ normalizedData = _context61.sent;
6184
+ _context61.next = 9;
5999
6185
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6000
6186
  case 9:
6001
- numberedData = _context60.sent;
6187
+ numberedData = _context61.sent;
6002
6188
  checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6003
- _context60.next = 13;
6189
+ _context61.next = 13;
6004
6190
  return this.handlePendingSyncCheckoutOrder({
6005
6191
  backendPath: backendPath,
6006
6192
  data: checkoutData,
@@ -6008,17 +6194,17 @@ var Server = /*#__PURE__*/function () {
6008
6194
  reason: 'checkout 已转入设备任务同步'
6009
6195
  });
6010
6196
  case 13:
6011
- pendingResult = _context60.sent;
6197
+ pendingResult = _context61.sent;
6012
6198
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6013
- _context60.next = 21;
6199
+ _context61.next = 21;
6014
6200
  break;
6015
6201
  }
6016
6202
  pendingOrder = pendingResult.data;
6017
6203
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
6018
- _context60.next = 19;
6204
+ _context61.next = 19;
6019
6205
  break;
6020
6206
  }
6021
- _context60.next = 19;
6207
+ _context61.next = 19;
6022
6208
  return this.dispatchLocalReceiptPrint({
6023
6209
  checkoutData: checkoutData,
6024
6210
  order: pendingOrder,
@@ -6026,7 +6212,7 @@ var Server = /*#__PURE__*/function () {
6026
6212
  requireFullyPaid: true
6027
6213
  });
6028
6214
  case 19:
6029
- _context60.next = 21;
6215
+ _context61.next = 21;
6030
6216
  return this.dispatchCheckoutSyncTask({
6031
6217
  backendPath: backendPath,
6032
6218
  data: checkoutData,
@@ -6034,23 +6220,23 @@ var Server = /*#__PURE__*/function () {
6034
6220
  });
6035
6221
  case 21:
6036
6222
  if (pendingResult.data.order_id) {
6037
- _context60.next = 23;
6223
+ _context61.next = 23;
6038
6224
  break;
6039
6225
  }
6040
- return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6226
+ return _context61.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
6041
6227
  data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
6042
6228
  order_id: pendingResult.data.external_sale_number
6043
6229
  })
6044
6230
  }));
6045
6231
  case 23:
6046
- return _context60.abrupt("return", pendingResult);
6232
+ return _context61.abrupt("return", pendingResult);
6047
6233
  case 24:
6048
6234
  case "end":
6049
- return _context60.stop();
6235
+ return _context61.stop();
6050
6236
  }
6051
- }, _callee60, this);
6237
+ }, _callee61, this);
6052
6238
  }));
6053
- function handleOrderCheckoutSubmit(_x67) {
6239
+ function handleOrderCheckoutSubmit(_x68) {
6054
6240
  return _handleOrderCheckoutSubmit.apply(this, arguments);
6055
6241
  }
6056
6242
  return handleOrderCheckoutSubmit;
@@ -6058,27 +6244,27 @@ var Server = /*#__PURE__*/function () {
6058
6244
  }, {
6059
6245
  key: "handleSyncCheckoutSubmit",
6060
6246
  value: function () {
6061
- var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6247
+ var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6062
6248
  var _this$app16;
6063
6249
  var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6064
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6065
- while (1) switch (_context61.prev = _context61.next) {
6250
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6251
+ while (1) switch (_context62.prev = _context62.next) {
6066
6252
  case 0:
6067
6253
  backendPath = params.backendPath, data = params.data, title = params.title;
6068
6254
  if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
6069
- _context61.next = 4;
6255
+ _context62.next = 4;
6070
6256
  break;
6071
6257
  }
6072
6258
  this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
6073
- return _context61.abrupt("return", {
6259
+ return _context62.abrupt("return", {
6074
6260
  code: 500,
6075
6261
  status: false,
6076
6262
  message: 'app.request 不可用',
6077
6263
  data: null
6078
6264
  });
6079
6265
  case 4:
6080
- _context61.prev = 4;
6081
- _context61.next = 7;
6266
+ _context62.prev = 4;
6267
+ _context62.next = 7;
6082
6268
  return this.runCheckoutSync({
6083
6269
  backendPath: backendPath,
6084
6270
  data: data,
@@ -6086,13 +6272,13 @@ var Server = /*#__PURE__*/function () {
6086
6272
  persistCheckoutDataWithResponse: true
6087
6273
  });
6088
6274
  case 7:
6089
- syncResult = _context61.sent;
6275
+ syncResult = _context62.sent;
6090
6276
  if (!syncResult.rejected) {
6091
- _context61.next = 11;
6277
+ _context62.next = 11;
6092
6278
  break;
6093
6279
  }
6094
6280
  normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
6095
- return _context61.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6281
+ return _context62.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
6096
6282
  status: false,
6097
6283
  message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
6098
6284
  data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
@@ -6101,10 +6287,10 @@ var Server = /*#__PURE__*/function () {
6101
6287
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6102
6288
  syncedOrder = syncResult.syncedOrder;
6103
6289
  if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
6104
- _context61.next = 16;
6290
+ _context62.next = 16;
6105
6291
  break;
6106
6292
  }
6107
- _context61.next = 16;
6293
+ _context62.next = 16;
6108
6294
  return this.dispatchLocalReceiptPrint({
6109
6295
  checkoutData: syncResult.checkoutData,
6110
6296
  order: syncedOrder,
@@ -6113,29 +6299,29 @@ var Server = /*#__PURE__*/function () {
6113
6299
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6114
6300
  });
6115
6301
  case 16:
6116
- return _context61.abrupt("return", response);
6302
+ return _context62.abrupt("return", response);
6117
6303
  case 19:
6118
- _context61.prev = 19;
6119
- _context61.t0 = _context61["catch"](4);
6120
- backendError = this.extractBackendErrorResponse(_context61.t0);
6304
+ _context62.prev = 19;
6305
+ _context62.t0 = _context62["catch"](4);
6306
+ backendError = this.extractBackendErrorResponse(_context62.t0);
6121
6307
  if (!backendError) {
6122
- _context61.next = 25;
6308
+ _context62.next = 25;
6123
6309
  break;
6124
6310
  }
6125
6311
  _normalized = this.normalizeCheckoutResponse(backendError);
6126
- return _context61.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6312
+ return _context62.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
6127
6313
  status: false,
6128
6314
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6129
6315
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6130
6316
  }));
6131
6317
  case 25:
6132
- message = this.getUnknownErrorMessage(_context61.t0);
6318
+ message = this.getUnknownErrorMessage(_context62.t0);
6133
6319
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6134
6320
  backendPath: backendPath,
6135
6321
  error: message,
6136
- error_detail: this.normalizeUnknownError(_context61.t0)
6322
+ error_detail: this.normalizeUnknownError(_context62.t0)
6137
6323
  });
6138
- return _context61.abrupt("return", {
6324
+ return _context62.abrupt("return", {
6139
6325
  code: 500,
6140
6326
  status: false,
6141
6327
  message: message,
@@ -6143,11 +6329,11 @@ var Server = /*#__PURE__*/function () {
6143
6329
  });
6144
6330
  case 28:
6145
6331
  case "end":
6146
- return _context61.stop();
6332
+ return _context62.stop();
6147
6333
  }
6148
- }, _callee61, this, [[4, 19]]);
6334
+ }, _callee62, this, [[4, 19]]);
6149
6335
  }));
6150
- function handleSyncCheckoutSubmit(_x68) {
6336
+ function handleSyncCheckoutSubmit(_x69) {
6151
6337
  return _handleSyncCheckoutSubmit.apply(this, arguments);
6152
6338
  }
6153
6339
  return handleSyncCheckoutSubmit;
@@ -6155,10 +6341,10 @@ var Server = /*#__PURE__*/function () {
6155
6341
  }, {
6156
6342
  key: "handleOrderDraftSubmit",
6157
6343
  value: function () {
6158
- var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6344
+ var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6159
6345
  var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6160
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6161
- while (1) switch (_context62.prev = _context62.next) {
6346
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6347
+ while (1) switch (_context63.prev = _context63.next) {
6162
6348
  case 0:
6163
6349
  data = params.data, title = params.title;
6164
6350
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -6166,10 +6352,10 @@ var Server = /*#__PURE__*/function () {
6166
6352
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6167
6353
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6168
6354
  });
6169
- _context62.next = 4;
6355
+ _context63.next = 4;
6170
6356
  return this.normalizeCheckoutSubmitData(data, title);
6171
6357
  case 4:
6172
- normalizedData = _context62.sent;
6358
+ normalizedData = _context63.sent;
6173
6359
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6174
6360
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
6175
6361
  external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
@@ -6179,26 +6365,26 @@ var Server = /*#__PURE__*/function () {
6179
6365
  is_draft_order: 1
6180
6366
  });
6181
6367
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6182
- _context62.next = 10;
6368
+ _context63.next = 10;
6183
6369
  break;
6184
6370
  }
6185
6371
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
6186
- return _context62.abrupt("return", {
6372
+ return _context63.abrupt("return", {
6187
6373
  code: 500,
6188
6374
  status: false,
6189
6375
  message: 'Order 模块不支持本地草稿写入',
6190
6376
  data: null
6191
6377
  });
6192
6378
  case 10:
6193
- _context62.prev = 10;
6194
- _context62.next = 13;
6379
+ _context63.prev = 10;
6380
+ _context63.next = 13;
6195
6381
  return this.order.upsertLocalDraftOrders([draftOrder]);
6196
6382
  case 13:
6197
6383
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6198
6384
  order_id: draftOrder.order_id,
6199
6385
  external_sale_number: draftOrder.external_sale_number
6200
6386
  });
6201
- return _context62.abrupt("return", {
6387
+ return _context63.abrupt("return", {
6202
6388
  code: 200,
6203
6389
  status: true,
6204
6390
  message: '',
@@ -6210,13 +6396,13 @@ var Server = /*#__PURE__*/function () {
6210
6396
  })
6211
6397
  });
6212
6398
  case 17:
6213
- _context62.prev = 17;
6214
- _context62.t0 = _context62["catch"](10);
6215
- errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6399
+ _context63.prev = 17;
6400
+ _context63.t0 = _context63["catch"](10);
6401
+ errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
6216
6402
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6217
6403
  error: errorMessage
6218
6404
  });
6219
- return _context62.abrupt("return", {
6405
+ return _context63.abrupt("return", {
6220
6406
  code: 500,
6221
6407
  status: false,
6222
6408
  message: errorMessage,
@@ -6224,11 +6410,11 @@ var Server = /*#__PURE__*/function () {
6224
6410
  });
6225
6411
  case 22:
6226
6412
  case "end":
6227
- return _context62.stop();
6413
+ return _context63.stop();
6228
6414
  }
6229
- }, _callee62, this, [[10, 17]]);
6415
+ }, _callee63, this, [[10, 17]]);
6230
6416
  }));
6231
- function handleOrderDraftSubmit(_x69) {
6417
+ function handleOrderDraftSubmit(_x70) {
6232
6418
  return _handleOrderDraftSubmit.apply(this, arguments);
6233
6419
  }
6234
6420
  return handleOrderDraftSubmit;
@@ -6236,26 +6422,26 @@ var Server = /*#__PURE__*/function () {
6236
6422
  }, {
6237
6423
  key: "handlePendingSyncCheckoutOrder",
6238
6424
  value: function () {
6239
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6240
- var _this14 = this;
6425
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6426
+ var _this16 = this;
6241
6427
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6242
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6243
- while (1) switch (_context63.prev = _context63.next) {
6428
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6429
+ while (1) switch (_context64.prev = _context64.next) {
6244
6430
  case 0:
6245
6431
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
6246
- _context63.next = 3;
6432
+ _context64.next = 3;
6247
6433
  return this.buildPendingSyncCheckoutOrder(data);
6248
6434
  case 3:
6249
- pendingOrder = _context63.sent;
6435
+ pendingOrder = _context64.sent;
6250
6436
  if (pendingOrder) {
6251
- _context63.next = 7;
6437
+ _context64.next = 7;
6252
6438
  break;
6253
6439
  }
6254
6440
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
6255
6441
  backendPath: backendPath,
6256
6442
  reason: reason
6257
6443
  });
6258
- return _context63.abrupt("return", {
6444
+ return _context64.abrupt("return", {
6259
6445
  code: 500,
6260
6446
  status: false,
6261
6447
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -6263,22 +6449,22 @@ var Server = /*#__PURE__*/function () {
6263
6449
  });
6264
6450
  case 7:
6265
6451
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
6266
- _context63.next = 10;
6452
+ _context64.next = 10;
6267
6453
  break;
6268
6454
  }
6269
6455
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
6270
6456
  backendPath: backendPath,
6271
6457
  reason: reason
6272
6458
  });
6273
- return _context63.abrupt("return", {
6459
+ return _context64.abrupt("return", {
6274
6460
  code: 500,
6275
6461
  status: false,
6276
6462
  message: 'Order 模块不支持本地待同步写入',
6277
6463
  data: null
6278
6464
  });
6279
6465
  case 10:
6280
- _context63.prev = 10;
6281
- _context63.next = 13;
6466
+ _context64.prev = 10;
6467
+ _context64.next = 13;
6282
6468
  return this.order.upsertPendingSyncOrders([pendingOrder]);
6283
6469
  case 13:
6284
6470
  this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -6290,9 +6476,9 @@ var Server = /*#__PURE__*/function () {
6290
6476
  });
6291
6477
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6292
6478
  var _payment$metadata;
6293
- return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6479
+ 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);
6294
6480
  }, 0);
6295
- return _context63.abrupt("return", {
6481
+ return _context64.abrupt("return", {
6296
6482
  code: 200,
6297
6483
  status: true,
6298
6484
  message: '',
@@ -6307,15 +6493,15 @@ var Server = /*#__PURE__*/function () {
6307
6493
  })
6308
6494
  });
6309
6495
  case 18:
6310
- _context63.prev = 18;
6311
- _context63.t0 = _context63["catch"](10);
6312
- errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
6496
+ _context64.prev = 18;
6497
+ _context64.t0 = _context64["catch"](10);
6498
+ errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
6313
6499
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
6314
6500
  backendPath: backendPath,
6315
6501
  reason: reason,
6316
6502
  error: errorMessage
6317
6503
  });
6318
- return _context63.abrupt("return", {
6504
+ return _context64.abrupt("return", {
6319
6505
  code: 500,
6320
6506
  status: false,
6321
6507
  message: errorMessage,
@@ -6323,11 +6509,11 @@ var Server = /*#__PURE__*/function () {
6323
6509
  });
6324
6510
  case 23:
6325
6511
  case "end":
6326
- return _context63.stop();
6512
+ return _context64.stop();
6327
6513
  }
6328
- }, _callee63, this, [[10, 18]]);
6514
+ }, _callee64, this, [[10, 18]]);
6329
6515
  }));
6330
- function handlePendingSyncCheckoutOrder(_x70) {
6516
+ function handlePendingSyncCheckoutOrder(_x71) {
6331
6517
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
6332
6518
  }
6333
6519
  return handlePendingSyncCheckoutOrder;
@@ -6335,44 +6521,44 @@ var Server = /*#__PURE__*/function () {
6335
6521
  }, {
6336
6522
  key: "buildPendingSyncCheckoutOrder",
6337
6523
  value: function () {
6338
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6524
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(data) {
6339
6525
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6340
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6341
- while (1) switch (_context64.prev = _context64.next) {
6526
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6527
+ while (1) switch (_context65.prev = _context65.next) {
6342
6528
  case 0:
6343
6529
  if (!(!data || _typeof(data) !== 'object')) {
6344
- _context64.next = 2;
6530
+ _context65.next = 2;
6345
6531
  break;
6346
6532
  }
6347
- return _context64.abrupt("return", null);
6533
+ return _context65.abrupt("return", null);
6348
6534
  case 2:
6349
6535
  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 !== '';
6350
6536
  if (hasStorageKey) {
6351
- _context64.next = 5;
6537
+ _context65.next = 5;
6352
6538
  break;
6353
6539
  }
6354
- return _context64.abrupt("return", null);
6540
+ return _context65.abrupt("return", null);
6355
6541
  case 5:
6356
6542
  pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6357
6543
  need_sync: 1,
6358
6544
  is_draft_order: 0
6359
6545
  });
6360
- _context64.next = 8;
6546
+ _context65.next = 8;
6361
6547
  return this.buildSmallTicketProductMap(pendingOrder);
6362
6548
  case 8:
6363
- productMap = _context64.sent;
6549
+ productMap = _context65.sent;
6364
6550
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6365
- return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6551
+ return _context65.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6366
6552
  requireFullyPaid: true,
6367
6553
  productMap: productMap
6368
6554
  }));
6369
6555
  case 11:
6370
6556
  case "end":
6371
- return _context64.stop();
6557
+ return _context65.stop();
6372
6558
  }
6373
- }, _callee64, this);
6559
+ }, _callee65, this);
6374
6560
  }));
6375
- function buildPendingSyncCheckoutOrder(_x71) {
6561
+ function buildPendingSyncCheckoutOrder(_x72) {
6376
6562
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6377
6563
  }
6378
6564
  return buildPendingSyncCheckoutOrder;
@@ -6430,13 +6616,13 @@ var Server = /*#__PURE__*/function () {
6430
6616
  }, {
6431
6617
  key: "sumPaidOrderPayments",
6432
6618
  value: function sumPaidOrderPayments(payments) {
6433
- var _this15 = this;
6619
+ var _this17 = this;
6434
6620
  if (!Array.isArray(payments)) return 0;
6435
6621
  return payments.reduce(function (sum, payment) {
6436
6622
  var _payment$amount;
6437
6623
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6438
6624
  if (status !== 'paid') return sum;
6439
- return sum + _this15.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);
6625
+ 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);
6440
6626
  }, 0);
6441
6627
  }
6442
6628
  }, {
@@ -6450,12 +6636,12 @@ var Server = /*#__PURE__*/function () {
6450
6636
  }, {
6451
6637
  key: "buildSmallTicketProductMap",
6452
6638
  value: function () {
6453
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6639
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6454
6640
  var _this$products3,
6455
- _this16 = this;
6641
+ _this18 = this;
6456
6642
  var products, productIdSet, productIds, entries;
6457
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6458
- while (1) switch (_context66.prev = _context66.next) {
6643
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6644
+ while (1) switch (_context67.prev = _context67.next) {
6459
6645
  case 0:
6460
6646
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
6461
6647
  productIdSet = new Set();
@@ -6477,45 +6663,45 @@ var Server = /*#__PURE__*/function () {
6477
6663
  });
6478
6664
  productIds = Array.from(productIdSet);
6479
6665
  if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
6480
- _context66.next = 6;
6666
+ _context67.next = 6;
6481
6667
  break;
6482
6668
  }
6483
- return _context66.abrupt("return", {});
6669
+ return _context67.abrupt("return", {});
6484
6670
  case 6:
6485
- _context66.next = 8;
6671
+ _context67.next = 8;
6486
6672
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6487
- var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6488
- var _this16$products, _this16$products$getP, product;
6489
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6490
- while (1) switch (_context65.prev = _context65.next) {
6673
+ var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(id) {
6674
+ var _this18$products, _this18$products$getP, product;
6675
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6676
+ while (1) switch (_context66.prev = _context66.next) {
6491
6677
  case 0:
6492
- _context65.prev = 0;
6493
- _context65.next = 3;
6494
- return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
6678
+ _context66.prev = 0;
6679
+ _context66.next = 3;
6680
+ 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));
6495
6681
  case 3:
6496
- product = _context65.sent;
6497
- return _context65.abrupt("return", product ? [String(id), product] : null);
6682
+ product = _context66.sent;
6683
+ return _context66.abrupt("return", product ? [String(id), product] : null);
6498
6684
  case 7:
6499
- _context65.prev = 7;
6500
- _context65.t0 = _context65["catch"](0);
6501
- _this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6685
+ _context66.prev = 7;
6686
+ _context66.t0 = _context66["catch"](0);
6687
+ _this18.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6502
6688
  product_id: id,
6503
- error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6689
+ error: _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0)
6504
6690
  });
6505
- return _context65.abrupt("return", null);
6691
+ return _context66.abrupt("return", null);
6506
6692
  case 11:
6507
6693
  case "end":
6508
- return _context65.stop();
6694
+ return _context66.stop();
6509
6695
  }
6510
- }, _callee65, null, [[0, 7]]);
6696
+ }, _callee66, null, [[0, 7]]);
6511
6697
  }));
6512
- return function (_x73) {
6698
+ return function (_x74) {
6513
6699
  return _ref68.apply(this, arguments);
6514
6700
  };
6515
6701
  }()));
6516
6702
  case 8:
6517
- entries = _context66.sent;
6518
- return _context66.abrupt("return", entries.reduce(function (map, entry) {
6703
+ entries = _context67.sent;
6704
+ return _context67.abrupt("return", entries.reduce(function (map, entry) {
6519
6705
  if (!entry) return map;
6520
6706
  var _entry = _slicedToArray(entry, 2),
6521
6707
  id = _entry[0],
@@ -6525,11 +6711,11 @@ var Server = /*#__PURE__*/function () {
6525
6711
  }, {}));
6526
6712
  case 10:
6527
6713
  case "end":
6528
- return _context66.stop();
6714
+ return _context67.stop();
6529
6715
  }
6530
- }, _callee66, this);
6716
+ }, _callee67, this);
6531
6717
  }));
6532
- function buildSmallTicketProductMap(_x72) {
6718
+ function buildSmallTicketProductMap(_x73) {
6533
6719
  return _buildSmallTicketProductMap.apply(this, arguments);
6534
6720
  }
6535
6721
  return buildSmallTicketProductMap;
@@ -6559,40 +6745,40 @@ var Server = /*#__PURE__*/function () {
6559
6745
  }, {
6560
6746
  key: "buildSalesDetailProductSnapshotMap",
6561
6747
  value: function () {
6562
- var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
6748
+ var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6563
6749
  var _this$products4;
6564
6750
  var productIds, getSnapshots;
6565
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6566
- while (1) switch (_context67.prev = _context67.next) {
6751
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6752
+ while (1) switch (_context68.prev = _context68.next) {
6567
6753
  case 0:
6568
6754
  productIds = this.collectSalesDetailProductIds(order);
6569
6755
  getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
6570
6756
  if (!(!productIds.length || typeof getSnapshots !== 'function')) {
6571
- _context67.next = 4;
6757
+ _context68.next = 4;
6572
6758
  break;
6573
6759
  }
6574
- return _context67.abrupt("return", {});
6760
+ return _context68.abrupt("return", {});
6575
6761
  case 4:
6576
- _context67.prev = 4;
6577
- _context67.next = 7;
6762
+ _context68.prev = 4;
6763
+ _context68.next = 7;
6578
6764
  return getSnapshots.call(this.products, productIds);
6579
6765
  case 7:
6580
- return _context67.abrupt("return", _context67.sent);
6766
+ return _context68.abrupt("return", _context68.sent);
6581
6767
  case 10:
6582
- _context67.prev = 10;
6583
- _context67.t0 = _context67["catch"](4);
6768
+ _context68.prev = 10;
6769
+ _context68.t0 = _context68["catch"](4);
6584
6770
  this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
6585
6771
  product_ids: productIds,
6586
- error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
6772
+ error: _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0)
6587
6773
  });
6588
- return _context67.abrupt("return", {});
6774
+ return _context68.abrupt("return", {});
6589
6775
  case 14:
6590
6776
  case "end":
6591
- return _context67.stop();
6777
+ return _context68.stop();
6592
6778
  }
6593
- }, _callee67, this, [[4, 10]]);
6779
+ }, _callee68, this, [[4, 10]]);
6594
6780
  }));
6595
- function buildSalesDetailProductSnapshotMap(_x74) {
6781
+ function buildSalesDetailProductSnapshotMap(_x75) {
6596
6782
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6597
6783
  }
6598
6784
  return buildSalesDetailProductSnapshotMap;
@@ -6648,53 +6834,53 @@ var Server = /*#__PURE__*/function () {
6648
6834
  }, {
6649
6835
  key: "withSalesDetailProductSnapshots",
6650
6836
  value: function () {
6651
- var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6652
- var _this17 = this;
6837
+ var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6838
+ var _this19 = this;
6653
6839
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6654
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6655
- while (1) switch (_context68.prev = _context68.next) {
6840
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6841
+ while (1) switch (_context69.prev = _context69.next) {
6656
6842
  case 0:
6657
6843
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
6658
6844
  if (products !== null && products !== void 0 && products.length) {
6659
- _context68.next = 3;
6845
+ _context69.next = 3;
6660
6846
  break;
6661
6847
  }
6662
- return _context68.abrupt("return", order);
6848
+ return _context69.abrupt("return", order);
6663
6849
  case 3:
6664
- _context68.next = 5;
6850
+ _context69.next = 5;
6665
6851
  return this.buildSalesDetailProductSnapshotMap(order);
6666
6852
  case 5:
6667
- snapshotMap = _context68.sent;
6853
+ snapshotMap = _context69.sent;
6668
6854
  if (Object.keys(snapshotMap).length) {
6669
- _context68.next = 8;
6855
+ _context69.next = 8;
6670
6856
  break;
6671
6857
  }
6672
- return _context68.abrupt("return", order);
6858
+ return _context69.abrupt("return", order);
6673
6859
  case 8:
6674
6860
  hasChanged = false;
6675
6861
  enrichedProducts = products.map(function (product) {
6676
- var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
6677
- var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6862
+ var productWithBundleSnapshots = _this19.withBundleCatalogSnapshots(product, snapshotMap);
6863
+ var nextProduct = _this19.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6678
6864
  if (nextProduct !== product) hasChanged = true;
6679
6865
  return nextProduct;
6680
6866
  });
6681
6867
  if (hasChanged) {
6682
- _context68.next = 12;
6868
+ _context69.next = 12;
6683
6869
  break;
6684
6870
  }
6685
- return _context68.abrupt("return", order);
6871
+ return _context69.abrupt("return", order);
6686
6872
  case 12:
6687
6873
  enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
6688
6874
  products: enrichedProducts
6689
6875
  });
6690
- return _context68.abrupt("return", enrichedOrder);
6876
+ return _context69.abrupt("return", enrichedOrder);
6691
6877
  case 14:
6692
6878
  case "end":
6693
- return _context68.stop();
6879
+ return _context69.stop();
6694
6880
  }
6695
- }, _callee68, this);
6881
+ }, _callee69, this);
6696
6882
  }));
6697
- function withSalesDetailProductSnapshots(_x75) {
6883
+ function withSalesDetailProductSnapshots(_x76) {
6698
6884
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6699
6885
  }
6700
6886
  return withSalesDetailProductSnapshots;
@@ -6702,13 +6888,13 @@ var Server = /*#__PURE__*/function () {
6702
6888
  }, {
6703
6889
  key: "withPendingSyncProductTitles",
6704
6890
  value: function withPendingSyncProductTitles(order, productMap) {
6705
- var _this18 = this;
6891
+ var _this20 = this;
6706
6892
  var products = Array.isArray(order.products) ? order.products : null;
6707
6893
  if (!(products !== null && products !== void 0 && products.length)) return order;
6708
6894
  return _objectSpread(_objectSpread({}, order), {}, {
6709
6895
  products: products.map(function (product) {
6710
6896
  return _objectSpread(_objectSpread({}, product), {}, {
6711
- product_title: _this18.buildProductTitleSnapshot(product, productMap)
6897
+ product_title: _this20.buildProductTitleSnapshot(product, productMap)
6712
6898
  });
6713
6899
  })
6714
6900
  });
@@ -6719,7 +6905,7 @@ var Server = /*#__PURE__*/function () {
6719
6905
  var _product$product_id4,
6720
6906
  _product$product,
6721
6907
  _fallbackProduct$prod,
6722
- _this19 = this;
6908
+ _this21 = this;
6723
6909
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6724
6910
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6725
6911
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6727,7 +6913,7 @@ var Server = /*#__PURE__*/function () {
6727
6913
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6728
6914
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6729
6915
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6730
- snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6916
+ snapshot[key] = _this21.resolveProductTitleValue(ownTitle, key, currentLocale) || _this21.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6731
6917
  return snapshot;
6732
6918
  }, {});
6733
6919
  }
@@ -6825,31 +7011,31 @@ var Server = /*#__PURE__*/function () {
6825
7011
  }, {
6826
7012
  key: "enrichPaymentNamesByCode",
6827
7013
  value: function () {
6828
- var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6829
- var _this20 = this;
7014
+ var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order) {
7015
+ var _this22 = this;
6830
7016
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6831
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6832
- while (1) switch (_context69.prev = _context69.next) {
7017
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7018
+ while (1) switch (_context70.prev = _context70.next) {
6833
7019
  case 0:
6834
7020
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6835
7021
  hasMissingName = payments.some(function (payment) {
6836
- return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
7022
+ return _this22.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this22.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6837
7023
  });
6838
7024
  if (hasMissingName) {
6839
- _context69.next = 4;
7025
+ _context70.next = 4;
6840
7026
  break;
6841
7027
  }
6842
- return _context69.abrupt("return", order);
7028
+ return _context70.abrupt("return", order);
6843
7029
  case 4:
6844
- _context69.prev = 4;
6845
- _context69.next = 7;
7030
+ _context70.prev = 4;
7031
+ _context70.next = 7;
6846
7032
  return this.getPaymentRouteModule();
6847
7033
  case 7:
6848
- paymentModule = _context69.sent;
6849
- _context69.next = 10;
7034
+ paymentModule = _context70.sent;
7035
+ _context70.next = 10;
6850
7036
  return paymentModule.getPayMethodListAsync();
6851
7037
  case 10:
6852
- payMethods = _context69.sent;
7038
+ payMethods = _context70.sent;
6853
7039
  nameByCode = new Map();
6854
7040
  _iterator12 = _createForOfIteratorHelper(payMethods || []);
6855
7041
  try {
@@ -6866,9 +7052,9 @@ var Server = /*#__PURE__*/function () {
6866
7052
  }
6867
7053
  hasResolvedName = false;
6868
7054
  enrichedPayments = payments.map(function (payment) {
6869
- if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6870
- if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6871
- var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
7055
+ if (!_this22.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
7056
+ if (!_this22.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
7057
+ var name = nameByCode.get(_this22.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6872
7058
  if (!name) return payment;
6873
7059
  hasResolvedName = true;
6874
7060
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6876,28 +7062,28 @@ var Server = /*#__PURE__*/function () {
6876
7062
  });
6877
7063
  });
6878
7064
  if (hasResolvedName) {
6879
- _context69.next = 18;
7065
+ _context70.next = 18;
6880
7066
  break;
6881
7067
  }
6882
- return _context69.abrupt("return", order);
7068
+ return _context70.abrupt("return", order);
6883
7069
  case 18:
6884
- return _context69.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
7070
+ return _context70.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
6885
7071
  payments: enrichedPayments
6886
7072
  }));
6887
7073
  case 21:
6888
- _context69.prev = 21;
6889
- _context69.t0 = _context69["catch"](4);
7074
+ _context70.prev = 21;
7075
+ _context70.t0 = _context70["catch"](4);
6890
7076
  this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
6891
- error: _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0)
7077
+ error: _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0)
6892
7078
  });
6893
- return _context69.abrupt("return", order);
7079
+ return _context70.abrupt("return", order);
6894
7080
  case 25:
6895
7081
  case "end":
6896
- return _context69.stop();
7082
+ return _context70.stop();
6897
7083
  }
6898
- }, _callee69, this, [[4, 21]]);
7084
+ }, _callee70, this, [[4, 21]]);
6899
7085
  }));
6900
- function enrichPaymentNamesByCode(_x76) {
7086
+ function enrichPaymentNamesByCode(_x77) {
6901
7087
  return _enrichPaymentNamesByCode.apply(this, arguments);
6902
7088
  }
6903
7089
  return enrichPaymentNamesByCode;
@@ -6905,66 +7091,66 @@ var Server = /*#__PURE__*/function () {
6905
7091
  }, {
6906
7092
  key: "withLocalSmallTicketData",
6907
7093
  value: function () {
6908
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order, options) {
7094
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(order, options) {
6909
7095
  var _options$productMap, enrichedOrder, productMap, smallTicketData;
6910
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6911
- while (1) switch (_context70.prev = _context70.next) {
7096
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7097
+ while (1) switch (_context71.prev = _context71.next) {
6912
7098
  case 0:
6913
7099
  if (this.shouldBuildSmallTicketData(order)) {
6914
- _context70.next = 2;
7100
+ _context71.next = 2;
6915
7101
  break;
6916
7102
  }
6917
- return _context70.abrupt("return", order);
7103
+ return _context71.abrupt("return", order);
6918
7104
  case 2:
6919
7105
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
6920
- _context70.next = 4;
7106
+ _context71.next = 4;
6921
7107
  break;
6922
7108
  }
6923
- return _context70.abrupt("return", order);
7109
+ return _context71.abrupt("return", order);
6924
7110
  case 4:
6925
- _context70.prev = 4;
6926
- _context70.next = 7;
7111
+ _context71.prev = 4;
7112
+ _context71.next = 7;
6927
7113
  return this.enrichPaymentNamesByCode(order);
6928
7114
  case 7:
6929
- enrichedOrder = _context70.sent;
7115
+ enrichedOrder = _context71.sent;
6930
7116
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
6931
- _context70.next = 12;
7117
+ _context71.next = 12;
6932
7118
  break;
6933
7119
  }
6934
- _context70.t0 = _options$productMap;
6935
- _context70.next = 15;
7120
+ _context71.t0 = _options$productMap;
7121
+ _context71.next = 15;
6936
7122
  break;
6937
7123
  case 12:
6938
- _context70.next = 14;
7124
+ _context71.next = 14;
6939
7125
  return this.buildSmallTicketProductMap(enrichedOrder);
6940
7126
  case 14:
6941
- _context70.t0 = _context70.sent;
7127
+ _context71.t0 = _context71.sent;
6942
7128
  case 15:
6943
- productMap = _context70.t0;
7129
+ productMap = _context71.t0;
6944
7130
  smallTicketData = buildSmallTicketData({
6945
7131
  order: enrichedOrder,
6946
7132
  shopInfo: this.getSmallTicketShopInfo(),
6947
7133
  productMap: productMap
6948
7134
  });
6949
- return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7135
+ return _context71.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
6950
7136
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
6951
7137
  small_ticket_data: smallTicketData
6952
7138
  })
6953
7139
  }));
6954
7140
  case 20:
6955
- _context70.prev = 20;
6956
- _context70.t1 = _context70["catch"](4);
7141
+ _context71.prev = 20;
7142
+ _context71.t1 = _context71["catch"](4);
6957
7143
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
6958
- error: _context70.t1 instanceof Error ? _context70.t1.message : String(_context70.t1)
7144
+ error: _context71.t1 instanceof Error ? _context71.t1.message : String(_context71.t1)
6959
7145
  });
6960
- return _context70.abrupt("return", order);
7146
+ return _context71.abrupt("return", order);
6961
7147
  case 24:
6962
7148
  case "end":
6963
- return _context70.stop();
7149
+ return _context71.stop();
6964
7150
  }
6965
- }, _callee70, this, [[4, 20]]);
7151
+ }, _callee71, this, [[4, 20]]);
6966
7152
  }));
6967
- function withLocalSmallTicketData(_x77, _x78) {
7153
+ function withLocalSmallTicketData(_x78, _x79) {
6968
7154
  return _withLocalSmallTicketData.apply(this, arguments);
6969
7155
  }
6970
7156
  return withLocalSmallTicketData;
@@ -7026,22 +7212,22 @@ var Server = /*#__PURE__*/function () {
7026
7212
  }, {
7027
7213
  key: "handleUpdateLocalOrdersBatch",
7028
7214
  value: (function () {
7029
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
7215
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(orderIds) {
7030
7216
  var _this$app18;
7031
7217
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
7032
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7033
- while (1) switch (_context71.prev = _context71.next) {
7218
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7219
+ while (1) switch (_context72.prev = _context72.next) {
7034
7220
  case 0:
7035
7221
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
7036
7222
  count: orderIds.length,
7037
7223
  orderIds: orderIds
7038
7224
  });
7039
7225
  if (this.order) {
7040
- _context71.next = 4;
7226
+ _context72.next = 4;
7041
7227
  break;
7042
7228
  }
7043
7229
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
7044
- return _context71.abrupt("return", {
7230
+ return _context72.abrupt("return", {
7045
7231
  code: 500,
7046
7232
  status: false,
7047
7233
  message: 'Order 模块未注册',
@@ -7049,11 +7235,11 @@ var Server = /*#__PURE__*/function () {
7049
7235
  });
7050
7236
  case 4:
7051
7237
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
7052
- _context71.next = 7;
7238
+ _context72.next = 7;
7053
7239
  break;
7054
7240
  }
7055
7241
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
7056
- return _context71.abrupt("return", {
7242
+ return _context72.abrupt("return", {
7057
7243
  code: 500,
7058
7244
  status: false,
7059
7245
  message: 'app.request 不可用',
@@ -7076,21 +7262,21 @@ var Server = /*#__PURE__*/function () {
7076
7262
  _iterator13.f();
7077
7263
  }
7078
7264
  fetched = [];
7079
- _context71.prev = 11;
7080
- _context71.next = 14;
7265
+ _context72.prev = 11;
7266
+ _context72.next = 14;
7081
7267
  return this.order.fetchOrdersByHttp(orderIds);
7082
7268
  case 14:
7083
- fetched = _context71.sent;
7084
- _context71.next = 22;
7269
+ fetched = _context72.sent;
7270
+ _context72.next = 22;
7085
7271
  break;
7086
7272
  case 17:
7087
- _context71.prev = 17;
7088
- _context71.t0 = _context71["catch"](11);
7089
- message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7273
+ _context72.prev = 17;
7274
+ _context72.t0 = _context72["catch"](11);
7275
+ message = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7090
7276
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
7091
7277
  message: message
7092
7278
  });
7093
- return _context71.abrupt("return", {
7279
+ return _context72.abrupt("return", {
7094
7280
  code: 500,
7095
7281
  status: false,
7096
7282
  message: message,
@@ -7100,36 +7286,36 @@ var Server = /*#__PURE__*/function () {
7100
7286
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
7101
7287
  fetchedMap = new Map();
7102
7288
  _iterator14 = _createForOfIteratorHelper(fetched);
7103
- _context71.prev = 24;
7289
+ _context72.prev = 24;
7104
7290
  _iterator14.s();
7105
7291
  case 26:
7106
7292
  if ((_step14 = _iterator14.n()).done) {
7107
- _context71.next = 34;
7293
+ _context72.next = 34;
7108
7294
  break;
7109
7295
  }
7110
7296
  order = _step14.value;
7111
7297
  oid = order === null || order === void 0 ? void 0 : order.order_id;
7112
7298
  if (!(oid === undefined || oid === null)) {
7113
- _context71.next = 31;
7299
+ _context72.next = 31;
7114
7300
  break;
7115
7301
  }
7116
- return _context71.abrupt("continue", 32);
7302
+ return _context72.abrupt("continue", 32);
7117
7303
  case 31:
7118
7304
  fetchedMap.set(String(oid), order);
7119
7305
  case 32:
7120
- _context71.next = 26;
7306
+ _context72.next = 26;
7121
7307
  break;
7122
7308
  case 34:
7123
- _context71.next = 39;
7309
+ _context72.next = 39;
7124
7310
  break;
7125
7311
  case 36:
7126
- _context71.prev = 36;
7127
- _context71.t1 = _context71["catch"](24);
7128
- _iterator14.e(_context71.t1);
7312
+ _context72.prev = 36;
7313
+ _context72.t1 = _context72["catch"](24);
7314
+ _iterator14.e(_context72.t1);
7129
7315
  case 39:
7130
- _context71.prev = 39;
7316
+ _context72.prev = 39;
7131
7317
  _iterator14.f();
7132
- return _context71.finish(39);
7318
+ return _context72.finish(39);
7133
7319
  case 42:
7134
7320
  freshOrders = [];
7135
7321
  succeedIds = [];
@@ -7155,23 +7341,23 @@ var Server = /*#__PURE__*/function () {
7155
7341
  _iterator15.f();
7156
7342
  }
7157
7343
  if (!(freshOrders.length > 0)) {
7158
- _context71.next = 58;
7344
+ _context72.next = 58;
7159
7345
  break;
7160
7346
  }
7161
- _context71.prev = 48;
7162
- _context71.next = 51;
7347
+ _context72.prev = 48;
7348
+ _context72.next = 51;
7163
7349
  return this.order.upsertOrdersFromRemote(freshOrders);
7164
7350
  case 51:
7165
- _context71.next = 58;
7351
+ _context72.next = 58;
7166
7352
  break;
7167
7353
  case 53:
7168
- _context71.prev = 53;
7169
- _context71.t2 = _context71["catch"](48);
7170
- _message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
7354
+ _context72.prev = 53;
7355
+ _context72.t2 = _context72["catch"](48);
7356
+ _message2 = _context72.t2 instanceof Error ? _context72.t2.message : String(_context72.t2);
7171
7357
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
7172
7358
  message: _message2
7173
7359
  });
7174
- return _context71.abrupt("return", {
7360
+ return _context72.abrupt("return", {
7175
7361
  code: 500,
7176
7362
  status: false,
7177
7363
  message: _message2,
@@ -7190,7 +7376,7 @@ var Server = /*#__PURE__*/function () {
7190
7376
  insertedCount: inserted.length,
7191
7377
  failedCount: failed.length
7192
7378
  });
7193
- return _context71.abrupt("return", {
7379
+ return _context72.abrupt("return", {
7194
7380
  code: 200,
7195
7381
  status: true,
7196
7382
  message: '',
@@ -7202,11 +7388,11 @@ var Server = /*#__PURE__*/function () {
7202
7388
  });
7203
7389
  case 62:
7204
7390
  case "end":
7205
- return _context71.stop();
7391
+ return _context72.stop();
7206
7392
  }
7207
- }, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7393
+ }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7208
7394
  }));
7209
- function handleUpdateLocalOrdersBatch(_x79) {
7395
+ function handleUpdateLocalOrdersBatch(_x80) {
7210
7396
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7211
7397
  }
7212
7398
  return handleUpdateLocalOrdersBatch;
@@ -7450,10 +7636,10 @@ var Server = /*#__PURE__*/function () {
7450
7636
  value: function extractBackendErrorResponse(error) {
7451
7637
  var _error$response3,
7452
7638
  _error$response4,
7453
- _this21 = this;
7639
+ _this23 = this;
7454
7640
  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];
7455
7641
  return candidates.find(function (candidate) {
7456
- return _this21.isExplicitBackendErrorResponse(candidate);
7642
+ return _this23.isExplicitBackendErrorResponse(candidate);
7457
7643
  }) || null;
7458
7644
  }
7459
7645
  }, {
@@ -7572,16 +7758,16 @@ var Server = /*#__PURE__*/function () {
7572
7758
  }, {
7573
7759
  key: "recomputeAndNotifyFloorPlanQuery",
7574
7760
  value: (function () {
7575
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7761
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7576
7762
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7577
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7578
- while (1) switch (_context72.prev = _context72.next) {
7763
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7764
+ while (1) switch (_context73.prev = _context73.next) {
7579
7765
  case 0:
7580
7766
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7581
- _context72.next = 2;
7767
+ _context73.next = 2;
7582
7768
  break;
7583
7769
  }
7584
- return _context72.abrupt("return");
7770
+ return _context73.abrupt("return");
7585
7771
  case 2:
7586
7772
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7587
7773
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -7611,9 +7797,9 @@ var Server = /*#__PURE__*/function () {
7611
7797
  }
7612
7798
  case 5:
7613
7799
  case "end":
7614
- return _context72.stop();
7800
+ return _context73.stop();
7615
7801
  }
7616
- }, _callee72, this);
7802
+ }, _callee73, this);
7617
7803
  }));
7618
7804
  function recomputeAndNotifyFloorPlanQuery() {
7619
7805
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7643,20 +7829,20 @@ var Server = /*#__PURE__*/function () {
7643
7829
  * filter 逻辑暂为 mock,仅记录参数
7644
7830
  */
7645
7831
  function () {
7646
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7832
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7647
7833
  var rawList, result;
7648
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7649
- while (1) switch (_context73.prev = _context73.next) {
7834
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7835
+ while (1) switch (_context74.prev = _context74.next) {
7650
7836
  case 0:
7651
7837
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7652
7838
  data: data
7653
7839
  });
7654
7840
  if (this.order) {
7655
- _context73.next = 4;
7841
+ _context74.next = 4;
7656
7842
  break;
7657
7843
  }
7658
7844
  this.logError('computeOrderQueryResult: Order 模块未注册');
7659
- return _context73.abrupt("return", {
7845
+ return _context74.abrupt("return", {
7660
7846
  code: 500,
7661
7847
  message: 'Order 模块未注册',
7662
7848
  data: {
@@ -7686,7 +7872,7 @@ var Server = /*#__PURE__*/function () {
7686
7872
  skip: result.skip,
7687
7873
  rejected: result.rejected
7688
7874
  });
7689
- return _context73.abrupt("return", {
7875
+ return _context74.abrupt("return", {
7690
7876
  code: 200,
7691
7877
  data: result,
7692
7878
  message: '',
@@ -7694,11 +7880,11 @@ var Server = /*#__PURE__*/function () {
7694
7880
  });
7695
7881
  case 10:
7696
7882
  case "end":
7697
- return _context73.stop();
7883
+ return _context74.stop();
7698
7884
  }
7699
- }, _callee73, this);
7885
+ }, _callee74, this);
7700
7886
  }));
7701
- function computeOrderQueryResult(_x80) {
7887
+ function computeOrderQueryResult(_x81) {
7702
7888
  return _computeOrderQueryResult.apply(this, arguments);
7703
7889
  }
7704
7890
  return computeOrderQueryResult;
@@ -7711,17 +7897,17 @@ var Server = /*#__PURE__*/function () {
7711
7897
  }, {
7712
7898
  key: "computeBookingQueryResult",
7713
7899
  value: (function () {
7714
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7900
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data) {
7715
7901
  var rawOrders, result;
7716
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7717
- while (1) switch (_context74.prev = _context74.next) {
7902
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7903
+ while (1) switch (_context75.prev = _context75.next) {
7718
7904
  case 0:
7719
7905
  if (this.order) {
7720
- _context74.next = 3;
7906
+ _context75.next = 3;
7721
7907
  break;
7722
7908
  }
7723
7909
  this.logError('computeBookingQueryResult: Order 模块未注册');
7724
- return _context74.abrupt("return", {
7910
+ return _context75.abrupt("return", {
7725
7911
  code: 500,
7726
7912
  message: 'Order 模块未注册',
7727
7913
  data: {
@@ -7740,7 +7926,7 @@ var Server = /*#__PURE__*/function () {
7740
7926
  size: result.size,
7741
7927
  skip: result.skip
7742
7928
  });
7743
- return _context74.abrupt("return", {
7929
+ return _context75.abrupt("return", {
7744
7930
  code: 200,
7745
7931
  data: result,
7746
7932
  message: '',
@@ -7748,11 +7934,11 @@ var Server = /*#__PURE__*/function () {
7748
7934
  });
7749
7935
  case 8:
7750
7936
  case "end":
7751
- return _context74.stop();
7937
+ return _context75.stop();
7752
7938
  }
7753
- }, _callee74, this);
7939
+ }, _callee75, this);
7754
7940
  }));
7755
- function computeBookingQueryResult(_x81) {
7941
+ function computeBookingQueryResult(_x82) {
7756
7942
  return _computeBookingQueryResult.apply(this, arguments);
7757
7943
  }
7758
7944
  return computeBookingQueryResult;
@@ -7811,12 +7997,12 @@ var Server = /*#__PURE__*/function () {
7811
7997
  }, {
7812
7998
  key: "computeProductQueryResult",
7813
7999
  value: (function () {
7814
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
8000
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(context, options) {
7815
8001
  var _menu_list_ids$length3,
7816
- _this22 = this;
7817
- var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
7818
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7819
- while (1) switch (_context75.prev = _context75.next) {
8002
+ _this24 = this;
8003
+ 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;
8004
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8005
+ while (1) switch (_context76.prev = _context76.next) {
7820
8006
  case 0:
7821
8007
  tTotal = performance.now();
7822
8008
  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;
@@ -7825,12 +8011,6 @@ var Server = /*#__PURE__*/function () {
7825
8011
  }).filter(function (id) {
7826
8012
  return Number.isFinite(id);
7827
8013
  }) : [];
7828
- formatterContext = this.buildProductFormatterContext({
7829
- schedule_date: schedule_date,
7830
- schedule_datetime: schedule_datetime,
7831
- customer_id: customer_id,
7832
- strategy_context: strategy_context
7833
- });
7834
8014
  this.logInfo('computeProductQueryResult 开始', {
7835
8015
  menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
7836
8016
  ids: queryIds,
@@ -7842,29 +8022,49 @@ var Server = /*#__PURE__*/function () {
7842
8022
  strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
7843
8023
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7844
8024
  });
8025
+
8026
+ // 预渲染可能在 PisellOS 顺序 preload 尚未完成时发起商品查询。此时 Menu/Schedule
8027
+ // 暂时为空不代表缓存失效;等待当前 preload 后再按原逻辑查询,避免并发远端刷新先 clear
8028
+ // SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
8029
+ startupPreloadTask = this.startupModulePreloadInFlight;
8030
+ if (!startupPreloadTask) {
8031
+ _context76.next = 8;
8032
+ break;
8033
+ }
8034
+ _context76.next = 8;
8035
+ return startupPreloadTask;
8036
+ case 8:
8037
+ // Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
8038
+ // 避免 formatterContext 持有预加载前的空数组快照。
8039
+ formatterContext = this.buildProductFormatterContext({
8040
+ schedule_date: schedule_date,
8041
+ schedule_datetime: schedule_datetime,
8042
+ customer_id: customer_id,
8043
+ strategy_context: strategy_context
8044
+ });
7845
8045
  if (this.products) {
7846
- _context75.next = 8;
8046
+ _context76.next = 12;
7847
8047
  break;
7848
8048
  }
7849
8049
  this.logError('computeProductQueryResult: Products 模块未注册');
7850
- return _context75.abrupt("return", {
8050
+ return _context76.abrupt("return", {
7851
8051
  message: 'Products 模块未注册',
7852
8052
  data: this.buildProductQueryResultPayload([], 0)
7853
8053
  });
7854
- case 8:
8054
+ case 12:
7855
8055
  if (!(queryIds.length > 0)) {
7856
- _context75.next = 20;
8056
+ _context76.next = 24;
7857
8057
  break;
7858
8058
  }
7859
8059
  uniqueIds = Array.from(new Set(queryIds));
7860
8060
  _tPrice = performance.now();
7861
- _context75.next = 13;
8061
+ _context76.next = 17;
7862
8062
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7863
8063
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7864
8064
  productIds: uniqueIds
7865
8065
  });
7866
- case 13:
7867
- productsWithPrice = _context75.sent;
8066
+ case 17:
8067
+ productsWithPrice = _context76.sent;
7868
8068
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7869
8069
  count: productsWithPrice.length,
7870
8070
  ids: uniqueIds
@@ -7884,25 +8084,25 @@ var Server = /*#__PURE__*/function () {
7884
8084
  ids: uniqueIds,
7885
8085
  count: extensionFilteredProducts.length
7886
8086
  });
7887
- return _context75.abrupt("return", {
8087
+ return _context76.abrupt("return", {
7888
8088
  code: 200,
7889
8089
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7890
8090
  message: '',
7891
8091
  status: true
7892
8092
  });
7893
- case 20:
8093
+ case 24:
7894
8094
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7895
- _context75.next = 32;
8095
+ _context76.next = 36;
7896
8096
  break;
7897
8097
  }
7898
8098
  pid = Number(product_id);
7899
8099
  _tPrice2 = performance.now();
7900
- _context75.next = 25;
8100
+ _context76.next = 29;
7901
8101
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7902
8102
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7903
8103
  });
7904
- case 25:
7905
- allProductsWithPrice = _context75.sent;
8104
+ case 29:
8105
+ allProductsWithPrice = _context76.sent;
7906
8106
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7907
8107
  count: allProductsWithPrice.length,
7908
8108
  productId: pid
@@ -7922,24 +8122,24 @@ var Server = /*#__PURE__*/function () {
7922
8122
  productId: pid,
7923
8123
  found: !!item
7924
8124
  });
7925
- return _context75.abrupt("return", {
8125
+ return _context76.abrupt("return", {
7926
8126
  code: 200,
7927
8127
  data: item,
7928
8128
  message: item ? '' : '商品不存在或未发布',
7929
8129
  status: true
7930
8130
  });
7931
- case 32:
8131
+ case 36:
7932
8132
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7933
- _context75.next = 52;
8133
+ _context76.next = 56;
7934
8134
  break;
7935
8135
  }
7936
8136
  _tPrice3 = performance.now();
7937
- _context75.next = 36;
8137
+ _context76.next = 40;
7938
8138
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7939
8139
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7940
8140
  });
7941
- case 36:
7942
- _filteredProducts2 = _context75.sent;
8141
+ case 40:
8142
+ _filteredProducts2 = _context76.sent;
7943
8143
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7944
8144
  count: _filteredProducts2.length,
7945
8145
  extension_type: extension_type
@@ -7978,67 +8178,67 @@ var Server = /*#__PURE__*/function () {
7978
8178
  filteredCount: _filteredProducts2.length,
7979
8179
  extension_type: extension_type
7980
8180
  });
7981
- return _context75.abrupt("return", {
8181
+ return _context76.abrupt("return", {
7982
8182
  code: 200,
7983
8183
  data: this.buildProductQueryResultPayload(_filteredProducts2),
7984
8184
  message: '',
7985
8185
  status: true
7986
8186
  });
7987
- case 52:
8187
+ case 56:
7988
8188
  if (this.menu) {
7989
- _context75.next = 55;
8189
+ _context76.next = 59;
7990
8190
  break;
7991
8191
  }
7992
8192
  this.logError('computeProductQueryResult: Menu 模块未注册');
7993
- return _context75.abrupt("return", {
8193
+ return _context76.abrupt("return", {
7994
8194
  message: 'Menu 模块未注册',
7995
8195
  data: this.buildProductQueryResultPayload([], 0)
7996
8196
  });
7997
- case 55:
8197
+ case 59:
7998
8198
  if (this.schedule) {
7999
- _context75.next = 58;
8199
+ _context76.next = 62;
8000
8200
  break;
8001
8201
  }
8002
8202
  this.logError('computeProductQueryResult: Schedule 模块未注册');
8003
- return _context75.abrupt("return", {
8203
+ return _context76.abrupt("return", {
8004
8204
  message: 'Schedule 模块未注册',
8005
8205
  data: this.buildProductQueryResultPayload([], 0)
8006
8206
  });
8007
- case 58:
8207
+ case 62:
8008
8208
  activeMenuList = [];
8009
8209
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
8010
- _context75.next = 71;
8210
+ _context76.next = 75;
8011
8211
  break;
8012
8212
  }
8013
8213
  tMenu = performance.now();
8014
8214
  getActiveMenus = function getActiveMenus() {
8015
- return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8016
- var _this22$schedule;
8017
- return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8215
+ return _this24.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8216
+ var _this24$schedule;
8217
+ return ((_this24$schedule = _this24.schedule) === null || _this24$schedule === void 0 ? void 0 : _this24$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8018
8218
  });
8019
8219
  };
8020
8220
  activeMenuList = getActiveMenus();
8021
- _context75.t0 = !activeMenuList.length;
8022
- if (!_context75.t0) {
8023
- _context75.next = 68;
8221
+ _context76.t0 = !activeMenuList.length;
8222
+ if (!_context76.t0) {
8223
+ _context76.next = 72;
8024
8224
  break;
8025
8225
  }
8026
- _context75.next = 67;
8226
+ _context76.next = 71;
8027
8227
  return this.refreshMenuScheduleCacheAfterEmptyResult();
8028
- case 67:
8029
- _context75.t0 = _context75.sent;
8030
- case 68:
8031
- if (!_context75.t0) {
8032
- _context75.next = 70;
8228
+ case 71:
8229
+ _context76.t0 = _context76.sent;
8230
+ case 72:
8231
+ if (!_context76.t0) {
8232
+ _context76.next = 74;
8033
8233
  break;
8034
8234
  }
8035
8235
  activeMenuList = getActiveMenus();
8036
- case 70:
8236
+ case 74:
8037
8237
  perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
8038
8238
  totalMenu: menu_list_ids.length,
8039
8239
  activeMenu: activeMenuList.length
8040
8240
  });
8041
- case 71:
8241
+ case 75:
8042
8242
  tFilter = performance.now();
8043
8243
  productScope = this.getProductScopeByMenuConfig(activeMenuList);
8044
8244
  scopedProductIds = this.products.getProductIdsByScope(productScope);
@@ -8049,22 +8249,22 @@ var Server = /*#__PURE__*/function () {
8049
8249
  });
8050
8250
  tPrice = performance.now();
8051
8251
  if (!(scopedProductIds.length > 0)) {
8052
- _context75.next = 82;
8252
+ _context76.next = 86;
8053
8253
  break;
8054
8254
  }
8055
- _context75.next = 79;
8255
+ _context76.next = 83;
8056
8256
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
8057
8257
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
8058
8258
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
8059
8259
  });
8060
- case 79:
8061
- _context75.t1 = _context75.sent;
8062
- _context75.next = 83;
8063
- break;
8064
- case 82:
8065
- _context75.t1 = [];
8066
8260
  case 83:
8067
- filteredProducts = _context75.t1;
8261
+ _context76.t1 = _context76.sent;
8262
+ _context76.next = 87;
8263
+ break;
8264
+ case 86:
8265
+ _context76.t1 = [];
8266
+ case 87:
8267
+ filteredProducts = _context76.t1;
8068
8268
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
8069
8269
  count: filteredProducts.length,
8070
8270
  scopedProductCount: scopedProductIds.length
@@ -8105,19 +8305,19 @@ var Server = /*#__PURE__*/function () {
8105
8305
  filteredCount: filteredProducts.length,
8106
8306
  activeMenuCount: activeMenuList.length
8107
8307
  });
8108
- return _context75.abrupt("return", {
8308
+ return _context76.abrupt("return", {
8109
8309
  code: 200,
8110
8310
  data: this.buildProductQueryResultPayload(filteredProducts),
8111
8311
  message: '',
8112
8312
  status: true
8113
8313
  });
8114
- case 99:
8314
+ case 103:
8115
8315
  case "end":
8116
- return _context75.stop();
8316
+ return _context76.stop();
8117
8317
  }
8118
- }, _callee75, this);
8318
+ }, _callee76, this);
8119
8319
  }));
8120
- function computeProductQueryResult(_x82, _x83) {
8320
+ function computeProductQueryResult(_x83, _x84) {
8121
8321
  return _computeProductQueryResult.apply(this, arguments);
8122
8322
  }
8123
8323
  return computeProductQueryResult;
@@ -8131,16 +8331,18 @@ var Server = /*#__PURE__*/function () {
8131
8331
  }, {
8132
8332
  key: "buildProductFormatterContext",
8133
8333
  value: function buildProductFormatterContext(context) {
8134
- var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context5;
8334
+ var _this$core$context5, _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context6;
8135
8335
  var scheduleModule = this.getSchedule();
8136
8336
  return {
8137
8337
  scheduleModule: scheduleModule,
8138
8338
  schedule_datetime: context.schedule_datetime,
8139
8339
  customer_id: context.customer_id,
8140
8340
  strategy_context: context.strategy_context,
8341
+ // 固定本次商品查询使用的语言,确保格式化与缓存使用同一份 locale 快照。
8342
+ locale: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.locale,
8141
8343
  menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
8142
8344
  scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
8143
- dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
8345
+ dataVariantEvaluator: (_this$core$context6 = this.core.context) === null || _this$core$context6 === void 0 ? void 0 : _this$core$context6.dataVariantEvaluator
8144
8346
  };
8145
8347
  }
8146
8348
 
@@ -8153,72 +8355,72 @@ var Server = /*#__PURE__*/function () {
8153
8355
  }, {
8154
8356
  key: "recomputeAndNotifyProductQuery",
8155
8357
  value: (function () {
8156
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
8358
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(options) {
8157
8359
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
8158
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8159
- while (1) switch (_context76.prev = _context76.next) {
8360
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8361
+ while (1) switch (_context77.prev = _context77.next) {
8160
8362
  case 0:
8161
8363
  if (!(this.productQuerySubscribers.size === 0)) {
8162
- _context76.next = 2;
8364
+ _context77.next = 2;
8163
8365
  break;
8164
8366
  }
8165
- return _context76.abrupt("return");
8367
+ return _context77.abrupt("return");
8166
8368
  case 2:
8167
8369
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
8168
8370
  subscriberCount: this.productQuerySubscribers.size,
8169
8371
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8170
8372
  });
8171
8373
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
8172
- _context76.prev = 4;
8374
+ _context77.prev = 4;
8173
8375
  _iterator18.s();
8174
8376
  case 6:
8175
8377
  if ((_step18 = _iterator18.n()).done) {
8176
- _context76.next = 22;
8378
+ _context77.next = 22;
8177
8379
  break;
8178
8380
  }
8179
8381
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
8180
- _context76.prev = 8;
8181
- _context76.next = 11;
8382
+ _context77.prev = 8;
8383
+ _context77.next = 11;
8182
8384
  return this.computeProductQueryResult(subscriber.context, {
8183
8385
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8184
8386
  });
8185
8387
  case 11:
8186
- result = _context76.sent;
8388
+ result = _context77.sent;
8187
8389
  subscriber.callback(result);
8188
8390
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
8189
8391
  subscriberId: subscriberId
8190
8392
  });
8191
- _context76.next = 20;
8393
+ _context77.next = 20;
8192
8394
  break;
8193
8395
  case 16:
8194
- _context76.prev = 16;
8195
- _context76.t0 = _context76["catch"](8);
8196
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8396
+ _context77.prev = 16;
8397
+ _context77.t0 = _context77["catch"](8);
8398
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8197
8399
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
8198
8400
  subscriberId: subscriberId,
8199
8401
  error: errorMessage
8200
8402
  });
8201
8403
  case 20:
8202
- _context76.next = 6;
8404
+ _context77.next = 6;
8203
8405
  break;
8204
8406
  case 22:
8205
- _context76.next = 27;
8407
+ _context77.next = 27;
8206
8408
  break;
8207
8409
  case 24:
8208
- _context76.prev = 24;
8209
- _context76.t1 = _context76["catch"](4);
8210
- _iterator18.e(_context76.t1);
8410
+ _context77.prev = 24;
8411
+ _context77.t1 = _context77["catch"](4);
8412
+ _iterator18.e(_context77.t1);
8211
8413
  case 27:
8212
- _context76.prev = 27;
8414
+ _context77.prev = 27;
8213
8415
  _iterator18.f();
8214
- return _context76.finish(27);
8416
+ return _context77.finish(27);
8215
8417
  case 30:
8216
8418
  case "end":
8217
- return _context76.stop();
8419
+ return _context77.stop();
8218
8420
  }
8219
- }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8421
+ }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8220
8422
  }));
8221
- function recomputeAndNotifyProductQuery(_x84) {
8423
+ function recomputeAndNotifyProductQuery(_x85) {
8222
8424
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8223
8425
  }
8224
8426
  return recomputeAndNotifyProductQuery;
@@ -8230,16 +8432,16 @@ var Server = /*#__PURE__*/function () {
8230
8432
  }, {
8231
8433
  key: "recomputeAndNotifyOrderQuery",
8232
8434
  value: (function () {
8233
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8435
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8234
8436
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8235
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8236
- while (1) switch (_context77.prev = _context77.next) {
8437
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8438
+ while (1) switch (_context78.prev = _context78.next) {
8237
8439
  case 0:
8238
8440
  if (!(this.orderQuerySubscribers.size === 0)) {
8239
- _context77.next = 2;
8441
+ _context78.next = 2;
8240
8442
  break;
8241
8443
  }
8242
- return _context77.abrupt("return");
8444
+ return _context78.abrupt("return");
8243
8445
  case 2:
8244
8446
  notifyStartAt = Date.now();
8245
8447
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -8247,20 +8449,20 @@ var Server = /*#__PURE__*/function () {
8247
8449
  notifyStartAt: new Date(notifyStartAt).toISOString()
8248
8450
  });
8249
8451
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8250
- _context77.prev = 5;
8452
+ _context78.prev = 5;
8251
8453
  _iterator19.s();
8252
8454
  case 7:
8253
8455
  if ((_step19 = _iterator19.n()).done) {
8254
- _context77.next = 27;
8456
+ _context78.next = 27;
8255
8457
  break;
8256
8458
  }
8257
8459
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8258
- _context77.prev = 9;
8460
+ _context78.prev = 9;
8259
8461
  computeStartAt = Date.now();
8260
- _context77.next = 13;
8462
+ _context78.next = 13;
8261
8463
  return this.computeOrderQueryResult(subscriber.context);
8262
8464
  case 13:
8263
- result = _context77.sent;
8465
+ result = _context78.sent;
8264
8466
  computeEndAt = Date.now();
8265
8467
  callbackStartAt = Date.now();
8266
8468
  subscriber.callback(result);
@@ -8271,30 +8473,30 @@ var Server = /*#__PURE__*/function () {
8271
8473
  callbackDurationMs: callbackEndAt - callbackStartAt,
8272
8474
  totalDurationMs: callbackEndAt - computeStartAt
8273
8475
  });
8274
- _context77.next = 25;
8476
+ _context78.next = 25;
8275
8477
  break;
8276
8478
  case 21:
8277
- _context77.prev = 21;
8278
- _context77.t0 = _context77["catch"](9);
8279
- errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8479
+ _context78.prev = 21;
8480
+ _context78.t0 = _context78["catch"](9);
8481
+ errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8280
8482
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
8281
8483
  subscriberId: subscriberId,
8282
8484
  error: errorMessage
8283
8485
  });
8284
8486
  case 25:
8285
- _context77.next = 7;
8487
+ _context78.next = 7;
8286
8488
  break;
8287
8489
  case 27:
8288
- _context77.next = 32;
8490
+ _context78.next = 32;
8289
8491
  break;
8290
8492
  case 29:
8291
- _context77.prev = 29;
8292
- _context77.t1 = _context77["catch"](5);
8293
- _iterator19.e(_context77.t1);
8493
+ _context78.prev = 29;
8494
+ _context78.t1 = _context78["catch"](5);
8495
+ _iterator19.e(_context78.t1);
8294
8496
  case 32:
8295
- _context77.prev = 32;
8497
+ _context78.prev = 32;
8296
8498
  _iterator19.f();
8297
- return _context77.finish(32);
8499
+ return _context78.finish(32);
8298
8500
  case 35:
8299
8501
  notifyEndAt = Date.now();
8300
8502
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8303,9 +8505,9 @@ var Server = /*#__PURE__*/function () {
8303
8505
  });
8304
8506
  case 37:
8305
8507
  case "end":
8306
- return _context77.stop();
8508
+ return _context78.stop();
8307
8509
  }
8308
- }, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
8510
+ }, _callee78, this, [[5, 29, 32, 35], [9, 21]]);
8309
8511
  }));
8310
8512
  function recomputeAndNotifyOrderQuery() {
8311
8513
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8323,7 +8525,7 @@ var Server = /*#__PURE__*/function () {
8323
8525
  }, {
8324
8526
  key: "notifySalesSearchSubscribers",
8325
8527
  value: function notifySalesSearchSubscribers(payload) {
8326
- var _this23 = this;
8528
+ var _this25 = this;
8327
8529
  if (this.salesSearchSubscribers.size === 0) return;
8328
8530
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8329
8531
  if (changedOrders.length === 0) {
@@ -8341,21 +8543,21 @@ var Server = /*#__PURE__*/function () {
8341
8543
  subscriber = _step20$value[1];
8342
8544
  try {
8343
8545
  var changedVisibleOrders = changedOrders.filter(function (order) {
8344
- var orderId = _this23.getSalesSearchOrderId(order);
8546
+ var orderId = _this25.getSalesSearchOrderId(order);
8345
8547
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8346
8548
  });
8347
8549
  if (changedVisibleOrders.length === 0) {
8348
8550
  return 1; // continue
8349
8551
  }
8350
- subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8351
- _this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8552
+ subscriber.callback(_this25.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8553
+ _this25.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8352
8554
  subscriberId: subscriberId,
8353
8555
  kind: subscriber.kind,
8354
8556
  count: changedVisibleOrders.length
8355
8557
  });
8356
8558
  } catch (error) {
8357
8559
  var errorMessage = error instanceof Error ? error.message : String(error);
8358
- _this23.logError('notifySalesSearchSubscribers: 推送失败', {
8560
+ _this25.logError('notifySalesSearchSubscribers: 推送失败', {
8359
8561
  subscriberId: subscriberId,
8360
8562
  error: errorMessage
8361
8563
  });
@@ -8446,67 +8648,67 @@ var Server = /*#__PURE__*/function () {
8446
8648
  }, {
8447
8649
  key: "recomputeAndNotifyBookingQuery",
8448
8650
  value: (function () {
8449
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8651
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8450
8652
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8451
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8452
- while (1) switch (_context78.prev = _context78.next) {
8653
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8654
+ while (1) switch (_context79.prev = _context79.next) {
8453
8655
  case 0:
8454
8656
  if (!(this.bookingQuerySubscribers.size === 0)) {
8455
- _context78.next = 2;
8657
+ _context79.next = 2;
8456
8658
  break;
8457
8659
  }
8458
- return _context78.abrupt("return");
8660
+ return _context79.abrupt("return");
8459
8661
  case 2:
8460
8662
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8461
8663
  subscriberCount: this.bookingQuerySubscribers.size
8462
8664
  });
8463
8665
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8464
- _context78.prev = 4;
8666
+ _context79.prev = 4;
8465
8667
  _iterator21.s();
8466
8668
  case 6:
8467
8669
  if ((_step21 = _iterator21.n()).done) {
8468
- _context78.next = 22;
8670
+ _context79.next = 22;
8469
8671
  break;
8470
8672
  }
8471
8673
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8472
- _context78.prev = 8;
8473
- _context78.next = 11;
8674
+ _context79.prev = 8;
8675
+ _context79.next = 11;
8474
8676
  return this.computeBookingQueryResult(subscriber.context);
8475
8677
  case 11:
8476
- result = _context78.sent;
8678
+ result = _context79.sent;
8477
8679
  subscriber.callback(result);
8478
8680
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8479
8681
  subscriberId: subscriberId
8480
8682
  });
8481
- _context78.next = 20;
8683
+ _context79.next = 20;
8482
8684
  break;
8483
8685
  case 16:
8484
- _context78.prev = 16;
8485
- _context78.t0 = _context78["catch"](8);
8486
- errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8686
+ _context79.prev = 16;
8687
+ _context79.t0 = _context79["catch"](8);
8688
+ errorMessage = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
8487
8689
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8488
8690
  subscriberId: subscriberId,
8489
8691
  error: errorMessage
8490
8692
  });
8491
8693
  case 20:
8492
- _context78.next = 6;
8694
+ _context79.next = 6;
8493
8695
  break;
8494
8696
  case 22:
8495
- _context78.next = 27;
8697
+ _context79.next = 27;
8496
8698
  break;
8497
8699
  case 24:
8498
- _context78.prev = 24;
8499
- _context78.t1 = _context78["catch"](4);
8500
- _iterator21.e(_context78.t1);
8700
+ _context79.prev = 24;
8701
+ _context79.t1 = _context79["catch"](4);
8702
+ _iterator21.e(_context79.t1);
8501
8703
  case 27:
8502
- _context78.prev = 27;
8704
+ _context79.prev = 27;
8503
8705
  _iterator21.f();
8504
- return _context78.finish(27);
8706
+ return _context79.finish(27);
8505
8707
  case 30:
8506
8708
  case "end":
8507
- return _context78.stop();
8709
+ return _context79.stop();
8508
8710
  }
8509
- }, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
8711
+ }, _callee79, this, [[4, 24, 27, 30], [8, 16]]);
8510
8712
  }));
8511
8713
  function recomputeAndNotifyBookingQuery() {
8512
8714
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);