| @@ -0,0 +1,11 @@ | ||||
| package kr.co.vividnext.sodalive.admin.calculate | ||||
|  | ||||
| import com.querydsl.core.annotations.QueryProjection | ||||
|  | ||||
| data class GetCalculateCommunityPostQueryData @QueryProjection constructor( | ||||
|     val nickname: String, | ||||
|     val title: String, | ||||
|     val date: String, | ||||
|     val numberOfPurchase: Long, | ||||
|     val totalCan: Int | ||||
| ) | ||||
| @@ -0,0 +1,16 @@ | ||||
| package kr.co.vividnext.sodalive.admin.calculate | ||||
|  | ||||
| import com.fasterxml.jackson.annotation.JsonProperty | ||||
|  | ||||
| data class GetCalculateCommunityPostResponse( | ||||
|     @JsonProperty("nickname") val nickname: String, | ||||
|     @JsonProperty("title") val title: String, | ||||
|     @JsonProperty("date") val date: String, | ||||
|     @JsonProperty("numberOfPurchase") val numberOfPurchase: Int, | ||||
|     @JsonProperty("totalCan") val totalCan: Int, | ||||
|     @JsonProperty("totalKrw") val totalKrw: Int, | ||||
|     @JsonProperty("paymentFee") val paymentFee: Int, | ||||
|     @JsonProperty("settlementAmount") val settlementAmount: Int, | ||||
|     @JsonProperty("tax") val tax: Int, | ||||
|     @JsonProperty("depositAmount") val depositAmount: Int | ||||
| ) | ||||
| @@ -72,4 +72,24 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/community-post") | ||||
|     fun getCalculateCommunityPost( | ||||
|         @RequestParam startDateStr: String, | ||||
|         @RequestParam endDateStr: String, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok( | ||||
|             service.getCalculateCommunityPost( | ||||
|                 startDateStr, | ||||
|                 endDateStr, | ||||
|                 member.id!!, | ||||
|                 pageable.offset, | ||||
|                 pageable.pageSize.toLong() | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,10 +4,12 @@ import com.querydsl.core.types.dsl.DateTimePath | ||||
| import com.querydsl.core.types.dsl.Expressions | ||||
| import com.querydsl.core.types.dsl.StringTemplate | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateCommunityPostQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentDonationQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateLiveQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.QGetCalculateCommunityPostQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.QGetCalculateContentDonationQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.QGetCalculateContentQueryData | ||||
| import kr.co.vividnext.sodalive.admin.calculate.QGetCalculateLiveQueryData | ||||
| @@ -16,6 +18,7 @@ import kr.co.vividnext.sodalive.can.use.CanUsage | ||||
| import kr.co.vividnext.sodalive.can.use.QUseCan.useCan | ||||
| import kr.co.vividnext.sodalive.content.QAudioContent.audioContent | ||||
| import kr.co.vividnext.sodalive.content.order.QOrder.order | ||||
| import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.QCreatorCommunity.creatorCommunity | ||||
| import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom | ||||
| import kr.co.vividnext.sodalive.member.QMember.member | ||||
| import org.springframework.stereotype.Repository | ||||
| @@ -246,4 +249,56 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|             .orderBy(member.id.asc(), donationFormattedDate.desc()) | ||||
|             .fetch() | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityPostTotalCount(startDate: LocalDateTime?, endDate: LocalDateTime?, memberId: Long): Int { | ||||
|         val formattedDate = getFormattedDate(useCan.createdAt) | ||||
|         return queryFactory | ||||
|             .select(creatorCommunity.id) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.communityPost, creatorCommunity) | ||||
|             .innerJoin(creatorCommunity.member, member) | ||||
|             .where( | ||||
|                 useCan.isRefund.isFalse | ||||
|                     .and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST)) | ||||
|                     .and(useCan.createdAt.goe(startDate)) | ||||
|                     .and(useCan.createdAt.loe(endDate)) | ||||
|                     .and(creatorCommunity.member.id.eq(memberId)) | ||||
|             ) | ||||
|             .groupBy(formattedDate, creatorCommunity.id) | ||||
|             .fetch() | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityPostList( | ||||
|         startDate: LocalDateTime?, | ||||
|         endDate: LocalDateTime?, | ||||
|         memberId: Long, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetCalculateCommunityPostQueryData> { | ||||
|         val formattedDate = getFormattedDate(useCan.createdAt) | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 QGetCalculateCommunityPostQueryData( | ||||
|                     member.nickname, | ||||
|                     Expressions.stringTemplate("substring({0}, 1, 10)", creatorCommunity.content), | ||||
|                     formattedDate, | ||||
|                     useCan.id.count(), | ||||
|                     useCan.can.add(useCan.rewardCan).sum() | ||||
|                 ) | ||||
|             ) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.communityPost, creatorCommunity) | ||||
|             .innerJoin(creatorCommunity.member, member) | ||||
|             .where( | ||||
|                 useCan.isRefund.isFalse | ||||
|                     .and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST)) | ||||
|                     .and(useCan.createdAt.goe(startDate)) | ||||
|                     .and(useCan.createdAt.loe(endDate)) | ||||
|                     .and(creatorCommunity.member.id.eq(memberId)) | ||||
|             ) | ||||
|             .groupBy(formattedDate, creatorCommunity.id) | ||||
|             .orderBy(member.id.asc(), formattedDate.desc()) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package kr.co.vividnext.sodalive.creator.admin.calculate | ||||
|  | ||||
| import kr.co.vividnext.sodalive.admin.calculate.CumulativeSalesByContentItem | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateCommunityPostResponse | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentDonationResponse | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentResponse | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateLiveResponse | ||||
| @@ -288,4 +289,49 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | ||||
|  | ||||
|         return GetCreatorCalculateContentDonationResponse(totalCount, items) | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityPost( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
|         memberId: Long, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): GetCreatorCalculateCommunityPostResponse { | ||||
|         val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||||
|         val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) | ||||
|             .atZone(ZoneId.of("Asia/Seoul")) | ||||
|             .withZoneSameInstant(ZoneId.of("UTC")) | ||||
|             .toLocalDateTime() | ||||
|  | ||||
|         val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59) | ||||
|             .atZone(ZoneId.of("Asia/Seoul")) | ||||
|             .withZoneSameInstant(ZoneId.of("UTC")) | ||||
|             .toLocalDateTime() | ||||
|  | ||||
|         val totalCount = repository.getCalculateCommunityPostTotalCount(startDate, endDate, memberId) | ||||
|         val items = repository | ||||
|             .getCalculateCommunityPostList(startDate, endDate, memberId, offset, limit) | ||||
|             .map { | ||||
|                 val totalKrw = it.totalCan * 100 | ||||
|                 val paymentFee = totalKrw * 0.066f | ||||
|                 val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7 | ||||
|                 val tax = settlementAmount * 0.033 | ||||
|                 val depositAmount = settlementAmount - tax | ||||
|  | ||||
|                 GetCalculateCommunityPostResponse( | ||||
|                     nickname = it.nickname, | ||||
|                     title = it.title, | ||||
|                     date = it.date, | ||||
|                     numberOfPurchase = it.numberOfPurchase.toInt(), | ||||
|                     totalCan = it.totalCan, | ||||
|                     totalKrw = totalKrw, | ||||
|                     paymentFee = paymentFee.roundToInt(), | ||||
|                     settlementAmount = settlementAmount.roundToInt(), | ||||
|                     tax = tax.roundToInt(), | ||||
|                     depositAmount = depositAmount.roundToInt() | ||||
|                 ) | ||||
|             } | ||||
|  | ||||
|         return GetCreatorCalculateCommunityPostResponse(totalCount, items) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,9 @@ | ||||
| package kr.co.vividnext.sodalive.creator.admin.calculate | ||||
|  | ||||
| import com.fasterxml.jackson.annotation.JsonProperty | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCalculateCommunityPostResponse | ||||
|  | ||||
| data class GetCreatorCalculateCommunityPostResponse( | ||||
|     @JsonProperty("totalCount") val totalCount: Int, | ||||
|     @JsonProperty("items") val items: List<GetCalculateCommunityPostResponse> | ||||
| ) | ||||
		Reference in New Issue
	
	Block a user