From da23c21279b0b62aeea951277544d0b891a6fbf0 Mon Sep 17 00:00:00 2001 From: cyc Date: Mon, 11 May 2020 15:12:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/innerTrainSearch.php | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/application/third_party/trainsystem/controllers/innerTrainSearch.php b/application/third_party/trainsystem/controllers/innerTrainSearch.php index d5284af7..9729b99e 100644 --- a/application/third_party/trainsystem/controllers/innerTrainSearch.php +++ b/application/third_party/trainsystem/controllers/innerTrainSearch.php @@ -20,6 +20,35 @@ class innerTrainSearch extends CI_Controller{ exit('你走错了!'); } + //查询选择 + public function search(){ + //接收参数 + $date = $this->input->get_post('date'); + $from = $this->input->get_post('from'); + $to = $this->input->get_post('to'); + + if(!$date || !$from || !$to){ + header("HTTP/1.1 404 Not Found"); + exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}'); + }else{ + //根据选择的接口供应商调用对应的接口,默认使用携程的接口 + $supplier = $this->input->get_post('supplier'); + + switch ($supplier){ + case 'juhe': + $this->juheApi($date,$from,$to); + break; + case 'ctrip': + $this->ctripApi($date,$from,$to); + break; + default : + $this->ctripApi($date,$from,$to); + break; + } + } + } + + //聚合数据接口 public function juheApi($train_date=null,$fromStation=null,$toStation=null){ //定义一些变量 $flag = true; @@ -79,8 +108,9 @@ class innerTrainSearch extends CI_Controller{ function createTrainJson($returnjson){ $return_data = new stdClass(); $return_data->data = new stdClass(); - $return_data->httpstatus = 200; - $return_data->seveth = $this->seveth; + $return_data->data->httpstatus = 200; + $return_data->data->seveth = $this->seveth; + $return_data->data->supplier = 'juhe'; $return_data->data->result = array(); $return_data->data->map = new stdClass(); $obj = array(); @@ -174,16 +204,8 @@ class innerTrainSearch extends CI_Controller{ return json_encode($return_data); } + //携程数据接口 public function ctripApi($date=null,$from=null,$to=null,$return=false){ - //接收参数 - if(!$date && !$from && !$to){ - $date = $this->input->get_post('date'); - $from = $this->input->get_post('from'); - $to = $this->input->get_post('to'); - } - - $TrainNo = $this->input->get_post('TrainNo'); - if(!$date || !$from || !$to){ header("HTTP/1.1 404 Not Found"); exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}'); @@ -240,6 +262,7 @@ class innerTrainSearch extends CI_Controller{ $ReturnData->data = new stdClass(); $ReturnData->data->seven = $iseven; $ReturnData->data->cache = $isCache; + $ReturnData->data->supplier = 'ctrip'; $ReturnData->data->result = array(); $ReturnData->data->map = new stdClass(); $obj = array(); @@ -367,7 +390,6 @@ class innerTrainSearch extends CI_Controller{ }else{ echo json_encode($ReturnData); } - } } @@ -479,6 +501,7 @@ class innerTrainSearch extends CI_Controller{ } } + //火车移动端数据接口 public function get_train(){ $train_date = $this->input->get('date'); $fromStation = $this->input->get('from');