From 5f6b09421acde8c6dde1870a80af171dd8f00fe9 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Mon, 4 Sep 2023 18:04:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E5=8A=9E=E3=80=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AdminStatistics.php | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/controller/AdminStatistics.php diff --git a/app/controller/AdminStatistics.php b/app/controller/AdminStatistics.php new file mode 100644 index 0000000..40260fc --- /dev/null +++ b/app/controller/AdminStatistics.php @@ -0,0 +1,67 @@ +field('SUM(withdrawal_balance) as quota')->find(); + + $agentData = AgentUser::where('status',1)->field('SUM(withdrawal_balance) as quota')->find(); + + return $this->renderSuccess('数据返回成功',[ + 'update_time' => date("Y/m/d H:i",time()), + 'down_scores_quota' => [ + 'title' => '待下分额度', + 'quota' => bcadd($userData->quota,$agentData->quota,2) + ] + ]); + } + + /** + * 用户统计 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function userStatistics() + { + + $userData = UserModel::where('status',1)->field('count(id) as num')->find(); + + $agentData = AgentUser::where('status',1)->field('count(id) as num')->find(); + $user_num = $userData->num; + $agent_num = $agentData->num; + $sum_num = $user_num + $agent_num; + + return $this->renderSuccess('数据返回成功',[ + 'agent' => [ + 'num' => $agent_num, + 'rate' => round($agent_num / $sum_num * 100,2) . '%' + ], + 'user' => [ + 'num' => $user_num, + 'rate' => round($user_num / $sum_num * 100,2) . '%' + ], + 'sum' => [ + 'num' => format_people_count($sum_num) + ] + ]); + } +}