|
|
@@ -117,9 +117,7 @@ class MoneyLog Extends Model
|
|
|
//统计用户余额
|
|
|
public static function getCountAllUserBalance(int $type, string $time = '', string $user_ids='')
|
|
|
{
|
|
|
- $list = self::alias('a')
|
|
|
- ->join('user b', 'a.user_id=b.id')
|
|
|
- ->where('a.status', self::STATUS_NORMAL);
|
|
|
+ $list = self::where('status', self::STATUS_NORMAL);
|
|
|
|
|
|
if($type == 1 && !empty($time)) $list = $list->whereMonth('create_date', $time);
|
|
|
if($type == 2 && !empty($time)) $list = $list->whereYear('create_date', $time);
|
|
|
@@ -129,8 +127,8 @@ class MoneyLog Extends Model
|
|
|
}
|
|
|
if(!empty($user_ids)) $list = $list->whereIn('user_id', $user_ids);
|
|
|
$list = $list
|
|
|
- ->field('a.user_id, sum(if(a.type=1,`change`,0)) as income, sum(if(a.type=2,`change`, 0)) as expenditure,b.nickname,b.avatar')
|
|
|
- ->group('user_id')
|
|
|
+ ->field('bank_account, sum(if(type=1,`change`,0)) as income, sum(if(type=2,`change`, 0)) as expenditure')
|
|
|
+ ->group('bank_account')
|
|
|
->select();
|
|
|
return $list;
|
|
|
}
|