@pisell/pisellos 2.3.58 → 2.3.60

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 (33) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -66
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/Quotation/index.d.ts +6 -0
  5. package/dist/modules/Quotation/index.js +75 -19
  6. package/dist/plugins/request.d.ts +1 -0
  7. package/dist/server/index.d.ts +15 -2
  8. package/dist/server/index.js +222 -147
  9. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  10. package/dist/server/modules/floor-plan/index.js +240 -98
  11. package/dist/server/modules/menu/index.js +48 -23
  12. package/dist/server/modules/order/index.d.ts +12 -7
  13. package/dist/server/modules/order/index.js +248 -96
  14. package/dist/server/modules/products/index.d.ts +8 -2
  15. package/dist/server/modules/products/index.js +167 -75
  16. package/dist/server/modules/resource/index.js +21 -13
  17. package/lib/core/index.d.ts +7 -0
  18. package/lib/core/index.js +20 -3
  19. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  20. package/lib/modules/Quotation/index.d.ts +6 -0
  21. package/lib/modules/Quotation/index.js +49 -5
  22. package/lib/plugins/request.d.ts +1 -0
  23. package/lib/server/index.d.ts +15 -2
  24. package/lib/server/index.js +87 -23
  25. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  26. package/lib/server/modules/floor-plan/index.js +54 -6
  27. package/lib/server/modules/menu/index.js +31 -5
  28. package/lib/server/modules/order/index.d.ts +12 -7
  29. package/lib/server/modules/order/index.js +143 -28
  30. package/lib/server/modules/products/index.d.ts +8 -2
  31. package/lib/server/modules/products/index.js +97 -24
  32. package/lib/server/modules/resource/index.js +7 -2
  33. package/package.json +1 -1
@@ -33,6 +33,7 @@ import { FloorPlanModule } from "./modules/floor-plan";
33
33
  import { FloorPlanHooks } from "./modules/floor-plan/types";
34
34
  import { PaymentServerModule } from "./modules/payment";
35
35
  import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
36
+ import { sortTimePoints } from "./utils/time";
36
37
  import { ProductsHooks } from "./modules/products/types";
37
38
  import { perfMark } from "./utils/product";
38
39
  import { OrderModule } from "./modules/order";
@@ -58,6 +59,7 @@ import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPending
58
59
  /** 平面图 GET 查询订阅者(列表 / id 详情 / code 详情) */
59
60
 
60
61
  var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', 'kitchen', 'original'];
62
+ var AUTO_PRINT_STORAGE_KEY = 'auto_print';
61
63
 
62
64
  /**
63
65
  * Server 类
@@ -336,7 +338,11 @@ var Server = /*#__PURE__*/function () {
336
338
  case 9:
337
339
  result = _context3.sent;
338
340
  if (subscriberId && typeof callback === 'function') {
339
- _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
341
+ _this.syncProductQueryScheduleTimers({
342
+ subscriberId: subscriberId,
343
+ menu_list_ids: menu_list_ids,
344
+ strategy_context: strategy_context
345
+ });
340
346
  }
341
347
  return _context3.abrupt("return", result);
342
348
  case 12:
@@ -1679,7 +1685,7 @@ var Server = /*#__PURE__*/function () {
1679
1685
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1680
1686
  var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
1681
1687
  var _menu_list_ids$length;
1682
- var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1688
+ var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1683
1689
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1684
1690
  while (1) switch (_context24.prev = _context24.next) {
1685
1691
  case 0:
@@ -1735,8 +1741,7 @@ var Server = /*#__PURE__*/function () {
1735
1741
  });
1736
1742
  case 16:
1737
1743
  _context24.prev = 16;
1738
- // 1. 获取餐牌列表
1739
- menuList = _this.menu.getMenuByIds(menu_list_ids);
1744
+ _this$getMenuSchedule = _this.getMenuScheduleTimePoints(menu_list_ids), menuList = _this$getMenuSchedule.menuList, scheduleIds = _this$getMenuSchedule.scheduleIds, scheduleList = _this$getMenuSchedule.scheduleList, timePoints = _this$getMenuSchedule.timePoints;
1740
1745
  console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
1741
1746
  _this.logInfo('handleGetScheduleTimePoints: 获取到餐牌列表', {
1742
1747
  requestedCount: menu_list_ids.length,
@@ -1744,15 +1749,12 @@ var Server = /*#__PURE__*/function () {
1744
1749
  menu_list_ids: menu_list_ids,
1745
1750
  menuList: menuList
1746
1751
  });
1747
-
1748
- // 2. 提取所有的 schedule IDs
1749
- scheduleIds = extractScheduleIdsFromMenus(menuList);
1750
1752
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
1751
1753
  _this.logInfo('handleGetScheduleTimePoints: 提取到日程 IDs', {
1752
1754
  scheduleCount: scheduleIds.length
1753
1755
  });
1754
1756
  if (!(scheduleIds.length === 0)) {
1755
- _context24.next = 26;
1757
+ _context24.next = 25;
1756
1758
  break;
1757
1759
  }
1758
1760
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
@@ -1764,17 +1766,12 @@ var Server = /*#__PURE__*/function () {
1764
1766
  data: [],
1765
1767
  status: true
1766
1768
  });
1767
- case 26:
1768
- // 3. 获取日程详情
1769
- scheduleList = _this.schedule.getScheduleByIds(scheduleIds);
1769
+ case 25:
1770
1770
  console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
1771
1771
  _this.logInfo('handleGetScheduleTimePoints: 获取到日程详情', {
1772
1772
  requestedCount: scheduleIds.length,
1773
1773
  foundCount: scheduleList.length
1774
1774
  });
1775
-
1776
- // 4. 提取时间点
1777
- timePoints = extractTimePointsFromSchedules(scheduleList);
1778
1775
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
1779
1776
  _this.logInfo('handleGetScheduleTimePoints 处理完成', {
1780
1777
  menuListIdsCount: menu_list_ids.length,
@@ -1788,8 +1785,8 @@ var Server = /*#__PURE__*/function () {
1788
1785
  data: timePoints,
1789
1786
  status: true
1790
1787
  });
1791
- case 35:
1792
- _context24.prev = 35;
1788
+ case 32:
1789
+ _context24.prev = 32;
1793
1790
  _context24.t0 = _context24["catch"](16);
1794
1791
  errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : '未知错误';
1795
1792
  console.error('[Server] 获取日程时间点失败:', _context24.t0);
@@ -1803,11 +1800,11 @@ var Server = /*#__PURE__*/function () {
1803
1800
  data: [],
1804
1801
  status: false
1805
1802
  });
1806
- case 41:
1803
+ case 38:
1807
1804
  case "end":
1808
1805
  return _context24.stop();
1809
1806
  }
1810
- }, _callee24, null, [[16, 35]]);
1807
+ }, _callee24, null, [[16, 32]]);
1811
1808
  }));
1812
1809
  return function (_x24) {
1813
1810
  return _ref59.apply(this, arguments);
@@ -2720,6 +2717,7 @@ var Server = /*#__PURE__*/function () {
2720
2717
  key: "setupProductsQuotationPriceBridge",
2721
2718
  value: (function () {
2722
2719
  var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2720
+ var _this5 = this;
2723
2721
  var _this$core$context, errorMessage;
2724
2722
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2725
2723
  while (1) switch (_context33.prev = _context33.next) {
@@ -2739,31 +2737,42 @@ var Server = /*#__PURE__*/function () {
2739
2737
  return _context33.abrupt("return");
2740
2738
  case 6:
2741
2739
  _context33.prev = 6;
2742
- _context33.next = 9;
2743
- return this.schedule.loadAllSchedule();
2744
- case 9:
2745
2740
  this.products.clearPriceCache();
2746
- _context33.next = 12;
2741
+ _context33.next = 10;
2747
2742
  return this.products.setupQuotationPriceBridge({
2748
2743
  scheduleModule: this.schedule,
2749
- channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
2744
+ channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
2745
+ onQuotationUpdated: function onQuotationUpdated() {
2746
+ void _this5.recomputeAndNotifyProductQuery();
2747
+ }
2748
+ });
2749
+ case 10:
2750
+ // Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
2751
+ // 远端刷新转为后台校准,避免二次启动重复阻塞请求。
2752
+ void this.schedule.loadAllSchedule().then(function () {
2753
+ var _this5$products;
2754
+ (_this5$products = _this5.products) === null || _this5$products === void 0 || _this5$products.clearPriceCache();
2755
+ void _this5.recomputeAndNotifyProductQuery();
2756
+ }).catch(function (error) {
2757
+ _this5.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
2758
+ error: error instanceof Error ? error.message : String(error)
2759
+ });
2750
2760
  });
2751
- case 12:
2752
2761
  this.logInfo('Products 报价单价格桥接初始化完成');
2753
- _context33.next = 19;
2762
+ _context33.next = 18;
2754
2763
  break;
2755
- case 15:
2756
- _context33.prev = 15;
2764
+ case 14:
2765
+ _context33.prev = 14;
2757
2766
  _context33.t0 = _context33["catch"](6);
2758
2767
  errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
2759
2768
  this.logError('Products 报价单价格桥接初始化失败', {
2760
2769
  error: errorMessage
2761
2770
  });
2762
- case 19:
2771
+ case 18:
2763
2772
  case "end":
2764
2773
  return _context33.stop();
2765
2774
  }
2766
- }, _callee33, this, [[6, 15]]);
2775
+ }, _callee33, this, [[6, 14]]);
2767
2776
  }));
2768
2777
  function setupProductsQuotationPriceBridge() {
2769
2778
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -2833,44 +2842,58 @@ var Server = /*#__PURE__*/function () {
2833
2842
  key: "refreshProductsInBackground",
2834
2843
  value: (function () {
2835
2844
  var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2836
- var startTime, duration, _duration2, errorMessage;
2845
+ var options,
2846
+ trigger,
2847
+ startTime,
2848
+ duration,
2849
+ _duration2,
2850
+ errorMessage,
2851
+ _args34 = arguments;
2837
2852
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2838
2853
  while (1) switch (_context34.prev = _context34.next) {
2839
2854
  case 0:
2855
+ options = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
2840
2856
  if (this.products) {
2841
- _context34.next = 3;
2857
+ _context34.next = 4;
2842
2858
  break;
2843
2859
  }
2844
2860
  this.logWarning('refreshProductsInBackground: Products 模块未注册');
2845
2861
  return _context34.abrupt("return");
2846
- case 3:
2847
- this.logInfo('refreshProductsInBackground 开始');
2862
+ case 4:
2863
+ trigger = options.trigger || 'background';
2864
+ this.logInfo('refreshProductsInBackground 开始', {
2865
+ trigger: trigger
2866
+ });
2848
2867
  startTime = Date.now();
2849
- _context34.prev = 5;
2850
- _context34.next = 8;
2851
- return this.products.silentRefresh();
2852
- case 8:
2868
+ _context34.prev = 7;
2869
+ _context34.next = 10;
2870
+ return this.products.silentRefresh({
2871
+ trigger: trigger
2872
+ });
2873
+ case 10:
2853
2874
  duration = Date.now() - startTime;
2854
2875
  this.logInfo('refreshProductsInBackground 完成', {
2876
+ trigger: trigger,
2855
2877
  duration: "".concat(duration, "ms")
2856
2878
  });
2857
- _context34.next = 18;
2879
+ _context34.next = 20;
2858
2880
  break;
2859
- case 12:
2860
- _context34.prev = 12;
2861
- _context34.t0 = _context34["catch"](5);
2881
+ case 14:
2882
+ _context34.prev = 14;
2883
+ _context34.t0 = _context34["catch"](7);
2862
2884
  _duration2 = Date.now() - startTime;
2863
2885
  errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
2864
2886
  console.error('[Server] refreshProductsInBackground 失败:', _context34.t0);
2865
2887
  this.logError('refreshProductsInBackground 失败', {
2888
+ trigger: trigger,
2866
2889
  duration: "".concat(_duration2, "ms"),
2867
2890
  error: errorMessage
2868
2891
  });
2869
- case 18:
2892
+ case 20:
2870
2893
  case "end":
2871
2894
  return _context34.stop();
2872
2895
  }
2873
- }, _callee34, this, [[5, 12]]);
2896
+ }, _callee34, this, [[7, 14]]);
2874
2897
  }));
2875
2898
  function refreshProductsInBackground() {
2876
2899
  return _refreshProductsInBackground.apply(this, arguments);
@@ -2887,44 +2910,58 @@ var Server = /*#__PURE__*/function () {
2887
2910
  key: "refreshOrdersInBackground",
2888
2911
  value: (function () {
2889
2912
  var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2890
- var startTime, duration, _duration3, errorMessage;
2913
+ var options,
2914
+ trigger,
2915
+ startTime,
2916
+ duration,
2917
+ _duration3,
2918
+ errorMessage,
2919
+ _args35 = arguments;
2891
2920
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2892
2921
  while (1) switch (_context35.prev = _context35.next) {
2893
2922
  case 0:
2923
+ options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
2894
2924
  if (this.order) {
2895
- _context35.next = 3;
2925
+ _context35.next = 4;
2896
2926
  break;
2897
2927
  }
2898
2928
  this.logWarning('refreshOrdersInBackground: Order 模块未注册');
2899
2929
  return _context35.abrupt("return");
2900
- case 3:
2901
- this.logInfo('refreshOrdersInBackground 开始');
2930
+ case 4:
2931
+ trigger = options.trigger || 'background';
2932
+ this.logInfo('refreshOrdersInBackground 开始', {
2933
+ trigger: trigger
2934
+ });
2902
2935
  startTime = Date.now();
2903
- _context35.prev = 5;
2904
- _context35.next = 8;
2905
- return this.order.silentRefresh();
2906
- case 8:
2936
+ _context35.prev = 7;
2937
+ _context35.next = 10;
2938
+ return this.order.silentRefresh({
2939
+ trigger: trigger
2940
+ });
2941
+ case 10:
2907
2942
  duration = Date.now() - startTime;
2908
2943
  this.logInfo('refreshOrdersInBackground 完成', {
2944
+ trigger: trigger,
2909
2945
  duration: "".concat(duration, "ms")
2910
2946
  });
2911
- _context35.next = 18;
2947
+ _context35.next = 20;
2912
2948
  break;
2913
- case 12:
2914
- _context35.prev = 12;
2915
- _context35.t0 = _context35["catch"](5);
2949
+ case 14:
2950
+ _context35.prev = 14;
2951
+ _context35.t0 = _context35["catch"](7);
2916
2952
  _duration3 = Date.now() - startTime;
2917
2953
  errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
2918
2954
  console.error('[Server] refreshOrdersInBackground 失败:', _context35.t0);
2919
2955
  this.logError('refreshOrdersInBackground 失败', {
2956
+ trigger: trigger,
2920
2957
  duration: "".concat(_duration3, "ms"),
2921
2958
  error: errorMessage
2922
2959
  });
2923
- case 18:
2960
+ case 20:
2924
2961
  case "end":
2925
2962
  return _context35.stop();
2926
2963
  }
2927
- }, _callee35, this, [[5, 12]]);
2964
+ }, _callee35, this, [[7, 14]]);
2928
2965
  }));
2929
2966
  function refreshOrdersInBackground() {
2930
2967
  return _refreshOrdersInBackground.apply(this, arguments);
@@ -3238,10 +3275,10 @@ var Server = /*#__PURE__*/function () {
3238
3275
  }, {
3239
3276
  key: "getAllRoutes",
3240
3277
  value: function getAllRoutes() {
3241
- var _this5 = this;
3278
+ var _this6 = this;
3242
3279
  var routes = [];
3243
3280
  ['get', 'post', 'put', 'remove'].forEach(function (method) {
3244
- Object.keys(_this5.router[method]).forEach(function (path) {
3281
+ Object.keys(_this6.router[method]).forEach(function (path) {
3245
3282
  routes.push({
3246
3283
  method: method,
3247
3284
  path: path
@@ -3371,7 +3408,7 @@ var Server = /*#__PURE__*/function () {
3371
3408
  key: "getPaymentRouteModule",
3372
3409
  value: function () {
3373
3410
  var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3374
- var _this6 = this;
3411
+ var _this7 = this;
3375
3412
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3376
3413
  while (1) switch (_context40.prev = _context40.next) {
3377
3414
  case 0:
@@ -3400,13 +3437,13 @@ var Server = /*#__PURE__*/function () {
3400
3437
  case 0:
3401
3438
  module = new PaymentServerModule('server_payment_route', '1.0.0');
3402
3439
  _context39.next = 3;
3403
- return module.initialize(_this6.core, {
3440
+ return module.initialize(_this7.core, {
3404
3441
  store: {
3405
3442
  payMethods: []
3406
3443
  }
3407
3444
  });
3408
3445
  case 3:
3409
- _this6.paymentRouteModule = module;
3446
+ _this7.paymentRouteModule = module;
3410
3447
  return _context39.abrupt("return", module);
3411
3448
  case 5:
3412
3449
  case "end":
@@ -3414,7 +3451,7 @@ var Server = /*#__PURE__*/function () {
3414
3451
  }
3415
3452
  }, _callee39);
3416
3453
  }))().finally(function () {
3417
- _this6.paymentRouteModuleInFlight = undefined;
3454
+ _this7.paymentRouteModuleInFlight = undefined;
3418
3455
  });
3419
3456
  return _context40.abrupt("return", this.paymentRouteModuleInFlight);
3420
3457
  case 8:
@@ -3590,7 +3627,7 @@ var Server = /*#__PURE__*/function () {
3590
3627
  }, {
3591
3628
  key: "scheduleSubscriberTimePointReloads",
3592
3629
  value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
3593
- var _this7 = this;
3630
+ var _this8 = this;
3594
3631
  var subscriber = this.productQuerySubscribers.get(subscriberId);
3595
3632
  if (!subscriber || !timePoints.length) return;
3596
3633
  var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
@@ -3611,7 +3648,7 @@ var Server = /*#__PURE__*/function () {
3611
3648
  setInterval(function () {
3612
3649
  var currentTime = dayjs().format('hh:mm');
3613
3650
  if (timePoints.includes(currentTime)) {
3614
- _this7.onScheduleTimePointTimerFire(subscriberId);
3651
+ _this8.onScheduleTimePointTimerFire(subscriberId);
3615
3652
  }
3616
3653
  }, 60000);
3617
3654
  if (timerIds.length > 0) {
@@ -3709,18 +3746,48 @@ var Server = /*#__PURE__*/function () {
3709
3746
  return recomputeAndNotifySubscriber;
3710
3747
  }()
3711
3748
  /**
3712
- * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3749
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
3750
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
3713
3751
  */
3714
3752
  )
3753
+ }, {
3754
+ key: "getMenuScheduleTimePoints",
3755
+ value: function getMenuScheduleTimePoints(menuListIds) {
3756
+ var _this$menu$getMenuByI, _this$menu, _this$schedule$getSch, _this$schedule;
3757
+ var menuList = (_this$menu$getMenuByI = (_this$menu = this.menu) === null || _this$menu === void 0 ? void 0 : _this$menu.getMenuByIds(menuListIds)) !== null && _this$menu$getMenuByI !== void 0 ? _this$menu$getMenuByI : [];
3758
+ var scheduleIds = extractScheduleIdsFromMenus(menuList);
3759
+ var scheduleList = scheduleIds.length > 0 ? (_this$schedule$getSch = (_this$schedule = this.schedule) === null || _this$schedule === void 0 ? void 0 : _this$schedule.getScheduleByIds(scheduleIds)) !== null && _this$schedule$getSch !== void 0 ? _this$schedule$getSch : [] : [];
3760
+ var timePoints = extractTimePointsFromSchedules(scheduleList);
3761
+ return {
3762
+ menuList: menuList,
3763
+ scheduleIds: scheduleIds,
3764
+ scheduleList: scheduleList,
3765
+ timePoints: timePoints
3766
+ };
3767
+ }
3768
+
3769
+ /**
3770
+ * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3771
+ */
3715
3772
  }, {
3716
3773
  key: "syncProductQueryScheduleTimers",
3717
- value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3774
+ value: function syncProductQueryScheduleTimers(_ref61) {
3718
3775
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
3776
+ var subscriberId = _ref61.subscriberId,
3777
+ menu_list_ids = _ref61.menu_list_ids,
3778
+ strategy_context = _ref61.strategy_context;
3719
3779
  this.clearSubscriberScheduleTimers(subscriberId);
3720
3780
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3721
3781
  return;
3722
3782
  }
3723
- var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3783
+ var productTimePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3784
+ var menuListIds = Array.isArray(menu_list_ids) ? Array.from(new Set(menu_list_ids.map(function (id) {
3785
+ return Number(id);
3786
+ }).filter(function (id) {
3787
+ return Number.isFinite(id);
3788
+ }))) : [];
3789
+ var menuTimePoints = this.getMenuScheduleTimePoints(menuListIds).timePoints;
3790
+ var timePoints = sortTimePoints(Array.from(new Set([].concat(_toConsumableArray(productTimePoints), _toConsumableArray(menuTimePoints)))));
3724
3791
  if (timePoints.length > 0) {
3725
3792
  this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3726
3793
  }
@@ -3750,7 +3817,7 @@ var Server = /*#__PURE__*/function () {
3750
3817
  key: "refreshMenuScheduleCacheAfterEmptyResult",
3751
3818
  value: (function () {
3752
3819
  var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3753
- var _this8 = this;
3820
+ var _this9 = this;
3754
3821
  var now;
3755
3822
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3756
3823
  while (1) switch (_context44.prev = _context44.next) {
@@ -3773,11 +3840,11 @@ var Server = /*#__PURE__*/function () {
3773
3840
  this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
3774
3841
  return undefined;
3775
3842
  }).catch(function (error) {
3776
- _this8.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3843
+ _this9.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
3777
3844
  error: error instanceof Error ? error.message : String(error)
3778
3845
  });
3779
3846
  }).finally(function () {
3780
- _this8.menuScheduleRefreshInFlight = null;
3847
+ _this9.menuScheduleRefreshInFlight = null;
3781
3848
  });
3782
3849
  }
3783
3850
  _context44.next = 8;
@@ -3807,7 +3874,7 @@ var Server = /*#__PURE__*/function () {
3807
3874
  */
3808
3875
  function () {
3809
3876
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3810
- var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3877
+ var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3811
3878
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3812
3879
  while (1) switch (_context45.prev = _context45.next) {
3813
3880
  case 0:
@@ -3816,7 +3883,7 @@ var Server = /*#__PURE__*/function () {
3816
3883
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3817
3884
  case 3:
3818
3885
  result = _context45.sent;
3819
- _ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
3886
+ _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3820
3887
  if (subscriberId && typeof callback === 'function') {
3821
3888
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3822
3889
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -3963,10 +4030,10 @@ var Server = /*#__PURE__*/function () {
3963
4030
  }, {
3964
4031
  key: "stripSalesSearchPageParams",
3965
4032
  value: function stripSalesSearchPageParams(value) {
3966
- var _this9 = this;
4033
+ var _this10 = this;
3967
4034
  if (Array.isArray(value)) {
3968
4035
  return value.map(function (item) {
3969
- return _this9.stripSalesSearchPageParams(item);
4036
+ return _this10.stripSalesSearchPageParams(item);
3970
4037
  });
3971
4038
  }
3972
4039
  if (!value || _typeof(value) !== 'object') return value;
@@ -4004,12 +4071,12 @@ var Server = /*#__PURE__*/function () {
4004
4071
  key: "extractSalesSearchOrderIds",
4005
4072
  value: function extractSalesSearchOrderIds(kind, result) {
4006
4073
  var _this$findSalesSearch,
4007
- _this10 = this;
4074
+ _this11 = this;
4008
4075
  var data = this.extractSalesSearchResponseData(result);
4009
4076
  var list = kind === 'aggregate' ? (_this$findSalesSearch = this.findSalesSearchAggregateGroup(data)) === null || _this$findSalesSearch === void 0 ? void 0 : _this$findSalesSearch.list : data === null || data === void 0 ? void 0 : data.list;
4010
4077
  if (!Array.isArray(list)) return [];
4011
4078
  return list.map(function (item) {
4012
- return _this10.getSalesSearchOrderId(item);
4079
+ return _this11.getSalesSearchOrderId(item);
4013
4080
  }).filter(function (id) {
4014
4081
  return !!id;
4015
4082
  });
@@ -4176,11 +4243,11 @@ var Server = /*#__PURE__*/function () {
4176
4243
  }, {
4177
4244
  key: "stableSerialize",
4178
4245
  value: function stableSerialize(value) {
4179
- var _this11 = this;
4246
+ var _this12 = this;
4180
4247
  if (value === null || value === undefined) return 'null';
4181
4248
  if (Array.isArray(value)) {
4182
4249
  return "[".concat(value.map(function (item) {
4183
- return _this11.stableSerialize(item);
4250
+ return _this12.stableSerialize(item);
4184
4251
  }).join(','), "]");
4185
4252
  }
4186
4253
  if (_typeof(value) === 'object') {
@@ -4189,7 +4256,7 @@ var Server = /*#__PURE__*/function () {
4189
4256
  return obj[k] !== undefined;
4190
4257
  }).sort();
4191
4258
  return "{".concat(keys.map(function (k) {
4192
- return "".concat(JSON.stringify(k), ":").concat(_this11.stableSerialize(obj[k]));
4259
+ return "".concat(JSON.stringify(k), ":").concat(_this12.stableSerialize(obj[k]));
4193
4260
  }).join(','), "}");
4194
4261
  }
4195
4262
  return JSON.stringify(value);
@@ -4729,7 +4796,7 @@ var Server = /*#__PURE__*/function () {
4729
4796
  key: "runLocalPaymentUpdateInQueue",
4730
4797
  value: function () {
4731
4798
  var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
4732
- var _this12 = this;
4799
+ var _this13 = this;
4733
4800
  var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
4734
4801
  return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4735
4802
  while (1) switch (_context50.prev = _context50.next) {
@@ -4748,7 +4815,7 @@ var Server = /*#__PURE__*/function () {
4748
4815
  return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4749
4816
  while (1) switch (_context49.prev = _context49.next) {
4750
4817
  case 0:
4751
- _this12.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4818
+ _this13.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
4752
4819
  queue_key: key,
4753
4820
  queue_wait_ms: Date.now() - queuedAt
4754
4821
  }));
@@ -5874,7 +5941,7 @@ var Server = /*#__PURE__*/function () {
5874
5941
  key: "handleOrderCheckoutSubmit",
5875
5942
  value: function () {
5876
5943
  var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5877
- var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
5944
+ var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
5878
5945
  return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5879
5946
  while (1) switch (_context60.prev = _context60.next) {
5880
5947
  case 0:
@@ -5913,35 +5980,33 @@ var Server = /*#__PURE__*/function () {
5913
5980
  case 12:
5914
5981
  pendingResult = _context60.sent;
5915
5982
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5916
- _context60.next = 22;
5983
+ _context60.next = 20;
5917
5984
  break;
5918
5985
  }
5919
5986
  pendingOrder = pendingResult.data;
5920
- platform = (_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 ? void 0 : _this$core$context2.getPlatform();
5921
- isAndroid = platform === 'android';
5922
- if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
5923
- // TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
5924
- isAndroid ? checkoutData.type === 'virtual' : true))) {
5925
- _context60.next = 20;
5987
+ if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
5988
+ _context60.next = 18;
5926
5989
  break;
5927
5990
  }
5928
- _context60.next = 20;
5991
+ _context60.next = 18;
5929
5992
  return this.dispatchLocalReceiptPrint({
5930
5993
  checkoutData: checkoutData,
5931
5994
  order: pendingOrder,
5932
5995
  response: pendingResult,
5933
- requireFullyPaid: true
5996
+ requireFullyPaid: true,
5997
+ // 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
5998
+ isManualPrint: true
5934
5999
  });
5935
- case 20:
5936
- _context60.next = 22;
6000
+ case 18:
6001
+ _context60.next = 20;
5937
6002
  return this.dispatchCheckoutSyncTask({
5938
6003
  backendPath: backendPath,
5939
6004
  data: checkoutData,
5940
6005
  title: title
5941
6006
  });
5942
- case 22:
6007
+ case 20:
5943
6008
  if (pendingResult.data.order_id) {
5944
- _context60.next = 24;
6009
+ _context60.next = 22;
5945
6010
  break;
5946
6011
  }
5947
6012
  return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
@@ -5949,9 +6014,9 @@ var Server = /*#__PURE__*/function () {
5949
6014
  order_id: pendingResult.data.external_sale_number
5950
6015
  })
5951
6016
  }));
5952
- case 24:
6017
+ case 22:
5953
6018
  return _context60.abrupt("return", pendingResult);
5954
- case 25:
6019
+ case 23:
5955
6020
  case "end":
5956
6021
  return _context60.stop();
5957
6022
  }
@@ -6145,7 +6210,7 @@ var Server = /*#__PURE__*/function () {
6145
6210
  key: "handlePendingSyncCheckoutOrder",
6146
6211
  value: function () {
6147
6212
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6148
- var _this13 = this;
6213
+ var _this14 = this;
6149
6214
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6150
6215
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6151
6216
  while (1) switch (_context63.prev = _context63.next) {
@@ -6198,7 +6263,7 @@ var Server = /*#__PURE__*/function () {
6198
6263
  });
6199
6264
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6200
6265
  var _payment$metadata;
6201
- return sum + _this13.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6266
+ return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6202
6267
  }, 0);
6203
6268
  return _context63.abrupt("return", {
6204
6269
  code: 200,
@@ -6285,13 +6350,23 @@ var Server = /*#__PURE__*/function () {
6285
6350
  }
6286
6351
  return buildPendingSyncCheckoutOrder;
6287
6352
  }()
6353
+ /**
6354
+ * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
6355
+ */
6356
+ }, {
6357
+ key: "shouldAutoPrintCheckoutReceipt",
6358
+ value: function shouldAutoPrintCheckoutReceipt() {
6359
+ var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
6360
+ if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
6361
+ return ((_this$app17 = this.app) === null || _this$app17 === void 0 || (_this$app17 = _this$app17.storage) === null || _this$app17 === void 0 || (_this$app17$getStorag = _this$app17.getStorage) === null || _this$app17$getStorag === void 0 ? void 0 : _this$app17$getStorag.call(_this$app17, AUTO_PRINT_STORAGE_KEY)) === 'true';
6362
+ }
6288
6363
  }, {
6289
6364
  key: "shouldBuildSmallTicketData",
6290
6365
  value: function shouldBuildSmallTicketData(order) {
6291
- var _ref63, _order$small_ticket_d;
6366
+ var _ref64, _order$small_ticket_d;
6292
6367
  if (!order || _typeof(order) !== 'object') return false;
6293
6368
  // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6294
- return Number((_ref63 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref63 !== void 0 ? _ref63 : 0) === 1;
6369
+ return Number((_ref64 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref64 !== void 0 ? _ref64 : 0) === 1;
6295
6370
  }
6296
6371
  }, {
6297
6372
  key: "shouldPrintSyncedOrder",
@@ -6309,7 +6384,7 @@ var Server = /*#__PURE__*/function () {
6309
6384
  }, {
6310
6385
  key: "isSalesOrderFullyPaid",
6311
6386
  value: function isSalesOrderFullyPaid(order) {
6312
- var _order$summary$amount, _order$summary, _ref64, _ref65, _order$summary$expect, _order$summary2, _order$summary3;
6387
+ var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
6313
6388
  if (!order || _typeof(order) !== 'object') return false;
6314
6389
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6315
6390
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6321,20 +6396,20 @@ var Server = /*#__PURE__*/function () {
6321
6396
  return this.toAmountNumber(amountGap) <= 0;
6322
6397
  }
6323
6398
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6324
- var targetAmount = this.toAmountNumber((_ref64 = (_ref65 = (_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 && _ref65 !== void 0 ? _ref65 : order.expect_amount) !== null && _ref64 !== void 0 ? _ref64 : order.total_amount);
6399
+ var targetAmount = this.toAmountNumber((_ref65 = (_ref66 = (_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 && _ref66 !== void 0 ? _ref66 : order.expect_amount) !== null && _ref65 !== void 0 ? _ref65 : order.total_amount);
6325
6400
  if (targetAmount <= 0) return paidAmount > 0;
6326
6401
  return paidAmount >= targetAmount;
6327
6402
  }
6328
6403
  }, {
6329
6404
  key: "sumPaidOrderPayments",
6330
6405
  value: function sumPaidOrderPayments(payments) {
6331
- var _this14 = this;
6406
+ var _this15 = this;
6332
6407
  if (!Array.isArray(payments)) return 0;
6333
6408
  return payments.reduce(function (sum, payment) {
6334
6409
  var _payment$amount;
6335
6410
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6336
6411
  if (status !== 'paid') return sum;
6337
- return sum + _this14.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
6412
+ return sum + _this15.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
6338
6413
  }, 0);
6339
6414
  }
6340
6415
  }, {
@@ -6350,7 +6425,7 @@ var Server = /*#__PURE__*/function () {
6350
6425
  value: function () {
6351
6426
  var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6352
6427
  var _this$products3,
6353
- _this15 = this;
6428
+ _this16 = this;
6354
6429
  var products, productIdSet, productIds, entries;
6355
6430
  return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6356
6431
  while (1) switch (_context66.prev = _context66.next) {
@@ -6365,8 +6440,8 @@ var Server = /*#__PURE__*/function () {
6365
6440
  }
6366
6441
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6367
6442
  product.product_bundle.forEach(function (bundle) {
6368
- var _ref66, _bundle$bundle_produc;
6369
- var bundleProductId = (_ref66 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6443
+ var _ref67, _bundle$bundle_produc;
6444
+ var bundleProductId = (_ref67 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref67 !== void 0 ? _ref67 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6370
6445
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6371
6446
  productIdSet.add(bundleProductId);
6372
6447
  }
@@ -6382,21 +6457,21 @@ var Server = /*#__PURE__*/function () {
6382
6457
  case 6:
6383
6458
  _context66.next = 8;
6384
6459
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6385
- var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6386
- var _this15$products, _this15$products$getP, product;
6460
+ var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6461
+ var _this16$products, _this16$products$getP, product;
6387
6462
  return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6388
6463
  while (1) switch (_context65.prev = _context65.next) {
6389
6464
  case 0:
6390
6465
  _context65.prev = 0;
6391
6466
  _context65.next = 3;
6392
- return (_this15$products = _this15.products) === null || _this15$products === void 0 || (_this15$products$getP = _this15$products.getProductById) === null || _this15$products$getP === void 0 ? void 0 : _this15$products$getP.call(_this15$products, Number(id));
6467
+ return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
6393
6468
  case 3:
6394
6469
  product = _context65.sent;
6395
6470
  return _context65.abrupt("return", product ? [String(id), product] : null);
6396
6471
  case 7:
6397
6472
  _context65.prev = 7;
6398
6473
  _context65.t0 = _context65["catch"](0);
6399
- _this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6474
+ _this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6400
6475
  product_id: id,
6401
6476
  error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6402
6477
  });
@@ -6408,7 +6483,7 @@ var Server = /*#__PURE__*/function () {
6408
6483
  }, _callee65, null, [[0, 7]]);
6409
6484
  }));
6410
6485
  return function (_x73) {
6411
- return _ref67.apply(this, arguments);
6486
+ return _ref68.apply(this, arguments);
6412
6487
  };
6413
6488
  }()));
6414
6489
  case 8:
@@ -6447,8 +6522,8 @@ var Server = /*#__PURE__*/function () {
6447
6522
  addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
6448
6523
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6449
6524
  product.product_bundle.forEach(function (bundle) {
6450
- var _ref68, _bundle$bundle_produc2;
6451
- addProductId((_ref68 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref68 !== void 0 ? _ref68 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6525
+ var _ref69, _bundle$bundle_produc2;
6526
+ addProductId((_ref69 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6452
6527
  });
6453
6528
  }
6454
6529
  });
@@ -6524,9 +6599,9 @@ var Server = /*#__PURE__*/function () {
6524
6599
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
6525
6600
  var hasChanged = false;
6526
6601
  var productBundle = product.product_bundle.map(function (bundle) {
6527
- var _ref69, _bundle$bundle_produc3;
6602
+ var _ref70, _bundle$bundle_produc3;
6528
6603
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
6529
- var rawProductId = (_ref69 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6604
+ var rawProductId = (_ref70 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6530
6605
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
6531
6606
  var productId = Number(rawProductId);
6532
6607
  if (!Number.isFinite(productId)) return bundle;
@@ -6547,7 +6622,7 @@ var Server = /*#__PURE__*/function () {
6547
6622
  key: "withSalesDetailProductSnapshots",
6548
6623
  value: function () {
6549
6624
  var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6550
- var _this16 = this;
6625
+ var _this17 = this;
6551
6626
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6552
6627
  return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6553
6628
  while (1) switch (_context68.prev = _context68.next) {
@@ -6571,8 +6646,8 @@ var Server = /*#__PURE__*/function () {
6571
6646
  case 8:
6572
6647
  hasChanged = false;
6573
6648
  enrichedProducts = products.map(function (product) {
6574
- var productWithBundleSnapshots = _this16.withBundleCatalogSnapshots(product, snapshotMap);
6575
- var nextProduct = _this16.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6649
+ var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
6650
+ var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6576
6651
  if (nextProduct !== product) hasChanged = true;
6577
6652
  return nextProduct;
6578
6653
  });
@@ -6600,13 +6675,13 @@ var Server = /*#__PURE__*/function () {
6600
6675
  }, {
6601
6676
  key: "withPendingSyncProductTitles",
6602
6677
  value: function withPendingSyncProductTitles(order, productMap) {
6603
- var _this17 = this;
6678
+ var _this18 = this;
6604
6679
  var products = Array.isArray(order.products) ? order.products : null;
6605
6680
  if (!(products !== null && products !== void 0 && products.length)) return order;
6606
6681
  return _objectSpread(_objectSpread({}, order), {}, {
6607
6682
  products: products.map(function (product) {
6608
6683
  return _objectSpread(_objectSpread({}, product), {}, {
6609
- product_title: _this17.buildProductTitleSnapshot(product, productMap)
6684
+ product_title: _this18.buildProductTitleSnapshot(product, productMap)
6610
6685
  });
6611
6686
  })
6612
6687
  });
@@ -6617,7 +6692,7 @@ var Server = /*#__PURE__*/function () {
6617
6692
  var _product$product_id4,
6618
6693
  _product$product,
6619
6694
  _fallbackProduct$prod,
6620
- _this18 = this;
6695
+ _this19 = this;
6621
6696
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6622
6697
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6623
6698
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6625,7 +6700,7 @@ var Server = /*#__PURE__*/function () {
6625
6700
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6626
6701
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6627
6702
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6628
- snapshot[key] = _this18.resolveProductTitleValue(ownTitle, key, currentLocale) || _this18.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6703
+ snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6629
6704
  return snapshot;
6630
6705
  }, {});
6631
6706
  }
@@ -6650,7 +6725,7 @@ var Server = /*#__PURE__*/function () {
6650
6725
  }, {
6651
6726
  key: "resolveProductTitleValue",
6652
6727
  value: function resolveProductTitleValue(value, key, currentLocale) {
6653
- var _ref70, _ref71, _value$key;
6728
+ var _ref71, _ref72, _value$key;
6654
6729
  if (value === undefined || value === null || value === '') return null;
6655
6730
  if (_typeof(value) !== 'object') {
6656
6731
  var title = String(value);
@@ -6660,7 +6735,7 @@ var Server = /*#__PURE__*/function () {
6660
6735
  }
6661
6736
  var normalizedKey = key.replace('-', '_');
6662
6737
  var dashedKey = key.replace('_', '-');
6663
- var rawValue = (_ref70 = (_ref71 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref71 !== void 0 ? _ref71 : value[dashedKey]) !== null && _ref70 !== void 0 ? _ref70 : key === 'auto' ? value.default : undefined;
6738
+ var rawValue = (_ref71 = (_ref72 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref72 !== void 0 ? _ref72 : value[dashedKey]) !== null && _ref71 !== void 0 ? _ref71 : key === 'auto' ? value.default : undefined;
6664
6739
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
6665
6740
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
6666
6741
  return String(rawValue);
@@ -6724,14 +6799,14 @@ var Server = /*#__PURE__*/function () {
6724
6799
  key: "enrichPaymentNamesByCode",
6725
6800
  value: function () {
6726
6801
  var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6727
- var _this19 = this;
6802
+ var _this20 = this;
6728
6803
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6729
6804
  return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6730
6805
  while (1) switch (_context69.prev = _context69.next) {
6731
6806
  case 0:
6732
6807
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6733
6808
  hasMissingName = payments.some(function (payment) {
6734
- return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6809
+ return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6735
6810
  });
6736
6811
  if (hasMissingName) {
6737
6812
  _context69.next = 4;
@@ -6764,9 +6839,9 @@ var Server = /*#__PURE__*/function () {
6764
6839
  }
6765
6840
  hasResolvedName = false;
6766
6841
  enrichedPayments = payments.map(function (payment) {
6767
- if (!_this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6768
- if (!_this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6769
- var name = nameByCode.get(_this19.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6842
+ if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6843
+ if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6844
+ var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6770
6845
  if (!name) return payment;
6771
6846
  hasResolvedName = true;
6772
6847
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6925,7 +7000,7 @@ var Server = /*#__PURE__*/function () {
6925
7000
  key: "handleUpdateLocalOrdersBatch",
6926
7001
  value: (function () {
6927
7002
  var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
6928
- var _this$app17;
7003
+ var _this$app18;
6929
7004
  var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6930
7005
  return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6931
7006
  while (1) switch (_context71.prev = _context71.next) {
@@ -6946,7 +7021,7 @@ var Server = /*#__PURE__*/function () {
6946
7021
  data: null
6947
7022
  });
6948
7023
  case 4:
6949
- if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
7024
+ if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
6950
7025
  _context71.next = 7;
6951
7026
  break;
6952
7027
  }
@@ -7348,10 +7423,10 @@ var Server = /*#__PURE__*/function () {
7348
7423
  value: function extractBackendErrorResponse(error) {
7349
7424
  var _error$response3,
7350
7425
  _error$response4,
7351
- _this20 = this;
7426
+ _this21 = this;
7352
7427
  var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
7353
7428
  return candidates.find(function (candidate) {
7354
- return _this20.isExplicitBackendErrorResponse(candidate);
7429
+ return _this21.isExplicitBackendErrorResponse(candidate);
7355
7430
  }) || null;
7356
7431
  }
7357
7432
  }, {
@@ -7712,7 +7787,7 @@ var Server = /*#__PURE__*/function () {
7712
7787
  value: (function () {
7713
7788
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
7714
7789
  var _menu_list_ids$length3,
7715
- _this21 = this;
7790
+ _this22 = this;
7716
7791
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
7717
7792
  return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7718
7793
  while (1) switch (_context75.prev = _context75.next) {
@@ -7911,9 +7986,9 @@ var Server = /*#__PURE__*/function () {
7911
7986
  }
7912
7987
  tMenu = performance.now();
7913
7988
  getActiveMenus = function getActiveMenus() {
7914
- return _this21.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7915
- var _this21$schedule;
7916
- return ((_this21$schedule = _this21.schedule) === null || _this21$schedule === void 0 ? void 0 : _this21$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7989
+ return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7990
+ var _this22$schedule;
7991
+ return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7917
7992
  });
7918
7993
  };
7919
7994
  activeMenuList = getActiveMenus();
@@ -8030,14 +8105,14 @@ var Server = /*#__PURE__*/function () {
8030
8105
  }, {
8031
8106
  key: "buildProductFormatterContext",
8032
8107
  value: function buildProductFormatterContext(context) {
8033
- var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context5;
8108
+ var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context5;
8034
8109
  var scheduleModule = this.getSchedule();
8035
8110
  return {
8036
8111
  scheduleModule: scheduleModule,
8037
8112
  schedule_datetime: context.schedule_datetime,
8038
8113
  customer_id: context.customer_id,
8039
8114
  strategy_context: context.strategy_context,
8040
- menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
8115
+ menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
8041
8116
  scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
8042
8117
  dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
8043
8118
  };
@@ -8222,7 +8297,7 @@ var Server = /*#__PURE__*/function () {
8222
8297
  }, {
8223
8298
  key: "notifySalesSearchSubscribers",
8224
8299
  value: function notifySalesSearchSubscribers(payload) {
8225
- var _this22 = this;
8300
+ var _this23 = this;
8226
8301
  if (this.salesSearchSubscribers.size === 0) return;
8227
8302
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8228
8303
  if (changedOrders.length === 0) {
@@ -8240,21 +8315,21 @@ var Server = /*#__PURE__*/function () {
8240
8315
  subscriber = _step20$value[1];
8241
8316
  try {
8242
8317
  var changedVisibleOrders = changedOrders.filter(function (order) {
8243
- var orderId = _this22.getSalesSearchOrderId(order);
8318
+ var orderId = _this23.getSalesSearchOrderId(order);
8244
8319
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8245
8320
  });
8246
8321
  if (changedVisibleOrders.length === 0) {
8247
8322
  return 1; // continue
8248
8323
  }
8249
- subscriber.callback(_this22.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8250
- _this22.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8324
+ subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8325
+ _this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8251
8326
  subscriberId: subscriberId,
8252
8327
  kind: subscriber.kind,
8253
8328
  count: changedVisibleOrders.length
8254
8329
  });
8255
8330
  } catch (error) {
8256
8331
  var errorMessage = error instanceof Error ? error.message : String(error);
8257
- _this22.logError('notifySalesSearchSubscribers: 推送失败', {
8332
+ _this23.logError('notifySalesSearchSubscribers: 推送失败', {
8258
8333
  subscriberId: subscriberId,
8259
8334
  error: errorMessage
8260
8335
  });