|
|
@ -3,6 +3,9 @@ |
|
|
namespace App\AdminAgent\Controllers; |
|
|
namespace App\AdminAgent\Controllers; |
|
|
|
|
|
|
|
|
use App\AdminAgent\Metrics\Examples\FinanceStatistics; |
|
|
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\Admin; |
|
|
use Dcat\Admin\Layout\Column; |
|
|
use Dcat\Admin\Layout\Column; |
|
|
use Dcat\Admin\Layout\Content; |
|
|
use Dcat\Admin\Layout\Content; |
|
|
@ -21,7 +24,20 @@ class FinanceStatisticsController extends AdminController |
|
|
} |
|
|
} |
|
|
CSS |
|
|
CSS |
|
|
); |
|
|
); |
|
|
$count = $total = $totalNon = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据
|
|
|
|
|
|
|
|
|
|
|
|
//金额
|
|
|
|
|
|
$price = Order::query()->where('agent_id',Admin::user()->id)->where('status',OrderStatus::SUCCESS)->sum('price'); |
|
|
|
|
|
|
|
|
|
|
|
//利润
|
|
|
|
|
|
$costPrice = OrderProductItem::query()->where('agent_id',Admin::user()->id)->whereHas('order',function ($query) { |
|
|
|
|
|
$query->where('status',OrderStatus::SUCCESS); |
|
|
|
|
|
})->sum('price'); |
|
|
|
|
|
$profit = bcsub($price,$costPrice,2); |
|
|
|
|
|
|
|
|
|
|
|
//已完成订单
|
|
|
|
|
|
$count = Order::query()->where('agent_id',Admin::user()->id)->where('status',OrderStatus::SUCCESS)->count(); |
|
|
return $content |
|
|
return $content |
|
|
->body( |
|
|
->body( |
|
|
<<<HTML |
|
|
<<<HTML |
|
|
@ -38,34 +54,34 @@ class FinanceStatisticsController extends AdminController |
|
|
HTML |
|
|
HTML |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
->body(function (Row $row) use ($count, $total, $totalNon) { |
|
|
|
|
|
|
|
|
->body(function (Row $row) use ($price, $profit, $count) { |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($count) { |
|
|
|
|
|
$column->row(Card::make('金额', function () use ($count) { |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($price) { |
|
|
|
|
|
$column->row(Card::make('金额', function () use ($price) { |
|
|
return <<<HTML |
|
|
return <<<HTML |
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|
|
<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> |
|
|
|
|
|
|
|
|
<h2 class="ml-1 font-large-1 text-primary">$price</h2> |
|
|
</div> |
|
|
</div> |
|
|
HTML; |
|
|
HTML; |
|
|
})); |
|
|
})); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($total) { |
|
|
|
|
|
$column->row(Card::make('利润', function () use ($total) { |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($profit) { |
|
|
|
|
|
$column->row(Card::make('利润', function () use ($profit) { |
|
|
return <<<HTML |
|
|
return <<<HTML |
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|
|
<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">$total</h2> |
|
|
|
|
|
|
|
|
<h2 class="ml-1 font-large-1 text-primary">$profit</h2> |
|
|
</div> |
|
|
</div> |
|
|
HTML; |
|
|
HTML; |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($totalNon) { |
|
|
|
|
|
$column->row(Card::make('已完成订单', function () use ($totalNon) { |
|
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($count) { |
|
|
|
|
|
$column->row(Card::make('已完成订单', function () use ($count) { |
|
|
return <<<HTML |
|
|
return <<<HTML |
|
|
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|
|
<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">$totalNon</h2> |
|
|
|
|
|
|
|
|
<h2 class="ml-1 font-large-1 text-primary">$count</h2> |
|
|
</div> |
|
|
</div> |
|
|
HTML; |
|
|
HTML; |
|
|
})); |
|
|
})); |
|
|
@ -74,7 +90,8 @@ HTML; |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
->body(function (Row $row){ |
|
|
->body(function (Row $row){ |
|
|
$row->column(12,new FinanceStatistics()); |
|
|
|
|
|
|
|
|
$row->column(12,new FinanceStatistics() |
|
|
|
|
|
); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |