You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

150 lines
4.8 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. if (ALLOW_ORIGIN)
  8. header("Access-Control-Allow-Origin:*");
  9. $pdo=conn();
  10. $userid=getUserId();
  11. if ($userid ===false){
  12. echo json_encode(array("code"=>1,"info"=>"用户未登录"));
  13. exit;
  14. }
  15. if($_GET){
  16. $method=$_GET['method'];
  17. if ($method=='getticket'){
  18. $orderid=$_GET['orderid'];
  19. $sql="call xm_order_get_ticket(".$userid.",'".$method."',".$orderid.",0,'',0,0)";
  20. $data=getData($pdo, $sql);
  21. if (empty($data)){
  22. echo json_encode(array("code"=>1,"info"=>"单号错误"));
  23. exit;
  24. }
  25. $data1=array();
  26. $data2=array();
  27. foreach ($data as $k=>$v){
  28. $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['line_code']=$v['line_code'];
  29. $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['line_name']=$v['parent_prod_name'];
  30. $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['start_area']=$v['start_area'];
  31. $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['end_area']=$v['end_area'];
  32. $data2['start_time']=$v['start_time'];
  33. $data2['car_number']=$v['car_no'];
  34. $data2['seat']=$v['seat_type'];
  35. $data2['ticket_name']=$v['crowd'];
  36. $data2['seat_number']=$v['seat_name'];
  37. $data2['if_print']=$v['print'];
  38. $data2['if_meal']=$v['meal'];
  39. $data2['if_bounce']=$v['bounce'];
  40. $data2['price']=$v['price'];
  41. $data2['parent_prod_id']=$v['parent_prod_id'];
  42. $data2['prod_id']=$v['prod_id'];
  43. $data2['order_id']=$v['order_id'];
  44. $data2['up_station_id']=$v['up_station_id'];
  45. $data2['down_station_id']=$v['down_station_id'];
  46. $data1[$v['parent_prod_id'].$v['start_area'].$v['end_area']]['tickets'][]=$data2;
  47. }
  48. //print_r($data1);
  49. $json=array("code"=>0,"info"=>"查询成功","order_no"=>$orderid);
  50. $json['line_info']=array_values($data1);
  51. }else if($method=='bounce'){
  52. $json=array("errcode"=>0,"errinfo"=>"退票成功");
  53. }else if($method=='meal'){
  54. $prodid=$_GET['prodid'];
  55. $meal_date=$_GET['meal_date'];
  56. $meal_up_id=$_GET['meal_up_id'];
  57. $meal_down_id=$_GET['meal_down_id'];
  58. $sql="call xm_order_get_ticket(".$userid.",'".$method."',0,".$prodid.",'".$meal_date."',$meal_up_id,$meal_down_id)";
  59. $data=getData($pdo, $sql);
  60. if (empty($data)){
  61. echo json_encode(array("code"=>1,"info"=>"查询为空"));
  62. exit;
  63. }
  64. $json=array("errcode"=>0,"errinfo"=>"改签显示");
  65. $data1=array();
  66. $data2=array();
  67. foreach ($data as $v){
  68. $json['line_info']['prod_id']=$v['PROD_ID'];
  69. $json['line_info']['run_id']=$v['RUN_ID'];
  70. $json['line_info']['line_code']=$v['property'];
  71. $json['line_info']['line_name']=$v['prod_name'];
  72. $json['line_info']['start_area']=$v['start_area']."(".$v['start_res_name'].")";
  73. $json['line_info']['end_area']=$v['end_area']."(".$v['end_res_name'].")";
  74. $json['line_info']['start_time']=$v['startdate'];
  75. $json['line_info']['departure_station'][$v['RUN_ID']]=$v['start_res_name']." ".$v['start_time'];
  76. $json['line_info']['destination_station'][$v['RUN_ID']]=$v['end_res_name']." ".$v['end_time'];
  77. $json['line_info']['seat']=$v['seat_type_name'];
  78. $json['line_info']['ticket_name']=$v['crowd'];
  79. $json['line_info']['seat_type_id']=$v['seat_type_id'];
  80. $json['line_info']['crowd_id']=$v['crowd_id'];
  81. $json['line_info']['price']=$v['price'];
  82. //$data1[$v['PROD_ID'].$v['RUN_ID']]['in_stock']=$v['in_stock'];
  83. if(isset($json['line_info']['in_stock'])){
  84. $json['line_info']['in_stock']+=$v['stock'];
  85. }else{
  86. $json['line_info']['in_stock']=$v['stock'];
  87. }
  88. }
  89. }else if($method=='confirm_meal'){
  90. $json=array("errcode"=>0,"errinfo"=>"改签成功");
  91. }else if($method=='mealticket'){
  92. $json=array("errcode"=>0,"errinfo"=>"改签票显示");
  93. $json['line_info']=array(
  94. 'line_code'=>'SHWZ - J04',
  95. 'line_name'=>'(上海 - 舟山)',
  96. 'start_area'=>'上海(黄埔集散)',
  97. 'end_area'=>'舟山',
  98. 'start_time'=>'2016.05.20 07:00',
  99. 'car_number'=>'222',
  100. 'seat'=>'普通',
  101. 'ticket_name'=>'成人',
  102. 'seat_number'=>10,
  103. 'if_print'=>0,
  104. 'if_meal'=>0,
  105. 'if_bounce'=>0,
  106. 'price'=>130
  107. );
  108. }else if($method=='search'){
  109. $json=array("errcode"=>0,"errinfo"=>"查询成功");
  110. $json['line_info']=array(
  111. 'line_code'=>'SHWZ - J04',
  112. 'line_name'=>'(上海 - 舟山)',
  113. 'start_area'=>'上海(黄埔集散)',
  114. 'end_area'=>'舟山',
  115. 'start_time'=>'2016.05.21',
  116. 'departure_station'=>array(
  117. '黄埔集散07:00',
  118. '黄埔集散07:30',
  119. '黄埔集散08:00'
  120. ),
  121. 'destination_station'=>array(
  122. '舟山11:00',
  123. '舟山12:00',
  124. '舟山13:00',
  125. '舟山14:00'
  126. ),
  127. 'seat'=>'普通',
  128. 'ticket_name'=>'成人',
  129. 'price'=>120,
  130. 'in_stock'=>100,
  131. );
  132. }
  133. }
  134. echo json_encode($json);exit;
  135. function getData($pdo,$sql){
  136. $result=$pdo->query($sql);
  137. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  138. return $rowset;
  139. }