feat: roles, permissions

This commit is contained in:
2026-04-02 15:06:00 +02:00
parent 6428ddb527
commit 0ed9d792b6
22 changed files with 391 additions and 80 deletions

View File

@@ -321,19 +321,36 @@ AND (
)
)
ORDER BY
/* 🔥 STRICT PRIORITY */
ORDER BY
/* 🔥 SCOPE PRIORITY */
bsp.scope = 'product' DESC,
bsp.scope = 'category' DESC,
bsp.scope = 'shop' DESC,
bsp.b2b_id_customer DESC,
bsp.b2b_id_country DESC,
/* 🔥 CUSTOMER PRIORITY */
(
EXISTS (
SELECT 1 FROM b2b_specific_price_customer c
WHERE c.b2b_specific_price_id = bsp.id
AND c.b2b_id_customer = p_id_customer
)
) DESC,
/* 🔥 COUNTRY PRIORITY */
(
EXISTS (
SELECT 1 FROM b2b_specific_price_country ctry
WHERE ctry.b2b_specific_price_id = bsp.id
AND ctry.b2b_id_country = b2b_id_country
)
) DESC,
/* GLOBAL fallback (no restrictions) naturally goes last */
bsp.from_quantity DESC,
bsp.id DESC
LIMIT 1
LIMIT 1
) bsp ON 1=1
LEFT JOIN b2b_currency_rates br_bsp
ON br_bsp.b2b_id_currency = bsp.b2b_id_currency