관리자 콘텐츠, 커뮤니티 정산
- 크리에이터 정산 추가데이터가 있으면 해당 데이터에 입력된 정산비율로 계산되도록 수정
This commit is contained in:
		| @@ -61,18 +61,27 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) { | ||||
|                     order.type, | ||||
|                     order.can, | ||||
|                     order.id.count(), | ||||
|                     order.can.sum() | ||||
|                     order.can.sum(), | ||||
|                     creatorSettlementRatio.contentSettlementRatio | ||||
|                 ) | ||||
|             ) | ||||
|             .from(order) | ||||
|             .innerJoin(order.audioContent, audioContent) | ||||
|             .innerJoin(audioContent.member, member) | ||||
|             .leftJoin(creatorSettlementRatio) | ||||
|             .on(member.id.eq(creatorSettlementRatio.member.id)) | ||||
|             .where( | ||||
|                 order.createdAt.goe(startDate) | ||||
|                     .and(order.createdAt.loe(endDate)) | ||||
|                     .and(order.isActive.isTrue) | ||||
|             ) | ||||
|             .groupBy(audioContent.id, order.type, orderFormattedDate, order.can) | ||||
|             .groupBy( | ||||
|                 audioContent.id, | ||||
|                 order.type, | ||||
|                 orderFormattedDate, | ||||
|                 order.can, | ||||
|                 creatorSettlementRatio.contentSettlementRatio | ||||
|             ) | ||||
|             .orderBy(member.id.desc(), orderFormattedDate.desc(), audioContent.id.asc()) | ||||
|             .fetch() | ||||
|     } | ||||
| @@ -191,19 +200,22 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) { | ||||
|                     formattedDate, | ||||
|                     creatorCommunity.price, | ||||
|                     useCan.id.count(), | ||||
|                     useCan.can.add(useCan.rewardCan).sum() | ||||
|                     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(formattedDate, creatorCommunity.id) | ||||
|             .groupBy(formattedDate, creatorCommunity.id, creatorSettlementRatio.communitySettlementRatio) | ||||
|             .orderBy(member.id.asc(), formattedDate.desc()) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|   | ||||
| @@ -9,12 +9,17 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor( | ||||
|     val date: String, | ||||
|     val can: Int, | ||||
|     val numberOfPurchase: Long, | ||||
|     val totalCan: Int | ||||
|     val totalCan: Int, | ||||
|     val settlementRatio: Int? | ||||
| ) { | ||||
|     fun toGetCalculateCommunityPostResponse(): GetCalculateCommunityPostResponse { | ||||
|         val totalKrw = totalCan * 100 | ||||
|         val paymentFee = totalKrw * 0.066f | ||||
|         val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7 | ||||
|         val settlementAmount = if (settlementRatio != null) { | ||||
|             (totalKrw.toFloat() - paymentFee) * (settlementRatio.toFloat() / 100.0f) | ||||
|         } else { | ||||
|             (totalKrw.toFloat() - paymentFee) * 0.7f | ||||
|         } | ||||
|         val tax = settlementAmount * 0.033 | ||||
|         val depositAmount = settlementAmount - tax | ||||
|  | ||||
|   | ||||
| @@ -20,7 +20,9 @@ data class GetCalculateContentQueryData @QueryProjection constructor( | ||||
|     // 인원 | ||||
|     val numberOfPeople: Long, | ||||
|     // 합계 | ||||
|     val totalCan: Int | ||||
|     val totalCan: Int, | ||||
|     // 정산비율 | ||||
|     val settlementRatio: Int? | ||||
| ) { | ||||
|     fun toGetCalculateContentResponse(): GetCalculateContentResponse { | ||||
|         val orderTypeStr = if (orderType == OrderType.RENTAL) { | ||||
| @@ -36,7 +38,11 @@ data class GetCalculateContentQueryData @QueryProjection constructor( | ||||
|         val paymentFee = totalKrw * 0.066f | ||||
|  | ||||
|         // 정산금액 = (원화 - 결제수수료) 의 70% | ||||
|         val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7 | ||||
|         val settlementAmount = if (settlementRatio != null) { | ||||
|             (totalKrw.toFloat() - paymentFee) * (settlementRatio.toFloat() / 100.0f) | ||||
|         } else { | ||||
|             (totalKrw.toFloat() - paymentFee) * 0.7f | ||||
|         } | ||||
|  | ||||
|         // 원천세 = 정산금액의 3.3% | ||||
|         val tax = settlementAmount * 0.033 | ||||
|   | ||||
| @@ -59,7 +59,7 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|                     .and(liveRoom.beginDateTime.loe(endDate)) | ||||
|                     .and(liveRoom.member.id.eq(memberId)) | ||||
|             ) | ||||
|             .groupBy(liveRoom.id, useCan.canUsage) | ||||
|             .groupBy(liveRoom.id, useCan.canUsage, creatorSettlementRatio.liveSettlementRatio) | ||||
|             .orderBy(liveRoom.id.desc(), useCan.canUsage.desc(), formattedDate.desc()) | ||||
|             .fetch() | ||||
|     } | ||||
| @@ -105,19 +105,28 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|                     order.type, | ||||
|                     order.can, | ||||
|                     order.id.count(), | ||||
|                     order.can.sum() | ||||
|                     order.can.sum(), | ||||
|                     creatorSettlementRatio.contentSettlementRatio | ||||
|                 ) | ||||
|             ) | ||||
|             .from(order) | ||||
|             .innerJoin(order.audioContent, audioContent) | ||||
|             .innerJoin(audioContent.member, member) | ||||
|             .leftJoin(creatorSettlementRatio) | ||||
|             .on(member.id.eq(creatorSettlementRatio.member.id)) | ||||
|             .where( | ||||
|                 order.createdAt.goe(startDate) | ||||
|                     .and(order.createdAt.loe(endDate)) | ||||
|                     .and(order.isActive.isTrue) | ||||
|                     .and(order.creator.id.eq(memberId)) | ||||
|             ) | ||||
|             .groupBy(audioContent.id, order.type, orderFormattedDate, order.can) | ||||
|             .groupBy( | ||||
|                 audioContent.id, | ||||
|                 order.type, | ||||
|                 orderFormattedDate, | ||||
|                 order.can, | ||||
|                 creatorSettlementRatio.contentSettlementRatio | ||||
|             ) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .orderBy(member.id.desc(), orderFormattedDate.desc(), audioContent.id.asc()) | ||||
| @@ -279,12 +288,15 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|                     formattedDate, | ||||
|                     creatorCommunity.price, | ||||
|                     useCan.id.count(), | ||||
|                     useCan.can.add(useCan.rewardCan).sum() | ||||
|                     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)) | ||||
| @@ -292,7 +304,7 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|                     .and(useCan.createdAt.loe(endDate)) | ||||
|                     .and(creatorCommunity.member.id.eq(memberId)) | ||||
|             ) | ||||
|             .groupBy(formattedDate, creatorCommunity.id) | ||||
|             .groupBy(formattedDate, creatorCommunity.id, creatorSettlementRatio.communitySettlementRatio) | ||||
|             .orderBy(member.id.asc(), formattedDate.desc()) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user