Model_fedex.php 40 KB

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