121 lines
3.0 KiB
PHP
121 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Metrics;
|
|
|
|
use App\Models\Balance;
|
|
use App\Models\DistributionPreIncome;
|
|
use App\Models\UserInfo;
|
|
use App\Models\Wallet;
|
|
use Dcat\Admin\Widgets\Metrics\RadialBar;
|
|
use Illuminate\Http\Request;
|
|
|
|
class StatisticsTotal extends RadialBar
|
|
{
|
|
/**
|
|
* 初始化卡片内容
|
|
*/
|
|
protected function init()
|
|
{
|
|
parent::init();
|
|
|
|
$this->title('统计预览');
|
|
$this->height(300);
|
|
$this->contentWidth(12, 0);
|
|
}
|
|
|
|
/**
|
|
* 处理请求
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return mixed|void
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
// 卡片内容
|
|
$this->withContent([
|
|
'total_points'=> UserInfo::sum('points'),
|
|
'total_wallet'=> bcdiv(Wallet::sum('balance'), 100, 2),
|
|
'total_balance'=> bcdiv(Balance::sum('balance'), 100, 2),
|
|
'total_distribution'=> DistributionPreIncome::unsettlement()->sum('total_revenue'),
|
|
'total_quota_v2' => UserInfo::sum('quota_v2'),
|
|
'total_quota_v1' => UserInfo::sum('quota_v1'),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 卡片内容
|
|
*
|
|
* @param string $content
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function withContent($content)
|
|
{
|
|
return $this->content(
|
|
<<<HTML
|
|
<div class="d-flex row text-center align-items-center justify-content-center" >
|
|
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_distribution']}</h1>
|
|
当前预收益
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_wallet']}</h1>
|
|
总可提
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_balance']}</h1>
|
|
总余额
|
|
</div>
|
|
</div>
|
|
<div class="d-flex row text-center align-items-center justify-content-center" >
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_points']}</h1>
|
|
总积分
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_quota_v2']}</h1>
|
|
新配额
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<h1 class="font-lg-1 mt-2 mb-0">{$content['total_quota_v1']}</h1>
|
|
老配额
|
|
</div>
|
|
</div>
|
|
HTML
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 卡片底部内容.
|
|
*
|
|
* @param string $new
|
|
* @param string $open
|
|
* @param string $response
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function withFooter($new, $open, $response)
|
|
{
|
|
return $this->footer(
|
|
<<<HTML
|
|
<div class="d-flex justify-content-between p-1" style="padding-top: 0!important;">
|
|
<div class="text-center">
|
|
<p>New Tickets</p>
|
|
<span class="font-lg-1">{$new}</span>
|
|
</div>
|
|
<div class="text-center">
|
|
<p>Open Tickets</p>
|
|
<span class="font-lg-1">{$open}</span>
|
|
</div>
|
|
<div class="text-center">
|
|
<p>Response Time</p>
|
|
<span class="font-lg-1">{$response}</span>
|
|
</div>
|
|
</div>
|
|
HTML
|
|
);
|
|
}
|
|
}
|