|
|
|
@ -62,15 +62,24 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
|
}';
|
|
|
|
|
$back_data = post_tuniu($url,$post_data,$method = 'POST');
|
|
|
|
|
|
|
|
|
|
//print_r(json_decode($back_data));die();
|
|
|
|
|
|
|
|
|
|
//如果数据为空则调用缓存,有数据则进行数据存储
|
|
|
|
|
if(empty($back_data)){
|
|
|
|
|
log_message('error','tuniutrain 接口未响应|数据源:'.$fromStation.'|'.$toStation.'|'.$date);
|
|
|
|
|
if($differ <= 5){
|
|
|
|
|
$back_data = null;
|
|
|
|
|
}else{
|
|
|
|
|
$trainCache = $this->tuniuprice_model->get_train_cache($fromStation,$toStation);
|
|
|
|
|
$back_data = $trainCache->tpc_content;
|
|
|
|
|
$isCache = true;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(empty(json_decode($back_data)->data)){
|
|
|
|
|
$error = json_decode($back_data);
|
|
|
|
|
if($error->returnCode == '201'){
|
|
|
|
|
$back_data = null;
|
|
|
|
|
}else{
|
|
|
|
|
$trainCache = $this->tuniuprice_model->get_train_cache($fromStation,$toStation);
|
|
|
|
|
if(!empty($trainCache)){
|
|
|
|
|
$back_data = $trainCache->tpc_content;
|
|
|
|
@ -80,7 +89,7 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
|
$back_data = null;
|
|
|
|
|
log_message('error','tuniutrain 缓存为空|'.$fromStation.'|'.$toStation.'|'.$date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$this->tuniuprice_model->addOrUpdate($fromStation,$toStation,$back_data);
|
|
|
|
|
}
|
|
|
|
|