public function userInfluenceCollect(Request $request)
    {
        $types = ['logins', "checkins", "rewards", "likes", "fans", "FCCcy", "FCC",
            "forwards", "friends", "deduct"];
        $titles = ['每日登陆', '签到', '打赏', '点赞', '粉丝', 'FCCcy兑换', 'FCC兑换',
            '转发', '好友', '惩罚'];
$user = $request->user(); $data['query'] = DB::table('influence_logs') ->where('owner_id', $user->id) ->select(DB::raw('sum(type*amount) as user_amount,target_type')) ->groupBy('target_type') ->get(); $data['today'] = DB::table('influence_logs') ->where('owner_id', $user->id) ->whereDate('created_at', date('Y-m-d', time())) ->select(DB::raw('sum(type*amount) as today_amount,target_type')) ->groupBy('target_type') ->get();
$arr = []; foreach ($types as $key => $value) { $single["target_type"] = $value; $single['title'] = $titles[$key]; //总影响力 $single['user_amount'] = 0; foreach ($data['query'] as $user_key => $user_value) { if ($user_value->target_type == $value) { $single["user_amount"] = $user_value->user_amount; break; } } //今日影响力 $single['today_amount'] = 0; foreach ($data['today'] as $today_key => $today_value) { if ($today_value->target_type == $value) { $single["today_amount"] = $today_value->today_amount; break; } } $arr[] = $single; } return response()->json($arr, 200); }

相关文章:

  • 2021-05-27
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2021-11-28
  • 2022-01-06
  • 2021-04-26
  • 2021-06-29
猜你喜欢
  • 2021-12-18
  • 2021-08-18
  • 2021-05-17
  • 2021-11-26
  • 2022-02-12
  • 2022-02-12
相关资源
相似解决方案