好友迁移 + 定时器优化

This commit is contained in:
wong
2026-01-13 15:22:19 +08:00
parent 3e8b607948
commit 443ef6ad2d
6 changed files with 477 additions and 87 deletions

View File

@@ -22,7 +22,8 @@ class CheckUnreadMessageCommand extends Command
{
$this->setName('check:unread-message')
->setDescription('检查未读/未回复消息并自动迁移好友')
->addOption('minutes', 'm', \think\console\input\Option::VALUE_OPTIONAL, '未读/未回复分钟数默认30分钟', 30);
->addOption('minutes', 'm', \think\console\input\Option::VALUE_OPTIONAL, '未读/未回复分钟数默认30分钟', 30)
->addOption('page-size', 'p', \think\console\input\Option::VALUE_OPTIONAL, '每页处理数量默认100条', 100);
}
protected function execute(Input $input, Output $output)
@@ -32,11 +33,16 @@ class CheckUnreadMessageCommand extends Command
$minutes = 30;
}
$output->writeln("开始检查未读/未回复消息(超过{$minutes}分钟)...");
$pageSize = intval($input->getOption('page-size'));
if ($pageSize <= 0) {
$pageSize = 100;
}
$output->writeln("开始检查未读/未回复消息(超过{$minutes}分钟,每页处理{$pageSize}条)...");
try {
$friendTransferService = new FriendTransferService();
$result = $friendTransferService->checkAndTransferUnreadOrUnrepliedFriends($minutes);
$result = $friendTransferService->checkAndTransferUnreadOrUnrepliedFriends($minutes, $pageSize);
$output->writeln("检查完成:");
$output->writeln(" 总计需要迁移的好友数:{$result['total']}");