feat(platform-orders): 列表增加行级回执总额与对账差额列
This commit is contained in:
@@ -146,6 +146,15 @@ class PlatformOrderController extends Controller
|
|||||||
->paginate(10)
|
->paginate(10)
|
||||||
->withQueryString();
|
->withQueryString();
|
||||||
|
|
||||||
|
// 列表行级对账视图:回执总额 / 差额(便于运营快速定位问题订单)
|
||||||
|
$orders->getCollection()->transform(function (PlatformOrder $o) {
|
||||||
|
$receiptTotal = (float) $this->receiptTotalForOrder($o);
|
||||||
|
$o->setAttribute('receipt_total', $receiptTotal);
|
||||||
|
$o->setAttribute('reconciliation_delta_row', $receiptTotal - (float) $o->paid_amount);
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
});
|
||||||
|
|
||||||
$baseQuery = $this->applyFilters(PlatformOrder::query(), $filters);
|
$baseQuery = $this->applyFilters(PlatformOrder::query(), $filters);
|
||||||
|
|
||||||
// 同步失败原因聚合(Top 5):用于运营快速判断“常见失败原因”
|
// 同步失败原因聚合(Top 5):用于运营快速判断“常见失败原因”
|
||||||
@@ -1108,6 +1117,24 @@ class PlatformOrderController extends Controller
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function receiptTotalForOrder(PlatformOrder $order): float
|
||||||
|
{
|
||||||
|
// 优先读扁平字段 payment_summary.total_amount(更稳定、避免遍历 receipts)
|
||||||
|
$total = (float) (data_get($order->meta, 'payment_summary.total_amount') ?? 0);
|
||||||
|
if ($total > 0) {
|
||||||
|
return $total;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 回退:遍历 payment_receipts[].amount
|
||||||
|
$receipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []);
|
||||||
|
$sum = 0.0;
|
||||||
|
foreach ($receipts as $r) {
|
||||||
|
$sum += (float) (data_get($r, 'amount') ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
protected function sumReceiptAmount($orders): float
|
protected function sumReceiptAmount($orders): float
|
||||||
{
|
{
|
||||||
$total = 0.0;
|
$total = 0.0;
|
||||||
|
|||||||
@@ -340,6 +340,8 @@
|
|||||||
<th>失败原因</th>
|
<th>失败原因</th>
|
||||||
<th>最近批量同步</th>
|
<th>最近批量同步</th>
|
||||||
<th>最近批量生效</th>
|
<th>最近批量生效</th>
|
||||||
|
<th>回执总额</th>
|
||||||
|
<th>对账差额</th>
|
||||||
<th>回执数</th>
|
<th>回执数</th>
|
||||||
<th>退款数</th>
|
<th>退款数</th>
|
||||||
<th>退款总额</th>
|
<th>退款总额</th>
|
||||||
@@ -463,6 +465,24 @@
|
|||||||
<span class="muted">-</span>
|
<span class="muted">-</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@php
|
||||||
|
$receiptTotal = (float) ($order->receipt_total ?? 0);
|
||||||
|
@endphp
|
||||||
|
@if($receiptTotal > 0)
|
||||||
|
<span class="muted">¥{{ number_format($receiptTotal, 2) }}</span>
|
||||||
|
@else
|
||||||
|
<span class="muted">-</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@php $rowDelta = (float) ($order->reconciliation_delta_row ?? 0); @endphp
|
||||||
|
@if(abs($rowDelta) >= 0.01)
|
||||||
|
<span class="muted text-danger">¥{{ number_format($rowDelta, 2) }}</span>
|
||||||
|
@else
|
||||||
|
<span class="muted">¥0.00</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@php
|
@php
|
||||||
$receiptCount = count((array) (data_get($order->meta, 'payment_receipts', []) ?? []));
|
$receiptCount = count((array) (data_get($order->meta, 'payment_receipts', []) ?? []));
|
||||||
|
|||||||
Reference in New Issue
Block a user