lizhen_gitee hace 6 meses
padre
commit
6941fdabd8

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

@@ -26,8 +26,9 @@ class Index extends Api
             ->where('deletetime', NULL)
 //            ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
             ->whereRaw("((end_time = 0) or (end_time > {$now}))")
-            ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
+//            ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
             ->limit(3)
+            ->order('start_time desc')
             ->select();
 
         foreach($papers as $key => &$val){
@@ -53,6 +54,7 @@ class Index extends Api
             ->whereRaw("((endtime = 0) or (endtime > {$now}))")
             //->where("(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )")
             ->limit(3)
+            ->order('starttime desc')
             ->select();
 
         foreach($lists as $key => &$val){
@@ -95,12 +97,27 @@ class Index extends Api
 
     //培训,更多,所有培训列表
     public function all_trainactive_list(){
-        $now    = time();
+        $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';
+        }
 
         $papers = Db::name('train_active')->field('id,title,logo_image,starttime,endtime,pingjia_time')
             ->where('status', 1)
             ->where('deletetime', NULL)
+            ->where($where)
             ->autopage()
+            ->order('starttime desc')
             ->select();
 
         foreach($papers as $key => &$val){
@@ -131,9 +148,9 @@ class Index extends Api
         $now    = time();
         $papers = Db::name('exam_paper')->field('id,title,start_time,end_time,total_score,limit_time')
             ->where('status', 'NORMAL')
+            ->where('deletetime', NULL)
             ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
             ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
-            ->where('deletetime', NULL)
             ->autopage()
             ->select();
 

+ 6 - 0
application/api/controller/Trainactive.php

@@ -15,7 +15,13 @@ class Trainactive extends Api
     // 无需鉴权的接口,*表示全部
     protected $noNeedRight = ['test2'];
 
+    //我的培训
+    public function my_sinin_list(){
 
+    }
+    //培训详情
+    public function info(){
+    }
 
 
     //签到成功