| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084 | <?phpclass Model_Dhl extends Lin_Model {function __construct(){		parent::__construct();		$this->load->database();		$this->table = 'dhl';    	$this->load_table('dhl');    	$this->load->_model("Model_logic_ding",'logic_ding');}    public function get_data($data)	{		$nd = $data;		if($data['pay'] == 1)		{			$data['pay'] == 'PayPal';		}		else if($data['pay'] == 2)		{			$data['pay'] == 'Western Union';		}		else if($data['pay'] == 3)		{			$data['pay'] == '微信';		}		else if($data['pay'] == 4)		{			$data['pay'] == '支付宝';		}		else if($data['pay'] == 5)		{			$data['pay'] == '银行转账';		}		else if($data['pay'] == 6)		{			$data['pay'] == '现金收款';		}		else if($data['pay'] == 7)		{			$data['pay'] == 'PingPong金融';		}		$id = 'XUCHANGLONGY';		$pass = 'dJ84as3ELr';		//$sid = '603521441';//官方DHL		$sid = '605062090';//官方DHL美国		$xmend = "\n";		$Pieces = '';		for($i=0;$i<$data['zjs'];$i++)		{		    $Pieces .= "<Piece>".$xmend;		    $Pieces .= "<PieceID>".($i+1)."</PieceID>".$xmend;		    $Pieces .= "<PackageType>EE</PackageType>".$xmend;			$Pieces .= "<Weight>".$data['zzl']."</Weight>".$xmend;			$Pieces .= "<Width>15</Width>".$xmend;			$Pieces .= "<Height>3</Height>".$xmend;			$Pieces .= "<Depth>5</Depth>".$xmend;			$Pieces .= "</Piece>".$xmend;		}		/**  此内容是添加发票信息		$dataadress = array();$baddress = '';$ba1 = '';$ba2 = '';		for($i=5;$i<count($data['baddress']);$i++)		{			$dataadress[] = $data['baddress'][$i];		}				if(count($dataadress) > 1)		{			for($i=0;$i<count($dataadress);$i++)		    {				if($i < 2)				{					$ba1 .= $dataadress[$i].',';				}				else				{					$ba2 .= $dataadress[$i].',';				}			}				$baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;				$baddress .= "<BillToAddressLine>".rtrim($ba2,',')."</BillToAddressLine>".$xmend;		}		else		{			for($i=0;$i<count($dataadress);$i++)		    {				$ba1 .= $dataadress[$i].',';		    }			$baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;		}		**/		$hgbm = $data['sbbm'];		if(isset($data['hgbm']))		{			if($data['hgbm'] != '')			{				$hgbm = $data['hgbm'];			}		}		$xml = "";		$xml .= "<?xml version='1.0' encoding='UTF-8'?>".$xmend;        $xml .= "<req:ShipmentRequest xsi:schemaLocation='http://www.dhl.com ship-val-global-req.xsd' schemaVersion='10.0' xmlns:req='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>".$xmend;		$xml .= "<Request>".$xmend;		$xml .= "<ServiceHeader>".$xmend;		$xml .= "<MessageTime>".date('c')."</MessageTime>".$xmend;		//$rand = (strlen($data['orderinfo']) < 15)?rand(10000000,99999999):rand(100000,999999);		//$xml .= "<MessageReference>".time().$data['orderinfo'].$rand."</MessageReference>".$xmend;		$xml .= "<MessageReference>".time().time().rand(10000000,99999999)."</MessageReference>".$xmend;		$xml .= "<SiteID>".$id."</SiteID>".$xmend;//DHL账号		$xml .= "<Password>".$pass."</Password>".$xmend;//DHL密码		$xml .= "</ServiceHeader>".$xmend;		$xml .= "<MetaData>".$xmend;		$xml .= "<SoftwareName>LongYi ERP</SoftwareName>".$xmend;		$xml .= "<SoftwareVersion>V1.0.0</SoftwareVersion>".$xmend;		$xml .= "</MetaData>".$xmend;		$xml .= "</Request>".$xmend;		$xml .= "<RegionCode>AP</RegionCode>".$xmend;//地区代码		$xml .= "<LanguageCode>en</LanguageCode>".$xmend;//语言		///$xml .= "<PiecesEnabled>Y</PiecesEnabled>".$xmend;		$xml .= "<Billing>".$xmend;		$xml .= "<ShipperAccountNumber>".$sid."</ShipperAccountNumber>".$xmend;		$xml .= "<ShippingPaymentType>S</ShippingPaymentType>".$xmend;		$xml .= "<BillingAccountNumber>".$sid."</BillingAccountNumber>".$xmend;		///$xml .= "<DutyPaymentType>R</DutyPaymentType>".$xmend;//R为收件人付关税 S发件人付关税		$xml .= "</Billing>".$xmend;		$xml .= "<Consignee>".$xmend;		$xml .= "<CompanyName>".$data['name']."</CompanyName>".$xmend;//收货人名称		/**		if(strlen($data['address'].$data['address2']) > 44)		{			$adl = $data['address'].$data['address2'];			$adl1 = substr($adl,0,44);//截取44字符前内容			$adlnum = strripos($adl1," ");//查找最后一次出现空格位置			$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容			$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容			$xml .= "<AddressLine1>".$adl1."</AddressLine1>".$xmend;//收货人地址1			$xml .= "<AddressLine2>".$adl2."</AddressLine2>".$xmend;//收货人地址2		}		**/		if($data['address2'])		{			//$adl = $data['address'].$data['address2'];			//$adl1 = substr($adl,0,44);//截取44字符前内容			//$adlnum = strripos($adl1," ");//查找最后一次出现空格位置			//$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容			//$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容			$xml .= "<AddressLine1>".$data['address']."</AddressLine1>".$xmend;//收货人地址1			$xml .= "<AddressLine2>".$data['address2']."</AddressLine2>".$xmend;//收货人地址2		}		else		{		    $xml .= "<AddressLine1>".$data['address'].$data['address2']."</AddressLine1>".$xmend;//收货人地址		}		if($data['street'] != '')		{		    $xml .= "<AddressLine>".$data['street']."</AddressLine>".$xmend;//收货人街道		}		$xml .= "<City>".$data['city']."</City>".$xmend;//城市		if($data['lb'] == 'US')		{			$xml .= "<DivisionCode>".$data['province']."</DivisionCode>".$xmend;//州代码,仅美国		}		$xml .= "<PostalCode>".trim($data['zipcode'],' ')."</PostalCode>".$xmend;//邮编		$xml .= "<CountryCode>".$data['lb']."</CountryCode>".$xmend;//国家代码		$xml .= "<CountryName>".$data['country']."</CountryName>".$xmend;//国家名称		$xml .= "<Contact>".$xmend;		$xml .= "<PersonName>".$data['client']."</PersonName>".$xmend;//名称		$xml .= "<PhoneNumber>".preg_replace('/\D/s','',$data['phone'])."</PhoneNumber>".$xmend;//联系方式		//$xml .= "<Email>".$data['email']."</Email>".$xmend;//联系邮箱		$xml .= "</Contact>".$xmend;		if(($data['country'] == 'Mexico'  || $data['al'] == 'MX') && !empty($data['r_tax_id'])){			$xml .= "<RegistrationNumbers>".$xmend;			$xml .= "<RegistrationNumber>".$xmend;			$xml .= '<Number>'.$data['r_tax_id'].'</Number>'.$xmend;			$xml .= '<NumberTypeCode>VAT</NumberTypeCode>'.$xmend;			$xml .= '<NumberIssuerCountryCode>MX</NumberIssuerCountryCode>'.$xmend;			$xml .= "</RegistrationNumber>".$xmend;			$xml .= "</RegistrationNumbers>".$xmend;		}						$xml .= "</Consignee>".$xmend;		$xml .= "<Commodity>".$xmend;//多商品循环此外层标签及内层标签		$xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//商品编码		$xml .= "<CommodityName>".$data['sbpm']."</CommodityName>".$xmend;//商品名称		$xml .= "</Commodity>".$xmend;		$xml .= "<Dutiable>".$xmend;		$xml .= "<DeclaredValue>".$data['zsbjz']."</DeclaredValue>".$xmend;//申报价值		$xml .= "<DeclaredCurrency>".$data['currencytitle']."</DeclaredCurrency>".$xmend;//货币代码		$xml .= "<TermsOfTrade>DAP</TermsOfTrade>".$xmend;//贸易条款		$xml .= "</Dutiable>".$xmend;		/** 发票信息开始 **/		$xml .= "<UseDHLInvoice>Y</UseDHLInvoice>".$xmend;	    $xml .= "<DHLInvoiceLanguageCode>en</DHLInvoiceLanguageCode>".$xmend;	    $xml .= "<DHLInvoiceType>CMI</DHLInvoiceType>".$xmend;	    $xml .= "<ExportDeclaration>".$xmend;		$xml .= "<ExportReasonCode>P</ExportReasonCode>".$xmend;		if(strlen($data['paypal']) > 30)		{		    $xml .= "<InvoiceNumber>".str_replace(array('-'),array(''),$data['paypal'])."</InvoiceNumber>".$xmend;		}		else		{			$xml .= "<InvoiceNumber>".$data['paypal']."</InvoiceNumber>".$xmend;		}		$xml .= "<InvoiceDate>".date('Y-m-d',time())."</InvoiceDate>".$xmend;		/**		$xml .= "<BillToContactName>".$data['client']."</BillToContactName>".$xmend;		$xml .= "<BillToContanctName>".$data['client']."</BillToContanctName>".$xmend;//账单名称		$xml .= "<BillToAddressLine1><BillToAddressLine1>";//地址1		$xml .= "<BillToAddressLine2><BillToAddressLine2>";//地址2		$xml .= "<BillToCity>".$data['baddress'][4]."</BillToCity>".$xmend;//城市		$xml .= "<BillToPostcode>".$data['baddress'][2]."</BillToPostcode>".$xmend;//邮编		$xml .= "<BillToSuburb/>".$xmend;//所在郊区		if($data['baddress'][1] == 'United States')		{			$xml .= "<BillToState>".$data['baddress'][3]."</BillToState>".$xmend;//省、州		}		$xml .= "<BillToCountryName>".$data['baddress'][1]."</BillToCountryName>".$xmend;//国家		$xml .= "<BillToPhoneNumber>".preg_replace('/\D/s','',$data['baddress'][0])."</BillToPhoneNumber>".$xmend;//号码		**/		$xml .= "<ExportLineItem>".$xmend;		$xml .= "<LineNumber>1</LineNumber>".$xmend;//顺序号		$xml .= "<Quantity>".$data['ts']."</Quantity>".$xmend;//数量		$xml .= "<QuantityUnit>PCS</QuantityUnit>".$xmend;//单位		$xml .= "<Description>".$data['sbpm']."</Description>".$xmend;//品名		$xml .= "<Value>".$data['dtsbjz']."</Value>".$xmend;//单价		$xml .= "<IsDomestic>Y</IsDomestic>".$xmend;//是否国产,Y本国,N国外		$xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//品名编码		$xml .= "<Weight>".$xmend;		$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//净重		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;//重量单位,K千克		$xml .= "</Weight>".$xmend;		$xml .= "<GrossWeight>".$xmend;		$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//毛重		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;//毛重单位,K千克		$xml .= "</GrossWeight>".$xmend;		$xml .= "<ManufactureCountryCode>CN</ManufactureCountryCode>".$xmend;//原产国国家代码		$xml .= "<ManufactureCountryName>CHINA</ManufactureCountryName>".$xmend;//原产国名称		$xml .= "</ExportLineItem>".$xmend;		$xml .= "<PlaceOfIncoterm>PEK PORT</PlaceOfIncoterm>".$xmend;//适用港口	    $xml .= "</ExportDeclaration>".$xmend;		/** 发票信息结束 **/		$xml .= "<Reference>".$xmend;		$xml .= "<ReferenceID>".$data['number']."</ReferenceID>".$xmend;		$xml .= "</Reference>".$xmend;		$xml .= "<ShipmentDetails>".$xmend;		///$xml .= "<NumberOfPieces>".$data['zjs']."</NumberOfPieces>".$xmend;		$xml .= "<Pieces>".$xmend;		$xml .= $Pieces;		$xml .= "</Pieces>".$xmend;		///$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;		$xml .= "<GlobalProductCode>P</GlobalProductCode>".$xmend;		$xml .= "<LocalProductCode>P</LocalProductCode>".$xmend;		$xml .= "<Date>".date('Y-m-d',time())."</Date>".$xmend;		$xml .= "<Contents>".$data['sbpm']."</Contents>".$xmend;//内容		///$xml .= "<DoorTo>DD</DoorTo>".$xmend;		$xml .= "<DimensionUnit>C</DimensionUnit>".$xmend;		///$xml .= "<InsuredAmount>".$data['bx']."</InsuredAmount>".$xmend;//保险金额		$xml .= "<PackageType>EE</PackageType>".$xmend;		$xml .= "<IsDutiable>Y</IsDutiable>".$xmend;		$xml .= "<CurrencyCode>".$data['currencytitle']."</CurrencyCode>".$xmend;//货币代码		$xml .= "</ShipmentDetails>".$xmend;		$xml .= "<Shipper>".$xmend;		$xml .= "<ShipperID>".$sid."</ShipperID>".$xmend;		$xml .= "<CompanyName>LongYing</CompanyName>".$xmend;//发货公司名称		$xml .= "<AddressLine1>LongYingShiYe, Yinghao Rd.</AddressLine1>".$xmend;//发货地址		$xml .= "<AddressLine2>Shangji Economic Development Zone</AddressLine2>".$xmend;//发货地址		$xml .= "<City>".$data['warehouse']['city']."</City>".$xmend;//发货城市		$xml .= "<PostalCode>".$data['warehouse']['zipcode']."</PostalCode>".$xmend;		$xml .= "<CountryCode>CN</CountryCode>".$xmend;//发货国家代码		$xml .= "<CountryName>CHINA</CountryName>".$xmend;//发货国家名称		$xml .= "<Contact>".$xmend;		$xml .= '<PersonName>GeMengTi</PersonName>'.$xmend;//发货人 '.$data['warehouse']['company'].'		$xml .= '<PhoneNumber>15939964739</PhoneNumber>'.$xmend;		$xml .= "</Contact>".$xmend;				$xml .= "<RegistrationNumbers>".$xmend;		$xml .= "<RegistrationNumber>".$xmend;		$xml .= '<Number>91411002MA3X46XC9K</Number>'.$xmend;		$xml .= '<NumberTypeCode>VAT</NumberTypeCode>'.$xmend;		$xml .= '<NumberIssuerCountryCode>CN</NumberIssuerCountryCode>'.$xmend;		$xml .= "</RegistrationNumber>".$xmend;		$xml .= "</RegistrationNumbers>".$xmend;			    $xml .= "</Shipper>".$xmend;		/** 无纸化 PLT 开始 **/		$xml .= "<SpecialService>".$xmend;		$xml .= "<SpecialServiceType>WY</SpecialServiceType>".$xmend;		$xml .= "</SpecialService>".$xmend;		/** 无纸化 PLT 结束 **/		if( !empty($data['js']) && ($data['js'] == 6)){			/** 发件人承担税费 s**/			$xml .= "<SpecialService>".$xmend;			$xml .= "<SpecialServiceType>DD</SpecialServiceType>".$xmend;			$xml .= "</SpecialService>".$xmend;			/** 发件人承担税费 e**/		}						if($data['bx'] > 0)		{		    $xml .= "<SpecialService>".$xmend;		    $xml .= "<SpecialServiceType>II</SpecialServiceType>".$xmend;			$xml .= "<ChargeValue>".$data['bx']."</ChargeValue>".$xmend;			$xml .= "<CurrencyCode>USD</CurrencyCode>".$xmend;		    $xml .= "</SpecialService>".$xmend;		}	    $xml .= "<LabelImageFormat>PDF</LabelImageFormat>".$xmend;		/** 无纸化 PLT 启用这个 **/		$xml .= "<RequestArchiveDoc>N</RequestArchiveDoc>".$xmend;		/** 无纸化 PLT 启用这个 **/		/** 无纸化 PLT 关闭这个 **/		//$xml .= "<RequestArchiveDoc>Y</RequestArchiveDoc>".$xmend;        //$xml .= "<NumberOfArchiveDoc>1</NumberOfArchiveDoc>".$xmend;		/** 无纸化 PLT 关闭这个 **/		$xml .= "<Label>".$xmend;		$xml .= "<HideAccount>N</HideAccount>".$xmend;		$xml .= "<LabelTemplate>8X4_PDF</LabelTemplate>".$xmend;		$xml .= "<CustomsInvoiceTemplate>COMMERCIAL_INVOICE_P_10</CustomsInvoiceTemplate>".$xmend;		$xml .= "<Resolution>200</Resolution>".$xmend;	    $xml .= "</Label>".$xmend;        $xml .= "</req:ShipmentRequest>".$xmend;                        $this->logic_ding->sendToDing("dhl发货单请求的报文".$xml);		$start_time = time();		$ch = curl_init(); 		curl_setopt($ch, CURLOPT_URL,'https://xml-api.dhl.com/XMLShippingServlet'); 		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, $xml);		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);		$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);		$this->logic_ding->sendToDing("dhl发货单请求的报文回执".json_encode($values));		if(!empty($values['AirwayBillNumber'])){			$end_time = time();			if( $end_time - $start_time  > 45){				$this->logic_ding->addJobs('outtime_order',['number'=>$data['number']]);			}		}					/**		$ch = curl_init();		$url = 'http://z.wepolicy.cn/dhl.php';		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);        //设置post数据		$post = array();		$post['data'] = $xml;        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));		$res = curl_exec($ch);		curl_close($ch);		$values = json_decode($res,true);				**/		//发送C类		//$this->get_data_c($nd);		$cx = $this->find("number = '".$nd['number']."'");		if(!$cx && $nd['printcode'] != "DHLUSA")		{		    $this->insert(array("number"=>$nd['number'],'time'=>time()));		}		return $values;	}		public function get_data_new($data)	{		if($data['pay'] == 1)		{			$data['pay'] == 'PayPal';		}		else if($data['pay'] == 2)		{			$data['pay'] == 'Western Union';		}		else if($data['pay'] == 3)		{			$data['pay'] == '微信';		}		else if($data['pay'] == 4)		{			$data['pay'] == '支付宝';		}		else if($data['pay'] == 5)		{			$data['pay'] == '银行转账';		}		else if($data['pay'] == 6)		{			$data['pay'] == '现金收款';		}		else if($data['pay'] == 7)		{			$data['pay'] == 'PingPong金融';		}		$id = 'XUCHANGLONGY';		$pass = 'dJ84as3ELr';		//$sid = '603521441';//官方DHL		$sid = '605062090';//官方DHL美国		$xmend = "\n";		$Pieces = '';		for($i=0;$i<$data['zjs'];$i++)		{		    $Pieces .= "<Piece>".$xmend;		    $Pieces .= "<PieceID>".($i+1)."</PieceID>".$xmend;		    $Pieces .= "<PackageType>EE</PackageType>".$xmend;			$Pieces .= "</Piece>".$xmend;		}		/**  此内容是添加发票信息		$dataadress = array();$baddress = '';$ba1 = '';$ba2 = '';		for($i=5;$i<count($data['baddress']);$i++)		{			$dataadress[] = $data['baddress'][$i];		}				if(count($dataadress) > 1)		{			for($i=0;$i<count($dataadress);$i++)		    {				if($i < 2)				{					$ba1 .= $dataadress[$i].',';				}				else				{					$ba2 .= $dataadress[$i].',';				}			}				$baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;				$baddress .= "<BillToAddressLine>".rtrim($ba2,',')."</BillToAddressLine>".$xmend;		}		else		{			for($i=0;$i<count($dataadress);$i++)		    {				$ba1 .= $dataadress[$i].',';		    }			$baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;		}		**/		$hgbm = $data['sbbm'];		if(isset($data['hgbm']))		{			if($data['hgbm'] != '')			{				$hgbm = $data['hgbm'];			}		}		$xml = "";		$xml .= "<?xml version='1.0' encoding='UTF-8'?>".$xmend;        $xml .= "<req:ShipmentRequest schemaVersion='6.2' xmlns:req='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.dhl.com ship-val-global-req-6.2.xsd'>".$xmend;		$xml .= "<Request>".$xmend;		$xml .= "<ServiceHeader>".$xmend;		$xml .= "<MessageTime>".date('c')."</MessageTime>".$xmend;		//$rand = (strlen($data['orderinfo']) < 15)?rand(10000000,99999999):rand(100000,999999);		//$xml .= "<MessageReference>".time().$data['orderinfo'].$rand."</MessageReference>".$xmend;		$xml .= "<MessageReference>".time().time().rand(10000000,99999999)."</MessageReference>".$xmend;		$xml .= "<SiteID>".$id."</SiteID>".$xmend;//DHL账号		$xml .= "<Password>".$pass."</Password>".$xmend;//DHL密码		$xml .= "</ServiceHeader>".$xmend;		$xml .= "<MetaData>".$xmend;		$xml .= "<SoftwareName>LongYi ERP</SoftwareName>".$xmend;		$xml .= "<SoftwareVersion>V1.0.0</SoftwareVersion>".$xmend;		$xml .= "</MetaData>".$xmend;		$xml .= "</Request>".$xmend;		$xml .= "<RegionCode>AP</RegionCode>".$xmend;//地区代码		$xml .= "<LanguageCode>en</LanguageCode>".$xmend;//语言		$xml .= "<PiecesEnabled>Y</PiecesEnabled>".$xmend;		$xml .= "<Billing>".$xmend;		$xml .= "<ShipperAccountNumber>".$sid."</ShipperAccountNumber>".$xmend;		$xml .= "<ShippingPaymentType>S</ShippingPaymentType>".$xmend;		$xml .= "<BillingAccountNumber>".$sid."</BillingAccountNumber>".$xmend;		$xml .= "<DutyPaymentType>R</DutyPaymentType>".$xmend;//R为收件人付关税 S发件人付关税		$xml .= "</Billing>".$xmend;		$xml .= "<Consignee>".$xmend;		$xml .= "<CompanyName>".$data['name']."</CompanyName>".$xmend;//收货人名称		if(strlen($data['address'].$data['address2']) > 44)		{			$adl = $data['address'].$data['address2'];			$adl1 = substr($adl,0,44);//截取44字符前内容			$adlnum = strripos($adl1," ");//查找最后一次出现空格位置			$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容			$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容			$xml .= "<AddressLine>".$adl1."</AddressLine>".$xmend;//收货人地址1			$xml .= "<AddressLine>".$adl2."</AddressLine>".$xmend;//收货人地址2		}		else		{		    $xml .= "<AddressLine>".$data['address'].$data['address2']."</AddressLine>".$xmend;//收货人地址		}		if($data['street'] != '')		{		    $xml .= "<AddressLine>".$data['street']."</AddressLine>".$xmend;//收货人街道		}		$xml .= "<City>".$data['city']."</City>".$xmend;//城市		if($data['lb'] == 'US')		{			$xml .= "<DivisionCode>".$data['province']."</DivisionCode>".$xmend;//州代码,仅美国		}		$xml .= "<PostalCode>".trim($data['zipcode'],' ')."</PostalCode>".$xmend;//邮编		$xml .= "<CountryCode>".$data['lb']."</CountryCode>".$xmend;//国家代码		$xml .= "<CountryName>".$data['country']."</CountryName>".$xmend;//国家名称		$xml .= "<Contact>".$xmend;		$xml .= "<PersonName>".$data['client']."</PersonName>".$xmend;//名称		$xml .= "<PhoneNumber>".preg_replace('/\D/s','',$data['phone'])."</PhoneNumber>".$xmend;//联系方式		//$xml .= "<Email>".$data['email']."</Email>".$xmend;//联系邮箱		$xml .= "</Contact>".$xmend;		$xml .= "</Consignee>".$xmend;		$xml .= "<Commodity>".$xmend;//多商品循环此外层标签及内层标签		$xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//商品编码		$xml .= "<CommodityName>".$data['sbpm']."</CommodityName>".$xmend;//商品名称		$xml .= "</Commodity>".$xmend;		$xml .= "<Dutiable>".$xmend;		$xml .= "<DeclaredValue>".$data['zsbjz']."</DeclaredValue>".$xmend;//申报价值		$xml .= "<DeclaredCurrency>".$data['currencytitle']."</DeclaredCurrency>".$xmend;//货币代码		$xml .= "</Dutiable>".$xmend;		/** 发票信息开始 **/		$xml .= "<UseDHLInvoice>Y</UseDHLInvoice>".$xmend;	    $xml .= "<DHLInvoiceLanguageCode>en</DHLInvoiceLanguageCode>".$xmend;	    $xml .= "<DHLInvoiceType>CMI</DHLInvoiceType>".$xmend;	    $xml .= "<ExportDeclaration>".$xmend;		$xml .= "<ExportReasonCode>P</ExportReasonCode>".$xmend;		$xml .= "<InvoiceNumber>".$data['paypal']."</InvoiceNumber>".$xmend;		$xml .= "<InvoiceDate>".date('Y-m-d',time())."</InvoiceDate>".$xmend;		/**		$xml .= "<BillToCompanyName>".$data['client']."</BillToCompanyName>".$xmend;		$xml .= "<BillToContanctName>".$data['client']."</BillToContanctName>".$xmend;//账单名称		$xml .= $baddress;//地址		$xml .= "<BillToCity>".$data['baddress'][4]."</BillToCity>".$xmend;//城市		$xml .= "<BillToPostcode>".$data['baddress'][2]."</BillToPostcode>".$xmend;//邮编		$xml .= "<BillToSuburb/>".$xmend;//所在郊区		if($data['baddress'][1] == 'United States')		{			$xml .= "<BillToState>".$data['baddress'][3]."</BillToState>".$xmend;//省、州		}		$xml .= "<BillToCountryName>".$data['baddress'][1]."</BillToCountryName>".$xmend;//国家		$xml .= "<BillToPhoneNumber>".preg_replace('/\D/s','',$data['baddress'][0])."</BillToPhoneNumber>".$xmend;//号码		**/		$xml .= "<ExportLineItem>".$xmend;		$xml .= "<LineNumber>1</LineNumber>".$xmend;//顺序号		$xml .= "<Quantity>".$data['ts']."</Quantity>".$xmend;//数量		$xml .= "<QuantityUnit>PCS</QuantityUnit>".$xmend;//单位		$xml .= "<Description>".$data['sbpm']."</Description>".$xmend;//品名		$xml .= "<Value>".$data['dtsbjz']."</Value>".$xmend;//单价		$xml .= "<IsDomestic>Y</IsDomestic>".$xmend;//是否国产,Y本国,N国外		$xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//品名编码		$xml .= "<Weight>".$xmend;		$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//净重		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;//重量单位,K千克		$xml .= "</Weight>".$xmend;		$xml .= "<GrossWeight>".$xmend;		$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//毛重		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;//毛重单位,K千克		$xml .= "</GrossWeight>".$xmend;		$xml .= "<ManufactureCountryName>CN</ManufactureCountryName>".$xmend;//原产国名称		$xml .= "</OtherCharges>".$xmend;				$xml .= "<OtherCharges>".$xmend;		$xml .= "<OtherCharge>".$xmend;		$xml .= "<OtherChargeValue>".$data['zsbjz']."</OtherChargeValue>".$xmend;		$xml .= "<OtherChargeType>SOTHR</OtherChargeType>".$xmend;		$xml .= "</OtherCharge>".$xmend;		$xml .= "</OtherCharges>".$xmend;			    $xml .= "</ExportDeclaration>".$xmend;		/** 发票信息结束 **/		$xml .= "<Reference>".$xmend;		$xml .= "<ReferenceID>".$data['number']."</ReferenceID>".$xmend;		$xml .= "</Reference>".$xmend;		$xml .= "<ShipmentDetails>".$xmend;		$xml .= "<NumberOfPieces>".$data['zjs']."</NumberOfPieces>".$xmend;		$xml .= "<Pieces>".$xmend;		$xml .= $Pieces;		$xml .= "</Pieces>".$xmend;		$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;		$xml .= "<WeightUnit>K</WeightUnit>".$xmend;		$xml .= "<GlobalProductCode>P</GlobalProductCode>".$xmend;		$xml .= "<LocalProductCode>P</LocalProductCode>".$xmend;		$xml .= "<Date>".date('Y-m-d',time())."</Date>".$xmend;		$xml .= "<Contents>".$data['sbpm']."</Contents>".$xmend;//内容		///$xml .= "<DoorTo>DD</DoorTo>".$xmend;		$xml .= "<DimensionUnit>C</DimensionUnit>".$xmend;		$xml .= "<InsuredAmount>".$data['bx']."</InsuredAmount>".$xmend;//保险金额		$xml .= "<PackageType>EE</PackageType>".$xmend;		$xml .= "<IsDutiable>Y</IsDutiable>".$xmend;		$xml .= "<CurrencyCode>".$data['currencytitle']."</CurrencyCode>".$xmend;//货币代码		$xml .= "</ShipmentDetails>".$xmend;		$xml .= "<Shipper>".$xmend;		$xml .= "<ShipperID>".$sid."</ShipperID>".$xmend;		$xml .= "<CompanyName>".$data['warehouse']['company']."</CompanyName>".$xmend;//发货公司名称		$xml .= "<AddressLine>".$data['warehouse']['address']."</AddressLine>".$xmend;//发货地址		$xml .= "<AddressLine>".$data['warehouse']['address2']."</AddressLine>".$xmend;//发货地址		$xml .= "<AddressLine>".$data['warehouse']['province']."</AddressLine>".$xmend;//发货省、州		$xml .= "<City>".$data['warehouse']['city']."</City>".$xmend;//发货城市		$xml .= "<PostalCode>".$data['warehouse']['zipcode']."</PostalCode>".$xmend;		$xml .= "<CountryCode>".$data['warehouse']['lb']."</CountryCode>".$xmend;//发货国家代码		$xml .= "<CountryName>".$data['warehouse']['country']."</CountryName>".$xmend;//发货国家名称		$xml .= "<Contact>".$xmend;		$xml .= "<PersonName>".$data['warehouse']['company']."</PersonName>".$xmend;//发货人名称		$xml .= "<PhoneNumber>15939964739</PhoneNumber>".$xmend;//发货人电话 ".preg_replace('/\D/s','',$data['warehouse']['phone'])."		$xml .= "</Contact>".$xmend;	    $xml .= "</Shipper>".$xmend;		/** 无纸化 PLT 开始 **/		$xml .= "<SpecialService>".$xmend;		$xml .= "<SpecialServiceType>WY</SpecialServiceType>".$xmend;		$xml .= "</SpecialService>".$xmend;		/** 无纸化 PLT 结束 **/		if($data['bx'] > 0)		{		    $xml .= "<SpecialService>".$xmend;		    $xml .= "<SpecialServiceType>II</SpecialServiceType>".$xmend;		    $xml .= "</SpecialService>".$xmend;		}	    $xml .= "<LabelImageFormat>PDF</LabelImageFormat>".$xmend;		/** 无纸化 PLT 启用这个 **/		$xml .= "<RequestArchiveDoc>N</RequestArchiveDoc>".$xmend;		/** 无纸化 PLT 启用这个 **/		/** 无纸化 PLT 关闭这个 **/		//$xml .= "<RequestArchiveDoc>Y</RequestArchiveDoc>".$xmend;        //$xml .= "<NumberOfArchiveDoc>1</NumberOfArchiveDoc>".$xmend;		/** 无纸化 PLT 关闭这个 **/		$xml .= "<Label>".$xmend;		$xml .= "<HideAccount>N</HideAccount>".$xmend;		$xml .= "<LabelTemplate>8X4_PDF</LabelTemplate>".$xmend;		$xml .= "<Resolution>200</Resolution>".$xmend;	    $xml .= "</Label>".$xmend;        $xml .= "</req:ShipmentRequest>".$xmend;				/**		$ch = curl_init(); 		curl_setopt($ch, CURLOPT_URL,'https://xml-api.dhl.com/XMLShippingServlet'); 		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, $xml);		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);		$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);		**/								$ch = curl_init();		$url = 'http://z.wepolicy.cn/dhl.php';		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);        //设置post数据		$post = array();		$post['data'] = $xml;        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));		$res = curl_exec($ch);		curl_close($ch);		$values = json_decode($res,true);				return $values;	}		public function get_logistics_q($number)	{		$ch = curl_init();		$url = 'http://z.wepolicy.cn/dhl.php';		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);        //设置post数据		$post = array();		$post['number'] = $number;        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));		$res = curl_exec($ch);		curl_close($ch);		$values = json_decode($res,true);		return $values;	}	public function get_logistics($number)//直连DHL	{		$id = 'XUCHANGLONGY';		$pass = 'dJ84as3ELr';		//$sid = '603521441';//官方DHL		$sid = '605062090';//官方DHL美国		$Pieces = '';		$xmend = "\n";				$xml = "<?xml version='1.0' encoding='UTF-8'?>".$xmend;		$xml .= "<req:KnownTrackingRequest xmlns:req='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.dhl.com TrackingRequestKnown.xsd' schemaVersion='1.0'>";        $xml .= "<Request>".$xmend;		$xml .= "<ServiceHeader>".$xmend;		$xml .= "<MessageTime>".date('c')."</MessageTime>".$xmend;		$xml .= "<MessageReference>".time().time().rand(10000000,99999999)."</MessageReference>".$xmend;		$xml .= "<SiteID>".$id."</SiteID>".$xmend;//DHL账号		$xml .= "<Password>".$pass."</Password>".$xmend;//DHL密码		$xml .= "</ServiceHeader>".$xmend;		$xml .= "</Request>".$xmend;		$xml .= "<LanguageCode>en</LanguageCode>".$xmend;		$xml .= "<AWBNumber>".$number['waybill']."</AWBNumber>".$xmend;		$xml .= "<LevelOfDetails>ALL_CHECK_POINTS</LevelOfDetails>".$xmend;		$xml .= "</req:KnownTrackingRequest>".$xmend;		$ch = curl_init(); 		curl_setopt($ch, CURLOPT_URL,'https://xmlpi-ea.dhl.com/XMLShippingServlet'); 		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, $xml);		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		$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);		if(isset($values['AWBInfo']['ShipmentInfo']['ShipmentEvent'][0]))//是否有信息		{			$zt = array_reverse($values['AWBInfo']['ShipmentInfo']['ShipmentEvent']);			$xq = '';			$st = array();			foreach($zt as $v)		    {				$st[strtotime($v['Date'].' '.$v['Time'])] = $v;			}			rsort($st);			foreach($st as $v)		    {				if($v['ServiceEvent']['EventCode'] == 'BA')				{					$exstate = 1;					break;				}				else if($v['ServiceEvent']['EventCode'] == 'OK')				{					$exstate = 6;					break;				}				else if(stripos($v['ServiceEvent']['Description'],'forwarded') !== false || $v['ServiceEvent']['EventCode'] == 'WC' || $v['ServiceEvent']['EventCode'] == 'TP')//With delivery courier				{					$exstate = 5;					break;				}				else if(stripos($v['ServiceEvent']['Description'],'Clearance processing complete at') !== false && stripos($v['ServiceArea']['Description'],'CHINA') === false)				{					$exstate = 4;					break;				}				else if(stripos($v['ServiceEvent']['Description'],'In transit') !== false)				{					$exstate = 3;					break;				}				else if(stripos($v['ServiceEvent']['Description'],'picked up') !== false)				{					$exstate = 2;					break;				}			}			foreach($st as $v)		    {				$xq .= $v['Date'].' '.$v['Time'].' '.$v['ServiceEvent']['Description'].'<br />';			}			$content = date('Y-m-d H',time()).'-查询成功';			$list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$xq,'st'=>$st);//正常可发送站内信		}		else		{			$content = date('Y-m-d H',time()).'-查询失败';			$list = array('content'=>$content,'f'=>0);//非正常只更改详情信息		}		return $list;	}		public function get_epod($data)	{		$username = 'longyingCN';		$password = 'Q#1qC$2eG$2uA$0q';		$sid = '605062090';//官方DHL美国		$xmend = "\n";		$xml = '<?xml version="1.0" encoding="UTF-8"?>'.$xmend;		$xml .= '<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="glDHLExpressePOD/providers/DocumentRetrieve" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'.$xmend;        $xml .= '<SOAP-ENV:Header>'.$xmend;        $xml .= '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'.$xmend;        $xml .= '<wsse:UsernameToken wsu:Id="">'.$xmend;        $xml .= '<wsse:Username>'.$username.'</wsse:Username>'.$xmend;        $xml .= "<wsse:Password Type='PasswordText'>".$password."</wsse:Password>".$xmend;        $xml .= "<wsse:Nonce EncodingType=''></wsse:Nonce>".$xmend;        $xml .= '<wsu:Created>'.date('c').'</wsu:Created>'.$xmend;        $xml .= '</wsse:UsernameToken>'.$xmend;        $xml .= '</wsse:Security>'.$xmend;        $xml .= '</SOAP-ENV:Header>'.$xmend;        $xml .= '<SOAP-ENV:Body>'.$xmend;        $xml .= '<tns:shipmentDocumentRetrieveReq>'.$xmend;		$xml .= '<MSG>'.$xmend;		$xml .= '<Hdr Dtm="'.date('c').'" Id="'.time().rand(100,999).'" Ver="1.038">'.$xmend;		$xml .= '<Sndr AppCd="DCGAP" AppNm="DCGAP"/>'.$xmend;		$xml .= '</Hdr>'.$xmend;		$xml .= '<Bd>'.$xmend;		$xml .= '<Shp Id="'.$data['waybill'].'">'.$xmend;        $xml .= '<ShpTr>'.$xmend;        $xml .= '<SCDtl AccNo="'.$sid.'" CRlTyCd="PY"/>'.$xmend;        $xml .= '</ShpTr>'.$xmend;        $xml .= '<ShpInDoc>'.$xmend;        $xml .= '<SDoc DocTyCd="POD"/>'.$xmend;        $xml .= '</ShpInDoc>'.$xmend;        $xml .= '</Shp>'.$xmend;        $xml .= '<GenrcRq>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="IMG_CONTENT" Val="epod-detail"/>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="IMG_FORMAT" Val="PDF"/>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="DOC_RND_REQ" Val="true"/>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="DUPL_HANDL" Val="CORE_WB_NO"/>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="SORT_BY" Val="$INGEST_DATE,D"/>'.$xmend;        $xml .= '<GenrcRqCritr TyCd="LANGUAGE" Val="en"/>'.$xmend;        $xml .= '</GenrcRq>'.$xmend;		$xml .= '</Bd>'.$xmend;		$xml .= '</MSG>'.$xmend;		$xml .= '</tns:shipmentDocumentRetrieveReq>'.$xmend;        $xml .= '</SOAP-ENV:Body>'.$xmend;        $xml .= '</SOAP-ENV:Envelope>'.$xmend;		//echo $xml;exit;		$ch = curl_init(); 		curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/gbl/getePOD');		curl_setopt($ch, CURLOPT_POST, 1);		curl_setopt($ch, CURLOPT_HEADER, 0);		curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:text/xml; charset=utf-8")); 		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, $xml);		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);		$epoddata = curl_exec($ch);		curl_close($ch);		//header("Content-type: application/xml");		$xml = simplexml_load_string($epoddata);        $xml->registerXPathNamespace('tns','http://scxgxtt.phx-dc.dhl.com/glDHLExpressePOD/providers/DocumentRetrieve');		if($xml->xpath('//Img'))		{            foreach ($xml->xpath('//Img') as $item)            {			    $json = json_encode($item);        	    $convrt_arr = json_decode($json, true);				$epod = $this->_pdf($convrt_arr['@attributes']['Img'],'epod-'.$data['waybill'],date('Y',time()));			    return array('c'=>1,'d'=>'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf');		    }		}		else        {			foreach ($xml->xpath('//ErrMsgDtl ') as $item)            {				$json = json_encode($item);        	    $convrt_arr = json_decode($json, true);				return array('c'=>2,'d'=>$convrt_arr['@attributes']['DtlDsc']);		    }		}	}		public function _pdf($pdf,$title,$bctime)    {    	$pdf_path = './data/epod/'.$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);    }		public function _token()	{		$token_header = array(            'x-request-id: 605062090',			'Content-Type: application/json'        );		$ch = curl_init();		$url = 'https://dps-api.cndhl.com/dps-auth-server/api/gateway-token/generate';//正式   测试 https://webhub.cndhl.com/dps/dps-auth-server/api/gateway-token/generate		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch, CURLOPT_HTTPHEADER, $token_header);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);        //设置post数据		$post = array();		$post['consumerCode'] = 'P_f7yzl4675s';		$post['key'] = 'wt)!ftX{1Co$/i{|';		$data = json_encode($post);        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);		$res = curl_exec($ch);		$resp = json_decode($res,true);		$token = $resp['result']['token'];		return $token;	}		public function get_data_c($data,$id)//C类	{		$token = $this->_token();		$file_header = array(            'x-request-id: 605062090',			'Authorization: '.$token,			'Content-Type: application/json'        );		$ch = curl_init();		$url = 'https://dps-api.cndhl.com/dps-declaration-api/api/declare/submit-declare';		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch, CURLOPT_HTTPHEADER, $file_header);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);        //设置post数据				$list = $data;		$post = array();		$post['decMessage']['decHead']['iEFlag']="E";		$post['decMessage']['decHead']['tradeName']="许昌龙盈实业集团有限公司";        $post['decMessage']['decHead']['tradeCoScc']="91411023MA45JCKTXL";        $post['decMessage']['decHead']['tradeCode']="3316960A6A";		$post['decMessage']['decHead']['ownerName']="许昌龙盈实业集团有限公司";		$post['decMessage']['decHead']['ownerCodeScc']="91411023MA45JCKTXL";		$post['decMessage']['decHead']['tradeMode']="3010";		$post['decMessage']['decHead']['transMode']="2";		$post['decMessage']['decHead']['cutMode']="101";		$post['decMessage']['decHead']['feeMark']="3";		$post['decMessage']['decHead']['feeRate']="10";		$post['decMessage']['decHead']['feeCurr']="USD";				$post['decMessage']['decLists']['decList'][0]['gNo']="1";		$post['decMessage']['decLists']['decList'][0]['declGoodsEname']=$data['sbpm'];//申报品名		$post['decMessage']['decLists']['decList'][0]['gName']=$data['zwpm'];//中文品名		$post['decMessage']['decLists']['decList'][0]['codeTs']=$data['hgbm'];//海关编码		//$post['decMessage']['decLists']['decList'][0]['gModel']="0|2|假发|化纤";		$post['decMessage']['decLists']['decList'][0]['gModel']=$data['dhl_ggbm'];		$post['decMessage']['decLists']['decList'][0]['gQty']=$data['ts'];//数量		$post['decMessage']['decLists']['decList'][0]['gUnit']="007";		$post['decMessage']['decLists']['decList'][0]['declPrice']=$data['dtsbjz'];//申报单价		$post['decMessage']['decLists']['decList'][0]['declTotal']=$data['zsbjz'];//申报总价		$post['decMessage']['decLists']['decList'][0]['tradeCurr']="USD";		$post['decMessage']['decLists']['decList'][0]['firstQty']="0.10000";		$post['decMessage']['decLists']['decList'][0]['firstUnit']="035";		$post['decMessage']['decLists']['decList'][0]['goodsBrand']="无";		$post['decMessage']['decLists']['decList'][0]['dutyMode']="1";		$post['decMessage']['decLists']['decList'][0]['originCountry']="CHN";                $post['decMessage']['msgHead']['action']="A";		$post['decMessage']['msgHead']['awbGenDtm']= date("Y-m-d H:i:s",time()-3600);		$post['decMessage']['msgHead']['awbNo']=$data['waybill'];//运单号		$post['decMessage']['msgHead']['declareType']="C";		$post['decMessage']['msgHead']['msgGenDtm']=date("Y-m-d H:i:s",time());		$post['decMessage']['msgHead']['msgId']="7b67817a-9c81-412d-bedd-10a65ac22508";		$post['decMessage']['msgHead']['version']="1.0";						$data = json_encode($post);		//echo $data;exit;        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);		$res = curl_exec($ch);		curl_close($ch);		$this->logic_ding->sendToDing("dhl发货C类申报请求的报文".$list['number'].":".$data);		$this->logic_ding->sendToDing("dhl发货C类申报请求的返回参数".$list['number'].":".$res);		$resp = json_decode($res,true);		$j = '';		if(isset($resp['result']))		{			if($resp['result'] == 'OK')			{				$j =  1;			}			else			{				$j =  2;			}		}		else		{			$j =  2;		}		$this->save(array('type'=>$j),$id);	}		public function get_data_9610($data)//9610	{		$num = 1;		$token = $this->_token();		$file_header = array(            'x-request-id: 605062090',			'Authorization: '.$token,			'Content-Type: application/json'        );		$ch = curl_init();		$url = 'https://dps-api.cndhl.com/dps-declaration-api/api/cross-border/submit-declare';		curl_setopt($ch,CURLOPT_URL,$url);		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);		curl_setopt($ch, CURLOPT_HTTPHEADER, $file_header);		curl_setopt($ch,CURLOPT_HEADER,0);		curl_setopt($ch,CURLOPT_POST, 1);		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);        //设置post数据						$post = array();				$post['baseInfo']['logisticsNo']=$data['waybill'];//运单号		$post['baseInfo']['iEFlag']="E";//进出口类型		$post['baseInfo']['ebpName']=$data['shoptype'];//电商平台名称		$post['baseInfo']['ebpUsCode']="91411023MA45JCKTXL";//电商平台统一社会信用代码		$post['baseInfo']['ebpCode']="4110961543";//电商平台海关注册编码        $post['baseInfo']['ebcName']="许昌龙盈实业集团有限公司";//发货人		$post['baseInfo']['ebcUsCode']="91411023MA45JCKTXL";//收发货人统一社会信用代码		$post['baseInfo']['ebcCode']="4110961543";//发货人海关注册编码		$post['baseInfo']['ownerName']="许昌龙盈实业集团有限公司";//生产销售企业名称		$post['baseInfo']['ownerUsCode']="91411023MA45JCKTXL";//生产销售企业统一社会信用代码		$post['baseInfo']['ownerCode']="4110961543";//生产销售企业海关注册编码		$post['baseInfo']['version']="1.0";//报文版本号		$post['baseInfo']['requestTime']=date('Y-m-d H:i:s',time());//报文请求时间				$post['declareInfo']['orderNo']=$data['orderinfo'];//订单编号		$post['declareInfo']['statisticsFlag']="B";//申报业务类型A-简化申报,B-汇总申报,只能填写大写A或者B。		$post['declareInfo']['tradeMode']="9610";//贸易方式		$post['declareInfo']['grossWeight']=sprintf("%.2f",rtrim($data['weight'],'kg'));//毛重		$post['declareInfo']['wrapType']="22";//包装种类		$post['declareInfo']['netWeight']=sprintf("%.2f",$data['jweight']/1000);//净重		$post['declareInfo']['freight']="20";//运费		$post['declareInfo']['fcurrency']="USD";//运费币制		$post['declareInfo']['insuredFee']=$data['bx'];//保费总价		$post['declareInfo']['icurrency']="USD";//保费币制                $post['goodsInfoList'][0]['gnum']=1;//客户需要 从1开始递增		$post['goodsInfoList'][0]['itemNo']= "无";//企业自定义货号		$post['goodsInfoList'][0]['gname']=$data['zwpm'];//商品名称		$post['goodsInfoList'][0]['gcode']=$data['hgbm'];//商品编码		$post['goodsInfoList'][0]['gmodel']="0|0|假发|人发";//规格型号		$post['goodsInfoList'][0]['barCode']="无";//商品条形码		$post['goodsInfoList'][0]['qty1']=$post['declareInfo']['netWeight'];//第一法定数量		$post['goodsInfoList'][0]['unit1']="035";//第一法定计量单位		$post['goodsInfoList'][0]['qty']=$data['ts'];//申报数量		$post['goodsInfoList'][0]['unit']="015";//申报计量单位		$post['goodsInfoList'][0]['price']=$data['dtsbjz'];//单价		$post['goodsInfoList'][0]['totalPrice']=$data['zsbjz'];//总价		$post['goodsInfoList'][0]['currency']="USD";//币制		$data = json_encode($post);		//echo $data;exit;        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);		$res = curl_exec($ch);		curl_close($ch);		$resp = json_decode($res,true);				if(isset($resp['result']))		{			if($resp['result'] == 'OK')			{				return 1;			}			else			{				return $res;			}		}		else		{			return $res;		}	}}  //end class
 |