admin store 统计
parent
c959b718a0
commit
fcebed9a9d
|
|
@ -8,15 +8,22 @@ use Dcat\Admin\Http\Controllers\AdminController;
|
|||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Admin\Administrator;
|
||||
use Dcat\Admin\Layout\Row;
|
||||
use Dcat\Admin\Widgets\{Box, Tab, Card};
|
||||
use Dcat\Admin\Layout\Content;
|
||||
use Dcat\Admin\Layout\{Content, Row};
|
||||
use App\Admin\Metrics\Store\{TotalStore, TotalUser, TotalOrder, TotalMoney};
|
||||
|
||||
class StoreController extends AdminController
|
||||
{
|
||||
public function info(Content $content)
|
||||
{
|
||||
return $content->title('总览');
|
||||
$row = new Row();
|
||||
$row->column(3, new TotalStore());
|
||||
$row->column(3, new TotalUser());
|
||||
$row->column(3, new TotalOrder());
|
||||
$row->column(3, new TotalMoney());
|
||||
return $content
|
||||
->title('总览')
|
||||
->body($row);
|
||||
}
|
||||
|
||||
public function list()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Metrics\Store;
|
||||
|
||||
use Dcat\Admin\Widgets\Metrics\Card;
|
||||
use App\Models\Order;
|
||||
|
||||
class TotalMoney extends Card
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title('营业额');
|
||||
$this->subTitle('订单营业额');
|
||||
|
||||
$this->withContent(Order::whereNotNull('store_id')->where('status', Order::STATUS_COMPLETED)->sum('total_amount'));
|
||||
}
|
||||
|
||||
public function withContent($content)
|
||||
{
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="card-body">
|
||||
<h1 class="text-left">{$content}<h1>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Metrics\Store;
|
||||
|
||||
use Dcat\Admin\Widgets\Metrics\Card;
|
||||
use App\Models\Order;
|
||||
|
||||
class TotalOrder extends Card
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title('订单');
|
||||
$this->subTitle('订单总数');
|
||||
|
||||
$this->withContent(Order::whereNotNull('store_id')->where('status', Order::STATUS_COMPLETED)->count());
|
||||
}
|
||||
|
||||
public function withContent($content)
|
||||
{
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="card-body">
|
||||
<h1 class="text-left">{$content}<h1>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Metrics\Store;
|
||||
|
||||
use Dcat\Admin\Widgets\Metrics\Card;
|
||||
use App\Models\Store\Store;
|
||||
|
||||
class TotalStore extends Card
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title('店铺');
|
||||
$this->subTitle('店铺总数');
|
||||
|
||||
$this->withContent(Store::effective()->count());
|
||||
}
|
||||
|
||||
public function withContent($content)
|
||||
{
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="card-body">
|
||||
<h1 class="text-left">{$content}<h1>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Metrics\Store;
|
||||
|
||||
use Dcat\Admin\Widgets\Metrics\Card;
|
||||
use App\Models\UserInfo;
|
||||
|
||||
class TotalUser extends Card
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title('员工');
|
||||
$this->subTitle('员工总数');
|
||||
|
||||
$this->withContent(UserInfo::where('is_company', 1)->count());
|
||||
}
|
||||
|
||||
public function withContent($content)
|
||||
{
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="card-body">
|
||||
<h1 class="text-left">{$content}<h1>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ class AgentSeeder extends Seeder
|
|||
['name' => '市级代理', 'slug' => 'agent', 'growth_value' => 80000, 'ratio' => 50, 'sort' => 2, 'created_at' => $time, 'updated_at' => $time],
|
||||
['name' => '区级代理', 'slug' => 'agent', 'growth_value' => 70000, 'ratio' => 40, 'sort' => 3, 'created_at' => $time, 'updated_at' => $time],
|
||||
['name' => '金级爱好者', 'slug' => 'favoite', 'growth_value' => 50000, 'ratio' => 30, 'sort' => 4, 'created_at' => $time, 'updated_at' => $time],
|
||||
['name' => '银级爱好者', 'slug' => 'favoite', 'growth_value' => 50000, 'ratio' => 20, 'sort' => 5, 'created_at' => $time, 'updated_at' => $time],
|
||||
['name' => '银级爱好者', 'slug' => 'favoite', 'growth_value' => 20000, 'ratio' => 20, 'sort' => 5, 'created_at' => $time, 'updated_at' => $time],
|
||||
['name' => '铜级爱好者', 'slug' => 'favoite', 'growth_value' => 5000, 'ratio' => 10, 'sort' => 6, 'created_at' => $time, 'updated_at' => $time],
|
||||
];
|
||||
Agent::insert($list);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ return [
|
|||
'labels' => [
|
||||
'Store' => '信息管理',
|
||||
'store' => '信息管理',
|
||||
'info' => '总揽'
|
||||
],
|
||||
'fields' => [
|
||||
'title' => '名称',
|
||||
|
|
|
|||
Loading…
Reference in New Issue