fix(admin-dashboard): paid_pending count aligns with unsynced scope

This commit is contained in:
萝卜
2026-03-16 19:23:42 +08:00
parent 7c318ef59c
commit 763c706cf3
2 changed files with 22 additions and 2 deletions

View File

@@ -59,6 +59,25 @@ class AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest extends TestC
'paid_amount' => 9,
]);
// 脏数据兜底:即使 status=pending + paid但若 meta 已写入 subscription_activation视为已同步不应计入“待生效(unsynced)”集合。
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_BUT_ALREADY_SYNCED',
'order_type' => 'new_purchase',
'status' => 'pending',
'payment_status' => 'paid',
'payable_amount' => 9,
'paid_amount' => 9,
'meta' => [
'subscription_activation' => [
'subscription_id' => 123,
],
],
]);
PlatformOrder::query()->create([
'merchant_id' => $merchantId,
'plan_id' => null,
@@ -81,7 +100,7 @@ class AdminDashboardBillingWorkbenchQuickLinksShouldShowCountsTest extends TestC
// 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());
$this->assertSame(3, PlatformOrder::query()->where('payment_status', 'paid')->where('status', 'pending')->count());
$res = $this->get('/admin');
$res->assertOk();