@pisell/pisellos 2.0.19 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Date/utils.js +12 -1
- package/dist/modules/Rules/index.js +4 -2
- package/dist/modules/Schedule/utils.js +10 -1
- package/dist/solution/BookingByStep/index.js +36 -16
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/dist/solution/BookingByStep/utils/resources.js +22 -4
- package/lib/modules/Date/utils.js +7 -0
- package/lib/modules/Rules/index.js +2 -2
- package/lib/modules/Schedule/utils.js +5 -1
- package/lib/solution/BookingByStep/index.js +21 -5
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/lib/solution/BookingByStep/utils/resources.js +17 -4
- package/package.json +1 -1
|
@@ -209,7 +209,18 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
|
|
|
209
209
|
var disabledDate = _objectSpread(_objectSpread({}, date), {}, {
|
|
210
210
|
status: 'unavailable'
|
|
211
211
|
});
|
|
212
|
-
|
|
212
|
+
var hasScheduleConfig = rules.find(function (n) {
|
|
213
|
+
var _n$schedule;
|
|
214
|
+
return (_n$schedule = n.schedule) === null || _n$schedule === void 0 ? void 0 : _n$schedule.length;
|
|
215
|
+
});
|
|
216
|
+
// 如果外面穿了 schedule,但是这个时候scheduleMap为空,则设置为不可用
|
|
217
|
+
// 这种情况为,商品设置了 5.1-5.31 可用,资源设置了 5.1-6.30 可用,session 类商品详情弹窗里里看到的6 月以后的日期都应该是不可用的
|
|
218
|
+
if (Object.keys(scheduleMap).length === 0 && hasScheduleConfig) {
|
|
219
|
+
return _objectSpread(_objectSpread({}, date), {}, {
|
|
220
|
+
color: '',
|
|
221
|
+
status: 'unavailable'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
213
224
|
// 根据日程判断日期是否可用
|
|
214
225
|
if (Object.keys(scheduleMap).length) {
|
|
215
226
|
var schedule = scheduleMap[date.date];
|
|
@@ -243,7 +243,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
243
243
|
|
|
244
244
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
245
245
|
sortedProductList.forEach(function (originProduct) {
|
|
246
|
-
var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5;
|
|
246
|
+
var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7;
|
|
247
247
|
var product = _this3.hooks.getProduct(originProduct);
|
|
248
248
|
if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
|
|
249
249
|
return discount.id && discount.type === 'good_pass';
|
|
@@ -271,7 +271,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
271
271
|
var selectedDiscount = applicableDiscounts[0];
|
|
272
272
|
|
|
273
273
|
// 如果是手动折扣,则不适用优惠券
|
|
274
|
-
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && !((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length)
|
|
274
|
+
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || (product === null || product === void 0 || (_product$discount_lis6 = product.discount_list) === null || _product$discount_lis6 === void 0 || (_product$discount_lis7 = _product$discount_lis6.every) === null || _product$discount_lis7 === void 0 ? void 0 : _product$discount_lis7.call(_product$discount_lis6, function (item) {
|
|
275
|
+
return item.type === 'product';
|
|
276
|
+
})));
|
|
275
277
|
|
|
276
278
|
// 勾选时覆盖手动折扣
|
|
277
279
|
if (options !== null && options !== void 0 && options.discountId && (options === null || options === void 0 ? void 0 : options.discountId) === (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.id)) {
|
|
@@ -716,7 +716,7 @@ export function getAllSortedDateRanges(schedules) {
|
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
// 按照开始时间和时长排序
|
|
719
|
-
|
|
719
|
+
var sortedDateRanges = allDateRanges.sort(function (a, b) {
|
|
720
720
|
// 首先按开始时间排序
|
|
721
721
|
var startTimeCompare = dayjs(a.start).valueOf() - dayjs(b.start).valueOf();
|
|
722
722
|
if (startTimeCompare !== 0) return startTimeCompare;
|
|
@@ -726,4 +726,13 @@ export function getAllSortedDateRanges(schedules) {
|
|
|
726
726
|
var durationB = dayjs(b.end).valueOf() - dayjs(b.start).valueOf();
|
|
727
727
|
return durationA - durationB;
|
|
728
728
|
});
|
|
729
|
+
|
|
730
|
+
// 排序完了,还需要做个去重,如果有开始时间结束时间完全一致的,则只保留一个
|
|
731
|
+
// 需要使用 dayjs 的 isSame 方法来判断
|
|
732
|
+
var uniqueDateRanges = sortedDateRanges.filter(function (range, index, self) {
|
|
733
|
+
return index === self.findIndex(function (t) {
|
|
734
|
+
return dayjs(t.start).isSame(dayjs(range.start)) && dayjs(t.end).isSame(dayjs(range.end));
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
return uniqueDateRanges;
|
|
729
738
|
}
|
|
@@ -216,6 +216,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
216
216
|
});
|
|
217
217
|
if (schedule_ids_data.length) {
|
|
218
218
|
schedule_ids = schedule_ids_data;
|
|
219
|
+
} else if (schedule_date) {
|
|
220
|
+
// 后端说如果 schedule_ids 如果为空,需要给[0]
|
|
221
|
+
schedule_ids = [0];
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
_context2.next = 4;
|
|
@@ -1293,6 +1296,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1296
|
return false;
|
|
1294
1297
|
}
|
|
1295
1298
|
var canUseArr = mTimes.map(function (item) {
|
|
1299
|
+
var _cartItem$_productOri3;
|
|
1296
1300
|
var res = getIsUsableByTimeItem({
|
|
1297
1301
|
timeSlice: {
|
|
1298
1302
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1303,7 +1307,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1303
1307
|
time: item,
|
|
1304
1308
|
resource: m,
|
|
1305
1309
|
currentCount: currentCapacity || 0,
|
|
1306
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1310
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1311
|
+
cut_off_time: (_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.cut_off_time
|
|
1307
1312
|
});
|
|
1308
1313
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1309
1314
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1323,13 +1328,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1328
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1324
1329
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1325
1330
|
item.renderList = item.renderList.filter(function (n) {
|
|
1326
|
-
var _cartItem$
|
|
1331
|
+
var _cartItem$_productOri4;
|
|
1327
1332
|
var recordCount = n.capacity || 0;
|
|
1328
1333
|
if (n.onlyComputed) return false;
|
|
1329
1334
|
// 查一下这个资源基于商品的可用时间片
|
|
1330
1335
|
var timeSlots = getTimeSlicesByResource({
|
|
1331
1336
|
resource: n,
|
|
1332
|
-
duration: ((_cartItem$
|
|
1337
|
+
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
1338
|
split: 10,
|
|
1334
1339
|
currentDate: dateRange[0].date
|
|
1335
1340
|
});
|
|
@@ -1373,10 +1378,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1373
1378
|
var cartItems = this.store.cart.getItems();
|
|
1374
1379
|
var arr = [];
|
|
1375
1380
|
cartItems.forEach(function (cartItem) {
|
|
1376
|
-
var _cartItem$
|
|
1381
|
+
var _cartItem$_productOri5, _cartItem$_productOri6;
|
|
1377
1382
|
var selectedResources = [];
|
|
1378
1383
|
var formatCapacity = formatDefaultCapacitys({
|
|
1379
|
-
capacity: (_cartItem$
|
|
1384
|
+
capacity: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.capacity,
|
|
1380
1385
|
product_bundle: cartItem._origin.product.product_bundle
|
|
1381
1386
|
});
|
|
1382
1387
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1388,7 +1393,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1393
|
} else {
|
|
1389
1394
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1390
1395
|
}
|
|
1391
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1396
|
+
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
1397
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1393
1398
|
if (cartItem._origin.start_time) {
|
|
1394
1399
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1416,6 +1421,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1416
1421
|
return false;
|
|
1417
1422
|
}
|
|
1418
1423
|
var canUseArr = mTimes.map(function (item) {
|
|
1424
|
+
var _cartItem$_productOri7;
|
|
1419
1425
|
var res = getIsUsableByTimeItem({
|
|
1420
1426
|
timeSlice: {
|
|
1421
1427
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1426,7 +1432,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1426
1432
|
time: item,
|
|
1427
1433
|
resource: m,
|
|
1428
1434
|
currentCount: currentCapacity || 0,
|
|
1429
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1435
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1436
|
+
cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
|
|
1430
1437
|
});
|
|
1431
1438
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1432
1439
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1446,13 +1453,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1453
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1447
1454
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1448
1455
|
item.renderList = item.renderList.filter(function (n) {
|
|
1449
|
-
var _cartItem$
|
|
1456
|
+
var _cartItem$_productOri8;
|
|
1450
1457
|
var recordCount = n.capacity || 0;
|
|
1451
1458
|
if (n.onlyComputed) return false;
|
|
1452
1459
|
// 查一下这个资源基于商品的可用时间片
|
|
1453
1460
|
var timeSlots = getTimeSlicesByResource({
|
|
1454
1461
|
resource: n,
|
|
1455
|
-
duration: ((_cartItem$
|
|
1462
|
+
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
1463
|
split: 10,
|
|
1457
1464
|
currentDate: dateRange[0].date
|
|
1458
1465
|
});
|
|
@@ -1554,7 +1561,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1554
1561
|
}, {
|
|
1555
1562
|
key: "autoSelectAccountResources",
|
|
1556
1563
|
value: function autoSelectAccountResources(_ref8) {
|
|
1557
|
-
var _cartItem$
|
|
1564
|
+
var _cartItem$_productOri9, _allProductResources$;
|
|
1558
1565
|
var cartItem = _ref8.cartItem,
|
|
1559
1566
|
holder_id = _ref8.holder_id,
|
|
1560
1567
|
resources_code = _ref8.resources_code,
|
|
@@ -1603,7 +1610,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1610
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1604
1611
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1605
1612
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1606
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1613
|
+
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
1614
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1608
1615
|
return n.code === resources_code;
|
|
1609
1616
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
@@ -1653,12 +1660,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1653
1660
|
return 0; // continue
|
|
1654
1661
|
}
|
|
1655
1662
|
var canUseTime = mTimes.find(function (item) {
|
|
1663
|
+
var _cartItem$_productOri10;
|
|
1656
1664
|
var res = getIsUsableByTimeItem({
|
|
1657
1665
|
timeSlice: timeSlots,
|
|
1658
1666
|
time: item,
|
|
1659
1667
|
resource: n,
|
|
1660
1668
|
currentCount: recordCount + (capacity || 0),
|
|
1661
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1669
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1670
|
+
cut_off_time: (_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.cut_off_time
|
|
1662
1671
|
});
|
|
1663
1672
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1664
1673
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1909,11 +1918,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1909
1918
|
// if (cartItems?.[0].start_date) return [];
|
|
1910
1919
|
var resourceIds = [];
|
|
1911
1920
|
var resourcesTypeId = undefined;
|
|
1921
|
+
var isSingleResource = false;
|
|
1912
1922
|
cartItems.forEach(function (item) {
|
|
1913
1923
|
var _item$_productOrigin11, _item$_productOrigin12;
|
|
1914
1924
|
(_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
1925
|
if (n.code === resources_code) {
|
|
1916
1926
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1927
|
+
isSingleResource = n.type === 'single';
|
|
1917
1928
|
}
|
|
1918
1929
|
});
|
|
1919
1930
|
// item._origin.resources?.forEach((n: any) => {
|
|
@@ -1944,8 +1955,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
1955
|
var checkDuration = function checkDuration(cartItems) {
|
|
1945
1956
|
var accountDuration = 0;
|
|
1946
1957
|
cartItems.forEach(function (item) {
|
|
1947
|
-
|
|
1948
|
-
|
|
1958
|
+
// 单个预约累加账号 多个预约取最大值
|
|
1959
|
+
if (isSingleResource) {
|
|
1960
|
+
var _item$_productOrigin$3, _item$_productOrigin13;
|
|
1961
|
+
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;
|
|
1962
|
+
} else {
|
|
1963
|
+
var _item$_productOrigin$4, _item$_productOrigin14;
|
|
1964
|
+
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)) {
|
|
1965
|
+
var _item$_productOrigin$5, _item$_productOrigin15;
|
|
1966
|
+
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;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1949
1969
|
});
|
|
1950
1970
|
if (accountDuration > duration) {
|
|
1951
1971
|
duration = accountDuration;
|
|
@@ -2015,9 +2035,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2015
2035
|
var _newResources$;
|
|
2016
2036
|
var newResources = cloneDeep(item._origin.resources);
|
|
2017
2037
|
newResources.forEach(function (resource) {
|
|
2018
|
-
var _item$_productOrigin$
|
|
2038
|
+
var _item$_productOrigin$6, _item$_productOrigin16, _ref11, _item$_productOrigin17;
|
|
2019
2039
|
resource.startTime = currentStartTime;
|
|
2020
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$
|
|
2040
|
+
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
2041
|
delete resource.times;
|
|
2022
2042
|
});
|
|
2023
2043
|
_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,32 @@ 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 if (type === 'ongoing' && (ongoing === null || ongoing === void 0 ? void 0 : ongoing.type) === 'before_end') {
|
|
209
|
+
if (dayjs(timeSlice.end_at).isAfter(earliest)) {
|
|
210
|
+
canBookingForOngoing = true;
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
if (unit) {
|
|
214
|
+
earliest = earliest.add(unit, unit_type);
|
|
215
|
+
}
|
|
198
216
|
}
|
|
199
217
|
// 不可预约提前量时间之前的
|
|
200
|
-
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
218
|
+
if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
|
|
201
219
|
return status;
|
|
202
220
|
}
|
|
203
221
|
status.afterToDay = true;
|
|
@@ -155,6 +155,13 @@ var handleAvailableDatesByRules = (dates, rules) => {
|
|
|
155
155
|
newDates = newDates.map((date) => {
|
|
156
156
|
var _a;
|
|
157
157
|
const disabledDate = { ...date, status: "unavailable" };
|
|
158
|
+
const hasScheduleConfig = rules.find((n) => {
|
|
159
|
+
var _a2;
|
|
160
|
+
return (_a2 = n.schedule) == null ? void 0 : _a2.length;
|
|
161
|
+
});
|
|
162
|
+
if (Object.keys(scheduleMap).length === 0 && hasScheduleConfig) {
|
|
163
|
+
return { ...date, color: "", status: "unavailable" };
|
|
164
|
+
}
|
|
158
165
|
if (Object.keys(scheduleMap).length) {
|
|
159
166
|
const schedule = scheduleMap[date.date];
|
|
160
167
|
if (!schedule || (schedule == null ? void 0 : schedule.isExcluded)) {
|
|
@@ -154,7 +154,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
156
|
sortedProductList.forEach((originProduct) => {
|
|
157
|
-
var _a, _b, _c;
|
|
157
|
+
var _a, _b, _c, _d, _e;
|
|
158
158
|
const product = this.hooks.getProduct(originProduct);
|
|
159
159
|
if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && discount.type === "good_pass"))) {
|
|
160
160
|
processedProductsMap.set(product._id, originProduct);
|
|
@@ -172,7 +172,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
172
172
|
return false;
|
|
173
173
|
});
|
|
174
174
|
const selectedDiscount = applicableDiscounts[0];
|
|
175
|
-
let isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && !((_c = product.discount_list) == null ? void 0 : _c.length);
|
|
175
|
+
let isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (!((_c = product.discount_list) == null ? void 0 : _c.length) || ((_e = (_d = product == null ? void 0 : product.discount_list) == null ? void 0 : _d.every) == null ? void 0 : _e.call(_d, (item) => item.type === "product")));
|
|
176
176
|
if ((options == null ? void 0 : options.discountId) && (options == null ? void 0 : options.discountId) === (selectedDiscount == null ? void 0 : selectedDiscount.id)) {
|
|
177
177
|
isManualDiscount = false;
|
|
178
178
|
}
|
|
@@ -573,7 +573,7 @@ function getAllSortedDateRanges(schedules) {
|
|
|
573
573
|
console.log("No dateRanges found in schedules:", schedules);
|
|
574
574
|
return [];
|
|
575
575
|
}
|
|
576
|
-
|
|
576
|
+
let sortedDateRanges = allDateRanges.sort((a, b) => {
|
|
577
577
|
const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
578
578
|
if (startTimeCompare !== 0)
|
|
579
579
|
return startTimeCompare;
|
|
@@ -581,6 +581,10 @@ function getAllSortedDateRanges(schedules) {
|
|
|
581
581
|
const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
582
582
|
return durationA - durationB;
|
|
583
583
|
});
|
|
584
|
+
const uniqueDateRanges = sortedDateRanges.filter(
|
|
585
|
+
(range, index, self) => index === self.findIndex((t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end)))
|
|
586
|
+
);
|
|
587
|
+
return uniqueDateRanges;
|
|
584
588
|
}
|
|
585
589
|
// Annotate the CommonJS export names for ESM import in node:
|
|
586
590
|
0 && (module.exports = {
|
|
@@ -165,6 +165,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
165
165
|
const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
|
|
166
166
|
if (schedule_ids_data.length) {
|
|
167
167
|
schedule_ids = schedule_ids_data;
|
|
168
|
+
} else if (schedule_date) {
|
|
169
|
+
schedule_ids = [0];
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
const productsData = await this.request.post(
|
|
@@ -728,6 +730,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
728
730
|
return false;
|
|
729
731
|
}
|
|
730
732
|
const canUseArr = mTimes.map((item) => {
|
|
733
|
+
var _a2;
|
|
731
734
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
732
735
|
timeSlice: {
|
|
733
736
|
start_time: startTime.format("HH:mm"),
|
|
@@ -738,7 +741,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
738
741
|
time: item,
|
|
739
742
|
resource: m,
|
|
740
743
|
currentCount: currentCapacity || 0,
|
|
741
|
-
resourcesUseableMap
|
|
744
|
+
resourcesUseableMap,
|
|
745
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
742
746
|
});
|
|
743
747
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
744
748
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -855,6 +859,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
855
859
|
return false;
|
|
856
860
|
}
|
|
857
861
|
const canUseArr = mTimes.map((item) => {
|
|
862
|
+
var _a2;
|
|
858
863
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
859
864
|
timeSlice: {
|
|
860
865
|
start_time: startTime.format("HH:mm"),
|
|
@@ -865,7 +870,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
865
870
|
time: item,
|
|
866
871
|
resource: m,
|
|
867
872
|
currentCount: currentCapacity || 0,
|
|
868
|
-
resourcesUseableMap
|
|
873
|
+
resourcesUseableMap,
|
|
874
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
869
875
|
});
|
|
870
876
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
871
877
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -1059,12 +1065,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1059
1065
|
continue;
|
|
1060
1066
|
}
|
|
1061
1067
|
const canUseTime = mTimes.find((item) => {
|
|
1068
|
+
var _a2;
|
|
1062
1069
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1063
1070
|
timeSlice: timeSlots,
|
|
1064
1071
|
time: item,
|
|
1065
1072
|
resource: n,
|
|
1066
1073
|
currentCount: recordCount + (capacity || 0),
|
|
1067
|
-
resourcesUseableMap
|
|
1074
|
+
resourcesUseableMap,
|
|
1075
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1068
1076
|
});
|
|
1069
1077
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
|
|
1070
1078
|
resourcesUseableMap[n.id] = res.usable;
|
|
@@ -1284,11 +1292,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1284
1292
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1285
1293
|
const resourceIds = [];
|
|
1286
1294
|
let resourcesTypeId = void 0;
|
|
1295
|
+
let isSingleResource = false;
|
|
1287
1296
|
cartItems.forEach((item) => {
|
|
1288
1297
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
1289
1298
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1290
1299
|
if (n.code === resources_code) {
|
|
1291
1300
|
resources.push(...n.renderList || []);
|
|
1301
|
+
isSingleResource = n.type === "single";
|
|
1292
1302
|
}
|
|
1293
1303
|
});
|
|
1294
1304
|
if (item.resource_id) {
|
|
@@ -1311,8 +1321,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1311
1321
|
const checkDuration = (cartItems2) => {
|
|
1312
1322
|
let accountDuration = 0;
|
|
1313
1323
|
cartItems2.forEach((item) => {
|
|
1314
|
-
var _a2, _b2;
|
|
1315
|
-
|
|
1324
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1325
|
+
if (isSingleResource) {
|
|
1326
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
|
|
1327
|
+
} else {
|
|
1328
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) ?? 0)) {
|
|
1329
|
+
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) ?? 0;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1316
1332
|
});
|
|
1317
1333
|
if (accountDuration > duration) {
|
|
1318
1334
|
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,24 @@ 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 if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "before_end") {
|
|
153
|
+
if ((0, import_dayjs.default)(timeSlice.end_at).isAfter(earliest)) {
|
|
154
|
+
canBookingForOngoing = true;
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
if (unit) {
|
|
158
|
+
earliest = earliest.add(unit, unit_type);
|
|
159
|
+
}
|
|
147
160
|
}
|
|
148
|
-
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
161
|
+
if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
|
|
149
162
|
return status;
|
|
150
163
|
}
|
|
151
164
|
status.afterToDay = true;
|