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.

run_bus_passengers_static.php 2.8 KiB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. Author:LB
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. require_once '../Common/config_api.inc';
  8. if (ALLOW_ORIGIN)
  9. header("Access-Control-Allow-Origin:*");
  10. $USER_ID=getUserId();
  11. if ($USER_ID ===false){
  12. echo json_encode(array("code"=>"1","info"=>"用户未登录"));
  13. exit;
  14. }
  15. $data = array();
  16. //$USER_ID=1;
  17. $pdo=conn();
  18. $run_id=isset($_POST['run_id'])?$_POST['run_id']:0;
  19. $bus_order_id=isset($_POST['bus_order_id'])?$_POST['bus_order_id']:0;
  20. if ( $run_id == 0 || $bus_order_id == 0){
  21. echo json_encode(array("code"=>"1","info"=>"参数不正确"));
  22. exit;
  23. }
  24. $search_start_sql = " SELECT PROD_START_STATION_RES_ID, count(ID) as passenger_num FROM order_main
  25. WHERE RUN_ID = {$run_id} AND RUN_BUS_ORDER_ID = {$bus_order_id} AND AGENT_LEVEL=1 AND ORDER_STATUS IN (146,147) AND CANCEL_FLAG=0 GROUP BY PROD_START_STATION_RES_ID";
  26. $search_end_sql = " SELECT PROD_END_STATION_RES_ID, count(ID) as passenger_num FROM order_main
  27. WHERE RUN_ID = {$run_id} AND RUN_BUS_ORDER_ID = {$bus_order_id} AND AGENT_LEVEL=1 AND ORDER_STATUS IN (146,147) AND CANCEL_FLAG=0 GROUP BY PROD_END_STATION_RES_ID";
  28. $search_run_station = " SELECT rs.STATION_RES_ID,br.RES_NAME FROM run_station as rs left join base_resource as br on br.RES_ID= rs.STATION_RES_ID WHERE rs.RUN_ID={$run_id} ORDER BY rs.STATION_ORDER_ID ";
  29. $up_passenger = array();
  30. $result=$pdo->query($search_start_sql);
  31. writeLog($search_start_sql);
  32. if( !$result ) {
  33. echo json_encode(array("code"=>"1","info"=>"参数不正确"));
  34. exit;
  35. } else {
  36. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  37. $result->closeCursor();
  38. foreach ($rowset as $row_info) {
  39. $up_passenger[$row_info["PROD_START_STATION_RES_ID"]] = $row_info["passenger_num"];
  40. }
  41. }
  42. $down_passenger = array();
  43. $result=$pdo->query($search_end_sql);
  44. writeLog($search_end_sql);
  45. if( !$result ) {
  46. echo json_encode(array("code"=>"1","info"=>"参数不正确"));
  47. exit;
  48. } else {
  49. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  50. $result->closeCursor();
  51. foreach ($rowset as $row_info) {
  52. $down_passenger[$row_info["PROD_END_STATION_RES_ID"]] = $row_info["passenger_num"];
  53. }
  54. }
  55. $run_station = array();
  56. $result=$pdo->query($search_run_station);
  57. writeLog($search_run_station);
  58. if( !$result ) {
  59. echo json_encode(array("code"=>"1","info"=>"参数不正确"));
  60. exit;
  61. } else {
  62. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  63. $result->closeCursor();
  64. foreach ($rowset as $row_info) {
  65. $station_res_id = $row_info["STATION_RES_ID"];
  66. $row_info["up_num"] = isset($up_passenger[$station_res_id]) ? $up_passenger[$station_res_id] : 0;
  67. $row_info["down_num"] = isset($down_passenger[$station_res_id]) ? $down_passenger[$station_res_id] : 0;
  68. $run_station[] = $row_info;
  69. }
  70. }
  71. echo json_encode(array("code"=>"0","data"=>$run_station));
  72. exit;