Skip to content

Commit

Permalink
Kyungwhan (#53)
Browse files Browse the repository at this point in the history
* feat: Recharge

* fix: git pull

* feat: git pull

* feat: git pull

* merge : 충돌 해결

* fix

* fix : cashlog 중복 제거

* fix : 달력 예약되어있는 날짜 수정

* fix

* fix

* fix

* refactor: Refactor

* feat: Inheritance of payment Entities, Add Querydsl on CashLogRepository

* for merge

* fix: Bug fix

* feat: CashLog 쿼리 최적화, 결제 내역에 Pay 관련 데이터만 출력되도록 변경, 2차 프로젝트 엔티티 추가

* for merge

* refactor : reservation save, modify 서비스와 컨트롤러 리팩토링

* feat : HOST, GUEST 역할 분리

* feat : 웹소켓 연결 설정

* commit

* feat : 채팅방 생성 후 db에 저장, 생성된 채팅방 id를 응답

* fix : 특정 채팅방만 구독

* feat : 클라이언트로부터 받는 메세지 정보 DTO로 받음, DB에 저장 후 DTO로 응답, 채팅방 정보 전송

* fix : WebSocketConfig에서 CORS 설정에 배포환경 추가

* refactor : 채팅 api와 웹소켓 컨트롤러 구분

* feat : 채팅방에 이전 채팅 내역 찾아서 보내기

* feat: Add Batch, Settle, modify ReservationInit etc

* merge

* feat : 마이페이지 나의 문의내역을 위한 DTO

* fix : 채팅방에 다른 유저 접근 못하게 설정

* feat : 마이페이지 나의 문의내역 채팅방 리스트
채팅방 생성된 순서로 정렬(수정 필요)

* feat : 숙소 예약 현황 불러오기1

* feat : 숙소 호스트 숙소 관리 페이지 초안 완성

* feat : 채팅방 최신 메세지 순으로 정렬

* feat : 쿠폰 관련 CRUD 패키지 생성

* feat : 쿠폰 생성 로직 구현1

* feat : 첫 예약 쿠폰 발급 로직 초안 구현

* feat: SettleController

* feat : Guest의 쿠폰 가지고 오는 로직 구현

* feat : 채팅방 퇴장을 위한 필드 추가, 채팅방 생성 로직 변경

* feat : 마이페이지 문의내역 게스트와 호스트 구분
- 게스트는 퇴장한 채팅방 보이지 않게

* feat : 종료된 채팅방 정보를 위해 DTO에 필드 추가

* feat : 채팅 내역은 없고 생성만 된 채팅방 마이페이지에서 채팅방이 생성된 시간 표시
- ChatRoom이 DateEntity를 상속받게 함
- DTO에도 생성시간 필드 추가

* feat: Settle Api

* feat : 쿠폰 사용 로직 초안 구현

* feat : 결제 시 쿠폰 사용 구현 초안

* feat : 쿠폰 사용 시 삭제하는 컨트롤러, 서비스 구현 중1

* feat: Settle Page

* feat : 마이페이지 문의내역 호스트 진행중/종료 구분

* fix: bug

* fix

* fix: bug fix

* fix : 마이페이지 호스트와 게스트 분리 후 페이징 문제 해결

* fix : 마이페이지 문의내역 응답 유저 역할로만 구분

* fix : 채팅내역이 없는 채팅방은 마이페이지 문의내역에 표시하지 않음

* feat : 채팅방 입장 및 퇴장 시 메세지 읽음 처리

* feat : 채팅방 목록 응답 시 안 읽은 메세지 개수 포함

* feat : 채팅방 목록 응답 시 안 읽은 메세지 개수 포함

* fix : 채팅방 목록 응답 시 안 읽은 메세지 개수 포함(상대방이 보낸 메세지들 중)

* refactor : 코드 정리

* feat : 쿠폰 사용 시 CouponRecord에 사용기록 저장 및 쿠폰 삭제

* feat: settleKw

* merge

* feat: Refactor Init

* feat : ReservationService 테스트 코드 작성

* fix: Fix bug on Settle

* fix

* fix

* merge

* test : ReservationController 테스트 코드 작성 중

* test : ReservationControllerTest 코드 작성(추가 확인 필요)

* merge

* feat: CashLogControllerTest

* delete : Withdraw 엔티티 삭제됨

* fix : ReservationControllerTest 수정

* fix : ReservationControllerTest 수정 - ObjectMapper로 응답 데이터 비교

* fix : ReservationControllerTest 수정 - ObjectMapper로 응답 데이터 비교

* feat : ReservationControllerTest post

* fix : ReservationControllerTest post 응답 데이터 비교

* fix : ReservationControllerTest MemberOnly 체커 작동하게 설정, 접근 권한까지 확인

* feat: Add test code

* fix: Fix test code

* feat: Payment ControllerTest

* fix: Delete SecurityTestConfig

* feat: CashLogServiceTest

* feat: CashLogServiceTest 테스트 추가

* feat: 테스트 추가

* feat: RechargeServiceTest 작성

* merge

* feat: SettleService 테스트 코드 작성

* fix: 버그 수정

---------

Co-authored-by: jkeum-dev <[email protected]>
Co-authored-by: kyumho kim <[email protected]>
  • Loading branch information
3 people authored Apr 20, 2024
1 parent 6fdacd4 commit 2215bb5
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ public class RechargeService {
@Transactional
public void doRecharge(final TossConfirmRequest tossConfirmRequest, final Member member, final Long discountAmount) {
TossPaymentRequest tossPaymentRequest = tossService.confirmTossPayment(tossConfirmRequest).block();
Recharge recharge = null;

if (isVirtual(tossPaymentRequest)) {
Recharge recharge = requestVirtualRecharge(tossPaymentRequest, member);
rechargeRepository.save(recharge);
return;
}
if (isVirtual(tossPaymentRequest)) recharge = requestVirtualRecharge(tossPaymentRequest, member);

if (isEasyPay(tossPaymentRequest)) recharge = easyPayRecharge(tossPaymentRequest, member, discountAmount);

if (isEasyPay(tossPaymentRequest)) {
Recharge recharge = easyPayRecharge(tossPaymentRequest, member, discountAmount);
if (recharge != null) {
rechargeRepository.save(recharge);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.hotsix_be.payment.settle.service;

import com.example.hotsix_be.common.exception.ExceptionCode;
import com.example.hotsix_be.member.entity.Member;
import com.example.hotsix_be.member.service.MemberService;
import com.example.hotsix_be.payment.cashlog.entity.EventType;
Expand All @@ -21,6 +20,8 @@
import java.time.LocalDate;
import java.util.Optional;

import static com.example.hotsix_be.common.exception.ExceptionCode.ALREADY_BEEN_SETTLED;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Expand All @@ -34,9 +35,7 @@ public class SettleService {
@Transactional
public Settle doSettle(final Reservation reservation) {
// 이미 정산된 데이터일 경우 예외 발생
if (reservation.isSettled()) {
throw new PaymentException(ExceptionCode.ALREADY_BEEN_SETTLED);
}
if (reservation.isSettled()) throw new PaymentException(ALREADY_BEEN_SETTLED);

Member host = reservation.getHost(); // 호스트
Long price = reservation.getPrice(); // 원래 가격
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class SettleUt {
@Getter
private static Integer commissionRate;

public SettleUt(@Value("${settle.commissionRate}") final Integer commissionRate) {
@Value("${settle.commissionRate}")
private void setCommissionRate(final Integer commissionRate) {
this.commissionRate = commissionRate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,50 +54,51 @@ public class PayServiceTest {
private CouponService couponService;

private Member guest;
private Member host;
private Hotel hotel;
private Reservation reservation;

@BeforeEach
void initData() {
guest = new Member(
1L,
"KIM",
"KIM",
null
);
Member host = Member.builder()
.id(2L)
.socialLoginId("techit")
.nickname("techit")
.imageUrl(null)
.build();
host.assignRole(Role.HOST);

guest = Member.builder()
.id(3L)
.socialLoginId("Park")
.nickname("Park")
.imageUrl(null)
.restCash(0L)
.build();
guest.assignRole(Role.GUEST);

host = new Member(
2L,
"techit",
"techit",
null
);
host.assignRole(Role.HOST);
hotel = new Hotel(
"호텔",
"서울시 강남구",
"강남역 1번출구",
10L,
10L,
10L,
10L,
List.of("헬스장"),
"강남호텔",
"강남호텔입니다.",
10000L,
host
);
reservation = new Reservation(
LocalDate.now().plusDays(3),
LocalDate.now().plusDays(6),
2L,
100000L,
false,
hotel,
guest
);
Hotel hotel = Hotel.builder()
.hotelType("호텔")
.address("서울시 강남구")
.addressDetail("강남역 1번출구")
.roomCnt(10L)
.bedCnt(10L)
.bathroomCnt(10L)
.maxPeople(10L)
.facility(List.of("헬스장"))
.nickname("강남호텔")
.description("강남호텔입니다.")
.price(10000L)
.owner(host)
.build();

reservation = Reservation.builder()
.checkInDate(LocalDate.now().plusDays(3))
.checkOutDate(LocalDate.now().plusDays(6))
.guests(2L)
.price(100000L)
.isPaid(false)
.hotel(hotel)
.member(guest)
.build();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package com.example.hotsix_be.payment.refund.service;

import com.example.hotsix_be.hotel.entity.Hotel;
import com.example.hotsix_be.member.entity.Member;
import com.example.hotsix_be.member.entity.Role;
import com.example.hotsix_be.payment.cashlog.service.CashLogService;
import com.example.hotsix_be.payment.refund.repository.RefundRepository;
import com.example.hotsix_be.reservation.entity.Reservation;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.time.LocalDate;
import java.util.List;

@ExtendWith(MockitoExtension.class)
public class RefundServiceTest {
@InjectMocks
Expand All @@ -18,5 +28,59 @@ public class RefundServiceTest {
@Mock
private CashLogService cashLogService;

private Member guest;
private Reservation reservation;

@BeforeEach
void initData() {
guest = new Member(
1L,
"KIM",
"KIM",
null
);
guest.assignRole(Role.GUEST);

Member host = new Member(
2L,
"techit",
"techit",
null
);
host.assignRole(Role.HOST);
Hotel hotel = new Hotel(
"호텔",
"서울시 강남구",
"강남역 1번출구",
10L,
10L,
10L,
10L,
List.of("헬스장"),
"강남호텔",
"강남호텔입니다.",
10000L,
host
);
reservation = new Reservation(
LocalDate.now().plusDays(3),
LocalDate.now().plusDays(6),
2L,
100000L,
false,
hotel,
guest
);
}

@Test
@DisplayName("예약 취소를 진행한다.")
void doRefund() {
// given

// when
refundService.doRefund(reservation, 0L);

// then
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.example.hotsix_be.payment.settle.batch.config;

/*
@Configuration
@RequiredArgsConstructor
public class BatchTestConfig {
@Bean
public JobLauncherTestUtils settleJobLauncherTestUtils(Job settleJob) {
JobLauncherTestUtils utils = new JobLauncherTestUtils();
utils.setJob(settleJob);
return utils;
}
}
*/
//package com.example.hotsix_be.payment.settle.batch.config;
//
//import lombok.RequiredArgsConstructor;
//import org.springframework.batch.core.Job;
//import org.springframework.batch.test.JobLauncherTestUtils;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//@RequiredArgsConstructor
//public class BatchTestConfig {
// @Bean
// public JobLauncherTestUtils settleJobLauncherTestUtils(Job settleJob) {
// JobLauncherTestUtils utils = new JobLauncherTestUtils();
// utils.setJob(settleJob);
// return utils;
// }
//}
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
package com.example.hotsix_be.payment.settle.batch.service;


/*
@SpringBootTest
@SpringBatchTest
@ActiveProfiles("test")
public class BatchServiceTest {
@Autowired
private JobLauncherTestUtils settleJobLauncherTestUtils;
@DisplayName("settleJob launchTest")
@Test
public void t1() throws Exception {
// given
LocalDate currentDateTime = LocalDate.now();
LocalDate endDay = currentDateTime
.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY));
JobParameters jobParameters = new JobParametersBuilder()
.addLocalDate("endDay", endDay)
.addJobParameters(settleJobLauncherTestUtils.getUniqueJobParameters())
.toJobParameters();
// when
JobExecution jobExecution = settleJobLauncherTestUtils.launchJob(jobParameters);
// then
Assertions.assertEquals(jobExecution.getStatus(), BatchStatus.COMPLETED);
Assertions.assertEquals(jobExecution.getExitStatus(), ExitStatus.COMPLETED);
}}
=======
}
}
*/
//package com.example.hotsix_be.payment.settle.batch.service;
//
//import org.junit.jupiter.api.Assertions;
//import org.junit.jupiter.api.DisplayName;
//import org.junit.jupiter.api.Test;
//import org.springframework.batch.core.*;
//import org.springframework.batch.test.JobLauncherTestUtils;
//import org.springframework.batch.test.context.SpringBatchTest;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.ActiveProfiles;
//
//import java.time.DayOfWeek;
//import java.time.LocalDate;
//import java.time.temporal.TemporalAdjusters;
//
//@SpringBootTest
//@SpringBatchTest
//@ActiveProfiles("test")
//public class BatchServiceTest {
// @Autowired
// private JobLauncherTestUtils settleJobLauncherTestUtils;
//
// @DisplayName("settleJob launchTest")
// @Test
// public void t1() throws Exception {
//
// // given
// LocalDate currentDateTime = LocalDate.now();
//
// LocalDate endDay = currentDateTime
// .with(TemporalAdjusters.previous(DayOfWeek.SUNDAY));
//
// JobParameters jobParameters = new JobParametersBuilder()
// .addLocalDate("endDay", endDay)
// .addJobParameters(settleJobLauncherTestUtils.getUniqueJobParameters())
// .toJobParameters();
//
// // when
// JobExecution jobExecution = settleJobLauncherTestUtils.launchJob(jobParameters);
//
// // then
// Assertions.assertEquals(jobExecution.getStatus(), BatchStatus.COMPLETED);
// Assertions.assertEquals(jobExecution.getExitStatus(), ExitStatus.COMPLETED);
// }
//}
Loading

0 comments on commit 2215bb5

Please sign in to comment.