Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

91 linhas
3.9 KiB

  1. <?php
  2. /*
  3. Author:ZSQ
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../../Common/Mysql.php';
  7. header("Access-Control-Allow-Origin:*");
  8. $lineStyle = isset($_POST['lineStyle']) ? $_POST['lineStyle'] : 0;
  9. $keywords = isset($_POST['keywords']) ? (empty($_POST['keywords'])?'':$_POST['keywords']) : '';
  10. $currpage = isset($_POST['currpage']) ? (empty($_POST['currpage']) ? 1 : $_POST['currpage']) : 1;
  11. $pagesize = isset($_POST['pagesize']) ? (empty($_POST['pagesize']) ? 1 : $_POST['pagesize']) : 10;
  12. $pdo = conn();
  13. $user_id = $_COOKIE['user_id'];
  14. $opera_org_id_sql = "select opera_org_id,main_corp_id from base_user where id = " . $user_id . " and cancel_flag = 0";
  15. $opera_org_id_result = $pdo->query($opera_org_id_sql);
  16. $rowset = $opera_org_id_result->fetchAll(PDO::FETCH_ASSOC);
  17. $opera_org_id = $rowset[0]['opera_org_id'];
  18. $main_corp_id = $rowset[0]['main_corp_id'];
  19. $and_sql = '';
  20. if ($opera_org_id != '') {
  21. $and_sql .= " and L.org_id in (" . $opera_org_id . ") ";
  22. }
  23. if ($main_corp_id != 0) {
  24. $and_sql .= " and L.main_corp_id in (" . $main_corp_id . ") ";
  25. }
  26. // $sql="CALL sp_get_line_list(".$lineStyle.",'".$keywords."',".$pagesize.",".$currpage.");";
  27. $sql = "SELECT L.LINE_ID as prod_id,
  28. L.LINE_CODE as property,
  29. L.LINE_NAME as prod_name,
  30. L.LINE_TYPE as bus_type,
  31. CASE L.LINE_TYPE WHEN 255 THEN '直通巴士' WHEN 256 THEN '穿梭巴士' WHEN 284 THEN '城际商务车' ELSE '' END AS bus_type_name,
  32. CASE L.IF_DISABLED WHEN 0 THEN '启用' ELSE '停用' END AS disabled_status,
  33. (select count(*) from opera_station where line_id = L.line_id and cancel_flag = 0) AS station_cnt , -- 站点数量
  34. ifnull(t.ticket_cnt,0) as ticket_cnt -- 票种数量
  35. FROM OPERA_LINE L left join
  36. (select line_id,count(*) as ticket_cnt
  37. from (select distinct line_id,start_station_area_id,end_station_area_id,seat_type,human_type,prod_price,cus_price
  38. from opera_tickets
  39. where TICKET_TYPE = 1 ) a
  40. group by line_id) T ON L.LINE_ID = T.line_id
  41. WHERE L.CANCEL_FLAG = 0
  42. AND IF(TRIM('" . $keywords . "')='',0=0,(L.LINE_CODE LIKE CONCAT('%','" . $keywords . "','%') OR L.LINE_NAME LIKE CONCAT('%','" . $keywords . "','%')))
  43. AND IF(" . $lineStyle . "=0,0=0,L.LINE_TYPE=" . $lineStyle . ")
  44. " . $and_sql . "
  45. GROUP BY L.LINE_ID,L.LINE_CODE,L.LINE_NAME,L.LINE_TYPE,L.IF_DISABLED
  46. ORDER BY L.LINE_ID desc
  47. limit " . ($currpage-1)*$pagesize . "," . $pagesize;
  48. $result = $pdo->query($sql);
  49. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  50. //$data = array();
  51. //do {
  52. // $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  53. // if ($rowset) {
  54. // $data[] = $rowset;
  55. // }
  56. //} while ($result->nextRowset());
  57. $count_sql = "SELECT L.LINE_ID as prod_id
  58. FROM OPERA_LINE L left join
  59. (select line_id,count(*) as ticket_cnt
  60. from (select distinct line_id,start_station_area_id,end_station_area_id,seat_type,human_type,prod_price,cus_price
  61. from opera_tickets
  62. where TICKET_TYPE = 1 ) a
  63. group by line_id) T ON L.LINE_ID = T.line_id
  64. WHERE L.CANCEL_FLAG = 0
  65. AND IF(TRIM('" . $keywords . "')='',0=0,(L.LINE_CODE LIKE CONCAT('%','" . $keywords . "','%') OR L.LINE_NAME LIKE CONCAT('%','" . $keywords . "','%')))
  66. AND IF(" . $lineStyle . "=0,0=0,L.LINE_TYPE=" . $lineStyle . ")
  67. " . $and_sql . "
  68. GROUP BY L.LINE_ID,L.LINE_CODE,L.LINE_NAME,L.LINE_TYPE,L.IF_DISABLED";
  69. $result = $pdo->query($count_sql);
  70. $count = $result->fetchAll(PDO::FETCH_ASSOC);
  71. $jason_array = array();
  72. $jason_array["code"] = 0;
  73. $jason_array["info"] = "";
  74. $jason_array["totalNum"] = count($count);//$data[0][0]["total"];
  75. $jason_array["list"] = $rowset;//array();
  76. //
  77. //foreach ($data[1] as $common_key => $common_info) {
  78. // $jason_array["list"][] = $common_info;
  79. //}
  80. echo json_encode($jason_array);
  81. exit();