diff --git a/YD_Event.Application/Event/UserEventRegistrationService.cs b/YD_Event.Application/Event/UserEventRegistrationService.cs index cf4569e..b7e632b 100644 --- a/YD_Event.Application/Event/UserEventRegistrationService.cs +++ b/YD_Event.Application/Event/UserEventRegistrationService.cs @@ -1415,4 +1415,78 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient return result; } + + /// + /// 验证用户是否已报名该赛事 + /// + [DisplayName("验证用户报名状态")] + [HttpPost("registration-status/check")] + public async Task CheckRegistrationStatus([FromBody] CheckRegistrationStatusInput input) + { + var userId = _authManager.UserId; + var result = new CheckRegistrationStatusOutput(); + + // 查询用户是否已报名该赛事 + var registration = await _registrationRepository.GetFirstAsync(x => + x.EventId == input.EventId && + x.CreatedUserId == userId && + !x.DeleteMark && + ( + (x.PaymentMethod == 1 && (x.PaymentStatus == 0 || x.PaymentStatus == 1)) || + (x.PaymentMethod == 2 && x.PaymentStatus == 1) + )); + + if (registration != null) + { + result.IsRegistered = true; + result.RegistrationId = registration.Id; + result.RegistrationStatus = GetPaymentStatusDesc(registration.PaymentStatus); + result.Message = "您已报名该赛事,请先取消报名后再重新报名"; + } + else + { + result.IsRegistered = false; + result.Message = "可以报名"; + } + + return result; + } + + /// + /// 验证用户报名状态输入 + /// + public class CheckRegistrationStatusInput + { + /// + /// 赛事ID + /// + [Required] + public long EventId { get; set; } + } + + /// + /// 验证用户报名状态输出 + /// + public class CheckRegistrationStatusOutput + { + /// + /// 是否已报名 + /// + public bool IsRegistered { get; set; } + + /// + /// 报名ID (如果已报名) + /// + public long? RegistrationId { get; set; } + + /// + /// 报名状态描述 + /// + public string? RegistrationStatus { get; set; } + + /// + /// 提示消息 + /// + public string? Message { get; set; } + } } diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml index 03432e2..fb1580d 100644 --- a/YD_Event.Application/YD_Event.Application.xml +++ b/YD_Event.Application/YD_Event.Application.xml @@ -8487,6 +8487,46 @@ 检查组别选择限制 + + + 验证用户是否已报名该赛事 + + + + + 验证用户报名状态输入 + + + + + 赛事ID + + + + + 验证用户报名状态输出 + + + + + 是否已报名 + + + + + 报名ID (如果已报名) + + + + + 报名状态描述 + + + + + 提示消息 + + 日志分页查询输入