From 43d78193ea3745c9ea3772f138c34a58bfc700a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 13 Mar 2026 17:09:01 +0000 Subject: [PATCH] Keep batch bmpa 24h filter in clear errors tools filtered scope --- .../Admin/PlatformOrderController.php | 2 + ...BmpaErrorsBatchBmpa24hFilterFieldsTest.php | 108 +++++++++++++++++ ...SyncErrorsBatchBmpa24hFilterFieldsTest.php | 112 ++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderClearBmpaErrorsBatchBmpa24hFilterFieldsTest.php create mode 100644 tests/Feature/AdminPlatformOrderClearSyncErrorsBatchBmpa24hFilterFieldsTest.php diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 49d4ba3..35889b0 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -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', '')), diff --git a/tests/Feature/AdminPlatformOrderClearBmpaErrorsBatchBmpa24hFilterFieldsTest.php b/tests/Feature/AdminPlatformOrderClearBmpaErrorsBatchBmpa24hFilterFieldsTest.php new file mode 100644 index 0000000..9c21207 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderClearBmpaErrorsBatchBmpa24hFilterFieldsTest.php @@ -0,0 +1,108 @@ +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')); + } +} diff --git a/tests/Feature/AdminPlatformOrderClearSyncErrorsBatchBmpa24hFilterFieldsTest.php b/tests/Feature/AdminPlatformOrderClearSyncErrorsBatchBmpa24hFilterFieldsTest.php new file mode 100644 index 0000000..f80aa3e --- /dev/null +++ b/tests/Feature/AdminPlatformOrderClearSyncErrorsBatchBmpa24hFilterFieldsTest.php @@ -0,0 +1,112 @@ +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')); + } +}