...
|
...
|
@@ -119,6 +119,9 @@ class Index extends Api |
|
|
*
|
|
|
* @ApiParams (name="type", type="int", required=false, description="类型(如果为空或者为1是今日推荐列表 2是更多老师列表)")
|
|
|
* @ApiParams (name="keyword", type="string", required=false, description="关键字")
|
|
|
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
*
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
...
|
...
|
@@ -151,6 +154,8 @@ class Index extends Api |
|
|
public function today()
|
|
|
{
|
|
|
$token = $this->request->header('token');
|
|
|
$page = $this->request->param('page', 1, 'intval');
|
|
|
$pageNum = $this->request->param('pageNum', 10, 'intval');
|
|
|
//未登录的状态下
|
|
|
if(empty($token)){
|
|
|
$type = $this->request->param('type');
|
...
|
...
|
@@ -160,6 +165,7 @@ class Index extends Api |
|
|
->where('status',1)
|
|
|
->where('is_recommend',1)
|
|
|
->field('status,updatetime',true)
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
}else{
|
|
|
if(!empty($keyword)){
|
...
|
...
|
@@ -178,6 +184,7 @@ class Index extends Api |
|
|
->whereOr('honor','Like',"%$keyword%")
|
|
|
->whereOr('user_id','In',$territory)
|
|
|
->field('status,updatetime',true)
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
}else{
|
|
|
$data = Db::name('teacher')
|
...
|
...
|
@@ -189,6 +196,22 @@ class Index extends Api |
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
foreach ($data as &$v){
|
|
|
//查看老师的已帮助人数以及评分星级
|
|
|
$comment = Db::name('comment')->where('teacher_id',$v['id'])->select();
|
|
|
//评价为五星的人数
|
|
|
$five = Db::name('comment')->where('teacher_id',$v['id'])->where('level',5)->count();
|
|
|
//评价为四星的人数
|
|
|
$four = Db::name('comment')->where('teacher_id',$v['id'])->where('level',4)->count();
|
|
|
//评价为三星的人数
|
|
|
$three = Db::name('comment')->where('teacher_id',$v['id'])->where('level',3)->count();
|
|
|
//评价为二星的人数
|
|
|
$two = Db::name('comment')->where('teacher_id',$v['id'])->where('level',2)->count();
|
|
|
//评价为一星的人数
|
|
|
$one = Db::name('comment')->where('teacher_id',$v['id'])->where('level',1)->count();
|
|
|
if(!empty($comment)){
|
|
|
$v['help_num'] = $five + $four + $three + $two + $one + $v['help_num'];
|
|
|
$v['level'] = ceil(($v['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$v['help_num']);
|
|
|
}
|
|
|
if($v['sex'] == 1){
|
|
|
$v['sex'] = '男';
|
|
|
}else{
|
...
|
...
|
@@ -268,6 +291,22 @@ class Index extends Api |
|
|
$qiniu = get_addon_config('qiniu');
|
|
|
$http = $qiniu['cdnurl'];
|
|
|
foreach ($data as &$v){
|
|
|
//查看老师的已帮助人数以及评分星级
|
|
|
$comment = Db::name('comment')->where('teacher_id',$v['id'])->select();
|
|
|
//评价为五星的人数
|
|
|
$five = Db::name('comment')->where('teacher_id',$v['id'])->where('level',5)->count();
|
|
|
//评价为四星的人数
|
|
|
$four = Db::name('comment')->where('teacher_id',$v['id'])->where('level',4)->count();
|
|
|
//评价为三星的人数
|
|
|
$three = Db::name('comment')->where('teacher_id',$v['id'])->where('level',3)->count();
|
|
|
//评价为二星的人数
|
|
|
$two = Db::name('comment')->where('teacher_id',$v['id'])->where('level',2)->count();
|
|
|
//评价为一星的人数
|
|
|
$one = Db::name('comment')->where('teacher_id',$v['id'])->where('level',1)->count();
|
|
|
if(!empty($comment)){
|
|
|
$v['help_num'] = $five + $four + $three + $two + $one + $v['help_num'];
|
|
|
$v['level'] = ceil(($v['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$v['help_num']);
|
|
|
}
|
|
|
if($v['sex'] == 1){
|
|
|
$v['sex'] = '男';
|
|
|
}else{
|
...
|
...
|
@@ -366,6 +405,7 @@ class Index extends Api |
|
|
"level"://星级
|
|
|
"createtime"://创建时间
|
|
|
"is_guan"://是否关注(1已关注2还未关注)
|
|
|
"you_num"://优惠劵个数
|
|
|
}
|
|
|
})
|
|
|
*/
|
...
|
...
|
@@ -396,6 +436,29 @@ class Index extends Api |
|
|
}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']);
|
|
|
}
|
|
|
$data['before'] = $http.$data['before'];
|
|
|
$data['behind'] = $http.$data['behind'];
|
|
|
$data['thumbnail'] = $http.$data['thumbnail'];
|
...
|
...
|
@@ -403,7 +466,7 @@ class Index extends Api |
|
|
$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')
|
|
|
->field('a.id,a.money,a.content,b.title,b.type')
|
|
|
->whereIn('a.id',$territory_id)
|
|
|
->select();
|
|
|
|
...
|
...
|
@@ -411,6 +474,51 @@ class Index extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (学员评价列表)
|
|
|
* @ApiSummary (学员评价列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/index/commentlist)
|
|
|
*
|
|
|
* @ApiParams (name="id", type="string", required=true, description="老师ID")
|
|
|
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1571492001",
|
|
|
"data": {
|
|
|
'id'://评价ID
|
|
|
'content'://评价内容
|
|
|
'nickname'://昵称
|
|
|
'avatar'://头像
|
|
|
'createtime':创建时间
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function commentlist()
|
|
|
{
|
|
|
$id = $this->request->param('id');
|
|
|
$page = $this->request->param('page', 1, 'intval');
|
|
|
$pageNum = $this->request->param('pageNum', 10, 'intval');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$data = Db::name('comment')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->field('a.id,a.content,a.createtime,b.nickname,b.avatar')
|
|
|
->where('a.teacher_id',$id)
|
|
|
->order('a.createtime desc')
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$v['createtime'] = date('Y-m-d',$v['createtime']);
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (老师关注/取消关注接口)
|
|
|
* @ApiSummary (老师关注/取消关注接口)
|
|
|
* @ApiMethod (POST)
|
...
|
...
|
@@ -458,4 +566,6 @@ class Index extends Api |
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|