Commit 7f445908 authored by wangtao's avatar wangtao

学习资料

parent 4fc5c753
...@@ -21,6 +21,9 @@ class UserMoneyLog extends Model ...@@ -21,6 +21,9 @@ class UserMoneyLog extends Model
public static function getUserMoneyRanking($limit = 10, $timeRange = 'all', $type = null) public static function getUserMoneyRanking($limit = 10, $timeRange = 'all', $type = null)
{ {
$query = self::field('user_id, SUM(money) as total_money, COUNT(*) as record_count') $query = self::field('user_id, SUM(money) as total_money, COUNT(*) as record_count')
->withAttr('total_money', function($value, $data, Model $user) {
return intval($value);
})
->group('user_id') ->group('user_id')
->order('total_money', 'DESC') ->order('total_money', 'DESC')
->limit($limit); ->limit($limit);
...@@ -47,8 +50,7 @@ class UserMoneyLog extends Model ...@@ -47,8 +50,7 @@ class UserMoneyLog extends Model
$query->where('type', $type); $query->where('type', $type);
} }
$ranking = $query->select()->toArray();; $ranking = $query->select()->toArray();
// 获取用户信息 // 获取用户信息
if (!empty($ranking)) { if (!empty($ranking)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment