|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- //巴士每天发短信提醒明天用户
- require_once __DIR__ . '/../Common/Mysql.php';
- require_once __DIR__ . '/../Common/config_api.inc';
- require_once __DIR__ . '/../Common/sinaAPI.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
-
- $not_send_array = array(
- 451874,451875,451868,451869
- );
-
- $next_hour = date("Y-m-d H:i", strtotime("+1 hours"));
- $next_2hour = date("Y-m-d H:i", strtotime("+2 hours"));
-
-
- $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.PROD_ID <> 380001 and A.PARENT_PROD_ID NOT IN (".implode( ",", $not_send_array ).") and A.ORDER_PROD_TYPE IN (81,82) and A.CANCEL_FLAG=0 and DATE_FORMAT(CONCAT( A.PROD_START_STATION_DATE,\" \", A.PROD_START_STATION_TIME), \"%Y-%m-%d %H:%i\") = \"{$next_hour}\" AND A.AGENT_LEVEL=1 group by A.PARENT_ORDER_ID;";
- // $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A where A.ORDER_STATUS<>148 and A.PROD_ID <> 380001 and A.PARENT_PROD_ID NOT IN (".implode( ",", $not_send_array ).") and A.ORDER_PROD_TYPE IN (81,82) and A.CANCEL_FLAG=0 and CONCAT( A.PROD_START_STATION_DATE,\" \", A.PROD_START_STATION_TIME) >= \"{$next_hour}\" AND CONCAT( A.PROD_START_STATION_DATE,\" \", A.PROD_START_STATION_TIME) < \"{$next_2hour}\" AND A.AGENT_LEVEL=1 group by A.PARENT_ORDER_ID;";
- $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A where A.ORDER_STATUS<>148 and A.PROD_ID <> 380001 and A.PARENT_PROD_ID NOT IN (".implode( ",", $not_send_array ).") and A.ORDER_PROD_TYPE IN (81,82) and A.CANCEL_FLAG=0 and A.RUN_DATE=DATE_ADD(current_date,INTERVAL 1 day) AND A.AGENT_LEVEL=1 AND A.SOURCE_MAIN_CORP_ID=37 group by A.PARENT_ORDER_ID;";
-
- $result = $pdo -> query($sql);
- writeLog("search sql ::" . $sql);
- $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
- $result -> closeCursor();
-
- // $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A where A.ORDER_STATUS<>148 and A.PROD_ID <> 380001 and A.PARENT_PROD_ID NOT IN (".implode( ",", $not_send_array ).") and A.ORDER_PROD_TYPE IN (81,82) and A.CANCEL_FLAG=0 and A.RUN_DATE=DATE_ADD(current_date,INTERVAL 1 day) AND A.AGENT_LEVEL=1 AND A.OUTSIDE_SALE_ORG_ID in ( 164,147 ) group by A.PARENT_ORDER_ID;";
- // $result = $pdo -> query($sql);
- // $rowset2 = $result -> fetchAll(PDO::FETCH_ASSOC);
- // $result -> closeCursor();
- // $order_id_array = array();
- // foreach( $rowset as $v ) {
- // $order_id_array[] = $v['ORDER_ID'];
- // }
- // foreach( $rowset2 as $v ) {
- // if( !in_array( $v['ORDER_ID'],$order_id_array ) ) {
- // $rowset[] = $v;
- // }
- // }
- }
-
- $send_message_array = array();
- $current_time = date("Y-m-d H:i:s");
- if ($rowset) {
- writeLog("check_car_travel_remind.php ::" . json_encode($rowset));
- if (SEND_MESSAGE == true) {
- foreach ($rowset as $v) {
- $order_id = $v['ORDER_ID'];
- $send_message_array[] = $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);
-
- $comment_type=0;
- $comment_text="";
- $send_success = $response;
-
- $pdo_send_msg = conn();
- $sql1 = "insert into order_send_message(ORDER_ID,SEND_MOBILE,SEND_MESSAGE,SEND_TIME,SEND_ERROR,CREATE_USER_ID,CREATE_TIME,UPDATE_USER_ID,UPDATE_TIME) VALUES ({$order_id},'{$tel}', '{$content}','{$current_time}', {$send_success}, 2,'{$current_time}', 2,'{$current_time}' )";
- $pdo_send_msg->exec( $sql1 );
-
- 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);
- }
- }
- }
- }
-
- $order_id_list = implode( ",", $send_message_array );
- $post_data['order_id'] = "{$order_id_list}";
- $post_data['order_status'] = "455";
- send_post("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data);
-
- function get_msg_info($ORDER_ID) {
- $url='http://'. CS1_DOMAIN. '/api/msg/get-msg-info2';
- $sendInfo=array();
- $sendInfo['order_id']=$ORDER_ID;
- $sendInfo['msg_type']='ota';
- $res_content = httpRequest($url,$sendInfo);
- $result_array = json_decode($res_content,true);
- if( $result_array["code"] != 0 ) {
- return false;
- }
- return array(isset($result_array['name']) ? $result_array['name'] : "", isset($result_array['mobile']) ? $result_array['mobile'] : "", isset($result_array['content']) ? $result_array['content'] : "短信错误,联系客服!!!");
- }
|