WillUserApplyController.class.php 2.8 KB
<?php
/**
 * Created by PhpStorm.
 * User: 29925
 * Date: 2018/4/26
 * Time: 11:32
 */

namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class WillUserApplyController extends AdminbaseController {

    protected $user_model;
    protected $will_user_apply_model;

    function _initialize() {
        parent::_initialize(); // TODO: Change the autogenerated stub
        $this->will_user_apply_model = D('Common/WillUserApply');
        $this->user_model = D('Common/User');
    }

    // 鹿鸣社申请列表
    public function index() {
        $this->assign('list', $this->will_user_apply_model->getList(I('get.p'), I('post.keyword'), strtotime(I('post.start_time')), strtotime(I('post.end_time'))));
        $count = $this->will_user_apply_model->getCount(I('post.keyword'), strtotime(I('post.start_time')), strtotime(I('post.end_time')));
        $page = $this->page($count, C('MAX_PAGE_NUM'));
        $this->assign('page', $page->show('Admin'));
        $this->assign('formget', I('post.'));
        $this->assign('keyword', I('post.keyword'));
        $this->display();
    }

    // 查看
    public function view(){
        $id = I("get.id",0,'intval');
        $info = $this->will_user_apply_model->where(array('id'=>$id, 'is_del'=>0))->find();
        $info['images'] = explode(',', $info['images']);
        $this->assign($info);
        $this->display();
    }

    //用户认证编辑
    public function edit_post(){
        if(IS_POST) {
            $post = I('post.');
            $id = I('post.id');
            $user_id = $this->will_user_apply_model->where(array('id'=>$id))->getField('user_id');
            if($this->will_user_apply_model->save($post)) {
                if(I('post.status') == 2) {
                    $this->user_model->where(array('id'=>$user_id))->save(array('status'=>2,'join_time'=>time()));
                } else {
                    $this->user_model->where(array('id'=>$user_id))->save(array('status'=>1));
                }
                $this->success('保存成功');
            } else {
                $this->error('保存失败');
            }
        }
    }

    // 删除
    public function delete(){
        if(I('get.id')){
            $id = I("get.id",0,'intval');
            if ($this->will_produce_apply_model->where(array('id'=>$id))->save(array('is_del'=>1,'dtime'=>time())) !==false) {
                $this->success("删除成功!");
            } else {
                $this->error("删除失败!");
            }
        }

        if(I('post.ids')){
            $ids = I('post.ids/a');

            if (!$this->will_produce_apply_model->where(array('id'=>array('in',$ids)))->save(array('is_del'=>1,'dtime'=>time()))) {
                $this->error("删除失败!");
            }
            $this->success("删除成功!");
        }
    }

}