<?php
/**
 * 系统检查
 * User: lwx
 * Date: 2018/4/17
 */
namespace Admin\Controller;

use Think\Controller;

class CheckController extends ThinkController{
		
		const model_name = 'check';
		
		/*
		 * 列表
		 */
    public function index() {
			
			if (!empty($_REQUEST['type'])){
				$extend['type'] = $_REQUEST['type'];
				unset($_REQUEST['type']);
      }
			
			if(!empty($_REQUEST['start']) && !empty($_REQUEST['end'])){
					
					$extend['create_time'] = array('BETWEEN',array(strtotime(I('start')),strtotime(I('end'))+24*60*60-1));
					
			}elseif(!empty($_REQUEST['start'])){
					
				$extend['create_time'] =array('egt',strtotime(I('start')));
				
			}elseif(!empty($_REQUEST['end'])){
					
				$extend['create_time'] = array('elt',strtotime(I('end'))+24*60*60-1);
				
			}
			
			if(is_numeric($_REQUEST['status']) && $_REQUEST['status']>=0 && $_REQUEST['status']<3) {$extend['status'] = $_REQUEST['status'];}
			else {$extend['status']=array('egt',0);}
			
			if(is_numeric($_GET['t']) && $_GET['t']>0 && $_GET['t']<5) { $extend['type'] = array('like',$_GET['t'].'%'); }
			
			
			$this->m_title = '系统检查';
			$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Check/index','status'=>1])->find());
				
			
			parent::flists(self::model_name,$_GET["p"],$extend,'url');
			
		}
		
		/*
		 * 更改状态
		 */
		public function status(){
			
      parent::set_status(self::model_name);
			
    }
		
		/*
		 * 检测用户相关
		 */
		public function checkUser() {			
			
			$check = D(self::model_name);
			
			if($check->checkUser()>0) {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>1,'url'=>U('Check/index',array('t'=>1))],'json');
				
			} else {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>0,'url'=>U('Check/index',array('t'=>1))],'json');
				
			}
			
		}
		
		/*
		 * 检测提现相关
		 */
		public function checkWithdraw() {
			
			$check = D(self::model_name);
			
			if($check->checkWithdraw()>0) {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>1,'url'=>U('Check/index',array('t'=>2))],'json');
				
			} else {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>0,'url'=>U('Check/index',array('t'=>2))],'json');
				
			}
			
		}
		
		/*
		 * 检测推广员相关
		 */
		public function checkPromote() {

			$check = D(self::model_name);
		
			if($check->checkPromote()>0) {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>1,'url'=>U('Check/index',array('t'=>3))],'json');
				
			} else {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>0,'url'=>U('Check/index',array('t'=>3))],'json');
				
			}
			
		}
		
		/*
		 * 一键检测
		 */
		public function checkOne() {
			
			$check = D(self::model_name);
			
			if($check->checkOne()>0) {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>1,'url'=>U('Check/index',array('t'=>4))],'json');
				
			} else {
				
				$this->ajaxReturn(['info'=>$check->getError(),'status'=>0,'url'=>U('Check/index',array('t'=>4))],'json');
				
			}
			
		}
		
}