作者 lianghiu
此 diff 太大无法显示。
@@ -18,7 +18,10 @@ use think\Db; @@ -18,7 +18,10 @@ use think\Db;
18 18
19 class CommentController extends UserBaseController 19 class CommentController extends UserBaseController
20 { 20 {
21 - //去评价 21 + /**
  22 + * 学生评价部分
  23 + */
  24 + //学员去评价教练
22 public function index(){ 25 public function index(){
23 $id = $this->request->param("id", 0, "intval"); 26 $id = $this->request->param("id", 0, "intval");
24 $yuyue_id = $this->request->param("yuyue_id", 0, "intval"); 27 $yuyue_id = $this->request->param("yuyue_id", 0, "intval");
@@ -35,7 +38,7 @@ class CommentController extends UserBaseController @@ -35,7 +38,7 @@ class CommentController extends UserBaseController
35 $this->assign("yuyue_id", $yuyue_id); 38 $this->assign("yuyue_id", $yuyue_id);
36 return $this->fetch('go_ping'); 39 return $this->fetch('go_ping');
37 } 40 }
38 - //评价提交接口 41 + //学员去评价教练提交接口
39 public function comment_do_by_stu(){ 42 public function comment_do_by_stu(){
40 $data = $this->request->param(); 43 $data = $this->request->param();
41 if(!$data){ 44 if(!$data){
@@ -44,6 +47,10 @@ class CommentController extends UserBaseController @@ -44,6 +47,10 @@ class CommentController extends UserBaseController
44 $dataa['teach_id'] = $data['teach_id']; 47 $dataa['teach_id'] = $data['teach_id'];
45 $dataa['yuyue_id'] = $data['yuyue_id']; 48 $dataa['yuyue_id'] = $data['yuyue_id'];
46 $dataa['uid'] = session('user.id'); 49 $dataa['uid'] = session('user.id');
  50 + $yiping = Db::name('commente')->where($dataa)->find();
  51 + if($yiping){
  52 + return json(['code'=>'1','msg'=>'您已经评价']);
  53 + }
47 $dataa['create_time'] = time(); 54 $dataa['create_time'] = time();
48 $dataa['comment_tag'] = $data['comment_tag']; 55 $dataa['comment_tag'] = $data['comment_tag'];
49 $dataa['comment'] = $data['comment']; 56 $dataa['comment'] = $data['comment'];
@@ -57,20 +64,86 @@ class CommentController extends UserBaseController @@ -57,20 +64,86 @@ class CommentController extends UserBaseController
57 }else{ 64 }else{
58 return json(['code'=>'0','msg'=>'抱歉,评价失败']); 65 return json(['code'=>'0','msg'=>'抱歉,评价失败']);
59 } 66 }
60 - } //评价提交接口 67 + }
  68 + //评价详情--对教练的评价
  69 + public function show_stu(){
  70 + $id = $this->request->param("yuyue_id", 0, "intval");
  71 + if(!$id){
  72 + $this->error('数据异常');
  73 + }
  74 + //获取预约信息
  75 + $yuyue_data = Db::name('yuyue')
  76 + ->alias('yy')
  77 + ->join('qnb_user qu','qu.id = yy .teach_id')
  78 + ->field('yy.*,qu.user_nickname,qu.headimgurl')
  79 + ->where(['yy.id'=>$id])
  80 + ->find();
  81 + $teach_id = $yuyue_data['teach_id'];
  82 + $kemu = Db::name('user')->where(['id'=>$yuyue_data['uid']])->value('kemu');
  83 + $yuyue_data['kemu'] = $kemu;
  84 + //获取标签
  85 + $rre = Db::name('commente')->where(['yuyue_id'=>$id,'teach_id'=>$teach_id])->find();
  86 + $rree = Db::name('commente_tag')->where(['id'=>['in',$rre['comment_tag']]])->field('name')->select()->toArray();
  87 +
  88 + $this->assign("yuyue",$yuyue_data);
  89 + $this->assign("ctdata",$rree);
  90 + $this->assign("cdata",$rre);
  91 + return $this->fetch('look_ping');
  92 + }
  93 +
  94 + /**
  95 + * 教练评价部分
  96 + */
  97 + public function pingjia_by_coach(){
  98 + $id = $this->request->param("yuyue_id", 0, "intval");
  99 + $uid = $this->request->param("id", 0, "intval");
  100 + $this->assign('yuyue_id',$id);
  101 + $this->assign('uid',$uid);
  102 + return $this->fetch('ping_stu');
  103 + }
  104 + //对学生的评价放到commente1
  105 + public function pingjia_by_coach_do(){
  106 + $id = $this->request->param("yuyue_id", 0, "intval");
  107 + $uid = $this->request->param("uid", 0, "intval");
  108 + $comment = $this->request->param("comment");
  109 + if($id && $uid){
  110 + $data['uid'] = $uid;
  111 + $data['yuyue_id'] = $id;
  112 + $data['teach_id'] = session('user.id');
  113 + $data['comment'] = $comment;
  114 + $data['create_time'] = time();
  115 + $re = DB::name('commente1')->insert($data);
  116 + $res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']);
  117 + if($re){
  118 + return json(['code'=>'1','msg'=>'评价成功']);
  119 + }else{
  120 + return json(['code'=>'0','msg'=>'抱歉,评价失败']);
  121 + }
  122 + }else{
  123 + return json(['code'=>'0','msg'=>'数据异常']);
  124 + }
  125 + }
  126 + //教练对学生的评价提交
61 public function comment_do(){ 127 public function comment_do(){
62 $data = $this->request->param(); 128 $data = $this->request->param();
63 if(!$data){ 129 if(!$data){
64 return json(['code'=>'0','msg'=>'非法提交']); 130 return json(['code'=>'0','msg'=>'非法提交']);
65 } 131 }
  132 +
66 $dataa['teach_id'] = $data['teach_id']; 133 $dataa['teach_id'] = $data['teach_id'];
67 $dataa['yuyue_id'] = $data['yuyue_id']; 134 $dataa['yuyue_id'] = $data['yuyue_id'];
68 $dataa['uid'] = session('user.id'); 135 $dataa['uid'] = session('user.id');
  136 + $yiping = Db::name('commente1')->where($dataa)->find();
  137 + if($yiping){
  138 + return json(['code'=>'1','msg'=>'您已经评价']);
  139 + }
  140 +
  141 +
69 $dataa['create_time'] = time(); 142 $dataa['create_time'] = time();
70 $dataa['comment_tag'] = $data['comment_tag']; 143 $dataa['comment_tag'] = $data['comment_tag'];
71 $dataa['comment'] = $data['comment']; 144 $dataa['comment'] = $data['comment'];
72 $dataa['type'] = $data['type']; 145 $dataa['type'] = $data['type'];
73 - $re = Db::name('commente')->insert($dataa); 146 + $re = Db::name('commente1')->insert($dataa);
74 $res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']); 147 $res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']);
75 //echo Db::name('yuyue')->getLastSql(); 148 //echo Db::name('yuyue')->getLastSql();
76 149
@@ -80,7 +153,7 @@ class CommentController extends UserBaseController @@ -80,7 +153,7 @@ class CommentController extends UserBaseController
80 return json(['code'=>'0','msg'=>'抱歉,评价失败']); 153 return json(['code'=>'0','msg'=>'抱歉,评价失败']);
81 } 154 }
82 } 155 }
83 - //评价详情--对学生的评价 156 + //评价详情--教练对学生的评价
84 public function show(){ 157 public function show(){
85 $id = $this->request->param("yuyue_id", 0, "intval"); 158 $id = $this->request->param("yuyue_id", 0, "intval");
86 159
@@ -91,54 +164,22 @@ class CommentController extends UserBaseController @@ -91,54 +164,22 @@ class CommentController extends UserBaseController
91 $yuyue_data = Db::name('yuyue') 164 $yuyue_data = Db::name('yuyue')
92 ->alias('yy') 165 ->alias('yy')
93 ->join('qnb_user qu','qu.id = yy.uid') 166 ->join('qnb_user qu','qu.id = yy.uid')
94 - ->field('yy.*,qu.user_nickname,qu.headimgurl') 167 + ->field('yy.*,qu.user_nickname,qu.headimgurl,qu.kemu')
95 ->where(['yy.id'=>$id]) 168 ->where(['yy.id'=>$id])
96 ->find(); 169 ->find();
97 $uid = $yuyue_data['uid']; 170 $uid = $yuyue_data['uid'];
98 - //获取学车的资料  
99 - $gname = Db::name('goods')  
100 - ->alias('g')  
101 - ->join('qnb_order qo','qo.gid = g.id')  
102 - ->where(['qo.uid'=>$yuyue_data['uid'],'qo.status'=>1])  
103 - ->value('g.name');  
104 //获取评价 171 //获取评价
105 $cdata = Db::name('commente1')->where(['uid'=>$uid,'yuyue_id'=>$id])->find(); 172 $cdata = Db::name('commente1')->where(['uid'=>$uid,'yuyue_id'=>$id])->find();
106 173
107 - $this->assign("gname",$gname);  
108 $this->assign("yuyue",$yuyue_data); 174 $this->assign("yuyue",$yuyue_data);
109 $this->assign("cdata",$cdata); 175 $this->assign("cdata",$cdata);
110 return $this->fetch('my_ping'); 176 return $this->fetch('my_ping');
111 } 177 }
112 - //评价详情--教练的评价  
113 - public function show_stu(){  
114 - $id = $this->request->param("yuyue_id", 0, "intval");  
115 - if(!$id){  
116 - $this->error('数据异常');  
117 - }  
118 - //获取预约信息  
119 - $yuyue_data = Db::name('yuyue')  
120 - ->alias('yy')  
121 - ->join('qnb_user qu','qu.id = yy .teach_id')  
122 - ->field('yy.*,qu.user_nickname,qu.headimgurl')  
123 - ->where(['yy.id'=>$id])  
124 - ->find();  
125 - //获取学车的资料  
126 - $teach_id = $yuyue_data['teach_id'];  
127 - $gname = Db::name('goods')  
128 - ->alias('g')  
129 - ->join('qnb_order qo','qo.gid = g.id')  
130 - ->where(['qo.uid'=>$yuyue_data['uid'],'qo.status'=>1])  
131 - ->value('g.name');  
132 - //获取标签  
133 - $rre = Db::name('commente')->where(['teach_id'=>$teach_id])->find();  
134 - $rree = Db::name('commente_tag')->where(['id'=>['in',$rre['comment_tag']]])->field('name')->select()->toArray();  
135 178
136 - $this->assign("gname",$gname);  
137 - $this->assign("yuyue",$yuyue_data);  
138 - $this->assign("ctdata",$rree);  
139 - $this->assign("cdata",$rre);  
140 - return $this->fetch('look_ping');  
141 - } 179 +
  180 +
  181 +
  182 +
142 183
143 //评价详情--对教练的评价 184 //评价详情--对教练的评价
144 public function jindu(){ 185 public function jindu(){
@@ -167,36 +208,6 @@ class CommentController extends UserBaseController @@ -167,36 +208,6 @@ class CommentController extends UserBaseController
167 208
168 } 209 }
169 210
170 - public function pingjia_by_coach(){  
171 - $id = $this->request->param("yuyue_id", 0, "intval");  
172 - $uid = $this->request->param("id", 0, "intval");  
173 - $this->assign('yuyue_id',$id);  
174 - $this->assign('uid',$uid);  
175 - return $this->fetch('ping_stu');  
176 - }  
177 - //对学生的评价放到commente1  
178 - public function pingjia_by_coach_do(){  
179 - $id = $this->request->param("yuyue_id", 0, "intval");  
180 - $uid = $this->request->param("uid", 0, "intval");  
181 - $comment = $this->request->param("comment");  
182 - if($id && $uid){  
183 - $data['uid'] = $uid;  
184 - $data['yuyue_id'] = $id;  
185 - $data['teach_id'] = session('user.id');  
186 - $data['comment'] = $comment;  
187 - $data['create_time'] = time();  
188 - $re = DB::name('commente1')->insert($data);  
189 - $res = Db::name('yuyue')->where(['id'=>$data['yuyue_id']])->update(['status'=>'3','pingjia_xueyuan'=>'1']);  
190 - if($re){  
191 - return json(['code'=>'1','msg'=>'评价成功']);  
192 - }else{  
193 - return json(['code'=>'0','msg'=>'抱歉,评价失败']);  
194 - }  
195 - }else{  
196 - return json(['code'=>'0','msg'=>'数据异常']);  
197 - }  
198 - }  
199 -  
200 211
201 212
202 213
@@ -35,15 +35,17 @@ class ProfileController extends UserBaseController @@ -35,15 +35,17 @@ class ProfileController extends UserBaseController
35 if ($data['user_type'] == '3') { 35 if ($data['user_type'] == '3') {
36 $yyxs = Db::name('yuyue') 36 $yyxs = Db::name('yuyue')
37 ->where(['teach_id' => $uid, 'status' => 3]) 37 ->where(['teach_id' => $uid, 'status' => 3])
38 - ->count();  
39 - $yyxs = $yyxs ? $yyxs : 0; 38 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  39 + ->select()->toArray();
  40 + $yyxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
40 $this->assign("yyxs", $yyxs); 41 $this->assign("yyxs", $yyxs);
41 return $this->fetch('percenter_coach'); 42 return $this->fetch('percenter_coach');
42 } else { 43 } else {
43 $yyxs = Db::name('yuyue') 44 $yyxs = Db::name('yuyue')
44 ->where(['uid' => $uid, 'status' => 3]) 45 ->where(['uid' => $uid, 'status' => 3])
45 - ->count();  
46 - $yyxs = $yyxs ? $yyxs : 0; 46 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  47 + ->select()->toArray();
  48 + $yyxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
47 $this->assign("yyxs", $yyxs); 49 $this->assign("yyxs", $yyxs);
48 return $this->fetch('percenter_stu'); 50 return $this->fetch('percenter_stu');
49 } 51 }
@@ -406,10 +406,16 @@ class YuyueController extends UserBaseController @@ -406,10 +406,16 @@ class YuyueController extends UserBaseController
406 ->select() 406 ->select()
407 ->toArray(); 407 ->toArray();
408 408
  409 +// $yyxs = Db::name('yuyue')
  410 +// ->where(['uid' => $id, 'status' => 3])
  411 +// ->count();
  412 +// $yyxs = $yyxs ? $yyxs : 0;
  413 +
409 $yyxs = Db::name('yuyue') 414 $yyxs = Db::name('yuyue')
410 ->where(['uid' => $id, 'status' => 3]) 415 ->where(['uid' => $id, 'status' => 3])
411 - ->count();  
412 - $yyxs = $yyxs ? $yyxs : 0; 416 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  417 + ->select()->toArray();
  418 + $yyxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
413 419
414 $this->assign("data", $data); 420 $this->assign("data", $data);
415 $this->assign("yyxs", $yyxs); 421 $this->assign("yyxs", $yyxs);
@@ -483,10 +489,16 @@ class YuyueController extends UserBaseController @@ -483,10 +489,16 @@ class YuyueController extends UserBaseController
483 ->select() 489 ->select()
484 ->toArray(); 490 ->toArray();
485 491
486 - $yjxs = Db::name('yuyue') 492 +// $yjxs = Db::name('yuyue')
  493 +// ->where(['teach_id' => $id, 'status' => 3])
  494 +// ->count();
  495 +// $yjxs = $yjxs ? $yjxs : 0;
  496 +
  497 + $yyxs = Db::name('yuyue')
487 ->where(['teach_id' => $id, 'status' => 3]) 498 ->where(['teach_id' => $id, 'status' => 3])
488 - ->count();  
489 - $yjxs = $yjxs ? $yjxs : 0; 499 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  500 + ->select()->toArray();
  501 + $yjxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
490 502
491 $this->assign("data", $data); 503 $this->assign("data", $data);
492 $this->assign("data1", $data1); 504 $this->assign("data1", $data1);
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <img src="{$yuyue.headimgurl}" class="yu_user_head"/> 19 <img src="{$yuyue.headimgurl}" class="yu_user_head"/>
20 <div class="yu_user_info"> 20 <div class="yu_user_info">
21 <b class="user_name">{$yuyue.user_nickname}</b> 21 <b class="user_name">{$yuyue.user_nickname}</b>
22 - <i class="user_fun">{$gname}</i> 22 + <i class="user_fun">{$yuyue.kemu}</i>
23 </div> 23 </div>
24 <div class="yu_date"> 24 <div class="yu_date">
25 <b class="yu_week">{$yuyue.yuyue_week}</b> 25 <b class="yu_week">{$yuyue.yuyue_week}</b>
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 <img src="{$yuyue.headimgurl}" class="yu_user_head"/> 25 <img src="{$yuyue.headimgurl}" class="yu_user_head"/>
26 <div class="yu_user_info"> 26 <div class="yu_user_info">
27 <b class="user_name">{$yuyue.user_nickname}</b> 27 <b class="user_name">{$yuyue.user_nickname}</b>
28 - <i class="user_fun">{$gname}</i> 28 + <i class="user_fun">{$yuyue.kemu}</i>
29 </div> 29 </div>
30 <div class="yu_date"> 30 <div class="yu_date">
31 <b class="yu_week">{$yuyue.yuyue_week}</b> 31 <b class="yu_week">{$yuyue.yuyue_week}</b>
@@ -60,26 +60,35 @@ @@ -60,26 +60,35 @@
60 $('#wordage').html(pattern); 60 $('#wordage').html(pattern);
61 } 61 }
62 ); 62 );
  63 + var click_num = 0;
63 $('.btn_ping').click(function () { 64 $('.btn_ping').click(function () {
64 - var str_len = $('#wordtext').val().length;  
65 - if (str_len ==0) {  
66 - layer.msg('评价不能为空!')  
67 - } else {  
68 - $.ajax({  
69 - url: "{:url('pingjia_by_coach_do')}",  
70 - data: {  
71 - uid: {$uid},  
72 - yuyue_id: {$yuyue_id},  
73 - comment: $('#wordtext').val()  
74 - },  
75 - success: function (res) {  
76 - console.log(res);  
77 - if (res.code == '1') {  
78 - layer.msg(res.msg);  
79 - window.location.href="/user/profile/percenter"; 65 + if(click_num == 0){
  66 + click_num++;
  67 + var str_len = $('#wordtext').val().length;
  68 + if (str_len ==0) {
  69 + layer.msg('评价不能为空!')
  70 + } else {
  71 + $.ajax({
  72 + url: "{:url('pingjia_by_coach_do')}",
  73 + data: {
  74 + uid: {$uid},
  75 + yuyue_id: {$yuyue_id},
  76 + comment: $('#wordtext').val()
  77 + },
  78 + success: function (res) {
  79 + console.log(res);
  80 + if (res.code == '1') {
  81 + layer.msg(res.msg);
  82 + window.location.href="/user/profile/percenter";
  83 + }
  84 + },
  85 + error:function(err){
  86 + click_num=0;
80 } 87 }
81 - }  
82 - }); 88 + });
  89 + }
  90 + }else{
  91 + layer.msg("请勿重复评价");
83 } 92 }
84 }); 93 });
85 })(window, jQuery) 94 })(window, jQuery)
@@ -241,33 +241,11 @@ @@ -241,33 +241,11 @@
241 <i class="yu_times">{$vo.yuyue_begin}:00 - {$vo.yuyue_end}:00</i> 241 <i class="yu_times">{$vo.yuyue_begin}:00 - {$vo.yuyue_end}:00</i>
242 </div> 242 </div>
243 </div> 243 </div>
244 - <switch name="$vo.status">  
245 - <case value="1">  
246 - <div class="yuyue_btn">  
247 - <b class="click_yuyue" data-id="{$vo.id}">开始学车</b>  
248 - <b class="click_jindu"  
249 - onclick=location.href="{:url('user/comment/jindu',array('id'=>$vo['uid'],'yuyue_id'=>$vo['id']))}">查看进度</b>  
250 - </div>  
251 - </case>  
252 - <case value="2">  
253 - <div class="yuyue_btn" onclick=location.href="{:url('user/comment/pingjia_by_coach',array('id'=>  
254 - $vo['uid'],'yuyue_id'=>$vo['id']))}">  
255 - <b class="click_yuyue">去评价</b>  
256 - </div>  
257 - </case>  
258 - <case value="3">  
259 - <div class="yuyue_btn" onclick=location.href="{:url('user/comment/show',array('id'=>  
260 - $vo['uid'],'yuyue_id'=>$vo['id']))}">  
261 - <b class="click_yuyue">查看评价</b>  
262 - </div>  
263 - </case>  
264 - <case value="4">  
265 - <div class="yuyue_btn">  
266 - <b class="click_yuyue" data-id="{$vo.id}">学车完毕</b>  
267 - </div>  
268 - </case>  
269 - <default/>  
270 - </switch> 244 +
  245 + <div class="yuyue_btn" onclick=location.href="{:url('user/comment/pingjia_by_coach',array('id'=>
  246 + $vo['uid'],'yuyue_id'=>$vo['id']))}">
  247 + <b class="click_yuyue">去评价</b>
  248 + </div>
271 </div> 249 </div>
272 </volist> 250 </volist>
273 </empty> 251 </empty>
@@ -2089,12 +2089,18 @@ function birthday_old($id){ @@ -2089,12 +2089,18 @@ function birthday_old($id){
2089 function id_xueshi($id){ 2089 function id_xueshi($id){
2090 $name = Db::name('yuyue') 2090 $name = Db::name('yuyue')
2091 ->where(['uid'=>$id,'status'=>'3']) 2091 ->where(['uid'=>$id,'status'=>'3'])
2092 - ->count();  
2093 - return $name; 2092 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  2093 + ->select()->toArray();
  2094 +// return Db::name('yuyue')->getLastSql();
  2095 + // return json_encode($name,true) ;
  2096 + $yyxs = $name ? $name[0]['yyxs'] : '0';
  2097 + return $yyxs;
2094 } 2098 }
2095 function tid_xueshi($id){ 2099 function tid_xueshi($id){
2096 $name = Db::name('yuyue') 2100 $name = Db::name('yuyue')
2097 ->where(['teach_id'=>$id,'status'=>'3']) 2101 ->where(['teach_id'=>$id,'status'=>'3'])
2098 - ->count();  
2099 - return $name; 2102 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  2103 + ->select()->toArray();
  2104 + $yyxs = $name ? $name[0]['yyxs'] : '0';
  2105 + return $yyxs;
2100 } 2106 }