feat: 로또 추천 API, 텔레그램 봇 연동, 관리자 페이지 추가

- 로또 번호 추천 구독자 전용 페이지 (/services/lotto/recommend)
- NAS 몬테카를로 API 연동 + 클라이언트 사이드 폴백
- 무료 미리보기 1개 + 구독자용 프리미엄 번호 추천
- 구독 플랜 변경: 골드(900원)/플래티넘(2,900원)/다이아(9,900원)
- 텔레그램 봇 연동: 연결/해제, 웹훅, /start 명령 처리
- 마이페이지 텔레그램 연결 UI + 가이드 모달
- 관리자 페이지 (/admin): 대시보드, 회원, 서비스, 문의 관리
- Supabase 마이그레이션: profiles 텔레그램 컬럼, 신규 상품

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 02:12:17 +09:00
parent 2469063979
commit a95715ec6b
32 changed files with 3060 additions and 35 deletions

View File

@@ -0,0 +1,25 @@
-- ============================================================
-- Migration 002: 텔레그램 연동 + 신규 로또 상품 추가
-- Supabase SQL Editor에서 실행하세요
-- ============================================================
-- ① profiles에 텔레그램 필드 추가
alter table public.profiles
add column if not exists telegram_chat_id text,
add column if not exists telegram_connect_token text,
add column if not exists telegram_token_expires timestamptz;
-- ② 신규 로또 상품 추가 (이미 있으면 가격/설명 업데이트)
insert into public.products (id, name, description, price, category) values
('lotto_gold', '로또 골드 플랜', '매주 1회 번호 추천 · 이메일 발송', 900, 'lotto'),
('lotto_platinum', '로또 플래티넘 플랜', '매주 3회 번호 + 상세 분석 + 텔레그램 알림', 2900, 'lotto'),
('lotto_diamond', '로또 다이아 플랜', '횟수 무제한 + 전체 기능 + 연간 패턴 리포트', 9900, 'lotto')
on conflict (id) do update set
name = excluded.name,
description = excluded.description,
price = excluded.price;
-- 구버전 상품 비활성화 (데이터 보존, 신규 결제만 막음)
update public.products
set is_active = false
where id in ('lotto_basic', 'lotto_premium', 'lotto_annual');

View File

@@ -66,8 +66,10 @@ create table public.products (
-- 초기 상품 데이터
insert into public.products (id, name, description, price, category) values
('saju_detail', 'AI 사주 상세 리포트', '신강/신약, 용신, 대운, AI 12가지 항목 해석', 4900, 'saju'),
('lotto_premium', '로또 프리미엄 구독', '매주 프리미엄 번호 5조합 + 통계', 4900, 'lotto');
('saju_detail', 'AI 사주 상세 리포트', '신강/신약, 용신, 대운, AI 12가지 항목 해석', 4900, 'saju'),
('lotto_gold', '로또 골드 플랜', '매주 1회 번호 추천 · 이메일 발송', 900, 'lotto'),
('lotto_platinum', '로또 플래티넘 플랜', '매주 3회 번호 + 상세 분석 + 텔레그램 알림', 2900, 'lotto'),
('lotto_diamond', '로또 다이아 플랜', '횟수 무제한 + 전체 기능 + 연간 패턴 리포트', 9900, 'lotto');
-- ④ orders (주문 - 결제 전 생성)
@@ -119,3 +121,28 @@ create table public.contact_requests (
alter table public.contact_requests enable row level security;
create policy "본인 의뢰 내역 조회" on public.contact_requests for select using (auth.uid() = user_id);
create policy "누구나 의뢰 생성" on public.contact_requests for insert with check (true);
-- ⑦ service_settings (서비스 노출 on/off 관리자 설정)
create table public.service_settings (
id text primary key, -- 서비스 ID: 'saju', 'lotto', 'stock', ...
name text not null,
description text,
is_active boolean default true,
order_index integer default 0,
updated_at timestamptz default now()
);
-- 초기 서비스 데이터
insert into public.service_settings (id, name, description, is_active, order_index) values
('saju', 'AI 사주 분석', '사주 입력 및 AI 해석 서비스', true, 1),
('lotto', '로또 번호 추천', '빅데이터 기반 로또 번호 분석', true, 2),
('stock', '주식 자동매매', '텔레그램 연동 자동매매 프로그램', true, 3),
('automation', '업무 자동화 RPA', '반복 업무 자동화 개발', true, 4),
('prompt', '프롬프트 엔지니어링', 'AI 프롬프트 설계 서비스', true, 5),
('freelance', '외주 개발', '맞춤형 소프트웨어 개발', true, 6);
-- service_settings는 누구나 읽기 가능 (공개 서비스 목록 조회용)
alter table public.service_settings enable row level security;
create policy "누구나 서비스 설정 조회" on public.service_settings for select using (true);
-- 쓰기는 service_role(관리자)만 가능 (별도 정책 없음 = anon 불가)