feat(channel-donation): 채널 후원 기능 추가
This commit is contained in:
@@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.can.payment.PaymentGateway
|
||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||
import kr.co.vividnext.sodalive.common.CountryContext
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.ZoneId
|
||||
@@ -13,7 +14,8 @@ import java.time.format.DateTimeFormatter
|
||||
@Service
|
||||
class CanService(
|
||||
private val repository: CanRepository,
|
||||
private val countryContext: CountryContext
|
||||
private val countryContext: CountryContext,
|
||||
private val memberRepository: MemberRepository
|
||||
) {
|
||||
fun getCans(isNotSelectedCurrency: Boolean): List<CanResponse> {
|
||||
val currency = if (isNotSelectedCurrency) {
|
||||
@@ -40,7 +42,7 @@ class CanService(
|
||||
timezone: String,
|
||||
container: String
|
||||
): List<GetCanUseStatusResponseItem> {
|
||||
return repository.getCanUseStatus(member, pageable)
|
||||
val useCanList = repository.getCanUseStatus(member, pageable)
|
||||
.filter { (it.can + it.rewardCan) > 0 }
|
||||
.filter {
|
||||
when (container) {
|
||||
@@ -66,6 +68,21 @@ class CanService(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val channelDonationCreatorIds = useCanList
|
||||
.asSequence()
|
||||
.filter { it.canUsage == CanUsage.CHANNEL_DONATION }
|
||||
.mapNotNull { it.useCanCalculates.firstOrNull()?.recipientCreatorId }
|
||||
.distinct()
|
||||
.toList()
|
||||
|
||||
val channelDonationCreatorNicknameMap = if (channelDonationCreatorIds.isEmpty()) {
|
||||
emptyMap()
|
||||
} else {
|
||||
memberRepository.findAllById(channelDonationCreatorIds).associate { it.id!! to it.nickname }
|
||||
}
|
||||
|
||||
return useCanList
|
||||
.map {
|
||||
val title: String = when (it.canUsage) {
|
||||
CanUsage.HEART, CanUsage.DONATION, CanUsage.SPIN_ROULETTE -> {
|
||||
@@ -78,6 +95,17 @@ class CanService(
|
||||
}
|
||||
}
|
||||
|
||||
CanUsage.CHANNEL_DONATION -> {
|
||||
val creatorId = it.useCanCalculates.firstOrNull()?.recipientCreatorId
|
||||
val creatorNickname = creatorId?.let { id -> channelDonationCreatorNicknameMap[id] }
|
||||
|
||||
if (creatorNickname.isNullOrBlank()) {
|
||||
"[채널 후원]"
|
||||
} else {
|
||||
"[채널 후원] $creatorNickname"
|
||||
}
|
||||
}
|
||||
|
||||
CanUsage.LIVE -> {
|
||||
"[라이브] ${it.room!!.title}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user