Compare commits
2 Commits
cbbfe014cc
...
ffa8e5aebb
Author | SHA1 | Date |
---|---|---|
|
ffa8e5aebb | |
|
ae439b7e64 |
|
@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
|||
import kr.co.vividnext.sodalive.can.payment.QPayment.payment
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import kr.co.vividnext.sodalive.member.QSignOut.signOut
|
||||
import kr.co.vividnext.sodalive.member.auth.QAuth.auth
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.LocalDateTime
|
||||
|
||||
|
@ -27,6 +28,18 @@ class AdminMemberStatisticsRepository(private val queryFactory: JPAQueryFactory)
|
|||
.size
|
||||
}
|
||||
|
||||
fun getTotalAuthCount(startDate: LocalDateTime, endDate: LocalDateTime): Int {
|
||||
return queryFactory
|
||||
.select(auth.id)
|
||||
.from(auth)
|
||||
.where(
|
||||
auth.createdAt.goe(startDate),
|
||||
auth.createdAt.loe(endDate)
|
||||
)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
|
||||
fun getTotalSignOutCount(startDate: LocalDateTime, endDate: LocalDateTime): Int {
|
||||
return queryFactory
|
||||
.select(signOut.id)
|
||||
|
@ -79,6 +92,24 @@ class AdminMemberStatisticsRepository(private val queryFactory: JPAQueryFactory)
|
|||
.fetch()
|
||||
}
|
||||
|
||||
fun getAuthCountInRange(startDate: LocalDateTime, endDate: LocalDateTime): List<DateAndMemberCount> {
|
||||
return queryFactory
|
||||
.select(
|
||||
QDateAndMemberCount(
|
||||
getFormattedDate(auth.createdAt),
|
||||
auth.id.countDistinct().castToNum(Int::class.java)
|
||||
)
|
||||
)
|
||||
.from(auth)
|
||||
.where(
|
||||
auth.createdAt.goe(startDate),
|
||||
auth.createdAt.loe(endDate)
|
||||
)
|
||||
.groupBy(getFormattedDate(auth.createdAt))
|
||||
.orderBy(getFormattedDate(auth.createdAt).desc())
|
||||
.fetch()
|
||||
}
|
||||
|
||||
fun getSignOutCountInRange(startDate: LocalDateTime, endDate: LocalDateTime): List<DateAndMemberCount> {
|
||||
return queryFactory
|
||||
.select(
|
||||
|
|
|
@ -46,6 +46,7 @@ class AdminMemberStatisticsService(private val repository: AdminMemberStatistics
|
|||
.toLocalDateTime()
|
||||
|
||||
val totalSignUpCount = repository.getTotalSignUpCount(startDate = startDateTime, endDate = endDateTime)
|
||||
val totalAuthCount = repository.getTotalAuthCount(startDate = startDateTime, endDate = endDateTime)
|
||||
val totalSignOutCount = repository.getTotalSignOutCount(startDate = startDateTime, endDate = endDateTime)
|
||||
val totalPaymentMemberCount = repository.getPaymentMemberCount(startDate = startDateTime, endDate = endDateTime)
|
||||
|
||||
|
@ -64,6 +65,11 @@ class AdminMemberStatisticsService(private val repository: AdminMemberStatistics
|
|||
endDate = endDateTime
|
||||
).associateBy({ it.date }, { it.memberCount })
|
||||
|
||||
val authCountInRange = repository.getAuthCountInRange(
|
||||
startDate = startDateTime,
|
||||
endDate = endDateTime
|
||||
).associateBy({ it.date }, { it.memberCount })
|
||||
|
||||
val signOutCountInRange = repository.getSignOutCountInRange(
|
||||
startDate = startDateTime,
|
||||
endDate = endDateTime
|
||||
|
@ -83,6 +89,7 @@ class AdminMemberStatisticsService(private val repository: AdminMemberStatistics
|
|||
val date = it.format(formatter)
|
||||
GetMemberStatisticsItem(
|
||||
date = date,
|
||||
authCount = authCountInRange[date] ?: 0,
|
||||
signUpCount = signUpCountInRange[date] ?: 0,
|
||||
signOutCount = signOutCountInRange[date] ?: 0,
|
||||
paymentMemberCount = paymentMemberCountInRangeMap[date] ?: 0
|
||||
|
@ -92,6 +99,7 @@ class AdminMemberStatisticsService(private val repository: AdminMemberStatistics
|
|||
|
||||
return GetMemberStatisticsResponse(
|
||||
totalCount = dateRange.totalDays,
|
||||
totalAuthCount = totalAuthCount,
|
||||
totalSignUpCount = totalSignUpCount,
|
||||
totalSignOutCount = totalSignOutCount,
|
||||
totalPaymentMemberCount = totalPaymentMemberCount,
|
||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.admin.statistics.member
|
|||
|
||||
data class GetMemberStatisticsResponse(
|
||||
val totalCount: Int,
|
||||
val totalAuthCount: Int,
|
||||
val totalSignUpCount: Int,
|
||||
val totalSignOutCount: Int,
|
||||
val totalPaymentMemberCount: Int,
|
||||
|
@ -10,6 +11,7 @@ data class GetMemberStatisticsResponse(
|
|||
|
||||
data class GetMemberStatisticsItem(
|
||||
val date: String,
|
||||
val authCount: Int,
|
||||
val signUpCount: Int,
|
||||
val signOutCount: Int,
|
||||
val paymentMemberCount: Int
|
||||
|
|
Loading…
Reference in New Issue