7658-devToTest_2428 #2663
|
@ -1,16 +1,15 @@
|
||||||
DROP PROCEDURE IF EXISTS floranet.catalogue_get;
|
|
||||||
|
|
||||||
DELIMITER $$
|
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
|
READS SQL DATA
|
||||||
proc:BEGIN
|
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 vLanded Delivery date
|
||||||
* @param vPostalCode Delivery address postal code
|
* @param vPostalCode Delivery address postal code
|
||||||
*/
|
*/
|
||||||
|
DECLARE vAddressFk INT;
|
||||||
DECLARE vLastCatalogueFk INT;
|
DECLARE vLastCatalogueFk INT;
|
||||||
DECLARE vLockName VARCHAR(20);
|
DECLARE vLockName VARCHAR(20);
|
||||||
DECLARE vLockTime INT;
|
DECLARE vLockTime INT;
|
||||||
|
@ -32,6 +31,15 @@ proc:BEGIN
|
||||||
SELECT MAX(id) INTO vLastCatalogueFk
|
SELECT MAX(id) INTO vLastCatalogueFk
|
||||||
FROM catalogue;
|
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(
|
INSERT INTO catalogue(
|
||||||
name,
|
name,
|
||||||
price,
|
price,
|
||||||
|
@ -51,17 +59,14 @@ proc:BEGIN
|
||||||
it.name,
|
it.name,
|
||||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
||||||
i.description,
|
i.description,
|
||||||
apc.addressFk
|
vAddressFk
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
JOIN (SELECT itemFk, SUM(quantity * cost) price
|
JOIN (SELECT itemFk, SUM(quantity * cost) price
|
||||||
FROM recipe
|
FROM recipe
|
||||||
GROUP BY itemFk) r ON r.itemFk = i.id
|
GROUP BY itemFk) r ON r.itemFk = i.id
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
JOIN addressPostCode apc
|
JOIN addressPostCode apc ON addressFk = vAddressFk
|
||||||
ON apc.dayOfWeek = dayOfWeek(vLanded)
|
JOIN vn.address a ON a.id = vAddressFk;
|
||||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
|
||||||
AND apc.postCode = vPostalCode
|
|
||||||
JOIN vn.address a ON a.id = apc.addressFk;
|
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM catalogue
|
FROM catalogue
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
DROP PROCEDURE IF EXISTS floranet.deliveryDate_get;
|
|
||||||
|
|
||||||
DELIMITER $$
|
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
|
READS SQL DATA
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -101,7 +101,7 @@ proc:BEGIN
|
||||||
vNewTicketFk,
|
vNewTicketFk,
|
||||||
c.itemFk,
|
c.itemFk,
|
||||||
CONCAT('Entrega: ',c.name),
|
CONCAT('Entrega: ',c.name),
|
||||||
- c.price,
|
- apc.deliveryCost,
|
||||||
1
|
1
|
||||||
FROM catalogue c
|
FROM catalogue c
|
||||||
JOIN addressPostCode apc
|
JOIN addressPostCode apc
|
||||||
|
@ -119,7 +119,7 @@ proc:BEGIN
|
||||||
vNewTicketFk,
|
vNewTicketFk,
|
||||||
r.elementFk,
|
r.elementFk,
|
||||||
i.longName,
|
i.longName,
|
||||||
r.cost,
|
0,
|
||||||
r.quantity
|
r.quantity
|
||||||
FROM catalogue c
|
FROM catalogue c
|
||||||
JOIN recipe r ON r.itemFk = c.itemFk
|
JOIN recipe r ON r.itemFk = c.itemFk
|
||||||
|
|
Loading…
Reference in New Issue