| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Module\Pet\Console;
- use App\Module\Pet\Jobs\ProcessActiveSkillsJob;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- /**
- * 处理宠物激活技能的定时命令
- *
- * 每分钟执行一次,处理所有激活中的宠物技能
- */
- class ProcessActiveSkillsCommand extends Command
- {
- /**
- * 命令签名
- *
- * @var string
- */
- protected $signature = 'pet:process-active-skills';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '处理宠物激活技能的定时任务';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- $this->info('开始处理宠物激活技能...');
- try {
- // 分发任务到队列
- ProcessActiveSkillsJob::dispatch();
- $this->info('宠物激活技能处理任务已分发到队列');
- Log::info('宠物激活技能定时命令执行成功');
- return Command::SUCCESS;
- } catch (\Exception $e) {
- $this->error('处理宠物激活技能失败: ' . $e->getMessage());
- Log::error('宠物激活技能定时命令执行失败', [
- 'error' => $e->getMessage(),
- 'trace' => $e->getTraceAsString()
- ]);
- return Command::FAILURE;
- }
- }
- }
|