浏览代码

各种列表

lizhen_gitee 6 月之前
父节点
当前提交
6272776d96
共有 2 个文件被更改,包括 32 次插入36 次删除
  1. 20 21
      application/api/controller/Index.php
  2. 12 15
      application/api/controller/Trainactive.php

+ 20 - 21
application/api/controller/Index.php

@@ -67,18 +67,17 @@ class Index extends Api
         foreach($lists as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if($now < $val['starttime']){
+            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+                $val['show_status'] = 3;
+                $val['show_status_text'] = '已结束';
+            }elseif($now < $val['starttime']){
                 $val['show_status'] = 1;
                 $val['show_status_text'] = '待开始';
-            }
-            if($val['starttime'] < $now && $now < $val['endtime']){
+            }else{
                 $val['show_status'] = 2;
                 $val['show_status_text'] = '进行中';
             }
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
-                $val['show_status'] = 3;
-                $val['show_status_text'] = '已结束';
-            }
+
         }
 
         $this->success('', $lists);
@@ -86,6 +85,7 @@ class Index extends Api
 
     //考试,更多,所有考试列表
     public function all_paper_list(){
+        if($this->auth->idcard_status != 1){$this->success(1,[]);}
 
         $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
             ->where('status', 'NORMAL')
@@ -103,20 +103,20 @@ class Index extends Api
 
     //培训,更多,所有培训列表
     public function all_trainactive_list(){
+
         $type = input('type',1);
         $now  = time();
 
         $where = [];
-        if($type == 1){
-            $where['starttime'] = ['gt',$now];
-        }
-        if($type == 2){
-            $where['starttime'] = ['lt',$now];
-            $where['endtime'] = ['gt',$now];
-        }
+
         if($type == 3){
 //            $where = 'endtime < '.$now.' or pingjia_time > 0';
             $where['pingjia_uid'] = ['NEQ',0];
+        }elseif($type == 1){
+            $where['starttime'] = ['gt',$now];
+        }else{
+            $where['starttime'] = ['lt',$now];
+            $where['endtime'] = ['gt',$now];
         }
 
         $papers = Db::name('train_active')->field('id,title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
@@ -130,18 +130,17 @@ class Index extends Api
         foreach($papers as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if($now < $val['starttime']){
+            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+                $val['show_status'] = 3;
+                $val['show_status_text'] = '已结束';
+            }elseif($now < $val['starttime']){
                 $val['show_status'] = 1;
                 $val['show_status_text'] = '待开始';
-            }
-            if($val['starttime'] < $now && $now < $val['endtime']){
+            }else{
                 $val['show_status'] = 2;
                 $val['show_status_text'] = '进行中';
             }
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
-                $val['show_status'] = 3;
-                $val['show_status_text'] = '已结束';
-            }
+
         }
 
         $this->success(1, $papers);

+ 12 - 15
application/api/controller/Trainactive.php

@@ -31,18 +31,16 @@ class Trainactive extends Api
         foreach($papers as $key => &$val){
             $val['logo_image'] = localpath_to_netpath($val['logo_image']);
 
-            if($now < $val['starttime']){
+            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
+                $val['show_status'] = 3;
+                $val['show_status_text'] = '已结束';
+            }elseif($now < $val['starttime']){
                 $val['show_status'] = 1;
                 $val['show_status_text'] = '待开始';
-            }
-            if($val['starttime'] < $now && $now < $val['endtime']){
+            }else{
                 $val['show_status'] = 2;
                 $val['show_status_text'] = '进行中';
             }
-            if(/*$val['endtime'] < $now || */$val['pingjia_uid'] != 0){ //时间或评价,都行
-                $val['show_status'] = 3;
-                $val['show_status_text'] = '已结束';
-            }
         }
 
         $this->success('', $papers);
@@ -64,17 +62,16 @@ class Trainactive extends Api
             }
 
             $now  = time();
-            if($now < $info['starttime']){
-                $val['show_status'] = 1;
-                $val['show_status_text'] = '待开始';
-            }
-            if($info['starttime'] < $now && $now < $info['endtime']){
-                $info['show_status'] = 2;
-                $info['show_status_text'] = '进行中';
-            }
+
             if(/*$info['endtime'] < $now || */$info['pingjia_uid'] != 0){ //时间或评价,都行
                 $info['show_status'] = 3;
                 $info['show_status_text'] = '已结束';
+            }elseif($now < $info['starttime']){
+                $info['show_status'] = 1;
+                $info['show_status_text'] = '待开始';
+            }else{
+                $info['show_status'] = 2;
+                $info['show_status_text'] = '进行中';
             }
         }