Explorar el Código

Update AutoDisableExpireUserJob.php

aiden3434 hace 7 años
padre
commit
4ebad3aeee
Se han modificado 1 ficheros con 19 adiciones y 0 borrados
  1. 19 0
      app/Console/Commands/AutoDisableExpireUserJob.php

+ 19 - 0
app/Console/Commands/AutoDisableExpireUserJob.php

@@ -3,6 +3,7 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
+use App\Http\Models\Config;
 use App\Http\Models\User;
 use Log;
 
@@ -19,8 +20,26 @@ class autoDisableExpireUserJob extends Command
     public function handle()
     {
         // 到期账号禁用
+      $config = $this->systemConfig();
+      if ($config['is_ban_status']) {
+        User::query()->where('enable', 1)->where('expire_time', '<=', date('Y-m-d'))->update(['enable' => 0, 'status' => -1]);
+      }
+      else{
         User::query()->where('enable', 1)->where('expire_time', '<=', date('Y-m-d'))->update(['enable' => 0]);
+      }
 
         Log::info('定时任务:' . $this->description);
     }
+  
+    // 系统配置
+    private function systemConfig()
+    {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }