@pisell/pisellos 2.1.71 → 2.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solution/BookingByStep/index.d.ts +10 -0
- package/dist/solution/BookingByStep/index.js +407 -132
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/lib/solution/BookingByStep/index.d.ts +10 -0
- package/lib/solution/BookingByStep/index.js +212 -13
- 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,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2417
2688
|
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
2418
2689
|
}, {
|
|
2419
2690
|
key: "getTimeslotBySchedule",
|
|
2420
|
-
value: function getTimeslotBySchedule(
|
|
2691
|
+
value: function getTimeslotBySchedule(_ref11) {
|
|
2421
2692
|
var _this$store$currentPr2,
|
|
2422
2693
|
_targetProductData$pr,
|
|
2423
2694
|
_targetProductData$pr2,
|
|
2424
|
-
|
|
2425
|
-
var date =
|
|
2426
|
-
scheduleIds =
|
|
2427
|
-
resources =
|
|
2428
|
-
product =
|
|
2695
|
+
_this15 = this;
|
|
2696
|
+
var date = _ref11.date,
|
|
2697
|
+
scheduleIds = _ref11.scheduleIds,
|
|
2698
|
+
resources = _ref11.resources,
|
|
2699
|
+
product = _ref11.product;
|
|
2429
2700
|
var targetProduct = this.store.currentProduct;
|
|
2430
2701
|
// 如果外面传递了product 优先用外面的
|
|
2431
2702
|
var targetProductData = product || targetProduct;
|
|
@@ -2548,7 +2819,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2548
2819
|
}
|
|
2549
2820
|
});
|
|
2550
2821
|
// 容量检测
|
|
2551
|
-
var cartItems =
|
|
2822
|
+
var cartItems = _this15.store.cart.getItems();
|
|
2552
2823
|
productResources.forEach(function (n) {
|
|
2553
2824
|
// 单个预约检测规则:
|
|
2554
2825
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
@@ -2567,13 +2838,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2567
2838
|
}
|
|
2568
2839
|
// 规则 2
|
|
2569
2840
|
var otherCartItems = cartItems.filter(function (m) {
|
|
2570
|
-
var _m$_productOrigin2, _targetProductData$id2;
|
|
2571
|
-
|
|
2841
|
+
var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
|
|
2842
|
+
var isTimeMatch = ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2843
|
+
var isResourceMatch = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
|
|
2844
|
+
return m.type === n.type && m.status === 1;
|
|
2845
|
+
});
|
|
2846
|
+
return isTimeMatch && isResourceMatch;
|
|
2572
2847
|
});
|
|
2573
2848
|
otherCartItems.forEach(function (m) {
|
|
2574
|
-
var _m$
|
|
2575
|
-
var sameTypeResources = (_m$
|
|
2576
|
-
return m.type === n.type;
|
|
2849
|
+
var _m$_productOrigin4;
|
|
2850
|
+
var sameTypeResources = (_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.product_resource) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.resources) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.find(function (m) {
|
|
2851
|
+
return m.type === n.type && m.status === 1;
|
|
2577
2852
|
});
|
|
2578
2853
|
var sameTypeResourcesSet = new Set([].concat(_toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.optional_resource) || []), _toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.default_resource) || [])));
|
|
2579
2854
|
// 把sameTypeResourcesSet 加到currentResourcesSet
|
|
@@ -2582,7 +2857,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2857
|
});
|
|
2583
2858
|
});
|
|
2584
2859
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
2585
|
-
var currentDataResources =
|
|
2860
|
+
var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
2586
2861
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
2587
2862
|
if (currentResourcesSet.has(m.id)) {
|
|
2588
2863
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -2604,8 +2879,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2604
2879
|
// 多个预约的检测规则:
|
|
2605
2880
|
// 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
|
|
2606
2881
|
var _sameCartItems = cartItems.filter(function (m) {
|
|
2607
|
-
var _m$
|
|
2608
|
-
return ((_m$
|
|
2882
|
+
var _m$_productOrigin5, _targetProductData$id3;
|
|
2883
|
+
return ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.id) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2609
2884
|
});
|
|
2610
2885
|
var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
|
|
2611
2886
|
return acc + getCapacityInfoByCartItem(curr).currentCapacity;
|
|
@@ -2630,8 +2905,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2630
2905
|
return !m.onlyComputed;
|
|
2631
2906
|
}));
|
|
2632
2907
|
otherSameTimesCartItems.forEach(function (m) {
|
|
2633
|
-
var _m$
|
|
2634
|
-
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$
|
|
2908
|
+
var _m$_productOrigin6;
|
|
2909
|
+
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin6 = m._productOrigin) === null || _m$_productOrigin6 === void 0 || (_m$_productOrigin6 = _m$_productOrigin6.product_resource) === null || _m$_productOrigin6 === void 0 ? void 0 : _m$_productOrigin6.resources) || [], selectedResources, 1);
|
|
2635
2910
|
productResources.forEach(function (m) {
|
|
2636
2911
|
if (m.id === n.id) {
|
|
2637
2912
|
m.renderList.forEach(function (n) {
|
|
@@ -2757,7 +3032,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2757
3032
|
}));
|
|
2758
3033
|
|
|
2759
3034
|
// 与其他资源的时间段求交集
|
|
2760
|
-
var
|
|
3035
|
+
var _loop3 = function _loop3() {
|
|
2761
3036
|
var currentResourceSlots = allTimeSlots[i];
|
|
2762
3037
|
var intersections = [];
|
|
2763
3038
|
|
|
@@ -2786,7 +3061,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2786
3061
|
}));
|
|
2787
3062
|
};
|
|
2788
3063
|
for (var i = 1; i < allTimeSlots.length; i++) {
|
|
2789
|
-
if (
|
|
3064
|
+
if (_loop3()) continue;
|
|
2790
3065
|
}
|
|
2791
3066
|
|
|
2792
3067
|
// 格式化返回结果
|
|
@@ -2802,7 +3077,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2802
3077
|
}, {
|
|
2803
3078
|
key: "checkMaxDurationCapacity",
|
|
2804
3079
|
value: function checkMaxDurationCapacity() {
|
|
2805
|
-
var
|
|
3080
|
+
var _this16 = this;
|
|
2806
3081
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
2807
3082
|
return !isNormalProduct(item._productOrigin);
|
|
2808
3083
|
});
|
|
@@ -2892,7 +3167,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2892
3167
|
var processedCartItemIds = new Set();
|
|
2893
3168
|
|
|
2894
3169
|
// 先检查所有资源类型,收集可用数量信息
|
|
2895
|
-
var
|
|
3170
|
+
var _loop4 = function _loop4() {
|
|
2896
3171
|
var _resourceTypeConfig;
|
|
2897
3172
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
2898
3173
|
resourceCode = _Object$entries$_i[0],
|
|
@@ -3008,7 +3283,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3008
3283
|
}));
|
|
3009
3284
|
|
|
3010
3285
|
// 找到所有资源都可用的时间段
|
|
3011
|
-
var commonTimeSlots =
|
|
3286
|
+
var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3012
3287
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3013
3288
|
if (commonTimeSlots.length === 0) {
|
|
3014
3289
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3039,7 +3314,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3039
3314
|
},
|
|
3040
3315
|
_ret2;
|
|
3041
3316
|
for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
|
|
3042
|
-
_ret2 =
|
|
3317
|
+
_ret2 = _loop4();
|
|
3043
3318
|
if (_ret2) return _ret2.v;
|
|
3044
3319
|
}
|
|
3045
3320
|
|
|
@@ -3083,7 +3358,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3083
3358
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3084
3359
|
});
|
|
3085
3360
|
// 检查每个时间段是否有足够的资源容量
|
|
3086
|
-
var
|
|
3361
|
+
var _loop5 = function _loop5() {
|
|
3087
3362
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3088
3363
|
timeSlotKey = _Object$entries2$_i[0],
|
|
3089
3364
|
itemsInTimeSlot = _Object$entries2$_i[1];
|
|
@@ -3101,8 +3376,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3101
3376
|
var resourcesIdSet = new Set();
|
|
3102
3377
|
|
|
3103
3378
|
// 获取资源数据
|
|
3104
|
-
var dateRange =
|
|
3105
|
-
var resourcesDates =
|
|
3379
|
+
var dateRange = _this16.store.date.getDateRange();
|
|
3380
|
+
var resourcesDates = _this16.store.date.getDateList();
|
|
3106
3381
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3107
3382
|
return n.date === startDate;
|
|
3108
3383
|
});
|
|
@@ -3139,7 +3414,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3139
3414
|
},
|
|
3140
3415
|
_ret3;
|
|
3141
3416
|
for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
|
|
3142
|
-
_ret3 =
|
|
3417
|
+
_ret3 = _loop5();
|
|
3143
3418
|
if (_ret3 === 0) continue;
|
|
3144
3419
|
if (_ret3) return _ret3.v;
|
|
3145
3420
|
}
|
|
@@ -3158,17 +3433,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3158
3433
|
*/
|
|
3159
3434
|
}, {
|
|
3160
3435
|
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 =
|
|
3436
|
+
value: function convertProductToCartItem(_ref12) {
|
|
3437
|
+
var product = _ref12.product,
|
|
3438
|
+
date = _ref12.date,
|
|
3439
|
+
account = _ref12.account;
|
|
3440
|
+
var _ref13 = product || {},
|
|
3441
|
+
bundle = _ref13.bundle,
|
|
3442
|
+
options = _ref13.options,
|
|
3443
|
+
origin = _ref13.origin,
|
|
3444
|
+
product_variant_id = _ref13.product_variant_id,
|
|
3445
|
+
_ref13$quantity = _ref13.quantity,
|
|
3446
|
+
quantity = _ref13$quantity === void 0 ? 1 : _ref13$quantity;
|
|
3172
3447
|
|
|
3173
3448
|
// 处理商品数据,类似 addProductToCart 中的逻辑
|
|
3174
3449
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -3223,11 +3498,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3223
3498
|
}
|
|
3224
3499
|
}, {
|
|
3225
3500
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3226
|
-
value: function checkMaxDurationCapacityForDetailNums(
|
|
3227
|
-
var
|
|
3228
|
-
var product =
|
|
3229
|
-
date =
|
|
3230
|
-
account =
|
|
3501
|
+
value: function checkMaxDurationCapacityForDetailNums(_ref14) {
|
|
3502
|
+
var _this17 = this;
|
|
3503
|
+
var product = _ref14.product,
|
|
3504
|
+
date = _ref14.date,
|
|
3505
|
+
account = _ref14.account;
|
|
3231
3506
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3232
3507
|
return !isNormalProduct(item._productOrigin);
|
|
3233
3508
|
});
|
|
@@ -3325,7 +3600,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3600
|
var processedCartItemIds = new Set();
|
|
3326
3601
|
|
|
3327
3602
|
// 先检查所有资源类型,收集可用数量信息
|
|
3328
|
-
var
|
|
3603
|
+
var _loop6 = function _loop6() {
|
|
3329
3604
|
var _resourceTypeConfig2;
|
|
3330
3605
|
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
3331
3606
|
resourceCode = _Object$entries3$_i[0],
|
|
@@ -3441,7 +3716,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3441
3716
|
}));
|
|
3442
3717
|
|
|
3443
3718
|
// 找到所有资源都可用的时间段
|
|
3444
|
-
var commonTimeSlots =
|
|
3719
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3445
3720
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3446
3721
|
if (commonTimeSlots.length === 0) {
|
|
3447
3722
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3472,7 +3747,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3472
3747
|
},
|
|
3473
3748
|
_ret4;
|
|
3474
3749
|
for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
|
|
3475
|
-
_ret4 =
|
|
3750
|
+
_ret4 = _loop6();
|
|
3476
3751
|
if (_ret4) return _ret4.v;
|
|
3477
3752
|
}
|
|
3478
3753
|
|
|
@@ -3516,7 +3791,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3516
3791
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3517
3792
|
});
|
|
3518
3793
|
// 检查每个时间段是否有足够的资源容量
|
|
3519
|
-
var
|
|
3794
|
+
var _loop7 = function _loop7() {
|
|
3520
3795
|
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
3521
3796
|
timeSlotKey = _Object$entries4$_i[0],
|
|
3522
3797
|
itemsInTimeSlot = _Object$entries4$_i[1];
|
|
@@ -3535,7 +3810,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3535
3810
|
|
|
3536
3811
|
// 获取资源数据
|
|
3537
3812
|
// const dateRange = this.store.date.getDateRange();
|
|
3538
|
-
var resourcesDates =
|
|
3813
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3539
3814
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3540
3815
|
return n.date === startDate;
|
|
3541
3816
|
});
|
|
@@ -3572,7 +3847,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3572
3847
|
},
|
|
3573
3848
|
_ret5;
|
|
3574
3849
|
for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
|
|
3575
|
-
_ret5 =
|
|
3850
|
+
_ret5 = _loop7();
|
|
3576
3851
|
if (_ret5 === 0) continue;
|
|
3577
3852
|
if (_ret5) return _ret5.v;
|
|
3578
3853
|
}
|
|
@@ -3605,41 +3880,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3605
3880
|
}, {
|
|
3606
3881
|
key: "getProductTypeById",
|
|
3607
3882
|
value: function () {
|
|
3608
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3883
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
3609
3884
|
var productData, _productData$schedule;
|
|
3610
|
-
return _regeneratorRuntime().wrap(function
|
|
3611
|
-
while (1) switch (
|
|
3885
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
3886
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3612
3887
|
case 0:
|
|
3613
|
-
|
|
3888
|
+
_context27.next = 2;
|
|
3614
3889
|
return this.store.products.getProduct(id);
|
|
3615
3890
|
case 2:
|
|
3616
|
-
productData =
|
|
3891
|
+
productData = _context27.sent;
|
|
3617
3892
|
if (!productData) {
|
|
3618
|
-
|
|
3893
|
+
_context27.next = 9;
|
|
3619
3894
|
break;
|
|
3620
3895
|
}
|
|
3621
3896
|
if (!productData.duration) {
|
|
3622
|
-
|
|
3897
|
+
_context27.next = 6;
|
|
3623
3898
|
break;
|
|
3624
3899
|
}
|
|
3625
|
-
return
|
|
3900
|
+
return _context27.abrupt("return", 'duration');
|
|
3626
3901
|
case 6:
|
|
3627
3902
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
3628
|
-
|
|
3903
|
+
_context27.next = 8;
|
|
3629
3904
|
break;
|
|
3630
3905
|
}
|
|
3631
|
-
return
|
|
3906
|
+
return _context27.abrupt("return", 'session');
|
|
3632
3907
|
case 8:
|
|
3633
|
-
return
|
|
3908
|
+
return _context27.abrupt("return", 'normal');
|
|
3634
3909
|
case 9:
|
|
3635
|
-
return
|
|
3910
|
+
return _context27.abrupt("return", 'normal');
|
|
3636
3911
|
case 10:
|
|
3637
3912
|
case "end":
|
|
3638
|
-
return
|
|
3913
|
+
return _context27.stop();
|
|
3639
3914
|
}
|
|
3640
|
-
},
|
|
3915
|
+
}, _callee26, this);
|
|
3641
3916
|
}));
|
|
3642
|
-
function getProductTypeById(
|
|
3917
|
+
function getProductTypeById(_x21) {
|
|
3643
3918
|
return _getProductTypeById.apply(this, arguments);
|
|
3644
3919
|
}
|
|
3645
3920
|
return getProductTypeById;
|
|
@@ -3759,12 +4034,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
4034
|
}, {
|
|
3760
4035
|
key: "getTimeslotsScheduleByDateRange",
|
|
3761
4036
|
value: (function () {
|
|
3762
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4037
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref15) {
|
|
3763
4038
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
3764
|
-
return _regeneratorRuntime().wrap(function
|
|
3765
|
-
while (1) switch (
|
|
4039
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
4040
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3766
4041
|
case 0:
|
|
3767
|
-
startDate =
|
|
4042
|
+
startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
|
|
3768
4043
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
3769
4044
|
startDate: startDate,
|
|
3770
4045
|
endDate: endDate,
|
|
@@ -3789,14 +4064,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3789
4064
|
resources: resources
|
|
3790
4065
|
});
|
|
3791
4066
|
}
|
|
3792
|
-
return
|
|
4067
|
+
return _context28.abrupt("return", results);
|
|
3793
4068
|
case 9:
|
|
3794
4069
|
case "end":
|
|
3795
|
-
return
|
|
4070
|
+
return _context28.stop();
|
|
3796
4071
|
}
|
|
3797
|
-
},
|
|
4072
|
+
}, _callee27, this);
|
|
3798
4073
|
}));
|
|
3799
|
-
function getTimeslotsScheduleByDateRange(
|
|
4074
|
+
function getTimeslotsScheduleByDateRange(_x22) {
|
|
3800
4075
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
3801
4076
|
}
|
|
3802
4077
|
return getTimeslotsScheduleByDateRange;
|
|
@@ -3804,7 +4079,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3804
4079
|
}, {
|
|
3805
4080
|
key: "getAvailableDateForSessionOptimize",
|
|
3806
4081
|
value: function () {
|
|
3807
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4082
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3808
4083
|
var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
|
|
3809
4084
|
var params,
|
|
3810
4085
|
startDate,
|
|
@@ -3823,12 +4098,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3823
4098
|
openResources,
|
|
3824
4099
|
allProductResources,
|
|
3825
4100
|
targetSchedules,
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
return _regeneratorRuntime().wrap(function
|
|
3829
|
-
while (1) switch (
|
|
4101
|
+
_loop8,
|
|
4102
|
+
_args30 = arguments;
|
|
4103
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
4104
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3830
4105
|
case 0:
|
|
3831
|
-
params =
|
|
4106
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3832
4107
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3833
4108
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
3834
4109
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3853,15 +4128,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3853
4128
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3854
4129
|
cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
|
|
3855
4130
|
if (!cache) {
|
|
3856
|
-
|
|
4131
|
+
_context30.next = 13;
|
|
3857
4132
|
break;
|
|
3858
4133
|
}
|
|
3859
4134
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3860
|
-
|
|
4135
|
+
_context30.next = 13;
|
|
3861
4136
|
break;
|
|
3862
4137
|
}
|
|
3863
4138
|
this.store.date.setDateList(cache.dateList);
|
|
3864
|
-
return
|
|
4139
|
+
return _context30.abrupt("return", {
|
|
3865
4140
|
dateList: cache.dateList,
|
|
3866
4141
|
firstAvailableDate: cache.firstAvailableDate
|
|
3867
4142
|
});
|
|
@@ -3871,7 +4146,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3871
4146
|
schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
|
|
3872
4147
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3873
4148
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3874
|
-
|
|
4149
|
+
_context30.next = 19;
|
|
3875
4150
|
return this.store.date.fetchResourceDates({
|
|
3876
4151
|
query: {
|
|
3877
4152
|
start_date: startDate || '',
|
|
@@ -3880,7 +4155,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3880
4155
|
}
|
|
3881
4156
|
});
|
|
3882
4157
|
case 19:
|
|
3883
|
-
res =
|
|
4158
|
+
res = _context30.sent;
|
|
3884
4159
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3885
4160
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3886
4161
|
dates = [];
|
|
@@ -3900,10 +4175,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3900
4175
|
}
|
|
3901
4176
|
});
|
|
3902
4177
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3903
|
-
|
|
4178
|
+
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
3904
4179
|
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
3905
|
-
return _regeneratorRuntime().wrap(function
|
|
3906
|
-
while (1) switch (
|
|
4180
|
+
return _regeneratorRuntime().wrap(function _loop8$(_context29) {
|
|
4181
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3907
4182
|
case 0:
|
|
3908
4183
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3909
4184
|
status = 'available';
|
|
@@ -4037,32 +4312,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4037
4312
|
|
|
4038
4313
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
4039
4314
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
4040
|
-
|
|
4315
|
+
_context29.next = 12;
|
|
4041
4316
|
break;
|
|
4042
4317
|
}
|
|
4043
|
-
return
|
|
4318
|
+
return _context29.abrupt("return", 1);
|
|
4044
4319
|
case 12:
|
|
4045
4320
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
4046
4321
|
case 13:
|
|
4047
4322
|
case "end":
|
|
4048
|
-
return
|
|
4323
|
+
return _context29.stop();
|
|
4049
4324
|
}
|
|
4050
|
-
},
|
|
4325
|
+
}, _loop8);
|
|
4051
4326
|
});
|
|
4052
4327
|
case 28:
|
|
4053
4328
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
4054
|
-
|
|
4329
|
+
_context30.next = 34;
|
|
4055
4330
|
break;
|
|
4056
4331
|
}
|
|
4057
|
-
return
|
|
4332
|
+
return _context30.delegateYield(_loop8(), "t0", 30);
|
|
4058
4333
|
case 30:
|
|
4059
|
-
if (!
|
|
4060
|
-
|
|
4334
|
+
if (!_context30.t0) {
|
|
4335
|
+
_context30.next = 32;
|
|
4061
4336
|
break;
|
|
4062
4337
|
}
|
|
4063
|
-
return
|
|
4338
|
+
return _context30.abrupt("break", 34);
|
|
4064
4339
|
case 32:
|
|
4065
|
-
|
|
4340
|
+
_context30.next = 28;
|
|
4066
4341
|
break;
|
|
4067
4342
|
case 34:
|
|
4068
4343
|
// 最终把资源数据也加到日期内
|
|
@@ -4077,15 +4352,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4077
4352
|
startDate: startDate,
|
|
4078
4353
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
4079
4354
|
};
|
|
4080
|
-
return
|
|
4355
|
+
return _context30.abrupt("return", {
|
|
4081
4356
|
dateList: dates,
|
|
4082
4357
|
firstAvailableDate: firstAvailableDate
|
|
4083
4358
|
});
|
|
4084
4359
|
case 39:
|
|
4085
4360
|
case "end":
|
|
4086
|
-
return
|
|
4361
|
+
return _context30.stop();
|
|
4087
4362
|
}
|
|
4088
|
-
},
|
|
4363
|
+
}, _callee28, this);
|
|
4089
4364
|
}));
|
|
4090
4365
|
function getAvailableDateForSessionOptimize() {
|
|
4091
4366
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4132,18 +4407,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4132
4407
|
}, {
|
|
4133
4408
|
key: "getContactInfo",
|
|
4134
4409
|
value: (function () {
|
|
4135
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4136
|
-
return _regeneratorRuntime().wrap(function
|
|
4137
|
-
while (1) switch (
|
|
4410
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4411
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
4412
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4138
4413
|
case 0:
|
|
4139
|
-
return
|
|
4414
|
+
return _context31.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4140
4415
|
case 1:
|
|
4141
4416
|
case "end":
|
|
4142
|
-
return
|
|
4417
|
+
return _context31.stop();
|
|
4143
4418
|
}
|
|
4144
|
-
},
|
|
4419
|
+
}, _callee29, this);
|
|
4145
4420
|
}));
|
|
4146
|
-
function getContactInfo(
|
|
4421
|
+
function getContactInfo(_x23) {
|
|
4147
4422
|
return _getContactInfo.apply(this, arguments);
|
|
4148
4423
|
}
|
|
4149
4424
|
return getContactInfo;
|