From a6289e2f8325f0f3cc50af66aa16321733da4271 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 22 Jul 2022 16:42:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Metrics/NewUsers.php | 5 +++-- app/Admin/Metrics/Orders.php | 13 ++++++++++++- app/Admin/Metrics/StatisticsTotal.php | 9 +++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Admin/Metrics/NewUsers.php b/app/Admin/Metrics/NewUsers.php index a7b2643a..b4ccdef3 100644 --- a/app/Admin/Metrics/NewUsers.php +++ b/app/Admin/Metrics/NewUsers.php @@ -20,6 +20,7 @@ class NewUsers extends Line $this->title('新注册'); $this->dropdown([ + '1' => '当天', '7' => '最近7天', '30' => '最近30天', '90' => '最近3个月', @@ -55,11 +56,11 @@ class NewUsers extends Line case '7': default: // 卡片内容 - $start_time = Carbon::now()->subDays(7)->startOfDay(); + $start_time = Carbon::now()->startOfDay(); $end_time = Carbon::now()->endOfDay(); $this->withContent($this->getUserCount($start_time, $end_time).'人'); // 图表数据 - $this->withChart($this->getUserGenerator($start_time, $end_time, 7)); + $this->withChart($this->getUserGenerator($start_time, $end_time, 1)); } } diff --git a/app/Admin/Metrics/Orders.php b/app/Admin/Metrics/Orders.php index be63f797..30418e7a 100644 --- a/app/Admin/Metrics/Orders.php +++ b/app/Admin/Metrics/Orders.php @@ -28,6 +28,7 @@ class Orders extends Bar $this->title('订单'); // 设置下拉选项 $this->dropdown([ + '1' => '当天', '7' => '最近7天', '30' => '最近30天', ]); @@ -64,7 +65,6 @@ class Orders extends Bar $this->withChart($this->getOrderGenerator($start_time, $end_time, 30)); break; case '7': - default: $start_time = Carbon::now()->subDays(6)->startOfDay(); $end_time = Carbon::now()->endOfDay(); // 卡片内容 @@ -72,6 +72,17 @@ class Orders extends Bar // 图表数据 $this->withChart($this->getOrderGenerator($start_time, $end_time, 7)); + break; + default: + $start_time = Carbon::now()->startOfDay(); + $end_time = Carbon::now()->endOfDay(); + // 卡片内容 + $this->withContent($this->getOrderCount($start_time, $end_time).'单', '+5.2%'); + + // 图表数据 + $this->withChart($this->getOrderGenerator($start_time, $end_time, 1)); + break; + } } diff --git a/app/Admin/Metrics/StatisticsTotal.php b/app/Admin/Metrics/StatisticsTotal.php index c64efd04..13ed1c16 100644 --- a/app/Admin/Metrics/StatisticsTotal.php +++ b/app/Admin/Metrics/StatisticsTotal.php @@ -3,6 +3,7 @@ namespace App\Admin\Metrics; use App\Models\Balance; +use App\Models\Order; use App\Models\UserInfo; use App\Models\Wallet; use Dcat\Admin\Widgets\Metrics\RadialBar; @@ -31,11 +32,13 @@ class StatisticsTotal extends RadialBar */ public function handle(Request $request) { + $order = Order::whereNotIn('status', [Order::STATUS_PENDING, Order::STATUS_CANCELLED])->sum('total_amount'); // 卡片内容 $this->withContent([ 'total_points'=> UserInfo::sum('points'), 'total_wallet'=> bcdiv(Wallet::sum('balance'), 100, 2), 'total_balance'=> bcdiv(Balance::sum('balance'), 100, 2), + 'order_money' => bcdiv($order, 100, 2) ]); } @@ -64,6 +67,12 @@ class StatisticsTotal extends RadialBar 总余额 +