feat(ai): Ask Chat 대화권 과금 정책 추가 - #204
Merged
Merged
Conversation
ask_chat_wallets와 ask_chat_wallet_logs 테이블을 추가해 무료/유료 대화권 잔액과 지갑 변동 이력을 분리 저장하도록 구현함
AskChatWalletGrantService를 추가해 신규 사용자에게 무료 대화권 3회를 지급하도록 구현함. 일반 가입, 신규 소셜 가입, 테스트 계정 생성 흐름에 초기 지급을 연결하고, 기존 사용자 보정을 위한 backfill migration과 지급 서비스 테스트를 추가함
30 크리스탈을 차감해 유료 대화권 10회를 충전하는 Ask Chat 충전 API와 서비스를 추가함. 크리스탈 차감 이력은 CrystalLog에, 대화권 충전 이력은 AskChatWalletLog에 각각 기록하고, 충전 후 크리스탈 및 대화권 잔액을 응답으로 반환하도록 구현함
질문 전송 시 메시지 저장과 AI 답변 생성 전에 AskChatTurnReservationService로 Ask Chat 대화권 잔액을 검증하도록 추가함
질문 전송 시 무료 대화권 우선으로 PENDING 예약 차감하고, 답변 생성 성공 시 예약 로그를 CONFIRMED로 확정하도록 구현함. AI 답변 생성 실패 시 예약 차감을 환불하고 ANSWER_FAILURE_REFUND 로그를 남겨 실패 응답에서 대화권이 차감되지 않도록 처리함
Ask Chat 대화권 지갑 생성 및 초기 무료 대화권 backfill migration 파일명을 최신 Flyway 버전 기준으로 변경함
Ask Chat 답변 프롬프트 버전을 2로 올리고, 고도화된 프롬프트와 답변 길이에 맞춰 max-tokens 기본값을 900으로 조정함
POST /ask-chat/sessions에서 누적 답변 20개 이상인 사용자만 새 세션을 생성할 수 있도록 검증함
Collaborator
|
LGTM! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 요약(Summary)
주요 변경사항
대화권 지갑/로그
ask_chat_wallets,ask_chat_wallet_logs테이블 추가무료 지급/충전
POST /ask-chat/turns/charge추가질문 전송 차감 정책
ASK_CHAT_TURN_BALANCE_INSUFFICIENT반환answerGeneration필드로 전달사용 조건
POST /ask-chat/sessions호출 시 누적 답변 20개 이상인지 검증ASK_CHAT_NOT_ENOUGH_ANSWERS반환프롬프트/설정
테스트
검증
.\gradlew.bat compileJava.\gradlew.bat test --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatSessionServiceTest" --tests "com.devkor.ifive.nadab.domain.askchat.api.AskChatSessionControllerTest"git diff --check🔗 Related Issue
💬 공유사항
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.