|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /*
- Author:ZSQ
- Compeny:Spiders Travel
- */
- require_once '../../Common/Mysql.php';
- header("Access-Control-Allow-Origin:*");
- $lineStyle = isset($_POST['lineStyle']) ? $_POST['lineStyle'] : 0;
- $keywords = isset($_POST['keywords']) ? (empty($_POST['keywords'])?'':$_POST['keywords']) : '';
- $currpage = isset($_POST['currpage']) ? (empty($_POST['currpage']) ? 1 : $_POST['currpage']) : 1;
- $pagesize = isset($_POST['pagesize']) ? (empty($_POST['pagesize']) ? 1 : $_POST['pagesize']) : 10;
-
- $pdo = conn();
-
- $user_id = $_COOKIE['user_id'];
- $opera_org_id_sql = "select opera_org_id,main_corp_id from base_user where id = " . $user_id . " and cancel_flag = 0";
-
- $opera_org_id_result = $pdo->query($opera_org_id_sql);
- $rowset = $opera_org_id_result->fetchAll(PDO::FETCH_ASSOC);
-
- $opera_org_id = $rowset[0]['opera_org_id'];
- $main_corp_id = $rowset[0]['main_corp_id'];
- $and_sql = '';
- if ($opera_org_id != '') {
- $and_sql .= " and L.org_id in (" . $opera_org_id . ") ";
- }
- if ($main_corp_id != 0) {
- $and_sql .= " and L.main_corp_id in (" . $main_corp_id . ") ";
- }
-
- // $sql="CALL sp_get_line_list(".$lineStyle.",'".$keywords."',".$pagesize.",".$currpage.");";
-
- $sql = "SELECT L.LINE_ID as prod_id,
- L.LINE_CODE as property,
- L.LINE_NAME as prod_name,
- L.LINE_TYPE as bus_type,
- CASE L.LINE_TYPE WHEN 255 THEN '直通巴士' WHEN 256 THEN '穿梭巴士' WHEN 284 THEN '城际商务车' ELSE '' END AS bus_type_name,
- CASE L.IF_DISABLED WHEN 0 THEN '启用' ELSE '停用' END AS disabled_status,
- (select count(*) from opera_station where line_id = L.line_id and cancel_flag = 0) AS station_cnt , -- 站点数量
- ifnull(t.ticket_cnt,0) as ticket_cnt -- 票种数量
- FROM OPERA_LINE L left join
- (select line_id,count(*) as ticket_cnt
- from (select distinct line_id,start_station_area_id,end_station_area_id,seat_type,human_type,prod_price,cus_price
- from opera_tickets
- where TICKET_TYPE = 1 ) a
- group by line_id) T ON L.LINE_ID = T.line_id
- WHERE L.CANCEL_FLAG = 0
- AND IF(TRIM('" . $keywords . "')='',0=0,(L.LINE_CODE LIKE CONCAT('%','" . $keywords . "','%') OR L.LINE_NAME LIKE CONCAT('%','" . $keywords . "','%')))
- AND IF(" . $lineStyle . "=0,0=0,L.LINE_TYPE=" . $lineStyle . ")
- " . $and_sql . "
- GROUP BY L.LINE_ID,L.LINE_CODE,L.LINE_NAME,L.LINE_TYPE,L.IF_DISABLED
- ORDER BY L.LINE_ID desc
- limit " . ($currpage-1)*$pagesize . "," . $pagesize;
-
- $result = $pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- //$data = array();
- //do {
- // $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- // if ($rowset) {
- // $data[] = $rowset;
- // }
- //} while ($result->nextRowset());
- $count_sql = "SELECT L.LINE_ID as prod_id
- FROM OPERA_LINE L left join
- (select line_id,count(*) as ticket_cnt
- from (select distinct line_id,start_station_area_id,end_station_area_id,seat_type,human_type,prod_price,cus_price
- from opera_tickets
- where TICKET_TYPE = 1 ) a
- group by line_id) T ON L.LINE_ID = T.line_id
- WHERE L.CANCEL_FLAG = 0
- AND IF(TRIM('" . $keywords . "')='',0=0,(L.LINE_CODE LIKE CONCAT('%','" . $keywords . "','%') OR L.LINE_NAME LIKE CONCAT('%','" . $keywords . "','%')))
- AND IF(" . $lineStyle . "=0,0=0,L.LINE_TYPE=" . $lineStyle . ")
- " . $and_sql . "
- GROUP BY L.LINE_ID,L.LINE_CODE,L.LINE_NAME,L.LINE_TYPE,L.IF_DISABLED";
- $result = $pdo->query($count_sql);
- $count = $result->fetchAll(PDO::FETCH_ASSOC);
-
- $jason_array = array();
- $jason_array["code"] = 0;
- $jason_array["info"] = "";
- $jason_array["totalNum"] = count($count);//$data[0][0]["total"];
- $jason_array["list"] = $rowset;//array();
- //
- //foreach ($data[1] as $common_key => $common_info) {
- // $jason_array["list"][] = $common_info;
- //}
- echo json_encode($jason_array);
-
- exit();
|