diff --git a/application/third_party/ctrip/controllers/ctrip_train.php b/application/third_party/ctrip/controllers/ctrip_train.php index 7f818f37..1836268e 100644 --- a/application/third_party/ctrip/controllers/ctrip_train.php +++ b/application/third_party/ctrip/controllers/ctrip_train.php @@ -123,6 +123,12 @@ class ctrip_train extends CI_Controller{ $rwNum = $Seats->TicketLeft; } + if($Seats->SeatName == '一等双软下'){ + $ydrwPrice = $Seats->Price * 10; + $SeaType .= '"I":"'.$ydrwPrice.'","AI":"¥'.$Seats->Price.'",'; + $ydrwNum = $Seats->TicketLeft; + } + if($Seats->SeatName == '软座'){ $rzPrice = $Seats->Price * 10; $SeaType .= '"2":"'.$rzPrice.'","A2":"¥'.$Seats->Price.'",'; @@ -167,6 +173,12 @@ class ctrip_train extends CI_Controller{ $ywNum = $Seats->TicketLeft; } + if($Seats->SeatName == '二等双软下'){ + $errwPrice = $Seats->Price * 10; + $SeaType .= '"J":"'.$errwPrice.'","AJ":"¥'.$Seats->Price.'",'; + $errwNum = $Seats->TicketLeft; + } + if($Seats->SeatName == '动卧下'){ $SeaType .= '"F":"¥'.$Seats->Price.'",'; $dwNum = $Seats->TicketLeft; @@ -175,6 +187,7 @@ class ctrip_train extends CI_Controller{ $PriceStr = $SeaType.'"train_no":'.'"'.$TrainInfo->TrainNo.'"'; } + //对返回的数据进行容错处理 $gjrwNum = isset($gjrwNum) ? ticket_exchange($gjrwNum,$iseven) : ''; $rwNum = isset($rwNum) ? ticket_exchange($rwNum,$iseven) : ''; @@ -187,6 +200,17 @@ class ctrip_train extends CI_Controller{ $ydzNum = isset($ydzNum) ? ticket_exchange($ydzNum,$iseven) : ''; $swzNum = isset($swzNum) ? ticket_exchange($swzNum,$iseven) : ''; $dwNum = isset($dwNum) ? ticket_exchange($dwNum,$iseven) : ''; + $ydrwNum = isset($ydrwNum) ? ticket_exchange($ydrwNum,$iseven) : ''; + $errwNum = isset($errwNum) ? ticket_exchange($errwNum,$iseven) : ''; + + if($rwNum == '' && $ydrwNum != ''){ + $rwNum = $ydrwNum; + } + + if($ywNum == '' && $errwNum != ''){ + $ywNum = $errwNum; + } + $runMin = $TrainInfo->DurationMinutes % 60; $runHour = ($TrainInfo->DurationMinutes - $runMin) / 60; diff --git a/application/third_party/tripadvisor_spider/config/config.php b/application/third_party/tripadvisor_spider/config/config.php index b76a507d..022d61f8 100644 --- a/application/third_party/tripadvisor_spider/config/config.php +++ b/application/third_party/tripadvisor_spider/config/config.php @@ -17,7 +17,11 @@ $config['tripadvisor_website'] = array( 'Lijiang' => 'http://www.tripadvisor.com/Attraction_Review-g303783-d8464335-Reviews{PAGENUM}China_Highlights_Lijiang-Lijiang_Yunnan.html', 'Zhangjiajie' => 'http://www.tripadvisor.com/Attraction_Review-g494933-d8077695-Reviews{PAGENUM}China_Highlights_Zhangjiajie_Day_Tour-Zhangjiajie_Hunan.html', 'HongKong' => 'https://www.tripadvisor.com/Attraction_Review-g294217-d10243951-Reviews{PAGENUM}China_Highlights_Hong_Kong-Hong_Kong.html', - 'Panda' => 'https://www.tripadvisor.com/Attraction_Review-g297463-d11489225-Reviews{PAGENUM}China_Highlights-Chengdu_Sichuan.html' + 'Panda' => 'https://www.tripadvisor.com/Attraction_Review-g297463-d11489225-Reviews{PAGENUM}China_Highlights-Chengdu_Sichuan.html', + 'tp_Beijing' => 'https://www.tripadvisor.com/Attraction_Review-g294212-d4006739-Reviews-The_Trippest_Mini_Group_Tours-Beijing.html', + 'tp_Xian' => 'https://www.tripadvisor.com/Attraction_Review-g298557-d10999897-Reviews-Xi_an_Trippest_Mini_Group_Tours-Xi_an_Shaanxi.html', + 'tp_Shanghai' => 'https://www.tripadvisor.com/Attraction_Review-g308272-d6222868-Reviews-Shanghai_Trippest_Mini_Group_Tours-Shanghai.html', + 'tp_Guilin' => 'https://www.tripadvisor.com/Attraction_Review-g298556-d14121459-Reviews-Trippest_Mini_Group_Tours-Guilin_Guangxi.html' ); diff --git a/application/third_party/tripadvisor_spider/controllers/index.php b/application/third_party/tripadvisor_spider/controllers/index.php index e2dee812..6bc23ea5 100644 --- a/application/third_party/tripadvisor_spider/controllers/index.php +++ b/application/third_party/tripadvisor_spider/controllers/index.php @@ -11,6 +11,11 @@ class Index extends CI_Controller { public function __construct() { parent::__construct(); //$this->output->enable_profiler(TRUE); + header('Access-Control-Allow-Origin:*'); + header('Access-Control-Allow-Methods:POST, GET'); + header('Access-Control-Max-Age:0'); + header('Access-Control-Allow-Headers:x-requested-with, Content-Type'); + header('Access-Control-Allow-Credentials:true'); $this->load->model('Tripadvisor_Review_model'); } @@ -186,5 +191,156 @@ class Index extends CI_Controller { } echo json_encode(array('group_result' => $this->load->view('find_group_result', $data, true), 'tr_content' => $data['ta_review']->tr_content)); } - + + //第三方数据导入 + public function third_party_input(){ + $this->load->view('bootstrap3/header'); + $this->load->view('third_party_input'); + $this->load->view('bootstrap3/footer'); + } + + function ensure_writable_dir($dir) { + if(!file_exists($dir)) { + mkdir($dir, 0766, true); + chmod($dir, 0766); + chmod($dir, 0777); + }else if(!is_writable($dir)) { + chmod($dir, 0766); + chmod($dir, 0777); + if(!is_writable($dir)) { + throw new FileSystemException("目录 $dir 不可写"); + } + } + } + + //第三方数据录入 + public function analysis_excel(){ + $filename = date('Y').date('m').date('d').date('h').date('i').date('s').'.'.explode('.',$_FILES['fileArray']['name'])[1]; + $tmp = $_FILES['fileArray']['tmp_name']; + $error = $_FILES['fileArray']['error']; + if($error > 0){ + header("HTTP/1.1 404 Not Found"); + echo '{"status":404,"message":'.$_FILES["fileArray"]["error"].'}'; + }else{ + $path = 'upload/'.date('Y').'/'.date('m').'/'; + $this->ensure_writable_dir($path); + if(move_uploaded_file($tmp,$path.$filename)){ + require_once "PHPExcel/IOFactory.php"; + $phpExcel = PHPExcel_IOFactory::load($path.$filename); + + //创建返回的数组 + $data = []; + foreach ($phpExcel->getSheetNames() as $key=>$destination){ + $data[$key] = new stdClass(); + $data[$key]->destination = $destination; + $data[$key]->list_name = array(); + $data[$key]->list_data = array(); + //循环获取每个表格的行/列数 + $row = $phpExcel->getActiveSheet()->getHighestRow(); + $column = $phpExcel->getActiveSheet()->getHighestColumn(); + $j = 0; + // 行数循环 + for ($i = 1; $i <= $row; $i++) { + // 列数循环 + for ($c = 'A'; $c <= $column; $c++) { + if($phpExcel->getActiveSheet($key)->getCell('A' . $i)->getValue() == ''){ + continue; + }else{ + if($i == 1){ + array_push($data[$key]->list_name,$phpExcel->getActiveSheet($key)->getCell($c . $i)->getValue()); + }else{ + $data[$key]->list_data[$j][] = $phpExcel->getActiveSheet($key)->getCell($c . $i)->getValue(); + } + + } + } + $j++; + } + } + //返回处理完后的json + print_r(json_encode($data)); + }else{ + header("HTTP/1.1 404 Not Found"); + echo '{"status":404,"message":"文件上传失败!","picname":""}'; + } + } + } + + public function get_destination_reviews($destination = null){ + $ta_website = $this->config->item('tripadvisor_website'); + + //根据传入的目的地简码获取TA的相应评论列表 + if(isset($ta_website[$destination])){ + $url = $ta_website[$destination]; + + //根据url获取页面内容 + $content = GET_HTTP($url); + + //进行页面解析 + $html_object = str_get_html($content); + + //获取第一页列表上的url + foreach ($html_object->find('.reviewSelector .quote a') as $a_info){ + $url = 'https://www.tripadvisor.com'.$a_info->href; + + } + } + } + + function get_reviews_detail(){ + set_time_limit(0); + $url = $this->input->get_post('url'); + $destination = $this->input->get_post('destination'); + + //$url = 'https://www.tripadvisor.com/ShowUserReviews-g294212-d4006739-r666168101-The_Trippest_Mini_Group_Tours-Beijing.html'; + $destination = 'tp_Beijing'; + + if($url != ''){ + $content = GET_HTTP($url); + $html_object = str_get_html($content); + + //做一个数组用于存储数据 + $detail_data = new stdClass(); + $detail_data->destination = $destination; + + //提取局部,不做整个页面的寻找元素,提升效率 + $meta_inner = $html_object->find('.meta_inner'); + + foreach($meta_inner as $detail_info){ + //获取评论者帐号 + foreach($detail_info->find('.info_text') as $review_name){ + $detail_data->review_name = $review_name->first_child()->innertext; + } + + //获取评论者ID + foreach($detail_info->find('.reviewSelector') as $review_id){ + $detail_data->review_id = str_replace('review_','',$review_id->id); + } + + //获取标题 + foreach($detail_info->find('#HEADING') as $title){ + $detail_data->title = $title->innertext; + } + + //获取星级 + foreach($detail_info->find('.ui_bubble_rating') as $star_nums){ + $detail_data->star_nums = str_replace('ui_bubble_rating ','',$star_nums->getAttribute('class')); + $detail_data->star_nums = str_replace(array('bubble_50','bubble_40','bubble_30','bubble_20'),array(5,4,3,2),$detail_data->star_nums); + } + + //获取评论内容 + foreach($detail_info->find('.partial_entry .fullText') as $content){ + $detail_data->content = $content->innertext; + } + + //获取评论时间 + foreach($detail_info->find('.prw_reviews_stay_date_hsx') as $review_date){ + $detail_data->review_date = str_replace('Date of experience: ','',$review_date->innertext); + } + } + + //拿到数据后进行入库 + print_r(json_encode($detail_data)); + } + } } diff --git a/webht/third_party/messagecenter/controllers/index.php b/webht/third_party/messagecenter/controllers/index.php new file mode 100644 index 00000000..2ac45867 --- /dev/null +++ b/webht/third_party/messagecenter/controllers/index.php @@ -0,0 +1,183 @@ +load->helper('message'); + $this->key = '3d15821171548bf7d0a93afab66e797b'; + $this->sendsms = 'https://yun.tim.qq.com/v5/tlssmssvr/sendsms'; + } + + public function test(){ + echo phpinfo(); + /*try { + echo '1'; + } finally { + echo '2'; + }*/ + } + + public function index(){ + $this->load->view('n-header'); + $this->load->view('message_index'); + } + + //新建短信模板 + public function add_templete(){ + $templete = htmlspecialchars($this->input->post('templete')); + $title = $this->input->post('title'); + + if(empty($templete)){ + header("HTTP/1.1 404 Not Found"); + exit('{"status":"404","reason":"传参为空!"}'); + } + + if(empty($title)){ + $title = 'trippset'.rand(1,100); + } + + $random = rand(1000,9999); + $time = time(); + $sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time; + $sig = hash("sha256", $sig); + + $post_str = '{ + "remark": "", + "sig": "'.$sig.'", + "text": "'.$templete.'", + "time": '.$time.', + "title": "'.$title.'", + "type": 1 + }'; + + $url = 'https://yun.tim.qq.com/v5/tlssmssvr/add_template?sdkappid=1400082793&random='.$random; + + $back_json = sms_post($url,$post_str,'POST'); + $back_data = json_decode($back_json); + print_r($back_data); + + } + + //查询短信模板状态 + public function search_templete_status(){ + $random = rand(1000,9999); + $time = time(); + $sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time; + $sig = hash("sha256", $sig); + + $post_str = '{ + "sig": "'.$sig.'", + "time": '.$time.', + "tpl_page": { + "max": 10, + "offset": 0 + } + }'; + + $url = 'https://yun.tim.qq.com/v5/tlssmssvr/get_template?sdkappid=1400082793&random='.$random; + $back_json = sms_post($url,$post_str,'POST'); + $back_data = json_decode($back_json); + print_r($back_data); + } + + //短信模板更新 + public function update_templete($id,$title){ + $contents = "Hi {1}, your guide on {2} is {3}, (local)mobile is {4}. He/she'll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. {5} at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!"; + $random = rand(1000,9999); + $time = time(); + $sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time; + $sig = hash("sha256", $sig); + + $post_str = '{ + "sig": "'.$sig.'", + "text": "'.$contents.'", + "time": '.$time.', + "title": "'.$title.'", + "tpl_id": '.$id.', + "type": 0 + }'; + + $url = 'https://yun.tim.qq.com/v5/tlssmssvr/mod_template?sdkappid=1400082793&random='.$random; + $back_json = sms_post($url,$post_str,'POST'); + $back_data = json_decode($back_json); + print_r($back_data); + } + + //删除模板 + public function delete_templete(){ + $random = rand(1000,9999); + $time = time(); + $sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time; + $sig = hash("sha256", $sig); + + $post_str = '{ + "sig": "'.$sig.'", + "time": '.$time.', + "tpl_id": [ + 212919, + 213082 + ] + }'; + + $url = 'https://yun.tim.qq.com/v5/tlssmssvr/del_template?sdkappid=1400082793&random='.$random; + $back_json = sms_post($url,$post_str,'POST'); + $back_data = json_decode($back_json); + print_r($back_data); + } + + //发送短信 + public function send_message(){ + //接收参数 + //1-4为四个参数依次排序 字符格式不做限制 + $one = $this->input->post('one'); + $two = $this->input->post('two'); + $three = $this->input->post('three'); + $four = $this->input->post('four'); + $five = $this->input->post('five'); + //手机号 * 必填 + $phone = $this->input->post('phone'); + //区号 * 必填 + $nation_code = $this->input->post('nation_code'); + + if(empty($phone) || empty($nation_code)){ + header("HTTP/1.1 404 Not Found"); + exit('{"status":"404","reason":"传参为空!"}'); + } + + //构造发送短信的报文 + $random = rand(1000,9999); + $time = time(); + $sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time.'&mobile='.$phone; + $sig = hash("sha256", $sig); + $mysign = '[ChinaHighlights]'; + + if($nation_code == 86){ + $mysign = '【桂林海纳国旅】'; + } + + $post_str = '{ + "ext": "", + "extend": "", + "msg": "Hi '.$one.', your guide on '.$two.' is '.$three.', (local) mobile is '.$four.'. He/she\'ll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. '.$five.' at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!", + "sig": "'.$sig.'", + "tel": { + "mobile": "'.$phone.'", + "nationcode": "'.$nation_code.'" + }, + "time": '.$time.', + "type": 0 + }'; + + $url = 'https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400082793&random='.$random; + $back_json = sms_post($url,$post_str,'POST'); + $back_data = json_decode($back_json); + print_r($back_json); + } + +} + + +?> \ No newline at end of file diff --git a/webht/third_party/messagecenter/helpers/message_helper.php b/webht/third_party/messagecenter/helpers/message_helper.php new file mode 100644 index 00000000..8634dd43 --- /dev/null +++ b/webht/third_party/messagecenter/helpers/message_helper.php @@ -0,0 +1,31 @@ + +
版本1.0
+可以正常添加模板,但是只有一个模板可以发送
+模板示例:Hi {1}, your guide on {2} is {3}, (local)mobile is {4}. He/she'll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No {5} at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!
+ +线路代号 | +订单数量 | +具体订单号 | +
---|---|---|
'.$key.' | '; + $table_body .= ''.count($items).' | '; + $table_body .= ''; + $orders_num = 0; + foreach ($items as $value){ + $orders_num++; + if($orders_num == count($items)){ + $table_body .= $value->COLI_ID; + }else{ + $table_body .= $value->COLI_ID.'、'; + } + } + + $table_body .= ' | '; + $table_body .= '
总订单数:
+订单来源 | +订单数量 | +具体订单号 | +
---|---|---|
'.$key.' | '; + $table_body .= ''.$items['num'].' | '; + $table_body .= ''; + $orders_num = 0; + foreach ($items['order'] as $value){ + $orders_num++; + if($orders_num == count($items['order'])){ + $table_body .= $value; + }else{ + $table_body .= $value.'、'; + } + } + + $table_body .= ' | '; + $table_body .= '