作者 王晓刚

获取学员详情

@@ -71,14 +71,64 @@ class University extends Api @@ -71,14 +71,64 @@ class University extends Api
71 } 71 }
72 72
73 public function getCollegeDetail(){ 73 public function getCollegeDetail(){
  74 + $user_id = $this->auth->id;
74 $college_id = $this->request->param('college_id',0,'intval'); 75 $college_id = $this->request->param('college_id',0,'intval');
75 // 获取学院 76 // 获取学院
76 - $college = new College();  
77 - $data = $college->infoById($college_id); 77 + $collegeModel = new College();
  78 + $data = $collegeModel->infoById($college_id);
78 foreach ($data as $k => $v) { 79 foreach ($data as $k => $v) {
79 $data[$k]['des_image'] = $this->qiNiu.$v['des_image']; 80 $data[$k]['des_image'] = $this->qiNiu.$v['des_image'];
80 } 81 }
81 - $this->success('SUCCESS',$data); 82 + $studentModel = new Student();
  83 + //获取当前用户信息
  84 + $user = $studentModel->infoByUserId($user_id);
  85 + //获取当前用户所属高中信息
  86 + $schoolModel = new School();
  87 + $school = $schoolModel->infoById($user['school_id']);
  88 + //获取当前用户同大学、院系、高中人数
  89 + $total1 = $studentModel->where([
  90 + 'level'=>'2',
  91 + 'show_switch'=>1,
  92 + 'university_id'=>$user['university_id'],
  93 + 'school_id'=>$user['school_id'],
  94 + 'college_id'=>$college_id,
  95 + 'deletetime'=>['exp',Db::raw('is null')]
  96 + ])->count();
  97 + //获取当前用户同省、大学、学院人数
  98 + //获取当前用户同省的高中
  99 + $school_province = $schoolModel->where(['province_id'=>$school['province_id']])->select();
  100 + $school_ids = [];
  101 + foreach($school_province as $key => $s_p){
  102 + $school_ids[] = $s_p['province_id'];
  103 + }
  104 + $total2 = $studentModel->where([
  105 + 'level'=>'2',
  106 + 'show_switch'=>1,
  107 + 'university_id'=>$user['university_id'],
  108 + 'school_id'=>['in',$school_ids],
  109 + 'college_id'=>$college_id,
  110 + 'deletetime'=>['exp',Db::raw('is null')]
  111 + ])->count();
  112 + //获取当前用户同城市、大学、学院人数
  113 + //获取当前用户同城市的高中
  114 + $school_city = $schoolModel->where(['city_id'=>$school['city_id']])->select();
  115 + $school_ids = [];
  116 + foreach($school_city as $key => $s_c){
  117 + $school_ids[] = $s_c['province_id'];
  118 + }
  119 + $total3 = $studentModel->where([
  120 + 'level'=>'2',
  121 + 'show_switch'=>1,
  122 + 'university_id'=>$user['university_id'],
  123 + 'school_id'=>['in',$school_ids],
  124 + 'college_id'=>$college_id,
  125 + 'deletetime'=>['exp',Db::raw('is null')]
  126 + ])->count();
  127 + $result['data'] = $data;
  128 + $result['total1'] = $total1;
  129 + $result['total2'] = $total2;
  130 + $result['total3'] = $total3;
  131 + $this->success('SUCCESS',$result);
82 } 132 }
83 133
84 134