Merge branch 'dev' into 7272_bug_redirectToLogin
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-05-27 06:54:55 +00:00
commit 693356f4cb
12 changed files with 232 additions and 46 deletions

View File

@ -1205,11 +1205,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(32, 36, -92.324), (32, 36, -92.324),
(32, 39, 0.994); (32, 39, 0.994);
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`) INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
VALUES VALUES
(2, 'GVC', 1, 1, 1, 1106), (2, 'GVC', 1, 1, 1, 2,1106),
(4, 'HEJ', 1, 1, 1, 1106), (4, 'HEJ', 1, 1, 1, NULL,1106),
(1, 'UXN', 2, 12, 12, 1106); (1, 'UXN', 2, 12, 12, NULL,1106);
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
VALUES VALUES

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,13 +17,15 @@ BEGIN
SELECT SELECT
itemFk, itemFk,
packing, packing,
created created,
buyFk
FROM itemShelving FROM itemShelving
WHERE id = vItemShelvingFk WHERE id = vItemShelvingFk
) ish2 ) ish2
ON ish2.itemFk = ish.itemFk ON ish2.itemFk = ish.itemFk
AND ish2.packing = ish.packing AND ish2.packing = ish.packing
AND date(ish2.created) = date(ish.created) AND date(ish2.created) = date(ish.created)
AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
IF vNewItemShelvingFk THEN IF vNewItemShelvingFk THEN

View File

@ -2,7 +2,6 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN BEGIN
/** /**
* Añade registro o lo actualiza si ya existe. * Añade registro o lo actualiza si ya existe.
* *
@ -15,11 +14,23 @@ BEGIN
* @param vWarehouseFk indica el sector * @param vWarehouseFk indica el sector
* *
**/ **/
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vBuyFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
SELECT barcodeToItem(vBarcode) INTO vItemFk; SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
CALL cache.last_buy_refresh(FALSE);
SELECT buy_id INTO vBuyFk
FROM cache.last_buy
WHERE item_id = vItemFk
AND warehouse_id = vWarehouseFk;
END IF;
IF vPacking IS NULL IF vPacking IS NULL
THEN THEN
SET vPacking = itemPacking(vBarcode, vWarehouseFk); SET vPacking = itemPacking(vBarcode, vWarehouseFk);
@ -29,31 +40,32 @@ BEGIN
IF (SELECT COUNT(*) FROM itemShelving IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN AND packing = vPacking
AND buyFk = vBuyFk) THEN
UPDATE itemShelving UPDATE itemShelving
SET visible = visible+vQuantity SET visible = visible + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
grouping,
packing,
packagingFk)
SELECT vItemFk, INSERT INTO itemShelving(
vShelvingFk, itemFk,
vQuantity, shelvingFk,
IFNULL(vGrouping, b.grouping), visible,
IFNULL(vPacking, b.packing), grouping,
IFNULL(vPackagingFk, b.packagingFk) packing,
FROM item i packagingFk,
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk buyFk)
LEFT JOIN buy b ON b.id = lb.buy_id SELECT vItemFk,
WHERE i.id = vItemFk; vShelvingFk,
vQuantity,
IFNULL(vGrouping, b.grouping),
IFNULL(vPacking, b.packing),
IFNULL(vPackagingFk, b.packagingFk),
id
FROM buy b
WHERE id = vBuyFk;
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

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

View File

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

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;

View File

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