diff --git a/CoreCms.Net.Services/SQ/SQServices.cs b/CoreCms.Net.Services/SQ/SQServices.cs index 39d8a8d..569cc08 100644 --- a/CoreCms.Net.Services/SQ/SQServices.cs +++ b/CoreCms.Net.Services/SQ/SQServices.cs @@ -1,6 +1,7 @@ using AutoMapper; using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.SQ; using Kdbndp.KingbaseTypes; @@ -60,7 +61,7 @@ namespace CoreCms.Net.Services.SQ /// /// /// - public static async Task LoadSQReservationParticipantsApiDto(this List list, int userId, SqlSugarScope _dbBase, ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices, IMapper _mapper) + public static async Task LoadSQReservationParticipantsApiDto(this List list, int userId, SqlSugarScope _dbBase, ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices, List rooms, IMapper _mapper) { var rIds = list.Select(it => it.id).ToList(); if (rIds != null && rIds.Count > 0) @@ -89,6 +90,11 @@ namespace CoreCms.Net.Services.SQ { var temp = participants.Where(it => it.reservation_id == item.id).OrderBy(it => it.role).ThenBy(it => it.status).ToList(); var dto = _mapper.Map>(temp); + var room = rooms.Find(it => it.id == item.room_id); + if (room != null) + { + item.room_name = $"{room.name} {room.price_per_hour.ToString("#.##")}/小时"; + } item.Participants = dto; } } diff --git a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs index 9f97d8a..9f38f8f 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs @@ -93,9 +93,10 @@ public class SQController : ControllerBase var list = await _dbBase.Ado.SqlQueryAsync($"select r.*,p.id pid, p.status pstatus,p.join_time, p.quit_time ,p.is_refund from SQReservationParticipants p inner join SQReservations r on p.reservation_id=r.id where p.user_id={userId} and p.role={type} order by p.id desc OFFSET {(index - 1) * size} ROWS FETCH NEXT {size} ROWS ONLY"); if (list != null && list.Count > 0) { + var roomList = await _SQRoomsServices.GetRoomList(); // 转为基类列表 var baseList = list.Cast().ToList(); - await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, _mapper); + await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, roomList, _mapper); } return new WebApiDto() { @@ -117,9 +118,10 @@ public class SQController : ControllerBase var list = await _dbBase.Ado.SqlQueryAsync($"select top 3 r.* from SQReservations r left join SQReservationParticipants p on r.id=p.reservation_id where r.status<2 and p.user_id={userId} and p.status=0 order by r.start_time "); if (list != null && list.Count > 0) { + var roomList = await _SQRoomsServices.GetRoomList(); // 转为基类列表 var baseList = list.Cast().ToList(); - await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, _mapper); + await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, roomList, _mapper); } return new WebApiDto() { @@ -149,7 +151,7 @@ public class SQController : ControllerBase { // 转为基类列表 var baseList = pageList.Cast().ToList(); - await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, _mapper); + await baseList.LoadSQReservationParticipantsApiDto(userId, _dbBase, _coreCmsUserBlacklistServices, roomList, _mapper); } return new WebApiDto() {