lizhen_gitee 6 maanden geleden
bovenliggende
commit
7a49f65a86
2 gewijzigde bestanden met toevoegingen van 20 en 14 verwijderingen
  1. 17 11
      application/api/controller/Index.php
  2. 3 3
      application/api/controller/Trainactive.php

+ 17 - 11
application/api/controller/Index.php

@@ -24,20 +24,29 @@ class Index extends Api
 
         //非实名,只能看一部分
         $where_auth = "";
-        if($this->auth->idcard_status != 1){
+        /*if($this->auth->idcard_status != 1){
             $where_auth = "(find_in_set('".$this->auth->id."',user_ids) )";
-        }
+        }*/
 
         $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time,user_ids')
             ->where('status', 'NORMAL')
             ->where('deletetime', NULL)
             ->whereRaw("((end_time = 0) or (end_time > {$now}))")
-            ->where($where_auth)
+//            ->where($where_auth)
 //            ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
-            ->limit(3)
+            ->limit(2)
             ->order('start_time desc')
             ->select();
 
+        if(empty($papers)){
+            $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time,user_ids')
+                ->where('status', 'NORMAL')
+                ->where('deletetime', NULL)
+                ->limit(2)
+                ->order('start_time desc')
+                ->select();
+        }
+
         foreach($papers as $key => &$val){
             $val['image'] = localpath_to_netpath($val['image']);
             $val['limit_time'] = $val['limit_time']/60; //秒转换分种
@@ -69,18 +78,17 @@ class Index extends Api
         }
 
         $lists = Db::name('train_active')->field('id,name as title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
-            ->where('status', 1)
+            ->where('pingjia_uid',0)
             ->where('deletetime', NULL)
-            ->whereRaw("((endtime = 0) or (endtime > {$now}))")
             ->where($where_auth)
-            ->limit(3)
+            ->limit(2)
             ->order('starttime desc')
             ->select();
 
         foreach($lists as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+            if($val['pingjia_uid'] != 0){
                 $val['show_status'] = 3;
                 $val['show_status_text'] = '已结束';
             }elseif($now < $val['starttime']){
@@ -129,7 +137,6 @@ class Index extends Api
         $where = [];
 
         if($type == 3){
-//            $where = 'endtime < '.$now.' or pingjia_time > 0';
             $where['pingjia_uid'] = ['NEQ',0];
         }elseif($type == 1){
             $where['starttime'] = ['gt',$now];
@@ -145,7 +152,6 @@ class Index extends Api
         }
 
         $papers = Db::name('train_active')->field('id,name as title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
-            ->where('status', 1)
             ->where('deletetime', NULL)
             ->where($where)
             ->where($where_auth)
@@ -156,7 +162,7 @@ class Index extends Api
         foreach($papers as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+            if($val['pingjia_uid'] != 0){ //时间或评价,都行
                 $val['show_status'] = 3;
                 $val['show_status_text'] = '已结束';
             }elseif($now < $val['starttime']){

+ 3 - 3
application/api/controller/Trainactive.php

@@ -21,7 +21,7 @@ class Trainactive extends Api
 
 
         $papers = Db::name('train_active')->field('id,name as title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
-            ->where('status', 1)
+//            ->where('status', 1)
             ->where('deletetime', NULL)
             ->where("(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )")
             ->autopage()
@@ -31,7 +31,7 @@ class Trainactive extends Api
         foreach($papers as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+            if($val['pingjia_uid'] != 0){ //时间或评价,都行
                 $val['show_status'] = 3;
                 $val['show_status_text'] = '已结束';
             }elseif($now < $val['starttime']){
@@ -63,7 +63,7 @@ class Trainactive extends Api
 
             $now  = time();
 
-            if(/*$info['endtime'] < $now || */$info['pingjia_uid'] != 0){ //时间或评价,都行
+            if($info['pingjia_uid'] != 0){ //时间或评价,都行
                 $info['show_status'] = 3;
                 $info['show_status_text'] = '已结束';
             }elseif($now < $info['starttime']){