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.
125 lines
3.5 KiB
125 lines
3.5 KiB
<?php
|
|
|
|
namespace App\AdminAgent\Controllers;
|
|
|
|
use App\Admin\Actions\Tools\DataReportOption;
|
|
use App\AdminAgent\Tools\DataReportDate;
|
|
use App\AdminAgent\Metrics\Examples\FinanceStatistics;
|
|
use App\AdminAgent\Metrics\Examples\OrderStatistics;
|
|
use App\AdminAgent\Metrics\Examples\ProductStatistics;
|
|
use App\AdminAgent\Metrics\Examples\UserStatistics;
|
|
use App\Common\OrderStatus;
|
|
use App\Common\ProductStatus;
|
|
use App\Models\AgentProduct;
|
|
use App\Models\ImsCjdcMarket;
|
|
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;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class ProductStatisticsController extends AdminController
|
|
{
|
|
public function index(Content $content)
|
|
{
|
|
Admin::style(
|
|
<<<CSS
|
|
.col-sm-12.d-flex{
|
|
display: inline-block !important;
|
|
}
|
|
CSS
|
|
);
|
|
|
|
//数据
|
|
|
|
//订单
|
|
|
|
|
|
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){
|
|
$row->column(6,function (Column $column){
|
|
$column->row(new \App\AdminAgent\Tools\DataReportDate('data_report'));
|
|
});
|
|
|
|
})
|
|
|
|
->body(function (Row $row){
|
|
$row->column(4, function (Column $column) {
|
|
$column->row(Card::make('总数', function () {
|
|
$dateTime = request()->get('created_at')??null;
|
|
$count = AgentProduct::query()->where('agent_id',Admin::user()->id);
|
|
if (!empty($dateTime)) {
|
|
$count->whereBetween('created_at',$dateTime);
|
|
}
|
|
$count = $count->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;
|
|
}));
|
|
});
|
|
|
|
$row->column(4, function (Column $column) {
|
|
$column->row(Card::make('上架', function () {
|
|
$dateTime = request()->get('created_at')??null;
|
|
$profit = AgentProduct::query()->where('agent_id',Admin::user()->id)->where('status',ProductStatus::ON_SALE);
|
|
if (!empty($dateTime)) {
|
|
$profit->whereBetween('created_at',$dateTime);
|
|
}
|
|
$profit = $profit->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">$profit</h2>
|
|
</div>
|
|
HTML;
|
|
}));
|
|
|
|
});
|
|
|
|
$row->column(4, function (Column $column) {
|
|
$column->row(Card::make('下架', function () {
|
|
$unSale = AgentProduct::query()
|
|
->where('agent_id',Admin::user()->id)
|
|
->where('status',ProductStatus::SOLD_OUT);
|
|
$dateTime = request()->get('created_at')??null;
|
|
if (!empty($dateTime)) {
|
|
$unSale->whereBetween('created_at',$dateTime);
|
|
}
|
|
$unSale = $unSale->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">$unSale</h2>
|
|
</div>
|
|
HTML;
|
|
}));
|
|
|
|
});
|
|
|
|
})
|
|
->body(function (Row $row){
|
|
$row->column(12,new ProductStatistics()
|
|
);
|
|
});
|
|
}
|
|
}
|