@pisell/pisellos 0.0.556 → 0.0.557

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.
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -121,6 +121,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
121
121
  private fetchResourceOccupyDetailsByResourceId;
122
122
  private resolveAdditionalOrderFromOccupyDetail;
123
123
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
124
+ restorePreviousOrderData(): Promise<void>;
124
125
  getAdditionalOrderInfo(): Promise<{
125
126
  orderId: string;
126
127
  orderStatus: 'pending' | 'processing' | 'completed' | 'cancelled';
@@ -32,7 +32,7 @@ import { OrderModule } from "../../modules/Order";
32
32
  import { AccountHooks } from "../../modules/Account/types";
33
33
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
34
34
  import Decimal from 'decimal.js';
35
- import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
35
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, findReservationRuleProductByResourceId, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
36
36
  import { createModule } from "../BookingByStep/types";
37
37
  import { ProductList } from "../../modules/ProductList";
38
38
  import { ScheduleModule } from "../../modules/Schedule";
@@ -2687,8 +2687,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2687
2687
  _occupyDetail$form_re2,
2688
2688
  _this$otherParams14,
2689
2689
  _this$store$order6,
2690
- _this$store$order8,
2691
- _this$store$order8$ge,
2690
+ _this$store$order7,
2691
+ _this$store$order7$ge,
2692
2692
  _this$otherParams15,
2693
2693
  businessCode,
2694
2694
  channel,
@@ -2713,6 +2713,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2713
2713
  scheduleDate,
2714
2714
  scheduleDatetime,
2715
2715
  loaded,
2716
+ matchedRuleProduct,
2717
+ ruleProductsForResource,
2716
2718
  occupancyMinutes,
2717
2719
  paxBounds,
2718
2720
  error,
@@ -2728,10 +2730,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2728
2730
  additionalOrderId,
2729
2731
  availabilityInfo,
2730
2732
  isAdditionalOrderMode,
2731
- _this$store$order7,
2732
- _res$data,
2733
- res,
2734
- entryPaxNumber,
2735
2733
  lastOrderInfo,
2736
2734
  historicalItems,
2737
2735
  _args37 = arguments;
@@ -2863,14 +2861,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2863
2861
  case 46:
2864
2862
  loaded = _context37.sent;
2865
2863
  if (Array.isArray(loaded)) {
2866
- this.enabledReservationRuleProducts = loaded;
2867
- occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2864
+ matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
2865
+ ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
2866
+ this.enabledReservationRuleProducts = ruleProductsForResource;
2867
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(ruleProductsForResource);
2868
2868
  if (occupancyMinutes !== undefined) {
2869
2869
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
2870
2870
  }
2871
- if (hasCustomCapacityProduct(loaded)) {
2871
+ if (hasCustomCapacityProduct(ruleProductsForResource)) {
2872
2872
  pendingRequestEntryPax = 1;
2873
- paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2873
+ paxBounds = pickFirstCustomCapacityPaxBounds(ruleProductsForResource);
2874
2874
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
2875
2875
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
2876
2876
  }
@@ -2977,27 +2977,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2977
2977
  if (isAdditionalOrderMode) {
2978
2978
  tempOrder.order_id = additionalOrderId;
2979
2979
  }
2980
- if (!tempOrder.order_id) {
2981
- _context37.next = 86;
2982
- break;
2983
- }
2984
- _context37.next = 81;
2985
- return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2986
- case 81:
2987
- res = _context37.sent;
2988
- // 找到下单的时候输入的 entryPaxNumber
2989
- entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
2990
- var _p$metadata;
2991
- return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2992
- })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2993
- if (!entryPaxNumber) {
2994
- _context37.next = 86;
2995
- break;
2996
- }
2997
- _context37.next = 86;
2998
- return this.setEntryPaxNumber(entryPaxNumber);
2999
- case 86:
3000
- lastOrderInfo = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ge = _this$store$order8.getLastOrderInfo) === null || _this$store$order8$ge === void 0 ? void 0 : _this$store$order8$ge.call(_this$store$order8);
2980
+ lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
3001
2981
  historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
3002
2982
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
3003
2983
  acc.push(_objectSpread({
@@ -3008,13 +2988,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3008
2988
  } : {}));
3009
2989
  return acc;
3010
2990
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
3011
- _context37.next = 90;
2991
+ _context37.next = 82;
3012
2992
  return this.setItemRuleRuntimeConfig({
3013
2993
  serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
3014
2994
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
3015
2995
  historicalItems: historicalItems
3016
2996
  });
3017
- case 90:
2997
+ case 82:
3018
2998
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
3019
2999
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
3020
3000
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -3036,31 +3016,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3036
3016
  isFull: resourceState.isFull
3037
3017
  });
3038
3018
  return _context37.abrupt("return", availabilityInfo);
3039
- case 95:
3040
- _context37.prev = 95;
3019
+ case 87:
3020
+ _context37.prev = 87;
3041
3021
  _context37.t0 = _context37["catch"](3);
3042
3022
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3043
3023
  resourceId: normalizedResourceId
3044
3024
  });
3045
3025
  throw _context37.t0;
3046
- case 99:
3026
+ case 91:
3047
3027
  case "end":
3048
3028
  return _context37.stop();
3049
3029
  }
3050
- }, _callee37, this, [[3, 95]]);
3030
+ }, _callee37, this, [[3, 87]]);
3051
3031
  }));
3052
3032
  function checkResourceAvailable(_x19) {
3053
3033
  return _checkResourceAvailable.apply(this, arguments);
3054
3034
  }
3055
3035
  return checkResourceAvailable;
3036
+ }() // 恢复之前订单的数据,读取 entrypax
3037
+ }, {
3038
+ key: "restorePreviousOrderData",
3039
+ value: function () {
3040
+ var _restorePreviousOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3041
+ var tempOrder, _this$store$order8, _res$data, res, entryPaxNumber;
3042
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3043
+ while (1) switch (_context38.prev = _context38.next) {
3044
+ case 0:
3045
+ tempOrder = this.ensureTempOrder();
3046
+ if (!tempOrder.order_id) {
3047
+ _context38.next = 9;
3048
+ break;
3049
+ }
3050
+ _context38.next = 4;
3051
+ return (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderInfoByRemote(tempOrder.order_id);
3052
+ case 4:
3053
+ res = _context38.sent;
3054
+ // 找到下单的时候输入的 entryPaxNumber
3055
+ entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
3056
+ var _p$metadata;
3057
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
3058
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
3059
+ if (!entryPaxNumber) {
3060
+ _context38.next = 9;
3061
+ break;
3062
+ }
3063
+ _context38.next = 9;
3064
+ return this.setEntryPaxNumber(entryPaxNumber);
3065
+ case 9:
3066
+ case "end":
3067
+ return _context38.stop();
3068
+ }
3069
+ }, _callee38, this);
3070
+ }));
3071
+ function restorePreviousOrderData() {
3072
+ return _restorePreviousOrderData.apply(this, arguments);
3073
+ }
3074
+ return restorePreviousOrderData;
3056
3075
  }() // 如果是加单的情况,提供返回当前订单相关信息的能力
3057
3076
  }, {
3058
3077
  key: "getAdditionalOrderInfo",
3059
3078
  value: function () {
3060
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3079
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3061
3080
  var result;
3062
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3063
- while (1) switch (_context38.prev = _context38.next) {
3081
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3082
+ while (1) switch (_context39.prev = _context39.next) {
3064
3083
  case 0:
3065
3084
  this.logMethodStart('getAdditionalOrderInfo');
3066
3085
  result = {
@@ -3074,12 +3093,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3074
3093
  orderId: result.orderId,
3075
3094
  orderStatus: result.orderStatus
3076
3095
  });
3077
- return _context38.abrupt("return", result);
3096
+ return _context39.abrupt("return", result);
3078
3097
  case 4:
3079
3098
  case "end":
3080
- return _context38.stop();
3099
+ return _context39.stop();
3081
3100
  }
3082
- }, _callee38, this);
3101
+ }, _callee39, this);
3083
3102
  }));
3084
3103
  function getAdditionalOrderInfo() {
3085
3104
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -3089,25 +3108,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3089
3108
  }, {
3090
3109
  key: "getProductList",
3091
3110
  value: function () {
3092
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3111
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3093
3112
  var _this$otherParams16;
3094
3113
  var menu_list_ids, res, productList, formattedRes;
3095
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3096
- while (1) switch (_context39.prev = _context39.next) {
3114
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3115
+ while (1) switch (_context40.prev = _context40.next) {
3097
3116
  case 0:
3098
3117
  this.logMethodStart('getProductList');
3099
3118
  // 可以直接通过配置里的 menu 读取
3100
3119
  menu_list_ids = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16 = _this$otherParams16.dineInConfig) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16['menu.associated_menus'].map(function (n) {
3101
3120
  return Number(n.value);
3102
3121
  })) || [];
3103
- _context39.prev = 2;
3122
+ _context40.prev = 2;
3104
3123
  if (this.store.products) {
3105
- _context39.next = 5;
3124
+ _context40.next = 5;
3106
3125
  break;
3107
3126
  }
3108
3127
  throw new Error('products 模块未初始化');
3109
3128
  case 5:
3110
- _context39.next = 7;
3129
+ _context40.next = 7;
3111
3130
  return this.store.products.loadProducts({
3112
3131
  menu_list_ids: menu_list_ids,
3113
3132
  cacheId: this.cacheId,
@@ -3115,7 +3134,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3115
3134
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3116
3135
  });
3117
3136
  case 7:
3118
- res = _context39.sent;
3137
+ res = _context40.sent;
3119
3138
  productList = this.assertProductListLoaded('getProductList', res, {
3120
3139
  menu_list_ids: menu_list_ids,
3121
3140
  cacheId: this.cacheId
@@ -3124,22 +3143,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3124
3143
  this.logMethodSuccess('getProductList', {
3125
3144
  menuCount: menu_list_ids.length
3126
3145
  });
3127
- return _context39.abrupt("return", formattedRes);
3146
+ return _context40.abrupt("return", formattedRes);
3128
3147
  case 14:
3129
- _context39.prev = 14;
3130
- _context39.t0 = _context39["catch"](2);
3131
- if (!(_context39.t0 !== null && _context39.t0 !== void 0 && _context39.t0.__scanOrderLogged)) {
3132
- this.logMethodError('getProductList', _context39.t0, {
3148
+ _context40.prev = 14;
3149
+ _context40.t0 = _context40["catch"](2);
3150
+ if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
3151
+ this.logMethodError('getProductList', _context40.t0, {
3133
3152
  menu_list_ids: menu_list_ids,
3134
3153
  cacheId: this.cacheId
3135
3154
  });
3136
3155
  }
3137
- throw _context39.t0;
3156
+ throw _context40.t0;
3138
3157
  case 18:
3139
3158
  case "end":
3140
- return _context39.stop();
3159
+ return _context40.stop();
3141
3160
  }
3142
- }, _callee39, this, [[2, 14]]);
3161
+ }, _callee40, this, [[2, 14]]);
3143
3162
  }));
3144
3163
  function getProductList() {
3145
3164
  return _getProductList.apply(this, arguments);
@@ -3154,15 +3173,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3154
3173
  }, {
3155
3174
  key: "setOtherParams",
3156
3175
  value: function () {
3157
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3176
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3158
3177
  var _ref9,
3159
3178
  _ref9$cover,
3160
3179
  cover,
3161
- _args40 = arguments;
3162
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3163
- while (1) switch (_context40.prev = _context40.next) {
3180
+ _args41 = arguments;
3181
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3182
+ while (1) switch (_context41.prev = _context41.next) {
3164
3183
  case 0:
3165
- _ref9 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3184
+ _ref9 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3166
3185
  if (cover) {
3167
3186
  this.otherParams = params;
3168
3187
  } else {
@@ -3170,9 +3189,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3170
3189
  }
3171
3190
  case 2:
3172
3191
  case "end":
3173
- return _context40.stop();
3192
+ return _context41.stop();
3174
3193
  }
3175
- }, _callee40, this);
3194
+ }, _callee41, this);
3176
3195
  }));
3177
3196
  function setOtherParams(_x20) {
3178
3197
  return _setOtherParams.apply(this, arguments);
@@ -3264,10 +3283,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3264
3283
  }, {
3265
3284
  key: "setEntryPaxNumber",
3266
3285
  value: function () {
3267
- var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(number) {
3286
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(number) {
3268
3287
  var pax, t;
3269
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3270
- while (1) switch (_context41.prev = _context41.next) {
3288
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3289
+ while (1) switch (_context42.prev = _context42.next) {
3271
3290
  case 0:
3272
3291
  pax = normalizeSubmitCollectPaxValue(number);
3273
3292
  this.store.entryPaxNumber = pax;
@@ -3288,16 +3307,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3288
3307
  }
3289
3308
  });
3290
3309
  this.itemRulePrefillApplied = false;
3291
- _context41.next = 7;
3310
+ _context42.next = 7;
3292
3311
  return this.refreshItemRuleQuantityLimits();
3293
3312
  case 7:
3294
- _context41.next = 9;
3313
+ _context42.next = 9;
3295
3314
  return this.refreshCartValidationPassed();
3296
3315
  case 9:
3297
3316
  case "end":
3298
- return _context41.stop();
3317
+ return _context42.stop();
3299
3318
  }
3300
- }, _callee41, this);
3319
+ }, _callee42, this);
3301
3320
  }));
3302
3321
  function setEntryPaxNumber(_x21) {
3303
3322
  return _setEntryPaxNumber.apply(this, arguments);
@@ -3312,11 +3331,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3312
3331
  }, {
3313
3332
  key: "syncAdditionalOrderFromResource",
3314
3333
  value: function () {
3315
- var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
3334
+ var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3316
3335
  var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
3317
3336
  var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3318
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3319
- while (1) switch (_context42.prev = _context42.next) {
3337
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3338
+ while (1) switch (_context43.prev = _context43.next) {
3320
3339
  case 0:
3321
3340
  tempOrder = this.ensureTempOrder();
3322
3341
  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();
@@ -3324,7 +3343,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3324
3343
  resourceId: normalizedResourceId
3325
3344
  });
3326
3345
  if (normalizedResourceId) {
3327
- _context42.next = 7;
3346
+ _context43.next = 7;
3328
3347
  break;
3329
3348
  }
3330
3349
  _result = {
@@ -3332,18 +3351,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3332
3351
  reason: 'missing_resource_id'
3333
3352
  };
3334
3353
  this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
3335
- return _context42.abrupt("return", _result);
3354
+ return _context43.abrupt("return", _result);
3336
3355
  case 7:
3337
- _context42.next = 9;
3356
+ _context43.next = 9;
3338
3357
  return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
3339
3358
  case 9:
3340
- occupyDetails = _context42.sent;
3359
+ occupyDetails = _context43.sent;
3341
3360
  occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3342
3361
  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));
3343
3362
  allowAddItems = toBoolean((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['sale.allow_add_items']);
3344
3363
  result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3345
3364
  if (!(!result.matched || !result.order_id)) {
3346
- _context42.next = 17;
3365
+ _context43.next = 17;
3347
3366
  break;
3348
3367
  }
3349
3368
  this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
@@ -3351,7 +3370,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3351
3370
  resourceSelectType: resourceSelectType,
3352
3371
  allowAddItems: allowAddItems
3353
3372
  }));
3354
- return _context42.abrupt("return", result);
3373
+ return _context43.abrupt("return", result);
3355
3374
  case 17:
3356
3375
  tempOrder.order_id = result.order_id;
3357
3376
  tempOrder.resource_id = normalizedResourceId;
@@ -3363,12 +3382,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3363
3382
  resourceSelectType: resourceSelectType,
3364
3383
  allowAddItems: allowAddItems
3365
3384
  }));
3366
- return _context42.abrupt("return", result);
3385
+ return _context43.abrupt("return", result);
3367
3386
  case 24:
3368
3387
  case "end":
3369
- return _context42.stop();
3388
+ return _context43.stop();
3370
3389
  }
3371
- }, _callee42, this);
3390
+ }, _callee43, this);
3372
3391
  }));
3373
3392
  function syncAdditionalOrderFromResource(_x22) {
3374
3393
  return _syncAdditionalOrderFromResource.apply(this, arguments);
@@ -134,6 +134,11 @@ export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderPro
134
134
  * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
135
135
  */
136
136
  export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
137
+ /**
138
+ * 找到第一个归属指定桌台的预约规则商品。
139
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
140
+ */
141
+ export declare function findReservationRuleProductByResourceId(products: ProductData[], resourceId: string | number | null | undefined): ProductData | undefined;
137
142
  /**
138
143
  * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
139
144
  */
@@ -629,23 +629,55 @@ export function collectLinkProductIdsFromReservationRules(rules) {
629
629
  }
630
630
 
631
631
  /**
632
- * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
632
+ * 找到第一个归属指定桌台的预约规则商品。
633
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
633
634
  */
634
- export function pickFirstDurationMinutesFromProducts(products) {
635
+ export function findReservationRuleProductByResourceId(products, resourceId) {
636
+ var numericResourceId = Number(resourceId);
637
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0) return undefined;
635
638
  var _iterator7 = _createForOfIteratorHelper(products),
636
639
  _step7;
637
640
  try {
638
641
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
639
- var _product$duration;
642
+ var _product$product_reso;
640
643
  var product = _step7.value;
644
+ var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
645
+ if (!Array.isArray(resources)) continue;
646
+ var hasMatchedResource = resources.some(function (resource) {
647
+ var defaultResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.default_resource) ? resource.default_resource : [];
648
+ var optionalResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
649
+ return [].concat(_toConsumableArray(defaultResources), _toConsumableArray(optionalResources)).some(function (id) {
650
+ return Number(id) === numericResourceId;
651
+ });
652
+ });
653
+ if (hasMatchedResource) return product;
654
+ }
655
+ } catch (err) {
656
+ _iterator7.e(err);
657
+ } finally {
658
+ _iterator7.f();
659
+ }
660
+ return undefined;
661
+ }
662
+
663
+ /**
664
+ * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
665
+ */
666
+ export function pickFirstDurationMinutesFromProducts(products) {
667
+ var _iterator8 = _createForOfIteratorHelper(products),
668
+ _step8;
669
+ try {
670
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
671
+ var _product$duration;
672
+ var product = _step8.value;
641
673
  var value = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.value;
642
674
  var n = Number(value);
643
675
  if (Number.isFinite(n) && n > 0) return Math.floor(n);
644
676
  }
645
677
  } catch (err) {
646
- _iterator7.e(err);
678
+ _iterator8.e(err);
647
679
  } finally {
648
- _iterator7.f();
680
+ _iterator8.f();
649
681
  }
650
682
  return undefined;
651
683
  }
@@ -675,11 +707,11 @@ export function computeResourceIsFull(params) {
675
707
  if (!Number.isFinite(totalCapacity) || totalCapacity <= 0) return false;
676
708
  var now = dayjs();
677
709
  var occupied = 0;
678
- var _iterator8 = _createForOfIteratorHelper(capacityList || []),
679
- _step8;
710
+ var _iterator9 = _createForOfIteratorHelper(capacityList || []),
711
+ _step9;
680
712
  try {
681
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
682
- var slot = _step8.value;
713
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
714
+ var slot = _step9.value;
683
715
  var start = dayjs(slot === null || slot === void 0 ? void 0 : slot.start_at);
684
716
  var end = dayjs(slot === null || slot === void 0 ? void 0 : slot.end_at);
685
717
  if (!start.isValid() || !end.isValid()) continue;
@@ -689,9 +721,9 @@ export function computeResourceIsFull(params) {
689
721
  }
690
722
  }
691
723
  } catch (err) {
692
- _iterator8.e(err);
724
+ _iterator9.e(err);
693
725
  } finally {
694
- _iterator8.f();
726
+ _iterator9.f();
695
727
  }
696
728
  return occupied >= totalCapacity;
697
729
  }
@@ -701,11 +733,11 @@ export function computeResourceIsFull(params) {
701
733
  * 仅返回有限数字字段;若均无法解析则返回 `undefined`。
702
734
  */
703
735
  export function pickFirstCustomCapacityPaxBounds(products) {
704
- var _iterator9 = _createForOfIteratorHelper(products),
705
- _step9;
736
+ var _iterator10 = _createForOfIteratorHelper(products),
737
+ _step10;
706
738
  try {
707
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
708
- var p = _step9.value;
739
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
740
+ var p = _step10.value;
709
741
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
710
742
  if (!cap || cap.type !== 'custom') continue;
711
743
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -724,9 +756,9 @@ export function pickFirstCustomCapacityPaxBounds(products) {
724
756
  if (out.min !== undefined || out.max !== undefined) return out;
725
757
  }
726
758
  } catch (err) {
727
- _iterator9.e(err);
759
+ _iterator10.e(err);
728
760
  } finally {
729
- _iterator9.f();
761
+ _iterator10.f();
730
762
  }
731
763
  return undefined;
732
764
  }
@@ -736,11 +768,11 @@ export function pickFirstCustomCapacityPaxBounds(products) {
736
768
  * 无匹配时返回 `undefined`,调用方应回退为 `0`。
737
769
  */
738
770
  export function pickFirstCustomCapacityDimensionId(products) {
739
- var _iterator10 = _createForOfIteratorHelper(products),
740
- _step10;
771
+ var _iterator11 = _createForOfIteratorHelper(products),
772
+ _step11;
741
773
  try {
742
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
743
- var p = _step10.value;
774
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
775
+ var p = _step11.value;
744
776
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
745
777
  if (!cap || cap.type !== 'custom') continue;
746
778
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -756,9 +788,9 @@ export function pickFirstCustomCapacityDimensionId(products) {
756
788
  }
757
789
  }
758
790
  } catch (err) {
759
- _iterator10.e(err);
791
+ _iterator11.e(err);
760
792
  } finally {
761
- _iterator10.f();
793
+ _iterator11.f();
762
794
  }
763
795
  return undefined;
764
796
  }
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -121,6 +121,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
121
121
  private fetchResourceOccupyDetailsByResourceId;
122
122
  private resolveAdditionalOrderFromOccupyDetail;
123
123
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
124
+ restorePreviousOrderData(): Promise<void>;
124
125
  getAdditionalOrderInfo(): Promise<{
125
126
  orderId: string;
126
127
  orderStatus: 'pending' | 'processing' | 'completed' | 'cancelled';
@@ -1601,7 +1601,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1601
1601
  // 通过 resource_id + 店铺配置
1602
1602
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1603
1603
  async checkResourceAvailable(resourceId, hasOrderId = false) {
1604
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1604
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1605
1605
  const normalizedResourceId = String(resourceId ?? "").trim();
1606
1606
  this.logMethodStart("checkResourceAvailable", {
1607
1607
  resourceId: normalizedResourceId
@@ -1693,14 +1693,19 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1693
1693
  cacheId: this.cacheId
1694
1694
  });
1695
1695
  if (Array.isArray(loaded)) {
1696
- this.enabledReservationRuleProducts = loaded;
1697
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1696
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1697
+ loaded,
1698
+ normalizedResourceId
1699
+ );
1700
+ const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1701
+ this.enabledReservationRuleProducts = ruleProductsForResource;
1702
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1698
1703
  if (occupancyMinutes !== void 0) {
1699
1704
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1700
1705
  }
1701
- if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1706
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1702
1707
  pendingRequestEntryPax = 1;
1703
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1708
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1704
1709
  if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1705
1710
  pendingRequestPaxMin = paxBounds.min;
1706
1711
  if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
@@ -1799,17 +1804,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1799
1804
  if (isAdditionalOrderMode) {
1800
1805
  tempOrder.order_id = additionalOrderId;
1801
1806
  }
1802
- if (tempOrder.order_id) {
1803
- const res = await ((_j = this.store.order) == null ? void 0 : _j.getOrderInfoByRemote(tempOrder.order_id));
1804
- const entryPaxNumber = (_n = (_m = (_l = (_k = res == null ? void 0 : res.data) == null ? void 0 : _k.bookings) == null ? void 0 : _l.find((p) => {
1805
- var _a2;
1806
- return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1807
- })) == null ? void 0 : _m.metadata) == null ? void 0 : _n.collect_pax;
1808
- if (entryPaxNumber) {
1809
- await this.setEntryPaxNumber(entryPaxNumber);
1810
- }
1811
- }
1812
- const lastOrderInfo = (_p = (_o = this.store.order) == null ? void 0 : _o.getLastOrderInfo) == null ? void 0 : _p.call(_o);
1807
+ const lastOrderInfo = (_k = (_j = this.store.order) == null ? void 0 : _j.getLastOrderInfo) == null ? void 0 : _k.call(_j);
1813
1808
  const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1814
1809
  if (typeof (p == null ? void 0 : p.product_id) !== "number")
1815
1810
  return acc;
@@ -1821,7 +1816,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1821
1816
  return acc;
1822
1817
  }, []) : [];
1823
1818
  await this.setItemRuleRuntimeConfig({
1824
- serviceType: (_q = this.otherParams) == null ? void 0 : _q.businessCode,
1819
+ serviceType: (_l = this.otherParams) == null ? void 0 : _l.businessCode,
1825
1820
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
1826
1821
  historicalItems
1827
1822
  });
@@ -1851,6 +1846,21 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1851
1846
  throw error;
1852
1847
  }
1853
1848
  }
1849
+ // 恢复之前订单的数据,读取 entrypax
1850
+ async restorePreviousOrderData() {
1851
+ var _a, _b, _c, _d, _e;
1852
+ const tempOrder = this.ensureTempOrder();
1853
+ if (tempOrder.order_id) {
1854
+ const res = await ((_a = this.store.order) == null ? void 0 : _a.getOrderInfoByRemote(tempOrder.order_id));
1855
+ const entryPaxNumber = (_e = (_d = (_c = (_b = res == null ? void 0 : res.data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.find((p) => {
1856
+ var _a2;
1857
+ return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1858
+ })) == null ? void 0 : _d.metadata) == null ? void 0 : _e.collect_pax;
1859
+ if (entryPaxNumber) {
1860
+ await this.setEntryPaxNumber(entryPaxNumber);
1861
+ }
1862
+ }
1863
+ }
1854
1864
  // 如果是加单的情况,提供返回当前订单相关信息的能力
1855
1865
  async getAdditionalOrderInfo() {
1856
1866
  this.logMethodStart("getAdditionalOrderInfo");
@@ -134,6 +134,11 @@ export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderPro
134
134
  * 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
135
135
  */
136
136
  export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
137
+ /**
138
+ * 找到第一个归属指定桌台的预约规则商品。
139
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
140
+ */
141
+ export declare function findReservationRuleProductByResourceId(products: ProductData[], resourceId: string | number | null | undefined): ProductData | undefined;
137
142
  /**
138
143
  * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
139
144
  */
@@ -39,6 +39,7 @@ __export(utils_exports, {
39
39
  computeResourceIsFull: () => computeResourceIsFull,
40
40
  createEmptySummary: () => createEmptySummary,
41
41
  extractStrategyModelIdsFromTableConfig: () => extractStrategyModelIdsFromTableConfig,
42
+ findReservationRuleProductByResourceId: () => findReservationRuleProductByResourceId,
42
43
  getProductIdentityIndex: () => getProductIdentityIndex,
43
44
  getSafeProductNum: () => getSafeProductNum,
44
45
  getTopLevelProductId: () => getTopLevelProductId,
@@ -510,6 +511,27 @@ function collectLinkProductIdsFromReservationRules(rules) {
510
511
  }
511
512
  return [...new Set(ids)];
512
513
  }
514
+ function findReservationRuleProductByResourceId(products, resourceId) {
515
+ var _a;
516
+ const numericResourceId = Number(resourceId);
517
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0)
518
+ return void 0;
519
+ for (const product of products) {
520
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
521
+ if (!Array.isArray(resources))
522
+ continue;
523
+ const hasMatchedResource = resources.some((resource) => {
524
+ const defaultResources = Array.isArray(resource == null ? void 0 : resource.default_resource) ? resource.default_resource : [];
525
+ const optionalResources = Array.isArray(resource == null ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
526
+ return [...defaultResources, ...optionalResources].some(
527
+ (id) => Number(id) === numericResourceId
528
+ );
529
+ });
530
+ if (hasMatchedResource)
531
+ return product;
532
+ }
533
+ return void 0;
534
+ }
513
535
  function pickFirstDurationMinutesFromProducts(products) {
514
536
  var _a;
515
537
  for (const product of products) {
@@ -613,6 +635,7 @@ function pickFirstCustomCapacityDimensionId(products) {
613
635
  computeResourceIsFull,
614
636
  createEmptySummary,
615
637
  extractStrategyModelIdsFromTableConfig,
638
+ findReservationRuleProductByResourceId,
616
639
  getProductIdentityIndex,
617
640
  getSafeProductNum,
618
641
  getTopLevelProductId,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.556",
4
+ "version": "0.0.557",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",