@pisell/pisellos 0.0.88 → 0.0.90
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/Rules/index.js +1 -1
- package/dist/solution/BookingByStep/index.js +106 -91
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/dist/solution/BookingByStep/utils/resources.js +18 -4
- package/lib/modules/Rules/index.js +1 -1
- package/lib/solution/BookingByStep/index.js +82 -73
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -0
- package/lib/solution/BookingByStep/utils/resources.js +13 -4
- package/package.json +1 -1
|
@@ -302,7 +302,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
302
302
|
})));
|
|
303
303
|
} else {
|
|
304
304
|
processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
|
|
305
|
-
total: product.
|
|
305
|
+
total: product.total,
|
|
306
306
|
price: product.price
|
|
307
307
|
}), {}, {
|
|
308
308
|
discount_list: []
|
|
@@ -112,8 +112,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
112
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
+
this.loadAllSchedule();
|
|
115
116
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
116
|
-
case
|
|
117
|
+
case 16:
|
|
117
118
|
case "end":
|
|
118
119
|
return _context.stop();
|
|
119
120
|
}
|
|
@@ -306,7 +307,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
306
307
|
while (1) switch (_context4.prev = _context4.next) {
|
|
307
308
|
case 0:
|
|
308
309
|
_context4.next = 2;
|
|
309
|
-
return this.request.get("/schedule
|
|
310
|
+
return this.request.get("/schedule", {
|
|
311
|
+
num: 999
|
|
312
|
+
}, {
|
|
313
|
+
useCache: true
|
|
314
|
+
});
|
|
310
315
|
case 2:
|
|
311
316
|
scheduleList = _context4.sent;
|
|
312
317
|
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
@@ -1069,72 +1074,75 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1069
1074
|
if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
|
|
1070
1075
|
});
|
|
1071
1076
|
}
|
|
1072
|
-
//
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
//
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1077
|
+
// 只有在更新资源的时候做这个判断,其他情况下不做处理
|
|
1078
|
+
if (params.resources) {
|
|
1079
|
+
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,且资源是单个预约,则要把选择了相同资源的 product._origin.resources 给去除
|
|
1080
|
+
var cartItems = this.store.cart.getItems();
|
|
1081
|
+
cartItems.forEach(function (item) {
|
|
1082
|
+
if (item._id !== targetCartItem._id) {
|
|
1083
|
+
var _item$_origin$resourc;
|
|
1084
|
+
var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
|
|
1085
|
+
// 检查当前资源是否与目标资源的任何资源匹配
|
|
1086
|
+
return !targetCartItem._origin.resources.some(function (targetRes) {
|
|
1087
|
+
// 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
|
|
1088
|
+
if (targetRes.resourceType !== 'single') {
|
|
1089
|
+
var _item$_productOrigin2;
|
|
1090
|
+
var _formatCapacity = formatDefaultCapacitys({
|
|
1091
|
+
capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
|
|
1092
|
+
product_bundle: item._origin.product.product_bundle
|
|
1093
|
+
});
|
|
1094
|
+
var _currentCapacity = getSumCapacity({
|
|
1095
|
+
capacity: _formatCapacity
|
|
1096
|
+
});
|
|
1097
|
+
var originResource = allOriginResources.find(function (n) {
|
|
1098
|
+
return n.id === targetRes.id;
|
|
1099
|
+
});
|
|
1100
|
+
if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
|
|
1107
|
+
var _targetRes$metadata$c, _m$metadata$combined_;
|
|
1108
|
+
// 检查主资源ID是否匹配
|
|
1109
|
+
if (targetRes.id === m.id) return true;
|
|
1110
|
+
// 检查组合资源的情况
|
|
1111
|
+
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
|
|
1112
|
+
// 如果现在选择的是组合资源,需要判断
|
|
1113
|
+
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
1114
|
+
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
1115
|
+
targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
|
|
1116
|
+
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
1117
|
+
}))) return true;
|
|
1118
|
+
if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
|
|
1095
1119
|
}
|
|
1096
|
-
currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
|
|
1097
1120
|
return false;
|
|
1098
|
-
}
|
|
1099
|
-
if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
|
|
1100
|
-
var _targetRes$metadata$c, _m$metadata$combined_;
|
|
1101
|
-
// 检查主资源ID是否匹配
|
|
1102
|
-
if (targetRes.id === m.id) return true;
|
|
1103
|
-
// 检查组合资源的情况
|
|
1104
|
-
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
|
|
1105
|
-
// 如果现在选择的是组合资源,需要判断
|
|
1106
|
-
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
1107
|
-
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
1108
|
-
targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
|
|
1109
|
-
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
1110
|
-
}))) return true;
|
|
1111
|
-
if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
|
|
1112
|
-
}
|
|
1113
|
-
return false;
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
// session 类商品应该只调用清空 resource 的方法
|
|
1117
|
-
if (item.start_time) {
|
|
1118
|
-
var start_time = item.start_time;
|
|
1119
|
-
var end_time = item.end_time;
|
|
1120
|
-
var start_date = item.start_date;
|
|
1121
|
-
var end_date = item.end_date;
|
|
1122
|
-
_this5.store.cart.updateItem({
|
|
1123
|
-
_id: item._id,
|
|
1124
|
-
resources: resources,
|
|
1125
|
-
date: {
|
|
1126
|
-
startTime: dayjs("".concat(start_date, " ").concat(start_time)).format('YYYY-MM-DD HH:mm'),
|
|
1127
|
-
endTime: dayjs("".concat(end_date, " ").concat(end_time)).format('YYYY-MM-DD HH:mm')
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
} else {
|
|
1131
|
-
_this5.store.cart.updateItem({
|
|
1132
|
-
_id: item._id,
|
|
1133
|
-
resources: resources
|
|
1121
|
+
});
|
|
1134
1122
|
});
|
|
1123
|
+
// session 类商品应该只调用清空 resource 的方法
|
|
1124
|
+
if (item.start_time) {
|
|
1125
|
+
var start_time = item.start_time;
|
|
1126
|
+
var end_time = item.end_time;
|
|
1127
|
+
var start_date = item.start_date;
|
|
1128
|
+
var end_date = item.end_date;
|
|
1129
|
+
_this5.store.cart.updateItem({
|
|
1130
|
+
_id: item._id,
|
|
1131
|
+
resources: resources,
|
|
1132
|
+
date: {
|
|
1133
|
+
startTime: dayjs("".concat(start_date, " ").concat(start_time)).format('YYYY-MM-DD HH:mm'),
|
|
1134
|
+
endTime: dayjs("".concat(end_date, " ").concat(end_time)).format('YYYY-MM-DD HH:mm')
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
} else {
|
|
1138
|
+
_this5.store.cart.updateItem({
|
|
1139
|
+
_id: item._id,
|
|
1140
|
+
resources: resources
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1135
1143
|
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1138
1146
|
}
|
|
1139
1147
|
|
|
1140
1148
|
// 删除购物车里某个商品
|
|
@@ -1285,6 +1293,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
1293
|
return false;
|
|
1286
1294
|
}
|
|
1287
1295
|
var canUseArr = mTimes.map(function (item) {
|
|
1296
|
+
var _cartItem$_productOri3;
|
|
1288
1297
|
var res = getIsUsableByTimeItem({
|
|
1289
1298
|
timeSlice: {
|
|
1290
1299
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1295,7 +1304,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1295
1304
|
time: item,
|
|
1296
1305
|
resource: m,
|
|
1297
1306
|
currentCount: currentCapacity || 0,
|
|
1298
|
-
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
|
|
1299
1309
|
});
|
|
1300
1310
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1301
1311
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1315,13 +1325,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1325
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1316
1326
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1317
1327
|
item.renderList = item.renderList.filter(function (n) {
|
|
1318
|
-
var _cartItem$
|
|
1328
|
+
var _cartItem$_productOri4;
|
|
1319
1329
|
var recordCount = n.capacity || 0;
|
|
1320
1330
|
if (n.onlyComputed) return false;
|
|
1321
1331
|
// 查一下这个资源基于商品的可用时间片
|
|
1322
1332
|
var timeSlots = getTimeSlicesByResource({
|
|
1323
1333
|
resource: n,
|
|
1324
|
-
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,
|
|
1325
1335
|
split: 10,
|
|
1326
1336
|
currentDate: dateRange[0].date
|
|
1327
1337
|
});
|
|
@@ -1365,10 +1375,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1365
1375
|
var cartItems = this.store.cart.getItems();
|
|
1366
1376
|
var arr = [];
|
|
1367
1377
|
cartItems.forEach(function (cartItem) {
|
|
1368
|
-
var _cartItem$
|
|
1378
|
+
var _cartItem$_productOri5, _cartItem$_productOri6;
|
|
1369
1379
|
var selectedResources = [];
|
|
1370
1380
|
var formatCapacity = formatDefaultCapacitys({
|
|
1371
|
-
capacity: (_cartItem$
|
|
1381
|
+
capacity: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.capacity,
|
|
1372
1382
|
product_bundle: cartItem._origin.product.product_bundle
|
|
1373
1383
|
});
|
|
1374
1384
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1380,7 +1390,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1390
|
} else {
|
|
1381
1391
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1382
1392
|
}
|
|
1383
|
-
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);
|
|
1384
1394
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1385
1395
|
if (cartItem._origin.start_time) {
|
|
1386
1396
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1408,6 +1418,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1418
|
return false;
|
|
1409
1419
|
}
|
|
1410
1420
|
var canUseArr = mTimes.map(function (item) {
|
|
1421
|
+
var _cartItem$_productOri7;
|
|
1411
1422
|
var res = getIsUsableByTimeItem({
|
|
1412
1423
|
timeSlice: {
|
|
1413
1424
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1418,7 +1429,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1418
1429
|
time: item,
|
|
1419
1430
|
resource: m,
|
|
1420
1431
|
currentCount: currentCapacity || 0,
|
|
1421
|
-
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
|
|
1422
1434
|
});
|
|
1423
1435
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1424
1436
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1438,13 +1450,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1438
1450
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1439
1451
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1440
1452
|
item.renderList = item.renderList.filter(function (n) {
|
|
1441
|
-
var _cartItem$
|
|
1453
|
+
var _cartItem$_productOri8;
|
|
1442
1454
|
var recordCount = n.capacity || 0;
|
|
1443
1455
|
if (n.onlyComputed) return false;
|
|
1444
1456
|
// 查一下这个资源基于商品的可用时间片
|
|
1445
1457
|
var timeSlots = getTimeSlicesByResource({
|
|
1446
1458
|
resource: n,
|
|
1447
|
-
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,
|
|
1448
1460
|
split: 10,
|
|
1449
1461
|
currentDate: dateRange[0].date
|
|
1450
1462
|
});
|
|
@@ -1546,7 +1558,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1546
1558
|
}, {
|
|
1547
1559
|
key: "autoSelectAccountResources",
|
|
1548
1560
|
value: function autoSelectAccountResources(_ref8) {
|
|
1549
|
-
var _cartItem$
|
|
1561
|
+
var _cartItem$_productOri9, _allProductResources$;
|
|
1550
1562
|
var cartItem = _ref8.cartItem,
|
|
1551
1563
|
holder_id = _ref8.holder_id,
|
|
1552
1564
|
resources_code = _ref8.resources_code,
|
|
@@ -1595,7 +1607,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1595
1607
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1596
1608
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1597
1609
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1598
|
-
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);
|
|
1599
1611
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1600
1612
|
return n.code === resources_code;
|
|
1601
1613
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
@@ -1645,12 +1657,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1645
1657
|
return 0; // continue
|
|
1646
1658
|
}
|
|
1647
1659
|
var canUseTime = mTimes.find(function (item) {
|
|
1660
|
+
var _cartItem$_productOri10;
|
|
1648
1661
|
var res = getIsUsableByTimeItem({
|
|
1649
1662
|
timeSlice: timeSlots,
|
|
1650
1663
|
time: item,
|
|
1651
1664
|
resource: n,
|
|
1652
1665
|
currentCount: recordCount + (capacity || 0),
|
|
1653
|
-
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
|
|
1654
1668
|
});
|
|
1655
1669
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1656
1670
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1745,16 +1759,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1745
1759
|
};
|
|
1746
1760
|
}
|
|
1747
1761
|
if (recordTimeSlots) {
|
|
1748
|
-
var _item$_productOrigin4;
|
|
1762
|
+
var _item$_productOrigin4, _item$_productOrigin5;
|
|
1749
1763
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
1750
1764
|
// 前提:当前资源是单个预约才需要这么做
|
|
1751
1765
|
var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
|
|
1752
1766
|
return n.code === resources_code;
|
|
1753
1767
|
});
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
var
|
|
1757
|
-
var
|
|
1768
|
+
// 只有 duration 类商品需要这个操作
|
|
1769
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
|
|
1770
|
+
var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1771
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1772
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1758
1773
|
recordTimeSlots = {
|
|
1759
1774
|
start_time: start_at.format('HH:mm'),
|
|
1760
1775
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1796,12 +1811,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1796
1811
|
errorList.push(item._id);
|
|
1797
1812
|
}
|
|
1798
1813
|
} else {
|
|
1799
|
-
var _item$
|
|
1814
|
+
var _item$_productOrigin10, _productResources$fin;
|
|
1800
1815
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1801
1816
|
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1802
1817
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1803
1818
|
var selectedResources = [];
|
|
1804
|
-
var _resources = cloneDeep(((_item$
|
|
1819
|
+
var _resources = cloneDeep(((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.resources) || []);
|
|
1805
1820
|
var currentResourcesRenderList = [];
|
|
1806
1821
|
_resources.forEach(function (n) {
|
|
1807
1822
|
var _n$renderList;
|
|
@@ -1901,8 +1916,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1901
1916
|
var resourceIds = [];
|
|
1902
1917
|
var resourcesTypeId = undefined;
|
|
1903
1918
|
cartItems.forEach(function (item) {
|
|
1904
|
-
var _item$
|
|
1905
|
-
(_item$
|
|
1919
|
+
var _item$_productOrigin11, _item$_productOrigin12;
|
|
1920
|
+
(_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) {
|
|
1906
1921
|
if (n.code === resources_code) {
|
|
1907
1922
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1908
1923
|
}
|
|
@@ -1913,9 +1928,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1913
1928
|
if (item.resource_id) {
|
|
1914
1929
|
resourceIds.push(item.resource_id);
|
|
1915
1930
|
}
|
|
1916
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
1931
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.product_resource) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.resources) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.find(function (n) {
|
|
1917
1932
|
return n.code === resources_code;
|
|
1918
|
-
})) === null || _item$
|
|
1933
|
+
})) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
|
|
1919
1934
|
});
|
|
1920
1935
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1921
1936
|
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
@@ -1935,8 +1950,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1935
1950
|
var checkDuration = function checkDuration(cartItems) {
|
|
1936
1951
|
var accountDuration = 0;
|
|
1937
1952
|
cartItems.forEach(function (item) {
|
|
1938
|
-
var _item$_productOrigin$3, _item$
|
|
1939
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1953
|
+
var _item$_productOrigin$3, _item$_productOrigin13;
|
|
1954
|
+
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;
|
|
1940
1955
|
});
|
|
1941
1956
|
if (accountDuration > duration) {
|
|
1942
1957
|
duration = accountDuration;
|
|
@@ -2006,9 +2021,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
2021
|
var _newResources$;
|
|
2007
2022
|
var newResources = cloneDeep(item._origin.resources);
|
|
2008
2023
|
newResources.forEach(function (resource) {
|
|
2009
|
-
var _item$_productOrigin$4, _item$
|
|
2024
|
+
var _item$_productOrigin$4, _item$_productOrigin14, _ref11, _item$_productOrigin15;
|
|
2010
2025
|
resource.startTime = currentStartTime;
|
|
2011
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
2026
|
+
resource.endTime = dayjs(currentStartTime).add((_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, (_ref11 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2012
2027
|
delete resource.times;
|
|
2013
2028
|
});
|
|
2014
2029
|
_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;
|
|
@@ -206,7 +206,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
206
206
|
product._id,
|
|
207
207
|
this.hooks.setProduct(originProduct, {
|
|
208
208
|
...isManualDiscount ? {} : {
|
|
209
|
-
total: product.
|
|
209
|
+
total: product.total,
|
|
210
210
|
price: product.price
|
|
211
211
|
},
|
|
212
212
|
discount_list: []
|
|
@@ -102,6 +102,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
102
102
|
throw new Error(`模块 ${step} 不存在`);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
this.loadAllSchedule();
|
|
105
106
|
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
106
107
|
}
|
|
107
108
|
// 初始化step
|
|
@@ -214,7 +215,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
214
215
|
// 加载当前店铺下所有 schedule
|
|
215
216
|
async loadAllSchedule() {
|
|
216
217
|
var _a;
|
|
217
|
-
const scheduleList = await this.request.get(`/schedule
|
|
218
|
+
const scheduleList = await this.request.get(`/schedule`, { num: 999 }, { useCache: true });
|
|
218
219
|
this.store.schedule.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
|
|
219
220
|
}
|
|
220
221
|
// ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
@@ -527,69 +528,71 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
527
528
|
allOriginResources.push(...n.resource);
|
|
528
529
|
});
|
|
529
530
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
531
|
+
if (params.resources) {
|
|
532
|
+
const cartItems = this.store.cart.getItems();
|
|
533
|
+
cartItems.forEach((item) => {
|
|
534
|
+
var _a2;
|
|
535
|
+
if (item._id !== targetCartItem._id) {
|
|
536
|
+
const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
|
|
537
|
+
return !targetCartItem._origin.resources.some((targetRes) => {
|
|
538
|
+
var _a3, _b, _c;
|
|
539
|
+
if (targetRes.resourceType !== "single") {
|
|
540
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
541
|
+
capacity: (_a3 = item._productOrigin) == null ? void 0 : _a3.capacity,
|
|
542
|
+
product_bundle: item._origin.product.product_bundle
|
|
543
|
+
});
|
|
544
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
545
|
+
const originResource = allOriginResources.find((n) => n.id === targetRes.id);
|
|
546
|
+
if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
currentResourcesCapacityMap[targetRes.id] += currentCapacity;
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
553
|
+
if (targetRes.id === m.id)
|
|
554
|
+
return true;
|
|
555
|
+
if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
556
|
+
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
557
|
+
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
558
|
+
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
559
|
+
m.id
|
|
560
|
+
) || targetRes.metadata.combined_resource.resource_ids.some(
|
|
561
|
+
(n) => {
|
|
562
|
+
return m.metadata.combined_resource.resource_ids.includes(
|
|
563
|
+
n
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
)))
|
|
567
|
+
return true;
|
|
568
|
+
if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
569
|
+
return true;
|
|
546
570
|
}
|
|
547
|
-
currentResourcesCapacityMap[targetRes.id] += currentCapacity;
|
|
548
571
|
return false;
|
|
549
|
-
}
|
|
550
|
-
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
551
|
-
if (targetRes.id === m.id)
|
|
552
|
-
return true;
|
|
553
|
-
if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
554
|
-
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
555
|
-
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
556
|
-
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
557
|
-
m.id
|
|
558
|
-
) || targetRes.metadata.combined_resource.resource_ids.some(
|
|
559
|
-
(n) => {
|
|
560
|
-
return m.metadata.combined_resource.resource_ids.includes(
|
|
561
|
-
n
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
)))
|
|
565
|
-
return true;
|
|
566
|
-
if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
return false;
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
if (item.start_time) {
|
|
573
|
-
const start_time = item.start_time;
|
|
574
|
-
const end_time = item.end_time;
|
|
575
|
-
const start_date = item.start_date;
|
|
576
|
-
const end_date = item.end_date;
|
|
577
|
-
this.store.cart.updateItem({
|
|
578
|
-
_id: item._id,
|
|
579
|
-
resources,
|
|
580
|
-
date: {
|
|
581
|
-
startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format("YYYY-MM-DD HH:mm"),
|
|
582
|
-
endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format("YYYY-MM-DD HH:mm")
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
} else {
|
|
586
|
-
this.store.cart.updateItem({
|
|
587
|
-
_id: item._id,
|
|
588
|
-
resources
|
|
572
|
+
});
|
|
589
573
|
});
|
|
574
|
+
if (item.start_time) {
|
|
575
|
+
const start_time = item.start_time;
|
|
576
|
+
const end_time = item.end_time;
|
|
577
|
+
const start_date = item.start_date;
|
|
578
|
+
const end_date = item.end_date;
|
|
579
|
+
this.store.cart.updateItem({
|
|
580
|
+
_id: item._id,
|
|
581
|
+
resources,
|
|
582
|
+
date: {
|
|
583
|
+
startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format("YYYY-MM-DD HH:mm"),
|
|
584
|
+
endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format("YYYY-MM-DD HH:mm")
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
} else {
|
|
588
|
+
this.store.cart.updateItem({
|
|
589
|
+
_id: item._id,
|
|
590
|
+
resources
|
|
591
|
+
});
|
|
592
|
+
}
|
|
590
593
|
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
593
596
|
}
|
|
594
597
|
// 删除购物车里某个商品
|
|
595
598
|
deleteCart(cartItemId) {
|
|
@@ -725,6 +728,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
725
728
|
return false;
|
|
726
729
|
}
|
|
727
730
|
const canUseArr = mTimes.map((item) => {
|
|
731
|
+
var _a2;
|
|
728
732
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
729
733
|
timeSlice: {
|
|
730
734
|
start_time: startTime.format("HH:mm"),
|
|
@@ -735,7 +739,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
735
739
|
time: item,
|
|
736
740
|
resource: m,
|
|
737
741
|
currentCount: currentCapacity || 0,
|
|
738
|
-
resourcesUseableMap
|
|
742
|
+
resourcesUseableMap,
|
|
743
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
739
744
|
});
|
|
740
745
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
741
746
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -852,6 +857,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
852
857
|
return false;
|
|
853
858
|
}
|
|
854
859
|
const canUseArr = mTimes.map((item) => {
|
|
860
|
+
var _a2;
|
|
855
861
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
856
862
|
timeSlice: {
|
|
857
863
|
start_time: startTime.format("HH:mm"),
|
|
@@ -862,7 +868,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
862
868
|
time: item,
|
|
863
869
|
resource: m,
|
|
864
870
|
currentCount: currentCapacity || 0,
|
|
865
|
-
resourcesUseableMap
|
|
871
|
+
resourcesUseableMap,
|
|
872
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
866
873
|
});
|
|
867
874
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
868
875
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -1056,12 +1063,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1056
1063
|
continue;
|
|
1057
1064
|
}
|
|
1058
1065
|
const canUseTime = mTimes.find((item) => {
|
|
1066
|
+
var _a2;
|
|
1059
1067
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1060
1068
|
timeSlice: timeSlots,
|
|
1061
1069
|
time: item,
|
|
1062
1070
|
resource: n,
|
|
1063
1071
|
currentCount: recordCount + (capacity || 0),
|
|
1064
|
-
resourcesUseableMap
|
|
1072
|
+
resourcesUseableMap,
|
|
1073
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1065
1074
|
});
|
|
1066
1075
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
|
|
1067
1076
|
resourcesUseableMap[n.id] = res.usable;
|
|
@@ -1114,7 +1123,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1114
1123
|
const selectForCartResources = (cartItems2) => {
|
|
1115
1124
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1116
1125
|
cartItems2.forEach((item, index) => {
|
|
1117
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1126
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1118
1127
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1119
1128
|
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1120
1129
|
product_bundle: item._origin.product.product_bundle
|
|
@@ -1130,14 +1139,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1130
1139
|
}
|
|
1131
1140
|
if (recordTimeSlots) {
|
|
1132
1141
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find((n) => n.code === resources_code);
|
|
1133
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single") {
|
|
1142
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1134
1143
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1135
|
-
((
|
|
1136
|
-
((
|
|
1144
|
+
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
|
|
1145
|
+
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
|
|
1137
1146
|
);
|
|
1138
1147
|
let end_at = start_at.add(
|
|
1139
|
-
((
|
|
1140
|
-
((
|
|
1148
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) ?? 0,
|
|
1149
|
+
((_m = (_l = item._productOrigin) == null ? void 0 : _l.duration) == null ? void 0 : _m.type) ?? "minutes"
|
|
1141
1150
|
);
|
|
1142
1151
|
recordTimeSlots = {
|
|
1143
1152
|
start_time: start_at.format("HH:mm"),
|
|
@@ -1182,7 +1191,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1182
1191
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1183
1192
|
let selectedResources = [];
|
|
1184
1193
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1185
|
-
((
|
|
1194
|
+
((_o = (_n = item._productOrigin) == null ? void 0 : _n.product_resource) == null ? void 0 : _o.resources) || []
|
|
1186
1195
|
);
|
|
1187
1196
|
const currentResourcesRenderList = [];
|
|
1188
1197
|
resources2.forEach((n) => {
|
|
@@ -1230,11 +1239,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1230
1239
|
return recordCount >= currentCapacity;
|
|
1231
1240
|
});
|
|
1232
1241
|
});
|
|
1233
|
-
const targetRenderList = (
|
|
1242
|
+
const targetRenderList = (_p = productResources.find(
|
|
1234
1243
|
(n) => n.code === resources_code
|
|
1235
|
-
)) == null ? void 0 :
|
|
1244
|
+
)) == null ? void 0 : _p.renderList;
|
|
1236
1245
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1237
|
-
if ((
|
|
1246
|
+
if ((_q = item._origin.resources) == null ? void 0 : _q.some(
|
|
1238
1247
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1239
1248
|
)) {
|
|
1240
1249
|
return;
|
|
@@ -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;
|