修复bug

This commit is contained in:
马梓彭 2026-05-08 13:04:31 +08:00
parent 532ad46ca0
commit 5afa939e14
5 changed files with 53 additions and 25 deletions

View File

@ -171,8 +171,9 @@ public class AppUserService : BaseService<AppUserEntity>, 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<AppUserEntity>, 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<AppUserEntity>, ITransient
entity.UpdatedUserId = _authManager.UserId;
entity.UpdatedTime = DateTime.Now;
}
else
else if (isNewRecord)
{
// 新增模式:检查本单位内是否有相同手机号且相同类型的记录
var existingInSameUnit = await _appUserRep.AsQueryable()

View File

@ -14,7 +14,7 @@ public class EventClientQueryInput : Pagination
public string? Keyword { get; set; }
/// <summary>
/// 状态筛选:0-全部 1-报名中 2-比赛中 3-已结束
/// 状态筛选:0-全部 1-报名中 3-比赛中 4-已结束
/// </summary>
public int Status { get; set; } = 0;

View File

@ -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,

View File

@ -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<EventInfo>((c, e) => c.EventId == e.Id)
.LeftJoin<EventProject>((c, e, ep) => c.ProjectId == ep.Id)
.LeftJoin<ProjectEntity>((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<MyCertificateDto>

View File

@ -1791,7 +1791,7 @@
</member>
<member name="P:YD_Event.Application.Client.Dtos.EventClientQueryInput.Status">
<summary>
状态筛选:0-全部 1-报名中 2-比赛中 3-已结束
状态筛选:0-全部 1-报名中 3-比赛中 4-已结束
</summary>
</member>
<member name="P:YD_Event.Application.Client.Dtos.EventClientQueryInput.EventType">