admin order 底部统计
parent
f774997e42
commit
45fff9f005
|
|
@ -13,9 +13,8 @@ use App\Admin\Actions\Show\OrderRemark;
|
||||||
use App\Admin\Extensions\Grid\Tools\Order\ExportProduct;
|
use App\Admin\Extensions\Grid\Tools\Order\ExportProduct;
|
||||||
use App\Admin\Renderable\Grid\Filter\OrderStatusIn;
|
use App\Admin\Renderable\Grid\Filter\OrderStatusIn;
|
||||||
use App\Admin\Renderable\PackageProductSimpleTable;
|
use App\Admin\Renderable\PackageProductSimpleTable;
|
||||||
use App\Admin\Repositories\Order;
|
|
||||||
use App\Enums\PayWay;
|
use App\Enums\PayWay;
|
||||||
use App\Models\Order as OrderModel;
|
use App\Models\Order;
|
||||||
use App\Models\OrderActivity;
|
use App\Models\OrderActivity;
|
||||||
use App\Models\OrderLog;
|
use App\Models\OrderLog;
|
||||||
use App\Models\OrderPackage;
|
use App\Models\OrderPackage;
|
||||||
|
|
@ -246,6 +245,36 @@ class OrderController extends AdminController
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$grid->footer(function ($collection) use ($grid) {
|
||||||
|
$query = Order::query();
|
||||||
|
$grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
|
||||||
|
if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
||||||
|
});
|
||||||
|
$count = $query->count();
|
||||||
|
$total_amount = number_format($query->sum('total_amount') / 100);
|
||||||
|
$market_price = number_format($query->sum('market_price') / 100);
|
||||||
|
$cost_price = number_format($query->sum('cost_price') / 100);
|
||||||
|
$sales_value = number_format($query->sum('sales_value'));
|
||||||
|
return <<<HTML
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>统计</td>
|
||||||
|
<td>订单数: $count</td>
|
||||||
|
<td>订单总额: $total_amount</td>
|
||||||
|
<td>市场价: $market_price</td>
|
||||||
|
<td>成本价: $cost_price</td>
|
||||||
|
<td>成长值: $sales_value</td>
|
||||||
|
<tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
HTML;
|
||||||
|
});
|
||||||
|
|
||||||
return $grid;
|
return $grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,36 @@ class OrderController extends AdminController
|
||||||
])->width(3);
|
])->width(3);
|
||||||
$filter->between('created_at')->dateTime()->width(6);
|
$filter->between('created_at')->dateTime()->width(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$grid->footer(function ($collection) use ($grid) {
|
||||||
|
$query = Order::query();
|
||||||
|
$grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
|
||||||
|
if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
|
||||||
|
});
|
||||||
|
$count = $query->count();
|
||||||
|
$total_amount = number_format($query->sum('total_amount') / 100);
|
||||||
|
$market_price = number_format($query->sum('market_price') / 100);
|
||||||
|
$cost_price = number_format($query->sum('cost_price') / 100);
|
||||||
|
$sales_value = number_format($query->sum('sales_value'));
|
||||||
|
return <<<HTML
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>统计</td>
|
||||||
|
<td>订单数: $count</td>
|
||||||
|
<td>订单总额: $total_amount</td>
|
||||||
|
<td>市场价: $market_price</td>
|
||||||
|
<td>成本价: $cost_price</td>
|
||||||
|
<td>成长值: $sales_value</td>
|
||||||
|
<tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
HTML;
|
||||||
|
});
|
||||||
return $grid;
|
return $grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue