|
|
|
@ -7,6 +7,7 @@ class search extends CI_Controller{
|
|
|
|
|
public function __construct(){
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->load->model("BIZ_train_model");//加载模型
|
|
|
|
|
$this->load->model("BIZ_intel_train_model");//国际火车模型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询聚合余票接口,对返回的数据进行处理
|
|
|
|
@ -31,7 +32,6 @@ class search extends CI_Controller{
|
|
|
|
|
//调用查询模块
|
|
|
|
|
$search_return = $this->Searchtrain($train_date,$fromStation,$toStation);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//调用数据处理模块
|
|
|
|
|
$returnJson = $this->dataOperate($search_return,$fromStation,$toStation);
|
|
|
|
|
|
|
|
|
@ -53,14 +53,9 @@ class search extends CI_Controller{
|
|
|
|
|
$train_date = date('Y-m-d',strtotime('+7day'));
|
|
|
|
|
$this->seveth = 'yes';
|
|
|
|
|
}
|
|
|
|
|
$url = 'http://139.129.246.118:12309/trainTickets/ticketsAvailable?key='.JUHE_TRAIN_API_KEY.'&train_date='.$train_date.'&from_station='.$fromStation.'&to_station='.$toStation;
|
|
|
|
|
$url = JUHE_TRAIN_CX_API.'?key='.JUHE_TRAIN_API_KEY.'&train_date='.$train_date.'&from_station='.$fromStation.'&to_station='.$toStation;
|
|
|
|
|
$this->url = $url;
|
|
|
|
|
$train_info = $this->get_http($url);
|
|
|
|
|
//如果为网络错误就再执行一次
|
|
|
|
|
if(json_decode($train_info)->reason == '网络故障,请重试(0)'){
|
|
|
|
|
$train_info = $this->get_http($url);
|
|
|
|
|
}
|
|
|
|
|
return $train_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -182,6 +177,7 @@ class search extends CI_Controller{
|
|
|
|
|
}
|
|
|
|
|
$pricestr = $seat_type.'"train_no":'.'"'.$value->train_no.'"';
|
|
|
|
|
//余票字符串
|
|
|
|
|
$this->can_buy_now = $value->can_buy_now;
|
|
|
|
|
$return_data->data->result[$i] = '|预定|'.$value->train_no.'|'.$value->train_code.'|'.$value->from_station_name.'|'.$value->to_station_name.'|'.$value->from_station_code.'|'.$value->to_station_code.'|'.$value->start_time.'|'.$value->arrive_time.'|'.$value->run_time.'|'.$value->can_buy_now.'||'.$value->train_start_date.'||||||||'.$this->ticket_exchange($value->gjrw_num).'|'.$this->ticket_exchange($value->qtxb_num).'|'.$this->ticket_exchange($value->rw_num).'|'.$this->ticket_exchange($value->rz_num).'|'.$this->ticket_exchange($value->tdz_num).'|'.$this->ticket_exchange($value->wz_num).'||'.$this->ticket_exchange($value->yw_num).'|'.$this->ticket_exchange($value->yz_num).'|'.$this->ticket_exchange($value->edz_num).'|'.$this->ticket_exchange($value->ydz_num).'|'.$this->ticket_exchange($value->swz_num).'|'.$this->ticket_exchange($value->dw_num).'||';
|
|
|
|
|
$data = '{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":{'.$pricestr.'},"messages":[],"validateMessages":{}}';
|
|
|
|
|
$return_data->data->price[$i] = $data;
|
|
|
|
@ -201,8 +197,7 @@ class search extends CI_Controller{
|
|
|
|
|
header('Access-Control-Max-Age:0');
|
|
|
|
|
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
|
|
|
|
|
header('Access-Control-Allow-Credentials:true');
|
|
|
|
|
//加载数据模型
|
|
|
|
|
$this->load->model("BIZ_intel_train_model");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$json = file_get_contents('php://input');
|
|
|
|
|
|
|
|
|
@ -299,6 +294,18 @@ class search extends CI_Controller{
|
|
|
|
|
print_r(json_encode($return_json));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function search_one_train($train_no){
|
|
|
|
|
$obj = $this->BIZ_intel_train_model->get_one_train($train_no);
|
|
|
|
|
$seat_code = json_decode($obj->seatPriceInfo2)->price;
|
|
|
|
|
$obj->seat_info = new stdClass();
|
|
|
|
|
foreach ($seat_code as $key=>$code){
|
|
|
|
|
$seat_info = $this->BIZ_intel_train_model->get_seat_info($key);
|
|
|
|
|
$obj->seat_info->$key = $seat_info;
|
|
|
|
|
}
|
|
|
|
|
print_r(json_encode($obj));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取价格(废弃)
|
|
|
|
|
/*
|
|
|
|
|
fromStationCode:出发站三字码
|
|
|
|
@ -320,12 +327,17 @@ class search extends CI_Controller{
|
|
|
|
|
|
|
|
|
|
//余票转换
|
|
|
|
|
function ticket_exchange($num){
|
|
|
|
|
//echo $this->can_buy_now;
|
|
|
|
|
if($this->cache == 'yes' || $this->seveth == 'yes'){
|
|
|
|
|
return '有';
|
|
|
|
|
}else{
|
|
|
|
|
if(is_numeric($num)){
|
|
|
|
|
if($num == 0){
|
|
|
|
|
return '无';
|
|
|
|
|
if($this->can_buy_now == 'N'){
|
|
|
|
|
return '有';
|
|
|
|
|
}else{
|
|
|
|
|
return '无';
|
|
|
|
|
}
|
|
|
|
|
}elseif($num >= 99){
|
|
|
|
|
return '有';
|
|
|
|
|
}else{
|
|
|
|
|