This commit is contained in:
parent
3f7663da97
commit
a0a9e299d9
|
@ -34,30 +34,30 @@ module.exports = Self => {
|
|||
SUM(delivered) delivered,
|
||||
GROUP_CONCAT(totalPacking ORDER BY total DESC SEPARATOR ' ') itemPackingType
|
||||
FROM (
|
||||
SELECT r.id AS routeFk,
|
||||
t.addressFk,
|
||||
CONCAT (IFNULL(e.itemPackingTypeFk,'-'), '', COUNT(*)) totalPacking,
|
||||
COUNT(*) total,
|
||||
SUM(est.code = 'ON DELIVERY') delivery,
|
||||
SUM(est.code = 'LOST') lost,
|
||||
SUM(est.code = 'DELIVERED') delivered,
|
||||
t.priority
|
||||
FROM vn.ticket t
|
||||
JOIN vn.route r ON r.id = t.routeFk
|
||||
JOIN vn.expedition e ON e.ticketFk = t.id
|
||||
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||
LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId()
|
||||
WHERE (r.created = util.VN_CURDATE() OR r.created = TIMESTAMPADD(day,-1, util.VN_CURDATE()))
|
||||
AND t.routeFk = ?
|
||||
GROUP BY t.addressFk, e.itemPackingTypeFk
|
||||
) sub
|
||||
SELECT r.id AS routeFk,
|
||||
t.addressFk,
|
||||
CONCAT (IFNULL(e.itemPackingTypeFk,'-'), '', COUNT(*)) totalPacking,
|
||||
COUNT(*) total,
|
||||
SUM(est.code = 'ON DELIVERY') delivery,
|
||||
SUM(est.code = 'LOST') lost,
|
||||
SUM(est.code = 'DELIVERED') delivered,
|
||||
t.priority
|
||||
FROM vn.ticket t
|
||||
JOIN vn.route r ON r.id = t.routeFk
|
||||
JOIN vn.expedition e ON e.ticketFk = t.id
|
||||
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||
LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId()
|
||||
WHERE (r.created = util.VN_CURDATE() OR r.created = util.yesterday())
|
||||
AND t.routeFk = ?
|
||||
GROUP BY t.addressFk, e.itemPackingTypeFk
|
||||
) sub
|
||||
GROUP BY addressFk
|
||||
ORDER BY priority DESC
|
||||
`;
|
||||
|
||||
const results = await Self.rawSql(query, [routeFk], options);
|
||||
const results = await Self.rawSql(query, [routeFk], myOptions);
|
||||
return results;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -51,11 +51,16 @@ module.exports = Self => {
|
|||
u.nickname AS userNickname,
|
||||
vn.ticketTotalVolume(t.id) AS volume,
|
||||
tob.description,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||
c.phone ClientPhone,
|
||||
c.mobile ClientMobile,
|
||||
a.phone AddressPhone,
|
||||
a.mobile AddressMobile
|
||||
FROM vn.route r
|
||||
JOIN ticket t ON t.routeFk = r.id
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
LEFT JOIN vn.sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN vn.item i ON i.id = s.itemFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.id = ts.stateFk
|
||||
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
|
||||
|
|
Loading…
Reference in New Issue