@pisell/pisellos 3.0.21 → 3.0.22
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.js +33 -16
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/dist/solution/BookingByStep/utils/resources.js +18 -4
- package/lib/solution/BookingByStep/index.js +19 -5
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/lib/solution/BookingByStep/utils/resources.js +13 -4
- package/package.json +1 -1
|
@@ -1293,6 +1293,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1293
|
return false;
|
|
1294
1294
|
}
|
|
1295
1295
|
var canUseArr = mTimes.map(function (item) {
|
|
1296
|
+
var _cartItem$_productOri3;
|
|
1296
1297
|
var res = getIsUsableByTimeItem({
|
|
1297
1298
|
timeSlice: {
|
|
1298
1299
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1303,7 +1304,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1303
1304
|
time: item,
|
|
1304
1305
|
resource: m,
|
|
1305
1306
|
currentCount: currentCapacity || 0,
|
|
1306
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1307
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1308
|
+
cut_off_time: (_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.cut_off_time
|
|
1307
1309
|
});
|
|
1308
1310
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1309
1311
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1323,13 +1325,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1325
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1324
1326
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1325
1327
|
item.renderList = item.renderList.filter(function (n) {
|
|
1326
|
-
var _cartItem$
|
|
1328
|
+
var _cartItem$_productOri4;
|
|
1327
1329
|
var recordCount = n.capacity || 0;
|
|
1328
1330
|
if (n.onlyComputed) return false;
|
|
1329
1331
|
// 查一下这个资源基于商品的可用时间片
|
|
1330
1332
|
var timeSlots = getTimeSlicesByResource({
|
|
1331
1333
|
resource: n,
|
|
1332
|
-
duration: ((_cartItem$
|
|
1334
|
+
duration: ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.value) || 0,
|
|
1333
1335
|
split: 10,
|
|
1334
1336
|
currentDate: dateRange[0].date
|
|
1335
1337
|
});
|
|
@@ -1373,10 +1375,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1373
1375
|
var cartItems = this.store.cart.getItems();
|
|
1374
1376
|
var arr = [];
|
|
1375
1377
|
cartItems.forEach(function (cartItem) {
|
|
1376
|
-
var _cartItem$
|
|
1378
|
+
var _cartItem$_productOri5, _cartItem$_productOri6;
|
|
1377
1379
|
var selectedResources = [];
|
|
1378
1380
|
var formatCapacity = formatDefaultCapacitys({
|
|
1379
|
-
capacity: (_cartItem$
|
|
1381
|
+
capacity: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.capacity,
|
|
1380
1382
|
product_bundle: cartItem._origin.product.product_bundle
|
|
1381
1383
|
});
|
|
1382
1384
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1388,7 +1390,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1390
|
} else {
|
|
1389
1391
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1390
1392
|
}
|
|
1391
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1393
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.product_resource) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.resources) || [], selectedResources, currentCapacity);
|
|
1392
1394
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1393
1395
|
if (cartItem._origin.start_time) {
|
|
1394
1396
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1416,6 +1418,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1416
1418
|
return false;
|
|
1417
1419
|
}
|
|
1418
1420
|
var canUseArr = mTimes.map(function (item) {
|
|
1421
|
+
var _cartItem$_productOri7;
|
|
1419
1422
|
var res = getIsUsableByTimeItem({
|
|
1420
1423
|
timeSlice: {
|
|
1421
1424
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1426,7 +1429,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1426
1429
|
time: item,
|
|
1427
1430
|
resource: m,
|
|
1428
1431
|
currentCount: currentCapacity || 0,
|
|
1429
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1432
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1433
|
+
cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
|
|
1430
1434
|
});
|
|
1431
1435
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1432
1436
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1446,13 +1450,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1450
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1447
1451
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1448
1452
|
item.renderList = item.renderList.filter(function (n) {
|
|
1449
|
-
var _cartItem$
|
|
1453
|
+
var _cartItem$_productOri8;
|
|
1450
1454
|
var recordCount = n.capacity || 0;
|
|
1451
1455
|
if (n.onlyComputed) return false;
|
|
1452
1456
|
// 查一下这个资源基于商品的可用时间片
|
|
1453
1457
|
var timeSlots = getTimeSlicesByResource({
|
|
1454
1458
|
resource: n,
|
|
1455
|
-
duration: ((_cartItem$
|
|
1459
|
+
duration: ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.duration) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.value) || 0,
|
|
1456
1460
|
split: 10,
|
|
1457
1461
|
currentDate: dateRange[0].date
|
|
1458
1462
|
});
|
|
@@ -1554,7 +1558,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1554
1558
|
}, {
|
|
1555
1559
|
key: "autoSelectAccountResources",
|
|
1556
1560
|
value: function autoSelectAccountResources(_ref8) {
|
|
1557
|
-
var _cartItem$
|
|
1561
|
+
var _cartItem$_productOri9, _allProductResources$;
|
|
1558
1562
|
var cartItem = _ref8.cartItem,
|
|
1559
1563
|
holder_id = _ref8.holder_id,
|
|
1560
1564
|
resources_code = _ref8.resources_code,
|
|
@@ -1603,7 +1607,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1607
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1604
1608
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1605
1609
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1606
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1610
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 || (_cartItem$_productOri9 = _cartItem$_productOri9.product_resource) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.resources) || [], selectedResources, 1);
|
|
1607
1611
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1608
1612
|
return n.code === resources_code;
|
|
1609
1613
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
@@ -1653,12 +1657,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1653
1657
|
return 0; // continue
|
|
1654
1658
|
}
|
|
1655
1659
|
var canUseTime = mTimes.find(function (item) {
|
|
1660
|
+
var _cartItem$_productOri10;
|
|
1656
1661
|
var res = getIsUsableByTimeItem({
|
|
1657
1662
|
timeSlice: timeSlots,
|
|
1658
1663
|
time: item,
|
|
1659
1664
|
resource: n,
|
|
1660
1665
|
currentCount: recordCount + (capacity || 0),
|
|
1661
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1666
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1667
|
+
cut_off_time: (_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.cut_off_time
|
|
1662
1668
|
});
|
|
1663
1669
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1664
1670
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1909,11 +1915,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1909
1915
|
// if (cartItems?.[0].start_date) return [];
|
|
1910
1916
|
var resourceIds = [];
|
|
1911
1917
|
var resourcesTypeId = undefined;
|
|
1918
|
+
var isSingleResource = false;
|
|
1912
1919
|
cartItems.forEach(function (item) {
|
|
1913
1920
|
var _item$_productOrigin11, _item$_productOrigin12;
|
|
1914
1921
|
(_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || _item$_productOrigin11.forEach(function (n) {
|
|
1915
1922
|
if (n.code === resources_code) {
|
|
1916
1923
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1924
|
+
isSingleResource = n.type === 'single';
|
|
1917
1925
|
}
|
|
1918
1926
|
});
|
|
1919
1927
|
// item._origin.resources?.forEach((n: any) => {
|
|
@@ -1944,8 +1952,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
1952
|
var checkDuration = function checkDuration(cartItems) {
|
|
1945
1953
|
var accountDuration = 0;
|
|
1946
1954
|
cartItems.forEach(function (item) {
|
|
1947
|
-
|
|
1948
|
-
|
|
1955
|
+
// 单个预约累加账号 多个预约取最大值
|
|
1956
|
+
if (isSingleResource) {
|
|
1957
|
+
var _item$_productOrigin$3, _item$_productOrigin13;
|
|
1958
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1959
|
+
} else {
|
|
1960
|
+
var _item$_productOrigin$4, _item$_productOrigin14;
|
|
1961
|
+
if (accountDuration < ((_item$_productOrigin$4 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0)) {
|
|
1962
|
+
var _item$_productOrigin$5, _item$_productOrigin15;
|
|
1963
|
+
accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1949
1966
|
});
|
|
1950
1967
|
if (accountDuration > duration) {
|
|
1951
1968
|
duration = accountDuration;
|
|
@@ -2015,9 +2032,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2015
2032
|
var _newResources$;
|
|
2016
2033
|
var newResources = cloneDeep(item._origin.resources);
|
|
2017
2034
|
newResources.forEach(function (resource) {
|
|
2018
|
-
var _item$_productOrigin$
|
|
2035
|
+
var _item$_productOrigin$6, _item$_productOrigin16, _ref11, _item$_productOrigin17;
|
|
2019
2036
|
resource.startTime = currentStartTime;
|
|
2020
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$
|
|
2037
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2021
2038
|
delete resource.times;
|
|
2022
2039
|
});
|
|
2023
2040
|
_this10.store.cart.updateItem({
|
|
@@ -37,6 +37,11 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
37
37
|
future_day: number;
|
|
38
38
|
unit: number;
|
|
39
39
|
unit_type: string;
|
|
40
|
+
type: string;
|
|
41
|
+
ongoing?: {
|
|
42
|
+
type: string;
|
|
43
|
+
unit: number;
|
|
44
|
+
} | undefined;
|
|
40
45
|
} | undefined;
|
|
41
46
|
}) => {
|
|
42
47
|
afterToDay: boolean;
|
|
@@ -190,14 +190,28 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
190
190
|
};
|
|
191
191
|
// 最早可预约时间为 当前日期之后并且提前量之后
|
|
192
192
|
var earliest = dayjs();
|
|
193
|
+
var canBookingForOngoing = false;
|
|
193
194
|
var _ref3 = cut_off_time || {},
|
|
194
195
|
unit = _ref3.unit,
|
|
195
|
-
unit_type = _ref3.unit_type
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
unit_type = _ref3.unit_type,
|
|
197
|
+
type = _ref3.type,
|
|
198
|
+
ongoing = _ref3.ongoing;
|
|
199
|
+
// 允许购买已开始的活动
|
|
200
|
+
if (type === 'ongoing' && (ongoing === null || ongoing === void 0 ? void 0 : ongoing.type) === 'after_start') {
|
|
201
|
+
// 如果timeSlice.start_at 小于当前时间,判断当前时间是否在如果timeSlice.start_at+ongoing.unit之间
|
|
202
|
+
// 即,如果现在是15:30,timeSlice.start_at是15:00,ongoing.unit是60分钟,则允许预约
|
|
203
|
+
if (dayjs(timeSlice.start_at).isBefore(dayjs())) {
|
|
204
|
+
if (earliest.isBefore(dayjs(timeSlice.start_at).add(ongoing.unit, 'minute'))) {
|
|
205
|
+
canBookingForOngoing = true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
if (unit) {
|
|
210
|
+
earliest = earliest.add(unit, unit_type);
|
|
211
|
+
}
|
|
198
212
|
}
|
|
199
213
|
// 不可预约提前量时间之前的
|
|
200
|
-
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
214
|
+
if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
|
|
201
215
|
return status;
|
|
202
216
|
}
|
|
203
217
|
status.afterToDay = true;
|
|
@@ -728,6 +728,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
728
728
|
return false;
|
|
729
729
|
}
|
|
730
730
|
const canUseArr = mTimes.map((item) => {
|
|
731
|
+
var _a2;
|
|
731
732
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
732
733
|
timeSlice: {
|
|
733
734
|
start_time: startTime.format("HH:mm"),
|
|
@@ -738,7 +739,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
738
739
|
time: item,
|
|
739
740
|
resource: m,
|
|
740
741
|
currentCount: currentCapacity || 0,
|
|
741
|
-
resourcesUseableMap
|
|
742
|
+
resourcesUseableMap,
|
|
743
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
742
744
|
});
|
|
743
745
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
744
746
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -855,6 +857,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
855
857
|
return false;
|
|
856
858
|
}
|
|
857
859
|
const canUseArr = mTimes.map((item) => {
|
|
860
|
+
var _a2;
|
|
858
861
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
859
862
|
timeSlice: {
|
|
860
863
|
start_time: startTime.format("HH:mm"),
|
|
@@ -865,7 +868,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
865
868
|
time: item,
|
|
866
869
|
resource: m,
|
|
867
870
|
currentCount: currentCapacity || 0,
|
|
868
|
-
resourcesUseableMap
|
|
871
|
+
resourcesUseableMap,
|
|
872
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
869
873
|
});
|
|
870
874
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
871
875
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -1059,12 +1063,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1059
1063
|
continue;
|
|
1060
1064
|
}
|
|
1061
1065
|
const canUseTime = mTimes.find((item) => {
|
|
1066
|
+
var _a2;
|
|
1062
1067
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1063
1068
|
timeSlice: timeSlots,
|
|
1064
1069
|
time: item,
|
|
1065
1070
|
resource: n,
|
|
1066
1071
|
currentCount: recordCount + (capacity || 0),
|
|
1067
|
-
resourcesUseableMap
|
|
1072
|
+
resourcesUseableMap,
|
|
1073
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1068
1074
|
});
|
|
1069
1075
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
|
|
1070
1076
|
resourcesUseableMap[n.id] = res.usable;
|
|
@@ -1284,11 +1290,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1284
1290
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1285
1291
|
const resourceIds = [];
|
|
1286
1292
|
let resourcesTypeId = void 0;
|
|
1293
|
+
let isSingleResource = false;
|
|
1287
1294
|
cartItems.forEach((item) => {
|
|
1288
1295
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
1289
1296
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1290
1297
|
if (n.code === resources_code) {
|
|
1291
1298
|
resources.push(...n.renderList || []);
|
|
1299
|
+
isSingleResource = n.type === "single";
|
|
1292
1300
|
}
|
|
1293
1301
|
});
|
|
1294
1302
|
if (item.resource_id) {
|
|
@@ -1311,8 +1319,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1311
1319
|
const checkDuration = (cartItems2) => {
|
|
1312
1320
|
let accountDuration = 0;
|
|
1313
1321
|
cartItems2.forEach((item) => {
|
|
1314
|
-
var _a2, _b2;
|
|
1315
|
-
|
|
1322
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1323
|
+
if (isSingleResource) {
|
|
1324
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
|
|
1325
|
+
} else {
|
|
1326
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) ?? 0)) {
|
|
1327
|
+
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) ?? 0;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1316
1330
|
});
|
|
1317
1331
|
if (accountDuration > duration) {
|
|
1318
1332
|
duration = accountDuration;
|
|
@@ -37,6 +37,11 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
37
37
|
future_day: number;
|
|
38
38
|
unit: number;
|
|
39
39
|
unit_type: string;
|
|
40
|
+
type: string;
|
|
41
|
+
ongoing?: {
|
|
42
|
+
type: string;
|
|
43
|
+
unit: number;
|
|
44
|
+
} | undefined;
|
|
40
45
|
} | undefined;
|
|
41
46
|
}) => {
|
|
42
47
|
afterToDay: boolean;
|
|
@@ -141,11 +141,20 @@ var getIsUsableByTimeItem = ({
|
|
|
141
141
|
reason: ""
|
|
142
142
|
};
|
|
143
143
|
let earliest = (0, import_dayjs.default)();
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
let canBookingForOngoing = false;
|
|
145
|
+
const { unit, unit_type, type, ongoing } = cut_off_time || {};
|
|
146
|
+
if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "after_start") {
|
|
147
|
+
if ((0, import_dayjs.default)(timeSlice.start_at).isBefore((0, import_dayjs.default)())) {
|
|
148
|
+
if (earliest.isBefore((0, import_dayjs.default)(timeSlice.start_at).add(ongoing.unit, "minute"))) {
|
|
149
|
+
canBookingForOngoing = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
if (unit) {
|
|
154
|
+
earliest = earliest.add(unit, unit_type);
|
|
155
|
+
}
|
|
147
156
|
}
|
|
148
|
-
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
157
|
+
if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
|
|
149
158
|
return status;
|
|
150
159
|
}
|
|
151
160
|
status.afterToDay = true;
|