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.
 
 
 
 

134 rivejä
6.9 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 = {$_POST["run_id"]} AND RUN_BUS_ORDER_ID={$_POST["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 "以下短信已经发送成功<hr />";
  13. foreach( $rowset as $row_info ) {
  14. $order_id=$row_info['PARENT_ORDER_ID'];
  15. $res_content=get_msg_info($order_id);
  16. $name=$res_content[0];
  17. $tel=$res_content[1];
  18. $content=$res_content[2];
  19. echo $content."<hr />";
  20. $response = sendTelMessage($tel, $name, $content, $order_id);
  21. $comment_type=0;
  22. $comment_text="";
  23. $send_success = (int)$response;
  24. $sql1 = "CALL HT_ADD_MSG_COMMENT(1,'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
  25. $result1 = $pdo->query($sql1);
  26. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  27. $result1 -> closeCursor();
  28. }
  29. echo "发送完成!!";
  30. exit();
  31. function get_msg_info($ORDER_ID) {
  32. $msg_pdo = conn1();
  33. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  34. $content = '';
  35. if (is_object($msg_pdo)) {
  36. $msg_result = $msg_pdo -> query($msg_sql);
  37. $i = 1;
  38. $data = array();
  39. if ($msg_result) {
  40. $data['code'] = "0";
  41. $data['info'] = "";
  42. do {
  43. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  44. if ($i == 1) {
  45. $data['seat'] = isset($row) ? $row : array();
  46. } else if ($i == 2) {
  47. $data['run_info'] = isset($row) ? $row : array();
  48. } else if ($i == 3) {
  49. $data['driver'] = isset($row) ? $row : array();
  50. } else {
  51. }
  52. $i++;
  53. } while($msg_result->nextRowset());
  54. }
  55. $json_obj = json_decode(json_encode($data), TRUE);
  56. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  57. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  58. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  59. // 出发前一天
  60. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  61. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  62. $content = "您预订的{出发日期}{出发地}({上车站点})-{目的地}({下车站点})的车次即将在明日{发车时间}出发,请提前达到上车点{上车站点},车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  63. if ($seat) {
  64. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  65. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  66. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  67. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  68. if ($seat_name == "") {
  69. $content = str_replace("{座位号}", "", $content);
  70. } else {
  71. $content = str_replace("{座位号}", $seat_name, $content);
  72. }
  73. }else{
  74. $content = str_replace("{座位号}", "", $content);
  75. }
  76. if ($driver) {
  77. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  78. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  79. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  80. if ($bus_no == "") {
  81. $content = str_replace(",车牌号{车牌号}", "", $content);
  82. } else {
  83. $content = str_replace("{车牌号}", $bus_no, $content);
  84. }
  85. if ($driver_name == "") {
  86. $content = str_replace(",司机电话{司机电话}", "", $content);
  87. } else {
  88. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  89. $driver_name_mobile = $driver_xing . $driver_mobile;
  90. $content = str_replace("{司机电话}", $driver_name_mobile, $content);
  91. }
  92. } else {
  93. $content = str_replace(",车牌号{车牌号}", "", $content);
  94. $content = str_replace(",司机电话{司机电话}", "", $content);
  95. }
  96. if ($run_info) {
  97. $order_count = $run_info['order_count'];
  98. $start_date = $run_info['start_date'];
  99. $start_time = $run_info['start_time'];
  100. $parent_order_id = $run_info['parent_order_id'];
  101. $end_date = $run_info['end_date'];
  102. $start_area = $run_info['start_area'];
  103. $end_area = $run_info['end_area'];
  104. $res_name = $run_info['res_name'];
  105. $prod_name = $run_info['prod_name'];
  106. $customer_name = $run_info['customer_name'];
  107. $customer_mobile = $run_info['customer_mobile'];
  108. $content = str_replace("{出发日期}", $start_date, $content);
  109. $content = str_replace("{发车时间}", $start_time, $content);
  110. $content = str_replace("{出发地}", $start_area, $content);
  111. $content = str_replace("{目的地}", $end_area, $content);
  112. $content = str_replace("{上车站点}", $res_name, $content);
  113. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  114. //..判断千岛湖的特殊情况
  115. //if(strpos($start_area,"千岛湖")!==false || strpos($end_area, "千岛湖")!==false){
  116. // $content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  117. //}
  118. }else{
  119. $content = str_replace("{出发日期}", "", $content);
  120. $content = str_replace("{发车时间}", "", $content);
  121. $content = str_replace("{出发地}", "", $content);
  122. $content = str_replace("{目的地}", "", $content);
  123. $content = str_replace("{上车站点}", "", $content);
  124. }
  125. }
  126. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
  127. }