| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Module\Farm\Commands;
- use App\Module\Farm\Listeners\CheckHouseDowngradeListener;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- /**
- * 检查房屋降级命令
- */
- class CheckHouseDowngradeCommand extends Command
- {
- /**
- * 命令名称
- *
- * @var string
- */
- protected $signature = 'farm:check-house-downgrade';
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '检查用户房屋是否需要降级';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- $this->info('开始检查房屋降级...');
-
- try {
- // 使用监听器处理房屋降级逻辑
- app()->make(CheckHouseDowngradeListener::class)->handle();
-
- $this->info('房屋降级检查完成');
-
- Log::info('房屋降级检查成功');
-
- return 0;
- } catch (\Exception $e) {
- $this->error('房屋降级检查失败: ' . $e->getMessage());
-
- Log::error('房屋降级检查失败', [
- 'error' => $e->getMessage(),
- 'trace' => $e->getTraceAsString()
- ]);
-
- return 1;
- }
- }
- }
|