This commit is contained in:
董海洋
2026-06-04 19:25:02 +08:00
parent 129cf155e1
commit d529333ba7
+2 -2
View File
@@ -33,11 +33,11 @@ async function getHotProducts(ctx) {
const limit = parseInt(ctx.query.limit) || 10 const limit = parseInt(ctx.query.limit) || 10
const rows = await query( const rows = await query(
`SELECT id, name, price, sales, stock, `SELECT goods.id, goods.name, goods.price, goods.sales, goods.stock,
COALESCE(s.quantity, 0) as stock_qty COALESCE(s.quantity, 0) as stock_qty
FROM goods FROM goods
LEFT JOIN stock s ON goods.id = s.goods_id LEFT JOIN stock s ON goods.id = s.goods_id
ORDER BY sales DESC ORDER BY goods.sales DESC
LIMIT ?`, LIMIT ?`,
[limit] [limit]
) )