-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from WE-ARE-RACCOONS/RAC-325
RAC-325 feat : 환불 기능 추가
- Loading branch information
Showing
39 changed files
with
482 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminAuthUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.postgraduate.domain.adminssr.application.usecase; | ||
|
||
import com.postgraduate.domain.adminssr.application.dto.req.Login; | ||
import com.postgraduate.domain.adminssr.domain.service.AuthGetService; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AdminAuthUseCase { | ||
private final AuthGetService authGetService; | ||
|
||
public User login(Login loginForm) { | ||
return authGetService.login(loginForm.nickName(), loginForm.phoneNumber()); | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
...main/java/com/postgraduate/domain/adminssr/application/usecase/AdminMentoringUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.postgraduate.domain.adminssr.application.usecase; | ||
|
||
import com.postgraduate.domain.admin.application.dto.MentoringInfo; | ||
import com.postgraduate.domain.admin.application.dto.UserMentoringInfo; | ||
import com.postgraduate.domain.admin.application.dto.res.MentoringManageResponse; | ||
import com.postgraduate.domain.admin.application.dto.res.MentoringWithPaymentResponse; | ||
import com.postgraduate.domain.admin.application.mapper.AdminMapper; | ||
import com.postgraduate.domain.mentoring.domain.entity.Mentoring; | ||
import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; | ||
import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; | ||
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.salary.domain.entity.Salary; | ||
import com.postgraduate.domain.salary.domain.service.SalaryGetService; | ||
import com.postgraduate.domain.salary.domain.service.SalaryUpdateService; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.service.SeniorGetService; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.domain.user.domain.service.UserGetService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToMentoringWithPaymentResponse; | ||
import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToUserMentoringInfo; | ||
import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.DONE; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AdminMentoringUseCase { | ||
private final MentoringGetService mentoringGetService; | ||
private final MentoringUpdateService mentoringUpdateService; | ||
private final SeniorGetService seniorGetService; | ||
private final UserGetService userGetService; | ||
private final PaymentGetService paymentGetService; | ||
private final PaymentManageUseCase paymentManageUseCase; | ||
private final SalaryGetService salaryGetService; | ||
private final SalaryUpdateService salaryUpdateService; | ||
|
||
public MentoringManageResponse seniorMentorings(Long seniorId) { | ||
Senior senior = seniorGetService.bySeniorId(seniorId); | ||
List<Mentoring> mentorings = mentoringGetService.bySeniorId(seniorId); | ||
List<MentoringInfo> mentoringInfos = mentorings.stream() | ||
.map(AdminMapper::mapToMentoringInfo) | ||
.toList(); | ||
UserMentoringInfo seniorInfo = mapToUserMentoringInfo(senior); | ||
return new MentoringManageResponse(mentoringInfos, seniorInfo); | ||
} | ||
|
||
public MentoringManageResponse userMentoringInfos(Long userId) { | ||
User user = userGetService.byUserId(userId); | ||
List<Mentoring> mentorings = mentoringGetService.byUserId(userId); | ||
List<MentoringInfo> mentoringInfos = mentorings.stream() | ||
.map(AdminMapper::mapToMentoringInfo) | ||
.toList(); | ||
UserMentoringInfo userInfo = mapToUserMentoringInfo(user); | ||
return new MentoringManageResponse(mentoringInfos, userInfo); | ||
} | ||
|
||
public MentoringWithPaymentResponse paymentMentoringInfo(Long paymentId) { | ||
Payment payment = paymentGetService.byId(paymentId); | ||
Mentoring mentoring = mentoringGetService.byPayment(payment); | ||
return mapToMentoringWithPaymentResponse(mentoring); | ||
} | ||
|
||
public void refundMentoring(User user, Long mentoringId) { | ||
Mentoring mentoring = mentoringGetService.byMentoringId(mentoringId); | ||
Payment payment = mentoring.getPayment(); | ||
paymentManageUseCase.refundPayByAdmin(user, payment.getPaymentId()); | ||
if (mentoring.getStatus() == DONE) { | ||
Senior senior = mentoring.getSenior(); | ||
Salary salary = salaryGetService.bySenior(senior); | ||
salaryUpdateService.minusTotalAmount(salary); | ||
} | ||
mentoringUpdateService.updateCancel(mentoring); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminPaymentUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.postgraduate.domain.adminssr.application.usecase; | ||
|
||
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; | ||
|
||
import java.util.List; | ||
|
||
import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToPaymentInfo; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AdminPaymentUseCase { | ||
private final PaymentGetService paymentGetService; | ||
private final MentoringGetService mentoringGetService; | ||
private final PaymentManageUseCase paymentManageUseCase; | ||
|
||
public List<PaymentInfo> paymentInfos() { | ||
List<Payment> all = paymentGetService.all(); | ||
return all.stream() | ||
.map(payment -> { | ||
Mentoring mentoring = mentoringGetService.byPaymentWithNull(payment); | ||
if (mentoring == null) | ||
return mapToPaymentInfo(payment); | ||
return mapToPaymentInfo(payment, mentoring); | ||
}) | ||
.toList(); | ||
} | ||
|
||
public void refundPayment(User user, Long paymentId) { | ||
paymentManageUseCase.refundPayByAdmin(user, paymentId); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSalaryUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.postgraduate.domain.adminssr.application.usecase; | ||
|
||
import com.postgraduate.domain.admin.application.dto.SalaryInfo; | ||
import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; | ||
import com.postgraduate.domain.salary.domain.entity.Salary; | ||
import com.postgraduate.domain.salary.domain.service.SalaryGetService; | ||
import com.postgraduate.domain.salary.domain.service.SalaryUpdateService; | ||
import com.postgraduate.domain.salary.exception.SalaryNotYetException; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.service.SeniorGetService; | ||
import com.postgraduate.global.config.security.util.EncryptorUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
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; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AdminSalaryUseCase { | ||
private final SeniorGetService seniorGetService; | ||
private final SalaryGetService salaryGetService; | ||
private final SalaryUpdateService salaryUpdateService; | ||
private final EncryptorUtils encryptorUtils; | ||
|
||
public List<SalaryInfo> salaryInfos() { | ||
List<Salary> all = salaryGetService.findAll(); | ||
return all.stream() | ||
.filter(salary -> getStatus(salary) == DONE) | ||
.map(salary -> { | ||
if (salary.getAccountNumber() == null) | ||
return mapToSalaryResponse(salary.getSenior(), salary); | ||
String accountNumber = encryptorUtils.decryptData(salary.getAccountNumber()); | ||
return mapToSalaryResponse(salary.getSenior(), accountNumber, salary); | ||
}) | ||
.toList(); | ||
} | ||
|
||
public SalaryInfo seniorSalary(Long seniorId) { | ||
Senior senior = seniorGetService.bySeniorId(seniorId); | ||
Salary salary = salaryGetService.bySeniorLastWeek(senior); | ||
SalaryStatus status = getStatus(salary); | ||
if (status != YET) | ||
throw new SalaryNotYetException(); | ||
if (salary.getAccountNumber() == null) | ||
return mapToSalaryResponse(senior, salary); | ||
String accountNumber = encryptorUtils.decryptData(salary.getAccountNumber()); | ||
return mapToSalaryResponse(senior, accountNumber, salary); | ||
} | ||
|
||
public void salaryDone(Long salaryId) { | ||
Salary salary = salaryGetService.bySalaryId(salaryId); | ||
salaryUpdateService.updateDone(salary); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/postgraduate/domain/adminssr/application/usecase/AdminSeniorUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.postgraduate.domain.adminssr.application.usecase; | ||
|
||
import com.postgraduate.domain.admin.application.dto.SeniorInfo; | ||
import com.postgraduate.domain.admin.application.dto.res.CertificationDetailsResponse; | ||
import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; | ||
import com.postgraduate.domain.salary.domain.entity.Salary; | ||
import com.postgraduate.domain.salary.domain.service.SalaryGetService; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.service.SeniorGetService; | ||
import com.postgraduate.domain.senior.domain.service.SeniorUpdateService; | ||
import com.postgraduate.domain.senior.exception.SeniorCertificationException; | ||
import com.postgraduate.domain.wish.domain.entity.Wish; | ||
import com.postgraduate.domain.wish.domain.service.WishGetService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToCertificationInfo; | ||
import static com.postgraduate.domain.admin.application.mapper.AdminMapper.mapToSeniorInfo; | ||
import static com.postgraduate.domain.salary.util.SalaryUtil.getStatus; | ||
import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AdminSeniorUseCase { | ||
private final SeniorGetService seniorGetService; | ||
private final SeniorUpdateService seniorUpdateService; | ||
private final SalaryGetService salaryGetService; | ||
private final WishGetService wishGetService; | ||
|
||
public List<SeniorInfo> allSenior() { | ||
List<Senior> seniors = seniorGetService.allSeniorId(); | ||
return seniors.stream() | ||
.map(senior -> { | ||
Salary salary = salaryGetService.bySeniorLastWeek(senior); | ||
SalaryStatus salaryStatus = getStatus(salary); | ||
Optional<Wish> wish = wishGetService.byUser(senior.getUser()); | ||
return mapToSeniorInfo(senior, salaryStatus, wish.isPresent()); | ||
}) | ||
.toList(); | ||
} | ||
|
||
public CertificationDetailsResponse getCertification(Long seniorId) { | ||
Senior senior = seniorGetService.bySeniorId(seniorId); | ||
if (senior.getStatus() == APPROVE) | ||
throw new SeniorCertificationException(); | ||
return mapToCertificationInfo(senior); | ||
} | ||
|
||
|
||
public void updateNotApprove(Long seniorId) { | ||
Senior senior = seniorGetService.bySeniorId(seniorId); | ||
seniorUpdateService.certificationUpdateNotApprove(senior); | ||
} | ||
|
||
public void updateApprove(Long seniorId) { | ||
Senior senior = seniorGetService.bySeniorId(seniorId); | ||
seniorUpdateService.certificationUpdateApprove(senior); | ||
} | ||
|
||
} |
Oops, something went wrong.