Model_fedex_ficp.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. <?php
  2. class Model_Fedex_ficp extends Lin_Model {
  3. function __construct(){
  4. parent::__construct();
  5. }
  6. public function get_data($data)
  7. {
  8. $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');
  9. $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
  10. $data['province'] = trim($data['province'],' ');
  11. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  12. $data['province'] = $dataprovince;
  13. //your account details here
  14. /**许昌联邦账号
  15. $key = 'L7Vtg0uUP0BxgNfp';
  16. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  17. $AccountNumber = '644155250';
  18. $MeterNumber = '250140772';
  19. **/
  20. //杭州联邦账号
  21. $key = 'Jx8Rq9QL34sMKJTK';
  22. $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
  23. $AccountNumber = '692362136';
  24. $MeterNumber = '250759448';
  25. $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  26. $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v26="http://fedex.com/ws/ship/v26">';
  27. $xml.='<soapenv:Header/>';
  28. $xml.='<soapenv:Body>';
  29. $xml.='<v26:ProcessShipmentRequest>';
  30. $xml.='<v26:WebAuthenticationDetail>';
  31. $xml.='<v26:ParentCredential>';
  32. $xml.='<v26:Key>'.$key.'</v26:Key>';
  33. $xml.='<v26:Password>'.$password.'</v26:Password>';
  34. $xml.='</v26:ParentCredential>';
  35. $xml.='<v26:UserCredential>';
  36. $xml.='<v26:Key>'.$key.'</v26:Key>';
  37. $xml.='<v26:Password>'.$password.'</v26:Password>';
  38. $xml.='</v26:UserCredential>';
  39. $xml.='</v26:WebAuthenticationDetail>';
  40. $xml.='<v26:ClientDetail>';
  41. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  42. $xml.='<v26:MeterNumber>'.$MeterNumber.'</v26:MeterNumber>';
  43. $xml.='</v26:ClientDetail>';
  44. $xml.='<v26:TransactionDetail>';
  45. //$xml.='<v26:CustomerTransactionId>Ship_International_basic</v26:CustomerTransactionId>';
  46. $xml.='</v26:TransactionDetail>';
  47. $xml.='<v26:Version>';
  48. $xml.='<v26:ServiceId>ship</v26:ServiceId>';
  49. $xml.='<v26:Major>26</v26:Major>';
  50. $xml.='<v26:Intermediate>0</v26:Intermediate>';
  51. $xml.='<v26:Minor>0</v26:Minor>';
  52. $xml.='</v26:Version>';
  53. $xml.='<v26:RequestedShipment>';
  54. $xml.='<v26:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v26:ShipTimestamp>';
  55. $xml.='<v26:DropoffType>REGULAR_PICKUP</v26:DropoffType>';
  56. $xml.='<v26:ServiceType>FEDEX_INTERNATIONAL_CONNECT_PLUS</v26:ServiceType>';//FEDEX_INTERNATIONAL_PRIORITY、FEDEX_INTERNATIONAL_PRIORITY_EXPRESS也是优先。INTERNATIONAL_ECONOMY经济
  57. //超过重量需要换包装,现在不设置,超出也按0.4走
  58. if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
  59. {
  60. $xml.='<v26:PackagingType>FEDEX_PAK</v26:PackagingType>';
  61. }
  62. else
  63. {
  64. $xml.='<v26:PackagingType>FEDEX_BOX</v26:PackagingType>';
  65. }
  66. $xml.='<v26:Shipper>';//发货人信息开始
  67. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  68. $xml.='<v26:Contact>';
  69. $xml.='<v26:PersonName>LONGYI</v26:PersonName>';//$data['warehouse']['company']
  70. $xml.='<v26:CompanyName>LONGYI</v26:CompanyName>';//$data['warehouse']['company']
  71. $xml.='<v26:PhoneNumber>18539006340</v26:PhoneNumber>';//$data['warehouse']['phone']
  72. //$xml.='<v26:EMailAddress>'.$data['warehouse']['name'].'</v26:EMailAddress>';
  73. $xml.='</v26:Contact>';
  74. $xml.='<v26:Address>';
  75. $xml.='<v26:StreetLines>1703B,building C,bodi center,ningwei street</v26:StreetLines>';//$data['warehouse']['address']
  76. $xml.='<v26:City>Hang Zhou</v26:City>';//$data['warehouse']['city']
  77. //$xml.='<v26:StateOrProvinceCode>TN</v26:StateOrProvinceCode>';
  78. $xml.='<v26:PostalCode>310000</v26:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
  79. $xml.='<v26:CountryCode>'.$data['warehouse']['lb'].'</v26:CountryCode>';
  80. $xml.='</v26:Address>';
  81. $xml.='</v26:Shipper>';
  82. $xml.='<v26:Recipient>';//收货人信息开始
  83. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  84. $xml.='<v26:Contact>';
  85. $xml.='<v26:PersonName>'.$data['name'].'</v26:PersonName>';
  86. $xml.='<v26:CompanyName>'.$data['client'].'</v26:CompanyName>';
  87. $xml.='<v26:PhoneNumber>'.$data['phone'].'</v26:PhoneNumber>';
  88. //$xml.='<v26:EMailAddress>'.$data['name'].'</v26:EMailAddress>';
  89. $xml.='</v26:Contact>';
  90. $xml.='<v26:Address>';
  91. $xml.='<v26:StreetLines>'.$data['address'].'</v26:StreetLines>';
  92. $xml.='<v26:StreetLines>'.$data['address2'].'</v26:StreetLines>';
  93. $xml.='<v26:City>'.$data['city'].'</v26:City>';
  94. $xml.='<v26:StateOrProvinceCode>'.$data['province'].'</v26:StateOrProvinceCode>';
  95. $xml.='<v26:PostalCode>'.$data['zipcode'].'</v26:PostalCode>';
  96. $xml.='<v26:CountryCode>'.$data['lb'].'</v26:CountryCode>';
  97. $xml.='</v26:Address>';
  98. $xml.='</v26:Recipient>';
  99. $xml.='<v26:ShippingChargesPayment>';
  100. $xml.='<v26:PaymentType>SENDER</v26:PaymentType>';
  101. $xml.='<v26:Payor>';
  102. $xml.='<v26:ResponsibleParty>';
  103. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  104. $xml.='<v26:Contact>';
  105. $xml.='<v26:PersonName>He Cong</v26:PersonName>';
  106. //$xml.='<v26:EMailAddress></v26:EMailAddress>';
  107. $xml.='</v26:Contact>';
  108. $xml.='</v26:ResponsibleParty>';
  109. $xml.='</v26:Payor>';
  110. $xml.='</v26:ShippingChargesPayment>';
  111. //ETD开始
  112. $xml.='<v26:SpecialServicesRequested>';
  113. $xml.='<v26:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v26:SpecialServiceTypes>';
  114. $xml.='<v26:EtdDetail>';
  115. $xml.='<v26:RequestedDocumentCopies>COMMERCIAL_INVOICE</v26:RequestedDocumentCopies>';
  116. $xml.='</v26:EtdDetail>';
  117. $xml.='</v26:SpecialServicesRequested>';
  118. //ETD结束
  119. $xml.='<v26:CustomsClearanceDetail>';
  120. $xml.='<v26:DutiesPayment>';
  121. $xml.='<v26:PaymentType>RECIPIENT</v26:PaymentType>';
  122. $xml.='<v26:Payor>';
  123. $xml.='<v26:ResponsibleParty>';
  124. $xml.='<v26:AccountNumber></v26:AccountNumber>';
  125. //$xml.='<v26:Tins>';
  126. //$xml.='<v26:TinType>BUSINESS_STATE</v26:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
  127. //$xml.='<v26:Number>213456</v26:Number>';//这里填税号
  128. //$xml.='</v26:Tins>';
  129. //$xml.='<v26:Contact>';
  130. //$xml.='<v26:ContactId>12345</v26:ContactId>';
  131. //$xml.='<v26:PersonName>INPUT YOUR INFORMATION</v26:PersonName>';
  132. //$xml.='</v26:Contact>';
  133. $xml.='</v26:ResponsibleParty>';
  134. $xml.='</v26:Payor>';
  135. $xml.='</v26:DutiesPayment>';
  136. $xml.='<v26:DocumentContent>DOCUMENTS_ONLY</v26:DocumentContent>';
  137. $xml.='<v26:CustomsValue>';
  138. $xml.='<v26:Currency>USD</v26:Currency>';
  139. $xml.='<v26:Amount>'.$data['zsbjz'].'</v26:Amount>';
  140. $xml.='</v26:CustomsValue>';
  141. //DESC1---:Commodities循环
  142. $xml.='<v26:Commodities>';
  143. $xml.='<v26:NumberOfPieces>'.$data['zjs'].'</v26:NumberOfPieces>';//件数
  144. $hgbm = 67041900;
  145. if(isset($data['hgbm']))
  146. {
  147. if($data['hgbm'] != '')
  148. {
  149. $hgbm = $data['hgbm'];
  150. }
  151. }
  152. $xml.='<v26:Description>'.$data['sbpm'].'-'.$data['ts'].'PCS</v26:Description>';//描述 HSCODE:'.$hgbm.'
  153. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  154. $xml.='<v26:HarmonizedCode>'.$hgbm.'</v26:HarmonizedCode>';
  155. $xml.='<v26:Weight>';//需要填写重量
  156. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  157. $xml.='<v26:Value>0.4</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  158. $xml.='</v26:Weight>';
  159. $xml.='<v26:Quantity>'.$data['ts'].'</v26:Quantity>';//需要填写数量
  160. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  161. $xml.='<v26:UnitPrice>';
  162. $xml.='<v26:Currency>USD</v26:Currency>';
  163. $xml.='<v26:Amount>'.$data['dtsbjz'].'</v26:Amount>';
  164. $xml.='</v26:UnitPrice>';
  165. $xml.='</v26:Commodities>';
  166. /**
  167. //DESC2
  168. $xml.='<v26:Commodities>';
  169. $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
  170. $xml.='<v26:Description>HSCODE:67041900</v26:Description>';//描述
  171. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  172. $xml.='<v26:Weight>';//需要填写重量
  173. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  174. $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
  175. $xml.='</v26:Weight>';
  176. $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
  177. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  178. $xml.='<v26:UnitPrice>';
  179. $xml.='<v26:Currency>USD</v26:Currency>';
  180. $xml.='<v26:Amount>0</v26:Amount>';
  181. $xml.='</v26:UnitPrice>';
  182. $xml.='</v26:Commodities>';
  183. //DESC3
  184. $xml.='<v26:Commodities>';
  185. $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
  186. $xml.='<v26:Description>MAKE WOMEN MORE BEAUTIFUL WITH THE HAIR</v26:Description>';//描述
  187. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  188. $xml.='<v26:Weight>';//需要填写重量
  189. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  190. $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
  191. $xml.='</v26:Weight>';
  192. $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
  193. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  194. $xml.='<v26:UnitPrice>';
  195. $xml.='<v26:Currency>USD</v26:Currency>';
  196. $xml.='<v26:Amount>0</v26:Amount>';
  197. $xml.='</v26:UnitPrice>';
  198. $xml.='</v26:Commodities>';
  199. //DESC4
  200. $xml.='<v26:Commodities>';
  201. $xml.='<v26:NumberOfPieces>0</v26:NumberOfPieces>';//件数
  202. $xml.='<v26:Description>MADE IN CHINA</v26:Description>';//描述
  203. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  204. $xml.='<v26:Weight>';//需要填写重量
  205. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  206. $xml.='<v26:Value>0.0001</v26:Value>';//重量填写单位为KG
  207. $xml.='</v26:Weight>';
  208. $xml.='<v26:Quantity>1</v26:Quantity>';//需要填写数量
  209. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  210. $xml.='<v26:UnitPrice>';
  211. $xml.='<v26:Currency>USD</v26:Currency>';
  212. $xml.='<v26:Amount>0</v26:Amount>';
  213. $xml.='</v26:UnitPrice>';
  214. $xml.='</v26:Commodities>';
  215. **/
  216. $xml.='<v26:ExportDetail>';
  217. $xml.='<v26:ExportComplianceStatement>30.37(f)</v26:ExportComplianceStatement>';
  218. $xml.='</v26:ExportDetail>';
  219. $xml.='</v26:CustomsClearanceDetail>';
  220. $xml.='<v26:LabelSpecification>';
  221. $xml.='<v26:LabelFormatType>COMMON2D</v26:LabelFormatType>';
  222. $xml.='<v26:ImageType>PDF</v26:ImageType>';
  223. $xml.='<v26:LabelStockType>STOCK_4X6.75</v26:LabelStockType>';
  224. $xml.='</v26:LabelSpecification>';
  225. //发票参数开始
  226. $xml.='<v26:ShippingDocumentSpecification>';
  227. $xml.='<v26:ShippingDocumentTypes>COMMERCIAL_INVOICE</v26:ShippingDocumentTypes>';
  228. //ETD
  229. $xml.='<v26:CommercialInvoiceDetail>';
  230. $xml.='<v26:Format>';
  231. $xml.='<v26:ImageType>PDF</v26:ImageType>';
  232. $xml.='<v26:StockType>PAPER_LETTER</v26:StockType>';
  233. $xml.='<v26:ProvideInstructions>true</v26:ProvideInstructions>';
  234. $xml.='</v26:Format>';
  235. $xml.='<v26:CustomerImageUsages>';
  236. $xml.='<v26:Type>LETTER_HEAD</v26:Type>';
  237. $xml.='<v26:Id>IMAGE_1</v26:Id>';
  238. $xml.='</v26:CustomerImageUsages>';
  239. $xml.='<v26:CustomerImageUsages>';
  240. $xml.='<v26:Type>SIGNATURE</v26:Type>';
  241. $xml.='<v26:Id>IMAGE_2</v26:Id>';
  242. $xml.='</v26:CustomerImageUsages>';
  243. //ETD
  244. $xml.='</v26:CommercialInvoiceDetail>';
  245. $xml.='</v26:ShippingDocumentSpecification>';
  246. //发票参数结束
  247. $xml.='<v26:RateRequestTypes>LIST</v26:RateRequestTypes>';//费率请求类型
  248. $xml.='<v26:PackageCount>'.$data['zjs'].'</v26:PackageCount>';//包装数量
  249. $xml.='<v26:RequestedPackageLineItems>';
  250. $xml.='<v26:SequenceNumber>1</v26:SequenceNumber>';
  251. //$xml.='<v26:InsuredValue><v26:Currency>USD</v26:Currency><v26:Amount>120.00</v26:Amount></v26:InsuredValue>';//保险金额
  252. $xml.='<v26:Weight>';
  253. $xml.='<v26:Units>KG</v26:Units>';
  254. $xml.='<v26:Value>0.4</v26:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
  255. $xml.='</v26:Weight>';
  256. //超过重量需要填尺寸,现在不设置,超出也按0.4走
  257. if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
  258. {
  259. $xml.='<v26:Dimensions>';
  260. $xml.='<v26:Length>4</v26:Length>';
  261. $xml.='<v26:Width>20</v26:Width>';
  262. $xml.='<v26:Height>30</v26:Height>';
  263. $xml.='<v26:Units>CM</v26:Units>';
  264. $xml.='</v26:Dimensions>';
  265. }
  266. //$xml.='<v26:ItemDescription>Book</v26:ItemDescription>';//阿联酋需要选择
  267. $xml.='<v26:CustomerReferences>';
  268. $xml.='<v26:CustomerReferenceType>CUSTOMER_REFERENCE</v26:CustomerReferenceType>';
  269. $xml.='<v26:Value>'.$data['number'].'</v26:Value>';
  270. $xml.='</v26:CustomerReferences>';
  271. //签名开始
  272. if($data['qm'] > 0)
  273. {
  274. $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
  275. $xml.='<v26:SpecialServicesRequested>';
  276. $xml.='<v26:SpecialServiceTypes>SIGNATURE_OPTION</v26:SpecialServiceTypes>';
  277. $xml.='<v26:SignatureOptionDetail>';
  278. $xml.='<v26:OptionType>'.$qm.'</v26:OptionType>';
  279. $xml.='</v26:SignatureOptionDetail>';
  280. $xml.='</v26:SpecialServicesRequested>';
  281. }
  282. //签名结束
  283. $xml.='</v26:RequestedPackageLineItems>';
  284. $xml.='</v26:RequestedShipment>';
  285. $xml.='</v26:ProcessShipmentRequest>';
  286. $xml.='</soapenv:Body>';
  287. $xml.='</soapenv:Envelope>';
  288. file_put_contents("./test.txt",$xml);
  289. $ch = curl_init();
  290. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services/ship');
  291. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  292. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  293. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  294. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  295. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  296. curl_setopt($ch, CURLOPT_POST, 1);
  297. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  298. $result_xml = curl_exec($ch);
  299. $result_xml = str_replace(array(':','-'), '', $result_xml);
  300. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  301. /**
  302. $ch = curl_init();
  303. $url = 'http://z.wepolicy.cn/fedexhz.php';
  304. curl_setopt($ch,CURLOPT_URL,$url);
  305. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  306. curl_setopt($ch,CURLOPT_HEADER,0);
  307. curl_setopt($ch,CURLOPT_POST, 1);
  308. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  309. //设置post数据
  310. $post = array();
  311. $post['data'] = $xml;
  312. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  313. $res = curl_exec($ch);
  314. curl_close($ch);
  315. $values = json_decode($res,true);
  316. **/
  317. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
  318. {
  319. $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']);
  320. }
  321. else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
  322. {
  323. $a = '';
  324. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
  325. {
  326. $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
  327. }
  328. else
  329. {
  330. foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
  331. {
  332. $a .= $v['LocalizedMessage'].'--';
  333. }
  334. }
  335. $g = array('x'=>'0','Description'=>$a);
  336. }
  337. else
  338. {
  339. $g = array('x'=>'0','Description'=>'未知错误','cw'=>$values);
  340. }
  341. return $g;
  342. }
  343. public function get_Upload_signature($id='',$img='')//上传签名图片
  344. {
  345. /**
  346. //一下为旧的测试账号
  347. $key = 'lx0vfuP9eZMXyDdd';
  348. $password = '1e6HFUgU1SxoZ6CpYMXBupqQY';
  349. $AccountNumber = '510087720';
  350. $MeterNumber = '100421603';
  351. **/
  352. //以下为旧的正式账号
  353. /**
  354. $key = 'L7Vtg0uUP0BxgNfp';
  355. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  356. $AccountNumber = '644155250';
  357. $MeterNumber = '250140772';
  358. **/
  359. //以下为杭州账号
  360. $key = 'Jx8Rq9QL34sMKJTK';
  361. $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
  362. $AccountNumber = '692362136';
  363. $MeterNumber = '250759448';
  364. $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v11="http://fedex.com/ws/uploaddocument/v11">';
  365. $xml.='<soapenv:Header/>';
  366. $xml.='<soapenv:Body>';
  367. $xml.='<v11:UploadImagesRequest>';
  368. $xml.='<v11:WebAuthenticationDetail>';
  369. $xml.='<v11:ParentCredential>';
  370. $xml.='<v11:Key>'.$key.'</v11:Key>';
  371. $xml.='<v11:Password>'.$password.'</v11:Password>';
  372. $xml.='</v11:ParentCredential>';
  373. $xml.='<v11:UserCredential>';
  374. $xml.='<v11:Key>'.$key.'</v11:Key>';
  375. $xml.='<v11:Password>'.$password.'</v11:Password>';
  376. $xml.='</v11:UserCredential>';
  377. $xml.='</v11:WebAuthenticationDetail>';
  378. $xml.='<v11:ClientDetail>';
  379. $xml.='<v11:AccountNumber>'.$AccountNumber.'</v11:AccountNumber>';
  380. $xml.='<v11:MeterNumber>'.$MeterNumber.'</v11:MeterNumber>';
  381. $xml.='</v11:ClientDetail>';
  382. $xml.='<v11:TransactionDetail>';
  383. $xml.='<v11:CustomerTransactionId>UploadImagesRequest_v11</v11:CustomerTransactionId>';
  384. $xml.='</v11:TransactionDetail>';
  385. $xml.='<v11:Version>';
  386. $xml.='<v11:ServiceId>cdus</v11:ServiceId>';
  387. $xml.='<v11:Major>11</v11:Major>';
  388. $xml.='<v11:Intermediate>0</v11:Intermediate>';
  389. $xml.='<v11:Minor>0</v11:Minor>';
  390. $xml.='</v11:Version>';
  391. $xml.='<v11:Images>';
  392. $xml.='<v11:Id>IMAGE_2</v11:Id>';//填IMAGE_1和IMAGE_2,两个都需要传一遍
  393. $xml.='<v11:Image></v11:Image>';//填LOGO 700*50 64编码 不用站长工具,转换错误
  394. $xml.='</v11:Images>';
  395. $xml.='</v11:UploadImagesRequest>';
  396. $xml.='</soapenv:Body>';
  397. $xml.='</soapenv:Envelope>';
  398. $ch = curl_init();
  399. //https://ws.fedex.com:443/web-services 正式
  400. //https://wsbeta.fedex.com:443/web-services 测试
  401. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  402. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  403. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  404. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  405. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  406. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  407. curl_setopt($ch, CURLOPT_POST, 1);
  408. $result_xml = curl_exec($ch);
  409. $result_xml = str_replace(array(':','-'), '', $result_xml);
  410. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  411. return $values;
  412. }
  413. public function get_logistics_q($number)
  414. {
  415. $ch = curl_init();
  416. $url = 'http://z.wepolicy.cn/fedexhz.php';
  417. curl_setopt($ch,CURLOPT_URL,$url);
  418. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  419. curl_setopt($ch,CURLOPT_HEADER,0);
  420. curl_setopt($ch,CURLOPT_POST, 1);
  421. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  422. //设置post数据
  423. $post = array();
  424. $post['number'] = $number;
  425. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  426. $res = curl_exec($ch);
  427. curl_close($ch);
  428. $values = json_decode($res,true);
  429. return $values;
  430. }
  431. public function get_logistics($number)//追踪快递
  432. {
  433. $key = 'Jx8Rq9QL34sMKJTK';
  434. $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
  435. $AccountNumber = '692362136';
  436. $MeterNumber = '250759448';
  437. $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v16="http://fedex.com/ws/track/v16">';
  438. $xml.='<soapenv:Header/>';
  439. $xml.='<soapenv:Body>';
  440. $xml.='<v16:TrackRequest>';
  441. $xml.='<v16:WebAuthenticationDetail>';
  442. $xml.='<v16:ParentCredential>';
  443. $xml.='<v16:Key>'.$key.'</v16:Key>';
  444. $xml.='<v16:Password>'.$password.'</v16:Password>';
  445. $xml.='</v16:ParentCredential>';
  446. $xml.='<v16:UserCredential>';
  447. $xml.='<v16:Key>'.$key.'</v16:Key>';
  448. $xml.='<v16:Password>'.$password.'</v16:Password>';
  449. $xml.='</v16:UserCredential>';
  450. $xml.='</v16:WebAuthenticationDetail>';
  451. $xml.='<v16:ClientDetail>';
  452. $xml.='<v16:AccountNumber>'.$AccountNumber.'</v16:AccountNumber>';
  453. $xml.='<v16:MeterNumber>'.$MeterNumber.'</v16:MeterNumber>';
  454. $xml.='</v16:ClientDetail>';
  455. $xml.='<v16:TransactionDetail>';
  456. $xml.='<v16:CustomerTransactionId>Track By Number_v16</v16:CustomerTransactionId>';
  457. $xml.='<v16:Localization>';
  458. $xml.='<v16:LanguageCode>EN</v16:LanguageCode>';
  459. $xml.='<v16:LocaleCode>US</v16:LocaleCode>';
  460. $xml.='</v16:Localization>';
  461. $xml.='</v16:TransactionDetail>';
  462. $xml.='<v16:Version>';
  463. $xml.='<v16:ServiceId>trck</v16:ServiceId>';
  464. $xml.='<v16:Major>16</v16:Major>';
  465. $xml.='<v16:Intermediate>0</v16:Intermediate>';
  466. $xml.='<v16:Minor>0</v16:Minor>';
  467. $xml.='</v16:Version>';
  468. $xml.='<v16:SelectionDetails>';
  469. $xml.='<v16:CarrierCode>FDXE</v16:CarrierCode>';
  470. $xml.='<v16:PackageIdentifier>';
  471. $xml.='<v16:Type>TRACKING_NUMBER_OR_DOORTAG</v16:Type>';
  472. $xml.='<v16:Value>'.$number['waybill'].'</v16:Value>';
  473. $xml.='</v16:PackageIdentifier>';
  474. $xml.='<v16:ShipmentAccountNumber/>';
  475. $xml.='<v16:SecureSpodAccount/>';
  476. $xml.='<v16:Destination>';
  477. $xml.='<v16:GeographicCoordinates>'.$number['address'].$number['address2'].'</v16:GeographicCoordinates>';
  478. $xml.='</v16:Destination>';
  479. $xml.='</v16:SelectionDetails>';
  480. $xml.='</v16:TrackRequest>';
  481. $xml.='</soapenv:Body>';
  482. $xml.='</soapenv:Envelope>';
  483. $ch = curl_init();
  484. //https://ws.fedex.com:443/web-services 正式
  485. //https://wsbeta.fedex.com:443/web-services 测试
  486. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  487. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  488. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  489. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  490. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  491. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  492. curl_setopt($ch, CURLOPT_POST, 1);
  493. $result_xml = curl_exec($ch);
  494. $result_xml = str_replace(array(':','-'), '', $result_xml);
  495. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  496. if($values['SOAPENVBody']['TrackReply']['HighestSeverity'] == 'SUCCESS')//SUCCESS成功,FAILURE失败,ERROR错误,WARNING警告,NOTE注意
  497. {
  498. $zt = isset($values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description'])?$values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description']:''; //In transit在途中,At FedEx destination facility配送中,Delivered完成
  499. $xq = '';
  500. if(stripos($zt,'picked up') !== false)
  501. {
  502. $exstate = 2;
  503. }
  504. else if(stripos($zt,'In transit') !== false)
  505. {
  506. $exstate = 3;
  507. }
  508. else if(stripos($zt,'International shipment release') !== false)
  509. {
  510. $exstate = 4;
  511. }
  512. /**
  513. else if($zt == 'At local FedEx facility')
  514. {
  515. $exstate = 5;
  516. }
  517. **/
  518. else if(stripos($zt,'Delivered') !== false || stripos($zt,'Recipient') !== false)
  519. {
  520. $exstate = 6;
  521. }
  522. else if(stripos($zt,'Delivery exception') !== false)
  523. {
  524. $exstate = 1;
  525. }
  526. else
  527. {
  528. $exstate = 0;
  529. }
  530. $content = date('Y-m-d H',time()).'-查询成功';
  531. $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$zt,'s'=>$values);//正常可发送站内信
  532. }
  533. else
  534. {
  535. $content = date('Y-m-d H',time()).'-查询失败';
  536. $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
  537. }
  538. return $list;
  539. }
  540. public function get_data_old($data)
  541. {
  542. $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');
  543. $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
  544. $data['province'] = trim($data['province'],' ');
  545. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  546. $data['province'] = $dataprovince;
  547. //your account details here
  548. /**许昌联邦账号
  549. $key = 'L7Vtg0uUP0BxgNfp';
  550. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  551. $AccountNumber = '644155250';
  552. $MeterNumber = '250140772';
  553. **/
  554. //杭州联邦账号
  555. $key = 'Jx8Rq9QL34sMKJTK';
  556. $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
  557. $AccountNumber = '692362136';
  558. $MeterNumber = '250759448';
  559. $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  560. $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v23="http://fedex.com/ws/ship/v23">';
  561. $xml.='<soapenv:Header/>';
  562. $xml.='<soapenv:Body>';
  563. $xml.='<v23:ProcessShipmentRequest>';
  564. $xml.='<v23:WebAuthenticationDetail>';
  565. $xml.='<v23:ParentCredential>';
  566. $xml.='<v23:Key>'.$key.'</v23:Key>';
  567. $xml.='<v23:Password>'.$password.'</v23:Password>';
  568. $xml.='</v23:ParentCredential>';
  569. $xml.='<v23:UserCredential>';
  570. $xml.='<v23:Key>'.$key.'</v23:Key>';
  571. $xml.='<v23:Password>'.$password.'</v23:Password>';
  572. $xml.='</v23:UserCredential>';
  573. $xml.='</v23:WebAuthenticationDetail>';
  574. $xml.='<v23:ClientDetail>';
  575. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  576. $xml.='<v23:MeterNumber>'.$MeterNumber.'</v23:MeterNumber>';
  577. $xml.='</v23:ClientDetail>';
  578. $xml.='<v23:TransactionDetail>';
  579. //$xml.='<v23:CustomerTransactionId>Ship_International_basic</v23:CustomerTransactionId>';
  580. $xml.='</v23:TransactionDetail>';
  581. $xml.='<v23:Version>';
  582. $xml.='<v23:ServiceId>ship</v23:ServiceId>';
  583. $xml.='<v23:Major>23</v23:Major>';
  584. $xml.='<v23:Intermediate>0</v23:Intermediate>';
  585. $xml.='<v23:Minor>0</v23:Minor>';
  586. $xml.='</v23:Version>';
  587. $xml.='<v23:RequestedShipment>';
  588. $xml.='<v23:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v23:ShipTimestamp>';
  589. $xml.='<v23:DropoffType>REGULAR_PICKUP</v23:DropoffType>';
  590. $xml.='<v23:ServiceType>FEDEX_INTERNATIONAL_CONNECT_PLUS</v23:ServiceType>';//优先。
  591. //超过重量需要换包装,现在不设置,超出也按0.4走
  592. if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
  593. {
  594. $xml.='<v23:PackagingType>FEDEX_PAK</v23:PackagingType>';
  595. }
  596. else
  597. {
  598. $xml.='<v23:PackagingType>FEDEX_BOX</v23:PackagingType>';
  599. }
  600. $xml.='<v23:Shipper>';//发货人信息开始
  601. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  602. $xml.='<v23:Contact>';
  603. $xml.='<v23:PersonName>LONGYI</v23:PersonName>';//$data['warehouse']['company']
  604. $xml.='<v23:CompanyName>LONGYI</v23:CompanyName>';//$data['warehouse']['company']
  605. $xml.='<v23:PhoneNumber>18539006340</v23:PhoneNumber>';//$data['warehouse']['phone']
  606. //$xml.='<v23:EMailAddress>'.$data['warehouse']['name'].'</v23:EMailAddress>';
  607. $xml.='</v23:Contact>';
  608. $xml.='<v23:Address>';
  609. $xml.='<v23:StreetLines>1703B,building C,bodi center,ningwei street</v23:StreetLines>';//$data['warehouse']['address']
  610. $xml.='<v23:City>Hang Zhou</v23:City>';//$data['warehouse']['city']
  611. //$xml.='<v23:StateOrProvinceCode>TN</v23:StateOrProvinceCode>';
  612. $xml.='<v23:PostalCode>310000</v23:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
  613. $xml.='<v23:CountryCode>'.$data['warehouse']['lb'].'</v23:CountryCode>';
  614. $xml.='</v23:Address>';
  615. $xml.='</v23:Shipper>';
  616. $xml.='<v23:Recipient>';//收货人信息开始
  617. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  618. $xml.='<v23:Contact>';
  619. $xml.='<v23:PersonName>'.$data['name'].'</v23:PersonName>';
  620. $xml.='<v23:CompanyName>'.$data['name'].'</v23:CompanyName>';
  621. $xml.='<v23:PhoneNumber>'.$data['phone'].'</v23:PhoneNumber>';
  622. //$xml.='<v23:EMailAddress>'.$data['name'].'</v23:EMailAddress>';
  623. $xml.='</v23:Contact>';
  624. $xml.='<v23:Address>';
  625. $xml.='<v23:StreetLines>'.$data['address'].'</v23:StreetLines>';
  626. $xml.='<v23:StreetLines>'.$data['address2'].'</v23:StreetLines>';
  627. $xml.='<v23:City>'.$data['city'].'</v23:City>';
  628. $xml.='<v23:StateOrProvinceCode>'.$data['province'].'</v23:StateOrProvinceCode>';
  629. $xml.='<v23:PostalCode>'.$data['zipcode'].'</v23:PostalCode>';
  630. $xml.='<v23:CountryCode>'.$data['lb'].'</v23:CountryCode>';
  631. $xml.='</v23:Address>';
  632. $xml.='</v23:Recipient>';
  633. $xml.='<v23:ShippingChargesPayment>';
  634. $xml.='<v23:PaymentType>SENDER</v23:PaymentType>';
  635. $xml.='<v23:Payor>';
  636. $xml.='<v23:ResponsibleParty>';
  637. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  638. $xml.='<v23:Contact>';
  639. $xml.='<v23:PersonName>He Cong</v23:PersonName>';
  640. //$xml.='<v23:EMailAddress></v23:EMailAddress>';
  641. $xml.='</v23:Contact>';
  642. $xml.='</v23:ResponsibleParty>';
  643. $xml.='</v23:Payor>';
  644. $xml.='</v23:ShippingChargesPayment>';
  645. //ETD开始
  646. $xml.='<v23:SpecialServicesRequested>';
  647. $xml.='<v23:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v23:SpecialServiceTypes>';
  648. $xml.='<v23:EtdDetail>';
  649. $xml.='<v23:RequestedDocumentCopies>COMMERCIAL_INVOICE</v23:RequestedDocumentCopies>';
  650. $xml.='</v23:EtdDetail>';
  651. $xml.='</v23:SpecialServicesRequested>';
  652. //ETD结束
  653. $xml.='<v23:CustomsClearanceDetail>';
  654. $xml.='<v23:DutiesPayment>';
  655. $xml.='<v23:PaymentType>RECIPIENT</v23:PaymentType>';
  656. $xml.='<v23:Payor>';
  657. $xml.='<v23:ResponsibleParty>';
  658. $xml.='<v23:AccountNumber></v23:AccountNumber>';
  659. //$xml.='<v23:Tins>';
  660. //$xml.='<v23:TinType>BUSINESS_STATE</v23:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
  661. //$xml.='<v23:Number>213456</v23:Number>';//这里填税号
  662. //$xml.='</v23:Tins>';
  663. //$xml.='<v23:Contact>';
  664. //$xml.='<v23:ContactId>12345</v23:ContactId>';
  665. //$xml.='<v23:PersonName>INPUT YOUR INFORMATION</v23:PersonName>';
  666. //$xml.='</v23:Contact>';
  667. $xml.='</v23:ResponsibleParty>';
  668. $xml.='</v23:Payor>';
  669. $xml.='</v23:DutiesPayment>';
  670. $xml.='<v23:DocumentContent>DOCUMENTS_ONLY</v23:DocumentContent>';
  671. $xml.='<v23:CustomsValue>';
  672. $xml.='<v23:Currency>USD</v23:Currency>';
  673. $xml.='<v23:Amount>'.$data['zsbjz'].'</v23:Amount>';
  674. $xml.='</v23:CustomsValue>';
  675. //DESC1---:Commodities循环
  676. $xml.='<v23:Commodities>';
  677. $xml.='<v23:NumberOfPieces>'.$data['zjs'].'</v23:NumberOfPieces>';//件数
  678. $hgbm = 67041900;
  679. if(isset($data['hgbm']))
  680. {
  681. if($data['hgbm'] != '')
  682. {
  683. $hgbm = $data['hgbm'];
  684. }
  685. }
  686. $xml.='<v23:Description>'.$data['sbpm'].'-'.$data['ts'].'PCS HSCODE:'.$hgbm.'</v23:Description>';//描述
  687. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  688. $xml.='<v23:Weight>';//需要填写重量
  689. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  690. $xml.='<v23:Value>0.4</v23:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  691. $xml.='</v23:Weight>';
  692. $xml.='<v23:Quantity>'.$data['ts'].'</v23:Quantity>';//需要填写数量
  693. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  694. $xml.='<v23:UnitPrice>';
  695. $xml.='<v23:Currency>USD</v23:Currency>';
  696. $xml.='<v23:Amount>'.$data['dtsbjz'].'</v23:Amount>';
  697. $xml.='</v23:UnitPrice>';
  698. $xml.='</v23:Commodities>';
  699. /**
  700. //DESC2
  701. $xml.='<v23:Commodities>';
  702. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  703. $xml.='<v23:Description>HSCODE:67041900</v23:Description>';//描述
  704. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  705. $xml.='<v23:Weight>';//需要填写重量
  706. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  707. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  708. $xml.='</v23:Weight>';
  709. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  710. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  711. $xml.='<v23:UnitPrice>';
  712. $xml.='<v23:Currency>USD</v23:Currency>';
  713. $xml.='<v23:Amount>0</v23:Amount>';
  714. $xml.='</v23:UnitPrice>';
  715. $xml.='</v23:Commodities>';
  716. //DESC3
  717. $xml.='<v23:Commodities>';
  718. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  719. $xml.='<v23:Description>MAKE WOMEN MORE BEAUTIFUL WITH THE HAIR</v23:Description>';//描述
  720. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  721. $xml.='<v23:Weight>';//需要填写重量
  722. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  723. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  724. $xml.='</v23:Weight>';
  725. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  726. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  727. $xml.='<v23:UnitPrice>';
  728. $xml.='<v23:Currency>USD</v23:Currency>';
  729. $xml.='<v23:Amount>0</v23:Amount>';
  730. $xml.='</v23:UnitPrice>';
  731. $xml.='</v23:Commodities>';
  732. //DESC4
  733. $xml.='<v23:Commodities>';
  734. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  735. $xml.='<v23:Description>MADE IN CHINA</v23:Description>';//描述
  736. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  737. $xml.='<v23:Weight>';//需要填写重量
  738. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  739. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  740. $xml.='</v23:Weight>';
  741. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  742. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  743. $xml.='<v23:UnitPrice>';
  744. $xml.='<v23:Currency>USD</v23:Currency>';
  745. $xml.='<v23:Amount>0</v23:Amount>';
  746. $xml.='</v23:UnitPrice>';
  747. $xml.='</v23:Commodities>';
  748. **/
  749. $xml.='<v23:ExportDetail>';
  750. $xml.='<v23:ExportComplianceStatement>30.37(f)</v23:ExportComplianceStatement>';
  751. $xml.='</v23:ExportDetail>';
  752. $xml.='</v23:CustomsClearanceDetail>';
  753. $xml.='<v23:LabelSpecification>';
  754. $xml.='<v23:LabelFormatType>COMMON2D</v23:LabelFormatType>';
  755. $xml.='<v23:ImageType>PDF</v23:ImageType>';
  756. $xml.='<v23:LabelStockType>STOCK_4X6.75</v23:LabelStockType>';
  757. $xml.='</v23:LabelSpecification>';
  758. //发票参数开始
  759. $xml.='<v23:ShippingDocumentSpecification>';
  760. $xml.='<v23:ShippingDocumentTypes>COMMERCIAL_INVOICE</v23:ShippingDocumentTypes>';
  761. //ETD
  762. $xml.='<v23:CommercialInvoiceDetail>';
  763. $xml.='<v23:Format>';
  764. $xml.='<v23:ImageType>PDF</v23:ImageType>';
  765. $xml.='<v23:StockType>PAPER_LETTER</v23:StockType>';
  766. $xml.='<v23:ProvideInstructions>true</v23:ProvideInstructions>';
  767. $xml.='</v23:Format>';
  768. $xml.='<v23:CustomerImageUsages>';
  769. $xml.='<v23:Type>LETTER_HEAD</v23:Type>';
  770. $xml.='<v23:Id>IMAGE_1</v23:Id>';
  771. $xml.='</v23:CustomerImageUsages>';
  772. $xml.='<v23:CustomerImageUsages>';
  773. $xml.='<v23:Type>SIGNATURE</v23:Type>';
  774. $xml.='<v23:Id>IMAGE_2</v23:Id>';
  775. $xml.='</v23:CustomerImageUsages>';
  776. //ETD
  777. $xml.='</v23:CommercialInvoiceDetail>';
  778. $xml.='</v23:ShippingDocumentSpecification>';
  779. //发票参数结束
  780. $xml.='<v23:RateRequestTypes>LIST</v23:RateRequestTypes>';//费率请求类型
  781. $xml.='<v23:PackageCount>'.$data['zjs'].'</v23:PackageCount>';//包装数量
  782. $xml.='<v23:RequestedPackageLineItems>';
  783. $xml.='<v23:SequenceNumber>1</v23:SequenceNumber>';
  784. //$xml.='<v23:InsuredValue><v23:Currency>USD</v23:Currency><v23:Amount>120.00</v23:Amount></v23:InsuredValue>';//保险金额
  785. $xml.='<v23:Weight>';
  786. $xml.='<v23:Units>KG</v23:Units>';
  787. $xml.='<v23:Value>0.4</v23:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
  788. $xml.='</v23:Weight>';
  789. //超过重量需要填尺寸,现在不设置,超出也按0.4走
  790. if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
  791. {
  792. $xml.='<v23:Dimensions>';
  793. $xml.='<v23:Length>4</v23:Length>';
  794. $xml.='<v23:Width>20</v23:Width>';
  795. $xml.='<v23:Height>30</v23:Height>';
  796. $xml.='<v23:Units>CM</v23:Units>';
  797. $xml.='</v23:Dimensions>';
  798. }
  799. //$xml.='<v23:ItemDescription>Book</v23:ItemDescription>';//阿联酋需要选择
  800. $xml.='<v23:CustomerReferences>';
  801. $xml.='<v23:CustomerReferenceType>CUSTOMER_REFERENCE</v23:CustomerReferenceType>';
  802. $xml.='<v23:Value>'.$data['number'].'</v23:Value>';
  803. $xml.='</v23:CustomerReferences>';
  804. //签名开始
  805. if($data['qm'] > 0)
  806. {
  807. $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
  808. $xml.='<v23:SpecialServicesRequested>';
  809. $xml.='<v23:SpecialServiceTypes>SIGNATURE_OPTION</v23:SpecialServiceTypes>';
  810. $xml.='<v23:SignatureOptionDetail>';
  811. $xml.='<v23:OptionType>'.$qm.'</v23:OptionType>';
  812. $xml.='</v23:SignatureOptionDetail>';
  813. $xml.='</v23:SpecialServicesRequested>';
  814. }
  815. //签名结束
  816. $xml.='</v23:RequestedPackageLineItems>';
  817. $xml.='</v23:RequestedShipment>';
  818. $xml.='</v23:ProcessShipmentRequest>';
  819. $xml.='</soapenv:Body>';
  820. $xml.='</soapenv:Envelope>';
  821. $ch = curl_init();
  822. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  823. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  824. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  825. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  826. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  827. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  828. curl_setopt($ch, CURLOPT_POST, 1);
  829. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  830. $result_xml = curl_exec($ch);
  831. $result_xml = str_replace(array(':','-'), '', $result_xml);
  832. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  833. /**
  834. $ch = curl_init();
  835. $url = 'http://z.wepolicy.cn/fedexhz.php';
  836. curl_setopt($ch,CURLOPT_URL,$url);
  837. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  838. curl_setopt($ch,CURLOPT_HEADER,0);
  839. curl_setopt($ch,CURLOPT_POST, 1);
  840. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  841. //设置post数据
  842. $post = array();
  843. $post['data'] = $xml;
  844. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  845. $res = curl_exec($ch);
  846. curl_close($ch);
  847. $values = json_decode($res,true);
  848. **/
  849. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
  850. {
  851. $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']);
  852. }
  853. else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
  854. {
  855. $a = '';
  856. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
  857. {
  858. $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
  859. }
  860. else
  861. {
  862. foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
  863. {
  864. $a .= $v['LocalizedMessage'].'--';
  865. }
  866. }
  867. $g = array('x'=>'0','Description'=>$a);
  868. }
  869. else
  870. {
  871. $g = array('x'=>'0','Description'=>'未知错误');
  872. }
  873. return $g;
  874. }
  875. } //end class