|
|
|
@ -85,23 +85,27 @@ class search extends CI_Controller{
|
|
|
|
|
$this->BIZ_train_model->addOrUpdate($fromStation,$toStation,$search_return);
|
|
|
|
|
$operate_data = $search_return;
|
|
|
|
|
}else{
|
|
|
|
|
$cache_train_info = $this->BIZ_train_model->get_train_info($fromStation,$toStation);
|
|
|
|
|
if(empty($cache_train_info)){
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|缓存为空');
|
|
|
|
|
$operate_data = NULL;
|
|
|
|
|
}else{
|
|
|
|
|
$cache_time = $cache_train_info->tpc_datetime;
|
|
|
|
|
$now_time = time();
|
|
|
|
|
$differ_time = ($now_time - strtotime($cache_time)) / 86400;
|
|
|
|
|
if($differ_time >= 3){
|
|
|
|
|
$this->BIZ_train_model->delete_traincache($fromStation,$toStation);
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|缓存超时,已经删除');
|
|
|
|
|
if($this->seveth == 'yes'){
|
|
|
|
|
$cache_train_info = $this->BIZ_train_model->get_train_info($fromStation,$toStation);
|
|
|
|
|
if(empty($cache_train_info)){
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|缓存为空');
|
|
|
|
|
$operate_data = NULL;
|
|
|
|
|
}else{
|
|
|
|
|
$this->cache = 'yes';
|
|
|
|
|
$operate_data = $cache_train_info->tpc_content;
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|调用缓存号:'.$cache_train_info->tpc_sn.'|缓存生成的时间:'.$cache_train_info->tpc_datetime);
|
|
|
|
|
}
|
|
|
|
|
$cache_time = $cache_train_info->tpc_datetime;
|
|
|
|
|
$now_time = time();
|
|
|
|
|
$differ_time = ($now_time - strtotime($cache_time)) / 86400;
|
|
|
|
|
if($differ_time >= 3){
|
|
|
|
|
$this->BIZ_train_model->delete_traincache($fromStation,$toStation);
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|缓存超时,已经删除');
|
|
|
|
|
$operate_data = NULL;
|
|
|
|
|
}else{
|
|
|
|
|
$this->cache = 'yes';
|
|
|
|
|
$operate_data = $cache_train_info->tpc_content;
|
|
|
|
|
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|调用缓存号:'.$cache_train_info->tpc_sn.'|缓存生成的时间:'.$cache_train_info->tpc_datetime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$operate_data = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $operate_data;
|
|
|
|
@ -282,6 +286,7 @@ class search extends CI_Controller{
|
|
|
|
|
$item->adult_seat[$i]['name'] = $seat_name;
|
|
|
|
|
$item->adult_seat[$i]['code'] = $key_adult;
|
|
|
|
|
$item->adult_seat[$i]['price'] = $value;
|
|
|
|
|
$item->adult_seat[$i]['pic'] = $this->BIZ_intel_train_model->get_seatname($key_adult)->Seat_Pic;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -356,6 +361,30 @@ class search extends CI_Controller{
|
|
|
|
|
print_r(json_encode($obj));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取国际火车出发规则
|
|
|
|
|
public function get_station_rules(){
|
|
|
|
|
//获取所有站点的列表
|
|
|
|
|
$return_json = array();
|
|
|
|
|
$return_json['TrainList'] = array();
|
|
|
|
|
$all_stations = $this->BIZ_intel_train_model->get_allstations();
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach($all_stations as $item){
|
|
|
|
|
$return_json['TrainList'][$i]['FromStation'] = $item->s_ename.','.$item->s_country;
|
|
|
|
|
$return_json['TrainList'][$i]['ToStations'] = array();
|
|
|
|
|
$rule_arr = $this->BIZ_intel_train_model->get_train_rules($item->station_id);
|
|
|
|
|
$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.','.$item->s_country;
|
|
|
|
|
$j++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
//print_r($return_json);
|
|
|
|
|
print_r(json_encode($return_json));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取价格(废弃)
|
|
|
|
|
/*
|
|
|
|
|
fromStationCode:出发站三字码
|
|
|
|
@ -553,7 +582,7 @@ class search extends CI_Controller{
|
|
|
|
|
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
|
|
|
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
|
|
|
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
|
|
|
|
|
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
|
|
|
|
|
//curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
|
|
|
|
|
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
|
|
|
|
|
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
|
|
|
|
|
if ($method == 'POST' && !empty($data)) {
|
|
|
|
|