From c04e10e27a909cb268ba8565e291395df91ba270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 13:00:52 +0800 Subject: [PATCH] chore(admin-platform-order): disable batch BMPA button when filters not pending+unpaid --- .../admin/platform_orders/index.blade.php | 16 ++++- ...nShouldDisableWhenNotPendingUnpaidTest.php | 72 +++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenNotPendingUnpaidTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 1f7a59a..2fae2c1 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -922,6 +922,17 @@
批量标记支付并生效(BMPA)
+ @php + // 批量 BMPA:前端治理提示(后端仍有安全阀阻断,这里只做“减少误点/更可治理”) + $batchBmpaBlockedReason = ''; + if ((string) ($filters['status'] ?? '') !== 'pending' || (string) ($filters['payment_status'] ?? '') !== 'unpaid') { + $batchBmpaBlockedReason = '请先筛选「订单状态=待处理」且「支付状态=未支付」再执行批量 BMPA。'; + } + if ($batchBmpaBlockedReason === '' && (((string) ($filters['reconcile_mismatch'] ?? '') === '1') || ((string) ($filters['refund_inconsistent'] ?? '') === '1'))) { + $batchBmpaBlockedReason = '当前集合包含「对账不一致/退款不一致」治理集合:建议先完成回执/退款治理后再批量推进。'; + } + $batchBmpaBlocked = $batchBmpaBlockedReason !== ''; + @endphp
@csrf @@ -956,7 +967,10 @@
提示:建议先筛选「待处理 + 未支付」后再执行,避免误操作。
- + + @if($batchBmpaBlocked) +
提示:{{ $batchBmpaBlockedReason }}
+ @endif
diff --git a/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenNotPendingUnpaidTest.php b/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenNotPendingUnpaidTest.php new file mode 100644 index 0000000..7c98aa9 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenNotPendingUnpaidTest.php @@ -0,0 +1,72 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_batch_bmpa_button_should_disable_when_filters_not_pending_unpaid(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_index_batch_bmpa_btn_disable_plan', + 'name' => '批量BMPA按钮禁用测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_IDX_BATCH_BMPA_BTN_DISABLE_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'meta' => [], + ]); + + // 当前筛选口径不为 pending+unpaid:前端按钮应禁用并提示原因(后端也会阻断,双保险)。 + $res = $this->get('/admin/platform-orders?status=activated&payment_status=paid'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertStringContainsString('批量标记支付并生效(含订阅同步)(当前筛选范围)', $html); + $this->assertStringContainsString('data-role="batch-bmpa-blocked-hint"', $html); + $this->assertStringContainsString('待处理', $html); + $this->assertStringContainsString('未支付', $html); + + // 按钮 disabled(用宽松断言,避免受 HTML 格式影响) + $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"')); + } +}