mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-11-08 20:10:50 +08:00
chore(notice): 规范修复与安装演练收尾
This commit is contained in:
@@ -17,7 +17,7 @@ class NoticeEventBase
|
||||
}
|
||||
|
||||
// 不传 channels=按场景注册渠道展开(admin_login=[inmail,email]),再经各管理员订阅矩阵过滤
|
||||
NoticeService::send([$admin->id], '登录提醒', "账号 {$admin->username} 于 ".date('Y-m-d H:i').' 登录成功', ['scene' => 'admin_login']);
|
||||
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());
|
||||
|
||||
@@ -12,9 +12,9 @@ class LogEventBase
|
||||
[$notice, $targets] = $payload;
|
||||
|
||||
Log::info('notice sended', [
|
||||
'notice_id' => (int) $notice->id,
|
||||
'notice_id' => (int) $notice->id,
|
||||
'target_count' => count($targets),
|
||||
'channels' => array_values(array_unique(array_column($targets, 'channel'))),
|
||||
'channels' => array_values(array_unique(array_column($targets, 'channel'))),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,15 +29,15 @@ class EmailChannel implements NoticeChannelInterface
|
||||
throw new RuntimeException('邮件发送失败: 渠道未启用(notify_email_enable != 1)');
|
||||
}
|
||||
|
||||
$host = (string) sysconfig('notify', 'notify_smtp_host');
|
||||
$port = (int) sysconfig('notify', 'notify_smtp_port');
|
||||
$secure = strtolower((string) sysconfig('notify', 'notify_smtp_secure'));
|
||||
$user = (string) sysconfig('notify', 'notify_smtp_user');
|
||||
$pass = (string) sysconfig('notify', 'notify_smtp_pass');
|
||||
$from = (string) sysconfig('notify', 'notify_smtp_from', 'notice@localhost');
|
||||
$host = (string) sysconfig('notify', 'notify_smtp_host');
|
||||
$port = (int) sysconfig('notify', 'notify_smtp_port');
|
||||
$secure = strtolower((string) sysconfig('notify', 'notify_smtp_secure'));
|
||||
$user = (string) sysconfig('notify', 'notify_smtp_user');
|
||||
$pass = (string) sysconfig('notify', 'notify_smtp_pass');
|
||||
$from = (string) sysconfig('notify', 'notify_smtp_from', 'notice@localhost');
|
||||
$fromName = (string) sysconfig('notify', 'notify_smtp_from_name');
|
||||
|
||||
$title = (string) ($notice['title'] ?? '');
|
||||
$title = (string) ($notice['title'] ?? '');
|
||||
$content = (string) ($notice['content'] ?? '');
|
||||
|
||||
$mailer = new PHPMailer(true);
|
||||
|
||||
@@ -34,11 +34,11 @@ class SmsChannel implements NoticeChannelInterface
|
||||
// 骨架驱动模拟发送:开关状态仅记入日志(关闭也恒成功),不拦截投递、不真实外呼
|
||||
$enabled = (int) sysconfig('notify', 'notify_sms_enable');
|
||||
Log::info('notice sms channel skeleton simulated send', [
|
||||
'channel' => self::name(),
|
||||
'enabled' => $enabled,
|
||||
'notice_id' => $notice['id'] ?? 0,
|
||||
'channel' => self::name(),
|
||||
'enabled' => $enabled,
|
||||
'notice_id' => $notice['id'] ?? 0,
|
||||
'target_addr' => $target['target_addr'] ?? '',
|
||||
'title' => $notice['title'] ?? '',
|
||||
'title' => $notice['title'] ?? '',
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -34,11 +34,11 @@ class WechatChannel implements NoticeChannelInterface
|
||||
// 骨架驱动模拟发送:开关状态仅记入日志(关闭也恒成功),不拦截投递、不真实外呼
|
||||
$enabled = (int) sysconfig('notify', 'notify_wechat_enable');
|
||||
Log::info('notice wechat channel skeleton simulated send', [
|
||||
'channel' => self::name(),
|
||||
'enabled' => $enabled,
|
||||
'notice_id' => $notice['id'] ?? 0,
|
||||
'channel' => self::name(),
|
||||
'enabled' => $enabled,
|
||||
'notice_id' => $notice['id'] ?? 0,
|
||||
'target_addr' => $target['target_addr'] ?? '',
|
||||
'title' => $notice['title'] ?? '',
|
||||
'title' => $notice['title'] ?? '',
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -47,10 +47,10 @@ class NoticeServiceBase
|
||||
public static function scenes(): array
|
||||
{
|
||||
return [
|
||||
'system' => ['title' => '系统公告', 'channels' => [self::CHANNEL_INMAIL], 'locked' => true],
|
||||
'common' => ['title' => '通用通知', 'channels' => [self::CHANNEL_INMAIL, self::CHANNEL_EMAIL], 'locked' => false],
|
||||
'system' => ['title' => '系统公告', 'channels' => [self::CHANNEL_INMAIL], 'locked' => true],
|
||||
'common' => ['title' => '通用通知', 'channels' => [self::CHANNEL_INMAIL, self::CHANNEL_EMAIL], 'locked' => false],
|
||||
'admin_login' => ['title' => '登录提醒', 'channels' => [self::CHANNEL_INMAIL, self::CHANNEL_EMAIL], 'locked' => false],
|
||||
'mall_stock' => ['title' => '库存预警', 'channels' => [self::CHANNEL_INMAIL, self::CHANNEL_EMAIL], 'locked' => false],
|
||||
'mall_stock' => ['title' => '库存预警', 'channels' => [self::CHANNEL_INMAIL, self::CHANNEL_EMAIL], 'locked' => false],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ class NoticeServiceBase
|
||||
{
|
||||
return [
|
||||
self::CHANNEL_INMAIL => InMailChannel::class,
|
||||
self::CHANNEL_EMAIL => EmailChannel::class,
|
||||
self::CHANNEL_SMS => SmsChannel::class,
|
||||
self::CHANNEL_EMAIL => EmailChannel::class,
|
||||
self::CHANNEL_SMS => SmsChannel::class,
|
||||
self::CHANNEL_WECHAT => WechatChannel::class,
|
||||
];
|
||||
}
|
||||
@@ -117,10 +117,10 @@ class NoticeServiceBase
|
||||
$now = time();
|
||||
|
||||
$notice = SystemNotice::create([
|
||||
'scene' => $scene,
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'biz_id' => (string) ($options['biz_id'] ?? ''),
|
||||
'scene' => $scene,
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'biz_id' => (string) ($options['biz_id'] ?? ''),
|
||||
'send_admin_id' => (int) ($options['send_admin_id'] ?? 0),
|
||||
]);
|
||||
$noticeId = (int) $notice->id;
|
||||
@@ -196,13 +196,13 @@ class NoticeServiceBase
|
||||
$status = $isInmail ? SystemNoticeTargetBase::STATUS_SUCCESS : SystemNoticeTargetBase::STATUS_PENDING;
|
||||
|
||||
$targets[] = [
|
||||
'notice_id' => $noticeId,
|
||||
'admin_id' => $adminId,
|
||||
'channel' => $channel,
|
||||
'notice_id' => $noticeId,
|
||||
'admin_id' => $adminId,
|
||||
'channel' => $channel,
|
||||
'target_addr' => $targetAddr,
|
||||
'status' => $status,
|
||||
'send_time' => $isInmail ? $now : 0,
|
||||
'read_time' => 0,
|
||||
'status' => $status,
|
||||
'send_time' => $isInmail ? $now : 0,
|
||||
'read_time' => 0,
|
||||
'create_time' => $now,
|
||||
'update_time' => $now,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user