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.
 
 
 
 

58 lines
2.2 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. //载入配置文件和连接数据库
  4. $pdo = conn();
  5. //区分是普通乘客还是分销员 0普通,1分销
  6. $user_type = 0;
  7. //判断出发地 目的地 时间是否为空
  8. $start_area = empty($_POST['start_id']) ? "" : $_POST['start_id'];
  9. $end_area = empty($_POST['end_id']) ? "" : $_POST['end_id'];
  10. $run_date = empty($_POST['back_time']) ? date("Y-m-d", time() + 24 * 3600) : $_POST['back_time'];
  11. $line_type = $_POST['line_type'];
  12. $now_date = date("Y-m-d", time());
  13. //$user_id = $_COOKIE['user_id'];
  14. //if($user_id == 136){
  15. // $line_id_arr = array(213344,213343,213342,213341,213340,213339,1579,1578,449887,451180);
  16. //}else{
  17. // $line_id_arr = array(213344,213343,213342,213341,213340,213339,1579,1578,451188,451237,449887,451180);
  18. //}
  19. $sql = "SELECT
  20. m.run_id,
  21. m.run_time
  22. FROM
  23. run_main AS m,
  24. run_prod AS p,
  25. opera_line AS l
  26. WHERE
  27. m.run_id = p.run_id
  28. AND m.prod_id = l.line_id
  29. AND p.start_station_area_id = " . $start_area . "
  30. AND p.end_station_area_id = " . $end_area . "
  31. AND m.run_date >= '" . $now_date . "'
  32. AND m.run_date = '" . $run_date . "'
  33. AND m.run_status = 138
  34. and case l.sale_expired_type when 321 then if(date_add(date_add(m.run_date,interval -1 day), interval (substring_index(l.sale_expired_time,':',1)*60 + substring_index(l.sale_expired_time,':',-1)) minute) > now(),0=0,0=1)
  35. when 322 then if(date_add(m.run_date, interval m.run_minutes -(substring_index(l.sale_expired_time,':',1)*60 + substring_index(l.sale_expired_time,':',-1)) minute)>= now(),0=0,0=1)
  36. else 0=0 end
  37. AND l.line_type = " . $line_type . "
  38. GROUP BY m.run_id
  39. order by m.run_time";
  40. $result = $pdo->query($sql);
  41. $run_info = $result->fetchAll(PDO::FETCH_ASSOC);
  42. if(count($run_info) == 0){
  43. $code = '1';
  44. $info = '没有返程班次';
  45. }else{
  46. $code = '0';
  47. $info = '返回班次成功';
  48. }
  49. $json['code'] = $code;
  50. $json['info'] = $info;
  51. $json['list'] = $run_info;
  52. echo json_encode($json);
  53. ?>