@pisell/pisellos 2.1.68 → 2.1.72
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.
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +3 -3
- package/dist/solution/BookingByStep/index.d.ts +18 -1
- package/dist/solution/BookingByStep/index.js +503 -149
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +5 -3
- package/lib/solution/BookingByStep/index.d.ts +18 -1
- package/lib/solution/BookingByStep/index.js +319 -41
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +6 -0
- package/package.json +1 -1
|
@@ -2060,6 +2060,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2060
2060
|
key: "getTimeSlotByAllResources",
|
|
2061
2061
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2062
2062
|
var _dateRange,
|
|
2063
|
+
_dateRange2,
|
|
2063
2064
|
_this12 = this,
|
|
2064
2065
|
_cartItems$,
|
|
2065
2066
|
_cartItems$2,
|
|
@@ -2115,6 +2116,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2115
2116
|
}
|
|
2116
2117
|
});
|
|
2117
2118
|
}
|
|
2119
|
+
// 检查通过购物车 renderList 加入的资源数据里 times 的正确性,如果不对则需要修正
|
|
2120
|
+
if ((_dateRange2 = dateRange) !== null && _dateRange2 !== void 0 && (_dateRange2 = _dateRange2[0]) !== null && _dateRange2 !== void 0 && _dateRange2.date && resources.length) {
|
|
2121
|
+
var _dateRange3;
|
|
2122
|
+
var currentDate = (_dateRange3 = dateRange) === null || _dateRange3 === void 0 || (_dateRange3 = _dateRange3[0]) === null || _dateRange3 === void 0 ? void 0 : _dateRange3.date;
|
|
2123
|
+
var theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
2124
|
+
resources.forEach(function (item) {
|
|
2125
|
+
var noCurrentDateTimes = item.times.some(function (n) {
|
|
2126
|
+
return dayjs(n.start_at).isSame(dayjs(currentDate), 'day');
|
|
2127
|
+
});
|
|
2128
|
+
if (!noCurrentDateTimes) {
|
|
2129
|
+
var _theDateResources$fin;
|
|
2130
|
+
item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin = theDateResources.find(function (n) {
|
|
2131
|
+
return n.id === item.id;
|
|
2132
|
+
})) === null || _theDateResources$fin === void 0 ? void 0 : _theDateResources$fin.times) || [];
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2118
2136
|
var resourcesMap = getResourcesMap(resources);
|
|
2119
2137
|
var duration = 0;
|
|
2120
2138
|
// duration = 不同账号的最长时间
|
|
@@ -2187,12 +2205,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2187
2205
|
}
|
|
2188
2206
|
// 计算容量的辅助函数
|
|
2189
2207
|
var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2208
|
+
var _items$0$_resourceOri;
|
|
2209
|
+
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2210
|
+
var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
|
|
2211
|
+
var sameResourceLength = items.filter(function (item) {
|
|
2212
|
+
var _item$_resourceOrigin;
|
|
2213
|
+
return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
|
|
2214
|
+
}).length;
|
|
2215
|
+
if (sameResourceLength !== items.length) {
|
|
2216
|
+
return 1;
|
|
2217
|
+
}
|
|
2190
2218
|
return items.reduce(function (total, item) {
|
|
2191
2219
|
return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2192
2220
|
}, 0);
|
|
2193
2221
|
};
|
|
2194
2222
|
|
|
2195
|
-
//
|
|
2223
|
+
// 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
|
|
2196
2224
|
var maxCapacity = 1;
|
|
2197
2225
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2198
2226
|
accountList.forEach(function (account) {
|
|
@@ -2220,13 +2248,256 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2220
2248
|
});
|
|
2221
2249
|
return timeSlots;
|
|
2222
2250
|
}
|
|
2251
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
2252
|
+
}, {
|
|
2253
|
+
key: "getTimeSlotByAllResourcesForDate",
|
|
2254
|
+
value: function () {
|
|
2255
|
+
var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
|
|
2256
|
+
var _this13 = this,
|
|
2257
|
+
_cartItems$5,
|
|
2258
|
+
_cartItems$6,
|
|
2259
|
+
_this$shopStore$get2;
|
|
2260
|
+
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;
|
|
2261
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context25) {
|
|
2262
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2263
|
+
case 0:
|
|
2264
|
+
resources_code = _ref10.resources_code, startDate = _ref10.startDate, endDate = _ref10.endDate;
|
|
2265
|
+
// 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
|
|
2266
|
+
if (dayjs(endDate).diff(dayjs(startDate), 'day') < 30) {
|
|
2267
|
+
endDate = dayjs(startDate).add(30, 'day').format('YYYY-MM-DD');
|
|
2268
|
+
}
|
|
2269
|
+
// 预请求资源数据,防止日期超过之前选择的范围
|
|
2270
|
+
_context25.next = 4;
|
|
2271
|
+
return this.getAvailableDate({
|
|
2272
|
+
startDate: startDate,
|
|
2273
|
+
endDate: endDate,
|
|
2274
|
+
useCache: true
|
|
2275
|
+
});
|
|
2276
|
+
case 4:
|
|
2277
|
+
// 取出购物车中所有一已选择的第一步资源
|
|
2278
|
+
resources = [];
|
|
2279
|
+
cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2280
|
+
return !isNormalProduct(n._productOrigin);
|
|
2281
|
+
}); // if (cartItems?.[0].start_date) return [];
|
|
2282
|
+
resourceIds = [];
|
|
2283
|
+
resourcesTypeId = undefined;
|
|
2284
|
+
isSingleResource = false; // 找出购物车里最大的 cut_off_time
|
|
2285
|
+
maxCutOffTime = undefined;
|
|
2286
|
+
maxCutOffTimeValue = dayjs();
|
|
2287
|
+
cartItems.forEach(function (item) {
|
|
2288
|
+
var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
|
|
2289
|
+
(_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) {
|
|
2290
|
+
// TODO: 少了个 status 的判断
|
|
2291
|
+
if (n.code === resources_code) {
|
|
2292
|
+
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
2293
|
+
isSingleResource = n.type === 'single';
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
// item._origin.resources?.forEach((n: any) => {
|
|
2297
|
+
// resourceIds.push(n.relation_id);
|
|
2298
|
+
// });
|
|
2299
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2300
|
+
resourceIds.push(item.resource_id);
|
|
2301
|
+
}
|
|
2302
|
+
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) {
|
|
2303
|
+
return n.code === resources_code;
|
|
2304
|
+
})) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
|
|
2305
|
+
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') {
|
|
2306
|
+
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2307
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2308
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
2309
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2223
2313
|
|
|
2224
|
-
|
|
2314
|
+
// 保护: 如果 resources 为空则直接 return
|
|
2315
|
+
if (resources.length) {
|
|
2316
|
+
_context25.next = 14;
|
|
2317
|
+
break;
|
|
2318
|
+
}
|
|
2319
|
+
return _context25.abrupt("return", []);
|
|
2320
|
+
case 14:
|
|
2321
|
+
duration = 0; // duration = 不同账号的最长时间
|
|
2322
|
+
accountList = this.store.accountList.getAccounts();
|
|
2323
|
+
checkDuration = function checkDuration(cartItems) {
|
|
2324
|
+
var accountDuration = 0;
|
|
2325
|
+
cartItems.forEach(function (item) {
|
|
2326
|
+
// 单个预约累加账号 多个预约取最大值
|
|
2327
|
+
if (isSingleResource) {
|
|
2328
|
+
var _item$_productOrigin21;
|
|
2329
|
+
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;
|
|
2330
|
+
} else {
|
|
2331
|
+
var _item$_productOrigin22;
|
|
2332
|
+
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)) {
|
|
2333
|
+
var _item$_productOrigin23;
|
|
2334
|
+
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;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
if (accountDuration > duration) {
|
|
2339
|
+
duration = accountDuration;
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2343
|
+
accountList.forEach(function (account) {
|
|
2344
|
+
var cartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2345
|
+
checkDuration(cartItems);
|
|
2346
|
+
});
|
|
2347
|
+
} else {
|
|
2348
|
+
checkDuration(cartItems);
|
|
2349
|
+
}
|
|
2350
|
+
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
2351
|
+
// 同时 session 类商品的流程也不应该调用这个方法
|
|
2352
|
+
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))) {
|
|
2353
|
+
_context25.next = 20;
|
|
2354
|
+
break;
|
|
2355
|
+
}
|
|
2356
|
+
return _context25.abrupt("return", []);
|
|
2357
|
+
case 20:
|
|
2358
|
+
resourcesUseableMap = {};
|
|
2359
|
+
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2360
|
+
var _item$_productOrigin24;
|
|
2361
|
+
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';
|
|
2362
|
+
});
|
|
2363
|
+
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 的值
|
|
2364
|
+
maxBlockThreshold = 0;
|
|
2365
|
+
if (hasFlexibleDuration) {
|
|
2366
|
+
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2367
|
+
var _item$_productOrigin25;
|
|
2368
|
+
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2369
|
+
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) {
|
|
2370
|
+
var _item$_productOrigin26;
|
|
2371
|
+
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);
|
|
2372
|
+
}
|
|
2373
|
+
return 0;
|
|
2374
|
+
}, 0);
|
|
2375
|
+
}
|
|
2376
|
+
// 计算容量的辅助函数
|
|
2377
|
+
calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2378
|
+
var _items$0$_resourceOri2;
|
|
2379
|
+
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2380
|
+
var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
|
|
2381
|
+
var sameResourceLength = items.filter(function (item) {
|
|
2382
|
+
var _item$_resourceOrigin2;
|
|
2383
|
+
return ((_item$_resourceOrigin2 = item._resourceOrigin) === null || _item$_resourceOrigin2 === void 0 ? void 0 : _item$_resourceOrigin2[0].id) === firstResource;
|
|
2384
|
+
}).length;
|
|
2385
|
+
if (sameResourceLength !== items.length) {
|
|
2386
|
+
return 1;
|
|
2387
|
+
}
|
|
2388
|
+
return items.reduce(function (total, item) {
|
|
2389
|
+
return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2390
|
+
}, 0);
|
|
2391
|
+
}; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2392
|
+
maxCapacity = 1;
|
|
2393
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2394
|
+
accountList.forEach(function (account) {
|
|
2395
|
+
var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2396
|
+
var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
2397
|
+
if (currentCapacity > maxCapacity) {
|
|
2398
|
+
maxCapacity = currentCapacity;
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
} else {
|
|
2402
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
2403
|
+
}
|
|
2404
|
+
arr = [];
|
|
2405
|
+
today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
|
|
2406
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
2407
|
+
var currentDate, theDateResources, resourcesMap, timeSlots;
|
|
2408
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context24) {
|
|
2409
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2410
|
+
case 0:
|
|
2411
|
+
currentDate = i.format('YYYY-MM-DD');
|
|
2412
|
+
theDateResources = _this13.store.date.getResourcesListByDate(currentDate);
|
|
2413
|
+
resources.forEach(function (item) {
|
|
2414
|
+
var _theDateResources$fin2;
|
|
2415
|
+
item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin2 = theDateResources.find(function (n) {
|
|
2416
|
+
return n.id === item.id;
|
|
2417
|
+
})) === null || _theDateResources$fin2 === void 0 ? void 0 : _theDateResources$fin2.times) || [];
|
|
2418
|
+
});
|
|
2419
|
+
resourcesMap = getResourcesMap(resources); // 如果日期已经过期则直接标记为不可用
|
|
2420
|
+
if (!i.isBefore(today)) {
|
|
2421
|
+
_context24.next = 7;
|
|
2422
|
+
break;
|
|
2423
|
+
}
|
|
2424
|
+
arr.push({
|
|
2425
|
+
date: currentDate,
|
|
2426
|
+
status: 'unavailable',
|
|
2427
|
+
week: i.format('ddd'),
|
|
2428
|
+
weekNum: i.day()
|
|
2429
|
+
});
|
|
2430
|
+
return _context24.abrupt("return", 1);
|
|
2431
|
+
case 7:
|
|
2432
|
+
timeSlots = getTimeSlicesByResources({
|
|
2433
|
+
resourceIds: resourceIds,
|
|
2434
|
+
resourcesMap: resourcesMap,
|
|
2435
|
+
duration: duration,
|
|
2436
|
+
currentDate: currentDate,
|
|
2437
|
+
split: 10,
|
|
2438
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2439
|
+
capacity: maxCapacity,
|
|
2440
|
+
cut_off_time: maxCutOffTime,
|
|
2441
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2442
|
+
operating_day_boundary: operating_day_boundary,
|
|
2443
|
+
maxBlockThreshold: maxBlockThreshold
|
|
2444
|
+
});
|
|
2445
|
+
if (timeSlots.length > 0) {
|
|
2446
|
+
arr.push({
|
|
2447
|
+
date: currentDate,
|
|
2448
|
+
status: 'available',
|
|
2449
|
+
week: i.format('ddd'),
|
|
2450
|
+
weekNum: i.day()
|
|
2451
|
+
});
|
|
2452
|
+
} else {
|
|
2453
|
+
arr.push({
|
|
2454
|
+
date: currentDate,
|
|
2455
|
+
status: 'unavailable',
|
|
2456
|
+
week: i.format('ddd'),
|
|
2457
|
+
weekNum: i.day()
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
case 9:
|
|
2461
|
+
case "end":
|
|
2462
|
+
return _context24.stop();
|
|
2463
|
+
}
|
|
2464
|
+
}, _loop2);
|
|
2465
|
+
});
|
|
2466
|
+
i = dayjs(startDate);
|
|
2467
|
+
case 32:
|
|
2468
|
+
if (!i.isBefore(dayjs(endDate))) {
|
|
2469
|
+
_context25.next = 39;
|
|
2470
|
+
break;
|
|
2471
|
+
}
|
|
2472
|
+
return _context25.delegateYield(_loop2(), "t0", 34);
|
|
2473
|
+
case 34:
|
|
2474
|
+
if (!_context25.t0) {
|
|
2475
|
+
_context25.next = 36;
|
|
2476
|
+
break;
|
|
2477
|
+
}
|
|
2478
|
+
return _context25.abrupt("continue", 36);
|
|
2479
|
+
case 36:
|
|
2480
|
+
i = i.add(1, 'day');
|
|
2481
|
+
_context25.next = 32;
|
|
2482
|
+
break;
|
|
2483
|
+
case 39:
|
|
2484
|
+
return _context25.abrupt("return", arr);
|
|
2485
|
+
case 40:
|
|
2486
|
+
case "end":
|
|
2487
|
+
return _context25.stop();
|
|
2488
|
+
}
|
|
2489
|
+
}, _callee24, this);
|
|
2490
|
+
}));
|
|
2491
|
+
function getTimeSlotByAllResourcesForDate(_x19) {
|
|
2492
|
+
return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
|
|
2493
|
+
}
|
|
2494
|
+
return getTimeSlotByAllResourcesForDate;
|
|
2495
|
+
}() // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2225
2496
|
}, {
|
|
2226
2497
|
key: "submitTimeSlot",
|
|
2227
2498
|
value: function submitTimeSlot(timeSlots) {
|
|
2228
|
-
var _this$shopStore$
|
|
2229
|
-
|
|
2499
|
+
var _this$shopStore$get3,
|
|
2500
|
+
_this14 = this;
|
|
2230
2501
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2231
2502
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2232
2503
|
return !isNormalProduct(n._productOrigin);
|
|
@@ -2246,7 +2517,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2246
2517
|
}, {});
|
|
2247
2518
|
|
|
2248
2519
|
// 店铺营业结束时间
|
|
2249
|
-
var operating_day_boundary = (_this$shopStore$
|
|
2520
|
+
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;
|
|
2250
2521
|
|
|
2251
2522
|
// 处理每个账号的商品
|
|
2252
2523
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
@@ -2256,10 +2527,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2256
2527
|
var osWarnTips = [];
|
|
2257
2528
|
var newResources = cloneDeep(item._origin.resources);
|
|
2258
2529
|
newResources.forEach(function (resource) {
|
|
2259
|
-
var _item$
|
|
2530
|
+
var _item$_productOrigin27;
|
|
2260
2531
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2261
|
-
if (((_item$
|
|
2262
|
-
var _allResources$find, _item$
|
|
2532
|
+
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') {
|
|
2533
|
+
var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
|
|
2263
2534
|
item.duration = {
|
|
2264
2535
|
type: 'minutes',
|
|
2265
2536
|
value: 10
|
|
@@ -2289,19 +2560,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2289
2560
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2290
2561
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2291
2562
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2292
|
-
if ((_item$
|
|
2563
|
+
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))) {
|
|
2293
2564
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2294
2565
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2295
2566
|
}
|
|
2296
2567
|
}
|
|
2297
2568
|
} else {
|
|
2298
|
-
var _item$
|
|
2569
|
+
var _item$_productOrigin30;
|
|
2299
2570
|
resource.startTime = currentStartTime;
|
|
2300
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2571
|
+
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');
|
|
2301
2572
|
}
|
|
2302
2573
|
// delete resource.times;
|
|
2303
2574
|
});
|
|
2304
|
-
|
|
2575
|
+
_this14.store.cart.updateItem({
|
|
2305
2576
|
_id: item._id,
|
|
2306
2577
|
resources: newResources,
|
|
2307
2578
|
osWarnTips: osWarnTips
|
|
@@ -2345,42 +2616,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2345
2616
|
}, {
|
|
2346
2617
|
key: "openProductDetail",
|
|
2347
2618
|
value: function () {
|
|
2348
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2619
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
2349
2620
|
var targetProductData, newScheduleArr, dateRange;
|
|
2350
|
-
return _regeneratorRuntime().wrap(function
|
|
2351
|
-
while (1) switch (
|
|
2621
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context26) {
|
|
2622
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2352
2623
|
case 0:
|
|
2353
|
-
|
|
2624
|
+
_context26.next = 2;
|
|
2354
2625
|
return this.store.products.getProduct(productId);
|
|
2355
2626
|
case 2:
|
|
2356
|
-
targetProductData =
|
|
2627
|
+
targetProductData = _context26.sent;
|
|
2357
2628
|
if (!targetProductData) {
|
|
2358
|
-
|
|
2629
|
+
_context26.next = 17;
|
|
2359
2630
|
break;
|
|
2360
2631
|
}
|
|
2361
2632
|
this.store.currentProduct = targetProductData;
|
|
2362
2633
|
this.store.currentProductMeta = {};
|
|
2363
2634
|
// 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
|
|
2364
2635
|
if (!targetProductData['schedule.ids']) {
|
|
2365
|
-
|
|
2636
|
+
_context26.next = 12;
|
|
2366
2637
|
break;
|
|
2367
2638
|
}
|
|
2368
2639
|
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2369
2640
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
2370
2641
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
2371
|
-
|
|
2642
|
+
_context26.next = 17;
|
|
2372
2643
|
break;
|
|
2373
2644
|
case 12:
|
|
2374
2645
|
if (!targetProductData.duration) {
|
|
2375
|
-
|
|
2646
|
+
_context26.next = 17;
|
|
2376
2647
|
break;
|
|
2377
2648
|
}
|
|
2378
2649
|
dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
|
|
2379
2650
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
2380
|
-
|
|
2651
|
+
_context26.next = 16;
|
|
2381
2652
|
break;
|
|
2382
2653
|
}
|
|
2383
|
-
return
|
|
2654
|
+
return _context26.abrupt("return");
|
|
2384
2655
|
case 16:
|
|
2385
2656
|
// this.store.date.getResourceDates({
|
|
2386
2657
|
// query: {
|
|
@@ -2396,11 +2667,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2396
2667
|
});
|
|
2397
2668
|
case 17:
|
|
2398
2669
|
case "end":
|
|
2399
|
-
return
|
|
2670
|
+
return _context26.stop();
|
|
2400
2671
|
}
|
|
2401
|
-
},
|
|
2672
|
+
}, _callee25, this);
|
|
2402
2673
|
}));
|
|
2403
|
-
function openProductDetail(
|
|
2674
|
+
function openProductDetail(_x20) {
|
|
2404
2675
|
return _openProductDetail.apply(this, arguments);
|
|
2405
2676
|
}
|
|
2406
2677
|
return openProductDetail;
|
|
@@ -2417,14 +2688,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2417
2688
|
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
2418
2689
|
}, {
|
|
2419
2690
|
key: "getTimeslotBySchedule",
|
|
2420
|
-
value: function getTimeslotBySchedule(
|
|
2691
|
+
value: function getTimeslotBySchedule(_ref11) {
|
|
2421
2692
|
var _this$store$currentPr2,
|
|
2422
2693
|
_targetProductData$pr,
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2694
|
+
_targetProductData$pr2,
|
|
2695
|
+
_this15 = this;
|
|
2696
|
+
var date = _ref11.date,
|
|
2697
|
+
scheduleIds = _ref11.scheduleIds,
|
|
2698
|
+
resources = _ref11.resources,
|
|
2699
|
+
product = _ref11.product;
|
|
2428
2700
|
var targetProduct = this.store.currentProduct;
|
|
2429
2701
|
// 如果外面传递了product 优先用外面的
|
|
2430
2702
|
var targetProductData = product || targetProduct;
|
|
@@ -2463,7 +2735,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2463
2735
|
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) {
|
|
2464
2736
|
return n.status === 1;
|
|
2465
2737
|
})) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.id;
|
|
2466
|
-
|
|
2738
|
+
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) {
|
|
2739
|
+
return n.status === 1 && n.id === firstEnabledResourceId;
|
|
2740
|
+
});
|
|
2741
|
+
var isMultipleBooking = (firstEnabledResourceConfig === null || firstEnabledResourceConfig === void 0 ? void 0 : firstEnabledResourceConfig.type) === 'multiple';
|
|
2467
2742
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2468
2743
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2469
2744
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
@@ -2471,6 +2746,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2471
2746
|
var count = 0;
|
|
2472
2747
|
var bookingLeft = 0;
|
|
2473
2748
|
var summaryCount = 0;
|
|
2749
|
+
var summaryConfigCount = 0;
|
|
2474
2750
|
// 遍历所有资源
|
|
2475
2751
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2476
2752
|
// 遍历所有资源的上工时间片
|
|
@@ -2484,9 +2760,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2484
2760
|
// n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
|
|
2485
2761
|
// item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
|
|
2486
2762
|
// 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
|
|
2487
|
-
//
|
|
2763
|
+
// 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
|
|
2764
|
+
// https://project.feishu.cn/v2qint/bug/detail/6657165010
|
|
2488
2765
|
var mTimes = m.times.filter(function (n) {
|
|
2489
|
-
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');
|
|
2766
|
+
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');
|
|
2490
2767
|
});
|
|
2491
2768
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2492
2769
|
if (mTimes.length === 0) {
|
|
@@ -2518,6 +2795,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2518
2795
|
}
|
|
2519
2796
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2520
2797
|
});
|
|
2798
|
+
if (m.form_id === firstEnabledResourceId) {
|
|
2799
|
+
// 确认当前资源是单个预约还是多个预约,单个预约则只需要计数,多个预约才添加容量
|
|
2800
|
+
if (isMultipleBooking) {
|
|
2801
|
+
summaryConfigCount += m.capacity;
|
|
2802
|
+
} else {
|
|
2803
|
+
summaryConfigCount += 1;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2521
2806
|
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
2522
2807
|
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
2523
2808
|
return n === false;
|
|
@@ -2534,7 +2819,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2534
2819
|
}
|
|
2535
2820
|
});
|
|
2536
2821
|
// 容量检测
|
|
2537
|
-
var cartItems =
|
|
2822
|
+
var cartItems = _this15.store.cart.getItems();
|
|
2538
2823
|
productResources.forEach(function (n) {
|
|
2539
2824
|
// 单个预约检测规则:
|
|
2540
2825
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
@@ -2553,13 +2838,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2553
2838
|
}
|
|
2554
2839
|
// 规则 2
|
|
2555
2840
|
var otherCartItems = cartItems.filter(function (m) {
|
|
2556
|
-
var _m$_productOrigin2, _targetProductData$id2;
|
|
2557
|
-
|
|
2841
|
+
var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
|
|
2842
|
+
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;
|
|
2843
|
+
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) {
|
|
2844
|
+
return m.type === n.type && m.status === 1;
|
|
2845
|
+
});
|
|
2846
|
+
return isTimeMatch && isResourceMatch;
|
|
2558
2847
|
});
|
|
2559
2848
|
otherCartItems.forEach(function (m) {
|
|
2560
|
-
var _m$
|
|
2561
|
-
var sameTypeResources = (_m$
|
|
2562
|
-
return m.type === n.type;
|
|
2849
|
+
var _m$_productOrigin4;
|
|
2850
|
+
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) {
|
|
2851
|
+
return m.type === n.type && m.status === 1;
|
|
2563
2852
|
});
|
|
2564
2853
|
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) || [])));
|
|
2565
2854
|
// 把sameTypeResourcesSet 加到currentResourcesSet
|
|
@@ -2568,7 +2857,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2568
2857
|
});
|
|
2569
2858
|
});
|
|
2570
2859
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
2571
|
-
var currentDataResources =
|
|
2860
|
+
var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
2572
2861
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
2573
2862
|
if (currentResourcesSet.has(m.id)) {
|
|
2574
2863
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -2590,8 +2879,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2590
2879
|
// 多个预约的检测规则:
|
|
2591
2880
|
// 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
|
|
2592
2881
|
var _sameCartItems = cartItems.filter(function (m) {
|
|
2593
|
-
var _m$
|
|
2594
|
-
return ((_m$
|
|
2882
|
+
var _m$_productOrigin5, _targetProductData$id3;
|
|
2883
|
+
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;
|
|
2595
2884
|
});
|
|
2596
2885
|
var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
|
|
2597
2886
|
return acc + getCapacityInfoByCartItem(curr).currentCapacity;
|
|
@@ -2616,8 +2905,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2616
2905
|
return !m.onlyComputed;
|
|
2617
2906
|
}));
|
|
2618
2907
|
otherSameTimesCartItems.forEach(function (m) {
|
|
2619
|
-
var _m$
|
|
2620
|
-
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$
|
|
2908
|
+
var _m$_productOrigin6;
|
|
2909
|
+
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);
|
|
2621
2910
|
productResources.forEach(function (m) {
|
|
2622
2911
|
if (m.id === n.id) {
|
|
2623
2912
|
m.renderList.forEach(function (n) {
|
|
@@ -2672,6 +2961,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2672
2961
|
});
|
|
2673
2962
|
var startDayJs = dayjs(item.start);
|
|
2674
2963
|
var endDayJs = dayjs(item.end);
|
|
2964
|
+
|
|
2965
|
+
// 状态
|
|
2966
|
+
// 如果是isMultipleBooking
|
|
2967
|
+
// lots_of_space: summaryCount / summaryConfigCount > 0.5
|
|
2968
|
+
// filling_up_fast: summaryCount / summaryConfigCount <= 0.5 && summaryCount > 0
|
|
2969
|
+
// sold_out: bookingLeft = 0
|
|
2970
|
+
// 如果不是isMultipleBooking
|
|
2971
|
+
// lots_of_space: bookingLeft / summaryConfigCount > 0.5
|
|
2972
|
+
// filling_up_fast: bookingLeft / summaryConfigCount <= 0.5 && count > 0
|
|
2973
|
+
// sold_out: bookingLeft = 0
|
|
2974
|
+
var timeStatus = 'sold_out';
|
|
2975
|
+
if (bookingLeft === 0) timeStatus = 'sold_out';else if (isMultipleBooking) {
|
|
2976
|
+
if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
|
|
2977
|
+
var usageRatio = summaryCount / summaryConfigCount;
|
|
2978
|
+
if (usageRatio > 0.5) timeStatus = 'lots_of_space';else if (summaryCount > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2979
|
+
}
|
|
2980
|
+
} else {
|
|
2981
|
+
if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
|
|
2982
|
+
var _usageRatio = bookingLeft / summaryConfigCount;
|
|
2983
|
+
if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2675
2986
|
return {
|
|
2676
2987
|
start_time: startDayJs.format('HH:mm'),
|
|
2677
2988
|
end_time: endDayJs.format('HH:mm'),
|
|
@@ -2679,7 +2990,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2679
2990
|
end_at: endDayJs,
|
|
2680
2991
|
count: count,
|
|
2681
2992
|
left: bookingLeft,
|
|
2682
|
-
summaryCount: summaryCount
|
|
2993
|
+
summaryCount: summaryCount,
|
|
2994
|
+
status: timeStatus
|
|
2683
2995
|
};
|
|
2684
2996
|
});
|
|
2685
2997
|
return formatScheduleTimeSlots;
|
|
@@ -2720,7 +3032,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2720
3032
|
}));
|
|
2721
3033
|
|
|
2722
3034
|
// 与其他资源的时间段求交集
|
|
2723
|
-
var
|
|
3035
|
+
var _loop3 = function _loop3() {
|
|
2724
3036
|
var currentResourceSlots = allTimeSlots[i];
|
|
2725
3037
|
var intersections = [];
|
|
2726
3038
|
|
|
@@ -2749,7 +3061,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2749
3061
|
}));
|
|
2750
3062
|
};
|
|
2751
3063
|
for (var i = 1; i < allTimeSlots.length; i++) {
|
|
2752
|
-
if (
|
|
3064
|
+
if (_loop3()) continue;
|
|
2753
3065
|
}
|
|
2754
3066
|
|
|
2755
3067
|
// 格式化返回结果
|
|
@@ -2765,7 +3077,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2765
3077
|
}, {
|
|
2766
3078
|
key: "checkMaxDurationCapacity",
|
|
2767
3079
|
value: function checkMaxDurationCapacity() {
|
|
2768
|
-
var
|
|
3080
|
+
var _this16 = this;
|
|
2769
3081
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
2770
3082
|
return !isNormalProduct(item._productOrigin);
|
|
2771
3083
|
});
|
|
@@ -2855,7 +3167,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2855
3167
|
var processedCartItemIds = new Set();
|
|
2856
3168
|
|
|
2857
3169
|
// 先检查所有资源类型,收集可用数量信息
|
|
2858
|
-
var
|
|
3170
|
+
var _loop4 = function _loop4() {
|
|
2859
3171
|
var _resourceTypeConfig;
|
|
2860
3172
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
2861
3173
|
resourceCode = _Object$entries$_i[0],
|
|
@@ -2971,7 +3283,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2971
3283
|
}));
|
|
2972
3284
|
|
|
2973
3285
|
// 找到所有资源都可用的时间段
|
|
2974
|
-
var commonTimeSlots =
|
|
3286
|
+
var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2975
3287
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
2976
3288
|
if (commonTimeSlots.length === 0) {
|
|
2977
3289
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3002,7 +3314,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3002
3314
|
},
|
|
3003
3315
|
_ret2;
|
|
3004
3316
|
for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
|
|
3005
|
-
_ret2 =
|
|
3317
|
+
_ret2 = _loop4();
|
|
3006
3318
|
if (_ret2) return _ret2.v;
|
|
3007
3319
|
}
|
|
3008
3320
|
|
|
@@ -3046,7 +3358,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3046
3358
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3047
3359
|
});
|
|
3048
3360
|
// 检查每个时间段是否有足够的资源容量
|
|
3049
|
-
var
|
|
3361
|
+
var _loop5 = function _loop5() {
|
|
3050
3362
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3051
3363
|
timeSlotKey = _Object$entries2$_i[0],
|
|
3052
3364
|
itemsInTimeSlot = _Object$entries2$_i[1];
|
|
@@ -3064,8 +3376,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3064
3376
|
var resourcesIdSet = new Set();
|
|
3065
3377
|
|
|
3066
3378
|
// 获取资源数据
|
|
3067
|
-
var dateRange =
|
|
3068
|
-
var resourcesDates =
|
|
3379
|
+
var dateRange = _this16.store.date.getDateRange();
|
|
3380
|
+
var resourcesDates = _this16.store.date.getDateList();
|
|
3069
3381
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3070
3382
|
return n.date === startDate;
|
|
3071
3383
|
});
|
|
@@ -3102,7 +3414,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3102
3414
|
},
|
|
3103
3415
|
_ret3;
|
|
3104
3416
|
for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
|
|
3105
|
-
_ret3 =
|
|
3417
|
+
_ret3 = _loop5();
|
|
3106
3418
|
if (_ret3 === 0) continue;
|
|
3107
3419
|
if (_ret3) return _ret3.v;
|
|
3108
3420
|
}
|
|
@@ -3121,17 +3433,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3121
3433
|
*/
|
|
3122
3434
|
}, {
|
|
3123
3435
|
key: "convertProductToCartItem",
|
|
3124
|
-
value: function convertProductToCartItem(
|
|
3125
|
-
var product =
|
|
3126
|
-
date =
|
|
3127
|
-
account =
|
|
3128
|
-
var
|
|
3129
|
-
bundle =
|
|
3130
|
-
options =
|
|
3131
|
-
origin =
|
|
3132
|
-
product_variant_id =
|
|
3133
|
-
|
|
3134
|
-
quantity =
|
|
3436
|
+
value: function convertProductToCartItem(_ref12) {
|
|
3437
|
+
var product = _ref12.product,
|
|
3438
|
+
date = _ref12.date,
|
|
3439
|
+
account = _ref12.account;
|
|
3440
|
+
var _ref13 = product || {},
|
|
3441
|
+
bundle = _ref13.bundle,
|
|
3442
|
+
options = _ref13.options,
|
|
3443
|
+
origin = _ref13.origin,
|
|
3444
|
+
product_variant_id = _ref13.product_variant_id,
|
|
3445
|
+
_ref13$quantity = _ref13.quantity,
|
|
3446
|
+
quantity = _ref13$quantity === void 0 ? 1 : _ref13$quantity;
|
|
3135
3447
|
|
|
3136
3448
|
// 处理商品数据,类似 addProductToCart 中的逻辑
|
|
3137
3449
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -3186,11 +3498,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3186
3498
|
}
|
|
3187
3499
|
}, {
|
|
3188
3500
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3189
|
-
value: function checkMaxDurationCapacityForDetailNums(
|
|
3190
|
-
var
|
|
3191
|
-
var product =
|
|
3192
|
-
date =
|
|
3193
|
-
account =
|
|
3501
|
+
value: function checkMaxDurationCapacityForDetailNums(_ref14) {
|
|
3502
|
+
var _this17 = this;
|
|
3503
|
+
var product = _ref14.product,
|
|
3504
|
+
date = _ref14.date,
|
|
3505
|
+
account = _ref14.account;
|
|
3194
3506
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3195
3507
|
return !isNormalProduct(item._productOrigin);
|
|
3196
3508
|
});
|
|
@@ -3288,7 +3600,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3288
3600
|
var processedCartItemIds = new Set();
|
|
3289
3601
|
|
|
3290
3602
|
// 先检查所有资源类型,收集可用数量信息
|
|
3291
|
-
var
|
|
3603
|
+
var _loop6 = function _loop6() {
|
|
3292
3604
|
var _resourceTypeConfig2;
|
|
3293
3605
|
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
3294
3606
|
resourceCode = _Object$entries3$_i[0],
|
|
@@ -3404,7 +3716,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3404
3716
|
}));
|
|
3405
3717
|
|
|
3406
3718
|
// 找到所有资源都可用的时间段
|
|
3407
|
-
var commonTimeSlots =
|
|
3719
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3408
3720
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3409
3721
|
if (commonTimeSlots.length === 0) {
|
|
3410
3722
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3435,7 +3747,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3435
3747
|
},
|
|
3436
3748
|
_ret4;
|
|
3437
3749
|
for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
|
|
3438
|
-
_ret4 =
|
|
3750
|
+
_ret4 = _loop6();
|
|
3439
3751
|
if (_ret4) return _ret4.v;
|
|
3440
3752
|
}
|
|
3441
3753
|
|
|
@@ -3479,7 +3791,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3479
3791
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3480
3792
|
});
|
|
3481
3793
|
// 检查每个时间段是否有足够的资源容量
|
|
3482
|
-
var
|
|
3794
|
+
var _loop7 = function _loop7() {
|
|
3483
3795
|
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
3484
3796
|
timeSlotKey = _Object$entries4$_i[0],
|
|
3485
3797
|
itemsInTimeSlot = _Object$entries4$_i[1];
|
|
@@ -3498,7 +3810,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3498
3810
|
|
|
3499
3811
|
// 获取资源数据
|
|
3500
3812
|
// const dateRange = this.store.date.getDateRange();
|
|
3501
|
-
var resourcesDates =
|
|
3813
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3502
3814
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3503
3815
|
return n.date === startDate;
|
|
3504
3816
|
});
|
|
@@ -3535,7 +3847,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3535
3847
|
},
|
|
3536
3848
|
_ret5;
|
|
3537
3849
|
for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
|
|
3538
|
-
_ret5 =
|
|
3850
|
+
_ret5 = _loop7();
|
|
3539
3851
|
if (_ret5 === 0) continue;
|
|
3540
3852
|
if (_ret5) return _ret5.v;
|
|
3541
3853
|
}
|
|
@@ -3568,41 +3880,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3568
3880
|
}, {
|
|
3569
3881
|
key: "getProductTypeById",
|
|
3570
3882
|
value: function () {
|
|
3571
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3883
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
3572
3884
|
var productData, _productData$schedule;
|
|
3573
|
-
return _regeneratorRuntime().wrap(function
|
|
3574
|
-
while (1) switch (
|
|
3885
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
3886
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3575
3887
|
case 0:
|
|
3576
|
-
|
|
3888
|
+
_context27.next = 2;
|
|
3577
3889
|
return this.store.products.getProduct(id);
|
|
3578
3890
|
case 2:
|
|
3579
|
-
productData =
|
|
3891
|
+
productData = _context27.sent;
|
|
3580
3892
|
if (!productData) {
|
|
3581
|
-
|
|
3893
|
+
_context27.next = 9;
|
|
3582
3894
|
break;
|
|
3583
3895
|
}
|
|
3584
3896
|
if (!productData.duration) {
|
|
3585
|
-
|
|
3897
|
+
_context27.next = 6;
|
|
3586
3898
|
break;
|
|
3587
3899
|
}
|
|
3588
|
-
return
|
|
3900
|
+
return _context27.abrupt("return", 'duration');
|
|
3589
3901
|
case 6:
|
|
3590
3902
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
3591
|
-
|
|
3903
|
+
_context27.next = 8;
|
|
3592
3904
|
break;
|
|
3593
3905
|
}
|
|
3594
|
-
return
|
|
3906
|
+
return _context27.abrupt("return", 'session');
|
|
3595
3907
|
case 8:
|
|
3596
|
-
return
|
|
3908
|
+
return _context27.abrupt("return", 'normal');
|
|
3597
3909
|
case 9:
|
|
3598
|
-
return
|
|
3910
|
+
return _context27.abrupt("return", 'normal');
|
|
3599
3911
|
case 10:
|
|
3600
3912
|
case "end":
|
|
3601
|
-
return
|
|
3913
|
+
return _context27.stop();
|
|
3602
3914
|
}
|
|
3603
|
-
},
|
|
3915
|
+
}, _callee26, this);
|
|
3604
3916
|
}));
|
|
3605
|
-
function getProductTypeById(
|
|
3917
|
+
function getProductTypeById(_x21) {
|
|
3606
3918
|
return _getProductTypeById.apply(this, arguments);
|
|
3607
3919
|
}
|
|
3608
3920
|
return getProductTypeById;
|
|
@@ -3722,12 +4034,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3722
4034
|
}, {
|
|
3723
4035
|
key: "getTimeslotsScheduleByDateRange",
|
|
3724
4036
|
value: (function () {
|
|
3725
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4037
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref15) {
|
|
3726
4038
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
3727
|
-
return _regeneratorRuntime().wrap(function
|
|
3728
|
-
while (1) switch (
|
|
4039
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
4040
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3729
4041
|
case 0:
|
|
3730
|
-
startDate =
|
|
4042
|
+
startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
|
|
3731
4043
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
3732
4044
|
startDate: startDate,
|
|
3733
4045
|
endDate: endDate,
|
|
@@ -3752,14 +4064,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
4064
|
resources: resources
|
|
3753
4065
|
});
|
|
3754
4066
|
}
|
|
3755
|
-
return
|
|
4067
|
+
return _context28.abrupt("return", results);
|
|
3756
4068
|
case 9:
|
|
3757
4069
|
case "end":
|
|
3758
|
-
return
|
|
4070
|
+
return _context28.stop();
|
|
3759
4071
|
}
|
|
3760
|
-
},
|
|
4072
|
+
}, _callee27, this);
|
|
3761
4073
|
}));
|
|
3762
|
-
function getTimeslotsScheduleByDateRange(
|
|
4074
|
+
function getTimeslotsScheduleByDateRange(_x22) {
|
|
3763
4075
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
3764
4076
|
}
|
|
3765
4077
|
return getTimeslotsScheduleByDateRange;
|
|
@@ -3767,7 +4079,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3767
4079
|
}, {
|
|
3768
4080
|
key: "getAvailableDateForSessionOptimize",
|
|
3769
4081
|
value: function () {
|
|
3770
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4082
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3771
4083
|
var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
|
|
3772
4084
|
var params,
|
|
3773
4085
|
startDate,
|
|
@@ -3786,12 +4098,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3786
4098
|
openResources,
|
|
3787
4099
|
allProductResources,
|
|
3788
4100
|
targetSchedules,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
return _regeneratorRuntime().wrap(function
|
|
3792
|
-
while (1) switch (
|
|
4101
|
+
_loop8,
|
|
4102
|
+
_args30 = arguments;
|
|
4103
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
4104
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3793
4105
|
case 0:
|
|
3794
|
-
params =
|
|
4106
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3795
4107
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3796
4108
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
3797
4109
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3816,15 +4128,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3816
4128
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3817
4129
|
cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
|
|
3818
4130
|
if (!cache) {
|
|
3819
|
-
|
|
4131
|
+
_context30.next = 13;
|
|
3820
4132
|
break;
|
|
3821
4133
|
}
|
|
3822
4134
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3823
|
-
|
|
4135
|
+
_context30.next = 13;
|
|
3824
4136
|
break;
|
|
3825
4137
|
}
|
|
3826
4138
|
this.store.date.setDateList(cache.dateList);
|
|
3827
|
-
return
|
|
4139
|
+
return _context30.abrupt("return", {
|
|
3828
4140
|
dateList: cache.dateList,
|
|
3829
4141
|
firstAvailableDate: cache.firstAvailableDate
|
|
3830
4142
|
});
|
|
@@ -3834,7 +4146,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3834
4146
|
schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
|
|
3835
4147
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3836
4148
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3837
|
-
|
|
4149
|
+
_context30.next = 19;
|
|
3838
4150
|
return this.store.date.fetchResourceDates({
|
|
3839
4151
|
query: {
|
|
3840
4152
|
start_date: startDate || '',
|
|
@@ -3843,7 +4155,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3843
4155
|
}
|
|
3844
4156
|
});
|
|
3845
4157
|
case 19:
|
|
3846
|
-
res =
|
|
4158
|
+
res = _context30.sent;
|
|
3847
4159
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3848
4160
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3849
4161
|
dates = [];
|
|
@@ -3863,13 +4175,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3863
4175
|
}
|
|
3864
4176
|
});
|
|
3865
4177
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3866
|
-
|
|
3867
|
-
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
3868
|
-
return _regeneratorRuntime().wrap(function
|
|
3869
|
-
while (1) switch (
|
|
4178
|
+
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
4179
|
+
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
4180
|
+
return _regeneratorRuntime().wrap(function _loop8$(_context29) {
|
|
4181
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3870
4182
|
case 0:
|
|
3871
4183
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3872
|
-
status = 'available';
|
|
4184
|
+
status = 'available';
|
|
4185
|
+
summaryCount = 0;
|
|
4186
|
+
availableCount = 0; // 1. 检查商品的提前量等情况是否满足
|
|
3873
4187
|
_checkSessionProductL = checkSessionProductLeadTime(tempProducts), latestStartDate = _checkSessionProductL.latestStartDate, earliestEndDate = _checkSessionProductL.earliestEndDate;
|
|
3874
4188
|
if (latestStartDate || earliestEndDate) {
|
|
3875
4189
|
// 如果时间在最早开始时间之前,则设置为不可用
|
|
@@ -3895,17 +4209,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3895
4209
|
if (status === 'available') {
|
|
3896
4210
|
minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, currentDateStr);
|
|
3897
4211
|
scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime); // 同一天内多个时间片下 只要有一个可用则视为可用
|
|
3898
|
-
timesSlotCanUse =
|
|
4212
|
+
timesSlotCanUse = false;
|
|
4213
|
+
scheduleTimeSlots.forEach(function (item) {
|
|
3899
4214
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
3900
4215
|
var resourcesUseableMap = {};
|
|
3901
4216
|
// 遍历产品下启用的资源
|
|
3902
4217
|
// 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
|
|
3903
|
-
|
|
4218
|
+
// 求出第一个资源的剩余量和总量
|
|
4219
|
+
// 剩余量=每个资源在每个时间片内剩余之和
|
|
4220
|
+
// 总量=每个资源在每个时间片内资源总量之和
|
|
4221
|
+
var isAllResourceTypesUseable = true;
|
|
4222
|
+
openResources.forEach(function (resource) {
|
|
4223
|
+
// if (!isAllResourceTypesUseable) return;
|
|
4224
|
+
|
|
3904
4225
|
// 获取当前资源类型的资源列表
|
|
3905
4226
|
var currentResourcesList = allProductResources.filter(function (n) {
|
|
3906
4227
|
return n.form_id === resource.resource_type_id;
|
|
3907
4228
|
});
|
|
3908
|
-
|
|
4229
|
+
var isAnyResourceUseableInType = false;
|
|
4230
|
+
currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
|
|
3909
4231
|
// 遍历所有资源的上工时间片
|
|
3910
4232
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
3911
4233
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
@@ -3913,12 +4235,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3913
4235
|
var mTimes = m.times.filter(function (n) {
|
|
3914
4236
|
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
|
|
3915
4237
|
});
|
|
4238
|
+
|
|
3916
4239
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
3917
|
-
if (mTimes.length === 0)
|
|
3918
|
-
|
|
4240
|
+
if (mTimes.length === 0) return;
|
|
4241
|
+
// 如果资源可用则把他的容量纳入总计
|
|
4242
|
+
if (resource.type === 'multiple') {
|
|
4243
|
+
summaryCount += m.capacity;
|
|
4244
|
+
} else {
|
|
4245
|
+
summaryCount += 1;
|
|
3919
4246
|
}
|
|
3920
|
-
var
|
|
4247
|
+
var isAnyTimeSliceUseable = false;
|
|
4248
|
+
mTimes.forEach(function (childTiem) {
|
|
3921
4249
|
var _tempProducts3;
|
|
4250
|
+
if (isAnyTimeSliceUseable) return;
|
|
4251
|
+
|
|
3922
4252
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
3923
4253
|
var res = getIsUsableByTimeItem({
|
|
3924
4254
|
timeSlice: {
|
|
@@ -3936,11 +4266,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3936
4266
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
3937
4267
|
resourcesUseableMap[m.id] = res.usable;
|
|
3938
4268
|
}
|
|
3939
|
-
|
|
4269
|
+
if (res.usable && !m.onlyComputed) {
|
|
4270
|
+
isAnyTimeSliceUseable = true;
|
|
4271
|
+
if (resource.type === 'multiple') {
|
|
4272
|
+
availableCount += res.remainingCapacity;
|
|
4273
|
+
} else {
|
|
4274
|
+
availableCount += 1;
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
;
|
|
3940
4278
|
});
|
|
3941
|
-
|
|
4279
|
+
if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
|
|
3942
4280
|
});
|
|
4281
|
+
if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
|
|
3943
4282
|
});
|
|
4283
|
+
if (isAllResourceTypesUseable) timesSlotCanUse = true;
|
|
3944
4284
|
});
|
|
3945
4285
|
if (!timesSlotCanUse) {
|
|
3946
4286
|
status = 'unavailable';
|
|
@@ -3949,41 +4289,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3949
4289
|
firstAvailableDate = currentDateStr;
|
|
3950
4290
|
}
|
|
3951
4291
|
}
|
|
4292
|
+
// 状态: lots_of_space: availableCount / summaryCount > 0.5
|
|
4293
|
+
// filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
|
|
4294
|
+
// sold_out: summaryCount = 0
|
|
4295
|
+
// unavailable: summaryCount > 0 && availableCount = 0
|
|
4296
|
+
|
|
4297
|
+
if (status === 'unavailable') {
|
|
4298
|
+
// dateStatus = 'unavailable'
|
|
4299
|
+
if (availableCount === 0 && summaryCount > 0) dateStatus = 'sold_out';else dateStatus = 'unavailable';
|
|
4300
|
+
} else {
|
|
4301
|
+
usageRatio = availableCount / summaryCount;
|
|
4302
|
+
if (usageRatio > 0.5) dateStatus = 'lots_of_space';else dateStatus = 'filling_up_fast';
|
|
4303
|
+
}
|
|
3952
4304
|
dates.push({
|
|
3953
4305
|
date: dayjs(currentDate).format('YYYY-MM-DD'),
|
|
3954
4306
|
week: dayjs(currentDate).format('ddd'),
|
|
3955
4307
|
weekNum: dayjs(currentDate).day(),
|
|
3956
|
-
|
|
4308
|
+
summaryCount: summaryCount,
|
|
4309
|
+
availableCount: availableCount,
|
|
4310
|
+
status: dateStatus
|
|
3957
4311
|
});
|
|
3958
4312
|
|
|
3959
4313
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
3960
4314
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
3961
|
-
|
|
4315
|
+
_context29.next = 12;
|
|
3962
4316
|
break;
|
|
3963
4317
|
}
|
|
3964
|
-
return
|
|
3965
|
-
case
|
|
4318
|
+
return _context29.abrupt("return", 1);
|
|
4319
|
+
case 12:
|
|
3966
4320
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
3967
|
-
case
|
|
4321
|
+
case 13:
|
|
3968
4322
|
case "end":
|
|
3969
|
-
return
|
|
4323
|
+
return _context29.stop();
|
|
3970
4324
|
}
|
|
3971
|
-
},
|
|
4325
|
+
}, _loop8);
|
|
3972
4326
|
});
|
|
3973
4327
|
case 28:
|
|
3974
4328
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3975
|
-
|
|
4329
|
+
_context30.next = 34;
|
|
3976
4330
|
break;
|
|
3977
4331
|
}
|
|
3978
|
-
return
|
|
4332
|
+
return _context30.delegateYield(_loop8(), "t0", 30);
|
|
3979
4333
|
case 30:
|
|
3980
|
-
if (!
|
|
3981
|
-
|
|
4334
|
+
if (!_context30.t0) {
|
|
4335
|
+
_context30.next = 32;
|
|
3982
4336
|
break;
|
|
3983
4337
|
}
|
|
3984
|
-
return
|
|
4338
|
+
return _context30.abrupt("break", 34);
|
|
3985
4339
|
case 32:
|
|
3986
|
-
|
|
4340
|
+
_context30.next = 28;
|
|
3987
4341
|
break;
|
|
3988
4342
|
case 34:
|
|
3989
4343
|
// 最终把资源数据也加到日期内
|
|
@@ -3998,15 +4352,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3998
4352
|
startDate: startDate,
|
|
3999
4353
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
4000
4354
|
};
|
|
4001
|
-
return
|
|
4355
|
+
return _context30.abrupt("return", {
|
|
4002
4356
|
dateList: dates,
|
|
4003
4357
|
firstAvailableDate: firstAvailableDate
|
|
4004
4358
|
});
|
|
4005
4359
|
case 39:
|
|
4006
4360
|
case "end":
|
|
4007
|
-
return
|
|
4361
|
+
return _context30.stop();
|
|
4008
4362
|
}
|
|
4009
|
-
},
|
|
4363
|
+
}, _callee28, this);
|
|
4010
4364
|
}));
|
|
4011
4365
|
function getAvailableDateForSessionOptimize() {
|
|
4012
4366
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4053,18 +4407,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4053
4407
|
}, {
|
|
4054
4408
|
key: "getContactInfo",
|
|
4055
4409
|
value: (function () {
|
|
4056
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4057
|
-
return _regeneratorRuntime().wrap(function
|
|
4058
|
-
while (1) switch (
|
|
4410
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4411
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
4412
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4059
4413
|
case 0:
|
|
4060
|
-
return
|
|
4414
|
+
return _context31.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4061
4415
|
case 1:
|
|
4062
4416
|
case "end":
|
|
4063
|
-
return
|
|
4417
|
+
return _context31.stop();
|
|
4064
4418
|
}
|
|
4065
|
-
},
|
|
4419
|
+
}, _callee29, this);
|
|
4066
4420
|
}));
|
|
4067
|
-
function getContactInfo(
|
|
4421
|
+
function getContactInfo(_x23) {
|
|
4068
4422
|
return _getContactInfo.apply(this, arguments);
|
|
4069
4423
|
}
|
|
4070
4424
|
return getContactInfo;
|