feat(platform-orders): 退款总额统计(详情页+导出)
This commit is contained in:
@@ -537,6 +537,7 @@ class PlatformOrderController extends Controller
|
|||||||
'最近退款时间',
|
'最近退款时间',
|
||||||
'最近退款金额',
|
'最近退款金额',
|
||||||
'最近退款渠道',
|
'最近退款渠道',
|
||||||
|
'退款总额',
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($includeMeta) {
|
if ($includeMeta) {
|
||||||
@@ -596,6 +597,13 @@ class PlatformOrderController extends Controller
|
|||||||
(string) (data_get($latestRefund, 'refunded_at') ?? ''),
|
(string) (data_get($latestRefund, 'refunded_at') ?? ''),
|
||||||
(float) (data_get($latestRefund, 'amount') ?? 0),
|
(float) (data_get($latestRefund, 'amount') ?? 0),
|
||||||
(string) (data_get($latestRefund, 'channel') ?? ''),
|
(string) (data_get($latestRefund, 'channel') ?? ''),
|
||||||
|
(function () use ($refunds) {
|
||||||
|
$total = 0.0;
|
||||||
|
foreach ($refunds as $r) {
|
||||||
|
$total += (float) (data_get($r, 'amount') ?? 0);
|
||||||
|
}
|
||||||
|
return $total;
|
||||||
|
})(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($includeMeta) {
|
if ($includeMeta) {
|
||||||
|
|||||||
@@ -24,6 +24,13 @@
|
|||||||
<tr><th>支付时间</th><td>{{ optional($order->paid_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
<tr><th>支付时间</th><td>{{ optional($order->paid_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
||||||
<tr><th>生效时间</th><td>{{ optional($order->activated_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
<tr><th>生效时间</th><td>{{ optional($order->activated_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
||||||
<tr><th>退款时间</th><td>{{ optional($order->refunded_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
<tr><th>退款时间</th><td>{{ optional($order->refunded_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
|
||||||
|
@php
|
||||||
|
$refundTotal = 0.0;
|
||||||
|
foreach ((array) (data_get($order->meta, 'refund_receipts', []) ?? []) as $r) {
|
||||||
|
$refundTotal += (float) (data_get($r, 'amount') ?? 0);
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
<tr><th>退款总额</th><td>¥{{ number_format($refundTotal, 2) }}</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class AdminPlatformOrderExportTest extends TestCase
|
|||||||
$this->assertStringContainsString('订阅ID', $content);
|
$this->assertStringContainsString('订阅ID', $content);
|
||||||
$this->assertStringContainsString('最近批量生效时间', $content);
|
$this->assertStringContainsString('最近批量生效时间', $content);
|
||||||
$this->assertStringContainsString('最近批量生效管理员', $content);
|
$this->assertStringContainsString('最近批量生效管理员', $content);
|
||||||
|
$this->assertStringContainsString('退款总额', $content);
|
||||||
|
|
||||||
// include_meta=1 时应包含 meta(JSON) 列
|
// include_meta=1 时应包含 meta(JSON) 列
|
||||||
$res2 = $this->get('/admin/platform-orders/export?include_meta=1');
|
$res2 = $this->get('/admin/platform-orders/export?include_meta=1');
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ class AdminPlatformOrderRefundReceiptTest extends TestCase
|
|||||||
|
|
||||||
$this->assertSame('partially_refunded', $order->payment_status);
|
$this->assertSame('partially_refunded', $order->payment_status);
|
||||||
$this->assertNotNull($order->refunded_at);
|
$this->assertNotNull($order->refunded_at);
|
||||||
|
|
||||||
|
// 确保退款轨迹可用于对账统计
|
||||||
|
$totalRefunded = 0.0;
|
||||||
|
foreach ($refunds as $r) {
|
||||||
|
$totalRefunded += (float) (data_get($r, 'amount') ?? 0);
|
||||||
|
}
|
||||||
|
$this->assertSame(10.0, $totalRefunded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_platform_admin_can_add_refund_receipt_and_mark_fully_refunded_when_total_refund_reaches_paid_amount(): void
|
public function test_platform_admin_can_add_refund_receipt_and_mark_fully_refunded_when_total_refund_reaches_paid_amount(): void
|
||||||
|
|||||||
Reference in New Issue
Block a user