feat(chat): 글로벌/방 쿼터 정책 개편, 결제/조회/차단/이관 로직 반영

글로벌: 무료 40, UTC 20:00 lazy refill(유료 제거)
방: 무료 10, 무료 0 순간 now+6h, 경과 시 lazy refill(무료=10, next=null)
전송: 유료 우선, 무료 사용 시 글로벌/룸 동시 차감, 조건 불충족 예외
API: 방 쿼터 조회/구매 추가(구매 시 30캔, UseCan에 roomId:characterId 기록)
next 계산: enter/send에서 경계 케이스 처리(max(room, global))
대화 초기화: 유료 쿼터 새 방으로 이관
This commit is contained in:
2025-09-09 22:42:14 +09:00
parent a9d1b9f4a6
commit fd83abb46c
9 changed files with 470 additions and 75 deletions

View File

@@ -38,6 +38,8 @@ class CanPaymentService(
memberId: Long,
needCan: Int,
canUsage: CanUsage,
chatRoomId: Long? = null,
characterId: Long? = null,
isSecret: Boolean = false,
liveRoom: LiveRoom? = null,
order: Order? = null,
@@ -110,12 +112,14 @@ class CanPaymentService(
recipientId = liveRoom.member!!.id!!
useCan.room = liveRoom
useCan.member = member
} else if (canUsage == CanUsage.CHAT_QUOTA_PURCHASE) {
// 채팅 쿼터 구매는 수신자 개념 없이 본인에게 귀속
} else if (canUsage == CanUsage.CHAT_QUOTA_PURCHASE && chatRoomId != null && characterId != null) {
useCan.member = member
useCan.chatRoomId = chatRoomId
useCan.characterId = characterId
} else if (canUsage == CanUsage.CHAT_ROOM_RESET) {
// 채팅방 초기화 결제: 별도 구분. 수신자 없이 본인 귀속
useCan.member = member
useCan.chatRoomId = chatRoomId
useCan.characterId = characterId
} else {
throw SodaException("잘못된 요청입니다.")
}

View File

@@ -30,7 +30,11 @@ data class UseCan(
var isRefund: Boolean = false,
val isSecret: Boolean = false
val isSecret: Boolean = false,
// 채팅 연동을 위한 식별자 (옵션)
var chatRoomId: Long? = null,
var characterId: Long? = null
) : BaseEntity() {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)