diff --git a/YD_Event.Application/Client/MyController.cs b/YD_Event.Application/Client/MyController.cs
index 0c320f0..9bdec08 100644
--- a/YD_Event.Application/Client/MyController.cs
+++ b/YD_Event.Application/Client/MyController.cs
@@ -187,6 +187,8 @@ public class MyController : IDynamicApiController
user.IdCardImageUrl = input.IdCardImageUrl;
user.IdCardBackImageUrl = input.IdCardBackImageUrl;
user.PassportPhotoUrl = null; // 清空护照图片
+ user.Gender = (Gender)input.Gender.Value;
+ user.BirthDate = input.BirthDate.Value;
}
else
{
diff --git a/YD_Event.Application/Event/Dtos/ScoreDtos.cs b/YD_Event.Application/Event/Dtos/ScoreDtos.cs
index 9347f4b..70189c6 100644
--- a/YD_Event.Application/Event/Dtos/ScoreDtos.cs
+++ b/YD_Event.Application/Event/Dtos/ScoreDtos.cs
@@ -66,10 +66,15 @@ public class ScoreListOutput
public string UnitName { get; set; }
///
- /// 名次
+ /// 名次(数字)
///
public int Rank { get; set; }
+ ///
+ /// 名次(汉字)
+ ///
+ public string RankText { get; set; }
+
///
/// 性别
///
@@ -250,13 +255,13 @@ public class ScoreImportDto
///
/// 名次(数字)
///
- [ExcelColumnName("名次")]
+ [ExcelColumnName("名次(数字)")]
public int Rank { get; set; }
///
- /// 名次说明(文字描述,如"冠军"、"亚军"等)
+ /// 名次(汉字)
///
- [ExcelColumnName("名次说明")]
+ [ExcelColumnName("名次(汉字)")]
public string RankText { get; set; }
}
diff --git a/YD_Event.Application/Event/EventScoreService.cs b/YD_Event.Application/Event/EventScoreService.cs
index 1efaa9b..e21e3b0 100644
--- a/YD_Event.Application/Event/EventScoreService.cs
+++ b/YD_Event.Application/Event/EventScoreService.cs
@@ -4,8 +4,12 @@ using Microsoft.Extensions.Logging;
using YD_Event.Application.Event.Dtos;
using YD_Event.Core.Entities;
using YD_Event.Core.Enum;
+using YD_Event.Core.Domain.Export;
using MiniExcelLibs;
using SqlSugar;
+using OfficeOpenXml;
+using OfficeOpenXml.Style;
+using System.Drawing;
namespace YD_Event.Application.Event;
@@ -14,11 +18,40 @@ namespace YD_Event.Application.Event;
///
public class EventScoreService : BaseService, ITransient
{
+ private static readonly string[] ChineseNumbers = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" };
+
+ ///
+ /// 将数字名次转换为汉字形式
+ ///
+ private static string ConvertRankToChinese(int rank)
+ {
+ if (rank <= 0)
+ return string.Empty;
+
+ if (rank <= 10)
+ return $"第{ChineseNumbers[rank]}名";
+
+ if (rank < 20)
+ return $"第十{ChineseNumbers[rank % 10]}名";
+
+ if (rank % 10 == 0)
+ return $"第{ChineseNumbers[rank / 10]}十名";
+
+ return $"第{ChineseNumbers[rank / 10]}十{ChineseNumbers[rank % 10]}名";
+ }
+
private readonly ISqlSugarRepository _personRepository;
private readonly ISqlSugarRepository _resultRepository;
private readonly ISqlSugarRepository _certificateRepository;
private readonly ISqlSugarRepository _registrationRepository;
private readonly ISqlSugarRepository _templateRepository;
+ private readonly ISqlSugarRepository _projectRepository;
+ private readonly ISqlSugarRepository _teamMemberRepository;
+ private readonly ISqlSugarRepository _eventRepository;
+ private readonly ISqlSugarRepository _pointsRuleRepository;
+ private readonly ISqlSugarRepository _pointsRuleDetailRepository;
+ private readonly ISqlSugarRepository _pointsRecordRepository;
+ private readonly ISqlSugarRepository _appUserRepository;
private readonly IIdGenerator _idGenerator;
private readonly ILogger _logger;
@@ -28,6 +61,13 @@ public class EventScoreService : BaseService, ITransient
ISqlSugarRepository certificateRepository,
ISqlSugarRepository registrationRepository,
ISqlSugarRepository templateRepository,
+ ISqlSugarRepository projectRepository,
+ ISqlSugarRepository teamMemberRepository,
+ ISqlSugarRepository eventRepository,
+ ISqlSugarRepository pointsRuleRepository,
+ ISqlSugarRepository pointsRuleDetailRepository,
+ ISqlSugarRepository pointsRecordRepository,
+ ISqlSugarRepository appUserRepository,
IIdGenerator idGenerator,
ILogger logger) : base(resultRepository)
{
@@ -36,6 +76,13 @@ public class EventScoreService : BaseService, ITransient
_certificateRepository = certificateRepository;
_registrationRepository = registrationRepository;
_templateRepository = templateRepository;
+ _projectRepository = projectRepository;
+ _teamMemberRepository = teamMemberRepository;
+ _eventRepository = eventRepository;
+ _pointsRuleRepository = pointsRuleRepository;
+ _pointsRuleDetailRepository = pointsRuleDetailRepository;
+ _pointsRecordRepository = pointsRecordRepository;
+ _appUserRepository = appUserRepository;
_idGenerator = idGenerator;
_logger = logger;
}
@@ -46,7 +93,7 @@ public class EventScoreService : BaseService, ITransient
[DisplayName("运动员成绩列表")]
public async Task> PageAthlete(ScoreQueryInput input)
{
- return await _personRepository.AsQueryable()
+ var pageResult = await _personRepository.AsQueryable()
.LeftJoin((p, r) => p.RegistrationId == r.Id)
.LeftJoin((p, r, res) => p.Id == res.RegistrationPersonId)
.LeftJoin((p, r, res, c) => res.Id == c.ResultId)
@@ -68,32 +115,79 @@ public class EventScoreService : BaseService, ITransient
CertificateId = c.Id
})
.ToPagedListAsync(input);
+
+ foreach (var item in pageResult.Rows)
+ {
+ item.RankText = ConvertRankToChinese(item.Rank);
+ }
+
+ return pageResult;
}
///
/// 教练/领队列表
///
+ ///
+ /// 通过运动员所在的团队关联获取教练和领队人员信息
+ ///
[DisplayName("教练领队列表")]
public async Task> PageCoachLeader(CoachLeaderQueryInput input)
{
- return await _personRepository.AsQueryable()
- .LeftJoin((p, c) => p.Id == c.ParticipationRecordId)
- .InnerJoin((p, c, r) => p.RegistrationId == r.Id)
- .Where((p, c, r) => r.EventId == input.EventId && p.PersonType == input.PersonType)
- .WhereIF(!string.IsNullOrWhiteSpace(input.Name), p => p.Name.Contains(input.Name))
- .WhereIF(!string.IsNullOrWhiteSpace(input.Mobile), p => p.Phone.Contains(input.Mobile))
- .WhereIF(input.Gender.HasValue, p => p.Gender == input.Gender.Value)
- .Select((p, c) => new CoachLeaderListOutput
+ // 步骤1:获取该赛事的所有运动员的 UserId
+ var athleteUserIds = await _personRepository.AsQueryable()
+ .InnerJoin((p, r) => p.RegistrationId == r.Id)
+ .Where((p, r) => r.EventId == input.EventId && p.PersonType == PersonType.Athlete)
+ .Select(p => p.UserId)
+ .ToListAsync();
+
+ if (!athleteUserIds.Any())
+ {
+ return new PageResult();
+ }
+
+ // 步骤2:通过运动员的 UserId 找到对应的 TeamId
+ var teamIds = await _teamMemberRepository.AsQueryable()
+ .Where(tm => athleteUserIds.Contains(tm.UserId) && !tm.DeleteMark)
+ .Select(tm => tm.TeamId)
+ .Distinct()
+ .ToListAsync();
+
+ if (!teamIds.Any())
+ {
+ return new PageResult();
+ }
+
+ // 步骤3:通过 TeamId 获取同团队的教练/领队的 UserId
+ var coachLeaderUserIds = await _teamMemberRepository.AsQueryable()
+ .Where(tm => teamIds.Contains(tm.TeamId) && tm.PersonType == input.PersonType && !tm.DeleteMark)
+ .Select(tm => tm.UserId)
+ .Distinct()
+ .ToListAsync();
+
+ if (!coachLeaderUserIds.Any())
+ {
+ return new PageResult();
+ }
+
+ // 步骤4:从 AppUser 表获取教练/领队的详细信息(需要关联查询)
+ var userQuery = _appUserRepository.AsQueryable()
+ .Where(p => coachLeaderUserIds.Contains(p.Id))
+ .Where(p=> p.PersonType == input.PersonType);
+
+ var pageResult = await userQuery
+ .Select(p => new CoachLeaderListOutput
{
Id = p.Id,
Name = p.Name,
Age = p.Age,
- Gender = p.Gender.ToString(),
+ Gender = p.Gender.Description(),
IdCardNumber = p.IdCard,
Mobile = p.Phone,
- CertificateId = c.Id
+ CertificateId = 0 // 需要单独查询,此处先设为0
})
.ToPagedListAsync(input);
+
+ return pageResult;
}
///
@@ -142,7 +236,7 @@ public class EventScoreService : BaseService, ITransient
p.ProjectName,
p.GroupName,
p.RegistrationId,
- p.ProjectId
+ p.ProjectId
})
.ToListAsync();
@@ -152,6 +246,11 @@ public class EventScoreService : BaseService, ITransient
var personDict = allPersons
.GroupBy(p => $"{p.Name}_{p.ProjectName}_{p.GroupName}")
.ToDictionary(g => g.Key, g => g.First());
+
+ // 预加载项目信息,用于获取项目类型名称
+ var projectIds = allPersons.Select(p => p.ProjectId).Distinct().ToList();
+ var projects = await _projectRepository.GetListAsync(x => projectIds.Contains(x.Id));
+ var projectDict = projects.ToDictionary(p => p.Id, p => p.ProjectType.Description());
// 步骤3:预加载该赛事的所有成绩记录
var personIds = allPersons.Select(p => p.Id).ToList();
@@ -182,6 +281,7 @@ public class EventScoreService : BaseService, ITransient
existingResult.Score = row.Score;
existingResult.Rank = row.Rank;
existingResult.Remark = row.RankText;
+ existingResult.ProjectTypeName = projectDict.TryGetValue(person.ProjectId, out var projectTypeName) ? projectTypeName : string.Empty;
existingResult.UpdatedTime = now;
resultsToUpdate.Add(existingResult);
}
@@ -197,6 +297,7 @@ public class EventScoreService : BaseService, ITransient
ProjectId = person.ProjectId,
ParticipantName = person.Name,
GroupName = person.GroupName,
+ ProjectTypeName = projectDict.TryGetValue(person.ProjectId, out var projectTypeName) ? projectTypeName : string.Empty,
Score = row.Score,
Rank = row.Rank,
Remark = row.RankText,
@@ -370,35 +471,29 @@ public class EventScoreService : BaseService, ITransient
///
/// 查看证书接口
///
- /// 报名人员ID (EventRegistrationPerson的Id)
+ /// 输入参数
/// 证书详情
[DisplayName("查看证书")]
- [HttpGet("/api/EventScore/GetCertificateDetail/{id}")]
- public async Task GetCertificateDetail([FromRoute] long id)
+ public async Task
+
+
+ 成绩模板导出器
+
+
导出证书
@@ -7550,6 +7568,16 @@
验证导入数据
+
+
+ 发放积分输入模型
+
+
+
+
+ 发放积分
+
+
赛事管理服务
@@ -7659,6 +7687,36 @@
支付超时处理后台服务
+
+
+ 处理微信未支付订单:定期检查并更新订单状态
+
+
+
+
+ 处理微信支付成功的订单
+
+
+
+
+ 处理微信支付关闭的订单
+
+
+
+
+ 处理微信退款中的订单
+
+
+
+
+ 处理微信退款成功的订单
+
+
+
+
+ 处理微信退款失败的订单
+
+
统一报名处理服务