feat(admin): 仪表盘占比卡接入套餐订单占比(Top5)
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\Admin;
|
||||
use App\Models\Order;
|
||||
use App\Models\Product;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use App\Models\User;
|
||||
use App\Support\CacheKeys;
|
||||
@@ -59,10 +60,31 @@ class DashboardController extends Controller
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
// 占比卡(最小可用):按套餐统计平台订单数量 TopN
|
||||
$planOrderShare = PlatformOrder::query()
|
||||
->selectRaw('plan_id, COUNT(*) as cnt')
|
||||
->whereNotNull('plan_id')
|
||||
->groupBy('plan_id')
|
||||
->orderByDesc('cnt')
|
||||
->limit(5)
|
||||
->get()
|
||||
->map(function ($row) {
|
||||
return [
|
||||
'plan_id' => (int) $row->plan_id,
|
||||
'count' => (int) $row->cnt,
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$planIdToName = Plan::query()->pluck('name', 'id')->all();
|
||||
|
||||
return view('admin.dashboard', [
|
||||
'adminName' => $admin->name,
|
||||
'stats' => $stats,
|
||||
'recentPlatformOrders' => $recentPlatformOrders,
|
||||
'planOrderShare' => $planOrderShare,
|
||||
'planIdToName' => $planIdToName,
|
||||
'platformAdmin' => $admin,
|
||||
'cacheMeta' => [
|
||||
'store' => config('cache.default'),
|
||||
|
||||
Reference in New Issue
Block a user