load->_model('Model_shop','shop');
		$this->load->_model('Model_fullorder','fullorder');
		$this->load->_model('Model_fullordertt','fullordertt');
		$this->load->_model('Model_fullorderxw','fullorderxw');
		$this->load->_model('Model_fullordersmt','fullordersmt');
		$this->load->_model('Model_fullorder_2020','fullorder2020');
		$this->load->_model('Model_fullordersmt_2020','fullordersmt2020');
		$this->load->_model('Model_customersmt','customersmt');
		$this->load->_model('Model_country','country');
		$this->load->_model('Model_hl','hl');
		$this->load->_model('Model_is','is');
		$this->load->_model('Model_kdniao','kdniao');
		$this->load->_model('Model_typeclass','typeclass');
		$this->load->_model('Model_warehouse','warehouse');
		$this->load->_model('Model_fullorderexcel','fullorderexcel');
		$this->load->_model('Model_dhl','dhl');
		$this->load->_model('Model_usps','usps');
		$this->load->_model('Model_dhltest','dhltest');
		$this->load->_model('Model_customer','customer');
		$this->load->_model('Model_express','express');
		$this->load->_model('Model_notice','notice');
		$this->load->_model('Model_whlabel','whlabel');
		$this->load->_model('Model_productdescribe','productdescribe');
		$this->load->_model('Model_ljg','ljg');
		$this->load->_model('Model_commodityread','commodityread');
		$this->load->_model('Model_service','service');
		$this->load->_model('Model_fedex','fedex');
		$this->load->_model('Model_commodity','commodity');
		$this->load->_model('Model_fullordersmtorder','fullordersmtorder');
		$this->load->_model('Model_ali','ali');
		$this->load->_model('Model_fullordersmthb','fullordersmthb');
		$this->load->_model('Model_fullordersmtbf','fullordersmtbf');
		$this->load->_model('Model_taxzhengzhou','taxzhengzhou');
		$this->load->_model('Model_taxshanghai','taxshanghai');
		$this->load->_model('Model_excel','excel');
		$this->load->_model('Model_ups','ups');
		$this->load->_model('Model_dpd','dpd');
		$this->load->_model('Model_dpdold','dpdold');
		$this->load->_model('Model_dpd_IOSS','dpd_IOSS');
		$this->load->_model('Model_dpdxw','dpdxw');
		$this->load->_model('Model_cne','cne');
		$this->load->_model('Model_outbound','outbound');
		$this->load->_model('Model_api','api');
		$this->load->_model('Model_dhlhz','dhlhz');
		$this->load->_model('Model_apismt','apismt');
		$this->load->_model('Model_specialstock','specialstock');
		$this->load->_model('Model_systemwigsout','systemwigsout');
		$this->load->_model('Model_purchaseorder','purchaseorder');
		$this->load->_model('Model_returns','returns');
		$this->load->_model('Model_whlabellabel','whlabellabel');
		$this->load->_model('Model_whlabelbarcode','whlabelbarcode');
		$this->load->_model('Model_tjadd','tjadd');
		$this->load->_model('Model_stafflist','stafflist');
		$this->load->_model('Model_paypal','paypal');
		$this->load->_model('Model_warehousefactory','warehousefactory');
		$this->load->_model('Model_commodityread_del','commodityreaddel');
		$this->load->_model('Model_als','als');
		$this->load->_model('Model_allocation','allocation');
		$this->load->_model('Model_17track','17track');
		$this->load->_model('Model_hualei','hualei');
		$this->load->_model('Model_hualeixw','hualeixw');
		$this->load->_model('Model_ck','ck');
		$this->load->_model('Model_colour','colour');
		$this->load->_model('Model_color','color');
		$this->load->_model('Model_emaildata','emaildata');
		$this->load->_model('Model_wigprint','wigprint');
		$this->load->_model('Model_weight','weight');
		$this->load->_model('Model_whlabeltransport','whlabeltransport');
		$this->load->_model('Model_pay','pay');
		$this->load->_model('Model_orderurl','orderurl');
		$this->load->_model('Model_classid','classid');
		$this->load->_model('Model_whlabel','whlabel');
		$this->load->_model('Model_systemtransfer','systemtransfer');
		$this->load->_model('Model_whlabel_bh','whlabel_bh');
		$this->load->_model('Model_excel','excel');
		$this->load->_model('Model_yuntu','yuntu');
		$this->load->_model('Model_fedex_ficp','fedex_ficp');
		$this->load->_model('Model_fedexv1','fedexv1');
		$this->load->_model("Model_customsdeclaration","customsdeclaration");
	}
	//定义方法的调用规则 获取URI第二段值
    public function _remap($arg,$arg_array)
    {
		 if($arg == 'x3')
        {
             $this->_x3($arg_array);
        }
		else if($arg == 'qk')
        {
             $this->_qk();
        }
		else if($arg == 'qczd')
        {
             $this->_qczd($arg_array);
        }
		else if($arg == 'd')
        {
             $this->_d($arg_array);
        }
		else if($arg == 'w')
        {
             $this->_w($arg_array);
        }
		else if($arg == 'wz')
        {
             $this->_wz($arg_array);//改仓库位置
        }
		else if($arg == 'qkyy')
        {
             $this->_qkyy($arg_array);//清除备货用友数据
        }
		else if($arg == 'cxxq')
        {
             $this->_cxxq($arg_array);//查询独立站订单详情
        }
		else if($arg == 'user')
        {
             $this->_user($arg_array);//批量添加店铺权限
        }
    }
	
	public function _x3($arg_array)
	{
	   die;
		$fullorder = $this->fullorder->get_number($arg_array[0]);
		if(!$fullorder)
		{
			$fullorder = $this->fullordersmt->get_number($arg_array[0]);
		}
		if(!$fullorder)
		{
			$fullorder = $this->fullordertt->get_number($arg_array[0]);
		}
		if(!$fullorder)
		{
			$fullorder = $this->fullorderxw->get_number($arg_array[0]);
		}
		if(!$fullorder)
		{
			echo "编号错误";exit;
		}
		/** 发票地址信息暂时无用 
		$fullorder['baddress'] = explode(',',$fullorder['baddress']);
		$fullorder['baddress'] = array_reverse($fullorder['baddress']);
		$fullorder['baddress'][1] = $country['ename'];
		**/
		//获取所用相关信息
		
		
		$warehouse = $this->warehouse->read($fullorder['type']);
		$country = $this->country->read($fullorder['country']);//订单国家信息
		$fcountry = $this->country->read($warehouse['country']);//仓库国家信息
	
		$warehouse['country'] = $fcountry['ename'];//仓库国家名
		$warehouse['lb'] = $fcountry['lb'];//仓库国家编码
		$fullorder['warehouse'] = $warehouse;//仓库数据加入订单
		$fullorder['lb'] = $country['lb'];//订单国家编码加入
		$fullorder['country'] = $country['ename'];//订单国家名
		$fullorder['zhou'] = $country['continent'];//所属州
		$express = $this->express->read($fullorder['express']);
		$fullorder['express'] = $express['servicename'];
		$fullorder['account'] = $express['account'];
		$fullorder['printcode'] = $express['printcode'];
		$fullorder['time'] = date('Y-m-d',time());
		$fullorder['times'] = date('Y-m-d H:i',time());
		$declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
	    //var_dump($declara_info);
		$sbbm = "";
		if(empty($declara_info)){
			$sbbm = "";
		}else{
		    $sbbm = $declara_info['bname'];
		}
	
		$fullorder['sbbm']= $sbbm;
		$fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
		$fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
		$fullorder['shipremarks'] = str_replace(array('<','>'),array('<','>'),$fullorder['shipremarks']);
		$fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';
',';
'),$fullorder['shipremarks']);
		$shop = $this->shop->read($fullorder['shop']);
		$fullorder['shop'] = $shop['shopname'];
		$fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
		$fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
		if(is_numeric($fullorder['pay']))
		{
		    $pay = $this->typeclass->read($fullorder['pay']);
		    if($pay['classid'] == '4')
		    {
		        $fullorder['pay'] = $pay['title'];
		    }
		}
		if($fullorder['printcode'] != "USPS")
		{
		    $fullorder['client'] = htmlspecialchars($fullorder['client']);
		    $fullorder['name'] = htmlspecialchars($fullorder['name']);
		}
		//增加退货单所需信息
		$pt = '';
		$fpdata = explode(';',trim($fullorder['fpdata'],';'));
		foreach ($fpdata as $v) 
		{
			$p = explode('|',trim($v,'|'));
			//$pt .= '
'.$p[1].' * '.$p[2].'
'; } $fullorder['pt'] = $pt; $fullorder['printnumber'] += 2; // $fullorder['address'] = "221 5TH ST # APT305"; // $fullorder['city'] = "W SACRAMENTO"; // echo "";
// 		var_dump($fullorder['sbbm']);
// 		die;
		//$fullorder['printcode'] = 'HUALEIXW-FEDEX';
		//$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
		//$fullorder['sbbm']= 4202320000;//($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
		//$fullorder['sbpm']= 'eyelashes';
		//$fullorder['zwpm']= '假睫毛';
		//$fullorder['sbpm']= 'Satin Bag';
		//$fullorder['zwpm']= '袋子';
		//$fullorder['hgbm']= 4202320000;
		//$fullorder['address'] = '1653 Treutlan Place';
		//$fullorder['address2'] = '';
		//$fullorder['qm'] = 2;
		//$notice = $this->notice->read(6);
		//$fcountry['warehouse']['name'] = 'Hair Me Please LLC';
		//$fullorder['cxcode'] = strtolower($express['cxcode']);
		//$barcode = $this->fedex->get_logistics($fullorder);//获取联邦快递信息
		//echo $fullorder['name'];
		//$b = $this->yuntu->get_data($fullorder);
		//$b = $this->usps->get_logistics($fullorder);
	//	$fullorder['printcode'] = 'HUALEI-DHL';
// 		$fullorder['js'] = 2;
// 		$fullorder['bx'] = 110;
		//$fullorder['qm'] = 1;
		echo "";
		
		
		//$fullorder['printcode'] = 'usps_priority';
 		$b  = $this->usps->get_data($fullorder);
 		print_r($b);
         die;
//         echo "";
// 		$b = $this->fedexv1->get_data($fullorder);
// 		var_dump($b);
		//echo $fullorder['zzl'];
	//	echo  "";
	//	var_dump($fullorder);
		//$b = $this->usps->get_data_new($fullorder);
		
// 		$b = $this->ups->get_data($fullorder);
// 		echo "";
// 		print_r($b);
		//$this->_pdf($b['labelImage'],"test",date("Ymd"));
		
	}
	
	public function get_data($data)
	{
		$ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
		$data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
		$data['province'] = trim($data['province'],' ');
		$dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
		$data['address'] = str_replace(array('#','&','&'),array('%23','%26'),$data['address']);
		$data['address2'] = str_replace(array('#','&','&'),array('%23','%26'),$data['address2']);
		$data['client'] = str_replace(array('#','&','&'),array('%23','%26'),$data['client']);
		$data['name'] = str_replace(array('#','&','&'),array('%23','%26'),$data['name']);
		$data['name'] = str_replace('  ',' ',$data['name']);
        $xml = "";
        $xml .= "";
        $xml .= "";
		$xml .= "1 ";
		$xml .= "";
		$xml .= "4X6LABELP ";
		$xml .= " ";
        $xml .= "Kenny Kwok ";//发件人姓名或公司
        $xml .= "Long Human Hair Factory Inc ";//发件人姓名或公司
        $xml .= "819 6th Avenue Store front ";//发件人地址2
        $xml .= "New York ";//发件人城市
        $xml .= "NY ";//发件人所属州
        $xml .= "10001 ";//发件人邮政编码
        $xml .= "8455583605 ";//发件人电话,10位
        $xml .= "true ";//是否检查地址 true不检查
        $xml .= "".$data['name']." ";//收件人名称
        $xml .= "".$data['address2']." ";//收件人地址1 不超过50个字符
            $xml .= "".$data['address']." ";//收件人地址2
		}
		else
		{
			$xml .= "".$data['address']." ";//收件人地址1 不超过50个字符
            $xml .= "".$data['address2']." ";//收件人地址2
		}
        $xml .= "".$data['city']." ";//收件人城市
        $xml .= "".$dataprovince." ";//收件人州
        $xml .= "".trim($data['zipcode'],' ')." ";//收件人邮编
        $xml .= "EMAIL ";
		        $xml .= "".$data['email']." ";
			}
		}
        $xml .= "false ";
        $xml .= "".$data['zzl']." ";//重量
        $xml .= "".$ServiceType." ";//服务类型
        $xml .= "".$Container." ";//货物类型
        $xml .= "".$data['bx']." ";//保险金 可选
        $xml .= "True ";//可选 客户变更地址提醒
		/**
		$data['qm'] = ($data['qm']==1)?'False':'True';
		if($data['qm'] == 'False')
		{
		    $xml .= "";
		    //$xml .= "1 ";//可选 交付选择 默认1:正常交付
		    $xml .= "".$data['qm']." ";//可选 接收签名用False
            $xml .= " ";
		}
        **/
		if($data['qm']==1 && $data['js'] == 2)
		{
		    $xml .= "";
		    //$xml .= "1 ";//可选 交付选择 默认1:正常交付
		    $xml .= "FALSE ";//可选 接收签名用False
            $xml .= " ";
		}
        $xml .= "".date('m/d/Y',time()-(12*3600)+($data['yc']*24*3600))." ";//可选 发货日期 当前至7天 格式 mm/ dd/ yyyy 延迟发货
		//$xml .= "true ";
        $xml .= "".$data['number']." ";//可选 内部编号显示在运单 不超过19字符
        $xml .= "";
		if(isset($ExtraService))
		{
		   $xml .= "".$ExtraService." ";//可选额外服务
		}
		if($data['bx'] > 0)
		{
		   $xml .= "".$ExtraServicebx." ";//可选额外服务
		}
        $xml .= " ";
        $xml .= "NONE ";//可选打印布局SEPARATE PAGE 或NONE
        $xml .= "PDF ";//输出类型
		$xml .= "Y ";
		$xml .= "true ";//内部编号显示要用这个标签
        $xml .= " ";
		
		/** 直连 **/
	
		$ch = curl_init();
		$url = 'https://secure.shippingapis.com/ShippingAPI.dll?API=eVS&XML='.$xml;
		$url = str_replace(" ",'%20',$url);
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,0);
		curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
		curl_setopt($ch,CURLOPT_TIMEOUT,25);
		$data = curl_exec($ch);
		curl_close($ch);
		$data = utf8_encode($data);
        libxml_disable_entity_loader(true);
       // @$values = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
		return $data;
	
		
/**
		$ch = curl_init();
		$url = 'http://z.wepolicy.cn/usps.php?XML='.$xml;
		$url = str_replace(" ",'%20',$url);
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,0);
		curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
		$data = curl_exec($ch);
		curl_close($ch);
		$data = json_decode($data,TRUE);
		return $data;
		//Description提示错误    LabelImage运单PDF  BarcodeNumber运单号
		**/
		
	}
	
	public function _pdf($pdf,$title,$bctime)
    {
    	$pdf_path = './data/pdf/'.$bctime.'/';
        $file_base64 = $pdf; 
        $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);  
        $file_base64 = base64_decode($file_base64);
		if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
        file_put_contents($pdf_path.$title.'.pdf',$file_base64);
		return $bctime;
    }
	
	public function _qk()//清空用友数据
	{
		$sc = array();
		$a = $this->fullorder->find_all("scapi = '99'");
		foreach ($a as $v) 
		{
			if(stripos($v['scid'],'XD') === false || $v['scid'] == '|' || $v['scid'] == '')
			{
				$this->fullorder->save(array('scid'=>'','scapi'=>0,'dbapi'=>0),$v['id']);
				continue;
			}
			 $b = explode('|',trim($v['scid'],'|'));
			 $b = explode('~',trim($b[0],'~'));
			 //$c =  str_replace('XD','',$b[1]);
			if(strlen($b[1]) != 12)
			{
				$this->fullorder->save(array('scid'=>'','scapi'=>0,'dbapi'=>0),$v['id']);
				continue;
			}
		}
		echo "";
		print_r($sc);
		exit;
	}
	
	public function _w($arg_array)
	{
		$a = $this->whlabel->read($arg_array[0]);
		$s = $this->whlabel->find_all("features = '".$a['features']."'");
		echo "";
		print_r($a);
		echo "";
		print_r($s);
		exit;
	}
	
	
	public function _qczd($arg_array)//清空用友数据
	{
		$a = $this->whlabel->find_all("zd = '$arg_array[0]'");
		foreach ($a as $v) 
		{
			$this->whlabel->save(array('zd'=>''),$v['id']);
		}
	}
	
	public function _d($arg_array)
	{
		$a = $this->fullorder->get_number($arg_array[0]);
		if(!$a)
		{
			//$a = $this->fullorder->get_orderinfo($arg_array[0]);
			if(!$a)
		    {
				$a = $this->fullordersmt->get_number($arg_array[0]);
				if(!$a)
				{
					//$a = $this->fullordersmt->get_orderinfo($arg_array[0]);
					if(!$a)
		    		{
						$a = $this->fullordertt->get_number($arg_array[0]);
						if(!$a)
						{
							$a = $this->fullorderxw->get_number($arg_array[0]);
							if(!$a)
							{
								//$a = $this->fullordertt->get_orderinfo($arg_array[0]);
							}
						}
					}
				}
			}
		}
		if($a)
		{
			echo "";
			print_r($a);
		}
		else
		{
			echo "没有此数据";
		}
		exit;	
	}
        public function _wz($arg_array)
		{
			if(!isset($arg_array[1]))
			{
				//echo "没有位置数据";
				return "没有位置数据";
			}
			$cid = $this->whlabellabel->find_all("cpid = '".$arg_array[0]."'");
			if(isset($cid[0]))
			{
			    $w = $this->whlabel->find_all("number = '".$cid[0]['number']."' and warehouse = '13'");
			    foreach ($w as $v) 
		        {
                   $this->whlabel->save(array('details'=>$arg_array[1]),$v['id']);
                }
				echo json_encode(array('msg'=>'!','success'=>true));exit;
				//echo '成功';
				//echo "";
				//print_r($w);
			}
		}
		
		
		public function _qkyy($arg_array)//清空备货用友数据
	{
		$y = $this->whlabel_bh->read($arg_array[0]);
		if($y)
		{
			$this->whlabel_bh->save(array('scid'=>'','scapi'=>0,'dbapi'=>0,'state'=>0),$y['id']);
			echo 'ok';
		}
		else
		{
			echo '没有ID';
		}
	}
	
	
	public function _cxxq()//查询独立站订单详情
	{
		$value = $this->shop->read(3);
		$res = $this->get_hq($value['brandname'],$value['shopadmin'],$value);
			
		echo "";
		print_r($res);
	}
	
	public function get_hq($name,$shopapi,$shop)
	{
		$jqtime = ($name=='SuperNova')?24*3600:2*3600;
		$fromTime = time()-24*3600-$jqtime;//strtotime('yesterday')-$jqtime;//昨日0点+1小时保险无漏单
		$toTime = time();
		$post['cs'] = 1;
			$post['name'] = $name;
        	$post['from'] = $fromTime;
        	$post['to'] = $toTime;
			$ch = curl_init();
			curl_setopt($ch,CURLOPT_URL,$shopapi);
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
			$res = curl_exec($ch);
			curl_close($ch);
   	    	if($res)
			{
				$res = json_decode($res,true);
				$x = array();
				foreach ($res as $v)
				{
					$source = '';
					$sc = substr($v['order_id'],0,3);
					if($sc == '600')
					{
						$source = $shop['thurl']; //手机订单
					}
					else
					{
						$source = $shop['url'];//PC订单
					}
					if($v['wjauthorid'] != '' && $v['sourcecontentid'] != '' && $source != '' && $shop['tweak'] != '')
					{
						$authorid = $this->authorid($source.'?author_id='.$v['wjauthorid'].'&source_content_id='.$v['sourcecontentid'],$shop['tweak']);
						if($authorid)
						{
							$v['authorid'] = $authorid;
						}
					}
					$x[] = $v;
				}
				return $x;
			}
	}
	
	public function _user($arg_array)//查询独立站订单详情
	{
		$id = $arg_array[0];
		$d = $arg_array[1];
		$shop = $this->shop->read($id);
		$value = $this->user->find_all("shop not like '|".$id."|' and shop like '%|".$d."|%'");
		foreach ($value as $v)
		{
			//$this->user->save(array('shop'=>$v['shop'].$id.'|','shoptext'=>$v['shoptext'].$shop[''].'|'),$v['id']);
		}
			
		echo "";
		print_r($value);
	}
}