From d816463fb5206f14a04eceb3a6c227439af5a12a Mon Sep 17 00:00:00 2001 From: cmz Date: Sun, 18 Aug 2024 22:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=96=B0=E5=A2=9E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A6=82=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/HomeController.php | 2 +- app/Admin/Metrics/Chart/ColumnCharts.php | 7 ++++++- app/Admin/Metrics/Chart/FemaleColumnCharts.php | 7 ++++++- app/Admin/Metrics/Chart/FullPaymentRateColumnCharts.php | 7 ++++++- app/Admin/Metrics/Chart/MaleColumnCharts.php | 7 ++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php index 5c4ba45..ac87f90 100644 --- a/app/Admin/Controllers/HomeController.php +++ b/app/Admin/Controllers/HomeController.php @@ -43,7 +43,7 @@ class HomeController extends Controller $row->column(3, new Examples\FemaleRegistering()); //女生报到率 $row->column(6, Card::make('各学院报到率',ColumnCharts::make())); -// $row->column(6, Card::make('各学院全额缴费率',FullPaymentRateColumnCharts::make())); + $row->column(6, Card::make('各学院全额缴费率',FullPaymentRateColumnCharts::make())); $row->column(6, Card::make('各学院男生报到率',MaleColumnCharts::make())); $row->column(6, Card::make('各学院女生报到率',FemaleColumnCharts::make())); diff --git a/app/Admin/Metrics/Chart/ColumnCharts.php b/app/Admin/Metrics/Chart/ColumnCharts.php index 085a44f..d2932e3 100644 --- a/app/Admin/Metrics/Chart/ColumnCharts.php +++ b/app/Admin/Metrics/Chart/ColumnCharts.php @@ -78,7 +78,12 @@ class ColumnCharts extends Chart $completedOfflineStep = CompletedOfflineStep::query()->whereIn("unique_number", $userList)->where("annual_session", $config->data)->where("step_id",">=",$stepCount)->count(); //报到率 - $registering = ($completedOfflineStep / count($importStudents) * 100) ; + if($completedOfflineStep == 0 || count($importStudents) == 0){ + $registering = 0; + }else{ + $registering = ($completedOfflineStep / count($importStudents) * 100) ; + } + $list[$key]["registering"] = $registering; } } diff --git a/app/Admin/Metrics/Chart/FemaleColumnCharts.php b/app/Admin/Metrics/Chart/FemaleColumnCharts.php index 916fb76..dacc7cc 100644 --- a/app/Admin/Metrics/Chart/FemaleColumnCharts.php +++ b/app/Admin/Metrics/Chart/FemaleColumnCharts.php @@ -86,7 +86,12 @@ class FemaleColumnCharts extends Chart $studentsNum = count($importStudents); //报到率 - $registering = (($completedOfflineStep / $studentsNum) * 100) ; + if($completedOfflineStep == 0 || $studentsNum == 0){ + $registering = 0; + }else{ + $registering = (($completedOfflineStep / $studentsNum) * 100) ; + } + $list[$key]["registering"] = $registering; } } diff --git a/app/Admin/Metrics/Chart/FullPaymentRateColumnCharts.php b/app/Admin/Metrics/Chart/FullPaymentRateColumnCharts.php index 4de719f..4503cd6 100644 --- a/app/Admin/Metrics/Chart/FullPaymentRateColumnCharts.php +++ b/app/Admin/Metrics/Chart/FullPaymentRateColumnCharts.php @@ -92,7 +92,12 @@ class FullPaymentRateColumnCharts extends Chart $studentsNum = count($paymentList); //报到率 - $registering = (($studentsNum / $completedOfflineStep ) * 100) ; + if($studentsNum == 0 || $completedOfflineStep == 0){ + $registering = 0; + }else{ + $registering = (($studentsNum / $completedOfflineStep ) * 100) ; + } + $list[$key]["registering"] = $registering; } } diff --git a/app/Admin/Metrics/Chart/MaleColumnCharts.php b/app/Admin/Metrics/Chart/MaleColumnCharts.php index 1baefc6..6eac37e 100644 --- a/app/Admin/Metrics/Chart/MaleColumnCharts.php +++ b/app/Admin/Metrics/Chart/MaleColumnCharts.php @@ -86,7 +86,12 @@ class MaleColumnCharts extends Chart $studentsNum = count($importStudents); //报到率 - $registering = (($completedOfflineStep / $studentsNum) * 100) ; + if($completedOfflineStep == 0 || $studentsNum == 0){ + $registering = 0; + }else{ + $registering = (($completedOfflineStep / $studentsNum) * 100) ; + } + $list[$key]["registering"] = $registering; } }