salix/db/changes/10081-agency/01-zone_getWarehouse.sql

42 lines
1.0 KiB
MySQL
Raw Normal View History

2019-10-29 11:29:38 +00:00
USE `vn`;
2019-11-06 12:44:58 +00:00
DROP procedure IF EXISTS `zone_getWarehouse`;
2019-10-29 11:29:38 +00:00
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
BEGIN
/**
* Devuelve el listado de agencias disponibles para la fecha,
2019-11-06 12:44:58 +00:00
* dirección y warehouse pasadas
2019-10-29 11:29:38 +00:00
*
* @param vAddress
* @param vWarehouse warehouse
* @param vLanded Fecha de recogida
* @select Listado de agencias disponibles
*/
CALL zone_getFromGeo(address_getGeo(vAddress));
CALL zone_getOptionsForLanding(vLanded);
2019-10-29 11:29:38 +00:00
SELECT am.id agencyModeFk,
am.name agencyMode,
am.description,
am.deliveryMethodFk,
TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
zw.warehouseFk,
z.id zoneFk
FROM tmp.zoneOption zo
JOIN zone z ON z.id = zo.zoneFk
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
WHERE zw.warehouseFk
GROUP BY z.agencyModeFk;
2019-11-06 12:44:58 +00:00
DROP TEMPORARY TABLE
tmp.zone,
tmp.zoneOption;
2019-10-29 11:29:38 +00:00
END$$
DELIMITER ;
2019-11-06 12:44:58 +00:00