feat(notify): add balance low & account quota notification system

- User balance low notification: email alert when balance drops below
  configurable threshold (user email + verified extra emails)
- Account quota notification: broadcast email to admin-configured
  recipients when daily/weekly/total quota usage exceeds alert threshold
- Admin settings: global enable/disable, default threshold, quota
  notification email list (Email Settings tab)
- User profile: enable/disable, custom threshold, add/remove extra
  notification emails with verification code flow
- Account quota: per-dimension alert toggle and threshold in quota
  control card
- Trigger logic: first-crossing only (old >= threshold && new < threshold
  for balance; old < threshold && new >= threshold for quota), naturally
  prevents duplicate notifications without Redis dedup
This commit is contained in:
erio
2026-04-12 02:48:57 +08:00
parent 60b0fa81ec
commit b32d1a2c9f
47 changed files with 2375 additions and 121 deletions

View File

@@ -902,6 +902,31 @@ export default {
sendCode: 'Send Code',
codeSent: 'Verification code sent to your email',
sendCodeFailed: 'Failed to send verification code'
},
balanceNotify: {
title: 'Balance Low Notification',
description: 'Send email alert when account balance falls below threshold',
enabled: 'Enable Balance Low Notification',
threshold: 'Custom Threshold',
thresholdHint: 'Leave empty to use system default',
thresholdPlaceholder: 'Enter amount',
systemDefault: 'System Default',
extraEmails: 'Extra Notification Emails',
noExtraEmails: 'No extra notification emails',
enterEmail: 'Enter email address',
addEmail: 'Add Email',
emailPlaceholder: 'Enter email address',
sendCode: 'Send Code',
codeSent: 'Verification code sent',
codeSentTo: 'Code sent to {email}',
enterCode: 'Enter verification code',
codePlaceholder: '6-digit code',
verify: 'Verify & Add',
emailAdded: 'Email added',
emailRemoved: 'Email removed',
verifySuccess: 'Email added successfully',
removeEmail: 'Remove',
removeSuccess: 'Email removed',
}
},
@@ -2228,6 +2253,12 @@ export default {
},
quotaLimitAmount: 'Total Limit',
quotaLimitAmountHint: 'Cumulative spending limit. Does not auto-reset.',
quotaNotify: {
alert: 'Alert Threshold',
enabled: 'Enable Alert',
threshold: 'Alert Amount',
thresholdPlaceholder: 'Enter alert amount',
},
testConnection: 'Test Connection',
reAuthorize: 'Re-Authorize',
refreshToken: 'Refresh Token',
@@ -4593,6 +4624,22 @@ export default {
supportedTypesHint: 'Comma-separated, e.g. alipay,wxpay',
refundEnabled: 'Allow Refund',
},
balanceNotify: {
title: 'Balance Low Notification',
description: 'Send email notification when user balance falls below threshold',
enabled: 'Enable Balance Low Notification',
threshold: 'Default Threshold',
thresholdHint: 'Used when user has not set a custom value',
thresholdPlaceholder: 'Enter amount',
},
quotaNotify: {
title: 'Account Quota Notification',
description: 'Notify admins when account quota usage reaches alert threshold',
emails: 'Notification Emails',
emailsHint: 'Leave empty to disable notifications',
addEmail: 'Add Email',
emailPlaceholder: 'Enter email address',
},
smtp: {
title: 'SMTP Settings',
description: 'Configure email sending for verification codes',

View File

@@ -906,6 +906,31 @@ export default {
sendCode: '发送验证码',
codeSent: '验证码已发送到您的邮箱',
sendCodeFailed: '发送验证码失败'
},
balanceNotify: {
title: '余额不足提醒',
description: '当账户余额低于阈值时发送邮件提醒',
enabled: '启用余额不足提醒',
threshold: '自定义提醒阈值',
thresholdHint: '留空使用系统默认值',
thresholdPlaceholder: '输入金额',
systemDefault: '系统默认值',
extraEmails: '额外通知邮箱',
noExtraEmails: '暂无额外通知邮箱',
enterEmail: '输入邮箱地址',
addEmail: '添加邮箱',
emailPlaceholder: '输入邮箱地址',
sendCode: '发送验证码',
codeSent: '验证码已发送',
codeSentTo: '验证码已发送到 {email}',
enterCode: '输入验证码',
codePlaceholder: '6位验证码',
verify: '确认添加',
emailAdded: '邮箱已添加',
emailRemoved: '邮箱已移除',
verifySuccess: '邮箱添加成功',
removeEmail: '移除',
removeSuccess: '邮箱已移除',
}
},
@@ -2226,6 +2251,12 @@ export default {
},
quotaLimitAmount: '总限额',
quotaLimitAmountHint: '累计消费上限,不会自动重置。',
quotaNotify: {
alert: '告警阈值',
enabled: '启用告警',
threshold: '告警金额',
thresholdPlaceholder: '输入告警金额',
},
testConnection: '测试连接',
reAuthorize: '重新授权',
refreshToken: '刷新令牌',
@@ -4757,6 +4788,22 @@ export default {
supportedTypesHint: '逗号分隔,如 alipay,wxpay',
refundEnabled: '允许退款',
},
balanceNotify: {
title: '余额不足提醒',
description: '当用户余额低于阈值时发送邮件提醒',
enabled: '启用余额不足提醒',
threshold: '默认提醒阈值',
thresholdHint: '用户未自定义时使用此值',
thresholdPlaceholder: '输入金额',
},
quotaNotify: {
title: '账号限额通知',
description: '当账号配额用量达到告警阈值时通知管理员',
emails: '通知邮箱',
emailsHint: '留空则不发送通知',
addEmail: '添加邮箱',
emailPlaceholder: '输入邮箱地址',
},
smtp: {
title: 'SMTP 设置',
description: '配置用于发送验证码的邮件服务',