优化途牛数据

hotfix/远程访问多媒体中心
cyc 7 years ago
parent 0325457ce4
commit 288272d021

@ -61,26 +61,35 @@ class Tuniu_train extends CI_Controller{
"data": { "trainDate": "'.$date.'", "fromStation": "'.$fromStation.'", "toStation": "'.$toStation.'", "trainCode": "" }
}';
$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);
$trainCache = $this->tuniuprice_model->get_train_cache($fromStation,$toStation);
$back_data = $trainCache->tpc_content;
$isCache = true;
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);
$trainCache = $this->tuniuprice_model->get_train_cache($fromStation,$toStation);
if(!empty($trainCache)){
$back_data = $trainCache->tpc_content;
$isCache = true;
log_message('error','tuniutrain 查询出错|'.$error->errorMsg);
}else{
if($error->returnCode == '201'){
$back_data = null;
log_message('error','tuniutrain 缓存为空|'.$fromStation.'|'.$toStation.'|'.$date);
}else{
$trainCache = $this->tuniuprice_model->get_train_cache($fromStation,$toStation);
if(!empty($trainCache)){
$back_data = $trainCache->tpc_content;
$isCache = true;
log_message('error','tuniutrain 查询出错|'.$error->errorMsg);
}else{
$back_data = null;
log_message('error','tuniutrain 缓存为空|'.$fromStation.'|'.$toStation.'|'.$date);
}
}
}else{
$this->tuniuprice_model->addOrUpdate($fromStation,$toStation,$back_data);
}

Loading…
Cancel
Save