From 745594fa09a6a56144529771bd6b67221611a14f Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 19 Mar 2024 01:51:26 +0900 Subject: [PATCH 1/3] =?UTF-8?q?RAC-325=20fix=20:=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=9E=90=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/adminssr/application/usecase/AdminSalaryUseCase.java | 2 ++ .../domain/salary/domain/service/SalaryGetService.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java index 005647c1..56b991de 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java +++ b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java @@ -16,6 +16,7 @@ import java.util.List; import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToSalaryResponse; +import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.DONE; import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.YET; import static com.postgraduate.domain.salary.util.SalaryUtil.getStatus; @@ -31,6 +32,7 @@ public class AdminSalaryUseCase { public List salaryInfos() { List all = salaryGetService.findAll(); return all.stream() + .filter(salary -> getStatus(salary) == DONE) .map(salary -> { if (salary.getAccountNumber() == null) return mapToSalaryResponse(salary.getSenior(), salary); diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java index bf2750c3..dfba9da4 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java @@ -30,7 +30,7 @@ public Salary bySalaryId(Long salaryId) { } public Salary bySenior(Senior senior) { - LocalDate salaryDate = SalaryUtil.getSalaryDate(); + LocalDate salaryDate = SalaryUtil.getSalaryDate().minusDays(7); return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate) .orElseThrow(SalaryNotFoundException::new); } From 503bde60035382cd4a1efa1e92f5e3dfbb7eec4d Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 19 Mar 2024 01:51:51 +0900 Subject: [PATCH 2/3] =?UTF-8?q?RAC-325=20fix=20:=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=9E=90=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=99=98=EB=B6=88=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/AdminPaymentUseCase.java | 7 ++ .../AdminWithThymeLeafController.java | 64 +++++++++---------- src/main/resources/templates/adminMain.html | 21 ++++++ .../resources/templates/adminPayment.html | 2 + 4 files changed, 61 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminPaymentUseCase.java b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminPaymentUseCase.java index bb04fa7d..e66ab04c 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminPaymentUseCase.java +++ b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminPaymentUseCase.java @@ -3,8 +3,10 @@ import com.postgraduate.domain.admin.application.dto.PaymentInfo; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; +import com.postgraduate.domain.payment.application.usecase.PaymentManageUseCase; import com.postgraduate.domain.payment.domain.entity.Payment; import com.postgraduate.domain.payment.domain.service.PaymentGetService; +import com.postgraduate.domain.user.domain.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,6 +21,7 @@ public class AdminPaymentUseCase { private final PaymentGetService paymentGetService; private final MentoringGetService mentoringGetService; + private final PaymentManageUseCase paymentManageUseCase; public List paymentInfos() { List all = paymentGetService.all(); @@ -31,4 +34,8 @@ public List paymentInfos() { }) .toList(); } + + public void refundPayment(User user, Long paymentId) { + paymentManageUseCase.refundPayByAdmin(user, paymentId); + } } diff --git a/src/main/java/com/postgraduate/domain/adminssr/presentation/AdminWithThymeLeafController.java b/src/main/java/com/postgraduate/domain/adminssr/presentation/AdminWithThymeLeafController.java index 912fa633..7dc439df 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/presentation/AdminWithThymeLeafController.java +++ b/src/main/java/com/postgraduate/domain/adminssr/presentation/AdminWithThymeLeafController.java @@ -3,7 +3,6 @@ import com.postgraduate.domain.admin.application.dto.*; import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; import com.postgraduate.domain.admin.application.dto.res.MentoringManageResponse; -import com.postgraduate.domain.admin.application.dto.res.MentoringWithPaymentResponse; import com.postgraduate.domain.admin.application.dto.res.WishResponse; import com.postgraduate.domain.adminssr.application.dto.req.Login; import com.postgraduate.domain.adminssr.application.usecase.*; @@ -51,27 +50,6 @@ public String seniorInfo(Model model) { return "adminSenior"; } - @GetMapping("/userInfo") - public String userInfo(Model model) { - List userInfos = adminUserUseCase.userInfos(); - model.addAttribute("userInfos", userInfos); - return "adminUser"; - } - - @GetMapping("/paymentInfo") - public String paymentInfo(Model model) { - List paymentInfos = adminPaymentUseCase.paymentInfos(); - model.addAttribute("paymentInfos", paymentInfos); - return "adminPayment"; - } - - @GetMapping("/salaryInfo") - public String salaryInfo(Model model) { - List salaryInfos = adminSalaryUseCase.salaryInfos(); - model.addAttribute("salaryInfo", salaryInfos); - return "adminSalary"; - } - @GetMapping("/certification/{seniorId}") public String certification(@PathVariable Long seniorId, Model model) { CertificationDetailsResponse certification = adminSeniorUseCase.getCertification(seniorId); @@ -104,6 +82,13 @@ public String refundMentoring(@AuthenticationPrincipal User user, @PathVariable return "adminEmpty"; } + @GetMapping("/salaryInfo") + public String salaryInfo(Model model) { + List salaryInfos = adminSalaryUseCase.salaryInfos(); + model.addAttribute("salaryInfo", salaryInfos); + return "adminSalary"; + } + @GetMapping("/salary/{seniorId}") public String seniorSalaryInfo(@PathVariable Long seniorId, Model model) { SalaryInfo salaryInfo = adminSalaryUseCase.seniorSalary(seniorId); @@ -117,6 +102,12 @@ public String salaryDone(@PathVariable Long salaryId) { return "adminEmpty"; } + @PostMapping("/wish/done/{wishId}") + public String wishDone(@PathVariable Long wishId) { + adminUserUseCase.wishDone(wishId); + return "adminEmpty"; + } + @GetMapping("/user/matching/{userId}") public String userMatching(@PathVariable Long userId, Model model) { WishResponse wishResponse = adminUserUseCase.wishInfo(userId); @@ -124,12 +115,6 @@ public String userMatching(@PathVariable Long userId, Model model) { return "userWish"; } - @PostMapping("/wish/done/{wishId}") - public String wishDone(@PathVariable Long wishId) { - adminUserUseCase.wishDone(wishId); - return "adminEmpty"; - } - @GetMapping("/user/mentoring/{userId}") public String userMentoring(@PathVariable Long userId, Model model) { MentoringManageResponse mentoringInfos = adminMentoringUseCase.userMentoringInfos(userId); @@ -137,10 +122,23 @@ public String userMentoring(@PathVariable Long userId, Model model) { return "userMentoring"; } - @GetMapping("/payment/mentoring/{paymentId}") - public String paymentMentoring(@PathVariable Long paymentId, Model model) { - MentoringWithPaymentResponse mentoringInfo = adminMentoringUseCase.paymentMentoringInfo(paymentId); - model.addAttribute("mentoringInfo", mentoringInfo); - return "paymentMentoring"; + @GetMapping("/userInfo") + public String userInfo(Model model) { + List userInfos = adminUserUseCase.userInfos(); + model.addAttribute("userInfos", userInfos); + return "adminUser"; + } + + @GetMapping("/paymentInfo") + public String paymentInfo(Model model) { + List paymentInfos = adminPaymentUseCase.paymentInfos(); + model.addAttribute("paymentInfos", paymentInfos); + return "adminPayment"; + } + + @PostMapping("/payment/refund/{paymentId}") + public String refundPayment(@AuthenticationPrincipal User user, @PathVariable Long paymentId) { + adminPaymentUseCase.refundPayment(user, paymentId); + return "adminEmpty"; } } diff --git a/src/main/resources/templates/adminMain.html b/src/main/resources/templates/adminMain.html index 8d84756e..31f7b94c 100644 --- a/src/main/resources/templates/adminMain.html +++ b/src/main/resources/templates/adminMain.html @@ -286,6 +286,27 @@ }; xhr.send(); } + + function refundPayment(paymentId) { + if (confirm("정말 환불하겠습니까??") == true){ //확인 + var xhr = new XMLHttpRequest(); + xhr.open("POST", "/adminServer/payment/refund/" + paymentId, true); + xhr.setRequestHeader("Authorization", "Bearer " + accessToken); + xhr.onreadystatechange = function() { + if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status === 200) { + document.getElementById("output").innerHTML = xhr.responseText; + } else { + localStorage.removeItem("accessToken"); + localStorage.removeItem("refreshToken"); + } + } + }; + xhr.send(); + }else{ //취소 + return false; + } + } diff --git a/src/main/resources/templates/adminPayment.html b/src/main/resources/templates/adminPayment.html index 6d96a756..ab554f2b 100644 --- a/src/main/resources/templates/adminPayment.html +++ b/src/main/resources/templates/adminPayment.html @@ -26,6 +26,7 @@ 전화번호 결제일시 멘토링정보 + 환불/취소 결제상태 @@ -36,6 +37,7 @@ phoneNumber createdAt + status From 69fecd2cbe76c401dc0f8ef9c69a6e10a7751b2b Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 19 Mar 2024 02:29:53 +0900 Subject: [PATCH 3/3] =?UTF-8?q?RAC-325=20fix=20:=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminssr/application/usecase/AdminSalaryUseCase.java | 2 +- .../adminssr/application/usecase/AdminSeniorUseCase.java | 2 +- .../domain/salary/domain/service/SalaryGetService.java | 6 ++++++ .../domain/senior/presentation/SeniorControllerTest.java | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java index 56b991de..e386a9d1 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java +++ b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java @@ -44,7 +44,7 @@ public List salaryInfos() { public SalaryInfo seniorSalary(Long seniorId) { Senior senior = seniorGetService.bySeniorId(seniorId); - Salary salary = salaryGetService.bySenior(senior); + Salary salary = salaryGetService.bySeniorLastWeek(senior); SalaryStatus status = getStatus(salary); if (status != YET) throw new SalaryNotYetException(); diff --git a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSeniorUseCase.java b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSeniorUseCase.java index f1d276ce..d2fe6c0b 100644 --- a/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSeniorUseCase.java +++ b/src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSeniorUseCase.java @@ -36,7 +36,7 @@ public List allSenior() { List seniors = seniorGetService.allSeniorId(); return seniors.stream() .map(senior -> { - Salary salary = salaryGetService.bySenior(senior); + Salary salary = salaryGetService.bySeniorLastWeek(senior); SalaryStatus salaryStatus = getStatus(salary); Optional wish = wishGetService.byUser(senior.getUser()); return mapToSeniorInfo(senior, salaryStatus, wish.isPresent()); diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java index dfba9da4..1958dd83 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java @@ -30,6 +30,12 @@ public Salary bySalaryId(Long salaryId) { } public Salary bySenior(Senior senior) { + LocalDate salaryDate = SalaryUtil.getSalaryDate(); + return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate) + .orElseThrow(SalaryNotFoundException::new); + } + + public Salary bySeniorLastWeek(Senior senior) { LocalDate salaryDate = SalaryUtil.getSalaryDate().minusDays(7); return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate) .orElseThrow(SalaryNotFoundException::new); diff --git a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java index 405d88f0..c074fcac 100644 --- a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java +++ b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java @@ -9,6 +9,7 @@ import com.postgraduate.domain.available.domain.repository.AvailableRepository; import com.postgraduate.domain.salary.domain.entity.Salary; import com.postgraduate.domain.salary.domain.repository.SalaryRepository; +import com.postgraduate.domain.salary.util.SalaryUtil; import com.postgraduate.domain.senior.application.dto.req.*; import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Profile; @@ -31,12 +32,14 @@ import org.junit.jupiter.params.provider.EmptySource; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.mockito.BDDMockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; import java.io.IOException; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -47,6 +50,7 @@ import static java.lang.Boolean.TRUE; import static java.time.LocalDateTime.now; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;