审查视图

app/admin/controller/AuditController.php 3.1 KB
anyv authored
1 2 3 4 5 6 7 8 9 10 11 12
<?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(){
刘朕 authored
13 14 15 16 17 18 19 20 21 22
        $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'])){
刘朕 authored
23
            $where['phone'] = ['like','%'.trim($param['keyword']).'%'];
刘朕 authored
24 25
        }
        $data = Db::name('sale_audit')->where($where)->order('create_time','DESC')->paginate(12);
26
        $data->appends($param);
刘朕 authored
27 28 29 30
        $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'];
anyv authored
31
        }
刘朕 authored
32 33
        $this->assign('start_time',!empty($param['start_time']) ? $param['start_time'] : '');
        $this->assign('end_time',!empty($param['end_time']) ? $param['end_time'] : '');
刘朕 authored
34
        $this->assign('keyword',!empty($param['keyword']) ? trim($param['keyword']) : '');
anyv authored
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        $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'];
5  
anyv authored
50 51
            //判断身份证号不能重复
            $id_number = Db::name('sale_audit') -> where('id',$id) -> find();
4  
anyv authored
52 53
            $id_number_id = $id_number['id_number'];
            $chongfu = Db::name('sale_audit') -> where("id_number='$id_number_id' and is_audit=1") -> find();
5  
anyv authored
54 55 56
            if(!empty($chongfu)){
                $this -> error('身份证号重复');
            }
王晓刚 authored
57
            Db::name('my_user') -> where('uid',$uid) -> update(['status'=>2,'audit_time'=>$time,'is_pro'=>1]);
anyv authored
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
            $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]);
5  
anyv authored
80
        Db::name('sale_audit') -> where('uid',$uid) -> delete();
anyv authored
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
        if($data){
            return true;
        }else{
            return false;
        }

    }













}