优化查询过程避免出现php错误

hotfix/远程访问多媒体中心
cyc 7 years ago
parent 76b07703d4
commit b1329b2dad

@ -43,7 +43,8 @@ class ctrip_train extends CI_Controller{
$TrainNo = $this->input->get_post('TrainNo');
if(!$date || !$from || !$to){
exit('传参错误!');
header("HTTP/1.1 404 Not Found");
exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}');
}else{
$isCache = false;
$iseven = false;
@ -55,10 +56,19 @@ class ctrip_train extends CI_Controller{
$iseven = true;
}
//转换三字码为中文
$from = $this->ctrip_model->ReplaceCodeToName($from)->station_name;
$to = $this->ctrip_model->ReplaceCodeToName($to)->station_name;
//转换三字码为中文
$FromCode = $this->ctrip_model->ReplaceCodeToName($from);
$ToCode = $this->ctrip_model->ReplaceCodeToName($to);
if(!$FromCode || !$ToCode){
header("HTTP/1.1 404 Not Found");
exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}');
}else{
$from = $FromCode->station_name;
$to = $ToCode->station_name;
}
//生成请求链接
$TimeStamp = time();
$Sign = md5($TimeStamp.DATAKEY);
@ -74,8 +84,14 @@ class ctrip_train extends CI_Controller{
$ResponseData = json_decode($ResponseJson);
$api_responsive_time = $api_end_time - $api_start_time;
//print_r($ResponseData);die();
if(empty($ResponseData->Trains)){
log_message('error','ctrip_trian|status:trains is empty |相应时间:'.$api_responsive_time);
}else{
log_message('error','ctrip_trian|status:'.$ResponseData->ResponseStatus->Ack.'|相应时间:'.$api_responsive_time);
}
log_message('error','ctrip_trian|status:'.$ResponseData->ResponseStatus->Ack.'|相应时间:'.$api_responsive_time);
//定义返回的json
$ReturnData = new stdClass();

Loading…
Cancel
Save