123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933 |
- <?php
- class Model_Fedex extends Lin_Model {
- function __construct(){
- parent::__construct();
- }
-
- 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['province'] = $dataprovince;
- //默认为ip 选择4服务为ficp
- // $service_type = "FEDEX_INTERNATIONAL_PRIORITY";
- // if($data['js'] == 4){
- // $service_type = "FEDEX_INTERNATIONAL_CONNECT_PLUS";
- // }
-
- //默认为ficp 选择3服务为ip
- $service_type = "FEDEX_INTERNATIONAL_CONNECT_PLUS";
- if($data['js'] == 3){
- $service_type = "FEDEX_INTERNATIONAL_PRIORITY";
- }
- //your account details here
- /**许昌联邦账号
- $key = 'L7Vtg0uUP0BxgNfp';
- $password = 'iOqmHwfjx12sxszdEZstGtRYs';
- $AccountNumber = '644155250';
- $MeterNumber = '250140772';
- **/
- //杭州联邦账号
- $key = 'Jx8Rq9QL34sMKJTK';
- $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
- $AccountNumber = '692362136';
- $MeterNumber = '250759448';
- $xml = '<?xml version="1.0" encoding="UTF-8"?>';
- $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v26="http://fedex.com/ws/ship/v26">';
- $xml.='<soapenv:Header/>';
- $xml.='<soapenv:Body>';
- $xml.='<v26:ProcessShipmentRequest>';
- $xml.='<v26:WebAuthenticationDetail>';
- $xml.='<v26:ParentCredential>';
- $xml.='<v26:Key>'.$key.'</v26:Key>';
- $xml.='<v26:Password>'.$password.'</v26:Password>';
- $xml.='</v26:ParentCredential>';
- $xml.='<v26:UserCredential>';
- $xml.='<v26:Key>'.$key.'</v26:Key>';
- $xml.='<v26:Password>'.$password.'</v26:Password>';
- $xml.='</v26:UserCredential>';
- $xml.='</v26:WebAuthenticationDetail>';
- $xml.='<v26:ClientDetail>';
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:MeterNumber>'.$MeterNumber.'</v26:MeterNumber>';
- $xml.='</v26:ClientDetail>';
- $xml.='<v26:TransactionDetail>';
- //$xml.='<v26:CustomerTransactionId>Ship_International_basic</v26:CustomerTransactionId>';
- $xml.='</v26:TransactionDetail>';
- $xml.='<v26:Version>';
- $xml.='<v26:ServiceId>ship</v26:ServiceId>';
- $xml.='<v26:Major>26</v26:Major>';
- $xml.='<v26:Intermediate>0</v26:Intermediate>';
- $xml.='<v26:Minor>0</v26:Minor>';
- $xml.='</v26:Version>';
- $xml.='<v26:RequestedShipment>';
- $xml.='<v26:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v26:ShipTimestamp>';
- $xml.='<v26:DropoffType>REGULAR_PICKUP</v26:DropoffType>';
- $xml.='<v26:ServiceType>'.$service_type.'</v26:ServiceType>';//FEDEX_INTERNATIONAL_PRIORITY、FEDEX_INTERNATIONAL_PRIORITY_EXPRESS也是优先。INTERNATIONAL_ECONOMY经济
- //超过重量需要换包装,现在不设置,超出也按0.4走
- if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
- {
- $xml.='<v26:PackagingType>FEDEX_PAK</v26:PackagingType>';
- }
- else
- {
- $xml.='<v26:PackagingType>FEDEX_BOX</v26:PackagingType>';
- }
- $xml.='<v26:Shipper>';//发货人信息开始
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>LONGYI</v26:PersonName>';//$data['warehouse']['company']
- $xml.='<v26:CompanyName>LONGYI</v26:CompanyName>';//$data['warehouse']['company']
- $xml.='<v26:PhoneNumber>18539006340</v26:PhoneNumber>';//$data['warehouse']['phone']
- //$xml.='<v26:EMailAddress>'.$data['warehouse']['name'].'</v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='<v26:Address>';
- $xml.='<v26:StreetLines>1703B,building C,bodi center,ningwei street</v26:StreetLines>';//$data['warehouse']['address']
- $xml.='<v26:City>Hang Zhou</v26:City>';//$data['warehouse']['city']
- //$xml.='<v26:StateOrProvinceCode>TN</v26:StateOrProvinceCode>';
- $xml.='<v26:PostalCode>310000</v26:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
- $xml.='<v26:CountryCode>'.$data['warehouse']['lb'].'</v26:CountryCode>';
- $xml.='</v26:Address>';
- $xml.='</v26:Shipper>';
- $xml.='<v26:Recipient>';//收货人信息开始
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>'.$data['name'].'</v26:PersonName>';
- $xml.='<v26:CompanyName>'.$data['client'].'</v26:CompanyName>';
- $xml.='<v26:PhoneNumber>'.$data['phone'].'</v26:PhoneNumber>';
- //$xml.='<v26:EMailAddress>'.$data['name'].'</v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='<v26:Address>';
- $xml.='<v26:StreetLines>'.$data['address'].'</v26:StreetLines>';
- $xml.='<v26:StreetLines>'.$data['address2'].'</v26:StreetLines>';
- $xml.='<v26:City>'.$data['city'].'</v26:City>';
- $xml.='<v26:StateOrProvinceCode>'.$data['province'].'</v26:StateOrProvinceCode>';
- $xml.='<v26:PostalCode>'.$data['zipcode'].'</v26:PostalCode>';
- $xml.='<v26:CountryCode>'.$data['lb'].'</v26:CountryCode>';
- $xml.='</v26:Address>';
- $xml.='</v26:Recipient>';
- $xml.='<v26:ShippingChargesPayment>';
- $xml.='<v26:PaymentType>SENDER</v26:PaymentType>';
- $xml.='<v26:Payor>';
- $xml.='<v26:ResponsibleParty>';
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>He Cong</v26:PersonName>';
- //$xml.='<v26:EMailAddress></v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='</v26:ResponsibleParty>';
- $xml.='</v26:Payor>';
- $xml.='</v26:ShippingChargesPayment>';
- //ETD开始
- $xml.='<v26:SpecialServicesRequested>';
- $xml.='<v26:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v26:SpecialServiceTypes>';
- $xml.='<v26:EtdDetail>';
- $xml.='<v26:RequestedDocumentCopies>COMMERCIAL_INVOICE</v26:RequestedDocumentCopies>';
- $xml.='</v26:EtdDetail>';
- $xml.='</v26:SpecialServicesRequested>';
- //ETD结束
- $xml.='<v26:CustomsClearanceDetail>';
- $xml.='<v26:DutiesPayment>';
- $xml.='<v26:PaymentType>RECIPIENT</v26:PaymentType>';
- $xml.='<v26:Payor>';
- $xml.='<v26:ResponsibleParty>';
- $xml.='<v26:AccountNumber></v26:AccountNumber>';
- //$xml.='<v26:Tins>';
- //$xml.='<v26:TinType>BUSINESS_STATE</v26:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
- //$xml.='<v26:Number>213456</v26:Number>';//这里填税号
- //$xml.='</v26:Tins>';
- //$xml.='<v26:Contact>';
- //$xml.='<v26:ContactId>12345</v26:ContactId>';
- //$xml.='<v26:PersonName>INPUT YOUR INFORMATION</v26:PersonName>';
- //$xml.='</v26:Contact>';
- $xml.='</v26:ResponsibleParty>';
- $xml.='</v26:Payor>';
- $xml.='</v26:DutiesPayment>';
- $xml.='<v26:DocumentContent>DOCUMENTS_ONLY</v26:DocumentContent>';
- $xml.='<v26:CustomsValue>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>'.$data['zsbjz'].'</v26:Amount>';
- $xml.='</v26:CustomsValue>';
- //DESC1---:Commodities循环
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>'.$data['zjs'].'</v26:NumberOfPieces>';//件数
- $hgbm = 67041900;
- if(isset($data['hgbm']))
- {
- if($data['hgbm'] != '')
- {
- $hgbm = $data['hgbm'];
- }
- }
- $xml.='<v26:Description>'.$data['sbpm'].'-'.$data['ts'].'PCS</v26:Description>';//描述 HSCODE:'.$hgbm.'
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:HarmonizedCode>'.$hgbm.'</v26:HarmonizedCode>';
- $xml.='<v26:Weight>';//需要填写重量
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.4</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>'.$data['ts'].'</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>'.$data['dtsbjz'].'</v26:Amount>';
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- /**
- //DESC2
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>HSCODE:67041900</v26:Description>';//描述
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:Weight>';//需要填写重量
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0</v26:Amount>';
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- //DESC3
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>MAKE WOMEN MORE BEAUTIFUL WITH THE HAIR</v26:Description>';//描述
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:Weight>';//需要填写重量
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0</v26:Amount>';
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- //DESC4
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>MADE IN CHINA</v26:Description>';//描述
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:Weight>';//需要填写重量
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0</v26:Amount>';
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- **/
- $xml.='<v26:ExportDetail>';
- $xml.='<v26:ExportComplianceStatement>30.37(f)</v26:ExportComplianceStatement>';
- $xml.='</v26:ExportDetail>';
- $xml.='</v26:CustomsClearanceDetail>';
- $xml.='<v26:LabelSpecification>';
- $xml.='<v26:LabelFormatType>COMMON2D</v26:LabelFormatType>';
- $xml.='<v26:ImageType>PDF</v26:ImageType>';
- $xml.='<v26:LabelStockType>STOCK_4X6.75</v26:LabelStockType>';
- $xml.='</v26:LabelSpecification>';
- //发票参数开始
- $xml.='<v26:ShippingDocumentSpecification>';
- $xml.='<v26:ShippingDocumentTypes>COMMERCIAL_INVOICE</v26:ShippingDocumentTypes>';
- //ETD
- $xml.='<v26:CommercialInvoiceDetail>';
- $xml.='<v26:Format>';
- $xml.='<v26:ImageType>PDF</v26:ImageType>';
- $xml.='<v26:StockType>PAPER_LETTER</v26:StockType>';
- $xml.='<v26:ProvideInstructions>true</v26:ProvideInstructions>';
- $xml.='</v26:Format>';
- $xml.='<v26:CustomerImageUsages>';
- $xml.='<v26:Type>LETTER_HEAD</v26:Type>';
- $xml.='<v26:Id>IMAGE_1</v26:Id>';
- $xml.='</v26:CustomerImageUsages>';
- $xml.='<v26:CustomerImageUsages>';
- $xml.='<v26:Type>SIGNATURE</v26:Type>';
- $xml.='<v26:Id>IMAGE_2</v26:Id>';
- $xml.='</v26:CustomerImageUsages>';
- //ETD
- $xml.='</v26:CommercialInvoiceDetail>';
- $xml.='</v26:ShippingDocumentSpecification>';
- //发票参数结束
- $xml.='<v26:RateRequestTypes>LIST</v26:RateRequestTypes>';//费率请求类型
- $xml.='<v26:PackageCount>'.$data['zjs'].'</v26:PackageCount>';//包装数量
- $xml.='<v26:RequestedPackageLineItems>';
- $xml.='<v26:SequenceNumber>1</v26:SequenceNumber>';
- //$xml.='<v26:InsuredValue><v26:Currency>USD</v26:Currency><v26:Amount>120.00</v26:Amount></v26:InsuredValue>';//保险金额
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';
- $xml.='<v26:Value>0.4</v26:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
- $xml.='</v26:Weight>';
- //超过重量需要填尺寸,现在不设置,超出也按0.4走
- if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
- {
- $xml.='<v26:Dimensions>';
- $xml.='<v26:Length>4</v26:Length>';
- $xml.='<v26:Width>20</v26:Width>';
- $xml.='<v26:Height>30</v26:Height>';
- $xml.='<v26:Units>CM</v26:Units>';
- $xml.='</v26:Dimensions>';
- }
- //$xml.='<v26:ItemDescription>Book</v26:ItemDescription>';//阿联酋需要选择
- $xml.='<v26:CustomerReferences>';
- $xml.='<v26:CustomerReferenceType>CUSTOMER_REFERENCE</v26:CustomerReferenceType>';
- $xml.='<v26:Value>'.$data['number'].'</v26:Value>';
- $xml.='</v26:CustomerReferences>';
- //签名开始
- if($data['qm'] > 0)
- {
- $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
- $xml.='<v26:SpecialServicesRequested>';
- $xml.='<v26:SpecialServiceTypes>SIGNATURE_OPTION</v26:SpecialServiceTypes>';
- $xml.='<v26:SignatureOptionDetail>';
- $xml.='<v26:OptionType>'.$qm.'</v26:OptionType>';
- $xml.='</v26:SignatureOptionDetail>';
- $xml.='</v26:SpecialServicesRequested>';
- }
- //签名结束
- $xml.='</v26:RequestedPackageLineItems>';
- $xml.='</v26:RequestedShipment>';
- $xml.='</v26:ProcessShipmentRequest>';
- $xml.='</soapenv:Body>';
- $xml.='</soapenv:Envelope>';
-
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services/ship');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $result_xml = curl_exec($ch);
- $result_xml = str_replace(array(':','-'), '', $result_xml);
- @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
-
-
- /**
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/fedexhz.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);
- **/
-
-
-
-
-
-
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
- {
- $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']);
- }
- else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
- {
- $a = '';
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
- {
- $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
- }
- else
- {
- foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
- {
- $a .= $v['LocalizedMessage'].'--';
- }
- }
- $g = array('x'=>'0','Description'=>$a);
- }
- else
- {
- $g = array('x'=>'0','Description'=>'未知错误','cw'=>$values);
- }
- return $g;
- }
-
-
- public function get_Upload_signature($id='',$img='')//上传签名图片
- {
- /**
- //一下为旧的测试账号
- $key = 'lx0vfuP9eZMXyDdd';
- $password = '1e6HFUgU1SxoZ6CpYMXBupqQY';
- $AccountNumber = '510087720';
- $MeterNumber = '100421603';
- **/
-
- //以下为旧的正式账号
- /**
- $key = 'L7Vtg0uUP0BxgNfp';
- $password = 'iOqmHwfjx12sxszdEZstGtRYs';
- $AccountNumber = '644155250';
- $MeterNumber = '250140772';
- **/
-
- //以下为杭州账号
- $key = 'Jx8Rq9QL34sMKJTK';
- $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
- $AccountNumber = '692362136';
- $MeterNumber = '250759448';
-
- $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v11="http://fedex.com/ws/uploaddocument/v11">';
- $xml.='<soapenv:Header/>';
- $xml.='<soapenv:Body>';
- $xml.='<v11:UploadImagesRequest>';
- $xml.='<v11:WebAuthenticationDetail>';
- $xml.='<v11:ParentCredential>';
- $xml.='<v11:Key>'.$key.'</v11:Key>';
- $xml.='<v11:Password>'.$password.'</v11:Password>';
- $xml.='</v11:ParentCredential>';
- $xml.='<v11:UserCredential>';
- $xml.='<v11:Key>'.$key.'</v11:Key>';
- $xml.='<v11:Password>'.$password.'</v11:Password>';
- $xml.='</v11:UserCredential>';
- $xml.='</v11:WebAuthenticationDetail>';
- $xml.='<v11:ClientDetail>';
- $xml.='<v11:AccountNumber>'.$AccountNumber.'</v11:AccountNumber>';
- $xml.='<v11:MeterNumber>'.$MeterNumber.'</v11:MeterNumber>';
- $xml.='</v11:ClientDetail>';
- $xml.='<v11:TransactionDetail>';
- $xml.='<v11:CustomerTransactionId>UploadImagesRequest_v11</v11:CustomerTransactionId>';
- $xml.='</v11:TransactionDetail>';
- $xml.='<v11:Version>';
- $xml.='<v11:ServiceId>cdus</v11:ServiceId>';
- $xml.='<v11:Major>11</v11:Major>';
- $xml.='<v11:Intermediate>0</v11:Intermediate>';
- $xml.='<v11:Minor>0</v11:Minor>';
- $xml.='</v11:Version>';
- $xml.='<v11:Images>';
- $xml.='<v11:Id>IMAGE_2</v11:Id>';//填IMAGE_1和IMAGE_2,两个都需要传一遍
- $xml.='<v11:Image></v11:Image>';//填LOGO 700*50 64编码 不用站长工具,转换错误
- $xml.='</v11:Images>';
- $xml.='</v11:UploadImagesRequest>';
- $xml.='</soapenv:Body>';
- $xml.='</soapenv:Envelope>';
- $ch = curl_init();
- //https://ws.fedex.com:443/web-services 正式
- //https://wsbeta.fedex.com:443/web-services 测试
- curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- $result_xml = curl_exec($ch);
- $result_xml = str_replace(array(':','-'), '', $result_xml);
- @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
- return $values;
- }
-
-
- public function get_logistics_q($number)
- {
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/fedexhz.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)//追踪快递
- {
- $key = 'Jx8Rq9QL34sMKJTK';
- $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
- $AccountNumber = '692362136';
- $MeterNumber = '250759448';
-
- $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v16="http://fedex.com/ws/track/v16">';
- $xml.='<soapenv:Header/>';
- $xml.='<soapenv:Body>';
- $xml.='<v16:TrackRequest>';
- $xml.='<v16:WebAuthenticationDetail>';
- $xml.='<v16:ParentCredential>';
- $xml.='<v16:Key>'.$key.'</v16:Key>';
- $xml.='<v16:Password>'.$password.'</v16:Password>';
- $xml.='</v16:ParentCredential>';
- $xml.='<v16:UserCredential>';
- $xml.='<v16:Key>'.$key.'</v16:Key>';
- $xml.='<v16:Password>'.$password.'</v16:Password>';
- $xml.='</v16:UserCredential>';
- $xml.='</v16:WebAuthenticationDetail>';
- $xml.='<v16:ClientDetail>';
- $xml.='<v16:AccountNumber>'.$AccountNumber.'</v16:AccountNumber>';
- $xml.='<v16:MeterNumber>'.$MeterNumber.'</v16:MeterNumber>';
- $xml.='</v16:ClientDetail>';
- $xml.='<v16:TransactionDetail>';
- $xml.='<v16:CustomerTransactionId>Track By Number_v16</v16:CustomerTransactionId>';
- $xml.='<v16:Localization>';
- $xml.='<v16:LanguageCode>EN</v16:LanguageCode>';
- $xml.='<v16:LocaleCode>US</v16:LocaleCode>';
- $xml.='</v16:Localization>';
- $xml.='</v16:TransactionDetail>';
- $xml.='<v16:Version>';
- $xml.='<v16:ServiceId>trck</v16:ServiceId>';
- $xml.='<v16:Major>16</v16:Major>';
- $xml.='<v16:Intermediate>0</v16:Intermediate>';
- $xml.='<v16:Minor>0</v16:Minor>';
- $xml.='</v16:Version>';
- $xml.='<v16:SelectionDetails>';
- $xml.='<v16:CarrierCode>FDXE</v16:CarrierCode>';
- $xml.='<v16:PackageIdentifier>';
- $xml.='<v16:Type>TRACKING_NUMBER_OR_DOORTAG</v16:Type>';
- $xml.='<v16:Value>'.$number['waybill'].'</v16:Value>';
- $xml.='</v16:PackageIdentifier>';
- $xml.='<v16:ShipmentAccountNumber/>';
- $xml.='<v16:SecureSpodAccount/>';
- $xml.='<v16:Destination>';
- $xml.='<v16:GeographicCoordinates>'.$number['address'].$number['address2'].'</v16:GeographicCoordinates>';
- $xml.='</v16:Destination>';
- $xml.='</v16:SelectionDetails>';
- $xml.='</v16:TrackRequest>';
- $xml.='</soapenv:Body>';
- $xml.='</soapenv:Envelope>';
- $ch = curl_init();
- //https://ws.fedex.com:443/web-services 正式
- //https://wsbeta.fedex.com:443/web-services 测试
- curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- $result_xml = curl_exec($ch);
- $result_xml = str_replace(array(':','-'), '', $result_xml);
- @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
- if($values['SOAPENVBody']['TrackReply']['HighestSeverity'] == 'SUCCESS')//SUCCESS成功,FAILURE失败,ERROR错误,WARNING警告,NOTE注意
- {
- $zt = isset($values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description'])?$values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description']:''; //In transit在途中,At FedEx destination facility配送中,Delivered完成
- $xq = '';
- if(stripos($zt,'picked up') !== false)
- {
- $exstate = 2;
- }
- else if(stripos($zt,'In transit') !== false)
- {
- $exstate = 3;
- }
- else if(stripos($zt,'International shipment release') !== false)
- {
- $exstate = 4;
- }
- /**
- else if($zt == 'At local FedEx facility')
- {
- $exstate = 5;
- }
- **/
- else if(stripos($zt,'Delivered') !== false || stripos($zt,'Recipient') !== false)
- {
- $exstate = 6;
- }
- else if(stripos($zt,'Delivery exception') !== false)
- {
- $exstate = 1;
- }
- else
- {
- $exstate = 0;
- }
- $content = date('Y-m-d H',time()).'-查询成功';
- $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$zt,'s'=>$values);//正常可发送站内信
- }
- else
- {
- $content = date('Y-m-d H',time()).'-查询失败';
- $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
- }
- return $list;
- }
-
-
-
-
- public function get_data_old($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');
- $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
- $data['province'] = trim($data['province'],' ');
- $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
- $data['province'] = $dataprovince;
-
- //默认为ip 选择4服务为ficp
- $service_type = "FEDEX_INTERNATIONAL_PRIORITY";
- if($data['js'] == 4){
- $service_type = "FEDEX_INTERNATIONAL_CONNECT_PLUS";
- }
- //your account details here
- /**许昌联邦账号
- $key = 'L7Vtg0uUP0BxgNfp';
- $password = 'iOqmHwfjx12sxszdEZstGtRYs';
- $AccountNumber = '644155250';
- $MeterNumber = '250140772';
- **/
- //杭州联邦账号
- $key = 'Jx8Rq9QL34sMKJTK';
- $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
- $AccountNumber = '692362136';
- $MeterNumber = '250759448';
- $xml = '<?xml version="1.0" encoding="UTF-8"?>';
- $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v23="http://fedex.com/ws/ship/v23">';
- $xml.='<soapenv:Header/>';
- $xml.='<soapenv:Body>';
- $xml.='<v23:ProcessShipmentRequest>';
- $xml.='<v23:WebAuthenticationDetail>';
- $xml.='<v23:ParentCredential>';
- $xml.='<v23:Key>'.$key.'</v23:Key>';
- $xml.='<v23:Password>'.$password.'</v23:Password>';
- $xml.='</v23:ParentCredential>';
- $xml.='<v23:UserCredential>';
- $xml.='<v23:Key>'.$key.'</v23:Key>';
- $xml.='<v23:Password>'.$password.'</v23:Password>';
- $xml.='</v23:UserCredential>';
- $xml.='</v23:WebAuthenticationDetail>';
- $xml.='<v23:ClientDetail>';
- $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
- $xml.='<v23:MeterNumber>'.$MeterNumber.'</v23:MeterNumber>';
- $xml.='</v23:ClientDetail>';
- $xml.='<v23:TransactionDetail>';
- //$xml.='<v23:CustomerTransactionId>Ship_International_basic</v23:CustomerTransactionId>';
- $xml.='</v23:TransactionDetail>';
- $xml.='<v23:Version>';
- $xml.='<v23:ServiceId>ship</v23:ServiceId>';
- $xml.='<v23:Major>23</v23:Major>';
- $xml.='<v23:Intermediate>0</v23:Intermediate>';
- $xml.='<v23:Minor>0</v23:Minor>';
- $xml.='</v23:Version>';
- $xml.='<v23:RequestedShipment>';
- $xml.='<v23:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v23:ShipTimestamp>';
- $xml.='<v23:DropoffType>REGULAR_PICKUP</v23:DropoffType>';
- $xml.='<v23:ServiceType>'.$service_type.'</v23:ServiceType>';//优先。//INTERNATIONAL_ECONOMY经济
- //超过重量需要换包装,现在不设置,超出也按0.4走
- if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
- {
- $xml.='<v23:PackagingType>FEDEX_PAK</v23:PackagingType>';
- }
- else
- {
- $xml.='<v23:PackagingType>FEDEX_BOX</v23:PackagingType>';
- }
- $xml.='<v23:Shipper>';//发货人信息开始
- $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
- $xml.='<v23:Contact>';
- $xml.='<v23:PersonName>LONGYI</v23:PersonName>';//$data['warehouse']['company']
- $xml.='<v23:CompanyName>LONGYI</v23:CompanyName>';//$data['warehouse']['company']
- $xml.='<v23:PhoneNumber>18539006340</v23:PhoneNumber>';//$data['warehouse']['phone']
- //$xml.='<v23:EMailAddress>'.$data['warehouse']['name'].'</v23:EMailAddress>';
- $xml.='</v23:Contact>';
- $xml.='<v23:Address>';
- $xml.='<v23:StreetLines>1703B,building C,bodi center,ningwei street</v23:StreetLines>';//$data['warehouse']['address']
- $xml.='<v23:City>Hang Zhou</v23:City>';//$data['warehouse']['city']
- //$xml.='<v23:StateOrProvinceCode>TN</v23:StateOrProvinceCode>';
- $xml.='<v23:PostalCode>310000</v23:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
- $xml.='<v23:CountryCode>'.$data['warehouse']['lb'].'</v23:CountryCode>';
- $xml.='</v23:Address>';
- $xml.='</v23:Shipper>';
- $xml.='<v23:Recipient>';//收货人信息开始
- $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
- $xml.='<v23:Contact>';
- $xml.='<v23:PersonName>'.$data['name'].'</v23:PersonName>';
- $xml.='<v23:CompanyName>'.$data['name'].'</v23:CompanyName>';
- $xml.='<v23:PhoneNumber>'.$data['phone'].'</v23:PhoneNumber>';
- //$xml.='<v23:EMailAddress>'.$data['name'].'</v23:EMailAddress>';
- $xml.='</v23:Contact>';
- $xml.='<v23:Address>';
- $xml.='<v23:StreetLines>'.$data['address'].'</v23:StreetLines>';
- $xml.='<v23:StreetLines>'.$data['address2'].'</v23:StreetLines>';
- $xml.='<v23:City>'.$data['city'].'</v23:City>';
- $xml.='<v23:StateOrProvinceCode>'.$data['province'].'</v23:StateOrProvinceCode>';
- $xml.='<v23:PostalCode>'.$data['zipcode'].'</v23:PostalCode>';
- $xml.='<v23:CountryCode>'.$data['lb'].'</v23:CountryCode>';
- $xml.='</v23:Address>';
- $xml.='</v23:Recipient>';
- $xml.='<v23:ShippingChargesPayment>';
- $xml.='<v23:PaymentType>SENDER</v23:PaymentType>';
- $xml.='<v23:Payor>';
- $xml.='<v23:ResponsibleParty>';
- $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
- $xml.='<v23:Contact>';
- $xml.='<v23:PersonName>He Cong</v23:PersonName>';
- //$xml.='<v23:EMailAddress></v23:EMailAddress>';
- $xml.='</v23:Contact>';
- $xml.='</v23:ResponsibleParty>';
- $xml.='</v23:Payor>';
- $xml.='</v23:ShippingChargesPayment>';
- //ETD开始
- $xml.='<v23:SpecialServicesRequested>';
- $xml.='<v23:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v23:SpecialServiceTypes>';
- $xml.='<v23:EtdDetail>';
- $xml.='<v23:RequestedDocumentCopies>COMMERCIAL_INVOICE</v23:RequestedDocumentCopies>';
- $xml.='</v23:EtdDetail>';
- $xml.='</v23:SpecialServicesRequested>';
- //ETD结束
- $xml.='<v23:CustomsClearanceDetail>';
- $xml.='<v23:DutiesPayment>';
- $xml.='<v23:PaymentType>RECIPIENT</v23:PaymentType>';
- $xml.='<v23:Payor>';
- $xml.='<v23:ResponsibleParty>';
- $xml.='<v23:AccountNumber></v23:AccountNumber>';
- //$xml.='<v23:Tins>';
- //$xml.='<v23:TinType>BUSINESS_STATE</v23:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
- //$xml.='<v23:Number>213456</v23:Number>';//这里填税号
- //$xml.='</v23:Tins>';
- //$xml.='<v23:Contact>';
- //$xml.='<v23:ContactId>12345</v23:ContactId>';
- //$xml.='<v23:PersonName>INPUT YOUR INFORMATION</v23:PersonName>';
- //$xml.='</v23:Contact>';
- $xml.='</v23:ResponsibleParty>';
- $xml.='</v23:Payor>';
- $xml.='</v23:DutiesPayment>';
- $xml.='<v23:DocumentContent>DOCUMENTS_ONLY</v23:DocumentContent>';
- $xml.='<v23:CustomsValue>';
- $xml.='<v23:Currency>USD</v23:Currency>';
- $xml.='<v23:Amount>'.$data['zsbjz'].'</v23:Amount>';
- $xml.='</v23:CustomsValue>';
- //DESC1---:Commodities循环
- $xml.='<v23:Commodities>';
- $xml.='<v23:NumberOfPieces>'.$data['zjs'].'</v23:NumberOfPieces>';//件数
- $hgbm = 67041900;
- if(isset($data['hgbm']))
- {
- if($data['hgbm'] != '')
- {
- $hgbm = $data['hgbm'];
- }
- }
- $xml.='<v23:Description>'.$data['sbpm'].'-'.$data['ts'].'PCS HSCODE:'.$hgbm.'</v23:Description>';//描述
- $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
- $xml.='<v23:Weight>';//需要填写重量
- $xml.='<v23:Units>KG</v23:Units>';//重量:磅
- $xml.='<v23:Value>0.4</v23:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v23:Weight>';
- $xml.='<v23:Quantity>'.$data['ts'].'</v23:Quantity>';//需要填写数量
- $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
- $xml.='<v23:UnitPrice>';
- $xml.='<v23:Currency>USD</v23:Currency>';
- $xml.='<v23:Amount>'.$data['dtsbjz'].'</v23:Amount>';
- $xml.='</v23:UnitPrice>';
- $xml.='</v23:Commodities>';
- /**
- //DESC2
- $xml.='<v23:Commodities>';
- $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
- $xml.='<v23:Description>HSCODE:67041900</v23:Description>';//描述
- $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
- $xml.='<v23:Weight>';//需要填写重量
- $xml.='<v23:Units>KG</v23:Units>';//重量:磅
- $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
- $xml.='</v23:Weight>';
- $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
- $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
- $xml.='<v23:UnitPrice>';
- $xml.='<v23:Currency>USD</v23:Currency>';
- $xml.='<v23:Amount>0</v23:Amount>';
- $xml.='</v23:UnitPrice>';
- $xml.='</v23:Commodities>';
- //DESC3
- $xml.='<v23:Commodities>';
- $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
- $xml.='<v23:Description>MAKE WOMEN MORE BEAUTIFUL WITH THE HAIR</v23:Description>';//描述
- $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
- $xml.='<v23:Weight>';//需要填写重量
- $xml.='<v23:Units>KG</v23:Units>';//重量:磅
- $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
- $xml.='</v23:Weight>';
- $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
- $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
- $xml.='<v23:UnitPrice>';
- $xml.='<v23:Currency>USD</v23:Currency>';
- $xml.='<v23:Amount>0</v23:Amount>';
- $xml.='</v23:UnitPrice>';
- $xml.='</v23:Commodities>';
- //DESC4
- $xml.='<v23:Commodities>';
- $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
- $xml.='<v23:Description>MADE IN CHINA</v23:Description>';//描述
- $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
- $xml.='<v23:Weight>';//需要填写重量
- $xml.='<v23:Units>KG</v23:Units>';//重量:磅
- $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
- $xml.='</v23:Weight>';
- $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
- $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
- $xml.='<v23:UnitPrice>';
- $xml.='<v23:Currency>USD</v23:Currency>';
- $xml.='<v23:Amount>0</v23:Amount>';
- $xml.='</v23:UnitPrice>';
- $xml.='</v23:Commodities>';
- **/
- $xml.='<v23:ExportDetail>';
- $xml.='<v23:ExportComplianceStatement>30.37(f)</v23:ExportComplianceStatement>';
- $xml.='</v23:ExportDetail>';
- $xml.='</v23:CustomsClearanceDetail>';
- $xml.='<v23:LabelSpecification>';
- $xml.='<v23:LabelFormatType>COMMON2D</v23:LabelFormatType>';
- $xml.='<v23:ImageType>PDF</v23:ImageType>';
- $xml.='<v23:LabelStockType>STOCK_4X6.75</v23:LabelStockType>';
- $xml.='</v23:LabelSpecification>';
- //发票参数开始
- $xml.='<v23:ShippingDocumentSpecification>';
- $xml.='<v23:ShippingDocumentTypes>COMMERCIAL_INVOICE</v23:ShippingDocumentTypes>';
- //ETD
- $xml.='<v23:CommercialInvoiceDetail>';
- $xml.='<v23:Format>';
- $xml.='<v23:ImageType>PDF</v23:ImageType>';
- $xml.='<v23:StockType>PAPER_LETTER</v23:StockType>';
- $xml.='<v23:ProvideInstructions>true</v23:ProvideInstructions>';
- $xml.='</v23:Format>';
- $xml.='<v23:CustomerImageUsages>';
- $xml.='<v23:Type>LETTER_HEAD</v23:Type>';
- $xml.='<v23:Id>IMAGE_1</v23:Id>';
- $xml.='</v23:CustomerImageUsages>';
- $xml.='<v23:CustomerImageUsages>';
- $xml.='<v23:Type>SIGNATURE</v23:Type>';
- $xml.='<v23:Id>IMAGE_2</v23:Id>';
- $xml.='</v23:CustomerImageUsages>';
- //ETD
- $xml.='</v23:CommercialInvoiceDetail>';
- $xml.='</v23:ShippingDocumentSpecification>';
- //发票参数结束
- $xml.='<v23:RateRequestTypes>LIST</v23:RateRequestTypes>';//费率请求类型
- $xml.='<v23:PackageCount>'.$data['zjs'].'</v23:PackageCount>';//包装数量
- $xml.='<v23:RequestedPackageLineItems>';
- $xml.='<v23:SequenceNumber>1</v23:SequenceNumber>';
- //$xml.='<v23:InsuredValue><v23:Currency>USD</v23:Currency><v23:Amount>120.00</v23:Amount></v23:InsuredValue>';//保险金额
- $xml.='<v23:Weight>';
- $xml.='<v23:Units>KG</v23:Units>';
- $xml.='<v23:Value>0.4</v23:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
- $xml.='</v23:Weight>';
- //超过重量需要填尺寸,现在不设置,超出也按0.4走
- if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
- {
- $xml.='<v23:Dimensions>';
- $xml.='<v23:Length>4</v23:Length>';
- $xml.='<v23:Width>20</v23:Width>';
- $xml.='<v23:Height>30</v23:Height>';
- $xml.='<v23:Units>CM</v23:Units>';
- $xml.='</v23:Dimensions>';
- }
- //$xml.='<v23:ItemDescription>Book</v23:ItemDescription>';//阿联酋需要选择
- $xml.='<v23:CustomerReferences>';
- $xml.='<v23:CustomerReferenceType>CUSTOMER_REFERENCE</v23:CustomerReferenceType>';
- $xml.='<v23:Value>'.$data['number'].'</v23:Value>';
- $xml.='</v23:CustomerReferences>';
- //签名开始
- if($data['qm'] > 0)
- {
- $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
- $xml.='<v23:SpecialServicesRequested>';
- $xml.='<v23:SpecialServiceTypes>SIGNATURE_OPTION</v23:SpecialServiceTypes>';
- $xml.='<v23:SignatureOptionDetail>';
- $xml.='<v23:OptionType>'.$qm.'</v23:OptionType>';
- $xml.='</v23:SignatureOptionDetail>';
- $xml.='</v23:SpecialServicesRequested>';
- }
- //签名结束
- $xml.='</v23:RequestedPackageLineItems>';
- $xml.='</v23:RequestedShipment>';
- $xml.='</v23:ProcessShipmentRequest>';
- $xml.='</soapenv:Body>';
- $xml.='</soapenv:Envelope>';
-
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $result_xml = curl_exec($ch);
- $result_xml = str_replace(array(':','-'), '', $result_xml);
- @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
-
-
- /**
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/fedexhz.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);
- **/
-
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
- {
- $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']);
- }
- else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
- {
- $a = '';
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
- {
- $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
- }
- else
- {
- foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
- {
- $a .= $v['LocalizedMessage'].'--';
- }
- }
- $g = array('x'=>'0','Description'=>$a);
- }
- else
- {
- $g = array('x'=>'0','Description'=>'未知错误');
- }
- return $g;
- }
-
- } //end class
|