diff --git a/CoreCms.Net.IRepository/SQ/ISQReservationEvaluateRepository.cs b/CoreCms.Net.IRepository/SQ/ISQReservationEvaluateRepository.cs new file mode 100644 index 0000000..14ee6c3 --- /dev/null +++ b/CoreCms.Net.IRepository/SQ/ISQReservationEvaluateRepository.cs @@ -0,0 +1,103 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.IRepository +{ + /// + /// 对局评价表 工厂接口 + /// + public interface ISQReservationEvaluateRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + new Task InsertAsync(SQReservationEvaluate entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(SQReservationEvaluate entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(List entity); + + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + new Task DeleteByIdAsync(object id); + + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + new Task DeleteByIdsAsync(int[] ids); + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + /// + /// 更新cache + /// + Task> UpdateCaChe(); + + #endregion + + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + } +} diff --git a/CoreCms.Net.IServices/SQ/ISQReservationEvaluateServices.cs b/CoreCms.Net.IServices/SQ/ISQReservationEvaluateServices.cs new file mode 100644 index 0000000..1cddcd1 --- /dev/null +++ b/CoreCms.Net.IServices/SQ/ISQReservationEvaluateServices.cs @@ -0,0 +1,99 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.IServices +{ + /// + /// 对局评价表 服务工厂接口 + /// + public interface ISQReservationEvaluateServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + new Task InsertAsync(SQReservationEvaluate entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(SQReservationEvaluate entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + new Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + new Task DeleteByIdsAsync(int[] ids); + + #endregion + + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + /// + /// 更新cache + /// + Task> UpdateCaChe(); + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + #endregion + } +} diff --git a/CoreCms.Net.Model/Entities/SQ/SQReservationEvaluate.cs b/CoreCms.Net.Model/Entities/SQ/SQReservationEvaluate.cs new file mode 100644 index 0000000..8f59c24 --- /dev/null +++ b/CoreCms.Net.Model/Entities/SQ/SQReservationEvaluate.cs @@ -0,0 +1,128 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; + +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 对局评价表 + /// + public partial class SQReservationEvaluate + { + /// + /// 构造函数 + /// + public SQReservationEvaluate() + { + } + + /// + /// 主键 + /// + [Display(Name = "主键")] + + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 id { get; set; } + + + /// + /// 对局id + /// + [Display(Name = "对局id")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 reservation_id { get; set; } + + + /// + /// 用户id + /// + [Display(Name = "用户id")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 user_id { get; set; } + + /// + /// 被评价用户id + /// + [Display(Name = "被评价用户id")] + + [Required(ErrorMessage = "请输入{0}")] + public int to_user_id { get; set; } + + + /// + /// 角色 + /// + [Display(Name = "角色")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 role { get; set; } + + + /// + /// 牌品等级 + /// + [Display(Name = "牌品等级")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Decimal play_level { get; set; } + + + /// + /// 牌技等级 + /// + [Display(Name = "牌技等级")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Decimal skills_level { get; set; } + + + + + + /// + /// 评价时间 + /// + [Display(Name = "评价时间")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.DateTime created_at { get; set; } + + + } +} diff --git a/CoreCms.Net.Model/Entities/SQ/SQReservationParticipants.cs b/CoreCms.Net.Model/Entities/SQ/SQReservationParticipants.cs index 5df1f57..75609bd 100644 --- a/CoreCms.Net.Model/Entities/SQ/SQReservationParticipants.cs +++ b/CoreCms.Net.Model/Entities/SQ/SQReservationParticipants.cs @@ -132,5 +132,12 @@ namespace CoreCms.Net.Model.Entities /// [Display(Name = "是否需要退款。0 无需退款,未交押金,1 交押金,待退款,2,交押金,退款中,3 退款成功,9退款失败")] public System.Int32 is_refund { get; set; } + + /// + /// 是否赴约 + /// + [Display(Name = "是否赴约")] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 is_arrive { get; set; } } } diff --git a/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs b/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs index 1189d99..4214b6e 100644 --- a/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs +++ b/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs @@ -142,5 +142,21 @@ namespace CoreCms.Net.Model.Entities [SugarColumn(ColumnDescription = "删除标志 有数据就是删除")] [Required(ErrorMessage = "请输入{0}")] public System.Boolean isDelete { get; set; } + + + /// + /// 牌品等级 + /// + [Display(Name = "牌品等级")] + [Required(ErrorMessage = "请输入{0}")] + public System.Decimal play_level { get; set; } + + + /// + /// 牌技等级 + /// + [Display(Name = "牌技等级")] + [Required(ErrorMessage = "请输入{0}")] + public System.Decimal skills_level { get; set; } } } \ No newline at end of file diff --git a/CoreCms.Net.Model/ViewModels/SQ/SQReservationEvaluateDto.cs b/CoreCms.Net.Model/ViewModels/SQ/SQReservationEvaluateDto.cs new file mode 100644 index 0000000..31557c8 --- /dev/null +++ b/CoreCms.Net.Model/ViewModels/SQ/SQReservationEvaluateDto.cs @@ -0,0 +1,69 @@ +using SqlSugar; + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CoreCms.Net.Model.ViewModels.SQ; + +public class SQReservationEvaluateDto +{ + + /// + /// 对局id + /// + [Display(Name = "对局id")] + + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 reservation_id { get; set; } + + + /// + /// 被评价用户id + /// + [Display(Name = "被评价用户id")] + [Required(ErrorMessage = "请输入{0}")] + public int to_user_id { get; set; } + + + /// + /// 牌品等级 + /// + [Display(Name = "牌品等级")] + + [Required(ErrorMessage = "请输入{0}")] + public System.Decimal play_level { get; set; } + + + /// + /// 牌技等级 + /// + [Display(Name = "牌技等级")] + + [Required(ErrorMessage = "请输入{0}")] + public System.Decimal skills_level { get; set; } + + +} + +/// +/// +/// +public class SQReservationEvaluateFDto +{ + + public System.Decimal level { get; set; } + + + /// + /// + /// + [Display(Name = " ")] + + [Required(ErrorMessage = "请输入{0}")] + public int rs_count { get; set; } +} + diff --git a/CoreCms.Net.Model/ViewModels/SQ/SQReservationParticipantsDto.cs b/CoreCms.Net.Model/ViewModels/SQ/SQReservationParticipantsDto.cs index c5e71f6..7fc98fd 100644 --- a/CoreCms.Net.Model/ViewModels/SQ/SQReservationParticipantsDto.cs +++ b/CoreCms.Net.Model/ViewModels/SQ/SQReservationParticipantsDto.cs @@ -92,4 +92,20 @@ namespace CoreCms.Net.Model.ViewModels.SQ /// public int UserBlackStatus { get; set; } } + + /// + /// + /// + public class SQReservationParticipantsApiEavDto : SQReservationParticipantsApiDto + { + /// + /// + /// + public decimal play_level { get; set; } + + /// + /// + /// + public decimal skills_level { get; set; } + } } diff --git a/CoreCms.Net.Repository/SQ/SQReservationEvaluateRepository.cs b/CoreCms.Net.Repository/SQ/SQReservationEvaluateRepository.cs new file mode 100644 index 0000000..165925b --- /dev/null +++ b/CoreCms.Net.Repository/SQ/SQReservationEvaluateRepository.cs @@ -0,0 +1,245 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Caching.Manual; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.Repository +{ + /// + /// 对局评价表 接口实现 + /// + public class SQReservationEvaluateRepository : BaseRepository, ISQReservationEvaluateRepository + { + private readonly IUnitOfWork _unitOfWork; + public SQReservationEvaluateRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public new async Task InsertAsync(SQReservationEvaluate entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0; + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public new async Task UpdateAsync(SQReservationEvaluate entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await DbClient.Queryable().In(entity.id).SingleAsync(); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + //事物处理过程开始 + oldModel.id = entity.id; + oldModel.reservation_id = entity.reservation_id; + oldModel.user_id = entity.user_id; + oldModel.role = entity.role; + oldModel.play_level = entity.play_level; + oldModel.skills_level = entity.skills_level; + oldModel.is_arrive = entity.is_arrive; + oldModel.created_at = entity.created_at; + + //事物处理过程结束 + var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public new async Task UpdateAsync(List entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public new async Task DeleteByIdAsync(object id) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable(id).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public new async Task DeleteByIdsAsync(int[] ids) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + var cache = ManualDataCache.Instance.Get>(GlobalConstVars.CacheSQReservationEvaluate); + if (cache != null) + { + return cache; + } + return await UpdateCaChe(); + } + + /// + /// 更新cache + /// + public async Task> UpdateCaChe() + { + var list = await DbClient.Queryable().With(SqlWith.NoLock).ToListAsync(); + ManualDataCache.Instance.Set(GlobalConstVars.CacheSQReservationEvaluate, list); + return list; + } + + #endregion + + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + RefAsync totalCount = 0; + List page; + if (blUseNoLock) + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new SQReservationEvaluate + { + id = p.id, + reservation_id = p.reservation_id, + user_id = p.user_id, + role = p.role, + play_level = p.play_level, + skills_level = p.skills_level, + is_arrive = p.is_arrive, + created_at = p.created_at, + + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new SQReservationEvaluate + { + id = p.id, + reservation_id = p.reservation_id, + user_id = p.user_id, + role = p.role, + play_level = p.play_level, + skills_level = p.skills_level, + is_arrive = p.is_arrive, + created_at = p.created_at, + + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } +} diff --git a/CoreCms.Net.Services/SQ/SQReservationEvaluateServices.cs b/CoreCms.Net.Services/SQ/SQReservationEvaluateServices.cs new file mode 100644 index 0000000..4a93a2d --- /dev/null +++ b/CoreCms.Net.Services/SQ/SQReservationEvaluateServices.cs @@ -0,0 +1,137 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.Services +{ + /// + /// 对局评价表 接口实现 + /// + public class SQReservationEvaluateServices : BaseServices, ISQReservationEvaluateServices + { + private readonly ISQReservationEvaluateRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public SQReservationEvaluateServices(IUnitOfWork unitOfWork, ISQReservationEvaluateRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public new async Task InsertAsync(SQReservationEvaluate entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public new async Task UpdateAsync(SQReservationEvaluate entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public new async Task UpdateAsync(List entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public new async Task DeleteByIdAsync(object id) + { + return await _dal.DeleteByIdAsync(id); + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public new async Task DeleteByIdsAsync(int[] ids) + { + return await _dal.DeleteByIdsAsync(ids); + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + return await _dal.GetCaChe(); + } + + /// + /// 更新cache + /// + public async Task> UpdateCaChe() + { + return await _dal.UpdateCaChe(); + } + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + } + #endregion + + } +} diff --git a/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationEvaluateController.cs b/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationEvaluateController.cs new file mode 100644 index 0000000..7422496 --- /dev/null +++ b/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationEvaluateController.cs @@ -0,0 +1,646 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/12 16:38:57 + * Description: 暂无 + ***********************************************************************/ + + +using System; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.Entities.Expression; +using CoreCms.Net.Model.FromBody; +using CoreCms.Net.Model.ViewModels.UI; +using CoreCms.Net.Filter; +using CoreCms.Net.Loging; +using CoreCms.Net.IServices; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.Utility.Extensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using NPOI.HSSF.UserModel; +using SqlSugar; + +namespace CoreCms.Net.Web.Admin.Controllers +{ + /// + /// 对局评价表 + /// + [Description("对局评价表")] + [Route("api/[controller]/[action]")] + [ApiController] + [RequiredErrorForAdmin] + [Authorize] + public class SQReservationEvaluateController : ControllerBase + { + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly ISQReservationEvaluateServices _SQReservationEvaluateServices; + + /// + /// 构造函数 + /// + public SQReservationEvaluateController(IWebHostEnvironment webHostEnvironment + ,ISQReservationEvaluateServices SQReservationEvaluateServices + ) + { + _webHostEnvironment = webHostEnvironment; + _SQReservationEvaluateServices = SQReservationEvaluateServices; + } + + #region 获取列表============================================================ + // POST: Api/SQReservationEvaluate/GetPageList + /// + /// 获取列表 + /// + /// + [HttpPost] + [Description("获取列表")] + public async Task GetPageList() + { + var jm = new AdminUiCallBack(); + var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); + var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); + var where = PredicateBuilder.True(); + //获取排序字段 + var orderField = Request.Form["orderField"].FirstOrDefault(); + + Expression> orderEx = orderField switch + { + "id" => p => p.id,"reservation_id" => p => p.reservation_id,"user_id" => p => p.user_id,"role" => p => p.role,"play_level" => p => p.play_level,"skills_level" => p => p.skills_level,"is_arrive" => p => p.is_arrive,"created_at" => p => p.created_at, + _ => p => p.id + }; + + //设置排序方式 + var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); + var orderBy = orderDirection switch + { + "asc" => OrderByType.Asc, + "desc" => OrderByType.Desc, + _ => OrderByType.Desc + }; + //查询筛选 + + //主键 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //对局id int + var reservation_id = Request.Form["reservation_id"].FirstOrDefault().ObjectToInt(0); + if (reservation_id > 0) + { + where = where.And(p => p.reservation_id == reservation_id); + } + //用户id int + var user_id = Request.Form["user_id"].FirstOrDefault().ObjectToInt(0); + if (user_id > 0) + { + where = where.And(p => p.user_id == user_id); + } + //角色 int + var role = Request.Form["role"].FirstOrDefault().ObjectToInt(0); + if (role > 0) + { + where = where.And(p => p.role == role); + } + //牌品等级 decimal + var play_level = Request.Form["play_level"].FirstOrDefault().ObjectToDecimal(0); + if (play_level > 0) + { + where = where.And(p => p.play_level == play_level); + } + //牌技等级 decimal + var skills_level = Request.Form["skills_level"].FirstOrDefault().ObjectToDecimal(0); + if (skills_level > 0) + { + where = where.And(p => p.skills_level == skills_level); + } + //是否赴约 int + var is_arrive = Request.Form["is_arrive"].FirstOrDefault().ObjectToInt(0); + if (is_arrive > 0) + { + where = where.And(p => p.is_arrive == is_arrive); + } + //评价时间 datetime + var created_at = Request.Form["created_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(created_at)) + { + if (created_at.Contains("到")) + { + var dts = created_at.Split("到"); + var dtStart = dts[0].Trim().ObjectToDate(); + where = where.And(p => p.created_at > dtStart); + var dtEnd = dts[1].Trim().ObjectToDate(); + where = where.And(p => p.created_at < dtEnd); + } + else + { + var dt = created_at.ObjectToDate(); + where = where.And(p => p.created_at > dt); + } + } + //获取数据 + var list = await _SQReservationEvaluateServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); + //返回数据 + jm.data = list; + jm.code = 0; + jm.count = list.TotalCount; + jm.msg = "数据调用成功!"; + return jm; + } + #endregion + + #region 首页数据============================================================ + // POST: Api/SQReservationEvaluate/GetIndex + /// + /// 首页数据 + /// + /// + [HttpPost] + [Description("首页数据")] + public AdminUiCallBack GetIndex() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建数据============================================================ + // POST: Api/SQReservationEvaluate/GetCreate + /// + /// 创建数据 + /// + /// + [HttpPost] + [Description("创建数据")] + public AdminUiCallBack GetCreate() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建提交============================================================ + // POST: Api/SQReservationEvaluate/DoCreate + /// + /// 创建提交 + /// + /// + /// + [HttpPost] + [Description("创建提交")] + public async Task DoCreate([FromBody]SQReservationEvaluate entity) + { + var jm = await _SQReservationEvaluateServices.InsertAsync(entity); + return jm; + } + #endregion + + #region 编辑数据============================================================ + // POST: Api/SQReservationEvaluate/GetEdit + /// + /// 编辑数据 + /// + /// + /// + [HttpPost] + [Description("编辑数据")] + public async Task GetEdit([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationEvaluateServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 编辑提交============================================================ + // POST: Api/SQReservationEvaluate/Edit + /// + /// 编辑提交 + /// + /// + /// + [HttpPost] + [Description("编辑提交")] + public async Task DoEdit([FromBody]SQReservationEvaluate entity) + { + var jm = await _SQReservationEvaluateServices.UpdateAsync(entity); + return jm; + } + #endregion + + #region 删除数据============================================================ + // POST: Api/SQReservationEvaluate/DoDelete/10 + /// + /// 单选删除 + /// + /// + /// + [HttpPost] + [Description("单选删除")] + public async Task DoDelete([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationEvaluateServices.ExistsAsync(p => p.id == entity.id, true); + if (!model) + { + jm.msg = GlobalConstVars.DataisNo; + return jm; + } + jm = await _SQReservationEvaluateServices.DeleteByIdAsync(entity.id); + + return jm; + } + #endregion + + #region 批量删除============================================================ + // POST: Api/SQReservationEvaluate/DoBatchDelete/10,11,20 + /// + /// 批量删除 + /// + /// + /// + [HttpPost] + [Description("批量删除")] + public async Task DoBatchDelete([FromBody]FMArrayIntIds entity) + { + var jm = await _SQReservationEvaluateServices.DeleteByIdsAsync(entity.id); + return jm; + } + + #endregion + + #region 预览数据============================================================ + // POST: Api/SQReservationEvaluate/GetDetails/10 + /// + /// 预览数据 + /// + /// + /// + [HttpPost] + [Description("预览数据")] + public async Task GetDetails([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationEvaluateServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 选择导出============================================================ + // POST: Api/SQReservationEvaluate/SelectExportExcel/10 + /// + /// 选择导出 + /// + /// + /// + [HttpPost] + [Description("选择导出")] + public async Task SelectExportExcel([FromBody]FMArrayIntIds entity) + { + var jm = new AdminUiCallBack(); + + //创建Excel文件的对象 + var book = new HSSFWorkbook(); + //添加一个sheet + var mySheet = book.CreateSheet("Sheet1"); + //获取list数据 + var listModel = await _SQReservationEvaluateServices.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id, OrderByType.Asc, true); + //给sheet1添加第一行的头部标题 + var headerRow = mySheet.CreateRow(0); + var headerStyle = ExcelHelper.GetHeaderStyle(book); + + var cell0 = headerRow.CreateCell(0); + cell0.SetCellValue("主键"); + cell0.CellStyle = headerStyle; + mySheet.SetColumnWidth(0, 10 * 256); + + var cell1 = headerRow.CreateCell(1); + cell1.SetCellValue("对局id"); + cell1.CellStyle = headerStyle; + mySheet.SetColumnWidth(1, 10 * 256); + + var cell2 = headerRow.CreateCell(2); + cell2.SetCellValue("用户id"); + cell2.CellStyle = headerStyle; + mySheet.SetColumnWidth(2, 10 * 256); + + var cell3 = headerRow.CreateCell(3); + cell3.SetCellValue("角色"); + cell3.CellStyle = headerStyle; + mySheet.SetColumnWidth(3, 10 * 256); + + var cell4 = headerRow.CreateCell(4); + cell4.SetCellValue("牌品等级"); + cell4.CellStyle = headerStyle; + mySheet.SetColumnWidth(4, 10 * 256); + + var cell5 = headerRow.CreateCell(5); + cell5.SetCellValue("牌技等级"); + cell5.CellStyle = headerStyle; + mySheet.SetColumnWidth(5, 10 * 256); + + var cell6 = headerRow.CreateCell(6); + cell6.SetCellValue("是否赴约"); + cell6.CellStyle = headerStyle; + mySheet.SetColumnWidth(6, 10 * 256); + + var cell7 = headerRow.CreateCell(7); + cell7.SetCellValue("评价时间"); + cell7.CellStyle = headerStyle; + mySheet.SetColumnWidth(7, 10 * 256); + + headerRow.Height = 30 * 20; + var commonCellStyle = ExcelHelper.GetCommonStyle(book); + + //将数据逐步写入sheet1各个行 + for (var i = 0; i < listModel.Count; i++) + { + var rowTemp = mySheet.CreateRow(i + 1); + + var rowTemp0 = rowTemp.CreateCell(0); + rowTemp0.SetCellValue(listModel[i].id.ToString()); + rowTemp0.CellStyle = commonCellStyle; + + var rowTemp1 = rowTemp.CreateCell(1); + rowTemp1.SetCellValue(listModel[i].reservation_id.ToString()); + rowTemp1.CellStyle = commonCellStyle; + + var rowTemp2 = rowTemp.CreateCell(2); + rowTemp2.SetCellValue(listModel[i].user_id.ToString()); + rowTemp2.CellStyle = commonCellStyle; + + var rowTemp3 = rowTemp.CreateCell(3); + rowTemp3.SetCellValue(listModel[i].role.ToString()); + rowTemp3.CellStyle = commonCellStyle; + + var rowTemp4 = rowTemp.CreateCell(4); + rowTemp4.SetCellValue(listModel[i].play_level.ToString()); + rowTemp4.CellStyle = commonCellStyle; + + var rowTemp5 = rowTemp.CreateCell(5); + rowTemp5.SetCellValue(listModel[i].skills_level.ToString()); + rowTemp5.CellStyle = commonCellStyle; + + var rowTemp6 = rowTemp.CreateCell(6); + rowTemp6.SetCellValue(listModel[i].is_arrive.ToString()); + rowTemp6.CellStyle = commonCellStyle; + + var rowTemp7 = rowTemp.CreateCell(7); + rowTemp7.SetCellValue(listModel[i].created_at.ToString()); + rowTemp7.CellStyle = commonCellStyle; + + } + // 导出excel + string webRootPath = _webHostEnvironment.WebRootPath; + string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; + string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SQReservationEvaluate导出(选择结果).xls"; + string filePath = webRootPath + tpath; + DirectoryInfo di = new DirectoryInfo(filePath); + if (!di.Exists) + { + di.Create(); + } + FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); + book.Write(fileHssf); + fileHssf.Close(); + + jm.code = 0; + jm.msg = GlobalConstVars.ExcelExportSuccess; + jm.data = tpath + fileName; + + return jm; + } + #endregion + + #region 查询导出============================================================ + // POST: Api/SQReservationEvaluate/QueryExportExcel/10 + /// + /// 查询导出 + /// + /// + [HttpPost] + [Description("查询导出")] + public async Task QueryExportExcel() + { + var jm = new AdminUiCallBack(); + + var where = PredicateBuilder.True(); + //查询筛选 + + //主键 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //对局id int + var reservation_id = Request.Form["reservation_id"].FirstOrDefault().ObjectToInt(0); + if (reservation_id > 0) + { + where = where.And(p => p.reservation_id == reservation_id); + } + //用户id int + var user_id = Request.Form["user_id"].FirstOrDefault().ObjectToInt(0); + if (user_id > 0) + { + where = where.And(p => p.user_id == user_id); + } + //角色 int + var role = Request.Form["role"].FirstOrDefault().ObjectToInt(0); + if (role > 0) + { + where = where.And(p => p.role == role); + } + //牌品等级 decimal + var play_level = Request.Form["play_level"].FirstOrDefault().ObjectToDecimal(0); + if (play_level > 0) + { + where = where.And(p => p.play_level == play_level); + } + //牌技等级 decimal + var skills_level = Request.Form["skills_level"].FirstOrDefault().ObjectToDecimal(0); + if (skills_level > 0) + { + where = where.And(p => p.skills_level == skills_level); + } + //是否赴约 int + var is_arrive = Request.Form["is_arrive"].FirstOrDefault().ObjectToInt(0); + if (is_arrive > 0) + { + where = where.And(p => p.is_arrive == is_arrive); + } + //评价时间 datetime + var created_at = Request.Form["created_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(created_at)) + { + var dt = created_at.ObjectToDate(); + where = where.And(p => p.created_at > dt); + } + //获取数据 + //创建Excel文件的对象 + var book = new HSSFWorkbook(); + //添加一个sheet + var mySheet = book.CreateSheet("Sheet1"); + //获取list数据 + var listModel = await _SQReservationEvaluateServices.QueryListByClauseAsync(where, p => p.id, OrderByType.Asc, true); + //给sheet1添加第一行的头部标题 + var headerRow = mySheet.CreateRow(0); + var headerStyle = ExcelHelper.GetHeaderStyle(book); + + var cell0 = headerRow.CreateCell(0); + cell0.SetCellValue("主键"); + cell0.CellStyle = headerStyle; + mySheet.SetColumnWidth(0, 10 * 256); + + var cell1 = headerRow.CreateCell(1); + cell1.SetCellValue("对局id"); + cell1.CellStyle = headerStyle; + mySheet.SetColumnWidth(1, 10 * 256); + + var cell2 = headerRow.CreateCell(2); + cell2.SetCellValue("用户id"); + cell2.CellStyle = headerStyle; + mySheet.SetColumnWidth(2, 10 * 256); + + var cell3 = headerRow.CreateCell(3); + cell3.SetCellValue("角色"); + cell3.CellStyle = headerStyle; + mySheet.SetColumnWidth(3, 10 * 256); + + var cell4 = headerRow.CreateCell(4); + cell4.SetCellValue("牌品等级"); + cell4.CellStyle = headerStyle; + mySheet.SetColumnWidth(4, 10 * 256); + + var cell5 = headerRow.CreateCell(5); + cell5.SetCellValue("牌技等级"); + cell5.CellStyle = headerStyle; + mySheet.SetColumnWidth(5, 10 * 256); + + var cell6 = headerRow.CreateCell(6); + cell6.SetCellValue("是否赴约"); + cell6.CellStyle = headerStyle; + mySheet.SetColumnWidth(6, 10 * 256); + + var cell7 = headerRow.CreateCell(7); + cell7.SetCellValue("评价时间"); + cell7.CellStyle = headerStyle; + mySheet.SetColumnWidth(7, 10 * 256); + + + headerRow.Height = 30 * 20; + var commonCellStyle = ExcelHelper.GetCommonStyle(book); + + //将数据逐步写入sheet1各个行 + for (var i = 0; i < listModel.Count; i++) + { + var rowTemp = mySheet.CreateRow(i + 1); + + + var rowTemp0 = rowTemp.CreateCell(0); + rowTemp0.SetCellValue(listModel[i].id.ToString()); + rowTemp0.CellStyle = commonCellStyle; + + + + var rowTemp1 = rowTemp.CreateCell(1); + rowTemp1.SetCellValue(listModel[i].reservation_id.ToString()); + rowTemp1.CellStyle = commonCellStyle; + + + + var rowTemp2 = rowTemp.CreateCell(2); + rowTemp2.SetCellValue(listModel[i].user_id.ToString()); + rowTemp2.CellStyle = commonCellStyle; + + + + var rowTemp3 = rowTemp.CreateCell(3); + rowTemp3.SetCellValue(listModel[i].role.ToString()); + rowTemp3.CellStyle = commonCellStyle; + + + + var rowTemp4 = rowTemp.CreateCell(4); + rowTemp4.SetCellValue(listModel[i].play_level.ToString()); + rowTemp4.CellStyle = commonCellStyle; + + + + var rowTemp5 = rowTemp.CreateCell(5); + rowTemp5.SetCellValue(listModel[i].skills_level.ToString()); + rowTemp5.CellStyle = commonCellStyle; + + + + var rowTemp6 = rowTemp.CreateCell(6); + rowTemp6.SetCellValue(listModel[i].is_arrive.ToString()); + rowTemp6.CellStyle = commonCellStyle; + + + + var rowTemp7 = rowTemp.CreateCell(7); + rowTemp7.SetCellValue(listModel[i].created_at.ToString()); + rowTemp7.CellStyle = commonCellStyle; + + + } + // 写入到excel + string webRootPath = _webHostEnvironment.WebRootPath; + string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; + string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SQReservationEvaluate导出(查询结果).xls"; + string filePath = webRootPath + tpath; + DirectoryInfo di = new DirectoryInfo(filePath); + if (!di.Exists) + { + di.Create(); + } + FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); + book.Write(fileHssf); + fileHssf.Close(); + + jm.code = 0; + jm.msg = GlobalConstVars.ExcelExportSuccess; + jm.data = tpath + fileName; + + return jm; + } + #endregion + + + + } +} diff --git a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj index f897671..7f06bb7 100644 --- a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj +++ b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj @@ -1,4 +1,4 @@ - + net8.0 diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/create.html new file mode 100644 index 0000000..d3af008 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/create.html @@ -0,0 +1,91 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/details.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/details.html new file mode 100644 index 0000000..b16578f --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/details.html @@ -0,0 +1,99 @@ + + \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/edit.html new file mode 100644 index 0000000..705bdf4 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/edit.html @@ -0,0 +1,91 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/index.html new file mode 100644 index 0000000..6263e0c --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationevaluate/index.html @@ -0,0 +1,401 @@ +对局评价表 + +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + diff --git a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs index 9f38f8f..2c28eed 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs @@ -26,6 +26,7 @@ using System.Linq; using System.Threading.Tasks; using CoreCms.Net.Services.SQ; using CoreCms.Net.Utility.Extensions; +using ToolGood.Words.internals; namespace CoreCms.Net.Web.WebApi.Controllers; /// @@ -47,6 +48,8 @@ public class SQController : ControllerBase private readonly SqlSugarScope _dbBase; private readonly ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices; + private readonly ISQReservationEvaluateServices _sQReservationEvaluateServices; + /// /// 构造函数 /// @@ -61,6 +64,9 @@ public class SQController : ControllerBase , IHttpContextUser user , IUnitOfWork unitOfWork , ICoreCmsUserBlacklistServices coreCmsUserBlacklistServices + , +ISQReservationEvaluateServices sQReservationEvaluateServices + ) { _webHostEnvironment = webHostEnvironment; @@ -74,6 +80,7 @@ public class SQController : ControllerBase _user = user; _dbBase = unitOfWork.GetDbClient(); _coreCmsUserBlacklistServices = coreCmsUserBlacklistServices; + _sQReservationEvaluateServices = sQReservationEvaluateServices; } @@ -161,4 +168,146 @@ public class SQController : ControllerBase }; } + + /// + /// 获取预约评价 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task GetEvaluateServices([FromQuery] int reId) + { + var userId = _user.ID; + var list = await _sQReservationEvaluateServices.QueryListByClauseAsync(it => it.reservation_id == reId && it.user_id == userId); + var participants = await _dbBase.Ado.SqlQueryAsync($"select p.id,p.reservation_id,p.status,p.join_time,p.user_id, p.role,u.nickName UserName,u.avatarImage AvatarImage,ISNULL(u.play_level,4) play_level,ISNULL(u.skills_level,4) skills_level from SQReservationParticipants p inner join CoreCmsUser u on p.user_id=u.id where p.status=0 and p.reservation_id ={reId} and p.is_arrive=1 "); + if (participants == null) + { + return new WebApiDto() + { + Code = 0, + Data = null + }; + } + List obj = new List(); + foreach (var item in participants) + { + if (item.user_id == userId) + { + continue; + } + var is_evaluate = false; + decimal play_level = 0; + decimal skills_level = 0; + decimal user_play_level = 4; + decimal user_skills_level = 4; + DateTime? now = null; + if (list.Count > 0) + { + var e = list.Find(it => it.to_user_id == item.user_id); + if (e != null) + { + is_evaluate = true; + play_level = e.play_level; + skills_level = e.skills_level; + now = e.created_at; + user_play_level = e.play_level; + user_skills_level = e.skills_level; + } + } + var o = new + { + item.UserName, + item.user_id, + item.AvatarImage, + user_play_level, + user_skills_level, + is_evaluate, + play_level, + skills_level, + evaluate_at = now + }; + obj.Add(o); + } + return new WebApiDto() + { + Code = 0, + Data = obj + }; + } + + + /// + /// + /// + /// + /// + [HttpPost] + [Authorize] + public async Task AddEvaluateServices([FromBody] SQReservationEvaluateDto evaluate) + { + var userId = _user.ID; + var reId = evaluate.reservation_id; + var list = await _sQReservationEvaluateServices.QueryListByClauseAsync(it => it.reservation_id == reId && it.user_id == userId); + var participants = await _dbBase.Ado.SqlQueryAsync($"select p.id,p.reservation_id,p.status,p.join_time,p.user_id, p.role,u.nickName UserName,u.avatarImage AvatarImage,ISNULL(u.play_level,4) play_level,ISNULL(u.skills_level,4) skills_level from SQReservationParticipants p inner join CoreCmsUser u on p.user_id=u.id where p.status=0 and p.reservation_id ={reId} and p.is_arrive=1 "); + if (participants == null) + { + return new WebApiDto() + { + Code = 0, + Data = null + }; + } + List obj = new List(); + var p = participants.Find(it => it.user_id == evaluate.to_user_id); + if (p == null) + { + return new WebApiDto() + { + Code = 500, + Data = null, + Msg = "未找到对局记录" + }; + } + SQReservationEvaluate sQReservationEvaluate = new SQReservationEvaluate() + { + created_at = DateTime.Now, + play_level = evaluate.play_level, + reservation_id = evaluate.reservation_id, + role = p.role, + skills_level = evaluate.skills_level, + to_user_id = evaluate.to_user_id, + user_id = userId, + }; + await _sQReservationEvaluateServices.InsertAsync(sQReservationEvaluate); + var play_level = _dbBase.Ado.SqlQuerySingle($"select ISNULL(sum(play_level),0) level,count(1) rscount from SQReservationEvaluate where to_user_id={evaluate.to_user_id} "); + + var skills_level = _dbBase.Ado.SqlQuerySingle($"select ISNULL(sum(skills_level),0) level,count(1) rscount from SQReservationEvaluate where to_user_id={evaluate.to_user_id} "); + //先加4 + play_level.level += 4; + if (play_level.rs_count > 0) + { + play_level.level = play_level.level / play_level.rs_count; + } + //先加4 + skills_level.level += 4; + if (skills_level.rs_count > 0) + { + skills_level.level = skills_level.level / skills_level.rs_count; + } + if (play_level.rs_count > 0 || skills_level.rs_count > 0) + { + await _userServices.UpdateAsync(it => new CoreCmsUser + { + play_level = play_level.level, + skills_level = skills_level.level + }, it => it.id == evaluate.to_user_id); + } + return new WebApiDto() + { + Code = 0, + Data = null, + Msg = "评价成功" + }; + } }