diff --git a/Match-Api/src/main/generated/com/example/matchapi/admin/notice/mapper/AdminNoticeMapperImpl.java b/Match-Api/src/main/generated/com/example/matchapi/admin/notice/mapper/AdminNoticeMapperImpl.java index f2e49ad2..0bd2a686 100644 --- a/Match-Api/src/main/generated/com/example/matchapi/admin/notice/mapper/AdminNoticeMapperImpl.java +++ b/Match-Api/src/main/generated/com/example/matchapi/admin/notice/mapper/AdminNoticeMapperImpl.java @@ -10,7 +10,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-01-17T03:34:23+0900", + date = "2024-01-17T19:31:30+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)" ) public class AdminNoticeMapperImpl implements AdminNoticeMapper { diff --git a/Match-Api/src/main/generated/com/example/matchapi/order/mapper/OrderMapperImpl.java b/Match-Api/src/main/generated/com/example/matchapi/order/mapper/OrderMapperImpl.java index 23929d59..49f4f51e 100644 --- a/Match-Api/src/main/generated/com/example/matchapi/order/mapper/OrderMapperImpl.java +++ b/Match-Api/src/main/generated/com/example/matchapi/order/mapper/OrderMapperImpl.java @@ -9,7 +9,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-01-17T03:34:23+0900", + date = "2024-01-17T19:31:30+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)" ) public class OrderMapperImpl implements OrderMapper { diff --git a/Match-Api/src/main/generated/com/example/matchapi/portone/mapper/PaymentMapperImpl.java b/Match-Api/src/main/generated/com/example/matchapi/portone/mapper/PaymentMapperImpl.java index 692bbdf2..0b8201c8 100644 --- a/Match-Api/src/main/generated/com/example/matchapi/portone/mapper/PaymentMapperImpl.java +++ b/Match-Api/src/main/generated/com/example/matchapi/portone/mapper/PaymentMapperImpl.java @@ -13,7 +13,7 @@ @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2024-01-17T03:34:23+0900", + date = "2024-01-17T19:31:30+0900", comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)" ) public class PaymentMapperImpl implements PaymentMapper { diff --git a/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationController.java b/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationController.java index d142eb85..e0e95c53 100644 --- a/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationController.java +++ b/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationController.java @@ -47,7 +47,6 @@ public CommonResponse getRegularInfo(){ } - @GetMapping("/{donationId}") @ApiErrorCodeExample(UserAuthErrorCode.class) @Operation(summary = "ADMIN-05-02 기부금 상세조회 API", description = "기부금 상세조회 API") diff --git a/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationV2Controller.java b/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationV2Controller.java new file mode 100644 index 00000000..16bbc409 --- /dev/null +++ b/Match-Api/src/main/java/com/example/matchapi/admin/donation/controller/AdminDonationV2Controller.java @@ -0,0 +1,29 @@ +package com.example.matchapi.admin.donation.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.example.matchapi.admin.donation.service.AdminDonationService; +import com.example.matchapi.donation.dto.DonationRes; +import com.example.matchcommon.annotation.ApiErrorCodeExample; +import com.example.matchcommon.reponse.CommonResponse; +import com.example.matchdomain.user.exception.UserAuthErrorCode; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; + +@RestController +@Tag(name = "ADMIN-05-Donation V2💸 관리자 기부금 관련 API 입니다.", description = "기부금 관련 API 입니다.") +@RequestMapping("/admin/v2/donations") +@RequiredArgsConstructor +public class AdminDonationV2Controller { + private final AdminDonationService adminDonationService; + @GetMapping("/regular") + @ApiErrorCodeExample(UserAuthErrorCode.class) + @Operation(summary = "ADMIN-05-01-01 V2 정기 결제 현황 파악", description = "정기 결제 현황파악") + public CommonResponse getRegularInfoV2(){ + return CommonResponse.onSuccess(adminDonationService.getRegularInfoV2()); + } +} diff --git a/Match-Api/src/main/java/com/example/matchapi/admin/donation/converter/AdminDonationConverter.java b/Match-Api/src/main/java/com/example/matchapi/admin/donation/converter/AdminDonationConverter.java index 872892b8..1edea512 100644 --- a/Match-Api/src/main/java/com/example/matchapi/admin/donation/converter/AdminDonationConverter.java +++ b/Match-Api/src/main/java/com/example/matchapi/admin/donation/converter/AdminDonationConverter.java @@ -142,4 +142,13 @@ public DonationRes.RegularInfoDto convertToRegularInfoDto(Long beforeCnt, Long u .beforeMonthRegularAmount(beforeMonthRegularAmount) .build(); } + + public DonationRes.RegularInfoV2Dto convertToRegularInfoV2Dto(Long thisMonthRegularCnt, Long thisMonthOneTimeCnt, Long thisMonthStartCnt) { + return DonationRes.RegularInfoV2Dto + .builder() + .thisMonthRegularCnt(thisMonthRegularCnt) + .thisMonthOneTimeCnt(thisMonthOneTimeCnt) + .thisMonthStartCnt(thisMonthStartCnt) + .build(); + } } diff --git a/Match-Api/src/main/java/com/example/matchapi/admin/donation/service/AdminDonationService.java b/Match-Api/src/main/java/com/example/matchapi/admin/donation/service/AdminDonationService.java index 73c569b0..e9625812 100644 --- a/Match-Api/src/main/java/com/example/matchapi/admin/donation/service/AdminDonationService.java +++ b/Match-Api/src/main/java/com/example/matchapi/admin/donation/service/AdminDonationService.java @@ -14,6 +14,7 @@ import com.example.matchdomain.donation.entity.HistoryImage; import com.example.matchdomain.donation.entity.RegularPayment; import com.example.matchdomain.donation.entity.enums.RegularPayStatus; +import com.example.matchdomain.donation.entity.enums.RegularStatus; import com.example.matchdomain.donation.repository.HistoryImageRepository; import com.example.matchdomain.project.adaptor.ProjectAdaptor; import com.example.matchdomain.project.entity.Project; @@ -35,8 +36,7 @@ import java.util.List; import java.util.stream.Collectors; -import static com.example.matchcommon.constants.MatchStatic.FIRST_TIME; -import static com.example.matchcommon.constants.MatchStatic.LAST_TIME; +import static com.example.matchcommon.constants.MatchStatic.*; import static com.example.matchdomain.donation.entity.enums.DonationStatus.*; @Service @@ -250,4 +250,26 @@ public Long countByUserId(Long userId) { public List findByUserId(Long userId) { return donationAdaptor.findByUserId(userId); } + + public DonationRes.RegularInfoV2Dto getRegularInfoV2() { + List donationUsers = donationAdaptor.getRegularDonationLists(); + List regularPayments = paymentAdaptor.getRegularInfo(); + + Long thisMonthRegularCnt = 0L, thisMonthOneTimeCnt = 0L, thisMonthStartCnt = 0L; + LocalDate now = LocalDate.now(); + for (DonationUser donationUser : donationUsers){ + if(now.getMonthValue() == donationUser.getCreatedAt().getMonthValue() && now.getYear() == donationUser.getCreatedAt().getYear()){ + if(donationUser.getRegularStatus().equals(RegularStatus.REGULAR)) thisMonthRegularCnt++; + else thisMonthOneTimeCnt++; + } + } + + for (RegularPayment regularPayment : regularPayments){ + if(now.getMonthValue() == regularPayment.getCreatedAt().getMonthValue() && now.getYear() == regularPayment.getCreatedAt().getYear()){ + thisMonthStartCnt++; + } + } + + return adminDonationConverter.convertToRegularInfoV2Dto(thisMonthRegularCnt, thisMonthOneTimeCnt, thisMonthStartCnt); + } } diff --git a/Match-Api/src/main/java/com/example/matchapi/donation/dto/DonationRes.java b/Match-Api/src/main/java/com/example/matchapi/donation/dto/DonationRes.java index c21b7bb8..41417227 100644 --- a/Match-Api/src/main/java/com/example/matchapi/donation/dto/DonationRes.java +++ b/Match-Api/src/main/java/com/example/matchapi/donation/dto/DonationRes.java @@ -429,4 +429,17 @@ public static class RegularInfoDto { private String beforeMonthRegularAmount; } + + @Getter + @Setter + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class RegularInfoV2Dto { + private Long thisMonthRegularCnt; + + private Long thisMonthOneTimeCnt; + + private Long thisMonthStartCnt; + } } diff --git a/Match-Common/src/main/java/com/example/matchcommon/constants/enums/Version.java b/Match-Common/src/main/java/com/example/matchcommon/constants/enums/Version.java new file mode 100644 index 00000000..4e92cb05 --- /dev/null +++ b/Match-Common/src/main/java/com/example/matchcommon/constants/enums/Version.java @@ -0,0 +1,5 @@ +package com.example.matchcommon.constants.enums; + +public enum Version { + API_V1, API_V2, API_V3, API_V4, API_V5 +}