From ab663187b6efc7badbc457196317f0cd4262e3e7 Mon Sep 17 00:00:00 2001 From: "lmr@hainatravel.com" <59361885@qq.com> Date: Fri, 23 Feb 2018 15:40:23 +0800 Subject: [PATCH 1/7] fix amp v4 add css --- application/controllers/info_amp.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index 57e2e19d..f9d96987 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -20,6 +20,7 @@ class Info_amp extends CI_Controller $icid = $this->input->post('icid'); $json = $this->input->post('json'); $html = $this->input->post('html'); + $css = $this->input->post('css'); $status = $this->input->post('status'); if ($icid && $json && $html) { try { @@ -37,6 +38,13 @@ class Info_amp extends CI_Controller } else { $this->InfoMetas_model->update($icid, 'AMP_JSON', $json); } + //css + $meta = $this->InfoMetas_model->get($icid, 'AMP_CSS'); + if ($meta === false) { + $this->InfoMetas_model->add($icid, 'AMP_CSS', $css); + } else { + $this->InfoMetas_model->update($icid, 'AMP_CSS', $css); + } //status $meta = $this->InfoMetas_model->get($icid, 'AMP_STATUS'); if ($meta === false) { From de0e3b3e1a28707a9526e779b25d5070b99ddca0 Mon Sep 17 00:00:00 2001 From: lmrwork <59361885@qq.com> Date: Fri, 23 Feb 2018 16:56:20 +0800 Subject: [PATCH 2/7] fix amp v4 add ampmpbodu --- application/controllers/info_amp.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index f9d96987..7f179fc1 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -25,11 +25,11 @@ class Info_amp extends CI_Controller if ($icid && $json && $html) { try { //html - $meta = $this->InfoMetas_model->get($icid, 'AMP'); + $meta = $this->InfoMetas_model->get($icid, 'AMP_BODY'); if ($meta === false) { - $this->InfoMetas_model->add($icid, 'AMP', $html); + $this->InfoMetas_model->add($icid, 'AMP_BODY', $html); } else { - $this->InfoMetas_model->update($icid, 'AMP', $html); + $this->InfoMetas_model->update($icid, 'AMP_BODY', $html); } //json $meta = $this->InfoMetas_model->get($icid, 'AMP_JSON'); From edce7fa77709b620b6330ac9888f2153d33f5429 Mon Sep 17 00:00:00 2001 From: lmr Date: Fri, 23 Feb 2018 03:01:16 -0800 Subject: [PATCH 3/7] =?UTF-8?q?Update=20.gitlab-ci.yml=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=9B=BD=E9=99=85=E7=AB=99=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88646b84..29b1b372 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ staging: production: script: - curl -sSf http://cht.mycht.cn/please_dont_delete_this_file_4a4f500ae61d9e44b931d9f72fb14aaf95517b7e.php?branch=master + - curl -sSf https://www.arachina.com/pull-from-origin-by-icht.php?branch=info only: - master - /^deploy-.*$/ \ No newline at end of file From 7181fdb52f1bb8abda4b58c636b33687e7812f50 Mon Sep 17 00:00:00 2001 From: lmrwork <59361885@qq.com> Date: Sat, 24 Feb 2018 09:18:45 +0800 Subject: [PATCH 4/7] test ci --- application/controllers/info_amp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index 7f179fc1..6fb9fb35 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -11,7 +11,7 @@ class Info_amp extends CI_Controller parent::__construct(); //$this->permission->is_admin(); $this->load->model('InfoMetas_model'); - //CORS + //CORS TEST header('Access-Control-Allow-Origin:*'); } From 1f05b91c67f2d743d010be2fb9d92827d99c5a0d Mon Sep 17 00:00:00 2001 From: lmrwork <59361885@qq.com> Date: Sat, 24 Feb 2018 14:25:34 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0amp=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/views/bootstrap3/information_edit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/views/bootstrap3/information_edit.php b/application/views/bootstrap3/information_edit.php index 70098812..893cb8b0 100644 --- a/application/views/bootstrap3/information_edit.php +++ b/application/views/bootstrap3/information_edit.php @@ -537,6 +537,7 @@
+ | ic_id, 'AMP_STATUS') === '1') {?> From ed6906223e7b412c10f79962f1d64a04f48aafbc Mon Sep 17 00:00:00 2001 From: cyc Date: Sat, 24 Feb 2018 16:22:49 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=BD=91=E5=89=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=BC=93=E5=AD=98=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../train/controllers/searchnew.php | 292 ++++++++++++++++++ .../train/models/BIZ_train_model.php | 16 +- 2 files changed, 293 insertions(+), 15 deletions(-) create mode 100644 application/third_party/train/controllers/searchnew.php diff --git a/application/third_party/train/controllers/searchnew.php b/application/third_party/train/controllers/searchnew.php new file mode 100644 index 00000000..dac1d8d7 --- /dev/null +++ b/application/third_party/train/controllers/searchnew.php @@ -0,0 +1,292 @@ +load->model("BIZ_train_model");//加载模型 + } + + //查询聚合余票接口,对返回的数据进行处理 + public function index($train_date=null,$fromStation=null,$toStation=null){ + //定义一些变量 + $cache = 'no'; + $flag = true; + $juheTrainInfo = ''; + set_time_limit(0); + + //判断数据是否合法 + if(!$train_date || !$fromStation || !$toStation){ + exit('传参不能为空!'); + }else{ + if(strlen($fromStation) != 3){ + exit('fromStation:参数错误!'); + } + if(strlen($toStation) != 3){ + exit('toStation:参数错误!'); + } + $this->train_date = $train_date; + $now_time = time(); + $differ_time = (strtotime($train_date) - $now_time) / 86400; + if($differ_time <= 29){ + //调用聚合搜索模块 + $juheTrainInfo = $this->juheSearch($train_date,$fromStation,$toStation); + if(empty($juheTrainInfo)){ + $flag = 'error'; + } + }else{ + $flag = 'cache'; + } + + //调用数据处理模块。 + $returnJson = $this->dataOperate($juheTrainInfo,$flag,$fromStation,$toStation); + + //调用拼接处理模块 + $trainjson = $this->createTrainJson($returnJson); + + print_r($trainjson); + die(); + } + } + + //搜索模块 + function juheSearch($train_date,$fromStation,$toStation){ + $url = 'http://139.129.246.118:12309/trainTickets/ticketsAvailable?key='.JUHE_TRAIN_API_KEY.'&train_date='.$train_date.'&from_station='.$fromStation.'&to_station='.$toStation; + $this->url = $url; + $juheTrainInfo = $this->get_http($url); + if($this->validateJuhe($juheTrainInfo)){ + return $juheTrainInfo; + }else{ + return null; + } + } + + + //缓存处理模块(包含缓存处理) + function dataOperate($trainInfo,$flag,$fromStation,$toStation){ + if($flag == 'error'){ + $research = $this->juheSearch($this->train_date,$fromStation,$toStation); + if($this->validateJuhe($research)){ + $trainInfo = $research; + }else{ + $flag = 'cache'; + } + } + + if($flag == 'cache'){ + $cacheTrainInfo = $this->BIZ_train_model->get_train_info($fromStation,$toStation); + if(empty($cacheTrainInfo)){ + return null; + }else{ + $cache_time = $cacheTrainInfo->tpc_datetime; + $now_time = time(); + $differ_time = ($now_time - strtotime($cache_time)) / 86400; + if($differ_time >= 7){ + $this->delete_traincache($fromStation,$toStation); + $research = $this->juheSearch(strtotime('+7day'),$fromStation,$toStation); + if($this->validateJuhe($research)){ + $trainInfo = $research; + }else{ + return null; + } + } + } + } + $this->BIZ_train_model->addOrUpdate($fromStation,$toStation,$trainInfo); + return $trainInfo; + } + + //字符串拼接模块 + function createTrainJson($returnJson){ + + if(empty($returnJson)){ + + }else{ + $return_data = new stdClass(); + $return_data->data = new stdClass(); + $return_data->httpstatus = 200; + //$return_data->reason = $reason; + //$return_data->cache = $cache; + $return_data->data->result = array(); + $return_data->data->map = new stdClass(); + $obj = array(); + $i = 0; + $pricestr = ''; + //print_r(json_decode($returnJson)); + //die(); + if(!empty(json_decode($returnJson)->result->list)){ + foreach (json_decode($returnJson)->result->list as $value){ + $obj[$value->from_station_code] = $value->from_station_name; + $obj[$value->to_station_code] = $value->to_station_name; + $seat_type = ''; + if(isset($value->gjrw_price)){ + if($value->gjrw_price > 0){ + $gjrwPrice = $value->gjrw_price * 10; + $seat_type .= '"6":"'.$gjrwPrice.'","A6":"¥'.$value->gjrw_price.'",'; + } + } + if(isset($value->qtxb_price)){ + if($value->qtxb_price > 0){ + $seat_type .= '"H":"¥'.$value->qtxb_price.'",'; + } + } + if(isset($value->rw_price)){ + if($value->rw_price > 0){ + $rwPrice = $value->rw_price * 10; + $seat_type .= '"4":"'.$rwPrice.'","A4":"¥'.$value->rw_price.'",'; + } + } + if(isset($value->rz_price)){ + if($value->rz_price > 0){ + $rzPrice = $value->rz_price * 10; + $seat_type .= '"2":"'.$rzPrice.'","A2":"¥'.$value->rz_price.'",'; + } + } + if(isset($value->tdz_price)){ + if($value->tdz_price > 0){ + $seat_type .= '"P":"¥'.$value->tdz_price.'",'; + } + } + if(isset($value->wz_price)){ + if($value->wz_price > 0){ + $wzPrice = $value->wz_price * 10; + $seat_type .= '"WZ":"¥'.$value->wz_price.'",'; + } + } + if(isset($value->yw_price)){ + if($value->yw_price > 0){ + $ywPrice = $value->yw_price * 10; + $seat_type .= '"3":"'.$ywPrice.'","A3":"¥'.$value->yw_price.'",'; + } + } + if(isset($value->yz_price)){ + if($value->yz_price > 0){ + $yzPrice = $value->yz_price * 10; + $seat_type .= '"1":"'.$yzPrice.'","A1":"¥'.$value->yz_price.'",'; + } + } + if(isset($value->edz_price)){ + if($value->edz_price > 0){ + $seat_type .= '"O":"¥'.$value->edz_price.'",'; + } + } + if(isset($value->ydz_price)){ + if($value->ydz_price > 0){ + $seat_type .= '"M":"¥'.$value->ydz_price.'",'; + } + } + if(isset($value->swz_price)){ + if($value->swz_price > 0){ + $swzPrice = $value->swz_price * 10; + $seat_type .= '"9":"'.$swzPrice.'","A9":"¥'.$value->swz_price.'",'; + } + } + if(isset($value->dw_price)){ + if($value->dw_price > 0){ + $seat_type .= '"F":"¥'.$value->dw_price.'",'; + } + } + $pricestr = $seat_type.'"train_no":'.'"'.$value->train_no.'"'; + //余票字符串 + $return_data->data->result[$i] = '|预定|'.$value->train_no.'|'.$value->train_code.'|'.$value->from_station_name.'|'.$value->to_station_name.'|'.$value->from_station_code.'|'.$value->to_station_code.'|'.$value->start_time.'|'.$value->arrive_time.'|'.$value->run_time.'|'.$value->can_buy_now.'||'.$value->train_start_date.'||||||||'.$this->ticket_exchange($value->gjrw_num).'|'.$this->ticket_exchange($value->qtxb_num).'|'.$this->ticket_exchange($value->rw_num).'|'.$this->ticket_exchange($value->rz_num).'|'.$this->ticket_exchange($value->tdz_num).'|'.$this->ticket_exchange($value->wz_num).'||'.$this->ticket_exchange($value->yw_num).'|'.$this->ticket_exchange($value->yz_num).'|'.$this->ticket_exchange($value->edz_num).'|'.$this->ticket_exchange($value->ydz_num).'|'.$this->ticket_exchange($value->swz_num).'|'.$this->ticket_exchange($value->dw_num).'||'; + $data = '{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":{'.$pricestr.'},"messages":[],"validateMessages":{}}'; + $return_data->data->price[$i] = $data; + $i++; + } + } + $return_data->data->map = (object)$obj; + print_r($return_data); + } + } + + + //获取价格(废弃) + /* + fromStationCode:出发站三字码 + toStationCode:终点站三字码 + trainCode:车次号 + */ + public function get_price($fromStationCode=null,$toStationCode=null,$trainCode=null){ + if(!$fromStationCode || !$toStationCode || !$trainCode){ + exit('传参错误!'); + }else{ + $return_data = $this->BIZ_train_model->get_price($fromStationCode,$toStationCode,$trainCode); + if(!empty($return_data)){ + print_r(json_decode($return_data->TPL_Price)); + }else{ + print_r('没有数据返回'); + } + } + } + + //验证聚合返回的信息是否正确 + function validateJuhe($trainInfo){ + if(!empty($trainInfo) && !empty(json_decode($trainInfo)->result)){ + return true; + }else{ + return false; + } + } + + + //余票转换 + function ticket_exchange($num){ + if(isset($this->cache)){ + $time = strtotime($this->train_date) - time(); + $day = $time / 86400; + if($day > 15){ + return '有'; + }else{ + return $num; + } + }else{ + if(is_numeric($num)){ + if($num == 0){ + return '无'; + }elseif($num >= 99){ + return '有'; + }else{ + return $num; + } + }else{ + if($num == '--'){ + return ''; + } + } + } + } + + //发送请求 + function get_http($url, $data = '', $method = 'GET') { + $curl = curl_init(); // 启动一个CURL会话 + 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_FOLLOWLOCATION, 1); // 使用自动跳转 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer + if ($method == 'POST' && !empty($data)) { + curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包 + } + curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环 + curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 + $tmpInfo = curl_exec($curl); // 执行操作 + $errno = curl_errno($curl); + if ($errno !== 0) { + return false; + $error_message = $errno . ' ' . curl_error($curl); //记录错误日志 + log_message('error', "third_party/train_app/index/get_http curl {$error_message}"); + } + curl_close($curl); //关闭CURL会话 + return $tmpInfo; //返回数据 + } +} + + + + +?> \ No newline at end of file diff --git a/application/third_party/train/models/BIZ_train_model.php b/application/third_party/train/models/BIZ_train_model.php index e7908e4e..ebad9cd0 100644 --- a/application/third_party/train/models/BIZ_train_model.php +++ b/application/third_party/train/models/BIZ_train_model.php @@ -59,21 +59,7 @@ class BIZ_train_model extends CI_Model { AND tpc_to_station = '$tpc_to_station'"; $query = $this->INFO->query($sql); - - if($query->row()){ - $cache_time = strtotime($query->row()->tpc_datetime); - $now_time = time(); - $differ_time = ($now_time - $cache_time) / 86400; - if($differ_time >= 7){ - $this->delete_traincache($tpc_from_station,$tpc_to_station); - return null; - }else{ - return $query->row(); - } - }else{ - return null; - } - + return $query->row(); } //删除缓存操作 From 7068129201147803306d2cd58e29af0ecc8fbfca Mon Sep 17 00:00:00 2001 From: cyc Date: Sat, 24 Feb 2018 16:26:58 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=90=8C=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/third_party/train/controllers/searchnew.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/third_party/train/controllers/searchnew.php b/application/third_party/train/controllers/searchnew.php index dac1d8d7..c02fa71a 100644 --- a/application/third_party/train/controllers/searchnew.php +++ b/application/third_party/train/controllers/searchnew.php @@ -2,7 +2,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); -class search extends CI_Controller{ +class searchnew extends CI_Controller{ public function __construct(){ parent::__construct();