|
|
@ -60,26 +60,37 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
"timestamp": "'.$time.'",
|
|
|
|
"timestamp": "'.$time.'",
|
|
|
|
"data": { "trainDate": "'.$date.'", "fromStation": "'.$fromStation.'", "toStation": "'.$toStation.'", "trainCode": "" }
|
|
|
|
"data": { "trainDate": "'.$date.'", "fromStation": "'.$fromStation.'", "toStation": "'.$toStation.'", "trainCode": "" }
|
|
|
|
}';
|
|
|
|
}';
|
|
|
|
|
|
|
|
//设置请求接口时间
|
|
|
|
|
|
|
|
$api_start_time = microtime(true);
|
|
|
|
|
|
|
|
|
|
|
|
$back_data = post_tuniu($url,$post_data,$method = 'POST');
|
|
|
|
$back_data = post_tuniu($url,$post_data,$method = 'POST');
|
|
|
|
|
|
|
|
$back_data = null;
|
|
|
|
|
|
|
|
//接口结束时间
|
|
|
|
|
|
|
|
$api_end_time = microtime(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算响应时间
|
|
|
|
|
|
|
|
$api_responsive_time = $api_end_time - $api_start_time;
|
|
|
|
|
|
|
|
|
|
|
|
log_message('error','tuniutrain 原始数据:'.$back_data);
|
|
|
|
if(!empty($back_data)){
|
|
|
|
//print_r(json_decode($back_data));die();
|
|
|
|
$tn_info = json_decode($back_data);
|
|
|
|
//$log_info = '';
|
|
|
|
$retrun_code = $tn_info->returnCode;
|
|
|
|
|
|
|
|
$return_msg = $tn_info->errorMsg;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$retrun_code = '404';
|
|
|
|
|
|
|
|
$return_msg = '途牛接口未响应';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//记录数据格式 |出发站|到达站|发车时间|接口响应时间|接口返回代码|接口返回信息
|
|
|
|
|
|
|
|
log_message('error','tuniutrain|'.$fromStation.'|'.$toStation.'|'.$date.'|'.$api_responsive_time.'|'.$retrun_code.'|'.$return_msg);
|
|
|
|
|
|
|
|
|
|
|
|
$tn_info = json_decode($back_data);
|
|
|
|
|
|
|
|
$retrun_code = $tn_info->returnCode;
|
|
|
|
|
|
|
|
$return_msg = $tn_info->errorMsg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($tn_info->data)){
|
|
|
|
if(isset($tn_info->data)){
|
|
|
|
if(empty(json_decode($back_data)->data)){
|
|
|
|
if(empty(json_decode($back_data)->data)){
|
|
|
|
$isCache = true;
|
|
|
|
$isCache = true;
|
|
|
|
//$log_info = 'tuniutrain data缺失|数据源:'.$fromStation.'|'.$toStation.'|'.$date.'|retrun_code:'.$retrun_code.'|return_msg:'.$return_msg;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$this->tuniuprice_model->addOrUpdate($fromStation,$toStation,$back_data);
|
|
|
|
$this->tuniuprice_model->addOrUpdate($fromStation,$toStation,$back_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$isCache = true;
|
|
|
|
$isCache = true;
|
|
|
|
//$log_info = 'tuniutrain 接口未响应|数据源:'.$fromStation.'|'.$toStation.'|'.$date.'|retrun_code:'.$retrun_code.'|return_msg:'.$return_msg;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($isCache){
|
|
|
|
if($isCache){
|
|
|
@ -90,12 +101,8 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
if(!empty($trainCache)){
|
|
|
|
if(!empty($trainCache)){
|
|
|
|
$back_data = $trainCache->tpc_content;
|
|
|
|
$back_data = $trainCache->tpc_content;
|
|
|
|
$isCache = true;
|
|
|
|
$isCache = true;
|
|
|
|
//$log_info .= '|调用缓存';
|
|
|
|
|
|
|
|
//log_message('error',$log_info);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$back_data = null;
|
|
|
|
$back_data = null;
|
|
|
|
//$log_info .= '|缓存为空';
|
|
|
|
|
|
|
|
//log_message('error',$log_info);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|