ComplaintController.php
8.0 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
<?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\portal\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use think\Loader;
use think\Request;
class ComplaintController extends AdminBaseController
{
// 提现申请
public function index(){
$data = $this->request->param();
$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_money['d.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_money['d.create_time'] = array('egt',$startTime);
$this->assign('start_time', $data['start_time']);
}
if($endTime){
$arr['end_time'] = $data['end_time'];
$where_money['d.create_time'] = array('elt',$endTime);
$this->assign('end_time', $data['end_time']);
}
}
if(!empty($data['name'])){
$arr['name'] = $data['name'];
$where_money['name'] = array('like','%'.$data['name'].'%');
$this->assign('name', $data['name']);
}
if(!empty($data['tel'])){
$arr['tel'] = $data['tel'];
$where_money['tel'] = array('like','%'.$data['tel'].'%');
$this->assign('tel', $data['tel']);
}
}
$where_money['c.status'] = array('neq',9);
$money_list = Db::name('Complaint')->alias('c')
->join("Member m",'m.id = c.user_id')
->where($where_money)
->field("m.name,m.tel,c.*")
->order('c.create_time desc')
->paginate(10,false,['query'=>$arr]);
$page = $money_list->render();
$this->assign('page',$page);
$this->assign('lists',$money_list);
return $this->fetch('getdetail');
}
// 同意投诉
public function agree(){
$data = $this->request->param();
$where_money['id'] = $data['id'];
$where_money['status'] = array('neq',9);
$money = Db::name('Complaint')->where($where_money)->find();
if($money){
if($money['type'] == 1){
// 用户投诉
$add_get['type'] = 3;
$where_agency['id'] = $money['intermediary_id'];
$where_agency['status'] = array('neq','1,9');
$agency = Db::name('Agency')->where($where_agency)->find();
if($agency){
$update_agency['update_time'] = time();
$update_agency['is_refuse'] = 3;
$agency_up = Db::name('Agency')->where($where_agency)->update($update_agency);
if(!$agency_up){
$this->error('失败');
}
}
$add_get['money'] = $agency['deposit'];
}else if($money['type'] == 2){
// 中介投诉
$add_get['type'] = 2;
$where_need['id'] = $money['need_id'];
$where_need['status'] = array('neq','1,9');
$need = Db::name('UserNeed')->where($where_need)->find();
if($need){
$update_need['update_time'] = time();
$update_need['is_refuse'] = 3;
$need_up = Db::name('UserNeed')->where($where_need)->update($update_need);
if(!$need_up){
$this->error('失败');
}
}
$add_get['money'] = $need['pay_money'];
}
$add_get['agency_id'] = $money['intermediary_id'];
$add_get['complaint'] = $money['id'];
$add_get['create_time'] = time();
$add_get['update_time'] = time();
$res = Db::name('Get')->insertGetId($add_get);
if(!$res){
$this->error('失败');
}
$save['status'] = 2;
$save['update_time'] = time();
$update = Db::name('Complaint')->where($where_money)->update($save);
if($update){
$this->success('成功');
}else{
$this->error('失败');
}
}else{
$this->error('投诉状态不正确');
}
}
// 拒绝投诉
public function refuse(){
$data = $this->request->param();
$time = time();
$where_money['id'] = $data['id'];
$where_money['status'] = array('neq',9);
$money = Db::name('Complaint')->where($where_money)->find();
if($money){
$save['status'] = 3;
$save['update_time'] = time();
$update = Db::name('Complaint')->where($where_money)->update($save);
if($update){
if($money['type'] == 2){
// 中介投诉
$where_need['id'] = $money['need_id'];
$where_need['status'] = array('neq',9);
$findNeed = Db::name('UserNeed')->where($where_need)->find();
$needTime = ($findNeed['next_choose_time']+259200)-$findNeed['complaint_time'];
$change_need['refuse_complaint_time'] = $time+$needTime;
$change_need['status'] = 7;
$change_need['is_refuse'] = 4;
$saveNeed = Db::name('UserNeed')->where($where_need)->update($change_need);
if(!$saveNeed){
$this->error('拒绝失败');
}
$where_agency['id'] = $money['intermediary_id'];
$where_agency['status'] = array('neq',9);
$findAgency = Db::name('Agency')->where($where_agency)->find();
$agencyTime = ($findAgency['choose_time']+259200)-$findAgency['complaint_time'];
$change_agency['refuse_complaint_time'] = $time+$agencyTime;
$change_agency['status'] = 5;
$change_agency['is_refuse'] = 4;
$saveAgency = Db::name('Agency')->where($where_agency)->update($change_agency);
if(!$saveAgency){
$this->error('拒绝失败');
}
}
$this->success('成功');
}else{
$this->error('失败');
}
}else{
$this->error('订单状态不正确');
}
}
/**
* 后台删除第三方用户绑定
* @adminMenu(
* 'name' => '删除第三方用户绑定',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除第三方用户绑定',
* 'param' => ''
* )
*/
public function delete()
{
$id = input('param.id', 0, 'intval');
if (empty($id)) {
$this->error('非法数据!');
}
Db::name("third_party_user")->where("id", $id)->delete();
$this->success("删除成功!", "admin_oauth/index");
}
}