크리에이터 기준 커뮤니티 합계 정산 API 추가
This commit is contained in:
		| @@ -76,4 +76,18 @@ class AdminCalculateController(private val service: AdminCalculateService) { | ||||
|             pageable.pageSize.toLong() | ||||
|         ) | ||||
|     ) | ||||
|  | ||||
|     @GetMapping("/community-by-creator") | ||||
|     fun getCalculateCommunityByCreator( | ||||
|         @RequestParam startDateStr: String, | ||||
|         @RequestParam endDateStr: String, | ||||
|         pageable: Pageable | ||||
|     ) = ApiResponse.ok( | ||||
|         service.getCalculateCommunityByCreator( | ||||
|             startDateStr, | ||||
|             endDateStr, | ||||
|             pageable.offset, | ||||
|             pageable.pageSize.toLong() | ||||
|         ) | ||||
|     ) | ||||
| } | ||||
|   | ||||
| @@ -324,4 +324,56 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) { | ||||
|             .limit(limit) | ||||
|             .fetch() | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityByCreatorTotalCount(startDate: LocalDateTime, endDate: LocalDateTime): Int { | ||||
|         return queryFactory | ||||
|             .select(member.id) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.communityPost, creatorCommunity) | ||||
|             .innerJoin(creatorCommunity.member, member) | ||||
|             .leftJoin(creatorSettlementRatio) | ||||
|             .on(member.id.eq(creatorSettlementRatio.member.id)) | ||||
|             .where( | ||||
|                 useCan.isRefund.isFalse | ||||
|                     .and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST)) | ||||
|                     .and(useCan.createdAt.goe(startDate)) | ||||
|                     .and(useCan.createdAt.loe(endDate)) | ||||
|             ) | ||||
|             .groupBy(member.id) | ||||
|             .fetch() | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityByCreator( | ||||
|         startDate: LocalDateTime, | ||||
|         endDate: LocalDateTime, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetCalculateByCreatorQueryData> { | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 QGetCalculateByCreatorQueryData( | ||||
|                     member.email, | ||||
|                     member.nickname, | ||||
|                     useCan.can.add(useCan.rewardCan).sum(), | ||||
|                     creatorSettlementRatio.communitySettlementRatio | ||||
|                 ) | ||||
|             ) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.communityPost, creatorCommunity) | ||||
|             .innerJoin(creatorCommunity.member, member) | ||||
|             .leftJoin(creatorSettlementRatio) | ||||
|             .on(member.id.eq(creatorSettlementRatio.member.id)) | ||||
|             .where( | ||||
|                 useCan.isRefund.isFalse | ||||
|                     .and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST)) | ||||
|                     .and(useCan.createdAt.goe(startDate)) | ||||
|                     .and(useCan.createdAt.loe(endDate)) | ||||
|             ) | ||||
|             .groupBy(member.id, creatorSettlementRatio.communitySettlementRatio) | ||||
|             .orderBy(member.id.desc()) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -122,4 +122,21 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor | ||||
|  | ||||
|         GetCalculateByCreatorResponse(totalCount, items) | ||||
|     } | ||||
|  | ||||
|     fun getCalculateCommunityByCreator( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ) = run { | ||||
|         val startDate = startDateStr.convertLocalDateTime() | ||||
|         val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) | ||||
|  | ||||
|         val totalCount = repository.getCalculateCommunityByCreatorTotalCount(startDate, endDate) | ||||
|         val items = repository | ||||
|             .getCalculateCommunityByCreator(startDate, endDate, offset, limit) | ||||
|             .map { it.toGetCalculateByCreator() } | ||||
|  | ||||
|         GetCalculateByCreatorResponse(totalCount, items) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user