| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 | 
							- <?php
 
- class Model_Apismt extends Lin_Model {
 
- function __construct(){
 
- 		parent::__construct();
 
- }
 
-     public function get_ex($code) //查看支持快递
 
- 	{
 
- 		$ch = curl_init();
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_hq($page,$size,$starttime,$endtime,$state,$code) //获取
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/order';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_list'] = 1;
 
- 		$post['starttime'] = $starttime;
 
- 		$post['endtime'] = $endtime;
 
- 		$post['page'] = $page;
 
- 		$post['size'] = $size;
 
- 		$post['state'] = $state;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
- 		if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_hqfull($page,$size,$starttime,$endtime,$state,$code) //获取
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/orderfull';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_list_full'] = 1;
 
- 		$post['starttime'] = $starttime;
 
- 		$post['endtime'] = $endtime;
 
- 		$post['page'] = $page;
 
- 		$post['size'] = $size;
 
- 		$post['state'] = $state;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
- 		$data = array();$fund_status = '';
 
-    	        if(isset($res['result']['target_list']['aeop_order_item_dto']))
 
- 		    {
 
- 			    foreach ($res['result']['target_list']['aeop_order_item_dto'] as $v) 
 
- 		        {
 
- 				    if(!isset($v['fund_status']))
 
- 				    {
 
- 				    	$fund_status = 'NOT_PAY';
 
- 				    }
 
- 				    if($fund_status = 'NOT_PAY' && isset($v['gmt_pay_time']))
 
- 				    {
 
- 				    	$fund_status = 'PAY_SUCCESS';
 
- 				    }
 
- 				    if(isset($v['order_id']) && isset($v['order_status']) && isset($v['buyer_login_id']))
 
- 				    {
 
- 				        $data[] = array('orderinfo'=>$v['order_id'],'state'=>$v['order_status'],'userid'=>$v['buyer_login_id'],'fundstate'=>$fund_status);
 
- 				    }
 
- 			    }
 
- 			    return $data;
 
- 			}
 
- 		
 
- 	}
 
- 	
 
- 	public function get_order($orderid,$code) //详情
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/data';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_id'] = 1;
 
- 		$post['orderid'] = $orderid;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_out($whlabel,$all,$orderinfo,$ex,$code) //发货声明
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/out';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_out'] = 1;
 
- 		$post['whlabel'] = $whlabel;
 
- 		$post['all'] = $all;
 
- 		$post['orderinfo'] = $orderinfo;
 
- 		$post['ex'] = $ex;
 
- 		$post['code'] = $code;
 
- 		$this->logic_ding->sendToDing("SMT运单同步".json_encode($post,JSON_UNESCAPED_UNICODE));
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
- 		if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_obtain($orderinfo,$code) //查询声明
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/obtain';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['statement'] = 1;
 
- 		$post['orderinfo'] = $orderinfo;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_editout($oldwhlabel,$whlabel,$all,$orderinfo,$oldex,$ex,$code) //更改声明
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/editout';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['editstatement'] = 1;
 
- 		$post['oldwhlabel'] = $oldwhlabel;
 
- 		$post['whlabel'] = $whlabel;
 
- 		$post['all'] = $all;
 
- 		$post['orderinfo'] = $orderinfo;
 
- 		$post['oldex'] = $oldex;
 
- 		$post['ex'] = $ex;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_msg($shopid,$userid,$content,$code,$order) //发送站内信
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/msg';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['shopid'] = $shopid;
 
- 		$post['userid'] = $userid;
 
- 		$post['message_type'] = 'order';
 
- 		$post['content'] = $content;
 
- 		$post['code'] = $code;
 
- 		$post['order'] = $order;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_commoditylist($page,$size,$code) //获取商品列表
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/commoditylist';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_commodity_list'] = 1;
 
- 		$post['page'] = $page;
 
- 		$post['size'] = $size;//小于等于100
 
- 		$post['type'] = 'onSelling';//商品业务状态,目前提供5种,输入参数分别是:上架:onSelling ;下架:offline ;审核中:auditing ;审核不通过:editingRequired;客服删除:service_delete
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_commodityread($data,$code) //商品详情
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/commodityread';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_commodity_read'] = 1;
 
- 		$post['data'] = $data;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    $sku = array();
 
- 		if(isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']))
 
- 		{
 
- 			$gg = array();
 
- 			if(!isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'][0]))
 
- 		    {
 
- 				foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg)
 
- 		        {
 
- 					if(isset($vg['property_value_definition_name']))
 
- 				    {
 
- 						$gg[$vg['property_value_id']] = $vg['property_value_definition_name'];
 
- 				    }
 
- 			    }
 
- 				$code = isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code'])?$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code']:'';
 
- 			    $sku[$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id']] = array('skuid'=>$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id'],'code'=>$code);
 
- 			}
 
- 			else
 
- 			{
 
- 		        foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'] as $vv)
 
- 		        {
 
- 				    foreach ($vv['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg)
 
- 		            {
 
- 				       if(isset($vg['property_value_definition_name']))
 
- 				       {
 
- 					       $gg[$vg['property_value_id']] = $vg['property_value_definition_name'];
 
- 				       }
 
- 			        }
 
- 				    $code = isset($vv['sku_code'])?$vv['sku_code']:'';
 
- 			        $sku[$vv['id']] = array('skuid'=>$vv['id'],'code'=>$code);
 
- 		        }
 
- 			}
 
- 		    $img = explode(';',$res['image_u_r_ls']);
 
- 			$title = '';
 
- 			if(isset($res['subject_list']['subject'][14]['value']))
 
- 			{
 
- 				$title = $res['subject_list']['subject'][14]['value'];
 
- 			}
 
- 			else if(isset($res['subject_list']['subject']['locale']))
 
- 			{
 
- 				if($res['subject_list']['subject']['locale'] == 'en_US')
 
- 				{
 
- 					$title = $res['subject_list']['subject']['value'];
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 				foreach ($res['subject_list']['subject'] as $rv)
 
- 		        {
 
- 					if($rv['locale'] == 'en_US')
 
- 				    {
 
- 						$title = $rv['value'];
 
- 				    }
 
- 			    }
 
- 			}
 
- 		    @$mid = array('productid'=>$res['product_id'],'img'=>$img[0],'title'=>$title,'type'=>$res['product_status_type'],'cid'=>$res['category_id'],'sku'=>$sku,'gg'=>$gg);
 
- 		    return $mid;
 
- 		}
 
- 		else
 
- 		{
 
- 			$myfile = fopen("./data/errors/txt/".$data.'-'.date('Ymd_His',time()).".txt", "w");
 
- 			$txt = json_encode($res);
 
- 			fwrite($myfile,$txt);
 
- 			fclose($myfile);
 
- 			return 1;exit;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_commoditysku($data,$code) //商品类目(sku)
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/commoditysku';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['order_commodity_sku'] = 1;
 
- 		$post['sku'] = $data;
 
- 		$post['code'] = $code;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_logistics9($data,$orderinfo,$express,$al) //速卖通物流接口
 
- 	{
 
- 		$ch = curl_init();
 
- 		//$url = 'http://39.100.97.180/start/logistics';
 
- 		$url = 'http://39.100.97.180/smt.php';
 
- 		curl_setopt($ch,CURLOPT_URL,$url);
 
- 		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
- 		curl_setopt($ch,CURLOPT_HEADER,0);
 
- 		curl_setopt($ch,CURLOPT_POST, 1);
 
- 		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
 
-         //设置post数据
 
- 		$post = array();
 
- 		$post['logistics'] = 1;
 
- 		$post['waybill'] = $waybill;
 
- 		$post['ESCROW'] = 'ESCROW';
 
- 		$post['orderinfo'] = $orderinfo;
 
- 		$post['express'] = $express;
 
- 		$post['al'] = $al;
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res,true);
 
-    	    if(isset($res))
 
- 		{
 
- 			return $res;
 
- 		}
 
- 	}
 
- 	
 
- 	public function get_logistics($v) //阿里云云市场
 
- 	{
 
- 		$host = "https://ali-deliver.showapi.com";
 
-     	$path = "/showapi_expInfo";
 
-     	$method = "GET";
 
-     	$appcode = "008b9815e9fa49c49ba3a95f83f662f6";
 
-     	$headers = array();
 
-     	array_push($headers, "Authorization:APPCODE " . $appcode);
 
- 		$waybill = ($v['express'] == 'usps')?str_replace(array('420',$v['zipcode']),array('',''),$v['waybill']):$v['waybill'];
 
-     	$querys = "com=".$v['cxcode']."&nu=".$waybill;
 
-     	$bodys = "";
 
-     	$url = $host . $path . "?" . $querys;
 
- 		$v['exstate'] = (isset($v['exstate']))?$v['exstate']:'';//非订单查询无此属性
 
-     	$curl = curl_init();
 
-     	curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
 
-     	curl_setopt($curl, CURLOPT_URL, $url);
 
-     	curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
 
-     	curl_setopt($curl, CURLOPT_FAILONERROR, false);
 
-     	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 
-     	//curl_setopt($curl, CURLOPT_HEADER, true);
 
-     	if (1 == strpos("$".$host, "https://"))
 
-     	{
 
-         	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
 
-         	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
 
-     	}
 
-         $read = json_decode(curl_exec($curl),true);
 
- 		if(!isset($read['showapi_res_body']['status']))
 
- 		{
 
- 			$content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败';
 
- 			$list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
 
- 		}
 
- 		else if($read['showapi_res_body']['status'] > 1 && $read['showapi_res_body']['status'] != $v['exstate'])
 
- 		{
 
- 			$exstate = $read['showapi_res_body']['status'];
 
- 			$content = $read['showapi_res_body']['data'][0]['time'].' - '.$read['showapi_res_body']['data'][0]['context'];
 
- 			$xq = '';
 
- 			foreach($read['showapi_res_body']['data'] as $v)
 
- 		    {
 
- 				$xq .= $v['time'].' '.$v['context'].'<br />';
 
- 			}
 
- 			if($exstate == 2)
 
- 			{
 
- 				$exstate = 3;
 
- 			}
 
- 			else if($exstate == 3)
 
- 			{
 
- 				$exstate = 5;
 
- 			}
 
- 			else if($exstate == 4)
 
- 			{
 
- 				$exstate = 6;
 
- 			}
 
- 			else if($exstate == 9 || $exstate == 5)
 
- 			{
 
- 				$exstate = 1;
 
- 			}
 
- 			$list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$xq);//正常可发送站内信
 
- 		}
 
- 		else
 
- 		{
 
- 			$content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败';
 
- 			$list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
 
- 		}
 
- 	    return $list;
 
- 		//status : -1 待查询 0 查询异常 1 暂无记录 2 在途中 3 派送中 4 已签收 5 用户拒签 6 疑难件 7 无效单 8 超时单 9 签收失败 10 退回
 
- 	}
 
- 	
 
- 	public function get_logistics1($data) //快递100
 
- 	{
 
- 		$key = 'jUQDydMC8647';//客户授权key
 
- 		$customer = '2C11630697BD4A3F260479649ADD9236';	//查询公司编号
 
-     	$param = array (
 
- 		'com' => $data['express'],			//快递公司编码
 
- 		'num' => $data['waybill'],	//快递单号
 
- 		'phone' => '',				//手机号
 
- 		'from' => '',				//出发地城市
 
- 		'to' => '',					//目的地城市
 
- 		'resultv2' => '1'			//开启行政区域解析
 
- 		);
 
- 		//请求参数
 
-     	$post_data = array();
 
-     	$post_data["customer"] = $customer;
 
-     	$post_data["param"] = json_encode($param);
 
-     	$sign = md5($post_data["param"].$key.$post_data["customer"]);
 
-     	$post_data["sign"] = strtoupper($sign);
 
-     	$url = 'http://poll.kuaidi100.com/poll/query.do';	//实时查询请求地址
 
- 		$params = "";
 
-     	foreach ($post_data as $k=>$v) {
 
-         	$params .= "$k=".urlencode($v)."&";		//默认UTF-8编码格式
 
-     	}
 
-     	$post_data = substr($params, 0, -1);
 
-     	$ch = curl_init();
 
- 		curl_setopt($ch, CURLOPT_POST, 1);
 
- 		curl_setopt($ch, CURLOPT_HEADER, 0);
 
- 		curl_setopt($ch, CURLOPT_URL, $url);
 
- 		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
 
- 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
- 		$result = curl_exec($ch);
 
- 		$data = str_replace("\"", '"', $result );
 
- 		return json_decode($data);
 
- 	}
 
- 	
 
- 	//快递鸟查询快递信息开始
 
- 	public function get_logistics3($data){
 
- 	$requestData= "{'OrderCode':'','ShipperCode':'".$data['express']."','LogisticCode':'".$data['waybill']."'}";
 
- 	$datas = array(
 
-         'EBusinessID' => '1397054',
 
-         'RequestType' => '8001',
 
-         'RequestData' => urlencode($requestData) ,
 
-         'DataType' => '2',
 
-     );
 
-     $datas['DataSign']=$this->_encrypt($requestData,'34aedf94-322e-438e-b6ba-79eea59710bd');
 
- 	$result=$this->_sendPost('http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',$datas);	
 
- 	return $result;
 
-     }
 
- 	
 
- 	public  function _sendPost($url,$datas) {
 
-     $temps = array();	
 
-     foreach ($datas as $key => $value) {
 
-         $temps[] = sprintf('%s=%s', $key, $value);		
 
-     }	
 
-     $post_data = implode('&', $temps);
 
-     $url_info = parse_url($url);
 
- 	if(empty($url_info['port']))
 
- 	{
 
- 		$url_info['port']=80;	
 
- 	}
 
-     $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
 
-     $httpheader.= "Host:" . $url_info['host'] . "\r\n";
 
-     $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n";
 
-     $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n";
 
-     $httpheader.= "Connection:close\r\n\r\n";
 
-     $httpheader.= $post_data;
 
-     $fd = fsockopen($url_info['host'], $url_info['port']);
 
-     fwrite($fd, $httpheader);
 
-     $gets = "";
 
- 	$headerFlag = true;
 
- 	while (!feof($fd)) {
 
- 		if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
 
- 			break;
 
- 		}
 
- 	}
 
-     while (!feof($fd)) {
 
- 		$gets.= fread($fd, 128);
 
-     }
 
-     fclose($fd);   
 
-     return $gets;
 
-     }
 
- 	
 
- 	public function _encrypt($data,$appkey) {
 
-     return urlencode(base64_encode(md5($data.$appkey)));
 
-     }
 
- 	//快递鸟查询快递信息结束
 
- }  //end class
 
 
  |