@pisell/pisellos 2.2.210 → 2.2.211

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 (53) hide show
  1. package/dist/modules/BookingContext/index.d.ts +13 -2
  2. package/dist/modules/BookingContext/index.js +198 -68
  3. package/dist/modules/Order/index.d.ts +1 -0
  4. package/dist/modules/Order/index.js +62 -28
  5. package/dist/modules/Order/types.d.ts +4 -1
  6. package/dist/modules/Order/utils.d.ts +1 -0
  7. package/dist/modules/Order/utils.js +11 -6
  8. package/dist/modules/Quotation/index.js +2 -1
  9. package/dist/modules/SalesSummary/index.d.ts +1 -0
  10. package/dist/modules/SalesSummary/index.js +29 -15
  11. package/dist/modules/SurchargeList/index.d.ts +16 -0
  12. package/dist/modules/SurchargeList/index.js +162 -0
  13. package/dist/modules/SurchargeList/types.d.ts +11 -0
  14. package/dist/modules/SurchargeList/types.js +1 -0
  15. package/dist/modules/index.d.ts +1 -0
  16. package/dist/modules/index.js +1 -0
  17. package/dist/server/index.d.ts +8 -0
  18. package/dist/server/index.js +1075 -915
  19. package/dist/server/modules/order/index.d.ts +9 -0
  20. package/dist/server/modules/order/index.js +557 -411
  21. package/dist/server/modules/order/utils/filterOrders.js +3 -2
  22. package/dist/server/test.json +713 -0
  23. package/dist/server/utils/small-ticket.d.ts +1 -1
  24. package/dist/server/utils/small-ticket.js +1 -1
  25. package/dist/solution/BookingByStep/index.d.ts +2 -2
  26. package/dist/solution/BookingTicket/index.js +22 -20
  27. package/lib/modules/BookingContext/index.d.ts +13 -2
  28. package/lib/modules/BookingContext/index.js +99 -28
  29. package/lib/modules/Order/index.d.ts +1 -0
  30. package/lib/modules/Order/index.js +12 -1
  31. package/lib/modules/Order/types.d.ts +4 -1
  32. package/lib/modules/Order/utils.d.ts +1 -0
  33. package/lib/modules/Order/utils.js +10 -3
  34. package/lib/modules/Quotation/index.js +1 -1
  35. package/lib/modules/SalesSummary/index.d.ts +1 -0
  36. package/lib/modules/SalesSummary/index.js +11 -1
  37. package/lib/modules/SurchargeList/index.d.ts +16 -0
  38. package/lib/modules/SurchargeList/index.js +89 -0
  39. package/lib/modules/SurchargeList/types.d.ts +11 -0
  40. package/lib/modules/SurchargeList/types.js +17 -0
  41. package/lib/modules/index.d.ts +1 -0
  42. package/lib/modules/index.js +2 -0
  43. package/lib/server/index.d.ts +8 -0
  44. package/lib/server/index.js +134 -19
  45. package/lib/server/modules/order/index.d.ts +9 -0
  46. package/lib/server/modules/order/index.js +107 -19
  47. package/lib/server/modules/order/utils/filterOrders.js +3 -2
  48. package/lib/server/test.json +713 -0
  49. package/lib/server/utils/small-ticket.d.ts +1 -1
  50. package/lib/server/utils/small-ticket.js +1 -35
  51. package/lib/solution/BookingByStep/index.d.ts +2 -2
  52. package/lib/solution/BookingTicket/index.js +12 -7
  53. package/package.json +1 -1
@@ -75,6 +75,8 @@ var Server = /*#__PURE__*/function () {
75
75
  _defineProperty(this, "payment", void 0);
76
76
  _defineProperty(this, "paymentRouteModule", void 0);
77
77
  _defineProperty(this, "paymentRouteModuleInFlight", void 0);
78
+ _defineProperty(this, "quotationAvailableCache", new Map());
79
+ _defineProperty(this, "quotationAvailableInFlight", new Map());
78
80
  /** GET 前缀路由(最长前缀优先匹配) */
79
81
  _defineProperty(this, "prefixRouterGet", []);
80
82
  // 路由注册表
@@ -210,20 +212,68 @@ var Server = /*#__PURE__*/function () {
210
212
  return _ref2.apply(this, arguments);
211
213
  };
212
214
  }());
215
+ _defineProperty(this, "handleQuotationAvailable", /*#__PURE__*/function () {
216
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
217
+ var data, queryPayload, cacheKey, inFlight, requestPromise;
218
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
219
+ while (1) switch (_context2.prev = _context2.next) {
220
+ case 0:
221
+ data = _ref3.data;
222
+ queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
223
+ cacheKey = _this.stableSerialize(queryPayload);
224
+ if (!_this.quotationAvailableCache.has(cacheKey)) {
225
+ _context2.next = 6;
226
+ break;
227
+ }
228
+ _this.logInfo('handleQuotationAvailable: 命中运行时缓存', {
229
+ cacheKey: cacheKey
230
+ });
231
+ return _context2.abrupt("return", _this.quotationAvailableCache.get(cacheKey));
232
+ case 6:
233
+ inFlight = _this.quotationAvailableInFlight.get(cacheKey);
234
+ if (!inFlight) {
235
+ _context2.next = 10;
236
+ break;
237
+ }
238
+ _this.logInfo('handleQuotationAvailable: 复用进行中的请求', {
239
+ cacheKey: cacheKey
240
+ });
241
+ return _context2.abrupt("return", inFlight);
242
+ case 10:
243
+ requestPromise = _this.fetchQuotationAvailableFromAPI(queryPayload).then(function (response) {
244
+ if (_this.isSuccessfulRemoteResponse(response)) {
245
+ _this.quotationAvailableCache.set(cacheKey, response);
246
+ }
247
+ return response;
248
+ }).finally(function () {
249
+ _this.quotationAvailableInFlight.delete(cacheKey);
250
+ });
251
+ _this.quotationAvailableInFlight.set(cacheKey, requestPromise);
252
+ return _context2.abrupt("return", requestPromise);
253
+ case 13:
254
+ case "end":
255
+ return _context2.stop();
256
+ }
257
+ }, _callee2);
258
+ }));
259
+ return function (_x2) {
260
+ return _ref4.apply(this, arguments);
261
+ };
262
+ }());
213
263
  /**
214
264
  * 处理商品查询请求
215
265
  * 存储订阅者信息,便于数据变更时推送最新结果
216
266
  */
217
267
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
218
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
219
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, _ref5, callback, subscriberId;
220
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
221
- while (1) switch (_context2.prev = _context2.next) {
268
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
269
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, _ref7, callback, subscriberId;
270
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
271
+ while (1) switch (_context3.prev = _context3.next) {
222
272
  case 0:
223
- url = _ref3.url, method = _ref3.method, data = _ref3.data, config = _ref3.config;
273
+ url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
224
274
  console.log('[Server] handleProductQuery:', url, method, data, config);
225
275
  menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids;
226
- _ref5 = config || {}, callback = _ref5.callback, subscriberId = _ref5.subscriberId;
276
+ _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
227
277
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
228
278
  menu_list_ids: menu_list_ids,
229
279
  ids: ids,
@@ -249,7 +299,7 @@ var Server = /*#__PURE__*/function () {
249
299
  totalSubscribers: _this.productQuerySubscribers.size
250
300
  });
251
301
  }
252
- return _context2.abrupt("return", _this.computeProductQueryResult({
302
+ return _context3.abrupt("return", _this.computeProductQueryResult({
253
303
  menu_list_ids: menu_list_ids,
254
304
  ids: ids,
255
305
  schedule_date: schedule_date,
@@ -258,12 +308,12 @@ var Server = /*#__PURE__*/function () {
258
308
  }));
259
309
  case 7:
260
310
  case "end":
261
- return _context2.stop();
311
+ return _context3.stop();
262
312
  }
263
- }, _callee2);
313
+ }, _callee3);
264
314
  }));
265
- return function (_x2) {
266
- return _ref4.apply(this, arguments);
315
+ return function (_x3) {
316
+ return _ref6.apply(this, arguments);
267
317
  };
268
318
  }());
269
319
  /**
@@ -271,24 +321,24 @@ var Server = /*#__PURE__*/function () {
271
321
  * schedule_date 必填:query 或 data;schedule_datetime 可选。不走订阅。
272
322
  */
273
323
  _defineProperty(this, "handleProductQueryById", /*#__PURE__*/function () {
274
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref6) {
324
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref8) {
275
325
  var path, method, data, url, pathname, idMatch, productId, scheduleDateFromData, schedule_date, scheduleDtFromData, scheduleDtFromUrl, scheduleDatetime;
276
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
277
- while (1) switch (_context3.prev = _context3.next) {
326
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
327
+ while (1) switch (_context4.prev = _context4.next) {
278
328
  case 0:
279
- path = _ref6.path, method = _ref6.method, data = _ref6.data, url = _ref6.url;
329
+ path = _ref8.path, method = _ref8.method, data = _ref8.data, url = _ref8.url;
280
330
  pathname = _this.parseRequestPath(url || '', path);
281
331
  idMatch = pathname.match(/^\/shop\/product\/query\/(\d+)$/);
282
332
  productId = idMatch ? Number(idMatch[1]) : NaN;
283
333
  console.log('[Server] handleProductQueryById:', pathname, method, data);
284
334
  if (Number.isFinite(productId)) {
285
- _context3.next = 8;
335
+ _context4.next = 8;
286
336
  break;
287
337
  }
288
338
  _this.logWarning('handleProductQueryById: 无效的商品 id', {
289
339
  path: pathname
290
340
  });
291
- return _context3.abrupt("return", {
341
+ return _context4.abrupt("return", {
292
342
  code: 400,
293
343
  message: '无效的商品路径',
294
344
  status: false,
@@ -300,13 +350,13 @@ var Server = /*#__PURE__*/function () {
300
350
  scheduleDateFromData = data && _typeof(data) === 'object' && typeof data.schedule_date === 'string' ? data.schedule_date.trim() : '';
301
351
  schedule_date = scheduleDateFromData || (_this.extractQueryParam(url || '', 'schedule_date') || '').trim() || dayjs().format('YYYY-MM-DD');
302
352
  if (schedule_date) {
303
- _context3.next = 13;
353
+ _context4.next = 13;
304
354
  break;
305
355
  }
306
356
  _this.logWarning('handleProductQueryById: 缺少 schedule_date', {
307
357
  productId: productId
308
358
  });
309
- return _context3.abrupt("return", {
359
+ return _context4.abrupt("return", {
310
360
  code: 400,
311
361
  message: 'schedule_date 为必填(query 或 data)',
312
362
  status: false,
@@ -321,46 +371,46 @@ var Server = /*#__PURE__*/function () {
321
371
  schedule_date: schedule_date,
322
372
  schedule_datetime: scheduleDatetime
323
373
  });
324
- return _context3.abrupt("return", _this.computeProductQueryResult({
374
+ return _context4.abrupt("return", _this.computeProductQueryResult({
325
375
  schedule_date: schedule_date,
326
376
  schedule_datetime: scheduleDatetime,
327
377
  product_id: productId
328
378
  }));
329
379
  case 18:
330
380
  case "end":
331
- return _context3.stop();
381
+ return _context4.stop();
332
382
  }
333
- }, _callee3);
383
+ }, _callee4);
334
384
  }));
335
- return function (_x3) {
336
- return _ref7.apply(this, arguments);
385
+ return function (_x4) {
386
+ return _ref9.apply(this, arguments);
337
387
  };
338
388
  }());
339
389
  /**
340
390
  * 取消商品查询订阅(HTTP 路由入口)
341
391
  */
342
392
  _defineProperty(this, "handleUnsubscribeProductQuery", /*#__PURE__*/function () {
343
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref8) {
344
- var data, _ref10, subscriberId;
345
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
346
- while (1) switch (_context4.prev = _context4.next) {
393
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref10) {
394
+ var data, _ref12, subscriberId;
395
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
396
+ while (1) switch (_context5.prev = _context5.next) {
347
397
  case 0:
348
- data = _ref8.data;
349
- _ref10 = data || {}, subscriberId = _ref10.subscriberId;
398
+ data = _ref10.data;
399
+ _ref12 = data || {}, subscriberId = _ref12.subscriberId;
350
400
  _this.removeProductQuerySubscriber(subscriberId);
351
- return _context4.abrupt("return", {
401
+ return _context5.abrupt("return", {
352
402
  code: 200,
353
403
  message: 'ok',
354
404
  status: true
355
405
  });
356
406
  case 4:
357
407
  case "end":
358
- return _context4.stop();
408
+ return _context5.stop();
359
409
  }
360
- }, _callee4);
410
+ }, _callee5);
361
411
  }));
362
- return function (_x4) {
363
- return _ref9.apply(this, arguments);
412
+ return function (_x5) {
413
+ return _ref11.apply(this, arguments);
364
414
  };
365
415
  }());
366
416
  /**
@@ -368,22 +418,22 @@ var Server = /*#__PURE__*/function () {
368
418
  * 存储订阅者信息,本地计算结果;数据变更时通过 callback 推送
369
419
  */
370
420
  _defineProperty(this, "handleOrderList", /*#__PURE__*/function () {
371
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref11) {
372
- var url, method, data, config, queryPayload, _ref13, callback, subscriberId, useLocal;
373
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
374
- while (1) switch (_context5.prev = _context5.next) {
421
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref13) {
422
+ var url, method, data, config, queryPayload, _ref15, callback, subscriberId, useLocal;
423
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
424
+ while (1) switch (_context6.prev = _context6.next) {
375
425
  case 0:
376
- url = _ref11.url, method = _ref11.method, data = _ref11.data, config = _ref11.config;
426
+ url = _ref13.url, method = _ref13.method, data = _ref13.data, config = _ref13.config;
377
427
  console.log('[Server] handleOrderList:', url, method, data, config);
378
428
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
379
- _ref13 = config || {}, callback = _ref13.callback, subscriberId = _ref13.subscriberId;
429
+ _ref15 = config || {}, callback = _ref15.callback, subscriberId = _ref15.subscriberId;
380
430
  useLocal = _this.shouldUseLocalOrderQuery(queryPayload);
381
431
  _this.logInfo('handleOrderList: 开始处理订单列表请求', {
382
432
  data: queryPayload,
383
433
  useLocal: useLocal
384
434
  });
385
435
  if (!useLocal) {
386
- _context5.next = 9;
436
+ _context6.next = 9;
387
437
  break;
388
438
  }
389
439
  if (subscriberId && typeof callback === 'function') {
@@ -396,7 +446,7 @@ var Server = /*#__PURE__*/function () {
396
446
  totalSubscribers: _this.orderQuerySubscribers.size
397
447
  });
398
448
  }
399
- return _context5.abrupt("return", _this.computeOrderQueryResult(queryPayload));
449
+ return _context6.abrupt("return", _this.computeOrderQueryResult(queryPayload));
400
450
  case 9:
401
451
  if (subscriberId) {
402
452
  _this.orderQuerySubscribers.delete(subscriberId);
@@ -405,28 +455,28 @@ var Server = /*#__PURE__*/function () {
405
455
  remaining: _this.orderQuerySubscribers.size
406
456
  });
407
457
  }
408
- return _context5.abrupt("return", _this.fetchOrderListFromAPI(queryPayload));
458
+ return _context6.abrupt("return", _this.fetchOrderListFromAPI(queryPayload));
409
459
  case 11:
410
460
  case "end":
411
- return _context5.stop();
461
+ return _context6.stop();
412
462
  }
413
- }, _callee5);
463
+ }, _callee6);
414
464
  }));
415
- return function (_x5) {
416
- return _ref12.apply(this, arguments);
465
+ return function (_x6) {
466
+ return _ref14.apply(this, arguments);
417
467
  };
418
468
  }());
419
469
  /**
420
470
  * 取消订单列表查询订阅(HTTP 路由入口)
421
471
  */
422
472
  _defineProperty(this, "handleUnsubscribeOrderQuery", /*#__PURE__*/function () {
423
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref14) {
424
- var data, _ref16, subscriberId;
425
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
426
- while (1) switch (_context6.prev = _context6.next) {
473
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref16) {
474
+ var data, _ref18, subscriberId;
475
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
476
+ while (1) switch (_context7.prev = _context7.next) {
427
477
  case 0:
428
- data = _ref14.data;
429
- _ref16 = data || {}, subscriberId = _ref16.subscriberId;
478
+ data = _ref16.data;
479
+ _ref18 = data || {}, subscriberId = _ref18.subscriberId;
430
480
  if (subscriberId) {
431
481
  _this.orderQuerySubscribers.delete(subscriberId);
432
482
  _this.logInfo('handleUnsubscribeOrderQuery: 已移除订阅者', {
@@ -434,19 +484,19 @@ var Server = /*#__PURE__*/function () {
434
484
  remaining: _this.orderQuerySubscribers.size
435
485
  });
436
486
  }
437
- return _context6.abrupt("return", {
487
+ return _context7.abrupt("return", {
438
488
  code: 200,
439
489
  message: 'ok',
440
490
  status: true
441
491
  });
442
492
  case 4:
443
493
  case "end":
444
- return _context6.stop();
494
+ return _context7.stop();
445
495
  }
446
- }, _callee6);
496
+ }, _callee7);
447
497
  }));
448
- return function (_x6) {
449
- return _ref15.apply(this, arguments);
498
+ return function (_x7) {
499
+ return _ref17.apply(this, arguments);
450
500
  };
451
501
  }());
452
502
  /**
@@ -456,21 +506,21 @@ var Server = /*#__PURE__*/function () {
456
506
  * await this.handleSalesSearchModule({ url: '/shop/es/search/sales', method: 'post', data: { keyword: 'A' } })
457
507
  */
458
508
  _defineProperty(this, "handleSalesSearchModule", /*#__PURE__*/function () {
459
- var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref17) {
509
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref19) {
460
510
  var data, config;
461
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
462
- while (1) switch (_context7.prev = _context7.next) {
511
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
512
+ while (1) switch (_context8.prev = _context8.next) {
463
513
  case 0:
464
- data = _ref17.data, config = _ref17.config;
465
- return _context7.abrupt("return", _this.handleSalesSearchRequest('single', '/shop/es/search/sales', data, config));
514
+ data = _ref19.data, config = _ref19.config;
515
+ return _context8.abrupt("return", _this.handleSalesSearchRequest('single', '/shop/es/search/sales', data, config));
466
516
  case 2:
467
517
  case "end":
468
- return _context7.stop();
518
+ return _context8.stop();
469
519
  }
470
- }, _callee7);
520
+ }, _callee8);
471
521
  }));
472
- return function (_x7) {
473
- return _ref18.apply(this, arguments);
522
+ return function (_x8) {
523
+ return _ref20.apply(this, arguments);
474
524
  };
475
525
  }());
476
526
  /**
@@ -480,21 +530,21 @@ var Server = /*#__PURE__*/function () {
480
530
  * await this.handleSalesSearchAggregate({ url: '/shop/es/search', method: 'post', data: { modules: [] } })
481
531
  */
482
532
  _defineProperty(this, "handleSalesSearchAggregate", /*#__PURE__*/function () {
483
- var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref19) {
533
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
484
534
  var data, config;
485
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
486
- while (1) switch (_context8.prev = _context8.next) {
535
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
536
+ while (1) switch (_context9.prev = _context9.next) {
487
537
  case 0:
488
- data = _ref19.data, config = _ref19.config;
489
- return _context8.abrupt("return", _this.handleSalesSearchRequest('aggregate', '/shop/es/search', data, config));
538
+ data = _ref21.data, config = _ref21.config;
539
+ return _context9.abrupt("return", _this.handleSalesSearchRequest('aggregate', '/shop/es/search', data, config));
490
540
  case 2:
491
541
  case "end":
492
- return _context8.stop();
542
+ return _context9.stop();
493
543
  }
494
- }, _callee8);
544
+ }, _callee9);
495
545
  }));
496
- return function (_x8) {
497
- return _ref20.apply(this, arguments);
546
+ return function (_x9) {
547
+ return _ref22.apply(this, arguments);
498
548
  };
499
549
  }());
500
550
  /**
@@ -504,13 +554,13 @@ var Server = /*#__PURE__*/function () {
504
554
  * await this.handleUnsubscribeSalesSearch({ data: { subscriberId: 'global-search-order' } } as any)
505
555
  */
506
556
  _defineProperty(this, "handleUnsubscribeSalesSearch", /*#__PURE__*/function () {
507
- var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
508
- var data, _ref23, subscriberId;
509
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
510
- while (1) switch (_context9.prev = _context9.next) {
557
+ var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref23) {
558
+ var data, _ref25, subscriberId;
559
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
560
+ while (1) switch (_context10.prev = _context10.next) {
511
561
  case 0:
512
- data = _ref21.data;
513
- _ref23 = data || {}, subscriberId = _ref23.subscriberId;
562
+ data = _ref23.data;
563
+ _ref25 = data || {}, subscriberId = _ref25.subscriberId;
514
564
  if (subscriberId) {
515
565
  _this.salesSearchSubscribers.delete(subscriberId);
516
566
  _this.logInfo('handleUnsubscribeSalesSearch: 已移除订阅者', {
@@ -518,19 +568,19 @@ var Server = /*#__PURE__*/function () {
518
568
  remaining: _this.salesSearchSubscribers.size
519
569
  });
520
570
  }
521
- return _context9.abrupt("return", {
571
+ return _context10.abrupt("return", {
522
572
  code: 200,
523
573
  message: 'ok',
524
574
  status: true
525
575
  });
526
576
  case 4:
527
577
  case "end":
528
- return _context9.stop();
578
+ return _context10.stop();
529
579
  }
530
- }, _callee9);
580
+ }, _callee10);
531
581
  }));
532
- return function (_x9) {
533
- return _ref22.apply(this, arguments);
582
+ return function (_x10) {
583
+ return _ref24.apply(this, arguments);
534
584
  };
535
585
  }());
536
586
  /**
@@ -543,22 +593,22 @@ var Server = /*#__PURE__*/function () {
543
593
  * 今天:注册订阅者 + 本地数据筛选;非今天:清理订阅者 + 走真实 API
544
594
  */
545
595
  _defineProperty(this, "handleBookingList", /*#__PURE__*/function () {
546
- var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref24) {
547
- var url, method, data, config, queryPayload, _ref26, callback, subscriberId, useLocal, withFields, requestPayload, cacheKey;
548
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
549
- while (1) switch (_context10.prev = _context10.next) {
596
+ var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref26) {
597
+ var url, method, data, config, queryPayload, _ref28, callback, subscriberId, useLocal, withFields, requestPayload, cacheKey;
598
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
599
+ while (1) switch (_context11.prev = _context11.next) {
550
600
  case 0:
551
- url = _ref24.url, method = _ref24.method, data = _ref24.data, config = _ref24.config;
601
+ url = _ref26.url, method = _ref26.method, data = _ref26.data, config = _ref26.config;
552
602
  console.log('[Server] handleBookingList:', url, method, data, config);
553
603
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
554
- _ref26 = config || {}, callback = _ref26.callback, subscriberId = _ref26.subscriberId;
604
+ _ref28 = config || {}, callback = _ref28.callback, subscriberId = _ref28.subscriberId;
555
605
  useLocal = _this.shouldUseLocalBookingQuery(queryPayload);
556
606
  _this.logInfo('handleBookingList: 开始处理预约列表请求', {
557
607
  data: queryPayload,
558
608
  useLocal: useLocal
559
609
  });
560
610
  if (!useLocal) {
561
- _context10.next = 12;
611
+ _context11.next = 12;
562
612
  break;
563
613
  }
564
614
  if (subscriberId) {
@@ -574,7 +624,7 @@ var Server = /*#__PURE__*/function () {
574
624
  totalSubscribers: _this.bookingQuerySubscribers.size
575
625
  });
576
626
  }
577
- return _context10.abrupt("return", _this.computeBookingQueryResult(queryPayload));
627
+ return _context11.abrupt("return", _this.computeBookingQueryResult(queryPayload));
578
628
  case 12:
579
629
  if (subscriberId) {
580
630
  _this.bookingQuerySubscribers.delete(subscriberId);
@@ -600,15 +650,15 @@ var Server = /*#__PURE__*/function () {
600
650
  remaining: _this.bookingQuerySubscribers.size
601
651
  });
602
652
  }
603
- return _context10.abrupt("return", _this.fetchBookingListFromAPI(queryPayload));
653
+ return _context11.abrupt("return", _this.fetchBookingListFromAPI(queryPayload));
604
654
  case 16:
605
655
  case "end":
606
- return _context10.stop();
656
+ return _context11.stop();
607
657
  }
608
- }, _callee10);
658
+ }, _callee11);
609
659
  }));
610
- return function (_x10) {
611
- return _ref25.apply(this, arguments);
660
+ return function (_x11) {
661
+ return _ref27.apply(this, arguments);
612
662
  };
613
663
  }());
614
664
  /**
@@ -616,13 +666,13 @@ var Server = /*#__PURE__*/function () {
616
666
  * 转发到资源模块去
617
667
  */
618
668
  _defineProperty(this, "handleResourceList", /*#__PURE__*/function () {
619
- var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref27) {
669
+ var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref29) {
620
670
  var _this$resource;
621
671
  var url, method, data, config, list;
622
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
623
- while (1) switch (_context11.prev = _context11.next) {
672
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
673
+ while (1) switch (_context12.prev = _context12.next) {
624
674
  case 0:
625
- url = _ref27.url, method = _ref27.method, data = _ref27.data, config = _ref27.config;
675
+ url = _ref29.url, method = _ref29.method, data = _ref29.data, config = _ref29.config;
626
676
  console.log('[Server] handleResourceList:', url, method, data, config);
627
677
  list = (_this$resource = _this.resource) === null || _this$resource === void 0 ? void 0 : _this$resource.getResources({
628
678
  skip: (data === null || data === void 0 ? void 0 : data.skip) || 1,
@@ -631,7 +681,7 @@ var Server = /*#__PURE__*/function () {
631
681
  _this.logInfo('Server 劫持 Resource 接口:handleResourceList: 资源列表查询结果', {
632
682
  list: list
633
683
  });
634
- return _context11.abrupt("return", {
684
+ return _context12.abrupt("return", {
635
685
  code: 200,
636
686
  data: {
637
687
  list: list,
@@ -642,12 +692,12 @@ var Server = /*#__PURE__*/function () {
642
692
  });
643
693
  case 5:
644
694
  case "end":
645
- return _context11.stop();
695
+ return _context12.stop();
646
696
  }
647
- }, _callee11);
697
+ }, _callee12);
648
698
  }));
649
- return function (_x11) {
650
- return _ref28.apply(this, arguments);
699
+ return function (_x12) {
700
+ return _ref30.apply(this, arguments);
651
701
  };
652
702
  }());
653
703
  /**
@@ -665,35 +715,35 @@ var Server = /*#__PURE__*/function () {
665
715
  * @example 批量:GET /update/localOrder?order_ids=96971,96972,96973
666
716
  */
667
717
  _defineProperty(this, "handleUpdateLocalOrder", /*#__PURE__*/function () {
668
- var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref29) {
669
- var _ref31, _this$app;
718
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref31) {
719
+ var _ref33, _this$app;
670
720
  var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response, fresh, exists, _yield$_this$order$ov, overwritten, errorMessage;
671
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
672
- while (1) switch (_context12.prev = _context12.next) {
721
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
722
+ while (1) switch (_context13.prev = _context13.next) {
673
723
  case 0:
674
- url = _ref29.url, data = _ref29.data;
724
+ url = _ref31.url, data = _ref31.data;
675
725
  batchIds = _this.parseOrderIdsParam(url, data);
676
726
  if (!(batchIds.length > 0)) {
677
- _context12.next = 4;
727
+ _context13.next = 4;
678
728
  break;
679
729
  }
680
- return _context12.abrupt("return", _this.handleUpdateLocalOrdersBatch(batchIds));
730
+ return _context13.abrupt("return", _this.handleUpdateLocalOrdersBatch(batchIds));
681
731
  case 4:
682
- rawOrderId = (_ref31 = data && _typeof(data) === 'object' ? data.order_id : undefined) !== null && _ref31 !== void 0 ? _ref31 : _this.extractQueryParam(url, 'order_id');
732
+ rawOrderId = (_ref33 = data && _typeof(data) === 'object' ? data.order_id : undefined) !== null && _ref33 !== void 0 ? _ref33 : _this.extractQueryParam(url, 'order_id');
683
733
  orderId = rawOrderId === undefined || rawOrderId === null || rawOrderId === '' ? null : String(rawOrderId).trim();
684
734
  _this.logInfo('handleUpdateLocalOrder: 开始处理', {
685
735
  url: url,
686
736
  orderId: orderId
687
737
  });
688
738
  if (orderId) {
689
- _context12.next = 10;
739
+ _context13.next = 10;
690
740
  break;
691
741
  }
692
742
  _this.logWarning('handleUpdateLocalOrder: order_id 缺失', {
693
743
  url: url,
694
744
  data: data
695
745
  });
696
- return _context12.abrupt("return", {
746
+ return _context13.abrupt("return", {
697
747
  code: 400,
698
748
  status: false,
699
749
  message: 'order_id 缺失',
@@ -701,11 +751,11 @@ var Server = /*#__PURE__*/function () {
701
751
  });
702
752
  case 10:
703
753
  if (_this.order) {
704
- _context12.next = 13;
754
+ _context13.next = 13;
705
755
  break;
706
756
  }
707
757
  _this.logError('handleUpdateLocalOrder: Order 模块未注册');
708
- return _context12.abrupt("return", {
758
+ return _context13.abrupt("return", {
709
759
  code: 500,
710
760
  status: false,
711
761
  message: 'Order 模块未注册',
@@ -713,11 +763,11 @@ var Server = /*#__PURE__*/function () {
713
763
  });
714
764
  case 13:
715
765
  if ((_this$app = _this.app) !== null && _this$app !== void 0 && _this$app.request) {
716
- _context12.next = 16;
766
+ _context13.next = 16;
717
767
  break;
718
768
  }
719
769
  _this.logError('handleUpdateLocalOrder: app.request 不可用');
720
- return _context12.abrupt("return", {
770
+ return _context13.abrupt("return", {
721
771
  code: 500,
722
772
  status: false,
723
773
  message: 'app.request 不可用',
@@ -725,23 +775,23 @@ var Server = /*#__PURE__*/function () {
725
775
  });
726
776
  case 16:
727
777
  backendPath = "/shop/order/sales/".concat(encodeURIComponent(orderId), "?with%5B%5D=all");
728
- _context12.prev = 17;
729
- _context12.next = 20;
778
+ _context13.prev = 17;
779
+ _context13.next = 20;
730
780
  return _this.app.request.get(backendPath, undefined, {
731
781
  isShopApi: true
732
782
  });
733
783
  case 20:
734
- response = _context12.sent;
784
+ response = _context13.sent;
735
785
  fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
736
786
  if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
737
- _context12.next = 25;
787
+ _context13.next = 25;
738
788
  break;
739
789
  }
740
790
  _this.logError('handleUpdateLocalOrder: 后端返回订单为空', {
741
791
  orderId: orderId,
742
792
  backendPath: backendPath
743
793
  });
744
- return _context12.abrupt("return", {
794
+ return _context13.abrupt("return", {
745
795
  code: 500,
746
796
  status: false,
747
797
  message: '后端返回订单为空',
@@ -750,19 +800,19 @@ var Server = /*#__PURE__*/function () {
750
800
  case 25:
751
801
  exists = !!_this.order.getOrderByOrderId(orderId);
752
802
  if (!exists) {
753
- _context12.next = 33;
803
+ _context13.next = 33;
754
804
  break;
755
805
  }
756
- _context12.next = 29;
806
+ _context13.next = 29;
757
807
  return _this.order.overwriteExistingOrder(fresh);
758
808
  case 29:
759
- _yield$_this$order$ov = _context12.sent;
809
+ _yield$_this$order$ov = _context13.sent;
760
810
  overwritten = _yield$_this$order$ov.overwritten;
761
811
  _this.logInfo('handleUpdateLocalOrder: 覆盖完成', {
762
812
  orderId: orderId,
763
813
  overwritten: overwritten
764
814
  });
765
- return _context12.abrupt("return", {
815
+ return _context13.abrupt("return", {
766
816
  code: 200,
767
817
  status: true,
768
818
  message: '',
@@ -773,13 +823,13 @@ var Server = /*#__PURE__*/function () {
773
823
  }
774
824
  });
775
825
  case 33:
776
- _context12.next = 35;
826
+ _context13.next = 35;
777
827
  return _this.order.upsertOrdersFromRemote([fresh]);
778
828
  case 35:
779
829
  _this.logInfo('handleUpdateLocalOrder: 本地合并新订单完成', {
780
830
  orderId: orderId
781
831
  });
782
- return _context12.abrupt("return", {
832
+ return _context13.abrupt("return", {
783
833
  code: 200,
784
834
  status: true,
785
835
  message: '',
@@ -790,15 +840,15 @@ var Server = /*#__PURE__*/function () {
790
840
  }
791
841
  });
792
842
  case 39:
793
- _context12.prev = 39;
794
- _context12.t0 = _context12["catch"](17);
795
- errorMessage = _context12.t0 instanceof Error ? _context12.t0.message : String(_context12.t0);
843
+ _context13.prev = 39;
844
+ _context13.t0 = _context13["catch"](17);
845
+ errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
796
846
  _this.logError('handleUpdateLocalOrder: 请求失败', {
797
847
  orderId: orderId,
798
848
  backendPath: backendPath,
799
849
  error: errorMessage
800
850
  });
801
- return _context12.abrupt("return", {
851
+ return _context13.abrupt("return", {
802
852
  code: 500,
803
853
  status: false,
804
854
  message: errorMessage,
@@ -806,72 +856,72 @@ var Server = /*#__PURE__*/function () {
806
856
  });
807
857
  case 44:
808
858
  case "end":
809
- return _context12.stop();
859
+ return _context13.stop();
810
860
  }
811
- }, _callee12, null, [[17, 39]]);
861
+ }, _callee13, null, [[17, 39]]);
812
862
  }));
813
- return function (_x12) {
814
- return _ref30.apply(this, arguments);
863
+ return function (_x13) {
864
+ return _ref32.apply(this, arguments);
815
865
  };
816
866
  }());
817
867
  _defineProperty(this, "handleOrderSalesCheckout", /*#__PURE__*/function () {
818
- var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref32) {
868
+ var _ref35 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref34) {
819
869
  var data;
820
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
821
- while (1) switch (_context13.prev = _context13.next) {
870
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
871
+ while (1) switch (_context14.prev = _context14.next) {
822
872
  case 0:
823
- data = _ref32.data;
824
- return _context13.abrupt("return", _this.handleOrderCheckoutSubmit({
873
+ data = _ref34.data;
874
+ return _context14.abrupt("return", _this.handleOrderCheckoutSubmit({
825
875
  backendPath: '/shop/order/sales/checkout',
826
876
  data: data,
827
877
  title: 'handleOrderSalesCheckout'
828
878
  }));
829
879
  case 2:
830
880
  case "end":
831
- return _context13.stop();
881
+ return _context14.stop();
832
882
  }
833
- }, _callee13);
883
+ }, _callee14);
834
884
  }));
835
- return function (_x13) {
836
- return _ref33.apply(this, arguments);
885
+ return function (_x14) {
886
+ return _ref35.apply(this, arguments);
837
887
  };
838
888
  }());
839
889
  _defineProperty(this, "handleOrderCheckout", /*#__PURE__*/function () {
840
- var _ref35 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref34) {
890
+ var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref36) {
841
891
  var data;
842
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
843
- while (1) switch (_context14.prev = _context14.next) {
892
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
893
+ while (1) switch (_context15.prev = _context15.next) {
844
894
  case 0:
845
- data = _ref34.data;
846
- return _context14.abrupt("return", _this.handleOrderCheckoutSubmit({
895
+ data = _ref36.data;
896
+ return _context15.abrupt("return", _this.handleOrderCheckoutSubmit({
847
897
  backendPath: '/order/checkout',
848
898
  data: data,
849
899
  title: 'handleOrderCheckout'
850
900
  }));
851
901
  case 2:
852
902
  case "end":
853
- return _context14.stop();
903
+ return _context15.stop();
854
904
  }
855
- }, _callee14);
905
+ }, _callee15);
856
906
  }));
857
- return function (_x14) {
858
- return _ref35.apply(this, arguments);
907
+ return function (_x15) {
908
+ return _ref37.apply(this, arguments);
859
909
  };
860
910
  }());
861
911
  _defineProperty(this, "handleLocalPrintOrder", /*#__PURE__*/function () {
862
- var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref36) {
912
+ var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref38) {
863
913
  var data, _need_sync, inputOrder, checkoutData, printableOrder, printResult, message;
864
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
865
- while (1) switch (_context15.prev = _context15.next) {
914
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
915
+ while (1) switch (_context16.prev = _context16.next) {
866
916
  case 0:
867
- data = _ref36.data;
868
- _context15.prev = 1;
917
+ data = _ref38.data;
918
+ _context16.prev = 1;
869
919
  inputOrder = data !== null && data !== void 0 && data.order && _typeof(data.order) === 'object' ? data.order : data;
870
920
  if (!(!inputOrder || _typeof(inputOrder) !== 'object')) {
871
- _context15.next = 5;
921
+ _context16.next = 5;
872
922
  break;
873
923
  }
874
- return _context15.abrupt("return", {
924
+ return _context16.abrupt("return", {
875
925
  code: 400,
876
926
  status: false,
877
927
  message: '订单数据不能为空',
@@ -881,16 +931,16 @@ var Server = /*#__PURE__*/function () {
881
931
  }
882
932
  });
883
933
  case 5:
884
- _context15.next = 7;
934
+ _context16.next = 7;
885
935
  return _this.ensureCheckoutOrderNumbers(_objectSpread(_objectSpread({}, inputOrder), {}, {
886
936
  small_ticket_data_flag: 1
887
937
  }), 'handleLocalPrintOrder');
888
938
  case 7:
889
- checkoutData = _context15.sent;
939
+ checkoutData = _context16.sent;
890
940
  printableOrder = _objectSpread(_objectSpread({}, checkoutData), {}, {
891
941
  need_sync: (_need_sync = checkoutData.need_sync) !== null && _need_sync !== void 0 ? _need_sync : 1
892
942
  });
893
- _context15.next = 11;
943
+ _context16.next = 11;
894
944
  return _this.dispatchLocalReceiptPrint({
895
945
  checkoutData: checkoutData,
896
946
  order: printableOrder,
@@ -898,8 +948,8 @@ var Server = /*#__PURE__*/function () {
898
948
  requireFullyPaid: false
899
949
  });
900
950
  case 11:
901
- printResult = _context15.sent;
902
- return _context15.abrupt("return", {
951
+ printResult = _context16.sent;
952
+ return _context16.abrupt("return", {
903
953
  code: 200,
904
954
  status: true,
905
955
  message: '',
@@ -909,13 +959,13 @@ var Server = /*#__PURE__*/function () {
909
959
  }
910
960
  });
911
961
  case 15:
912
- _context15.prev = 15;
913
- _context15.t0 = _context15["catch"](1);
914
- message = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
962
+ _context16.prev = 15;
963
+ _context16.t0 = _context16["catch"](1);
964
+ message = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
915
965
  _this.logError('handleLocalPrintOrder: 本地打印小票失败', {
916
966
  error: message
917
967
  });
918
- return _context15.abrupt("return", {
968
+ return _context16.abrupt("return", {
919
969
  code: 500,
920
970
  status: false,
921
971
  message: message,
@@ -926,22 +976,22 @@ var Server = /*#__PURE__*/function () {
926
976
  });
927
977
  case 20:
928
978
  case "end":
929
- return _context15.stop();
979
+ return _context16.stop();
930
980
  }
931
- }, _callee15, null, [[1, 15]]);
981
+ }, _callee16, null, [[1, 15]]);
932
982
  }));
933
- return function (_x15) {
934
- return _ref37.apply(this, arguments);
983
+ return function (_x16) {
984
+ return _ref39.apply(this, arguments);
935
985
  };
936
986
  }());
937
987
  _defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
938
- var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref38) {
988
+ var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref40) {
939
989
  var _this$app2;
940
990
  var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data2, response, fresh, savedOrder, errorMessage;
941
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
942
- while (1) switch (_context16.prev = _context16.next) {
991
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
992
+ while (1) switch (_context17.prev = _context17.next) {
943
993
  case 0:
944
- url = _ref38.url, data = _ref38.data, path = _ref38.path;
994
+ url = _ref40.url, data = _ref40.data, path = _ref40.path;
945
995
  requestPath = _this.parseRequestPath(url, path);
946
996
  lookup = _this.extractOrderSalesDetailLookup(requestPath);
947
997
  _this.logInfo('handleOrderSalesDetail: 开始处理', {
@@ -950,14 +1000,14 @@ var Server = /*#__PURE__*/function () {
950
1000
  lookup: lookup
951
1001
  });
952
1002
  if (lookup) {
953
- _context16.next = 7;
1003
+ _context17.next = 7;
954
1004
  break;
955
1005
  }
956
1006
  _this.logWarning('handleOrderSalesDetail: lookup 缺失', {
957
1007
  url: url,
958
1008
  path: requestPath
959
1009
  });
960
- return _context16.abrupt("return", {
1010
+ return _context17.abrupt("return", {
961
1011
  code: 400,
962
1012
  status: false,
963
1013
  message: '订单 lookup 缺失',
@@ -965,11 +1015,11 @@ var Server = /*#__PURE__*/function () {
965
1015
  });
966
1016
  case 7:
967
1017
  if (_this.order) {
968
- _context16.next = 10;
1018
+ _context17.next = 10;
969
1019
  break;
970
1020
  }
971
1021
  _this.logError('handleOrderSalesDetail: Order 模块未注册');
972
- return _context16.abrupt("return", {
1022
+ return _context17.abrupt("return", {
973
1023
  code: 500,
974
1024
  status: false,
975
1025
  message: 'Order 模块未注册',
@@ -977,21 +1027,21 @@ var Server = /*#__PURE__*/function () {
977
1027
  });
978
1028
  case 10:
979
1029
  if (_this.shouldForceRemoteSalesDetail(data)) {
980
- _context16.next = 17;
1030
+ _context17.next = 17;
981
1031
  break;
982
1032
  }
983
- _context16.next = 13;
1033
+ _context17.next = 13;
984
1034
  return _this.order.getLocalOrderByLookup(lookup);
985
1035
  case 13:
986
- localOrder = _context16.sent;
1036
+ localOrder = _context17.sent;
987
1037
  if (!localOrder) {
988
- _context16.next = 17;
1038
+ _context17.next = 17;
989
1039
  break;
990
1040
  }
991
1041
  _this.logInfo('handleOrderSalesDetail: 命中本地订单', {
992
1042
  lookup: lookup
993
1043
  });
994
- return _context16.abrupt("return", {
1044
+ return _context17.abrupt("return", {
995
1045
  code: 200,
996
1046
  status: true,
997
1047
  message: '',
@@ -999,11 +1049,11 @@ var Server = /*#__PURE__*/function () {
999
1049
  });
1000
1050
  case 17:
1001
1051
  if ((_this$app2 = _this.app) !== null && _this$app2 !== void 0 && _this$app2.request) {
1002
- _context16.next = 20;
1052
+ _context17.next = 20;
1003
1053
  break;
1004
1054
  }
1005
1055
  _this.logError('handleOrderSalesDetail: app.request 不可用');
1006
- return _context16.abrupt("return", {
1056
+ return _context17.abrupt("return", {
1007
1057
  code: 500,
1008
1058
  status: false,
1009
1059
  message: 'app.request 不可用',
@@ -1011,8 +1061,8 @@ var Server = /*#__PURE__*/function () {
1011
1061
  });
1012
1062
  case 20:
1013
1063
  backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
1014
- _context16.prev = 21;
1015
- _context16.next = 24;
1064
+ _context17.prev = 21;
1065
+ _context17.next = 24;
1016
1066
  return _this.app.request.get(backendPath, {
1017
1067
  lookup_mode: 'multi'
1018
1068
  }, {
@@ -1020,38 +1070,38 @@ var Server = /*#__PURE__*/function () {
1020
1070
  customToast: function customToast() {}
1021
1071
  });
1022
1072
  case 24:
1023
- response = _context16.sent;
1073
+ response = _context17.sent;
1024
1074
  fresh = (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response;
1025
1075
  if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
1026
- _context16.next = 29;
1076
+ _context17.next = 29;
1027
1077
  break;
1028
1078
  }
1029
1079
  _this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
1030
1080
  lookup: lookup,
1031
1081
  backendPath: backendPath
1032
1082
  });
1033
- return _context16.abrupt("return", {
1083
+ return _context17.abrupt("return", {
1034
1084
  code: 500,
1035
1085
  status: false,
1036
1086
  message: '后端返回订单为空',
1037
1087
  data: null
1038
1088
  });
1039
1089
  case 29:
1040
- _context16.next = 31;
1090
+ _context17.next = 31;
1041
1091
  return _this.order.upsertOrdersFromRemote([fresh]);
1042
1092
  case 31:
1043
- _context16.next = 33;
1093
+ _context17.next = 33;
1044
1094
  return _this.order.getLocalOrderByLookup(lookup);
1045
1095
  case 33:
1046
- savedOrder = _context16.sent;
1096
+ savedOrder = _context17.sent;
1047
1097
  if (savedOrder) {
1048
- _context16.next = 37;
1098
+ _context17.next = 37;
1049
1099
  break;
1050
1100
  }
1051
1101
  _this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
1052
1102
  lookup: lookup
1053
1103
  });
1054
- return _context16.abrupt("return", {
1104
+ return _context17.abrupt("return", {
1055
1105
  code: 500,
1056
1106
  status: false,
1057
1107
  message: '订单写入后回读失败',
@@ -1061,22 +1111,22 @@ var Server = /*#__PURE__*/function () {
1061
1111
  _this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
1062
1112
  lookup: lookup
1063
1113
  });
1064
- return _context16.abrupt("return", {
1114
+ return _context17.abrupt("return", {
1065
1115
  code: 200,
1066
1116
  status: true,
1067
1117
  message: '',
1068
1118
  data: savedOrder
1069
1119
  });
1070
1120
  case 41:
1071
- _context16.prev = 41;
1072
- _context16.t0 = _context16["catch"](21);
1073
- errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1121
+ _context17.prev = 41;
1122
+ _context17.t0 = _context17["catch"](21);
1123
+ errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1074
1124
  _this.logError('handleOrderSalesDetail: 请求失败', {
1075
1125
  lookup: lookup,
1076
1126
  backendPath: backendPath,
1077
1127
  error: errorMessage
1078
1128
  });
1079
- return _context16.abrupt("return", {
1129
+ return _context17.abrupt("return", {
1080
1130
  code: 500,
1081
1131
  status: false,
1082
1132
  message: errorMessage,
@@ -1084,28 +1134,28 @@ var Server = /*#__PURE__*/function () {
1084
1134
  });
1085
1135
  case 46:
1086
1136
  case "end":
1087
- return _context16.stop();
1137
+ return _context17.stop();
1088
1138
  }
1089
- }, _callee16, null, [[21, 41]]);
1139
+ }, _callee17, null, [[21, 41]]);
1090
1140
  }));
1091
- return function (_x16) {
1092
- return _ref39.apply(this, arguments);
1141
+ return function (_x17) {
1142
+ return _ref41.apply(this, arguments);
1093
1143
  };
1094
1144
  }());
1095
1145
  /**
1096
1146
  * GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
1097
1147
  */
1098
1148
  _defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
1099
- var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref40) {
1100
- var url, data, config, routePath, base, path, _subscriberId, _ref42, callback, subscriberId, ctx;
1101
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1102
- while (1) switch (_context17.prev = _context17.next) {
1149
+ var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref42) {
1150
+ var url, data, config, routePath, base, path, _subscriberId, _ref44, callback, subscriberId, ctx;
1151
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1152
+ while (1) switch (_context18.prev = _context18.next) {
1103
1153
  case 0:
1104
- url = _ref40.url, data = _ref40.data, config = _ref40.config, routePath = _ref40.path;
1154
+ url = _ref42.url, data = _ref42.data, config = _ref42.config, routePath = _ref42.path;
1105
1155
  base = '/shop/schedule/floor-plan';
1106
1156
  path = _this.parseRequestPath(url, routePath);
1107
1157
  if (!(path === "".concat(base, "/unsubscribe"))) {
1108
- _context17.next = 7;
1158
+ _context18.next = 7;
1109
1159
  break;
1110
1160
  }
1111
1161
  _subscriberId = data === null || data === void 0 ? void 0 : data.subscriberId;
@@ -1116,19 +1166,19 @@ var Server = /*#__PURE__*/function () {
1116
1166
  remaining: _this.floorPlanQuerySubscribers.size
1117
1167
  });
1118
1168
  }
1119
- return _context17.abrupt("return", {
1169
+ return _context18.abrupt("return", {
1120
1170
  code: 200,
1121
1171
  message: 'ok',
1122
1172
  status: true
1123
1173
  });
1124
1174
  case 7:
1125
- _ref42 = config || {}, callback = _ref42.callback, subscriberId = _ref42.subscriberId;
1175
+ _ref44 = config || {}, callback = _ref44.callback, subscriberId = _ref44.subscriberId;
1126
1176
  ctx = _this.resolveFloorPlanQueryContext(path, base);
1127
1177
  if (ctx) {
1128
- _context17.next = 11;
1178
+ _context18.next = 11;
1129
1179
  break;
1130
1180
  }
1131
- return _context17.abrupt("return", {
1181
+ return _context18.abrupt("return", {
1132
1182
  status: false,
1133
1183
  code: 404,
1134
1184
  message: 'Not Found',
@@ -1146,28 +1196,28 @@ var Server = /*#__PURE__*/function () {
1146
1196
  total: _this.floorPlanQuerySubscribers.size
1147
1197
  });
1148
1198
  }
1149
- return _context17.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
1199
+ return _context18.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
1150
1200
  case 13:
1151
1201
  case "end":
1152
- return _context17.stop();
1202
+ return _context18.stop();
1153
1203
  }
1154
- }, _callee17);
1204
+ }, _callee18);
1155
1205
  }));
1156
- return function (_x17) {
1157
- return _ref41.apply(this, arguments);
1206
+ return function (_x18) {
1207
+ return _ref43.apply(this, arguments);
1158
1208
  };
1159
1209
  }());
1160
1210
  /**
1161
1211
  * 取消预约列表查询订阅(HTTP 路由入口)
1162
1212
  */
1163
1213
  _defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
1164
- var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref43) {
1165
- var data, _ref45, subscriberId;
1166
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1167
- while (1) switch (_context18.prev = _context18.next) {
1214
+ var _ref46 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref45) {
1215
+ var data, _ref47, subscriberId;
1216
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1217
+ while (1) switch (_context19.prev = _context19.next) {
1168
1218
  case 0:
1169
- data = _ref43.data;
1170
- _ref45 = data || {}, subscriberId = _ref45.subscriberId;
1219
+ data = _ref45.data;
1220
+ _ref47 = data || {}, subscriberId = _ref47.subscriberId;
1171
1221
  if (subscriberId) {
1172
1222
  _this.bookingQuerySubscribers.delete(subscriberId);
1173
1223
  _this.bookingRemoteQuerySubscribers.delete(subscriberId);
@@ -1177,19 +1227,19 @@ var Server = /*#__PURE__*/function () {
1177
1227
  remainingRemote: _this.bookingRemoteQuerySubscribers.size
1178
1228
  });
1179
1229
  }
1180
- return _context18.abrupt("return", {
1230
+ return _context19.abrupt("return", {
1181
1231
  code: 200,
1182
1232
  message: 'ok',
1183
1233
  status: true
1184
1234
  });
1185
1235
  case 4:
1186
1236
  case "end":
1187
- return _context18.stop();
1237
+ return _context19.stop();
1188
1238
  }
1189
- }, _callee18);
1239
+ }, _callee19);
1190
1240
  }));
1191
- return function (_x18) {
1192
- return _ref44.apply(this, arguments);
1241
+ return function (_x19) {
1242
+ return _ref46.apply(this, arguments);
1193
1243
  };
1194
1244
  }());
1195
1245
  /**
@@ -1197,13 +1247,13 @@ var Server = /*#__PURE__*/function () {
1197
1247
  * 通过餐牌ID列表获取所有相关日程的时间段点
1198
1248
  */
1199
1249
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1200
- var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref46) {
1250
+ var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref48) {
1201
1251
  var _menu_list_ids$length;
1202
1252
  var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1203
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1204
- while (1) switch (_context19.prev = _context19.next) {
1253
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1254
+ while (1) switch (_context20.prev = _context20.next) {
1205
1255
  case 0:
1206
- url = _ref46.url, method = _ref46.method, data = _ref46.data, config = _ref46.config;
1256
+ url = _ref48.url, method = _ref48.method, data = _ref48.data, config = _ref48.config;
1207
1257
  console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
1208
1258
  menu_list_ids = data.menu_list_ids;
1209
1259
  _this.logInfo('handleGetScheduleTimePoints 开始处理', {
@@ -1213,12 +1263,12 @@ var Server = /*#__PURE__*/function () {
1213
1263
 
1214
1264
  // 检查必要的模块是否已注册
1215
1265
  if (_this.menu) {
1216
- _context19.next = 8;
1266
+ _context20.next = 8;
1217
1267
  break;
1218
1268
  }
1219
1269
  console.error('[Server] Menu 模块未注册');
1220
1270
  _this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
1221
- return _context19.abrupt("return", {
1271
+ return _context20.abrupt("return", {
1222
1272
  code: 500,
1223
1273
  message: 'Menu 模块未注册',
1224
1274
  data: [],
@@ -1226,12 +1276,12 @@ var Server = /*#__PURE__*/function () {
1226
1276
  });
1227
1277
  case 8:
1228
1278
  if (_this.schedule) {
1229
- _context19.next = 12;
1279
+ _context20.next = 12;
1230
1280
  break;
1231
1281
  }
1232
1282
  console.error('[Server] Schedule 模块未注册');
1233
1283
  _this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
1234
- return _context19.abrupt("return", {
1284
+ return _context20.abrupt("return", {
1235
1285
  code: 500,
1236
1286
  message: 'Schedule 模块未注册',
1237
1287
  data: [],
@@ -1239,7 +1289,7 @@ var Server = /*#__PURE__*/function () {
1239
1289
  });
1240
1290
  case 12:
1241
1291
  if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
1242
- _context19.next = 16;
1292
+ _context20.next = 16;
1243
1293
  break;
1244
1294
  }
1245
1295
  console.error('[Server] menu_list_ids 参数无效');
@@ -1247,14 +1297,14 @@ var Server = /*#__PURE__*/function () {
1247
1297
  menuListIdsCount: (_menu_list_ids$length2 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length2 !== void 0 ? _menu_list_ids$length2 : 0,
1248
1298
  menu_list_ids: menu_list_ids
1249
1299
  });
1250
- return _context19.abrupt("return", {
1300
+ return _context20.abrupt("return", {
1251
1301
  code: 400,
1252
1302
  message: 'menu_list_ids 参数无效',
1253
1303
  data: [],
1254
1304
  status: false
1255
1305
  });
1256
1306
  case 16:
1257
- _context19.prev = 16;
1307
+ _context20.prev = 16;
1258
1308
  // 1. 获取餐牌列表
1259
1309
  menuList = _this.menu.getMenuByIds(menu_list_ids);
1260
1310
  console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
@@ -1272,13 +1322,13 @@ var Server = /*#__PURE__*/function () {
1272
1322
  scheduleCount: scheduleIds.length
1273
1323
  });
1274
1324
  if (!(scheduleIds.length === 0)) {
1275
- _context19.next = 26;
1325
+ _context20.next = 26;
1276
1326
  break;
1277
1327
  }
1278
1328
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
1279
1329
  menuListIdsCount: menu_list_ids.length
1280
1330
  });
1281
- return _context19.abrupt("return", {
1331
+ return _context20.abrupt("return", {
1282
1332
  code: 200,
1283
1333
  message: '没有找到相关日程',
1284
1334
  data: [],
@@ -1302,22 +1352,22 @@ var Server = /*#__PURE__*/function () {
1302
1352
  scheduleCount: scheduleList.length,
1303
1353
  timePointCount: timePoints.length
1304
1354
  });
1305
- return _context19.abrupt("return", {
1355
+ return _context20.abrupt("return", {
1306
1356
  code: 200,
1307
1357
  message: '获取成功',
1308
1358
  data: timePoints,
1309
1359
  status: true
1310
1360
  });
1311
1361
  case 35:
1312
- _context19.prev = 35;
1313
- _context19.t0 = _context19["catch"](16);
1314
- errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : '未知错误';
1315
- console.error('[Server] 获取日程时间点失败:', _context19.t0);
1362
+ _context20.prev = 35;
1363
+ _context20.t0 = _context20["catch"](16);
1364
+ errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : '未知错误';
1365
+ console.error('[Server] 获取日程时间点失败:', _context20.t0);
1316
1366
  _this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
1317
1367
  menuListIdsCount: menu_list_ids.length,
1318
1368
  error: errorMessage
1319
1369
  });
1320
- return _context19.abrupt("return", {
1370
+ return _context20.abrupt("return", {
1321
1371
  code: 500,
1322
1372
  message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
1323
1373
  data: [],
@@ -1325,12 +1375,12 @@ var Server = /*#__PURE__*/function () {
1325
1375
  });
1326
1376
  case 41:
1327
1377
  case "end":
1328
- return _context19.stop();
1378
+ return _context20.stop();
1329
1379
  }
1330
- }, _callee19, null, [[16, 35]]);
1380
+ }, _callee20, null, [[16, 35]]);
1331
1381
  }));
1332
- return function (_x19) {
1333
- return _ref47.apply(this, arguments);
1382
+ return function (_x20) {
1383
+ return _ref49.apply(this, arguments);
1334
1384
  };
1335
1385
  }());
1336
1386
  this.core = core;
@@ -1427,10 +1477,10 @@ var Server = /*#__PURE__*/function () {
1427
1477
  }, {
1428
1478
  key: "registerModuleWithRoutes",
1429
1479
  value: (function () {
1430
- var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(module, options, moduleName) {
1480
+ var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(module, options, moduleName) {
1431
1481
  var routes;
1432
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1433
- while (1) switch (_context20.prev = _context20.next) {
1482
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1483
+ while (1) switch (_context21.prev = _context21.next) {
1434
1484
  case 0:
1435
1485
  this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
1436
1486
  moduleName: moduleName,
@@ -1438,7 +1488,7 @@ var Server = /*#__PURE__*/function () {
1438
1488
  });
1439
1489
 
1440
1490
  // 注册模块到 Core
1441
- _context20.next = 3;
1491
+ _context21.next = 3;
1442
1492
  return this.core.registerModule(module, options);
1443
1493
  case 3:
1444
1494
  console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
@@ -1459,11 +1509,11 @@ var Server = /*#__PURE__*/function () {
1459
1509
  }
1460
1510
  case 6:
1461
1511
  case "end":
1462
- return _context20.stop();
1512
+ return _context21.stop();
1463
1513
  }
1464
- }, _callee20, this);
1514
+ }, _callee21, this);
1465
1515
  }));
1466
- function registerModuleWithRoutes(_x20, _x21, _x22) {
1516
+ function registerModuleWithRoutes(_x21, _x22, _x23) {
1467
1517
  return _registerModuleWithRoutes.apply(this, arguments);
1468
1518
  }
1469
1519
  return registerModuleWithRoutes;
@@ -1476,10 +1526,10 @@ var Server = /*#__PURE__*/function () {
1476
1526
  }, {
1477
1527
  key: "registerModuleByName",
1478
1528
  value: (function () {
1479
- var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(moduleConfig) {
1529
+ var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(moduleConfig) {
1480
1530
  var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
1481
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1482
- while (1) switch (_context21.prev = _context21.next) {
1531
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1532
+ while (1) switch (_context22.prev = _context22.next) {
1483
1533
  case 0:
1484
1534
  // 解析配置
1485
1535
  moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
@@ -1494,7 +1544,7 @@ var Server = /*#__PURE__*/function () {
1494
1544
  // 查找模块配置
1495
1545
  registryConfig = this.moduleRegistry[moduleName];
1496
1546
  if (registryConfig) {
1497
- _context21.next = 8;
1547
+ _context22.next = 8;
1498
1548
  break;
1499
1549
  }
1500
1550
  this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
@@ -1508,7 +1558,7 @@ var Server = /*#__PURE__*/function () {
1508
1558
  moduleOptions = _objectSpread({
1509
1559
  store: _objectSpread({}, registryConfig.defaultStore)
1510
1560
  }, customConfig); // 注册模块和路由
1511
- _context21.next = 13;
1561
+ _context22.next = 13;
1512
1562
  return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
1513
1563
  case 13:
1514
1564
  // 保存模块实例
@@ -1518,18 +1568,18 @@ var Server = /*#__PURE__*/function () {
1518
1568
  shouldPreload: shouldPreload,
1519
1569
  version: registryConfig.version
1520
1570
  });
1521
- return _context21.abrupt("return", {
1571
+ return _context22.abrupt("return", {
1522
1572
  module: moduleInstance,
1523
1573
  config: registryConfig,
1524
1574
  shouldPreload: shouldPreload
1525
1575
  });
1526
1576
  case 16:
1527
1577
  case "end":
1528
- return _context21.stop();
1578
+ return _context22.stop();
1529
1579
  }
1530
- }, _callee21, this);
1580
+ }, _callee22, this);
1531
1581
  }));
1532
- function registerModuleByName(_x23) {
1582
+ function registerModuleByName(_x24) {
1533
1583
  return _registerModuleByName.apply(this, arguments);
1534
1584
  }
1535
1585
  return registerModuleByName;
@@ -1542,10 +1592,10 @@ var Server = /*#__PURE__*/function () {
1542
1592
  }, {
1543
1593
  key: "registerModules",
1544
1594
  value: (function () {
1545
- var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(moduleConfigs) {
1595
+ var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(moduleConfigs) {
1546
1596
  var configs, registeredModules, _iterator2, _step2, config, configName, result, errorMessage;
1547
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1548
- while (1) switch (_context22.prev = _context22.next) {
1597
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1598
+ while (1) switch (_context23.prev = _context23.next) {
1549
1599
  case 0:
1550
1600
  console.log('[Server] 开始注册模块...');
1551
1601
 
@@ -1557,47 +1607,47 @@ var Server = /*#__PURE__*/function () {
1557
1607
  });
1558
1608
  registeredModules = [];
1559
1609
  _iterator2 = _createForOfIteratorHelper(configs);
1560
- _context22.prev = 5;
1610
+ _context23.prev = 5;
1561
1611
  _iterator2.s();
1562
1612
  case 7:
1563
1613
  if ((_step2 = _iterator2.n()).done) {
1564
- _context22.next = 25;
1614
+ _context23.next = 25;
1565
1615
  break;
1566
1616
  }
1567
1617
  config = _step2.value;
1568
1618
  configName = typeof config === 'string' ? config : config.name;
1569
- _context22.prev = 10;
1570
- _context22.next = 13;
1619
+ _context23.prev = 10;
1620
+ _context23.next = 13;
1571
1621
  return this.registerModuleByName(config);
1572
1622
  case 13:
1573
- result = _context22.sent;
1623
+ result = _context23.sent;
1574
1624
  registeredModules.push(result);
1575
- _context22.next = 23;
1625
+ _context23.next = 23;
1576
1626
  break;
1577
1627
  case 17:
1578
- _context22.prev = 17;
1579
- _context22.t0 = _context22["catch"](10);
1580
- errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1628
+ _context23.prev = 17;
1629
+ _context23.t0 = _context23["catch"](10);
1630
+ errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
1581
1631
  this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
1582
1632
  moduleName: configName,
1583
1633
  error: errorMessage
1584
1634
  });
1585
- console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context22.t0);
1586
- throw _context22.t0;
1635
+ console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context23.t0);
1636
+ throw _context23.t0;
1587
1637
  case 23:
1588
- _context22.next = 7;
1638
+ _context23.next = 7;
1589
1639
  break;
1590
1640
  case 25:
1591
- _context22.next = 30;
1641
+ _context23.next = 30;
1592
1642
  break;
1593
1643
  case 27:
1594
- _context22.prev = 27;
1595
- _context22.t1 = _context22["catch"](5);
1596
- _iterator2.e(_context22.t1);
1644
+ _context23.prev = 27;
1645
+ _context23.t1 = _context23["catch"](5);
1646
+ _iterator2.e(_context23.t1);
1597
1647
  case 30:
1598
- _context22.prev = 30;
1648
+ _context23.prev = 30;
1599
1649
  _iterator2.f();
1600
- return _context22.finish(30);
1650
+ return _context23.finish(30);
1601
1651
  case 33:
1602
1652
  console.log('[Server] ✅ 所有模块注册完成');
1603
1653
  this.logInfo('所有模块注册完成', {
@@ -1607,14 +1657,14 @@ var Server = /*#__PURE__*/function () {
1607
1657
  return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
1608
1658
  })
1609
1659
  });
1610
- return _context22.abrupt("return", registeredModules);
1660
+ return _context23.abrupt("return", registeredModules);
1611
1661
  case 36:
1612
1662
  case "end":
1613
- return _context22.stop();
1663
+ return _context23.stop();
1614
1664
  }
1615
- }, _callee22, this, [[5, 27, 30, 33], [10, 17]]);
1665
+ }, _callee23, this, [[5, 27, 30, 33], [10, 17]]);
1616
1666
  }));
1617
- function registerModules(_x24) {
1667
+ function registerModules(_x25) {
1618
1668
  return _registerModules.apply(this, arguments);
1619
1669
  }
1620
1670
  return registerModules;
@@ -1627,10 +1677,10 @@ var Server = /*#__PURE__*/function () {
1627
1677
  }, {
1628
1678
  key: "preloadModulesData",
1629
1679
  value: (function () {
1630
- var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(registeredModules, options) {
1680
+ var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(registeredModules, options) {
1631
1681
  var modulesToPreload, preloadResults, _iterator3, _step3, _step3$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
1632
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1633
- while (1) switch (_context23.prev = _context23.next) {
1682
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1683
+ while (1) switch (_context24.prev = _context24.next) {
1634
1684
  case 0:
1635
1685
  console.log('[Server] 开始预加载模块数据...');
1636
1686
  modulesToPreload = registeredModules.filter(function (m) {
@@ -1643,16 +1693,16 @@ var Server = /*#__PURE__*/function () {
1643
1693
  });
1644
1694
  preloadResults = [];
1645
1695
  _iterator3 = _createForOfIteratorHelper(registeredModules);
1646
- _context23.prev = 5;
1696
+ _context24.prev = 5;
1647
1697
  _iterator3.s();
1648
1698
  case 7:
1649
1699
  if ((_step3 = _iterator3.n()).done) {
1650
- _context23.next = 40;
1700
+ _context24.next = 40;
1651
1701
  break;
1652
1702
  }
1653
1703
  _step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
1654
1704
  if (shouldPreload) {
1655
- _context23.next = 13;
1705
+ _context24.next = 13;
1656
1706
  break;
1657
1707
  }
1658
1708
  console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
@@ -1660,19 +1710,19 @@ var Server = /*#__PURE__*/function () {
1660
1710
  moduleName: config.name,
1661
1711
  reason: 'shouldPreload=false'
1662
1712
  });
1663
- return _context23.abrupt("continue", 38);
1713
+ return _context24.abrupt("continue", 38);
1664
1714
  case 13:
1665
1715
  if (!(typeof module.preload === 'function')) {
1666
- _context23.next = 36;
1716
+ _context24.next = 36;
1667
1717
  break;
1668
1718
  }
1669
1719
  startTime = Date.now();
1670
- _context23.prev = 15;
1720
+ _context24.prev = 15;
1671
1721
  this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
1672
1722
  moduleName: config.name
1673
1723
  });
1674
1724
  options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
1675
- _context23.next = 20;
1725
+ _context24.next = 20;
1676
1726
  return module.preload();
1677
1727
  case 20:
1678
1728
  options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
@@ -1686,14 +1736,14 @@ var Server = /*#__PURE__*/function () {
1686
1736
  name: config.name,
1687
1737
  success: true
1688
1738
  });
1689
- _context23.next = 34;
1739
+ _context24.next = 34;
1690
1740
  break;
1691
1741
  case 27:
1692
- _context23.prev = 27;
1693
- _context23.t0 = _context23["catch"](15);
1742
+ _context24.prev = 27;
1743
+ _context24.t0 = _context24["catch"](15);
1694
1744
  _duration = Date.now() - startTime;
1695
- errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
1696
- console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context23.t0);
1745
+ errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
1746
+ console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context24.t0);
1697
1747
  this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
1698
1748
  moduleName: config.name,
1699
1749
  duration: "".concat(_duration, "ms"),
@@ -1705,7 +1755,7 @@ var Server = /*#__PURE__*/function () {
1705
1755
  error: errorMessage
1706
1756
  });
1707
1757
  case 34:
1708
- _context23.next = 38;
1758
+ _context24.next = 38;
1709
1759
  break;
1710
1760
  case 36:
1711
1761
  console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
@@ -1713,19 +1763,19 @@ var Server = /*#__PURE__*/function () {
1713
1763
  moduleName: config.name
1714
1764
  });
1715
1765
  case 38:
1716
- _context23.next = 7;
1766
+ _context24.next = 7;
1717
1767
  break;
1718
1768
  case 40:
1719
- _context23.next = 45;
1769
+ _context24.next = 45;
1720
1770
  break;
1721
1771
  case 42:
1722
- _context23.prev = 42;
1723
- _context23.t1 = _context23["catch"](5);
1724
- _iterator3.e(_context23.t1);
1772
+ _context24.prev = 42;
1773
+ _context24.t1 = _context24["catch"](5);
1774
+ _iterator3.e(_context24.t1);
1725
1775
  case 45:
1726
- _context23.prev = 45;
1776
+ _context24.prev = 45;
1727
1777
  _iterator3.f();
1728
- return _context23.finish(45);
1778
+ return _context24.finish(45);
1729
1779
  case 48:
1730
1780
  successCount = preloadResults.filter(function (r) {
1731
1781
  return r.success;
@@ -1740,11 +1790,11 @@ var Server = /*#__PURE__*/function () {
1740
1790
  });
1741
1791
  case 52:
1742
1792
  case "end":
1743
- return _context23.stop();
1793
+ return _context24.stop();
1744
1794
  }
1745
- }, _callee23, this, [[5, 42, 45, 48], [15, 27]]);
1795
+ }, _callee24, this, [[5, 42, 45, 48], [15, 27]]);
1746
1796
  }));
1747
- function preloadModulesData(_x25, _x26) {
1797
+ function preloadModulesData(_x26, _x27) {
1748
1798
  return _preloadModulesData.apply(this, arguments);
1749
1799
  }
1750
1800
  return preloadModulesData;
@@ -1758,7 +1808,7 @@ var Server = /*#__PURE__*/function () {
1758
1808
  }, {
1759
1809
  key: "initialize",
1760
1810
  value: (function () {
1761
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(moduleConfigs) {
1811
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(moduleConfigs) {
1762
1812
  var _moduleConfigs$length,
1763
1813
  _this3 = this;
1764
1814
  var autoPreload,
@@ -1766,12 +1816,12 @@ var Server = /*#__PURE__*/function () {
1766
1816
  startTime,
1767
1817
  registeredModules,
1768
1818
  duration,
1769
- _args24 = arguments;
1770
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1771
- while (1) switch (_context24.prev = _context24.next) {
1819
+ _args25 = arguments;
1820
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1821
+ while (1) switch (_context25.prev = _context25.next) {
1772
1822
  case 0:
1773
- autoPreload = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : true;
1774
- options = _args24.length > 2 ? _args24[2] : undefined;
1823
+ autoPreload = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : true;
1824
+ options = _args25.length > 2 ? _args25[2] : undefined;
1775
1825
  startTime = Date.now();
1776
1826
  this.logInfo('Server 初始化开始', {
1777
1827
  moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
@@ -1784,25 +1834,25 @@ var Server = /*#__PURE__*/function () {
1784
1834
  this.registerDeviceTaskActions();
1785
1835
 
1786
1836
  // 注册模块
1787
- _context24.next = 8;
1837
+ _context25.next = 8;
1788
1838
  return this.registerModules(moduleConfigs);
1789
1839
  case 8:
1790
- registeredModules = _context24.sent;
1840
+ registeredModules = _context25.sent;
1791
1841
  if (!autoPreload) {
1792
- _context24.next = 14;
1842
+ _context25.next = 14;
1793
1843
  break;
1794
1844
  }
1795
- _context24.next = 12;
1845
+ _context25.next = 12;
1796
1846
  return this.preloadModulesData(registeredModules, options);
1797
1847
  case 12:
1798
- _context24.next = 15;
1848
+ _context25.next = 15;
1799
1849
  break;
1800
1850
  case 14:
1801
1851
  this.logInfo('跳过自动预加载', {
1802
1852
  autoPreload: autoPreload
1803
1853
  });
1804
1854
  case 15:
1805
- _context24.next = 17;
1855
+ _context25.next = 17;
1806
1856
  return this.setupProductsQuotationPriceBridge();
1807
1857
  case 17:
1808
1858
  // 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
@@ -1829,14 +1879,14 @@ var Server = /*#__PURE__*/function () {
1829
1879
  duration: "".concat(duration, "ms"),
1830
1880
  registeredModuleCount: registeredModules.length
1831
1881
  });
1832
- return _context24.abrupt("return", registeredModules);
1882
+ return _context25.abrupt("return", registeredModules);
1833
1883
  case 23:
1834
1884
  case "end":
1835
- return _context24.stop();
1885
+ return _context25.stop();
1836
1886
  }
1837
- }, _callee24, this);
1887
+ }, _callee25, this);
1838
1888
  }));
1839
- function initialize(_x27) {
1889
+ function initialize(_x28) {
1840
1890
  return _initialize.apply(this, arguments);
1841
1891
  }
1842
1892
  return initialize;
@@ -1878,39 +1928,39 @@ var Server = /*#__PURE__*/function () {
1878
1928
  }, {
1879
1929
  key: "handleSyncSalesTask",
1880
1930
  value: function () {
1881
- var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(ctx) {
1931
+ var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(ctx) {
1882
1932
  var _ctx$task, _this$app4;
1883
- var payload, backendPath, data, title, response, message, fresh, syncedOrder, _ctx$task2, backendError, _message, errorMessage;
1884
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1885
- while (1) switch (_context25.prev = _context25.next) {
1933
+ var payload, backendPath, data, title, _syncedOrder2, response, message, fresh, externalSaleNumber, shouldMergeRemoteOrder, syncedOrder, _external_sale_number, _syncedOrder$order_id, _syncedOrder, patch, result, _ctx$task2, backendError, _message, errorMessage;
1934
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1935
+ while (1) switch (_context26.prev = _context26.next) {
1886
1936
  case 0:
1887
1937
  payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
1888
1938
  backendPath = payload.backendPath;
1889
1939
  data = payload.data;
1890
1940
  title = payload.title || 'sync_sales';
1891
1941
  if (!(!backendPath || !data)) {
1892
- _context25.next = 6;
1942
+ _context26.next = 6;
1893
1943
  break;
1894
1944
  }
1895
- return _context25.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
1945
+ return _context26.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
1896
1946
  case 6:
1897
1947
  if ((_this$app4 = this.app) !== null && _this$app4 !== void 0 && _this$app4.request) {
1898
- _context25.next = 9;
1948
+ _context26.next = 9;
1899
1949
  break;
1900
1950
  }
1901
1951
  this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
1902
- return _context25.abrupt("return", this.taskTimeout('app.request 不可用'));
1952
+ return _context26.abrupt("return", this.taskTimeout('app.request 不可用'));
1903
1953
  case 9:
1904
- _context25.prev = 9;
1905
- _context25.next = 12;
1906
- return this.app.request.post('/shop/order/sales/checkout', data, {
1954
+ _context26.prev = 9;
1955
+ _context26.next = 12;
1956
+ return this.app.request.post(backendPath, data, {
1907
1957
  isShopApi: true,
1908
1958
  customToast: function customToast() {}
1909
1959
  });
1910
1960
  case 12:
1911
- response = _context25.sent;
1961
+ response = _context26.sent;
1912
1962
  if (!this.isCheckoutResponseRejected(response)) {
1913
- _context25.next = 17;
1963
+ _context26.next = 17;
1914
1964
  break;
1915
1965
  }
1916
1966
  message = (response === null || response === void 0 ? void 0 : response.message) || '后端明确拒绝 checkout';
@@ -1918,67 +1968,86 @@ var Server = /*#__PURE__*/function () {
1918
1968
  backendPath: backendPath,
1919
1969
  response: response
1920
1970
  });
1921
- return _context25.abrupt("return", this.taskFail('BACKEND_REJECTED', message, response));
1971
+ return _context26.abrupt("return", this.taskFail('BACKEND_REJECTED', message, response));
1922
1972
  case 17:
1923
1973
  fresh = this.extractOrderDataFromCheckoutResponse(response);
1924
- if (fresh) {
1925
- _context25.next = 21;
1974
+ externalSaleNumber = this.getCheckoutExternalSaleNumber(data, payload);
1975
+ shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
1976
+ if (!(this.order && fresh && shouldMergeRemoteOrder)) {
1977
+ _context26.next = 27;
1926
1978
  break;
1927
1979
  }
1928
- this.logWarning("".concat(title, ": sync_sales \u8FD4\u56DE\u672A\u5305\u542B\u53EF\u540C\u6B65\u8BA2\u5355"), {
1929
- backendPath: backendPath,
1930
- response: response
1931
- });
1932
- return _context25.abrupt("return", this.taskTimeout('checkout 返回未包含可同步订单'));
1933
- case 21:
1934
1980
  syncedOrder = _objectSpread(_objectSpread({}, fresh), {}, {
1981
+ external_sale_number: (_external_sale_number = fresh.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : externalSaleNumber,
1935
1982
  need_sync: 0
1936
1983
  });
1937
- if (!this.order) {
1938
- _context25.next = 28;
1939
- break;
1940
- }
1941
- _context25.next = 25;
1984
+ _context26.next = 24;
1942
1985
  return this.order.upsertOrdersFromRemote([syncedOrder]);
1943
- case 25:
1944
- this.logInfo("".concat(title, ": sync_sales \u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
1986
+ case 24:
1987
+ this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
1945
1988
  order_id: fresh.order_id,
1946
- external_sale_number: fresh.external_sale_number,
1989
+ external_sale_number: syncedOrder.external_sale_number,
1947
1990
  order_number: fresh.order_number
1948
1991
  });
1949
- _context25.next = 29;
1992
+ _context26.next = 37;
1950
1993
  break;
1951
- case 28:
1994
+ case 27:
1995
+ if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
1996
+ _context26.next = 36;
1997
+ break;
1998
+ }
1999
+ patch = this.buildCheckoutSyncSuccessPatch(fresh);
2000
+ _context26.next = 31;
2001
+ return this.order.markOrderSyncedByExternalSaleNumber({
2002
+ externalSaleNumber: externalSaleNumber,
2003
+ patch: patch
2004
+ });
2005
+ case 31:
2006
+ result = _context26.sent;
2007
+ syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, data), patch), {}, {
2008
+ external_sale_number: externalSaleNumber,
2009
+ need_sync: 0
2010
+ });
2011
+ this.logInfo("".concat(title, ": sync_sales \u5DF2\u6309 external_sale_number \u6807\u8BB0\u672C\u5730\u8BA2\u5355"), {
2012
+ order_id: (_syncedOrder$order_id = (_syncedOrder = syncedOrder) === null || _syncedOrder === void 0 ? void 0 : _syncedOrder.order_id) !== null && _syncedOrder$order_id !== void 0 ? _syncedOrder$order_id : null,
2013
+ external_sale_number: externalSaleNumber,
2014
+ hasRemoteOrder: !!fresh,
2015
+ mergedRemoteOrder: false
2016
+ });
2017
+ _context26.next = 37;
2018
+ break;
2019
+ case 36:
1952
2020
  this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
1953
2021
  backendPath: backendPath,
1954
- order_id: fresh.order_id
2022
+ external_sale_number: externalSaleNumber,
2023
+ order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
1955
2024
  });
1956
- case 29:
1957
- if (!this.shouldPrintSyncedOrder({
2025
+ case 37:
2026
+ if (!(syncedOrder && this.shouldPrintSyncedOrder({
1958
2027
  checkoutData: data,
1959
2028
  syncedOrder: syncedOrder
1960
- })) {
1961
- _context25.next = 32;
2029
+ }))) {
2030
+ _context26.next = 40;
1962
2031
  break;
1963
2032
  }
1964
- _context25.next = 32;
2033
+ _context26.next = 40;
1965
2034
  return this.dispatchPrintOtherReceiptTask({
1966
2035
  checkoutData: data,
1967
2036
  syncedOrder: syncedOrder,
1968
2037
  response: response,
1969
2038
  deviceId: (_ctx$task2 = ctx.task) === null || _ctx$task2 === void 0 ? void 0 : _ctx$task2.device_id
1970
2039
  });
1971
- case 32:
1972
- return _context25.abrupt("return", this.taskOk({
1973
- order: syncedOrder,
2040
+ case 40:
2041
+ return _context26.abrupt("return", this.taskOk({
2042
+ order: (_syncedOrder2 = syncedOrder) !== null && _syncedOrder2 !== void 0 ? _syncedOrder2 : null,
1974
2043
  response: this.normalizeCheckoutResponse(response)
1975
2044
  }));
1976
- case 35:
1977
- _context25.prev = 35;
1978
- _context25.t0 = _context25["catch"](9);
1979
- backendError = this.extractBackendErrorResponse(_context25.t0);
2045
+ case 43:
2046
+ _context26.prev = 43;
2047
+ _context26.t0 = _context26["catch"](9);
2048
+ backendError = this.extractBackendErrorResponse(_context26.t0);
1980
2049
  if (!backendError) {
1981
- _context25.next = 42;
2050
+ _context26.next = 50;
1982
2051
  break;
1983
2052
  }
1984
2053
  _message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
@@ -1986,21 +2055,21 @@ var Server = /*#__PURE__*/function () {
1986
2055
  backendPath: backendPath,
1987
2056
  backendError: backendError
1988
2057
  });
1989
- return _context25.abrupt("return", this.taskFail('BACKEND_REJECTED', _message, backendError));
1990
- case 42:
1991
- errorMessage = _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0);
2058
+ return _context26.abrupt("return", this.taskFail('BACKEND_REJECTED', _message, backendError));
2059
+ case 50:
2060
+ errorMessage = _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0);
1992
2061
  this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
1993
2062
  backendPath: backendPath,
1994
2063
  error: errorMessage
1995
2064
  });
1996
- return _context25.abrupt("return", this.taskTimeout(errorMessage));
1997
- case 45:
2065
+ return _context26.abrupt("return", this.taskTimeout(errorMessage));
2066
+ case 53:
1998
2067
  case "end":
1999
- return _context25.stop();
2068
+ return _context26.stop();
2000
2069
  }
2001
- }, _callee25, this, [[9, 35]]);
2070
+ }, _callee26, this, [[9, 43]]);
2002
2071
  }));
2003
- function handleSyncSalesTask(_x28) {
2072
+ function handleSyncSalesTask(_x29) {
2004
2073
  return _handleSyncSalesTask.apply(this, arguments);
2005
2074
  }
2006
2075
  return handleSyncSalesTask;
@@ -2011,51 +2080,51 @@ var Server = /*#__PURE__*/function () {
2011
2080
  }, {
2012
2081
  key: "setupProductsQuotationPriceBridge",
2013
2082
  value: (function () {
2014
- var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2083
+ var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2015
2084
  var _this$core$context, errorMessage;
2016
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2017
- while (1) switch (_context26.prev = _context26.next) {
2085
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2086
+ while (1) switch (_context27.prev = _context27.next) {
2018
2087
  case 0:
2019
2088
  if (this.products) {
2020
- _context26.next = 3;
2089
+ _context27.next = 3;
2021
2090
  break;
2022
2091
  }
2023
2092
  this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
2024
- return _context26.abrupt("return");
2093
+ return _context27.abrupt("return");
2025
2094
  case 3:
2026
2095
  if (this.schedule) {
2027
- _context26.next = 6;
2096
+ _context27.next = 6;
2028
2097
  break;
2029
2098
  }
2030
2099
  this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
2031
- return _context26.abrupt("return");
2100
+ return _context27.abrupt("return");
2032
2101
  case 6:
2033
- _context26.prev = 6;
2034
- _context26.next = 9;
2102
+ _context27.prev = 6;
2103
+ _context27.next = 9;
2035
2104
  return this.schedule.loadAllSchedule();
2036
2105
  case 9:
2037
2106
  this.products.clearPriceCache();
2038
- _context26.next = 12;
2107
+ _context27.next = 12;
2039
2108
  return this.products.setupQuotationPriceBridge({
2040
2109
  scheduleModule: this.schedule,
2041
2110
  channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
2042
2111
  });
2043
2112
  case 12:
2044
2113
  this.logInfo('Products 报价单价格桥接初始化完成');
2045
- _context26.next = 19;
2114
+ _context27.next = 19;
2046
2115
  break;
2047
2116
  case 15:
2048
- _context26.prev = 15;
2049
- _context26.t0 = _context26["catch"](6);
2050
- errorMessage = _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0);
2117
+ _context27.prev = 15;
2118
+ _context27.t0 = _context27["catch"](6);
2119
+ errorMessage = _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0);
2051
2120
  this.logError('Products 报价单价格桥接初始化失败', {
2052
2121
  error: errorMessage
2053
2122
  });
2054
2123
  case 19:
2055
2124
  case "end":
2056
- return _context26.stop();
2125
+ return _context27.stop();
2057
2126
  }
2058
- }, _callee26, this, [[6, 15]]);
2127
+ }, _callee27, this, [[6, 15]]);
2059
2128
  }));
2060
2129
  function setupProductsQuotationPriceBridge() {
2061
2130
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -2124,45 +2193,45 @@ var Server = /*#__PURE__*/function () {
2124
2193
  }, {
2125
2194
  key: "refreshProductsInBackground",
2126
2195
  value: (function () {
2127
- var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2196
+ var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2128
2197
  var startTime, duration, _duration2, errorMessage;
2129
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2130
- while (1) switch (_context27.prev = _context27.next) {
2198
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2199
+ while (1) switch (_context28.prev = _context28.next) {
2131
2200
  case 0:
2132
2201
  if (this.products) {
2133
- _context27.next = 3;
2202
+ _context28.next = 3;
2134
2203
  break;
2135
2204
  }
2136
2205
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
2137
- return _context27.abrupt("return");
2206
+ return _context28.abrupt("return");
2138
2207
  case 3:
2139
2208
  this.logInfo('refreshProductsInBackground 开始');
2140
2209
  startTime = Date.now();
2141
- _context27.prev = 5;
2142
- _context27.next = 8;
2210
+ _context28.prev = 5;
2211
+ _context28.next = 8;
2143
2212
  return this.products.silentRefresh();
2144
2213
  case 8:
2145
2214
  duration = Date.now() - startTime;
2146
2215
  this.logInfo('refreshProductsInBackground 完成', {
2147
2216
  duration: "".concat(duration, "ms")
2148
2217
  });
2149
- _context27.next = 18;
2218
+ _context28.next = 18;
2150
2219
  break;
2151
2220
  case 12:
2152
- _context27.prev = 12;
2153
- _context27.t0 = _context27["catch"](5);
2221
+ _context28.prev = 12;
2222
+ _context28.t0 = _context28["catch"](5);
2154
2223
  _duration2 = Date.now() - startTime;
2155
- errorMessage = _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0);
2156
- console.error('[Server] refreshProductsInBackground 失败:', _context27.t0);
2224
+ errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0);
2225
+ console.error('[Server] refreshProductsInBackground 失败:', _context28.t0);
2157
2226
  this.logError('refreshProductsInBackground 失败', {
2158
2227
  duration: "".concat(_duration2, "ms"),
2159
2228
  error: errorMessage
2160
2229
  });
2161
2230
  case 18:
2162
2231
  case "end":
2163
- return _context27.stop();
2232
+ return _context28.stop();
2164
2233
  }
2165
- }, _callee27, this, [[5, 12]]);
2234
+ }, _callee28, this, [[5, 12]]);
2166
2235
  }));
2167
2236
  function refreshProductsInBackground() {
2168
2237
  return _refreshProductsInBackground.apply(this, arguments);
@@ -2178,45 +2247,45 @@ var Server = /*#__PURE__*/function () {
2178
2247
  }, {
2179
2248
  key: "refreshOrdersInBackground",
2180
2249
  value: (function () {
2181
- var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2250
+ var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2182
2251
  var startTime, duration, _duration3, errorMessage;
2183
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2184
- while (1) switch (_context28.prev = _context28.next) {
2252
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2253
+ while (1) switch (_context29.prev = _context29.next) {
2185
2254
  case 0:
2186
2255
  if (this.order) {
2187
- _context28.next = 3;
2256
+ _context29.next = 3;
2188
2257
  break;
2189
2258
  }
2190
2259
  this.logWarning('refreshOrdersInBackground: Order 模块未注册');
2191
- return _context28.abrupt("return");
2260
+ return _context29.abrupt("return");
2192
2261
  case 3:
2193
2262
  this.logInfo('refreshOrdersInBackground 开始');
2194
2263
  startTime = Date.now();
2195
- _context28.prev = 5;
2196
- _context28.next = 8;
2264
+ _context29.prev = 5;
2265
+ _context29.next = 8;
2197
2266
  return this.order.silentRefresh();
2198
2267
  case 8:
2199
2268
  duration = Date.now() - startTime;
2200
2269
  this.logInfo('refreshOrdersInBackground 完成', {
2201
2270
  duration: "".concat(duration, "ms")
2202
2271
  });
2203
- _context28.next = 18;
2272
+ _context29.next = 18;
2204
2273
  break;
2205
2274
  case 12:
2206
- _context28.prev = 12;
2207
- _context28.t0 = _context28["catch"](5);
2275
+ _context29.prev = 12;
2276
+ _context29.t0 = _context29["catch"](5);
2208
2277
  _duration3 = Date.now() - startTime;
2209
- errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0);
2210
- console.error('[Server] refreshOrdersInBackground 失败:', _context28.t0);
2278
+ errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2279
+ console.error('[Server] refreshOrdersInBackground 失败:', _context29.t0);
2211
2280
  this.logError('refreshOrdersInBackground 失败', {
2212
2281
  duration: "".concat(_duration3, "ms"),
2213
2282
  error: errorMessage
2214
2283
  });
2215
2284
  case 18:
2216
2285
  case "end":
2217
- return _context28.stop();
2286
+ return _context29.stop();
2218
2287
  }
2219
- }, _callee28, this, [[5, 12]]);
2288
+ }, _callee29, this, [[5, 12]]);
2220
2289
  }));
2221
2290
  function refreshOrdersInBackground() {
2222
2291
  return _refreshOrdersInBackground.apply(this, arguments);
@@ -2231,10 +2300,10 @@ var Server = /*#__PURE__*/function () {
2231
2300
  }, {
2232
2301
  key: "clearAllIndexDB",
2233
2302
  value: (function () {
2234
- var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2303
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2235
2304
  var clearTasks, moduleNames, errorMessage;
2236
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2237
- while (1) switch (_context29.prev = _context29.next) {
2305
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2306
+ while (1) switch (_context30.prev = _context30.next) {
2238
2307
  case 0:
2239
2308
  console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
2240
2309
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
@@ -2269,41 +2338,41 @@ var Server = /*#__PURE__*/function () {
2269
2338
  moduleNames.push('FloorPlan');
2270
2339
  }
2271
2340
  if (!(clearTasks.length === 0)) {
2272
- _context29.next = 15;
2341
+ _context30.next = 15;
2273
2342
  break;
2274
2343
  }
2275
2344
  console.warn('[Server] 没有找到已注册的模块,无需清空');
2276
2345
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
2277
- return _context29.abrupt("return");
2346
+ return _context30.abrupt("return");
2278
2347
  case 15:
2279
2348
  this.logInfo('准备清空模块缓存', {
2280
2349
  moduleNames: moduleNames
2281
2350
  });
2282
- _context29.prev = 16;
2283
- _context29.next = 19;
2351
+ _context30.prev = 16;
2352
+ _context30.next = 19;
2284
2353
  return Promise.all(clearTasks);
2285
2354
  case 19:
2286
2355
  console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
2287
2356
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
2288
2357
  moduleNames: moduleNames
2289
2358
  });
2290
- _context29.next = 29;
2359
+ _context30.next = 29;
2291
2360
  break;
2292
2361
  case 23:
2293
- _context29.prev = 23;
2294
- _context29.t0 = _context29["catch"](16);
2295
- errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2296
- console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context29.t0);
2362
+ _context30.prev = 23;
2363
+ _context30.t0 = _context30["catch"](16);
2364
+ errorMessage = _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0);
2365
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context30.t0);
2297
2366
  this.logError('清空 IndexedDB 缓存时发生错误', {
2298
2367
  moduleNames: moduleNames,
2299
2368
  error: errorMessage
2300
2369
  });
2301
- throw _context29.t0;
2370
+ throw _context30.t0;
2302
2371
  case 29:
2303
2372
  case "end":
2304
- return _context29.stop();
2373
+ return _context30.stop();
2305
2374
  }
2306
- }, _callee29, this, [[16, 23]]);
2375
+ }, _callee30, this, [[16, 23]]);
2307
2376
  }));
2308
2377
  function clearAllIndexDB() {
2309
2378
  return _clearAllIndexDB.apply(this, arguments);
@@ -2378,10 +2447,10 @@ var Server = /*#__PURE__*/function () {
2378
2447
  }, {
2379
2448
  key: "handleRoute",
2380
2449
  value: (function () {
2381
- var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(method, path, params) {
2450
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(method, path, params) {
2382
2451
  var startTime, handler, result, duration, _duration4, errorMessage;
2383
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2384
- while (1) switch (_context30.prev = _context30.next) {
2452
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2453
+ while (1) switch (_context31.prev = _context31.next) {
2385
2454
  case 0:
2386
2455
  startTime = Date.now();
2387
2456
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -2392,7 +2461,7 @@ var Server = /*#__PURE__*/function () {
2392
2461
  });
2393
2462
  handler = this.getRouteHandler(method, path);
2394
2463
  if (handler) {
2395
- _context30.next = 6;
2464
+ _context31.next = 6;
2396
2465
  break;
2397
2466
  }
2398
2467
  this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
@@ -2401,13 +2470,13 @@ var Server = /*#__PURE__*/function () {
2401
2470
  });
2402
2471
  throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
2403
2472
  case 6:
2404
- _context30.prev = 6;
2405
- _context30.next = 9;
2473
+ _context31.prev = 6;
2474
+ _context31.next = 9;
2406
2475
  return handler(_objectSpread(_objectSpread({}, params), {}, {
2407
2476
  path: path
2408
2477
  }));
2409
2478
  case 9:
2410
- result = _context30.sent;
2479
+ result = _context31.sent;
2411
2480
  duration = Date.now() - startTime;
2412
2481
  this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
2413
2482
  method: method.toUpperCase(),
@@ -2416,12 +2485,12 @@ var Server = /*#__PURE__*/function () {
2416
2485
  resultCode: result === null || result === void 0 ? void 0 : result.code,
2417
2486
  resultStatus: result === null || result === void 0 ? void 0 : result.status
2418
2487
  });
2419
- return _context30.abrupt("return", result);
2488
+ return _context31.abrupt("return", result);
2420
2489
  case 15:
2421
- _context30.prev = 15;
2422
- _context30.t0 = _context30["catch"](6);
2490
+ _context31.prev = 15;
2491
+ _context31.t0 = _context31["catch"](6);
2423
2492
  _duration4 = Date.now() - startTime;
2424
- errorMessage = _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0);
2493
+ errorMessage = _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0);
2425
2494
  this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
2426
2495
  method: method.toUpperCase(),
2427
2496
  path: path,
@@ -2429,15 +2498,15 @@ var Server = /*#__PURE__*/function () {
2429
2498
  error: errorMessage,
2430
2499
  data: params.data
2431
2500
  });
2432
- console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context30.t0);
2433
- throw _context30.t0;
2501
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context31.t0);
2502
+ throw _context31.t0;
2434
2503
  case 22:
2435
2504
  case "end":
2436
- return _context30.stop();
2505
+ return _context31.stop();
2437
2506
  }
2438
- }, _callee30, this, [[6, 15]]);
2507
+ }, _callee31, this, [[6, 15]]);
2439
2508
  }));
2440
- function handleRoute(_x29, _x30, _x31) {
2509
+ function handleRoute(_x30, _x31, _x32) {
2441
2510
  return _handleRoute.apply(this, arguments);
2442
2511
  }
2443
2512
  return handleRoute;
@@ -2527,6 +2596,14 @@ var Server = /*#__PURE__*/function () {
2527
2596
  method: 'get',
2528
2597
  path: '/shop/pay/custom-payment/all',
2529
2598
  handler: this.handlePaymentMethods.bind(this)
2599
+ }, {
2600
+ method: 'get',
2601
+ path: '/shop/quotation/available',
2602
+ handler: this.handleQuotationAvailable.bind(this)
2603
+ }, {
2604
+ method: 'get',
2605
+ path: '/quotation/available',
2606
+ handler: this.handleQuotationAvailable.bind(this)
2530
2607
  }, {
2531
2608
  method: 'post',
2532
2609
  path: '/shop/order/sales/checkout',
@@ -2553,36 +2630,36 @@ var Server = /*#__PURE__*/function () {
2553
2630
  }, {
2554
2631
  key: "getPaymentRouteModule",
2555
2632
  value: function () {
2556
- var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2633
+ var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2557
2634
  var _this6 = this;
2558
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2559
- while (1) switch (_context32.prev = _context32.next) {
2635
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2636
+ while (1) switch (_context33.prev = _context33.next) {
2560
2637
  case 0:
2561
2638
  if (!this.payment) {
2562
- _context32.next = 2;
2639
+ _context33.next = 2;
2563
2640
  break;
2564
2641
  }
2565
- return _context32.abrupt("return", this.payment);
2642
+ return _context33.abrupt("return", this.payment);
2566
2643
  case 2:
2567
2644
  if (!this.paymentRouteModule) {
2568
- _context32.next = 4;
2645
+ _context33.next = 4;
2569
2646
  break;
2570
2647
  }
2571
- return _context32.abrupt("return", this.paymentRouteModule);
2648
+ return _context33.abrupt("return", this.paymentRouteModule);
2572
2649
  case 4:
2573
2650
  if (!this.paymentRouteModuleInFlight) {
2574
- _context32.next = 6;
2651
+ _context33.next = 6;
2575
2652
  break;
2576
2653
  }
2577
- return _context32.abrupt("return", this.paymentRouteModuleInFlight);
2654
+ return _context33.abrupt("return", this.paymentRouteModuleInFlight);
2578
2655
  case 6:
2579
- this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2656
+ this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2580
2657
  var module;
2581
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2582
- while (1) switch (_context31.prev = _context31.next) {
2658
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2659
+ while (1) switch (_context32.prev = _context32.next) {
2583
2660
  case 0:
2584
2661
  module = new PaymentServerModule('server_payment_route', '1.0.0');
2585
- _context31.next = 3;
2662
+ _context32.next = 3;
2586
2663
  return module.initialize(_this6.core, {
2587
2664
  store: {
2588
2665
  payMethods: []
@@ -2590,34 +2667,79 @@ var Server = /*#__PURE__*/function () {
2590
2667
  });
2591
2668
  case 3:
2592
2669
  _this6.paymentRouteModule = module;
2593
- return _context31.abrupt("return", module);
2670
+ return _context32.abrupt("return", module);
2594
2671
  case 5:
2595
2672
  case "end":
2596
- return _context31.stop();
2673
+ return _context32.stop();
2597
2674
  }
2598
- }, _callee31);
2675
+ }, _callee32);
2599
2676
  }))().finally(function () {
2600
2677
  _this6.paymentRouteModuleInFlight = undefined;
2601
2678
  });
2602
- return _context32.abrupt("return", this.paymentRouteModuleInFlight);
2603
- case 8:
2679
+ return _context33.abrupt("return", this.paymentRouteModuleInFlight);
2680
+ case 8:
2681
+ case "end":
2682
+ return _context33.stop();
2683
+ }
2684
+ }, _callee33, this);
2685
+ }));
2686
+ function getPaymentRouteModule() {
2687
+ return _getPaymentRouteModule.apply(this, arguments);
2688
+ }
2689
+ return getPaymentRouteModule;
2690
+ }()
2691
+ }, {
2692
+ key: "fetchQuotationAvailableFromAPI",
2693
+ value: function () {
2694
+ var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(data) {
2695
+ var _this$app5;
2696
+ var requester;
2697
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2698
+ while (1) switch (_context34.prev = _context34.next) {
2699
+ case 0:
2700
+ requester = ((_this$app5 = this.app) === null || _this$app5 === void 0 ? void 0 : _this$app5.request) || this.core.getPlugin('request');
2701
+ if (requester !== null && requester !== void 0 && requester.get) {
2702
+ _context34.next = 4;
2703
+ break;
2704
+ }
2705
+ this.logError('fetchQuotationAvailableFromAPI: request 不可用');
2706
+ return _context34.abrupt("return", {
2707
+ code: 500,
2708
+ message: 'request 不可用',
2709
+ data: {
2710
+ list: []
2711
+ },
2712
+ status: false
2713
+ });
2714
+ case 4:
2715
+ return _context34.abrupt("return", requester.get('/shop/quotation/available', data));
2716
+ case 5:
2604
2717
  case "end":
2605
- return _context32.stop();
2718
+ return _context34.stop();
2606
2719
  }
2607
- }, _callee32, this);
2720
+ }, _callee34, this);
2608
2721
  }));
2609
- function getPaymentRouteModule() {
2610
- return _getPaymentRouteModule.apply(this, arguments);
2722
+ function fetchQuotationAvailableFromAPI(_x33) {
2723
+ return _fetchQuotationAvailableFromAPI.apply(this, arguments);
2611
2724
  }
2612
- return getPaymentRouteModule;
2725
+ return fetchQuotationAvailableFromAPI;
2613
2726
  }()
2614
2727
  }, {
2615
- key: "removeProductQuerySubscriber",
2616
- value:
2728
+ key: "isSuccessfulRemoteResponse",
2729
+ value: function isSuccessfulRemoteResponse(response) {
2730
+ if (!response) return false;
2731
+ if (response.status === false) return false;
2732
+ if (typeof response.status === 'number' && response.status >= 400) return false;
2733
+ if (response.code !== undefined && response.code !== 200 && response.code !== '200') return false;
2734
+ return true;
2735
+ }
2736
+
2617
2737
  /**
2618
2738
  * 根据 subscriberId 移除商品查询订阅者
2619
2739
  */
2620
- function removeProductQuerySubscriber(subscriberId) {
2740
+ }, {
2741
+ key: "removeProductQuerySubscriber",
2742
+ value: function removeProductQuerySubscriber(subscriberId) {
2621
2743
  if (subscriberId) {
2622
2744
  this.productQuerySubscribers.delete(subscriberId);
2623
2745
  this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
@@ -2637,17 +2759,17 @@ var Server = /*#__PURE__*/function () {
2637
2759
  * const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
2638
2760
  */
2639
2761
  function () {
2640
- var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(kind, backendPath, data, config) {
2641
- var queryPayload, result, _ref49, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
2642
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2643
- while (1) switch (_context33.prev = _context33.next) {
2762
+ var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(kind, backendPath, data, config) {
2763
+ var queryPayload, result, _ref51, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
2764
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2765
+ while (1) switch (_context35.prev = _context35.next) {
2644
2766
  case 0:
2645
2767
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
2646
- _context33.next = 3;
2768
+ _context35.next = 3;
2647
2769
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
2648
2770
  case 3:
2649
- result = _context33.sent;
2650
- _ref49 = config || {}, callback = _ref49.callback, subscriberId = _ref49.subscriberId, resetVisibleOrderIds = _ref49.resetVisibleOrderIds;
2771
+ result = _context35.sent;
2772
+ _ref51 = config || {}, callback = _ref51.callback, subscriberId = _ref51.subscriberId, resetVisibleOrderIds = _ref51.resetVisibleOrderIds;
2651
2773
  if (subscriberId && typeof callback === 'function') {
2652
2774
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
2653
2775
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -2678,14 +2800,14 @@ var Server = /*#__PURE__*/function () {
2678
2800
  visibleCount: visibleOrderIds.size
2679
2801
  });
2680
2802
  }
2681
- return _context33.abrupt("return", result);
2803
+ return _context35.abrupt("return", result);
2682
2804
  case 7:
2683
2805
  case "end":
2684
- return _context33.stop();
2806
+ return _context35.stop();
2685
2807
  }
2686
- }, _callee33, this);
2808
+ }, _callee35, this);
2687
2809
  }));
2688
- function handleSalesSearchRequest(_x32, _x33, _x34, _x35) {
2810
+ function handleSalesSearchRequest(_x34, _x35, _x36, _x37) {
2689
2811
  return _handleSalesSearchRequest.apply(this, arguments);
2690
2812
  }
2691
2813
  return handleSalesSearchRequest;
@@ -2700,20 +2822,20 @@ var Server = /*#__PURE__*/function () {
2700
2822
  }, {
2701
2823
  key: "fetchSalesSearchFromAPI",
2702
2824
  value: (function () {
2703
- var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(backendPath, data) {
2704
- var _this$app5;
2825
+ var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(backendPath, data) {
2826
+ var _this$app6;
2705
2827
  var _response$data3, _response$code, _response$status, _response$message, response, _payload, errorMessage;
2706
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2707
- while (1) switch (_context34.prev = _context34.next) {
2828
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2829
+ while (1) switch (_context36.prev = _context36.next) {
2708
2830
  case 0:
2709
- if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && _this$app5.request) {
2710
- _context34.next = 3;
2831
+ if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && _this$app6.request) {
2832
+ _context36.next = 3;
2711
2833
  break;
2712
2834
  }
2713
2835
  this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
2714
2836
  backendPath: backendPath
2715
2837
  });
2716
- return _context34.abrupt("return", {
2838
+ return _context36.abrupt("return", {
2717
2839
  code: 500,
2718
2840
  message: 'app.request 不可用',
2719
2841
  data: backendPath === '/shop/es/search' ? {
@@ -2725,29 +2847,29 @@ var Server = /*#__PURE__*/function () {
2725
2847
  status: false
2726
2848
  });
2727
2849
  case 3:
2728
- _context34.prev = 3;
2729
- _context34.next = 6;
2850
+ _context36.prev = 3;
2851
+ _context36.next = 6;
2730
2852
  return this.app.request.post(backendPath, data, {
2731
2853
  isShopApi: true
2732
2854
  });
2733
2855
  case 6:
2734
- response = _context34.sent;
2856
+ response = _context36.sent;
2735
2857
  _payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
2736
- return _context34.abrupt("return", {
2858
+ return _context36.abrupt("return", {
2737
2859
  code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : 200,
2738
2860
  status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : true,
2739
2861
  message: (_response$message = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message !== void 0 ? _response$message : '',
2740
2862
  data: _payload
2741
2863
  });
2742
2864
  case 11:
2743
- _context34.prev = 11;
2744
- _context34.t0 = _context34["catch"](3);
2745
- errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2865
+ _context36.prev = 11;
2866
+ _context36.t0 = _context36["catch"](3);
2867
+ errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0);
2746
2868
  this.logError('fetchSalesSearchFromAPI: 请求失败', {
2747
2869
  backendPath: backendPath,
2748
2870
  error: errorMessage
2749
2871
  });
2750
- return _context34.abrupt("return", {
2872
+ return _context36.abrupt("return", {
2751
2873
  code: 500,
2752
2874
  message: errorMessage,
2753
2875
  data: backendPath === '/shop/es/search' ? {
@@ -2760,11 +2882,11 @@ var Server = /*#__PURE__*/function () {
2760
2882
  });
2761
2883
  case 16:
2762
2884
  case "end":
2763
- return _context34.stop();
2885
+ return _context36.stop();
2764
2886
  }
2765
- }, _callee34, this, [[3, 11]]);
2887
+ }, _callee36, this, [[3, 11]]);
2766
2888
  }));
2767
- function fetchSalesSearchFromAPI(_x36, _x37) {
2889
+ function fetchSalesSearchFromAPI(_x38, _x39) {
2768
2890
  return _fetchSalesSearchFromAPI.apply(this, arguments);
2769
2891
  }
2770
2892
  return fetchSalesSearchFromAPI;
@@ -3269,18 +3391,18 @@ var Server = /*#__PURE__*/function () {
3269
3391
  }, {
3270
3392
  key: "fetchOrderListFromAPI",
3271
3393
  value: (function () {
3272
- var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(data) {
3273
- var _this$app6;
3394
+ var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(data) {
3395
+ var _this$app7;
3274
3396
  var _response$data4, response, _payload2, list, count, errorMessage;
3275
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3276
- while (1) switch (_context35.prev = _context35.next) {
3397
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3398
+ while (1) switch (_context37.prev = _context37.next) {
3277
3399
  case 0:
3278
- if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && _this$app6.request) {
3279
- _context35.next = 3;
3400
+ if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
3401
+ _context37.next = 3;
3280
3402
  break;
3281
3403
  }
3282
3404
  this.logError('fetchOrderListFromAPI: app.request 不可用');
3283
- return _context35.abrupt("return", {
3405
+ return _context37.abrupt("return", {
3284
3406
  code: 500,
3285
3407
  message: 'app.request 不可用',
3286
3408
  data: {
@@ -3290,17 +3412,17 @@ var Server = /*#__PURE__*/function () {
3290
3412
  status: false
3291
3413
  });
3292
3414
  case 3:
3293
- _context35.prev = 3;
3294
- _context35.next = 6;
3415
+ _context37.prev = 3;
3416
+ _context37.next = 6;
3295
3417
  return this.app.request.post('/shop/order/v2/list', data, {
3296
3418
  isShopApi: true
3297
3419
  });
3298
3420
  case 6:
3299
- response = _context35.sent;
3421
+ response = _context37.sent;
3300
3422
  _payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3301
3423
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
3302
3424
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
3303
- return _context35.abrupt("return", {
3425
+ return _context37.abrupt("return", {
3304
3426
  code: 200,
3305
3427
  data: _objectSpread(_objectSpread({}, _payload2), {}, {
3306
3428
  list: list,
@@ -3310,13 +3432,13 @@ var Server = /*#__PURE__*/function () {
3310
3432
  status: true
3311
3433
  });
3312
3434
  case 13:
3313
- _context35.prev = 13;
3314
- _context35.t0 = _context35["catch"](3);
3315
- errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
3435
+ _context37.prev = 13;
3436
+ _context37.t0 = _context37["catch"](3);
3437
+ errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3316
3438
  this.logError('fetchOrderListFromAPI: 请求失败', {
3317
3439
  error: errorMessage
3318
3440
  });
3319
- return _context35.abrupt("return", {
3441
+ return _context37.abrupt("return", {
3320
3442
  code: 500,
3321
3443
  message: errorMessage,
3322
3444
  data: {
@@ -3327,11 +3449,11 @@ var Server = /*#__PURE__*/function () {
3327
3449
  });
3328
3450
  case 18:
3329
3451
  case "end":
3330
- return _context35.stop();
3452
+ return _context37.stop();
3331
3453
  }
3332
- }, _callee35, this, [[3, 13]]);
3454
+ }, _callee37, this, [[3, 13]]);
3333
3455
  }));
3334
- function fetchOrderListFromAPI(_x38) {
3456
+ function fetchOrderListFromAPI(_x40) {
3335
3457
  return _fetchOrderListFromAPI.apply(this, arguments);
3336
3458
  }
3337
3459
  return fetchOrderListFromAPI;
@@ -3343,17 +3465,17 @@ var Server = /*#__PURE__*/function () {
3343
3465
  }, {
3344
3466
  key: "fetchBookingListFromAPI",
3345
3467
  value: (function () {
3346
- var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(data) {
3468
+ var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(data) {
3347
3469
  var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
3348
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3349
- while (1) switch (_context36.prev = _context36.next) {
3470
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3471
+ while (1) switch (_context38.prev = _context38.next) {
3350
3472
  case 0:
3351
3473
  if (this.order) {
3352
- _context36.next = 3;
3474
+ _context38.next = 3;
3353
3475
  break;
3354
3476
  }
3355
3477
  this.logError('fetchBookingListFromAPI: Order 模块不可用');
3356
- return _context36.abrupt("return", {
3478
+ return _context38.abrupt("return", {
3357
3479
  code: 500,
3358
3480
  message: 'Order 模块不可用',
3359
3481
  data: {
@@ -3363,18 +3485,18 @@ var Server = /*#__PURE__*/function () {
3363
3485
  status: false
3364
3486
  });
3365
3487
  case 3:
3366
- _context36.prev = 3;
3488
+ _context38.prev = 3;
3367
3489
  memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
3368
3490
  withFields = this.resolveBookingSalesWith(data);
3369
3491
  requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
3370
3492
  cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
3371
3493
  if (!memoryCacheEnabled) {
3372
- _context36.next = 13;
3494
+ _context38.next = 13;
3373
3495
  break;
3374
3496
  }
3375
3497
  cached = this.readBookingRemoteCache(cacheKey);
3376
3498
  if (!cached) {
3377
- _context36.next = 13;
3499
+ _context38.next = 13;
3378
3500
  break;
3379
3501
  }
3380
3502
  this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
@@ -3382,14 +3504,14 @@ var Server = /*#__PURE__*/function () {
3382
3504
  listCount: cached.bookingResult.count,
3383
3505
  withFields: cached.withFields
3384
3506
  });
3385
- return _context36.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
3507
+ return _context38.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
3386
3508
  cache_hit: true
3387
3509
  }));
3388
3510
  case 13:
3389
- _context36.next = 15;
3511
+ _context38.next = 15;
3390
3512
  return this.order.fetchOrdersBySSE(requestPayload);
3391
3513
  case 15:
3392
- rawList = _context36.sent;
3514
+ rawList = _context38.sent;
3393
3515
  bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
3394
3516
  if (typeof globalThis !== 'undefined') {
3395
3517
  globalThis.__SSE_BOOKING_DEBUG__ = {
@@ -3436,15 +3558,15 @@ var Server = /*#__PURE__*/function () {
3436
3558
  cacheKey: cacheKey,
3437
3559
  withFields: withFields
3438
3560
  });
3439
- return _context36.abrupt("return", this.buildBookingResponse(bookingResult));
3561
+ return _context38.abrupt("return", this.buildBookingResponse(bookingResult));
3440
3562
  case 23:
3441
- _context36.prev = 23;
3442
- _context36.t0 = _context36["catch"](3);
3443
- errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0);
3563
+ _context38.prev = 23;
3564
+ _context38.t0 = _context38["catch"](3);
3565
+ errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
3444
3566
  this.logError('fetchBookingListFromAPI: SSE 请求失败', {
3445
3567
  error: errorMessage
3446
3568
  });
3447
- return _context36.abrupt("return", {
3569
+ return _context38.abrupt("return", {
3448
3570
  code: 500,
3449
3571
  message: errorMessage,
3450
3572
  data: {
@@ -3455,11 +3577,11 @@ var Server = /*#__PURE__*/function () {
3455
3577
  });
3456
3578
  case 28:
3457
3579
  case "end":
3458
- return _context36.stop();
3580
+ return _context38.stop();
3459
3581
  }
3460
- }, _callee36, this, [[3, 23]]);
3582
+ }, _callee38, this, [[3, 23]]);
3461
3583
  }));
3462
- function fetchBookingListFromAPI(_x39) {
3584
+ function fetchBookingListFromAPI(_x41) {
3463
3585
  return _fetchBookingListFromAPI.apply(this, arguments);
3464
3586
  }
3465
3587
  return fetchBookingListFromAPI;
@@ -3467,24 +3589,24 @@ var Server = /*#__PURE__*/function () {
3467
3589
  }, {
3468
3590
  key: "getDeviceTaskPlugin",
3469
3591
  value: function getDeviceTaskPlugin() {
3470
- var _this$app7, _this$app7$getPlugin;
3471
- return ((_this$app7 = this.app) === null || _this$app7 === void 0 || (_this$app7$getPlugin = _this$app7.getPlugin) === null || _this$app7$getPlugin === void 0 ? void 0 : _this$app7$getPlugin.call(_this$app7, 'deviceTask')) || null;
3592
+ var _this$app8, _this$app8$getPlugin;
3593
+ return ((_this$app8 = this.app) === null || _this$app8 === void 0 || (_this$app8$getPlugin = _this$app8.getPlugin) === null || _this$app8$getPlugin === void 0 ? void 0 : _this$app8$getPlugin.call(_this$app8, 'deviceTask')) || null;
3472
3594
  }
3473
3595
  }, {
3474
3596
  key: "getIdGeneratorPlugin",
3475
3597
  value: function getIdGeneratorPlugin() {
3476
- var _this$app8, _this$app8$getPlugin;
3477
- return ((_this$app8 = this.app) === null || _this$app8 === void 0 || (_this$app8$getPlugin = _this$app8.getPlugin) === null || _this$app8$getPlugin === void 0 ? void 0 : _this$app8$getPlugin.call(_this$app8, 'idGenerator')) || null;
3598
+ var _this$app9, _this$app9$getPlugin;
3599
+ return ((_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getPlugin = _this$app9.getPlugin) === null || _this$app9$getPlugin === void 0 ? void 0 : _this$app9$getPlugin.call(_this$app9, 'idGenerator')) || null;
3478
3600
  }
3479
3601
  }, {
3480
3602
  key: "getAppData",
3481
3603
  value: function getAppData(key) {
3482
- var _this$core$getPlugin, _this$core$getPlugin$, _this$app9, _this$app9$getData, _this$app10, _this$app10$getStore, _this$app10$getStore$, _this$app10$getStore$2, _this$app11, _this$app11$getStore, _this$app11$getStore$, _this$app11$getStore$2, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2;
3604
+ var _this$core$getPlugin, _this$core$getPlugin$, _this$app10, _this$app10$getData, _this$app11, _this$app11$getStore, _this$app11$getStore$, _this$app11$getStore$2, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2;
3483
3605
  var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
3484
3606
  if (typeof getData === 'function') return getData(key);
3485
- var directValue = (_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getData = _this$app9.getData) === null || _this$app9$getData === void 0 ? void 0 : _this$app9$getData.call(_this$app9, key);
3607
+ var directValue = (_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getData = _this$app10.getData) === null || _this$app10$getData === void 0 ? void 0 : _this$app10$getData.call(_this$app10, key);
3486
3608
  if (directValue !== undefined) return directValue;
3487
- var coreData = ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10 = _this$app10.models) === null || _this$app10 === void 0 || (_this$app10$getStore = _this$app10.getStore) === null || _this$app10$getStore === void 0 || (_this$app10$getStore$ = (_this$app10$getStore$2 = _this$app10$getStore.call(_this$app10)).getDataByModel) === null || _this$app10$getStore$ === void 0 ? void 0 : _this$app10$getStore$.call(_this$app10$getStore$2, 'core', 'core')) || ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.data) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.store) === null || _this$app11 === void 0 || (_this$app11$getStore = _this$app11.getStore) === null || _this$app11$getStore === void 0 || (_this$app11$getStore$ = (_this$app11$getStore$2 = _this$app11$getStore.call(_this$app11)).getDataByModel) === null || _this$app11$getStore$ === void 0 ? void 0 : _this$app11$getStore$.call(_this$app11$getStore$2, 'core', 'core')) || ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.data) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.store) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 || (_this$app12$getStore$ = _this$app12$getStore$.call(_this$app12$getStore$2, 'core')) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.core);
3609
+ var coreData = ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11 = _this$app11.models) === null || _this$app11 === void 0 || (_this$app11$getStore = _this$app11.getStore) === null || _this$app11$getStore === void 0 || (_this$app11$getStore$ = (_this$app11$getStore$2 = _this$app11$getStore.call(_this$app11)).getDataByModel) === null || _this$app11$getStore$ === void 0 ? void 0 : _this$app11$getStore$.call(_this$app11$getStore$2, 'core', 'core')) || ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.data) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.store) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 || (_this$app13$getStore$ = _this$app13$getStore$.call(_this$app13$getStore$2, 'core')) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.core);
3488
3610
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
3489
3611
  }
3490
3612
  }, {
@@ -3535,32 +3657,32 @@ var Server = /*#__PURE__*/function () {
3535
3657
  }, {
3536
3658
  key: "getShortNumberOrDeviceId",
3537
3659
  value: function () {
3538
- var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3660
+ var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3539
3661
  var getAsyncIotDeviceInfo, res;
3540
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3541
- while (1) switch (_context37.prev = _context37.next) {
3662
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3663
+ while (1) switch (_context39.prev = _context39.next) {
3542
3664
  case 0:
3543
3665
  getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
3544
3666
  if (!getAsyncIotDeviceInfo) {
3545
- _context37.next = 7;
3667
+ _context39.next = 7;
3546
3668
  break;
3547
3669
  }
3548
- _context37.next = 4;
3670
+ _context39.next = 4;
3549
3671
  return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
3550
3672
  case 4:
3551
- res = _context37.sent;
3673
+ res = _context39.sent;
3552
3674
  if (!(res !== null && res !== void 0 && res.short_number)) {
3553
- _context37.next = 7;
3675
+ _context39.next = 7;
3554
3676
  break;
3555
3677
  }
3556
- return _context37.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
3678
+ return _context39.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
3557
3679
  case 7:
3558
- return _context37.abrupt("return", this.getAppData('device_id') || 0);
3680
+ return _context39.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
3559
3681
  case 8:
3560
3682
  case "end":
3561
- return _context37.stop();
3683
+ return _context39.stop();
3562
3684
  }
3563
- }, _callee37, this);
3685
+ }, _callee39, this);
3564
3686
  }));
3565
3687
  function getShortNumberOrDeviceId() {
3566
3688
  return _getShortNumberOrDeviceId.apply(this, arguments);
@@ -3577,81 +3699,81 @@ var Server = /*#__PURE__*/function () {
3577
3699
  }, {
3578
3700
  key: "ensureCheckoutOrderNumbers",
3579
3701
  value: function () {
3580
- var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(data, title) {
3702
+ var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data, title) {
3581
3703
  var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
3582
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3583
- while (1) switch (_context38.prev = _context38.next) {
3704
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3705
+ while (1) switch (_context40.prev = _context40.next) {
3584
3706
  case 0:
3585
3707
  if (!(!data || _typeof(data) !== 'object')) {
3586
- _context38.next = 2;
3708
+ _context40.next = 2;
3587
3709
  break;
3588
3710
  }
3589
- return _context38.abrupt("return", data);
3711
+ return _context40.abrupt("return", data);
3590
3712
  case 2:
3591
3713
  next = _objectSpread({}, data);
3592
3714
  needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
3593
3715
  needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
3594
3716
  if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
3595
- _context38.next = 7;
3717
+ _context40.next = 7;
3596
3718
  break;
3597
3719
  }
3598
- return _context38.abrupt("return", next);
3720
+ return _context40.abrupt("return", next);
3599
3721
  case 7:
3600
3722
  idGenerator = this.getIdGeneratorPlugin();
3601
3723
  if (idGenerator) {
3602
- _context38.next = 11;
3724
+ _context40.next = 11;
3603
3725
  break;
3604
3726
  }
3605
3727
  this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
3606
3728
  needsShopOrderNumber: needsShopOrderNumber,
3607
3729
  needsShopFullOrderNumber: needsShopFullOrderNumber
3608
3730
  });
3609
- return _context38.abrupt("return", next);
3731
+ return _context40.abrupt("return", next);
3610
3732
  case 11:
3611
- _context38.prev = 11;
3733
+ _context40.prev = 11;
3612
3734
  if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
3613
- _context38.next = 16;
3735
+ _context40.next = 16;
3614
3736
  break;
3615
3737
  }
3616
- _context38.next = 15;
3738
+ _context40.next = 15;
3617
3739
  return idGenerator.generateShopOrderNumber({
3618
3740
  biz: next.business_code || 'ticket'
3619
3741
  });
3620
3742
  case 15:
3621
- next.shop_order_number = _context38.sent;
3743
+ next.shop_order_number = _context40.sent;
3622
3744
  case 16:
3623
3745
  if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
3624
- _context38.next = 20;
3746
+ _context40.next = 20;
3625
3747
  break;
3626
3748
  }
3627
- _context38.next = 19;
3749
+ _context40.next = 19;
3628
3750
  return idGenerator.generateReceiptId({
3629
3751
  biz: next.business_code || 'ticket'
3630
3752
  });
3631
3753
  case 19:
3632
- next.shop_full_order_number = _context38.sent;
3754
+ next.shop_full_order_number = _context40.sent;
3633
3755
  case 20:
3634
3756
  this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
3635
3757
  shop_order_number: next.shop_order_number,
3636
3758
  shop_full_order_number: next.shop_full_order_number
3637
3759
  });
3638
- _context38.next = 26;
3760
+ _context40.next = 26;
3639
3761
  break;
3640
3762
  case 23:
3641
- _context38.prev = 23;
3642
- _context38.t0 = _context38["catch"](11);
3763
+ _context40.prev = 23;
3764
+ _context40.t0 = _context40["catch"](11);
3643
3765
  this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
3644
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
3766
+ error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3645
3767
  });
3646
3768
  case 26:
3647
- return _context38.abrupt("return", next);
3769
+ return _context40.abrupt("return", next);
3648
3770
  case 27:
3649
3771
  case "end":
3650
- return _context38.stop();
3772
+ return _context40.stop();
3651
3773
  }
3652
- }, _callee38, this, [[11, 23]]);
3774
+ }, _callee40, this, [[11, 23]]);
3653
3775
  }));
3654
- function ensureCheckoutOrderNumbers(_x40, _x41) {
3776
+ function ensureCheckoutOrderNumbers(_x42, _x43) {
3655
3777
  return _ensureCheckoutOrderNumbers.apply(this, arguments);
3656
3778
  }
3657
3779
  return ensureCheckoutOrderNumbers;
@@ -3659,33 +3781,34 @@ var Server = /*#__PURE__*/function () {
3659
3781
  }, {
3660
3782
  key: "dispatchCheckoutSyncTask",
3661
3783
  value: function () {
3662
- var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3663
- var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, result;
3664
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3665
- while (1) switch (_context39.prev = _context39.next) {
3784
+ var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3785
+ var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
3786
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3787
+ while (1) switch (_context41.prev = _context41.next) {
3666
3788
  case 0:
3667
3789
  this.registerDeviceTaskActions();
3668
3790
  deviceTask = this.getDeviceTaskPlugin();
3669
- _context39.next = 4;
3791
+ _context41.next = 4;
3670
3792
  return this.getShortNumberOrDeviceId();
3671
3793
  case 4:
3672
- debugDeviceId = _context39.sent;
3794
+ debugDeviceId = _context41.sent;
3673
3795
  debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
3674
3796
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3675
- _context39.next = 9;
3797
+ _context41.next = 9;
3676
3798
  break;
3677
3799
  }
3678
3800
  this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
3679
- return _context39.abrupt("return");
3801
+ return _context41.abrupt("return");
3680
3802
  case 9:
3681
- _context39.prev = 9;
3682
- _context39.next = 12;
3803
+ _context41.prev = 9;
3804
+ _context41.next = 12;
3683
3805
  return deviceTask.dispatch({
3684
3806
  action: 'sync_sales',
3685
3807
  device_id: debugDeviceId,
3686
3808
  payload: {
3687
3809
  backendPath: params.backendPath,
3688
3810
  data: params.data,
3811
+ external_sale_number: (_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.external_sale_number,
3689
3812
  title: params.title
3690
3813
  },
3691
3814
  retry_limit: 5,
@@ -3693,30 +3816,30 @@ var Server = /*#__PURE__*/function () {
3693
3816
  name: '同步订单',
3694
3817
  source: 'server',
3695
3818
  source_type: 'order',
3696
- source_id: ((_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.order_id) || ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.external_sale_number) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.shop_order_number)
3819
+ 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)
3697
3820
  });
3698
3821
  case 12:
3699
- result = _context39.sent;
3822
+ result = _context41.sent;
3700
3823
  this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
3701
3824
  uuid: result === null || result === void 0 ? void 0 : result.uuid,
3702
3825
  status: result === null || result === void 0 ? void 0 : result.status,
3703
3826
  reused: result === null || result === void 0 ? void 0 : result.reused
3704
3827
  });
3705
- _context39.next = 19;
3828
+ _context41.next = 19;
3706
3829
  break;
3707
3830
  case 16:
3708
- _context39.prev = 16;
3709
- _context39.t0 = _context39["catch"](9);
3831
+ _context41.prev = 16;
3832
+ _context41.t0 = _context41["catch"](9);
3710
3833
  this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
3711
- error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
3834
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
3712
3835
  });
3713
3836
  case 19:
3714
3837
  case "end":
3715
- return _context39.stop();
3838
+ return _context41.stop();
3716
3839
  }
3717
- }, _callee39, this, [[9, 16]]);
3840
+ }, _callee41, this, [[9, 16]]);
3718
3841
  }));
3719
- function dispatchCheckoutSyncTask(_x42) {
3842
+ function dispatchCheckoutSyncTask(_x44) {
3720
3843
  return _dispatchCheckoutSyncTask.apply(this, arguments);
3721
3844
  }
3722
3845
  return dispatchCheckoutSyncTask;
@@ -3724,26 +3847,26 @@ var Server = /*#__PURE__*/function () {
3724
3847
  }, {
3725
3848
  key: "dispatchPrintOtherReceiptTask",
3726
3849
  value: function () {
3727
- var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3850
+ var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3728
3851
  var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
3729
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3730
- while (1) switch (_context40.prev = _context40.next) {
3852
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3853
+ while (1) switch (_context42.prev = _context42.next) {
3731
3854
  case 0:
3732
3855
  deviceTask = this.getDeviceTaskPlugin();
3733
3856
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3734
- _context40.next = 4;
3857
+ _context42.next = 4;
3735
3858
  break;
3736
3859
  }
3737
3860
  this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
3738
- return _context40.abrupt("return");
3861
+ return _context42.abrupt("return");
3739
3862
  case 4:
3740
- _context40.prev = 4;
3863
+ _context42.prev = 4;
3741
3864
  printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
3742
- _context40.next = 8;
3865
+ _context42.next = 8;
3743
3866
  return this.getShortNumberOrDeviceId();
3744
3867
  case 8:
3745
- deviceId = _context40.sent;
3746
- _context40.next = 11;
3868
+ deviceId = _context42.sent;
3869
+ _context42.next = 11;
3747
3870
  return deviceTask.dispatch({
3748
3871
  action: 'print_all',
3749
3872
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
@@ -3768,21 +3891,21 @@ var Server = /*#__PURE__*/function () {
3768
3891
  source_id: printIdentity
3769
3892
  });
3770
3893
  case 11:
3771
- _context40.next = 16;
3894
+ _context42.next = 16;
3772
3895
  break;
3773
3896
  case 13:
3774
- _context40.prev = 13;
3775
- _context40.t0 = _context40["catch"](4);
3897
+ _context42.prev = 13;
3898
+ _context42.t0 = _context42["catch"](4);
3776
3899
  this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
3777
- error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
3900
+ error: _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0)
3778
3901
  });
3779
3902
  case 16:
3780
3903
  case "end":
3781
- return _context40.stop();
3904
+ return _context42.stop();
3782
3905
  }
3783
- }, _callee40, this, [[4, 13]]);
3906
+ }, _callee42, this, [[4, 13]]);
3784
3907
  }));
3785
- function dispatchPrintOtherReceiptTask(_x43) {
3908
+ function dispatchPrintOtherReceiptTask(_x45) {
3786
3909
  return _dispatchPrintOtherReceiptTask.apply(this, arguments);
3787
3910
  }
3788
3911
  return dispatchPrintOtherReceiptTask;
@@ -3802,37 +3925,37 @@ var Server = /*#__PURE__*/function () {
3802
3925
  }, {
3803
3926
  key: "dispatchLocalReceiptPrint",
3804
3927
  value: function () {
3805
- var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3928
+ var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3806
3929
  var _payment_info;
3807
3930
  var printableOrder;
3808
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3809
- while (1) switch (_context41.prev = _context41.next) {
3931
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3932
+ while (1) switch (_context43.prev = _context43.next) {
3810
3933
  case 0:
3811
3934
  if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
3812
- _context41.next = 2;
3935
+ _context43.next = 2;
3813
3936
  break;
3814
3937
  }
3815
- return _context41.abrupt("return", {
3938
+ return _context43.abrupt("return", {
3816
3939
  printed: false,
3817
3940
  order: params.order
3818
3941
  });
3819
3942
  case 2:
3820
- _context41.next = 4;
3943
+ _context43.next = 4;
3821
3944
  return this.withLocalSmallTicketData(params.order, {
3822
3945
  requireFullyPaid: params.requireFullyPaid
3823
3946
  });
3824
3947
  case 4:
3825
- printableOrder = _context41.sent;
3948
+ printableOrder = _context43.sent;
3826
3949
  if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
3827
- _context41.next = 7;
3950
+ _context43.next = 7;
3828
3951
  break;
3829
3952
  }
3830
- return _context41.abrupt("return", {
3953
+ return _context43.abrupt("return", {
3831
3954
  printed: false,
3832
3955
  order: printableOrder
3833
3956
  });
3834
3957
  case 7:
3835
- _context41.next = 9;
3958
+ _context43.next = 9;
3836
3959
  return this.dispatchPrintOtherReceiptTask({
3837
3960
  checkoutData: params.checkoutData,
3838
3961
  syncedOrder: printableOrder,
@@ -3840,17 +3963,17 @@ var Server = /*#__PURE__*/function () {
3840
3963
  receiptOnly: true
3841
3964
  });
3842
3965
  case 9:
3843
- return _context41.abrupt("return", {
3966
+ return _context43.abrupt("return", {
3844
3967
  printed: true,
3845
3968
  order: printableOrder
3846
3969
  });
3847
3970
  case 10:
3848
3971
  case "end":
3849
- return _context41.stop();
3972
+ return _context43.stop();
3850
3973
  }
3851
- }, _callee41, this);
3974
+ }, _callee43, this);
3852
3975
  }));
3853
- function dispatchLocalReceiptPrint(_x44) {
3976
+ function dispatchLocalReceiptPrint(_x46) {
3854
3977
  return _dispatchLocalReceiptPrint.apply(this, arguments);
3855
3978
  }
3856
3979
  return dispatchLocalReceiptPrint;
@@ -3858,10 +3981,10 @@ var Server = /*#__PURE__*/function () {
3858
3981
  }, {
3859
3982
  key: "handleOrderCheckoutSubmit",
3860
3983
  value: function () {
3861
- var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
3984
+ var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3862
3985
  var backendPath, data, title, checkoutData, pendingResult, pendingOrder;
3863
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3864
- while (1) switch (_context42.prev = _context42.next) {
3986
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3987
+ while (1) switch (_context44.prev = _context44.next) {
3865
3988
  case 0:
3866
3989
  backendPath = params.backendPath, data = params.data, title = params.title;
3867
3990
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
@@ -3870,11 +3993,11 @@ var Server = /*#__PURE__*/function () {
3870
3993
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
3871
3994
  order_number: data === null || data === void 0 ? void 0 : data.order_number
3872
3995
  });
3873
- _context42.next = 4;
3996
+ _context44.next = 4;
3874
3997
  return this.ensureCheckoutOrderNumbers(data, title);
3875
3998
  case 4:
3876
- checkoutData = _context42.sent;
3877
- _context42.next = 7;
3999
+ checkoutData = _context44.sent;
4000
+ _context44.next = 7;
3878
4001
  return this.handlePendingSyncCheckoutOrder({
3879
4002
  backendPath: backendPath,
3880
4003
  data: checkoutData,
@@ -3882,17 +4005,20 @@ var Server = /*#__PURE__*/function () {
3882
4005
  reason: 'checkout 已转入设备任务同步'
3883
4006
  });
3884
4007
  case 7:
3885
- pendingResult = _context42.sent;
4008
+ pendingResult = _context44.sent;
3886
4009
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
3887
- _context42.next = 15;
4010
+ _context44.next = 15;
3888
4011
  break;
3889
4012
  }
3890
4013
  pendingOrder = pendingResult.data;
3891
- if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder))) {
3892
- _context42.next = 13;
4014
+ if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) &&
4015
+ // TODO 这里先加个兼容,只有 type 为 virtual 才走打印
4016
+ // 后期需要迁移到 picoding ,根据工作流配置
4017
+ checkoutData.type === 'virtual')) {
4018
+ _context44.next = 13;
3893
4019
  break;
3894
4020
  }
3895
- _context42.next = 13;
4021
+ _context44.next = 13;
3896
4022
  return this.dispatchLocalReceiptPrint({
3897
4023
  checkoutData: checkoutData,
3898
4024
  order: pendingOrder,
@@ -3900,21 +4026,21 @@ var Server = /*#__PURE__*/function () {
3900
4026
  requireFullyPaid: true
3901
4027
  });
3902
4028
  case 13:
3903
- _context42.next = 15;
4029
+ _context44.next = 15;
3904
4030
  return this.dispatchCheckoutSyncTask({
3905
4031
  backendPath: backendPath,
3906
4032
  data: checkoutData,
3907
4033
  title: title
3908
4034
  });
3909
4035
  case 15:
3910
- return _context42.abrupt("return", pendingResult);
4036
+ return _context44.abrupt("return", pendingResult);
3911
4037
  case 16:
3912
4038
  case "end":
3913
- return _context42.stop();
4039
+ return _context44.stop();
3914
4040
  }
3915
- }, _callee42, this);
4041
+ }, _callee44, this);
3916
4042
  }));
3917
- function handleOrderCheckoutSubmit(_x45) {
4043
+ function handleOrderCheckoutSubmit(_x47) {
3918
4044
  return _handleOrderCheckoutSubmit.apply(this, arguments);
3919
4045
  }
3920
4046
  return handleOrderCheckoutSubmit;
@@ -3922,25 +4048,25 @@ var Server = /*#__PURE__*/function () {
3922
4048
  }, {
3923
4049
  key: "handlePendingSyncCheckoutOrder",
3924
4050
  value: function () {
3925
- var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4051
+ var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3926
4052
  var backendPath, data, title, reason, pendingOrder, errorMessage;
3927
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3928
- while (1) switch (_context43.prev = _context43.next) {
4053
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4054
+ while (1) switch (_context45.prev = _context45.next) {
3929
4055
  case 0:
3930
4056
  backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
3931
- _context43.next = 3;
4057
+ _context45.next = 3;
3932
4058
  return this.buildPendingSyncCheckoutOrder(data);
3933
4059
  case 3:
3934
- pendingOrder = _context43.sent;
4060
+ pendingOrder = _context45.sent;
3935
4061
  if (pendingOrder) {
3936
- _context43.next = 7;
4062
+ _context45.next = 7;
3937
4063
  break;
3938
4064
  }
3939
4065
  this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
3940
4066
  backendPath: backendPath,
3941
4067
  reason: reason
3942
4068
  });
3943
- return _context43.abrupt("return", {
4069
+ return _context45.abrupt("return", {
3944
4070
  code: 500,
3945
4071
  status: false,
3946
4072
  message: '订单缺少本地存储标识,无法写入待同步队列',
@@ -3948,22 +4074,22 @@ var Server = /*#__PURE__*/function () {
3948
4074
  });
3949
4075
  case 7:
3950
4076
  if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
3951
- _context43.next = 10;
4077
+ _context45.next = 10;
3952
4078
  break;
3953
4079
  }
3954
4080
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
3955
4081
  backendPath: backendPath,
3956
4082
  reason: reason
3957
4083
  });
3958
- return _context43.abrupt("return", {
4084
+ return _context45.abrupt("return", {
3959
4085
  code: 500,
3960
4086
  status: false,
3961
4087
  message: 'Order 模块不支持本地待同步写入',
3962
4088
  data: null
3963
4089
  });
3964
4090
  case 10:
3965
- _context43.prev = 10;
3966
- _context43.next = 13;
4091
+ _context45.prev = 10;
4092
+ _context45.next = 13;
3967
4093
  return this.order.upsertPendingSyncOrders([pendingOrder]);
3968
4094
  case 13:
3969
4095
  this.logWarning("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
@@ -3973,22 +4099,22 @@ var Server = /*#__PURE__*/function () {
3973
4099
  external_sale_number: pendingOrder.external_sale_number,
3974
4100
  order_number: pendingOrder.order_number
3975
4101
  });
3976
- return _context43.abrupt("return", {
4102
+ return _context45.abrupt("return", {
3977
4103
  code: 200,
3978
4104
  status: true,
3979
4105
  message: '',
3980
4106
  data: pendingOrder
3981
4107
  });
3982
4108
  case 17:
3983
- _context43.prev = 17;
3984
- _context43.t0 = _context43["catch"](10);
3985
- errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
4109
+ _context45.prev = 17;
4110
+ _context45.t0 = _context45["catch"](10);
4111
+ errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
3986
4112
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
3987
4113
  backendPath: backendPath,
3988
4114
  reason: reason,
3989
4115
  error: errorMessage
3990
4116
  });
3991
- return _context43.abrupt("return", {
4117
+ return _context45.abrupt("return", {
3992
4118
  code: 500,
3993
4119
  status: false,
3994
4120
  message: errorMessage,
@@ -3996,11 +4122,11 @@ var Server = /*#__PURE__*/function () {
3996
4122
  });
3997
4123
  case 22:
3998
4124
  case "end":
3999
- return _context43.stop();
4125
+ return _context45.stop();
4000
4126
  }
4001
- }, _callee43, this, [[10, 17]]);
4127
+ }, _callee45, this, [[10, 17]]);
4002
4128
  }));
4003
- function handlePendingSyncCheckoutOrder(_x46) {
4129
+ function handlePendingSyncCheckoutOrder(_x48) {
4004
4130
  return _handlePendingSyncCheckoutOrder.apply(this, arguments);
4005
4131
  }
4006
4132
  return handlePendingSyncCheckoutOrder;
@@ -4008,36 +4134,36 @@ var Server = /*#__PURE__*/function () {
4008
4134
  }, {
4009
4135
  key: "buildPendingSyncCheckoutOrder",
4010
4136
  value: function () {
4011
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data) {
4137
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
4012
4138
  var hasStorageKey;
4013
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4014
- while (1) switch (_context44.prev = _context44.next) {
4139
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4140
+ while (1) switch (_context46.prev = _context46.next) {
4015
4141
  case 0:
4016
4142
  if (!(!data || _typeof(data) !== 'object')) {
4017
- _context44.next = 2;
4143
+ _context46.next = 2;
4018
4144
  break;
4019
4145
  }
4020
- return _context44.abrupt("return", null);
4146
+ return _context46.abrupt("return", null);
4021
4147
  case 2:
4022
4148
  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 !== '';
4023
4149
  if (hasStorageKey) {
4024
- _context44.next = 5;
4150
+ _context46.next = 5;
4025
4151
  break;
4026
4152
  }
4027
- return _context44.abrupt("return", null);
4153
+ return _context46.abrupt("return", null);
4028
4154
  case 5:
4029
- return _context44.abrupt("return", this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, data), {}, {
4155
+ return _context46.abrupt("return", this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, data), {}, {
4030
4156
  need_sync: 1
4031
4157
  }), {
4032
4158
  requireFullyPaid: true
4033
4159
  }));
4034
4160
  case 6:
4035
4161
  case "end":
4036
- return _context44.stop();
4162
+ return _context46.stop();
4037
4163
  }
4038
- }, _callee44, this);
4164
+ }, _callee46, this);
4039
4165
  }));
4040
- function buildPendingSyncCheckoutOrder(_x47) {
4166
+ function buildPendingSyncCheckoutOrder(_x49) {
4041
4167
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
4042
4168
  }
4043
4169
  return buildPendingSyncCheckoutOrder;
@@ -4045,10 +4171,10 @@ var Server = /*#__PURE__*/function () {
4045
4171
  }, {
4046
4172
  key: "shouldBuildSmallTicketData",
4047
4173
  value: function shouldBuildSmallTicketData(order) {
4048
- var _order$payment_info, _ref50, _order$small_ticket_d;
4174
+ var _order$payment_info, _ref52, _order$small_ticket_d;
4049
4175
  if (!order || _typeof(order) !== 'object') return false;
4050
4176
  if (hasSmallTicketData((_order$payment_info = order.payment_info) === null || _order$payment_info === void 0 ? void 0 : _order$payment_info.small_ticket_data)) return false;
4051
- return Number((_ref50 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref50 !== void 0 ? _ref50 : 0) === 1;
4177
+ return Number((_ref52 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref52 !== void 0 ? _ref52 : 0) === 1;
4052
4178
  }
4053
4179
  }, {
4054
4180
  key: "shouldPrintSyncedOrder",
@@ -4066,7 +4192,7 @@ var Server = /*#__PURE__*/function () {
4066
4192
  }, {
4067
4193
  key: "isSalesOrderFullyPaid",
4068
4194
  value: function isSalesOrderFullyPaid(order) {
4069
- var _order$summary$amount, _order$summary, _ref51, _ref52, _order$summary$expect, _order$summary2, _order$summary3;
4195
+ var _order$summary$amount, _order$summary, _ref53, _ref54, _order$summary$expect, _order$summary2, _order$summary3;
4070
4196
  if (!order || _typeof(order) !== 'object') return false;
4071
4197
  var paymentStatus = String(order.payment_status || '').toLowerCase();
4072
4198
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -4078,7 +4204,7 @@ var Server = /*#__PURE__*/function () {
4078
4204
  return this.toAmountNumber(amountGap) <= 0;
4079
4205
  }
4080
4206
  var paidAmount = this.sumPaidOrderPayments(order.payments);
4081
- var targetAmount = this.toAmountNumber((_ref51 = (_ref52 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref52 !== void 0 ? _ref52 : order.expect_amount) !== null && _ref51 !== void 0 ? _ref51 : order.total_amount);
4207
+ var targetAmount = this.toAmountNumber((_ref53 = (_ref54 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref54 !== void 0 ? _ref54 : order.expect_amount) !== null && _ref53 !== void 0 ? _ref53 : order.total_amount);
4082
4208
  if (targetAmount <= 0) return paidAmount > 0;
4083
4209
  return paidAmount >= targetAmount;
4084
4210
  }
@@ -4105,12 +4231,12 @@ var Server = /*#__PURE__*/function () {
4105
4231
  }, {
4106
4232
  key: "buildSmallTicketProductMap",
4107
4233
  value: function () {
4108
- var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order) {
4234
+ var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order) {
4109
4235
  var _this$products,
4110
4236
  _this11 = this;
4111
4237
  var products, productIds, entries;
4112
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4113
- while (1) switch (_context46.prev = _context46.next) {
4238
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4239
+ while (1) switch (_context48.prev = _context48.next) {
4114
4240
  case 0:
4115
4241
  products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
4116
4242
  productIds = Array.from(new Set(products.map(function (product) {
@@ -4120,45 +4246,45 @@ var Server = /*#__PURE__*/function () {
4120
4246
  return id !== undefined && id !== null && id !== '';
4121
4247
  })));
4122
4248
  if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
4123
- _context46.next = 4;
4249
+ _context48.next = 4;
4124
4250
  break;
4125
4251
  }
4126
- return _context46.abrupt("return", {});
4252
+ return _context48.abrupt("return", {});
4127
4253
  case 4:
4128
- _context46.next = 6;
4254
+ _context48.next = 6;
4129
4255
  return Promise.all(productIds.map( /*#__PURE__*/function () {
4130
- var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(id) {
4256
+ var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(id) {
4131
4257
  var _this11$products, _this11$products$getP, product;
4132
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4133
- while (1) switch (_context45.prev = _context45.next) {
4258
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4259
+ while (1) switch (_context47.prev = _context47.next) {
4134
4260
  case 0:
4135
- _context45.prev = 0;
4136
- _context45.next = 3;
4261
+ _context47.prev = 0;
4262
+ _context47.next = 3;
4137
4263
  return (_this11$products = _this11.products) === null || _this11$products === void 0 || (_this11$products$getP = _this11$products.getProductById) === null || _this11$products$getP === void 0 ? void 0 : _this11$products$getP.call(_this11$products, Number(id));
4138
4264
  case 3:
4139
- product = _context45.sent;
4140
- return _context45.abrupt("return", product ? [String(id), product] : null);
4265
+ product = _context47.sent;
4266
+ return _context47.abrupt("return", product ? [String(id), product] : null);
4141
4267
  case 7:
4142
- _context45.prev = 7;
4143
- _context45.t0 = _context45["catch"](0);
4268
+ _context47.prev = 7;
4269
+ _context47.t0 = _context47["catch"](0);
4144
4270
  _this11.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
4145
4271
  product_id: id,
4146
- error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
4272
+ error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4147
4273
  });
4148
- return _context45.abrupt("return", null);
4274
+ return _context47.abrupt("return", null);
4149
4275
  case 11:
4150
4276
  case "end":
4151
- return _context45.stop();
4277
+ return _context47.stop();
4152
4278
  }
4153
- }, _callee45, null, [[0, 7]]);
4279
+ }, _callee47, null, [[0, 7]]);
4154
4280
  }));
4155
- return function (_x49) {
4156
- return _ref53.apply(this, arguments);
4281
+ return function (_x51) {
4282
+ return _ref55.apply(this, arguments);
4157
4283
  };
4158
4284
  }()));
4159
4285
  case 6:
4160
- entries = _context46.sent;
4161
- return _context46.abrupt("return", entries.reduce(function (map, entry) {
4286
+ entries = _context48.sent;
4287
+ return _context48.abrupt("return", entries.reduce(function (map, entry) {
4162
4288
  if (!entry) return map;
4163
4289
  var _entry = _slicedToArray(entry, 2),
4164
4290
  id = _entry[0],
@@ -4168,11 +4294,11 @@ var Server = /*#__PURE__*/function () {
4168
4294
  }, {}));
4169
4295
  case 8:
4170
4296
  case "end":
4171
- return _context46.stop();
4297
+ return _context48.stop();
4172
4298
  }
4173
- }, _callee46, this);
4299
+ }, _callee48, this);
4174
4300
  }));
4175
- function buildSmallTicketProductMap(_x48) {
4301
+ function buildSmallTicketProductMap(_x50) {
4176
4302
  return _buildSmallTicketProductMap.apply(this, arguments);
4177
4303
  }
4178
4304
  return buildSmallTicketProductMap;
@@ -4180,52 +4306,52 @@ var Server = /*#__PURE__*/function () {
4180
4306
  }, {
4181
4307
  key: "withLocalSmallTicketData",
4182
4308
  value: function () {
4183
- var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(order, options) {
4309
+ var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(order, options) {
4184
4310
  var productMap, smallTicketData;
4185
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4186
- while (1) switch (_context47.prev = _context47.next) {
4311
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4312
+ while (1) switch (_context49.prev = _context49.next) {
4187
4313
  case 0:
4188
4314
  if (this.shouldBuildSmallTicketData(order)) {
4189
- _context47.next = 2;
4315
+ _context49.next = 2;
4190
4316
  break;
4191
4317
  }
4192
- return _context47.abrupt("return", order);
4318
+ return _context49.abrupt("return", order);
4193
4319
  case 2:
4194
4320
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
4195
- _context47.next = 4;
4321
+ _context49.next = 4;
4196
4322
  break;
4197
4323
  }
4198
- return _context47.abrupt("return", order);
4324
+ return _context49.abrupt("return", order);
4199
4325
  case 4:
4200
- _context47.prev = 4;
4201
- _context47.next = 7;
4326
+ _context49.prev = 4;
4327
+ _context49.next = 7;
4202
4328
  return this.buildSmallTicketProductMap(order);
4203
4329
  case 7:
4204
- productMap = _context47.sent;
4330
+ productMap = _context49.sent;
4205
4331
  smallTicketData = buildSmallTicketData({
4206
4332
  order: order,
4207
4333
  shopInfo: this.getSmallTicketShopInfo(),
4208
4334
  productMap: productMap
4209
4335
  });
4210
- return _context47.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4336
+ return _context49.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
4211
4337
  payment_info: _objectSpread(_objectSpread({}, order.payment_info || {}), {}, {
4212
4338
  small_ticket_data: smallTicketData
4213
4339
  })
4214
4340
  }));
4215
4341
  case 12:
4216
- _context47.prev = 12;
4217
- _context47.t0 = _context47["catch"](4);
4342
+ _context49.prev = 12;
4343
+ _context49.t0 = _context49["catch"](4);
4218
4344
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
4219
- error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
4345
+ error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0)
4220
4346
  });
4221
- return _context47.abrupt("return", order);
4347
+ return _context49.abrupt("return", order);
4222
4348
  case 16:
4223
4349
  case "end":
4224
- return _context47.stop();
4350
+ return _context49.stop();
4225
4351
  }
4226
- }, _callee47, this, [[4, 12]]);
4352
+ }, _callee49, this, [[4, 12]]);
4227
4353
  }));
4228
- function withLocalSmallTicketData(_x50, _x51) {
4354
+ function withLocalSmallTicketData(_x52, _x53) {
4229
4355
  return _withLocalSmallTicketData.apply(this, arguments);
4230
4356
  }
4231
4357
  return withLocalSmallTicketData;
@@ -4287,34 +4413,34 @@ var Server = /*#__PURE__*/function () {
4287
4413
  }, {
4288
4414
  key: "handleUpdateLocalOrdersBatch",
4289
4415
  value: (function () {
4290
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(orderIds) {
4291
- var _this$app13;
4416
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderIds) {
4417
+ var _this$app14;
4292
4418
  var existedBefore, _iterator12, _step12, id, fetched, message, fetchedMap, _iterator13, _step13, order, oid, freshOrders, succeedIds, failed, _iterator14, _step14, _id, fresh, _message2, overwritten, inserted;
4293
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4294
- while (1) switch (_context48.prev = _context48.next) {
4419
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4420
+ while (1) switch (_context50.prev = _context50.next) {
4295
4421
  case 0:
4296
4422
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
4297
4423
  count: orderIds.length,
4298
4424
  orderIds: orderIds
4299
4425
  });
4300
4426
  if (this.order) {
4301
- _context48.next = 4;
4427
+ _context50.next = 4;
4302
4428
  break;
4303
4429
  }
4304
4430
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
4305
- return _context48.abrupt("return", {
4431
+ return _context50.abrupt("return", {
4306
4432
  code: 500,
4307
4433
  status: false,
4308
4434
  message: 'Order 模块未注册',
4309
4435
  data: null
4310
4436
  });
4311
4437
  case 4:
4312
- if ((_this$app13 = this.app) !== null && _this$app13 !== void 0 && _this$app13.request) {
4313
- _context48.next = 7;
4438
+ if ((_this$app14 = this.app) !== null && _this$app14 !== void 0 && _this$app14.request) {
4439
+ _context50.next = 7;
4314
4440
  break;
4315
4441
  }
4316
4442
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
4317
- return _context48.abrupt("return", {
4443
+ return _context50.abrupt("return", {
4318
4444
  code: 500,
4319
4445
  status: false,
4320
4446
  message: 'app.request 不可用',
@@ -4337,21 +4463,21 @@ var Server = /*#__PURE__*/function () {
4337
4463
  _iterator12.f();
4338
4464
  }
4339
4465
  fetched = [];
4340
- _context48.prev = 11;
4341
- _context48.next = 14;
4466
+ _context50.prev = 11;
4467
+ _context50.next = 14;
4342
4468
  return this.order.fetchOrdersByHttp(orderIds);
4343
4469
  case 14:
4344
- fetched = _context48.sent;
4345
- _context48.next = 22;
4470
+ fetched = _context50.sent;
4471
+ _context50.next = 22;
4346
4472
  break;
4347
4473
  case 17:
4348
- _context48.prev = 17;
4349
- _context48.t0 = _context48["catch"](11);
4350
- message = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
4474
+ _context50.prev = 17;
4475
+ _context50.t0 = _context50["catch"](11);
4476
+ message = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
4351
4477
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
4352
4478
  message: message
4353
4479
  });
4354
- return _context48.abrupt("return", {
4480
+ return _context50.abrupt("return", {
4355
4481
  code: 500,
4356
4482
  status: false,
4357
4483
  message: message,
@@ -4361,36 +4487,36 @@ var Server = /*#__PURE__*/function () {
4361
4487
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
4362
4488
  fetchedMap = new Map();
4363
4489
  _iterator13 = _createForOfIteratorHelper(fetched);
4364
- _context48.prev = 24;
4490
+ _context50.prev = 24;
4365
4491
  _iterator13.s();
4366
4492
  case 26:
4367
4493
  if ((_step13 = _iterator13.n()).done) {
4368
- _context48.next = 34;
4494
+ _context50.next = 34;
4369
4495
  break;
4370
4496
  }
4371
4497
  order = _step13.value;
4372
4498
  oid = order === null || order === void 0 ? void 0 : order.order_id;
4373
4499
  if (!(oid === undefined || oid === null)) {
4374
- _context48.next = 31;
4500
+ _context50.next = 31;
4375
4501
  break;
4376
4502
  }
4377
- return _context48.abrupt("continue", 32);
4503
+ return _context50.abrupt("continue", 32);
4378
4504
  case 31:
4379
4505
  fetchedMap.set(String(oid), order);
4380
4506
  case 32:
4381
- _context48.next = 26;
4507
+ _context50.next = 26;
4382
4508
  break;
4383
4509
  case 34:
4384
- _context48.next = 39;
4510
+ _context50.next = 39;
4385
4511
  break;
4386
4512
  case 36:
4387
- _context48.prev = 36;
4388
- _context48.t1 = _context48["catch"](24);
4389
- _iterator13.e(_context48.t1);
4513
+ _context50.prev = 36;
4514
+ _context50.t1 = _context50["catch"](24);
4515
+ _iterator13.e(_context50.t1);
4390
4516
  case 39:
4391
- _context48.prev = 39;
4517
+ _context50.prev = 39;
4392
4518
  _iterator13.f();
4393
- return _context48.finish(39);
4519
+ return _context50.finish(39);
4394
4520
  case 42:
4395
4521
  freshOrders = [];
4396
4522
  succeedIds = [];
@@ -4416,23 +4542,23 @@ var Server = /*#__PURE__*/function () {
4416
4542
  _iterator14.f();
4417
4543
  }
4418
4544
  if (!(freshOrders.length > 0)) {
4419
- _context48.next = 58;
4545
+ _context50.next = 58;
4420
4546
  break;
4421
4547
  }
4422
- _context48.prev = 48;
4423
- _context48.next = 51;
4548
+ _context50.prev = 48;
4549
+ _context50.next = 51;
4424
4550
  return this.order.upsertOrdersFromRemote(freshOrders);
4425
4551
  case 51:
4426
- _context48.next = 58;
4552
+ _context50.next = 58;
4427
4553
  break;
4428
4554
  case 53:
4429
- _context48.prev = 53;
4430
- _context48.t2 = _context48["catch"](48);
4431
- _message2 = _context48.t2 instanceof Error ? _context48.t2.message : String(_context48.t2);
4555
+ _context50.prev = 53;
4556
+ _context50.t2 = _context50["catch"](48);
4557
+ _message2 = _context50.t2 instanceof Error ? _context50.t2.message : String(_context50.t2);
4432
4558
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
4433
4559
  message: _message2
4434
4560
  });
4435
- return _context48.abrupt("return", {
4561
+ return _context50.abrupt("return", {
4436
4562
  code: 500,
4437
4563
  status: false,
4438
4564
  message: _message2,
@@ -4451,7 +4577,7 @@ var Server = /*#__PURE__*/function () {
4451
4577
  insertedCount: inserted.length,
4452
4578
  failedCount: failed.length
4453
4579
  });
4454
- return _context48.abrupt("return", {
4580
+ return _context50.abrupt("return", {
4455
4581
  code: 200,
4456
4582
  status: true,
4457
4583
  message: '',
@@ -4463,11 +4589,11 @@ var Server = /*#__PURE__*/function () {
4463
4589
  });
4464
4590
  case 62:
4465
4591
  case "end":
4466
- return _context48.stop();
4592
+ return _context50.stop();
4467
4593
  }
4468
- }, _callee48, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4594
+ }, _callee50, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
4469
4595
  }));
4470
- function handleUpdateLocalOrdersBatch(_x52) {
4596
+ function handleUpdateLocalOrdersBatch(_x54) {
4471
4597
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
4472
4598
  }
4473
4599
  return handleUpdateLocalOrdersBatch;
@@ -4555,6 +4681,40 @@ var Server = /*#__PURE__*/function () {
4555
4681
  }
4556
4682
  return null;
4557
4683
  }
4684
+ }, {
4685
+ key: "getCheckoutExternalSaleNumber",
4686
+ value: function getCheckoutExternalSaleNumber(data, payload) {
4687
+ var _payload$data;
4688
+ var candidates = [payload === null || payload === void 0 ? void 0 : payload.external_sale_number, data === null || data === void 0 ? void 0 : data.external_sale_number, payload === null || payload === void 0 || (_payload$data = payload.data) === null || _payload$data === void 0 ? void 0 : _payload$data.external_sale_number];
4689
+ var value = candidates.find(function (candidate) {
4690
+ return candidate !== undefined && candidate !== null && candidate !== '';
4691
+ });
4692
+ return value === undefined ? undefined : String(value);
4693
+ }
4694
+ }, {
4695
+ key: "buildCheckoutSyncSuccessPatch",
4696
+ value: function buildCheckoutSyncSuccessPatch(fresh) {
4697
+ if (!fresh) return {};
4698
+ var patch = {};
4699
+ if (fresh.order_id !== undefined && fresh.order_id !== null) patch.order_id = fresh.order_id;
4700
+ if (fresh.order_number !== undefined && fresh.order_number !== null) {
4701
+ patch.order_number = fresh.order_number;
4702
+ }
4703
+ return patch;
4704
+ }
4705
+ }, {
4706
+ key: "isMergeableCheckoutOrder",
4707
+ value: function isMergeableCheckoutOrder(order, externalSaleNumber) {
4708
+ if (!order || _typeof(order) !== 'object') return false;
4709
+ var orderExternalSaleNumber = order.external_sale_number;
4710
+ if (externalSaleNumber && orderExternalSaleNumber !== undefined && orderExternalSaleNumber !== null && String(orderExternalSaleNumber) !== externalSaleNumber) {
4711
+ return false;
4712
+ }
4713
+ if (externalSaleNumber && (orderExternalSaleNumber === undefined || orderExternalSaleNumber === null || orderExternalSaleNumber === '')) {
4714
+ return false;
4715
+ }
4716
+ return Array.isArray(order.products) || Array.isArray(order.bookings) || Array.isArray(order.payments) || !!order.summary || order.order_number !== undefined || order.payment_status !== undefined || order.status !== undefined;
4717
+ }
4558
4718
  }, {
4559
4719
  key: "normalizeCheckoutResponse",
4560
4720
  value: function normalizeCheckoutResponse(response) {
@@ -4704,16 +4864,16 @@ var Server = /*#__PURE__*/function () {
4704
4864
  }, {
4705
4865
  key: "recomputeAndNotifyFloorPlanQuery",
4706
4866
  value: (function () {
4707
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4867
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
4708
4868
  var _iterator16, _step16, _step16$value, subscriberId, sub, result, errorMessage;
4709
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4710
- while (1) switch (_context49.prev = _context49.next) {
4869
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4870
+ while (1) switch (_context51.prev = _context51.next) {
4711
4871
  case 0:
4712
4872
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
4713
- _context49.next = 2;
4873
+ _context51.next = 2;
4714
4874
  break;
4715
4875
  }
4716
- return _context49.abrupt("return");
4876
+ return _context51.abrupt("return");
4717
4877
  case 2:
4718
4878
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
4719
4879
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -4743,9 +4903,9 @@ var Server = /*#__PURE__*/function () {
4743
4903
  }
4744
4904
  case 5:
4745
4905
  case "end":
4746
- return _context49.stop();
4906
+ return _context51.stop();
4747
4907
  }
4748
- }, _callee49, this);
4908
+ }, _callee51, this);
4749
4909
  }));
4750
4910
  function recomputeAndNotifyFloorPlanQuery() {
4751
4911
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -4775,21 +4935,21 @@ var Server = /*#__PURE__*/function () {
4775
4935
  * filter 逻辑暂为 mock,仅记录参数
4776
4936
  */
4777
4937
  function () {
4778
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data) {
4938
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data) {
4779
4939
  var rawList, result;
4780
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4781
- while (1) switch (_context50.prev = _context50.next) {
4940
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4941
+ while (1) switch (_context52.prev = _context52.next) {
4782
4942
  case 0:
4783
4943
  this.logInfo('computeOrderQueryResult: 开始过滤', {
4784
4944
  data: data
4785
4945
  });
4786
4946
  console.log('[Server] computeOrderQueryResult', data);
4787
4947
  if (this.order) {
4788
- _context50.next = 5;
4948
+ _context52.next = 5;
4789
4949
  break;
4790
4950
  }
4791
4951
  this.logError('computeOrderQueryResult: Order 模块未注册');
4792
- return _context50.abrupt("return", {
4952
+ return _context52.abrupt("return", {
4793
4953
  code: 500,
4794
4954
  message: 'Order 模块未注册',
4795
4955
  data: {
@@ -4813,7 +4973,7 @@ var Server = /*#__PURE__*/function () {
4813
4973
  skip: result.skip,
4814
4974
  rejected: result.rejected
4815
4975
  });
4816
- return _context50.abrupt("return", {
4976
+ return _context52.abrupt("return", {
4817
4977
  code: 200,
4818
4978
  data: result,
4819
4979
  message: '',
@@ -4821,11 +4981,11 @@ var Server = /*#__PURE__*/function () {
4821
4981
  });
4822
4982
  case 10:
4823
4983
  case "end":
4824
- return _context50.stop();
4984
+ return _context52.stop();
4825
4985
  }
4826
- }, _callee50, this);
4986
+ }, _callee52, this);
4827
4987
  }));
4828
- function computeOrderQueryResult(_x53) {
4988
+ function computeOrderQueryResult(_x55) {
4829
4989
  return _computeOrderQueryResult.apply(this, arguments);
4830
4990
  }
4831
4991
  return computeOrderQueryResult;
@@ -4838,17 +4998,17 @@ var Server = /*#__PURE__*/function () {
4838
4998
  }, {
4839
4999
  key: "computeBookingQueryResult",
4840
5000
  value: (function () {
4841
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(data) {
5001
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data) {
4842
5002
  var rawOrders, result;
4843
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4844
- while (1) switch (_context51.prev = _context51.next) {
5003
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5004
+ while (1) switch (_context53.prev = _context53.next) {
4845
5005
  case 0:
4846
5006
  if (this.order) {
4847
- _context51.next = 3;
5007
+ _context53.next = 3;
4848
5008
  break;
4849
5009
  }
4850
5010
  this.logError('computeBookingQueryResult: Order 模块未注册');
4851
- return _context51.abrupt("return", {
5011
+ return _context53.abrupt("return", {
4852
5012
  code: 500,
4853
5013
  message: 'Order 模块未注册',
4854
5014
  data: {
@@ -4867,7 +5027,7 @@ var Server = /*#__PURE__*/function () {
4867
5027
  size: result.size,
4868
5028
  skip: result.skip
4869
5029
  });
4870
- return _context51.abrupt("return", {
5030
+ return _context53.abrupt("return", {
4871
5031
  code: 200,
4872
5032
  data: result,
4873
5033
  message: '',
@@ -4875,11 +5035,11 @@ var Server = /*#__PURE__*/function () {
4875
5035
  });
4876
5036
  case 8:
4877
5037
  case "end":
4878
- return _context51.stop();
5038
+ return _context53.stop();
4879
5039
  }
4880
- }, _callee51, this);
5040
+ }, _callee53, this);
4881
5041
  }));
4882
- function computeBookingQueryResult(_x54) {
5042
+ function computeBookingQueryResult(_x56) {
4883
5043
  return _computeBookingQueryResult.apply(this, arguments);
4884
5044
  }
4885
5045
  return computeBookingQueryResult;
@@ -4895,12 +5055,12 @@ var Server = /*#__PURE__*/function () {
4895
5055
  }, {
4896
5056
  key: "computeProductQueryResult",
4897
5057
  value: (function () {
4898
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(context, options) {
5058
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(context, options) {
4899
5059
  var _menu_list_ids$length3,
4900
5060
  _this13 = this;
4901
5061
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
4902
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4903
- while (1) switch (_context52.prev = _context52.next) {
5062
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5063
+ while (1) switch (_context54.prev = _context54.next) {
4904
5064
  case 0:
4905
5065
  tTotal = performance.now();
4906
5066
  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, product_id = context.product_id;
@@ -4919,11 +5079,11 @@ var Server = /*#__PURE__*/function () {
4919
5079
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
4920
5080
  });
4921
5081
  if (this.products) {
4922
- _context52.next = 7;
5082
+ _context54.next = 7;
4923
5083
  break;
4924
5084
  }
4925
5085
  this.logError('computeProductQueryResult: Products 模块未注册');
4926
- return _context52.abrupt("return", {
5086
+ return _context54.abrupt("return", {
4927
5087
  message: 'Products 模块未注册',
4928
5088
  data: {
4929
5089
  list: [],
@@ -4932,12 +5092,12 @@ var Server = /*#__PURE__*/function () {
4932
5092
  });
4933
5093
  case 7:
4934
5094
  if (!(queryIds.length > 0)) {
4935
- _context52.next = 18;
5095
+ _context54.next = 18;
4936
5096
  break;
4937
5097
  }
4938
5098
  uniqueIds = Array.from(new Set(queryIds));
4939
5099
  _tPrice = performance.now();
4940
- _context52.next = 12;
5100
+ _context54.next = 12;
4941
5101
  return this.products.getProductsWithPrice(schedule_date, {
4942
5102
  scheduleModule: this.getSchedule(),
4943
5103
  schedule_datetime: schedule_datetime,
@@ -4947,7 +5107,7 @@ var Server = /*#__PURE__*/function () {
4947
5107
  productIds: uniqueIds
4948
5108
  });
4949
5109
  case 12:
4950
- productsWithPrice = _context52.sent;
5110
+ productsWithPrice = _context54.sent;
4951
5111
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
4952
5112
  count: productsWithPrice.length,
4953
5113
  ids: uniqueIds
@@ -4966,7 +5126,7 @@ var Server = /*#__PURE__*/function () {
4966
5126
  ids: uniqueIds,
4967
5127
  count: _filteredProducts.length
4968
5128
  });
4969
- return _context52.abrupt("return", {
5129
+ return _context54.abrupt("return", {
4970
5130
  code: 200,
4971
5131
  data: {
4972
5132
  list: _filteredProducts,
@@ -4977,19 +5137,19 @@ var Server = /*#__PURE__*/function () {
4977
5137
  });
4978
5138
  case 18:
4979
5139
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
4980
- _context52.next = 30;
5140
+ _context54.next = 30;
4981
5141
  break;
4982
5142
  }
4983
5143
  pid = Number(product_id);
4984
5144
  _tPrice2 = performance.now();
4985
- _context52.next = 23;
5145
+ _context54.next = 23;
4986
5146
  return this.products.getProductsWithPrice(schedule_date, {
4987
5147
  scheduleModule: this.getSchedule()
4988
5148
  }, {
4989
5149
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
4990
5150
  });
4991
5151
  case 23:
4992
- allProductsWithPrice = _context52.sent;
5152
+ allProductsWithPrice = _context54.sent;
4993
5153
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
4994
5154
  count: allProductsWithPrice.length,
4995
5155
  productId: pid
@@ -5009,7 +5169,7 @@ var Server = /*#__PURE__*/function () {
5009
5169
  productId: pid,
5010
5170
  found: !!item
5011
5171
  });
5012
- return _context52.abrupt("return", {
5172
+ return _context54.abrupt("return", {
5013
5173
  code: 200,
5014
5174
  data: item,
5015
5175
  message: item ? '' : '商品不存在或未发布',
@@ -5017,11 +5177,11 @@ var Server = /*#__PURE__*/function () {
5017
5177
  });
5018
5178
  case 30:
5019
5179
  if (this.menu) {
5020
- _context52.next = 33;
5180
+ _context54.next = 33;
5021
5181
  break;
5022
5182
  }
5023
5183
  this.logError('computeProductQueryResult: Menu 模块未注册');
5024
- return _context52.abrupt("return", {
5184
+ return _context54.abrupt("return", {
5025
5185
  message: 'Menu 模块未注册',
5026
5186
  data: {
5027
5187
  list: [],
@@ -5030,11 +5190,11 @@ var Server = /*#__PURE__*/function () {
5030
5190
  });
5031
5191
  case 33:
5032
5192
  if (this.schedule) {
5033
- _context52.next = 36;
5193
+ _context54.next = 36;
5034
5194
  break;
5035
5195
  }
5036
5196
  this.logError('computeProductQueryResult: Schedule 模块未注册');
5037
- return _context52.abrupt("return", {
5197
+ return _context54.abrupt("return", {
5038
5198
  message: 'Schedule 模块未注册',
5039
5199
  data: {
5040
5200
  list: [],
@@ -5065,10 +5225,10 @@ var Server = /*#__PURE__*/function () {
5065
5225
  });
5066
5226
  tPrice = performance.now();
5067
5227
  if (!(scopedProductIds.length > 0)) {
5068
- _context52.next = 49;
5228
+ _context54.next = 49;
5069
5229
  break;
5070
5230
  }
5071
- _context52.next = 46;
5231
+ _context54.next = 46;
5072
5232
  return this.products.getProductsWithPrice(schedule_date, {
5073
5233
  scheduleModule: this.getSchedule(),
5074
5234
  schedule_datetime: schedule_datetime,
@@ -5078,13 +5238,13 @@ var Server = /*#__PURE__*/function () {
5078
5238
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
5079
5239
  });
5080
5240
  case 46:
5081
- _context52.t0 = _context52.sent;
5082
- _context52.next = 50;
5241
+ _context54.t0 = _context54.sent;
5242
+ _context54.next = 50;
5083
5243
  break;
5084
5244
  case 49:
5085
- _context52.t0 = [];
5245
+ _context54.t0 = [];
5086
5246
  case 50:
5087
- filteredProducts = _context52.t0;
5247
+ filteredProducts = _context54.t0;
5088
5248
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
5089
5249
  count: filteredProducts.length,
5090
5250
  scopedProductCount: scopedProductIds.length
@@ -5117,7 +5277,7 @@ var Server = /*#__PURE__*/function () {
5117
5277
  filteredCount: filteredProducts.length,
5118
5278
  activeMenuCount: activeMenuList.length
5119
5279
  });
5120
- return _context52.abrupt("return", {
5280
+ return _context54.abrupt("return", {
5121
5281
  code: 200,
5122
5282
  data: {
5123
5283
  list: filteredProducts,
@@ -5128,11 +5288,11 @@ var Server = /*#__PURE__*/function () {
5128
5288
  });
5129
5289
  case 62:
5130
5290
  case "end":
5131
- return _context52.stop();
5291
+ return _context54.stop();
5132
5292
  }
5133
- }, _callee52, this);
5293
+ }, _callee54, this);
5134
5294
  }));
5135
- function computeProductQueryResult(_x55, _x56) {
5295
+ function computeProductQueryResult(_x57, _x58) {
5136
5296
  return _computeProductQueryResult.apply(this, arguments);
5137
5297
  }
5138
5298
  return computeProductQueryResult;
@@ -5147,72 +5307,72 @@ var Server = /*#__PURE__*/function () {
5147
5307
  }, {
5148
5308
  key: "recomputeAndNotifyProductQuery",
5149
5309
  value: (function () {
5150
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(options) {
5310
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(options) {
5151
5311
  var _iterator17, _step17, _step17$value, subscriberId, subscriber, result, errorMessage;
5152
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5153
- while (1) switch (_context53.prev = _context53.next) {
5312
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5313
+ while (1) switch (_context55.prev = _context55.next) {
5154
5314
  case 0:
5155
5315
  if (!(this.productQuerySubscribers.size === 0)) {
5156
- _context53.next = 2;
5316
+ _context55.next = 2;
5157
5317
  break;
5158
5318
  }
5159
- return _context53.abrupt("return");
5319
+ return _context55.abrupt("return");
5160
5320
  case 2:
5161
5321
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
5162
5322
  subscriberCount: this.productQuerySubscribers.size,
5163
5323
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5164
5324
  });
5165
5325
  _iterator17 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
5166
- _context53.prev = 4;
5326
+ _context55.prev = 4;
5167
5327
  _iterator17.s();
5168
5328
  case 6:
5169
5329
  if ((_step17 = _iterator17.n()).done) {
5170
- _context53.next = 22;
5330
+ _context55.next = 22;
5171
5331
  break;
5172
5332
  }
5173
5333
  _step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], subscriber = _step17$value[1];
5174
- _context53.prev = 8;
5175
- _context53.next = 11;
5334
+ _context55.prev = 8;
5335
+ _context55.next = 11;
5176
5336
  return this.computeProductQueryResult(subscriber.context, {
5177
5337
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5178
5338
  });
5179
5339
  case 11:
5180
- result = _context53.sent;
5340
+ result = _context55.sent;
5181
5341
  subscriber.callback(result);
5182
5342
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
5183
5343
  subscriberId: subscriberId
5184
5344
  });
5185
- _context53.next = 20;
5345
+ _context55.next = 20;
5186
5346
  break;
5187
5347
  case 16:
5188
- _context53.prev = 16;
5189
- _context53.t0 = _context53["catch"](8);
5190
- errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
5348
+ _context55.prev = 16;
5349
+ _context55.t0 = _context55["catch"](8);
5350
+ errorMessage = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
5191
5351
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
5192
5352
  subscriberId: subscriberId,
5193
5353
  error: errorMessage
5194
5354
  });
5195
5355
  case 20:
5196
- _context53.next = 6;
5356
+ _context55.next = 6;
5197
5357
  break;
5198
5358
  case 22:
5199
- _context53.next = 27;
5359
+ _context55.next = 27;
5200
5360
  break;
5201
5361
  case 24:
5202
- _context53.prev = 24;
5203
- _context53.t1 = _context53["catch"](4);
5204
- _iterator17.e(_context53.t1);
5362
+ _context55.prev = 24;
5363
+ _context55.t1 = _context55["catch"](4);
5364
+ _iterator17.e(_context55.t1);
5205
5365
  case 27:
5206
- _context53.prev = 27;
5366
+ _context55.prev = 27;
5207
5367
  _iterator17.f();
5208
- return _context53.finish(27);
5368
+ return _context55.finish(27);
5209
5369
  case 30:
5210
5370
  case "end":
5211
- return _context53.stop();
5371
+ return _context55.stop();
5212
5372
  }
5213
- }, _callee53, this, [[4, 24, 27, 30], [8, 16]]);
5373
+ }, _callee55, this, [[4, 24, 27, 30], [8, 16]]);
5214
5374
  }));
5215
- function recomputeAndNotifyProductQuery(_x57) {
5375
+ function recomputeAndNotifyProductQuery(_x59) {
5216
5376
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
5217
5377
  }
5218
5378
  return recomputeAndNotifyProductQuery;
@@ -5224,16 +5384,16 @@ var Server = /*#__PURE__*/function () {
5224
5384
  }, {
5225
5385
  key: "recomputeAndNotifyOrderQuery",
5226
5386
  value: (function () {
5227
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5387
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5228
5388
  var notifyStartAt, _iterator18, _step18, _step18$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
5229
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5230
- while (1) switch (_context54.prev = _context54.next) {
5389
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5390
+ while (1) switch (_context56.prev = _context56.next) {
5231
5391
  case 0:
5232
5392
  if (!(this.orderQuerySubscribers.size === 0)) {
5233
- _context54.next = 2;
5393
+ _context56.next = 2;
5234
5394
  break;
5235
5395
  }
5236
- return _context54.abrupt("return");
5396
+ return _context56.abrupt("return");
5237
5397
  case 2:
5238
5398
  notifyStartAt = Date.now();
5239
5399
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -5241,20 +5401,20 @@ var Server = /*#__PURE__*/function () {
5241
5401
  notifyStartAt: new Date(notifyStartAt).toISOString()
5242
5402
  });
5243
5403
  _iterator18 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
5244
- _context54.prev = 5;
5404
+ _context56.prev = 5;
5245
5405
  _iterator18.s();
5246
5406
  case 7:
5247
5407
  if ((_step18 = _iterator18.n()).done) {
5248
- _context54.next = 27;
5408
+ _context56.next = 27;
5249
5409
  break;
5250
5410
  }
5251
5411
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
5252
- _context54.prev = 9;
5412
+ _context56.prev = 9;
5253
5413
  computeStartAt = Date.now();
5254
- _context54.next = 13;
5414
+ _context56.next = 13;
5255
5415
  return this.computeOrderQueryResult(subscriber.context);
5256
5416
  case 13:
5257
- result = _context54.sent;
5417
+ result = _context56.sent;
5258
5418
  computeEndAt = Date.now();
5259
5419
  callbackStartAt = Date.now();
5260
5420
  subscriber.callback(result);
@@ -5265,30 +5425,30 @@ var Server = /*#__PURE__*/function () {
5265
5425
  callbackDurationMs: callbackEndAt - callbackStartAt,
5266
5426
  totalDurationMs: callbackEndAt - computeStartAt
5267
5427
  });
5268
- _context54.next = 25;
5428
+ _context56.next = 25;
5269
5429
  break;
5270
5430
  case 21:
5271
- _context54.prev = 21;
5272
- _context54.t0 = _context54["catch"](9);
5273
- errorMessage = _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0);
5431
+ _context56.prev = 21;
5432
+ _context56.t0 = _context56["catch"](9);
5433
+ errorMessage = _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0);
5274
5434
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
5275
5435
  subscriberId: subscriberId,
5276
5436
  error: errorMessage
5277
5437
  });
5278
5438
  case 25:
5279
- _context54.next = 7;
5439
+ _context56.next = 7;
5280
5440
  break;
5281
5441
  case 27:
5282
- _context54.next = 32;
5442
+ _context56.next = 32;
5283
5443
  break;
5284
5444
  case 29:
5285
- _context54.prev = 29;
5286
- _context54.t1 = _context54["catch"](5);
5287
- _iterator18.e(_context54.t1);
5445
+ _context56.prev = 29;
5446
+ _context56.t1 = _context56["catch"](5);
5447
+ _iterator18.e(_context56.t1);
5288
5448
  case 32:
5289
- _context54.prev = 32;
5449
+ _context56.prev = 32;
5290
5450
  _iterator18.f();
5291
- return _context54.finish(32);
5451
+ return _context56.finish(32);
5292
5452
  case 35:
5293
5453
  notifyEndAt = Date.now();
5294
5454
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -5297,9 +5457,9 @@ var Server = /*#__PURE__*/function () {
5297
5457
  });
5298
5458
  case 37:
5299
5459
  case "end":
5300
- return _context54.stop();
5460
+ return _context56.stop();
5301
5461
  }
5302
- }, _callee54, this, [[5, 29, 32, 35], [9, 21]]);
5462
+ }, _callee56, this, [[5, 29, 32, 35], [9, 21]]);
5303
5463
  }));
5304
5464
  function recomputeAndNotifyOrderQuery() {
5305
5465
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -5437,67 +5597,67 @@ var Server = /*#__PURE__*/function () {
5437
5597
  }, {
5438
5598
  key: "recomputeAndNotifyBookingQuery",
5439
5599
  value: (function () {
5440
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5600
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5441
5601
  var _iterator20, _step20, _step20$value, subscriberId, subscriber, result, errorMessage;
5442
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5443
- while (1) switch (_context55.prev = _context55.next) {
5602
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5603
+ while (1) switch (_context57.prev = _context57.next) {
5444
5604
  case 0:
5445
5605
  if (!(this.bookingQuerySubscribers.size === 0)) {
5446
- _context55.next = 2;
5606
+ _context57.next = 2;
5447
5607
  break;
5448
5608
  }
5449
- return _context55.abrupt("return");
5609
+ return _context57.abrupt("return");
5450
5610
  case 2:
5451
5611
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
5452
5612
  subscriberCount: this.bookingQuerySubscribers.size
5453
5613
  });
5454
5614
  _iterator20 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
5455
- _context55.prev = 4;
5615
+ _context57.prev = 4;
5456
5616
  _iterator20.s();
5457
5617
  case 6:
5458
5618
  if ((_step20 = _iterator20.n()).done) {
5459
- _context55.next = 22;
5619
+ _context57.next = 22;
5460
5620
  break;
5461
5621
  }
5462
5622
  _step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
5463
- _context55.prev = 8;
5464
- _context55.next = 11;
5623
+ _context57.prev = 8;
5624
+ _context57.next = 11;
5465
5625
  return this.computeBookingQueryResult(subscriber.context);
5466
5626
  case 11:
5467
- result = _context55.sent;
5627
+ result = _context57.sent;
5468
5628
  subscriber.callback(result);
5469
5629
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
5470
5630
  subscriberId: subscriberId
5471
5631
  });
5472
- _context55.next = 20;
5632
+ _context57.next = 20;
5473
5633
  break;
5474
5634
  case 16:
5475
- _context55.prev = 16;
5476
- _context55.t0 = _context55["catch"](8);
5477
- errorMessage = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
5635
+ _context57.prev = 16;
5636
+ _context57.t0 = _context57["catch"](8);
5637
+ errorMessage = _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0);
5478
5638
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
5479
5639
  subscriberId: subscriberId,
5480
5640
  error: errorMessage
5481
5641
  });
5482
5642
  case 20:
5483
- _context55.next = 6;
5643
+ _context57.next = 6;
5484
5644
  break;
5485
5645
  case 22:
5486
- _context55.next = 27;
5646
+ _context57.next = 27;
5487
5647
  break;
5488
5648
  case 24:
5489
- _context55.prev = 24;
5490
- _context55.t1 = _context55["catch"](4);
5491
- _iterator20.e(_context55.t1);
5649
+ _context57.prev = 24;
5650
+ _context57.t1 = _context57["catch"](4);
5651
+ _iterator20.e(_context57.t1);
5492
5652
  case 27:
5493
- _context55.prev = 27;
5653
+ _context57.prev = 27;
5494
5654
  _iterator20.f();
5495
- return _context55.finish(27);
5655
+ return _context57.finish(27);
5496
5656
  case 30:
5497
5657
  case "end":
5498
- return _context55.stop();
5658
+ return _context57.stop();
5499
5659
  }
5500
- }, _callee55, this, [[4, 24, 27, 30], [8, 16]]);
5660
+ }, _callee57, this, [[4, 24, 27, 30], [8, 16]]);
5501
5661
  }));
5502
5662
  function recomputeAndNotifyBookingQuery() {
5503
5663
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);