$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); ?>