Skip to content

Commit

Permalink
Merge branch 'feat/billing' of https://github.com/Try-AngIe/cms-plus
Browse files Browse the repository at this point in the history
…into feat/billing
  • Loading branch information
pogihae committed Jul 24, 2024
2 parents f2cb302 + bb2dac2 commit df975e2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ private ErrorRes(final ErrorCode code) {
this.errors = new ArrayList<>();
}

private ErrorRes(final ErrorCode code, final String message) {
this.message = message;
this.status = code.getStatus();
this.code = code.getCode();
this.errors = new ArrayList<>();
}


public static ErrorRes of(final ErrorCode code, final BindingResult bindingResult) {
return new ErrorRes(code, FieldError.of(bindingResult));
Expand All @@ -48,6 +55,10 @@ public static ErrorRes of(final ErrorCode code) {
return new ErrorRes(code);
}

public static ErrorRes of(final ErrorCode code, final String message) {
return new ErrorRes(code, message);
}

public static ErrorRes of(final ErrorCode code, final List<FieldError> errors) {
return new ErrorRes(code, errors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import kr.or.kosa.cmsplusmain.domain.base.error.exception.BusinessException;
import kr.or.kosa.cmsplusmain.domain.base.error.exception.EntityNotFoundException;
import kr.or.kosa.cmsplusmain.domain.billing.exception.InvalidBillingStatusException;
import lombok.extern.slf4j.Slf4j;

@ControllerAdvice
Expand Down Expand Up @@ -80,6 +81,14 @@ protected ResponseEntity<ErrorRes> handleAccessDeniedException(AccessDeniedExcep
return new ResponseEntity<>(response, HttpStatus.valueOf(ErrorCode.HANDLE_ACCESS_DENIED.getStatus()));
}

@ExceptionHandler(InvalidBillingStatusException.class)
protected ResponseEntity<ErrorRes> handleInvalidBillingStatusException(final InvalidBillingStatusException e) {
log.error("handleInvalidBillingStatusException", e);
final ErrorCode errorCode = e.getErrorCode();
final ErrorRes response = ErrorRes.of(errorCode, e.getMessage());
return new ResponseEntity<>(response, HttpStatus.valueOf(errorCode.getStatus()));
}

@ExceptionHandler(BusinessException.class)
protected ResponseEntity<ErrorRes> handleBusinessException(final BusinessException e) {
log.error("handleBusinessException", e);
Expand All @@ -88,7 +97,6 @@ protected ResponseEntity<ErrorRes> handleBusinessException(final BusinessExcepti
return new ResponseEntity<>(response, HttpStatus.valueOf(errorCode.getStatus()));
}


@ExceptionHandler(Exception.class)
protected ResponseEntity<ErrorRes> handleException(Exception e) {
log.error("handleUnknownException", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void cancelInvoice(@VendorId Long vendorId, @PathVariable Long billingId)
* */
@GetMapping("payment/{billingId}")
public void payRealtimeBilling(@VendorId Long vendorId, @PathVariable Long billingId) {
billingService.payBilling(vendorId, billingId);
billingService.payRealTimeBilling(vendorId, billingId);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ public void cancelInvoice(Long vendorId, Long billingId) {
billing.setInvoiceCancelled();
}

/*
* 청구 실시간 결제
* */
@Transactional
public void payBilling(Long vendorId, Long billingId) {
Billing billing = validateAndGetBilling(vendorId, billingId);
Expand All @@ -127,6 +124,19 @@ public void payBilling(Long vendorId, Long billingId) {
billing.setPaid();
}

/*
* 청구 실시간 결제
* */
@Transactional
public void payRealTimeBilling(Long vendorId, Long billingId) {
Billing billing = validateAndGetBilling(vendorId, billingId);
BillingState.Field.PAY_REALTIME.validateState(billing);

// TODO: 결제 프로세스 구현

billing.setPaid();
}

/*
* 청구 실시간 결제 취소
* */
Expand Down

0 comments on commit df975e2

Please sign in to comment.