赛事积分
This commit is contained in:
parent
bf3d90388e
commit
3b53312c27
@ -64,6 +64,7 @@ public class EventClientController : IDynamicApiController
|
||||
private readonly OrderNoGeneratorService _orderNoGeneratorService;
|
||||
private readonly YD_Event.Application.Banner.BannerService _bannerService;
|
||||
private readonly UnifiedRegistrationService _unifiedRegistrationService;
|
||||
private readonly YD_Event.Application.Refund.RefundConfigService _refundConfigService;
|
||||
|
||||
public EventClientController(
|
||||
ISqlSugarRepository<EventInfo> eventRepository,
|
||||
@ -99,7 +100,8 @@ public class EventClientController : IDynamicApiController
|
||||
ILogger<EventClientController> logger,
|
||||
OrderNoGeneratorService orderNoGeneratorService,
|
||||
YD_Event.Application.Banner.BannerService bannerService,
|
||||
UnifiedRegistrationService unifiedRegistrationService)
|
||||
UnifiedRegistrationService unifiedRegistrationService,
|
||||
YD_Event.Application.Refund.RefundConfigService refundConfigService)
|
||||
{
|
||||
_eventRepository = eventRepository;
|
||||
_projectRepository = projectRepository;
|
||||
@ -135,6 +137,7 @@ public class EventClientController : IDynamicApiController
|
||||
_orderNoGeneratorService = orderNoGeneratorService;
|
||||
_bannerService = bannerService;
|
||||
_unifiedRegistrationService = unifiedRegistrationService;
|
||||
_refundConfigService = refundConfigService;
|
||||
}
|
||||
|
||||
private long GetCurrentUserId()
|
||||
@ -198,7 +201,7 @@ public class EventClientController : IDynamicApiController
|
||||
query = query.Where(e => now > e.MatchEndTime);
|
||||
}
|
||||
|
||||
query = query.OrderByDescending(e => e.RegistrationStartTime);
|
||||
query = query.OrderByDescending(e => e.CreatedTime);
|
||||
|
||||
var list = await query.ToPagedListAsync(input);
|
||||
|
||||
@ -364,6 +367,34 @@ public class EventClientController : IDynamicApiController
|
||||
string refundRule = "开赛前7天扣除金额5%,3-7天扣除金额10%,3天内扣除金额20%";
|
||||
string pointsRule = "参与积分:5积分;名次积分:1-8名 15积分,9-20名 10积分";
|
||||
|
||||
// 优先从 RefundConfig 表读取配置并生成描述文本
|
||||
try
|
||||
{
|
||||
var refundConfigs = await _refundConfigService.GetList();
|
||||
var enabledConfigs = refundConfigs.Where(x => x.Status == Core.Enum.AvailabilityStatus.Enable).OrderBy(x => x.DayStart).ToList();
|
||||
if (enabledConfigs.Any())
|
||||
{
|
||||
var ruleParts = new List<string>();
|
||||
foreach (var config in enabledConfigs)
|
||||
{
|
||||
if (config.DayEnd >= 999)
|
||||
{
|
||||
ruleParts.Add($"开赛前{config.DayStart}天及以上扣除金额{Math.Round(config.DeductPercentage)}%");
|
||||
}
|
||||
else
|
||||
{
|
||||
ruleParts.Add($"开赛前{config.DayStart}-{config.DayEnd}天扣除金额{Math.Round(config.DeductPercentage)}%");
|
||||
}
|
||||
}
|
||||
refundRule = string.Join(",", ruleParts);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "读取退款配置失败,赛事ID={EventId},使用默认规则", evt.Id);
|
||||
}
|
||||
|
||||
// 如果有自定义配置,优先使用自定义配置(保持向后兼容)
|
||||
if (!string.IsNullOrWhiteSpace(evt.CustomConfigJson))
|
||||
{
|
||||
try
|
||||
|
||||
@ -1374,7 +1374,7 @@ public class EventScoreService : BaseService<EventResult>, ITransient
|
||||
GroupName = r.GroupName,
|
||||
Rank = r.Rank,
|
||||
ParticipantName = r.ParticipantName,
|
||||
ProjectIdForRecord = r.ProjectId,
|
||||
ProjectGroupId = p.EventProjectGroupId,
|
||||
RegistrationId = p.RegistrationId
|
||||
})
|
||||
.ToListAsync();
|
||||
@ -1435,7 +1435,8 @@ public class EventScoreService : BaseService<EventResult>, ITransient
|
||||
UserId = result.UserId,
|
||||
Type = PointsOperationType.Acquire,
|
||||
EventId = input.EventId,
|
||||
ProjectId = result.ProjectIdForRecord,
|
||||
ProjectId = result.ProjectId,
|
||||
ProjectGroupId = result.ProjectGroupId,
|
||||
ResultId = result.ResultId,
|
||||
MerchantCertificationId = merchantCertId,
|
||||
Points = pointsToAward,
|
||||
|
||||
@ -77,9 +77,11 @@ public class PointsRecordService : BaseService<PointsRecord>, ITransient
|
||||
|
||||
var query = _repository.AsQueryable()
|
||||
.LeftJoin<EventInfo>((pr, e) => pr.EventId == e.Id)
|
||||
.LeftJoin<YD_Event.Core.Entities.Project>((pr, e, p) => pr.ProjectId == p.Id)
|
||||
.LeftJoin<ProjectGroup>((pr, e, p, pg) => pr.ProjectGroupId == pg.Id)
|
||||
.LeftJoin<YD_Event.Core.Entities.AppUser>((pr, e, p, pg, u) => pr.UserId == u.Id)
|
||||
.LeftJoin<YD_Event.Core.Entities.EventProject>((pr, e, ep) => pr.ProjectId == ep.Id)
|
||||
.LeftJoin<YD_Event.Core.Entities.Project>((pr, e, ep, p) => ep.ProjectId == p.Id)
|
||||
.LeftJoin<EventProjectGroup>((pr, e, ep, p, pg) => pr.ProjectGroupId == pg.Id)
|
||||
.LeftJoin<EventResult>((pr, e, ep, p, pg, er) => pr.ResultId == er.Id)
|
||||
.LeftJoin<YD_Event.Core.Entities.AppUser>((pr, e, ep, p, pg, er, u) => pr.UserId == u.Id)
|
||||
.WhereIF(input.Type.HasValue, pr => pr.Type == input.Type)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.ActionKeyword), (pr, e) => e.EventName.Contains(input.ActionKeyword) || pr.Remark.Contains(input.ActionKeyword))
|
||||
.WhereIF(input.StartTime.HasValue, pr => pr.CreatedTime >= input.StartTime)
|
||||
@ -97,7 +99,7 @@ public class PointsRecordService : BaseService<PointsRecord>, ITransient
|
||||
query = query.Where(pr => pr.UserId == userId && pr.MerchantCertificationId == null);
|
||||
}
|
||||
|
||||
var result = await query.Select((pr, e, p, pg, u) => new UserPointsLogDto
|
||||
var result = await query.Select((pr, e, ep, p, pg, er, u) => new UserPointsLogDto
|
||||
{
|
||||
Id = pr.Id,
|
||||
Type = pr.Type,
|
||||
@ -105,7 +107,7 @@ public class PointsRecordService : BaseService<PointsRecord>, ITransient
|
||||
ProjectName = p.Name,
|
||||
GroupName = pg.GroupName,
|
||||
ParticipantName = u.Name, // 显示关联用户的姓名
|
||||
Rank = 0, // 暂无法直接关联到名次,需业务侧在写入PointsRecord时记录
|
||||
Rank = er.Rank > 0 ? er.Rank : null, // 使用 EventResult 中的名次
|
||||
Points = pr.Points,
|
||||
CreatedTime = pr.CreatedTime
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user