fix: dspy same fix — remove IS NULL, remove GROUP BY, use dd.discount directly

This commit is contained in:
yumoqing 2026-07-03 18:05:41 +08:00
parent 5e90686fbd
commit c39e54f379

View File

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