<?php
/**
 * 自动确认订单
 * @Copyright (C) 2017 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author chang <13331202938@126.com>
 */
namespace Common\Vendor\Cron;
class ConfirmOrder{	
    public function index($config_info){
		if(!empty($config_info)){
			$map=array();
			$map['pay_status']=3;//已支付
			$map['status']=2;//已确认
			$map['shipping_status']=3;//已发货
            
            $param1=idtoname('ORDER_AUTOTAKE','Config','value','name');
            if(empty($param1))$param1=intval($config_info['param1']);
            if(empty($param1))$param1=7;if($param1<1)$param1=1;
            
			$map_time=NOW_TIME-86400*$param1;//待配置
			$map['pay_time']=array('lt',$map_time);
			$order_list=M('OrderInfo')->where($map)->getField('id',true);
           // echo M('OrderInfo')->_sql();exit;
			if(!empty($order_list)){
				foreach($order_list as $k=>$v){
				    $data=array();
                    $data['order_id']=$v;
                    $data['type']='admin';
					D('Common/OrderInfo')->confirm_order($data);
				}
			}
			//更新计划任务
			updatetask($config_info);
		}else{return;}
	}
}
?>