AuditController.php
2.8 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
<?php
namespace app\admin\controller;
use app\admin\model\RouteModel;
use cmf\controller\AdminBaseController;
use think\Db;
class AuditController extends AdminBaseController{
/**
*业务员审核列表
*/
public function audit_list(){
if($this -> request -> isPost()){
$where = [
'is_audit' => 0,
];
if(!empty($_POST['start_time']) && !empty($_POST['end_time'])){
$start_time = strtotime($_POST['start_time']);
$end_time = strtotime($_POST['end_time']);
$where['create_time'] = [['>=',$start_time],['<=',$end_time]];
}
if(!empty($_POST['keyword'])){
$where['phone'] = $_POST['keyword'];
}
$data = Db::name('sale_audit') -> where($where) -> paginate(12);
$data_arr = $data -> toArray();
foreach($data_arr['data'] as $key => $val){
$data_user = Db::name('user') -> where('id',$val['uid']) -> find();
$data_arr['data'][$key]['wname'] = $data_user['user_nickname'];
}
}else{
$data = Db::name('sale_audit') -> where('is_audit',0) -> paginate(12);
$data_arr = $data -> toArray();
foreach($data_arr['data'] as $key => $val){
$data_user = Db::name('user') -> where('id',$val['uid']) -> find();
$data_arr['data'][$key]['wname'] = $data_user['user_nickname'];
}
}
$this -> assign('data',$data);
$this -> assign('data_arr',$data_arr['data']);
return $this -> fetch();
}
/**
* 业务员审核编辑
*/
public function audit_edit(){
if($this -> request -> isPost()){
$id = $_POST['id'];
$time = time();
$uid = $_POST['uid'];
Db::name('my_user') -> where('uid',$uid) -> update(['status'=>2,'audit_time'=>$time]);
$data = Db::name('sale_audit') -> where('id',$id) -> update(['is_audit'=>1]);
if($data){
$this -> success('审核通过',url('Audit/audit_list'));
}else{
$this -> error('审核失败');
}
}else{
$id = $this -> request -> param();
$data = Db::name('sale_audit') -> where('id',$id['id']) -> find();
$this -> assign('data',$data);
return $this -> fetch();
}
}
/**
* 业务员审核驳回
*/
public function turn_down(){
$uid = $_POST['uid'];
$data = Db::name('my_user') -> where('uid',$uid) -> update(['status'=>6]);
Db::name('sale_audit') -> delete($uid);
if($data){
return true;
}else{
return false;
}
}
}