refs #6281 feat:buyFk in itemShelving #2002
|
@ -40,18 +40,25 @@ proc:BEGIN
|
||||||
postalCode,
|
postalCode,
|
||||||
`type`,
|
`type`,
|
||||||
image,
|
image,
|
||||||
description
|
description,
|
||||||
|
addressFk
|
||||||
)
|
)
|
||||||
SELECT i.name,
|
SELECT CONCAT(i.name, ' by ',a.nickname),
|
||||||
i.`size`,
|
i.minPrice + apc.deliveryCost,
|
||||||
i.id,
|
i.id,
|
||||||
vLanded,
|
vLanded,
|
||||||
vPostalCode,
|
vPostalCode,
|
||||||
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
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
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
|
||||||
WHERE it.code IN ('FNR','FNP');
|
WHERE it.code IN ('FNR','FNP');
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
|
@ -13,8 +13,17 @@ BEGIN
|
||||||
/**
|
/**
|
||||||
* Set actions for contact request
|
* Set actions for contact request
|
||||||
*
|
*
|
||||||
* @param vPostalCode Delivery address postal code
|
* @param vName Name
|
||||||
|
* @param vPhone Phone number
|
||||||
|
* @param vEmail e-mail
|
||||||
|
* @param vMessage text of the message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
CALL vn.mail_insert(
|
||||||
|
'floranet@verdnatura.es',
|
||||||
|
vEmail,
|
||||||
|
'Contact request',
|
||||||
|
CONCAT('Phone: ',vPhone, ' Message: ', vMessage)
|
||||||
|
);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -21,7 +21,7 @@ BEGIN
|
||||||
apc.dayOfWeek - vCurrentDayOfWeek,
|
apc.dayOfWeek - vCurrentDayOfWeek,
|
||||||
7 - apc.dayOfWeek
|
7 - apc.dayOfWeek
|
||||||
) DAY nextDay,
|
) DAY nextDay,
|
||||||
NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime
|
NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime
|
||||||
FROM addressPostCode apc
|
FROM addressPostCode apc
|
||||||
WHERE apc.postCode = vPostalCode
|
WHERE apc.postCode = vPostalCode
|
||||||
HAVING nextDay > minDeliveryTime) sub;
|
HAVING nextDay > minDeliveryTime) sub;
|
||||||
|
|
|
@ -1,24 +1,127 @@
|
||||||
DROP PROCEDURE IF EXISTS floranet.order_confirm;
|
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
$$
|
||||||
|
|
||||||
CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
|
||||||
READS SQL DATA
|
READS SQL DATA
|
||||||
|
|
||||||
BEGIN
|
proc:BEGIN
|
||||||
/** Update order.isPaid field.
|
/** Update order.isPaid field, and makes the ticket
|
||||||
*
|
*
|
||||||
* @param vCatalogueFk floranet.catalogue.id
|
* @param vCatalogueFk floranet.catalogue.id
|
||||||
*
|
*
|
||||||
* @returns floranet.order.isPaid
|
* @returns floranet.order.isPaid
|
||||||
*/
|
*/
|
||||||
|
DECLARE vNewTicketFk INT;
|
||||||
|
DECLARE vCustomerEmail VARCHAR(255);
|
||||||
|
DECLARE vFloranetEmail VARCHAR(255);
|
||||||
|
DECLARE vSubjectEmail VARCHAR(100);
|
||||||
|
DECLARE vBodyEmail TEXT;
|
||||||
|
DECLARE vZoneFk INT;
|
||||||
|
|
||||||
|
IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN
|
||||||
|
CALL util.throw('Esta orden ya está confirmada');
|
||||||
|
END IF;
|
||||||
|
|
||||||
UPDATE `order`
|
UPDATE `order`
|
||||||
SET isPaid = TRUE,
|
SET isPaid = TRUE,
|
||||||
payed = NOW()
|
payed = NOW()
|
||||||
WHERE catalogueFk = vCatalogueFk;
|
WHERE catalogueFk = vCatalogueFk;
|
||||||
|
|
||||||
SELECT isPaid
|
SELECT zoneFk
|
||||||
|
INTO vZoneFk
|
||||||
|
FROM (
|
||||||
|
SELECT zoneFk, COUNT(*) totalCount
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN catalogue c ON c.id = vCatalogueFk
|
||||||
|
WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||||
|
AND t.addressFk = c.addressFk
|
||||||
|
GROUP BY zoneFk
|
||||||
|
ORDER BY totalCount DESC
|
||||||
|
LIMIT 10000000000000000000
|
||||||
|
) sub
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
INSERT INTO vn.ticket (
|
||||||
|
clientFk,
|
||||||
|
shipped,
|
||||||
|
addressFk,
|
||||||
|
agencyModeFk,
|
||||||
|
nickname,
|
||||||
|
warehouseFk,
|
||||||
|
routeFk,
|
||||||
|
companyFk,
|
||||||
|
landed,
|
||||||
|
zoneFk
|
||||||
|
)
|
||||||
|
SELECT a.clientFk,
|
||||||
|
c.dated - INTERVAL 1 DAY,
|
||||||
|
c.addressFk,
|
||||||
|
a.agencyModeFk,
|
||||||
|
a.nickname,
|
||||||
|
ag.warehouseFk,
|
||||||
|
NULL,
|
||||||
|
co.id,
|
||||||
|
c.dated,
|
||||||
|
vZoneFk
|
||||||
|
FROM vn.address a
|
||||||
|
JOIN vn.agencyMode am ON am.id = a.agencyModeFk
|
||||||
|
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||||
|
JOIN catalogue c ON c.addressFk = a.id
|
||||||
|
JOIN vn.company co ON co.code = 'VNL'
|
||||||
|
WHERE c.id = vCatalogueFk;
|
||||||
|
|
||||||
|
SET vNewTicketFk = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
INSERT INTO vn.sale(
|
||||||
|
ticketFk,
|
||||||
|
itemFk,
|
||||||
|
concept,
|
||||||
|
price,
|
||||||
|
quantity)
|
||||||
|
SELECT
|
||||||
|
vNewTicketFk,
|
||||||
|
c.itemFk,
|
||||||
|
CONCAT('Entrega: ',c.name),
|
||||||
|
- c.price,
|
||||||
|
1
|
||||||
|
FROM catalogue c
|
||||||
|
JOIN addressPostCode apc
|
||||||
|
ON apc.addressFk = c.addressFk
|
||||||
|
AND apc.dayOfWeek = dayOfWeek(c.dated)
|
||||||
|
WHERE c.id = vCatalogueFk;
|
||||||
|
|
||||||
|
SELECT cl.email,
|
||||||
|
cf.email,
|
||||||
|
CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated),
|
||||||
|
CONCAT_WS('\n',
|
||||||
|
CONCAT('Producto: ', c.name),
|
||||||
|
CONCAT('Fecha de entrega: ',c.dated),
|
||||||
|
CONCAT('Destinatario: ', o.deliveryName),
|
||||||
|
CONCAT('Dirección: ', o.address),
|
||||||
|
CONCAT('CP: ', c.postalCode),
|
||||||
|
CONCAT('Foto: ', c.image),
|
||||||
|
CONCAT('Mensaje: ', IFNULL(o.message,"Ninguno.")),
|
||||||
|
CONCAT('Teléfono: ',IFNULL(o.deliveryPhone,"--")),
|
||||||
|
CONCAT('Observaciones: ', IFNULL(o.observations,"No hay."))
|
||||||
|
)
|
||||||
|
INTO vCustomerEmail,
|
||||||
|
vFloranetEmail,
|
||||||
|
vSubjectEmail,
|
||||||
|
vBodyEmail
|
||||||
|
FROM vn.client cl
|
||||||
|
JOIN vn.address a ON a.clientFk = cl.id
|
||||||
|
JOIN catalogue c ON c.addressFk = a.id
|
||||||
|
JOIN `order` o ON o.catalogueFk = c.id
|
||||||
|
JOIN config cf
|
||||||
|
WHERE c.id = vCatalogueFk;
|
||||||
|
|
||||||
|
CALL vn.mail_insert(
|
||||||
|
vCustomerEmail,
|
||||||
|
vFloranetEmail,
|
||||||
|
vSubjectEmail,
|
||||||
|
vBodyEmail);
|
||||||
|
|
||||||
|
SELECT isPaid, vNewTicketFk
|
||||||
FROM `order`
|
FROM `order`
|
||||||
WHERE catalogueFk = vCatalogueFk;
|
WHERE catalogueFk = vCatalogueFk;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -9,12 +9,11 @@ BEGIN
|
||||||
* Returns list of url for sliders.
|
* Returns list of url for sliders.
|
||||||
*/
|
*/
|
||||||
SELECT
|
SELECT
|
||||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
|
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
|
||||||
i.longName
|
i.longName
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
WHERE it.code IN ('FNR','FNP')
|
WHERE it.code IN ('FNR','FNP')
|
||||||
LIMIT 3;
|
LIMIT 3;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,4 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE floranet.catalogue ADD addressFk int(11) NOT NULL;
|
||||||
|
ALTER TABLE floranet.catalogue ADD CONSTRAINT catalogue_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE floranet.builder DROP FOREIGN KEY builder_FK_1;
|
||||||
|
ALTER TABLE floranet.`element` DROP PRIMARY KEY;
|
||||||
|
ALTER TABLE floranet.`element` ADD id INT NOT NULL;
|
||||||
|
ALTER TABLE floranet.`element` ADD CONSTRAINT element_pk PRIMARY KEY (id);
|
||||||
|
ALTER TABLE floranet.builder ADD CONSTRAINT builder_element_FK FOREIGN KEY (elementFk) REFERENCES floranet.`element`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
CREATE OR REPLACE TABLE floranet.config (
|
||||||
|
email varchar(255) DEFAULT 'floranet@verdnatura.es' NOT NULL
|
||||||
|
)
|
||||||
|
ENGINE=InnoDB
|
||||||
|
DEFAULT CHARSET=utf8mb3
|
||||||
|
COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
DROP TABLE IF EXISTS floranet.builder;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE floranet.`element` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(30) NOT NULL,
|
||||||
|
`itemFk` int(11) DEFAULT NULL,
|
||||||
|
`longNameFilter` varchar(30) DEFAULT NULL,
|
||||||
|
`typeFk` smallint(5) unsigned DEFAULT NULL,
|
||||||
|
`minSize` int(10) unsigned DEFAULT NULL,
|
||||||
|
`maxSize` int(10) unsigned DEFAULT NULL,
|
||||||
|
`inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||||
|
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `element_FK` (`itemFk`),
|
||||||
|
KEY `element_FK_1` (`typeFk`),
|
||||||
|
KEY `element_FK_2` (`inkFk`),
|
||||||
|
KEY `element_FK_3` (`originFk`),
|
||||||
|
CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción';
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE floranet.`recipe` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`itemFk` int(11) NOT NULL,
|
||||||
|
`elementFk` int(11) NOT NULL,
|
||||||
|
`quantity` int(10) unsigned NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `recipe_FK` (`itemFk`),
|
||||||
|
KEY `recipe_FK_1` (`elementFk`),
|
||||||
|
CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `recipe_element_FK` FOREIGN KEY (`elementFk`) REFERENCES `element` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements';
|
Loading…
Reference in New Issue