Files
ulthon_admin/extend/base/common/event/AdminLoginSuccess/NoticeEventBase.php
2026-10-12 13:40:40 +00:00

27 lines
956 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace base\common\event\AdminLoginSuccess;
use app\admin\model\SystemAdmin;
use app\common\service\NoticeService;
use think\facade\Log;
class NoticeEventBase
{
public function handle(SystemAdmin $admin)
{
try {
// 登录提醒场景默认关闭:无配置行(null 强转 0)不发,DB value 为字符串须强转 int
if ((int) sysconfig('notify', 'notify_login_scene_enable') === 0) {
return;
}
// 不传 channels=按场景注册渠道展开(admin_login=[inmail,email]),再经各管理员订阅矩阵过滤
NoticeService::send([$admin->id], '登录提醒', "账号 {$admin->username} 于 " . date('Y-m-d H:i') . ' 登录成功', ['scene' => 'admin_login']);
} catch (\Throwable $e) {
// 通知失败不得影响登录主流程
Log::error('admin login notice failed: ' . $e->getMessage());
}
}
}