chore(governance): block batch mark activated when receipt none/refund has
This commit is contained in:
@@ -1885,6 +1885,16 @@ class PlatformOrderController extends Controller
|
|||||||
return redirect()->back()->with('warning', '当前已勾选「只看可同步」:该集合语义为“已生效(activated)+未同步”,与本动作处理的“待处理(pending)”互斥。请先取消只看可同步后再执行。');
|
return redirect()->back()->with('warning', '当前已勾选「只看可同步」:该集合语义为“已生效(activated)+未同步”,与本动作处理的“待处理(pending)”互斥。请先取消只看可同步后再执行。');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 治理优先:当用户显式筛选「无回执」时,不允许直接批量生效
|
||||||
|
if ((string) ($filters['receipt_status'] ?? '') === 'none') {
|
||||||
|
return redirect()->back()->with('warning', '当前筛选为「无回执」订单集合。为保证收费闭环可治理,请先补齐支付回执留痕后再执行批量仅标记为已生效。');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 治理优先:当用户显式筛选「有退款」时,不允许直接批量生效
|
||||||
|
if ((string) ($filters['refund_status'] ?? '') === 'has') {
|
||||||
|
return redirect()->back()->with('warning', '当前筛选为「有退款」订单集合。为避免带退款订单直接批量生效,请先完成退款治理(核对退款回执/修正状态)后再执行。');
|
||||||
|
}
|
||||||
|
|
||||||
// 治理优先:当筛选集合命中“对账不一致/退款不一致”时,不允许直接批量生效
|
// 治理优先:当筛选集合命中“对账不一致/退款不一致”时,不允许直接批量生效
|
||||||
if ((string) ($filters['reconcile_mismatch'] ?? '') === '1' || (string) ($filters['refund_inconsistent'] ?? '') === '1') {
|
if ((string) ($filters['reconcile_mismatch'] ?? '') === '1' || (string) ($filters['refund_inconsistent'] ?? '') === '1') {
|
||||||
return redirect()->back()->with('warning', '当前筛选集合包含「对账不一致/退款不一致」订单,为避免带病推进,请先完成金额/状态治理(补回执/核对退款/修正状态)后再执行批量仅标记为已生效。');
|
return redirect()->back()->with('warning', '当前筛选集合包含「对账不一致/退款不一致」订单,为避免带病推进,请先完成金额/状态治理(补回执/核对退款/修正状态)后再执行批量仅标记为已生效。');
|
||||||
|
|||||||
@@ -132,6 +132,12 @@ class PlatformOrderToolsGuard
|
|||||||
if ((string) ($filters['syncable_only'] ?? '') === '1') {
|
if ((string) ($filters['syncable_only'] ?? '') === '1') {
|
||||||
return '当前已勾选「只看可同步」:该集合语义为“已生效(activated)+未同步”,与本动作处理的“待处理(pending)”互斥。请先取消只看可同步后再执行。';
|
return '当前已勾选「只看可同步」:该集合语义为“已生效(activated)+未同步”,与本动作处理的“待处理(pending)”互斥。请先取消只看可同步后再执行。';
|
||||||
}
|
}
|
||||||
|
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')) {
|
if (((string) ($filters['reconcile_mismatch'] ?? '') === '1') || ((string) ($filters['refund_inconsistent'] ?? '') === '1')) {
|
||||||
return '当前集合包含「对账不一致/退款不一致」治理集合:建议先完成金额/状态治理(补回执/核对退款/修正状态)后再批量生效。';
|
return '当前集合包含「对账不一致/退款不一致」治理集合:建议先完成金额/状态治理(补回执/核对退款/修正状态)后再批量生效。';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,17 +86,21 @@ class AdminPlatformOrderBatchMarkActivatedRefundStatusFilterFieldsTest extends T
|
|||||||
$page->assertSee('name="refund_status"', false);
|
$page->assertSee('name="refund_status"', false);
|
||||||
$page->assertSee('value="none"', false);
|
$page->assertSee('value="none"', false);
|
||||||
|
|
||||||
$this->post('/admin/platform-orders/batch-mark-activated', [
|
$res = $this->post('/admin/platform-orders/batch-mark-activated', [
|
||||||
'scope' => 'filtered',
|
'scope' => 'filtered',
|
||||||
'payment_status' => 'paid',
|
'payment_status' => 'paid',
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
|
'sync_status' => 'unsynced',
|
||||||
'refund_status' => 'none',
|
'refund_status' => 'none',
|
||||||
'limit' => 50,
|
'limit' => 50,
|
||||||
])->assertRedirect();
|
]);
|
||||||
|
|
||||||
|
$res->assertRedirect();
|
||||||
|
|
||||||
$a->refresh();
|
$a->refresh();
|
||||||
$b->refresh();
|
$b->refresh();
|
||||||
|
|
||||||
|
// 口径升级:只允许在“无退款”集合上推进;因此 A 会被推进、B 保持 pending。
|
||||||
$this->assertSame('activated', $a->status);
|
$this->assertSame('activated', $a->status);
|
||||||
$this->assertSame('pending', $b->status);
|
$this->assertSame('pending', $b->status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderBatchMarkActivatedShouldBlockWhenReceiptStatusNoneTest 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_activated_should_block_when_receipt_status_none_is_set(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->post('/admin/platform-orders/batch-mark-activated', [
|
||||||
|
'scope' => 'filtered',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'status' => 'pending',
|
||||||
|
'sync_status' => 'unsynced',
|
||||||
|
'receipt_status' => 'none',
|
||||||
|
'limit' => 50,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res->assertRedirect();
|
||||||
|
$res->assertSessionHas('warning');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderBatchMarkActivatedShouldBlockWhenRefundStatusHasTest 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_activated_should_block_when_refund_status_has_is_set(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->post('/admin/platform-orders/batch-mark-activated', [
|
||||||
|
'scope' => 'filtered',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'status' => 'pending',
|
||||||
|
'sync_status' => 'unsynced',
|
||||||
|
'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 AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenReceiptStatusNoneTest 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_activated_button_should_disable_when_receipt_status_none_even_if_paid_pending(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?payment_status=paid&status=pending&sync_status=unsynced&receipt_status=none');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
$this->assertStringContainsString('批量仅标记为已生效(当前筛选范围)', $html);
|
||||||
|
$this->assertStringContainsString('data-role="batch-mark-activated-blocked-hint"', $html);
|
||||||
|
$this->assertStringContainsString('无回执', $html);
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenRefundStatusHasTest 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_activated_button_should_disable_when_refund_status_has_even_if_paid_pending(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?payment_status=paid&status=pending&sync_status=unsynced&refund_status=has');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
$this->assertStringContainsString('批量仅标记为已生效(当前筛选范围)', $html);
|
||||||
|
$this->assertStringContainsString('data-role="batch-mark-activated-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