2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-08 11:17:29 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`setParking`(
|
|
|
|
vParam VARCHAR(8),
|
|
|
|
vParkingCode VARCHAR(8)
|
|
|
|
)
|
|
|
|
BEGIN
|
2024-01-15 11:31:03 +00:00
|
|
|
/**
|
|
|
|
* Aparca una colección, un ticket, un saleGroup o un shelving en un parking
|
|
|
|
*
|
|
|
|
* @param vParam id del ticket, colección, saleGroup o shelving
|
|
|
|
* @param vParkingCode código del parking
|
|
|
|
*/
|
|
|
|
DECLARE vParkingFk INT;
|
2024-07-08 11:17:29 +00:00
|
|
|
DECLARE vLastWeek DATE;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-07-08 11:17:29 +00:00
|
|
|
SET vParkingCode = REPLACE(vParkingCode, ' ', '');
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
SELECT id INTO vParkingFk
|
2024-07-08 11:17:29 +00:00
|
|
|
FROM parking
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE code = vParkingCode COLLATE utf8_unicode_ci;
|
|
|
|
|
|
|
|
IF vParkingFk IS NULL THEN
|
|
|
|
CALL util.throw('parkingNotExist');
|
|
|
|
END IF;
|
2024-07-10 09:32:41 +00:00
|
|
|
|
2024-07-12 07:42:10 +00:00
|
|
|
SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK;
|
|
|
|
|
|
|
|
-- Comprobamos si es una prep. previa, ticket, colección o shelving
|
|
|
|
IF (SELECT TRUE FROM saleGroup WHERE id = vParam) THEN
|
|
|
|
CALL saleGroup_setParking(vParam, vParkingFk);
|
|
|
|
ELSEIF (SELECT TRUE FROM ticket WHERE id = vParam AND shipped >= vLastWeek) THEN
|
|
|
|
CALL ticket_setParking(vParam, vParkingFk);
|
|
|
|
ELSEIF (SELECT TRUE FROM `collection` WHERE id = vParam AND created >= vLastWeek) THEN
|
|
|
|
CALL collection_setParking(vParam, vParkingFk);
|
|
|
|
ELSEIF (SELECT TRUE FROM shelving WHERE code = vParam COLLATE utf8_unicode_ci) THEN
|
|
|
|
CALL shelving_setParking(vParam, vParkingFk);
|
2024-07-01 07:25:00 +00:00
|
|
|
ELSE
|
2024-07-11 12:50:21 +00:00
|
|
|
CALL util.throw('paramNotExist');
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|