CommonController.php
4.4 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
<?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\AdminBaseController;
use cmf\controller\UserBaseController;
use app\user\model\UserModel;
use think\Db;
class CommonController extends AdminBaseController
{
// 中介评价
public function comment(){
$data = $this->request->param();
$size = 10;
if(empty($data['page'])){
$data['page'] = 1;
}
$page = $data['page'];
$where_comment['m.status'] = 1;
$arr = array();
if($data){
$startTime = empty($data['start_time']) ? 0 : strtotime($data['start_time']);
$endTime = empty($data['end_time']) ? 0 : strtotime($data['end_time']);
if ($startTime && $endTime) {
$arr['start_time'] = $data['start_time'];
$arr['end_time'] = $data['end_time'];
$where_comment['c.create_time'] = array('between',"$startTime,$endTime");
$this->assign('start_time', $data['start_time']);
$this->assign('end_time', $data['end_time']);
}else{
if($startTime){
$arr['start_time'] = $data['start_time'];
$where_comment['c.create_time'] = array('egt',$startTime);
$this->assign('start_time', $data['start_time']);
}
if($endTime){
$arr['end_time'] = $data['end_time'];
$where_comment['c.create_time'] = array('elt',$endTime);
$this->assign('end_time', $data['end_time']);
}
}
if(!empty($data['name'])){
$arr['name'] = $data['name'];
$where_comment['m.name'] = array('like','%'.$data['name'].'%');
$this->assign('name', $data['name']);
}
if(!empty($data['tel'])){
$arr['tel'] = $data['tel'];
$where_comment['m.tel'] = array('like','%'.$data['tel'].'%');
$this->assign('tel', $data['tel']);
}
}
$comment_list = Db::name('Comment')->alias('c')
->join("Member m",'m.id=c.user_id')
->where($where_comment)
->field('m.name as user_name,m.tel as user_tel,m.id as user_id,c.*')
->limit($size)->page($page)
->select()->toArray();
$count = Db::name('Comment')->alias('c')
->join("Member m",'m.id=c.user_id')
->where($where_comment)
->count();
$all_page = ceil($count/$size);
foreach ($comment_list as $comk=>$comv){
$where_agency['id'] = $comv['intermediary_id'];
$agency = Db::name('Member')->where($where_agency)->field('id,name,tel')->find();
$comment_list[$comk]['agency_id'] = $agency['id'];
$comment_list[$comk]['agency_name'] = $agency['name'];
$comment_list[$comk]['agency_tel'] = $agency['tel'];
}
$this->assign('count', $count);
$this->assign('page', $all_page);
$this->assign('lists',$comment_list);
return $this->fetch('common');
}
// 删除中介评价
public function agencyDel(){
$data = $this->request->param();
$where_com['id'] = $data['id'];
$where_com['status'] = array('neq',9);
$complaint = Db::name('Comment')->where($where_com)->find();
if($complaint){
$save['status'] = 9;
$save['update_time'] = time();
$update = Db::name('Comment')->where($where_com)->update($save);
if($update){
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}else{
$this->error('评论状态错误');
}
}
}