Dashboard recent platform orders: add mini chart summary with links

This commit is contained in:
萝卜
2026-03-18 07:50:51 +08:00
parent 37ef934e40
commit bd153c9813
3 changed files with 248 additions and 0 deletions

View File

@@ -825,6 +825,117 @@
<a class="muted" href="{!! $platformOrdersQuickLinks['platform_orders'] !!}">查看全部</a>
</div>
@php
// 最近平台订单:概览 mini chart渐进增强
// 目标:让“最近订单列表”也纳入数据图形化体系,但不牺牲明细扫描行。
$recentPos = (array) ($recentPlatformOrders ?? []);
$recentTotal = count($recentPos);
$recentCntBmpaSuccess = 0;
$recentCntBmpaFailed = 0;
$recentCntSyncSuccess = 0;
$recentCntSyncFailed = 0;
$recentCntRenewalMissing = 0;
$recentCntRefundTrace = 0;
$recentCntReconcileMismatch = 0;
foreach ($recentPos as $rpo) {
$orderType = (string) ($rpo->order_type ?? '');
$bmpaErr = (string) (data_get($rpo, 'meta.batch_mark_paid_and_activate_error.message') ?? '');
$bmpaRunId = (string) (data_get($rpo, 'meta.batch_mark_paid_and_activate.run_id') ?? '');
if ($bmpaErr !== '') {
$recentCntBmpaFailed++;
} elseif ($bmpaRunId !== '') {
$recentCntBmpaSuccess++;
}
$syncErr = (string) (data_get($rpo, 'meta.subscription_activation_error.message') ?? '');
$syncSubId = (string) (data_get($rpo, 'meta.subscription_activation.subscription_id') ?? '');
if ($syncErr !== '') {
$recentCntSyncFailed++;
} elseif ($syncSubId !== '') {
$recentCntSyncSuccess++;
}
if ($orderType === 'renewal' && ((int) ($rpo->site_subscription_id ?? 0) <= 0)) {
$recentCntRenewalMissing++;
}
$refundTotal = (float) (data_get($rpo, 'refund_total') ?? 0);
if ($refundTotal > 0) {
$recentCntRefundTrace++;
}
if ((bool) (data_get($rpo, 'reconciliation_delta_row') ?? 0) != 0) {
$recentCntReconcileMismatch++;
}
}
// clickable links: 复用 $platformOrdersQuickLinks保证口径不漂移
$recentMiniPoints = [
[
'key' => 'bmpa_success',
'label' => 'BMPA成功',
'count' => $recentCntBmpaSuccess,
'href' => $platformOrdersQuickLinks['bmpa_success'] ?? $platformOrdersQuickLinks['platform_orders'],
'tone' => 'success',
],
[
'key' => 'bmpa_failed',
'label' => 'BMPA失败',
'count' => $recentCntBmpaFailed,
'href' => $platformOrdersQuickLinks['bmpa_failed'] ?? $platformOrdersQuickLinks['platform_orders'],
'tone' => 'danger',
],
[
'key' => 'sync_success',
'label' => '同步成功',
'count' => $recentCntSyncSuccess,
'href' => \App\Support\BackUrl::withBack('/admin/platform-orders?' . \Illuminate\Support\Arr::query([
'sync_status' => 'synced',
]), $selfWithoutBack),
'tone' => 'success',
],
[
'key' => 'sync_failed',
'label' => '同步失败',
'count' => $recentCntSyncFailed,
'href' => $platformOrdersQuickLinks['sync_failed'] ?? $platformOrdersQuickLinks['platform_orders'],
'tone' => 'danger',
],
[
'key' => 'renewal_missing_subscription',
'label' => '续费缺订阅',
'count' => $recentCntRenewalMissing,
'href' => $platformOrdersQuickLinks['renewal_missing_subscription'] ?? $platformOrdersQuickLinks['platform_orders'],
'tone' => 'warn',
],
[
'key' => 'refund_trace',
'label' => '有退款轨迹',
'count' => $recentCntRefundTrace,
'href' => \App\Support\BackUrl::withBack('/admin/platform-orders?refund_status=has', $selfWithoutBack),
'tone' => 'warn',
],
[
'key' => 'reconcile_mismatch',
'label' => '对账不一致',
'count' => $recentCntReconcileMismatch,
'href' => $platformOrdersQuickLinks['reconcile_mismatch'] ?? $platformOrdersQuickLinks['platform_orders'],
'tone' => 'danger',
],
];
@endphp
<div class="adm-mini-rank" data-role="recent-platform-orders-mini-bars" data-total="{{ $recentTotal }}" data-points='@json($recentMiniPoints)'></div>
<div class="adm-mini-meta" data-role="recent-platform-orders-mini-meta">
<span class="adm-mini-meta-item">最近:<strong>{{ $recentTotal }}</strong> </span>
<span class="adm-mini-meta-sep"></span>
<span class="adm-mini-meta-item">说明:点击条目进入对应治理集合(用于快速 spot-check</span>
</div>
<table data-role="recent-platform-orders-table">
<thead>
<tr>