chore(governance): block batch activate when refund_status=has
This commit is contained in:
@@ -1447,6 +1447,13 @@ class PlatformOrderController extends Controller
|
||||
return redirect()->back()->with('warning', '当前筛选集合包含「对账不一致/退款不一致」订单,为避免带病同步,请先完成金额/状态治理(补回执/核对退款/修正状态)后再批量同步订阅。');
|
||||
}
|
||||
|
||||
// 防误操作(退款治理优先):当用户显式筛选「有退款」时,禁止直接批量同步
|
||||
if ($scope === 'filtered'
|
||||
&& ($filters['syncable_only'] ?? '') === '1'
|
||||
&& ((string) ($filters['refund_status'] ?? '') === 'has')) {
|
||||
return redirect()->back()->with('warning', '当前筛选为「有退款」订单集合。为避免带退款订单直接同步订阅,请先完成退款治理(核对退款回执/修正状态)后再批量同步订阅。');
|
||||
}
|
||||
|
||||
// 防误操作(回执治理优先):当用户显式筛选「无回执」时,禁止直接批量同步
|
||||
// 原因:已支付/已生效但无回执证据的订单属于收费闭环缺口,应先补齐回执留痕(可治理、可对账)再同步订阅。
|
||||
if ($scope === 'filtered'
|
||||
|
||||
@@ -68,6 +68,9 @@ class PlatformOrderToolsGuard
|
||||
if ((string) ($filters['receipt_status'] ?? '') === 'none') {
|
||||
return '当前集合为「无回执」:建议先补齐支付回执留痕后再批量同步。';
|
||||
}
|
||||
if ((string) ($filters['refund_status'] ?? '') === 'has') {
|
||||
return '当前集合为「有退款」:为避免带退款订单直接同步订阅,请先完成退款治理(核对退款回执/修正状态)后再批量同步。';
|
||||
}
|
||||
if (((string) ($filters['reconcile_mismatch'] ?? '') === '1') || ((string) ($filters['refund_inconsistent'] ?? '') === '1')) {
|
||||
return '当前集合包含「对账不一致/退款不一致」:建议先完成金额/状态治理后再批量同步。';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderBatchActivateSubscriptionsShouldBlockWhenRefundStatusHasTest 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_activate_should_block_when_refund_status_has_present(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->post('/admin/platform-orders/batch-activate-subscriptions', [
|
||||
'scope' => 'filtered',
|
||||
'syncable_only' => '1',
|
||||
'refund_status' => 'has',
|
||||
'limit' => 50,
|
||||
]);
|
||||
|
||||
$res->assertRedirect();
|
||||
$res->assertSessionHas('warning');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexBatchActivateButtonShouldDisableWhenRefundStatusHasTest 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_activate_button_should_disable_when_refund_status_has_even_if_syncable_only_checked(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/platform-orders?syncable_only=1&refund_status=has');
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
$this->assertStringContainsString('批量同步订阅(当前筛选范围)', $html);
|
||||
$this->assertStringContainsString('data-role="batch-activate-subscriptions-blocked-hint"', $html);
|
||||
$this->assertStringContainsString('有退款', $html);
|
||||
|
||||
$this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user