v2board/app/Console/Commands/CheckExpire.php

54 lines
1006 B
PHP
Raw Normal View History

2019-10-29 15:33:36 +08:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Order;
use App\Models\User;
class CheckExpire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'check:expire';
/**
* 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()
{
2019-12-30 15:13:11 +08:00
$users = User::all();
foreach ($users as $user) {
if ($user->expired_at < time() || $user->u + $user->d >= $user->transfer_enable) {
$user->enable = 0;
2019-10-29 15:33:36 +08:00
} else {
2019-12-30 15:13:11 +08:00
$user->enable = 1;
2019-10-29 15:33:36 +08:00
}
2019-12-30 15:13:11 +08:00
$user->save();
2019-10-29 15:33:36 +08:00
}
}
2020-01-11 13:36:52 +08:00
2019-10-29 15:33:36 +08:00
}