feat(platform-orders): 列表摘要增加对账差额视图
This commit is contained in:
@@ -275,6 +275,9 @@ class PlatformOrderController extends Controller
|
||||
}
|
||||
return $sum;
|
||||
}),
|
||||
// 对账差额:回执总额 - 订单已付总额(当前筛选范围)
|
||||
'reconciliation_delta' => (float) ($this->sumReceiptAmount((clone $baseQuery)->get()) - (float) ((clone $baseQuery)->sum('paid_amount') ?: 0)),
|
||||
'reconciliation_delta_note' => '回执总额 - 订单已付总额',
|
||||
],
|
||||
'failedReasonStats' => $failedReasonStats,
|
||||
]);
|
||||
@@ -1066,6 +1069,24 @@ class PlatformOrderController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
protected function sumReceiptAmount($orders): float
|
||||
{
|
||||
$total = 0.0;
|
||||
foreach ($orders as $o) {
|
||||
$t = (float) (data_get($o->meta, 'payment_summary.total_amount') ?? 0);
|
||||
if ($t > 0) {
|
||||
$total += $t;
|
||||
continue;
|
||||
}
|
||||
|
||||
$receipts = (array) (data_get($o->meta, 'payment_receipts', []) ?? []);
|
||||
foreach ($receipts as $r) {
|
||||
$total += (float) (data_get($r, 'amount') ?? 0);
|
||||
}
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
protected function statusLabels(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -135,6 +135,15 @@
|
||||
<div class="metric-number">{{ $summaryStats['receipt_orders'] ?? 0 }} / ¥{{ number_format((float) ($summaryStats['total_receipt_amount'] ?? 0), 2) }}</div>
|
||||
<div class="muted muted-xs">基于 meta.payment_summary.total_amount(缺省回退汇总)</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>对账差额</h3>
|
||||
@php $delta = (float) ($summaryStats['reconciliation_delta'] ?? 0); @endphp
|
||||
<div class="metric-number">¥{{ number_format($delta, 2) }}</div>
|
||||
<div class="muted muted-xs">{{ $summaryStats['reconciliation_delta_note'] ?? '回执总额 - 订单已付总额' }}(当前筛选范围)</div>
|
||||
@if(abs($delta) >= 0.01)
|
||||
<div class="muted text-danger mt-6">提示:差额非 0,可能存在回执金额与订单金额不一致的订单。</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>同步失败原因 TOP5</h3>
|
||||
@php $failedReasonStats = $failedReasonStats ?? []; @endphp
|
||||
|
||||
@@ -40,6 +40,7 @@ class AdminPlatformOrderTest extends TestCase
|
||||
->assertSee('部分退款 / 已退款')
|
||||
->assertSee('退款总额')
|
||||
->assertSee('有回执订单 / 回执总额')
|
||||
->assertSee('对账差额')
|
||||
->assertSee('快捷筛选')
|
||||
->assertSee('待支付')
|
||||
->assertSee('待生效')
|
||||
|
||||
Reference in New Issue
Block a user