feat(admin): 仪表盘占比卡接入套餐订单占比(Top5)

This commit is contained in:
萝卜
2026-03-15 18:57:48 +08:00
parent 257b532757
commit a47d91df96
3 changed files with 101 additions and 3 deletions

View File

@@ -151,9 +151,49 @@
</div>
<div class="card">
<h3 class="mt-0">占比(占位)</h3>
<div class="muted">后续接入:套餐销量占比 / 渠道占比 / 支付方式占比(支持时间范围切换)。</div>
<div class="muted muted-xs mt-10">说明:后续会补占比卡的 legend 与颜色体系(对齐 AntD Pro</div>
<div class="flex-between">
<h3 class="mt-0">套餐订单占比Top5</h3>
<a class="muted" href="/admin/plans">查看套餐</a>
</div>
@php
$shareRows = (array) ($planOrderShare ?? []);
$totalOrders = 0;
foreach ($shareRows as $r) {
$totalOrders += (int) ($r['count'] ?? 0);
}
@endphp
<table>
<thead>
<tr>
<th>套餐</th>
<th>订单数</th>
<th>占比</th>
</tr>
</thead>
<tbody>
@forelse($shareRows as $row)
@php
$planId = (int) ($row['plan_id'] ?? 0);
$count = (int) ($row['count'] ?? 0);
$pct = $totalOrders > 0 ? round(($count / $totalOrders) * 100, 1) : 0;
$planName = (string) (($planIdToName[$planId] ?? '') ?: ('#' . $planId));
@endphp
<tr>
<td>{{ $planName }}</td>
<td>{{ $count }}</td>
<td>{{ $pct }}%</td>
</tr>
@empty
<tr>
<td colspan="3" class="muted">暂无数据</td>
</tr>
@endforelse
</tbody>
</table>
<div class="muted muted-xs mt-10">说明:当前口径为“平台订单按 plan_id 的数量占比Top5后续扩展到金额占比、渠道占比与时间范围切换。</div>
</div>
</div>
@endsection