diff --git a/CoreCms.Net.Model/ViewModels/SQ/SQReservationsDto.cs b/CoreCms.Net.Model/ViewModels/SQ/SQReservationsDto.cs
index a827e6e..7801573 100644
--- a/CoreCms.Net.Model/ViewModels/SQ/SQReservationsDto.cs
+++ b/CoreCms.Net.Model/ViewModels/SQ/SQReservationsDto.cs
@@ -102,7 +102,26 @@ namespace CoreCms.Net.Model.ViewModels.SQ
[StringLength(maximumLength: 255, ErrorMessage = "{0}不能超过{1}字")]
public new System.String remarks { get; set; }
+
+ ///
+ /// 重要信息
+ ///
+ public string important_data { get; set; }
+ }
+ public class SQReservationParticipantsAddDto
+ {
+
+ ///
+ /// 预约ID
+ ///
+
+ public new System.Int32 ReservationsId { get; set; }
+
+
+ ///
+ /// 重要信息
+ ///
+ public string important_data { get; set; }
}
-
}
diff --git a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs
index 9b67c53..62fa1c1 100644
--- a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs
+++ b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs
@@ -29,6 +29,7 @@ using CoreCms.Net.Utility.Extensions;
using ToolGood.Words.internals;
using NPOI.SS.Formula.PTG;
using NPOI.OpenXmlFormats.Dml;
+using Humanizer;
namespace CoreCms.Net.Web.WebApi.Controllers;
///
@@ -544,6 +545,7 @@ ISQRoomUnavailableTimesServices sQRoomUnavailableTimesServices
role = 1,
status = 0,
is_refund = dto.deposit_fee > 0 ? 1 : 0,
+ important_data = dto.important_data
};
await _SQReservationParticipantsServices.InsertAsync(participant);
@@ -554,17 +556,18 @@ ISQRoomUnavailableTimesServices sQRoomUnavailableTimesServices
Msg = "预约成功"
};
}
+
///
/// 用户加入预约接口
///
- /// 预约ID
+ /// 预约
///
[HttpPost]
[Authorize]
- public async Task JoinReservation([FromBody] int reservationId)
+ public async Task JoinReservation([FromBody] SQReservationParticipantsAddDto dto)
{
var userId = _user.ID;
-
+ var reservationId = dto.ReservationsId;
// 1. 校验预约是否存在且未结束
var reservation = await _SQReservationsServices.QueryByClauseAsync(
r => r.id == reservationId && r.end_time > DateTime.Now && r.status < 2,
@@ -593,6 +596,61 @@ ISQRoomUnavailableTimesServices sQRoomUnavailableTimesServices
};
}
+ // 2.1 校验用户是否有其它预约时间冲突
+ // 2.1 校验用户是否有其它预约时间冲突(只查未开始或正在进行中的预约)
+ var now = DateTime.Now;
+ var hasConflict = await _SQReservationParticipantsServices.QueryMuchAsync(
+ (p, r) => new object[]
+ {
+ JoinType.Inner, p.reservation_id == r.id
+ },
+ (p, r) => r.id,
+ (p, r) =>
+ p.user_id == userId &&
+ p.status == 0 && // 只查未退出
+ r.status < 2 && // 只查未取消/未结束
+ r.end_time > now && // 只查未结束
+ r.start_time < reservation.end_time && r.end_time > reservation.start_time // 时间有重叠
+ );
+
+ if (hasConflict != null && hasConflict.Count > 0)
+ {
+ return new WebApiDto
+ {
+ Code = 402,
+ Data = null,
+ Msg = "您有其它预约时间冲突,无法加入该预约"
+ };
+ }
+ //// 查询用户所有未结束的预约参与记录
+ //var userReservations = await _SQReservationParticipantsServices.QueryListByClauseAsync(
+ // p => p.user_id == userId && p.status == 0, // 只查未退出的
+ // p => p.id, OrderByType.Asc);
+
+ //if (userReservations != null && userReservations.Count > 0)
+ //{
+ // // 获取这些预约的ID
+ // var reservationIds = userReservations.Select(p => p.reservation_id).ToList();
+ // // 查询这些预约的时间段
+ // var reservations = await _SQReservationsServices.QueryListByClauseAsync(
+ // r => reservationIds.Contains(r.id) && r.status < 2 && r.end_time > DateTime.Now,
+ // r => r.id, OrderByType.Asc);
+
+ // // 检查时间是否有重叠
+ // foreach (var r in reservations)
+ // {
+ // if (r.start_time < reservation.end_time && r.end_time > reservation.start_time)
+ // {
+ // return new WebApiDto
+ // {
+ // Code = 402,
+ // Data = null,
+ // Msg = "您有其它预约时间冲突,无法加入该预约"
+ // };
+ // }
+ // }
+ //}
+
//3.校验预约是否已满(如有容量限制,可补充)
var participantsCount = await _SQReservationParticipantsServices.QueryListByClauseAsync(
p => p.reservation_id == reservationId, p => p.id, OrderByType.Asc);
@@ -613,7 +671,9 @@ ISQRoomUnavailableTimesServices sQRoomUnavailableTimesServices
user_id = userId,
join_time = DateTime.Now,
role = 0, // 0为参与者
- status = 0
+ status = 0,
+ is_refund = reservation.deposit_fee > 0 ? 1 : 0,
+ important_data = dto.important_data
};
await _SQReservationParticipantsServices.InsertAsync(participant);