2020-02-17 11:01:11 +00:00
|
|
|
|
USE `vn`;
|
|
|
|
|
DROP procedure IF EXISTS `zone_getShippedWarehouse`;
|
|
|
|
|
|
|
|
|
|
DELIMITER $$
|
|
|
|
|
USE `vn`$$
|
|
|
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
|
|
|
|
|
BEGIN
|
|
|
|
|
/**
|
2020-02-20 14:15:50 +00:00
|
|
|
|
* Devuelve la mÃÂnima fecha de envío para cada warehouse
|
2020-02-17 11:01:11 +00:00
|
|
|
|
*
|
|
|
|
|
* @param vLanded La fecha de recepcion
|
|
|
|
|
* @param vAddressFk Id del consignatario
|
|
|
|
|
* @param vAgencyModeFk Id de la agencia
|
|
|
|
|
* @return tmp.zoneGetShipped
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
CALL zone_getFromGeo(address_getGeo(vAddressFk));
|
|
|
|
|
CALL zone_getOptionsForLanding(vLanded,TRUE);
|
|
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
|
|
|
|
|
CREATE TEMPORARY TABLE tmp.zoneGetShipped
|
|
|
|
|
ENGINE = MEMORY
|
|
|
|
|
SELECT * FROM (
|
|
|
|
|
SELECT zo.zoneFk,
|
|
|
|
|
TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
|
|
|
|
|
zo.`hour`,
|
|
|
|
|
zw.warehouseFk,
|
2020-02-20 14:15:50 +00:00
|
|
|
|
z.agencyModeFk,
|
|
|
|
|
zo.price,
|
|
|
|
|
zo.bonus
|
2020-02-17 11:01:11 +00:00
|
|
|
|
FROM tmp.zoneOption zo
|
|
|
|
|
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
|
|
|
|
JOIN zone z ON z.id = zo.zoneFk
|
|
|
|
|
WHERE z.agencyModeFk = vAgencyModeFk
|
|
|
|
|
ORDER BY shipped) t
|
|
|
|
|
GROUP BY warehouseFk;
|
|
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
|
tmp.zone,
|
|
|
|
|
tmp.zoneOption;
|
|
|
|
|
END$$
|
|
|
|
|
|
|
|
|
|
DELIMITER ;
|