106 lines
4.8 KiB
C#
106 lines
4.8 KiB
C#
using AutoMapper;
|
|
|
|
using CoreCms.Net.IServices;
|
|
using CoreCms.Net.Model.Entities;
|
|
using CoreCms.Net.Model.ViewModels.SQ;
|
|
|
|
using Kdbndp.KingbaseTypes;
|
|
|
|
using SqlSugar;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinUserInfoBatchGetRequest.Types;
|
|
|
|
namespace CoreCms.Net.Services.SQ
|
|
{
|
|
public static class SQServices
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sQReservationParticipants"></param>
|
|
/// <returns></returns>
|
|
public static async Task<List<SQReservationParticipantsApiDto>> LoadSQReservationParticipantsApiDtoId(List<int> rIds, int userId, SqlSugarScope _dbBase, ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices)
|
|
{
|
|
if (rIds != null && rIds.Count > 0)
|
|
{
|
|
string sqlWhere = string.Join(",", rIds);
|
|
var participants = await _dbBase.Ado.SqlQueryAsync<SQReservationParticipantsApiDto>($"select p.id,p.reservation_id,p.status,p.join_time,p.user_id, p.role,u.nickName UserName,u.avatarImage AvatarImage from SQReservationParticipants p inner join CoreCmsUser u on p.user_id=u.id where p.status=0 and p.reservation_id in ({sqlWhere})");
|
|
if (participants != null && participants.Count > 0)
|
|
{
|
|
var userBlacklist = new List<int>();
|
|
//如果用户登录了
|
|
userBlacklist = await _coreCmsUserBlacklistServices.GetUserBlacklists(userId);
|
|
//并且用户有黑名单数据
|
|
if (userBlacklist.Count > 0)
|
|
{
|
|
//查找并修改黑名单用户
|
|
foreach (var participant in participants.Where(it => userBlacklist.Contains(it.user_id)))
|
|
{
|
|
participant.UserBlackStatus = 1;
|
|
}
|
|
}
|
|
|
|
}
|
|
return participants;
|
|
}
|
|
return new List<SQReservationParticipantsApiDto>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载组局参与者信息
|
|
/// </summary>
|
|
/// <param name="list">预约信息</param>
|
|
/// <param name="userId">当前用户</param>
|
|
/// <param name="_dbBase"></param>
|
|
/// <param name="_coreCmsUserBlacklistServices"></param>
|
|
/// <param name="_mapper"></param>
|
|
/// <returns></returns>
|
|
public static async Task<bool> LoadSQReservationParticipantsApiDto(this List<SQReservationsBaseDto> list, int userId, SqlSugarScope _dbBase, ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices, List<SQRooms> rooms, IMapper _mapper)
|
|
{
|
|
var rIds = list.Select(it => it.id).ToList();
|
|
if (rIds != null && rIds.Count > 0)
|
|
{
|
|
string sqlWhere = string.Join(",", rIds);
|
|
var participants = await _dbBase.Ado.SqlQueryAsync<SQReservationParticipantsApiDto>($"select p.id,p.reservation_id,p.status,p.join_time,p.user_id, p.role,u.nickName UserName,u.avatarImage AvatarImage from SQReservationParticipants p inner join CoreCmsUser u on p.user_id=u.id where p.status=0 and p.reservation_id in ({sqlWhere})");
|
|
if (participants != null && participants.Count > 0)
|
|
{
|
|
|
|
if (userId > 0)
|
|
{
|
|
var userBlacklist = new List<int>();
|
|
//如果用户登录了
|
|
userBlacklist = await _coreCmsUserBlacklistServices.GetUserBlacklists(userId);
|
|
//并且用户有黑名单数据
|
|
if (userBlacklist.Count > 0)
|
|
{
|
|
//查找并修改黑名单用户
|
|
foreach (var participant in participants.Where(it => userBlacklist.Contains(it.user_id)))
|
|
{
|
|
participant.UserBlackStatus = 1;
|
|
}
|
|
}
|
|
}
|
|
foreach (var item in list)
|
|
{
|
|
var temp = participants.Where(it => it.reservation_id == item.id).OrderBy(it => it.role).ThenBy(it => it.status).ToList();
|
|
var dto = _mapper.Map<List<SQReservationParticipantsApiDto>>(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;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|