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;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.api.BillKkoPayApiSpec;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.BillKkoPay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.QBillKkoPay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.repository.BillKkoPayRepository;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.KkoPayUrlRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.PayUseSysApi;
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.modules.common.ctgy.intgrnbill.support.code.BillSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.Bill;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.BillHist;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.QBill;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository.BillHistRepository;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayUrlService;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.PayUrlData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.ReqAndRespInf;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.QOrgMng;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.querydsl.jpa.impl.JPAQueryFactory;
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;
import java.util.*;
import java.util.function.*;
import org.springframework.http.*;
import org.springframework.stereotype.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
import com.querydsl.jpa.impl.*;
import cokr.xit.ens.core.exception.*;
import cokr.xit.ens.core.exception.code.*;
import cokr.xit.ens.core.utils.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.api.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.entity.repository.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*;
import cokr.xit.ens.modules.common.domain.support.*;
import lombok.*;
import lombok.extern.slf4j.*;
@Slf4j
@RequiredArgsConstructor
@ -100,7 +91,7 @@ public class KkoPayUrlService implements PayUrlService<PayUrlData<BillKkoPay>, S
/**
* FIXME: Url API
* FIXME: Comment Url API
* [ ]
* 1. payUseSysApi.payUrl
* : 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
*/
Optional.ofNullable(data.getBillDetail())
.map(billKkoPay -> createMessage(billKkoPay.getBillerUserKey()))
.map(param -> loadReqData(data, useSysUrl, param))
.map(param -> payUseSysApi.payUrl(useSysUrl, param, null))
.map(response -> loadRespData(data, response))
.map(response -> checkResponse(response))
.map(document -> savePayUrlInfo(data, document))
.map(document -> createGnrUrlMessage(data, document))
.map(param -> loadGnrUrlReqData(data, param))
.map(param -> billKkoPayApi.url(billerCode, authorization, param))
.map(response -> loadGnrUrlRespData(data, response))
.map(response -> checkGnrUrlResponse(false, response))
.map(respData -> saveUrl(data, respData))
.filter(respData -> respData == null)
.map(respData -> loadGnrReUrlReqData(data))
.map(param -> billKkoPayApi.reUrl(billerCode, authorization, param))
.map(response -> checkGnrUrlResponse(true, response))
.map(respData -> saveUrl(data, respData))
.map(billKkoPay -> {
log.info("KkoPayUrlService::callApi - createMessage: {}", billKkoPay.getBillerUserKey());
return safely(() -> createMessage(billKkoPay.getBillerUserKey()));
})
.map(param -> {
log.info("KkoPayUrlService::callApi - loadReqData: {}", param);
return safely(() -> loadReqData(data, useSysUrl, param));
})
.map(param -> {
log.info("KkoPayUrlService::callApi - payUseSysApi.payUrl", param);
return safely(() -> payUseSysApi.payUrl(useSysUrl, param, null));
})
.map(response -> {
log.info("KkoPayUrlService::callApi - loadRespData: {}", response);
return safely(() -> loadRespData(data, response));
})
.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