feat: refs #8030 new field vn.priceDelta.zoneGeoFk
gitea/salix/pipeline/pr-master Build queued...
Details
gitea/salix/pipeline/pr-master Build queued...
Details
This commit is contained in:
parent
bc2ed26fc3
commit
02ef314ed9
|
@ -29,21 +29,24 @@ BEGIN
|
||||||
(INDEX (itemFk))
|
(INDEX (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT i.id itemFk,
|
SELECT i.id itemFk,
|
||||||
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
|
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
|
||||||
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing,
|
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing,
|
||||||
pd.warehouseFk
|
pd.warehouseFk
|
||||||
FROM item i
|
FROM item i
|
||||||
JOIN priceDelta pd
|
JOIN priceDelta pd
|
||||||
ON pd.itemTypeFk = i.typeFk
|
ON pd.itemTypeFk = i.typeFk
|
||||||
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`)
|
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`)
|
||||||
AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`)
|
AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`)
|
||||||
AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk)
|
AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk)
|
||||||
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
|
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
|
||||||
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
|
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
|
||||||
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
|
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
|
||||||
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
|
LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk
|
||||||
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
|
LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk)
|
||||||
GROUP BY i.id;
|
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
|
||||||
|
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
|
||||||
|
AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt)
|
||||||
|
GROUP BY itemFk;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
||||||
(INDEX (itemFk))
|
(INDEX (itemFk))
|
||||||
|
@ -130,15 +133,15 @@ BEGIN
|
||||||
|
|
||||||
-- Bonus del comprador a un rango de productos
|
-- Bonus del comprador a un rango de productos
|
||||||
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
|
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
|
||||||
SELECT
|
SELECT
|
||||||
tcb.warehouseFk,
|
tcb.warehouseFk,
|
||||||
tcb.itemFk,
|
tcb.itemFk,
|
||||||
c.id,
|
c.id,
|
||||||
IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0)
|
IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0)
|
||||||
FROM tmp.ticketComponentBase tcb
|
FROM tmp.ticketComponentBase tcb
|
||||||
JOIN component c ON c.code = 'bonus'
|
JOIN component c ON c.code = 'bonus'
|
||||||
JOIN tPriceDelta tpd
|
JOIN tPriceDelta tpd
|
||||||
ON tpd.itemFk = tcb.itemFk
|
ON tpd.itemFk = tcb.itemFk
|
||||||
AND tpd.warehouseFk = tcb.warehouseFk;
|
AND tpd.warehouseFk = tcb.warehouseFk;
|
||||||
|
|
||||||
-- RECOBRO
|
-- RECOBRO
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk)
|
||||||
|
REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
Loading…
Reference in New Issue