Skip to content

Commit

Permalink
#264 feat: 채팅 및 편지 결제 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyongdodam committed Oct 5, 2024
1 parent 89dad7f commit a5b3af0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
public interface AdminService {
List<ConsultGetUnpaidResponse> getUnpaidConsults();

List<ConsultGetUnpaidResponse> getPaidConsults();

SmsGetResponse updateConsultIsPaid(Long consultId);
List<CounselorGetProfileResponse> getPendingCounselors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public List<ConsultGetUnpaidResponse> getUnpaidConsults() {
.toList();
}

@Override
public List<ConsultGetUnpaidResponse> getPaidConsults() {
return consultService.getPaidConsults().stream()
.map(ConsultGetUnpaidResponse::of)
.toList();
}

@Transactional
public SmsGetResponse updateConsultIsPaid(Long consultId) {
Consult consult = consultService.getConsultByConsultId(consultId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public ResponseEntity<List<ConsultGetUnpaidResponse>> getUnpaidConsults() {
return ResponseEntity.ok(adminService.getUnpaidConsults());
}

@Operation(summary = "미결제 상담(편지/채팅) 리스트 조회", description = "결제 여부(isPaid)가 true인 consult 리스트 조회")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "조회 성공")
})
@GetMapping("/paid-consults")
public ResponseEntity<List<ConsultGetUnpaidResponse>> getPaidConsults() {
return ResponseEntity.ok(adminService.getPaidConsults());
}

@Operation(summary = "상담(편지/채팅) 결제 여부 수정", description = "결제 여부(isPaid)가 false인 consult를 true로 수정")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공, resultCode로 sms api 발송 여부가 전달됩니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface ConsultService {

List<Consult> getUnpaidConsults();

List<Consult> getPaidConsults();

List<Consult> getConsultsByCustomerIdAndConsultTypeAndIsPaid(Long customerId, ConsultType consultType);

List<Consult> getConsultsByCounselorIdAndConsultTypeAndIsPaid(Long counselorId, ConsultType consultType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public List<Consult> getUnpaidConsults() {
return consultRepository.findAllByIsPaidIsFalseAndIsActivatedIsTrue();
}

@Override
public List<Consult> getPaidConsults() {
return consultRepository.findAllByIsPaidIsTrueAndIsActivatedIsTrue();
}

@Override
public List<Consult> getConsultsByCustomerIdAndConsultTypeAndIsPaid(Long customerId, ConsultType consultType) {
return consultRepository.findByCustomerIdAndConsultTypeAndIsPaid(customerId, consultType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public interface ConsultRepository extends JpaRepository<Consult, Long> {
@Query("SELECT c FROM Consult c JOIN FETCH c.payment p WHERE p.isPaid = false AND c.isActivated = true")
List<Consult> findAllByIsPaidIsFalseAndIsActivatedIsTrue();

@Query("SELECT c FROM Consult c JOIN FETCH c.payment p WHERE p.isPaid = true AND c.isActivated = true")
List<Consult> findAllByIsPaidIsTrueAndIsActivatedIsTrue();

@Query("SELECT chat.chatId FROM Consult c JOIN c.chat chat " +
"WHERE c.customer.customerId = :customerId AND c.isActivated = true AND c.consultStatus != 'FINISH'")
List<Long> findChatIdsByCustomerId(Long customerId); //todo: 쿼리 최적화 필요
Expand Down

0 comments on commit a5b3af0

Please sign in to comment.