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

个人中心总收益调整

@@ -121,6 +121,17 @@ class User extends Api @@ -121,6 +121,17 @@ class User extends Api
121 { 121 {
122 $user = $this->auth->getUser(); 122 $user = $this->auth->getUser();
123 $house = House::get($user['house_id']); 123 $house = House::get($user['house_id']);
  124 + $plus = UserMoneyLog::where('user_id',$this->auth->id)
  125 + ->where('money','>',0)
  126 + ->select();
  127 + $total_money = 0;
  128 + foreach ($plus as $v) {
  129 + if($v['before'] > $v['after']) {
  130 + $total_money -= $v['money'];
  131 + } else {
  132 + $total_money += $v['money'];
  133 + }
  134 + }
124 $data = [ 135 $data = [
125 // 当前小区信息 136 // 当前小区信息
126 'house' => !empty($house) ? $house->visible(['id','name'])->toArray() : [], 137 'house' => !empty($house) ? $house->visible(['id','name'])->toArray() : [],
@@ -130,9 +141,7 @@ class User extends Api @@ -130,9 +141,7 @@ class User extends Api
130 ->whereTime('createtime', 'today') 141 ->whereTime('createtime', 'today')
131 ->sum('money'), 142 ->sum('money'),
132 // 总收益 143 // 总收益
133 - 'total_money' => UserMoneyLog::where('user_id',$this->auth->id)  
134 - ->where('money','>',0)  
135 - ->sum('money'), 144 + 'total_money' => $total_money,
136 // 未读消息数量 145 // 未读消息数量
137 'message_num' => \app\api\model\Message::where('user_id',$user['id']) 146 'message_num' => \app\api\model\Message::where('user_id',$user['id'])
138 ->where('is_read_user',2) 147 ->where('is_read_user',2)