Browse Source

测试一下轨迹

lvhao 3 tháng trước cách đây
mục cha
commit
af8de4feb1
1 tập tin đã thay đổi với 78 bổ sung1 xóa
  1. 78 1
      core/CoreApp/models/Model_cne.php

+ 78 - 1
core/CoreApp/models/Model_cne.php

@@ -443,7 +443,7 @@ function __construct(){
 		$res = json_decode($res,true);
 		return $res;
 	}
-	public function get_logistics($data)//快递渠道
+	public function get_logistics_bak($data)//快递渠道
 	{
 		$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=searchTrack";
 		$Clientid = 'LYFZP';
@@ -519,5 +519,82 @@ function __construct(){
 		}
 	    return $list;
 	}
+
+	//获取快递轨迹    不知道凯哥写了为啥不用  但是现在有个新的接口 为了统一好搞 就先借用下上述名字
+	public function get_logistics($data){
+		$url = "http://yqbug.kingtrans.net/PostInterfaceService?method=searchTrack";
+		$Clientid = '007';
+		$Token = 'WlpZUw==zRKOlUNdWs9J8Qp136Mj';
+		
+		$count = array(
+		'Verify' => array(
+		'Clientid'=>$Clientid,
+		'Token'=>$Token
+		),
+		'Datas'=> array(0=>array('TrackNumber'=>$data['waybill']))
+		);
+	    
+		$count = json_encode($count,true);
+        
+		$ch = curl_init();
+		curl_setopt($ch,CURLOPT_URL,$url);
+		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
+		curl_setopt($ch,CURLOPT_HEADER,0);
+		curl_setopt($ch,CURLOPT_POST, 1);
+		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
+        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		if($res['statusCode'] == 'success')
+		{
+			$exstate = 0;
+			$zt = ($res['returnDatas']['0']['statusCode'] == 'success')?$res['returnDatas']['0']['items']:'cw';
+			$xq = '';
+			if($zt == 'cw')
+			{
+				$content = date('Y-m-d H',time()).'-查询失败';
+			    $list = array('content'=>$content,'f'=>0);
+				return $list;exit;
+			}
+			foreach($zt as $v)
+		    {
+				if($v['info'] == 'Delivered')
+				{
+					$exstate = 6;
+					break;
+				}
+				else if(stripos($v['location'],$data['country']) !== false)
+				{
+					$exstate = 4;
+					break;
+				}
+				else if($v['info'] == '订单信息已收到')
+				{
+					$exstate = 2;
+					break;
+				}
+			}
+			if($exstate > 0)
+			{
+				foreach($zt as $v)
+		    	{
+					$xq .= date('m-d H:i',strtotime($v['dateTime'])).' '.$v['info'].'<br />';
+				}
+			    $content = date('Y-m-d H',time()).'-查询成功';
+			    $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$xq);//正常可发送站内信
+			}
+			else
+			{
+				$list = '';
+			}
+		}
+		else
+		{
+			$content = date('Y-m-d H',time()).'-查询失败';
+			$list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
+		}
+	    return $list;
+	}
 	
 }  //end class