diff --git a/YD_Event.Application/AppUser/AppUserService.cs b/YD_Event.Application/AppUser/AppUserService.cs index 8335787..93e54ff 100644 --- a/YD_Event.Application/AppUser/AppUserService.cs +++ b/YD_Event.Application/AppUser/AppUserService.cs @@ -171,8 +171,9 @@ public class AppUserService : BaseService, ITransient && !x.DeleteMark) .FirstAsync(); - AppUserEntity entity; + AppUserEntity? entity = null; bool isUnitTransfer = false; + bool isNewRecord = false; long? originalMerchantId = null; if (existingInOtherUnit != null) @@ -182,6 +183,29 @@ public class AppUserService : BaseService, ITransient entity = existingInOtherUnit; originalMerchantId = entity.MerchantCertificationId; } + else + { + // 检查是否存在相同手机号但还未加入任何单位的记录(小程序注册的用户) + var existingWithoutUnit = await _appUserRep.AsQueryable() + .Where(x => x.Mobile == input.Mobile + && x.PersonType == input.PersonType + && x.MerchantCertificationId == null + && !x.DeleteMark) + .FirstAsync(); + + if (existingWithoutUnit != null) + { + // 找到已存在但未加入任何单位的记录,复用该记录 + entity = existingWithoutUnit; + entity.UpdatedUserId = _authManager.UserId; + entity.UpdatedTime = DateTime.Now; + } + else + { + // 没有找到任何记录,标记为新增 + isNewRecord = true; + } + } if (input.Id.HasValue) { @@ -206,7 +230,7 @@ public class AppUserService : BaseService, ITransient entity.UpdatedUserId = _authManager.UserId; entity.UpdatedTime = DateTime.Now; } - else + else if (isNewRecord) { // 新增模式:检查本单位内是否有相同手机号且相同类型的记录 var existingInSameUnit = await _appUserRep.AsQueryable() diff --git a/YD_Event.Application/Client/Dtos/EventClientDtos.cs b/YD_Event.Application/Client/Dtos/EventClientDtos.cs index d2f58d1..5e919cd 100644 --- a/YD_Event.Application/Client/Dtos/EventClientDtos.cs +++ b/YD_Event.Application/Client/Dtos/EventClientDtos.cs @@ -14,7 +14,7 @@ public class EventClientQueryInput : Pagination public string? Keyword { get; set; } /// - /// 状态筛选:0-全部 1-报名中 2-比赛中 3-已结束 + /// 状态筛选:0-全部 1-报名中 3-比赛中 4-已结束 /// public int Status { get; set; } = 0; diff --git a/YD_Event.Application/Client/EventClientController.cs b/YD_Event.Application/Client/EventClientController.cs index 9fe7731..7a1fe9b 100644 --- a/YD_Event.Application/Client/EventClientController.cs +++ b/YD_Event.Application/Client/EventClientController.cs @@ -185,21 +185,8 @@ public class EventClientController : IDynamicApiController .Where(e => !e.DeleteMark && e.Status == AvailabilityStatus.Enable) .WhereIF(!string.IsNullOrEmpty(input.Keyword), e => e.EventName.Contains(input.Keyword)) .WhereIF(input.EventType.HasValue, e => e.EventType == input.EventType) - .WhereIF(input.ChargeMode.HasValue, e => e.ChargeMode == input.ChargeMode); - - var now = DateTime.Now; - if (input.Status == 1) - { - query = query.Where(e => now >= e.RegistrationStartTime && now <= e.RegistrationEndTime); - } - else if (input.Status == 2) - { - query = query.Where(e => now >= e.MatchStartTime && now <= e.MatchEndTime); - } - else if (input.Status == 3) - { - query = query.Where(e => now > e.MatchEndTime); - } + .WhereIF(input.ChargeMode.HasValue, e => e.ChargeMode == input.ChargeMode) + .WhereIF(input.Status > 0, e => e.EventStatus == (EventStatus)input.Status); query = query.OrderByDescending(e => e.CreatedTime); @@ -243,7 +230,7 @@ public class EventClientController : IDynamicApiController Id = e.Id, EventName = e.EventName, CoverImage = e.CoverImage, - EventStatus = CalculateEventStatus(e), + EventStatus = e.EventStatus, RegistrationStartTime = e.RegistrationStartTime, RegistrationEndTime = e.RegistrationEndTime, MatchStartTime = e.MatchStartTime, @@ -465,7 +452,7 @@ public class EventClientController : IDynamicApiController Id = evt.Id, EventName = evt.EventName, CoverImage = evt.CoverImage, - EventStatus = CalculateEventStatus(evt), + EventStatus = evt.EventStatus, RegistrationStartTime = evt.RegistrationStartTime, RegistrationEndTime = evt.RegistrationEndTime, MatchStartTime = evt.MatchStartTime, diff --git a/YD_Event.Application/Client/MyController.cs b/YD_Event.Application/Client/MyController.cs index a9073cb..463df02 100644 --- a/YD_Event.Application/Client/MyController.cs +++ b/YD_Event.Application/Client/MyController.cs @@ -257,6 +257,7 @@ public class MyController : IDynamicApiController .Where(tm => teamIds.Contains(tm.TeamId) && !tm.DeleteMark) .ToListAsync(); var memberCounts = teamMembers + .Where(tm => tm.PersonType == PersonType.Athlete) .GroupBy(tm => tm.TeamId) .ToDictionary(g => g.Key, g => g.Count()); @@ -337,7 +338,7 @@ public class MyController : IDynamicApiController Leader = leader, Coach = coach, CreatedTime = team.CreatedTime, - MemberCount = members.Count, + MemberCount = members.Count(m => m.PersonType == 1), Members = members }; } @@ -372,8 +373,24 @@ public class MyController : IDynamicApiController .LeftJoin((c, e) => c.EventId == e.Id) .LeftJoin((c, e, ep) => c.ProjectId == ep.Id) .LeftJoin((c, e, ep, p) => ep.ProjectId == p.Id) - .Where((c, e, ep, p) => c.UserId == userId && c.CertificateStatus == 2 && !c.DeleteMark) - .Select((c, e, ep, p) => new { + .Where((c, e, ep, p) => c.UserId == userId && c.CertificateStatus == 2 && !c.DeleteMark); + + // 根据类型筛选 + if (input.Type.HasValue) + { + if (input.Type == 1) + { + // 个人证书:没有单位认证ID + query = query.Where((c, e, ep, p) => !c.MerchantCertificationId.HasValue); + } + else if (input.Type == 2) + { + // 团队证书:有单位认证ID + query = query.Where((c, e, ep, p) => c.MerchantCertificationId.HasValue); + } + } + + var resultQuery = query.Select((c, e, ep, p) => new { Id = c.Id, EventName = e.EventName, ProjectName = p.Name, @@ -384,7 +401,7 @@ public class MyController : IDynamicApiController }) .OrderByDescending(c => c.IssuedTime); - var pagedResult = await query.ToPagedListAsync(input); + var pagedResult = await resultQuery.ToPagedListAsync(input); // 在内存中转换证书名称 var result = new PageResult diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml index 2ceb174..4c8d213 100644 --- a/YD_Event.Application/YD_Event.Application.xml +++ b/YD_Event.Application/YD_Event.Application.xml @@ -1791,7 +1791,7 @@ - 状态筛选:0-全部 1-报名中 2-比赛中 3-已结束 + 状态筛选:0-全部 1-报名中 3-比赛中 4-已结束