fix: 카카오페이결재 처리시 로깅추가

main
Jonguk. Lim 2 months ago
parent 168c5db27c
commit bc70be8695

@ -1,42 +1,33 @@
package cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process; package cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process;
import cokr.xit.ens.core.exception.EnsException; import java.util.*;
import cokr.xit.ens.core.exception.code.EnsErrCd; import java.util.function.*;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.api.BillKkoPayApiSpec; import org.springframework.http.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.BillKkoPay; import org.springframework.stereotype.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.QBillKkoPay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.repository.BillKkoPayRepository; import com.google.gson.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.KkoPayUrlRespData; import com.google.gson.reflect.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.PayUseSysApi; import com.querydsl.jpa.impl.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillLogSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillReqSeCd; import cokr.xit.ens.core.exception.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillSeCd; import cokr.xit.ens.core.exception.code.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd; import cokr.xit.ens.core.utils.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.Bill; import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.api.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.BillHist; import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.QBill; import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.repository.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository.BillHistRepository; import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayUrlService; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.PayUrlData; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.ReqAndRespInf; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.QOrgMng; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.*;
import cokr.xit.ens.modules.common.domain.support.FieldError; import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.*;
import com.google.gson.Gson; import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*;
import com.google.gson.GsonBuilder; import cokr.xit.ens.modules.common.domain.support.*;
import com.google.gson.reflect.TypeToken; import lombok.*;
import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.extern.slf4j.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@ -100,7 +91,7 @@ public class KkoPayUrlService implements PayUrlService<PayUrlData<BillKkoPay>, S
/** /**
* FIXME: Url API * FIXME: Comment Url API
* [ ] * [ ]
* 1. payUseSysApi.payUrl * 1. payUseSysApi.payUrl
* : https://phts-manager.koti.re.kr/iup/bill/kkopay/gnr/url * : https://phts-manager.koti.re.kr/iup/bill/kkopay/gnr/url
@ -117,23 +108,74 @@ public class KkoPayUrlService implements PayUrlService<PayUrlData<BillKkoPay>, S
* API RE API * API RE API
*/ */
Optional.ofNullable(data.getBillDetail()) Optional.ofNullable(data.getBillDetail())
.map(billKkoPay -> createMessage(billKkoPay.getBillerUserKey())) .map(billKkoPay -> {
.map(param -> loadReqData(data, useSysUrl, param)) log.info("KkoPayUrlService::callApi - createMessage: {}", billKkoPay.getBillerUserKey());
.map(param -> payUseSysApi.payUrl(useSysUrl, param, null)) return safely(() -> createMessage(billKkoPay.getBillerUserKey()));
.map(response -> loadRespData(data, response)) })
.map(response -> checkResponse(response)) .map(param -> {
.map(document -> savePayUrlInfo(data, document)) log.info("KkoPayUrlService::callApi - loadReqData: {}", param);
.map(document -> createGnrUrlMessage(data, document)) return safely(() -> loadReqData(data, useSysUrl, param));
.map(param -> loadGnrUrlReqData(data, param)) })
.map(param -> billKkoPayApi.url(billerCode, authorization, param)) .map(param -> {
.map(response -> loadGnrUrlRespData(data, response)) log.info("KkoPayUrlService::callApi - payUseSysApi.payUrl", param);
.map(response -> checkGnrUrlResponse(false, response)) return safely(() -> payUseSysApi.payUrl(useSysUrl, param, null));
.map(respData -> saveUrl(data, respData)) })
.filter(respData -> respData == null) .map(response -> {
.map(respData -> loadGnrReUrlReqData(data)) log.info("KkoPayUrlService::callApi - loadRespData: {}", response);
.map(param -> billKkoPayApi.reUrl(billerCode, authorization, param)) return safely(() -> loadRespData(data, response));
.map(response -> checkGnrUrlResponse(true, response)) })
.map(respData -> saveUrl(data, respData)) .map(response -> {
log.info("KkoPayUrlService::callApi - checkResponse: {}", response);
return safely(() -> checkResponse(response));
})
.map(document -> {
log.info("KkoPayUrlService::callApi - savePayUrlInfo: {}", document);
return safely(() -> savePayUrlInfo(data, document));
})
.map(document -> {
log.info("KkoPayUrlService::callApi - createGnrUrlMessage: {}", document);
return safely(() -> createGnrUrlMessage(data, document));
})
.map(param -> {
log.info("KkoPayUrlService::callApi - loadGnrUrlReqData: {}", param);
return safely(() -> loadGnrUrlReqData(data, param));
})
.map(param -> {
log.info("KkoPayUrlService::callApi - billKkoPayApi.url: {}", param);
return safely(() -> billKkoPayApi.url(billerCode, authorization, param));
})
.map(response -> {
log.info("KkoPayUrlService::callApi - loadGnrUrlRespData: {}", response);
return safely(() -> loadGnrUrlRespData(data, response));
})
.map(response -> {
log.info("KkoPayUrlService::callApi - checkGnrUrlResponse: {}", response);
return safely(() -> checkGnrUrlResponse(false, response));
})
.map(respData -> {
log.info("KkoPayUrlService::callApi - saveUrl: {}", respData);
return safely(() -> saveUrl(data, respData));
})
.filter(respData -> {
log.info("KkoPayUrlService::callApi - respData == null: {}", respData);
return safely(() -> respData == null);
})
.map(respData -> {
log.info("KkoPayUrlService::callApi - loadGnrReUrlReqData: {}", respData);
return safely(() -> loadGnrReUrlReqData(data));
})
.map(param -> {
log.info("KkoPayUrlService::callApi - billKkoPayApi.reUrl: {}", param);
return safely(() -> billKkoPayApi.reUrl(billerCode, authorization, param));
})
.map(response -> {
log.info("KkoPayUrlService::callApi - checkGnrReUrlResponse: {}", response);
return safely(() -> checkGnrUrlResponse(true, response));
})
.map(respData -> {
log.info("KkoPayUrlService::callApi - saveUrl: {}", respData);
return safely(() -> saveUrl(data, respData));
})
; ;
} }
@ -434,4 +476,13 @@ public class KkoPayUrlService implements PayUrlService<PayUrlData<BillKkoPay>, S
} }
} }
private <T> T safely(Supplier<T> supplier) {
try {
return supplier.get();
} catch (Exception e) {
log.info("Error occurred", e);
throw new EnsException(EnsErrCd.UNKNOWN, e.getMessage());
}
}
} }

Loading…
Cancel
Save