|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- //巴士每天发短信提醒明天用户
- require_once __DIR__ . '/../Common/Mysql.php';
- require_once __DIR__ . '/../Common/sinaAPI.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
-
- $pdo = conn();
- if (is_object($pdo)) {
- $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A where A.ORDER_STATUS<>148 and A.CANCEL_FLAG=0 and A.RUN_DATE=DATE_ADD(current_date,INTERVAL 1 day) group by A.PARENT_ORDER_ID;";
- $result = $pdo -> query($sql);
- $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
- $result -> closeCursor();
- }
-
- if ($rowset) {
- writeLog("check_car_travel_remind.php ::" . json_encode($rowset));
- if (SEND_MESSAGE == true) {
- foreach ($rowset as $v) {
- $order_id = $v['ORDER_ID'];
- $res_content = get_msg_info($order_id);
- if($res_content == false) {continue;}
- $name = isset($res_content[0]) ? $res_content[0] : "";
- $tel = isset($res_content[1]) ? $res_content[1] : "";
- // $tel=15639834000;
- $content = isset($res_content[2]) ? $res_content[2] : "";
- writeLog("短信模板内容:【" . $content . "】");
- $response = sendTelMessage($tel, $name, $content, $order_id);
- writeLog(json_encode($response));
- $comment_type=0;
- $comment_text="";
- $send_success = (int)$response;
- $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
- $result1 = $pdo -> query($sql1);
- $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
- $result1 -> closeCursor();
- writeLog("check_car_travel_remind.php HT_ADD_MSG_COMMENT()::" . $sql1);
- if( $send_success != 0 ) {
- $warning_tel = "13816608252,18652972567,13918071837,18817501483";
- $warning_txt = "以下用户出行提醒短信发送失败:{$name}({$tel}) 订单号:{$order_id}";
- sendTelMessage($warning_tel, $name, $warning_txt, $order_id);
- }
- }
- }
- }
-
- function get_msg_info($ORDER_ID) {
- $no_send_message_line = array( 152690, 152703 );
- $msg_pdo = conn();
- $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
- $content = '';
- if (is_object($msg_pdo)) {
- $msg_result = $msg_pdo -> query($msg_sql);
- $i = 1;
- $data = array();
- if ($msg_result) {
- $data['code'] = "0";
- $data['info'] = "";
- do {
- $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
- if ($i == 1) {
- $data['seat'] = isset($row) ? $row : array();
- } else if ($i == 2) {
- $data['run_info'] = isset($row) ? $row : array();
- } else if ($i == 3) {
- $data['driver'] = isset($row) ? $row : array();
- } else {
- }
- $i++;
- } while($msg_result->nextRowset());
- }
- $json_obj = json_decode(json_encode($data), TRUE);
- $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
- $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
- $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
-
- $sp_bus_1 = array(179546,179523,202560,199565,201176,201187,179854,199464,199514,199545,202203,202682,203480,203491,203641,205086,205856);
- $sp_bus_2 = array(203464,205059,205096,205653,202910,201718,179440,179453,202353,202357,202993,202985,202697);
- $sp_bus_3 = array(201057,179612,205427,200912,204132,179872,199499,202253);
- $sp_bus_4 = array(211064,211069,211074,211080,211086,211090,211095,206009,207967);
- $sp_bus_5 = array(198577,202780,205408,205169,205674,204115,204127,201724,204074,200567,180012,205721,202703,206750);
- $sp_bus_6 = array(199746,202399,202375,205703,207718,205866,179990,203694,180026);
- $sp_bus_7 = array(180026,202234,208020,208024,208028,208040,208047,208051,208055,208059,208063,208067,211043,211058,208071);
-
- if( in_array($ORDER_ID,$sp_bus_1) ) {
- $driver = array( 'bus_no'=> "沪ED6603", 'driver_name'=> "俞国明", 'driver_mobile'=> "13524363301");
- } else if( in_array($ORDER_ID,$sp_bus_2) ) {
- $driver = array( 'bus_no'=> "沪DL4157", 'driver_name'=> "闵瑞", 'driver_mobile'=> "13357844310");
- } else if( in_array($ORDER_ID,$sp_bus_3) ) {
- $driver = array( 'bus_no'=> "沪D60528", 'driver_name'=> "杨文新", 'driver_mobile'=> "15901965353");
- } else if( in_array($ORDER_ID,$sp_bus_4) ) {
- $driver = array( 'bus_no'=> "浙A5F855", 'driver_name'=> "鲍君健", 'driver_mobile'=> "18857179668");
- } else if( in_array($ORDER_ID,$sp_bus_5) ) {
- $driver = array( 'bus_no'=> "浙AF2839", 'driver_name'=> "徐建淳", 'driver_mobile'=> "13706719887");
- } else if( in_array($ORDER_ID,$sp_bus_6) ) {
- $driver = array( 'bus_no'=> "沪BR8815", 'driver_name'=> "金刚", 'driver_mobile'=> "13681807766");
- } else if( in_array($ORDER_ID,$sp_bus_7) ) {
- $driver = array( 'bus_no'=> "沪BQ7386", 'driver_name'=> "陈继国", 'driver_mobile'=> "1391619079");
- }
-
- // 出发前一天
- <<<<<<< .mine
- // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}出发,请提前10分钟到达上车点{上车站点},车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- =======
- $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张即将于明日{发车时间}出发,车牌号{车牌号},司机电话{司机电话}。请提前10分钟到达上车站点{上车站点}:{上车站点详细地址},并提前点开电子车票准备乘车{$short_url}。请关注微信公众号【蜘蛛出行】,查看车辆及站点照片。";
- >>>>>>> .r3971
- if ($seat) {
- $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
- $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
- $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
- $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
- if ($seat_name == "") {
- $content = str_replace("{座位号}", "", $content);
- } else {
- $content = str_replace("{座位号}", $seat_name, $content);
- }
- }else{
- $content = str_replace("{座位号}", "", $content);
- }
- if ($driver) {
- $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
- $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
- $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
-
- if ($bus_no == "") {
- $content = str_replace(",车牌号{车牌号}", "", $content);
- } else {
- $content = str_replace("{车牌号}", $bus_no, $content);
- }
- if ($driver_name == "") {
- $content = str_replace(",司机电话{司机电话}", "", $content);
- } else {
- $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
- $driver_name_mobile = $driver_xing . $driver_mobile;
- $content = str_replace("{司机电话}", $driver_name_mobile, $content);
- }
- } else {
- $content = str_replace(",车牌号{车牌号}", "", $content);
- $content = str_replace(",司机电话{司机电话}", "", $content);
- }
- if ($run_info) {
- $order_count = $run_info['order_count'];
- $start_date = $run_info['start_date'];
- $start_time = $run_info['start_time'];
- $parent_order_id = $run_info['parent_order_id'];
- $end_date = $run_info['end_date'];
- $start_area = $run_info['start_area'];
- $end_area = $run_info['end_area'];
- $res_name = $run_info['res_name'];
- $prod_name = $run_info['prod_name'];
- $customer_name = $run_info['customer_name'];
- $customer_mobile = $run_info['customer_mobile'];
- $content = str_replace("{出发日期}", $start_date, $content);
- $content = str_replace("{发车时间}", $start_time, $content);
- $content = str_replace("{出发地}", $start_area, $content);
- $content = str_replace("{目的地}", $end_area, $content);
- $content = str_replace("{上车站点}", $res_name, $content);
- //..判断千岛湖的特殊情况
- if(strpos($start_area,"天目湖")!==false || strpos($end_area, "天目湖")!==false || in_array($run_info['parent_prod_id'], $no_send_message_line) ){
- return false;
- }
- }else{
- return false;
- $content = str_replace("{出发日期}", "", $content);
- $content = str_replace("{发车时间}", "", $content);
- $content = str_replace("{出发地}", "", $content);
- $content = str_replace("{目的地}", "", $content);
- $content = str_replace("{上车站点}", "", $content);
- }
- //$content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
- }
- return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
- }
|