|
@@ -74,19 +74,31 @@ class User extends Index
|
|
}
|
|
}
|
|
|
|
|
|
public function userDep(){
|
|
public function userDep(){
|
|
- $depList = Db::name('dep')->where('enable',1)->where('org_id',$this->orgId)->where('del',0)->limit(6)->order('id desc')->select();
|
|
|
|
|
|
+ // $depList = Db::name('dep')->where('enable',1)->where('org_id',$this->orgId)->where('del',0)->limit(6)->order('id desc')->select();
|
|
$data = [];
|
|
$data = [];
|
|
- foreach ($depList as $v){
|
|
|
|
- $data[] = [
|
|
|
|
- 'name' => $v['title'],
|
|
|
|
- 'value' => Db::name('user_dep')
|
|
|
|
- ->alias('ud')
|
|
|
|
- ->join('user u','u.id=ud.user_id')
|
|
|
|
- ->where('ud.dep_id',$v['id'])
|
|
|
|
- ->where('u.del',0)
|
|
|
|
- ->count(),
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
|
|
+ $data = Db::name('user_dep')
|
|
|
|
+ ->alias('ud')
|
|
|
|
+ ->join('user u','u.id=ud.user_id')
|
|
|
|
+ ->join('dep dp','ud.dep_id=dp.id')
|
|
|
|
+ ->where('u.del',0)
|
|
|
|
+ ->field('count(ud.user_id) as value,dp.title as name')
|
|
|
|
+ ->group('ud.dep_id')
|
|
|
|
+ ->order('value','desc')
|
|
|
|
+ ->limit(6)
|
|
|
|
+ ->select();
|
|
|
|
+
|
|
|
|
+// foreach ($depList as $v){
|
|
|
|
+// $data[] = [
|
|
|
|
+// 'name' => $v['title'],
|
|
|
|
+// 'value' => Db::name('user_dep')
|
|
|
|
+// ->alias('ud')
|
|
|
|
+// ->join('user u','u.id=ud.user_id')
|
|
|
|
+// ->where('ud.dep_id',$v['id'])
|
|
|
|
+// ->where('u.del',0)
|
|
|
|
+// ->count(),
|
|
|
|
+// ];
|
|
|
|
+// }
|
|
|
|
+
|
|
HelpHander::success($data);
|
|
HelpHander::success($data);
|
|
|
|
|
|
}
|
|
}
|