@pisell/pisellos 3.0.77 → 3.0.78

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.
@@ -2031,6 +2031,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2031
2031
  key: "getTimeSlotByAllResources",
2032
2032
  value: function getTimeSlotByAllResources(resources_code) {
2033
2033
  var _dateRange,
2034
+ _dateRange2,
2034
2035
  _this12 = this,
2035
2036
  _cartItems$,
2036
2037
  _cartItems$2,
@@ -2086,6 +2087,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2086
2087
  }
2087
2088
  });
2088
2089
  }
2090
+ // 检查通过购物车 renderList 加入的资源数据里 times 的正确性,如果不对则需要修正
2091
+ if ((_dateRange2 = dateRange) !== null && _dateRange2 !== void 0 && (_dateRange2 = _dateRange2[0]) !== null && _dateRange2 !== void 0 && _dateRange2.date && resources.length) {
2092
+ var _dateRange3;
2093
+ var currentDate = (_dateRange3 = dateRange) === null || _dateRange3 === void 0 || (_dateRange3 = _dateRange3[0]) === null || _dateRange3 === void 0 ? void 0 : _dateRange3.date;
2094
+ var theDateResources = this.store.date.getResourcesListByDate(currentDate);
2095
+ resources.forEach(function (item) {
2096
+ var noCurrentDateTimes = item.times.some(function (n) {
2097
+ return dayjs(n.start_at).isSame(dayjs(currentDate), 'day');
2098
+ });
2099
+ if (!noCurrentDateTimes) {
2100
+ var _theDateResources$fin;
2101
+ item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin = theDateResources.find(function (n) {
2102
+ return n.id === item.id;
2103
+ })) === null || _theDateResources$fin === void 0 ? void 0 : _theDateResources$fin.times) || [];
2104
+ }
2105
+ });
2106
+ }
2089
2107
  var resourcesMap = getResourcesMap(resources);
2090
2108
  var duration = 0;
2091
2109
  // duration = 不同账号的最长时间
@@ -2158,12 +2176,26 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2158
2176
  }
2159
2177
  // 计算容量的辅助函数
2160
2178
  var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2161
- return items.reduce(function (total, item) {
2162
- return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2163
- }, 0);
2179
+ var _items$0$_resourceOri;
2180
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2181
+ var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
2182
+ var sameResourceLength = items.filter(function (item) {
2183
+ var _item$_resourceOrigin;
2184
+ return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
2185
+ }).length;
2186
+ if (sameResourceLength === items.length) {
2187
+ return 1;
2188
+ }
2189
+ // 找出单个购物车里最大的需求 capacity 即可
2190
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2191
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2192
+ })));
2193
+ // return items.reduce((total, item) => {
2194
+ // return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2195
+ // }, 0);
2164
2196
  };
2165
2197
 
2166
- // 如果是多个预约,去要求助几个 holder 下最大的需求容量capacity
2198
+ // 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
2167
2199
  var maxCapacity = 1;
2168
2200
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2169
2201
  accountList.forEach(function (account) {
@@ -2191,13 +2223,257 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2191
2223
  });
2192
2224
  return timeSlots;
2193
2225
  }
2226
+ // 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
2227
+ }, {
2228
+ key: "getTimeSlotByAllResourcesForDate",
2229
+ value: function () {
2230
+ var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
2231
+ var _this13 = this,
2232
+ _cartItems$5,
2233
+ _cartItems$6,
2234
+ _this$shopStore$get2;
2235
+ var resources_code, startDate, endDate, resources, cartItems, resourceIds, resourcesTypeId, isSingleResource, maxCutOffTime, maxCutOffTimeValue, duration, accountList, checkDuration, resourcesUseableMap, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold, calculateCapacityFromCartItems, maxCapacity, arr, today, _loop2, i;
2236
+ return _regeneratorRuntime().wrap(function _callee24$(_context25) {
2237
+ while (1) switch (_context25.prev = _context25.next) {
2238
+ case 0:
2239
+ resources_code = _ref10.resources_code, startDate = _ref10.startDate, endDate = _ref10.endDate;
2240
+ // 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
2241
+ if (dayjs(endDate).diff(dayjs(startDate), 'day') < 30) {
2242
+ endDate = dayjs(startDate).add(30, 'day').format('YYYY-MM-DD');
2243
+ }
2244
+ // 预请求资源数据,防止日期超过之前选择的范围
2245
+ _context25.next = 4;
2246
+ return this.getAvailableDate({
2247
+ startDate: startDate,
2248
+ endDate: endDate,
2249
+ useCache: true
2250
+ });
2251
+ case 4:
2252
+ // 取出购物车中所有一已选择的第一步资源
2253
+ resources = [];
2254
+ cartItems = this.store.cart.getItems().filter(function (n) {
2255
+ return !isNormalProduct(n._productOrigin);
2256
+ }); // if (cartItems?.[0].start_date) return [];
2257
+ resourceIds = [];
2258
+ resourcesTypeId = undefined;
2259
+ isSingleResource = false; // 找出购物车里最大的 cut_off_time
2260
+ maxCutOffTime = undefined;
2261
+ maxCutOffTimeValue = dayjs();
2262
+ cartItems.forEach(function (item) {
2263
+ var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
2264
+ (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.product_resource) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.resources) === null || _item$_productOrigin17 === void 0 || _item$_productOrigin17.forEach(function (n) {
2265
+ // TODO: 少了个 status 的判断
2266
+ if (n.code === resources_code) {
2267
+ resources.push.apply(resources, _toConsumableArray(n.renderList || []));
2268
+ isSingleResource = n.type === 'single';
2269
+ }
2270
+ });
2271
+ // item._origin.resources?.forEach((n: any) => {
2272
+ // resourceIds.push(n.relation_id);
2273
+ // });
2274
+ if (item.resource_id && !resourceIds.includes(item.resource_id)) {
2275
+ resourceIds.push(item.resource_id);
2276
+ }
2277
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.product_resource) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.resources) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.find(function (n) {
2278
+ return n.code === resources_code;
2279
+ })) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
2280
+ if ((_item$_productOrigin19 = item._productOrigin) !== null && _item$_productOrigin19 !== void 0 && _item$_productOrigin19.cut_off_time && ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.cut_off_time.type) === 'advance') {
2281
+ var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
2282
+ if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
2283
+ maxCutOffTimeValue = currentCutOffTime;
2284
+ maxCutOffTime = item._productOrigin.cut_off_time;
2285
+ }
2286
+ }
2287
+ });
2194
2288
 
2195
- // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
2289
+ // 保护: 如果 resources 为空则直接 return
2290
+ if (resources.length) {
2291
+ _context25.next = 14;
2292
+ break;
2293
+ }
2294
+ return _context25.abrupt("return", []);
2295
+ case 14:
2296
+ duration = 0; // duration = 不同账号的最长时间
2297
+ accountList = this.store.accountList.getAccounts();
2298
+ checkDuration = function checkDuration(cartItems) {
2299
+ var accountDuration = 0;
2300
+ cartItems.forEach(function (item) {
2301
+ // 单个预约累加账号 多个预约取最大值
2302
+ if (isSingleResource) {
2303
+ var _item$_productOrigin21;
2304
+ accountDuration += ((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.value) || 10;
2305
+ } else {
2306
+ var _item$_productOrigin22;
2307
+ if (accountDuration < (((_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.duration) === null || _item$_productOrigin22 === void 0 ? void 0 : _item$_productOrigin22.value) || 10)) {
2308
+ var _item$_productOrigin23;
2309
+ accountDuration = ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.value) || 10;
2310
+ }
2311
+ }
2312
+ });
2313
+ if (accountDuration > duration) {
2314
+ duration = accountDuration;
2315
+ }
2316
+ };
2317
+ if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2318
+ accountList.forEach(function (account) {
2319
+ var cartItems = _this13.store.cart.getCartByAccount(account.getId());
2320
+ checkDuration(cartItems);
2321
+ });
2322
+ } else {
2323
+ checkDuration(cartItems);
2324
+ }
2325
+ // 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
2326
+ // 同时 session 类商品的流程也不应该调用这个方法
2327
+ if (!(!(cartItems !== null && cartItems !== void 0 && (_cartItems$5 = cartItems[0]) !== null && _cartItems$5 !== void 0 && _cartItems$5.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$6 = cartItems[0]) !== null && _cartItems$6 !== void 0 && _cartItems$6.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration))) {
2328
+ _context25.next = 20;
2329
+ break;
2330
+ }
2331
+ return _context25.abrupt("return", []);
2332
+ case 20:
2333
+ resourcesUseableMap = {};
2334
+ hasFlexibleDuration = cartItems.some(function (item) {
2335
+ var _item$_productOrigin24;
2336
+ return ((_item$_productOrigin24 = item._productOrigin) === null || _item$_productOrigin24 === void 0 || (_item$_productOrigin24 = _item$_productOrigin24.duration) === null || _item$_productOrigin24 === void 0 ? void 0 : _item$_productOrigin24.type) === 'flexible';
2337
+ });
2338
+ operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
2339
+ maxBlockThreshold = 0;
2340
+ if (hasFlexibleDuration) {
2341
+ maxBlockThreshold = cartItems.reduce(function (max, item) {
2342
+ var _item$_productOrigin25;
2343
+ // 如果开启了灵活时长商品配置,则取 block_threshold 的值
2344
+ if ((_item$_productOrigin25 = item._productOrigin) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.duration) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.flexible_config) !== null && _item$_productOrigin25 !== void 0 && _item$_productOrigin25.is_enable_minimum_duration) {
2345
+ var _item$_productOrigin26;
2346
+ return Math.max(max, ((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.flexible_config) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.block_threshold) || 0);
2347
+ }
2348
+ return 0;
2349
+ }, 0);
2350
+ }
2351
+ // 计算容量的辅助函数
2352
+ calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2353
+ var _items$0$_resourceOri2;
2354
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2355
+ var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
2356
+ var sameResourceLength = items.filter(function (item) {
2357
+ var _item$_resourceOrigin2;
2358
+ return ((_item$_resourceOrigin2 = item._resourceOrigin) === null || _item$_resourceOrigin2 === void 0 ? void 0 : _item$_resourceOrigin2[0].id) === firstResource;
2359
+ }).length;
2360
+ if (sameResourceLength !== items.length) {
2361
+ return 1;
2362
+ }
2363
+ // 找出单个购物车里最大的需求 capacity 即可
2364
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2365
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2366
+ })));
2367
+ }; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
2368
+ maxCapacity = 1;
2369
+ if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2370
+ accountList.forEach(function (account) {
2371
+ var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
2372
+ var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
2373
+ if (currentCapacity > maxCapacity) {
2374
+ maxCapacity = currentCapacity;
2375
+ }
2376
+ });
2377
+ } else {
2378
+ maxCapacity = calculateCapacityFromCartItems(cartItems);
2379
+ }
2380
+ arr = [];
2381
+ today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
2382
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
2383
+ var currentDate, theDateResources, resourcesMap, timeSlots;
2384
+ return _regeneratorRuntime().wrap(function _loop2$(_context24) {
2385
+ while (1) switch (_context24.prev = _context24.next) {
2386
+ case 0:
2387
+ currentDate = i.format('YYYY-MM-DD');
2388
+ theDateResources = _this13.store.date.getResourcesListByDate(currentDate);
2389
+ resources.forEach(function (item) {
2390
+ var _theDateResources$fin2;
2391
+ item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin2 = theDateResources.find(function (n) {
2392
+ return n.id === item.id;
2393
+ })) === null || _theDateResources$fin2 === void 0 ? void 0 : _theDateResources$fin2.times) || [];
2394
+ });
2395
+ resourcesMap = getResourcesMap(resources); // 如果日期已经过期则直接标记为不可用
2396
+ if (!i.isBefore(today)) {
2397
+ _context24.next = 7;
2398
+ break;
2399
+ }
2400
+ arr.push({
2401
+ date: currentDate,
2402
+ status: 'unavailable',
2403
+ week: i.format('ddd'),
2404
+ weekNum: i.day()
2405
+ });
2406
+ return _context24.abrupt("return", 1);
2407
+ case 7:
2408
+ timeSlots = getTimeSlicesByResources({
2409
+ resourceIds: resourceIds,
2410
+ resourcesMap: resourcesMap,
2411
+ duration: duration,
2412
+ currentDate: currentDate,
2413
+ split: 10,
2414
+ resourcesUseableMap: resourcesUseableMap,
2415
+ capacity: maxCapacity,
2416
+ cut_off_time: maxCutOffTime,
2417
+ hasFlexibleDuration: hasFlexibleDuration,
2418
+ operating_day_boundary: operating_day_boundary,
2419
+ maxBlockThreshold: maxBlockThreshold
2420
+ });
2421
+ if (timeSlots.length > 0) {
2422
+ arr.push({
2423
+ date: currentDate,
2424
+ status: 'available',
2425
+ week: i.format('ddd'),
2426
+ weekNum: i.day()
2427
+ });
2428
+ } else {
2429
+ arr.push({
2430
+ date: currentDate,
2431
+ status: 'unavailable',
2432
+ week: i.format('ddd'),
2433
+ weekNum: i.day()
2434
+ });
2435
+ }
2436
+ case 9:
2437
+ case "end":
2438
+ return _context24.stop();
2439
+ }
2440
+ }, _loop2);
2441
+ });
2442
+ i = dayjs(startDate);
2443
+ case 32:
2444
+ if (!i.isBefore(dayjs(endDate))) {
2445
+ _context25.next = 39;
2446
+ break;
2447
+ }
2448
+ return _context25.delegateYield(_loop2(), "t0", 34);
2449
+ case 34:
2450
+ if (!_context25.t0) {
2451
+ _context25.next = 36;
2452
+ break;
2453
+ }
2454
+ return _context25.abrupt("continue", 36);
2455
+ case 36:
2456
+ i = i.add(1, 'day');
2457
+ _context25.next = 32;
2458
+ break;
2459
+ case 39:
2460
+ return _context25.abrupt("return", arr);
2461
+ case 40:
2462
+ case "end":
2463
+ return _context25.stop();
2464
+ }
2465
+ }, _callee24, this);
2466
+ }));
2467
+ function getTimeSlotByAllResourcesForDate(_x19) {
2468
+ return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
2469
+ }
2470
+ return getTimeSlotByAllResourcesForDate;
2471
+ }() // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
2196
2472
  }, {
2197
2473
  key: "submitTimeSlot",
2198
2474
  value: function submitTimeSlot(timeSlots) {
2199
- var _this$shopStore$get2,
2200
- _this13 = this;
2475
+ var _this$shopStore$get3,
2476
+ _this14 = this;
2201
2477
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
2202
2478
  var cartItems = this.store.cart.getItems().filter(function (n) {
2203
2479
  return !isNormalProduct(n._productOrigin);
@@ -2217,7 +2493,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2217
2493
  }, {});
2218
2494
 
2219
2495
  // 店铺营业结束时间
2220
- var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary;
2496
+ var operating_day_boundary = (_this$shopStore$get3 = this.shopStore.get('core')) === null || _this$shopStore$get3 === void 0 || (_this$shopStore$get3 = _this$shopStore$get3.core) === null || _this$shopStore$get3 === void 0 ? void 0 : _this$shopStore$get3.operating_day_boundary;
2221
2497
 
2222
2498
  // 处理每个账号的商品
2223
2499
  Object.values(itemsByAccount).forEach(function (accountItems) {
@@ -2227,10 +2503,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2227
2503
  var osWarnTips = [];
2228
2504
  var newResources = cloneDeep(item._origin.resources);
2229
2505
  newResources.forEach(function (resource) {
2230
- var _item$_productOrigin17;
2506
+ var _item$_productOrigin27;
2231
2507
  // 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
2232
- if (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible') {
2233
- var _allResources$find, _item$_productOrigin18, _item$_productOrigin19;
2508
+ if (((_item$_productOrigin27 = item._productOrigin) === null || _item$_productOrigin27 === void 0 || (_item$_productOrigin27 = _item$_productOrigin27.duration) === null || _item$_productOrigin27 === void 0 ? void 0 : _item$_productOrigin27.type) === 'flexible') {
2509
+ var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
2234
2510
  item.duration = {
2235
2511
  type: 'minutes',
2236
2512
  value: 10
@@ -2260,19 +2536,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2260
2536
  resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
2261
2537
  // 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
2262
2538
  // 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
2263
- if ((_item$_productOrigin18 = item._productOrigin) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.duration) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.flexible_config) !== null && _item$_productOrigin18 !== void 0 && _item$_productOrigin18.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.flexible_config) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
2539
+ if ((_item$_productOrigin28 = item._productOrigin) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.duration) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.flexible_config) !== null && _item$_productOrigin28 !== void 0 && _item$_productOrigin28.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.flexible_config) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
2264
2540
  if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
2265
2541
  osWarnTips.push('pisell2.product.card.closing-soon.warning');
2266
2542
  }
2267
2543
  }
2268
2544
  } else {
2269
- var _item$_productOrigin20;
2545
+ var _item$_productOrigin30;
2270
2546
  resource.startTime = currentStartTime;
2271
- resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 || (_item$_productOrigin20 = _item$_productOrigin20.duration) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2547
+ resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin30 = item._productOrigin) === null || _item$_productOrigin30 === void 0 || (_item$_productOrigin30 = _item$_productOrigin30.duration) === null || _item$_productOrigin30 === void 0 ? void 0 : _item$_productOrigin30.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2272
2548
  }
2273
2549
  // delete resource.times;
2274
2550
  });
2275
- _this13.store.cart.updateItem({
2551
+ _this14.store.cart.updateItem({
2276
2552
  _id: item._id,
2277
2553
  resources: newResources,
2278
2554
  osWarnTips: osWarnTips
@@ -2316,42 +2592,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2316
2592
  }, {
2317
2593
  key: "openProductDetail",
2318
2594
  value: function () {
2319
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productId) {
2595
+ var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2320
2596
  var targetProductData, newScheduleArr, dateRange;
2321
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2322
- while (1) switch (_context24.prev = _context24.next) {
2597
+ return _regeneratorRuntime().wrap(function _callee25$(_context26) {
2598
+ while (1) switch (_context26.prev = _context26.next) {
2323
2599
  case 0:
2324
- _context24.next = 2;
2600
+ _context26.next = 2;
2325
2601
  return this.store.products.getProduct(productId);
2326
2602
  case 2:
2327
- targetProductData = _context24.sent;
2603
+ targetProductData = _context26.sent;
2328
2604
  if (!targetProductData) {
2329
- _context24.next = 17;
2605
+ _context26.next = 17;
2330
2606
  break;
2331
2607
  }
2332
2608
  this.store.currentProduct = targetProductData;
2333
2609
  this.store.currentProductMeta = {};
2334
2610
  // 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
2335
2611
  if (!targetProductData['schedule.ids']) {
2336
- _context24.next = 12;
2612
+ _context26.next = 12;
2337
2613
  break;
2338
2614
  }
2339
2615
  newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2340
2616
  if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2341
2617
  this.store.currentProductMeta.schedule = newScheduleArr;
2342
- _context24.next = 17;
2618
+ _context26.next = 17;
2343
2619
  break;
2344
2620
  case 12:
2345
2621
  if (!targetProductData.duration) {
2346
- _context24.next = 17;
2622
+ _context26.next = 17;
2347
2623
  break;
2348
2624
  }
2349
2625
  dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
2350
2626
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
2351
- _context24.next = 16;
2627
+ _context26.next = 16;
2352
2628
  break;
2353
2629
  }
2354
- return _context24.abrupt("return");
2630
+ return _context26.abrupt("return");
2355
2631
  case 16:
2356
2632
  // this.store.date.getResourceDates({
2357
2633
  // query: {
@@ -2367,11 +2643,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2367
2643
  });
2368
2644
  case 17:
2369
2645
  case "end":
2370
- return _context24.stop();
2646
+ return _context26.stop();
2371
2647
  }
2372
- }, _callee24, this);
2648
+ }, _callee25, this);
2373
2649
  }));
2374
- function openProductDetail(_x19) {
2650
+ function openProductDetail(_x20) {
2375
2651
  return _openProductDetail.apply(this, arguments);
2376
2652
  }
2377
2653
  return openProductDetail;
@@ -2388,14 +2664,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2388
2664
  // 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
2389
2665
  }, {
2390
2666
  key: "getTimeslotBySchedule",
2391
- value: function getTimeslotBySchedule(_ref10) {
2667
+ value: function getTimeslotBySchedule(_ref11) {
2392
2668
  var _this$store$currentPr2,
2393
2669
  _targetProductData$pr,
2394
- _this14 = this;
2395
- var date = _ref10.date,
2396
- scheduleIds = _ref10.scheduleIds,
2397
- resources = _ref10.resources,
2398
- product = _ref10.product;
2670
+ _targetProductData$pr2,
2671
+ _this15 = this;
2672
+ var date = _ref11.date,
2673
+ scheduleIds = _ref11.scheduleIds,
2674
+ resources = _ref11.resources,
2675
+ product = _ref11.product;
2399
2676
  var targetProduct = this.store.currentProduct;
2400
2677
  // 如果外面传递了product 优先用外面的
2401
2678
  var targetProductData = product || targetProduct;
@@ -2434,7 +2711,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2434
2711
  var firstEnabledResourceId = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.find(function (n) {
2435
2712
  return n.status === 1;
2436
2713
  })) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.id;
2437
-
2714
+ var firstEnabledResourceConfig = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr2 = targetProductData.product_resource) === null || _targetProductData$pr2 === void 0 || (_targetProductData$pr2 = _targetProductData$pr2.resources) === null || _targetProductData$pr2 === void 0 ? void 0 : _targetProductData$pr2.find(function (n) {
2715
+ return n.status === 1 && n.id === firstEnabledResourceId;
2716
+ });
2717
+ var isMultipleBooking = (firstEnabledResourceConfig === null || firstEnabledResourceConfig === void 0 ? void 0 : firstEnabledResourceConfig.type) === 'multiple';
2438
2718
  // 计算每个日程切片下日程可用的资源的容量总和
2439
2719
  var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
2440
2720
  // 用来计算资源的可使用情况,针对单个schedule 时间片
@@ -2442,6 +2722,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2442
2722
  var count = 0;
2443
2723
  var bookingLeft = 0;
2444
2724
  var summaryCount = 0;
2725
+ var summaryConfigCount = 0;
2445
2726
  // 遍历所有资源
2446
2727
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2447
2728
  // 遍历所有资源的上工时间片
@@ -2455,9 +2736,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2455
2736
  // n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
2456
2737
  // item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
2457
2738
  // 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
2458
- // 如果 n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
2739
+ // 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
2740
+ // https://project.feishu.cn/v2qint/bug/detail/6657165010
2459
2741
  var mTimes = m.times.filter(function (n) {
2460
- return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
2742
+ return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || m.onlyComputed && dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
2461
2743
  });
2462
2744
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
2463
2745
  if (mTimes.length === 0) {
@@ -2489,6 +2771,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2489
2771
  }
2490
2772
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
2491
2773
  });
2774
+ if (m.form_id === firstEnabledResourceId) {
2775
+ // 确认当前资源是单个预约还是多个预约,单个预约则只需要计数,多个预约才添加容量
2776
+ if (isMultipleBooking) {
2777
+ summaryConfigCount += m.capacity;
2778
+ } else {
2779
+ summaryConfigCount += 1;
2780
+ }
2781
+ }
2492
2782
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
2493
2783
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
2494
2784
  return n === false;
@@ -2505,7 +2795,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2505
2795
  }
2506
2796
  });
2507
2797
  // 容量检测
2508
- var cartItems = _this14.store.cart.getItems();
2798
+ var cartItems = _this15.store.cart.getItems();
2509
2799
  productResources.forEach(function (n) {
2510
2800
  // 单个预约检测规则:
2511
2801
  // 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
@@ -2524,13 +2814,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2524
2814
  }
2525
2815
  // 规则 2
2526
2816
  var otherCartItems = cartItems.filter(function (m) {
2527
- var _m$_productOrigin2, _targetProductData$id2;
2528
- return ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2817
+ var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
2818
+ var isTimeMatch = ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2819
+ var isResourceMatch = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
2820
+ return m.type === n.type && m.status === 1;
2821
+ });
2822
+ return isTimeMatch && isResourceMatch;
2529
2823
  });
2530
2824
  otherCartItems.forEach(function (m) {
2531
- var _m$_productOrigin3;
2532
- var sameTypeResources = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
2533
- return m.type === n.type;
2825
+ var _m$_productOrigin4;
2826
+ var sameTypeResources = (_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.product_resource) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.resources) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.find(function (m) {
2827
+ return m.type === n.type && m.status === 1;
2534
2828
  });
2535
2829
  var sameTypeResourcesSet = new Set([].concat(_toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.optional_resource) || []), _toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.default_resource) || [])));
2536
2830
  // 把sameTypeResourcesSet 加到currentResourcesSet
@@ -2539,7 +2833,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2539
2833
  });
2540
2834
  });
2541
2835
  // 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
2542
- var currentDataResources = _this14.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
2836
+ var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
2543
2837
  currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
2544
2838
  if (currentResourcesSet.has(m.id)) {
2545
2839
  var mTimes = m.times.filter(function (n) {
@@ -2561,8 +2855,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2561
2855
  // 多个预约的检测规则:
2562
2856
  // 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
2563
2857
  var _sameCartItems = cartItems.filter(function (m) {
2564
- var _m$_productOrigin4, _targetProductData$id3;
2565
- return ((_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.id) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2858
+ var _m$_productOrigin5, _targetProductData$id3;
2859
+ return ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.id) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
2566
2860
  });
2567
2861
  var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
2568
2862
  return acc + getCapacityInfoByCartItem(curr).currentCapacity;
@@ -2587,8 +2881,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2587
2881
  return !m.onlyComputed;
2588
2882
  }));
2589
2883
  otherSameTimesCartItems.forEach(function (m) {
2590
- var _m$_productOrigin5;
2591
- var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.product_resource) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.resources) || [], selectedResources, 1);
2884
+ var _m$_productOrigin6;
2885
+ var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin6 = m._productOrigin) === null || _m$_productOrigin6 === void 0 || (_m$_productOrigin6 = _m$_productOrigin6.product_resource) === null || _m$_productOrigin6 === void 0 ? void 0 : _m$_productOrigin6.resources) || [], selectedResources, 1);
2592
2886
  productResources.forEach(function (m) {
2593
2887
  if (m.id === n.id) {
2594
2888
  m.renderList.forEach(function (n) {
@@ -2643,6 +2937,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2643
2937
  });
2644
2938
  var startDayJs = dayjs(item.start);
2645
2939
  var endDayJs = dayjs(item.end);
2940
+
2941
+ // 状态
2942
+ // 如果是isMultipleBooking
2943
+ // lots_of_space: summaryCount / summaryConfigCount > 0.5
2944
+ // filling_up_fast: summaryCount / summaryConfigCount <= 0.5 && summaryCount > 0
2945
+ // sold_out: bookingLeft = 0
2946
+ // 如果不是isMultipleBooking
2947
+ // lots_of_space: bookingLeft / summaryConfigCount > 0.5
2948
+ // filling_up_fast: bookingLeft / summaryConfigCount <= 0.5 && count > 0
2949
+ // sold_out: bookingLeft = 0
2950
+ var timeStatus = 'sold_out';
2951
+ if (bookingLeft === 0) timeStatus = 'sold_out';else if (isMultipleBooking) {
2952
+ if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
2953
+ var usageRatio = summaryCount / summaryConfigCount;
2954
+ if (usageRatio > 0.5) timeStatus = 'lots_of_space';else if (summaryCount > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
2955
+ }
2956
+ } else {
2957
+ if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
2958
+ var _usageRatio = bookingLeft / summaryConfigCount;
2959
+ if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
2960
+ }
2961
+ }
2646
2962
  return {
2647
2963
  start_time: startDayJs.format('HH:mm'),
2648
2964
  end_time: endDayJs.format('HH:mm'),
@@ -2650,7 +2966,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2650
2966
  end_at: endDayJs,
2651
2967
  count: count,
2652
2968
  left: bookingLeft,
2653
- summaryCount: summaryCount
2969
+ summaryCount: summaryCount,
2970
+ status: timeStatus
2654
2971
  };
2655
2972
  });
2656
2973
  return formatScheduleTimeSlots;
@@ -2691,7 +3008,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2691
3008
  }));
2692
3009
 
2693
3010
  // 与其他资源的时间段求交集
2694
- var _loop2 = function _loop2() {
3011
+ var _loop3 = function _loop3() {
2695
3012
  var currentResourceSlots = allTimeSlots[i];
2696
3013
  var intersections = [];
2697
3014
 
@@ -2720,7 +3037,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2720
3037
  }));
2721
3038
  };
2722
3039
  for (var i = 1; i < allTimeSlots.length; i++) {
2723
- if (_loop2()) continue;
3040
+ if (_loop3()) continue;
2724
3041
  }
2725
3042
 
2726
3043
  // 格式化返回结果
@@ -2736,7 +3053,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2736
3053
  }, {
2737
3054
  key: "checkMaxDurationCapacity",
2738
3055
  value: function checkMaxDurationCapacity() {
2739
- var _this15 = this;
3056
+ var _this16 = this;
2740
3057
  var cartItems = this.store.cart.getItems().filter(function (item) {
2741
3058
  return !isNormalProduct(item._productOrigin);
2742
3059
  });
@@ -2775,6 +3092,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2775
3092
  itemsByResourceType[resourceCode] = [];
2776
3093
  }
2777
3094
  // 避免重复添加同一个商品
3095
+ // 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
3096
+ if (itemsByResourceType[resourceCode].find(function (item) {
3097
+ return item.holder_id === cartItem.holder_id;
3098
+ })) {
3099
+ return;
3100
+ }
2778
3101
  if (!itemsByResourceType[resourceCode].find(function (item) {
2779
3102
  return item._id === cartItem._id;
2780
3103
  })) {
@@ -2826,7 +3149,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2826
3149
  var processedCartItemIds = new Set();
2827
3150
 
2828
3151
  // 先检查所有资源类型,收集可用数量信息
2829
- var _loop3 = function _loop3() {
3152
+ var _loop4 = function _loop4() {
2830
3153
  var _resourceTypeConfig;
2831
3154
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2832
3155
  resourceCode = _Object$entries$_i[0],
@@ -2942,7 +3265,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2942
3265
  }));
2943
3266
 
2944
3267
  // 找到所有资源都可用的时间段
2945
- var commonTimeSlots = _this15.findCommonAvailableTimeSlots(resourcesOfThisType);
3268
+ var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
2946
3269
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
2947
3270
  if (commonTimeSlots.length === 0) {
2948
3271
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
@@ -2973,7 +3296,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2973
3296
  },
2974
3297
  _ret2;
2975
3298
  for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
2976
- _ret2 = _loop3();
3299
+ _ret2 = _loop4();
2977
3300
  if (_ret2) return _ret2.v;
2978
3301
  }
2979
3302
 
@@ -3017,7 +3340,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3017
3340
  cartItemsByTimeSlot[timeSlotKey].push(cartItem);
3018
3341
  });
3019
3342
  // 检查每个时间段是否有足够的资源容量
3020
- var _loop4 = function _loop4() {
3343
+ var _loop5 = function _loop5() {
3021
3344
  var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
3022
3345
  timeSlotKey = _Object$entries2$_i[0],
3023
3346
  itemsInTimeSlot = _Object$entries2$_i[1];
@@ -3035,8 +3358,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3035
3358
  var resourcesIdSet = new Set();
3036
3359
 
3037
3360
  // 获取资源数据
3038
- var dateRange = _this15.store.date.getDateRange();
3039
- var resourcesDates = _this15.store.date.getDateList();
3361
+ var dateRange = _this16.store.date.getDateRange();
3362
+ var resourcesDates = _this16.store.date.getDateList();
3040
3363
  var targetResourceDate = resourcesDates.find(function (n) {
3041
3364
  return n.date === startDate;
3042
3365
  });
@@ -3073,7 +3396,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3073
3396
  },
3074
3397
  _ret3;
3075
3398
  for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
3076
- _ret3 = _loop4();
3399
+ _ret3 = _loop5();
3077
3400
  if (_ret3 === 0) continue;
3078
3401
  if (_ret3) return _ret3.v;
3079
3402
  }
@@ -3092,17 +3415,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3092
3415
  */
3093
3416
  }, {
3094
3417
  key: "convertProductToCartItem",
3095
- value: function convertProductToCartItem(_ref11) {
3096
- var product = _ref11.product,
3097
- date = _ref11.date,
3098
- account = _ref11.account;
3099
- var _ref12 = product || {},
3100
- bundle = _ref12.bundle,
3101
- options = _ref12.options,
3102
- origin = _ref12.origin,
3103
- product_variant_id = _ref12.product_variant_id,
3104
- _ref12$quantity = _ref12.quantity,
3105
- quantity = _ref12$quantity === void 0 ? 1 : _ref12$quantity;
3418
+ value: function convertProductToCartItem(_ref12) {
3419
+ var product = _ref12.product,
3420
+ date = _ref12.date,
3421
+ account = _ref12.account;
3422
+ var _ref13 = product || {},
3423
+ bundle = _ref13.bundle,
3424
+ options = _ref13.options,
3425
+ origin = _ref13.origin,
3426
+ product_variant_id = _ref13.product_variant_id,
3427
+ _ref13$quantity = _ref13.quantity,
3428
+ quantity = _ref13$quantity === void 0 ? 1 : _ref13$quantity;
3106
3429
 
3107
3430
  // 处理商品数据,类似 addProductToCart 中的逻辑
3108
3431
  var productData = _objectSpread(_objectSpread({}, origin), {}, {
@@ -3157,11 +3480,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3157
3480
  }
3158
3481
  }, {
3159
3482
  key: "checkMaxDurationCapacityForDetailNums",
3160
- value: function checkMaxDurationCapacityForDetailNums(_ref13) {
3161
- var _this16 = this;
3162
- var product = _ref13.product,
3163
- date = _ref13.date,
3164
- account = _ref13.account;
3483
+ value: function checkMaxDurationCapacityForDetailNums(_ref14) {
3484
+ var _this17 = this;
3485
+ var product = _ref14.product,
3486
+ date = _ref14.date,
3487
+ account = _ref14.account;
3165
3488
  var cartItems = this.store.cart.getItems().filter(function (item) {
3166
3489
  return !isNormalProduct(item._productOrigin);
3167
3490
  });
@@ -3259,7 +3582,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3259
3582
  var processedCartItemIds = new Set();
3260
3583
 
3261
3584
  // 先检查所有资源类型,收集可用数量信息
3262
- var _loop5 = function _loop5() {
3585
+ var _loop6 = function _loop6() {
3263
3586
  var _resourceTypeConfig2;
3264
3587
  var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
3265
3588
  resourceCode = _Object$entries3$_i[0],
@@ -3375,7 +3698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3375
3698
  }));
3376
3699
 
3377
3700
  // 找到所有资源都可用的时间段
3378
- var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
3701
+ var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
3379
3702
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
3380
3703
  if (commonTimeSlots.length === 0) {
3381
3704
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
@@ -3406,7 +3729,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3406
3729
  },
3407
3730
  _ret4;
3408
3731
  for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
3409
- _ret4 = _loop5();
3732
+ _ret4 = _loop6();
3410
3733
  if (_ret4) return _ret4.v;
3411
3734
  }
3412
3735
 
@@ -3450,7 +3773,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3450
3773
  cartItemsByTimeSlot[timeSlotKey].push(cartItem);
3451
3774
  });
3452
3775
  // 检查每个时间段是否有足够的资源容量
3453
- var _loop6 = function _loop6() {
3776
+ var _loop7 = function _loop7() {
3454
3777
  var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
3455
3778
  timeSlotKey = _Object$entries4$_i[0],
3456
3779
  itemsInTimeSlot = _Object$entries4$_i[1];
@@ -3469,7 +3792,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3469
3792
 
3470
3793
  // 获取资源数据
3471
3794
  // const dateRange = this.store.date.getDateRange();
3472
- var resourcesDates = _this16.store.date.getDateList();
3795
+ var resourcesDates = _this17.store.date.getDateList();
3473
3796
  var targetResourceDate = resourcesDates.find(function (n) {
3474
3797
  return n.date === startDate;
3475
3798
  });
@@ -3506,7 +3829,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3506
3829
  },
3507
3830
  _ret5;
3508
3831
  for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
3509
- _ret5 = _loop6();
3832
+ _ret5 = _loop7();
3510
3833
  if (_ret5 === 0) continue;
3511
3834
  if (_ret5) return _ret5.v;
3512
3835
  }
@@ -3539,41 +3862,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3539
3862
  }, {
3540
3863
  key: "getProductTypeById",
3541
3864
  value: function () {
3542
- var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(id) {
3865
+ var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
3543
3866
  var productData, _productData$schedule;
3544
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3545
- while (1) switch (_context25.prev = _context25.next) {
3867
+ return _regeneratorRuntime().wrap(function _callee26$(_context27) {
3868
+ while (1) switch (_context27.prev = _context27.next) {
3546
3869
  case 0:
3547
- _context25.next = 2;
3870
+ _context27.next = 2;
3548
3871
  return this.store.products.getProduct(id);
3549
3872
  case 2:
3550
- productData = _context25.sent;
3873
+ productData = _context27.sent;
3551
3874
  if (!productData) {
3552
- _context25.next = 9;
3875
+ _context27.next = 9;
3553
3876
  break;
3554
3877
  }
3555
3878
  if (!productData.duration) {
3556
- _context25.next = 6;
3879
+ _context27.next = 6;
3557
3880
  break;
3558
3881
  }
3559
- return _context25.abrupt("return", 'duration');
3882
+ return _context27.abrupt("return", 'duration');
3560
3883
  case 6:
3561
3884
  if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
3562
- _context25.next = 8;
3885
+ _context27.next = 8;
3563
3886
  break;
3564
3887
  }
3565
- return _context25.abrupt("return", 'session');
3888
+ return _context27.abrupt("return", 'session');
3566
3889
  case 8:
3567
- return _context25.abrupt("return", 'normal');
3890
+ return _context27.abrupt("return", 'normal');
3568
3891
  case 9:
3569
- return _context25.abrupt("return", 'normal');
3892
+ return _context27.abrupt("return", 'normal');
3570
3893
  case 10:
3571
3894
  case "end":
3572
- return _context25.stop();
3895
+ return _context27.stop();
3573
3896
  }
3574
- }, _callee25, this);
3897
+ }, _callee26, this);
3575
3898
  }));
3576
- function getProductTypeById(_x20) {
3899
+ function getProductTypeById(_x21) {
3577
3900
  return _getProductTypeById.apply(this, arguments);
3578
3901
  }
3579
3902
  return getProductTypeById;
@@ -3693,12 +4016,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3693
4016
  }, {
3694
4017
  key: "getTimeslotsScheduleByDateRange",
3695
4018
  value: (function () {
3696
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref14) {
4019
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref15) {
3697
4020
  var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
3698
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3699
- while (1) switch (_context26.prev = _context26.next) {
4021
+ return _regeneratorRuntime().wrap(function _callee27$(_context28) {
4022
+ while (1) switch (_context28.prev = _context28.next) {
3700
4023
  case 0:
3701
- startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
4024
+ startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
3702
4025
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
3703
4026
  startDate: startDate,
3704
4027
  endDate: endDate,
@@ -3723,14 +4046,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3723
4046
  resources: resources
3724
4047
  });
3725
4048
  }
3726
- return _context26.abrupt("return", results);
4049
+ return _context28.abrupt("return", results);
3727
4050
  case 9:
3728
4051
  case "end":
3729
- return _context26.stop();
4052
+ return _context28.stop();
3730
4053
  }
3731
- }, _callee26, this);
4054
+ }, _callee27, this);
3732
4055
  }));
3733
- function getTimeslotsScheduleByDateRange(_x21) {
4056
+ function getTimeslotsScheduleByDateRange(_x22) {
3734
4057
  return _getTimeslotsScheduleByDateRange.apply(this, arguments);
3735
4058
  }
3736
4059
  return getTimeslotsScheduleByDateRange;
@@ -3738,7 +4061,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3738
4061
  }, {
3739
4062
  key: "getAvailableDateForSessionOptimize",
3740
4063
  value: function () {
3741
- var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
4064
+ var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3742
4065
  var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
3743
4066
  var params,
3744
4067
  startDate,
@@ -3757,12 +4080,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3757
4080
  openResources,
3758
4081
  allProductResources,
3759
4082
  targetSchedules,
3760
- _loop7,
3761
- _args28 = arguments;
3762
- return _regeneratorRuntime().wrap(function _callee27$(_context28) {
3763
- while (1) switch (_context28.prev = _context28.next) {
4083
+ _loop8,
4084
+ _args30 = arguments;
4085
+ return _regeneratorRuntime().wrap(function _callee28$(_context30) {
4086
+ while (1) switch (_context30.prev = _context30.next) {
3764
4087
  case 0:
3765
- params = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
4088
+ params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
3766
4089
  // 开始日期如果小于今天,直接以今天当做开始日期
3767
4090
  startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
3768
4091
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
@@ -3787,15 +4110,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3787
4110
  // 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
3788
4111
  cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
3789
4112
  if (!cache) {
3790
- _context28.next = 13;
4113
+ _context30.next = 13;
3791
4114
  break;
3792
4115
  }
3793
4116
  if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
3794
- _context28.next = 13;
4117
+ _context30.next = 13;
3795
4118
  break;
3796
4119
  }
3797
4120
  this.store.date.setDateList(cache.dateList);
3798
- return _context28.abrupt("return", {
4121
+ return _context30.abrupt("return", {
3799
4122
  dateList: cache.dateList,
3800
4123
  firstAvailableDate: cache.firstAvailableDate
3801
4124
  });
@@ -3805,7 +4128,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3805
4128
  schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
3806
4129
  filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
3807
4130
  tempResourceIds = getResourcesIdsByProduct(tempProducts);
3808
- _context28.next = 19;
4131
+ _context30.next = 19;
3809
4132
  return this.store.date.fetchResourceDates({
3810
4133
  query: {
3811
4134
  start_date: startDate || '',
@@ -3814,7 +4137,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3814
4137
  }
3815
4138
  });
3816
4139
  case 19:
3817
- res = _context28.sent;
4140
+ res = _context30.sent;
3818
4141
  // 2. 商品 schedule 数据,确定日程在每一天的时间片
3819
4142
  // 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
3820
4143
  dates = [];
@@ -3834,13 +4157,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3834
4157
  }
3835
4158
  });
3836
4159
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
3837
- _loop7 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop7() {
3838
- var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
3839
- return _regeneratorRuntime().wrap(function _loop7$(_context27) {
3840
- while (1) switch (_context27.prev = _context27.next) {
4160
+ _loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
4161
+ var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
4162
+ return _regeneratorRuntime().wrap(function _loop8$(_context29) {
4163
+ while (1) switch (_context29.prev = _context29.next) {
3841
4164
  case 0:
3842
4165
  currentDateStr = currentDate.format('YYYY-MM-DD');
3843
- status = 'available'; // 1. 检查商品的提前量等情况是否满足
4166
+ status = 'available';
4167
+ summaryCount = 0;
4168
+ availableCount = 0; // 1. 检查商品的提前量等情况是否满足
3844
4169
  _checkSessionProductL = checkSessionProductLeadTime(tempProducts), latestStartDate = _checkSessionProductL.latestStartDate, earliestEndDate = _checkSessionProductL.earliestEndDate;
3845
4170
  if (latestStartDate || earliestEndDate) {
3846
4171
  // 如果时间在最早开始时间之前,则设置为不可用
@@ -3866,17 +4191,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3866
4191
  if (status === 'available') {
3867
4192
  minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, currentDateStr);
3868
4193
  scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime); // 同一天内多个时间片下 只要有一个可用则视为可用
3869
- timesSlotCanUse = scheduleTimeSlots.some(function (item) {
4194
+ timesSlotCanUse = false;
4195
+ scheduleTimeSlots.forEach(function (item) {
3870
4196
  // 用来计算资源的可使用情况,针对单个schedule 时间片
3871
4197
  var resourcesUseableMap = {};
3872
4198
  // 遍历产品下启用的资源
3873
4199
  // 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
3874
- return openResources.every(function (resource) {
4200
+ // 求出第一个资源的剩余量和总量
4201
+ // 剩余量=每个资源在每个时间片内剩余之和
4202
+ // 总量=每个资源在每个时间片内资源总量之和
4203
+ var isAllResourceTypesUseable = true;
4204
+ openResources.forEach(function (resource) {
4205
+ // if (!isAllResourceTypesUseable) return;
4206
+
3875
4207
  // 获取当前资源类型的资源列表
3876
4208
  var currentResourcesList = allProductResources.filter(function (n) {
3877
4209
  return n.form_id === resource.resource_type_id;
3878
4210
  });
3879
- return currentResourcesList === null || currentResourcesList === void 0 ? void 0 : currentResourcesList.some(function (m) {
4211
+ var isAnyResourceUseableInType = false;
4212
+ currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
3880
4213
  // 遍历所有资源的上工时间片
3881
4214
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
3882
4215
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
@@ -3884,12 +4217,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3884
4217
  var mTimes = m.times.filter(function (n) {
3885
4218
  return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
3886
4219
  });
4220
+
3887
4221
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
3888
- if (mTimes.length === 0) {
3889
- return;
4222
+ if (mTimes.length === 0) return;
4223
+ // 如果资源可用则把他的容量纳入总计
4224
+ if (resource.type === 'multiple') {
4225
+ summaryCount += m.capacity;
4226
+ } else {
4227
+ summaryCount += 1;
3890
4228
  }
3891
- var targetCanUseTimes = mTimes.some(function (childTiem) {
4229
+ var isAnyTimeSliceUseable = false;
4230
+ mTimes.forEach(function (childTiem) {
3892
4231
  var _tempProducts3;
4232
+ if (isAnyTimeSliceUseable) return;
4233
+
3893
4234
  // 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
3894
4235
  var res = getIsUsableByTimeItem({
3895
4236
  timeSlice: {
@@ -3907,11 +4248,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3907
4248
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
3908
4249
  resourcesUseableMap[m.id] = res.usable;
3909
4250
  }
3910
- return res.usable && !m.onlyComputed;
4251
+ if (res.usable && !m.onlyComputed) {
4252
+ isAnyTimeSliceUseable = true;
4253
+ if (resource.type === 'multiple') {
4254
+ availableCount += res.remainingCapacity;
4255
+ } else {
4256
+ availableCount += 1;
4257
+ }
4258
+ }
4259
+ ;
3911
4260
  });
3912
- return targetCanUseTimes;
4261
+ if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
3913
4262
  });
4263
+ if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
3914
4264
  });
4265
+ if (isAllResourceTypesUseable) timesSlotCanUse = true;
3915
4266
  });
3916
4267
  if (!timesSlotCanUse) {
3917
4268
  status = 'unavailable';
@@ -3920,41 +4271,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3920
4271
  firstAvailableDate = currentDateStr;
3921
4272
  }
3922
4273
  }
4274
+ // 状态: lots_of_space: availableCount / summaryCount > 0.5
4275
+ // filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
4276
+ // sold_out: summaryCount = 0
4277
+ // unavailable: summaryCount > 0 && availableCount = 0
4278
+
4279
+ if (status === 'unavailable') {
4280
+ // dateStatus = 'unavailable'
4281
+ if (availableCount === 0 && summaryCount > 0) dateStatus = 'sold_out';else dateStatus = 'unavailable';
4282
+ } else {
4283
+ usageRatio = availableCount / summaryCount;
4284
+ if (usageRatio > 0.5) dateStatus = 'lots_of_space';else dateStatus = 'filling_up_fast';
4285
+ }
3923
4286
  dates.push({
3924
4287
  date: dayjs(currentDate).format('YYYY-MM-DD'),
3925
4288
  week: dayjs(currentDate).format('ddd'),
3926
4289
  weekNum: dayjs(currentDate).day(),
3927
- status: status
4290
+ summaryCount: summaryCount,
4291
+ availableCount: availableCount,
4292
+ status: dateStatus
3928
4293
  });
3929
4294
 
3930
4295
  // 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
3931
4296
  if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
3932
- _context27.next = 9;
4297
+ _context29.next = 12;
3933
4298
  break;
3934
4299
  }
3935
- return _context27.abrupt("return", 1);
3936
- case 9:
4300
+ return _context29.abrupt("return", 1);
4301
+ case 12:
3937
4302
  currentDate = dayjs(currentDate).add(1, 'day');
3938
- case 10:
4303
+ case 13:
3939
4304
  case "end":
3940
- return _context27.stop();
4305
+ return _context29.stop();
3941
4306
  }
3942
- }, _loop7);
4307
+ }, _loop8);
3943
4308
  });
3944
4309
  case 28:
3945
4310
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
3946
- _context28.next = 34;
4311
+ _context30.next = 34;
3947
4312
  break;
3948
4313
  }
3949
- return _context28.delegateYield(_loop7(), "t0", 30);
4314
+ return _context30.delegateYield(_loop8(), "t0", 30);
3950
4315
  case 30:
3951
- if (!_context28.t0) {
3952
- _context28.next = 32;
4316
+ if (!_context30.t0) {
4317
+ _context30.next = 32;
3953
4318
  break;
3954
4319
  }
3955
- return _context28.abrupt("break", 34);
4320
+ return _context30.abrupt("break", 34);
3956
4321
  case 32:
3957
- _context28.next = 28;
4322
+ _context30.next = 28;
3958
4323
  break;
3959
4324
  case 34:
3960
4325
  // 最终把资源数据也加到日期内
@@ -3969,15 +4334,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3969
4334
  startDate: startDate,
3970
4335
  endDate: dayjs(currentDate).format('YYYY-MM-DD')
3971
4336
  };
3972
- return _context28.abrupt("return", {
4337
+ return _context30.abrupt("return", {
3973
4338
  dateList: dates,
3974
4339
  firstAvailableDate: firstAvailableDate
3975
4340
  });
3976
4341
  case 39:
3977
4342
  case "end":
3978
- return _context28.stop();
4343
+ return _context30.stop();
3979
4344
  }
3980
- }, _callee27, this);
4345
+ }, _callee28, this);
3981
4346
  }));
3982
4347
  function getAvailableDateForSessionOptimize() {
3983
4348
  return _getAvailableDateForSessionOptimize.apply(this, arguments);
@@ -4024,18 +4389,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4024
4389
  }, {
4025
4390
  key: "getContactInfo",
4026
4391
  value: (function () {
4027
- var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4028
- return _regeneratorRuntime().wrap(function _callee28$(_context29) {
4029
- while (1) switch (_context29.prev = _context29.next) {
4392
+ var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4393
+ return _regeneratorRuntime().wrap(function _callee29$(_context31) {
4394
+ while (1) switch (_context31.prev = _context31.next) {
4030
4395
  case 0:
4031
- return _context29.abrupt("return", this.request.get('/customer/metadata', params));
4396
+ return _context31.abrupt("return", this.request.get('/customer/metadata', params));
4032
4397
  case 1:
4033
4398
  case "end":
4034
- return _context29.stop();
4399
+ return _context31.stop();
4035
4400
  }
4036
- }, _callee28, this);
4401
+ }, _callee29, this);
4037
4402
  }));
4038
- function getContactInfo(_x22) {
4403
+ function getContactInfo(_x23) {
4039
4404
  return _getContactInfo.apply(this, arguments);
4040
4405
  }
4041
4406
  return getContactInfo;