You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

99 lines
4.9 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. //巴士每天发短信提醒明天用户
  7. require_once __DIR__ . '/../Common/Mysql.php';
  8. require_once __DIR__ . '/../Common/config_api.inc';
  9. require_once __DIR__ . '/../Common/sinaAPI.php';
  10. if (ALLOW_ORIGIN)
  11. header("Access-Control-Allow-Origin:*");
  12. $not_send_array = array(
  13. 451874,451875,451868,451869
  14. );
  15. $next_hour = date("Y-m-d H:i", strtotime("+1 hours"));
  16. $next_2hour = date("Y-m-d H:i", strtotime("+2 hours"));
  17. $pdo = conn();
  18. if (is_object($pdo)) {
  19. $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;";
  20. // $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;";
  21. // $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A inner join appoint_send_message as B on A.PARENT_ORDER_ID = B.order_id and B.cancel_flag = 0 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 group by A.PARENT_ORDER_ID;";
  22. $result = $pdo -> query($sql);
  23. writeLog("search sql ::" . $sql);
  24. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  25. $result -> closeCursor();
  26. // $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;";
  27. // $result = $pdo -> query($sql);
  28. // $rowset2 = $result -> fetchAll(PDO::FETCH_ASSOC);
  29. // $result -> closeCursor();
  30. // $order_id_array = array();
  31. // foreach( $rowset as $v ) {
  32. // $order_id_array[] = $v['ORDER_ID'];
  33. // }
  34. // foreach( $rowset2 as $v ) {
  35. // if( !in_array( $v['ORDER_ID'],$order_id_array ) ) {
  36. // $rowset[] = $v;
  37. // }
  38. // }
  39. }
  40. $send_message_array = array();
  41. $current_time = date("Y-m-d H:i:s");
  42. if ($rowset) {
  43. writeLog("check_car_travel_remind.php ::" . json_encode($rowset));
  44. if (SEND_MESSAGE == true) {
  45. foreach ($rowset as $v) {
  46. $order_id = $v['ORDER_ID'];
  47. $send_message_array[] = $order_id;
  48. $res_content = get_msg_info($order_id);
  49. if($res_content == false) {continue;}
  50. $name = isset($res_content[0]) ? $res_content[0] : "";
  51. $tel = isset($res_content[1]) ? $res_content[1] : "";
  52. // $tel=15639834000;
  53. $content = isset($res_content[2]) ? $res_content[2] : "";
  54. writeLog("短信模板内容:【" . $content . "】");
  55. $response = sendTelMessage($tel, $name, $content, $order_id);
  56. $comment_type=0;
  57. $comment_text="";
  58. $send_success = $response;
  59. $pdo_send_msg = conn();
  60. $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}' )";
  61. $pdo_send_msg->exec( $sql1 );
  62. writeLog("check_car_travel_remind.php HT_ADD_MSG_COMMENT()::" . $sql1);
  63. if( $send_success != 0 ) {
  64. $warning_tel = "13816608252,18652972567,13918071837,18817501483";
  65. $warning_txt = "以下用户出行提醒短信发送失败:{$name}({$tel}) 订单号:{$order_id}";
  66. sendTelMessage($warning_tel, $name, $warning_txt, $order_id);
  67. }
  68. }
  69. }
  70. }
  71. $order_id_list = implode( ",", $send_message_array );
  72. $post_data['order_id'] = "{$order_id_list}";
  73. $post_data['order_status'] = "455";
  74. send_post("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data);
  75. function get_msg_info($ORDER_ID) {
  76. $url='http://'. CS1_DOMAIN. '/api/msg/get-msg-info2';
  77. $sendInfo=array();
  78. $sendInfo['order_id']=$ORDER_ID;
  79. $sendInfo['msg_type']='ota';
  80. $res_content = httpRequest($url,$sendInfo);
  81. $result_array = json_decode($res_content,true);
  82. if( $result_array["code"] != 0 ) {
  83. return false;
  84. }
  85. return array(isset($result_array['name']) ? $result_array['name'] : "", isset($result_array['mobile']) ? $result_array['mobile'] : "", isset($result_array['content']) ? $result_array['content'] : "短信错误,联系客服!!!");
  86. }