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',