|
- <?php
- require_once '../st-xm/Common/Mysql.php';
- header("Access-Control-Allow-Origin:*");
-
- $pdo=conn1();
- $sql = " SELECT DISTINCT PARENT_ORDER_ID FROM order_main WHERE RUN_ID = {$_GET["run_id"]} AND RUN_BUS_ORDER_ID={$_GET["bus_order_id"]} AND CANCEL_FLAG = 0 ";
- $result=$pdo->query($sql);
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- if( $rowset == false ) {
- echo "该班次目前无乘客!";
- }
- echo "确认发送以下短信吗? ";
- echo "<form action='send_message.php' method='post'><input type='hidden' name='run_id' value='{$_GET["run_id"]}'><input type='hidden' name='bus_order_id' value='{$_GET["bus_order_id"]}'><input type='submit' value='确认发送'></form>";
- echo "<hr />";
- foreach( $rowset as $row_info ) {
- $order_id=$row_info['PARENT_ORDER_ID'];
- $res_content=get_msg_info($order_id);
- $name=$res_content[0];
- $tel=$res_content[1];
- $content=$res_content[2];
- echo "<b>订单号:{$order_id} 联系人:{$name} 手机号码:{$tel}</b><br />";
- echo $content."<hr />";
- }
- echo "<form action='send_message.php' method='post'><input type='hidden' name='run_id' value='{$_GET["run_id"]}'><input type='hidden' name='bus_order_id' value='{$_GET["bus_order_id"]}'><input type='submit' value='确认发送'></form>";
-
- exit();
- function get_msg_info($ORDER_ID) {
- $msg_pdo = conn1();
- $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();
-
- // 出发前一天
- // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}出发,请提前达到上车点{上车站点},车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
- 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){
- $content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
- }
- }else{
- $content = str_replace("{出发日期}", "", $content);
- $content = str_replace("{发车时间}", "", $content);
- $content = str_replace("{出发地}", "", $content);
- $content = str_replace("{目的地}", "", $content);
- $content = str_replace("{上车站点}", "", $content);
- }
-
-
- }
- return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
- }
|