lizhen_gitee 3 hónapja
szülő
commit
dc1fbce164
1 módosított fájl, 14 hozzáadás és 9 törlés
  1. 14 9
      application/admin/controller/user/User.php

+ 14 - 9
application/admin/controller/user/User.php

@@ -82,7 +82,15 @@ class User extends Backend
             ->group('log.user_id')->order('right_num desc,maxlogid asc')
             ->select();
 
-        $list_vote = Db::name('vote_record')->field('user_id,sum(vote) as vote_num')->group('user_id')->order('vote_num desc')->select();
+        //只要前300名,后面的砍掉
+        if(count($list_exam) > 300){
+            $list_exam = array_chunk($list_exam,300)[0];
+        }
+
+        $user_ids = array_column($list_exam,'user_id');
+
+
+        $list_vote = Db::name('vote_record')->field('user_id,sum(vote) as vote_num')->where('user_id','IN',$user_ids)->group('user_id')->order('vote_num desc')->select();
 
         foreach($list_exam as $key => $val){
             $val['num'] = $key + 1;
@@ -95,10 +103,7 @@ class User extends Backend
             $list_exam[$key] = $val;
         }
 
-        //只要前300名,后面的砍掉
-        if(count($list_exam) > 300){
-            $list_exam = array_chunk($list_exam,300)[0];
-        }
+
 //        dump($list_exam);
 //        dump($list_vote);
 
@@ -126,12 +131,12 @@ class User extends Backend
             $ExcelCsv = new ExcelCsv($excel_header, $excel_result);
             $data = $ExcelCsv->collection();
             $ExcelCsv->download($fileName, $excel_header, $data);
+        }else{
+            $this->assign('lists',$list_exam);
+            $this->view->engine->layout(false);
+            return $this->view->fetch();
         }
 
-        $this->assign('lists',$list_exam);
-        $this->view->engine->layout(false);
-        return $this->view->fetch();
-
     }
 
 }