feat(closure): send to driver the route report on route closure
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
087a5e9404
commit
f5b1eb3ccd
|
@ -6,6 +6,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
|
|||
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
|
||||
ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
|
||||
|
||||
INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
|
||||
VALUES
|
||||
('TOTALLY_SECURE_TOKEN', '1209600', CURDATE(), 66);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
||||
VALUES
|
||||
('1', '6');
|
||||
|
@ -208,7 +213,7 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8;
|
|||
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23;
|
||||
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10;
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `web` = 1;
|
||||
UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com';
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
|
||||
|
||||
|
|
|
@ -143,8 +143,24 @@ module.exports = app => {
|
|||
AND t.refFk IS NULL
|
||||
GROUP BY e.ticketFk`, [reqArgs.routeId]);
|
||||
const ticketIds = tickets.map(ticket => ticket.id);
|
||||
|
||||
await closeAll(ticketIds, reqArgs);
|
||||
|
||||
// Send route report to the agency
|
||||
const agencyMail = await db.findValue(`
|
||||
SELECT am.reportMail
|
||||
FROM route r
|
||||
JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
WHERE r.id = ?`, [reqArgs.routeId]);
|
||||
|
||||
if (agencyMail) {
|
||||
const args = Object.assign({
|
||||
routeId: reqArgs.routeId,
|
||||
recipient: agencyMail
|
||||
}, reqArgs);
|
||||
|
||||
const email = new Email('driver-route', args);
|
||||
await email.send();
|
||||
}
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue