From e23ae4de61c402b392c0cb6bf3263455e6b12012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 13:03:12 +0800 Subject: [PATCH] chore(admin-platform-order): disable batch mark-activated button when filters not paid+pending --- .../admin/platform_orders/index.blade.php | 13 +++- ...tonShouldDisableWhenNotPaidPendingTest.php | 70 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenNotPaidPendingTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 2fae2c1..3a3dbb8 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -993,6 +993,14 @@
批量仅标记为已生效
+ @php + // 批量仅标记为已生效:前端治理提示(后端仍有安全阀阻断,这里只做“减少误点/更可治理”) + $batchMarkActivatedBlockedReason = ''; + if ((string) ($filters['payment_status'] ?? '') !== 'paid' || (string) ($filters['status'] ?? '') !== 'pending') { + $batchMarkActivatedBlockedReason = '请先筛选「支付状态=已支付」且「订单状态=待处理」再执行批量生效。'; + } + $batchMarkActivatedBlocked = $batchMarkActivatedBlockedReason !== ''; + @endphp
@csrf @@ -1027,7 +1035,10 @@
提示:建议先用快捷筛选「待生效」(已支付+待处理)锁定范围,再执行批量生效。
- + + @if($batchMarkActivatedBlocked) +
提示:{{ $batchMarkActivatedBlockedReason }}
+ @endif
diff --git a/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenNotPaidPendingTest.php b/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenNotPaidPendingTest.php new file mode 100644 index 0000000..8fe44dc --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenNotPaidPendingTest.php @@ -0,0 +1,70 @@ +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_filters_not_paid_pending(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_index_batch_mark_activated_btn_disable_plan', + 'name' => '批量生效按钮禁用测试套餐', + '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_ACTIVATED_BTN_DISABLE_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders?status=activated&payment_status=unpaid'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertStringContainsString('批量仅标记为已生效(当前筛选范围)', $html); + $this->assertStringContainsString('data-role="batch-mark-activated-blocked-hint"', $html); + $this->assertStringContainsString('已支付', $html); + $this->assertStringContainsString('待处理', $html); + + $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"')); + } +}