Model_fedex.php 40 KB

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