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.bak 9.1 KiB

преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. //巴士每天发短信提醒明天用户
  7. require_once __DIR__ . '/../Common/Mysql.php';
  8. require_once __DIR__ . '/../Common/sinaAPI.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. if($res_content == false) {continue;}
  25. $name = isset($res_content[0]) ? $res_content[0] : "";
  26. $tel = isset($res_content[1]) ? $res_content[1] : "";
  27. // $tel=15639834000;
  28. $content = isset($res_content[2]) ? $res_content[2] : "";
  29. writeLog("短信模板内容:【" . $content . "】");
  30. $response = sendTelMessage($tel, $name, $content, $order_id);
  31. writeLog(json_encode($response));
  32. $comment_type=0;
  33. $comment_text="";
  34. $send_success = (int)$response;
  35. $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})";
  36. $result1 = $pdo -> query($sql1);
  37. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  38. $result1 -> closeCursor();
  39. writeLog("check_car_travel_remind.php HT_ADD_MSG_COMMENT()::" . $sql1);
  40. if( $send_success != 0 ) {
  41. $warning_tel = "13816608252,18652972567,13918071837,18817501483";
  42. $warning_txt = "以下用户出行提醒短信发送失败:{$name}({$tel}) 订单号:{$order_id}";
  43. sendTelMessage($warning_tel, $name, $warning_txt, $order_id);
  44. }
  45. }
  46. }
  47. }
  48. function get_msg_info($ORDER_ID) {
  49. $no_send_message_line = array( 152690, 152703 );
  50. $msg_pdo = conn();
  51. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  52. $content = '';
  53. if (is_object($msg_pdo)) {
  54. $msg_result = $msg_pdo -> query($msg_sql);
  55. $i = 1;
  56. $data = array();
  57. if ($msg_result) {
  58. $data['code'] = "0";
  59. $data['info'] = "";
  60. do {
  61. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  62. if ($i == 1) {
  63. $data['seat'] = isset($row) ? $row : array();
  64. } else if ($i == 2) {
  65. $data['run_info'] = isset($row) ? $row : array();
  66. } else if ($i == 3) {
  67. $data['driver'] = isset($row) ? $row : array();
  68. } else {
  69. }
  70. $i++;
  71. } while($msg_result->nextRowset());
  72. }
  73. $json_obj = json_decode(json_encode($data), TRUE);
  74. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  75. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  76. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  77. $sp_bus_1 = array(179546,179523,202560,199565,201176,201187,179854,199464,199514,199545,202203,202682,203480,203491,203641,205086,205856);
  78. $sp_bus_2 = array(203464,205059,205096,205653,202910,201718,179440,179453,202353,202357,202993,202985,202697);
  79. $sp_bus_3 = array(201057,179612,205427,200912,204132,179872,199499,202253);
  80. $sp_bus_4 = array(211064,211069,211074,211080,211086,211090,211095,206009,207967);
  81. $sp_bus_5 = array(198577,202780,205408,205169,205674,204115,204127,201724,204074,200567,180012,205721,202703,206750);
  82. $sp_bus_6 = array(199746,202399,202375,205703,207718,205866,179990,203694,180026);
  83. $sp_bus_7 = array(180026,202234,208020,208024,208028,208040,208047,208051,208055,208059,208063,208067,211043,211058,208071);
  84. if( in_array($ORDER_ID,$sp_bus_1) ) {
  85. $driver = array( 'bus_no'=> "沪ED6603", 'driver_name'=> "俞国明", 'driver_mobile'=> "13524363301");
  86. } else if( in_array($ORDER_ID,$sp_bus_2) ) {
  87. $driver = array( 'bus_no'=> "沪DL4157", 'driver_name'=> "闵瑞", 'driver_mobile'=> "13357844310");
  88. } else if( in_array($ORDER_ID,$sp_bus_3) ) {
  89. $driver = array( 'bus_no'=> "沪D60528", 'driver_name'=> "杨文新", 'driver_mobile'=> "15901965353");
  90. } else if( in_array($ORDER_ID,$sp_bus_4) ) {
  91. $driver = array( 'bus_no'=> "浙A5F855", 'driver_name'=> "鲍君健", 'driver_mobile'=> "18857179668");
  92. } else if( in_array($ORDER_ID,$sp_bus_5) ) {
  93. $driver = array( 'bus_no'=> "浙AF2839", 'driver_name'=> "徐建淳", 'driver_mobile'=> "13706719887");
  94. } else if( in_array($ORDER_ID,$sp_bus_6) ) {
  95. $driver = array( 'bus_no'=> "沪BR8815", 'driver_name'=> "金刚", 'driver_mobile'=> "13681807766");
  96. } else if( in_array($ORDER_ID,$sp_bus_7) ) {
  97. $driver = array( 'bus_no'=> "沪BQ7386", 'driver_name'=> "陈继国", 'driver_mobile'=> "1391619079");
  98. }
  99. // 出发前一天
  100. <<<<<<< .mine
  101. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  102. // $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}{座位号}出发,请提前达到上车点{上车站点},凭短信上车,车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  103. $content = "您预订的{出发日期}{出发地}-{目的地}的车次即将在明日{发车时间}出发,请提前10分钟到达上车点{上车站点},车牌号{车牌号},司机电话{司机电话},预祝您旅途愉快!";
  104. =======
  105. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张即将于明日{发车时间}出发,车牌号{车牌号},司机电话{司机电话}。请提前10分钟到达上车站点{上车站点}:{上车站点详细地址},并提前点开电子车票准备乘车{$short_url}。请关注微信公众号【蜘蛛出行】,查看车辆及站点照片。";
  106. >>>>>>> .r3971
  107. if ($seat) {
  108. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  109. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  110. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  111. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  112. if ($seat_name == "") {
  113. $content = str_replace("{座位号}", "", $content);
  114. } else {
  115. $content = str_replace("{座位号}", $seat_name, $content);
  116. }
  117. }else{
  118. $content = str_replace("{座位号}", "", $content);
  119. }
  120. if ($driver) {
  121. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  122. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  123. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  124. if ($bus_no == "") {
  125. $content = str_replace(",车牌号{车牌号}", "", $content);
  126. } else {
  127. $content = str_replace("{车牌号}", $bus_no, $content);
  128. }
  129. if ($driver_name == "") {
  130. $content = str_replace(",司机电话{司机电话}", "", $content);
  131. } else {
  132. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  133. $driver_name_mobile = $driver_xing . $driver_mobile;
  134. $content = str_replace("{司机电话}", $driver_name_mobile, $content);
  135. }
  136. } else {
  137. $content = str_replace(",车牌号{车牌号}", "", $content);
  138. $content = str_replace(",司机电话{司机电话}", "", $content);
  139. }
  140. if ($run_info) {
  141. $order_count = $run_info['order_count'];
  142. $start_date = $run_info['start_date'];
  143. $start_time = $run_info['start_time'];
  144. $parent_order_id = $run_info['parent_order_id'];
  145. $end_date = $run_info['end_date'];
  146. $start_area = $run_info['start_area'];
  147. $end_area = $run_info['end_area'];
  148. $res_name = $run_info['res_name'];
  149. $prod_name = $run_info['prod_name'];
  150. $customer_name = $run_info['customer_name'];
  151. $customer_mobile = $run_info['customer_mobile'];
  152. $content = str_replace("{出发日期}", $start_date, $content);
  153. $content = str_replace("{发车时间}", $start_time, $content);
  154. $content = str_replace("{出发地}", $start_area, $content);
  155. $content = str_replace("{目的地}", $end_area, $content);
  156. $content = str_replace("{上车站点}", $res_name, $content);
  157. //..判断千岛湖的特殊情况
  158. if(strpos($start_area,"天目湖")!==false || strpos($end_area, "天目湖")!==false || in_array($run_info['parent_prod_id'], $no_send_message_line) ){
  159. return false;
  160. }
  161. }else{
  162. return false;
  163. $content = str_replace("{出发日期}", "", $content);
  164. $content = str_replace("{发车时间}", "", $content);
  165. $content = str_replace("{出发地}", "", $content);
  166. $content = str_replace("{目的地}", "", $content);
  167. $content = str_replace("{上车站点}", "", $content);
  168. }
  169. //$content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  170. }
  171. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误!!!");
  172. }