7658-devToTest_2428 #2663
|
@ -1,16 +1,15 @@
|
|||
DROP PROCEDURE IF EXISTS floranet.catalogue_get;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
|
||||
READS SQL DATA
|
||||
proc:BEGIN
|
||||
/**
|
||||
* Returns list, price and all the stuff regarding the floranet items.
|
||||
* Returns list, price and all the stuff regarding the floranet items, for the designed shop
|
||||
*
|
||||
* @param vLanded Delivery date
|
||||
* @param vPostalCode Delivery address postal code
|
||||
*/
|
||||
DECLARE vAddressFk INT;
|
||||
DECLARE vLastCatalogueFk INT;
|
||||
DECLARE vLockName VARCHAR(20);
|
||||
DECLARE vLockTime INT;
|
||||
|
@ -21,7 +20,7 @@ proc:BEGIN
|
|||
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
|
||||
SET vLockName = 'catalogue_get';
|
||||
SET vLockTime = 15;
|
||||
|
||||
|
@ -32,6 +31,15 @@ proc:BEGIN
|
|||
SELECT MAX(id) INTO vLastCatalogueFk
|
||||
FROM catalogue;
|
||||
|
||||
SELECT addressFk
|
||||
INTO vAddressFk
|
||||
FROM addressPostCode apc
|
||||
WHERE apc.dayOfWeek = dayOfWeek(vLanded)
|
||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
||||
AND apc.postCode = vPostalCode
|
||||
-- Aquí hay que incluir los criterios de selección de tienda
|
||||
LIMIT 1;
|
||||
|
||||
INSERT INTO catalogue(
|
||||
name,
|
||||
price,
|
||||
|
@ -51,17 +59,14 @@ proc:BEGIN
|
|||
it.name,
|
||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
||||
i.description,
|
||||
apc.addressFk
|
||||
vAddressFk
|
||||
FROM vn.item i
|
||||
JOIN (SELECT itemFk, SUM(quantity * cost) price
|
||||
FROM recipe
|
||||
GROUP BY itemFk) r ON r.itemFk = i.id
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN addressPostCode apc
|
||||
ON apc.dayOfWeek = dayOfWeek(vLanded)
|
||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
||||
AND apc.postCode = vPostalCode
|
||||
JOIN vn.address a ON a.id = apc.addressFk;
|
||||
JOIN addressPostCode apc ON addressFk = vAddressFk
|
||||
JOIN vn.address a ON a.id = vAddressFk;
|
||||
|
||||
SELECT *
|
||||
FROM catalogue
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
DROP PROCEDURE IF EXISTS floranet.deliveryDate_get;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
|
|
|
@ -101,7 +101,7 @@ proc:BEGIN
|
|||
vNewTicketFk,
|
||||
c.itemFk,
|
||||
CONCAT('Entrega: ',c.name),
|
||||
- c.price,
|
||||
- apc.deliveryCost,
|
||||
1
|
||||
FROM catalogue c
|
||||
JOIN addressPostCode apc
|
||||
|
@ -119,7 +119,7 @@ proc:BEGIN
|
|||
vNewTicketFk,
|
||||
r.elementFk,
|
||||
i.longName,
|
||||
r.cost,
|
||||
0,
|
||||
r.quantity
|
||||
FROM catalogue c
|
||||
JOIN recipe r ON r.itemFk = c.itemFk
|
||||
|
|
Loading…
Reference in New Issue