From 5ee8f588073eb833294d71208ce3968282535b8a Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Wed, 26 Feb 2025 19:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A8=E5=B9=BF=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/admin/api/v1/PromotionController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controller/admin/api/v1/PromotionController.php b/app/controller/admin/api/v1/PromotionController.php index 884d885..c07d61b 100644 --- a/app/controller/admin/api/v1/PromotionController.php +++ b/app/controller/admin/api/v1/PromotionController.php @@ -14,6 +14,7 @@ use app\model\UserPhoneLog; use hg\apidoc\annotation as Apidoc; use app\model\Withdraw; use App\Utils\Random; +use support\Db; /** * @Apidoc\Title("admin推广链接控制器") @@ -72,6 +73,7 @@ class PromotionController 'users.remark', 'users.status', 'users.vip_id', + 'users.created_at', 'u.username as parent_username' // 选择所需字段,并为父用户用户名起别名 )->where('users.isrobot', 1) ->orderBy('users.id', 'desc')->get(); // 确保按 users 表的 id 排序 @@ -100,11 +102,14 @@ class PromotionController // 获取用户手机号(按 user_id 分组)并根据时间范围筛选 $UserPhone = UserPhone::whereIn('user_id', $users) ->whereBetween('created_at', [$startDate . ' 00:00:00', $endDate . ' 23:59:59']) // 时间范围筛选 + ->select('user_id', DB::raw('count(*) as phone_count')) // 聚合查询,按 user_id 分组,计算每个 user_id 的手机数量 ->groupBy('user_id') ->get(); - // 获取注册的用户数量 - $res['register'] = count($users); + // 获取注册的用户数量,按时间筛选 + $res['register'] = User::whereIn('id', $users) + ->whereBetween('created_at', [$startDate . ' 00:00:00', $endDate . ' 23:59:59']) // 时间范围筛选 + ->count(); // 获取绑定手机号的用户数量 $res['binding'] = count($UserPhone);