|
- <?php
- header("Access-Control-Allow-Origin:*");
-
- $user_type = 0;
- $pdo=conn();
-
- $run_id = $_POST['run_id'];
- $start_area_id = $_POST['start_area_id'];
- $end_area_id = $_POST['end_area_id'];
- $start_area = " and a.property = " . $start_area_id;
- $end_area = " and b.property = " . $end_area_id;
-
- $back = $_POST['back'];
- $youhui = $_COOKIE['youhui'];
- if($back == 1 || $youhui == 0){
- $back = "0,1";
- }
-
- // $run_id = 322478 ;
-
- // $start_area_id = 850;
- // $end_area_id = 791;
-
- // $start_area = " and a.property = 850 ";
- // $end_area = " and b.property = 791 ";
- // $user_type = 0;
-
- $sql = "select area_name from base_area where id = " . $start_area_id;
- $result = $pdo->query($sql);
- $start_area_name = $result->fetchAll(PDO::FETCH_ASSOC);
- $start_area_name = $start_area_name[0]['area_name'];
-
- $sql = "select area_name from base_area where id = " . $end_area_id;
- $result = $pdo->query($sql);
- $end_area_name = $result->fetchAll(PDO::FETCH_ASSOC);
- $end_area_name = $end_area_name[0]['area_name'];
-
- $sql = "select prod_id,run_date from run_main where run_status = 138 and run_id = " . $run_id;
- $result1 = $pdo->query($sql);
-
- $sql = "select start_time,station_res_id from run_station where run_id = " . $run_id;
- $result2 = $pdo->query($sql);
-
- if($result1 && $result2){
-
- $line_id = $result1->fetchAll(PDO::FETCH_ASSOC);
-
- $station_time = $result2->fetchAll(PDO::FETCH_ASSOC);
-
- if(count($line_id) == 1 && count($station_time) > 0){
-
- //日期
- $date = $line_id[0]['run_date'];
- //站点索引,时间为值
- $station = array();
-
- //站点ID数组
- $res_id = array();
-
- //站点索引,名字为值
- $res = array();
-
- foreach($station_time as $station_info){
- $station[$station_info['station_res_id']] = $station_info['start_time'];
- $res_id[] = $station_info['station_res_id'];
- }
-
- $sql = "select res_id,res_name from base_resource where id in(" . implode(",",$res_id) . ")";
- $result = $pdo->query($sql);
-
- $res_name = $result->fetchAll(PDO::FETCH_ASSOC);
-
-
- foreach($res_name as $res_info){
- $res[$res_info['res_id']] = $res_info['res_name'];
- }
-
- $line_id = $line_id[0]['prod_id'];
-
- $sql = "select a.prod_id,b.bus_type
- from opera_product as a,(select prod_id,bus_type from opera_product where cancel_flag = 0 and prod_id = " . $line_id . ") as b
- where a.parent_id = b.prod_id and a.if_disabled = 0 and a.ticket_mark in (" . $back . ") and a.prod_type = 82 and a.cancel_flag = 0";
- $result = $pdo->query($sql);
- $ticket = $result->fetchAll(PDO::FETCH_ASSOC);
-
-
- if($back == 2 && count($ticket) == 0){
- $sql = "select a.prod_id,b.bus_type
- from opera_product as a,(select prod_id,bus_type from opera_product where cancel_flag = 0 and prod_id = " . $line_id . ") as b
- where a.parent_id = b.prod_id and a.if_disabled = 0 and a.ticket_mark in (0,1) and a.prod_type = 82 and a.cancel_flag = 0";
- $result = $pdo->query($sql);
- $ticket = $result->fetchAll(PDO::FETCH_ASSOC);
- }
-
- if(count($ticket) > 0){
- foreach($ticket as $v){
- $ticket_id[] = $v['prod_id'];
- $bus_type[] = $v['bus_type'];
- }
-
- $bus_type = $bus_type[0] == 0 ? 255 : $bus_type[0];
-
- $sql = "select cus_price,cus_price,prod_id from opera_product_price where prod_id in (" . implode(",",$ticket_id) . ")";
- $result = $pdo->query($sql);
- $price = $result->fetchAll(PDO::FETCH_ASSOC);
-
- //价格-票种数据
- $price_array = array();
- foreach($price as $price_info){
- if($user_type == 0){
- $price_array[$price_info['prod_id']] = $price_info['cus_price'];
- }else{
- $price_array[$price_info['prod_id']] = $price_info['prod_price'];
- }
- }
-
- $sql = "select a.prod_id,a.property as s_area,b.property as e_area,c.property as up,d.property as down from opera_product_property as a,opera_product_property as b,opera_product_property as c,opera_product_property as d
- where a.prod_id = b.prod_id and a.prod_id = c.prod_id and a.prod_id = d.prod_id
- and a.type_id = 125 ".$start_area." and b.type_id= 126 ".$end_area." and c.type_id = 112 and d.type_id = 113 and a.prod_id in (" . implode(",",$ticket_id) . ")";
- $result = $pdo->query($sql);
- $ticket_array = $result->fetchAll(PDO::FETCH_ASSOC);
-
- //符合目的地出发地的票种信息
- $tic_array = array();
-
- foreach($ticket_array as $ticket_array_info) {
- $tic_array[$ticket_array_info['prod_id']]['up_name'] = $res[$ticket_array_info['up']]."(".$station[$ticket_array_info['up']].")";
- $tic_array[$ticket_array_info['prod_id']]['down_name'] = $res[$ticket_array_info['down']]."(".$station[$ticket_array_info['down']].")";
- $tic_array[$ticket_array_info['prod_id']]['price'] = $price_array[$ticket_array_info['prod_id']];
- $tic_array[$ticket_array_info['prod_id']] = array_merge($ticket_array_info,$tic_array[$ticket_array_info['prod_id']]);
-
- $start_order[$ticket_array_info['up']]['id'] = $ticket_array_info['up'];
- $start_order[$ticket_array_info['up']]['name'] = $tic_array[$ticket_array_info['prod_id']]['up_name'] ;
- $end_order[$ticket_array_info['down']]['id'] = $ticket_array_info['down'];
- $end_order[$ticket_array_info['down']]['name'] = $tic_array[$ticket_array_info['prod_id']]['down_name'];
-
- $str[] = "{" . $ticket_array_info['prod_id'] . "," . $ticket_array_info['up'] . "," . $station[$ticket_array_info['up']] . "," .$ticket_array_info['down'] . "," . $station[$ticket_array_info['down']] . "," . $price_array[$ticket_array_info['prod_id']] . "}";
- }
-
- $str = implode("|",$str);
-
- sort($start_order);
- sort($end_order);
-
- $code = 0;
- $info = $CODE[0];
- $list['date'] = $date;
- $list['run_id'] = $run_id;
- $list['line_id'] = $line_id;
- $list['start_area_name'] = $start_area_name;
- $list['end_area_name'] = $end_area_name;
- $list['ticket'] = $str;
- $list['start_order'] = $start_order;
- $list['end_order'] = $end_order;
- $list['bus_type'] = $bus_type;
- }else{
- $code = 0;
- $info = $CODE[9];
- $list = "";
- }
-
- }else{
- $code = 0;
- $info = $CODE[8];
- $list = "";
- }
- }else{
- $code = 1;
- $info = $CODE[1];
- $list = "";
- }
- $json = array();
- $json['code'] = $code;
- $json['info'] = $info;
- $json['list'] = $list;
- //print_r($json);
-
- echo json_encode($json);
- ?>
|