diff --git a/app/controller/api/TextController.php b/app/controller/api/TextController.php new file mode 100644 index 0000000..6cc1828 --- /dev/null +++ b/app/controller/api/TextController.php @@ -0,0 +1,45 @@ +select('username', Db::raw('SUM(amount) as total_points')) // 计算每个用户名的积分总数 + ->groupBy('username') // 按用户名分组 + ->get(); + foreach ($result as $v) { + $user = User::where('username', $v->username)->first(); + $user->money += $v->total_points; + $user->save(); + break; + } + } +}