tickets y email
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Pako Natek 2024-05-24 11:44:58 +02:00
parent 257de96743
commit 49a2e6fc84
3 changed files with 58 additions and 8 deletions

View File

@ -40,16 +40,18 @@ proc:BEGIN
postalCode, postalCode,
`type`, `type`,
image, image,
description description,
addressFk
) )
SELECT CONCAT(i.name, ' by ',a.nickname), SELECT CONCAT(i.name, ' by ',a.nickname),
i.`size` + apc.deliveryCost, 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 JOIN addressPostCode apc

View File

@ -4,7 +4,7 @@ $$
CREATE OR REPLACE 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, and makes the ticket /** Update order.isPaid field, and makes the ticket
* *
* @param vCatalogueFk floranet.catalogue.id * @param vCatalogueFk floranet.catalogue.id
@ -12,8 +12,16 @@ BEGIN
* @returns floranet.order.isPaid * @returns floranet.order.isPaid
*/ */
DECLARE vNewTicketFk INT; DECLARE vNewTicketFk INT;
DECLARE vCustomerEmail VARCHAR(255);
DECLARE vFloranetEmail VARCHAR(255);
DECLARE vSubjectEmail VARCHAR(100);
DECLARE vBodyEmail TEXT;
DECLARE vZoneFk INT; 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()
@ -33,7 +41,7 @@ BEGIN
) sub ) sub
LIMIT 1; LIMIT 1;
INSERT INTO ticket ( INSERT INTO vn.ticket (
clientFk, clientFk,
shipped, shipped,
addressFk, addressFk,
@ -57,7 +65,7 @@ BEGIN
vZoneFk vZoneFk
FROM vn.address a FROM vn.address a
JOIN vn.agencyMode am ON am.id = a.agencyModeFk JOIN vn.agencyMode am ON am.id = a.agencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk JOIN vn.agency ag ON ag.id = am.agencyFk
JOIN catalogue c ON c.addressFk = a.id JOIN catalogue c ON c.addressFk = a.id
JOIN vn.company co ON co.code = 'VNL' JOIN vn.company co ON co.code = 'VNL'
WHERE c.id = vCatalogueFk; WHERE c.id = vCatalogueFk;
@ -79,10 +87,41 @@ BEGIN
FROM catalogue c FROM catalogue c
JOIN addressPostCode apc JOIN addressPostCode apc
ON apc.addressFk = c.addressFk ON apc.addressFk = c.addressFk
AND apc.dayOfWeek = dayOfWeek(vDated) AND apc.dayOfWeek = dayOfWeek(c.dated)
WHERE c.id = vCatalogueFk; 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 SELECT isPaid, vNewTicketFk
FROM `order` FROM `order`
WHERE catalogueFk = vCatalogueFk; WHERE catalogueFk = vCatalogueFk;
END$$ END$$

View File

@ -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;