用户PC 【赛事管理】判断是否可以进行赛事报名

This commit is contained in:
马梓彭 2026-03-26 23:08:22 +08:00
parent bf896352a3
commit 369fed08f8
3 changed files with 25 additions and 1 deletions

View File

@ -81,6 +81,11 @@ public class UserEventListOutput
/// 比赛结束时间
/// </summary>
public DateTime MatchEndTime { get; set; }
/// <summary>
/// 当前用户是否可以报名参与该赛事
/// </summary>
public bool CanRegister { get; set; }
}
/// <summary>

View File

@ -42,6 +42,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
private readonly ISqlSugarRepository<PointsRule> _pointsRuleRepository;
private readonly ISqlSugarRepository<YD_Event.Core.Entities.Order> _orderRepository;
private readonly ISqlSugarRepository<WeChatPayConfig> _weChatPayConfigRepository;
private readonly ISqlSugarRepository<YD_Event.Core.Entities.Merchant> _merchantRepository;
private readonly AuthManager _authManager;
private readonly IIdGenerator _idGenerator;
private readonly WeChatPayService _weChatPayService;
@ -62,6 +63,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
ISqlSugarRepository<PointsRule> pointsRuleRepository,
ISqlSugarRepository<YD_Event.Core.Entities.Order> orderRepository,
ISqlSugarRepository<WeChatPayConfig> weChatPayConfigRepository,
ISqlSugarRepository<YD_Event.Core.Entities.Merchant> merchantRepository,
AuthManager authManager,
IIdGenerator idGenerator,
WeChatPayService weChatPayService,
@ -81,6 +83,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
_pointsRuleRepository = pointsRuleRepository;
_orderRepository = orderRepository;
_weChatPayConfigRepository = weChatPayConfigRepository;
_merchantRepository = merchantRepository;
_authManager = authManager;
_idGenerator = idGenerator;
_weChatPayService = weChatPayService;
@ -104,7 +107,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
.WhereIF(input.EndTime.HasValue, x => x.MatchEndTime <= input.EndTime)
.OrderByDescending(x => x.CreatedTime);
return await query.Select(x => new UserEventListOutput
var pageResult = await query.Select(x => new UserEventListOutput
{
Id = x.Id,
Name = x.EventName,
@ -115,6 +118,17 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
MatchStartTime = x.MatchStartTime,
MatchEndTime = x.MatchEndTime
}).ToPagedListAsync(input);
var userId = _authManager.UserId;
var merchant = await _merchantRepository.GetFirstAsync(m => m.CreatedUserId == userId);
var canRegister = merchant != null && merchant.AuditStatus == AuditStatus.Pass;
foreach (var item in pageResult.Rows)
{
item.CanRegister = canRegister;
}
return pageResult;
}
/// <summary>

View File

@ -4379,6 +4379,11 @@
比赛结束时间
</summary>
</member>
<member name="P:YD_Event.Application.Event.Dtos.UserEventListOutput.CanRegister">
<summary>
当前用户是否可以报名参与该赛事
</summary>
</member>
<member name="T:YD_Event.Application.Event.Dtos.UserEventDetailOutput">
<summary>
用户端赛事详情输出