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.
 
 
 
 

128 lines
6.8 KiB

  1. <?php
  2. require_once '../st-xm/Common/Mysql.php';
  3. header("Access-Control-Allow-Origin:*");
  4. $pdo=conn1();
  5. $sql = " SELECT DISTINCT PARENT_ORDER_ID FROM order_main WHERE RUN_ID = {$_GET["run_id"]} AND RUN_BUS_ORDER_ID={$_GET["bus_order_id"]} AND CANCEL_FLAG = 0 ";
  6. $result=$pdo->query($sql);
  7. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  8. $result->closeCursor();
  9. if( $rowset == false ) {
  10. echo "该班次目前无乘客!";
  11. }
  12. echo "确认发送以下短信吗? ";
  13. echo "<form action='send_message.php' method='post'><input type='hidden' name='run_id' value='{$_GET["run_id"]}'><input type='hidden' name='bus_order_id' value='{$_GET["bus_order_id"]}'><input type='submit' value='确认发送'></form>";
  14. echo "<hr />";
  15. foreach( $rowset as $row_info ) {
  16. $order_id=$row_info['PARENT_ORDER_ID'];
  17. $res_content=get_msg_info($order_id);
  18. $name=$res_content[0];
  19. $tel=$res_content[1];
  20. $content=$res_content[2];
  21. echo "<b>订单号:{$order_id} 联系人:{$name} 手机号码:{$tel}</b><br />";
  22. echo $content."<hr />";
  23. }
  24. echo "<form action='send_message.php' method='post'><input type='hidden' name='run_id' value='{$_GET["run_id"]}'><input type='hidden' name='bus_order_id' value='{$_GET["bus_order_id"]}'><input type='submit' value='确认发送'></form>";
  25. exit();
  26. function get_msg_info($ORDER_ID) {
  27. $msg_pdo = conn1();
  28. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  29. $content = '';
  30. if (is_object($msg_pdo)) {
  31. $msg_result = $msg_pdo -> query($msg_sql);
  32. $i = 1;
  33. $data = array();
  34. if ($msg_result) {
  35. $data['code'] = "0";
  36. $data['info'] = "";
  37. do {
  38. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  39. if ($i == 1) {
  40. $data['seat'] = isset($row) ? $row : array();
  41. } else if ($i == 2) {
  42. $data['run_info'] = isset($row) ? $row : array();
  43. } else if ($i == 3) {
  44. $data['driver'] = isset($row) ? $row : array();
  45. } else {
  46. }
  47. $i++;
  48. } while($msg_result->nextRowset());
  49. }
  50. $json_obj = json_decode(json_encode($data), TRUE);
  51. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  52. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  53. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  54. // 出发前一天
  55. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  56. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  57. $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}出发,请提前达到上车点{上车站点},车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  58. if ($seat) {
  59. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  60. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  61. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  62. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  63. if ($seat_name == "") {
  64. $content = str_replace("{座位号}", "", $content);
  65. } else {
  66. $content = str_replace("{座位号}", $seat_name, $content);
  67. }
  68. }else{
  69. $content = str_replace("{座位号}", "", $content);
  70. }
  71. if ($driver) {
  72. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  73. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  74. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  75. if ($bus_no == "") {
  76. $content = str_replace(",车牌号{车牌号}", "", $content);
  77. } else {
  78. $content = str_replace("{车牌号}", $bus_no, $content);
  79. }
  80. if ($driver_name == "") {
  81. $content = str_replace(",司机电话{司机电话}", "", $content);
  82. } else {
  83. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  84. $driver_name_mobile = $driver_xing . $driver_mobile;
  85. $content = str_replace("{司机电话}", $driver_name_mobile, $content);
  86. }
  87. } else {
  88. $content = str_replace(",车牌号{车牌号}", "", $content);
  89. $content = str_replace(",司机电话{司机电话}", "", $content);
  90. }
  91. if ($run_info) {
  92. $order_count = $run_info['order_count'];
  93. $start_date = $run_info['start_date'];
  94. $start_time = $run_info['start_time'];
  95. $parent_order_id = $run_info['parent_order_id'];
  96. $end_date = $run_info['end_date'];
  97. $start_area = $run_info['start_area'];
  98. $end_area = $run_info['end_area'];
  99. $res_name = $run_info['res_name'];
  100. $prod_name = $run_info['prod_name'];
  101. $customer_name = $run_info['customer_name'];
  102. $customer_mobile = $run_info['customer_mobile'];
  103. $content = str_replace("{出发日期}", $start_date, $content);
  104. $content = str_replace("{发车时间}", $start_time, $content);
  105. $content = str_replace("{出发地}", $start_area, $content);
  106. $content = str_replace("{目的地}", $end_area, $content);
  107. $content = str_replace("{上车站点}", $res_name, $content);
  108. //..判断千岛湖的特殊情况
  109. if(strpos($start_area,"千岛湖")!==false || strpos($end_area, "千岛湖")!==false){
  110. $content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  111. }
  112. }else{
  113. $content = str_replace("{出发日期}", "", $content);
  114. $content = str_replace("{发车时间}", "", $content);
  115. $content = str_replace("{出发地}", "", $content);
  116. $content = str_replace("{目的地}", "", $content);
  117. $content = str_replace("{上车站点}", "", $content);
  118. }
  119. }
  120. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
  121. }