You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.7 KiB
97 lines
2.7 KiB
<?php
|
|
|
|
namespace App\AdminAgent\Controllers;
|
|
|
|
use App\AdminAgent\Metrics\Examples\FinanceStatistics;
|
|
use App\Common\OrderStatus;
|
|
use App\Models\Order;
|
|
use App\Models\OrderProductItem;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Layout\Column;
|
|
use Dcat\Admin\Layout\Content;
|
|
use Dcat\Admin\Layout\Row;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Widgets\Card;
|
|
|
|
class FinanceStatisticsController extends AdminController
|
|
{
|
|
public function index(Content $content)
|
|
{
|
|
Admin::style(
|
|
<<<CSS
|
|
.col-sm-12.d-flex{
|
|
display: inline-block !important;
|
|
}
|
|
CSS
|
|
);
|
|
|
|
//数据
|
|
|
|
//金额
|
|
$price = Order::query()->where('agent_id',Admin::user()->id)->complete()->sum('price');
|
|
|
|
//利润
|
|
$costPrice = OrderProductItem::query()->where('agent_id',Admin::user()->id)->whereHas('order',function ($query) {
|
|
$query->complete();
|
|
})->sum('price');
|
|
$profit = bcsub($price,$costPrice,2);
|
|
|
|
//已完成订单
|
|
$count = Order::query()->where('agent_id',Admin::user()->id)->complete()->count();
|
|
return $content
|
|
->body(
|
|
<<<HTML
|
|
<div class="content-header">
|
|
<section class="content-header breadcrumbs-top">
|
|
<h1 class=" float-left">
|
|
<span class="text-capitalize">财务统计</span>
|
|
|
|
</h1>
|
|
<div class="clearfix"></div>
|
|
|
|
</section>
|
|
</div>
|
|
HTML
|
|
|
|
)
|
|
->body(function (Row $row) use ($price, $profit, $count) {
|
|
|
|
$row->column(4, function (Column $column) use ($price) {
|
|
$column->row(Card::make('金额', function () use ($price) {
|
|
return <<<HTML
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
|
|
<h2 class="ml-1 font-large-1 text-primary">$price</h2>
|
|
</div>
|
|
HTML;
|
|
}));
|
|
});
|
|
|
|
$row->column(4, function (Column $column) use ($profit) {
|
|
$column->row(Card::make('利润', function () use ($profit) {
|
|
return <<<HTML
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
|
|
<h2 class="ml-1 font-large-1 text-primary">$profit</h2>
|
|
</div>
|
|
HTML;
|
|
}));
|
|
|
|
});
|
|
|
|
$row->column(4, function (Column $column) use ($count) {
|
|
$column->row(Card::make('已完成订单', function () use ($count) {
|
|
return <<<HTML
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
|
|
<h2 class="ml-1 font-large-1 text-primary">$count</h2>
|
|
</div>
|
|
HTML;
|
|
}));
|
|
|
|
});
|
|
|
|
})
|
|
->body(function (Row $row){
|
|
$row->column(12,new FinanceStatistics()
|
|
);
|
|
});
|
|
}
|
|
}
|