웹페이지 제작 소개 페이지 생성 & 사주 분석 고도화
This commit is contained in:
@@ -6,6 +6,7 @@ import { EARTHLY_BRANCHES_KR, FIVE_ELEMENTS_KR, FIVE_ELEMENTS } from '@/lib/saju
|
||||
import { calculateElementScore, performFullAnalysis } from '@/lib/ai-interpretation';
|
||||
import { createClient } from '@/lib/supabase/server';
|
||||
import SajuAISection from './SajuAISection';
|
||||
import SajuLottoSection from './SajuLottoSection';
|
||||
|
||||
interface PageProps {
|
||||
searchParams: Promise<{
|
||||
@@ -116,13 +117,15 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
const solarTermIndex = getCurrentSolarTerm(yearNum, monthNum, dayNum);
|
||||
const solarTermName = getSolarTermName(solarTermIndex);
|
||||
|
||||
// ── 결제 여부 + 저장된 AI 해석 ────────────────────────────────────────
|
||||
// ── 결제 여부 + 저장된 AI 해석 + 로또 구독 확인 ─────────────────────
|
||||
let hasPaid = false;
|
||||
let savedInterpretation: string | null = null;
|
||||
let hasLottoSubscription = false;
|
||||
try {
|
||||
const supabase = await createClient();
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
if (user) {
|
||||
// 사주 결제 확인 (anon client — 본인 orders는 RLS 허용 가정)
|
||||
const { data: order } = await supabase
|
||||
.from('orders').select('id')
|
||||
.eq('user_id', user.id).eq('product_id', 'saju_detail').eq('status', 'paid')
|
||||
@@ -138,6 +141,31 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
.contains('saju_data', birthKey).maybeSingle();
|
||||
savedInterpretation = record?.interpretation ?? null;
|
||||
}
|
||||
|
||||
// 로또 구독 확인 — subscriptions 테이블 (세션 클라이언트로 RLS select_own 통과)
|
||||
const { data: lottoSub } = await supabase
|
||||
.from('subscriptions')
|
||||
.select('id')
|
||||
.eq('user_id', user.id)
|
||||
.eq('status', 'active')
|
||||
.in('product_id', ['lotto_gold', 'lotto_platinum', 'lotto_diamond', 'lotto_annual'])
|
||||
.maybeSingle();
|
||||
hasLottoSubscription = !!lottoSub;
|
||||
|
||||
// subscriptions에서 못 찾으면 orders 테이블로 폴백 (구독 마이그레이션 전 데이터)
|
||||
if (!hasLottoSubscription) {
|
||||
const now = new Date().toISOString();
|
||||
const thirtyOneDaysAgo = new Date(Date.now() - 31 * 24 * 60 * 60 * 1000).toISOString();
|
||||
const { data: lottoOrder } = await supabase
|
||||
.from('orders')
|
||||
.select('id, created_at')
|
||||
.eq('user_id', user.id)
|
||||
.eq('status', 'paid')
|
||||
.in('product_id', ['lotto_gold', 'lotto_platinum', 'lotto_diamond', 'lotto_annual'])
|
||||
.gte('created_at', thirtyOneDaysAgo)
|
||||
.maybeSingle();
|
||||
hasLottoSubscription = !!lottoOrder;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 미로그인 시 무시
|
||||
@@ -565,6 +593,29 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
);
|
||||
})()}
|
||||
|
||||
{/* 사주 연동 로또 번호 추천 (사주 결제 시 표시) */}
|
||||
{hasPaid && (
|
||||
<SajuLottoSection
|
||||
yongShin={analysis.yongShin.yongShin}
|
||||
yongShinKr={analysis.yongShin.yongShinKr}
|
||||
heeShin={analysis.yongShin.heeShin}
|
||||
heeShinKr={analysis.yongShin.heeShinKr}
|
||||
dayBranch={sajuData.day.branch}
|
||||
dayStemKr={sajuData.day.stemKr}
|
||||
currentDaeun={currentDaeun ? {
|
||||
stemKr: currentDaeun.stemKr,
|
||||
branchKr: currentDaeun.branchKr,
|
||||
startYear: currentDaeun.startYear,
|
||||
endYear: currentDaeun.endYear,
|
||||
age: currentDaeun.age,
|
||||
} : null}
|
||||
yearNum={yearNum}
|
||||
monthNum={monthNum}
|
||||
dayNum={dayNum}
|
||||
hasLottoSubscription={hasLottoSubscription}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 대운 */}
|
||||
<div className="bg-white rounded-2xl border border-[#dbe8ff] p-6">
|
||||
<h2 className="text-lg font-extrabold text-[#04102b] mb-5 text-center">
|
||||
|
||||
Reference in New Issue
Block a user