fix: base discount query — customerid default is '*' not NULL, remove IS NULL and unnecessary GROUP BY

This commit is contained in:
yumoqing 2026-07-03 18:05:14 +08:00
parent 33cd1d287d
commit 5e90686fbd

View File

@ -827,11 +827,10 @@ async def get_marketing_discount_products(request):
FROM product p FROM product p
LEFT JOIN product_category pc ON p.category_id = pc.id LEFT JOIN product_category pc ON p.category_id = pc.id
LEFT JOIN ( LEFT JOIN (
SELECT dd.productid, MAX(dd.discount) as discount SELECT dd.productid, dd.discount
FROM discount_detail dd FROM discount_detail dd
JOIN discount d ON dd.discountid = d.id JOIN discount d ON dd.discountid = d.id
WHERE d.resellerid = ${org_id}$ AND (d.customerid IS NULL OR d.customerid = '*') WHERE d.resellerid = ${org_id}$ AND d.customerid = '*'
GROUP BY dd.productid
) base ON base.productid = p.id ) base ON base.productid = p.id
LEFT JOIN discount_detail mkt ON mkt.productid = p.id AND mkt.discountid = ${discountid}$ LEFT JOIN discount_detail mkt ON mkt.productid = p.id AND mkt.discountid = ${discountid}$
WHERE p.org_id = ${org_id}$ AND p.status = '1' WHERE p.org_id = ${org_id}$ AND p.status = '1'