refactor: actualizada consulta sql
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3f7dee63ac
commit
5d19da48e2
|
@ -30,9 +30,6 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const dated = new Date(date);
|
|
||||||
const dayName = dated.toString().split(' ')[0];
|
|
||||||
|
|
||||||
query = `
|
query = `
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -43,18 +40,18 @@ module.exports = Self => {
|
||||||
IFNULL(ze.hour, z.hour) as hour,
|
IFNULL(ze.hour, z.hour) as hour,
|
||||||
IFNULL(ze.price, z.price) as price
|
IFNULL(ze.price, z.price) as price
|
||||||
FROM vn.zone z
|
FROM vn.zone z
|
||||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||||
LEFT JOIN zoneEvent ze ON ze.zoneFk = z.id
|
LEFT JOIN vn.zoneEvent ze ON ze.zoneFk = z.id
|
||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
dated = ?
|
ze.dated = ?
|
||||||
OR ? BETWEEN started AND ended
|
OR ? BETWEEN ze.started AND ze.ended
|
||||||
OR weekDays LIKE ?
|
OR ze.weekDays & (1 << WEEKDAY(?))
|
||||||
)
|
)
|
||||||
AND z.id IN (?)
|
AND z.id IN (?)
|
||||||
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
|
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
|
||||||
GROUP BY z.id`;
|
GROUP BY z.id;`;
|
||||||
|
|
||||||
return Self.rawSql(query, [date, date, dayName, zoneIds], myOptions);
|
return Self.rawSql(query, [date, date, date, zoneIds], myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue