平台订单详情:整理退款状态治理区块(更醒目)

This commit is contained in:
萝卜
2026-03-11 05:25:51 +00:00
parent fe19638433
commit 4b80486c0a
2 changed files with 96 additions and 19 deletions

View File

@@ -91,25 +91,32 @@
&& $order->payment_status === 'refunded'
&& (round($refundTotal * 100) + 1) < round($paidAmountFloat * 100);
@endphp
@if($canMarkRefunded)
<div class="muted" style="margin-top:10px;">
提示:退款总额已达到/超过已付金额,但支付状态尚未是「已退款」,如确认无误,可直接修正。
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-refunded" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为已退款?该操作不会自动写入退款回执,仅修正状态');">
@csrf
<button type="submit">标记为已退款</button>
</form>
</div>
@elseif($canFixRefundedButNotEnough)
<div class="muted" style="margin-top:10px;">
提示:当前支付状态为「已退款」,但退款总额不足。如确认无误,可将状态修正为「部分退款」或「已支付」。
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-partially-refunded" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为部分退款?该操作不会自动写入退款回执,仅修正状态');">
@csrf
<button type="submit">标记为部分退款</button>
</form>
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-status" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为已支付?该操作不会自动写入回执/退款回执,仅修正状态');">
@csrf
<button type="submit">标记为已支付</button>
</form>
@if($canMarkRefunded || $canFixRefundedButNotEnough)
<div class="card" style="margin-top:12px; border:1px dashed #fda29b; background:#fff1f3;">
<div class="muted" style="margin-bottom:6px;"><strong>退款状态治理</strong>(仅修正状态,不自动写回执/退款回执)</div>
<div class="muted muted-xs" style="margin-bottom:8px;">已付:¥{{ number_format($paidAmountFloat, 2) }}|退款总额:¥{{ number_format($refundTotal, 2) }}</div>
@if($canMarkRefunded)
<div class="muted">
当前支付状态不是「已退款」,但退款总额已达到/超过已付金额。
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-refunded" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为已退款?该操作不会自动写入退款回执,仅修正状态');">
@csrf
<button type="submit">标记为已退款</button>
</form>
</div>
@else
<div class="muted">
当前支付状态为「已退款」,但退款总额不足。
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-partially-refunded" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为部分退款?该操作不会自动写入退款回执,仅修正状态');">
@csrf
<button type="submit">标记为部分退款</button>
</form>
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-status" style="display:inline; margin-left:8px;" onsubmit="return confirm('确认将该订单支付状态标记为已支付?该操作不会自动写入回执/退款回执,仅修正状态');">
@csrf
<button type="submit">标记为已支付</button>
</form>
</div>
@endif
</div>
@endif

View File

@@ -0,0 +1,70 @@
<?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 AdminPlatformOrderShowRefundGovernanceBlockTest 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_show_page_can_render_refund_governance_block_when_refund_total_reaches_paid_amount(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'refund_governance_block_01',
'name' => '退款治理区块测试',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_REFUND_GOV_BLOCK_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/' . $order->id)
->assertOk()
->assertSee('退款状态治理')
->assertSee('/admin/platform-orders/' . $order->id . '/mark-refunded');
}
}