salix/db/changes/10032-webZone/00-deprecate.sql

399 lines
8.6 KiB
SQL

USE `vn2008`;
DROP procedure IF EXISTS `vn2008`.`bionic_available_`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_available_`(
vDate DATE,
vAddress INT,
vAgency INT)
BEGIN
/**
* Calcula el disponible para un conjunto de almacenes y fechas
* devueltos por el procedimiento agencyHourGetShipped()
*
* @deprecated Use vn.available_calc()
* @table t_bionic_available Tabla con los ids de cache
*/
DECLARE vAvailableCalc INT;
DECLARE vShipment DATE;
DECLARE vAgencyId INT;
DECLARE vWh INT;
DECLARE vDone BOOL;
DECLARE cTravelTree CURSOR FOR
SELECT warehouseFk, shipped FROM tmp.agencyHourGetShipped;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-- Establecemos los almacenes y las fechas que van a entrar al disponible
SELECT agency_id INTO vAgencyId
FROM Agencias WHERE Id_Agencia = vAgency;
CALL vn.agencyHourGetShipped (vDate, vAddress, vAgencyId);
DROP TEMPORARY TABLE IF EXISTS t_bionic_available;
CREATE TEMPORARY TABLE t_bionic_available(
calc_id INT UNSIGNED,
PRIMARY KEY (calc_id)
)
ENGINE = MEMORY;
OPEN cTravelTree;
l: LOOP
SET vDone = FALSE;
FETCH cTravelTree INTO vWh, vShipment;
IF vDone THEN
LEAVE l;
END IF;
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWh, vShipment);
INSERT IGNORE INTO t_bionic_available
SET calc_id = vAvailableCalc;
END LOOP;
CLOSE cTravelTree;
DROP TEMPORARY TABLE tmp.agencyHourGetShipped;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionic_from_item`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_item`(vItem INT)
BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT sent, addressFk, agencyModeFk
INTO vDate, vAddress, vAgencyMode
FROM myBasket;
CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
END$$
DELIMITER ;
;
USE `vn2008`;
DROP procedure IF EXISTS `vn2008`.`bionic_from_order`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_order`(
v_date DATE, -- fecha de recepcion de mercancia
v_consigna INT,
v_agencia INT,
v_order INT)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.bionic_calc;
CREATE TEMPORARY TABLE tmp.bionic_calc
(PRIMARY KEY (item_id))
ENGINE = MEMORY
SELECT item_id FROM order_row
WHERE order_id = v_order GROUP BY item_id;
CALL bionic_calc (v_date, v_consigna, v_agencia);
DROP TEMPORARY TABLE tmp.bionic_calc;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionicCalcWithDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionicCalcWithDate`(vDate DATE)
BEGIN
DECLARE vMyAddressFk INTEGER;
DECLARE vMyAgencyModeFk INTEGER;
SELECT id, agencyModeFk INTO vMyAddressFk, vMyAgencyModeFk
FROM myAddress
WHERE isDefaultAddress;
CALL vn2008.bionic_calc(vDate, vMyAddressFk, vMyAgencyModeFk);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`bionic_calc`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_calc`()
BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT sent, addressFk, agencyModeFk
INTO vDate, vAddress, vAgencyMode
FROM myBasket;
CALL vn2008.bionic_calc(vDate, vAddress, vAgencyMode);
IF account.myUserGetName() = 'visitor'
THEN
DROP TEMPORARY TABLE tmp.bionic_component;
UPDATE tmp.bionic_item SET price = NULL;
END IF;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`itemGetAvailableOrder`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailableOrder`(vOrder INT)
BEGIN
/**
* Gets the available items list with an order params.
*
* @table tmp.itemAvailable
*/
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vAgency INT;
SELECT landed, addressFk, agencyModeFk
INTO vDelivery, vAddress, vAgency
FROM myOrder
WHERE id = vOrder;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
CREATE TEMPORARY TABLE tmp.itemAvailable
(INDEX (id))
ENGINE = MEMORY
SELECT c.item_id id
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`itemGetAvailable`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailable`()
BEGIN
/**
* Gets the available items list.
*
* @table tmp.itemAvailable
*/
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vAgency INT;
SELECT sent, addressFk, agencyModeFk
INTO vDelivery, vAddress, vAgency
FROM myBasket;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
CREATE TEMPORARY TABLE tmp.itemAvailable
(INDEX (id))
ENGINE = MEMORY
SELECT c.item_id id
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myItemGetAvailableFromDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailableFromDate`(vDelivery DATE)
BEGIN
/**
* Gets the available items list.
*
* @deprecated Use item_calcCatalogFromMyAddress()
* @param vDelivery Delivery date
*/
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk, a.id
INTO vAgencyMode, vAddress
FROM myClient c
JOIN vn.address a ON a.id = c.defaultAddressFk;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
-- -------------------
/*SELECT b.itemFk, b.item, b.available, b.price
FROM tmp.ticketCalculateItem b
JOIN vn.item i ON i.id = b.itemFk
WHERE b.available > 0
ORDER BY i.relevancy DESC, i.name, i.size;
select * from tmp.ticketComponentPrice;*/
-- -------------------
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myItemGetAvailable`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailable`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
*
* @deprecated Use item_calcCatalogFromMyAddress()
* @param vDelivery Delivery date
* @param vAddress Id Address
*/
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk
INTO vAgencyMode
FROM myClient c
JOIN vn.address a ON a.clientFk = c.id
WHERE a.id = vAddress;
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM cache.available c
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
-- -------------------
/*SELECT b.itemFk, b.item, b.available, b.price
FROM tmp.ticketCalculateItem b
JOIN vn.item i ON i.id = b.itemFk
WHERE b.available > 0
ORDER BY i.relevancy DESC, i.name, i.size;
select * from tmp.ticketComponentPrice;*/
-- -------------------
DROP TEMPORARY TABLE vn2008.t_bionic_available;
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderAddItem`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderAddItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
vAmount INT)
BEGIN
/**
* @deprecated Use myOrder_addItem()
*/
CALL myOrder_addItem(vSelf, vWarehouse, vItem, vAmount);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderConfirm`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderConfirm`(vSelf INT)
BEGIN
/**
* @deprecated Use myOrder_confirm()
*/
CALL myOrder_confirm(vSelf);
END$$
DELIMITER ;
;
USE `hedera`;
DROP procedure IF EXISTS `hedera`.`myOrderNewFromDate`;
DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderNewFromDate`(
OUT vSelf INT,
vLandingDate DATE)
BEGIN
/**
* @deprecated Use myOrder_newWithDate()
*/
CALL myOrder_newWithDate(vSelf, vLandingDate);
END$$
DELIMITER ;
;