tongshanglei 2 rokov pred
rodič
commit
45f6f45a7f
1 zmenil súbory, kde vykonal 9 pridanie a 0 odobranie
  1. 9 0
      catch/device/model/Station.php

+ 9 - 0
catch/device/model/Station.php

@@ -8,6 +8,7 @@ use catcher\base\CatchModel as Model;
 use catchAdmin\permissions\model\DataRangScopeTrait;
 use catchAdmin\device\model\get\StationGet;
 use think\facade\Db;
+use think\facade\Env;
 class Station extends Model
 {
     use DataRangScopeTrait;
@@ -130,9 +131,17 @@ class Station extends Model
     public function searchOnlineStateAttr($query, $value, $data)
     {
         $time=date('Y-m-d H:i:s',time()-300);
+        $config=Env::get('app.station_state');
+        
         if($value=='1'){
+            if(!$config){
+                return $query->where('online_state', 1)->whereOr('online_state','null');
+            }
             return $query->where('online_time', '>=', $time)->whereOr('online_state','=', 1);
         }elseif($value=='2'){
+            if(!$config){
+                return $query->where('online_state',2);
+            }
             return $query->where(function ($query) use( $time) {
                 $query->whereOr('online_time','<', $time)->whereOr('online_time','=', null);
             });