|
- <?php
- header("Access-Control-Allow-Origin:*");
- $pdo=conn();
-
- $ticket = $_POST['tickets'];
- $run_id = $_POST['run_id'];
- $line_id = $_POST['line_id'];
- $start_id = empty($_POST['start_id'])?0:$_POST['start_id'];
- $end_id = empty($_POST['end_id'])?0:$_POST['end_id'];
-
-
- //获取班次信息
- //$ticket = "{152564,6,07:30,991,13:00,100.00}|{152565,6,07:30,993,13:40,100.00}|{152566,6
- //,07:30,990,12:45,100.00}|{152567,6,07:30,992,13:25,100.00}|{152568,6,07:30,989,12:30,100.00}|{152569
- //,1,08:00,993,13:40,100.00}|{152570,1,08:00,990,12:45,100.00}|{152571,1,08:00,992,13:25,100.00}|{152572
- //,1,08:00,989,12:30,100.00}|{152573,1,08:00,991,13:00,100.00}";
-
-
- //$run_id = 169143;
- //$line_id = 152248;
- //$price = 100.00;
- //$start_id = 1;
- //$end_id = 990;
-
- //获取已选班次从某出发地到某目的地的票种信息
-
- //选中的票种
- $tic = array();
- $ticket = explode("|",$ticket);
-
- foreach($ticket as $k => $v){
- $v = ltrim($v,'{');
- $v = rtrim($v,'}');
- $ticket[$k] = explode(",",$v);
- if($ticket[$k][1] == $start_id && $ticket[$k][3] == $end_id){
- $tic = $ticket[$k];
- }
- }
- if($start_id == 0 || $end_id == 0){
- $tic = $ticket[0];
- }
-
- $youhui = $_COOKIE['youhui'];
-
- if(count($tic) > 0){
-
- //往返票
-
-
- $go_tick_id = $tic[0];
- $sql = "select prod_id from opera_product where parent_id = " . $line_id . " and ticket_mark = 2";
- $result = $pdo->query($sql);
- $go_ticket_id = $result->fetchAll(PDO::FETCH_ASSOC);
- if(count($go_ticket_id) > 0){
- $go_ticket_array = array();
- foreach($go_ticket_id as $v){
- $go_ticket_array[] = $v['prod_id'];
- }
-
- if($youhui == 1){
- $sql = "select a.prod_id from opera_product_property as a,opera_product_property as b
- where a.prod_id = b.prod_id
- and a. prod_id in (" . implode(",",$go_ticket_array) . ") and a.type_id = 112 and a.property = " . $start_id . " and b.type_id= 113 and b.property = " . $end_id;
-
- $result = $pdo->query($sql);
- $go_ticket = $result->fetchAll(PDO::FETCH_ASSOC);
-
- $list['back_back_id'] = $go_ticket[0]['prod_id'];
- }else{
- $list['back_back_id'] = "不支持往返票价";
- }
-
- }else{
- $list['back_back_id'] = "没有往返票";
- }
-
-
- $price = $tic[5];
- //获取选定票种的信息,进而获得该票种的数量和价格
- $sql = "select a.res_id,a.seq_id,a.seat_type,a.total_count,a.saled_count
- from run_stock as a,(select seq_id from run_stock where run_id = " . $run_id . " and res_id = " . $start_id . " and seat_type = 72 and cancel_flag = 0 and prod_id = " . $line_id . ") as b,(select seq_id from run_stock where run_id = " . $run_id . " and res_id = " . $end_id . " and seat_type = 72 and cancel_flag = 0 and prod_id = " . $line_id . ") as c
- where a.run_id = " . $run_id . " and a.seat_type = 72 and a.cancel_flag = 0 and a.prod_id = " . $line_id . " and a.seq_id >= b.seq_id and a.seq_id < c.seq_id order by seq_id";
-
- $result = $pdo->query($sql);
-
- if($result){
-
- $stock = $result->fetchAll(PDO::FETCH_ASSOC);
-
- if(count($stock) > 0) {
- $tickets_array = array();
- foreach($stock as $k => $v){
- $tickets_array[] = $v['total_count'] - $v['saled_count'];
- }
-
- asort($tickets_array);
- sort($tickets_array);
-
- $tickets = $tickets_array[0];
-
- $code = 0;
- $info = $CODE[0];
- $list['ticket_id'] = $tic[0];
- $list['site_type'] = "普通座";
- $list['num'] = $tickets;
- $list['price'] = $price;
- $list['total_price'] = $price * $tickets;
- }else{
-
- $code = 0;
- $info = $CODE[8];
- $list = "";
- }
-
- }else{
- $code = 1;
- $info = $CODE[1];
- $list = "";
- }
- }else{
- $code = 0;
- $info = $CODE[8];
- $list = "";
- }
-
-
-
-
- $json = array();
- $json['code'] = $code;
- $json['info'] = $info;
- $json['list'] = $list;
- //print_r($json);
-
- echo json_encode($json);
-
-
- ?>
|