平台订单详情:存在退款/回执差额时禁用BMPA按钮并加护栏测试
This commit is contained in:
@@ -181,7 +181,7 @@
|
|||||||
<div style="margin-top:16px; display:flex; gap:12px; flex-wrap:wrap; align-items:center;">
|
<div style="margin-top:16px; display:flex; gap:12px; flex-wrap:wrap; align-items:center;">
|
||||||
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-and-activate" onsubmit="return confirm('确认将该订单标记为已支付并生效?此操作会推进状态并尝试同步订阅');">
|
<form method="post" action="/admin/platform-orders/{{ $order->id }}/mark-paid-and-activate" onsubmit="return confirm('确认将该订单标记为已支付并生效?此操作会推进状态并尝试同步订阅');">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit" @disabled(! $canMarkPaid)>标记支付并生效</button>
|
<button type="submit" @disabled(! $canMarkPaid || $markPaidBlockedByRefund || $markPaidBlockedByReceiptMismatch)>标记支付并生效</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@if($markPaidBlockedByRefund)
|
@if($markPaidBlockedByRefund)
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?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 AdminPlatformOrderShowMarkPaidAndActivateButtonDisabledWhenRefundExistsTest 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_mark_paid_and_activate_button_should_be_disabled_when_refund_exists(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'po_show_disable_bmpa_refund_plan',
|
||||||
|
'name' => '订单详情禁用BMPA-退款存在测试套餐',
|
||||||
|
'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_SHOW_DISABLE_BMPA_REFUND_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'unpaid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 0,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'refund_receipts' => [
|
||||||
|
[
|
||||||
|
'type' => 'refund',
|
||||||
|
'channel' => 'offline',
|
||||||
|
'amount' => 1,
|
||||||
|
'refunded_at' => now()->toDateTimeString(),
|
||||||
|
'note' => 'test-refund',
|
||||||
|
'created_at' => now()->toDateTimeString(),
|
||||||
|
'admin_id' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders/' . $order->id);
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
// 按现有页面渲染:应包含 disabled 属性(前端阻断,后端仍有安全阀)
|
||||||
|
$res->assertSee('action="/admin/platform-orders/' . $order->id . '/mark-paid-and-activate"', false);
|
||||||
|
$res->assertSee('标记支付并生效', false);
|
||||||
|
$res->assertSee('disabled', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user