refs #6861 feat: reservePrevious
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Sergio De la torre 2024-04-11 12:27:16 +02:00
parent 68fa64a937
commit bc1397d916
8 changed files with 26 additions and 248 deletions

View File

@ -1,22 +0,0 @@
DELIMITER $$
CREATE OR REPLACE
DEFINER=`root`@`localhost`
EVENT `floranet`.`clean`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-01-01 23:00:00.000'
ON COMPLETION PRESERVE
ENABLE
DO
BEGIN
DELETE
FROM `order`
WHERE created < CURDATE()
AND isPaid = FALSE;
DELETE c.*
FROM catalogue c
LEFT JOIN `order` o ON o.catalogueFk = c.id
WHERE c.created < CURDATE()
AND o.id IS NULL;
END$$
DELIMITER ;

View File

@ -1,64 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.catalogue_get;
DELIMITER $$
$$
CREATE 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
*
* @param vLanded Delivery date
* @param vPostalCode Delivery address postal code
*/
DECLARE vLastCatalogueFk INT;
DECLARE vLockName VARCHAR(20);
DECLARE vLockTime INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
DO RELEASE_LOCK(vLockName);
RESIGNAL;
END;
SET vLockName = 'catalogue_get';
SET vLockTime = 15;
IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc;
END IF;
SELECT MAX(id) INTO vLastCatalogueFk
FROM catalogue;
INSERT INTO catalogue(
name,
price,
itemFk,
dated,
postalCode,
`type`,
image,
description
)
SELECT i.name,
i.`size`,
i.id,
vLanded,
vPostalCode,
it.name,
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
i.description
FROM vn.item i
JOIN vn.itemType it ON it.id = i.typeFk
WHERE it.code IN ('FNR','FNP');
SELECT *
FROM catalogue
WHERE id > IFNULL(vLastCatalogueFk,0);
DO RELEASE_LOCK(vLockName);
END$$
DELIMITER ;

View File

@ -1,20 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.contact_request;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost`
PROCEDURE floranet.contact_request(
vName VARCHAR(100),
vPhone VARCHAR(15),
vEmail VARCHAR(100),
vMessage TEXT)
READS SQL DATA
BEGIN
/**
* Set actions for contact request.
*
* @param vPostalCode Delivery address postal code
*/
END$$
DELIMITER ;

View File

@ -1,29 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.deliveryDate_get;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
READS SQL DATA
BEGIN
/**
* Returns available dates for this postalCode, in the next seven days
*
* @param vPostalCode Delivery address postal code
*/
DECLARE vCurrentDayOfWeek INT;
SET vCurrentDayOfWeek = DAYOFWEEK(NOW());
SELECT DISTINCT nextDay
FROM (
SELECT CURDATE() + INTERVAL IF(
apc.dayOfWeek >= vCurrentDayOfWeek,
apc.dayOfWeek - vCurrentDayOfWeek,
7 - apc.dayOfWeek
) DAY nextDay,
NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime
FROM addressPostCode apc
WHERE apc.postCode = vPostalCode
HAVING nextDay > minDeliveryTime) sub;
END$$
DELIMITER ;

View File

@ -1,25 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.order_confirm;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
READS SQL DATA
BEGIN
/** Update order.isPaid field
*
* @param vCatalogueFk floranet.catalogue.id
*
* @returns floranet.order.isPaid
*/
UPDATE `order`
SET isPaid = TRUE,
payed = NOW()
WHERE catalogueFk = vCatalogueFk;
SELECT isPaid
FROM `order`
WHERE catalogueFk = vCatalogueFk;
END$$
DELIMITER ;

View File

@ -1,42 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.order_put;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON)
READS SQL DATA
BEGIN
/**
* Get and process an order
*
* @param vOrder Data of the order
*
* Customer data: <customerName>, <email>, <customerPhone>
*
* Item data: <catalogueFk>, <message>
*
* Delivery data: <deliveryName>, <address>, <deliveryPhone>
*
*/
INSERT IGNORE INTO `order`(
catalogueFk,
customerName,
email,
customerPhone,
message,
deliveryName,
address,
deliveryPhone
)
VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')),
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone'))
);
SELECT LAST_INSERT_ID() orderFk;
END$$
DELIMITER ;

View File

@ -1,20 +0,0 @@
DROP PROCEDURE IF EXISTS floranet.sliders_get;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get()
READS SQL DATA
BEGIN
/**
* Returns list of url for sliders
*/
SELECT
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
i.longName
FROM vn.item i
JOIN vn.itemType it ON it.id = i.typeFk
WHERE it.code IN ('FNR','FNP')
LIMIT 3;
END$$
DELIMITER ;

View File

@ -19,9 +19,9 @@ BEGIN
WITH observation AS ( WITH observation AS (
SELECT tob.ticketFk, tob.description SELECT tob.ticketFk, tob.description
FROM ticketObservation tob FROM vn.ticketObservation tob
JOIN ticketCollection tc ON tc.ticketFk = tob.ticketFk JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
LEFT JOIN observationType ot ON ot.id = tob.observationTypeFk LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
WHERE ot.`code` = 'itemPicker' WHERE ot.`code` = 'itemPicker'
AND tc.collectionFk = vParamFk AND tc.collectionFk = vParamFk
) )
@ -32,17 +32,17 @@ BEGIN
w.id salesPersonFk, w.id salesPersonFk,
IFNULL(ob.description,'') observation, IFNULL(ob.description,'') observation,
cc.rgb cc.rgb
FROM ticket t FROM vn.ticket t
LEFT JOIN ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN collection c2 ON c2.id = tc.collectionFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
LEFT JOIN collectionColors cc LEFT JOIN vn.collectionColors cc
ON cc.wagon = tc.wagon ON cc.wagon = tc.wagon
AND cc.shelve = tc.`level` AND cc.shelve = tc.`level`
AND cc.trainFk = c2.trainFk AND cc.trainFk = c2.trainFk
LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = c.salesPersonFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE t.id = vParamFk WHERE t.id = vParamFk
AND t.shipped >= vDated AND t.shipped >= vDated
@ -54,17 +54,17 @@ BEGIN
w.id salesPersonFk, w.id salesPersonFk,
ob.description, ob.description,
IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
FROM ticket t FROM vn.ticket t
JOIN ticketCollection tc ON t.id = tc.ticketFk JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN collection c2 ON c2.id = tc.collectionFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
LEFT JOIN collectionColors cc LEFT JOIN vn.collectionColors cc
ON cc.wagon = tc.wagon ON cc.wagon = tc.wagon
AND cc.shelve = tc.`level` AND cc.shelve = tc.`level`
AND cc.trainFk = c2.trainFk AND cc.trainFk = c2.trainFk
LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = c.salesPersonFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE tc.collectionFk = vParamFk WHERE tc.collectionFk = vParamFk
UNION ALL UNION ALL
@ -75,14 +75,14 @@ BEGIN
c.salesPersonFk, c.salesPersonFk,
ob.description, ob.description,
NULL `rgb` NULL `rgb`
FROM sectorCollection sc FROM vn.sectorCollection sc
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN saleGroup sg ON sg.id = ss.saleGroupFk JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
JOIN ticket t ON t.id = sg.ticketFk JOIN vn.ticket t ON t.id = sg.ticketFk
LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN observation ob ON ob.ticketFk = t.id LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN vn.client c ON c.id = t.clientFk
WHERE sc.id = vParamFk WHERE sc.id = vParamFk
AND t.shipped >= vDated; AND t.shipped >= vDated;
END$$ END$$