平台订单列表:退款不一致行级提示与跳转退款区
This commit is contained in:
@@ -639,11 +639,33 @@
|
||||
$refundTotal += (float) (data_get($r, 'amount') ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
$paidAmountFloat = (float) ($order->paid_amount ?? 0);
|
||||
$isRefundInconsistent = false;
|
||||
if ($paidAmountFloat > 0) {
|
||||
if ((string) $order->payment_status === 'refunded') {
|
||||
$isRefundInconsistent = (round($refundTotal * 100) + 1) < round($paidAmountFloat * 100);
|
||||
} else {
|
||||
$isRefundInconsistent = round($refundTotal * 100) >= round($paidAmountFloat * 100);
|
||||
}
|
||||
}
|
||||
|
||||
$refundShowUrl = '/admin/platform-orders/' . $order->id . '#refund-receipts';
|
||||
@endphp
|
||||
@if($refundTotal > 0)
|
||||
<span class="muted">¥{{ number_format($refundTotal, 2) }}</span>
|
||||
@if($isRefundInconsistent)
|
||||
<a class="link text-danger" href="{{ $refundShowUrl }}">¥{{ number_format($refundTotal, 2) }}</a>
|
||||
<div class="muted text-danger muted-xs">疑似不一致</div>
|
||||
@else
|
||||
<a class="muted" href="{{ $refundShowUrl }}">¥{{ number_format($refundTotal, 2) }}</a>
|
||||
@endif
|
||||
@else
|
||||
<span class="muted">-</span>
|
||||
@if($isRefundInconsistent)
|
||||
<a class="link text-danger" href="{{ $refundShowUrl }}">-</a>
|
||||
<div class="muted text-danger muted-xs">疑似不一致</div>
|
||||
@else
|
||||
<span class="muted">-</span>
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -256,7 +256,7 @@
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="card mb-20">
|
||||
<div class="card mb-20" id="refund-receipts">
|
||||
<h3>退款记录(退款轨迹留痕)</h3>
|
||||
<p class="muted muted-tight">用于记录退款动作与对账轨迹(先落 meta,不引入独立表)。追加退款后,系统会自动把支付状态推进为“部分退款/已退款”(仅在订单当前为已支付时)。</p>
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderRefundInconsistentRowHintTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function loginAsPlatformAdmin(): void
|
||||
{
|
||||
$this->seed();
|
||||
|
||||
$this->post('/admin/login', [
|
||||
'email' => 'platform.admin@demo.local',
|
||||
'password' => 'Platform@123456',
|
||||
])->assertRedirect('/admin');
|
||||
}
|
||||
|
||||
public function test_platform_orders_row_can_show_refund_inconsistent_hint_and_link_to_refund_anchor(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'refund_inconsistent_row_hint_plan',
|
||||
'name' => '退款不一致行级提示测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_ROW_REFUND_INCONS_0001',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'activated',
|
||||
'payment_status' => 'paid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 10,
|
||||
'placed_at' => now(),
|
||||
'paid_at' => now(),
|
||||
'activated_at' => now(),
|
||||
'meta' => [
|
||||
'refund_summary' => [
|
||||
'count' => 1,
|
||||
'total_amount' => 10.00,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->get('/admin/platform-orders')
|
||||
->assertOk()
|
||||
->assertSee('PO_ROW_REFUND_INCONS_0001')
|
||||
->assertSee('疑似不一致')
|
||||
->assertSee('#refund-receipts');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user