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.

check_car_travel_remind.php 2.9 KiB

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. $pdo = conn();
  13. if (is_object($pdo)) {
  14. $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.ORDER_PROD_TYPE IN (81,82) and A.CANCEL_FLAG=0 and A.RUN_DATE=DATE_ADD(current_date,INTERVAL 1 day) group by A.PARENT_ORDER_ID;";
  15. $result = $pdo -> query($sql);
  16. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  17. $result -> closeCursor();
  18. }
  19. $send_message_array = array();
  20. if ($rowset) {
  21. writeLog("check_car_travel_remind.php ::" . json_encode($rowset));
  22. if (SEND_MESSAGE == true) {
  23. foreach ($rowset as $v) {
  24. $order_id = $v['ORDER_ID'];
  25. $send_message_array[] = $order_id;
  26. $res_content = get_msg_info($order_id);
  27. if($res_content == false) {continue;}
  28. $name = isset($res_content[0]) ? $res_content[0] : "";
  29. $tel = isset($res_content[1]) ? $res_content[1] : "";
  30. // $tel=15639834000;
  31. $content = isset($res_content[2]) ? $res_content[2] : "";
  32. writeLog("短信模板内容:【" . $content . "】");
  33. $response = sendTelMessage($tel, $name, $content, $order_id);
  34. writeLog(json_encode($response));
  35. $comment_type=0;
  36. $comment_text="";
  37. $send_success = (int)$response;
  38. $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})";
  39. $result1 = $pdo -> query($sql1);
  40. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  41. $result1 -> closeCursor();
  42. writeLog("check_car_travel_remind.php HT_ADD_MSG_COMMENT()::" . $sql1);
  43. if( $send_success != 0 ) {
  44. $warning_tel = "13816608252,18652972567,13918071837,18817501483";
  45. $warning_txt = "以下用户出行提醒短信发送失败:{$name}({$tel}) 订单号:{$order_id}";
  46. sendTelMessage($warning_tel, $name, $warning_txt, $order_id);
  47. }
  48. }
  49. }
  50. }
  51. $order_id_list = implode( ",", $send_message_array );
  52. $post_data['order_id'] = "{$order_id_list}";
  53. $post_data['order_status'] = "455";
  54. send_post("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data);
  55. function get_msg_info($ORDER_ID) {
  56. $url='http://'. CS1_DOMAIN. '/api/msg/get-msg-info2';
  57. $sendInfo=array();
  58. $sendInfo['order_id']=$ORDER_ID;
  59. $sendInfo['msg_type']='ota';
  60. $res_content = httpRequest($url,$sendInfo);
  61. $result_array = json_decode($res_content,true);
  62. if( $result_array["code"] != 0 ) {
  63. return false;
  64. }
  65. return array(isset($result_array['name']) ? $result_array['name'] : "", isset($result_array['mobile']) ? $result_array['mobile'] : "", isset($result_array['content']) ? $result_array['content'] : "短信错误,联系客服!!!");
  66. }