Skip to content

Commit

Permalink
Merge pull request #28 from lotteon2/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
qwerty1434 authored Jan 20, 2024
2 parents 8194cdb + 4eefd90 commit cfd055b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import bloomingblooms.domain.payment.KakaopayApproveRequestDto;
import bloomingblooms.domain.payment.KakaopayReadyRequestDto;
import bloomingblooms.domain.payment.KakaopayReadyResponseDto;
import bloomingblooms.domain.payment.PaymentInfoDto;
import bloomingblooms.domain.payment.PaymentInfoMapDto;
import bloomingblooms.response.CommonResponse;
import bloomingblooms.domain.payment.PaymentInfoRequestDto;
import java.time.LocalDateTime;
import java.util.List;
import kr.bb.payment.dto.request.KakaopayCancelRequestDto;
import kr.bb.payment.service.KakaopayService;
import kr.bb.payment.service.PaymentService;
Expand Down Expand Up @@ -41,8 +43,8 @@ public CommonResponse<LocalDateTime> payApprove(
}

@PostMapping("/paymentInfo")
CommonResponse<PaymentInfoMapDto> getPaymentInfo(@RequestBody PaymentInfoRequestDto paymentInfoRequestDto ){
return CommonResponse.success(paymentService.getPaymentInfo(paymentInfoRequestDto.getOrderGroupIds()));
CommonResponse<List<PaymentInfoDto>> getPaymentInfo(@RequestBody List<String> orderGroupIds ){
return CommonResponse.success(paymentService.getPaymentInfo(orderGroupIds));
}

@GetMapping(value = "/paymentDate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface PaymentRepository extends JpaRepository<Payment, Long> {
Payment findByOrderId(String orderId);
@Query("select p from Payment p where p.orderId in :orderIds")
@Query("select p from Payment p where p.orderId in :orderIds order by p.createdAt desc")
List<Payment> findAllByOrderIds(List<String> orderIds);
}
10 changes: 3 additions & 7 deletions src/main/java/kr/bb/payment/service/PaymentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import bloomingblooms.domain.notification.order.OrderType;
import bloomingblooms.domain.payment.KakaopayApproveRequestDto;
import bloomingblooms.domain.payment.PaymentInfoDto;
import bloomingblooms.domain.payment.PaymentInfoMapDto;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -83,9 +82,9 @@ public void saveDeliveryIds(Map<Long, Long> oldDeliveryIdsMap, List<Long> newDel
}

@Transactional
public PaymentInfoMapDto getPaymentInfo(List<String> orderGroupIds ) {
public List<PaymentInfoDto> getPaymentInfo(List<String> orderGroupIds ) {
List<Payment> allPaymentsByOrderIds = paymentRepository.findAllByOrderIds(orderGroupIds);
Map<String, PaymentInfoDto> paymentInfoDtoMap = allPaymentsByOrderIds.stream()
return allPaymentsByOrderIds.stream()
.map(
payment -> {
return PaymentInfoDto.builder()
Expand All @@ -94,10 +93,7 @@ public PaymentInfoMapDto getPaymentInfo(List<String> orderGroupIds ) {
.createdAt(payment.getCreatedAt())
.build();
})
.collect(Collectors.toMap(PaymentInfoDto::getOrderGroupId, dto -> dto));
return PaymentInfoMapDto.builder()
.paymentInfoDtoMap(paymentInfoDtoMap)
.build();
.collect(Collectors.toList());
}

@Transactional
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/kr/bb/payment/service/PaymentServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import bloomingblooms.domain.payment.PaymentInfoMapDto;
import bloomingblooms.domain.payment.PaymentInfoDto;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -15,8 +15,8 @@ public class PaymentServiceTest {
@Autowired private PaymentService paymentService;
@Test
void getPaymentInfoTest(){
PaymentInfoMapDto paymentInfoMapDto = paymentService.getPaymentInfo(List.of("임시주문번호"));
assertThat(paymentInfoMapDto.getPaymentInfoDtoMap().size()).isEqualTo(0);
List<PaymentInfoDto> paymentInfo = paymentService.getPaymentInfo(List.of("임시주문번호"));
assertThat(paymentInfo.size()).isEqualTo(0);
}

@Test
Expand Down

0 comments on commit cfd055b

Please sign in to comment.