@pisell/pisellos 0.0.330 → 0.0.332

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.
@@ -329,13 +329,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
329
329
  * 参考 addProductToCart 方法的实现
330
330
  */
331
331
  private convertProductToCartItem;
332
- checkMaxDurationCapacityForDetailNums(currentProduct: ProductData): {
332
+ checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
333
+ product: ProductData;
334
+ date?: {
335
+ startTime: string;
336
+ endTime: string;
337
+ } | null;
338
+ account?: Account | null;
339
+ }): {
333
340
  success: boolean;
334
341
  minAvailableCount: number;
335
342
  };
336
343
  setOtherData(key: string, value: any): void;
337
344
  getOtherData(key: string): any;
338
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
345
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
339
346
  /**
340
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
341
348
  *
@@ -30,7 +30,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
30
30
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
31
  import { BaseModule } from "../../modules/BaseModule";
32
32
  import { createModule } from "./types";
33
- import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct } from "../../modules/Cart/utils";
33
+ import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
34
34
  import { getAvailableProductResources } from "./utils/products";
35
35
  import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
36
36
  import dayjs from 'dayjs';
@@ -1195,7 +1195,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1195
1195
  this.addProductCheck({
1196
1196
  date: date
1197
1197
  });
1198
- this.store.cart.addItem(addItemParams);
1198
+ // 如果 quantity 大于 1,则进入购物车拆散成多条数据
1199
+ if (addItemParams.quantity > 1) {
1200
+ for (var i = 0; i < addItemParams.quantity; i++) {
1201
+ var newAddItemParams = cloneDeep(addItemParams);
1202
+ newAddItemParams.quantity = 1;
1203
+ this.store.cart.addItem(newAddItemParams);
1204
+ }
1205
+ } else {
1206
+ this.store.cart.addItem(addItemParams);
1207
+ }
1199
1208
  return {
1200
1209
  success: true
1201
1210
  };
@@ -3048,7 +3057,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3048
3057
  });
3049
3058
 
3050
3059
  // 按资源类型分组检查容量
3051
- if (!checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
3060
+ var _checkTimeSlotCapacit = checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot),
3061
+ success = _checkTimeSlotCapacit.success,
3062
+ required = _checkTimeSlotCapacit.required,
3063
+ available = _checkTimeSlotCapacit.available;
3064
+ if (!success) {
3052
3065
  // 如果有可用数量记录,返回最小值;否则返回 0
3053
3066
  var _minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min.apply(Math, availableCountsByResourceType) : 0;
3054
3067
  return {
@@ -3080,14 +3093,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3080
3093
  */
3081
3094
  }, {
3082
3095
  key: "convertProductToCartItem",
3083
- value: function convertProductToCartItem(product) {
3084
- var _ref11 = product || {},
3085
- bundle = _ref11.bundle,
3086
- options = _ref11.options,
3087
- origin = _ref11.origin,
3088
- product_variant_id = _ref11.product_variant_id,
3089
- _ref11$quantity = _ref11.quantity,
3090
- quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
3096
+ value: function convertProductToCartItem(_ref11) {
3097
+ var product = _ref11.product,
3098
+ date = _ref11.date,
3099
+ account = _ref11.account;
3100
+ var _ref12 = product || {},
3101
+ bundle = _ref12.bundle,
3102
+ options = _ref12.options,
3103
+ origin = _ref12.origin,
3104
+ product_variant_id = _ref12.product_variant_id,
3105
+ _ref12$quantity = _ref12.quantity,
3106
+ quantity = _ref12$quantity === void 0 ? 1 : _ref12$quantity;
3091
3107
 
3092
3108
  // 处理商品数据,类似 addProductToCart 中的逻辑
3093
3109
  var productData = _objectSpread(_objectSpread({}, origin), {}, {
@@ -3097,6 +3113,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3097
3113
  // 处理组合商品
3098
3114
  var processedProduct = handleVariantProduct(productData);
3099
3115
 
3116
+ // 如果没有传入账户,获取当前活跃账户
3117
+ if (!account) {
3118
+ var activeAccount = this.getActiveAccount();
3119
+ if (activeAccount) {
3120
+ account = activeAccount;
3121
+ }
3122
+ }
3123
+
3100
3124
  // 创建基础的 CartItem
3101
3125
  var cartItem = {
3102
3126
  _id: getUniqueId('temp_'),
@@ -3105,9 +3129,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3105
3129
  _productInit: product
3106
3130
  };
3107
3131
 
3108
- // 获取当前活跃账户
3109
- var activeAccount = this.getActiveAccount();
3110
-
3111
3132
  // 使用格式化函数填充 CartItem 数据
3112
3133
  formatProductToCartItem({
3113
3134
  cartItem: cartItem,
@@ -3117,16 +3138,39 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3117
3138
  product_variant_id: product_variant_id,
3118
3139
  quantity: quantity
3119
3140
  });
3141
+
3142
+ // 如果有日期信息,格式化日期到购物车
3143
+ if (date) {
3144
+ formatDateToCartItem({
3145
+ cartItem: cartItem,
3146
+ date: date
3147
+ });
3148
+ }
3149
+
3150
+ // 如果有账户信息,格式化账户到购物车
3151
+ if (account) {
3152
+ formatAccountToCartItem({
3153
+ cartItem: cartItem,
3154
+ account: account
3155
+ });
3156
+ }
3120
3157
  return cartItem;
3121
3158
  }
3122
3159
  }, {
3123
3160
  key: "checkMaxDurationCapacityForDetailNums",
3124
- value: function checkMaxDurationCapacityForDetailNums(currentProduct) {
3161
+ value: function checkMaxDurationCapacityForDetailNums(_ref13) {
3125
3162
  var _this16 = this;
3163
+ var product = _ref13.product,
3164
+ date = _ref13.date,
3165
+ account = _ref13.account;
3126
3166
  var cartItems = cloneDeep(this.store.cart.getItems());
3127
3167
 
3128
3168
  // 将 ProductData 转换为 CartItem 但不真正添加到购物车
3129
- var currentCartItem = this.convertProductToCartItem(currentProduct);
3169
+ var currentCartItem = this.convertProductToCartItem({
3170
+ product: product,
3171
+ date: date,
3172
+ account: account
3173
+ });
3130
3174
  cartItems.push(currentCartItem);
3131
3175
  if (cartItems.length === 0) return {
3132
3176
  success: true,
@@ -3423,7 +3467,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3423
3467
  var resourcesIdSet = new Set();
3424
3468
 
3425
3469
  // 获取资源数据
3426
- var dateRange = _this16.store.date.getDateRange();
3470
+ // const dateRange = this.store.date.getDateRange();
3427
3471
  var resourcesDates = _this16.store.date.getDateList();
3428
3472
  var targetResourceDate = resourcesDates.find(function (n) {
3429
3473
  return n.date === startDate;
@@ -3444,13 +3488,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3444
3488
  });
3445
3489
 
3446
3490
  // 按资源类型分组检查容量
3447
- if (!checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
3491
+ var _checkTimeSlotCapacit2 = checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot),
3492
+ success = _checkTimeSlotCapacit2.success,
3493
+ required = _checkTimeSlotCapacit2.required,
3494
+ available = _checkTimeSlotCapacit2.available;
3495
+ if (!success) {
3448
3496
  // 如果有可用数量记录,返回最小值;否则返回 0
3449
- var _minAvailableCount2 = availableCountsByResourceType.length > 0 ? Math.min.apply(Math, availableCountsByResourceType) : 0;
3497
+ // const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
3450
3498
  return {
3451
3499
  v: {
3452
3500
  success: false,
3453
- minAvailableCount: _minAvailableCount2
3501
+ minAvailableCount: available
3454
3502
  }
3455
3503
  };
3456
3504
  }
@@ -3644,12 +3692,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3644
3692
  }, {
3645
3693
  key: "getTimeslotsScheduleByDateRange",
3646
3694
  value: (function () {
3647
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref12) {
3695
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref14) {
3648
3696
  var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
3649
3697
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3650
3698
  while (1) switch (_context26.prev = _context26.next) {
3651
3699
  case 0:
3652
- startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
3700
+ startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
3653
3701
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
3654
3702
  startDate: startDate,
3655
3703
  endDate: endDate,
@@ -68,4 +68,8 @@ export declare function getResourcesIdsByProduct(product: any): number[];
68
68
  /**
69
69
  * 检查特定时间段的容量是否足够
70
70
  */
71
- export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): boolean;
71
+ export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): {
72
+ success: boolean;
73
+ required: number;
74
+ available: number;
75
+ };
@@ -87,14 +87,14 @@ export var getSumCapacity = function getSumCapacity(_ref2) {
87
87
  * @return {*}
88
88
  */
89
89
  export function getCapacityInfoByCartItem(targetCartItem) {
90
- var _targetCartItem$_prod, _targetCartItem$_orig;
90
+ var _targetCartItem$_prod;
91
91
  var formatCapacity = formatDefaultCapacitys({
92
92
  capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
93
93
  product_bundle: targetCartItem._origin.product.product_bundle
94
94
  });
95
95
  var currentCapacity = getSumCapacity({
96
96
  capacity: formatCapacity,
97
- num: (targetCartItem === null || targetCartItem === void 0 || (_targetCartItem$_orig = targetCartItem._origin) === null || _targetCartItem$_orig === void 0 || (_targetCartItem$_orig = _targetCartItem$_orig.product) === null || _targetCartItem$_orig === void 0 ? void 0 : _targetCartItem$_orig.quantity) || 1
97
+ num: (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.num) || 1
98
98
  });
99
99
  return {
100
100
  formatCapacity: formatCapacity,
@@ -265,7 +265,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
265
265
  if (needsThisResourceType) {
266
266
  // 需要判断是单个预约还是多个预约,如果是单个预约,不用加 capacity,只用+1
267
267
  if (selectType === 'single') {
268
- requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
268
+ requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem === null || cartItem === void 0 ? void 0 : cartItem.num) || 1);
269
269
  } else {
270
270
  requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
271
271
  }
@@ -330,7 +330,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
330
330
  if (totalAvailableCapacity < requiredCapacity) {
331
331
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u5BB9\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(totalAvailableCapacity));
332
332
  return {
333
- v: false
333
+ v: {
334
+ success: false,
335
+ required: requiredCapacity,
336
+ available: totalAvailableCapacity
337
+ }
334
338
  };
335
339
  }
336
340
  } else {
@@ -349,7 +353,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
349
353
  if (availableResourceCount < requiredCapacity) {
350
354
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u6570\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(availableResourceCount));
351
355
  return {
352
- v: false
356
+ v: {
357
+ success: false,
358
+ required: requiredCapacity,
359
+ available: availableResourceCount
360
+ }
353
361
  };
354
362
  }
355
363
  }
@@ -360,5 +368,9 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
360
368
  if (_ret === 0) continue;
361
369
  if (_ret) return _ret.v;
362
370
  }
363
- return true;
371
+ return {
372
+ success: true,
373
+ required: 0,
374
+ available: 0
375
+ };
364
376
  }
@@ -329,13 +329,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
329
329
  * 参考 addProductToCart 方法的实现
330
330
  */
331
331
  private convertProductToCartItem;
332
- checkMaxDurationCapacityForDetailNums(currentProduct: ProductData): {
332
+ checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
333
+ product: ProductData;
334
+ date?: {
335
+ startTime: string;
336
+ endTime: string;
337
+ } | null;
338
+ account?: Account | null;
339
+ }): {
333
340
  success: boolean;
334
341
  minAvailableCount: number;
335
342
  };
336
343
  setOtherData(key: string, value: any): void;
337
344
  getOtherData(key: string): any;
338
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
345
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
339
346
  /**
340
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
341
348
  *
@@ -636,7 +636,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
636
636
  addItemParams.account = account;
637
637
  }
638
638
  this.addProductCheck({ date });
639
- this.store.cart.addItem(addItemParams);
639
+ if (addItemParams.quantity > 1) {
640
+ for (let i = 0; i < addItemParams.quantity; i++) {
641
+ const newAddItemParams = (0, import_lodash_es.cloneDeep)(addItemParams);
642
+ newAddItemParams.quantity = 1;
643
+ this.store.cart.addItem(newAddItemParams);
644
+ }
645
+ } else {
646
+ this.store.cart.addItem(addItemParams);
647
+ }
640
648
  return { success: true };
641
649
  }
642
650
  /**
@@ -2110,7 +2118,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2110
2118
  }
2111
2119
  });
2112
2120
  });
2113
- if (!(0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
2121
+ const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
2122
+ if (!success) {
2114
2123
  const minAvailableCount2 = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
2115
2124
  return { success: false, minAvailableCount: minAvailableCount2 };
2116
2125
  }
@@ -2122,7 +2131,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2122
2131
  * 将 ProductData 转换为 CartItem,但不添加到购物车
2123
2132
  * 参考 addProductToCart 方法的实现
2124
2133
  */
2125
- convertProductToCartItem(product) {
2134
+ convertProductToCartItem({
2135
+ product,
2136
+ date,
2137
+ account
2138
+ }) {
2126
2139
  const {
2127
2140
  bundle,
2128
2141
  options,
@@ -2132,13 +2145,18 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2132
2145
  } = product || {};
2133
2146
  const productData = { ...origin, product_variant_id };
2134
2147
  const processedProduct = (0, import_utils.handleVariantProduct)(productData);
2148
+ if (!account) {
2149
+ const activeAccount = this.getActiveAccount();
2150
+ if (activeAccount) {
2151
+ account = activeAccount;
2152
+ }
2153
+ }
2135
2154
  const cartItem = {
2136
2155
  _id: (0, import_utils.getUniqueId)("temp_"),
2137
2156
  _origin: (0, import_utils.createCartItemOrigin)(),
2138
2157
  _productOrigin: processedProduct,
2139
2158
  _productInit: product
2140
2159
  };
2141
- const activeAccount = this.getActiveAccount();
2142
2160
  (0, import_utils.formatProductToCartItem)({
2143
2161
  cartItem,
2144
2162
  product: processedProduct,
@@ -2147,12 +2165,28 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2147
2165
  product_variant_id,
2148
2166
  quantity
2149
2167
  });
2168
+ if (date) {
2169
+ (0, import_utils.formatDateToCartItem)({
2170
+ cartItem,
2171
+ date
2172
+ });
2173
+ }
2174
+ if (account) {
2175
+ (0, import_utils.formatAccountToCartItem)({
2176
+ cartItem,
2177
+ account
2178
+ });
2179
+ }
2150
2180
  return cartItem;
2151
2181
  }
2152
- checkMaxDurationCapacityForDetailNums(currentProduct) {
2182
+ checkMaxDurationCapacityForDetailNums({
2183
+ product,
2184
+ date,
2185
+ account
2186
+ }) {
2153
2187
  var _a, _b;
2154
2188
  const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
2155
- const currentCartItem = this.convertProductToCartItem(currentProduct);
2189
+ const currentCartItem = this.convertProductToCartItem({ product, date, account });
2156
2190
  cartItems.push(currentCartItem);
2157
2191
  if (cartItems.length === 0)
2158
2192
  return { success: true, minAvailableCount: 0 };
@@ -2331,7 +2365,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2331
2365
  const timeSlotEnd = `${endDate} ${endTime}`;
2332
2366
  const allResourcesForTimeSlot = [];
2333
2367
  const resourcesIdSet = /* @__PURE__ */ new Set();
2334
- const dateRange = this.store.date.getDateRange();
2335
2368
  const resourcesDates = this.store.date.getDateList();
2336
2369
  const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
2337
2370
  if (!targetResourceDate)
@@ -2348,9 +2381,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2348
2381
  }
2349
2382
  });
2350
2383
  });
2351
- if (!(0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
2352
- const minAvailableCount2 = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
2353
- return { success: false, minAvailableCount: minAvailableCount2 };
2384
+ const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
2385
+ if (!success) {
2386
+ return { success: false, minAvailableCount: available };
2354
2387
  }
2355
2388
  }
2356
2389
  const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
@@ -68,4 +68,8 @@ export declare function getResourcesIdsByProduct(product: any): number[];
68
68
  /**
69
69
  * 检查特定时间段的容量是否足够
70
70
  */
71
- export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): boolean;
71
+ export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): {
72
+ success: boolean;
73
+ required: number;
74
+ available: number;
75
+ };
@@ -76,12 +76,12 @@ var getSumCapacity = ({ capacity, num = 1 }) => {
76
76
  return sum * num;
77
77
  };
78
78
  function getCapacityInfoByCartItem(targetCartItem) {
79
- var _a, _b, _c;
79
+ var _a;
80
80
  const formatCapacity = formatDefaultCapacitys({
81
81
  capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
82
82
  product_bundle: targetCartItem._origin.product.product_bundle
83
83
  });
84
- const currentCapacity = getSumCapacity({ capacity: formatCapacity, num: ((_c = (_b = targetCartItem == null ? void 0 : targetCartItem._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.quantity) || 1 });
84
+ const currentCapacity = getSumCapacity({ capacity: formatCapacity, num: (targetCartItem == null ? void 0 : targetCartItem.num) || 1 });
85
85
  return {
86
86
  formatCapacity,
87
87
  currentCapacity
@@ -194,7 +194,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
194
194
  );
195
195
  if (needsThisResourceType) {
196
196
  if (selectType === "single") {
197
- requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
197
+ requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem == null ? void 0 : cartItem.num) || 1);
198
198
  } else {
199
199
  requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
200
200
  }
@@ -238,7 +238,11 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
238
238
  console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
239
239
  if (totalAvailableCapacity < requiredCapacity) {
240
240
  console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
241
- return false;
241
+ return {
242
+ success: false,
243
+ required: requiredCapacity,
244
+ available: totalAvailableCapacity
245
+ };
242
246
  }
243
247
  } else {
244
248
  let availableResourceCount = 0;
@@ -253,11 +257,19 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
253
257
  console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
254
258
  if (availableResourceCount < requiredCapacity) {
255
259
  console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
256
- return false;
260
+ return {
261
+ success: false,
262
+ required: requiredCapacity,
263
+ available: availableResourceCount
264
+ };
257
265
  }
258
266
  }
259
267
  }
260
- return true;
268
+ return {
269
+ success: true,
270
+ required: 0,
271
+ available: 0
272
+ };
261
273
  }
262
274
  // Annotate the CommonJS export names for ESM import in node:
263
275
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.330",
4
+ "version": "0.0.332",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",