@pisell/pisellos 2.1.174 → 2.1.176

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 (60) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
  4. package/dist/modules/Discount/index.d.ts +3 -6
  5. package/dist/modules/Discount/index.js +23 -125
  6. package/dist/modules/Discount/types.d.ts +5 -34
  7. package/dist/modules/OpenData/types.d.ts +1 -0
  8. package/dist/modules/ProductList/index.js +13 -6
  9. package/dist/modules/Rules/index.d.ts +2 -12
  10. package/dist/modules/Rules/index.js +113 -377
  11. package/dist/modules/Rules/types.d.ts +2 -2
  12. package/dist/plugins/window.d.ts +0 -2
  13. package/dist/solution/BookingByStep/index.d.ts +1 -1
  14. package/dist/solution/ScanOrder/index.d.ts +7 -5
  15. package/dist/solution/ScanOrder/index.js +123 -31
  16. package/dist/solution/ScanOrder/resourceSchedule.d.ts +12 -0
  17. package/dist/solution/ScanOrder/resourceSchedule.js +300 -0
  18. package/dist/solution/ScanOrder/types.d.ts +9 -1
  19. package/dist/solution/ShopDiscount/index.d.ts +0 -3
  20. package/dist/solution/ShopDiscount/index.js +78 -161
  21. package/dist/solution/ShopDiscount/utils.d.ts +0 -1
  22. package/dist/solution/ShopDiscount/utils.js +1 -40
  23. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  24. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -4
  25. package/lib/modules/Discount/index.d.ts +3 -6
  26. package/lib/modules/Discount/index.js +16 -66
  27. package/lib/modules/Discount/types.d.ts +5 -34
  28. package/lib/modules/OpenData/types.d.ts +1 -0
  29. package/lib/modules/ProductList/index.js +8 -1
  30. package/lib/modules/Rules/index.d.ts +2 -12
  31. package/lib/modules/Rules/index.js +69 -303
  32. package/lib/modules/Rules/types.d.ts +2 -2
  33. package/lib/plugins/window.d.ts +0 -2
  34. package/lib/solution/BookingByStep/index.d.ts +1 -1
  35. package/lib/solution/ScanOrder/index.d.ts +7 -5
  36. package/lib/solution/ScanOrder/index.js +90 -12
  37. package/lib/solution/ScanOrder/resourceSchedule.d.ts +12 -0
  38. package/lib/solution/ScanOrder/resourceSchedule.js +272 -0
  39. package/lib/solution/ScanOrder/types.d.ts +9 -1
  40. package/lib/solution/ShopDiscount/index.d.ts +0 -3
  41. package/lib/solution/ShopDiscount/index.js +28 -78
  42. package/lib/solution/ShopDiscount/utils.d.ts +0 -1
  43. package/lib/solution/ShopDiscount/utils.js +1 -42
  44. package/package.json +1 -1
  45. package/dist/modules/Discount/availability.d.ts +0 -7
  46. package/dist/modules/Discount/availability.js +0 -52
  47. package/dist/modules/Discount/entitlementPass.d.ts +0 -34
  48. package/dist/modules/Discount/entitlementPass.js +0 -147
  49. package/dist/modules/Discount/entitlementState.d.ts +0 -8
  50. package/dist/modules/Discount/entitlementState.js +0 -205
  51. package/dist/modules/Rules/entitlementLines.d.ts +0 -8
  52. package/dist/modules/Rules/entitlementLines.js +0 -157
  53. package/lib/modules/Discount/availability.d.ts +0 -7
  54. package/lib/modules/Discount/availability.js +0 -91
  55. package/lib/modules/Discount/entitlementPass.d.ts +0 -34
  56. package/lib/modules/Discount/entitlementPass.js +0 -184
  57. package/lib/modules/Discount/entitlementState.d.ts +0 -8
  58. package/lib/modules/Discount/entitlementState.js +0 -206
  59. package/lib/modules/Rules/entitlementLines.d.ts +0 -8
  60. package/lib/modules/Rules/entitlementLines.js +0 -158
@@ -29,7 +29,7 @@ export interface RulesModuleAPI {
29
29
  discountList: any[];
30
30
  productList: any[];
31
31
  holders: {
32
- form_record_id: number | string;
32
+ form_record_id: number;
33
33
  }[];
34
34
  isFormSubject: boolean;
35
35
  }) => DiscountResult;
@@ -49,7 +49,7 @@ type ProductDetail = {
49
49
  original_price?: number | string;
50
50
  num?: number;
51
51
  quantity: number;
52
- holder_id?: number | string | Array<number | string>;
52
+ holder_id?: number | string;
53
53
  vouchersApplicable?: boolean;
54
54
  startDate?: any;
55
55
  };
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from '../types';
2
- import type { WalletPassEvaluator } from '../model/strategy/adapter/walletPass/evaluator';
3
2
  /**
4
3
  * WindowPlugin 接口定义
5
4
  */
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
15
14
  document: Partial<Document>;
16
15
  history: History;
17
16
  interaction?: any;
18
- getWalletPassEvaluator?: () => WalletPassEvaluator | undefined;
19
17
  getLocalStorage?: (key: string) => string | null;
20
18
  }
21
19
  /**
@@ -325,7 +325,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
325
325
  date: string;
326
326
  status: string;
327
327
  week: string;
328
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
328
+ weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
329
329
  }[]>;
330
330
  submitTimeSlot(timeSlots: TimeSliceItem): void;
331
331
  private getScheduleDataByIds;
@@ -1,6 +1,6 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderAllowAddItemsInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderReservationResourceSelectInfo, ScanOrderScanCodeResult, ScanOrderSyncAdditionalOrderResult, ScanOrderTempOrder } from './types';
3
+ import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderFulfillmentModes, ScanOrderAllowAddItemsInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderReservationResourceSelectInfo, ScanOrderScanCodeResult, ScanOrderSyncAdditionalOrderResult, ScanOrderTempOrder } from './types';
4
4
  import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -75,6 +75,9 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
75
75
  service_type: 'dine_in' | '';
76
76
  pickup_reference_mode: 'counter_pickup' | 'table_service';
77
77
  };
78
+ setFulfillmentMode(mode: string): Record<string, any> & {
79
+ service_type?: string | undefined;
80
+ };
78
81
  setPickupRef(buzzer: string): string;
79
82
  private ensureTempOrder;
80
83
  addNewOrder(): Promise<ScanOrderTempOrder>;
@@ -116,6 +119,8 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
116
119
  private validateBeforeSubmitByItemRule;
117
120
  private refreshCartValidationPassed;
118
121
  setItemRuleRuntimeConfig(config?: ScanOrderItemRuleRuntimeConfig): Promise<void>;
122
+ /** 只根据已加载的桌台和日程计算当前可用性,不改变数据加载与缓存行为。 */
123
+ private checkResourceSchedule;
119
124
  private normalizeResourceState;
120
125
  private resolveResourceSelectType;
121
126
  private fetchResourceOccupyDetailsByResourceId;
@@ -147,10 +152,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
147
152
  syncAdditionalOrderFromResource(resourceId?: string | null): Promise<ScanOrderSyncAdditionalOrderResult>;
148
153
  getReservationResourceSelectType(): ScanOrderReservationResourceSelectInfo;
149
154
  checkAllowAddItems(): ScanOrderAllowAddItemsInfo;
150
- getFulfillmentModes(): {
151
- enablePickup: boolean;
152
- enableTableService: boolean;
153
- };
155
+ getFulfillmentModes(): ScanOrderFulfillmentModes;
154
156
  checkManualPickupRef(): {
155
157
  enabled: boolean;
156
158
  manualInputType?: string;
@@ -38,6 +38,7 @@ import { ProductList } from "../../modules/ProductList";
38
38
  import { ScheduleModule } from "../../modules/Schedule";
39
39
  import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
40
40
  import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
41
+ import { evaluateResourceSchedules } from "./resourceSchedule";
41
42
  import dayjs from 'dayjs';
42
43
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
44
  export * from "./types";
@@ -874,6 +875,44 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
874
875
  }
875
876
  }
876
877
 
878
+ // 新版履约方式直接保存配置值;旧取餐标识方式继续由 setPickupReferenceMode 处理。
879
+ }, {
880
+ key: "setFulfillmentMode",
881
+ value: function setFulfillmentMode(mode) {
882
+ this.logMethodStart('setFulfillmentMode', {
883
+ mode: mode
884
+ });
885
+ try {
886
+ var _this$getFulfillmentM = this.getFulfillmentModes(),
887
+ handoverModes = _this$getFulfillmentM.handoverModes;
888
+ var clearMode = mode === '' && (handoverModes === null || handoverModes === void 0 ? void 0 : handoverModes.length) === 0;
889
+ if (!clearMode && !(handoverModes !== null && handoverModes !== void 0 && handoverModes.includes(mode))) {
890
+ throw new Error('Fulfillment mode is not enabled');
891
+ }
892
+ if (!this.store.order) throw new Error('order 模块未初始化');
893
+ var tempOrder = this.store.order.ensureTempOrder();
894
+ var serviceData = _objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {});
895
+ if (clearMode) {
896
+ delete serviceData.service_type;
897
+ } else {
898
+ serviceData.service_type = mode;
899
+ }
900
+ tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
901
+ shop_service_data: serviceData
902
+ });
903
+ this.store.order.persistTempOrder();
904
+ this.logMethodSuccess('setFulfillmentMode', {
905
+ mode: mode
906
+ });
907
+ return tempOrder.metadata.shop_service_data;
908
+ } catch (error) {
909
+ this.logMethodError('setFulfillmentMode', error, {
910
+ mode: mode
911
+ });
912
+ throw error;
913
+ }
914
+ }
915
+
877
916
  // 存储用户自定义取餐标识到 tempOrder.buzzer
878
917
  }, {
879
918
  key: "setPickupRef",
@@ -1521,7 +1560,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1521
1560
  key: "submitScanOrder",
1522
1561
  value: function () {
1523
1562
  var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1524
- var _this$store$resource, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1563
+ var _this$store$resource, _this$store$resource2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9, _tempOrder$products, scheduleBlocked, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1525
1564
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1526
1565
  while (1) switch (_context18.prev = _context18.next) {
1527
1566
  case 0:
@@ -1536,9 +1575,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1536
1575
  }
1537
1576
  throw new Error('scanOrder解决方案需要 order 模块支持');
1538
1577
  case 6:
1578
+ scheduleBlocked = this.checkResourceSchedule((_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.table_form_record);
1579
+ if (!scheduleBlocked) {
1580
+ _context18.next = 9;
1581
+ break;
1582
+ }
1583
+ throw new Error(scheduleBlocked.errorTips);
1584
+ case 9:
1539
1585
  tempOrderForSubmit = this.store.order.ensureTempOrder();
1540
1586
  tempOrderForSubmit.delivery_type = 'shop_service';
1541
- resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
1587
+ resourceTableName = (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 || (_this$store$resource2 = _this$store$resource2.table_form_record) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.name;
1542
1588
  if (resourceTableName && _typeof(resourceTableName) === 'object') {
1543
1589
  tempOrderForSubmit.table_number = resourceTableName;
1544
1590
  } else {
@@ -1546,7 +1592,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1546
1592
  }
1547
1593
  this.store.order.persistTempOrder();
1548
1594
  enhancePayload = this.buildSubmitPayloadEnhancer();
1549
- _context18.next = 14;
1595
+ _context18.next = 17;
1550
1596
  return this.store.order.submitTempOrder({
1551
1597
  cacheId: this.cacheId,
1552
1598
  platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
@@ -1555,23 +1601,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1555
1601
  type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
1556
1602
  enhancePayload: enhancePayload
1557
1603
  });
1558
- case 14:
1604
+ case 17:
1559
1605
  result = _context18.sent;
1560
1606
  tempOrder = this.store.order.getTempOrder();
1561
1607
  this.logMethodSuccess('submitScanOrder', {
1562
1608
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
1563
1609
  });
1564
1610
  return _context18.abrupt("return", result);
1565
- case 20:
1566
- _context18.prev = 20;
1611
+ case 23:
1612
+ _context18.prev = 23;
1567
1613
  _context18.t0 = _context18["catch"](1);
1568
1614
  this.logMethodError('submitScanOrder', _context18.t0);
1569
1615
  throw _context18.t0;
1570
- case 24:
1616
+ case 27:
1571
1617
  case "end":
1572
1618
  return _context18.stop();
1573
1619
  }
1574
- }, _callee18, this, [[1, 20]]);
1620
+ }, _callee18, this, [[1, 23]]);
1575
1621
  }));
1576
1622
  function submitScanOrder() {
1577
1623
  return _submitScanOrder.apply(this, arguments);
@@ -2478,7 +2524,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2478
2524
  return _setItemRuleRuntimeConfig.apply(this, arguments);
2479
2525
  }
2480
2526
  return setItemRuleRuntimeConfig;
2481
- }()
2527
+ }() /** 只根据已加载的桌台和日程计算当前可用性,不改变数据加载与缓存行为。 */
2528
+ }, {
2529
+ key: "checkResourceSchedule",
2530
+ value: function checkResourceSchedule(formRecord) {
2531
+ var _this$core$getPlugin, _this$store$schedule, _coreState$core, _coreState$core2;
2532
+ var ids = formRecord === null || formRecord === void 0 ? void 0 : formRecord.schedule;
2533
+ if (!Array.isArray(ids) || !ids.length) return null;
2534
+ var coreState = (_this$core$getPlugin = this.core.getPlugin('shopStore')) === null || _this$core$getPlugin === void 0 ? void 0 : _this$core$getPlugin.get('core');
2535
+ var schedules = ((_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 ? void 0 : _this$store$schedule.getScheduleListByIds(ids.map(Number))) || [];
2536
+ var result = evaluateResourceSchedules({
2537
+ schedules: schedules,
2538
+ timeZone: coreState === null || coreState === void 0 || (_coreState$core = coreState.core) === null || _coreState$core === void 0 || (_coreState$core = _coreState$core.shop) === null || _coreState$core === void 0 ? void 0 : _coreState$core.timezone,
2539
+ now: new Date()
2540
+ });
2541
+ if (result.available) return null;
2542
+ var locale = String((coreState === null || coreState === void 0 ? void 0 : coreState.translateLocale) || (coreState === null || coreState === void 0 || (_coreState$core2 = coreState.core) === null || _coreState$core2 === void 0 || (_coreState$core2 = _coreState$core2.shop) === null || _coreState$core2 === void 0 ? void 0 : _coreState$core2.primary_locale) || 'en').toLowerCase();
2543
+ var errorTips = locale === 'zh-hk' || locale === 'zh-tw' ? '目前桌檯不在可用時段,請聯絡工作人員。' : locale.startsWith('zh') ? '当前桌台不在可用时段,请联系工作人员。' : 'This table is outside its available hours. Please contact staff.';
2544
+ return {
2545
+ mode: 'resource_block',
2546
+ table_form_record: formRecord,
2547
+ errorTips: errorTips
2548
+ };
2549
+ }
2482
2550
  }, {
2483
2551
  key: "normalizeResourceState",
2484
2552
  value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
@@ -2721,6 +2789,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2721
2789
  error,
2722
2790
  occupyDetails,
2723
2791
  occupyDetail,
2792
+ scheduleBlocked,
2724
2793
  resourceSelectType,
2725
2794
  allowAddItems,
2726
2795
  additionalOrderResult,
@@ -2892,13 +2961,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2892
2961
  return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2893
2962
  case 50:
2894
2963
  occupyDetails = _context37.sent;
2895
- occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2964
+ occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null;
2965
+ scheduleBlocked = this.checkResourceSchedule(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record);
2966
+ if (!scheduleBlocked) {
2967
+ _context37.next = 55;
2968
+ break;
2969
+ }
2970
+ return _context37.abrupt("return", scheduleBlocked);
2971
+ case 55:
2972
+ // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2896
2973
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2897
2974
  resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
2898
2975
  allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
2899
2976
  additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2900
2977
  if (!(additionalOrderResult.reason === 'multiple_orders')) {
2901
- _context37.next = 61;
2978
+ _context37.next = 64;
2902
2979
  break;
2903
2980
  }
2904
2981
  multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
@@ -2919,7 +2996,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2919
2996
  resourceSelectType: resourceSelectType
2920
2997
  });
2921
2998
  return _context37.abrupt("return", _availabilityInfo);
2922
- case 61:
2999
+ case 64:
2923
3000
  // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2924
3001
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2925
3002
  additionalOrderId = additionalOrderResult.order_id;
@@ -2968,12 +3045,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2968
3045
 
2969
3046
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2970
3047
  if (!(availabilityInfo.mode === 'idle')) {
2971
- _context37.next = 76;
3048
+ _context37.next = 79;
2972
3049
  break;
2973
3050
  }
2974
- _context37.next = 76;
3051
+ _context37.next = 79;
2975
3052
  return this.addNewOrder();
2976
- case 76:
3053
+ case 79:
2977
3054
  isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
2978
3055
  if (isAdditionalOrderMode) {
2979
3056
  tempOrder.order_id = additionalOrderId;
@@ -2989,13 +3066,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2989
3066
  } : {}));
2990
3067
  return acc;
2991
3068
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2992
- _context37.next = 82;
3069
+ _context37.next = 85;
2993
3070
  return this.setItemRuleRuntimeConfig({
2994
3071
  serviceType: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode,
2995
3072
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
2996
3073
  historicalItems: historicalItems
2997
3074
  });
2998
- case 82:
3075
+ case 85:
2999
3076
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
3000
3077
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
3001
3078
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -3017,18 +3094,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3017
3094
  isFull: resourceState.isFull
3018
3095
  });
3019
3096
  return _context37.abrupt("return", availabilityInfo);
3020
- case 87:
3021
- _context37.prev = 87;
3097
+ case 90:
3098
+ _context37.prev = 90;
3022
3099
  _context37.t0 = _context37["catch"](3);
3023
3100
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3024
3101
  resourceId: normalizedResourceId
3025
3102
  });
3026
3103
  throw _context37.t0;
3027
- case 91:
3104
+ case 94:
3028
3105
  case "end":
3029
3106
  return _context37.stop();
3030
3107
  }
3031
- }, _callee37, this, [[3, 87]]);
3108
+ }, _callee37, this, [[3, 90]]);
3032
3109
  }));
3033
3110
  function checkResourceAvailable(_x19) {
3034
3111
  return _checkResourceAvailable.apply(this, arguments);
@@ -3333,13 +3410,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3333
3410
  key: "syncAdditionalOrderFromResource",
3334
3411
  value: function () {
3335
3412
  var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3336
- var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams18, _this$store$order9;
3413
+ var _ref10, _ref11, _ref12, _this$store$resource3, _this$store$resource4, _occupyDetails$2, _this$store$resource5, _this$otherParams18, _this$store$order9;
3337
3414
  var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3338
3415
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3339
3416
  while (1) switch (_context43.prev = _context43.next) {
3340
3417
  case 0:
3341
3418
  tempOrder = this.ensureTempOrder();
3342
- normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
3419
+ normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
3343
3420
  this.logMethodStart('syncAdditionalOrderFromResource', {
3344
3421
  resourceId: normalizedResourceId
3345
3422
  });
@@ -3359,7 +3436,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3359
3436
  case 9:
3360
3437
  occupyDetails = _context43.sent;
3361
3438
  occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3362
- resourceSelectType = ((_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
3439
+ resourceSelectType = ((_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
3363
3440
  allowAddItems = toBoolean((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 || (_this$otherParams18 = _this$otherParams18.dineInConfig) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18['sale.allow_add_items']);
3364
3441
  result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3365
3442
  if (!(!result.matched || !result.order_id)) {
@@ -3399,9 +3476,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3399
3476
  }, {
3400
3477
  key: "getReservationResourceSelectType",
3401
3478
  value: function getReservationResourceSelectType() {
3402
- var _this$store$resource5;
3479
+ var _this$store$resource6;
3403
3480
  this.logMethodStart('getReservationResourceSelectType');
3404
- var resourceSelectType = (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.resourceSelectType;
3481
+ var resourceSelectType = (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.resourceSelectType;
3405
3482
  var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
3406
3483
  resourceSelectType: resourceSelectType
3407
3484
  } : {}), {}, {
@@ -3428,7 +3505,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3428
3505
  return result;
3429
3506
  }
3430
3507
 
3431
- // 读取取餐/送餐开关
3508
+ // 新版履约方式配置存在时优先使用,缺失时保留旧取餐/送餐开关语义。
3432
3509
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3433
3510
  }, {
3434
3511
  key: "getFulfillmentModes",
@@ -3436,10 +3513,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3436
3513
  var _this$otherParams20;
3437
3514
  this.logMethodStart('getFulfillmentModes');
3438
3515
  var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
3439
- var result = {
3440
- enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3441
- enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
3442
- };
3516
+ var configuredModes = dineInConfig['fulfillment.handover_mode'];
3517
+ var result;
3518
+ if (Object.prototype.hasOwnProperty.call(dineInConfig, 'fulfillment.handover_mode')) {
3519
+ var handoverModes = Array.isArray(configuredModes) ? Array.from(new Set(configuredModes.filter(function (mode) {
3520
+ return typeof mode === 'string';
3521
+ }).map(function (mode) {
3522
+ return mode.trim();
3523
+ }).filter(Boolean))) : [];
3524
+ result = {
3525
+ enablePickup: handoverModes.includes('pick_up'),
3526
+ enableTableService: handoverModes.includes('table_service'),
3527
+ handoverModes: handoverModes
3528
+ };
3529
+ } else {
3530
+ result = {
3531
+ enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3532
+ enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
3533
+ };
3534
+ }
3443
3535
  this.logMethodSuccess('getFulfillmentModes', result);
3444
3536
  return result;
3445
3537
  }
@@ -0,0 +1,12 @@
1
+ import type { ScheduleItem } from '../../modules/Schedule/types';
2
+ type Evaluation = {
3
+ available: boolean;
4
+ reason?: 'outside_schedule' | 'invalid_schedule' | 'invalid_timezone';
5
+ };
6
+ /** Current time is projected into the shop's calendar; host timezone is not used. */
7
+ export declare function evaluateResourceSchedules({ schedules, timeZone, now, }: {
8
+ schedules: ScheduleItem[];
9
+ timeZone: string;
10
+ now: Date;
11
+ }): Evaluation;
12
+ export {};