Keep batch bmpa 24h filter in clear errors tools filtered scope

This commit is contained in:
萝卜
2026-03-13 17:09:01 +00:00
parent 4d842e5743
commit 43d78193ea
3 changed files with 222 additions and 0 deletions

View File

@@ -1213,6 +1213,7 @@ class PlatformOrderController extends Controller
'bmpa_error_keyword' => trim((string) $request->input('bmpa_error_keyword', '')),
'syncable_only' => (string) $request->input('syncable_only', ''),
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
'batch_mark_paid_and_activate_24h' => (string) $request->input('batch_mark_paid_and_activate_24h', ''),
'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''),
'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''),
'receipt_status' => trim((string) $request->input('receipt_status', '')),
@@ -1620,6 +1621,7 @@ class PlatformOrderController extends Controller
'bmpa_error_keyword' => trim((string) $request->input('bmpa_error_keyword', '')),
'syncable_only' => (string) $request->input('syncable_only', ''),
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
'batch_mark_paid_and_activate_24h' => (string) $request->input('batch_mark_paid_and_activate_24h', ''),
'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''),
'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''),
'receipt_status' => trim((string) $request->input('receipt_status', '')),

View File

@@ -0,0 +1,108 @@
<?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 AdminPlatformOrderClearBmpaErrorsBatchBmpa24hFilterFieldsTest 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_clear_bmpa_errors_filtered_scope_respects_batch_mark_paid_and_activate_24h_filter_fields(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'clear_bmpa_batch_bmpa_24h_plan',
'name' => '清理BMPA失败标记 24h筛选透传 测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$recent = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_CLEAR_BMPA_24H_RECENT',
'order_type' => 'renewal',
'status' => 'pending',
'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' => [
'batch_mark_paid_and_activate' => [
'at' => now()->toDateTimeString(),
'admin_id' => 1,
'scope' => 'filtered',
],
'batch_mark_paid_and_activate_error' => [
'message' => '模拟BMPA失败recent',
'at' => now()->toDateTimeString(),
'admin_id' => 1,
],
],
]);
$old = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_CLEAR_BMPA_24H_OLD',
'order_type' => 'renewal',
'status' => 'pending',
'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()->subHours(30),
'meta' => [
'batch_mark_paid_and_activate' => [
'at' => now()->subHours(30)->toDateTimeString(),
'admin_id' => 1,
'scope' => 'filtered',
],
'batch_mark_paid_and_activate_error' => [
'message' => '模拟BMPA失败old',
'at' => now()->subHours(30)->toDateTimeString(),
'admin_id' => 1,
],
],
]);
$this->post('/admin/platform-orders/clear-bmpa-errors', [
'scope' => 'filtered',
'batch_mark_paid_and_activate_24h' => '1',
])->assertRedirect();
$recent->refresh();
$old->refresh();
$this->assertNull(data_get($recent->meta, 'batch_mark_paid_and_activate_error'));
$this->assertNotNull(data_get($old->meta, 'batch_mark_paid_and_activate_error'));
}
}

View File

@@ -0,0 +1,112 @@
<?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 AdminPlatformOrderClearSyncErrorsBatchBmpa24hFilterFieldsTest 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_clear_sync_errors_filtered_scope_respects_batch_mark_paid_and_activate_24h_filter_fields(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'clear_sync_batch_bmpa_24h_plan',
'name' => '清理同步失败标记 24h批量BMPA筛选透传 测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$recent = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_CLEAR_SYNC_24H_RECENT',
'order_type' => 'renewal',
'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(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'batch_mark_paid_and_activate' => [
'at' => now()->toDateTimeString(),
'admin_id' => 1,
'scope' => 'filtered',
],
'subscription_activation_error' => [
'message' => '模拟同步失败recent',
'at' => now()->toDateTimeString(),
'admin_id' => 1,
],
],
]);
$old = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_CLEAR_SYNC_24H_OLD',
'order_type' => 'renewal',
'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()->subHours(30),
'paid_at' => now()->subHours(30),
'activated_at' => now()->subHours(30),
'meta' => [
'batch_mark_paid_and_activate' => [
'at' => now()->subHours(30)->toDateTimeString(),
'admin_id' => 1,
'scope' => 'filtered',
],
'subscription_activation_error' => [
'message' => '模拟同步失败old',
'at' => now()->subHours(30)->toDateTimeString(),
'admin_id' => 1,
],
],
]);
$this->post('/admin/platform-orders/clear-sync-errors', [
'scope' => 'filtered',
'batch_mark_paid_and_activate_24h' => '1',
])->assertRedirect();
$recent->refresh();
$old->refresh();
$this->assertNull(data_get($recent->meta, 'subscription_activation_error'));
$this->assertNotNull(data_get($old->meta, 'subscription_activation_error'));
}
}