Compare commits
No commits in common. "b7196f5a0c8b29680e9195f811be8f39e659a12c" and "5d33a18890e0f4a7ed12044a78b2c08f8b242764" have entirely different histories.
b7196f5a0c
...
5d33a18890
|
@ -5,7 +5,6 @@ import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
import org.springframework.web.bind.annotation.RequestParam
|
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -13,14 +12,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
@RequestMapping("/admin/marketing/statistics")
|
@RequestMapping("/admin/marketing/statistics")
|
||||||
class AdminAdStatisticsController(private val service: AdminAdStatisticsService) {
|
class AdminAdStatisticsController(private val service: AdminAdStatisticsService) {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
fun getStatistics(
|
fun getStatistics(pageable: Pageable) = ApiResponse.ok(
|
||||||
@RequestParam startDateStr: String,
|
|
||||||
@RequestParam endDateStr: String,
|
|
||||||
pageable: Pageable
|
|
||||||
) = ApiResponse.ok(
|
|
||||||
service.getStatistics(
|
service.getStatistics(
|
||||||
startDateStr = startDateStr,
|
|
||||||
endDateStr = endDateStr,
|
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize.toLong()
|
limit = pageable.pageSize.toLong()
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,24 +28,13 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
).toInt()
|
).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAdStatisticsDataList(
|
fun getAdStatisticsDataList(offset: Long, limit: Long): List<GetAdminAdStatisticsItem> {
|
||||||
startDate: LocalDateTime,
|
|
||||||
endDate: LocalDateTime,
|
|
||||||
offset: Long,
|
|
||||||
limit: Long
|
|
||||||
): List<GetAdminAdStatisticsItem> {
|
|
||||||
val signUpCount = CaseBuilder()
|
val signUpCount = CaseBuilder()
|
||||||
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.SIGNUP))
|
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.SIGNUP))
|
||||||
.then(1)
|
.then(1)
|
||||||
.otherwise(0)
|
.otherwise(0)
|
||||||
.sum()
|
.sum()
|
||||||
|
|
||||||
val loginCount = CaseBuilder()
|
|
||||||
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.LOGIN))
|
|
||||||
.then(1)
|
|
||||||
.otherwise(0)
|
|
||||||
.sum()
|
|
||||||
|
|
||||||
val firstPaymentCount = CaseBuilder()
|
val firstPaymentCount = CaseBuilder()
|
||||||
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.FIRST_PAYMENT))
|
.`when`(adTrackingHistory.id.type.eq(AdTrackingHistoryType.FIRST_PAYMENT))
|
||||||
.then(1)
|
.then(1)
|
||||||
|
@ -95,7 +84,6 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
adTrackingHistory.mediaGroup,
|
adTrackingHistory.mediaGroup,
|
||||||
adTrackingHistory.id.pid,
|
adTrackingHistory.id.pid,
|
||||||
adTrackingHistory.pidName,
|
adTrackingHistory.pidName,
|
||||||
loginCount,
|
|
||||||
signUpCount,
|
signUpCount,
|
||||||
firstPaymentCount,
|
firstPaymentCount,
|
||||||
roundedValueDecimalPlaces2(firstPaymentTotalAmount),
|
roundedValueDecimalPlaces2(firstPaymentTotalAmount),
|
||||||
|
@ -106,10 +94,6 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(adTrackingHistory)
|
.from(adTrackingHistory)
|
||||||
.where(
|
|
||||||
adTrackingHistory.id.createdAt.goe(startDate),
|
|
||||||
adTrackingHistory.id.createdAt.loe(endDate)
|
|
||||||
)
|
|
||||||
.groupBy(
|
.groupBy(
|
||||||
getFormattedDate(adTrackingHistory.id.createdAt),
|
getFormattedDate(adTrackingHistory.id.createdAt),
|
||||||
adTrackingHistory.mediaGroup,
|
adTrackingHistory.mediaGroup,
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
package kr.co.vividnext.sodalive.admin.marketing.statistics
|
package kr.co.vividnext.sodalive.admin.marketing.statistics
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class AdminAdStatisticsService(
|
class AdminAdStatisticsService(
|
||||||
private val repository: AdminAdStatisticsRepository
|
private val repository: AdminAdStatisticsRepository
|
||||||
) {
|
) {
|
||||||
fun getStatistics(
|
fun getStatistics(offset: Long, limit: Long): GetAdminAdStatisticsResponse {
|
||||||
startDateStr: String,
|
|
||||||
endDateStr: String,
|
|
||||||
offset: Long,
|
|
||||||
limit: Long
|
|
||||||
): GetAdminAdStatisticsResponse {
|
|
||||||
val startDate = startDateStr.convertLocalDateTime()
|
|
||||||
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
|
|
||||||
|
|
||||||
val totalCount = repository.getAdStatisticsDataTotalCount()
|
val totalCount = repository.getAdStatisticsDataTotalCount()
|
||||||
val items = repository.getAdStatisticsDataList(startDate, endDate, offset, limit)
|
val items = repository.getAdStatisticsDataList(offset, limit)
|
||||||
|
|
||||||
return GetAdminAdStatisticsResponse(
|
return GetAdminAdStatisticsResponse(
|
||||||
totalCount = totalCount,
|
totalCount = totalCount,
|
||||||
|
|
|
@ -12,7 +12,6 @@ data class GetAdminAdStatisticsItem @QueryProjection constructor(
|
||||||
val mediaGroup: String,
|
val mediaGroup: String,
|
||||||
val pid: String,
|
val pid: String,
|
||||||
val pidName: String,
|
val pidName: String,
|
||||||
val loginCount: Int,
|
|
||||||
val signUpCount: Int,
|
val signUpCount: Int,
|
||||||
val firstPaymentCount: Int,
|
val firstPaymentCount: Int,
|
||||||
val firstPaymentTotalAmount: Double,
|
val firstPaymentTotalAmount: Double,
|
||||||
|
|
|
@ -42,8 +42,5 @@ enum class AdTrackingHistoryType {
|
||||||
FIRST_PAYMENT,
|
FIRST_PAYMENT,
|
||||||
|
|
||||||
// 재결제
|
// 재결제
|
||||||
REPEAT_PAYMENT,
|
REPEAT_PAYMENT
|
||||||
|
|
||||||
// 자동로그인
|
|
||||||
LOGIN
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,26 +135,15 @@ class MemberController(
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
val memberId = member.id!!
|
ApiResponse.ok(
|
||||||
val marketingPid = request.pid
|
service.updateMarketingInfo(
|
||||||
|
memberId = member.id!!,
|
||||||
val changedMarketingPid = service.updateMarketingInfo(
|
|
||||||
memberId = memberId,
|
|
||||||
adid = request.adid,
|
adid = request.adid,
|
||||||
pid = marketingPid
|
pid = request.pid
|
||||||
)
|
)
|
||||||
|
|
||||||
if (changedMarketingPid) {
|
|
||||||
trackingService.saveTrackingHistory(
|
|
||||||
pid = marketingPid,
|
|
||||||
type = AdTrackingHistoryType.LOGIN,
|
|
||||||
memberId = memberId
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiResponse.ok(Unit)
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/adid/update")
|
@PutMapping("/adid/update")
|
||||||
fun updateAdid(
|
fun updateAdid(
|
||||||
@RequestBody request: AdidUpdateRequest,
|
@RequestBody request: AdidUpdateRequest,
|
||||||
|
|
|
@ -648,7 +648,7 @@ class MemberService(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
fun updateMarketingInfo(memberId: Long, adid: String, pid: String): Boolean {
|
fun updateMarketingInfo(memberId: Long, adid: String, pid: String) {
|
||||||
val member = repository.findByIdOrNull(id = memberId)
|
val member = repository.findByIdOrNull(id = memberId)
|
||||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
@ -659,10 +659,6 @@ class MemberService(
|
||||||
if (pid != member.activePid && pid.isNotBlank()) {
|
if (pid != member.activePid && pid.isNotBlank()) {
|
||||||
member.activePid = pid
|
member.activePid = pid
|
||||||
member.partnerExpirationDatetime = LocalDateTime.now().plusYears(1)
|
member.partnerExpirationDatetime = LocalDateTime.now().plusYears(1)
|
||||||
|
}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue