fix: 홈 로또 카드 가격/플랜명 수정, 관리자 구독자 통계/구독 현황 추가

- 홈 카드: 월 4,900원 → 900원~, 플랜명 골드/플래티넘/다이아로 수정
- 관리자 대시보드: 활성 구독자 수 카드 추가
- 관리자 회원 목록: 구독 현황(플랜명, 만료일) 컬럼 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 03:51:18 +09:00
parent 16fa4f4c98
commit b250d4b50c
5 changed files with 43 additions and 9 deletions

View File

@@ -27,12 +27,14 @@ export async function GET() {
// 각 회원의 주문 수 + 결제 금액 집계
const enriched = await Promise.all(
(profiles ?? []).map(async (p: { id: string; email: string; full_name: string; created_at: string }) => {
const [ordersRes, paymentsRes] = await Promise.all([
const [ordersRes, paymentsRes, subsRes] = await Promise.all([
supabase.from('orders').select('id', { count: 'exact', head: true }).eq('user_id', p.id).eq('status', 'paid'),
supabase.from('payments').select('amount').eq('user_id', p.id).eq('status', 'paid'),
supabase.from('subscriptions').select('product_id, status, expires_at').eq('user_id', p.id).eq('status', 'active').order('created_at', { ascending: false }).limit(1),
]);
const totalPaid = (paymentsRes.data ?? []).reduce((s: number, x: { amount: number }) => s + x.amount, 0);
return { ...p, orderCount: ordersRes.count ?? 0, totalPaid };
const activeSub = subsRes.data?.[0] ?? null;
return { ...p, orderCount: ordersRes.count ?? 0, totalPaid, activeSub };
})
);