Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

138 wiersze
4.4 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. $pdo=conn();
  4. $ticket = $_POST['tickets'];
  5. $run_id = $_POST['run_id'];
  6. $line_id = $_POST['line_id'];
  7. $start_id = empty($_POST['start_id'])?0:$_POST['start_id'];
  8. $end_id = empty($_POST['end_id'])?0:$_POST['end_id'];
  9. //获取班次信息
  10. //$ticket = "{152564,6,07:30,991,13:00,100.00}|{152565,6,07:30,993,13:40,100.00}|{152566,6
  11. //,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
  12. //,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
  13. //,1,08:00,989,12:30,100.00}|{152573,1,08:00,991,13:00,100.00}";
  14. //$run_id = 169143;
  15. //$line_id = 152248;
  16. //$price = 100.00;
  17. //$start_id = 1;
  18. //$end_id = 990;
  19. //获取已选班次从某出发地到某目的地的票种信息
  20. //选中的票种
  21. $tic = array();
  22. $ticket = explode("|",$ticket);
  23. foreach($ticket as $k => $v){
  24. $v = ltrim($v,'{');
  25. $v = rtrim($v,'}');
  26. $ticket[$k] = explode(",",$v);
  27. if($ticket[$k][1] == $start_id && $ticket[$k][3] == $end_id){
  28. $tic = $ticket[$k];
  29. }
  30. }
  31. if($start_id == 0 || $end_id == 0){
  32. $tic = $ticket[0];
  33. }
  34. $youhui = $_COOKIE['youhui'];
  35. if(count($tic) > 0){
  36. //往返票
  37. $go_tick_id = $tic[0];
  38. $sql = "select prod_id from opera_product where parent_id = " . $line_id . " and ticket_mark = 2";
  39. $result = $pdo->query($sql);
  40. $go_ticket_id = $result->fetchAll(PDO::FETCH_ASSOC);
  41. if(count($go_ticket_id) > 0){
  42. $go_ticket_array = array();
  43. foreach($go_ticket_id as $v){
  44. $go_ticket_array[] = $v['prod_id'];
  45. }
  46. if($youhui == 1){
  47. $sql = "select a.prod_id from opera_product_property as a,opera_product_property as b
  48. where a.prod_id = b.prod_id
  49. 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;
  50. $result = $pdo->query($sql);
  51. $go_ticket = $result->fetchAll(PDO::FETCH_ASSOC);
  52. $list['back_back_id'] = $go_ticket[0]['prod_id'];
  53. }else{
  54. $list['back_back_id'] = "不支持往返票价";
  55. }
  56. }else{
  57. $list['back_back_id'] = "没有往返票";
  58. }
  59. $price = $tic[5];
  60. //获取选定票种的信息,进而获得该票种的数量和价格
  61. $sql = "select a.res_id,a.seq_id,a.seat_type,a.total_count,a.saled_count
  62. 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
  63. 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";
  64. $result = $pdo->query($sql);
  65. if($result){
  66. $stock = $result->fetchAll(PDO::FETCH_ASSOC);
  67. if(count($stock) > 0) {
  68. $tickets_array = array();
  69. foreach($stock as $k => $v){
  70. $tickets_array[] = $v['total_count'] - $v['saled_count'];
  71. }
  72. asort($tickets_array);
  73. sort($tickets_array);
  74. $tickets = $tickets_array[0];
  75. $code = 0;
  76. $info = $CODE[0];
  77. $list['ticket_id'] = $tic[0];
  78. $list['site_type'] = "普通座";
  79. $list['num'] = $tickets;
  80. $list['price'] = $price;
  81. $list['total_price'] = $price * $tickets;
  82. }else{
  83. $code = 0;
  84. $info = $CODE[8];
  85. $list = "";
  86. }
  87. }else{
  88. $code = 1;
  89. $info = $CODE[1];
  90. $list = "";
  91. }
  92. }else{
  93. $code = 0;
  94. $info = $CODE[8];
  95. $list = "";
  96. }
  97. $json = array();
  98. $json['code'] = $code;
  99. $json['info'] = $info;
  100. $json['list'] = $list;
  101. //print_r($json);
  102. echo json_encode($json);
  103. ?>