<?php
/**
 * 计划任务积分自动清零提醒
 * @Copyright (C) 2017 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaoq <xiaoq@570035208.com>
 */
namespace Common\Vendor\Cron;
class IntegralWarn{
	/**
     * 计划任务积分自动清零提醒
     */
    public function index($config_info){
    	if(!empty($config_info)){
    		$maps = $map = array();
	        $maps['classname'] = 'IntegralWarn';
	        $corn = M('Cron')->where($maps)->field(true)->find();
	        $map['status'] = 1;
            $map['usepoints']=array('gt',intval($cron['remark']));
	        $uidarr=M('Member')->where($map)->limit($corn['param1'],$corn['param2'])->getField('id',true);
	        if($uidarr){
		        $basedata['from'] = 1;
		        $basedata['title'] = '积分清零提现';
		        $basedata['content'] = '尊敬的会员积分将要清零';
		        $basedata['type'] = 1;
		        $basedata['addtime'] = NOW_TIME;
		        foreach ($uidarr as $key => $v) {
		            $adddata[$key] = $basedata;
		            $adddata[$key]['touid']=$v;
		            $adddata[$key]['to'] = $v;
		            $result=send_method(3,$adddata[$key]);
		        }
		        $save['param1'] = $corn['param1'] + $corn['param2'];
		        M('Cron')->where($maps)->save($save);
		        $config_info['next_time'] = NOW_TIME;
		        $config_info['interval_time'] = 20;
		        $config_info['execute_time'] = 1;
		    }else{
		    	$save['param1'] = 0;
		    	M('Cron')->where($maps)->save($save);
		    	$config_info['next_time'] = NOW_TIME;
		        $config_info['interval_time'] = $corn['interval_time'];
		        $config_info['execute_time'] = $corn['execute_time'];
		    }
		    $config_info['id'] = $corn['id'];
			//更新计划任务
			updatetask($config_info);
		}else{return '';}
	}
}
?>