test #358

Merged
klaus merged 4 commits from test into main 2025-11-10 06:53:41 +00:00
2 changed files with 17 additions and 12 deletions
Showing only changes of commit 26c09de7c9 - Show all commits

View File

@@ -1,7 +1,7 @@
package kr.co.vividnext.sodalive.admin.can
data class AdminCanChargeRequest(
val memberId: Long,
val memberIds: List<Long>,
val method: String,
val can: Int
)

View File

@@ -40,12 +40,16 @@ class AdminCanService(
@Transactional
fun charge(request: AdminCanChargeRequest) {
val member = memberRepository.findByIdOrNull(request.memberId)
?: throw SodaException("잘못된 회원번호 입니다.")
if (request.can <= 0) throw SodaException("1 캔 이상 입력하세요.")
if (request.method.isBlank()) throw SodaException("기록내용을 입력하세요.")
val ids = request.memberIds.distinct()
if (ids.isEmpty()) throw SodaException("회원번호를 입력하세요.")
val members = memberRepository.findAllById(ids).toList()
if (members.size != ids.size) throw SodaException("잘못된 회원번호 입니다.")
members.forEach { member ->
val charge = Charge(0, request.can, status = ChargeStatus.ADMIN)
charge.title = "${request.can.moneyFormat()}"
charge.member = member
@@ -58,4 +62,5 @@ class AdminCanService(
member.pgRewardCan += charge.rewardCan
}
}
}