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

37 lines
859 B
MySQL
Raw Normal View History

2019-05-30 06:41:08 +00:00
DROP procedure IF EXISTS `hedera`.`order_calcCatalog`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
BEGIN
/**
* Gets the availability and prices for order items.
*
* @param vSelf The order id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
*/
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
FROM `order`
WHERE id = vSelf;
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk FROM orderRow
WHERE orderFk = vSelf
GROUP BY itemFk;
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;