<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Index extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('message');
$this->key = '3d15821171548bf7d0a93afab66e797b';
$this->sendsms = 'https://yun.tim.qq.com/v5/tlssmssvr/sendsms';
$this->db_train_zw = $this->config->item('db_train_zw');
}
public function index(){
exit('前方高能!!!');
}
public function home(){
$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 sendBigCarTourMessage(){
$this->load->model('messagecenter_model');
$order = $this->input->get_post('order');
$guideName = $this->input->get_post('guideName');
$guidePhone = $this->input->get_post('guidePhone');
$phone = $this->input->get_post('phone');
$nation_code = $this->input->get_post('areaCode');
//$order = '170603001M';
$orderInfo = $this->messagecenter_model->getOrderInfo($order);
$name = $orderInfo->GUT_FirstName.$orderInfo->GUT_LastName;
$startDate = date('M. d, Y',strtotime($orderInfo->COLD_StartDate));
//构造发送短信的报文
$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 = '【桂林海纳国旅】';
}
$messageContent = 'Hi '.$name.', your guide on '.$startDate.' is '.$guideName.' ( mobile '.$guidePhone.'). He/she will call you at your hotel, or leave you a message tonight. Have a nice day!';
//添加导游信息到订单里面
$this->messagecenter_model->updateColiMemo($order,$messageContent);
$post_str = '{
"ext": "",
"extend": "",
"msg": "'.$messageContent.'",
"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);
}
//发送短信
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);
}
//计算各个事业部使用短信的价格
public function count_price(){
$this->load->model('messagecenter_model');
$from_time = $this->input->get_post('from_time');
$to_time = $this->input->get_post('to_time');
$rate = $this->input->get_post('rate');
$sms_price_list = array("376"=>"0.0651","971"=>"0.0415","93"=>"0.0731","1268"=>"0.0781","1264"=>"0.0454","355"=>"0.0949","374"=>"0.0813","244"=>"0.0633","54"=>"0.0301","1684"=>"0.1100","43"=>"0.1287","61"=>"0.0804","297"=>"0.0553","994"=>"0.1462","387"=>"0.0772","1246"=>"0.0521","880"=>"0.0846","32"=>"0.0825","226"=>"0.0776","359"=>"0.0737","973"=>"0.0229","257"=>"0.0383","229"=>"0.0498","1441"=>"0.0548","673"=>"0.0173","591"=>"0.0649","599"=>"0.0443","55"=>"0.0167","1242"=>"0.0390","975"=>"0.0396","267"=>"0.0427","375"=>"0.0638","501"=>"0.0330","1"=>"0.0080","243"=>"0.0513","236"=>"0.0633","242"=>"0.0664","41"=>"0.0712","225"=>"0.0819","682"=>"0.0403","56"=>"0.0680","237"=>"0.0548","57"=>"0.0414","506"=>"0.0694","238"=>"0.0869","599"=>"0.0489","357"=>"0.0335","420"=>"0.0801","49"=>"0.1000","253"=>"0.1106","45"=>"0.0532","1767"=>".0550","1809"=>"0.0519","213"=>"0.1656","593"=>"0.1068","372"=>"0.1141","20"=>"0.0492","291"=>"0.0915","34"=>"0.0988","251"=>"0.0336","358"=>"0.1390","679"=>"0.0367","691"=>"0.1491","298"=>"0.0158","33"=>"0.0778","241"=>"0.0357","44"=>"0.0464","1473"=>"0.0489","995"=>"0.0218","594"=>"0.1515","233"=>"0.0244","350"=>"0.0201","299"=>"0.0128","220"=>"0.0454","224"=>"0.0884","590"=>"0.2772","240"=>"0.0863","30"=>"0.1013","502"=>"0.0555","1671"=>"0.0564","245"=>"0.0978","592"=>"0.0726","852"=>"0.0448","504"=>"0.0645","385"=>"0.0801","509"=>"0.0848","36"=>"0.1197","62"=>"0.0334","353"=>"0.0824","972"=>"0.0173","91"=>"0.0085","964"=>"0.0611","354"=>"0.0333","39"=>"0.0823","1876"=>"0.0374","962"=>"0.0700","81"=>"0.0750","254"=>"0.0299","996"=>"0.0564","855"=>"0.0561","686"=>"0.0510","269"=>"0.0459","1869"=>"0.0947","82"=>"0.0357","965"=>"0.0518","1345"=>"0.0463","7"=>"0.0783","856"=>"0.0456","961"=>"0.0464","1758"=>"0.0414","423"=>"0.0297","94"=>"0.0690","231"=>"0.0709","266"=>"0.0589","370"=>"0.0419","352"=>"0.0157","371"=>"0.0696","218"=>"0.0569","212"=>"0.0832","377"=>"0.0638","373"=>"0.0954","382"=>"0.0358","261"=>"0.0564","692"=>"0.1323","389"=>"0.0303","223"=>"0.1927","95"=>"0.0940","976"=>"0.0645","853"=>"0.0267","222"=>"0.0800","1664"=>"0.0685","356"=>"0.0316","230"=>"0.0509","960"=>"0.0340","265"=>"0.0486","52"=>"0.0332","60"=>"0.0362","258"=>"0.0315","264"=>"0.0429","687"=>"0.2356","227"=>"0.0769","234"=>"0.0314","505"=>"0.0726","31"=>"0.1564","47"=>"0.0942","977"=>"0.1029","674"=>"0.0842","64"=>"0.1162","968"=>"0.0750","507"=>"0.0723","51"=>"0.0440","689"=>"0.1246","675"=>"0.0692","63"=>"0.0355","92"=>"0.0226","48"=>"0.0411","508"=>"0.0580","1787"=>"0.0564","351"=>"0.0522","680"=>"0.0855","595"=>"0.0306","974"=>"0.0526","262"=>"0.2108","40"=>"0.0744","381"=>"0.0472","7"=>"0.0321","250"=>"0.0366","966"=>"0.0357","677"=>"0.0303","248"=>"0.0644","249"=>"0.0510","46"=>"0.1066","65"=>"0.0380","386"=>"0.0383","421"=>"0.0999","232"=>"0.0305","378"=>"0.0587","221"=>"0.0719","252"=>"0.0873","597"=>"0.0495","239"=>"0.1149","503"=>"0.0574","268"=>"0.0748","1649"=>"0.0411","235"=>"0.0378","228"=>"0.0348","66"=>"0.0192","992"=>"0.0607","670"=>"0.0656","993"=>"0.0580","216"=>"0.1255","676"=>"0.0371","90"=>"0.0090","1868"=>"0.0384","886"=>"0.0540","255"=>"0.0422","380"=>"0.0533","256"=>"0.0776","1"=>"0.0063","598"=>"0.1093","998"=>"0.1411","1784"=>"0.0619","58"=>"0.0203","1284"=>"0.0480","84"=>"0.0399","678"=>"0.0611","685"=>"0.0774","967"=>"0.0284","269"=>"0.1589","27"=>"0.0319","260"=>"0.0422","263"=>"0.0253");
$tp_list = $this->messagecenter_model->get_tp_list($from_time,$to_time);
$tp_total_price = 0;
$cht_total_price = 0;
//TP的短信费用
foreach($tp_list as $tp_item){
if($tp_item->TPSL_nationCode == '86'){
$tp_total_price += 2 * 0.1;
}else{
//echo $sms_price_list[$tp_item->TPSL_nationCode];
$tp_total_price += (2 * $sms_price_list[$tp_item->TPSL_nationCode]) * $rate;
}
}
//商旅短信费用
$cht_list = $this->messagecenter_model->get_cht_list($from_time,$to_time);
foreach($cht_list as $cht_item){
if($cht_item->nation_code == '86'){
$cht_total_price += 2 * 0.1;
}else{
//echo $sms_price_list[$tp_item->TPSL_nationCode];
$cht_total_price += $sms_price_list[$cht_item->nation_code] * $rate;
}
}
$all_total = $cht_total_price + $tp_total_price;
/*echo 'tp:'.$tp_total_price.'< br > ';
echo 'cht:'.$cht_total_price.'< br > ';
echo 'total:'.$all_total.'< br > ';*/
echo '{"tp":"'.$tp_total_price.'","cht":"'.$cht_total_price.'","all_total":"'.$all_total.'"}';
}
//大车游信息录入页面
public function thirdinput(){
$this->load->view('n-header');
$this->load->view('thirdinput');
}
public function ajaxGetOrderInfo(){
$this->load->model('messagecenter_model');
$order = $this->input->get_post('order');
$orderInfo = $this->messagecenter_model->getOrderInfo($order);
$orderInfo->COLD_StartDate = date('M. d, Y',strtotime($orderInfo->COLD_StartDate));
echo json_encode($orderInfo);
}
public function ajaxGetTrainOrderInfo(){
$this->load->model('messagecenter_model');
$order = $this->input->get_post('order');
$orderInfo = $this->messagecenter_model->getOrderInfo($order);
}
}
?>