6
0
Fork 0

首页统计

base
panliang 2022-07-22 16:42:14 +08:00
parent c2fa6d7eca
commit a6289e2f83
3 changed files with 24 additions and 3 deletions

View File

@ -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));
}
}

View File

@ -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;
}
}

View File

@ -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
总余额
</div>
</div>
<div class="d-flex row text-center">
<div class="col-sm-4">
<h1 class="font-lg-1 mt-2 mb-0">{$content['order_money']}</h1>
销售额
</div>
</div>
HTML
);
}