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 218d311b..06691b62 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 @@ -4,10 +4,12 @@ import com.example.matchapi.donation.dto.DonationReq; import com.example.matchapi.donation.dto.DonationRes; import com.example.matchapi.donation.service.DonationService; +import com.example.matchapi.project.service.ProjectService; import com.example.matchcommon.annotation.ApiErrorCodeExample; import com.example.matchcommon.exception.errorcode.RequestErrorCode; import com.example.matchcommon.reponse.CommonResponse; import com.example.matchcommon.reponse.PageResponse; +import com.example.matchdomain.project.entity.Project; import com.example.matchdomain.user.exception.UserAuthErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -28,6 +30,7 @@ @Slf4j public class AdminDonationController { private final AdminDonationService adminDonationService; + private final ProjectService projectService; @GetMapping("") @ApiErrorCodeExample(UserAuthErrorCode.class) @Operation(summary = "ADMIN-05-01💸 기부금 현황파악 API.",description = "기부금 현황파악 API 입니다.") @@ -77,4 +80,15 @@ public CommonResponse>> get ){ return CommonResponse.onSuccess(adminDonationService.getProjectDonationStatus(page, size)); } + + @GetMapping("/execution/{projectId}") + @Operation(summary = "기부금 리스트 확인") + public CommonResponse>> getProjectDonationLists( + @Parameter(description = "페이지", example = "0") @RequestParam(required = false, defaultValue = "0") int page, + @Parameter(description = "페이지 사이즈", example = "10") @RequestParam(required = false, defaultValue = "5") int size, + @PathVariable("projectId") Long projectId + ){ + Project project = projectService.findByProjectId(projectId); + return CommonResponse.onSuccess(adminDonationService.getProjectDonationLists(project, page, size)); + } } 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 28537954..e527a3d8 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 @@ -11,6 +11,7 @@ import com.example.matchdomain.donation.entity.enums.HistoryStatus; import com.example.matchdomain.project.entity.Project; +import java.util.ArrayList; import java.util.List; @Converter @@ -100,4 +101,30 @@ public DonationRes.ProjectDonationStatus convertToStatusDetail(List convertToDonationLists(List content) { + List dtos = new ArrayList<>(); + + content.forEach( + result -> { + dtos.add(convertToDonationInfo(result)); + } + ); + return dtos; + } + + private DonationRes.ProjectDonationDto convertToDonationInfo(DonationUser result) { + return DonationRes.ProjectDonationDto + .builder() + .donationId(result.getId()) + .donationDate(result.getCreatedAt()) + .donationStatusName(result.getDonationStatus().getName()) + .donationStatus(result.getDonationStatus()) + .userId(result.getUserId()) + .userName(result.getUser().getName()) + .amount(result.getPrice()) + .importedAmount((int) (result.getPrice()*0.1)) + .waitingSortingAmount(result.getDonationStatus().equals(DonationStatus.PARTIAL_EXECUTION) ? result.getExecutionPrice() : (long) (result.getPrice() * 0.9)) + .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 1c4f793f..444be6a8 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 @@ -175,4 +175,10 @@ public PageResponse> getProjectDonationS return new PageResponse<>(projects.isLast(), projects.getTotalElements(), projectDonations); } + + public PageResponse> getProjectDonationLists(Project project, int page, int size) { + Page donationUsers = donationAdaptor.findDonationLists(project.getId(), page, size); + + return new PageResponse<>(donationUsers.isLast(),donationUsers.getTotalElements(), adminDonationConverter.convertToDonationLists(donationUsers.getContent())); + } } 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 03b3fbcc..c141caf1 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 @@ -4,11 +4,13 @@ import com.example.matchdomain.donation.entity.enums.HistoryStatus; import com.example.matchdomain.donation.entity.enums.RegularPayStatus; import com.example.matchdomain.project.entity.enums.ProjectKind; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.List; public class DonationRes { @@ -371,4 +373,31 @@ public static class CompleteDonation { @Schema(description = "랜덤 불꽃이 메세지") private String randomMessage; } + + @Getter + @Setter + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class ProjectDonationDto { + private Long donationId; + + @JsonFormat(pattern = "yyyy.MM.dd.HH:mm") + private LocalDateTime donationDate; + + private DonationStatus donationStatus; + + private String donationStatusName; + + private Long userId; + + private String userName; + + private Long amount; + + private Long waitingSortingAmount; + + @Schema(description = "수입 금액") + private int importedAmount; + } } diff --git a/Match-Api/src/main/java/com/example/matchapi/portone/controller/PaymentController.java b/Match-Api/src/main/java/com/example/matchapi/portone/controller/PaymentController.java index 8c70314a..c9a1abfc 100644 --- a/Match-Api/src/main/java/com/example/matchapi/portone/controller/PaymentController.java +++ b/Match-Api/src/main/java/com/example/matchapi/portone/controller/PaymentController.java @@ -66,7 +66,7 @@ public CommonResponse getPaymentInfo(@RequestParam Stri Project project = projectService.findByProject(orderRequest.getProjectId()); - String accessToken = jwtService.createTokenToWeb(user.getId(), 600L); + String accessToken = jwtService.createTokenToWeb(user.getId(), 6000L); return CommonResponse.onSuccess(mapper.toPaymentInfoDto(user.getName(), user.getBirth(), user.getPhoneNumber(), project.getUsages(), project.getRegularStatus(), accessToken)); } diff --git a/Match-Domain/src/main/generated/com/example/matchdomain/donation/entity/QDonationHistory.java b/Match-Domain/src/main/generated/com/example/matchdomain/donation/entity/QDonationHistory.java index 42e74dc6..8a3f9d36 100644 --- a/Match-Domain/src/main/generated/com/example/matchdomain/donation/entity/QDonationHistory.java +++ b/Match-Domain/src/main/generated/com/example/matchdomain/donation/entity/QDonationHistory.java @@ -43,6 +43,8 @@ public class QDonationHistory extends EntityPathBase { public final NumberPath id = createNumber("id", Long.class); + public final StringPath item = createString("item"); + public final com.example.matchdomain.project.entity.QProject project; public final NumberPath projectId = createNumber("projectId", Long.class); diff --git a/Match-Domain/src/main/java/com/example/matchdomain/donation/adaptor/DonationAdaptor.java b/Match-Domain/src/main/java/com/example/matchdomain/donation/adaptor/DonationAdaptor.java index 6393428d..1b92e024 100644 --- a/Match-Domain/src/main/java/com/example/matchdomain/donation/adaptor/DonationAdaptor.java +++ b/Match-Domain/src/main/java/com/example/matchdomain/donation/adaptor/DonationAdaptor.java @@ -18,7 +18,7 @@ import java.util.List; import static com.example.matchdomain.common.model.Status.ACTIVE; -import static com.example.matchdomain.donation.entity.enums.DonationStatus.EXECUTION_REFUND; +import static com.example.matchdomain.donation.entity.enums.DonationStatus.*; import static com.example.matchdomain.donation.exception.DonationListErrorCode.FILTER_NOT_EXIST; import static com.example.matchdomain.donation.exception.DonationRefundErrorCode.DONATION_NOT_EXIST; import static com.example.matchdomain.project.entity.enums.ImageRepresentStatus.REPRESENT; @@ -123,4 +123,12 @@ public Page findByUserForAdminPage(User user, int page, int size) return donationUserRepository.findByUserOrderByIdAsc(user, pageable); } + + public Page findDonationLists(Long projectId, int page, int size) { + Pageable pageable = PageRequest.of(page, size); + List in = List.of(new DonationStatus[]{EXECUTION_BEFORE, PARTIAL_EXECUTION}); + + return donationUserRepository.findByProjectIdAndDonationStatusInOrderByCreatedAtAsc(projectId, in, pageable); + + } } diff --git a/Match-Domain/src/main/java/com/example/matchdomain/donation/repository/DonationUserRepository.java b/Match-Domain/src/main/java/com/example/matchdomain/donation/repository/DonationUserRepository.java index 422e4f37..0da83b60 100644 --- a/Match-Domain/src/main/java/com/example/matchdomain/donation/repository/DonationUserRepository.java +++ b/Match-Domain/src/main/java/com/example/matchdomain/donation/repository/DonationUserRepository.java @@ -83,6 +83,11 @@ public interface DonationUserRepository extends JpaRepository Page findByUserOrderByIdAsc(User user, Pageable pageable); + @Query(value = "SELECT DU FROM DonationUser DU JOIN FETCH DU.user " + + "WHERE DU.projectId = :projectId AND DU.donationStatus IN :statuses ORDER BY DU.createdAt ASC", + countQuery = "SELECT count(DU) FROM DonationUser DU WHERE DU.projectId = :projectId AND DU.donationStatus IN :statuses") + Page findByProjectIdAndDonationStatusInOrderByCreatedAtAsc(@Param("projectId") Long projectId, @Param("statuses") List donationStatuses, Pageable pageable); + interface flameList { Long getRegularPayId(); diff --git a/Match-Domain/src/main/java/com/example/matchdomain/project/repository/ProjectRepository.java b/Match-Domain/src/main/java/com/example/matchdomain/project/repository/ProjectRepository.java index 29735e32..452fc25e 100644 --- a/Match-Domain/src/main/java/com/example/matchdomain/project/repository/ProjectRepository.java +++ b/Match-Domain/src/main/java/com/example/matchdomain/project/repository/ProjectRepository.java @@ -310,7 +310,7 @@ Page findTodayProject(@Param("userId") Long userId, @Param("project " count(RP.id)'totalDonationCnt',\n" + " GROUP_CONCAT(U.profileImgUrl SEPARATOR ',') AS 'imgUrlList'\n" + "FROM Project P\n" + - " LEFT JOIN RegularPayment RP ON P.id = RP.projectId\n" + + " LEFT JOIN RegularPayment RP ON P.id = RP.projectId and RP.regularPayStatus = 'PROCEEDING'\n" + " LEFT JOIN User U ON RP.userId = U.id\n" + "WHERE P.id = :projectId \n" + "GROUP BY P.id ", nativeQuery = true) diff --git a/Match-Infrastructure/src/main/java/com/example/matchinfrastructure/pay/portone/service/PortOneAuthService.java b/Match-Infrastructure/src/main/java/com/example/matchinfrastructure/pay/portone/service/PortOneAuthService.java index a7f4077f..223229ac 100644 --- a/Match-Infrastructure/src/main/java/com/example/matchinfrastructure/pay/portone/service/PortOneAuthService.java +++ b/Match-Infrastructure/src/main/java/com/example/matchinfrastructure/pay/portone/service/PortOneAuthService.java @@ -42,7 +42,7 @@ public String getAuthToken() { return portOneResponse.getResponse().getAccess_token(); } - @Scheduled(fixedRate = 1750000) // 30분마다 실행 + @Scheduled(fixedRate = 1200000) public void refreshAuthToken() { String refreshToken = getTokens(); log.info("refresh token {} ", refreshToken);