chore(admin-platform-order): refund governance forms disable on submit
This commit is contained in:
@@ -193,7 +193,7 @@
|
|||||||
@if($canMarkRefunded)
|
@if($canMarkRefunded)
|
||||||
<div class="muted">
|
<div class="muted">
|
||||||
当前支付状态不是「已退款」,但退款总额已达到/超过已付金额。
|
当前支付状态不是「已退款」,但退款总额已达到/超过已付金额。
|
||||||
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-refunded" class="inline-form" onsubmit="return confirm('确认将该订单支付状态标记为已退款?该操作不会自动写入退款回执,仅修正状态');">
|
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-refunded" class="inline-form" data-action="disable-on-submit" onsubmit="return confirm('确认将该订单支付状态标记为已退款?该操作不会自动写入退款回执,仅修正状态');">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="btn btn-danger btn-sm" type="submit">标记为已退款</button>
|
<button class="btn btn-danger btn-sm" type="submit">标记为已退款</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -201,11 +201,11 @@
|
|||||||
@else
|
@else
|
||||||
<div class="muted">
|
<div class="muted">
|
||||||
当前支付状态为「已退款」,但退款总额不足。
|
当前支付状态为「已退款」,但退款总额不足。
|
||||||
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-partially-refunded" class="inline-form" onsubmit="return confirm('确认将该订单支付状态标记为部分退款?该操作不会自动写入退款回执,仅修正状态');">
|
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-partially-refunded" class="inline-form" data-action="disable-on-submit" onsubmit="return confirm('确认将该订单支付状态标记为部分退款?该操作不会自动写入退款回执,仅修正状态');">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="btn btn-danger btn-sm" type="submit">标记为部分退款</button>
|
<button class="btn btn-danger btn-sm" type="submit">标记为部分退款</button>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-status" class="inline-form" onsubmit="return confirm('确认将该订单支付状态标记为已支付?该操作不会自动写入回执/退款回执,仅修正状态');">
|
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-status" class="inline-form" data-action="disable-on-submit" onsubmit="return confirm('确认将该订单支付状态标记为已支付?该操作不会自动写入回执/退款回执,仅修正状态');">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="btn btn-danger btn-sm" type="submit">标记为已支付</button>
|
<button class="btn btn-danger btn-sm" type="submit">标记为已支付</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?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 AdminPlatformOrderShowRefundGovernanceFormsShouldDisableOnSubmitTest 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_refund_governance_forms_should_disable_on_submit(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'refund_gov_disable_submit_01',
|
||||||
|
'name' => '退款治理禁用提交测试',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 让 canMarkRefunded = true:非 refunded 且 refund_total >= paid + tol
|
||||||
|
$order = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_REFUND_GOV_DISABLE_SUBMIT_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.01,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$html = $this->get('/admin/platform-orders/' . $order->id)
|
||||||
|
->assertOk()
|
||||||
|
->getContent();
|
||||||
|
|
||||||
|
$this->assertIsString($html);
|
||||||
|
|
||||||
|
// 退款治理区块内的关键表单必须带 data-action="disable-on-submit",避免运营重复点击造成重复请求。
|
||||||
|
$this->assertStringContainsString('/admin/platform-orders/' . $order->id . '/mark-refunded', $html);
|
||||||
|
$this->assertStringContainsString('data-action="disable-on-submit"', $html);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user