@pisell/pisellos 3.0.16 → 3.0.19
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/AccountList/index.d.ts +6 -3
- package/dist/modules/AccountList/index.js +67 -45
- package/dist/modules/Cart/utils.js +29 -12
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Rules/index.d.ts +2 -1
- package/dist/modules/Rules/index.js +7 -5
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +295 -86
- package/dist/solution/BookingByStep/utils/resources.js +18 -12
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/lib/modules/AccountList/index.d.ts +6 -3
- package/lib/modules/AccountList/index.js +32 -9
- package/lib/modules/Cart/utils.js +24 -8
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Rules/index.d.ts +2 -1
- package/lib/modules/Rules/index.js +7 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +283 -82
- package/lib/solution/BookingByStep/utils/resources.js +6 -12
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -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) || []);
|
|
@@ -430,7 +435,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
430
435
|
break;
|
|
431
436
|
}
|
|
432
437
|
_context7.next = 3;
|
|
433
|
-
return this.store.accountList.addHolderAccounts(
|
|
438
|
+
return this.store.accountList.addHolderAccounts({
|
|
439
|
+
holders: [account],
|
|
440
|
+
customerId: extra.customerId,
|
|
441
|
+
type: 'unshift'
|
|
442
|
+
});
|
|
434
443
|
case 3:
|
|
435
444
|
accountModules = _context7.sent;
|
|
436
445
|
return _context7.abrupt("return", accountModules[0].getAccount());
|
|
@@ -463,7 +472,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
472
|
_context8.next = 3;
|
|
464
473
|
break;
|
|
465
474
|
}
|
|
466
|
-
this.store.accountList.addHolderAccounts(
|
|
475
|
+
this.store.accountList.addHolderAccounts({
|
|
476
|
+
holders: accounts,
|
|
477
|
+
customerId: extra.customerId,
|
|
478
|
+
type: 'unshift'
|
|
479
|
+
});
|
|
467
480
|
return _context8.abrupt("return");
|
|
468
481
|
case 3:
|
|
469
482
|
res = [];
|
|
@@ -641,7 +654,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
641
654
|
key: "getAvailableDate",
|
|
642
655
|
value: function () {
|
|
643
656
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
644
|
-
var _this3 = this
|
|
657
|
+
var _this3 = this,
|
|
658
|
+
_dateRange$,
|
|
659
|
+
_dateRange$2,
|
|
660
|
+
_dateRange$3;
|
|
645
661
|
var params,
|
|
646
662
|
products,
|
|
647
663
|
startDate,
|
|
@@ -684,8 +700,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
684
700
|
})];
|
|
685
701
|
}
|
|
686
702
|
dateRange = this.store.date.getDateRange();
|
|
687
|
-
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 :
|
|
688
|
-
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[
|
|
703
|
+
tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
|
|
704
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date) || (dateRange === null || dateRange === void 0 || (_dateRange$3 = dateRange[0]) === null || _dateRange$3 === void 0 ? void 0 : _dateRange$3.date);
|
|
689
705
|
if (tempProducts.length) {
|
|
690
706
|
_context13.next = 11;
|
|
691
707
|
break;
|
|
@@ -1026,6 +1042,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1026
1042
|
if (!targetCartItem) {
|
|
1027
1043
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
1028
1044
|
}
|
|
1045
|
+
var currentResourcesCapacityMap = {};
|
|
1029
1046
|
if (params.resources) {
|
|
1030
1047
|
var _targetCartItem$_prod;
|
|
1031
1048
|
var formatCapacity = formatDefaultCapacitys({
|
|
@@ -1037,41 +1054,95 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1037
1054
|
});
|
|
1038
1055
|
params.resources = params.resources.map(function (n) {
|
|
1039
1056
|
n.capacity = currentCapacity || 1;
|
|
1057
|
+
currentResourcesCapacityMap[n.id] = currentCapacity;
|
|
1040
1058
|
checkSubResourcesCapacity(n);
|
|
1041
1059
|
return n;
|
|
1042
1060
|
});
|
|
1043
1061
|
}
|
|
1044
1062
|
this.store.cart.updateItem(params);
|
|
1045
|
-
|
|
1046
|
-
var
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1063
|
+
var allOriginResources = [];
|
|
1064
|
+
var dateRange = this.store.date.getDateRange();
|
|
1065
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1066
|
+
dateRange.forEach(function (n) {
|
|
1067
|
+
if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1071
|
+
if (!allOriginResources.length) {
|
|
1072
|
+
var dateList = this.store.date.getDateList();
|
|
1073
|
+
dateList.forEach(function (n) {
|
|
1074
|
+
if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
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;
|
|
1119
|
+
}
|
|
1120
|
+
return false;
|
|
1121
|
+
});
|
|
1067
1122
|
});
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
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
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1075
1146
|
}
|
|
1076
1147
|
|
|
1077
1148
|
// 删除购物车里某个商品
|
|
@@ -1178,15 +1249,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1178
1249
|
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1179
1250
|
var cartItems = this.store.cart.getItems();
|
|
1180
1251
|
var arr = [];
|
|
1181
|
-
var capacityMap = {};
|
|
1182
1252
|
cartItems.forEach(function (cartItem) {
|
|
1183
1253
|
var _cartItem$_productOri, _cartItem$_productOri2;
|
|
1184
1254
|
var selectedResources = [];
|
|
1185
|
-
if (cartItem.holder_id) {
|
|
1186
|
-
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1187
|
-
} else {
|
|
1188
|
-
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1189
|
-
}
|
|
1190
1255
|
var formatCapacity = formatDefaultCapacitys({
|
|
1191
1256
|
capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
|
|
1192
1257
|
product_bundle: cartItem._origin.product.product_bundle
|
|
@@ -1195,6 +1260,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1195
1260
|
var currentCapacity = getSumCapacity({
|
|
1196
1261
|
capacity: formatCapacity
|
|
1197
1262
|
});
|
|
1263
|
+
if (cartItem.holder_id) {
|
|
1264
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1265
|
+
} else {
|
|
1266
|
+
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1267
|
+
}
|
|
1198
1268
|
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1199
1269
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1200
1270
|
if (cartItem._origin.start_time) {
|
|
@@ -1212,7 +1282,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1212
1282
|
return 0;
|
|
1213
1283
|
});
|
|
1214
1284
|
n.renderList = n.renderList.filter(function (m) {
|
|
1215
|
-
var recordCount = capacityMap[m.id] || 0;
|
|
1216
1285
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1217
1286
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1218
1287
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -1233,7 +1302,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1233
1302
|
},
|
|
1234
1303
|
time: item,
|
|
1235
1304
|
resource: m,
|
|
1236
|
-
currentCount:
|
|
1305
|
+
currentCount: currentCapacity || 0,
|
|
1237
1306
|
resourcesUseableMap: resourcesUseableMap
|
|
1238
1307
|
});
|
|
1239
1308
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
@@ -1282,6 +1351,132 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1282
1351
|
return arr;
|
|
1283
1352
|
}
|
|
1284
1353
|
|
|
1354
|
+
// 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
1355
|
+
}, {
|
|
1356
|
+
key: "checkResourceListForDate",
|
|
1357
|
+
value: function checkResourceListForDate() {
|
|
1358
|
+
var dateRange = this.store.date.getDateRange();
|
|
1359
|
+
var resources = [];
|
|
1360
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1361
|
+
dateRange.forEach(function (n) {
|
|
1362
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1366
|
+
if (!resources.length) {
|
|
1367
|
+
var dateList = this.store.date.getDateList();
|
|
1368
|
+
dateList.forEach(function (n) {
|
|
1369
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1373
|
+
var cartItems = this.store.cart.getItems();
|
|
1374
|
+
var arr = [];
|
|
1375
|
+
cartItems.forEach(function (cartItem) {
|
|
1376
|
+
var _cartItem$_productOri4, _cartItem$_productOri5;
|
|
1377
|
+
var selectedResources = [];
|
|
1378
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1379
|
+
capacity: (_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.capacity,
|
|
1380
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
1381
|
+
});
|
|
1382
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1383
|
+
var currentCapacity = getSumCapacity({
|
|
1384
|
+
capacity: formatCapacity
|
|
1385
|
+
});
|
|
1386
|
+
if (cartItem.holder_id) {
|
|
1387
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1388
|
+
} else {
|
|
1389
|
+
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1390
|
+
}
|
|
1391
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.product_resource) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.resources) || [], selectedResources, currentCapacity);
|
|
1392
|
+
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1393
|
+
if (cartItem._origin.start_time) {
|
|
1394
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1395
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1396
|
+
var resourcesUseableMap = {};
|
|
1397
|
+
productResources.forEach(function (n) {
|
|
1398
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1399
|
+
n.renderList = n.renderList.sort(function (a, b) {
|
|
1400
|
+
var _a$metadata2, _b$metadata2;
|
|
1401
|
+
var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
|
|
1402
|
+
var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
|
|
1403
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1404
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1405
|
+
return 0;
|
|
1406
|
+
});
|
|
1407
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1408
|
+
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1409
|
+
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1410
|
+
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1411
|
+
var mTimes = m.times.filter(function (n) {
|
|
1412
|
+
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1413
|
+
});
|
|
1414
|
+
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1415
|
+
if (mTimes.length === 0) {
|
|
1416
|
+
return false;
|
|
1417
|
+
}
|
|
1418
|
+
var canUseArr = mTimes.map(function (item) {
|
|
1419
|
+
var res = getIsUsableByTimeItem({
|
|
1420
|
+
timeSlice: {
|
|
1421
|
+
start_time: startTime.format('HH:mm'),
|
|
1422
|
+
end_time: endTime.format('HH:mm'),
|
|
1423
|
+
start_at: startTime,
|
|
1424
|
+
end_at: endTime
|
|
1425
|
+
},
|
|
1426
|
+
time: item,
|
|
1427
|
+
resource: m,
|
|
1428
|
+
currentCount: currentCapacity || 0,
|
|
1429
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1430
|
+
});
|
|
1431
|
+
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1432
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1433
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
1434
|
+
}
|
|
1435
|
+
return res.usable;
|
|
1436
|
+
});
|
|
1437
|
+
if (m.onlyComputed) return false;
|
|
1438
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1439
|
+
return !canUseArr.some(function (n) {
|
|
1440
|
+
return n === false;
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
});
|
|
1444
|
+
} else {
|
|
1445
|
+
productResources.forEach(function (item) {
|
|
1446
|
+
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1447
|
+
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1448
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1449
|
+
var _cartItem$_productOri6;
|
|
1450
|
+
var recordCount = n.capacity || 0;
|
|
1451
|
+
if (n.onlyComputed) return false;
|
|
1452
|
+
// 查一下这个资源基于商品的可用时间片
|
|
1453
|
+
var timeSlots = getTimeSlicesByResource({
|
|
1454
|
+
resource: n,
|
|
1455
|
+
duration: ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.duration) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.value) || 0,
|
|
1456
|
+
split: 10,
|
|
1457
|
+
currentDate: dateRange[0].date
|
|
1458
|
+
});
|
|
1459
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1460
|
+
});
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
arr.push({
|
|
1464
|
+
id: cartItem.id,
|
|
1465
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1466
|
+
_id: cartItem._id,
|
|
1467
|
+
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1468
|
+
productResources: productResources
|
|
1469
|
+
});
|
|
1470
|
+
});
|
|
1471
|
+
// 检查 productResources里是不是每一项资源的 renderList 里都有数据
|
|
1472
|
+
var hasResource = arr.every(function (n) {
|
|
1473
|
+
return n.productResources.every(function (m) {
|
|
1474
|
+
return m.renderList.length > 0;
|
|
1475
|
+
});
|
|
1476
|
+
});
|
|
1477
|
+
return hasResource;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1285
1480
|
// 给单个购物车里的商品获取资源列表
|
|
1286
1481
|
}, {
|
|
1287
1482
|
key: "getResourcesListByCartItem",
|
|
@@ -1293,9 +1488,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1488
|
dateRange.forEach(function (n) {
|
|
1294
1489
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1295
1490
|
});
|
|
1296
|
-
// 这里为什么要 cloneDeep:因为 getOthersSelectedResources 和 getOthersCartSelectedResources 会修改 resourcesMap 的 capacity
|
|
1297
1491
|
// 用于确保后续分配的容量不会超出
|
|
1298
|
-
var resourcesMap = getResourcesMap(
|
|
1492
|
+
var resourcesMap = getResourcesMap(resources);
|
|
1299
1493
|
var targetCartItem = cartItems.find(function (n) {
|
|
1300
1494
|
return n._id === id;
|
|
1301
1495
|
});
|
|
@@ -1303,11 +1497,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1303
1497
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
1304
1498
|
}
|
|
1305
1499
|
var selectedResources = [];
|
|
1306
|
-
if (targetCartItem.holder_id) {
|
|
1307
|
-
selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
|
|
1308
|
-
} else {
|
|
1309
|
-
selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
|
|
1310
|
-
}
|
|
1311
1500
|
var formatCapacity = formatDefaultCapacitys({
|
|
1312
1501
|
capacity: (_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.capacity,
|
|
1313
1502
|
product_bundle: targetCartItem._origin.product.product_bundle
|
|
@@ -1315,6 +1504,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1315
1504
|
var currentCapacity = getSumCapacity({
|
|
1316
1505
|
capacity: formatCapacity
|
|
1317
1506
|
});
|
|
1507
|
+
if (targetCartItem.holder_id) {
|
|
1508
|
+
selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
|
|
1509
|
+
} else {
|
|
1510
|
+
selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
|
|
1511
|
+
}
|
|
1318
1512
|
var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
|
|
1319
1513
|
productResources.forEach(function (item) {
|
|
1320
1514
|
item.renderList = item.renderList.filter(function (n) {
|
|
@@ -1360,7 +1554,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1360
1554
|
}, {
|
|
1361
1555
|
key: "autoSelectAccountResources",
|
|
1362
1556
|
value: function autoSelectAccountResources(_ref8) {
|
|
1363
|
-
var _cartItem$
|
|
1557
|
+
var _cartItem$_productOri7, _allProductResources$;
|
|
1364
1558
|
var cartItem = _ref8.cartItem,
|
|
1365
1559
|
holder_id = _ref8.holder_id,
|
|
1366
1560
|
resources_code = _ref8.resources_code,
|
|
@@ -1409,21 +1603,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1409
1603
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1410
1604
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1411
1605
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1412
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1606
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 || (_cartItem$_productOri7 = _cartItem$_productOri7.product_resource) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.resources) || [], selectedResources, 1);
|
|
1413
1607
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1414
1608
|
return n.code === resources_code;
|
|
1415
1609
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
1416
1610
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1417
1611
|
resources.sort(function (a, b) {
|
|
1418
|
-
var _a$
|
|
1419
|
-
var aIsCombined = ((_a$
|
|
1420
|
-
var bIsCombined = ((_b$
|
|
1612
|
+
var _a$metadata3, _b$metadata3;
|
|
1613
|
+
var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
|
|
1614
|
+
var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
|
|
1421
1615
|
if (aIsCombined && !bIsCombined) return 1;
|
|
1422
1616
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1423
1617
|
return 0;
|
|
1424
1618
|
});
|
|
1425
1619
|
var resourcesUseableMap = _toConsumableArray(selectedResources).reduce(function (acc, n) {
|
|
1426
|
-
|
|
1620
|
+
var _resourcesMap$n;
|
|
1621
|
+
acc[n] = ((_resourcesMap$n = resourcesMap[n]) === null || _resourcesMap$n === void 0 ? void 0 : _resourcesMap$n.resourceType) === 'single' ? false : true;
|
|
1427
1622
|
return acc;
|
|
1428
1623
|
}, {});
|
|
1429
1624
|
|
|
@@ -1519,16 +1714,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1519
1714
|
}, {
|
|
1520
1715
|
key: "autoSelectAllProductResources",
|
|
1521
1716
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1522
|
-
var _dateRange
|
|
1717
|
+
var _dateRange$4,
|
|
1523
1718
|
_this8 = this;
|
|
1524
1719
|
var dateRange = this.store.date.getDateRange();
|
|
1525
1720
|
var resources = [];
|
|
1526
|
-
if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange
|
|
1721
|
+
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
1527
1722
|
dateRange.forEach(function (n) {
|
|
1528
1723
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1529
1724
|
});
|
|
1530
1725
|
}
|
|
1531
|
-
|
|
1726
|
+
// const resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1532
1727
|
// 一个账号一个账号处理
|
|
1533
1728
|
var errorList = [];
|
|
1534
1729
|
var selectResourcesMap = {};
|
|
@@ -1540,9 +1735,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1540
1735
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1541
1736
|
|
|
1542
1737
|
cartItems.forEach(function (item, index) {
|
|
1543
|
-
var _item$
|
|
1738
|
+
var _item$_productOrigin3;
|
|
1544
1739
|
var formatCapacity = formatDefaultCapacitys({
|
|
1545
|
-
capacity: (_item$
|
|
1740
|
+
capacity: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.capacity,
|
|
1546
1741
|
product_bundle: item._origin.product.product_bundle
|
|
1547
1742
|
});
|
|
1548
1743
|
var currentCapacity = getSumCapacity({
|
|
@@ -1558,10 +1753,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1558
1753
|
};
|
|
1559
1754
|
}
|
|
1560
1755
|
if (recordTimeSlots) {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1756
|
+
var _item$_productOrigin4, _item$_productOrigin5;
|
|
1757
|
+
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
1758
|
+
// 前提:当前资源是单个预约才需要这么做
|
|
1759
|
+
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) {
|
|
1760
|
+
return n.code === resources_code;
|
|
1761
|
+
});
|
|
1762
|
+
// 只有 duration 类商品需要这个操作
|
|
1763
|
+
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) {
|
|
1764
|
+
var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1765
|
+
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');
|
|
1766
|
+
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');
|
|
1565
1767
|
recordTimeSlots = {
|
|
1566
1768
|
start_time: start_at.format('HH:mm'),
|
|
1567
1769
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1603,12 +1805,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1805
|
errorList.push(item._id);
|
|
1604
1806
|
}
|
|
1605
1807
|
} else {
|
|
1606
|
-
var _item$
|
|
1808
|
+
var _item$_productOrigin10, _productResources$fin;
|
|
1607
1809
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1608
1810
|
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1609
1811
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1610
1812
|
var selectedResources = [];
|
|
1611
|
-
var _resources = cloneDeep(((_item$
|
|
1813
|
+
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) || []);
|
|
1612
1814
|
var currentResourcesRenderList = [];
|
|
1613
1815
|
_resources.forEach(function (n) {
|
|
1614
1816
|
var _n$renderList;
|
|
@@ -1616,7 +1818,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1616
1818
|
// 过滤掉 capacity 小于 currentCapacity 的资源
|
|
1617
1819
|
n.renderList = n.renderList.filter(function (m) {
|
|
1618
1820
|
var _item$duration;
|
|
1619
|
-
|
|
1821
|
+
// 同时 还需要减去 selectResourcesMap 里已经选中的资源的数量
|
|
1822
|
+
var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
1620
1823
|
var timeSlots = getTimeSlicesByResource({
|
|
1621
1824
|
resource: m,
|
|
1622
1825
|
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
|
|
@@ -1628,16 +1831,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1628
1831
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1629
1832
|
}
|
|
1630
1833
|
});
|
|
1631
|
-
var
|
|
1834
|
+
var resourcesMap = getResourcesMap(currentResourcesRenderList);
|
|
1632
1835
|
if (item.holder_id) {
|
|
1633
|
-
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id,
|
|
1836
|
+
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
|
|
1634
1837
|
} else {
|
|
1635
|
-
selectedResources = getOthersCartSelectedResources(allCartItems, item._id,
|
|
1838
|
+
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, resourcesMap);
|
|
1636
1839
|
}
|
|
1637
|
-
var productResources = getResourcesByProduct(
|
|
1840
|
+
var productResources = getResourcesByProduct(resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1638
1841
|
productResources.forEach(function (item) {
|
|
1639
1842
|
item.renderList = item.renderList.filter(function (n) {
|
|
1640
|
-
var recordCount = n.capacity || 0;
|
|
1843
|
+
var recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1641
1844
|
if (n.onlyComputed) return false;
|
|
1642
1845
|
return recordCount >= currentCapacity;
|
|
1643
1846
|
});
|
|
@@ -1658,6 +1861,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1658
1861
|
targetResource.capacity = currentCapacity;
|
|
1659
1862
|
// 在这里处理 children 的数据
|
|
1660
1863
|
checkSubResourcesCapacity(targetResource);
|
|
1864
|
+
if (!selectResourcesMap[targetResource.id]) {
|
|
1865
|
+
selectResourcesMap[targetResource.id] = currentCapacity;
|
|
1866
|
+
} else {
|
|
1867
|
+
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
1868
|
+
}
|
|
1661
1869
|
_this8.store.cart.updateItem({
|
|
1662
1870
|
_id: item._id,
|
|
1663
1871
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -1702,8 +1910,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1702
1910
|
var resourceIds = [];
|
|
1703
1911
|
var resourcesTypeId = undefined;
|
|
1704
1912
|
cartItems.forEach(function (item) {
|
|
1705
|
-
var _item$
|
|
1706
|
-
(_item$
|
|
1913
|
+
var _item$_productOrigin11, _item$_productOrigin12;
|
|
1914
|
+
(_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) {
|
|
1707
1915
|
if (n.code === resources_code) {
|
|
1708
1916
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1709
1917
|
}
|
|
@@ -1714,9 +1922,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1714
1922
|
if (item.resource_id) {
|
|
1715
1923
|
resourceIds.push(item.resource_id);
|
|
1716
1924
|
}
|
|
1717
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
1925
|
+
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) {
|
|
1718
1926
|
return n.code === resources_code;
|
|
1719
|
-
})) === null || _item$
|
|
1927
|
+
})) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
|
|
1720
1928
|
});
|
|
1721
1929
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1722
1930
|
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
@@ -1736,8 +1944,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1736
1944
|
var checkDuration = function checkDuration(cartItems) {
|
|
1737
1945
|
var accountDuration = 0;
|
|
1738
1946
|
cartItems.forEach(function (item) {
|
|
1739
|
-
var _item$_productOrigin$3, _item$
|
|
1740
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1947
|
+
var _item$_productOrigin$3, _item$_productOrigin13;
|
|
1948
|
+
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;
|
|
1741
1949
|
});
|
|
1742
1950
|
if (accountDuration > duration) {
|
|
1743
1951
|
duration = accountDuration;
|
|
@@ -1804,11 +2012,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1804
2012
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
1805
2013
|
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1806
2014
|
accountItems.forEach(function (item, index) {
|
|
2015
|
+
var _newResources$;
|
|
1807
2016
|
var newResources = cloneDeep(item._origin.resources);
|
|
1808
2017
|
newResources.forEach(function (resource) {
|
|
1809
|
-
var _item$_productOrigin$4, _item$
|
|
2018
|
+
var _item$_productOrigin$4, _item$_productOrigin14, _ref11, _item$_productOrigin15;
|
|
1810
2019
|
resource.startTime = currentStartTime;
|
|
1811
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
2020
|
+
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');
|
|
1812
2021
|
delete resource.times;
|
|
1813
2022
|
});
|
|
1814
2023
|
_this10.store.cart.updateItem({
|
|
@@ -1817,7 +2026,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1817
2026
|
});
|
|
1818
2027
|
|
|
1819
2028
|
// 更新下一个商品的开始时间为当前商品的结束时间
|
|
1820
|
-
if (index < accountItems.length - 1) {
|
|
2029
|
+
if (index < accountItems.length - 1 && (newResources === null || newResources === void 0 || (_newResources$ = newResources[0]) === null || _newResources$ === void 0 ? void 0 : _newResources$.resourceType) === 'single') {
|
|
1821
2030
|
currentStartTime = newResources[0].endTime;
|
|
1822
2031
|
}
|
|
1823
2032
|
});
|
|
@@ -1925,9 +2134,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1925
2134
|
});
|
|
1926
2135
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1927
2136
|
allProductResources.sort(function (a, b) {
|
|
1928
|
-
var _a$
|
|
1929
|
-
var aIsCombined = ((_a$
|
|
1930
|
-
var bIsCombined = ((_b$
|
|
2137
|
+
var _a$metadata4, _b$metadata4;
|
|
2138
|
+
var aIsCombined = ((_a$metadata4 = a.metadata) === null || _a$metadata4 === void 0 || (_a$metadata4 = _a$metadata4.combined_resource) === null || _a$metadata4 === void 0 ? void 0 : _a$metadata4.status) === 1;
|
|
2139
|
+
var bIsCombined = ((_b$metadata4 = b.metadata) === null || _b$metadata4 === void 0 || (_b$metadata4 = _b$metadata4.combined_resource) === null || _b$metadata4 === void 0 ? void 0 : _b$metadata4.status) === 1;
|
|
1931
2140
|
if (aIsCombined && !bIsCombined) return 1;
|
|
1932
2141
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1933
2142
|
return 0;
|