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); $name = isset($res_content[0]) ? $res_content[0] : ""; $tel = isset($res_content[1]) ? $res_content[1] : ""; $tel='18652972567'; $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); } } } function get_msg_info($ORDER_ID) { $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(); // 出发前一天 $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 : "短信错误!!!"); }