seed(); $this->post('/admin/login', [ 'email' => 'platform.admin@demo.local', 'password' => 'Platform@123456', ])->assertRedirect('/admin'); } public function test_batch_show_page_should_render_fallback_counts_without_last_result(): void { $this->loginAsPlatformAdmin(); $merchant = Merchant::query()->firstOrFail(); $plan = Plan::query()->create([ 'code' => 'plan_batch_show_fallback_counts_0001', 'name' => '批次页 fallback 粗统计测试套餐', 'billing_cycle' => 'monthly', 'price' => 10, 'list_price' => 10, 'status' => 'active', 'sort' => 10, 'published_at' => now(), ]); $runId = 'BAS_FALLBACK_COUNTS_0001'; PlatformOrder::query()->create([ 'merchant_id' => $merchant->id, 'plan_id' => $plan->id, 'order_no' => 'PO_BATCH_FALLBACK_A', '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()->subMinutes(10), 'paid_at' => now()->subMinutes(9), 'activated_at' => now()->subMinutes(8), 'meta' => [ 'batch_activation' => [ 'run_id' => $runId, ], 'subscription_activation_error' => [ 'message' => '模拟失败:同步异常', 'at' => now()->toDateTimeString(), 'admin_id' => 1, ], ], ]); PlatformOrder::query()->create([ 'merchant_id' => $merchant->id, 'plan_id' => $plan->id, 'order_no' => 'PO_BATCH_FALLBACK_B', '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()->subMinutes(7), 'paid_at' => now()->subMinutes(6), 'activated_at' => now()->subMinutes(5), 'meta' => [ 'batch_activation' => [ 'run_id' => $runId, ], ], ]); $html = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId) ->assertOk() ->getContent(); $this->assertStringContainsString('本批次尚未生成 last_result 汇总', $html); $this->assertStringContainsString('data-role="batch-matched-link"', $html); $this->assertStringContainsString('>2<', $html); $this->assertStringContainsString('data-role="batch-failed-count-link"', $html); $this->assertStringContainsString('>1<', $html); $this->assertStringContainsString('失败占比:', $html); $this->assertStringContainsString('50%', $html); } }