Skip to content

Commit

Permalink
Merge pull request #142 from WE-ARE-RACCOONS/develop
Browse files Browse the repository at this point in the history
RAC-304 deploy : 운영 반영
  • Loading branch information
ywj9811 authored Mar 2, 2024
2 parents 2f5c8ac + 3bbca7b commit 76efa0b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,17 @@ public static Payment resultToPayment(Salary salary, User user, PaymentResultReq
.paidAt(LocalDateTime.parse(request.PCD_PAY_TIME(), formatter))
.build();
}

public static Payment resultToPayment(PaymentResultRequest request) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
return Payment.builder()
.salary(null)
.user(null)
.pay(Integer.parseInt(request.PCD_PAY_TOTAL()))
.orderId(request.PCD_PAY_OID())
.cardAuthNumber(request.PCD_PAY_CARDAUTHNO())
.cardReceipt(request.PCD_PAY_CARDRECEIPT())
.paidAt(LocalDateTime.parse(request.PCD_PAY_TIME(), formatter))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,21 @@ public class PaymentManageUseCase {
private final WebClient webClient;

public void savePay(PaymentResultRequest request) {
if (!request.PCD_PAY_RST().equals(SUCCESS.getName()))
throw new PaymentFailException();
try {
if (!request.PCD_PAY_RST().equals(SUCCESS.getName()))
throw new PaymentFailException();
String seniorNickName = request.PCD_PAY_GOODS();
long userId = Long.parseLong(request.PCD_PAYER_NO());
User user = userGetService.byUserId(userId);
Senior senior = seniorGetService.bySeniorNickName(seniorNickName);
Salary salary = salaryGetService.bySeniorWithNull(senior);
Salary salary = salaryGetService.bySenior(senior);
Payment payment = PaymentMapper.resultToPayment(salary, user, request);
paymentSaveService.save(payment);
} catch (Exception ex) {
log.error("paymentError λ°œμƒ {}", ex.getMessage());
log.error("paymentError λ°œμƒ ν™˜λΆˆ 진행 | errorMessage : {}", ex.getMessage());
Payment payment = PaymentMapper.resultToPayment(request);
paymentSaveService.save(payment);
refundPay(payment);
}
}

Expand Down Expand Up @@ -124,16 +127,16 @@ private void refundProcess(CertificationResponse response, Payment payment) {
}
Map<String, String> requestBody = getRefundRequestBody(response, payment);
RefundResponse refundResponse = Optional.ofNullable(webClient.post()
.uri(refundUri + response.PCD_PAY_URL())
.headers(h -> {
h.setContentType(MediaType.APPLICATION_JSON);
h.setCacheControl(noCache());
h.set(REFERER.getName(), refererUri);
})
.bodyValue(requestBody)
.retrieve()
.bodyToMono(RefundResponse.class)
.block())
.uri(refundUri + response.PCD_PAY_URL())
.headers(h -> {
h.setContentType(MediaType.APPLICATION_JSON);
h.setCacheControl(noCache());
h.set(REFERER.getName(), refererUri);
})
.bodyValue(requestBody)
.retrieve()
.bodyToMono(RefundResponse.class)
.block())
.orElseThrow(() -> new RefundFailException("NPE"));
if (!refundResponse.PCD_PAY_RST().equals(SUCCESS.getName()))
throw new RefundFailException(refundResponse.PCD_PAY_CODE());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ public Salary bySenior(Senior senior) {
return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate).orElseThrow(SalaryNotFoundException::new);
}

public Salary bySeniorWithNull(Senior senior) {
LocalDate salaryDate = SalaryUtil.getSalaryDate();
return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate).orElse(null);
}

public Page<SeniorSalary> findDistinctSeniors(String search, Integer page) {
page = page == null ? 1 : page;
Pageable pageable = PageRequest.of(page - 1, ADMIN_PAGE_SIZE);
Expand Down

0 comments on commit 76efa0b

Please sign in to comment.