diff --git a/Fengling.RiskControl.Application/Events/LotteryCompletedEventHandler.cs b/Fengling.RiskControl.Application/Events/LotteryCompletedEventHandler.cs index 5863ff5..773f5cc 100644 --- a/Fengling.RiskControl.Application/Events/LotteryCompletedEventHandler.cs +++ b/Fengling.RiskControl.Application/Events/LotteryCompletedEventHandler.cs @@ -7,6 +7,8 @@ namespace Fengling.RiskControl.Application.Events; public class LotteryCompletedEventHandler : INotificationHandler { + private const int BIG_WIN_MULTIPLIER = 5; + private readonly IRiskScoreRepository _scoreRepository; public LotteryCompletedEventHandler(IRiskScoreRepository scoreRepository) @@ -22,7 +24,7 @@ public class LotteryCompletedEventHandler : INotificationHandler notification.StakePoints * 5) + if (notification.IsWin && notification.WinAmount > notification.StakePoints * BIG_WIN_MULTIPLIER) { score.AddRiskFactor("big_win", 20, "赢得超过投入5倍"); } diff --git a/Fengling.RiskControl.Application/Events/RiskAlertTriggeredEventHandler.cs b/Fengling.RiskControl.Application/Events/RiskAlertTriggeredEventHandler.cs index 64b0211..0f0c785 100644 --- a/Fengling.RiskControl.Application/Events/RiskAlertTriggeredEventHandler.cs +++ b/Fengling.RiskControl.Application/Events/RiskAlertTriggeredEventHandler.cs @@ -7,6 +7,8 @@ namespace Fengling.RiskControl.Application.Events; public class RiskAlertTriggeredEventHandler : INotificationHandler { + private const int ALERT_TRIGGER_THRESHOLD = 30; + private readonly IRiskAlertService _alertService; public RiskAlertTriggeredEventHandler(IRiskAlertService alertService) @@ -16,7 +18,7 @@ public class RiskAlertTriggeredEventHandler : INotificationHandler EvaluateFrequencyLimitAsync(RiskRule rule, RiskEvaluationRequest request) { - var config = rule.GetConfig(); - var recentCount = 0; - if (recentCount >= config.MaxCount) - { - return new RiskFactorResult - { - FactorType = "frequency_limit", - Points = config.Points, - Description = $"超过频率限制: {recentCount}/{config.MaxCount}", - RuleName = rule.Name - }; - } + // Frequency limit checking requires additional repository method + // Implement when ILotteryActivityRepository.GetLotteryCountByMemberAndTypeAsync is available return null; } @@ -113,7 +107,7 @@ public class RiskEvaluationService : IRiskEvaluationService return new RiskFactorResult { FactorType = "blacklist", - Points = 100, + Points = BLACKLIST_POINTS, Description = "用户在黑名单中", RuleName = rule.Name }; @@ -123,8 +117,8 @@ public class RiskEvaluationService : IRiskEvaluationService private RiskLevel DetermineRiskLevel(int score) { - return score >= 70 ? RiskLevel.High : - score >= 30 ? RiskLevel.Medium : + return score >= HIGH_THRESHOLD ? RiskLevel.High : + score >= MEDIUM_THRESHOLD ? RiskLevel.Medium : RiskLevel.Low; }