fix: p.name→p.product_name; remove spurious COLLATE in JOIN

This commit is contained in:
yumoqing 2026-07-14 16:07:25 +08:00
parent 9cd393c3b2
commit b3c61a6758

View File

@ -27,17 +27,17 @@ if sub_reseller_id:
sc_sql = f"""
SELECT
sa.productid,
p.name as productid_text,
p.product_name as productid_text,
COUNT(*) as tx_count,
SUM(sa.quantity) as total_qty,
SUM(sa.dist_amount) as our_total_amount,
SUM(sa.supply_amount) as supply_total_amount,
SUM(sa.profit_amount) as profit_total_amount
FROM supplychain_accounting sa
LEFT JOIN product p ON sa.productid = p.id COLLATE utf8mb4_unicode_ci
LEFT JOIN product p ON sa.productid = p.id
{sc_where}
GROUP BY sa.productid, p.name
ORDER BY p.name
GROUP BY sa.productid, p.product_name
ORDER BY p.product_name
"""
# 我方账务: accounting_log 中与该分销商相关的记账汇总
@ -49,7 +49,7 @@ SELECT
SUM(CASE WHEN bd.accounting_dir = 'D' THEN bd.amount ELSE 0 END) as acc_debit,
SUM(CASE WHEN bd.accounting_dir = 'C' THEN bd.amount ELSE 0 END) as acc_credit
FROM bill_detail bd
INNER JOIN bill b ON bd.billid = b.id COLLATE utf8mb4_unicode_ci
INNER JOIN bill b ON bd.billid = b.id
WHERE b.resellerid = ${userorgid}$
"""
acc_params = {'userorgid': userorgid}