|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /*
- Author:LB
- Compeny:Spiders Travel
- */
- require_once '../Common/Mysql.php';
- require_once '../Common/config_api.inc';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- $USER_ID=getUserId();
- if ($USER_ID ===false){
- echo json_encode(array("code"=>"1","info"=>"用户未登录"));
- exit;
- }
- $data = array();
- //$USER_ID=1;
- $pdo=conn();
-
- $run_id=isset($_POST['run_id'])?$_POST['run_id']:0;
- $bus_order_id=isset($_POST['bus_order_id'])?$_POST['bus_order_id']:0;
- if ( $run_id == 0 || $bus_order_id == 0){
- echo json_encode(array("code"=>"1","info"=>"参数不正确"));
- exit;
- }
-
-
-
- $search_start_sql = " SELECT PROD_START_STATION_RES_ID, count(ID) as passenger_num FROM order_main
- 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";
-
- $search_end_sql = " SELECT PROD_END_STATION_RES_ID, count(ID) as passenger_num FROM order_main
- 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";
-
- $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 ";
-
- $up_passenger = array();
- $result=$pdo->query($search_start_sql);
- writeLog($search_start_sql);
- if( !$result ) {
- echo json_encode(array("code"=>"1","info"=>"参数不正确"));
- exit;
- } else {
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- foreach ($rowset as $row_info) {
- $up_passenger[$row_info["PROD_START_STATION_RES_ID"]] = $row_info["passenger_num"];
- }
- }
-
- $down_passenger = array();
- $result=$pdo->query($search_end_sql);
- writeLog($search_end_sql);
- if( !$result ) {
- echo json_encode(array("code"=>"1","info"=>"参数不正确"));
- exit;
- } else {
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- foreach ($rowset as $row_info) {
- $down_passenger[$row_info["PROD_END_STATION_RES_ID"]] = $row_info["passenger_num"];
- }
- }
-
- $run_station = array();
- $result=$pdo->query($search_run_station);
- writeLog($search_run_station);
- if( !$result ) {
- echo json_encode(array("code"=>"1","info"=>"参数不正确"));
- exit;
- } else {
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
-
- foreach ($rowset as $row_info) {
- $station_res_id = $row_info["STATION_RES_ID"];
- $row_info["up_num"] = isset($up_passenger[$station_res_id]) ? $up_passenger[$station_res_id] : 0;
- $row_info["down_num"] = isset($down_passenger[$station_res_id]) ? $down_passenger[$station_res_id] : 0;
- $run_station[] = $row_info;
- }
- }
-
- echo json_encode(array("code"=>"0","data"=>$run_station));
- exit;
|