From 52a889712a16c859b16a1d2b3f0d1490ddf5848a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 19:08:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E4=BB=AA=E8=A1=A8=E7=9B=98?= =?UTF-8?q?=E6=94=B6=E8=B4=B9=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3=E6=98=BE=E7=A4=BA=E8=AE=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/admin/dashboard.blade.php | 6 +- ...orkbenchQuickLinksShouldShowCountsTest.php | 94 +++++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 tests/Feature/AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest.php diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 6fec59b..99f82d7 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -87,10 +87,10 @@
快捷筛选:
diff --git a/tests/Feature/AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest.php b/tests/Feature/AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest.php new file mode 100644 index 0000000..b24b7b5 --- /dev/null +++ b/tests/Feature/AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest.php @@ -0,0 +1,94 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_billing_workbench_quick_links_should_show_counts(): void + { + Cache::flush(); + + $this->loginAsPlatformAdmin(); + + $merchantId = (int) Merchant::query()->value('id'); + $platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id'); + + // 构造三类集合:待支付 / 待生效 / 同步失败 + PlatformOrder::query()->create([ + 'merchant_id' => $merchantId, + 'plan_id' => null, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_DASHBOARD_UNPAID_PENDING', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'payable_amount' => 9, + 'paid_amount' => 0, + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchantId, + 'plan_id' => null, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_DASHBOARD_PAID_PENDING', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'payable_amount' => 9, + 'paid_amount' => 9, + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchantId, + 'plan_id' => null, + 'site_subscription_id' => null, + 'created_by_admin_id' => $platformAdminId ?: null, + 'order_no' => 'PO_DASHBOARD_SYNC_FAILED', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'payable_amount' => 9, + 'paid_amount' => 9, + 'meta' => [ + 'subscription_activation_error' => [ + 'message' => 'sync failed', + ], + ], + ]); + + Cache::flush(); + + // Debug:确保我们构造的数据在 DB 里 + $this->assertSame(1, PlatformOrder::query()->where('payment_status', 'unpaid')->where('status', 'pending')->count()); + $this->assertSame(2, PlatformOrder::query()->where('payment_status', 'paid')->where('status', 'pending')->count()); + + $res = $this->get('/admin'); + $res->assertOk(); + + // paid_pending 的定义是 paid + pending,其中包含 sync_failed 那一条,因此预期为 2 + $res->assertSee('待支付(1)'); + $res->assertSee('待生效(2)'); + $res->assertSee('同步失败(1)'); + } +}