diff --git a/application/controllers/information.php b/application/controllers/information.php index 3bc803ec..12748951 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -440,7 +440,9 @@ class Information extends CI_Controller $update_info_log = $this->update_cache($ic_url, true); } else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) { $update_info_log = $this->update_cache($ic_url); - } else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0) { //非cht站点并且非GM + } else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) { + $update_info_log = $this->update_cache($ic_url); + } else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0 && strcasecmp($site_code, "ah") != 0) { //非cht站点并且非GM并且非AH $update_info_log = $this->update_cache($ic_url); } diff --git a/application/third_party/ctrip/controllers/ctrip_train.php b/application/third_party/ctrip/controllers/ctrip_train.php index 4943ea3f..0b1eac7f 100644 --- a/application/third_party/ctrip/controllers/ctrip_train.php +++ b/application/third_party/ctrip/controllers/ctrip_train.php @@ -317,8 +317,19 @@ class ctrip_train extends CI_Controller{ $ResponseJson = post_ctrip($url,'','GET'); - //$ResponseData = json_decode($ResponseJson); - print_r($ResponseJson); + $ResponseData = json_decode($ResponseJson); + + $priceAddSeats = ['软卧','硬卧']; + foreach ($ResponseData->TransferLines as $methodsItems){ + foreach($methodsItems->Trains as $trainsItems){ + foreach ($trainsItems->Seats as $seatsItems){ + if(in_array($seatsItems->SeatName,$priceAddSeats)){ + $seatsItems->Price = ceil($seatsItems->Price * 1.2); + } + } + } + } + print_r(json_encode($ResponseData)); } } } \ No newline at end of file diff --git a/application/third_party/flightsystem/config/config.php b/application/third_party/flightsystem/config/config.php new file mode 100644 index 00000000..7c1c6d75 --- /dev/null +++ b/application/third_party/flightsystem/config/config.php @@ -0,0 +1,21 @@ +"", + "1"=>"ʧЧ", + "2"=>"֧", + "3"=>"֧Ʊ", + "4"=>"Ʊɹ", + "5"=>"Ʊʧ", + "6"=>"Ʊ", + "7"=>"г˿Ʊ(ǩ)ɹ", + "8"=>"˿Ʊʧ", + "e"=>"ݴύʧ" + ); \ No newline at end of file diff --git a/application/third_party/flightsystem/controllers/api.php b/application/third_party/flightsystem/controllers/api.php new file mode 100644 index 00000000..1a2bc665 --- /dev/null +++ b/application/third_party/flightsystem/controllers/api.php @@ -0,0 +1,72 @@ +load->helper('tuniu'); + } + + public function index(){ + + } + + public function searchForHt(){ + $departDate = $this->input->get_post('departDate'); + $departCode = $this->input->get_post('departCode'); + $arriveCode = $this->input->get_post('arriveCode'); + + if(empty($departDate) || empty($departCode) || empty($arriveCode)){ + exit('请传入正确的参数,如有疑问请联系CYC!!!'); + } + + $url = 'https://www.trainspread.com/guide.php/flight/search/?departDate='.$departDate.'&departCode='.$departCode.'&arriveCode='.$arriveCode; + $json = post_tuniu($url); + $data['data'] = json_decode($json); + + $this->load->view('searchForHt',$data); + } + + public function addorders(){ + //接收参数 + $departime = $this->input->get_post('departime'); + $fromcode = $this->input->get_post('fromcode'); + $tocode = $this->input->get_post('tocode'); + $flightnumber = $this->input->get_post('flightnumber'); + + //测试数据 + $deparTime = '2019-08-15'; + $fromCode = 'BJS'; + $toCode = 'SHA'; + $flightNumber = 'KN5955'; + + //查询到sessionid + $searchJson = get_serach_json($deparTime,$fromCode,$toCode,$flightNumber); + $returnJson = post_tuniu(TUNIU_FLIGHT_API,$searchJson,'POST'); + $returnData = json_decode($returnJson); + $sessionId = $returnData->data->queryResultList['0']->resourceList['0']->sessionId; + //$sessionId = 'eyJuYW1lIjoiZGlzdE5ldyIsImZrIjoiTkFZI1NIQSNLTjU5NTUjMjAxOS0wOC0xNSIsInNpIjo4LCJjYSI6IlkiLCJjbyI6IkgiLCJhcCI6IjUxOCIsImNwIjoiNzcyIn0'; + echo $sessionId; + + //获取航班信息,订单信息 + + + //拼接下单报文 + $data = '{"contactTel":"18877381547","flight":{"adtPrice":1111,"arriveCityCode":"SHA","cabinClass":"Y","cabinCode":"H","departureCityCode":"BJS","departureDate":"2019-08-15","flightNum":"KN5955"},"remark":"haina123456","sessionId":"'.$sessionId.'","touristList":[{"birthday":"1992-08-13","firstName":"chen","lastName":"yuchao","name":"陈宇超","personType":"ADT","psptId":"450302199208131039","psptType":1,"tel":"18877381547"}]}'; + $timestamp = time(); + $sign = md5(TUNIU_FLIGHT_KEY.$data.$timestamp); + $bookJson = '{ + "purchaseId": '.TUNIU_FLIGHT_ID.', + "sign": "'.$sign .'", + "timestamp": '.$timestamp.', + "function": "createOrder", + "data":'.$data.' + }'; + //echo $bookJson;die(); + $returnJson = post_tuniu(TUNIU_FLIGHT_API,$bookJson,'POST'); + //print_r($returnData); + echo $returnJson; + //生成报文 + } +} \ No newline at end of file diff --git a/application/third_party/flightsystem/controllers/pages.php b/application/third_party/flightsystem/controllers/pages.php new file mode 100644 index 00000000..3479c6c4 --- /dev/null +++ b/application/third_party/flightsystem/controllers/pages.php @@ -0,0 +1,20 @@ +load->helper('tuniu'); + } + + public function index(){ + exit('ǰܣ'); + } + + public function homepage(){ + $this->load->view('common/header'); + $this->load->view('homepage'); + $this->load->view('common/footer'); + } +} \ No newline at end of file diff --git a/application/third_party/flightsystem/helpers/tuniu_helper.php b/application/third_party/flightsystem/helpers/tuniu_helper.php new file mode 100644 index 00000000..264ecac7 --- /dev/null +++ b/application/third_party/flightsystem/helpers/tuniu_helper.php @@ -0,0 +1,90 @@ += 99){ + return '有'; + }else{ + return $num; + } + } + } + } + + //获取毫秒数 + function get_microtime (){ + list($s1, $s2) = explode(' ', microtime()); + return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); + } + + //获取飞机查询报文 + function get_serach_json($departime,$fromcode,$tocode,$flightnumber=null){ + $timestamp = time(); + $function = 'queryNew'; + $flightnumberstr = ''; + if(!empty($flightnumber)){ + $flightnumberstr = ',"flightNum":"'.$flightnumber.'"'; + } + + $data = '{"channelId":7,"departureDate":"'.$departime.'","dstCityCode":"'.$tocode.'"'.$flightnumberstr.',"orgCityCode":"'.$fromcode.'"}'; + $sign = md5(TUNIU_FLIGHT_KEY.$data.$timestamp); + + $postJson = '{ + "purchaseId": '.TUNIU_FLIGHT_ID.', + "sign": "'.$sign .'", + "timestamp": '.$timestamp.', + "function": "'.$function.'", + "data":'.$data.' + }'; + + return $postJson; + } + + //发送请求函数 + function post_tuniu($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_HTTPHEADER, array('Content-Type:application/json')); + } + curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环 + curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环 + 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; + echo $errno . curl_error($curl); //记录错误日志 + } + curl_close($curl); //关闭CURL会话 + return $tmpInfo; //返回数据 + } + +?> \ No newline at end of file diff --git a/application/third_party/flightsystem/views/common/footer.php b/application/third_party/flightsystem/views/common/footer.php new file mode 100644 index 00000000..b231b902 --- /dev/null +++ b/application/third_party/flightsystem/views/common/footer.php @@ -0,0 +1,43 @@ + +
+ + +