作者 Cool
1 个管道 的构建 通过 耗费 1 秒

个人中心总收益调整

... ... @@ -121,6 +121,17 @@ class User extends Api
{
$user = $this->auth->getUser();
$house = House::get($user['house_id']);
$plus = UserMoneyLog::where('user_id',$this->auth->id)
->where('money','>',0)
->select();
$total_money = 0;
foreach ($plus as $v) {
if($v['before'] > $v['after']) {
$total_money -= $v['money'];
} else {
$total_money += $v['money'];
}
}
$data = [
// 当前小区信息
'house' => !empty($house) ? $house->visible(['id','name'])->toArray() : [],
... ... @@ -130,9 +141,7 @@ class User extends Api
->whereTime('createtime', 'today')
->sum('money'),
// 总收益
'total_money' => UserMoneyLog::where('user_id',$this->auth->id)
->where('money','>',0)
->sum('money'),
'total_money' => $total_money,
// 未读消息数量
'message_num' => \app\api\model\Message::where('user_id',$user['id'])
->where('is_read_user',2)
... ...