@pisell/pisellos 0.0.361 → 0.0.363
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/ProductList/index.js +8 -9
- package/dist/solution/BookingByStep/index.d.ts +6 -0
- package/dist/solution/BookingByStep/index.js +302 -99
- package/dist/solution/BookingByStep/utils/capacity.js +1 -2
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/solution/BookingByStep/index.d.ts +6 -0
- package/lib/solution/BookingByStep/index.js +161 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -2
- package/package.json +1 -1
|
@@ -140,17 +140,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
140
|
productsData = _context3.sent;
|
|
141
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
142
142
|
return Number(b.sort) - Number(a.sort);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
143
|
+
}); // if (sortedList.length) {
|
|
144
|
+
// sortedList.forEach((n: any) => {
|
|
145
|
+
// if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
|
|
146
|
+
// n.is_eject = 1
|
|
147
|
+
// }
|
|
148
|
+
// })
|
|
149
|
+
// }
|
|
151
150
|
this.addProduct(sortedList);
|
|
152
151
|
return _context3.abrupt("return", sortedList);
|
|
153
|
-
case
|
|
152
|
+
case 10:
|
|
154
153
|
case "end":
|
|
155
154
|
return _context3.stop();
|
|
156
155
|
}
|
|
@@ -299,6 +299,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
299
299
|
errorList: any[];
|
|
300
300
|
};
|
|
301
301
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
302
|
+
getTimeSlotByAllResourcesForDate(resources_code: string, start_date: string, end_date: string): Promise<{
|
|
303
|
+
date: string;
|
|
304
|
+
status: string;
|
|
305
|
+
week: string;
|
|
306
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
307
|
+
}[]>;
|
|
302
308
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
303
309
|
private getScheduleDataByIds;
|
|
304
310
|
openProductDetail(productId: number): Promise<void>;
|
|
@@ -2195,7 +2195,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2195
2195
|
}, 0);
|
|
2196
2196
|
};
|
|
2197
2197
|
|
|
2198
|
-
//
|
|
2198
|
+
// 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2199
2199
|
var maxCapacity = 1;
|
|
2200
2200
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2201
2201
|
accountList.forEach(function (account) {
|
|
@@ -2223,13 +2223,211 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2223
2223
|
});
|
|
2224
2224
|
return timeSlots;
|
|
2225
2225
|
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2226
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
2227
|
+
}, {
|
|
2228
|
+
key: "getTimeSlotByAllResourcesForDate",
|
|
2229
|
+
value: function () {
|
|
2230
|
+
var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(resources_code, start_date, end_date) {
|
|
2231
|
+
var _this13 = this,
|
|
2232
|
+
_cartItems$5,
|
|
2233
|
+
_cartItems$6,
|
|
2234
|
+
_this$shopStore$get2;
|
|
2235
|
+
var resources, cartItems, resourceIds, resourcesTypeId, isSingleResource, maxCutOffTime, maxCutOffTimeValue, resourcesMap, duration, accountList, checkDuration, resourcesUseableMap, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold, calculateCapacityFromCartItems, maxCapacity, arr, today, i, timeSlots;
|
|
2236
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2237
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2238
|
+
case 0:
|
|
2239
|
+
// 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
|
|
2240
|
+
if (dayjs(end_date).diff(dayjs(start_date), 'day') < 30) {
|
|
2241
|
+
end_date = dayjs(start_date).add(30, 'day').format('YYYY-MM-DD');
|
|
2242
|
+
}
|
|
2243
|
+
// 预请求资源数据,防止日期超过之前选择的范围
|
|
2244
|
+
_context24.next = 3;
|
|
2245
|
+
return this.getAvailableDate({
|
|
2246
|
+
startDate: start_date,
|
|
2247
|
+
endDate: end_date,
|
|
2248
|
+
useCache: true
|
|
2249
|
+
});
|
|
2250
|
+
case 3:
|
|
2251
|
+
// 取出购物车中所有一已选择的第一步资源
|
|
2252
|
+
resources = [];
|
|
2253
|
+
cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2254
|
+
return !isNormalProduct(n._productOrigin);
|
|
2255
|
+
}); // if (cartItems?.[0].start_date) return [];
|
|
2256
|
+
resourceIds = [];
|
|
2257
|
+
resourcesTypeId = undefined;
|
|
2258
|
+
isSingleResource = false; // 找出购物车里最大的 cut_off_time
|
|
2259
|
+
maxCutOffTime = undefined;
|
|
2260
|
+
maxCutOffTimeValue = dayjs();
|
|
2261
|
+
cartItems.forEach(function (item) {
|
|
2262
|
+
var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
|
|
2263
|
+
(_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) {
|
|
2264
|
+
// TODO: 少了个 status 的判断
|
|
2265
|
+
if (n.code === resources_code) {
|
|
2266
|
+
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
2267
|
+
isSingleResource = n.type === 'single';
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
// item._origin.resources?.forEach((n: any) => {
|
|
2271
|
+
// resourceIds.push(n.relation_id);
|
|
2272
|
+
// });
|
|
2273
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2274
|
+
resourceIds.push(item.resource_id);
|
|
2275
|
+
}
|
|
2276
|
+
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) {
|
|
2277
|
+
return n.code === resources_code;
|
|
2278
|
+
})) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
|
|
2279
|
+
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') {
|
|
2280
|
+
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2281
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2282
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
2283
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
resourcesMap = getResourcesMap(resources);
|
|
2288
|
+
duration = 0; // duration = 不同账号的最长时间
|
|
2289
|
+
accountList = this.store.accountList.getAccounts();
|
|
2290
|
+
checkDuration = function checkDuration(cartItems) {
|
|
2291
|
+
var accountDuration = 0;
|
|
2292
|
+
cartItems.forEach(function (item) {
|
|
2293
|
+
// 单个预约累加账号 多个预约取最大值
|
|
2294
|
+
if (isSingleResource) {
|
|
2295
|
+
var _item$_productOrigin21;
|
|
2296
|
+
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;
|
|
2297
|
+
} else {
|
|
2298
|
+
var _item$_productOrigin22;
|
|
2299
|
+
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)) {
|
|
2300
|
+
var _item$_productOrigin23;
|
|
2301
|
+
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;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
if (accountDuration > duration) {
|
|
2306
|
+
duration = accountDuration;
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2310
|
+
accountList.forEach(function (account) {
|
|
2311
|
+
var cartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2312
|
+
checkDuration(cartItems);
|
|
2313
|
+
});
|
|
2314
|
+
} else {
|
|
2315
|
+
checkDuration(cartItems);
|
|
2316
|
+
}
|
|
2317
|
+
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
2318
|
+
// 同时 session 类商品的流程也不应该调用这个方法
|
|
2319
|
+
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))) {
|
|
2320
|
+
_context24.next = 18;
|
|
2321
|
+
break;
|
|
2322
|
+
}
|
|
2323
|
+
return _context24.abrupt("return", []);
|
|
2324
|
+
case 18:
|
|
2325
|
+
resourcesUseableMap = {};
|
|
2326
|
+
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2327
|
+
var _item$_productOrigin24;
|
|
2328
|
+
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';
|
|
2329
|
+
});
|
|
2330
|
+
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 的值
|
|
2331
|
+
maxBlockThreshold = 0;
|
|
2332
|
+
if (hasFlexibleDuration) {
|
|
2333
|
+
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2334
|
+
var _item$_productOrigin25;
|
|
2335
|
+
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2336
|
+
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) {
|
|
2337
|
+
var _item$_productOrigin26;
|
|
2338
|
+
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);
|
|
2339
|
+
}
|
|
2340
|
+
return 0;
|
|
2341
|
+
}, 0);
|
|
2342
|
+
}
|
|
2343
|
+
// 计算容量的辅助函数
|
|
2344
|
+
calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2345
|
+
return items.reduce(function (total, item) {
|
|
2346
|
+
return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2347
|
+
}, 0);
|
|
2348
|
+
}; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2349
|
+
maxCapacity = 1;
|
|
2350
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2351
|
+
accountList.forEach(function (account) {
|
|
2352
|
+
var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2353
|
+
var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
2354
|
+
if (currentCapacity > maxCapacity) {
|
|
2355
|
+
maxCapacity = currentCapacity;
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
} else {
|
|
2359
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
2360
|
+
}
|
|
2361
|
+
arr = [];
|
|
2362
|
+
today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
|
|
2363
|
+
i = dayjs(start_date);
|
|
2364
|
+
case 29:
|
|
2365
|
+
if (!i.isBefore(dayjs(end_date))) {
|
|
2366
|
+
_context24.next = 38;
|
|
2367
|
+
break;
|
|
2368
|
+
}
|
|
2369
|
+
if (!i.isBefore(today)) {
|
|
2370
|
+
_context24.next = 33;
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
arr.push({
|
|
2374
|
+
date: i.format('YYYY-MM-DD'),
|
|
2375
|
+
status: 'unavailable',
|
|
2376
|
+
week: i.format('ddd'),
|
|
2377
|
+
weekNum: i.day()
|
|
2378
|
+
});
|
|
2379
|
+
return _context24.abrupt("continue", 35);
|
|
2380
|
+
case 33:
|
|
2381
|
+
timeSlots = getTimeSlicesByResources({
|
|
2382
|
+
resourceIds: resourceIds,
|
|
2383
|
+
resourcesMap: resourcesMap,
|
|
2384
|
+
duration: duration,
|
|
2385
|
+
currentDate: i.format('YYYY-MM-DD'),
|
|
2386
|
+
split: 10,
|
|
2387
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2388
|
+
capacity: maxCapacity,
|
|
2389
|
+
cut_off_time: maxCutOffTime,
|
|
2390
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2391
|
+
operating_day_boundary: operating_day_boundary,
|
|
2392
|
+
maxBlockThreshold: maxBlockThreshold
|
|
2393
|
+
});
|
|
2394
|
+
if (timeSlots.length > 0) {
|
|
2395
|
+
arr.push({
|
|
2396
|
+
date: i.format('YYYY-MM-DD'),
|
|
2397
|
+
status: 'available',
|
|
2398
|
+
week: i.format('ddd'),
|
|
2399
|
+
weekNum: i.day()
|
|
2400
|
+
});
|
|
2401
|
+
} else {
|
|
2402
|
+
arr.push({
|
|
2403
|
+
date: i.format('YYYY-MM-DD'),
|
|
2404
|
+
status: 'unavailable',
|
|
2405
|
+
week: i.format('ddd'),
|
|
2406
|
+
weekNum: i.day()
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
case 35:
|
|
2410
|
+
i = i.add(1, 'day');
|
|
2411
|
+
_context24.next = 29;
|
|
2412
|
+
break;
|
|
2413
|
+
case 38:
|
|
2414
|
+
return _context24.abrupt("return", arr);
|
|
2415
|
+
case 39:
|
|
2416
|
+
case "end":
|
|
2417
|
+
return _context24.stop();
|
|
2418
|
+
}
|
|
2419
|
+
}, _callee24, this);
|
|
2420
|
+
}));
|
|
2421
|
+
function getTimeSlotByAllResourcesForDate(_x19, _x20, _x21) {
|
|
2422
|
+
return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
|
|
2423
|
+
}
|
|
2424
|
+
return getTimeSlotByAllResourcesForDate;
|
|
2425
|
+
}() // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2228
2426
|
}, {
|
|
2229
2427
|
key: "submitTimeSlot",
|
|
2230
2428
|
value: function submitTimeSlot(timeSlots) {
|
|
2231
|
-
var _this$shopStore$
|
|
2232
|
-
|
|
2429
|
+
var _this$shopStore$get3,
|
|
2430
|
+
_this14 = this;
|
|
2233
2431
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2234
2432
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2235
2433
|
return !isNormalProduct(n._productOrigin);
|
|
@@ -2249,7 +2447,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2249
2447
|
}, {});
|
|
2250
2448
|
|
|
2251
2449
|
// 店铺营业结束时间
|
|
2252
|
-
var operating_day_boundary = (_this$shopStore$
|
|
2450
|
+
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;
|
|
2253
2451
|
|
|
2254
2452
|
// 处理每个账号的商品
|
|
2255
2453
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
@@ -2259,10 +2457,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2259
2457
|
var osWarnTips = [];
|
|
2260
2458
|
var newResources = cloneDeep(item._origin.resources);
|
|
2261
2459
|
newResources.forEach(function (resource) {
|
|
2262
|
-
var _item$
|
|
2460
|
+
var _item$_productOrigin27;
|
|
2263
2461
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2264
|
-
if (((_item$
|
|
2265
|
-
var _allResources$find, _item$
|
|
2462
|
+
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') {
|
|
2463
|
+
var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
|
|
2266
2464
|
item.duration = {
|
|
2267
2465
|
type: 'minutes',
|
|
2268
2466
|
value: 10
|
|
@@ -2292,19 +2490,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2292
2490
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2293
2491
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2294
2492
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2295
|
-
if ((_item$
|
|
2493
|
+
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))) {
|
|
2296
2494
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2297
2495
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2298
2496
|
}
|
|
2299
2497
|
}
|
|
2300
2498
|
} else {
|
|
2301
|
-
var _item$
|
|
2499
|
+
var _item$_productOrigin30;
|
|
2302
2500
|
resource.startTime = currentStartTime;
|
|
2303
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2501
|
+
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');
|
|
2304
2502
|
}
|
|
2305
2503
|
// delete resource.times;
|
|
2306
2504
|
});
|
|
2307
|
-
|
|
2505
|
+
_this14.store.cart.updateItem({
|
|
2308
2506
|
_id: item._id,
|
|
2309
2507
|
resources: newResources,
|
|
2310
2508
|
osWarnTips: osWarnTips
|
|
@@ -2348,42 +2546,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2348
2546
|
}, {
|
|
2349
2547
|
key: "openProductDetail",
|
|
2350
2548
|
value: function () {
|
|
2351
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2549
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
2352
2550
|
var targetProductData, newScheduleArr, dateRange;
|
|
2353
|
-
return _regeneratorRuntime().wrap(function
|
|
2354
|
-
while (1) switch (
|
|
2551
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2552
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2355
2553
|
case 0:
|
|
2356
|
-
|
|
2554
|
+
_context25.next = 2;
|
|
2357
2555
|
return this.store.products.getProduct(productId);
|
|
2358
2556
|
case 2:
|
|
2359
|
-
targetProductData =
|
|
2557
|
+
targetProductData = _context25.sent;
|
|
2360
2558
|
if (!targetProductData) {
|
|
2361
|
-
|
|
2559
|
+
_context25.next = 17;
|
|
2362
2560
|
break;
|
|
2363
2561
|
}
|
|
2364
2562
|
this.store.currentProduct = targetProductData;
|
|
2365
2563
|
this.store.currentProductMeta = {};
|
|
2366
2564
|
// 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
|
|
2367
2565
|
if (!targetProductData['schedule.ids']) {
|
|
2368
|
-
|
|
2566
|
+
_context25.next = 12;
|
|
2369
2567
|
break;
|
|
2370
2568
|
}
|
|
2371
2569
|
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2372
2570
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
2373
2571
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
2374
|
-
|
|
2572
|
+
_context25.next = 17;
|
|
2375
2573
|
break;
|
|
2376
2574
|
case 12:
|
|
2377
2575
|
if (!targetProductData.duration) {
|
|
2378
|
-
|
|
2576
|
+
_context25.next = 17;
|
|
2379
2577
|
break;
|
|
2380
2578
|
}
|
|
2381
2579
|
dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
|
|
2382
2580
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
2383
|
-
|
|
2581
|
+
_context25.next = 16;
|
|
2384
2582
|
break;
|
|
2385
2583
|
}
|
|
2386
|
-
return
|
|
2584
|
+
return _context25.abrupt("return");
|
|
2387
2585
|
case 16:
|
|
2388
2586
|
// this.store.date.getResourceDates({
|
|
2389
2587
|
// query: {
|
|
@@ -2399,11 +2597,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2399
2597
|
});
|
|
2400
2598
|
case 17:
|
|
2401
2599
|
case "end":
|
|
2402
|
-
return
|
|
2600
|
+
return _context25.stop();
|
|
2403
2601
|
}
|
|
2404
|
-
},
|
|
2602
|
+
}, _callee25, this);
|
|
2405
2603
|
}));
|
|
2406
|
-
function openProductDetail(
|
|
2604
|
+
function openProductDetail(_x22) {
|
|
2407
2605
|
return _openProductDetail.apply(this, arguments);
|
|
2408
2606
|
}
|
|
2409
2607
|
return openProductDetail;
|
|
@@ -2423,7 +2621,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2423
2621
|
value: function getTimeslotBySchedule(_ref10) {
|
|
2424
2622
|
var _this$store$currentPr2,
|
|
2425
2623
|
_targetProductData$pr,
|
|
2426
|
-
|
|
2624
|
+
_this15 = this;
|
|
2427
2625
|
var date = _ref10.date,
|
|
2428
2626
|
scheduleIds = _ref10.scheduleIds,
|
|
2429
2627
|
resources = _ref10.resources,
|
|
@@ -2531,8 +2729,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2531
2729
|
}
|
|
2532
2730
|
});
|
|
2533
2731
|
// 容量检测
|
|
2534
|
-
var cartItems =
|
|
2732
|
+
var cartItems = _this15.store.cart.getItems();
|
|
2535
2733
|
productResources.forEach(function (n) {
|
|
2734
|
+
debugger;
|
|
2536
2735
|
// 单个预约检测规则:
|
|
2537
2736
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
2538
2737
|
// 2、跟我不一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,她配置了几个资源的个数+我配置了几个资源的个数,然后购物车里有几个这样的商品,对应的资源做一个去重,不超过这个去重以后的总数
|
|
@@ -2549,13 +2748,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2549
2748
|
}
|
|
2550
2749
|
// 规则 2
|
|
2551
2750
|
var otherCartItems = cartItems.filter(function (m) {
|
|
2552
|
-
var _m$_productOrigin2, _targetProductData$id2;
|
|
2553
|
-
|
|
2751
|
+
var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
|
|
2752
|
+
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;
|
|
2753
|
+
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) {
|
|
2754
|
+
return m.type === n.type && m.status === 1;
|
|
2755
|
+
});
|
|
2756
|
+
return isTimeMatch && isResourceMatch;
|
|
2554
2757
|
});
|
|
2555
2758
|
otherCartItems.forEach(function (m) {
|
|
2556
|
-
var _m$
|
|
2557
|
-
var sameTypeResources = (_m$
|
|
2558
|
-
return m.type === n.type;
|
|
2759
|
+
var _m$_productOrigin4;
|
|
2760
|
+
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) {
|
|
2761
|
+
return m.type === n.type && m.status === 1;
|
|
2559
2762
|
});
|
|
2560
2763
|
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) || [])));
|
|
2561
2764
|
// 把sameTypeResourcesSet 加到currentResourcesSet
|
|
@@ -2564,7 +2767,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2564
2767
|
});
|
|
2565
2768
|
});
|
|
2566
2769
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
2567
|
-
var currentDataResources =
|
|
2770
|
+
var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
2568
2771
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
2569
2772
|
if (currentResourcesSet.has(m.id)) {
|
|
2570
2773
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -2585,8 +2788,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2585
2788
|
// 多个预约的检测规则:
|
|
2586
2789
|
// 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
|
|
2587
2790
|
var _sameCartItems = cartItems.filter(function (m) {
|
|
2588
|
-
var _m$
|
|
2589
|
-
return ((_m$
|
|
2791
|
+
var _m$_productOrigin5, _targetProductData$id3;
|
|
2792
|
+
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;
|
|
2590
2793
|
});
|
|
2591
2794
|
var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
|
|
2592
2795
|
return acc + getCapacityInfoByCartItem(curr).currentCapacity;
|
|
@@ -2610,8 +2813,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2610
2813
|
return !m.onlyComputed;
|
|
2611
2814
|
}));
|
|
2612
2815
|
otherSameTimesCartItems.forEach(function (m) {
|
|
2613
|
-
var _m$
|
|
2614
|
-
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$
|
|
2816
|
+
var _m$_productOrigin6;
|
|
2817
|
+
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);
|
|
2615
2818
|
productResources.forEach(function (m) {
|
|
2616
2819
|
if (m.id === n.id) {
|
|
2617
2820
|
m.renderList.forEach(function (n) {
|
|
@@ -2756,7 +2959,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2756
2959
|
}, {
|
|
2757
2960
|
key: "checkMaxDurationCapacity",
|
|
2758
2961
|
value: function checkMaxDurationCapacity() {
|
|
2759
|
-
var
|
|
2962
|
+
var _this16 = this;
|
|
2760
2963
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
2761
2964
|
return !isNormalProduct(item._productOrigin);
|
|
2762
2965
|
});
|
|
@@ -2962,7 +3165,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2962
3165
|
}));
|
|
2963
3166
|
|
|
2964
3167
|
// 找到所有资源都可用的时间段
|
|
2965
|
-
var commonTimeSlots =
|
|
3168
|
+
var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2966
3169
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
2967
3170
|
if (commonTimeSlots.length === 0) {
|
|
2968
3171
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3055,8 +3258,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3055
3258
|
var resourcesIdSet = new Set();
|
|
3056
3259
|
|
|
3057
3260
|
// 获取资源数据
|
|
3058
|
-
var dateRange =
|
|
3059
|
-
var resourcesDates =
|
|
3261
|
+
var dateRange = _this16.store.date.getDateRange();
|
|
3262
|
+
var resourcesDates = _this16.store.date.getDateList();
|
|
3060
3263
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3061
3264
|
return n.date === startDate;
|
|
3062
3265
|
});
|
|
@@ -3178,7 +3381,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3178
3381
|
}, {
|
|
3179
3382
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3180
3383
|
value: function checkMaxDurationCapacityForDetailNums(_ref13) {
|
|
3181
|
-
var
|
|
3384
|
+
var _this17 = this;
|
|
3182
3385
|
var product = _ref13.product,
|
|
3183
3386
|
date = _ref13.date,
|
|
3184
3387
|
account = _ref13.account;
|
|
@@ -3395,7 +3598,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3395
3598
|
}));
|
|
3396
3599
|
|
|
3397
3600
|
// 找到所有资源都可用的时间段
|
|
3398
|
-
var commonTimeSlots =
|
|
3601
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3399
3602
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3400
3603
|
if (commonTimeSlots.length === 0) {
|
|
3401
3604
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3489,7 +3692,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3489
3692
|
|
|
3490
3693
|
// 获取资源数据
|
|
3491
3694
|
// const dateRange = this.store.date.getDateRange();
|
|
3492
|
-
var resourcesDates =
|
|
3695
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3493
3696
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3494
3697
|
return n.date === startDate;
|
|
3495
3698
|
});
|
|
@@ -3559,41 +3762,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3559
3762
|
}, {
|
|
3560
3763
|
key: "getProductTypeById",
|
|
3561
3764
|
value: function () {
|
|
3562
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3765
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
3563
3766
|
var productData, _productData$schedule;
|
|
3564
|
-
return _regeneratorRuntime().wrap(function
|
|
3565
|
-
while (1) switch (
|
|
3767
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3768
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
3566
3769
|
case 0:
|
|
3567
|
-
|
|
3770
|
+
_context26.next = 2;
|
|
3568
3771
|
return this.store.products.getProduct(id);
|
|
3569
3772
|
case 2:
|
|
3570
|
-
productData =
|
|
3773
|
+
productData = _context26.sent;
|
|
3571
3774
|
if (!productData) {
|
|
3572
|
-
|
|
3775
|
+
_context26.next = 9;
|
|
3573
3776
|
break;
|
|
3574
3777
|
}
|
|
3575
3778
|
if (!productData.duration) {
|
|
3576
|
-
|
|
3779
|
+
_context26.next = 6;
|
|
3577
3780
|
break;
|
|
3578
3781
|
}
|
|
3579
|
-
return
|
|
3782
|
+
return _context26.abrupt("return", 'duration');
|
|
3580
3783
|
case 6:
|
|
3581
3784
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
3582
|
-
|
|
3785
|
+
_context26.next = 8;
|
|
3583
3786
|
break;
|
|
3584
3787
|
}
|
|
3585
|
-
return
|
|
3788
|
+
return _context26.abrupt("return", 'session');
|
|
3586
3789
|
case 8:
|
|
3587
|
-
return
|
|
3790
|
+
return _context26.abrupt("return", 'normal');
|
|
3588
3791
|
case 9:
|
|
3589
|
-
return
|
|
3792
|
+
return _context26.abrupt("return", 'normal');
|
|
3590
3793
|
case 10:
|
|
3591
3794
|
case "end":
|
|
3592
|
-
return
|
|
3795
|
+
return _context26.stop();
|
|
3593
3796
|
}
|
|
3594
|
-
},
|
|
3797
|
+
}, _callee26, this);
|
|
3595
3798
|
}));
|
|
3596
|
-
function getProductTypeById(
|
|
3799
|
+
function getProductTypeById(_x23) {
|
|
3597
3800
|
return _getProductTypeById.apply(this, arguments);
|
|
3598
3801
|
}
|
|
3599
3802
|
return getProductTypeById;
|
|
@@ -3713,10 +3916,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3713
3916
|
}, {
|
|
3714
3917
|
key: "getTimeslotsScheduleByDateRange",
|
|
3715
3918
|
value: (function () {
|
|
3716
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3919
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref14) {
|
|
3717
3920
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
3718
|
-
return _regeneratorRuntime().wrap(function
|
|
3719
|
-
while (1) switch (
|
|
3921
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3922
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3720
3923
|
case 0:
|
|
3721
3924
|
startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
|
|
3722
3925
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
@@ -3743,14 +3946,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3743
3946
|
resources: resources
|
|
3744
3947
|
});
|
|
3745
3948
|
}
|
|
3746
|
-
return
|
|
3949
|
+
return _context27.abrupt("return", results);
|
|
3747
3950
|
case 9:
|
|
3748
3951
|
case "end":
|
|
3749
|
-
return
|
|
3952
|
+
return _context27.stop();
|
|
3750
3953
|
}
|
|
3751
|
-
},
|
|
3954
|
+
}, _callee27, this);
|
|
3752
3955
|
}));
|
|
3753
|
-
function getTimeslotsScheduleByDateRange(
|
|
3956
|
+
function getTimeslotsScheduleByDateRange(_x24) {
|
|
3754
3957
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
3755
3958
|
}
|
|
3756
3959
|
return getTimeslotsScheduleByDateRange;
|
|
@@ -3758,7 +3961,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3758
3961
|
}, {
|
|
3759
3962
|
key: "getAvailableDateForSessionOptimize",
|
|
3760
3963
|
value: function () {
|
|
3761
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3964
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3762
3965
|
var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
|
|
3763
3966
|
var params,
|
|
3764
3967
|
startDate,
|
|
@@ -3778,11 +3981,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3778
3981
|
allProductResources,
|
|
3779
3982
|
targetSchedules,
|
|
3780
3983
|
_loop7,
|
|
3781
|
-
|
|
3782
|
-
return _regeneratorRuntime().wrap(function
|
|
3783
|
-
while (1) switch (
|
|
3984
|
+
_args29 = arguments;
|
|
3985
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
3986
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3784
3987
|
case 0:
|
|
3785
|
-
params =
|
|
3988
|
+
params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
|
|
3786
3989
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3787
3990
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
3788
3991
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3807,15 +4010,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3807
4010
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3808
4011
|
cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
|
|
3809
4012
|
if (!cache) {
|
|
3810
|
-
|
|
4013
|
+
_context29.next = 13;
|
|
3811
4014
|
break;
|
|
3812
4015
|
}
|
|
3813
4016
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3814
|
-
|
|
4017
|
+
_context29.next = 13;
|
|
3815
4018
|
break;
|
|
3816
4019
|
}
|
|
3817
4020
|
this.store.date.setDateList(cache.dateList);
|
|
3818
|
-
return
|
|
4021
|
+
return _context29.abrupt("return", {
|
|
3819
4022
|
dateList: cache.dateList,
|
|
3820
4023
|
firstAvailableDate: cache.firstAvailableDate
|
|
3821
4024
|
});
|
|
@@ -3825,7 +4028,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3825
4028
|
schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
|
|
3826
4029
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3827
4030
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3828
|
-
|
|
4031
|
+
_context29.next = 19;
|
|
3829
4032
|
return this.store.date.fetchResourceDates({
|
|
3830
4033
|
query: {
|
|
3831
4034
|
start_date: startDate || '',
|
|
@@ -3834,7 +4037,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3834
4037
|
}
|
|
3835
4038
|
});
|
|
3836
4039
|
case 19:
|
|
3837
|
-
res =
|
|
4040
|
+
res = _context29.sent;
|
|
3838
4041
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3839
4042
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3840
4043
|
dates = [];
|
|
@@ -3856,8 +4059,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3856
4059
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3857
4060
|
_loop7 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop7() {
|
|
3858
4061
|
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
3859
|
-
return _regeneratorRuntime().wrap(function _loop7$(
|
|
3860
|
-
while (1) switch (
|
|
4062
|
+
return _regeneratorRuntime().wrap(function _loop7$(_context28) {
|
|
4063
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3861
4064
|
case 0:
|
|
3862
4065
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3863
4066
|
status = 'available'; // 1. 检查商品的提前量等情况是否满足
|
|
@@ -3949,32 +4152,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3949
4152
|
|
|
3950
4153
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
3951
4154
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
3952
|
-
|
|
4155
|
+
_context28.next = 9;
|
|
3953
4156
|
break;
|
|
3954
4157
|
}
|
|
3955
|
-
return
|
|
4158
|
+
return _context28.abrupt("return", 1);
|
|
3956
4159
|
case 9:
|
|
3957
4160
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
3958
4161
|
case 10:
|
|
3959
4162
|
case "end":
|
|
3960
|
-
return
|
|
4163
|
+
return _context28.stop();
|
|
3961
4164
|
}
|
|
3962
4165
|
}, _loop7);
|
|
3963
4166
|
});
|
|
3964
4167
|
case 28:
|
|
3965
4168
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3966
|
-
|
|
4169
|
+
_context29.next = 34;
|
|
3967
4170
|
break;
|
|
3968
4171
|
}
|
|
3969
|
-
return
|
|
4172
|
+
return _context29.delegateYield(_loop7(), "t0", 30);
|
|
3970
4173
|
case 30:
|
|
3971
|
-
if (!
|
|
3972
|
-
|
|
4174
|
+
if (!_context29.t0) {
|
|
4175
|
+
_context29.next = 32;
|
|
3973
4176
|
break;
|
|
3974
4177
|
}
|
|
3975
|
-
return
|
|
4178
|
+
return _context29.abrupt("break", 34);
|
|
3976
4179
|
case 32:
|
|
3977
|
-
|
|
4180
|
+
_context29.next = 28;
|
|
3978
4181
|
break;
|
|
3979
4182
|
case 34:
|
|
3980
4183
|
// 最终把资源数据也加到日期内
|
|
@@ -3989,15 +4192,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3989
4192
|
startDate: startDate,
|
|
3990
4193
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
3991
4194
|
};
|
|
3992
|
-
return
|
|
4195
|
+
return _context29.abrupt("return", {
|
|
3993
4196
|
dateList: dates,
|
|
3994
4197
|
firstAvailableDate: firstAvailableDate
|
|
3995
4198
|
});
|
|
3996
4199
|
case 39:
|
|
3997
4200
|
case "end":
|
|
3998
|
-
return
|
|
4201
|
+
return _context29.stop();
|
|
3999
4202
|
}
|
|
4000
|
-
},
|
|
4203
|
+
}, _callee28, this);
|
|
4001
4204
|
}));
|
|
4002
4205
|
function getAvailableDateForSessionOptimize() {
|
|
4003
4206
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4044,18 +4247,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4044
4247
|
}, {
|
|
4045
4248
|
key: "getContactInfo",
|
|
4046
4249
|
value: (function () {
|
|
4047
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4048
|
-
return _regeneratorRuntime().wrap(function
|
|
4049
|
-
while (1) switch (
|
|
4250
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4251
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context30) {
|
|
4252
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4050
4253
|
case 0:
|
|
4051
|
-
return
|
|
4254
|
+
return _context30.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4052
4255
|
case 1:
|
|
4053
4256
|
case "end":
|
|
4054
|
-
return
|
|
4257
|
+
return _context30.stop();
|
|
4055
4258
|
}
|
|
4056
|
-
},
|
|
4259
|
+
}, _callee29, this);
|
|
4057
4260
|
}));
|
|
4058
|
-
function getContactInfo(
|
|
4261
|
+
function getContactInfo(_x25) {
|
|
4059
4262
|
return _getContactInfo.apply(this, arguments);
|
|
4060
4263
|
}
|
|
4061
4264
|
return getContactInfo;
|
|
@@ -344,8 +344,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
344
344
|
resourcesInType.forEach(function (resource) {
|
|
345
345
|
// 过滤出在时间段内的资源时间片
|
|
346
346
|
var availableTimes = resource.times.filter(function (time) {
|
|
347
|
-
|
|
348
|
-
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute') && ((_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.length) === 0;
|
|
347
|
+
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
|
|
349
348
|
});
|
|
350
349
|
if (availableTimes.length > 0) {
|
|
351
350
|
availableResourceCount++;
|
|
@@ -103,13 +103,6 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
103
103
|
{ useCache: true }
|
|
104
104
|
);
|
|
105
105
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
|
-
if (sortedList.length) {
|
|
107
|
-
sortedList.forEach((n) => {
|
|
108
|
-
if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
|
|
109
|
-
n.is_eject = 1;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
106
|
this.addProduct(sortedList);
|
|
114
107
|
return sortedList;
|
|
115
108
|
}
|
|
@@ -299,6 +299,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
299
299
|
errorList: any[];
|
|
300
300
|
};
|
|
301
301
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
302
|
+
getTimeSlotByAllResourcesForDate(resources_code: string, start_date: string, end_date: string): Promise<{
|
|
303
|
+
date: string;
|
|
304
|
+
status: string;
|
|
305
|
+
week: string;
|
|
306
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
307
|
+
}[]>;
|
|
302
308
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
303
309
|
private getScheduleDataByIds;
|
|
304
310
|
openProductDetail(productId: number): Promise<void>;
|
|
@@ -1545,6 +1545,157 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1545
1545
|
});
|
|
1546
1546
|
return timeSlots;
|
|
1547
1547
|
}
|
|
1548
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
1549
|
+
async getTimeSlotByAllResourcesForDate(resources_code, start_date, end_date) {
|
|
1550
|
+
var _a, _b, _c, _d;
|
|
1551
|
+
if ((0, import_dayjs.default)(end_date).diff((0, import_dayjs.default)(start_date), "day") < 30) {
|
|
1552
|
+
end_date = (0, import_dayjs.default)(start_date).add(30, "day").format("YYYY-MM-DD");
|
|
1553
|
+
}
|
|
1554
|
+
await this.getAvailableDate({
|
|
1555
|
+
startDate: start_date,
|
|
1556
|
+
endDate: end_date,
|
|
1557
|
+
useCache: true
|
|
1558
|
+
});
|
|
1559
|
+
const resources = [];
|
|
1560
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1561
|
+
const resourceIds = [];
|
|
1562
|
+
let resourcesTypeId = void 0;
|
|
1563
|
+
let isSingleResource = false;
|
|
1564
|
+
let maxCutOffTime = void 0;
|
|
1565
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1566
|
+
cartItems.forEach((item) => {
|
|
1567
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
1568
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1569
|
+
if (n.code === resources_code) {
|
|
1570
|
+
resources.push(...n.renderList || []);
|
|
1571
|
+
isSingleResource = n.type === "single";
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1575
|
+
resourceIds.push(item.resource_id);
|
|
1576
|
+
}
|
|
1577
|
+
resourcesTypeId = (_g = (_f = (_e = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find(
|
|
1578
|
+
(n) => n.code === resources_code
|
|
1579
|
+
)) == null ? void 0 : _g.id;
|
|
1580
|
+
if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1581
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1582
|
+
item._productOrigin.cut_off_time.unit,
|
|
1583
|
+
item._productOrigin.cut_off_time.unit_type
|
|
1584
|
+
);
|
|
1585
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1586
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
1587
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1592
|
+
let duration = 0;
|
|
1593
|
+
const accountList = this.store.accountList.getAccounts();
|
|
1594
|
+
const checkDuration = (cartItems2) => {
|
|
1595
|
+
let accountDuration = 0;
|
|
1596
|
+
cartItems2.forEach((item) => {
|
|
1597
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1598
|
+
if (isSingleResource) {
|
|
1599
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1600
|
+
} else {
|
|
1601
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1602
|
+
accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
if (accountDuration > duration) {
|
|
1607
|
+
duration = accountDuration;
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1611
|
+
accountList.forEach((account) => {
|
|
1612
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1613
|
+
checkDuration(cartItems2);
|
|
1614
|
+
});
|
|
1615
|
+
} else {
|
|
1616
|
+
checkDuration(cartItems);
|
|
1617
|
+
}
|
|
1618
|
+
if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1619
|
+
return [];
|
|
1620
|
+
}
|
|
1621
|
+
const resourcesUseableMap = {};
|
|
1622
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1623
|
+
(item) => {
|
|
1624
|
+
var _a2, _b2;
|
|
1625
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1626
|
+
}
|
|
1627
|
+
);
|
|
1628
|
+
let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
|
|
1629
|
+
let maxBlockThreshold = 0;
|
|
1630
|
+
if (hasFlexibleDuration) {
|
|
1631
|
+
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1632
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1633
|
+
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1634
|
+
return Math.max(max, ((_f = (_e = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.block_threshold) || 0);
|
|
1635
|
+
}
|
|
1636
|
+
return 0;
|
|
1637
|
+
}, 0);
|
|
1638
|
+
}
|
|
1639
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1640
|
+
return items.reduce((total, item) => {
|
|
1641
|
+
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1642
|
+
}, 0);
|
|
1643
|
+
};
|
|
1644
|
+
let maxCapacity = 1;
|
|
1645
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1646
|
+
accountList.forEach((account) => {
|
|
1647
|
+
const accountCartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1648
|
+
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1649
|
+
if (currentCapacity > maxCapacity) {
|
|
1650
|
+
maxCapacity = currentCapacity;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
} else {
|
|
1654
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1655
|
+
}
|
|
1656
|
+
const arr = [];
|
|
1657
|
+
const today = (0, import_dayjs.default)().startOf("day");
|
|
1658
|
+
for (let i = (0, import_dayjs.default)(start_date); i.isBefore((0, import_dayjs.default)(end_date)); i = i.add(1, "day")) {
|
|
1659
|
+
if (i.isBefore(today)) {
|
|
1660
|
+
arr.push({
|
|
1661
|
+
date: i.format("YYYY-MM-DD"),
|
|
1662
|
+
status: "unavailable",
|
|
1663
|
+
week: i.format("ddd"),
|
|
1664
|
+
weekNum: i.day()
|
|
1665
|
+
});
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1669
|
+
resourceIds,
|
|
1670
|
+
resourcesMap,
|
|
1671
|
+
duration,
|
|
1672
|
+
currentDate: i.format("YYYY-MM-DD"),
|
|
1673
|
+
split: 10,
|
|
1674
|
+
resourcesUseableMap,
|
|
1675
|
+
capacity: maxCapacity,
|
|
1676
|
+
cut_off_time: maxCutOffTime,
|
|
1677
|
+
hasFlexibleDuration,
|
|
1678
|
+
operating_day_boundary,
|
|
1679
|
+
maxBlockThreshold
|
|
1680
|
+
});
|
|
1681
|
+
if (timeSlots.length > 0) {
|
|
1682
|
+
arr.push({
|
|
1683
|
+
date: i.format("YYYY-MM-DD"),
|
|
1684
|
+
status: "available",
|
|
1685
|
+
week: i.format("ddd"),
|
|
1686
|
+
weekNum: i.day()
|
|
1687
|
+
});
|
|
1688
|
+
} else {
|
|
1689
|
+
arr.push({
|
|
1690
|
+
date: i.format("YYYY-MM-DD"),
|
|
1691
|
+
status: "unavailable",
|
|
1692
|
+
week: i.format("ddd"),
|
|
1693
|
+
weekNum: i.day()
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return arr;
|
|
1698
|
+
}
|
|
1548
1699
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1549
1700
|
submitTimeSlot(timeSlots) {
|
|
1550
1701
|
var _a, _b;
|
|
@@ -1783,6 +1934,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1783
1934
|
});
|
|
1784
1935
|
const cartItems2 = this.store.cart.getItems();
|
|
1785
1936
|
productResources.forEach((n) => {
|
|
1937
|
+
debugger;
|
|
1786
1938
|
if (n.type === "single") {
|
|
1787
1939
|
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
1788
1940
|
const sameCartItems = cartItems2.filter((m) => {
|
|
@@ -1793,13 +1945,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1793
1945
|
bookingLeft = 0;
|
|
1794
1946
|
count = 0;
|
|
1795
1947
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1948
|
+
let otherCartItems = cartItems2.filter(
|
|
1949
|
+
(m) => {
|
|
1950
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
1951
|
+
const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1952
|
+
const isResourceMatch = (_f = (_e2 = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f.find((m2) => m2.type === n.type && m2.status === 1);
|
|
1953
|
+
return isTimeMatch && isResourceMatch;
|
|
1954
|
+
}
|
|
1955
|
+
);
|
|
1800
1956
|
otherCartItems.forEach((m) => {
|
|
1801
1957
|
var _a2, _b2, _c2;
|
|
1802
|
-
const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type);
|
|
1958
|
+
const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type && m2.status === 1);
|
|
1803
1959
|
const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
|
|
1804
1960
|
sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
|
|
1805
1961
|
});
|
|
@@ -249,8 +249,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
249
249
|
let availableResourceCount = 0;
|
|
250
250
|
resourcesInType.forEach((resource) => {
|
|
251
251
|
const availableTimes = resource.times.filter((time) => {
|
|
252
|
-
|
|
253
|
-
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && ((_a2 = time.event_list) == null ? void 0 : _a2.length) === 0;
|
|
252
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
254
253
|
});
|
|
255
254
|
if (availableTimes.length > 0) {
|
|
256
255
|
availableResourceCount++;
|