From 6cd8c3424586417068766c72b4940d5caafeb98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 17 Mar 2026 01:40:51 +0800 Subject: [PATCH] Governance: block batch BMPA when renewal missing subscription filter present --- .../Admin/PlatformOrderController.php | 5 +++ ...lockWhenRenewalMissingSubscriptionTest.php | 38 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderBatchMarkPaidAndActivateShouldBlockWhenRenewalMissingSubscriptionTest.php diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index a6d3251..61255c2 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -1641,6 +1641,11 @@ class PlatformOrderController extends Controller 'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''), ]; + // 防误操作(治理优先):续费单未绑定订阅属于高风险治理集合,不允许执行 BMPA(会产生大量失败标记,掩盖问题)。 + if ($scope === 'filtered' && ((string) ($filters['renewal_missing_subscription'] ?? '') === '1')) { + return redirect()->back()->with('warning', '当前筛选为「续费单未绑定订阅」治理集合。为避免带病推进,请先完成订阅绑定/修复关联后再执行 BMPA。'); + } + // 防误操作:批量“标记支付并生效”默认要求当前筛选口径为「待处理(pending) + 未支付(unpaid)」 if ($scope === 'filtered') { if (($filters['status'] ?? '') !== 'pending' || ($filters['payment_status'] ?? '') !== 'unpaid') { diff --git a/tests/Feature/AdminPlatformOrderBatchMarkPaidAndActivateShouldBlockWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderBatchMarkPaidAndActivateShouldBlockWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..ec995e9 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderBatchMarkPaidAndActivateShouldBlockWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,38 @@ +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_renewal_missing_subscription_filter_present(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->post('/admin/platform-orders/batch-mark-paid-and-activate', [ + 'scope' => 'filtered', + 'renewal_missing_subscription' => '1', + // 即便其它条件满足 BMPA 口径,也应被治理集合优先阻断 + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'limit' => 50, + ]); + + $res->assertRedirect(); + $res->assertSessionHas('warning'); + } +}