diff --git a/src/main/java/com/hanaro/triptogether/account/controller/AccountController.java b/src/main/java/com/hanaro/triptogether/account/controller/AccountController.java index 9f862c1..7e163a9 100644 --- a/src/main/java/com/hanaro/triptogether/account/controller/AccountController.java +++ b/src/main/java/com/hanaro/triptogether/account/controller/AccountController.java @@ -32,15 +32,15 @@ public List accounts(@RequestBody Map memberIdxMap return accountService.accounts(memberIdx); } - // 계좌 입금 + // 계좌 입출금 @PutMapping("/account/deposit") public void depositAcc(@RequestBody UpdateAccBalanceReq updateAccBalanceReq) { accountService.depositAcc(updateAccBalanceReq); } // 계좌 출금 - @PutMapping("/account/withdraw") - public void withdrawAcc(@RequestBody UpdateAccBalanceReq updateAccBalanceReq) { - accountService.withdrawAcc(updateAccBalanceReq); - } +// @PutMapping("/account/withdraw") +// public void withdrawAcc(@RequestBody UpdateAccBalanceReq updateAccBalanceReq) { +// accountService.withdrawAcc(updateAccBalanceReq); +// } } diff --git a/src/main/java/com/hanaro/triptogether/account/dto/request/UpdateAccBalanceReq.java b/src/main/java/com/hanaro/triptogether/account/dto/request/UpdateAccBalanceReq.java index d67b80f..3ed215d 100644 --- a/src/main/java/com/hanaro/triptogether/account/dto/request/UpdateAccBalanceReq.java +++ b/src/main/java/com/hanaro/triptogether/account/dto/request/UpdateAccBalanceReq.java @@ -6,7 +6,8 @@ @Getter public class UpdateAccBalanceReq { - private Long accIdx; + private Long depositAccIdx; // 입금 계좌 + private Long withdrawAccIdx; // 출금 계좌 private BigDecimal amount; private String memo; } diff --git a/src/main/java/com/hanaro/triptogether/account/service/AccountService.java b/src/main/java/com/hanaro/triptogether/account/service/AccountService.java index c94d98e..adf76ac 100644 --- a/src/main/java/com/hanaro/triptogether/account/service/AccountService.java +++ b/src/main/java/com/hanaro/triptogether/account/service/AccountService.java @@ -13,9 +13,9 @@ public interface AccountService { // 전체 계좌 조회 (계좌 선택 기능) List accounts(Long memberIdx); - // 계좌 입금 + // 계좌 입출금 void depositAcc(UpdateAccBalanceReq updateAccBalanceReq); // 계좌 출금 - void withdrawAcc(UpdateAccBalanceReq updateAccBalanceReq); +// void withdrawAcc(UpdateAccBalanceReq updateAccBalanceReq); } diff --git a/src/main/java/com/hanaro/triptogether/account/service/impl/AccountServiceImpl.java b/src/main/java/com/hanaro/triptogether/account/service/impl/AccountServiceImpl.java index 23fac2e..3dc0222 100644 --- a/src/main/java/com/hanaro/triptogether/account/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/hanaro/triptogether/account/service/impl/AccountServiceImpl.java @@ -84,25 +84,33 @@ public List accounts(Long memberIdx) { return accountsResDtos; } - // 계좌 입금 + // 계좌 입출금 @Transactional @Override public void depositAcc(UpdateAccBalanceReq updateAccBalanceReq) { - Account account = accountRepository.findById(updateAccBalanceReq.getAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); + // 계좌 입금 + Account depositAcc = accountRepository.findById(updateAccBalanceReq.getDepositAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); - account.updateAccBalance(account.getAccBalance().add(updateAccBalanceReq.getAmount())); - account.updateModifiedAt(LocalDateTime.now()); - accountRepository.save(account); - } + depositAcc.updateAccBalance(depositAcc.getAccBalance().add(updateAccBalanceReq.getAmount())); + depositAcc.updateModifiedAt(LocalDateTime.now()); + accountRepository.save(depositAcc); - // 계좌 출금 - @Transactional - @Override - public void withdrawAcc(UpdateAccBalanceReq updateAccBalanceReq) { - Account account = accountRepository.findById(updateAccBalanceReq.getAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); + // 계좌 출금 + Account withdrawAcc = accountRepository.findById(updateAccBalanceReq.getWithdrawAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); - account.updateAccBalance(account.getAccBalance().subtract(updateAccBalanceReq.getAmount())); - account.updateModifiedAt(LocalDateTime.now()); - accountRepository.save(account); + withdrawAcc.updateAccBalance(withdrawAcc.getAccBalance().subtract(updateAccBalanceReq.getAmount())); + withdrawAcc.updateModifiedAt(LocalDateTime.now()); + accountRepository.save(withdrawAcc); } + + // 계좌 출금 +// @Transactional +// @Override +// public void withdrawAcc(UpdateAccBalanceReq updateAccBalanceReq) { +// Account account = accountRepository.findById(updateAccBalanceReq.getAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); +// +// account.updateAccBalance(account.getAccBalance().subtract(updateAccBalanceReq.getAmount())); +// account.updateModifiedAt(LocalDateTime.now()); +// accountRepository.save(account); +// } } diff --git a/src/main/java/com/hanaro/triptogether/team/dto/response/ManageTeamResDto.java b/src/main/java/com/hanaro/triptogether/team/dto/response/ManageTeamResDto.java index 8fc633b..e3d282b 100644 --- a/src/main/java/com/hanaro/triptogether/team/dto/response/ManageTeamResDto.java +++ b/src/main/java/com/hanaro/triptogether/team/dto/response/ManageTeamResDto.java @@ -12,4 +12,5 @@ public class ManageTeamResDto { private String accNumber; private BigDecimal accBalance; private Boolean alarmStatus; + private Long accIdx; } diff --git a/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java b/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java index 1520b8f..a1ae267 100644 --- a/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java +++ b/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java @@ -113,6 +113,7 @@ public ManageTeamResDto manageTeam(ManageTeamReqDto manageTeamReqDto) { .accNumber(account.getAccNumber()) .accBalance(account.getAccBalance()) .alarmStatus(member.getAlarmStatus()) + .accIdx(account.getAccIdx()) .build(); return manageTeamResDto; diff --git a/src/test/java/com/hanaro/triptogether/TeamServiceTests.java b/src/test/java/com/hanaro/triptogether/TeamServiceTests.java index 9882eb8..6e5ea07 100644 --- a/src/test/java/com/hanaro/triptogether/TeamServiceTests.java +++ b/src/test/java/com/hanaro/triptogether/TeamServiceTests.java @@ -145,6 +145,7 @@ void testManageTeam() { assertEquals(account.getAccNumber(), result.getAccNumber()); assertEquals(account.getAccBalance(), result.getAccBalance()); assertEquals(member.getAlarmStatus(), result.getAlarmStatus()); + assertEquals(account.getAccIdx(), result.getAccIdx()); verify(teamRepository, times(1)).findById(teamIdx); }