1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Console\Commands;
- use App\Http\Models\Site;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class SiteStatusCheck extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'siteStatus:check';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '检测站点状态并切换';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle(): void
- {
- return;
- $sites = Site::query()->get();
- foreach ($sites as $site) {
- if ($site->expired_at) {
- if (time() > strtotime($site->expired_at) && !in_array($site->status, [4, 6, 7])) {
- $site->update(['status' => 6]); //已过期
- continue;
- }
- if (strtotime('+3 month') > strtotime($site->expired_at) &&
- time() < strtotime($site->expired_at) && !in_array($site->status, [4, 5, 7])) {
- $site->update(['status' => 5]); //续费期
- continue;
- }
- }
- }
- $this->info('success');
- }
- }
|