...
|
...
|
@@ -427,66 +427,117 @@ class Index extends Api |
|
|
*/
|
|
|
public function detail()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$data = Db::name('teacher')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
if($data['sex'] == 1){
|
|
|
$data['sex'] = '男';
|
|
|
}else{
|
|
|
$data['sex'] = '女';
|
|
|
}
|
|
|
//查看用户是否已经关注该老师
|
|
|
$good = Db::name('good')
|
|
|
->where('user_id',$user_id)
|
|
|
->where('teacher_id',$id)
|
|
|
->find();
|
|
|
if(empty($good)){
|
|
|
$token = $this->request->header('token');
|
|
|
if(empty($token)){
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$data = Db::name('teacher')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
if($data['sex'] == 1){
|
|
|
$data['sex'] = '男';
|
|
|
}else{
|
|
|
$data['sex'] = '女';
|
|
|
}
|
|
|
//查看用户是否已经关注该老师
|
|
|
|
|
|
$data['is_guan'] = 2;
|
|
|
|
|
|
//查看老师的已帮助人数以及评分星级
|
|
|
$comment = Db::name('comment')->where('teacher_id',$id)->select();
|
|
|
//评价为五星的人数
|
|
|
$five = Db::name('comment')->where('teacher_id',$id)->where('level',5)->count();
|
|
|
//评价为四星的人数
|
|
|
$four = Db::name('comment')->where('teacher_id',$id)->where('level',4)->count();
|
|
|
//评价为三星的人数
|
|
|
$three = Db::name('comment')->where('teacher_id',$id)->where('level',3)->count();
|
|
|
//评价为二星的人数
|
|
|
$two = Db::name('comment')->where('teacher_id',$id)->where('level',2)->count();
|
|
|
//评价为一星的人数
|
|
|
$one = Db::name('comment')->where('teacher_id',$id)->where('level',1)->count();
|
|
|
if(!empty($comment)){
|
|
|
$data['help_num'] = $five + $four + $three + $two + $one + $data['help_num'];
|
|
|
$data['level'] = ceil(($data['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$data['help_num']);
|
|
|
}
|
|
|
$data['before'] = $http.$data['before'];
|
|
|
$data['behind'] = $http.$data['behind'];
|
|
|
$data['thumbnail'] = $http.$data['thumbnail'];
|
|
|
$territory_id = explode(',',$data['territory_id']);
|
|
|
$data['territory_id'] = Db::name('territory')
|
|
|
->alias('a')
|
|
|
->join('contype b','a.contype_id = b.id')
|
|
|
->field('a.id,a.money,a.content,b.title,b.type')
|
|
|
->whereIn('a.id',$territory_id)
|
|
|
->select();
|
|
|
|
|
|
$this->success('success',$data);
|
|
|
}else{
|
|
|
$data['is_guan'] = 1;
|
|
|
}
|
|
|
//查看用户是否有优惠劵
|
|
|
$data['you_num'] = Db::name('coupon')
|
|
|
->where('user_id',$user_id)
|
|
|
->where('is_use',0)
|
|
|
->whereTime('expirationtime','>',time())
|
|
|
->count();
|
|
|
$user_id = $this->getUserId();
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$data = Db::name('teacher')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
if($data['sex'] == 1){
|
|
|
$data['sex'] = '男';
|
|
|
}else{
|
|
|
$data['sex'] = '女';
|
|
|
}
|
|
|
//查看用户是否已经关注该老师
|
|
|
$good = Db::name('good')
|
|
|
->where('user_id',$user_id)
|
|
|
->where('teacher_id',$id)
|
|
|
->find();
|
|
|
if(empty($good)){
|
|
|
$data['is_guan'] = 2;
|
|
|
}else{
|
|
|
$data['is_guan'] = 1;
|
|
|
}
|
|
|
//查看用户是否有优惠劵
|
|
|
$data['you_num'] = Db::name('coupon')
|
|
|
->where('user_id',$user_id)
|
|
|
->where('is_use',0)
|
|
|
->whereTime('expirationtime','>',time())
|
|
|
->count();
|
|
|
|
|
|
//查看老师的已帮助人数以及评分星级
|
|
|
$comment = Db::name('comment')->where('teacher_id',$id)->select();
|
|
|
//评价为五星的人数
|
|
|
$five = Db::name('comment')->where('teacher_id',$id)->where('level',5)->count();
|
|
|
//评价为四星的人数
|
|
|
$four = Db::name('comment')->where('teacher_id',$id)->where('level',4)->count();
|
|
|
//评价为三星的人数
|
|
|
$three = Db::name('comment')->where('teacher_id',$id)->where('level',3)->count();
|
|
|
//评价为二星的人数
|
|
|
$two = Db::name('comment')->where('teacher_id',$id)->where('level',2)->count();
|
|
|
//评价为一星的人数
|
|
|
$one = Db::name('comment')->where('teacher_id',$id)->where('level',1)->count();
|
|
|
if(!empty($comment)){
|
|
|
$data['help_num'] = $five + $four + $three + $two + $one + $data['help_num'];
|
|
|
$data['level'] = ceil(($data['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$data['help_num']);
|
|
|
//查看老师的已帮助人数以及评分星级
|
|
|
$comment = Db::name('comment')->where('teacher_id',$id)->select();
|
|
|
//评价为五星的人数
|
|
|
$five = Db::name('comment')->where('teacher_id',$id)->where('level',5)->count();
|
|
|
//评价为四星的人数
|
|
|
$four = Db::name('comment')->where('teacher_id',$id)->where('level',4)->count();
|
|
|
//评价为三星的人数
|
|
|
$three = Db::name('comment')->where('teacher_id',$id)->where('level',3)->count();
|
|
|
//评价为二星的人数
|
|
|
$two = Db::name('comment')->where('teacher_id',$id)->where('level',2)->count();
|
|
|
//评价为一星的人数
|
|
|
$one = Db::name('comment')->where('teacher_id',$id)->where('level',1)->count();
|
|
|
if(!empty($comment)){
|
|
|
$data['help_num'] = $five + $four + $three + $two + $one + $data['help_num'];
|
|
|
$data['level'] = ceil(($data['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$data['help_num']);
|
|
|
}
|
|
|
$data['before'] = $http.$data['before'];
|
|
|
$data['behind'] = $http.$data['behind'];
|
|
|
$data['thumbnail'] = $http.$data['thumbnail'];
|
|
|
$territory_id = explode(',',$data['territory_id']);
|
|
|
$data['territory_id'] = Db::name('territory')
|
|
|
->alias('a')
|
|
|
->join('contype b','a.contype_id = b.id')
|
|
|
->field('a.id,a.money,a.content,b.title,b.type')
|
|
|
->whereIn('a.id',$territory_id)
|
|
|
->select();
|
|
|
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
$data['before'] = $http.$data['before'];
|
|
|
$data['behind'] = $http.$data['behind'];
|
|
|
$data['thumbnail'] = $http.$data['thumbnail'];
|
|
|
$territory_id = explode(',',$data['territory_id']);
|
|
|
$data['territory_id'] = Db::name('territory')
|
|
|
->alias('a')
|
|
|
->join('contype b','a.contype_id = b.id')
|
|
|
->field('a.id,a.money,a.content,b.title,b.type')
|
|
|
->whereIn('a.id',$territory_id)
|
|
|
->select();
|
|
|
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|