xieruidong 2 years ago
parent
commit
22d437c1e1
1 changed files with 21 additions and 0 deletions
  1. 21 0
      commands/UserLevelExpire.php

+ 21 - 0
commands/UserLevelExpire.php

@@ -0,0 +1,21 @@
+<?php
+
+use app\common\model\User;
+use Workerman\Lib\Timer;
+use Workerman\Worker as WO;
+
+class UserLevelExpire extends Com{
+    public static function run(){
+        $work=self::newWorker();
+        $work->onWorkerStart=function (WO $worker){
+            Timer::add(3,function ()use ($worker){
+                User::where('level','>',0)
+                    ->where('level_expire','>',date('Y-m-d H:i:s'))
+                    ->update([
+                        'level'=>User::LEVEL_COMM
+                    ]);
+            });
+        };
+    }
+}
+UserLevelExpire::run();