chore(admin-platform-order): disable batch mark-activated button when filters not paid+pending
This commit is contained in:
@@ -993,6 +993,14 @@
|
|||||||
|
|
||||||
<div class="tool-group focus-box">
|
<div class="tool-group focus-box">
|
||||||
<div class="tool-group-title">批量仅标记为已生效</div>
|
<div class="tool-group-title">批量仅标记为已生效</div>
|
||||||
|
@php
|
||||||
|
// 批量仅标记为已生效:前端治理提示(后端仍有安全阀阻断,这里只做“减少误点/更可治理”)
|
||||||
|
$batchMarkActivatedBlockedReason = '';
|
||||||
|
if ((string) ($filters['payment_status'] ?? '') !== 'paid' || (string) ($filters['status'] ?? '') !== 'pending') {
|
||||||
|
$batchMarkActivatedBlockedReason = '请先筛选「支付状态=已支付」且「订单状态=待处理」再执行批量生效。';
|
||||||
|
}
|
||||||
|
$batchMarkActivatedBlocked = $batchMarkActivatedBlockedReason !== '';
|
||||||
|
@endphp
|
||||||
<form method="post" action="/admin/platform-orders/batch-mark-activated" data-action="disable-on-submit" onsubmit="return confirm('确认批量将当前筛选范围内“已支付+待处理”的订单标记为已生效?(不修改支付状态,不自动同步订阅)');" class="mb-10">
|
<form method="post" action="/admin/platform-orders/batch-mark-activated" data-action="disable-on-submit" onsubmit="return confirm('确认批量将当前筛选范围内“已支付+待处理”的订单标记为已生效?(不修改支付状态,不自动同步订阅)');" class="mb-10">
|
||||||
@csrf
|
@csrf
|
||||||
<input type="hidden" name="scope" value="filtered">
|
<input type="hidden" name="scope" value="filtered">
|
||||||
@@ -1027,7 +1035,10 @@
|
|||||||
|
|
||||||
<div class="muted mb-8">提示:建议先用快捷筛选「待生效」(已支付+待处理)锁定范围,再执行批量生效。</div>
|
<div class="muted mb-8">提示:建议先用快捷筛选「待生效」(已支付+待处理)锁定范围,再执行批量生效。</div>
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<button class="btn btn-sm" type="submit">批量仅标记为已生效(当前筛选范围)</button>
|
<button class="btn btn-sm" type="submit" @disabled($batchMarkActivatedBlocked) title="{{ $batchMarkActivatedBlockedReason }}">批量仅标记为已生效(当前筛选范围)</button>
|
||||||
|
@if($batchMarkActivatedBlocked)
|
||||||
|
<div class="muted muted-xs text-danger mt-6" data-role="batch-mark-activated-blocked-hint">提示:{{ $batchMarkActivatedBlockedReason }}</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenNotPaidPendingTest 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_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"'));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user