套餐订单占比(Top5)
@php
$plansIndexUrl = \App\Support\BackUrl::withBack('/admin/plans', $selfWithoutBack);
@endphp
查看套餐
近7天|按订单数统计
@php
$shareRows = (array) ($planOrderShare ?? []);
$top5Orders = 0;
foreach ($shareRows as $r) {
$top5Orders += (int) ($r['count'] ?? 0);
}
$totalOrders = (int) ($planOrderShareTotal ?? 0);
if ($totalOrders <= 0) {
// 兜底:兼容旧数据(未传 total 时,至少不影响渲染)
$totalOrders = (int) $top5Orders;
}
@endphp
@php
// 用于前端渐进增强渲染占比条形图(JS 读取 data-points)
$sharePoints = [];
foreach ($shareRows as $r) {
$pid = (int) ($r['plan_id'] ?? 0);
$sharePoints[] = [
'plan_id' => $pid,
'name' => (string) (($planIdToName[$pid] ?? '') ?: ('#' . $pid)),
'count' => (int) ($r['count'] ?? 0),
];
}
@endphp
@php
$shareTop1Count = 0;
foreach ($shareRows as $r) {
$shareTop1Count = max($shareTop1Count, (int) ($r['count'] ?? 0));
}
$shareTop1Pct = $totalOrders > 0 ? round(($shareTop1Count / $totalOrders) * 100, 1) : 0;
$shareCoveragePct = $totalOrders > 0 ? round(($top5Orders / $totalOrders) * 100, 1) : 0;
$shareOtherPct = max(0, round(100 - $shareCoveragePct, 1));
$shareOtherCount = max(0, (int) $totalOrders - (int) $top5Orders);
@endphp
全量订单:{{ (int) $totalOrders }}
|
Top5合计:{{ (int) $top5Orders }}
|
覆盖率:{{ $shareCoveragePct }}%
|
其它:{{ $shareOtherPct }}%({{ (int) $shareOtherCount }}单)
|
Top1占比:{{ $shareTop1Pct }}%
| 套餐 |
订单数 |
占比 |
@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
@php
$planOrdersUrl = \App\Support\BackUrl::withBack(
'/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'plan_id' => $planId,
'created_from' => now()->subDays(6)->format('Y-m-d'),
'created_to' => now()->format('Y-m-d'),
]),
$selfWithoutBack
);
@endphp
| {{ $planName }} |
{{ $count }} |
{{ $pct }}% |
@empty
| 暂无数据 |
@endforelse
说明:当前口径为“平台订单按 plan_id 的数量占比(Top5)”;后续扩展到金额占比、渠道占比与时间范围切换。