修复高风险预警邮件通知并补充测试

This commit is contained in:
zhangshy
2026-09-12 15:56:50 +08:00
parent 164d55a05a
commit eb4e895e4e
12 changed files with 464 additions and 34 deletions
+16
View File
@@ -93,6 +93,22 @@ class RiskNotificationService:
self.session.add(notification)
return notification
def mark_mail_sent(self, notification: FundRiskNotification) -> None:
"""邮件发送成功后回写通知状态。"""
notification.send_status = "已发送"
notification.sent_at = _now()
notification.fail_reason = None
def mark_mail_failed(
self,
notification: FundRiskNotification,
reason: str,
) -> None:
"""邮件发送失败后保留通知记录并记录安全失败原因。"""
notification.send_status = "发送失败"
notification.sent_at = None
notification.fail_reason = reason.strip()[:500] or "邮件发送失败"
def create_high_risk_records(
self,
alerts: list[FundRiskAlert],