From 6ac8f928cdb598302123aa48adca7ff23f4988a8 Mon Sep 17 00:00:00 2001 From: cyc Date: Tue, 4 Sep 2018 15:03:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0CH=E4=B8=93=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third_party/train/controllers/search.php | 34 ++++++++++++++++++- .../train/models/BIZ_intel_train_model.php | 28 +++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/application/third_party/train/controllers/search.php b/application/third_party/train/controllers/search.php index ee428378..1b553255 100644 --- a/application/third_party/train/controllers/search.php +++ b/application/third_party/train/controllers/search.php @@ -361,7 +361,6 @@ class search extends CI_Controller{ $all_stations = $this->BIZ_intel_train_model->get_allstations(); $i = 0; foreach($all_stations as $item){ - $rule_arr = $this->BIZ_intel_train_model->get_train_rules($item->station_id); if(!empty($rule_arr)){ $return_json['TrainList'][$i]['FromStation'] = $item->s_ename; $return_json['TrainList'][$i]['FromCountry'] = $item->s_country; @@ -379,8 +378,41 @@ class search extends CI_Controller{ } //print_r($return_json); header('Content-type: application/json'); + //print_r(json_encode($return_json)); + } + + //获取国际火车出发规则 + public function ch_station_rules(){ + //获取所有站点的列表 + $return_json = array(); + $return_json['TrainList'] = array(); + $all_stations = $this->BIZ_intel_train_model->ch_allstations(); + $i = 0; + foreach($all_stations as $item){ + if($item->s_country == 'Vietnam'){ + $rule_arr = $this->BIZ_intel_train_model->ch_train_rules($item->station_id,true); + }else{ + $rule_arr = $this->BIZ_intel_train_model->ch_train_rules($item->station_id,false); + } + if(!empty($rule_arr)){ + $return_json['TrainList'][$i]['FromStation'] = $item->s_ename; + $return_json['TrainList'][$i]['FromCountry'] = $item->s_country; + $return_json['TrainList'][$i]['ToStations'] = array(); + $j = 0; + foreach($rule_arr as $rule_info){ + $return_json['TrainList'][$i]['ToStations'][$j]['Message'] = $rule_info->tsi_Message; + $return_json['TrainList'][$i]['ToStations'][$j]['Station'] = $rule_info->S_ename; + $return_json['TrainList'][$i]['ToStations'][$j]['StationCountry'] = $rule_info->s_country; + $j++; + } + $i++; + } + } + //print_r($return_json); + header('Content-type: application/json'); print_r(json_encode($return_json)); } + //获取价格(废弃) /* diff --git a/application/third_party/train/models/BIZ_intel_train_model.php b/application/third_party/train/models/BIZ_intel_train_model.php index 615287ee..43f21bd6 100644 --- a/application/third_party/train/models/BIZ_intel_train_model.php +++ b/application/third_party/train/models/BIZ_intel_train_model.php @@ -117,6 +117,12 @@ class BIZ_intel_train_model extends CI_Model { $query = $this->HT->query($sql); return $query->result(); } + + public function ch_allstations(){ + $sql = "SELECT * FROM TrainStation_intel"; + $query = $this->HT->query($sql); + return $query->result(); + } public function get_train_rules($station_id){ $sql = "SELECT @@ -132,4 +138,26 @@ class BIZ_intel_train_model extends CI_Model { $query = $this->HT->query($sql); return $query->result(); } + + public function ch_train_rules($station_id,$flag){ + if($flag){ + $and = "and s_country != 'Vietnam'"; + }else{ + $and = ""; + } + $sql = "SELECT + S_ename,s_country,tsi_Message + FROM + TrainSearch_intel + LEFT JOIN + TrainStation_intel + ON + tsi_ToStation = station_id + where + tsi_FromStation = '{$station_id}' + "; + $sql .= $and; + $query = $this->HT->query($sql); + return $query->result(); + } }