From d85ae3931e96661b8c6f020ea38da852efe24b12 Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Sun, 16 Mar 2025 12:03:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20TextController?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E6=89=8B=E6=9C=BA=E5=8F=B7=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E5=8E=86=E5=8F=B2=E5=BD=92=E7=B1=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/TextController.php | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/controller/api/TextController.php 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; + } + } +}