@pisell/pisellos 2.1.71 → 2.1.73
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/solution/BookingByStep/index.d.ts +11 -7
- package/dist/solution/BookingByStep/index.js +519 -210
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/lib/solution/BookingByStep/index.d.ts +11 -7
- package/lib/solution/BookingByStep/index.js +336 -92
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- 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,15 +2688,14 @@ 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
|
-
|
|
2428
|
-
product = _ref10.product;
|
|
2694
|
+
_this15 = this;
|
|
2695
|
+
var date = _ref11.date,
|
|
2696
|
+
scheduleIds = _ref11.scheduleIds,
|
|
2697
|
+
resources = _ref11.resources,
|
|
2698
|
+
product = _ref11.product;
|
|
2429
2699
|
var targetProduct = this.store.currentProduct;
|
|
2430
2700
|
// 如果外面传递了product 优先用外面的
|
|
2431
2701
|
var targetProductData = product || targetProduct;
|
|
@@ -2459,29 +2729,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2459
2729
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2460
2730
|
return 0;
|
|
2461
2731
|
});
|
|
2462
|
-
|
|
2463
|
-
// 找到当前商品下第一个启用的资源id
|
|
2464
|
-
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) {
|
|
2732
|
+
var enabledResourceTypeConfigs = (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 ? void 0 : _targetProductData$pr.filter(function (n) {
|
|
2465
2733
|
return n.status === 1;
|
|
2466
|
-
}))
|
|
2467
|
-
var
|
|
2468
|
-
return n.
|
|
2469
|
-
});
|
|
2470
|
-
|
|
2734
|
+
})) || [];
|
|
2735
|
+
var resourceTypeConfigById = new Map(enabledResourceTypeConfigs.map(function (n) {
|
|
2736
|
+
return [n.id, n];
|
|
2737
|
+
}));
|
|
2738
|
+
|
|
2471
2739
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2472
2740
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2473
2741
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2474
2742
|
var resourcesUseableMap = {};
|
|
2475
|
-
var
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2743
|
+
var statsByResourceType = {};
|
|
2744
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2745
|
+
statsByResourceType[cfg.id] = {
|
|
2746
|
+
count: 0,
|
|
2747
|
+
left: 0,
|
|
2748
|
+
summaryCount: 0,
|
|
2749
|
+
summaryConfigCount: 0
|
|
2750
|
+
};
|
|
2751
|
+
});
|
|
2752
|
+
|
|
2479
2753
|
// 遍历所有资源
|
|
2480
2754
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2755
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
2756
|
+
if (!currentResourceTypeConfig) return;
|
|
2757
|
+
|
|
2481
2758
|
// 遍历所有资源的上工时间片
|
|
2482
|
-
var
|
|
2483
|
-
var
|
|
2484
|
-
var currentResourcesTimeSlotCanUsedArr = [];
|
|
2759
|
+
var currentResourceMaxRemainingCapacity = 0;
|
|
2760
|
+
var isAllTimeSlicesUsable = true;
|
|
2485
2761
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
2486
2762
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2487
2763
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -2498,6 +2774,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2498
2774
|
if (mTimes.length === 0) {
|
|
2499
2775
|
return;
|
|
2500
2776
|
}
|
|
2777
|
+
|
|
2778
|
+
// 统计该资源类型在这个时间片的“配置容量”(无占用),只统计上工的资源
|
|
2779
|
+
if (!m.onlyComputed) {
|
|
2780
|
+
var _currentStats = statsByResourceType[m.form_id] || {
|
|
2781
|
+
count: 0,
|
|
2782
|
+
left: 0,
|
|
2783
|
+
summaryCount: 0,
|
|
2784
|
+
summaryConfigCount: 0
|
|
2785
|
+
};
|
|
2786
|
+
if (currentResourceTypeConfig.type === 'multiple') _currentStats.summaryConfigCount += m.capacity;else _currentStats.summaryConfigCount += 1;
|
|
2787
|
+
statsByResourceType[m.form_id] = _currentStats;
|
|
2788
|
+
}
|
|
2501
2789
|
mTimes.forEach(function (childTiem) {
|
|
2502
2790
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
2503
2791
|
var res = getIsUsableByTimeItem({
|
|
@@ -2516,40 +2804,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2516
2804
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2517
2805
|
resourcesUseableMap[m.id] = res.usable;
|
|
2518
2806
|
}
|
|
2519
|
-
if (res.usable
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
2523
|
-
currentResourcesSummaryCount = res.remainingCapacity;
|
|
2807
|
+
if (!res.usable) isAllTimeSlicesUsable = false;
|
|
2808
|
+
if (res.usable && !m.onlyComputed) {
|
|
2809
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity) currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2524
2810
|
}
|
|
2525
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2526
2811
|
});
|
|
2527
|
-
if (
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
}
|
|
2535
|
-
|
|
2536
|
-
if (
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
}
|
|
2544
|
-
if (!m.onlyComputed) {
|
|
2545
|
-
bookingLeft += 1;
|
|
2546
|
-
summaryCount += currentResourcesSummaryCount;
|
|
2547
|
-
}
|
|
2812
|
+
if (!isAllTimeSlicesUsable) return;
|
|
2813
|
+
if (m.onlyComputed) return;
|
|
2814
|
+
var currentStats = statsByResourceType[m.form_id] || {
|
|
2815
|
+
count: 0,
|
|
2816
|
+
left: 0,
|
|
2817
|
+
summaryCount: 0,
|
|
2818
|
+
summaryConfigCount: 0
|
|
2819
|
+
};
|
|
2820
|
+
currentStats.left += 1;
|
|
2821
|
+
if (currentResourceTypeConfig.type === 'multiple') {
|
|
2822
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2823
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count) currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2824
|
+
} else {
|
|
2825
|
+
// 单个预约:一个资源只计 1,不关心剩余容量
|
|
2826
|
+
currentStats.summaryCount += 1;
|
|
2827
|
+
if (currentStats.count < 1) currentStats.count = 1;
|
|
2548
2828
|
}
|
|
2829
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
2549
2830
|
});
|
|
2550
2831
|
// 容量检测
|
|
2551
|
-
var cartItems =
|
|
2832
|
+
var cartItems = _this15.store.cart.getItems();
|
|
2552
2833
|
productResources.forEach(function (n) {
|
|
2834
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2835
|
+
if (!currentResourceTypeConfig) return;
|
|
2836
|
+
var currentStats = statsByResourceType[n.id] || {
|
|
2837
|
+
count: 0,
|
|
2838
|
+
left: 0,
|
|
2839
|
+
summaryCount: 0
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2553
2842
|
// 单个预约检测规则:
|
|
2554
2843
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
2555
2844
|
// 2、跟我不一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,她配置了几个资源的个数+我配置了几个资源的个数,然后购物车里有几个这样的商品,对应的资源做一个去重,不超过这个去重以后的总数
|
|
@@ -2560,20 +2849,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2560
2849
|
var _m$_productOrigin, _targetProductData$id;
|
|
2561
2850
|
return ((_m$_productOrigin = m._productOrigin) === null || _m$_productOrigin === void 0 || (_m$_productOrigin = _m$_productOrigin.id) === null || _m$_productOrigin === void 0 ? void 0 : _m$_productOrigin.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id = targetProductData.id) === null || _targetProductData$id === void 0 ? void 0 : _targetProductData$id.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2562
2851
|
});
|
|
2563
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2564
|
-
|
|
2565
|
-
count = 0;
|
|
2566
|
-
summaryCount = 0;
|
|
2852
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2853
|
+
currentStats.left = 0;
|
|
2854
|
+
currentStats.count = 0;
|
|
2855
|
+
currentStats.summaryCount = 0;
|
|
2567
2856
|
}
|
|
2568
2857
|
// 规则 2
|
|
2569
2858
|
var otherCartItems = cartItems.filter(function (m) {
|
|
2570
|
-
var _m$_productOrigin2, _targetProductData$id2;
|
|
2571
|
-
|
|
2859
|
+
var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
|
|
2860
|
+
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;
|
|
2861
|
+
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) {
|
|
2862
|
+
return m.type === n.type && m.status === 1;
|
|
2863
|
+
});
|
|
2864
|
+
return isTimeMatch && isResourceMatch;
|
|
2572
2865
|
});
|
|
2573
2866
|
otherCartItems.forEach(function (m) {
|
|
2574
|
-
var _m$
|
|
2575
|
-
var sameTypeResources = (_m$
|
|
2576
|
-
return m.type === n.type;
|
|
2867
|
+
var _m$_productOrigin4;
|
|
2868
|
+
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) {
|
|
2869
|
+
return m.type === n.type && m.status === 1;
|
|
2577
2870
|
});
|
|
2578
2871
|
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) || [])));
|
|
2579
2872
|
// 把sameTypeResourcesSet 加到currentResourcesSet
|
|
@@ -2582,7 +2875,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2875
|
});
|
|
2583
2876
|
});
|
|
2584
2877
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
2585
|
-
var currentDataResources =
|
|
2878
|
+
var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
2586
2879
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
2587
2880
|
if (currentResourcesSet.has(m.id)) {
|
|
2588
2881
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -2596,16 +2889,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2596
2889
|
}
|
|
2597
2890
|
});
|
|
2598
2891
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2599
|
-
|
|
2600
|
-
count = 0;
|
|
2601
|
-
summaryCount = 0;
|
|
2892
|
+
currentStats.left = 0;
|
|
2893
|
+
currentStats.count = 0;
|
|
2894
|
+
currentStats.summaryCount = 0;
|
|
2602
2895
|
}
|
|
2603
2896
|
} else {
|
|
2604
2897
|
// 多个预约的检测规则:
|
|
2605
2898
|
// 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
|
|
2606
2899
|
var _sameCartItems = cartItems.filter(function (m) {
|
|
2607
|
-
var _m$
|
|
2608
|
-
return ((_m$
|
|
2900
|
+
var _m$_productOrigin5, _targetProductData$id3;
|
|
2901
|
+
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;
|
|
2609
2902
|
});
|
|
2610
2903
|
var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
|
|
2611
2904
|
return acc + getCapacityInfoByCartItem(curr).currentCapacity;
|
|
@@ -2614,9 +2907,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2614
2907
|
return !curr.onlyComputed ? acc + curr.capacity || 0 : acc;
|
|
2615
2908
|
}, 0);
|
|
2616
2909
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2617
|
-
|
|
2618
|
-
count = 0;
|
|
2619
|
-
summaryCount = 0;
|
|
2910
|
+
currentStats.left = 0;
|
|
2911
|
+
currentStats.count = 0;
|
|
2912
|
+
currentStats.summaryCount = 0;
|
|
2620
2913
|
}
|
|
2621
2914
|
// 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
|
|
2622
2915
|
// const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
|
|
@@ -2630,8 +2923,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2630
2923
|
return !m.onlyComputed;
|
|
2631
2924
|
}));
|
|
2632
2925
|
otherSameTimesCartItems.forEach(function (m) {
|
|
2633
|
-
var _m$
|
|
2634
|
-
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$
|
|
2926
|
+
var _m$_productOrigin6;
|
|
2927
|
+
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);
|
|
2635
2928
|
productResources.forEach(function (m) {
|
|
2636
2929
|
if (m.id === n.id) {
|
|
2637
2930
|
m.renderList.forEach(function (n) {
|
|
@@ -2678,45 +2971,61 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2678
2971
|
}, 0);
|
|
2679
2972
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
2680
2973
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2681
|
-
|
|
2682
|
-
count = 0;
|
|
2683
|
-
summaryCount = 0;
|
|
2974
|
+
currentStats.left = 0;
|
|
2975
|
+
currentStats.count = 0;
|
|
2976
|
+
currentStats.summaryCount = 0;
|
|
2684
2977
|
}
|
|
2685
2978
|
}
|
|
2979
|
+
statsByResourceType[n.id] = currentStats;
|
|
2686
2980
|
});
|
|
2687
2981
|
var startDayJs = dayjs(item.start);
|
|
2688
2982
|
var endDayJs = dayjs(item.end);
|
|
2689
2983
|
|
|
2690
|
-
//
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
if (
|
|
2702
|
-
|
|
2703
|
-
|
|
2984
|
+
// 选择“瓶颈资源类型”:multiple 取 summaryCount 最小,single 取 left 最小
|
|
2985
|
+
var bottleneckResourceTypeId;
|
|
2986
|
+
var bottleneckValue = Infinity;
|
|
2987
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2988
|
+
var stats = statsByResourceType[cfg.id] || {
|
|
2989
|
+
count: 0,
|
|
2990
|
+
left: 0,
|
|
2991
|
+
summaryCount: 0,
|
|
2992
|
+
summaryConfigCount: 0
|
|
2993
|
+
};
|
|
2994
|
+
var value = cfg.type === 'multiple' ? stats.summaryCount : stats.left;
|
|
2995
|
+
if (value < bottleneckValue) {
|
|
2996
|
+
bottleneckValue = value;
|
|
2997
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2704
2998
|
}
|
|
2999
|
+
});
|
|
3000
|
+
var bottleneckStats = bottleneckResourceTypeId !== undefined ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
3001
|
+
count: 0,
|
|
3002
|
+
left: 0,
|
|
3003
|
+
summaryCount: 0,
|
|
3004
|
+
summaryConfigCount: 0
|
|
3005
|
+
} : {
|
|
3006
|
+
count: 0,
|
|
3007
|
+
left: 0,
|
|
3008
|
+
summaryCount: 0,
|
|
3009
|
+
summaryConfigCount: 0
|
|
3010
|
+
};
|
|
3011
|
+
var bottleneckConfig = bottleneckResourceTypeId !== undefined ? resourceTypeConfigById.get(bottleneckResourceTypeId) : undefined;
|
|
3012
|
+
var status = 'sold_out';
|
|
3013
|
+
if (bottleneckStats.left === 0) status = 'sold_out';else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0) status = 'sold_out';else if (bottleneckConfig.type === 'multiple') {
|
|
3014
|
+
var usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
3015
|
+
if (usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.summaryCount > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2705
3016
|
} else {
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2709
|
-
}
|
|
3017
|
+
var _usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
3018
|
+
if (_usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.count > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2710
3019
|
}
|
|
2711
3020
|
return {
|
|
2712
3021
|
start_time: startDayJs.format('HH:mm'),
|
|
2713
3022
|
end_time: endDayJs.format('HH:mm'),
|
|
2714
3023
|
start_at: startDayJs,
|
|
2715
3024
|
end_at: endDayJs,
|
|
2716
|
-
count: count,
|
|
2717
|
-
left:
|
|
2718
|
-
summaryCount: summaryCount,
|
|
2719
|
-
status:
|
|
3025
|
+
count: bottleneckStats.count,
|
|
3026
|
+
left: bottleneckStats.left,
|
|
3027
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
3028
|
+
status: status
|
|
2720
3029
|
};
|
|
2721
3030
|
});
|
|
2722
3031
|
return formatScheduleTimeSlots;
|
|
@@ -2757,7 +3066,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2757
3066
|
}));
|
|
2758
3067
|
|
|
2759
3068
|
// 与其他资源的时间段求交集
|
|
2760
|
-
var
|
|
3069
|
+
var _loop3 = function _loop3() {
|
|
2761
3070
|
var currentResourceSlots = allTimeSlots[i];
|
|
2762
3071
|
var intersections = [];
|
|
2763
3072
|
|
|
@@ -2786,7 +3095,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2786
3095
|
}));
|
|
2787
3096
|
};
|
|
2788
3097
|
for (var i = 1; i < allTimeSlots.length; i++) {
|
|
2789
|
-
if (
|
|
3098
|
+
if (_loop3()) continue;
|
|
2790
3099
|
}
|
|
2791
3100
|
|
|
2792
3101
|
// 格式化返回结果
|
|
@@ -2802,7 +3111,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2802
3111
|
}, {
|
|
2803
3112
|
key: "checkMaxDurationCapacity",
|
|
2804
3113
|
value: function checkMaxDurationCapacity() {
|
|
2805
|
-
var
|
|
3114
|
+
var _this16 = this;
|
|
2806
3115
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
2807
3116
|
return !isNormalProduct(item._productOrigin);
|
|
2808
3117
|
});
|
|
@@ -2892,7 +3201,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2892
3201
|
var processedCartItemIds = new Set();
|
|
2893
3202
|
|
|
2894
3203
|
// 先检查所有资源类型,收集可用数量信息
|
|
2895
|
-
var
|
|
3204
|
+
var _loop4 = function _loop4() {
|
|
2896
3205
|
var _resourceTypeConfig;
|
|
2897
3206
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
2898
3207
|
resourceCode = _Object$entries$_i[0],
|
|
@@ -3008,7 +3317,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3008
3317
|
}));
|
|
3009
3318
|
|
|
3010
3319
|
// 找到所有资源都可用的时间段
|
|
3011
|
-
var commonTimeSlots =
|
|
3320
|
+
var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3012
3321
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3013
3322
|
if (commonTimeSlots.length === 0) {
|
|
3014
3323
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3039,7 +3348,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3039
3348
|
},
|
|
3040
3349
|
_ret2;
|
|
3041
3350
|
for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
|
|
3042
|
-
_ret2 =
|
|
3351
|
+
_ret2 = _loop4();
|
|
3043
3352
|
if (_ret2) return _ret2.v;
|
|
3044
3353
|
}
|
|
3045
3354
|
|
|
@@ -3083,7 +3392,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3083
3392
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3084
3393
|
});
|
|
3085
3394
|
// 检查每个时间段是否有足够的资源容量
|
|
3086
|
-
var
|
|
3395
|
+
var _loop5 = function _loop5() {
|
|
3087
3396
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3088
3397
|
timeSlotKey = _Object$entries2$_i[0],
|
|
3089
3398
|
itemsInTimeSlot = _Object$entries2$_i[1];
|
|
@@ -3101,8 +3410,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3101
3410
|
var resourcesIdSet = new Set();
|
|
3102
3411
|
|
|
3103
3412
|
// 获取资源数据
|
|
3104
|
-
var dateRange =
|
|
3105
|
-
var resourcesDates =
|
|
3413
|
+
var dateRange = _this16.store.date.getDateRange();
|
|
3414
|
+
var resourcesDates = _this16.store.date.getDateList();
|
|
3106
3415
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3107
3416
|
return n.date === startDate;
|
|
3108
3417
|
});
|
|
@@ -3139,7 +3448,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3139
3448
|
},
|
|
3140
3449
|
_ret3;
|
|
3141
3450
|
for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
|
|
3142
|
-
_ret3 =
|
|
3451
|
+
_ret3 = _loop5();
|
|
3143
3452
|
if (_ret3 === 0) continue;
|
|
3144
3453
|
if (_ret3) return _ret3.v;
|
|
3145
3454
|
}
|
|
@@ -3158,17 +3467,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3158
3467
|
*/
|
|
3159
3468
|
}, {
|
|
3160
3469
|
key: "convertProductToCartItem",
|
|
3161
|
-
value: function convertProductToCartItem(
|
|
3162
|
-
var product =
|
|
3163
|
-
date =
|
|
3164
|
-
account =
|
|
3165
|
-
var
|
|
3166
|
-
bundle =
|
|
3167
|
-
options =
|
|
3168
|
-
origin =
|
|
3169
|
-
product_variant_id =
|
|
3170
|
-
|
|
3171
|
-
quantity =
|
|
3470
|
+
value: function convertProductToCartItem(_ref12) {
|
|
3471
|
+
var product = _ref12.product,
|
|
3472
|
+
date = _ref12.date,
|
|
3473
|
+
account = _ref12.account;
|
|
3474
|
+
var _ref13 = product || {},
|
|
3475
|
+
bundle = _ref13.bundle,
|
|
3476
|
+
options = _ref13.options,
|
|
3477
|
+
origin = _ref13.origin,
|
|
3478
|
+
product_variant_id = _ref13.product_variant_id,
|
|
3479
|
+
_ref13$quantity = _ref13.quantity,
|
|
3480
|
+
quantity = _ref13$quantity === void 0 ? 1 : _ref13$quantity;
|
|
3172
3481
|
|
|
3173
3482
|
// 处理商品数据,类似 addProductToCart 中的逻辑
|
|
3174
3483
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -3223,11 +3532,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3223
3532
|
}
|
|
3224
3533
|
}, {
|
|
3225
3534
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3226
|
-
value: function checkMaxDurationCapacityForDetailNums(
|
|
3227
|
-
var
|
|
3228
|
-
var product =
|
|
3229
|
-
date =
|
|
3230
|
-
account =
|
|
3535
|
+
value: function checkMaxDurationCapacityForDetailNums(_ref14) {
|
|
3536
|
+
var _this17 = this;
|
|
3537
|
+
var product = _ref14.product,
|
|
3538
|
+
date = _ref14.date,
|
|
3539
|
+
account = _ref14.account;
|
|
3231
3540
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3232
3541
|
return !isNormalProduct(item._productOrigin);
|
|
3233
3542
|
});
|
|
@@ -3325,7 +3634,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3634
|
var processedCartItemIds = new Set();
|
|
3326
3635
|
|
|
3327
3636
|
// 先检查所有资源类型,收集可用数量信息
|
|
3328
|
-
var
|
|
3637
|
+
var _loop6 = function _loop6() {
|
|
3329
3638
|
var _resourceTypeConfig2;
|
|
3330
3639
|
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
3331
3640
|
resourceCode = _Object$entries3$_i[0],
|
|
@@ -3441,7 +3750,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3441
3750
|
}));
|
|
3442
3751
|
|
|
3443
3752
|
// 找到所有资源都可用的时间段
|
|
3444
|
-
var commonTimeSlots =
|
|
3753
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3445
3754
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3446
3755
|
if (commonTimeSlots.length === 0) {
|
|
3447
3756
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3472,7 +3781,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3472
3781
|
},
|
|
3473
3782
|
_ret4;
|
|
3474
3783
|
for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
|
|
3475
|
-
_ret4 =
|
|
3784
|
+
_ret4 = _loop6();
|
|
3476
3785
|
if (_ret4) return _ret4.v;
|
|
3477
3786
|
}
|
|
3478
3787
|
|
|
@@ -3516,7 +3825,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3516
3825
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3517
3826
|
});
|
|
3518
3827
|
// 检查每个时间段是否有足够的资源容量
|
|
3519
|
-
var
|
|
3828
|
+
var _loop7 = function _loop7() {
|
|
3520
3829
|
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
3521
3830
|
timeSlotKey = _Object$entries4$_i[0],
|
|
3522
3831
|
itemsInTimeSlot = _Object$entries4$_i[1];
|
|
@@ -3535,7 +3844,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3535
3844
|
|
|
3536
3845
|
// 获取资源数据
|
|
3537
3846
|
// const dateRange = this.store.date.getDateRange();
|
|
3538
|
-
var resourcesDates =
|
|
3847
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3539
3848
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3540
3849
|
return n.date === startDate;
|
|
3541
3850
|
});
|
|
@@ -3572,7 +3881,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3572
3881
|
},
|
|
3573
3882
|
_ret5;
|
|
3574
3883
|
for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
|
|
3575
|
-
_ret5 =
|
|
3884
|
+
_ret5 = _loop7();
|
|
3576
3885
|
if (_ret5 === 0) continue;
|
|
3577
3886
|
if (_ret5) return _ret5.v;
|
|
3578
3887
|
}
|
|
@@ -3605,41 +3914,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3605
3914
|
}, {
|
|
3606
3915
|
key: "getProductTypeById",
|
|
3607
3916
|
value: function () {
|
|
3608
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3917
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
3609
3918
|
var productData, _productData$schedule;
|
|
3610
|
-
return _regeneratorRuntime().wrap(function
|
|
3611
|
-
while (1) switch (
|
|
3919
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
3920
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3612
3921
|
case 0:
|
|
3613
|
-
|
|
3922
|
+
_context27.next = 2;
|
|
3614
3923
|
return this.store.products.getProduct(id);
|
|
3615
3924
|
case 2:
|
|
3616
|
-
productData =
|
|
3925
|
+
productData = _context27.sent;
|
|
3617
3926
|
if (!productData) {
|
|
3618
|
-
|
|
3927
|
+
_context27.next = 9;
|
|
3619
3928
|
break;
|
|
3620
3929
|
}
|
|
3621
3930
|
if (!productData.duration) {
|
|
3622
|
-
|
|
3931
|
+
_context27.next = 6;
|
|
3623
3932
|
break;
|
|
3624
3933
|
}
|
|
3625
|
-
return
|
|
3934
|
+
return _context27.abrupt("return", 'duration');
|
|
3626
3935
|
case 6:
|
|
3627
3936
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
3628
|
-
|
|
3937
|
+
_context27.next = 8;
|
|
3629
3938
|
break;
|
|
3630
3939
|
}
|
|
3631
|
-
return
|
|
3940
|
+
return _context27.abrupt("return", 'session');
|
|
3632
3941
|
case 8:
|
|
3633
|
-
return
|
|
3942
|
+
return _context27.abrupt("return", 'normal');
|
|
3634
3943
|
case 9:
|
|
3635
|
-
return
|
|
3944
|
+
return _context27.abrupt("return", 'normal');
|
|
3636
3945
|
case 10:
|
|
3637
3946
|
case "end":
|
|
3638
|
-
return
|
|
3947
|
+
return _context27.stop();
|
|
3639
3948
|
}
|
|
3640
|
-
},
|
|
3949
|
+
}, _callee26, this);
|
|
3641
3950
|
}));
|
|
3642
|
-
function getProductTypeById(
|
|
3951
|
+
function getProductTypeById(_x21) {
|
|
3643
3952
|
return _getProductTypeById.apply(this, arguments);
|
|
3644
3953
|
}
|
|
3645
3954
|
return getProductTypeById;
|
|
@@ -3759,12 +4068,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
4068
|
}, {
|
|
3760
4069
|
key: "getTimeslotsScheduleByDateRange",
|
|
3761
4070
|
value: (function () {
|
|
3762
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4071
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref15) {
|
|
3763
4072
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
3764
|
-
return _regeneratorRuntime().wrap(function
|
|
3765
|
-
while (1) switch (
|
|
4073
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
4074
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3766
4075
|
case 0:
|
|
3767
|
-
startDate =
|
|
4076
|
+
startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
|
|
3768
4077
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
3769
4078
|
startDate: startDate,
|
|
3770
4079
|
endDate: endDate,
|
|
@@ -3789,14 +4098,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3789
4098
|
resources: resources
|
|
3790
4099
|
});
|
|
3791
4100
|
}
|
|
3792
|
-
return
|
|
4101
|
+
return _context28.abrupt("return", results);
|
|
3793
4102
|
case 9:
|
|
3794
4103
|
case "end":
|
|
3795
|
-
return
|
|
4104
|
+
return _context28.stop();
|
|
3796
4105
|
}
|
|
3797
|
-
},
|
|
4106
|
+
}, _callee27, this);
|
|
3798
4107
|
}));
|
|
3799
|
-
function getTimeslotsScheduleByDateRange(
|
|
4108
|
+
function getTimeslotsScheduleByDateRange(_x22) {
|
|
3800
4109
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
3801
4110
|
}
|
|
3802
4111
|
return getTimeslotsScheduleByDateRange;
|
|
@@ -3804,7 +4113,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3804
4113
|
}, {
|
|
3805
4114
|
key: "getAvailableDateForSessionOptimize",
|
|
3806
4115
|
value: function () {
|
|
3807
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4116
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3808
4117
|
var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
|
|
3809
4118
|
var params,
|
|
3810
4119
|
startDate,
|
|
@@ -3823,12 +4132,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3823
4132
|
openResources,
|
|
3824
4133
|
allProductResources,
|
|
3825
4134
|
targetSchedules,
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
return _regeneratorRuntime().wrap(function
|
|
3829
|
-
while (1) switch (
|
|
4135
|
+
_loop8,
|
|
4136
|
+
_args30 = arguments;
|
|
4137
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
4138
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3830
4139
|
case 0:
|
|
3831
|
-
params =
|
|
4140
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3832
4141
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3833
4142
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
3834
4143
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3853,15 +4162,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3853
4162
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3854
4163
|
cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
|
|
3855
4164
|
if (!cache) {
|
|
3856
|
-
|
|
4165
|
+
_context30.next = 13;
|
|
3857
4166
|
break;
|
|
3858
4167
|
}
|
|
3859
4168
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3860
|
-
|
|
4169
|
+
_context30.next = 13;
|
|
3861
4170
|
break;
|
|
3862
4171
|
}
|
|
3863
4172
|
this.store.date.setDateList(cache.dateList);
|
|
3864
|
-
return
|
|
4173
|
+
return _context30.abrupt("return", {
|
|
3865
4174
|
dateList: cache.dateList,
|
|
3866
4175
|
firstAvailableDate: cache.firstAvailableDate
|
|
3867
4176
|
});
|
|
@@ -3871,7 +4180,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3871
4180
|
schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
|
|
3872
4181
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3873
4182
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3874
|
-
|
|
4183
|
+
_context30.next = 19;
|
|
3875
4184
|
return this.store.date.fetchResourceDates({
|
|
3876
4185
|
query: {
|
|
3877
4186
|
start_date: startDate || '',
|
|
@@ -3880,7 +4189,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3880
4189
|
}
|
|
3881
4190
|
});
|
|
3882
4191
|
case 19:
|
|
3883
|
-
res =
|
|
4192
|
+
res = _context30.sent;
|
|
3884
4193
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3885
4194
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3886
4195
|
dates = [];
|
|
@@ -3900,10 +4209,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3900
4209
|
}
|
|
3901
4210
|
});
|
|
3902
4211
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3903
|
-
|
|
4212
|
+
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
3904
4213
|
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
3905
|
-
return _regeneratorRuntime().wrap(function
|
|
3906
|
-
while (1) switch (
|
|
4214
|
+
return _regeneratorRuntime().wrap(function _loop8$(_context29) {
|
|
4215
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3907
4216
|
case 0:
|
|
3908
4217
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3909
4218
|
status = 'available';
|
|
@@ -4037,32 +4346,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4037
4346
|
|
|
4038
4347
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
4039
4348
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
4040
|
-
|
|
4349
|
+
_context29.next = 12;
|
|
4041
4350
|
break;
|
|
4042
4351
|
}
|
|
4043
|
-
return
|
|
4352
|
+
return _context29.abrupt("return", 1);
|
|
4044
4353
|
case 12:
|
|
4045
4354
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
4046
4355
|
case 13:
|
|
4047
4356
|
case "end":
|
|
4048
|
-
return
|
|
4357
|
+
return _context29.stop();
|
|
4049
4358
|
}
|
|
4050
|
-
},
|
|
4359
|
+
}, _loop8);
|
|
4051
4360
|
});
|
|
4052
4361
|
case 28:
|
|
4053
4362
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
4054
|
-
|
|
4363
|
+
_context30.next = 34;
|
|
4055
4364
|
break;
|
|
4056
4365
|
}
|
|
4057
|
-
return
|
|
4366
|
+
return _context30.delegateYield(_loop8(), "t0", 30);
|
|
4058
4367
|
case 30:
|
|
4059
|
-
if (!
|
|
4060
|
-
|
|
4368
|
+
if (!_context30.t0) {
|
|
4369
|
+
_context30.next = 32;
|
|
4061
4370
|
break;
|
|
4062
4371
|
}
|
|
4063
|
-
return
|
|
4372
|
+
return _context30.abrupt("break", 34);
|
|
4064
4373
|
case 32:
|
|
4065
|
-
|
|
4374
|
+
_context30.next = 28;
|
|
4066
4375
|
break;
|
|
4067
4376
|
case 34:
|
|
4068
4377
|
// 最终把资源数据也加到日期内
|
|
@@ -4077,15 +4386,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4077
4386
|
startDate: startDate,
|
|
4078
4387
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
4079
4388
|
};
|
|
4080
|
-
return
|
|
4389
|
+
return _context30.abrupt("return", {
|
|
4081
4390
|
dateList: dates,
|
|
4082
4391
|
firstAvailableDate: firstAvailableDate
|
|
4083
4392
|
});
|
|
4084
4393
|
case 39:
|
|
4085
4394
|
case "end":
|
|
4086
|
-
return
|
|
4395
|
+
return _context30.stop();
|
|
4087
4396
|
}
|
|
4088
|
-
},
|
|
4397
|
+
}, _callee28, this);
|
|
4089
4398
|
}));
|
|
4090
4399
|
function getAvailableDateForSessionOptimize() {
|
|
4091
4400
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4132,18 +4441,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4132
4441
|
}, {
|
|
4133
4442
|
key: "getContactInfo",
|
|
4134
4443
|
value: (function () {
|
|
4135
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4136
|
-
return _regeneratorRuntime().wrap(function
|
|
4137
|
-
while (1) switch (
|
|
4444
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4445
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
4446
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4138
4447
|
case 0:
|
|
4139
|
-
return
|
|
4448
|
+
return _context31.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4140
4449
|
case 1:
|
|
4141
4450
|
case "end":
|
|
4142
|
-
return
|
|
4451
|
+
return _context31.stop();
|
|
4143
4452
|
}
|
|
4144
|
-
},
|
|
4453
|
+
}, _callee29, this);
|
|
4145
4454
|
}));
|
|
4146
|
-
function getContactInfo(
|
|
4455
|
+
function getContactInfo(_x23) {
|
|
4147
4456
|
return _getContactInfo.apply(this, arguments);
|
|
4148
4457
|
}
|
|
4149
4458
|
return getContactInfo;
|