40 lines
1.0 KiB
MySQL
40 lines
1.0 KiB
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Gets the available items list.
|
||
|
*
|
||
|
* @param vDelivery Delivery date
|
||
|
* @param vAddress Address id
|
||
|
* @return tmp.ticketCalculateItem
|
||
|
* @return tmp.ticketComponentPrice
|
||
|
* @return tmp.ticketComponent
|
||
|
* @return tmp.ticketLot
|
||
|
* @return tmp.zoneGetShipped
|
||
|
*/
|
||
|
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 vn.available_calc(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 tmp.availableCalc a ON a.calcFk = c.calc_id
|
||
|
WHERE c.available > 0
|
||
|
GROUP BY c.item_id;
|
||
|
|
||
|
CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode);
|
||
|
|
||
|
DROP TEMPORARY TABLE tmp.item;
|
||
|
END$$
|
||
|
DELIMITER ;
|