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.
 
 
 
 

143 lines
5.8 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. //巴士每天发短信提醒明天用户
  7. exit();
  8. require_once __DIR__ . '/../Common/Mysql.php';
  9. if (ALLOW_ORIGIN)
  10. header("Access-Control-Allow-Origin:*");
  11. $pdo = conn();
  12. if (is_object($pdo)) {
  13. $sql = "select A.PARENT_ORDER_ID as ORDER_ID from order_main as A where A.ORDER_STATUS<>148 and A.CANCEL_FLAG=0 and A.RUN_DATE=DATE_ADD(current_date,INTERVAL 1 day) group by A.PARENT_ORDER_ID;";
  14. $result = $pdo -> query($sql);
  15. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  16. $result -> closeCursor();
  17. }
  18. if ($rowset) {
  19. writeLog("check_car_travel_remind.php ::" . json_encode($rowset));
  20. if (SEND_MESSAGE == true) {
  21. foreach ($rowset as $v) {
  22. $order_id = $v['ORDER_ID'];
  23. $res_content = get_msg_info($order_id);
  24. $name = isset($res_content[0]) ? $res_content[0] : "";
  25. $tel = isset($res_content[1]) ? $res_content[1] : "";
  26. $tel='18652972567';
  27. $content = isset($res_content[2]) ? $res_content[2] : "";
  28. writeLog("短信模板内容:【" . $content . "】");
  29. $response = sendTelMessage($tel, $name, $content, $order_id);
  30. writeLog(json_encode($response));
  31. $comment_type=0;
  32. $comment_text="";
  33. $send_success = (int)$response;
  34. $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})";
  35. $result1 = $pdo->query($sql1);
  36. $rowset1 = $result1->fetchAll(PDO::FETCH_ASSOC);
  37. $result1->closeCursor();
  38. writeLog("check_car_travel_remind.php HT_ADD_MSG_COMMENT()::" . $sql1);
  39. }
  40. }
  41. }
  42. function get_msg_info($ORDER_ID) {
  43. $msg_pdo = conn();
  44. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  45. $content = '';
  46. if (is_object($msg_pdo)) {
  47. $msg_result = $msg_pdo -> query($msg_sql);
  48. $i = 1;
  49. $data = array();
  50. if ($msg_result) {
  51. $data['code'] = "0";
  52. $data['info'] = "";
  53. do {
  54. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  55. if ($i == 1) {
  56. $data['seat'] = isset($row) ? $row : array();
  57. } else if ($i == 2) {
  58. $data['run_info'] = isset($row) ? $row : array();
  59. } else if ($i == 3) {
  60. $data['driver'] = isset($row) ? $row : array();
  61. } else {
  62. }
  63. $i++;
  64. } while($msg_result->nextRowset());
  65. }
  66. $json_obj = json_decode(json_encode($data), TRUE);
  67. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  68. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  69. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  70. // 出发前一天
  71. $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  72. if ($seat) {
  73. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  74. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  75. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  76. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  77. if ($seat_name == "") {
  78. $content = str_replace("{座位号}", "", $content);
  79. } else {
  80. $content = str_replace("{座位号}", $seat_name, $content);
  81. }
  82. }else{
  83. $content = str_replace("{座位号}", "", $content);
  84. }
  85. if ($driver) {
  86. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  87. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  88. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  89. if ($bus_no == "") {
  90. $content = str_replace(",车牌号{车牌号}", "", $content);
  91. } else {
  92. $content = str_replace("{车牌号}", $bus_no, $content);
  93. }
  94. if ($driver_name == "") {
  95. $content = str_replace(",司机电话{司机电话}", "", $content);
  96. } else {
  97. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  98. $driver_name_mobile = $driver_xing . $driver_mobile;
  99. $content = str_replace("{司机电话}", $driver_name_mobile, $content);
  100. }
  101. } else {
  102. $content = str_replace(",车牌号{车牌号}", "", $content);
  103. $content = str_replace(",司机电话{司机电话}", "", $content);
  104. }
  105. if ($run_info) {
  106. $order_count = $run_info['order_count'];
  107. $start_date = $run_info['start_date'];
  108. $start_time = $run_info['start_time'];
  109. $parent_order_id = $run_info['parent_order_id'];
  110. $end_date = $run_info['end_date'];
  111. $start_area = $run_info['start_area'];
  112. $end_area = $run_info['end_area'];
  113. $res_name = $run_info['res_name'];
  114. $prod_name = $run_info['prod_name'];
  115. $customer_name = $run_info['customer_name'];
  116. $customer_mobile = $run_info['customer_mobile'];
  117. $content = str_replace("{出发日期}", $start_date, $content);
  118. $content = str_replace("{发车时间}", $start_time, $content);
  119. $content = str_replace("{出发地}", $start_area, $content);
  120. $content = str_replace("{目的地}", $end_area, $content);
  121. $content = str_replace("{上车站点}", $res_name, $content);
  122. //..判断千岛湖的特殊情况
  123. if(strpos($start_area,"千岛湖")!==false || strpos($end_area, "千岛湖")!==false){
  124. $content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  125. }
  126. }else{
  127. $content = str_replace("{出发日期}", "", $content);
  128. $content = str_replace("{发车时间}", "", $content);
  129. $content = str_replace("{出发地}", "", $content);
  130. $content = str_replace("{目的地}", "", $content);
  131. $content = str_replace("{上车站点}", "", $content);
  132. }
  133. }
  134. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
  135. }