赛事统一查询规则

- 线上支付 (PaymentMethod == 2) :只显示已支付 (PaymentStatus == 1) 的记录
- 线下支付 (PaymentMethod == 1) :显示待审核 (PaymentStatus == 0) 和已支付 (PaymentStatus == 1) 的记录
This commit is contained in:
马梓彭 2026-05-12 10:51:12 +08:00
parent c559033720
commit 2e615d43c6
6 changed files with 34 additions and 25 deletions

View File

@ -262,7 +262,8 @@ public class EventClientController : IDynamicApiController
{
var userId = GetCurrentUserId();
isRegistered = await _registrationRepository.IsAnyAsync(r =>
r.EventId == id && r.CreatedUserId == userId && r.PaymentStatus != 4 && r.PaymentStatus == 1);
r.EventId == id && r.CreatedUserId == userId &&
((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1))));
}
catch
{
@ -855,8 +856,9 @@ public class EventClientController : IDynamicApiController
var query = _registrationRepository.AsQueryable()
.LeftJoin<EventInfo>((r, e) => r.EventId == e.Id)
// 只显示未取消的报名,排除 PaymentStatus=3(已退款/已取消)的记录
.Where(r => r.CreatedUserId == userId && !r.DeleteMark && r.PaymentStatus == 1)
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
.Where(r => r.CreatedUserId == userId && !r.DeleteMark &&
((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1))))
.OrderByDescending(r => r.RegistrationTime)
.Select((r, e) => new MyEventListDto
{

View File

@ -605,7 +605,8 @@ public class MyController : IDynamicApiController
// 1. 先分页查询报名记录
var regQuery = _registrationRepository.AsQueryable()
.Where(r => r.CreatedUserId == userId && !r.DeleteMark && r.PaymentStatus != 3 && r.PaymentStatus != 4 && r.PaymentStatus != 5)
.Where(r => r.CreatedUserId == userId && !r.DeleteMark &&
((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1))))
.OrderByDescending(r => r.RegistrationTime);
var pagedRegs = await regQuery.ToPagedListAsync(input);

View File

@ -106,8 +106,8 @@ namespace YD_Event.Application.Event;
var counts = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == eventId
&& r.PaymentStatus != 4 && r.PaymentStatus != 3 // 排除已取消的报名
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& !p.DeleteMark // 排除已删除的人员
&& p.PersonType == PersonType.Athlete) // 只统计运动员
.GroupBy((p, r) => new { p.ProjectId, p.GroupName })
@ -118,8 +118,8 @@ namespace YD_Event.Application.Event;
var personWithTeam = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == eventId
&& r.PaymentStatus != 4 && r.PaymentStatus != 3
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& !p.DeleteMark
&& p.PersonType == PersonType.Athlete
&& r.TeamName != null)
@ -284,8 +284,8 @@ namespace YD_Event.Application.Event;
var counts = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == eventId
&& r.PaymentStatus != 4 && r.PaymentStatus != 3
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& !p.DeleteMark
&& p.PersonType == PersonType.Athlete)
.GroupBy((p, r) => new { p.ProjectId, p.GroupName })
@ -296,8 +296,8 @@ namespace YD_Event.Application.Event;
var personWithTeam = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == eventId
&& r.PaymentStatus != 4 && r.PaymentStatus != 3
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& !p.DeleteMark
&& p.PersonType == PersonType.Athlete
&& r.TeamName != null)
@ -327,8 +327,8 @@ namespace YD_Event.Application.Event;
var basicPersons = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => p.ProjectId == eventProj.Id
&& r.PaymentStatus != 4 && r.PaymentStatus != 3
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& !p.DeleteMark
&& p.PersonType == PersonType.Athlete)
.OrderBy(p => p.GroupName)

View File

@ -86,7 +86,8 @@ public class EventRecordService : BaseService<EventRegistration>, ITransient
.LeftJoin<AppUserEntity>((r, e, u) => r.CreatedUserId == u.Id)
.LeftJoin<SysUserEntity>((r, e, u, s) => r.CreatedUserId == s.Id)
.LeftJoin<MerchantEntity>((r, e, u, s, m) => r.CreatedUserId == m.CreatedUserId)
.Where((r, e, u, s, m) => r.PaymentStatus != 5) // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
.Where((r, e, u, s, m) => (r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
.WhereIF(!string.IsNullOrWhiteSpace(input.EventName), (r, e, u, s, m) => e.EventName.Contains(input.EventName))
.WhereIF(input.StartTime.HasValue, (r, e, u, s, m) => e.MatchStartTime >= input.StartTime)
.WhereIF(input.EndTime.HasValue, (r, e, u, s, m) => e.MatchStartTime <= input.EndTime)

View File

@ -66,7 +66,8 @@ public class EventRegistrationService : BaseService<EventRegistration>, ITransie
public async Task<PageResult<RegistrationListOutput>> Page(RegistrationQueryInput input)
{
var query = _repository.AsQueryable()
.Where(x => x.PaymentStatus != 4 && x.PaymentStatus != 3 && x.PaymentStatus != 5) // 过滤掉已取消、已退款和预报名的记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
.Where(x => (x.PaymentMethod == 2 && x.PaymentStatus == 1) || (x.PaymentMethod == 1 && (x.PaymentStatus == 0 || x.PaymentStatus == 1)))
.WhereIF(input.EventId.HasValue, x => x.EventId == input.EventId)
.WhereIF(input.RegistrationMode.HasValue, x => x.RegistrationMode == input.RegistrationMode)
.WhereIF(!string.IsNullOrWhiteSpace(input.UnitName), x => x.TeamName.Contains(input.UnitName))
@ -500,7 +501,8 @@ public class EventRegistrationService : BaseService<EventRegistration>, ITransie
public async Task<byte[]> Export(RegistrationQueryInput input)
{
var registrations = await _repository.AsQueryable()
.Where(x => x.PaymentStatus != 4 && x.PaymentStatus != 3 && x.PaymentStatus != 5) // 过滤掉已取消、已退款和预报名的记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
.Where(x => (x.PaymentMethod == 2 && x.PaymentStatus == 1) || (x.PaymentMethod == 1 && (x.PaymentStatus == 0 || x.PaymentStatus == 1)))
.WhereIF(input.EventId.HasValue, x => x.EventId == input.EventId)
.WhereIF(input.RegistrationMode.HasValue, x => x.RegistrationMode == input.RegistrationMode)
.WhereIF(!string.IsNullOrWhiteSpace(input.UnitName), x => x.TeamName.Contains(input.UnitName))

View File

@ -131,9 +131,8 @@ public class EventScoreService : BaseService<EventResult>, ITransient
.LeftJoin<EventResult>((p, r, res) => p.Id == res.RegistrationPersonId)
.LeftJoin<EventCertificate>((p, r, res, c) => res.Id == c.ResultId)
.Where((p, r, res, c) => r.EventId == input.EventId
&& r.PaymentStatus != 3 // 排除已退款的报名
&& r.PaymentStatus != 4 // 排除已取消的报名
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& (p.PersonType == PersonType.Athlete || p.PersonType == PersonType.User));
// 应用筛选条件
@ -172,8 +171,8 @@ public class EventScoreService : BaseService<EventResult>, ITransient
// 先查找所有可能的 MerchantCertificationId
var registrationIds = await _registrationRepository.AsQueryable()
.Where(r => r.EventId == input.EventId
&& r.PaymentStatus != 3
&& r.PaymentStatus != 4)
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1))))
.Select(r => r.MerchantCertificationId)
.ToListAsync();
@ -340,7 +339,8 @@ public class EventScoreService : BaseService<EventResult>, ITransient
var athleteUserIds = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == input.EventId
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& p.PersonType == PersonType.Athlete && !p.DeleteMark)
.Select(p => p.UserId)
.ToListAsync();
@ -382,7 +382,8 @@ public class EventScoreService : BaseService<EventResult>, ITransient
var existingPersons = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == input.EventId
&& r.PaymentStatus != 5 // 排除预报名记录
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)))
&& coachLeaderUserIds.Contains(p.UserId) && p.PersonType == input.PersonType && !p.DeleteMark)
.LeftJoin<YD_Event.Core.Entities.AppUser>((p, r, u) => p.UserId == u.Id)
.Select((p, r, u) => new
@ -551,7 +552,9 @@ public class EventScoreService : BaseService<EventResult>, ITransient
// 步骤2:批量预加载该赛事的所有人员数据(包含团队信息)
var allPersonsWithTeam = await _personRepository.AsQueryable()
.InnerJoin<EventRegistration>((p, r) => p.RegistrationId == r.Id)
.Where((p, r) => r.EventId == eventId)
.Where((p, r) => r.EventId == eventId
// 线上支付只显示已支付(1),线下支付显示待审核(0)和已支付(1)
&& ((r.PaymentMethod == 2 && r.PaymentStatus == 1) || (r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1))))
.Select((p, r) => new {
p.Id,
p.RegistrationItemId,