ui(dashboard): 平台定位北极星指标补齐 mini bar

This commit is contained in:
萝卜
2026-03-17 07:37:32 +08:00
parent fb21e069a8
commit b2d5101d77
2 changed files with 63 additions and 0 deletions

View File

@@ -521,6 +521,34 @@
</tr>
</table>
@php
// 北极星指标图形化:给运营“规模感/健康感”,但不引入额外分类维度。
$merchantsTotal = (int) ($stats['merchants'] ?? 0);
$pctActivePaidMerchants = $merchantsTotal > 0 ? min(100, max(0, round(($activePaidMerchants / $merchantsTotal) * 100, 1))) : 0;
@endphp
<div class="mt-10" data-role="platform-ops-northstar-bars">
<div class="muted"><strong>北极星指标(图形化)</strong></div>
<a class="adm-mini-bar-row adm-mini-bar-row-link mt-6" data-role="ops-northstar-active-paid-merchants-row" href="{!! (string) ($opsLinks['active_paid_merchants_subscriptions'] ?? $billingEntryLinks['site_subscriptions']) !!}" aria-label="进入活跃付费站点订阅集合">
<div class="adm-mini-bar-label">付费渗透</div>
<div class="adm-mini-bar" data-role="ops-northstar-active-paid-merchants-bar" title="{{ $activePaidMerchants }} / {{ $merchantsTotal }}{{ $pctActivePaidMerchants }}%">
<span class="adm-mini-bar-fill" style="width: {{ $pctActivePaidMerchants }}%"></span>
</div>
<div class="adm-mini-bar-value">{{ $pctActivePaidMerchants }}%{{ $activePaidMerchants }}</div>
</a>
<a class="adm-mini-bar-row adm-mini-bar-row-link mt-6" data-role="ops-northstar-renewal-rate-row" href="{!! (string) ($opsLinks['renewal_orders_30d'] ?? $billingEntryLinks['platform_orders']) !!}" aria-label="进入近30天续费订单集合">
<div class="adm-mini-bar-label">续费成功率</div>
<div class="adm-mini-bar" data-role="ops-northstar-renewal-rate-bar" title="{{ $renewalRate30d }}%{{ $renewalSuccess30d }} / {{ $renewalCreated30d }}">
<span class="adm-mini-bar-fill" style="width: {{ $renewalRate30d }}%"></span>
</div>
<div class="adm-mini-bar-value">{{ $renewalRate30d }}%</div>
</a>
<div class="muted muted-xs mt-6">说明:付费渗透 = 活跃付费站点 / 站点总数续费成功率按近30天续费单计算。</div>
</div>
@php
$den = max(1, $ordersTotal7d);
$pctUnpaidPending = $den > 0 ? min(100, max(0, round(($funnelUnpaidPending7d / $den) * 100, 1))) : 0;

View File

@@ -0,0 +1,35 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardPlatformOpsOverviewNorthStarMiniBarsShouldRenderTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_dashboard_platform_ops_overview_should_render_northstar_mini_bars(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin');
$res->assertOk();
$html = (string) $res->getContent();
$this->assertStringContainsString('data-role="platform-ops-northstar-bars"', $html);
$this->assertStringContainsString('data-role="ops-northstar-active-paid-merchants-bar"', $html);
$this->assertStringContainsString('data-role="ops-northstar-renewal-rate-bar"', $html);
}
}