2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-01-25 16:33:54 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_beforeDelete`
|
2024-01-15 11:31:03 +00:00
|
|
|
BEFORE DELETE ON `sale`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
IF OLD.quantity > 0 THEN
|
|
|
|
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
|
|
|
|
SELECT r.id
|
|
|
|
FROM vn.sale s
|
|
|
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
|
|
|
JOIN vn.route r ON r.id = t.routeFk
|
|
|
|
WHERE r.isOk = FALSE
|
|
|
|
AND s.id = OLD.id
|
|
|
|
AND r.created >= util.VN_CURDATE()
|
|
|
|
GROUP BY r.id;
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|