CommentController.php
7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;
use app\user\model\CommentModel;
use cmf\controller\UserBaseController;
use app\user\model\UserModel;
use think\Db;
class CommentController extends UserBaseController
{
/**
* 学生评价部分
*/
//学员去评价教练
public function index(){
$id = $this->request->param("id", 0, "intval");
$yuyue_id = $this->request->param("yuyue_id", 0, "intval");
if(!$id){
$this->error('数据异常');
}
//获取评论标签
$ctag1 = Db::name('commente_tag')->where(['type'=>'1'])->select()->toArray();
$ctag2 = Db::name('commente_tag')->where(['type'=>'2'])->select()->toArray();
$this->assign("ctag1", $ctag1);
$this->assign("ctag2", $ctag2);
$this->assign("teach_id", $id);
$this->assign("yuyue_id", $yuyue_id);
return $this->fetch('go_ping');
}
//学员去评价教练提交接口
public function comment_do_by_stu(){
$data = $this->request->param();
if(!$data){
return json(['code'=>'0','msg'=>'非法提交']);
}
$dataa['teach_id'] = $data['teach_id'];
$dataa['yuyue_id'] = $data['yuyue_id'];
$dataa['uid'] = session('user.id');
$yiping = Db::name('commente')->where($dataa)->find();
if($yiping){
return json(['code'=>'1','msg'=>'您已经评价']);
}
$dataa['create_time'] = time();
$dataa['comment_tag'] = $data['comment_tag'];
$dataa['comment'] = $data['comment'];
$dataa['type'] = $data['type'];
$re = Db::name('commente')->insert($dataa);
$res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_jiaolian'=>'1']);
//echo Db::name('yuyue')->getLastSql();
if($re){
return json(['code'=>'1','msg'=>'评价成功']);
}else{
return json(['code'=>'0','msg'=>'抱歉,评价失败']);
}
}
//评价详情--对教练的评价
public function show_stu(){
$id = $this->request->param("yuyue_id", 0, "intval");
if(!$id){
$this->error('数据异常');
}
//获取预约信息
$yuyue_data = Db::name('yuyue')
->alias('yy')
->join('qnb_user qu','qu.id = yy .teach_id')
->field('yy.*,qu.user_nickname,qu.headimgurl')
->where(['yy.id'=>$id])
->find();
$teach_id = $yuyue_data['teach_id'];
$kemu = Db::name('user')->where(['id'=>$yuyue_data['uid']])->value('kemu');
$yuyue_data['kemu'] = $kemu;
//获取标签
$rre = Db::name('commente')->where(['yuyue_id'=>$id,'teach_id'=>$teach_id])->find();
$rree = Db::name('commente_tag')->where(['id'=>['in',$rre['comment_tag']]])->field('name')->select()->toArray();
$this->assign("yuyue",$yuyue_data);
$this->assign("ctdata",$rree);
$this->assign("cdata",$rre);
return $this->fetch('look_ping');
}
/**
* 教练评价部分
*/
public function pingjia_by_coach(){
$id = $this->request->param("yuyue_id", 0, "intval");
$uid = $this->request->param("id", 0, "intval");
$this->assign('yuyue_id',$id);
$this->assign('uid',$uid);
return $this->fetch('ping_stu');
}
//对学生的评价放到commente1
public function pingjia_by_coach_do(){
$id = $this->request->param("yuyue_id", 0, "intval");
$uid = $this->request->param("uid", 0, "intval");
$comment = $this->request->param("comment");
if($id && $uid){
$data['uid'] = $uid;
$data['yuyue_id'] = $id;
$data['teach_id'] = session('user.id');
$data['comment'] = $comment;
$data['create_time'] = time();
$re = DB::name('commente1')->insert($data);
$res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']);
if($re){
return json(['code'=>'1','msg'=>'评价成功']);
}else{
return json(['code'=>'0','msg'=>'抱歉,评价失败']);
}
}else{
return json(['code'=>'0','msg'=>'数据异常']);
}
}
//教练对学生的评价提交
public function comment_do(){
$data = $this->request->param();
if(!$data){
return json(['code'=>'0','msg'=>'非法提交']);
}
$dataa['teach_id'] = $data['teach_id'];
$dataa['yuyue_id'] = $data['yuyue_id'];
$dataa['uid'] = session('user.id');
$yiping = Db::name('commente1')->where($dataa)->find();
if($yiping){
return json(['code'=>'1','msg'=>'您已经评价']);
}
$dataa['create_time'] = time();
$dataa['comment_tag'] = $data['comment_tag'];
$dataa['comment'] = $data['comment'];
$dataa['type'] = $data['type'];
$re = Db::name('commente1')->insert($dataa);
$res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']);
//echo Db::name('yuyue')->getLastSql();
if($re){
return json(['code'=>'1','msg'=>'评价成功']);
}else{
return json(['code'=>'0','msg'=>'抱歉,评价失败']);
}
}
//评价详情--教练对学生的评价
public function show(){
$id = $this->request->param("yuyue_id", 0, "intval");
if(!$id){
$this->error('数据异常');
}
//获取预约信息
$yuyue_data = Db::name('yuyue')
->alias('yy')
->join('qnb_user qu','qu.id = yy.uid')
->field('yy.*,qu.user_nickname,qu.headimgurl,qu.kemu')
->where(['yy.id'=>$id])
->find();
$uid = $yuyue_data['uid'];
//获取评价
$cdata = Db::name('commente1')->where(['uid'=>$uid,'yuyue_id'=>$id])->find();
$this->assign("yuyue",$yuyue_data);
$this->assign("cdata",$cdata);
return $this->fetch('my_ping');
}
//评价详情--对教练的评价
public function jindu(){
$id = $this->request->param("yuyue_id", 0, "intval");
$uid = $this->request->param("id", 0, "intval");
//获取预约信息
$yuyue_data = Db::name('yuyue')
->alias('yy')
->join('qnb_user qu','qu.id = yy .uid')
->join('order o','o.uid=yy.uid','LEFT')
->join('goods g','g.id=o.gid','LEFT')
->field('yy.*,qu.user_nickname,qu.mobile,qu.headimgurl,g.name as gname')
->where(['yy.id'=>$id])
->find();
//dump($yuyue_data);
$cdata = Db::name('commente1')
->alias('yy')
->join('qnb_user qu','qu.id = yy .teach_id')
->field('yy.*,qu.user_nickname,qu.mobile,qu.headimgurl')
->where(['uid'=>$uid])
->select();
$this->assign("yuyue",$yuyue_data);
$this->assign("cdata",$cdata);
return $this->fetch('look_jindu');
}
}