优化:百家乐押注面板显示押注人数,今日排行榜修正金币净收益统计

This commit is contained in:
2026-03-28 17:38:59 +08:00
parent 63f9a174ed
commit 91b9a6bcef
2 changed files with 14 additions and 4 deletions

View File

@@ -136,9 +136,10 @@ class UserCurrencyService
return UserCurrencyLog::query()
->whereDate('created_at', $date)
->where('currency', $currency)
->where('amount', '>', 0) // 只统计正向
// 计算净收益,包含正向与负向消耗
->selectRaw('user_id, SUM(amount) as total')
->groupBy('user_id')
->havingRaw('SUM(amount) > 0') // 只有今日净收益为正数才能上榜
->orderByRaw('SUM(amount) DESC')
->limit($limit)
->get()