diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 520bf9b..a6d3251 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -1874,6 +1874,11 @@ class PlatformOrderController extends Controller 'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''), ]; + // 防误操作(治理优先):续费单未绑定订阅属于高风险治理集合,不允许直接批量仅标记为已生效。 + if ($scope === 'filtered' && ((string) ($filters['renewal_missing_subscription'] ?? '') === '1')) { + return redirect()->back()->with('warning', '当前筛选为「续费单未绑定订阅」治理集合。为避免带病推进,请先完成订阅绑定/修复关联后再批量仅标记为已生效。'); + } + // 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending) + 未同步(unsynced)」 if ($scope === 'filtered') { if (($filters['payment_status'] ?? '') !== 'paid' || ($filters['status'] ?? '') !== 'pending') { diff --git a/tests/Feature/AdminPlatformOrderBatchMarkActivatedShouldBlockWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderBatchMarkActivatedShouldBlockWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..909dd32 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderBatchMarkActivatedShouldBlockWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,39 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_batch_mark_activated_should_block_when_renewal_missing_subscription_present(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->post('/admin/platform-orders/batch-mark-activated', [ + 'scope' => 'filtered', + 'renewal_missing_subscription' => '1', + // 即便其它条件满足待生效口径,也应被治理集合优先阻断 + 'payment_status' => 'paid', + 'status' => 'pending', + 'sync_status' => 'unsynced', + 'limit' => 50, + ]); + + $res->assertRedirect(); + $res->assertSessionHas('warning'); + } +}