|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- require_once '../Common/Mysql.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- $pdo=conn();
- $userid=getUserId();
- if ($userid ===false){
- echo json_encode(array("code"=>1,"info"=>"用户未登录"));
- exit;
- }
- if($_GET){
- $method=$_GET['method'];
- if ($method=='getticket'){
- $orderid=$_GET['orderid'];
- $sql="call xm_order_get_ticket(".$userid.",'".$method."',".$orderid.",0,'',0,0)";
- $data=getData($pdo, $sql);
- if (empty($data)){
- echo json_encode(array("code"=>1,"info"=>"单号错误"));
- exit;
- }
- $data1=array();
- $data2=array();
- foreach ($data as $k=>$v){
- $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['line_code']=$v['line_code'];
- $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['line_name']=$v['parent_prod_name'];
- $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['start_area']=$v['start_area'];
- $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['end_area']=$v['end_area'];
-
- $data2['start_time']=$v['start_time'];
- $data2['car_number']=$v['car_no'];
- $data2['seat']=$v['seat_type'];
- $data2['ticket_name']=$v['crowd'];
- $data2['seat_number']=$v['seat_name'];
- $data2['if_print']=$v['print'];
- $data2['if_meal']=$v['meal'];
- $data2['if_bounce']=$v['bounce'];
- $data2['price']=$v['price'];
- $data2['parent_prod_id']=$v['parent_prod_id'];
- $data2['prod_id']=$v['prod_id'];
- $data2['order_id']=$v['order_id'];
- $data2['up_station_id']=$v['up_station_id'];
- $data2['down_station_id']=$v['down_station_id'];
-
- $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['tickets'][]=$data2;
- }
- //print_r($data1);
-
- $json=array("code"=>0,"info"=>"查询成功","order_no"=>$orderid);
- $json['line_info']=array_values($data1);
- }else if($method=='bounce'){
- $json=array("errcode"=>0,"errinfo"=>"退票成功");
- }else if($method=='meal'){
- $prodid=$_GET['prodid'];
- $meal_date=$_GET['meal_date'];
- $meal_up_id=$_GET['meal_up_id'];
- $meal_down_id=$_GET['meal_down_id'];
- $sql="call xm_order_get_ticket(".$userid.",'".$method."',0,".$prodid.",'".$meal_date."',$meal_up_id,$meal_down_id)";
- $data=getData($pdo, $sql);
- if (empty($data)){
- echo json_encode(array("code"=>1,"info"=>"查询为空"));
- exit;
- }
- $json=array("errcode"=>0,"errinfo"=>"改签显示");
- $data1=array();
- $data2=array();
- foreach ($data as $v){
- $json['line_info']['prod_id']=$v['PROD_ID'];
- $json['line_info']['run_id']=$v['RUN_ID'];
- $json['line_info']['line_code']=$v['property'];
- $json['line_info']['line_name']=$v['prod_name'];
- $json['line_info']['start_area']=$v['start_area']."(".$v['start_res_name'].")";
- $json['line_info']['end_area']=$v['end_area']."(".$v['end_res_name'].")";
- $json['line_info']['start_time']=$v['startdate'];
-
-
- $json['line_info']['departure_station'][$v['RUN_ID']]=$v['start_res_name']." ".$v['start_time'];
- $json['line_info']['destination_station'][$v['RUN_ID']]=$v['end_res_name']." ".$v['end_time'];
- $json['line_info']['seat']=$v['seat_type_name'];
- $json['line_info']['ticket_name']=$v['crowd'];
- $json['line_info']['seat_type_id']=$v['seat_type_id'];
- $json['line_info']['crowd_id']=$v['crowd_id'];
- $json['line_info']['price']=$v['price'];
- //$data1[$v['PROD_ID'].$v['RUN_ID']]['in_stock']=$v['in_stock'];
- if(isset($json['line_info']['in_stock'])){
- $json['line_info']['in_stock']+=$v['stock'];
- }else{
- $json['line_info']['in_stock']=$v['stock'];
- }
-
- }
-
- }else if($method=='confirm_meal'){
- $json=array("errcode"=>0,"errinfo"=>"改签成功");
- }else if($method=='mealticket'){
- $json=array("errcode"=>0,"errinfo"=>"改签票显示");
- $json['line_info']=array(
- 'line_code'=>'SHWZ - J04',
- 'line_name'=>'(上海 - 舟山)',
- 'start_area'=>'上海(黄埔集散)',
- 'end_area'=>'舟山',
- 'start_time'=>'2016.05.20 07:00',
-
- 'car_number'=>'222',
- 'seat'=>'普通',
- 'ticket_name'=>'成人',
- 'seat_number'=>10,
- 'if_print'=>0,
- 'if_meal'=>0,
- 'if_bounce'=>0,
-
- 'price'=>130
-
- );
- }else if($method=='search'){
- $json=array("errcode"=>0,"errinfo"=>"查询成功");
- $json['line_info']=array(
- 'line_code'=>'SHWZ - J04',
- 'line_name'=>'(上海 - 舟山)',
- 'start_area'=>'上海(黄埔集散)',
- 'end_area'=>'舟山',
- 'start_time'=>'2016.05.21',
- 'departure_station'=>array(
- '黄埔集散07:00',
- '黄埔集散07:30',
- '黄埔集散08:00'
-
- ),
- 'destination_station'=>array(
- '舟山11:00',
- '舟山12:00',
- '舟山13:00',
- '舟山14:00'
- ),
- 'seat'=>'普通',
- 'ticket_name'=>'成人',
- 'price'=>120,
- 'in_stock'=>100,
- );
- }
- }
- echo json_encode($json);exit;
- function getData($pdo,$sql){
- $result=$pdo->query($sql);
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- return $rowset;
- }
|