fix: refs #5699 clientsDisable #2419
|
@ -7,15 +7,19 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`clientsDisable`
|
||||||
DO BEGIN
|
DO BEGIN
|
||||||
UPDATE account.user u
|
UPDATE account.user u
|
||||||
JOIN client c ON c.id = u.id
|
JOIN client c ON c.id = u.id
|
||||||
|
LEFT JOIN account.account a ON a.id = u.id
|
||||||
SET u.active = FALSE
|
SET u.active = FALSE
|
||||||
WHERE c.typeFk = 'normal'
|
WHERE c.typeFk = 'normal'
|
||||||
|
AND a.id IS NULL
|
||||||
|
AND u.active
|
||||||
|
AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH
|
||||||
AND u.id NOT IN (
|
AND u.id NOT IN (
|
||||||
SELECT DISTINCT c.id
|
SELECT DISTINCT c.id
|
||||||
FROM client c
|
FROM client c
|
||||||
LEFT JOIN ticket t ON t.clientFk = c.id
|
LEFT JOIN ticket t ON t.clientFk = c.id
|
||||||
WHERE c.salesPersonFk IS NOT NULL
|
WHERE c.salesPersonFk IS NOT NULL
|
||||||
OR t.created > util.VN_CURDATE() - INTERVAL 2 MONTH
|
OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH
|
||||||
OR shipped > util.VN_CURDATE() - INTERVAL 2 MONTH
|
OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH
|
||||||
);
|
);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -8,7 +8,7 @@ BEGIN
|
||||||
WHERE clientFk = NEW.id;
|
WHERE clientFk = NEW.id;
|
||||||
|
|
||||||
UPDATE `address` SET isDefaultAddress = 1
|
UPDATE `address` SET isDefaultAddress = 1
|
||||||
WHERE id = NEW.defaultAddressFk;
|
WHERE id = NEW.defaultAddressFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN
|
IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN
|
||||||
|
@ -17,7 +17,7 @@ BEGIN
|
||||||
WHERE t.clientFk = NEW.id
|
WHERE t.clientFk = NEW.id
|
||||||
AND t.refFk IS NULL;
|
AND t.refFk IS NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT NEW.isActive THEN
|
IF NOT NEW.isActive THEN
|
||||||
UPDATE account.`user`
|
UPDATE account.`user`
|
||||||
SET active = FALSE
|
SET active = FALSE
|
||||||
|
|
Loading…
Reference in New Issue