|
- <?php
- header("Access-Control-Allow-Origin:*");
- //载入配置文件和连接数据库
- $pdo = conn();
-
- //区分是普通乘客还是分销员 0普通,1分销
- $user_type = 0;
-
-
- //判断出发地 目的地 时间是否为空
- $start_area = empty($_POST['start_id']) ? "" : $_POST['start_id'];
- $end_area = empty($_POST['end_id']) ? "" : $_POST['end_id'];
- $run_date = empty($_POST['back_time']) ? date("Y-m-d", time() + 24 * 3600) : $_POST['back_time'];
- $line_type = $_POST['line_type'];
- $now_date = date("Y-m-d", time());
-
- //$user_id = $_COOKIE['user_id'];
- //if($user_id == 136){
- // $line_id_arr = array(213344,213343,213342,213341,213340,213339,1579,1578,449887,451180);
- //}else{
- // $line_id_arr = array(213344,213343,213342,213341,213340,213339,1579,1578,451188,451237,449887,451180);
- //}
- $sql = "SELECT
- m.run_id,
- m.run_time
- FROM
- run_main AS m,
- run_prod AS p,
- opera_line AS l
- WHERE
- m.run_id = p.run_id
- AND m.prod_id = l.line_id
- AND p.start_station_area_id = " . $start_area . "
- AND p.end_station_area_id = " . $end_area . "
- AND m.run_date >= '" . $now_date . "'
- AND m.run_date = '" . $run_date . "'
- AND m.run_status = 138
- and case l.sale_expired_type when 321 then if(date_add(date_add(m.run_date,interval -1 day), interval (substring_index(l.sale_expired_time,':',1)*60 + substring_index(l.sale_expired_time,':',-1)) minute) > now(),0=0,0=1)
- when 322 then if(date_add(m.run_date, interval m.run_minutes -(substring_index(l.sale_expired_time,':',1)*60 + substring_index(l.sale_expired_time,':',-1)) minute)>= now(),0=0,0=1)
- else 0=0 end
- AND l.line_type = " . $line_type . "
- GROUP BY m.run_id
- order by m.run_time";
- $result = $pdo->query($sql);
- $run_info = $result->fetchAll(PDO::FETCH_ASSOC);
-
- if(count($run_info) == 0){
- $code = '1';
- $info = '没有返程班次';
- }else{
- $code = '0';
- $info = '返回班次成功';
- }
- $json['code'] = $code;
- $json['info'] = $info;
- $json['list'] = $run_info;
- echo json_encode($json);
- ?>
|