chore(governance): block batch BMPA when refund_status=has

This commit is contained in:
萝卜
2026-03-16 23:33:10 +08:00
parent 7f1d234393
commit 485a8a639d
4 changed files with 84 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderBatchMarkPaidAndActivateShouldBlockWhenRefundStatusHasTest 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_batch_mark_paid_and_activate_should_block_when_refund_status_has_present(): void
{
$this->loginAsPlatformAdmin();
$res = $this->post('/admin/platform-orders/batch-mark-paid-and-activate', [
'scope' => 'filtered',
'status' => 'pending',
'payment_status' => 'unpaid',
'refund_status' => 'has',
'limit' => 50,
]);
$res->assertRedirect();
$res->assertSessionHas('warning');
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenRefundStatusHasTest 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_batch_bmpa_button_should_disable_when_refund_status_has_even_if_pending_unpaid(): void
{
$this->loginAsPlatformAdmin();
// pending+unpaid 是 BMPA 的基本口径,但 refund_status=has 表示存在退款轨迹,应先治理再推进。
$res = $this->get('/admin/platform-orders?status=pending&payment_status=unpaid&refund_status=has');
$res->assertOk();
$html = (string) $res->getContent();
$this->assertStringContainsString('批量标记支付并生效(含订阅同步)(当前筛选范围)', $html);
$this->assertStringContainsString('data-role="batch-bmpa-blocked-hint"', $html);
$this->assertStringContainsString('有退款', $html);
$this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
}
}