first
This commit is contained in:
66
server-api/app/controller/admin/DashboardController.php
Normal file
66
server-api/app/controller/admin/DashboardController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
|
||||
class DashboardController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$totalOrders = (int)Db::name('orders')->count();
|
||||
$pendingCount = (int)Db::name('orders')->whereIn('order_status', [
|
||||
'pending_payment',
|
||||
'pending_submission',
|
||||
'pending_shipping',
|
||||
'pending_supplement',
|
||||
])->count();
|
||||
$processingCount = (int)Db::name('orders')->whereIn('order_status', [
|
||||
'received',
|
||||
'pending_assignment',
|
||||
'in_first_review',
|
||||
'in_final_review',
|
||||
'generating_report',
|
||||
])->count();
|
||||
$pendingReturnCount = (int)Db::name('orders')->where('order_status', 'report_published')->count();
|
||||
$returningCount = (int)Db::name('orders')
|
||||
->alias('o')
|
||||
->join('order_logistics l', 'l.order_id = o.id')
|
||||
->where('o.order_status', 'completed')
|
||||
->where('l.logistics_type', 'return_to_user')
|
||||
->where('l.tracking_no', '<>', '')
|
||||
->where('l.tracking_status', '<>', 'received')
|
||||
->count();
|
||||
|
||||
return api_success([
|
||||
'cards' => [
|
||||
[
|
||||
'title' => '订单总量',
|
||||
'value' => $totalOrders,
|
||||
'desc' => '当前数据库内订单总数',
|
||||
],
|
||||
[
|
||||
'title' => '待处理订单',
|
||||
'value' => $pendingCount,
|
||||
'desc' => '待支付、待补资料、待寄送等订单',
|
||||
],
|
||||
[
|
||||
'title' => '处理中订单',
|
||||
'value' => $processingCount,
|
||||
'desc' => '已进入鉴定流程的订单',
|
||||
],
|
||||
[
|
||||
'title' => '待寄回订单',
|
||||
'value' => $pendingReturnCount,
|
||||
'desc' => '报告已出具,等待平台安排回寄',
|
||||
],
|
||||
[
|
||||
'title' => '回寄途中',
|
||||
'value' => $returningCount,
|
||||
'desc' => '已登记回寄运单,等待用户签收',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user