AuditController.php
3.1 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
<?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(){
$param = $this->request->param();
$where = [
'is_audit' => 0,
];
if(!empty($param['start_time']) && !empty($param['end_time'])){
$start_time = strtotime($param['start_time']);
$end_time = strtotime($param['end_time']);
$where['create_time'] = [['>=',$start_time],['<=',$end_time]];
}
if(!empty($param['keyword'])){
$where['phone'] = ['like','%'.trim($param['keyword']).'%'];
}
$data = Db::name('sale_audit')->where($where)->order('create_time','DESC')->paginate(12);
$data->appends($param);
$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('start_time',!empty($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time',!empty($param['end_time']) ? $param['end_time'] : '');
$this->assign('keyword',!empty($param['keyword']) ? trim($param['keyword']) : '');
$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'];
//判断身份证号不能重复
$id_number = Db::name('sale_audit') -> where('id',$id) -> find();
$id_number_id = $id_number['id_number'];
$chongfu = Db::name('sale_audit') -> where("id_number='$id_number_id' and is_audit=1") -> find();
if(!empty($chongfu)){
$this -> error('身份证号重复');
}
Db::name('my_user') -> where('uid',$uid) -> update(['status'=>2,'audit_time'=>$time,'is_pro'=>1]);
$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') -> where('uid',$uid) -> delete();
if($data){
return true;
}else{
return false;
}
}
}