AdminResumeController.php 15.3 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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\ArtModel;
use app\portal\model\BannerModel;
use app\portal\model\HireModel;
use app\portal\model\OrderModel;
use app\portal\model\ResumeModel;
use cmf\controller\AdminBaseController;
use FontLib\Table\Type\post;
use think\Db;
use think\Loader;

/**
 * Class AdminResumeController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'简历管理',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'简历管理'
 * )
 */
class AdminResumeController extends AdminBaseController
{
    /**
     * 简历列表
     * @adminMenu(
     *     'name'   => '简历列表',
     *     'parent' => 'portal/AdminResume/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '简历列表',
     *     'param'  => ''
     * )
     */
    public function index(){
        $data = $this->request->param();
        $final = $this->adminIndex($data);
        $arr = array();
        if(!empty($final['where_arr']['create_time'])){
            $where_coo['r.create_time'] = $final['where_arr']['create_time'];
            $arr['create_time'] = $final['where_arr']['create_time'];
        }
        if(!empty($data['address'])){
            $arr['address'] = $data['address'];
            $where_coo['r.address'] = array('like',"%".$data['address']."%");
            $this->assign('address',$data['address']);
        }
        if(!empty($data['name'])){
            $arr['name'] = $data['name'];
            $where_coo['m.name'] = array('like',"%".$data['name']."%");
            $this->assign('name',$data['name']);
        }
        if(!empty($data['select'])){
            $arr['select'] = $data['select'];
            $where_coo['r.select_id'] = $data['select'];
            $this->assign('select',$data['select']);
        }
        $where_coo['r.status'] = array('neq',9);
        $coo_list = Db::name('Resume')->alias('r')
            ->where($where_coo)
            ->join("Select s",'s.id = r.select_id')
            ->join("Member m",'m.id = r.user_id')
            ->field('r.* , s.name as select_name ,m.name as member_name ')
            ->order('r.create_time desc')
            ->paginate(10,false,['query'=>$arr]);

        $this->assign('list',$coo_list);
        $where_sel['type'] = 2;
        $where_sel['status'] = array('neq',9);
        $sel = Db::name('Select')->where($where_sel)->select()->toArray();
        $this->assign('sel',$sel);
        return $this->fetch();
    }






    /**
     * 查看简历
     * @adminMenu(
     *     'name'   => '查看简历',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '查看简历',
     *     'param'  => ''
     * )
     */
    public function view()
    {
        $where_coo['r.id'] = $this->request->param('id');
        $where_coo['r.status'] = array('neq',9);
        $list = Db::name('Resume')->alias('r')
            ->where($where_coo)
            ->join("Select s",'s.id = r.select_id')
            ->join("Member m",'m.id = r.user_id')
            ->field('r.* , s.name as select_name ,m.name as member_name ')
            ->order('r.create_time desc')
            ->find();
        $list['create_time'] = date('Y-m-d H:i:s',$list['create_time']);
        $list['update_time'] = date('Y-m-d H:i:s',$list['update_time']);
        $this->assign('list',$list);
//        雇佣事项
        $where_select['type'] = 2;
        $where_select['status'] = array('neq',9);
        $select = Db::name('Select')->where($where_select)->select()->toArray();
        $this->assign('select',$select);
        return $this->fetch();
    }

    //    聘用信息审核
    public function operation(){
        $data = $this->request->param();
//        拒绝
        $model = new ResumeModel();
        if($data['type'] == 4){

//            判断是否重复提交
            $where_log['type'] = 2;
            $where_log['elseId'] = $data['id'];
            $isSet = Db::name('Refund')->where($where_log)->find();
            if($isSet){
                $where_findStatus['id'] = $data['id'];
                $where_findStatus['status'] = array('neq',4);
                $ischange = $model->where($where_findStatus)->find();
                if(!$ischange){
                    $this->apiResponse('0','请勿重复操作!');
                }else{
                    $up_order['id'] = $data['id'];
                    $up_order['status'] = $data['type'];
                    $up_order['update_time'] = time();
                    $res = $model->isUpdate(true)->save($up_order);
                    if(!$res){
                        $this->apiResponse('0','操作失败');
                    }
                }
            }
            $add_log['type'] = 2;
            $add_log['elseId'] = $data['id'];
            $add_log['content'] = $data['refund'];
            $add_log['create_time'] = time();
            $add_log['update_time'] = time();
            $res_refund = Db::name('Refund')->where($add_log)->insertGetId($add_log);
            if(!$res_refund){
                $this->apiResponse('0','操作失败');
            }
        }
        $up_order['id'] = $data['id'];
        $up_order['status'] = $data['type'];
        $up_order['update_time'] = time();
        $res = $model->isUpdate(true)->save($up_order);
        if($res){
//            发送模板消息
            $where_hire['r.id'] = $data['id'];
            $where_hire['r.status'] = array('neq',9);
            $hire = Db::name('Resume')->alias('r')
                ->where($where_hire)
                ->join("Member m",'m.id = r.user_id')
                ->field('m.openid, m.name,m.tel')
                ->find();
            $acctoken = $this->getAccessToken();
            $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$acctoken;
            $send = array();
            $send['touser'] = $hire['openid'];//OPENID
            $send['template_id'] = '1Pu27T_Ge01i6CKKXaRiPkW4QL7sJ_ZCLxuX3A8STr0';
            $send['url'] = 'http://yunzhi07.com/portal/Index/index/typeof/1';//模板跳转链接
            if($data['type'] == 3){
//                审核通过
                $send['data']['first']['value'] = '您好,您的审核已通过,请查看详情';//模板数据
            }else if($data['type'] == 4){
//                审核未通过
                $send['data']['first']['value'] = "抱歉,您的审核未通过,原因为".$data['refund'].",请重新填写表单";//模板数据
            }
            $send['data']['keyword1']['value'] = $hire['name'];//模板数据
            $send['data']['keyword2']['value'] = $hire['tel'];//模板数据
            $send['data']['remark']['value'] = '如有其他问题,请及时与我们联系!';//模板数据
            $ch = curl_init();//初始化curl
            curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
            curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
            curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($send));
            $res = curl_exec($ch);//运行curl
            $dec = json_decode($res) ;
            $final = $dec->errcode;
            if($final == 0){
                Db::commit();
                $this->apiResponse('1','操作成功');
            }else{
                Db::rollback();
                $this->apiResponse('0',$dec->errmsg);
            }
        }else{
            $this->apiResponse('0','操作失败');
        }
    }

    /**
     * 编辑简历
     * @adminMenu(
     *     'name'   => '编辑简历',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑简历',
     *     'param'  => ''
     * )
     */
    public function edit()
    {
//            添加数据
        $data = $this->request->post();
        unset($data['create_time']);
        unset($data['update_time']);
        unset($data['member_name']);
        $validate = Loader::validate('Resume');
        if(!$validate->scene('')->check($data)){
            $mes = $validate->getError();
            $this->error("$mes");
        }
        $model = new ResumeModel();
        $final = $model->isUpdate(true)->save($data);
        if($final){
            $this->success('成功',url('index'));
        }else{
            $this->error('失败');
        }
    }

    /**
     * 查看简历列表
     * @adminMenu(
     *     'name'   => ' 查看简历列表',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => ' 查看简历列表',
     *     'param'  => ''
     * )
     */
    public function toList()
    {
        $data = $this->request->param();
        $final = $this->adminIndex($data);
        $arr = array();
        if(!empty($final['where_arr']['create_time'])){
            $where_hire['l.create_time'] = $final['where_arr']['create_time'];
            $arr['create_time'] = $final['where_arr']['create_time'];
        }
        if(!empty($data['name'])){
            $arr['name'] = $data['name'];
            $where_hire['h.title'] = array('like',"%".$data['name']."%");
            $this->assign('name',$data['name']);
        }
        $where_coo['r.status'] = array('neq',9);
        $where_coo['r.id'] = $data['id'];
        $coo_list = Db::name('Resume')->alias('r')
            ->where($where_coo)
            ->join("Member m",'m.id = r.user_id')
            ->field('m.name,m.tel,r.id,m.id as user_id')
            ->find();
        $final['parent'] = $coo_list;
//        查询关联表,获取分配人信息
        $where_hire['l.resume_int'] = $coo_list['id'];
        $where_hire['l.resume_user_id'] = $coo_list['user_id'];
        $where_hire['l.status'] = array('neq',9);
        $log = Db::name('CompareLog')->alias('l')
            ->where($where_hire)
            ->join('Hire h','h.id = l.hire_id')
            ->join('Select s','s.id = h.select_id')
            ->field("h.*,s.name as select_name, l.status ,l.create_time,l.update_time,l.start,l.common_time ,l.id,l.one_money")
            ->paginate(1,false,['query'=>$arr]);
//            ->select()->toArray();
        $final['log'] = $log;
        $this->assign('list',$final);
        $this->assign('page',$log->render());
        return $this->fetch('tolist');
    }

    /**
     * 查看分配信息
     * @adminMenu(
     *     'name'   => '查看分配信息',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '查看分配信息',
     *     'param'  => ''
     * )
     */
    public function viewSon()
    {
        $where_coo['l.id'] = $this->request->param('id');
        $where_coo['l.status'] = array('neq',9);
        $list = Db::name('CompareLog')->alias('l')
            ->where($where_coo)
            ->join("Order o",'o.id = l.order_id')
            ->join("Hire h",'h.id = l.hire_id')
            ->join("Member m",'m.id = h.user_id')
            ->field('l.* ,m.name as hire_name,m.tel as hire_tel,o.order_sn,o.id as orderId')
            ->find();
        $list['create_time'] = date('Y-m-d H:i:s',$list['create_time']);
        $list['update_time'] = date('Y-m-d H:i:s',$list['update_time']);
        $list['common_time'] = $list['common_time']?date('Y-m-d H:i:s',$list['common_time']):'暂无';
        $where_mem['id'] = $list['resume_user_id'];
        $resume = Db::name("Member")->where($where_mem)->find();
//        $list['resume_id'] = $resume['id'];
        $list['resume_name'] = $resume['name'];
        $list['resume_tel'] = $resume['tel'];
        $this->assign('list',$list);
        return $this->fetch('editson');
    }
    /**
     * 编辑分配信息
     * @adminMenu(
     *     'name'   => '编辑分配信息',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑分配信息',
     *     'param'  => ''
     * )
     */
    public function editSon()
    {
//            添加数据
        $data = $this->request->post();
        $where_log['id'] = $data['id'];
        $where_log['status'] = array('neq',9);
        $up['start'] = empty($data['start'])?0:$data['start'];
        $up['status'] = $data['status'];
        $up['update_time'] = time();
        $up['common_time'] = $data['common_time'] == '暂无'?0:strtotime($data['common_time']);
        $final = Db::name('CompareLog')->where($where_log)->update($up);
        if($final){
            $resume_int = Db::name('CompareLog')->where($where_log)->value('resume_int');
            $this->success('成功',url('toList',array('id'=>$resume_int)));
        }else{
            $this->error('失败');
        }
    }
    /**
     * 取消分配
     * @adminMenu(
     *     'name'   => '取消分配',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '取消分配',
     *     'param'  => ''
     * )
     */
    public function cancel(){
        $data = $this->request->param();
        $where_log['id'] = $data['id'];
        $where_log['status'] = array('neq',9);
        $up['status'] = 9;
        $up['update_time'] = time();
        $log = Db::name('CompareLog')->where($where_log)->update($up);
        if($log){
            $this->success('取消成功');
        }else{
            $this->error('取消失败');
        }
    }


    /**
     * 删除聘用信息
     * @adminMenu(
     *     'name'   => '删除聘用信息',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '删除聘用信息',
     *     'param'  => ''
     * )
     */
    public function del(){
        $ids = $this->request->post();
        $id = $this->request->param('id');
        if($ids){
            $add_del['id'] = array('in',$ids['ids']);
        }else if($id){
            $add_del['id'] = $id;
        }else{
            $this->error('删除失败');
        }
        $add_del['status'] = 9;
        $model = new ResumeModel();
        $del = $model->isUpdate(true)->allowField(true)->save($add_del);
        if($del){
            $this->success('删除成功',url('index'));
        }else{
            $this->error('删除失败');
        }
    }
}