fix: block batch sync when receipt_status=none

This commit is contained in:
萝卜
2026-03-14 06:26:44 +00:00
parent fcabedff08
commit 41e3246381
2 changed files with 45 additions and 0 deletions

View File

@@ -1247,6 +1247,14 @@ class PlatformOrderController extends Controller
return redirect()->back()->with('warning', '当前筛选集合包含「对账不一致/退款不一致」订单,为避免带病同步,请先完成金额/状态治理(补回执/核对退款/修正状态)后再批量同步订阅。');
}
// 防误操作(回执治理优先):当用户显式筛选「无回执」时,禁止直接批量同步
// 原因:已支付/已生效但无回执证据的订单属于收费闭环缺口,应先补齐回执留痕(可治理、可对账)再同步订阅。
if ($scope === 'filtered'
&& ($filters['syncable_only'] ?? '') === '1'
&& ((string) ($filters['receipt_status'] ?? '') === 'none')) {
return redirect()->back()->with('warning', '当前筛选为「无回执」订单集合。为保证收费闭环可治理,请先补齐支付回执留痕后再批量同步订阅。');
}
// 防误操作(口径一致):当用户显式传入了 status/payment_status 时,要求口径至少锁定「已支付+已生效」
// 说明:订阅详情页的批量同步入口会带 site_subscription_id + syncable_only=1但未必显式带 status/payment_status。
// 这里采用“仅在显式传参时校验”的策略,避免误伤订阅详情页的一键批量同步。

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderBatchActivateSubscriptionsReceiptStatusNoneBlockedTest 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_subscriptions_blocked_when_syncable_only_and_receipt_status_none_present(): void
{
$this->loginAsPlatformAdmin();
// receipt_status=none 属于“收费闭环缺口”治理集合:应先补回执留痕,再批量同步订阅
$res = $this->post('/admin/platform-orders/batch-activate-subscriptions', [
'scope' => 'filtered',
'syncable_only' => '1',
'receipt_status' => 'none',
'limit' => 50,
]);
$res->assertRedirect();
$res->assertSessionHas('warning');
}
}