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.
 
 
 
 

88 lines
2.7 KiB

  1. <?php
  2. require_once '../st-xm/Common/Mysql.php';
  3. header("Access-Control-Allow-Origin:*");
  4. //test
  5. //$_POST['auth_code'] = "abcdefg";
  6. //$_POST['run_code'] = "201743_152691";
  7. //end of test
  8. $auth_code=isset($_POST['auth_code'])? $_POST['auth_code']:false;
  9. $run_code=isset($_POST['run_code'])? $_POST['run_code']:false;
  10. $return_data = array();
  11. $return_data['code']='201';
  12. if( $auth_code == false || $run_code == false ) {
  13. $return_data['code']='401';
  14. echo json_encode($return_data);
  15. exit();
  16. }
  17. $pdo=conn();
  18. $sql=" SELECT user_name,user_psd,user_auth_code FROM api_auth_code WHERE user_auth_code='".$auth_code."' ";
  19. $result=$pdo->query($sql);
  20. $rowset=$result->fetchAll();
  21. $result->closeCursor();
  22. if( false == $rowset ) {
  23. $return_data['code']='400';
  24. echo json_encode($return_data);
  25. exit();
  26. }
  27. $param_run_code = $run_code;
  28. $run_code_array = explode("_",$run_code);
  29. $run_code = $run_code_array[0];
  30. $sql2 = " SELECT * FROM run_main WHERE RUN_ID = {$run_code} AND RUN_STATUS=138 ";
  31. $result=$pdo->query($sql2);
  32. $rowset=$result->fetchAll();
  33. $result->closeCursor();
  34. $return_data['code']='201';
  35. if( $rowset == false ) {
  36. $return_data['code']='501';
  37. echo json_encode($return_data);
  38. exit();
  39. }
  40. $run_main_info = $rowset[0];
  41. $sql3 = " SELECT * FROM run_bus WHERE RUN_ID = {$run_code} ";
  42. $result=$pdo->query($sql3);
  43. $result_array=$result->fetchAll();
  44. $result->closeCursor();
  45. $run_bus_array = array();
  46. foreach( $result_array as $run_bus_info ) {
  47. if( !isset($run_bus_array[$run_bus_info["RUN_ID"]]) ) {
  48. $run_bus_array[$run_bus_info["RUN_ID"]] = array();
  49. }
  50. $run_bus_array[$run_bus_info["RUN_ID"]][] = $run_bus_info;
  51. }
  52. $data_array = array();
  53. $return_data["run_code"] = $param_run_code;
  54. $return_data["can_book"] = 1;
  55. $return_data["is_active"] = 1;
  56. $return_data["pre_days"] = $run_main_info["PRE_SALE_DAY"];
  57. if( !$run_bus_array[$run_main_info["RUN_ID"]] ) {
  58. $return_data["bus_no"] = "以实际情况为准";
  59. $return_data["total_count"] = 0;
  60. $return_data["saled_count"] = 0;
  61. $return_data["remain_count"] = 0;
  62. } else {
  63. $return_data["bus_no"] = mb_strlen($run_bus_array[$run_main_info["RUN_ID"]][0]["SEND_BUS_NO"]) > 0 ? $run_bus_array[$run_main_info["RUN_ID"]][0]["SEND_BUS_NO"] : "以实际情况为准";
  64. $total_count = 0;
  65. $saled_count = 0;
  66. $remain_count = 0;
  67. foreach( $run_bus_array[$run_main_info["RUN_ID"]] as $run_bus_info ) {
  68. $total_count += $run_bus_info["SEAT_COUNT"];
  69. $saled_count += $run_bus_info["SALED_COUNT"];
  70. }
  71. $remain_count = $total_count - $saled_count;
  72. $return_data["total_count"] = $total_count;
  73. $return_data["saled_count"] = $saled_count;
  74. $return_data["remain_count"] = $remain_count;
  75. }
  76. //print_r($return_data);exit();
  77. echo json_encode($return_data);
  78. exit();