feat(batch): 批次页last_result缺失时提供同批次粗略统计

This commit is contained in:
萝卜
2026-03-17 16:12:07 +08:00
parent 52d1507847
commit ea9cbe430c
2 changed files with 55 additions and 5 deletions

View File

@@ -10,12 +10,17 @@
$selfWithoutBack = \App\Support\BackUrl::selfWithoutBack();
$backToListUrl = $safeBackForLinks !== '' ? $safeBackForLinks : '/admin/platform-orders';
$hasSummary = $summary !== null;
$success = (int) (data_get($summary, 'success') ?? 0);
$failed = (int) (data_get($summary, 'failed') ?? 0);
$matched = (int) (data_get($summary, 'matched') ?? 0);
$processed = (int) (data_get($summary, 'processed') ?? 0);
$at = (string) (data_get($summary, 'at') ?? '');
$topReasons = (array) (data_get($summary, 'top_reasons', []) ?? []);
$fallbackMatched = (int) (data_get($fallbackCounts, 'matched') ?? 0);
$fallbackFailed = (int) (data_get($fallbackCounts, 'failed') ?? 0);
@endphp
<div class="card mb-20">
@@ -37,18 +42,25 @@
@if(($error ?? '') !== '')
<div class="warning">{{ $error }}</div>
@else
@if(! $hasSummary)
<div class="warning mb-20">
本批次尚未生成 last_result 汇总(可能队列任务仍在执行,或历史数据未补齐)。
当前页面展示的是基于同批次订单的<strong>粗略统计</strong>,供运营先行定位。
</div>
@endif
<div class="grid-3 mb-20">
<div class="card">
<h3>命中</h3>
<div class="metric-number">{{ $matched }}</div>
<div class="metric-number">{{ $hasSummary ? $matched : $fallbackMatched }}</div>
</div>
<div class="card">
<h3>本次处理</h3>
<div class="metric-number">{{ $processed }}</div>
<div class="metric-number">{{ $hasSummary ? $processed : '-' }}</div>
</div>
<div class="card">
<h3>成功 / 失败</h3>
<div class="metric-number">{{ $success }} / {{ $failed }}</div>
<div class="metric-number">{{ $hasSummary ? ($success . ' / ' . $failed) : ('- / ' . $fallbackFailed) }}</div>
</div>
</div>
@@ -80,8 +92,10 @@
<div class="card">
<h3>Top 失败原因</h3>
@if(count($topReasons) === 0)
<div class="muted">暂无(或尚未写入 last_result</div>
@if(! $hasSummary)
<div class="muted">暂无last_result 未写入时不做原因聚合,以免在页面侧引入重查询)。</div>
@elseif(count($topReasons) === 0)
<div class="muted">暂无。</div>
@else
<table class="table">
<thead>