Skip to content

Commit

Permalink
�Api-Release-v0.0.2.11
Browse files Browse the repository at this point in the history
�Api-Release-v0.0.2.11
  • Loading branch information
imenuuu authored Dec 6, 2023
2 parents 584c426 + 046feb4 commit 9e6164c
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 입니다.")
Expand Down Expand Up @@ -77,4 +80,15 @@ public CommonResponse<PageResponse<List<DonationRes.ProjectDonationStatus>>> get
){
return CommonResponse.onSuccess(adminDonationService.getProjectDonationStatus(page, size));
}

@GetMapping("/execution/{projectId}")
@Operation(summary = "기부금 리스트 확인")
public CommonResponse<PageResponse<List<DonationRes.ProjectDonationDto>>> 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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,4 +101,30 @@ public DonationRes.ProjectDonationStatus convertToStatusDetail(List<DonationExec
.completeAmount(completeAmount)
.build();
}

public List<DonationRes.ProjectDonationDto> convertToDonationLists(List<DonationUser> content) {
List<DonationRes.ProjectDonationDto> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,10 @@ public PageResponse<List<DonationRes.ProjectDonationStatus>> getProjectDonationS

return new PageResponse<>(projects.isLast(), projects.getTotalElements(), projectDonations);
}

public PageResponse<List<DonationRes.ProjectDonationDto>> getProjectDonationLists(Project project, int page, int size) {
Page<DonationUser> donationUsers = donationAdaptor.findDonationLists(project.getId(), page, size);

return new PageResponse<>(donationUsers.isLast(),donationUsers.getTotalElements(), adminDonationConverter.convertToDonationLists(donationUsers.getContent()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public CommonResponse<OrderRes.PaymentInfoDto> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class QDonationHistory extends EntityPathBase<DonationHistory> {

public final NumberPath<Long> id = createNumber("id", Long.class);

public final StringPath item = createString("item");

public final com.example.matchdomain.project.entity.QProject project;

public final NumberPath<Long> projectId = createNumber("projectId", Long.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -123,4 +123,12 @@ public Page<DonationUser> findByUserForAdminPage(User user, int page, int size)

return donationUserRepository.findByUserOrderByIdAsc(user, pageable);
}

public Page<DonationUser> findDonationLists(Long projectId, int page, int size) {
Pageable pageable = PageRequest.of(page, size);
List<DonationStatus> in = List.of(new DonationStatus[]{EXECUTION_BEFORE, PARTIAL_EXECUTION});

return donationUserRepository.findByProjectIdAndDonationStatusInOrderByCreatedAtAsc(projectId, in, pageable);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public interface DonationUserRepository extends JpaRepository<DonationUser,Long>

Page<DonationUser> 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<DonationUser> findByProjectIdAndDonationStatusInOrderByCreatedAtAsc(@Param("projectId") Long projectId, @Param("statuses") List<DonationStatus> donationStatuses, Pageable pageable);


interface flameList {
Long getRegularPayId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Page<ProjectList> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9e6164c

Please sign in to comment.