You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
<?php
|
|
|
|
namespace app\common\command;
|
|
|
|
use app\admin\model\Ip as IpModel;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
|
|
class IpUpdate extends Command
|
|
{
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('ip_up')
|
|
->setDescription('系统节点刷新服务');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$output->writeln("========正在更新IP状态:=====" . date('Y-m-d H:i:s'));
|
|
$check = $this->update();
|
|
$check !== true && $output->writeln("更新IP状态失败:" . $check);
|
|
$output->writeln("更新IP状态完成:" . date('Y-m-d H:i:s'));
|
|
}
|
|
|
|
protected function update(): bool
|
|
{
|
|
$ipModel = new IpModel();
|
|
$time = time();
|
|
|
|
$where = [['status', '=', 1], ['expire_time', '<', $time]];
|
|
$idArr = $ipModel->where($where)->column('id');
|
|
|
|
if ($idArr) {
|
|
$res = $ipModel->where('id', 'in', $idArr)->save(['status' => 0]);
|
|
if (!$res) {
|
|
return '数据更新失败';
|
|
}
|
|
} else {
|
|
return '占无修改数据';
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|