feat(catalog_componentCalculate): refs #8030 new component improved
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
The procedure has now the component "bonus", a special price increasing for a group of items Refs: #8030
This commit is contained in:
parent
9a0b487d20
commit
acabd3e154
|
@ -25,18 +25,39 @@ BEGIN
|
||||||
FROM address
|
FROM address
|
||||||
WHERE id = vAddressFk;
|
WHERE id = vAddressFk;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
CREATE OR REPLACE TEMPORARY TABLE tPriceDelta
|
||||||
(INDEX (itemFk))
|
(INDEX (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT * FROM (
|
SELECT i.id itemFk,
|
||||||
|
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
|
||||||
|
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing
|
||||||
|
FROM vn.item i
|
||||||
|
JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
|
||||||
|
JOIN buy b ON b.id = lb.buy_id
|
||||||
|
JOIN tmp.priceDelta pd
|
||||||
|
ON pd.itemTypeFk = i.typeFk
|
||||||
|
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`)
|
||||||
|
AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`)
|
||||||
|
AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk)
|
||||||
|
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
|
||||||
|
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
|
||||||
|
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
|
||||||
|
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
|
||||||
|
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
|
||||||
|
GROUP BY i.id;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
||||||
|
(INDEX (itemFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT * FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM specialPrice
|
FROM specialPrice
|
||||||
WHERE (clientFk = vClientFk OR clientFk IS NULL)
|
WHERE (clientFk = vClientFk OR clientFk IS NULL)
|
||||||
AND started <= vShipped
|
AND started <= vShipped
|
||||||
AND (ended >= vShipped OR ended IS NULL)
|
AND (ended >= vShipped OR ended IS NULL)
|
||||||
ORDER BY (clientFk = vClientFk) DESC, id DESC
|
ORDER BY (clientFk = vClientFk) DESC, id DESC
|
||||||
LIMIT 10000000000000000000) t
|
LIMIT 10000000000000000000) t
|
||||||
GROUP BY itemFk;
|
GROUP BY itemFk;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
|
||||||
(PRIMARY KEY (itemFk, warehouseFk))
|
(PRIMARY KEY (itemFk, warehouseFk))
|
||||||
|
@ -108,6 +129,17 @@ BEGIN
|
||||||
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
|
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
|
||||||
GROUP BY tc.itemFk, warehouseFk;
|
GROUP BY tc.itemFk, warehouseFk;
|
||||||
|
|
||||||
|
-- priceDelta Bonus del comprador a un rango de productos Refs: #8030
|
||||||
|
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
|
||||||
|
SELECT
|
||||||
|
tcb.warehouseFk,
|
||||||
|
tcb.itemFk,
|
||||||
|
c.id,
|
||||||
|
tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0)
|
||||||
|
FROM tmp.ticketComponentBase tcb
|
||||||
|
JOIN component c ON c.code = 'bonus'
|
||||||
|
JOIN tPriceDelta tpd ON tpd.itemFk = tcb.itemFk;
|
||||||
|
|
||||||
-- RECOBRO
|
-- RECOBRO
|
||||||
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
|
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
|
||||||
SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
|
SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
|
||||||
|
@ -303,6 +335,7 @@ BEGIN
|
||||||
tmp.ticketComponentBase,
|
tmp.ticketComponentBase,
|
||||||
tmp.ticketComponentRate,
|
tmp.ticketComponentRate,
|
||||||
tmp.ticketComponentCopy,
|
tmp.ticketComponentCopy,
|
||||||
tSpecialPrice;
|
tPriceDelta,
|
||||||
|
tSpecialPrice;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
-- Place your SQL code here
|
-- vn.priceDelta definition
|
||||||
-- Place your SQL code here
|
|
||||||
|
|
||||||
CREATE TABLE `priceDelta` (
|
CREATE OR REPLACE TABLE vn.priceDelta (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
||||||
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
||||||
|
@ -13,6 +12,7 @@ CREATE TABLE `priceDelta` (
|
||||||
`toDated` date DEFAULT NULL,
|
`toDated` date DEFAULT NULL,
|
||||||
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
||||||
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
||||||
|
`warehouseFk` smallint(6) unsigned DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
||||||
KEY `priceDelta_ink_FK` (`inkFk`),
|
KEY `priceDelta_ink_FK` (`inkFk`),
|
||||||
|
@ -20,4 +20,4 @@ CREATE TABLE `priceDelta` (
|
||||||
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
||||||
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
||||||
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE
|
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
Loading…
Reference in New Issue