test #339
| @@ -86,6 +86,10 @@ class ChatRoomQuotaService( | |||||||
|         // 1) 유료 우선 사용: 글로벌에 영향 없음 |         // 1) 유료 우선 사용: 글로벌에 영향 없음 | ||||||
|         if (quota.remainingPaid > 0) { |         if (quota.remainingPaid > 0) { | ||||||
|             quota.remainingPaid -= 1 |             quota.remainingPaid -= 1 | ||||||
|  |             // 유료 차감 후, 무료와 유료가 모두 0이 되는 시점이면 다음 무료 충전을 예약한다. | ||||||
|  |             if (quota.remainingPaid == 0 && quota.remainingFree == 0 && quota.nextRechargeAt == null) { | ||||||
|  |                 quota.nextRechargeAt = now.plus(Duration.ofHours(6)).toEpochMilli() | ||||||
|  |             } | ||||||
|             val total = calculateAvailableForRoom(globalFreeProvider(), quota.remainingFree, quota.remainingPaid) |             val total = calculateAvailableForRoom(globalFreeProvider(), quota.remainingFree, quota.remainingPaid) | ||||||
|             return RoomQuotaStatus(total, quota.nextRechargeAt, quota.remainingFree, quota.remainingPaid) |             return RoomQuotaStatus(total, quota.nextRechargeAt, quota.remainingFree, quota.remainingPaid) | ||||||
|         } |         } | ||||||
| @@ -94,16 +98,16 @@ class ChatRoomQuotaService( | |||||||
|         val globalFree = globalFreeProvider() |         val globalFree = globalFreeProvider() | ||||||
|         if (globalFree <= 0) { |         if (globalFree <= 0) { | ||||||
|             // 전송 차단: 글로벌 무료가 0이며 유료도 0 → 전송 불가 |             // 전송 차단: 글로벌 무료가 0이며 유료도 0 → 전송 불가 | ||||||
|             throw SodaException("무료 쿼터가 소진되었습니다. 글로벌 무료 충전 이후 이용해 주세요.") |             throw SodaException("오늘의 무료 채팅이 모두 소진되었습니다. 내일 다시 이용해 주세요.") | ||||||
|         } |         } | ||||||
|         if (quota.remainingFree <= 0) { |         if (quota.remainingFree <= 0) { | ||||||
|             // 전송 차단: 룸 무료가 0이며 유료도 0 → 전송 불가 |             // 전송 차단: 룸 무료가 0이며 유료도 0 → 전송 불가 | ||||||
|             val waitMillis = quota.nextRechargeAt |             val waitMillis = quota.nextRechargeAt | ||||||
|             if (waitMillis != null && waitMillis > nowMillis) { |             if (waitMillis == null) { | ||||||
|                 throw SodaException("채팅방 무료 쿼터가 소진되었습니다. 무료 충전 이후 이용해 주세요.") |                 quota.nextRechargeAt = now.plus(Duration.ofHours(6)).toEpochMilli() | ||||||
|             } else { |  | ||||||
|                 throw SodaException("채팅방 무료 쿼터가 소진되었습니다. 잠시 후 다시 시도해 주세요.") |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             throw SodaException("무료 채팅이 모두 소진되었습니다.") | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // 둘 다 가능 → 차감 |         // 둘 다 가능 → 차감 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user