CheckHouseDowngradeCommand.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Module\Farm\Commands;
  3. use App\Module\Farm\Listeners\CheckHouseDowngradeListener;
  4. use Illuminate\Console\Command;
  5. use Illuminate\Support\Facades\Log;
  6. /**
  7. * 检查房屋降级命令
  8. */
  9. class CheckHouseDowngradeCommand extends Command
  10. {
  11. /**
  12. * 命令名称
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'farm:check-house-downgrade';
  17. /**
  18. * 命令描述
  19. *
  20. * @var string
  21. */
  22. protected $description = '检查用户房屋是否需要降级';
  23. /**
  24. * 执行命令
  25. *
  26. * @return int
  27. */
  28. public function handle()
  29. {
  30. $this->info('开始检查房屋降级...');
  31. try {
  32. // 使用监听器处理房屋降级逻辑
  33. app()->make(CheckHouseDowngradeListener::class)->handle();
  34. $this->info('房屋降级检查完成');
  35. Log::info('房屋降级检查成功');
  36. return 0;
  37. } catch (\Exception $e) {
  38. $this->error('房屋降级检查失败: ' . $e->getMessage());
  39. Log::error('房屋降级检查失败', [
  40. 'error' => $e->getMessage(),
  41. 'trace' => $e->getTraceAsString()
  42. ]);
  43. return 1;
  44. }
  45. }
  46. }