|
|
|
@ -33,16 +33,26 @@ class FinanceStatisticsController extends AdminController |
|
|
|
//数据
|
|
|
|
|
|
|
|
//金额
|
|
|
|
$price = Order::query()->where('agent_id',Admin::user()->id)->complete()->sum('price'); |
|
|
|
|
|
|
|
$price = Order::query()->where('agent_id',Admin::user()->id)->complete(); |
|
|
|
//利润
|
|
|
|
$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(); |
|
|
|
$count = Order::query()->where('agent_id',Admin::user()->id)->complete(); |
|
|
|
|
|
|
|
$dateTime = request('created_at', 0); |
|
|
|
if ($dateTime) { |
|
|
|
$price->whereBetween('created_at',$dateTime); |
|
|
|
$costPrice->whereBetween('created_at',$dateTime); |
|
|
|
$count->whereBetween('created_at',$dateTime); |
|
|
|
} |
|
|
|
|
|
|
|
$price = $price->sum('price'); |
|
|
|
$costPrice = $costPrice->sum('price'); |
|
|
|
$profit = bcsub($price,$costPrice,2); |
|
|
|
$count = $count->count(); |
|
|
|
return $content |
|
|
|
->body( |
|
|
|
<<<HTML |
|
|
|
@ -59,6 +69,12 @@ class FinanceStatisticsController extends AdminController |
|
|
|
HTML |
|
|
|
|
|
|
|
) |
|
|
|
->body(function (Row $row){ |
|
|
|
$row->column(6,function (Column $column){ |
|
|
|
$column->row(new \App\AdminAgent\Tools\DataReportDate('data_report')); |
|
|
|
}); |
|
|
|
|
|
|
|
}) |
|
|
|
->body(function (Row $row) use ($price, $profit, $count) { |
|
|
|
|
|
|
|
$row->column(4, function (Column $column) use ($price) { |
|
|
|
|