1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- const field = require('../maps/field');
- const mysql = require('./mysql');
- const until_time = require('../until/time');
- const {getUnixTimeStamp} = require("../until/time");
- function fightSearch(departureCity,targetCity,routeType,startUnixTime,endUnixTime){
- let sql=``,values=[];
- sql = `select f.* ,dep.cityname as departureCityName,tar.cityname as targetCityName from
- flight as f
- LEFT JOIN (select id,cityname from area ) as dep on dep.id = f.departureCity
- LEFT JOIN (select id,cityname from area ) as tar on tar.id = f.targetCity
- where f.departureCity = ? and f.targetCity = ?`;
- values.push(departureCity,targetCity);
- if(routeType){
- sql += ` and f.routerType = ?`;
- values.push(routeType);
- }
- if(endUnixTime){
-
- if (!startUnixTime) startUnixTime=getUnixTimeStamp();
- sql += ` and f.sailingTime <= ?`;
- values.push(endUnixTime);
- }
- if(startUnixTime){
- sql += ` and f.sailingTime >= ?`;
- values.push(startUnixTime);
- }
- sql+=`;`
- return mysql.pq(sql,values);
- }
- function fightTicks(fightId){
- let sql=``,values=[];
- sql=`select ff.*,count(t.flightId = 1 or null) as pay
- from
- (select totalVotes from flight where id = 1) as ff,
- airTickets as t`
- return mysql.pq(sql,values);
- }
|