選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

179 行
7.4 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. $user_type = 0;
  4. $pdo=conn();
  5. $run_id = $_POST['run_id'];
  6. $start_area_id = $_POST['start_area_id'];
  7. $end_area_id = $_POST['end_area_id'];
  8. $start_area = " and a.property = " . $start_area_id;
  9. $end_area = " and b.property = " . $end_area_id;
  10. $back = $_POST['back'];
  11. $youhui = $_COOKIE['youhui'];
  12. if($back == 1 || $youhui == 0){
  13. $back = "0,1";
  14. }
  15. // $run_id = 322478 ;
  16. // $start_area_id = 850;
  17. // $end_area_id = 791;
  18. // $start_area = " and a.property = 850 ";
  19. // $end_area = " and b.property = 791 ";
  20. // $user_type = 0;
  21. $sql = "select area_name from base_area where id = " . $start_area_id;
  22. $result = $pdo->query($sql);
  23. $start_area_name = $result->fetchAll(PDO::FETCH_ASSOC);
  24. $start_area_name = $start_area_name[0]['area_name'];
  25. $sql = "select area_name from base_area where id = " . $end_area_id;
  26. $result = $pdo->query($sql);
  27. $end_area_name = $result->fetchAll(PDO::FETCH_ASSOC);
  28. $end_area_name = $end_area_name[0]['area_name'];
  29. $sql = "select prod_id,run_date from run_main where run_status = 138 and run_id = " . $run_id;
  30. $result1 = $pdo->query($sql);
  31. $sql = "select start_time,station_res_id from run_station where run_id = " . $run_id;
  32. $result2 = $pdo->query($sql);
  33. if($result1 && $result2){
  34. $line_id = $result1->fetchAll(PDO::FETCH_ASSOC);
  35. $station_time = $result2->fetchAll(PDO::FETCH_ASSOC);
  36. if(count($line_id) == 1 && count($station_time) > 0){
  37. //日期
  38. $date = $line_id[0]['run_date'];
  39. //站点索引,时间为值
  40. $station = array();
  41. //站点ID数组
  42. $res_id = array();
  43. //站点索引,名字为值
  44. $res = array();
  45. foreach($station_time as $station_info){
  46. $station[$station_info['station_res_id']] = $station_info['start_time'];
  47. $res_id[] = $station_info['station_res_id'];
  48. }
  49. $sql = "select res_id,res_name from base_resource where id in(" . implode(",",$res_id) . ")";
  50. $result = $pdo->query($sql);
  51. $res_name = $result->fetchAll(PDO::FETCH_ASSOC);
  52. foreach($res_name as $res_info){
  53. $res[$res_info['res_id']] = $res_info['res_name'];
  54. }
  55. $line_id = $line_id[0]['prod_id'];
  56. $sql = "select a.prod_id,b.bus_type
  57. from opera_product as a,(select prod_id,bus_type from opera_product where cancel_flag = 0 and prod_id = " . $line_id . ") as b
  58. 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";
  59. $result = $pdo->query($sql);
  60. $ticket = $result->fetchAll(PDO::FETCH_ASSOC);
  61. if($back == 2 && count($ticket) == 0){
  62. $sql = "select a.prod_id,b.bus_type
  63. from opera_product as a,(select prod_id,bus_type from opera_product where cancel_flag = 0 and prod_id = " . $line_id . ") as b
  64. 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";
  65. $result = $pdo->query($sql);
  66. $ticket = $result->fetchAll(PDO::FETCH_ASSOC);
  67. }
  68. if(count($ticket) > 0){
  69. foreach($ticket as $v){
  70. $ticket_id[] = $v['prod_id'];
  71. $bus_type[] = $v['bus_type'];
  72. }
  73. $bus_type = $bus_type[0] == 0 ? 255 : $bus_type[0];
  74. $sql = "select cus_price,cus_price,prod_id from opera_product_price where prod_id in (" . implode(",",$ticket_id) . ")";
  75. $result = $pdo->query($sql);
  76. $price = $result->fetchAll(PDO::FETCH_ASSOC);
  77. //价格-票种数据
  78. $price_array = array();
  79. foreach($price as $price_info){
  80. if($user_type == 0){
  81. $price_array[$price_info['prod_id']] = $price_info['cus_price'];
  82. }else{
  83. $price_array[$price_info['prod_id']] = $price_info['prod_price'];
  84. }
  85. }
  86. $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
  87. where a.prod_id = b.prod_id and a.prod_id = c.prod_id and a.prod_id = d.prod_id
  88. 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) . ")";
  89. $result = $pdo->query($sql);
  90. $ticket_array = $result->fetchAll(PDO::FETCH_ASSOC);
  91. //符合目的地出发地的票种信息
  92. $tic_array = array();
  93. foreach($ticket_array as $ticket_array_info) {
  94. $tic_array[$ticket_array_info['prod_id']]['up_name'] = $res[$ticket_array_info['up']]."(".$station[$ticket_array_info['up']].")";
  95. $tic_array[$ticket_array_info['prod_id']]['down_name'] = $res[$ticket_array_info['down']]."(".$station[$ticket_array_info['down']].")";
  96. $tic_array[$ticket_array_info['prod_id']]['price'] = $price_array[$ticket_array_info['prod_id']];
  97. $tic_array[$ticket_array_info['prod_id']] = array_merge($ticket_array_info,$tic_array[$ticket_array_info['prod_id']]);
  98. $start_order[$ticket_array_info['up']]['id'] = $ticket_array_info['up'];
  99. $start_order[$ticket_array_info['up']]['name'] = $tic_array[$ticket_array_info['prod_id']]['up_name'] ;
  100. $end_order[$ticket_array_info['down']]['id'] = $ticket_array_info['down'];
  101. $end_order[$ticket_array_info['down']]['name'] = $tic_array[$ticket_array_info['prod_id']]['down_name'];
  102. $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']] . "}";
  103. }
  104. $str = implode("|",$str);
  105. sort($start_order);
  106. sort($end_order);
  107. $code = 0;
  108. $info = $CODE[0];
  109. $list['date'] = $date;
  110. $list['run_id'] = $run_id;
  111. $list['line_id'] = $line_id;
  112. $list['start_area_name'] = $start_area_name;
  113. $list['end_area_name'] = $end_area_name;
  114. $list['ticket'] = $str;
  115. $list['start_order'] = $start_order;
  116. $list['end_order'] = $end_order;
  117. $list['bus_type'] = $bus_type;
  118. }else{
  119. $code = 0;
  120. $info = $CODE[9];
  121. $list = "";
  122. }
  123. }else{
  124. $code = 0;
  125. $info = $CODE[8];
  126. $list = "";
  127. }
  128. }else{
  129. $code = 1;
  130. $info = $CODE[1];
  131. $list = "";
  132. }
  133. $json = array();
  134. $json['code'] = $code;
  135. $json['info'] = $info;
  136. $json['list'] = $list;
  137. //print_r($json);
  138. echo json_encode($json);
  139. ?>