init: 민자도로 미납통행료 전자고지 시스템

main
kjh 4 months ago
commit c9b43d2479

@ -0,0 +1,54 @@
### 프로젝트 실행 오류 처리
```text
import static cokr.xit.ens.modules.common.ctgy.sys.mng.domain.QOrgMng.orgMng;
관련해서 못찾는 경우가 발생
target > generated-sources 폴더
annotations, java 폴더가 Excluded 상태인데 마우스 우클릭해서 Source로 변경
* /doc/setting.png 참조
```
### 배포
```text
[민자]
mvn clean package -P prod-iup
```
### 업무
```text
[전자고지]
- 나이스 CI 소켓
- 카카오톡 전자고지 (기존 카카오페이 내 문서함에서 변경)
- 네이버 전자문서
- 업무 흐름 : 카카오톡 전자고지 발송 후 실패 자료만 바로 네이버 전자문서 발송
[결제]
- 카카오톡 전자고지 모바일 페이지 열람 시 카카오페이 결제 버튼만 있음
- 네이버 전자문서 모바일 페이지 열람 시 네이버 간편결제 버튼만 있음
```
### 연계
```text
[나이스 CI 소켓]
- /doc/NICE_CI모듈.zip
[카카오톡 전자고지]
- 홈페이지 : https://developers.kakao.com/
- 개발가이드 : https://developers.kakao.com/docs/latest/ko/kakaotalk-edoc/common
- 네트워크 연동 가이드 : https://kko.to/gB3Ba7BOKy
[네이버 전자문서]
- /doc/네이버_고지서_연동_가이드_V_1_1.pdf
[카카오페이 청구서]
- /doc/카카오페이청구서_조회납부_API가이드_v0.1.3.pdf
- 호출 : 민자 시스템 -> 더즌 -> 카카오페이
* 카카오페이 결제 관련해서 url 및 항목이 변경되었으나 더즌에서 중간에서 바이패스하지 않고 카카오페이 변경 내용을 적용함
(카카오페이 결제 버전이 변경되었으나 민자 시스템 변경사항 없음)
[네이버페이 간편결제]
- 개발자센터 : https://developer.pay.naver.com/
```

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,84 @@
package cokr.xit.ens;
import cokr.xit.ens.core.utils.Checks;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@Slf4j
@SpringBootApplication
//@Import({QuerydslConfig.class, CodeMapperConfig.class})
@ComponentScan(
// nameGenerator = CustomBeanNameGenerator.class,
basePackages = "cokr.xit")
//@EnableAutoConfiguration
@EnableScheduling
//@EnableWebMvc
//public class ModulePostApplication{
public class ModulePostApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
log.info("ENS Application load start...");
if (Checks.isEmpty(System.getProperty("spring.profiles.active"))) {
log.error("====================================================================");
log.error(">>>>>>>>>>>>>> Undefined start option <<<<<<<<<<<<<<");
log.error(">>>>>>>>>>>>>> -Dspring.profiles.active=local|dev|prod-traffic/prod-traffic-cheonan/prod-iup <<<<<<<<<<<<<<");
log.error("============== ENS Application start fail ===============");
log.error("====================================================================");
System.exit(-1);
}
System.setProperty("ens.active.profile", System.getProperty("spring.profiles.active"));
/*
SpringApplication.run(ModulePostApplication.class, args);
*/
Long begin = System.currentTimeMillis();
SpringApplication application = new SpringApplication(ModulePostApplication.class);
application.addListeners(new ApplicationPidFileWriter());
application.run(args);
log.info("=========================================================================================");
log.info("========== ENS Application load Complete :: active profiles - {} ==========", System.getProperty("spring.profiles.active"));
log.info("=========================================================================================");
Long end = System.currentTimeMillis();
System.out.println("====================================================");
System.out.println("기동 소요시간: " + (end - begin) + "ms");
System.out.println("====================================================");
/* multi-thread test */
// try {
// MultiThreadSample.example();
// MultiThreadSample.runnableExample();
// MultiThreadSample.callableExample();
// MultiThreadSample.completionServiceExample();
// } catch (InterruptedException e) {
// e.printStackTrace();
// } catch (ExecutionException e) {
// e.printStackTrace();
// }
/* multi-thread return result test */
// ResultByRunnableExample.main(args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ModulePostApplication.class);
}
}

@ -0,0 +1,13 @@
package cokr.xit.ens;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ModulePostApplication.class);
}
}

@ -0,0 +1,70 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.IntgrnNotiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsIntgrnScheduler {
private final IntgrnNotiService intgrnNotiService;
/**
*
* -. .
*/
@Scheduled(cron = "0 */10 9-18 * * *")
public void resended() {
EnsResponseVO responseVO = intgrnNotiService.sendBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS INTGRN] 통합고지 재전송처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
*
* -. "실패(~fail) 또는 만료(close) 외" .
* -. "전송완료(sendcmplt) 또는 열람중(open)" .
*/
@Scheduled(cron = "0 0 23 * * *")
public void fetched() {
EnsResponseVO responseVO = intgrnNotiService.statBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS INTGRN] 통합고지 문서상태갱신 처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
*
* -. "열람(open)" "마감(close)" .
*/
@Scheduled(cron = "30 0 9-18 * * *")
public void closed() {
EnsResponseVO<List<Long>> responseVO = intgrnNotiService.closed();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS INTGRN] 통합고지 마감처리 - 총 {}건")
.append("\nIntSendMastId {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.getResultInfo().size(), responseVO.getResultInfo().toString());
}
}

@ -0,0 +1,35 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.kkoalimtalk.service.KkoAlimtalkService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsKkoAlimtalkScheduler {
private final KkoAlimtalkService kkoAlimtalkService;
/**
*
* -. "제작성공(makeok)" (sendDt) .
*/
@Scheduled(cron = "0 */1 9-18 * * *")
public void sended() {
EnsResponseVO responseVO = kkoAlimtalkService.sendBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 카카오 알림톡 전송처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
}

@ -0,0 +1,68 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.kkomydoc.service.KkoMydocHisService;
import cokr.xit.ens.modules.kkomydoc.service.KkoMydocService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsKkoMydocScheduler {
private final KkoMydocService kkoMydocService;
private final KkoMydocHisService kkoMydocHisService;
/**
* ()
* -. "제작성공(makeok)" .
*/
@Scheduled(cron = "0 */1 9-18 * * *")
public void sended() {
EnsResponseVO responseVO = kkoMydocService.sendBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 카카오 내문서함(인증톡) 전송처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
* ()
* -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" .
* -. "전송완료(sendcmplt) 또는 열람중(open)" .
*/
// @Scheduled(cron = "0 */5 9-18 * * *")
@Scheduled(cron = "0 */30 9-18 * * *")
public void fetched() {
EnsResponseVO responseVO = kkoMydocService.statBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 카카오 내문서함(인증톡) 문서상태갱신 처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
* ()
*/
@Scheduled(cron = "4 4 4 * * *")
public void deleteStateHis() {
Long totCnt = kkoMydocHisService.truncateStatHist();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 카카오 내문서함(인증톡) 상태변경요청이력 영구 삭제")
.append("\n결과: {} 건 삭제")
.append("\n=======================================================");
log.info(sb.toString(), totCnt);
}
}

@ -0,0 +1,82 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.modules.ktsigntalk.gibis.service.KtGibisHisService;
import cokr.xit.ens.modules.ktsigntalk.gibis.service.KtGibisService;
import com.querydsl.core.Tuple;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import static cokr.xit.ens.modules.common.ctgy.sys.mng.domain.QOrgMng.orgMng;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsKtGibisScheduler {
private final KtGibisService ktGibisService;
private final KtGibisHisService ktGibisHisService;
private final JPAQueryFactory query;
/**
* KT ()
* -. "제작성공(makeok)" .
*/
@Scheduled(cron = "0 */1 9-18 * * *")
public void sended() {
EnsResponseVO responseVO = ktGibisService.sendBulkAll();
log.info("=======================================================");
log.info("[ENS] KT 인증톡(지비스) 전송처리");
log.info("결과: {}", responseVO.toString());
log.info("=======================================================");
}
/**
* KT ()
*/
@Scheduled(cron = "0 0 0 1 */4 *")
public void refreshAuthToken() {
List<Tuple> list = query.select(orgMng.orgCd, orgMng.ktStClientId, orgMng.ktStClientSecret)
.from(orgMng)
.where(orgMng.ktStAccessToken.isNotNull())
.fetch();
int cntRefresh = list.stream()
.map(tuple -> {
EnsResponseVO<Long> ensResponseVO = ktGibisService.refreshAuthToken(tuple.get(orgMng.orgCd), tuple.get(orgMng.ktStClientId), tuple.get(orgMng.ktStClientSecret));
return EnsErrCd.OK.equals(ensResponseVO.getErrCode()) ? 1 : 0;
})
.reduce(Integer::sum)
.orElse(0);
log.info("=======================================================");
log.info("[ENS] KT 인증톡(지비스) accessToken 갱신");
log.info("결과: {} 건 갱신({}/{})", cntRefresh, cntRefresh, list.size());
log.info("=======================================================");
}
// /**
// * KT 인증톡(지비스) 상태갱신요청이력 영구 삭제
// */
// @Scheduled(cron = "4 4 4 * * *")
// public void deleteStateHis() {
// EnsResponseVO<Long> ensResponseVO = ktGibisHisService.truncateStatHist();
// log.info("=======================================================");
// log.info("[ENS] KT 인증톡(지비스) 상태변경요청이력 영구 삭제");
// log.info("결과: {} 건 삭제", ensResponseVO.getResultInfo());
// log.info("=======================================================");
// }
}

@ -0,0 +1,63 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.ktsigntalk.direct.service.KtSigntalkHisService;
import cokr.xit.ens.modules.ktsigntalk.direct.service.KtSigntalkService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsKtSigntalkScheduler {
private final KtSigntalkService ktSigntalkService;
private final KtSigntalkHisService ktSigntalkHisService;
/**
* KT
* -. "제작성공(makeok)" .
*/
@Scheduled(cron = "0 */1 9-18 * * *")
public void sended() {
EnsResponseVO responseVO = ktSigntalkService.sendBulkAll();
log.info("=======================================================");
log.info("[ENS] KT 인증톡 전송처리");
log.info("결과: {}", responseVO.toString());
log.info("=======================================================");
}
/**
* KT
* -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" .
* -. "전송완료(sendcmplt) 또는 열람중(open)" .
*/
// @Scheduled(cron = "0 */5 9-18 * * *")
@Scheduled(cron = "0 */30 9-18 * * *")
public void fetched() {
EnsResponseVO responseVO = ktSigntalkService.statBulkAll();
log.info("=======================================================");
log.info("[ENS] KT 인증톡 문서상태갱신 처리");
log.info("결과: {}", responseVO.toString());
log.info("=======================================================");
}
/**
* KT
*/
@Scheduled(cron = "4 4 4 * * *")
public void deleteStateHis() {
EnsResponseVO<Long> ensResponseVO = ktSigntalkHisService.truncateStatHist();
log.info("=======================================================");
log.info("[ENS] KT 인증톡 상태변경요청이력 영구 삭제");
log.info("결과: {} 건 삭제", ensResponseVO.getResultInfo());
log.info("=======================================================");
}
}

@ -0,0 +1,70 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.nvsigntalk.service.NvSigntalkHisService;
import cokr.xit.ens.modules.nvsigntalk.service.NvSigntalkService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
@RequiredArgsConstructor
public class EnsNvSigntalkScheduler {
private final NvSigntalkService nvSigntalkService;
private final NvSigntalkHisService nvSigntalkHisService;
/**
* ()
* -. "제작성공(makeok)" .
*/
@Scheduled(cron = "0 */1 9-18 * * *")
public void sended() {
EnsResponseVO responseVO = nvSigntalkService.sendBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 네이버 고지서(인증톡) 전송처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
* ()
* -. "발송성공/발송완료/열람중(sendok/sendcmplt/open)" .
* -. "전송완료(sendcmplt) 또는 열람중(open)" .
*/
// @Scheduled(cron = "0 */5 9-18 * * *")
@Scheduled(cron = "0 */30 9-18 * * *")
public void fetched() {
EnsResponseVO responseVO = nvSigntalkService.statBulkAll();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 네이버 고지서(인증톡) 문서상태갱신 처리")
.append("\n결과: {}")
.append("\n=======================================================");
log.info(sb.toString(), responseVO.toString());
}
/**
* ()
*/
@Scheduled(cron = "4 4 4 * * *")
public void deleteStateHis() {
Long totCnt = nvSigntalkHisService.truncateStatHist();
StringBuffer sb = new StringBuffer();
sb.append("\n=======================================================")
.append("\n[ENS] 네이버 고지서(인증톡) 상태변경요청이력 영구 삭제")
.append("\n결과: {} 건 삭제")
.append("\n=======================================================");
log.info(sb.toString(), totCnt);
}
}

@ -0,0 +1,48 @@
package cokr.xit.ens.batch.sched;
import cokr.xit.ens.modules.common.code.StatCd;
import cokr.xit.ens.modules.common.domain.SendMast;
import cokr.xit.ens.modules.common.domain.repository.SendMastRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Component
@Profile("!local & !local-maria & !local-oracle & !local-test")
//@Profile({"prod-traffic", "prod-iup"})
@RequiredArgsConstructor
public class EnsScheduler {
private final SendMastRepository sendMastRepository;
/**
*
* -. "열람(open)" "마감(close)" .
*/
@Scheduled(cron = "0 */5 9-18 * * *")
@Transactional
public void closed() {
log.info("=======================================================");
List<SendMast> sendMastList = sendMastRepository.findAllByStatCdInAndCloseDtBefore(Arrays.asList(StatCd.sendcmplt, StatCd.open), LocalDateTime.now());
log.info("[ENS] 마감처리 - 총 {}건", sendMastList.size());
log.info("SendMastId {}", sendMastList.stream()
.map(row -> {
row.setStatCd(StatCd.close);
return row.getSendMastId();
})
.collect(Collectors.toList())
.toString());
log.info("=======================================================");
}
}

@ -0,0 +1,42 @@
//package cokr.xit.biz.iup._legacy;
//
//
//import four.api.service.DoznService;
//import four.api.service.DoznVO;
//import java.util.Date;
//import javax.annotation.Resource;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//public class ApiController {
// private final Logger logger = LoggerFactory.getLogger(getClass());
//
// @Resource(name = "DoznService")
// private DoznService doznService;
//
// @RequestMapping(value = {"/kakao/notice"}, produces = {"application/json; charset=utf-8;"})
// public String createBill(@RequestBody String data) {
// this.logger.info("/kakao/notice(" + new Date() + ") : " + data);
// DoznVO doznVO = this.doznService.selectNoticeInfo(data);
// return this.doznService.updateApiResponse(doznVO);
// }
//
// @RequestMapping(value = {"/kakao/prepay"}, produces = {"application/json; charset=utf-8;"})
// public String kakaoPrepay(@RequestBody String data) {
// this.logger.info("/kakao/prepay(" + new Date() + ") : " + data);
// DoznVO doznVO = this.doznService.selectPrepayInfo(data);
// return this.doznService.updateApiResponse(doznVO);
// }
//
// @RequestMapping(value = {"/kakao/pay-result"}, produces = {"application/json; charset=utf-8;"})
// public String kakaoPayResult(@RequestBody String data) {
// this.logger.info("/kakao/pay-result(" + new Date() + ") : " + data);
// DoznVO doznVO = this.doznService.insertPayResultInfo(data);
// return this.doznService.updateApiResponse(doznVO);
// }
//}
//

@ -0,0 +1,54 @@
package cokr.xit.ens.biz.iup._legacy;
public class DetailVO
{
public String title;
public String itemType;
public String description;
public String unitName;
public Object elements;
public DetailVO()
{
this.title = null;
this.itemType = null;
this.description = null;
this.unitName = null;
this.elements = null; }
public String getTitle() {
return this.title; }
public void setTitle(String title) {
this.title = title; }
public String getItemType() {
return this.itemType; }
public void setItemType(String item_type) {
this.itemType = item_type; }
public String getDescription() {
return this.description; }
public void setDescription(String description) {
this.description = description; }
public Object getElements() {
return this.elements; }
public void setElements(Object elements) {
this.elements = elements; }
public String getUnitName() {
return this.unitName; }
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String toString()
{
return "DetailVO [title=" + this.title + ", itemType=" + this.itemType ;
}
}

@ -0,0 +1,274 @@
<!--<?xml version="1.0" encoding="UTF-8" ?>-->
<!--<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">-->
<!--<mapper namespace="DoznDAO">-->
<!-- &lt;!&ndash; <resultMap type="DoznVO" id="doznDtlMap">-->
<!-- <id property="billerNoticeKey" column="BILLER_NOTICE_KEY" />-->
<!-- <result property="billerUserKey" column="BILLER_USER_KEY"/>-->
<!-- <result property="billedYearMonth" column="BILLED_YEAR_MONTH"/>-->
<!-- <result property="ordinal" column="ORDINAL"/>-->
<!-- <result property="payBy" column="PAY_BY"/>-->
<!-- <result property="payType" column="PAY_TYPE"/>-->
<!-- <result property="payDetail1" column="PAY_DETAIL1"/>-->
<!-- <result property="payDetail2" column="PAY_DETAIL2"/>-->
<!-- <result property="amount" column="AMOUNT"/>-->
<!-- <result property="payAmount" column="PAY_AMOUNT"/>-->
<!-- <result property="payFeeType" column="PAY_FEE_TYPE"/>-->
<!-- <result property="payFee" column="PAY_FEE"/>-->
<!-- <result property="payFeeTax" column="PAY_FEE_TAX"/>-->
<!-- <result property="adjustDate" column="ADJUST_DATE"/>-->
<!-- <result property="paidAt" column="PAID_AT"/>-->
<!-- <result property="payId" column="PAY_ID"/>-->
<!-- <result property="resCode" column="RES_CODE"/>-->
<!-- <result property="message" column="MESSAGE"/>-->
<!-- <result property="errMsg" column="ERR_MSG"/>-->
<!-- <result property="userBirth" column="USER_BIRTH"/>-->
<!-- <result property="requestData" column="REQUEST_DATA"/>-->
<!-- <result property="responseData" column="RESPONSE_DATA"/>-->
<!-- <result property="orgCd" column="ORG_CD"/>-->
<!-- <result property="parametersJson" column="PARAMETERS" />-->
<!-- <collection property="details" ofType="DetailVO">-->
<!-- <result property="elements" column="CI_SEND_YN"/>-->
<!-- </collection>-->
<!-- </resultMap> &ndash;&gt;-->
<!-- <select id="selectNoticeName" resultType="String" parameterType="DoznVO">-->
<!-- SELECT Q1.JOB_NAME AS TITLE-->
<!-- FROM-->
<!-- FS_JOB Q1,-->
<!-- (-->
<!-- SELECT-->
<!-- A.JOB_CD,-->
<!-- B.DATA_ID-->
<!-- FROM-->
<!-- TB_INPUT A,-->
<!-- TB_INPUT_DATA B-->
<!-- WHERE-->
<!-- A.LNK_INPUT_ID = B.LNK_INPUT_ID-->
<!-- ) Q2-->
<!-- WHERE Q1.JOB_CD = Q2.JOB_CD-->
<!-- AND Q2.DATA_ID = #{billerUserKey}-->
<!-- </select>-->
<!-- <select id="selectNoticeInfo" resultType="DoznVO" parameterType="DoznVO">-->
<!-- SELECT-->
<!-- ENFRC_LEV_MASTR_ID,-->
<!-- USER_BIRTH ,-->
<!-- AMOUNT ,-->
<!-- PAY_EXPIRE_DATE ,-->
<!-- DETAIL_PASNG_CHRGE_SM ,-->
<!-- DETAIL_ADI_PASNG_CHRGE_SM-->
<!-- FROM V_KAKAO_NOTICE_INFO-->
<!-- WHERE 1=1-->
<!-- AND ENFRC_LEV_MASTR_ID = SUBSTR(#{billerUserKey}, 1, 20)-->
<!-- </select>-->
<!-- <select id="selectNoticeInfoSn" resultType="DoznVO" parameterType="DoznVO">-->
<!-- SELECT-->
<!-- USER_BIRTH ,-->
<!-- AMOUNT ,-->
<!-- PAY_EXPIRE_DATE ,-->
<!-- DETAIL_PASNG_CHRGE_SM ,-->
<!-- DETAIL_ADI_PASNG_CHRGE_SM-->
<!-- FROM V_KAKAO_NOTICE_INFO_SN-->
<!-- WHERE 1=1-->
<!-- AND DATA_ID = #{billerUserKey}-->
<!-- </select>-->
<!-- <select id="selectPrepayInfo" resultType="DoznVO" parameterType="DoznVO">-->
<!-- SELECT-->
<!-- ENFRC_LEV_RCIV_ID-->
<!-- FROM TB_ENFRC_LEV_RCIV-->
<!-- WHERE ENFRC_LEV_MASTR_ID = SUBSTR(#{billerUserKey}, 1, 20)-->
<!-- AND DELETE_AT = 'N'-->
<!-- </select>-->
<!-- <insert id="insertPayResultInfo" parameterType="DoznVO">-->
<!-- INSERT INTO TB_KAKAO_PAY_RESULT-->
<!-- (-->
<!-- DATA_ID,-->
<!-- JOB_SE,-->
<!-- PAY_MN,-->
<!-- PAY_TY,-->
<!-- PAY_DETAIL_1,-->
<!-- PAY_DETAIL_2,-->
<!-- PAY_DETAIL_3,-->
<!-- PAY_AMOUNT,-->
<!-- PAY_FEE_TY,-->
<!-- PAY_FEE_AMOUNT,-->
<!-- PAY_FEE_VAT,-->
<!-- EXCCLC_PREARNGE_DE,-->
<!-- PAY_DT,-->
<!-- PAY_ID,-->
<!-- PAY_RESULT_PROCESS_STTUS,-->
<!-- CREAT_DT,-->
<!-- CRTR-->
<!-- )-->
<!-- VALUES-->
<!-- (-->
<!-- #{billerUserKey},-->
<!-- #{jobSe},-->
<!-- #{payBy},-->
<!-- #{payType},-->
<!-- #{payDetail1},-->
<!-- #{payDetail2},-->
<!-- #{payDetail3},-->
<!-- #{payAmount},-->
<!-- #{payFeeType},-->
<!-- #{payFee},-->
<!-- #{payFeeTax},-->
<!-- #{adjustDate},-->
<!-- #{paidAt},-->
<!-- #{payId},-->
<!-- 0,-->
<!-- SYSDATE,-->
<!-- #{crtr}-->
<!-- )-->
<!-- </insert>-->
<!-- <select id="selectApiUrl" resultType="String" parameterType="DoznVO">-->
<!-- SELECT-->
<!-- <choose>-->
<!-- &lt;!&ndash; <when test = '"NOTICE".equals(apiType)'>-->
<!-- CONSIGNMENT_YN-->
<!-- </when> &ndash;&gt;-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- PREPAY_API-->
<!-- </when>-->
<!-- <when test = '"PAY_RESULT".equals(apiType)'>-->
<!-- PAY_RESULT_API-->
<!-- </when>-->
<!-- </choose>-->
<!-- FROM MOBI_ORG_MNG-->
<!-- WHERE ORG_CD = #{orgCd}-->
<!-- </select>-->
<!-- <select id="selectConsignmentYn" resultType="String" parameterType="String">-->
<!-- SELECT CONSIGNMENT_YN FROM MOBI_ORG_MNG WHERE ORG_CD = #{orgCd}-->
<!-- </select>-->
<!-- <select id="selectTbSeq" resultType="Integer" parameterType="DoznVO">-->
<!-- SELECT-->
<!-- <choose>-->
<!-- <when test = '"NOTICE".equals(apiType)'>-->
<!-- TB_PAY_NOTICE_SEQ.NEXTVAL-->
<!-- </when>-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- TB_PAY_PREPAY_SEQ.NEXTVAL-->
<!-- </when>-->
<!-- <when test='"PAY_RESULT".equals(apiType)'>-->
<!-- TB_PAY_RESULT_SEQ.NEXTVAL-->
<!-- </when>-->
<!-- </choose>-->
<!-- AS TB_SEQ From DUAL-->
<!-- </select>-->
<!-- <insert id="insertApiRequest" parameterType="DoznVO">-->
<!-- INSERT INTO-->
<!-- <choose>-->
<!-- <when test = '"NOTICE".equals(apiType)'>-->
<!-- TB_PAY_NOTICE (-->
<!-- PAY_NOTICE_SEQ,-->
<!-- USER_BIRTH,-->
<!-- </when>-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- TB_PAY_PREPAY (-->
<!-- PAY_PREPAY_SEQ,-->
<!-- AMOUNT ,-->
<!-- </when>-->
<!-- <when test='"PAY_RESULT".equals(apiType)'>-->
<!-- TB_PAY_RESULT (-->
<!-- PAY_RESULT_SEQ,-->
<!-- PAY_BY ,-->
<!-- PAY_TYPE ,-->
<!-- PAY_DETAIL1 ,-->
<!-- PAY_DETAIL2 ,-->
<!-- AMOUNT ,-->
<!-- PAY_AMOUNT ,-->
<!-- PAY_FEE ,-->
<!-- PAY_FEE_TAX ,-->
<!-- ADJUST_DATE ,-->
<!-- PAID_AT ,-->
<!-- PAY_ID ,-->
<!-- </when>-->
<!-- </choose>-->
<!-- REQUEST_DATA ,-->
<!-- BILLER_USER_KEY ,-->
<!-- BILLED_YEAR_MONTH ,-->
<!-- ORDINAL ,-->
<!-- BILLER_NOTICE_KEY ,-->
<!-- PARAMETERS ,-->
<!-- ORG_CD ,-->
<!-- REQ_DT-->
<!-- )-->
<!-- VALUES (-->
<!-- #{tbSeq},-->
<!-- <choose>-->
<!-- <when test = '"NOTICE".equals(apiType)'>-->
<!-- #{userBirth},-->
<!-- </when>-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- #{amount},-->
<!-- </when>-->
<!-- <when test='"PAY_RESULT".equals(apiType)'>-->
<!-- #{payBy},-->
<!-- #{payType},-->
<!-- #{payDetail1},-->
<!-- #{payDetail2},-->
<!-- #{amount},-->
<!-- #{payAmount},-->
<!-- #{payFee},-->
<!-- #{payFeeTax},-->
<!-- #{adjustDate},-->
<!-- #{paidAt},-->
<!-- #{payId},-->
<!-- </when>-->
<!-- </choose>-->
<!-- #{requestData},-->
<!-- #{billerUserKey},-->
<!-- #{billedYearMonth},-->
<!-- #{ordinal},-->
<!-- #{billerNoticeKey},-->
<!-- #{parametersJson},-->
<!-- #{orgCd},-->
<!-- SYSDATE-->
<!-- )-->
<!-- </insert>-->
<!-- <update id="updateApiResponse" parameterType="DoznVO">-->
<!-- UPDATE-->
<!-- <choose>-->
<!-- <when test = '"NOTICE".equals(apiType)'>-->
<!-- TB_PAY_NOTICE-->
<!-- </when>-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- TB_PAY_PREPAY-->
<!-- </when>-->
<!-- <when test='"PAY_RESULT".equals(apiType)'>-->
<!-- TB_PAY_RESULT-->
<!-- </when>-->
<!-- </choose>-->
<!-- SET-->
<!-- RES_CODE = #{resCode} ,-->
<!-- MESSAGE = #{message},-->
<!-- RESPONSE_DATA = #{responseData},-->
<!-- RES_DT = SYSDATE,-->
<!-- ERR_MSG = #{errMsg}-->
<!-- WHERE-->
<!-- <choose>-->
<!-- <when test = '"NOTICE".equals(apiType)'>-->
<!-- PAY_NOTICE_SEQ = #{tbSeq}-->
<!-- </when>-->
<!-- <when test = '"PREPAY".equals(apiType)'>-->
<!-- PAY_PREPAY_SEQ = #{tbSeq}-->
<!-- </when>-->
<!-- <when test='"PAY_RESULT".equals(apiType)'>-->
<!-- PAY_RESULT_SEQ = #{tbSeq}-->
<!-- </when>-->
<!-- </choose>-->
<!-- </update>-->
<!--</mapper>-->

@ -0,0 +1,354 @@
//package cokr.xit.biz.iup.service;
//
//import cokr.xit.biz.iup._legacy.DoznVO;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.google.gson.FieldNamingPolicy;
//import com.google.gson.Gson;
//import com.google.gson.GsonBuilder;
//import egovframework.com.cmm.util.StringUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.*;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.net.URLEncoder;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//public class DoznSender
//{
// private final Logger logger = LoggerFactory.getLogger(super.getClass());
//
// public static int CALL_FAIL_REPEAT_COUNT = 1;
//
// public static String PROXY_USE_YN = null;
// public static String PROXY_IP = null;
// public static int PROXY_PORT = 0;
//
// public static int CALL_CONNECTION_TIMEOUT = 8000;
//
// private ObjectMapper objectMapper = null;
//
// private String API_HOST = null;
// private String BILLER_CODE = null;
// private String AUTHORIZATION = null;
//
// public DoznSender() {
// getObjectMapper();
// this.logger.debug("DoznSender init");
// }
//
// public DoznSender(String api_host, String biller_code, String authorization)
// {
// getObjectMapper();
// this.API_HOST = api_host;
// this.BILLER_CODE = biller_code;
// this.AUTHORIZATION = authorization;
//
// this.logger.debug("DoznSender init");
// }
//
// public ObjectMapper getObjectMapper()
// {
// if (this.objectMapper == null) {
// this.objectMapper = new ObjectMapper();
// }
// return this.objectMapper;
// }
//
// public String makeQuerystring(Map<String, Object> params)
// throws IOException
// {
// if (params == null) return null;
// if (params.size() == 0) return null;
// StringBuffer sb = new StringBuffer();
// for (String key : params.keySet()) {
// if (sb.length() > 0) sb.append("&");
// sb.append(key + "=" + encodeString(params.get(key)));
// }
// return sb.toString();
// }
//
// public String encodeString(Object value) throws IOException {
// return URLEncoder.encode(String.valueOf(value), "UTF-8");
// }
//
// private Map<String, Object> parseRespData(String plaindata)
// throws IOException
// {
// return ((Map)getObjectMapper().readValue(plaindata, Map.class));
// }
//
// private void setResponse(Response resp) throws IOException {
// if (resp == null) return;
// if ((resp.status != -1) && (resp.plaindata != null)) {
// Map respMap = parseRespData(resp.plaindata);
// if (respMap.get("res_code") != null) {
// resp.res_code = ((String)respMap.get("res_code"));
// }
// if (respMap.get("message") != null) {
// resp.message = ((String)respMap.get("message"));
// }
// if (respMap.get("data") != null) {
// resp.data = respMap.get("data");
// }
// if (respMap.size() > 0)
// resp.plaindata = null;
// }
// }
//
// private HttpURLConnection getConnection(String address)
// throws IOException
// {
// URL url = new URL(address);
// return ((HttpURLConnection)url.openConnection());
// }
//
// public Response callGenerateUrl(Map<String, Object> params)
// {
// String uri = "/external/inquiry-payment/one-time/url/" + this.BILLER_CODE;
// try
// {
// HashMap someParam = new HashMap();
// someParam.put("some_param", params.get("org_cd"));
//
// HashMap parameters = new HashMap();
// parameters.put("biller_user_key", params.get("data_id"));
// parameters.put("expire_at", params.get("pay_expires_dt"));
// parameters.put("parameters", someParam);
//
// HashMap sendParams = new HashMap();
// sendParams.put("data", parameters);
//
// String querystring = this.objectMapper.writeValueAsString(sendParams);
//
// Response resp = sendData(uri, "POST", "application/json; charset=utf-8", querystring, "N");
// setResponse(resp);
//
// return resp;
// } catch (IOException e) {
// this.logger.error("callGenerateUrl {}", e);
// }
// return null;
// }
//
// public Response callReGenerateUrl(Map<String, Object> params)
// {
// String uri = "/external/inquiry-payment/one-time/url/re/" + this.BILLER_CODE;
// try
// {
// HashMap someParam = new HashMap();
// someParam.put("some_param", params.get("org_cd"));
//
// HashMap parameters = new HashMap();
// parameters.put("biller_user_key", params.get("data_id"));
// parameters.put("expire_at", params.get("pay_expires_dt"));
// parameters.put("parameters", someParam);
//
// HashMap sendParams = new HashMap();
// sendParams.put("data", parameters);
//
// String querystring = this.objectMapper.writeValueAsString(sendParams);
//
// Response resp = sendData(uri, "POST", "application/json; charset=utf-8", querystring, "N");
// setResponse(resp);
//
// return resp;
// } catch (IOException e) {
// this.logger.error("callReGenerateUrl {}", e);
// }
// return null;
// }
//
// public Response sendData(String uri, String method, String contentType, String querystring, String fullUrlYn)
// {
// int respCode;
// HttpURLConnection conn = null;
// OutputStreamWriter out = null;
//
// InputStream is = null;
// BufferedReader br = null;
//
// Response resp = new Response(this);
// try
// {
// String address = "";
//
// if ("N".equals(fullUrlYn)) {
// if ((this.API_HOST == null) || (this.API_HOST.length() < 5)) {
// throw new IOException("API_URL is null!");
// }
// if ((uri == null) || (uri.isEmpty())) {
// throw new IOException("URI is null!");
// }
//
// address = this.API_HOST + uri;
// }
// else {
// if ((uri == null) || (uri.isEmpty())) {
// throw new IOException("URI is null!");
// }
//
// address = uri;
// }
//
// this.logger.debug("DoznSender uri: " + address);
//
// if ((contentType == null) || (contentType.length() == 0)) {
// contentType = "application/json; charset=utf-8";
// }
//
// conn = getConnection(address);
//
// conn.setDefaultUseCaches(false);
// conn.setDoInput(true);
// conn.setDoOutput(true);
// conn.setRequestMethod(method);
// conn.setRequestProperty("Content-Type", contentType);
//
// if (this.AUTHORIZATION != null) {
// conn.setRequestProperty("Authorization", this.AUTHORIZATION);
// }
//
// conn.setConnectTimeout(CALL_CONNECTION_TIMEOUT);
// conn.setReadTimeout(CALL_CONNECTION_TIMEOUT);
// conn.connect();
//
// if ((querystring != null) && (querystring.length() > 0)) {
// this.logger.debug("DoznSender querystring[" + querystring + "]");
// out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
// out.write(querystring);
// out.flush();
// }
//
// respCode = conn.getResponseCode();
// System.out.println("respCode:" + respCode);
//
// if (respCode >= 400)
// {
// is = conn.getErrorStream();
// }
// else is = conn.getInputStream();
//
// br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
//
// String line = null;
// StringBuffer bf = new StringBuffer();
// while ((line = br.readLine()) != null) {
// bf.append(line.trim());
// }
// if (respCode != 200) {
// this.logger.warn("DoznSender HTTP status: " + respCode);
// }
// this.logger.debug("DoznSender RESPONSE: " + bf.toString());
//
// resp.status = respCode;
// resp.plaindata = bf.toString();
// return resp;
// }
// catch (IOException e) {
// this.logger.error("DoznSender sendData {}", e.toString());
// if ((querystring != null) && (querystring.length() > 0) &&
// (!(uri.endsWith("S510")))) {
// this.logger.warn(">>> DoznSender querystring: " + querystring);
// }
//
// resp.status = -1;
// resp.message = e.getLocalizedMessage();
// return resp;
// }
// finally {
// if (conn != null) { conn.disconnect(); conn = null; }
// if (out != null) { try { out.close(); } catch (IOException e) { this.logger.error("sendData finally {}", e); } out = null; }
// if (br != null) { try { br.close(); } catch (IOException e) { this.logger.error("sendData finally {}", e); } br = null; }
// if (is != null) { try { is.close(); } catch (IOException e) { this.logger.error("sendData finally {}", e); } is = null;
// }
// }
// }
//
// public String simpleResponse(DoznVO doznVO)
// {
// Map respData = new HashMap();
// DoznVO resultVO = new DoznVO();
// Response resp = new Response(this);
//
// if ((StringUtil.evl(doznVO.getApiType(), "").equals("NOTICE")) && (doznVO.getResCode().equals("OK")))
// {
// HashMap hashMap = new HashMap();
// hashMap.put("biller_user_key", doznVO.getBillerUserKey());
// hashMap.put("title", doznVO.getTitle());
// hashMap.put("amount", doznVO.getAmount());
//
// hashMap.put("expire_type", doznVO.getExpireType());
// hashMap.put("pay_expire_date", doznVO.getPayExpireDate());
//
// HashMap detail = new HashMap();
// List elements = new ArrayList();
// List details = new ArrayList();
// detail.put("item_type", "TEXT");
//
// elements.add("상세 통행료 : " + doznVO.getDetailPasngChrgeSm());
// elements.add("상세 부가통행료 : " + doznVO.getDetailAdiPasngChrgeSm());
// detail.put("elements", elements);
//
// details.add(detail);
// hashMap.put("details", details);
// respData.put("result", hashMap);
// }
// else {
// respData = null;
// }
//
// this.logger.debug("getResCode:" + doznVO.getResCode());
// this.logger.debug("getMessage:" + doznVO.getMessage());
//
// resp.res_code = doznVO.getResCode();
// resp.message = doznVO.getMessage();
// resp.data = respData;
//
// String result = new Gson().toJson(resp).replace("\"status\":0,", "");
//
// this.logger.debug("return :" + result);
// return result;
// }
//
// public DoznVO getData(String data)
// {
// Gson gson = new GsonBuilder()
// .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
// .create();
//
// String result = data.replace(" ", "").replace("\n", "").replace("\r", "").replace("\"data\":", "");
//
// return ((DoznVO)gson.fromJson(result.substring(1, result.length() - 1), DoznVO.class));
// }
//
// public DoznVO callBillsInfoUrl(String request, String uri) throws Exception
// {
// try {
// Response resp = sendData(uri, "POST", "application/json; charset=utf-8", request, "Y");
// setResponse(resp);
//
// DoznVO result = new DoznVO();
//
// this.logger.debug("res_code:" + resp.res_code);
// this.logger.debug("message:" + resp.message);
//
// result.setResCode(resp.res_code);
// result.setMessage(resp.message);
//
// if ((!(result.getResCode().equals("OK"))) || (!(result.getMessage().equals("성공")))) {
// result.setErrMsg(result.getMessage());
// }
//
// return result;
// } catch (IOException e) {
// this.logger.error("callBillsInfoUrl {}", e);
// }
//
// return null;
// }
//}

@ -0,0 +1,300 @@
//package cokr.xit.biz.iup._legacy;
//
//public class DoznServiceImpl {
//
//
// public DoznVO selectNoticeInfo(String request)
// {
// DoznVO data = this.doznSender.getData(request);
//
// String orgCd = null;
//
// if (data.getParameters() != null) {
// orgCd = (String)data.getParameters().get("some_param");
// }
//
// DoznVO noticeVO = new DoznVO();
// String errMsg = null;
//
// String title = this.doznDAO.selectNoticeName(data);
//
// data.setApiType("NOTICE");
// data.setTbSeq(Integer.valueOf(this.doznDAO.c(data)));
// data.setRequestData(request);
// data.setOrgCd(orgCd);
// data.setParametersJson();
// try
// {
// this.doznDAO.insertApiRequest(data);
// } catch (Exception e) {
// log.error("insertPayResultInfo : " + e.getMessage());
// }
//
// if ((orgCd == null) || (orgCd.equals(""))) {
// noticeVO = new DoznVO();
// noticeVO.setBillerUserKey(data.getBillerUserKey());
// noticeVO.setApiType("NOTICE");
// noticeVO.setResCode("E402");
// noticeVO.setMessage("청구서 조회 결과가 없습니다.");
// noticeVO.setErrMsg("요청받은 값에 기관코드가 없습니다.");
// noticeVO.setTbSeq(data.getTbSeq());
//
// return noticeVO;
// }
//
// String consignmentYn = this.doznDAO.selectConsignmentYn(orgCd);
// try
// {
// if ((consignmentYn == null) || (consignmentYn.equals("")))
// throw new Exception("청구서 조회 DB 구분값 미등록");
// if (consignmentYn.equals("N"))
// noticeVO = this.doznDAO.selectNoticeInfo(data);
// else if (consignmentYn.equals("Y")) {
// noticeVO = this.doznDAO.selectNoticeInfoSn(data);
// }
//
// if (noticeVO == null)
// throw new Exception("청구서 조회 결과가 없습니다.");
// }
// catch (Exception e)
// {
// log.error("selectNoticeInfo : " + e.getMessage());
// noticeVO = new DoznVO();
// noticeVO.setBillerUserKey(data.getBillerUserKey());
// noticeVO.setApiType("NOTICE");
// noticeVO.setResCode("E402");
// noticeVO.setMessage("청구서 조회 결과가 없습니다.");
// noticeVO.setErrMsg("청구서 조회 결과가 없습니다.");
// noticeVO.setTbSeq(data.getTbSeq());
// return noticeVO;
// }
//
// if (noticeVO != null)
// {
// noticeVO.setBillerUserKey(data.getBillerUserKey());
// noticeVO.setApiType("NOTICE");
// noticeVO.setResCode("OK");
// noticeVO.setMessage("성공");
// noticeVO.setTbSeq(data.getTbSeq());
// noticeVO.setExpireType("D1");
// }
//
// if ((title == null) || (title.equals("")))
// {
// noticeVO = new DoznVO();
// noticeVO.setBillerUserKey(data.getBillerUserKey());
// noticeVO.setApiType("NOTICE");
// noticeVO.setResCode("E402");
// noticeVO.setMessage("청구서 조회 결과가 없습니다.");
// noticeVO.setErrMsg("청구서 조회 결과가 없습니다.");
// noticeVO.setTbSeq(data.getTbSeq());
// return noticeVO;
// }
// noticeVO.setTitle(title);
//
// if ((noticeVO.getUserBirth() == null) || (noticeVO.getUserBirth().equals("")) || (!(noticeVO.getUserBirth().equals(data.getUserBirth())))) {
// noticeVO = new DoznVO();
// noticeVO.setBillerUserKey(data.getBillerUserKey());
// noticeVO.setApiType("NOTICE");
// noticeVO.setResCode("E404");
// noticeVO.setMessage("생년월일이 일치하지 않습니다.");
// noticeVO.setErrMsg("생년월일이 일치하지 않습니다.");
// noticeVO.setTbSeq(data.getTbSeq());
// return noticeVO;
// }
//
// return noticeVO;
// }
//
// public DoznVO selectPrepayInfo(String request) {
// DoznVO data = this.doznSender.getData(request);
// String orgCd = null;
// DoznVO noticeInfo = null;
// DoznVO prepayVO = null;
// if (data.getParameters() != null)
// orgCd = (String)data.getParameters().get("some_param");
// data.setApiType("PREPAY");
// data.setTbSeq(Integer.valueOf(this.doznDAO.selectTbSeq(data)));
// data.setRequestData(request);
// data.setOrgCd(orgCd);
// data.setParametersJson();
// try {
// this.doznDAO.insertApiRequest(data);
// } catch (Exception e) {
// this.logger.error("selectPrepayInfo : " + e.getMessage());
// }
// if (orgCd == null || orgCd.equals("")) {
// prepayVO = new DoznVO();
// prepayVO.setBillerUserKey(data.getBillerUserKey());
// prepayVO.setApiType("PREPAY");
// prepayVO.setResCode("E601");
// prepayVO.setMessage("수납처리실패 - 납부요청 정보 조회 실패");
// prepayVO.setErrMsg("요청받은 값에 기관코드가 없습니다.");
// prepayVO.setTbSeq(data.getTbSeq());
// return prepayVO;
// }
// Date now = new Date();
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
// try {
// String consignmentYn = this.doznDAO.selectConsignmentYn(orgCd);
// if (consignmentYn == null || consignmentYn.equals(""))
// throw new Exception("청구서 조회 DB 구분값 미등록");
// if (consignmentYn.equals("N")) {
// noticeInfo = this.doznDAO.selectNoticeInfo(data);
// } else if (consignmentYn.equals("Y")) {
// noticeInfo = this.doznDAO.selectNoticeInfoSn(data);
// }
// if (noticeInfo != null) {
// if (consignmentYn.equals("N")) {
// prepayVO = this.doznDAO.selectPrepayInfo(data);
// } else if (consignmentYn.equals("Y")) {
//
// prepayVO = this.doznSender.callBillsInfoUrl(request, this.doznDAO.selectApiUrl(data));
// prepayVO.setApiType("PREPAY");
// prepayVO.setTbSeq(data.getTbSeq());
// return prepayVO;
// }
// } else {
// prepayVO = new DoznVO();
// prepayVO.setBillerUserKey(data.getBillerUserKey());
// prepayVO.setApiType("PREPAY");
// prepayVO.setResCode("E502");
// prepayVO.setMessage("납부불가 - 납부 대상 없음");
// prepayVO.setErrMsg("납부대상이 존재하지 않습니다.");
// prepayVO.setTbSeq(data.getTbSeq());
// this.logger.error("selectPrepayInfo : " + prepayVO.getMessage());
// return prepayVO;
// }
//
//
// if (prepayVO != null)
// throw new Exception("수납처리실패 - 납부요청 정보 조회 실패");
// } catch (Exception e) {
// this.logger.error("selectPrepayInfo : " + e.getMessage());
// prepayVO = new DoznVO();
// prepayVO.setBillerUserKey(data.getBillerUserKey());
// prepayVO.setApiType("PREPAY");
// prepayVO.setResCode("E601");
// prepayVO.setMessage("수납처리실패 - 납부요청 정보 조회 실패");
// prepayVO.setErrMsg("수납처리실패 - 납부요청 정보 조회 실패");
// prepayVO.setTbSeq(data.getTbSeq());
// return prepayVO;
// }
//
//
// if (prepayVO == null) {
// prepayVO = new DoznVO();
// prepayVO.setBillerUserKey(data.getBillerUserKey());
// prepayVO.setApiType("PREPAY");
// prepayVO.setResCode("OK");
// prepayVO.setMessage("성공");
// prepayVO.setTbSeq(data.getTbSeq());
// }
// if (noticeInfo.getPayExpireDate() != null &&
// Integer.parseInt(noticeInfo.getPayExpireDate()) < Integer.parseInt(format.format(now).replace("-", ""))) {
// this.logger.error("selectPrepayInfo - noticeInfo.getPayExpireDate() : " + noticeInfo.getPayExpireDate());
// prepayVO = new DoznVO();
// prepayVO.setBillerUserKey(data.getBillerUserKey());
// prepayVO.setApiType("PREPAY");
// prepayVO.setResCode("E506");
// prepayVO.setMessage("납부기한이 경과했습니다.");
// prepayVO.setErrMsg("납부기한이 경과하여 납부가 불가능합니다. 이용기관에 문의하세요");
// prepayVO.setTbSeq(data.getTbSeq());
// return prepayVO;
// }
// if (noticeInfo.getAmount() == null || noticeInfo.getAmount().intValue() == 0 || !noticeInfo.getAmount().equals(data.getAmount())) {
// prepayVO.setResCode("E403");
// prepayVO.setMessage("납부 가능 금액이 없습니다.");
// prepayVO.setErrMsg("고객정보 및 금액이 일치하지 않아 납부가 불가합니다");
// prepayVO.setTbSeq(data.getTbSeq());
// return prepayVO;
// }
// return prepayVO;
// }
//
//
// public DoznVO insertPayResultInfo(String request)
// {
// DoznVO resultVO = new DoznVO();
//
// String orgCd = null;
// DoznVO data = null;
// try
// {
// data = this.doznSender.getData(request);
// if (data.getParameters() != null)
// orgCd = (String)data.getParameters().get("some_param");
// }
// catch (Exception consignmentYn)
// {
// log.error("FAILED TO PARSE DoznVO : " + request);
// log.error("insertPayResultInfo : " + consignmentYn.getMessage());
// }
// finally {
// data.setApiType("PAY_RESULT");
// data.setTbSeq(Integer.valueOf(this.doznDAO.selectTbSeq(data)));
// data.setRequestData(request);
// data.setOrgCd(orgCd);
// data.setParametersJson();
// try
// {
// this.doznDAO.insertApiRequest(data);
// } catch (Exception e) {
// log.error("insertPayResultInfo : " + e.getMessage());
// }
//
// resultVO.setBillerUserKey(data.getBillerUserKey());
// resultVO.setApiType("PAY_RESULT");
// resultVO.setResCode("OK");
// resultVO.setMessage("성공");
// resultVO.setTbSeq(data.getTbSeq());
//
// if (data.getBillerUserKey().substring(0, 2).equals("EL")) {
// data.setJobSe("2");
// }
// else {
// data.setJobSe("1");
// }
//
// this.doznDAO.insertPayResultInfo(data);
//
// String consignmentYn = this.doznDAO.selectConsignmentYn(orgCd);
// if (consignmentYn.equals("Y"))
// {
// try {
// resultVO = this.doznSender.callBillsInfoUrl(request, this.doznDAO.selectApiUrl(data));
// resultVO.setApiType("PAY_RESULT");
// resultVO.setTbSeq(data.getTbSeq());
// } catch (Exception e) {
// log.error("insertPayResultInfo : " + e.getMessage());
// resultVO.setResCode("SYSERR");
// resultVO.setMessage(orgCd + "(orgCd) 기관과의 통신 오류");
// resultVO.setApiType("PAY_RESULT");
// resultVO.setTbSeq(data.getTbSeq());
// }
//
// return resultVO; }
// if ((consignmentYn == null) || (consignmentYn.equals(""))) {
// resultVO.setResCode("SYSERR");
// resultVO.setMessage("위탁업체여부 구분값 미등록");
// resultVO.setApiType("PAY_RESULT");
// resultVO.setTbSeq(data.getTbSeq());
// }
// }
//
// return resultVO;
// }
//
// public String updateApiResponse(DoznVO doznVO)
// {
// doznVO.setResponseData(this.doznSender.simpleResponse(doznVO));
// try
// {
// this.doznDAO.updateApiResponse(doznVO);
// } catch (Exception e) {
// log.error("insertPayResultInfo : " + e.getMessage());
// }
//
// return doznVO.getResponseData();
// }
//}

@ -0,0 +1,450 @@
package cokr.xit.ens.biz.iup._legacy;
import java.util.List;
import java.util.Map;
public class DoznVO
{
private String billerUserKey;
private String billedYearMonth;
private String ordinal;
private String billerNoticeKey;
private Map<String, Object> parameters;
private String userBirth;
private Integer tbSeq;
private String settlementCode;
private String title;
private Integer amount;
private Integer taxFreeAmount;
private Integer vatAmount;
private String expireType;
private String payExpireDate;
private String secondPayExpireDate;
private String bankCode;
private String accountNo;
private String holderName;
private String senderName;
private String accountType;
private List<DetailVO> details;
private String enfrcLevMasterId;
private String enfrcLevRcivId;
private String jobSe;
private Integer detailPasngChrgeSm;
private Integer detailAdiPasngChrgeSm;
private String payBy;
private String payType;
private String payDetail1;
private String payDetail2;
private String payDetail3;
private Integer payAmount;
private String payFeeType;
private String payFee;
private String payFeeTax;
private String adjustDate;
private String paidAt;
private String payId;
private String requestData;
private String responseData;
private String resCode;
private String message;
private String errMsg;
private String orgCd;
private String parametersJson;
private String apiType;
private String crtr;
public DoznVO()
{
this.taxFreeAmount = null;
this.vatAmount = null;
this.crtr = "SYSTEM"; }
public String getParametersJson() {
return this.parametersJson;
}
public void setParametersJson() {
this.parametersJson = "{\"some_param\" : \"" + this.orgCd + "\"}";
}
public List<DetailVO> getDetails() {
return this.details;
}
public void setDetails(List<DetailVO> details) {
this.details = details;
}
public String getPayId() {
return this.payId;
}
public void setPayId(String payId) {
this.payId = payId;
}
public Integer getTbSeq() {
return this.tbSeq;
}
public void setTbSeq(Integer tbSeq) {
this.tbSeq = tbSeq;
}
public String getUserBirth() {
return this.userBirth;
}
public void setUserBirth(String userBirth) {
this.userBirth = userBirth;
}
public String getSettlementCode() {
return this.settlementCode;
}
public void setSettlementCode(String settlementCode) {
this.settlementCode = settlementCode;
}
public String getBillerUserKey() {
return this.billerUserKey;
}
public void setBillerUserKey(String billerUserKey) {
this.billerUserKey = billerUserKey;
}
public String getBilledYearMonth() {
return this.billedYearMonth;
}
public void setBilledYearMonth(String billedYearMonth) {
this.billedYearMonth = billedYearMonth;
}
public String getOrdinal() {
return this.ordinal;
}
public void setOrdinal(String ordinal) {
this.ordinal = ordinal;
}
public String getBillerNoticeKey() {
return this.billerNoticeKey;
}
public void setBillerNoticeKey(String billerNoticeKey) {
this.billerNoticeKey = billerNoticeKey;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getAmount() {
return this.amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public Integer getTaxFreeAmount() {
return this.taxFreeAmount;
}
public void setTaxFreeAmount(Integer taxFreeAmount) {
this.taxFreeAmount = taxFreeAmount;
}
public Integer getVatAmount() {
return this.vatAmount;
}
public void setVatAmount(Integer vatAmount) {
this.vatAmount = vatAmount;
}
public String getExpireType() {
return this.expireType;
}
public void setExpireType(String expireType) {
this.expireType = expireType;
}
public String getPayExpireDate() {
return this.payExpireDate;
}
public void setPayExpireDate(String payExpireDate) {
this.payExpireDate = payExpireDate;
}
public String getSecondPayExpireDate() {
return this.secondPayExpireDate;
}
public void setSecondPayExpireDate(String secondPayExpireDate) {
this.secondPayExpireDate = secondPayExpireDate;
}
public Map<String, Object> getParameters() {
return this.parameters;
}
public void setParameters(Map<String, Object> parameters) {
this.parameters = parameters;
}
public String getApiType() {
return this.apiType;
}
public void setApiType(String apiType) {
this.apiType = apiType;
}
public String getBankCode() {
return this.bankCode;
}
public void setBankCode(String bankCode) {
this.bankCode = bankCode;
}
public String getAccountNo() {
return this.accountNo;
}
public void setAccountNo(String accountNo) {
this.accountNo = accountNo;
}
public String getHolderName() {
return this.holderName;
}
public void setHolderName(String holderName) {
this.holderName = holderName;
}
public String getSenderName() {
return this.senderName;
}
public void setSenderName(String senderName) {
this.senderName = senderName;
}
public String getAccountType() {
return this.accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public String getEnfrcLevMasterId() {
return this.enfrcLevMasterId;
}
public void setEnfrcLevMasterId(String enfrcLevMasterId) {
this.enfrcLevMasterId = enfrcLevMasterId;
}
public String getJobSe() {
return this.jobSe;
}
public void setJobSe(String jobSe) {
this.jobSe = jobSe;
}
public Integer getDetailPasngChrgeSm() {
return this.detailPasngChrgeSm;
}
public void setDetailPasngChrgeSm(Integer detailPasngChrgeSm) {
this.detailPasngChrgeSm = detailPasngChrgeSm;
}
public Integer getDetailAdiPasngChrgeSm() {
return this.detailAdiPasngChrgeSm;
}
public void setDetailAdiPasngChrgeSm(Integer detailAdiPasngChrgeSm) {
this.detailAdiPasngChrgeSm = detailAdiPasngChrgeSm;
}
public String getPayBy() {
return this.payBy;
}
public void setPayBy(String payBy) {
this.payBy = payBy;
}
public String getPayType() {
return this.payType;
}
public void setPayType(String payType) {
this.payType = payType;
}
public String getPayDetail1() {
return this.payDetail1;
}
public void setPayDetail1(String payDetail1) {
this.payDetail1 = payDetail1;
}
public String getPayDetail2() {
return this.payDetail2;
}
public void setPayDetail2(String payDetail2) {
this.payDetail2 = payDetail2;
}
public String getPayDetail3() {
return this.payDetail3;
}
public void setPayDetail3(String payDetail3) {
this.payDetail3 = payDetail3;
}
public Integer getPayAmount() {
return this.payAmount;
}
public void setPayAmount(Integer payAmount) {
this.payAmount = payAmount;
}
public String getPayFeeType() {
return this.payFeeType;
}
public void setPayFeeType(String payFeeType) {
this.payFeeType = payFeeType;
}
public String getPayFee() {
return this.payFee;
}
public void setPayFee(String payFee) {
this.payFee = payFee;
}
public String getPayFeeTax() {
return this.payFeeTax;
}
public void setPayFeeTax(String payFeeTax) {
this.payFeeTax = payFeeTax;
}
public String getAdjustDate() {
return this.adjustDate;
}
public void setAdjustDate(String adjustDate) {
this.adjustDate = adjustDate;
}
public String getPaidAt() {
return this.paidAt;
}
public void setPaidAt(String paidAt) {
this.paidAt = paidAt;
}
public String getPaidId() {
return this.payId;
}
public void setPaidId(String paidId) {
this.payId = paidId;
}
public String getRequestData() {
return this.requestData;
}
public void setRequestData(String requestData) {
this.requestData = requestData;
}
public String getResponseData() {
return this.responseData;
}
public void setResponseData(String responseData) {
this.responseData = responseData;
}
public String getResCode() {
return this.resCode;
}
public void setResCode(String resCode) {
this.resCode = resCode;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public String getErrMsg() {
return this.errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getOrgCd() {
return this.orgCd;
}
public void setOrgCd(String orgCd) {
this.orgCd = orgCd;
}
public String getEnfrcLevRcivId() {
return this.enfrcLevRcivId;
}
public void setEnfrcLevRcivId(String enfrcLevRcivId) {
this.enfrcLevRcivId = enfrcLevRcivId;
}
public String getCrtr() {
return this.crtr;
}
public void setCrtr(String crtr) {
this.crtr = crtr;
}
}

@ -0,0 +1,190 @@
package cokr.xit.ens.biz.iup.billpay.api;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.code.BillKkoErrCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@Slf4j
@Component
@Profile({"!local-test"})
public class IupKkoPayUseSysApi implements IupKkoPayUseSysApiSpec {
/**
* API
*
* @param uri
* @param mParam
* @return
*/
@Override
public BillKkoApiRespDTO callApiByOrg(String uri, Map<String, Object> mParam) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(new MediaType(MediaType.APPLICATION_JSON, Charset.forName("utf-8")));
StringBuilder url = new StringBuilder();
url.append(uri);
String jsonStr = CmmnUtil.toJsonString(mParam);
ResponseEntity<String> resp = this.callApi(HttpMethod.POST, url.toString(), jsonStr, headers);
return setResponse(resp, url.toString());
}
/**
* API IupBillPayRespVO
*
* @param resp
* @return
*/
private BillKkoApiRespDTO setResponse(ResponseEntity<String> resp, String url) {
if (log.isDebugEnabled()) {
StringBuffer sb = new StringBuffer();
sb.append("\n================================================")
.append("\nKkoBillClientApi.setResponse...")
.append("\n" + resp.getBody())
.append("\n================================================");
log.debug(sb.toString());
}
BillKkoApiRespDTO respVO = null;
try {
if (HttpStatus.OK.equals(resp.getStatusCode())) {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> mResp = mapper.readValue(resp.getBody(), Map.class);
if ("OK".equals(mResp.get("res_code")) || "성공".equals(mResp.get("res_code")))
respVO = BillKkoApiRespDTO.okBuilder()
.data(null)
.build();
else
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(String.valueOf(mResp.get("res_code")))
.message(String.valueOf(mResp.get("message")))
.build();
} else {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.ERR601.getCode())
.message(String.format("기관과 통신 실패. [URL]:::%s. [ERROR]:::%s %s.", url, resp.getStatusCode().toString(), resp.getBody()))
.build();
}
} catch (IOException e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.ERR505.getCode())
.message(e.getMessage())
.build();
} catch (Exception e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.ERR999.getCode())
.message(e.getMessage())
.build();
}
return respVO;
}
/**
* <pre> : API
* </pre>
*
* @param method
* @param url
* @param body
* @param headers
* @return ResponseEntity
* @author:
* @date: 2021. 8. 4.
* @apiNote: https://e2e2e2.tistory.com/15
*/
private ResponseEntity<String> callApi(HttpMethod method, String url, String body, HttpHeaders headers) {
StringBuffer sb = new StringBuffer();
ResponseEntity<String> responseEntity = null;
try {
HttpEntity<?> entity = null;
UriComponents uri = null;
switch (method) {
case GET:
entity = new HttpEntity<>(headers);
uri = UriComponentsBuilder
.fromHttpUrl(String.format("%s?%s", url, body == null ? "" : body))
// .encode(StandardCharsets.UTF_8) //"%"기호가 "%25"로 인코딩 발생하여 주석처리 함.
.build(false);
break;
case POST:
entity = new HttpEntity<>(body, headers);
uri = UriComponentsBuilder
.fromHttpUrl(url)
.encode(StandardCharsets.UTF_8)
.build();
break;
default:
break;
}
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setConnectTimeout(5000);
// factory.setReadTimeout(3000);
// factory.setReadTimeout(10000);
factory.setReadTimeout(15000);
RestTemplate restTemplate = new RestTemplate(factory);
sb.append("\n url => " + uri.toString())
.append("\n method => " + method)
.append("\n headers => " + entity.getHeaders().toString())
.append("\n body => " + entity.getBody());
responseEntity = restTemplate.exchange(URI.create(uri.toString()), method, entity, String.class);
/*
* HttpStatus
* -.: responseEntity.getStatusCodeValue()
* -.: responseEntity.getStatusCode()
*/
} catch (HttpServerErrorException e) {
responseEntity = new ResponseEntity<String>(e.getResponseBodyAsString(), e.getStatusCode());
log.error("call API 서버오류\n[ url ]: {} \n[ param ]: {} \n[ error ]: {}", url, body, CmmnUtil.printStackTraceToString(e));
} catch (HttpClientErrorException e) {
responseEntity = new ResponseEntity<String>(e.getResponseBodyAsString(), e.getStatusCode());
log.error("call API 클라이언트오류\n[ url ]: {} \n[ param ]: {} \n[ error ]: {}", url, body, CmmnUtil.printStackTraceToString(e));
} catch (RestClientException e) {
responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.REQUEST_TIMEOUT);
log.error("RestAPI 호출 오류\n[ url ]: {} \n[ param ]: {} \n[ error ]: {}", url, body, CmmnUtil.printStackTraceToString(e));
} catch (Exception e) {
responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
log.error("call API 기타오류\n[ url ]: {} \n[ param ]: {} \n[ error ]: {}", url, body, CmmnUtil.printStackTraceToString(e));
} finally {
log.info("카카오페이 청구서 Client API\n[ REQUEST ]-----------------------------------------------------------------------\n{}\n[ RESPONSE ]-----------------------------------------------------------------------\n{}", sb.toString(), responseEntity.getBody());
}
return responseEntity;
}
}

@ -0,0 +1,17 @@
package cokr.xit.ens.biz.iup.billpay.api;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
import java.util.Map;
public interface IupKkoPayUseSysApiSpec {
/**
* API
*
* @param uri
* @param mParam
* @return
*/
BillKkoApiRespDTO callApiByOrg(String uri, Map<String, Object> mParam);
}

@ -0,0 +1,104 @@
package cokr.xit.ens.biz.iup.billpay.api;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@Slf4j
@Component
@Profile({"local-test"})
public class IupKkoPayUseSysApiTest implements IupKkoPayUseSysApiSpec {
/**
* API
*
* @param uri
* @param mParam
* @return
*/
@Override
public BillKkoApiRespDTO callApiByOrg(String uri, Map<String, Object> mParam) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(new MediaType(MediaType.APPLICATION_JSON, Charset.forName("utf-8")));
StringBuilder url = new StringBuilder();
url.append(uri);
String jsonStr = CmmnUtil.toJsonString(mParam);
ResponseEntity<String> resp = this.callApi(HttpMethod.POST, url.toString(), jsonStr, headers);
return BillKkoApiRespDTO.okBuilder()
.data(null)
.build();
}
/**
* <pre> : API
* </pre>
*
* @param method
* @param url
* @param body
* @param headers
* @return ResponseEntity
* @author:
* @date: 2021. 8. 4.
* @apiNote: https://e2e2e2.tistory.com/15
*/
private ResponseEntity<String> callApi(HttpMethod method, String url, String body, HttpHeaders headers) {
StringBuffer sb = new StringBuffer();
ResponseEntity<String> responseEntity = ResponseEntity.ok("test");
try {
HttpEntity<?> entity = null;
UriComponents uri = null;
switch (method) {
case GET:
entity = new HttpEntity<>(headers);
uri = UriComponentsBuilder
.fromHttpUrl(String.format("%s?%s", url, body == null ? "" : body))
.build(false);
break;
case POST:
entity = new HttpEntity<>(body, headers);
uri = UriComponentsBuilder
.fromHttpUrl(url)
.encode(StandardCharsets.UTF_8)
.build();
break;
default:
break;
}
sb.append("\n url => " + uri.toString())
.append("\n method => " + method)
.append("\n headers => " + entity.getHeaders().toString())
.append("\n body => " + entity.getBody());
} catch (Exception e) {
log.error("call API 기타오류\n[ url ]: {} \n[ param ]: {} \n[ error ]: {}", url, body, CmmnUtil.printStackTraceToString(e));
} finally {
log.info("카카오페이 청구서 Client API\n[ REQUEST ]-----------------------------------------------------------------------\n{}\n[ RESPONSE ]-----------------------------------------------------------------------\n{}", sb.toString(), responseEntity.getBody());
}
return responseEntity;
}
}

@ -0,0 +1,276 @@
package cokr.xit.ens.biz.iup.billpay.presentation;
import cokr.xit.ens.biz.iup.billpay.service.IupBillKkoPayUseSysService;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.biz.iup.domain.repository.TbInputDataXitRepository;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Tag(name = "IupBillKkoPayUseSysController")
@Slf4j
@RequiredArgsConstructor
@RestController
public class IupBillKkoPayUseSysController {
private final TbInputDataXitRepository tbInputDataXitRepository;
private final Map<String, IupBillKkoPayUseSysService> iupBillKkoPayUseSysServiceMap;
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Sample Example..."
, summary = "sample"
, value = "{\n" +
"\"data\": {\n" +
"\"biller_user_key\": \"0000000001\",\n" +
"\"user_birth\":\"19900301\",\n" +
"\"parameters\": {\n" +
"\"some_param\": \"KT00000001\"\n" +
"}\n" +
"}\n" +
"}"
)
})
})
@ApiResponses({
@ApiResponse(responseCode = "200", content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Success Example..."
, summary = "Success"
, value = "{\n" +
" \"res_code\": \"OK\",\n" +
" \"message\": \"성공\",\n" +
" \"data\": {\n" +
" \"result\": {\n" +
" \"biller_user_key\": \"0000000001\",\n" +
" \"title\": \"통신요금\",\n" +
" \"amount\": 29000,\n" +
" \"tax_free_amount\": 0,\n" +
" \"vat_amount\": 0,\n" +
" \"pay_expire_date\": \"20190801\",\n" +
" \"details\": [\n" +
" {\n" +
" \"title\": \"고객정보\",\n" +
" \"itemType\": \"KEY_VALUE\",\n" +
" \"elements\": [\n" +
" {\n" +
" \"key\": \"이름\",\n" +
" \"value\": \"홍길동\",\n" +
" \"level\": \"1\"\n" +
" },\n" +
" {\n" +
" \"key\": \"고객번호\",\n" +
" \"value\": \"945034260\",\n" +
" \"level\": \"1\"\n" +
" }\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"title\": \"상세내용\",\n" +
" \"itemType\": \"KEY_VALUE\",\n" +
" \"elements\": [\n" +
" {\n" +
" \"key\": \"상품명(서비스번호)\",\n" +
" \"value\": \"모바일(010-61**-*234)\",\n" +
" \"level\": \"1\"\n" +
" },\n" +
" {\n" +
" \"key\": \"당월요금계\",\n" +
" \"value\": \"42,610원\",\n" +
" \"level\": \"1\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
" }\n" +
"}"
),
@ExampleObject(name = "Fail Example..."
, summary = "Fail"
, value = "{\n" +
"\"res_code\": \"E402\",\n" +
"\"message\": \"청구서 조회 결과가 없습니다.\",\n" +
"\"data\": null\n" +
"}"
)
})
})
})
@Operation(summary = "청구서 조회")
@PostMapping(value = "/iup/kakao/notice", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillKkoApiRespDTO> kakaoNotice(@RequestBody Map<String, Object> mParam) {
try {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
String billerUserKey = (String) data.get("biller_user_key");
TbInputDataXit tbInputDataXit = tbInputDataXitRepository.findById(billerUserKey).orElseThrow(() -> new RuntimeException("biller_user_key와 일치하는 데이터를 찾을 수 없습니다."));
IupBillKkoPayUseSysService iupPayProcessService = iupBillKkoPayUseSysServiceMap.get("iupBillKkoPayUseSysService_" + tbInputDataXit.getTbInputXit().getSendType());
return new ResponseEntity<BillKkoApiRespDTO>(iupPayProcessService.findNoticeInfo(mParam), HttpStatus.OK);
} finally {
StringBuffer sb = new StringBuffer();
sb.append("\n==============================================================================")
.append("\n[ kakao 청구서 - 청구서조회 ]")
.append("\n### Request Info...")
.append("\n" + CmmnUtil.toJsonString(mParam))
// .append("\n### Response Info...")
// .append("\n" + resp.getBody())
.append("\n==============================================================================");
log.info(sb.toString());
}
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Sample Example..."
, summary = "sample"
, value = "{\n" +
"\"data\": {\n" +
"\"biller_user_key\": \"0000000001\",\n" +
"\"amount\": 29000,\n" +
"\"parameters\": {\n" +
"\"pay_rqt_seq\": \"KT00000001\"\n" +
"}\n" +
"}\n" +
"}")
})
})
@ApiResponses({
@ApiResponse(responseCode = "200", content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Success Example..."
, summary = "Success"
, value = "{\n" +
"\"res_code\": \"OK\",\n" +
"\"message\": \"성공\",\n" +
"\"data\": null\n" +
"}"
),
@ExampleObject(name = "Fail Example..."
, summary = "Fail"
, value = "{\n" +
"\"res_code\": \"E502\",\n" +
"\"message\": \"납부불가 - 납부 대상 없음\",\n" +
"\"data\": null\n" +
"}"
)
})
})
})
@Operation(summary = "납부 가능 조회")
@PostMapping(value = "/iup/kakao/prepay", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillKkoApiRespDTO> kakaoPrepay(@RequestBody Map<String, Object> mParam) {
try {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
String billerUserKey = (String) data.get("biller_user_key");
TbInputDataXit tbInputDataXit = tbInputDataXitRepository.findById(billerUserKey).orElseThrow(() -> new RuntimeException("biller_user_key와 일치하는 데이터를 찾을 수 없습니다."));
IupBillKkoPayUseSysService iupBillPayService = iupBillKkoPayUseSysServiceMap.get("iupBillKkoPayUseSysService_" + tbInputDataXit.getTbInputXit().getSendType());
return new ResponseEntity<BillKkoApiRespDTO>(iupBillPayService.findPrepayInfo(mParam), HttpStatus.OK);
} finally {
StringBuffer sb = new StringBuffer();
sb.append("\n==============================================================================")
.append("\n[ kakao 청구서 - 납부가능조회 ]")
.append("\n### Request Info...")
.append("\n" + CmmnUtil.toJsonString(mParam))
// .append("\n### Response Info...")
// .append("\n" + resp.getBody())
.append("\n==============================================================================");
log.info(sb.toString());
}
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Sample Example..."
, summary = "sample"
, value = "{\n" +
"\"data\": {\n" +
"\"biller_user_key\": \"0000000001\",\n" +
"\"parameters\": {\n" +
"\"pay_rqt_seq\": \"KT00000001\"\n" +
"},\n" +
"\"pay_by\": \"MONEY\",\n" +
"\"pay_type\": \"P\",\n" +
"\"pay_detail1\": \"\",\n" +
"\"pay_detail2\": \"\",\n" +
"\"amount\": 20000,\n" +
"\"pay_amount\": 20000,\n" +
"\"pay_fee_type\": \"BEFORE\",\n" +
"\"pay_fee\": 150,\n" +
"\"pay_fee_tax\": 15,\n" +
"\"paid_at\": \"20190220161656\",\n" +
"\"pay_id\": 2748877\n" +
"}\n" +
"}")
})
})
@ApiResponses({
@ApiResponse(responseCode = "200", content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "Success Example..."
, summary = "Success"
, value = "{\n" +
"\"res_code\": \"OK\",\n" +
"\"message\": \"성공\",\n" +
"\"data\": null\n" +
"}"
)
})
})
})
@Operation(summary = "납부 결과 전달")
@PostMapping(value = "/iup/kakao/pay-result", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillKkoApiRespDTO> kakaoPayResult(@RequestBody Map<String, Object> mParam) {
try {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
String billerUserKey = (String) data.get("biller_user_key");
TbInputDataXit tbInputDataXit = tbInputDataXitRepository.findById(billerUserKey).orElseThrow(() -> new RuntimeException("biller_user_key와 일치하는 데이터를 찾을 수 없습니다."));
IupBillKkoPayUseSysService iupBillPayService = iupBillKkoPayUseSysServiceMap.get("iupBillKkoPayUseSysService_" + tbInputDataXit.getTbInputXit().getSendType());
return new ResponseEntity<BillKkoApiRespDTO>(iupBillPayService.addPayReultIfno(mParam), HttpStatus.OK);
} finally {
StringBuffer sb = new StringBuffer();
sb.append("\n==============================================================================")
.append("\n[ kakao 청구서 - 납부결과전달 ]")
.append("\n### Request Info...")
.append("\n" + CmmnUtil.toJsonString(mParam))
// .append("\n### Response Info...")
// .append("\n" + resp.getBody())
.append("\n==============================================================================");
log.info(sb.toString());
}
}
}

@ -0,0 +1,135 @@
package cokr.xit.ens.biz.iup.billpay.presentation;
import cokr.xit.ens.biz.iup.billpay.service.IupPayUseSysServiceFactory;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
@Tag(name = "IupPayUseSysController")
@Slf4j
@RequiredArgsConstructor
@RestController
//public class IupPayUseSysController implements PayUseSysController<ResponseEntity, Map<String, Object>> {
public class IupPayUseSysController {
private final IupPayUseSysServiceFactory factory;
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "kkopay(카카오페이)"
, summary = "kkopay(카카오페이)"
, value = "{\"data\":{\"billerUserKey\":\"빌러유저키\"}}")
})
})
@Parameters({
@Parameter(name = "paySe", example = "kkopay", required = true, in = ParameterIn.PATH),
})
@Operation(summary = "청구서링크생성 정보")
@PostMapping(value = "/iup/bill/{paySe}/gnr/url", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity gnrUrl(@PathVariable String paySe, @RequestBody Map<String, Object> param) {
if (Arrays.stream(IupPayUseSysServiceFactory.IupPaySe.values()).noneMatch(iupPaySe -> iupPaySe.name().equals(paySe)))
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
return new ResponseEntity(factory.getService(IupPayUseSysServiceFactory.IupPaySe.valueOf(paySe)).gnrUrl(param), HttpStatus.OK);
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "kkopay(카카오페이)"
, summary = "kkopay(카카오페이)"
, value = "{\"data\":{\"biller_user_key\":\"빌러유저키\",\"user_birth\":\"\",\"parameters\":{\"some_param\":\"\"}}}"),
@ExampleObject(name = "nvpay(네이버페이)"
, summary = "nvpay(네이버페이)"
, value = "{\"data\":{\"billerUserKey\":\"빌러유저키\"}}")
})
})
@Parameters({
@Parameter(name = "paySe", example = "kkopay", required = true, in = ParameterIn.PATH),
})
@Operation(summary = "납부(결제)정보")
@PostMapping(value = "/iup/bill/{paySe}/pay/notice", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity payNotice(@PathVariable String paySe, @RequestBody Map<String, Object> param) {
if (Arrays.stream(IupPayUseSysServiceFactory.IupPaySe.values()).noneMatch(iupPaySe -> iupPaySe.name().equals(paySe)))
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
return new ResponseEntity(factory.getService(IupPayUseSysServiceFactory.IupPaySe.valueOf(paySe)).payNotice(param), HttpStatus.OK);
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "kkopay(카카오페이)"
, summary = "kkopay(카카오페이)"
, value = "{\"data\":{\"biller_user_key\":\"빌러유저키\",\"amount\":29000,\"parameters\":{\"pay_rqt_seq\":\"KT00000001\"}}}"),
@ExampleObject(name = "nvpay(네이버페이)"
, summary = "nvpay(네이버페이)"
, value = "{\"data\":{\"billerUserKey\":\"빌러유저키\",\"productName\":\"\",\"totalPayAmount\":1000,\"taxScopeAmount\":1000,\"taxExScopeAmount\":null}}")
})
})
@Parameters({
@Parameter(name = "paySe", example = "kkopay", required = true, in = ParameterIn.PATH),
})
@Operation(summary = "납부(결제)가능여부")
@PostMapping(value = "/iup/bill/{paySe}/pay/able", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity payAble(@PathVariable String paySe, @RequestBody Map<String, Object> param) {
if (Arrays.stream(IupPayUseSysServiceFactory.IupPaySe.values()).noneMatch(iupPaySe -> iupPaySe.name().equals(paySe)))
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
return new ResponseEntity(factory.getService(IupPayUseSysServiceFactory.IupPaySe.valueOf(paySe)).payAble(param), HttpStatus.OK);
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "kkopay(카카오페이)"
, summary = "kkopay(카카오페이)"
, value = "{\"data\":{\"biller_user_key\":\"빌러유저키\",\"parameters\":{\"pay_rqt_seq\":\"KT00000001\"},\"pay_by\":\"MONEY\",\"pay_type\":\"P\",\"pay_detail1\":\"\",\"pay_detail2\":\"\",\"amount\":20000,\"pay_amount\":20000,\"pay_fee_type\":\"BEFORE\",\"pay_fee\":150,\"pay_fee_tax\":15,\"paid_at\":\"20190220161656\",\"pay_id\":2748877}}"),
@ExampleObject(name = "nvpay(네이버페이)"
, summary = "nvpay(네이버페이)"
, value = "{\"code\":\"Success\",\"message\":\"detail message(optional)\",\"body\":{\"paymentId\":\"네이버페이 결제번호\",\"detail\":{\"productName\":\"샘플상품\",\"merchantId\":\"loginId\",\"merchantName\":\"가맹점명\",\"cardNo\":\"465887**********\",\"admissionYmdt\":\"20170201151722\",\"payHistId\":\"20170201NP1043587781\",\"totalPayAmount\":1000,\"primaryPayAmount\":1000,\"npointPayAmount\":0,\"giftCardAmount\":0,\"taxScopeAmount\":1000,\"taxExScopeAmount\":0,\"environmentDepositAmount\":0,\"primaryPayMeans\":\"CARD\",\"merchantPayKey\":\"청구서UID\",\"merchantUserKey\":\"빌러유저키\",\"cardCorpCode\":\"C0\",\"paymentId\":\"20170201NP1043587746\",\"admissionTypeCode\":\"01\",\"settleExpectAmount\":971,\"payCommissionAmount\":29,\"admissionState\":\"SUCCESS\",\"tradeConfirmYmdt\":\"20170201152510\",\"cardAuthNo\":\"17545616\",\"cardInstCount\":0,\"usedCardPoint\":false,\"bankCorpCode\":\"\",\"bankAccountNo\":\"\",\"settleExpected\":false,\"extraDeduction\":false,\"useCfmYmdt\":\"20180703\"}}}")
})
})
@Parameters({
@Parameter(name = "paySe", example = "kkopay", required = true, in = ParameterIn.PATH),
})
@Operation(summary = "납부(결제)결과")
@PostMapping(value = "/iup/bill/{paySe}/pay/result", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity payResult(@PathVariable String paySe, @RequestBody Map<String, Object> param) {
if (Arrays.stream(IupPayUseSysServiceFactory.IupPaySe.values()).noneMatch(iupPaySe -> iupPaySe.name().equals(paySe)))
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
return new ResponseEntity(factory.getService(IupPayUseSysServiceFactory.IupPaySe.valueOf(paySe)).payResult(param), HttpStatus.OK);
}
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = {
@ExampleObject(name = "nvpay(네이버페이)"
, summary = "nvpay(네이버페이)"
, value = "{\"code\":\"Success\",\"message\":\"detail message(optional)\",\"body\":{\"responseCount\":1,\"totalCount\":1,\"totalPageCount\":1,\"currentPageNumber\":1,\"list\":[{\"cardAuthNo\":\"00000000\",\"bankAccountNo\":\"\",\"bankCorpCode\":\"\",\"paymentId\":\"20170000NP1000229665\",\"cardCorpCode\":\"C0\",\"cardInstCount\":0,\"usedCardPoint\":false,\"settleInfo\":{\"primaryCommissionAmount\":30,\"npointCommissionAmount\":20,\"giftCardCommissionAmount\":0,\"primarySettleAmount\":470,\"npointSettleAmount\":480,\"giftCardSettleAmount\":0,\"totalSettleAmount\":850,\"totalCommissionAmount\":50,\"settleCreated\":true},\"merchantName\":\"나의가맹점\",\"productName\":\"나의상품\",\"payHistId\":\"20170000NP1000229668\",\"merchantId\":\"MID12345\",\"admissionYmdt\":\"20170914163930\",\"tradeConfirmYmdt\":\"20170915163956\",\"totalPayAmount\":1000,\"merchantPayKey\":\"orderKey-91516397\",\"merchantUserKey\":\"빌러유저키\",\"admissionTypeCode\":\"01\",\"primaryPayMeans\":\"CARD\",\"admissionState\":\"SUCCESS\",\"primaryPayAmount\":500,\"npointPayAmount\":500,\"giftCardPayAmount\":0,\"taxScopeAmount\":1000,\"taxExScopeAmount\":0,\"environmentDepositAmount\":0,\"cardNo\":\"123456**********\",\"extraDeduction\":false,\"useCfmYmdt\":\"20180703\"}]}}")
})
})
@Parameters({
@Parameter(name = "paySe", example = "kkopay", required = true, in = ParameterIn.PATH),
})
@Operation(summary = "결제취소정보")
@PostMapping(value = "/iup/bill/{paySe}/pay/cancel", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity payCancel(@PathVariable String paySe, @RequestBody Map<String, Object> param) {
if (Arrays.stream(IupPayUseSysServiceFactory.IupPaySe.values()).noneMatch(iupPaySe -> iupPaySe.name().equals(paySe)))
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
return new ResponseEntity(factory.getService(IupPayUseSysServiceFactory.IupPaySe.valueOf(paySe)).payCancel(param), HttpStatus.OK);
}
}

@ -0,0 +1,191 @@
package cokr.xit.ens.biz.iup.billpay.service;
import cokr.xit.ens.biz.iup.domain.VKakaoNoticeInfo;
import cokr.xit.ens.biz.iup.domain.VKakaoNoticeInfoSn;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
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.entity.BillHist;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository.BillHistRepository;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public abstract class IupBillKkoPayUseSysService {
@Autowired
private BillHistRepository billHistRepository;
/**
* -
*
* @param reqSeCd
* @param billerUserKey
* @param orgCd
* @param mParam
* @return
*/
protected BillHist addBillHistByReqInfo(BillReqSeCd reqSeCd, String billerUserKey, String orgCd, String billUid, Map<String, Object> mParam) {
BillHist billHist = BillHist.builder()
.billSe(BillSeCd.bpKko)
.billUid(billUid)
.reqSe(reqSeCd)
.orgMng(orgCd == null ? null : OrgMng.builder().orgCd(orgCd).build())
.linkedUuid(billerUserKey)
.requestData(CmmnUtil.toJsonString(mParam))
.build();
billHistRepository.save(billHist);
return billHist;
}
/**
* -
*
* @param billHist
* @param respData
* @param errCd
* @param errMsg
*/
protected void modifyBillHistByRespInfo(BillHist billHist, Object respData, EnsErrCd errCd, String errMsg) {
billHist.setResponseData(CmmnUtil.toJsonString(respData));
billHist.setError(FieldError.initBuilder()
.errorCode(CmmnUtil.isEmpty(errCd) ? null : errCd.getCode())
.errorMessage(errMsg)
.build());
billHistRepository.save(billHist);
}
/**
*
*
* @param mParam
* @return
*/
abstract public BillKkoApiRespDTO findNoticeInfo(Map<String, Object> mParam);
/**
*
*
* @param mParam
* @return
*/
abstract public BillKkoApiRespDTO findPrepayInfo(Map<String, Object> mParam);
/**
*
*
* @param mParam
* @return
*/
abstract public BillKkoApiRespDTO addPayReultIfno(Map<String, Object> mParam);
/**
* "강제징수"
*
* @param title
* @param orgMng
* @param vKakaoNoticeInfo
* @return
*/
protected Map<String, Object> respNoticeData(String title, OrgMng orgMng, VKakaoNoticeInfo vKakaoNoticeInfo) {
Map<String, Object> mParam = new HashMap<>();
mParam.put("biller_user_key", vKakaoNoticeInfo.getEnfrcLevMastrId());
mParam.put("user_birth ", vKakaoNoticeInfo.getUserBirth());
mParam.put("amount", vKakaoNoticeInfo.getAmount());
mParam.put("pay_expire_date", vKakaoNoticeInfo.getPayExpireDate());
mParam.put("detail_pasng_chrge_sm", vKakaoNoticeInfo.getDetailPasngChrgeSm());
mParam.put("detail_adi_pasng_chrge_sm", vKakaoNoticeInfo.getDetailAdiPasngChrgeSm());
return this.makeNoticeData(title, orgMng, mParam);
}
/**
* "단순미납"
*
* @param title
* @param orgMng
* @param vKakaoNoticeInfoSn
* @return
*/
protected Map<String, Object> respNoticeSnData(String title, OrgMng orgMng, VKakaoNoticeInfoSn vKakaoNoticeInfoSn) {
Map<String, Object> mParam = new HashMap<>();
mParam.put("biller_user_key", vKakaoNoticeInfoSn.getDataId());
mParam.put("user_birth", vKakaoNoticeInfoSn.getUserBirth());
mParam.put("amount", vKakaoNoticeInfoSn.getAmount());
mParam.put("pay_expire_date", vKakaoNoticeInfoSn.getPayExpireDate());
mParam.put("detail_pasng_chrge_sm", vKakaoNoticeInfoSn.getDetailPasngChrgeSm());
mParam.put("detail_adi_pasng_chrge_sm", vKakaoNoticeInfoSn.getDetailAdiPasngChrgeSm());
return this.makeNoticeData(title, orgMng, mParam);
}
/**
* Response
*
* @param title
* @param orgMng
* @param mParam
* @return
*/
protected Map<String, Object> makeNoticeData(String title, OrgMng orgMng, Map<String, Object> mParam) {
// Map<String, Object> bank_accounts = new HashMap<>();
// bank_accounts.put("bank_code", "");
// bank_accounts.put("account_no", "");
// bank_accounts.put("holder_name", "");
// bank_accounts.put("sender_name", "");
// bank_accounts.put("account_type", "");
Map<String, Object> result = new HashMap<>();
// result.put("settlement_code", "");
result.put("biller_user_key", mParam.get("biller_user_key"));
// result.put("billed_year_month", "");
// result.put("ordinal", "");
// result.put("biller_notice_key", "");
result.put("title", title);
result.put("amount", mParam.get("amount"));
// result.put("tax_free_amount", "");
// result.put("tax_free_amount", mParam.get("amount")); // 비과세 (카카오에서 답변이 없어서 배포 안함)
// result.put("vat_amount", "");
result.put("expire_type", "D1");
result.put("pay_expire_date", mParam.get("pay_expire_date"));
// result.put("second_pay_expire_date", "");
// result.put("bank_accounts", bank_accounts);
result.put("details", this.makeNoticeDetailsData(mParam));
Map<String, Object> data = new HashMap<>();
data.put("result", result);
return data;
}
/**
* Response "details"
*
* @param mParam
* @return
*/
protected List<Map<String, Object>> makeNoticeDetailsData(Map<String, Object> mParam) {
Map<String, Object> detail = new HashMap<>();
detail.put("item_type", "TEXT");
detail.put("elements", Arrays.asList(String.format("상세 통행료: %s", mParam.get("detail_pasng_chrge_sm"))
, String.format("상세 부가통행료: %s", mParam.get("detail_adi_pasng_chrge_sm"))));
List<Map<String, Object>> details = Arrays.asList(detail);
return details;
}
}

@ -0,0 +1,6 @@
package cokr.xit.ens.biz.iup.billpay.service;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.PayProcessService;
public interface IupPayUseSysService<T, P> extends PayProcessService<T, P> {
}

@ -0,0 +1,32 @@
package cokr.xit.ens.biz.iup.billpay.service;
import cokr.xit.ens.biz.iup.billpay.service.impl.IupKkoPayUseSysServiceImpl;
import cokr.xit.ens.biz.iup.billpay.service.impl.IupNvPayUseSysServiceImpl;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class IupPayUseSysServiceFactory {
private final IupKkoPayUseSysServiceImpl iupKkoPayUseSysService;
private final IupNvPayUseSysServiceImpl iupNvPayUseSysService;
public enum IupPaySe {
kkopay,
nvpay
}
public IupPayUseSysService getService(IupPaySe iupPaySe) {
switch (iupPaySe) {
case kkopay:
return iupKkoPayUseSysService;
case nvpay:
return iupNvPayUseSysService;
default:
throw new EnsException(EnsErrCd.INVALID_REQUEST_URL, EnsErrCd.INVALID_REQUEST_URL.getCodeNm());
}
}
}

@ -0,0 +1,86 @@
package cokr.xit.ens.biz.iup.billpay.service.impl;
import cokr.xit.ens.biz.iup.billpay.service.IupPayUseSysService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupKkoPayAbleService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupKkoPayNoticeService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupKkoPayResultService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupKkoPayUrlService;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.KkoPayNoticeRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.KkoPayUrlRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.Pay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.template.PayHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Map;
@Slf4j
@Service
@RequiredArgsConstructor
public class IupKkoPayUseSysServiceImpl implements IupPayUseSysService<PayApiRespDTO, Map<String, Object>> {
private final IupKkoPayUrlService iupKkoPayUrlService;
private final IupKkoPayNoticeService iupKkoPayNoticeService;
private final IupKkoPayAbleService iupKkoPayAbleService;
private final IupKkoPayResultService iupKkoPayResultService;
@Override
public PayApiRespDTO gnrUrl(Map<String, Object> param) {
Pay<PayApiRespDTO<KkoPayUrlRespData>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<KkoPayUrlRespData>>builder()
.param(param)
.payHelperService(iupKkoPayUrlService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payNotice(Map<String, Object> param) {
Pay<PayApiRespDTO<KkoPayNoticeRespData>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<KkoPayNoticeRespData>>builder()
.param(param)
.payHelperService(iupKkoPayNoticeService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payAble(Map<String, Object> param) {
Pay<PayApiRespDTO<Map<String, Object>>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>>builder()
.param(param)
.payHelperService(iupKkoPayAbleService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payResult(Map<String, Object> param) {
Pay<PayApiRespDTO<Map<String, Object>>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>>builder()
.param(param)
.payHelperService(iupKkoPayResultService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payCancel(Map<String, Object> param) {
return PayApiRespDTO.errBuilder()
.resCode(EnsErrCd.SERVICE_NOT_SUPPORTED.getCode())
.message(EnsErrCd.SERVICE_NOT_SUPPORTED.getCodeNm())
.build();
}
}

@ -0,0 +1,81 @@
package cokr.xit.ens.biz.iup.billpay.service.impl;
import cokr.xit.ens.biz.iup.billpay.service.IupPayUseSysService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupNvPayAbleService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupNvPayCancelService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupNvPayNoticeService;
import cokr.xit.ens.biz.iup.billpay.service.process.IupNvPayResultService;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.nv.service.process.model.NvPayNoticeRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.Pay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.template.PayHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Map;
@Slf4j
@Service
@RequiredArgsConstructor
public class IupNvPayUseSysServiceImpl implements IupPayUseSysService<PayApiRespDTO, Map<String, Object>> {
private final IupNvPayNoticeService iupNvPayNoticeService;
private final IupNvPayAbleService iupNvPayAbleService;
private final IupNvPayResultService iupNvPayResultService;
private final IupNvPayCancelService iupNvPayCancelService;
@Override
public PayApiRespDTO gnrUrl(Map<String, Object> param) {
return PayApiRespDTO.errBuilder()
.resCode(EnsErrCd.SERVICE_NOT_SUPPORTED.getCode())
.message(EnsErrCd.SERVICE_NOT_SUPPORTED.getCodeNm())
.build();
}
@Override
public PayApiRespDTO payNotice(Map<String, Object> param) {
Pay<PayApiRespDTO<NvPayNoticeRespData>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<NvPayNoticeRespData>>builder()
.param(param)
.payHelperService(iupNvPayNoticeService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payAble(Map<String, Object> param) {
Pay<PayApiRespDTO<Map<String, Object>>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>>builder()
.param(param)
.payHelperService(iupNvPayAbleService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payResult(Map<String, Object> param) {
Pay<PayApiRespDTO<Map<String, Object>>> pay = PayHelper.<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>>builder()
.param(param)
.payHelperService(iupNvPayResultService)
.build();
pay.exec();
return pay.getResult();
}
@Override
public PayApiRespDTO payCancel(Map<String, Object> param) {
return PayApiRespDTO.errBuilder()
.resCode(EnsErrCd.SERVICE_NOT_SUPPORTED.getCode())
.message(EnsErrCd.SERVICE_NOT_SUPPORTED.getCodeNm())
.build();
}
}

@ -0,0 +1,217 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbEnfrcLevMastrRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoSnRepository;
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.support.api.PayUseSysApi;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayAbleService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupKkoPayAbleService implements PayAbleService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>> {
private final JPAQueryFactory query;
private final VKakaoNoticeInfoSnRepository vKakaoNoticeInfoSnRepository;
private final VKakaoNoticeInfoRepository vKakaoNoticeInfoRepository;
private final TbEnfrcLevMastrRepository tbEnfrcLevMastrRepository;
private final PayUseSysApi payUseSysApi;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
private enum DataKeys {
tbInputDataXit,
payApiRespDTO,
responseJsonStr,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
// Integer amount = (Integer) reqData.get("amount");
if (billerUserKey == null) billerUserKey = "";
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String dataId = tbInputDataXit.getDataId();
if ("Y".equals(fsJob.getBpEntrustYn()) || "y".equals(fsJob.getBpEntrustYn())) {
final String url = fsJob.getBpKkoPrepayApi();
VKakaoNoticeInfoSn vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId)
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 단순미납부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfoSn)
.map(entity -> payUseSysApi.payAble(url, reqParam, null))
.map(response -> checkResponse(response))
.map(payApiRespDTO -> loadRespData(data, payApiRespDTO))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "단순미납 응답데이터 수신에 실패했습니다."))
;
} else if ("N".equals(fsJob.getBpEntrustYn()) || "n".equals(fsJob.getBpEntrustYn())) {
if (dataId.length() < 20)
throw new EnsException(EnsErrCd.INVALID_DATA, "데이터ID가 20자리 미만 입니다.");
VKakaoNoticeInfo vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20))
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 강제징수부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfo)
.map(entity -> validateData(reqParam, entity));
TbEnfrcLevMastr tbEnfrcLevMastr = tbEnfrcLevMastrRepository.findByEnfrcLevMastrIdAndEnfrcLevMastrProcessSttusAndDeleteAt(dataId.substring(0, 20), "04", "N")
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "납부가능 상태가 아닙니다.", PayUseSysResCd.NO_TARGET_PAYABLE));
Optional.of(tbEnfrcLevMastr)
.map(entity -> createRespData())
.map(payApiRespDTO -> loadRespData(data, payApiRespDTO))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "강제징수 응답데이터 생성에 실패했습니다."));
} else {
throw new EnsException(EnsErrCd.INVALID_DATA, "위탁여부가 등록되지 않았습니다.");
}
}
private PayApiRespDTO<Map<String, Object>> checkResponse(ResponseEntity<String> response) {
if (!HttpStatus.OK.equals(response.getStatusCode()))
throw new EnsException(EnsErrCd.API_COMM_ERROR, EnsErrCd.API_COMM_ERROR.getCodeNm() + " " + response.getStatusCode().toString(), response.getBody());
PayApiRespDTO<Map<String, Object>> result = null;
try {
result = gson.fromJson(response.getBody(), PayApiRespDTO.class);
} catch (Exception ex) {
throw new EnsException(EnsErrCd.INVALID_RESPONSE, EnsErrCd.INVALID_RESPONSE.getCodeNm(), ex);
}
return result;
}
private PayApiRespDTO loadRespData(Map<String, Object> data, PayApiRespDTO payApiRespDTO) {
if (CmmnUtil.isEmpty(payApiRespDTO))
return null;
data.put(DataKeys.payApiRespDTO.name(), payApiRespDTO);
data.put(DataKeys.responseJsonStr.name(), gson.toJson(payApiRespDTO));
return payApiRespDTO;
}
private VKakaoNoticeInfo validateData(Map<String, Object> reqParam, VKakaoNoticeInfo vKakaoNoticeInfo) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final Integer amount = (Integer) reqData.getOrDefault("amount", 0);
if (amount != Integer.parseInt(vKakaoNoticeInfo.getAmount()))
throw new EnsException(EnsErrCd.INVALID_DATA
, String.format("납부 가능 금액이 없거나 일치하지 않습니다. (요청금액:%s, 실제금액:%s)", amount, vKakaoNoticeInfo.getAmount())
, PayUseSysResCd.NO_AMOUNT_PAYABLE);
if (amount > Integer.parseInt(vKakaoNoticeInfo.getAmount()))
throw new EnsException(EnsErrCd.INVALID_DATA
, String.format("납부 가능 금액을 초과했습니다. (요청금액:%s, 실제금액:%s)", amount, vKakaoNoticeInfo.getAmount())
, PayUseSysResCd.OVERPAYABLE_AMOUNT);
if (CmmnUtil.isEmpty(vKakaoNoticeInfo.getPayExpireDate()))
throw new EnsException(EnsErrCd.INVALID_DATA
, "납부기한의 값이 비어있습니다."
, PayUseSysResCd.EXPIRED_DATE);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
if (Integer.parseInt(vKakaoNoticeInfo.getPayExpireDate()) < Integer.parseInt(simpleDateFormat.format(new Date())))
throw new EnsException(EnsErrCd.INVALID_DATA
, "납부기한이 경과한 자료 입니다."
, PayUseSysResCd.EXPIRED_DATE);
return vKakaoNoticeInfo;
}
private PayApiRespDTO createRespData() {
return PayApiRespDTO.okBuilder().build();
}
@Override
public PayApiRespDTO<Map<String, Object>> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
PayApiRespDTO payApiRespDTO = (PayApiRespDTO) data.get(DataKeys.payApiRespDTO.name());
return gson.fromJson(gson.toJson(payApiRespDTO), PayApiRespDTO.class);
} else {
if (e.getData() != null && e.getData() instanceof PayUseSysResCd) {
PayUseSysResCd resCode = (PayUseSysResCd) e.getData();
return PayApiRespDTO.<Map<String, Object>>errBuilder()
.resCode(resCode.getCode())
.message(resCode.getCodeNm())
.build();
} else {
return PayApiRespDTO.<Map<String, Object>>errBuilder()
.resCode(PayUseSysResCd.FAILED_CHECK_INFO.getCode())
.message(PayUseSysResCd.FAILED_CHECK_INFO.getCodeNm())
.build();
}
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.kakaoPay)
.hisSeCd(PayUseSysHisSeCd.payAble)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,227 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoSnRepository;
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.service.process.model.KkoPayNoticeRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayNoticeService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupKkoPayNoticeService implements PayNoticeService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<KkoPayNoticeRespData>> {
private final JPAQueryFactory query;
private final VKakaoNoticeInfoSnRepository vKakaoNoticeInfoSnRepository;
private final VKakaoNoticeInfoRepository vKakaoNoticeInfoRepository;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
private enum DataKeys {
tbInputDataXit,
kkoPayNoticeRespData,
responseJsonStr,
}
private enum PayDataKeys {
billerUserKey,
userBirth,
amount,
payExpireDate,
detailPasngChrgeSm,
detailAdiPasngChrgeSm,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
if (billerUserKey == null) billerUserKey = "";
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String dataId = tbInputDataXit.getDataId();
if ("Y".equals(fsJob.getBpEntrustYn()) || "y".equals(fsJob.getBpEntrustYn())) {
VKakaoNoticeInfoSn vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId)
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 단순미납부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfoSn)
.map(entity -> toDataMap(entity))
.map(payData -> validateData(reqParam, payData))
.map(payData -> createRespData(tbInputDataXit, payData))
.map(kkoPayNoticeRespData -> loadRespData(data, kkoPayNoticeRespData))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "단순미납 응답데이터 생성에 실패했습니다."))
;
} else if ("N".equals(fsJob.getBpEntrustYn()) || "n".equals(fsJob.getBpEntrustYn())) {
if (dataId.length() < 20)
throw new EnsException(EnsErrCd.INVALID_DATA, "데이터ID가 20자리 미만 입니다.");
VKakaoNoticeInfo vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20))
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 강제징수부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfo)
.map(entity -> toDataMap(entity))
.map(map -> validateData(reqParam, map))
.map(map -> createRespData(tbInputDataXit, map))
.map(kkoPayNoticeRespData -> loadRespData(data, kkoPayNoticeRespData))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "강제징수 응답데이터 생성에 실패했습니다."))
;
} else {
throw new EnsException(EnsErrCd.INVALID_DATA, "위탁여부가 등록되지 않았습니다.");
}
}
private Map<PayDataKeys, Object> toDataMap(VKakaoNoticeInfoSn vKakaoNoticeInfoSn) {
Map<PayDataKeys, Object> payData = new HashMap<>();
payData.put(PayDataKeys.billerUserKey, vKakaoNoticeInfoSn.getDataId());
payData.put(PayDataKeys.userBirth, vKakaoNoticeInfoSn.getUserBirth());
payData.put(PayDataKeys.amount, vKakaoNoticeInfoSn.getAmount().intValue());
payData.put(PayDataKeys.payExpireDate, vKakaoNoticeInfoSn.getPayExpireDate());
payData.put(PayDataKeys.detailPasngChrgeSm, vKakaoNoticeInfoSn.getDetailPasngChrgeSm());
payData.put(PayDataKeys.detailAdiPasngChrgeSm, vKakaoNoticeInfoSn.getDetailAdiPasngChrgeSm());
return payData;
}
private Map<PayDataKeys, Object> toDataMap(VKakaoNoticeInfo vKakaoNoticeInfo) {
Map<PayDataKeys, Object> payData = new HashMap<>();
payData.put(PayDataKeys.billerUserKey, vKakaoNoticeInfo.getEnfrcLevMastrId());
payData.put(PayDataKeys.userBirth, vKakaoNoticeInfo.getUserBirth());
payData.put(PayDataKeys.amount, Integer.parseInt(vKakaoNoticeInfo.getAmount()));
payData.put(PayDataKeys.payExpireDate, vKakaoNoticeInfo.getPayExpireDate());
payData.put(PayDataKeys.detailPasngChrgeSm, vKakaoNoticeInfo.getDetailPasngChrgeSm());
payData.put(PayDataKeys.detailAdiPasngChrgeSm, vKakaoNoticeInfo.getDetailAdiPasngChrgeSm());
return payData;
}
private Map<PayDataKeys, Object> validateData(Map<String, Object> reqParam, Map<PayDataKeys, Object> payData) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String userBirth = (String) reqData.getOrDefault("user_birth", "");
if (!userBirth.equals(payData.get(PayDataKeys.userBirth)))
throw new EnsException(EnsErrCd.INVALID_DATA, String.format("요청과 실제 생년월일이 일치하지 않습니다. (요청: %s 실제: %s)", userBirth, payData.get(PayDataKeys.userBirth)));
return payData;
}
private KkoPayNoticeRespData createRespData(TbInputDataXit tbInputDataXit, Map<PayDataKeys, Object> payData) {
Map<String, Object> detail = new HashMap<>();
detail.put("item_type", "TEXT");
detail.put("elements", Arrays.asList(String.format("상세 통행료: %s", payData.get(PayDataKeys.detailPasngChrgeSm))
, String.format("상세 부가통행료: %s", payData.get(PayDataKeys.detailAdiPasngChrgeSm))));
List<Map<String, Object>> details = Arrays.asList(detail);
return KkoPayNoticeRespData.builder()
.title(tbInputDataXit.getTbInputXit().getFsJob().getJobName())
.amount((Integer) payData.get(PayDataKeys.amount))
.expireType("D1")
.payExpireDate((String) payData.get(PayDataKeys.payExpireDate))
.details(details)
.build();
}
private KkoPayNoticeRespData loadRespData(Map<String, Object> data, KkoPayNoticeRespData kkoPayNoticeRespData) {
if (CmmnUtil.isEmpty(kkoPayNoticeRespData))
return null;
data.put(DataKeys.kkoPayNoticeRespData.name(), kkoPayNoticeRespData);
data.put(DataKeys.responseJsonStr.name(), gson.toJson(kkoPayNoticeRespData));
return kkoPayNoticeRespData;
}
@Override
public PayApiRespDTO<KkoPayNoticeRespData> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
KkoPayNoticeRespData kkoPayNoticeRespData = (KkoPayNoticeRespData) data.get(DataKeys.kkoPayNoticeRespData.name());
return PayApiRespDTO.<KkoPayNoticeRespData>okBuilder()
.data(kkoPayNoticeRespData)
.build();
} else {
String resCode = null;
String message = null;
switch (e.getErrCd()) {
case NO_DATA_FOUND:
resCode = PayUseSysResCd.NOT_FOUND_PAYDATA.getCode();
message = PayUseSysResCd.NOT_FOUND_PAYDATA.getCodeNm();
break;
default:
resCode = PayUseSysResCd.PAYDATA_FIND_FAILED.getCode();
message = PayUseSysResCd.PAYDATA_FIND_FAILED.getCodeNm();
break;
}
return PayApiRespDTO.<KkoPayNoticeRespData>errBuilder()
.resCode(resCode)
.message(message)
.build();
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.kakaoPay)
.hisSeCd(PayUseSysHisSeCd.payNotice)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,191 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbKakaoPayResultRepository;
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.service.process.model.KkoPayResultReqData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.PayUseSysApi;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayResultService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
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;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupKkoPayResultService implements PayResultService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>> {
private final JPAQueryFactory query;
private final PayUseSysApi payUseSysApi;
private final TbKakaoPayResultRepository tbKakaoPayResultRepository;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
private enum DataKeys {
tbInputDataXit,
responseJsonStr,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
if (billerUserKey == null) billerUserKey = "";
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String url = fsJob.getBpKkoPayresultApi();
Optional.ofNullable(gson.fromJson(gson.toJson(reqParam.get("data")), KkoPayResultReqData.class))
.map(kkoPayResultReqData -> toEntity(kkoPayResultReqData))
.map(entity -> savePayResult(entity))
.map(entity -> tbInputDataXit)
.filter(detail -> "Y".equals(detail.getTbInputXit().getFsJob()))
.map(vKakaoNoticeInfoSn -> payUseSysApi.payResult(url, reqParam, null))
.map(response -> loadRespData(data, response))
.map(response -> checkResponse(response))
;
}
private TbKakaoPayResult toEntity(KkoPayResultReqData kkoPayResultReqData) {
final String jobSe = "EL".equals(kkoPayResultReqData.getBillerUserKey().substring(0, 2)) ? "2" : "1";
final String payAmount = CmmnUtil.isEmpty(kkoPayResultReqData.getPayAmount()) ? null : String.valueOf(kkoPayResultReqData.getPayAmount());
final String payFee = CmmnUtil.isEmpty(kkoPayResultReqData.getPayFee()) ? null : String.valueOf(kkoPayResultReqData.getPayFee());
final String payFeeTax = CmmnUtil.isEmpty(kkoPayResultReqData.getPayFeeTax()) ? null : String.valueOf(kkoPayResultReqData.getPayFeeTax());
final String payId = CmmnUtil.isEmpty(kkoPayResultReqData.getPayId()) ? null : String.valueOf(kkoPayResultReqData.getPayId());
return TbKakaoPayResult.builder()
.dataId(kkoPayResultReqData.getBillerUserKey())
.jobSe(jobSe)
.payMn(kkoPayResultReqData.getPayBy())
.payTy(kkoPayResultReqData.getPayType())
.payDetail1(kkoPayResultReqData.getPayDetail1())
.payDetail2(kkoPayResultReqData.getPayDetail2())
.payDetail3(kkoPayResultReqData.getPayDetail3())
.payAmount(payAmount)
.payFeeTy(kkoPayResultReqData.getPayFeeType())
.payFeeAmount(payFee)
.payFeeVat(payFeeTax)
.excclcPrearngeDe(kkoPayResultReqData.getAdjustDate())
.payDt(kkoPayResultReqData.getPaidAt())
.payId(payId)
.payResultProcessSttus("0")
// .creatDt()
.crtr("ENS_SYS")
// .updtDt()
// .updusr()
.build();
}
private TbKakaoPayResult savePayResult(TbKakaoPayResult entity) {
tbKakaoPayResultRepository.save(entity);
return entity;
}
private ResponseEntity<String> loadRespData(Map<String, Object> data, ResponseEntity<String> response) {
data.put(DataKeys.responseJsonStr.name(), response.getBody());
return response;
}
private PayApiRespDTO<Map<String, Object>> checkResponse(ResponseEntity<String> response) {
if (!HttpStatus.OK.equals(response.getStatusCode()))
throw new EnsException(EnsErrCd.API_COMM_ERROR, EnsErrCd.API_COMM_ERROR.getCodeNm() + " " + response.getStatusCode().toString(), response.getBody());
PayApiRespDTO<Map<String, Object>> result = null;
try {
result = gson.fromJson(response.getBody(), PayApiRespDTO.class);
} catch (Exception ex) {
throw new EnsException(EnsErrCd.INVALID_RESPONSE, EnsErrCd.INVALID_RESPONSE.getCodeNm(), ex);
}
return result;
}
@Override
public PayApiRespDTO<Map<String, Object>> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
return PayApiRespDTO.<Map<String, Object>>okBuilder().build();
} else {
return PayApiRespDTO.<Map<String, Object>>errDataBuilder()
.resCode(PayUseSysResCd.FAILED_SAVE_PAYRSLT.getCode())
.message(PayUseSysResCd.FAILED_SAVE_PAYRSLT.getCodeNm())
.data(null)
.build();
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("biller_user_key");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.kakaoPay)
.hisSeCd(PayUseSysHisSeCd.payResult)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,147 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
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.service.process.model.CustomUrl;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.KkoPayUrlRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
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.domain.support.FieldError;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupKkoPayUrlService implements PayUrlService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<KkoPayUrlRespData>> {
private final JPAQueryFactory query;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new GsonBuilder().disableHtmlEscaping().create();
@Value("${contract.kakao.pay.bill.dozn.api.validate.host}")
private String BILL_HOST;
@Value("${contract.kakao.pay.bill.dozn.api.validate.notice}")
private String BILL_NOTICE_URL;
@Value("${contract.kakao.pay.bill.dozn.api.validate.prepay}")
private String BILL_PREPAY_URL;
@Value("${contract.kakao.pay.bill.dozn.api.validate.payresult}")
private String BILL_PAYREUSLT_URL;
private enum DataKeys {
tbInputDataXit,
responseJsonStr,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final String billerUserKey = (String) reqData.getOrDefault("billerUserKey", "");
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
Optional.ofNullable(createRespData(data))
.map(kkoPayUrlRespData -> loadRespData(data, kkoPayUrlRespData));
}
private KkoPayUrlRespData createRespData(Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
return KkoPayUrlRespData.builder()
.billedYearMonth(null)
.ordinal(null)
.expireAt(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")))
.parameters(null)
.customUrl(CustomUrl.builder()
.noticeUrl(this.BILL_HOST + this.BILL_NOTICE_URL)
.prepayUrl(this.BILL_HOST + this.BILL_PREPAY_URL)
.payResultUrl(this.BILL_HOST + this.BILL_PAYREUSLT_URL)
.build())
.build();
}
private Map<String, Object> loadRespData(Map<String, Object> data, KkoPayUrlRespData kkoPayUrlRespData) {
data.put(DataKeys.responseJsonStr.name(), gson.toJson(kkoPayUrlRespData));
return data;
}
@Override
public PayApiRespDTO<KkoPayUrlRespData> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
KkoPayUrlRespData kkoPayUrlRespData = gson.fromJson((String) data.get(DataKeys.responseJsonStr.name()), KkoPayUrlRespData.class);
return PayApiRespDTO.<KkoPayUrlRespData>okBuilder()
.data(kkoPayUrlRespData)
.build();
} else {
return PayApiRespDTO.<KkoPayUrlRespData>errBuilder()
.resCode(PayUseSysResCd.GRNURL_FIND_FAILED.getCode())
.message(PayUseSysResCd.GRNURL_FIND_FAILED.getCodeNm())
.build();
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final String billerUserKey = (String) reqData.getOrDefault("billerUserKey", "");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.kakaoPay)
.hisSeCd(PayUseSysHisSeCd.gnrUrl)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,224 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbEnfrcLevMastrRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoSnRepository;
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.support.api.PayUseSysApi;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayAbleService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupNvPayAbleService implements PayAbleService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>> {
private final JPAQueryFactory query;
private final VKakaoNoticeInfoSnRepository vKakaoNoticeInfoSnRepository;
private final VKakaoNoticeInfoRepository vKakaoNoticeInfoRepository;
private final TbEnfrcLevMastrRepository tbEnfrcLevMastrRepository;
private final PayUseSysApi payUseSysApi;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
private enum DataKeys {
tbInputDataXit,
payApiRespDTO,
responseJsonStr,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("billerUserKey");
// String productName = (String) reqData.get("productName");
// Integer totalPayAmount = (Integer) reqData.get("totalPayAmount");
// Integer taxScopeAmount = (Integer) reqData.get("taxScopeAmount");
// Integer taxExScopeAmount = (Integer) reqData.get("taxExScopeAmount");
if (billerUserKey == null) billerUserKey = "";
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String dataId = tbInputDataXit.getDataId();
if ("Y".equals(fsJob.getBpEntrustYn()) || "y".equals(fsJob.getBpEntrustYn())) {
final String url = fsJob.getBpNvPrepayApi();
VKakaoNoticeInfoSn vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId)
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 단순미납부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfoSn)
.map(entity -> payUseSysApi.payAble(url, reqParam, null))
.map(response -> checkResponse(response))
.map(payApiRespDTO -> loadRespData(data, payApiRespDTO))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "단순미납 응답데이터 수신에 실패했습니다."))
;
} else if ("N".equals(fsJob.getBpEntrustYn()) || "n".equals(fsJob.getBpEntrustYn())) {
if (dataId.length() < 20)
throw new EnsException(EnsErrCd.INVALID_DATA, "데이터ID가 20자리 미만 입니다.");
VKakaoNoticeInfo vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20))
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 강제징수부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfo)
.map(entity -> validateData(reqParam, entity));
TbEnfrcLevMastr tbEnfrcLevMastr = tbEnfrcLevMastrRepository.findByEnfrcLevMastrIdAndEnfrcLevMastrProcessSttusAndDeleteAt(dataId.substring(0, 20), "04", "N")
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "납부가능 상태가 아닙니다.", PayUseSysResCd.NO_TARGET_PAYABLE));
Optional.of(tbEnfrcLevMastr)
.map(entity -> createRespData())
.map(payApiRespDTO -> loadRespData(data, payApiRespDTO))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "강제징수 응답데이터 생성에 실패했습니다."));
} else {
throw new EnsException(EnsErrCd.INVALID_DATA, "위탁여부가 등록되지 않았습니다.");
}
}
private PayApiRespDTO<Map<String, Object>> checkResponse(ResponseEntity<String> response) {
if (!HttpStatus.OK.equals(response.getStatusCode()))
throw new EnsException(EnsErrCd.API_COMM_ERROR, EnsErrCd.API_COMM_ERROR.getCodeNm() + " " + response.getStatusCode().toString(), response.getBody());
PayApiRespDTO<Map<String, Object>> result = null;
try {
result = gson.fromJson(response.getBody(), PayApiRespDTO.class);
} catch (Exception ex) {
throw new EnsException(EnsErrCd.INVALID_RESPONSE, EnsErrCd.INVALID_RESPONSE.getCodeNm(), ex);
}
return result;
}
private PayApiRespDTO loadRespData(Map<String, Object> data, PayApiRespDTO payApiRespDTO) {
if (CmmnUtil.isEmpty(payApiRespDTO))
return null;
data.put(DataKeys.payApiRespDTO.name(), payApiRespDTO);
data.put(DataKeys.responseJsonStr.name(), gson.toJson(payApiRespDTO));
return payApiRespDTO;
}
private VKakaoNoticeInfo validateData(Map<String, Object> reqParam, VKakaoNoticeInfo vKakaoNoticeInfo) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final String productName = (String) reqData.get("productName");
final Integer totalPayAmount = (Integer) reqData.getOrDefault("totalPayAmount", 0);
final Integer taxScopeAmount = (Integer) reqData.get("taxScopeAmount");
final Integer taxExScopeAmount = (Integer) reqData.get("taxExScopeAmount");
if (totalPayAmount != Integer.parseInt(vKakaoNoticeInfo.getAmount()))
throw new EnsException(EnsErrCd.INVALID_DATA
, String.format("납부 가능 금액이 없거나 일치하지 않습니다. (요청금액:%s, 실제금액:%s)", totalPayAmount, vKakaoNoticeInfo.getAmount())
, PayUseSysResCd.NO_AMOUNT_PAYABLE);
if (totalPayAmount > Integer.parseInt(vKakaoNoticeInfo.getAmount()))
throw new EnsException(EnsErrCd.INVALID_DATA
, String.format("납부 가능 금액을 초과했습니다. (요청금액:%s, 실제금액:%s)", totalPayAmount, vKakaoNoticeInfo.getAmount())
, PayUseSysResCd.OVERPAYABLE_AMOUNT);
if (CmmnUtil.isEmpty(vKakaoNoticeInfo.getPayExpireDate()))
throw new EnsException(EnsErrCd.INVALID_DATA
, "납부기한의 값이 비어있습니다."
, PayUseSysResCd.EXPIRED_DATE);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
if (Integer.parseInt(vKakaoNoticeInfo.getPayExpireDate()) < Integer.parseInt(simpleDateFormat.format(new Date())))
throw new EnsException(EnsErrCd.INVALID_DATA
, "납부기한이 경과한 자료 입니다."
, PayUseSysResCd.EXPIRED_DATE);
return vKakaoNoticeInfo;
}
private PayApiRespDTO<Map<String, Object>> createRespData() {
return PayApiRespDTO.<Map<String, Object>>okBuilder().build();
}
@Override
public PayApiRespDTO<Map<String, Object>> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
PayApiRespDTO<Map<String, Object>> payApiRespDTO = (PayApiRespDTO<Map<String, Object>>) data.get(DataKeys.payApiRespDTO.name());
return payApiRespDTO;
} else {
if (e.getData() != null && e.getData() instanceof PayUseSysResCd) {
PayUseSysResCd resCode = (PayUseSysResCd) e.getData();
return PayApiRespDTO.<Map<String, Object>>errBuilder()
.resCode(resCode.getCode())
.message(resCode.getCodeNm())
.build();
} else {
return PayApiRespDTO.<Map<String, Object>>errBuilder()
.resCode(PayUseSysResCd.FAILED_CHECK_INFO.getCode())
.message(PayUseSysResCd.FAILED_CHECK_INFO.getCodeNm())
.build();
}
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
String billerUserKey = (String) reqData.get("billerUserKey");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.naverPay)
.hisSeCd(PayUseSysHisSeCd.payAble)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,51 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.utils.MapDeserailizer;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.nv.entity.BillNvEasyPay;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayCancelService;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.model.PayCancelData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Map;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupNvPayCancelService implements PayCancelService<PayCancelData<BillNvEasyPay>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>> {
private final JPAQueryFactory query;
private Gson gson = new GsonBuilder().registerTypeAdapter(Map.class, new MapDeserailizer()).create();
@Override
public PayCancelData<BillNvEasyPay> getData(Map<String, Object> reqParam) {
return null;
}
@Override
public void validate(Map<String, Object> reqParam, PayCancelData<BillNvEasyPay> data) {
}
@Override
public void callApi(Map<String, Object> reqParam, PayCancelData<BillNvEasyPay> data) {
}
@Override
public PayApiRespDTO<Map<String, Object>> generateResult(Map<String, Object> reqParam, PayCancelData<BillNvEasyPay> data, EnsException e) {
return null;
}
@Override
public void saveHist(Map<String, Object> reqParam, PayCancelData<BillNvEasyPay> data, EnsException e) {
}
}

@ -0,0 +1,229 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoRepository;
import cokr.xit.ens.biz.iup.domain.repository.VKakaoNoticeInfoSnRepository;
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.nv.service.process.code.NvEpCtgyIdCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.nv.service.process.model.NvPayNoticeRespData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.nv.service.process.model.config.notice.ProductItem;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayNoticeService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupNvPayNoticeService implements PayNoticeService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<NvPayNoticeRespData>> {
private final JPAQueryFactory query;
private final VKakaoNoticeInfoSnRepository vKakaoNoticeInfoSnRepository;
private final VKakaoNoticeInfoRepository vKakaoNoticeInfoRepository;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
@Value("${contract.naver.pay.easy.api.validate.host}")
private String BILL_HOST;
@Value("${contract.naver.pay.easy.api.validate.prepay}")
private String BILL_PAYABLE_URL;
private enum DataKeys {
tbInputDataXit,
nvPayNoticeRespData,
responseJsonStr,
}
private enum PayDataKeys {
billerUserKey,
userBirth,
amount,
payExpireDate,
detailPasngChrgeSm,
detailAdiPasngChrgeSm,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final String billerUserKey = (String) reqData.getOrDefault("billerUserKey", "");
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String dataId = tbInputDataXit.getDataId();
if ("Y".equals(fsJob.getBpEntrustYn()) || "y".equals(fsJob.getBpEntrustYn())) {
VKakaoNoticeInfoSn vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId)
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 단순미납부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfoSn)
.map(entity -> toDataMap(entity))
.map(payData -> validateData(reqParam, payData))
.map(payData -> createRespData(tbInputDataXit, payData))
.map(kkoPayNoticeRespData -> loadRespData(data, kkoPayNoticeRespData))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "단순미납 응답데이터 생성에 실패했습니다."))
;
} else if ("N".equals(fsJob.getBpEntrustYn()) || "n".equals(fsJob.getBpEntrustYn())) {
if (dataId.length() < 20)
throw new EnsException(EnsErrCd.INVALID_DATA, "데이터ID가 20자리 미만 입니다.");
VKakaoNoticeInfo vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20))
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, "일치하는 강제징수부과 자료가 없습니다."));
Optional.of(vKakaoNoticeInfo)
.map(entity -> toDataMap(entity))
.map(map -> validateData(reqParam, map))
.map(map -> createRespData(tbInputDataXit, map))
.map(kkoPayNoticeRespData -> loadRespData(data, kkoPayNoticeRespData))
.orElseThrow(() -> new EnsException(EnsErrCd.FAILED_CREATE_RESPONSE_DATA, "강제징수 응답데이터 생성에 실패했습니다."))
;
} else {
throw new EnsException(EnsErrCd.INVALID_DATA, "위탁여부가 등록되지 않았습니다.");
}
}
private Map<PayDataKeys, Object> toDataMap(VKakaoNoticeInfoSn vKakaoNoticeInfoSn) {
Map<PayDataKeys, Object> payData = new HashMap<>();
payData.put(PayDataKeys.billerUserKey, vKakaoNoticeInfoSn.getDataId());
payData.put(PayDataKeys.userBirth, vKakaoNoticeInfoSn.getUserBirth());
payData.put(PayDataKeys.amount, vKakaoNoticeInfoSn.getAmount().intValue());
payData.put(PayDataKeys.payExpireDate, vKakaoNoticeInfoSn.getPayExpireDate());
payData.put(PayDataKeys.detailPasngChrgeSm, vKakaoNoticeInfoSn.getDetailPasngChrgeSm());
payData.put(PayDataKeys.detailAdiPasngChrgeSm, vKakaoNoticeInfoSn.getDetailAdiPasngChrgeSm());
return payData;
}
private Map<PayDataKeys, Object> toDataMap(VKakaoNoticeInfo vKakaoNoticeInfo) {
Map<PayDataKeys, Object> payData = new HashMap<>();
payData.put(PayDataKeys.billerUserKey, vKakaoNoticeInfo.getEnfrcLevMastrId());
payData.put(PayDataKeys.userBirth, vKakaoNoticeInfo.getUserBirth());
payData.put(PayDataKeys.amount, Integer.parseInt(vKakaoNoticeInfo.getAmount()));
payData.put(PayDataKeys.payExpireDate, vKakaoNoticeInfo.getPayExpireDate());
payData.put(PayDataKeys.detailPasngChrgeSm, vKakaoNoticeInfo.getDetailPasngChrgeSm());
payData.put(PayDataKeys.detailAdiPasngChrgeSm, vKakaoNoticeInfo.getDetailAdiPasngChrgeSm());
return payData;
}
private Map<PayDataKeys, Object> validateData(Map<String, Object> reqParam, Map<PayDataKeys, Object> payData) {
return payData;
}
private NvPayNoticeRespData createRespData(TbInputDataXit tbInputDataXit, Map<PayDataKeys, Object> payData) {
NvEpCtgyIdCd productSe = NvEpCtgyIdCd.ETC_ETC;
List<ProductItem> productItems = Arrays.asList(ProductItem.builder()
.categoryType(productSe.getCategoryTypeCd())
.categoryId(productSe.getCode().split("_")[1])
// .uid(tbInputDataXit.getLinkedUuid())
.uid(tbInputDataXit.getTbInputXit().getFsJob().getJobCd()) //2023.03.14 네이버페이 검수 결과 - 상품고유ID로 변경
.name(tbInputDataXit.getTbInputXit().getFsJob().getJobName())
.count(1)
.build());
Integer productCount = productItems.stream().map(productItem -> productItem.getCount()).reduce(Integer::sum).get();
return NvPayNoticeRespData.builder()
.productName(tbInputDataXit.getTbInputXit().getFsJob().getJobName())
.productCount(productCount)
.totalPayAmount((Integer) payData.get(PayDataKeys.amount))
.taxScopeAmount(0)
.taxExScopeAmount((Integer) payData.get(PayDataKeys.amount))
.environmentDepositAmount(0)
.productItems(productItems)
.returnUrl(this.BILL_HOST + this.BILL_PAYABLE_URL)
.build();
}
private NvPayNoticeRespData loadRespData(Map<String, Object> data, NvPayNoticeRespData kkoPayNoticeRespData) {
if (CmmnUtil.isEmpty(kkoPayNoticeRespData))
return null;
data.put(DataKeys.nvPayNoticeRespData.name(), kkoPayNoticeRespData);
data.put(DataKeys.responseJsonStr.name(), gson.toJson(kkoPayNoticeRespData));
return kkoPayNoticeRespData;
}
@Override
public PayApiRespDTO<NvPayNoticeRespData> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
NvPayNoticeRespData nvPayNoticeRespData = (NvPayNoticeRespData) data.get(DataKeys.nvPayNoticeRespData.name());
return PayApiRespDTO.<NvPayNoticeRespData>okBuilder()
.data(nvPayNoticeRespData)
.build();
} else {
String resCode = null;
String message = null;
switch (e.getErrCd()) {
case NO_DATA_FOUND:
resCode = PayUseSysResCd.NOT_FOUND_PAYDATA.getCode();
message = PayUseSysResCd.NOT_FOUND_PAYDATA.getCodeNm();
break;
default:
resCode = PayUseSysResCd.PAYDATA_FIND_FAILED.getCode();
message = PayUseSysResCd.PAYDATA_FIND_FAILED.getCodeNm();
break;
}
return PayApiRespDTO.<NvPayNoticeRespData>errBuilder()
.resCode(resCode)
.message(message)
.build();
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> reqData = (Map<String, Object>) reqParam.getOrDefault("data", new HashMap<>());
final String billerUserKey = (String) reqData.getOrDefault("billerUserKey", "");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.naverPay)
.hisSeCd(PayUseSysHisSeCd.payNotice)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,213 @@
package cokr.xit.ens.biz.iup.billpay.service.process;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.TbIupBillPayHistRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbNaverPayResultRepository;
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.nv.service.process.model.NvPayResultDetail;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.nv.service.process.model.NvPayResultReqData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.PayUseSysApi;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PaidTypeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysHisSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.PayUseSysResCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.model.PayApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.service.process.kit.PayResultService;
import cokr.xit.ens.modules.common.domain.support.FieldError;
import com.google.gson.Gson;
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;
@Slf4j
@RequiredArgsConstructor
@Service
public class IupNvPayResultService implements PayResultService<Map<String, Object>, Map<String, Object>, PayApiRespDTO<Map<String, Object>>> {
private final JPAQueryFactory query;
private final PayUseSysApi payUseSysApi;
private final TbNaverPayResultRepository tbNaverPayResultRepository;
private final TbIupBillPayHistRepository tbIupBillPayHistRepository;
private Gson gson = new Gson();
private enum DataKeys {
tbInputDataXit,
responseJsonStr,
}
@Override
public Map<String, Object> getData(Map<String, Object> reqParam) {
Map<String, Object> body = (Map<String, Object>) reqParam.getOrDefault("body", new HashMap<>());
Map<String, Object> detail = (Map<String, Object>) body.getOrDefault("detail", new HashMap<>());
String billerUserKey = (String) detail.get("merchantUserKey");
if (billerUserKey == null) billerUserKey = "";
TbInputDataXit tbInputDataXit = query.selectFrom(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit).fetchJoin()
.innerJoin(QTbInputXit.tbInputXit.fsJob, QFsJob.fsJob).fetchJoin()
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(billerUserKey))
.fetchOne();
Map<String, Object> data = new HashMap<>();
data.put(DataKeys.tbInputDataXit.name(), tbInputDataXit);
return data;
}
@Override
public void validate(Map<String, Object> reqParam, Map<String, Object> data) {
if (CmmnUtil.isEmpty(data.get(DataKeys.tbInputDataXit.name())))
throw new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm());
}
@Override
public void callApi(Map<String, Object> reqParam, Map<String, Object> data) {
TbInputDataXit tbInputDataXit = (TbInputDataXit) data.get(DataKeys.tbInputDataXit.name());
TbInputXit tbInputXit = tbInputDataXit.getTbInputXit();
FsJob fsJob = tbInputXit.getFsJob();
final String url = fsJob.getBpNvPayresultApi();
Optional.ofNullable(gson.fromJson(gson.toJson(reqParam.get("body")), NvPayResultReqData.class))
.map(nvPayResultReqData -> toEntity(nvPayResultReqData))
.map(entity -> savePayResult(entity))
.map(entity -> tbInputDataXit)
.filter(detail -> "Y".equals(detail.getTbInputXit().getFsJob()))
.map(vKakaoNoticeInfoSn -> payUseSysApi.payResult(url, reqParam, null))
.map(respnose -> loadRespData(data, respnose))
.map(response -> checkResponse(response))
;
}
private TbNaverPayResult toEntity(NvPayResultReqData nvPayResultReqData) {
NvPayResultDetail detail = nvPayResultReqData.getDetail();
final String billerUserKey = detail.getMerchantUserKey();
final String jobSe = "EL".equals(billerUserKey.substring(0, 2)) ? "2" : "1";
return TbNaverPayResult.builder()
.dataId(billerUserKey)
.jobSe(jobSe)
.paymentId(detail.getPaymentId())
.payHistId(detail.getPayHistId())
.merchantId(detail.getMerchantId())
.merchantName(detail.getMerchantName())
.merchantPayKey(detail.getMerchantPayKey())
.merchantUserKey(detail.getMerchantUserKey())
.admissionTypeCode(detail.getAdmissionTypeCode())
.admissionYmdt(detail.getAdmissionYmdt())
.tradeConfirmYmdt(detail.getTradeConfirmYmdt())
.admissionState(detail.getAdmissionState())
.totalPayAmount(detail.getTotalPayAmount())
.primaryPayAmount(detail.getPrimaryPayAmount())
.npointPayAmount(detail.getNpointPayAmount())
.giftCardAmount(detail.getGiftCardAmount())
.taxScopeAmount(detail.getTaxScopeAmount())
.taxExScopeAmount(detail.getTaxExScopeAmount())
.environmentDepositAmount(detail.getEnvironmentDepositAmount())
.primaryPayMeans(detail.getPrimaryPayMeans())
.cardCorpCode(detail.getCardCorpCode())
.cardNo(detail.getCardNo())
.cardAuthNo(detail.getCardAuthNo())
.cardInstCount(detail.getCardInstCount())
.usedCardPoint(detail.getUsedCardPoint())
.bankCorpCode(detail.getBankCorpCode())
.bankAccountNo(detail.getBankAccountNo())
.productName(detail.getProductName())
.settleExpected(detail.getSettleExpected())
.settleExpectAmount(detail.getSettleExpectAmount())
.payCommissionAmount(detail.getPayCommissionAmount())
.extraDeduction(detail.getExtraDeduction())
.useCfmYmdt(detail.getUseCfmYmdt())
.merchantExtraParameter(detail.getMerchantExtraParameter())
.userIdentifier(detail.getUserIdentifier())
.payResultProcessSttus("0")
// .creatDt()
.crtr("ENS_SYS")
// .updtDt()
// .updusr()
.build();
}
private TbNaverPayResult savePayResult(TbNaverPayResult entity) {
tbNaverPayResultRepository.save(entity);
return entity;
}
private ResponseEntity<String> loadRespData(Map<String, Object> data, ResponseEntity<String> response) {
data.put(DataKeys.responseJsonStr.name(), response.getBody());
return response;
}
private PayApiRespDTO<Map<String, Object>> checkResponse(ResponseEntity<String> response) {
if (!HttpStatus.OK.equals(response.getStatusCode()))
throw new EnsException(EnsErrCd.API_COMM_ERROR, EnsErrCd.API_COMM_ERROR.getCodeNm() + " " + response.getStatusCode().toString(), response.getBody());
PayApiRespDTO<Map<String, Object>> result = null;
try {
result = gson.fromJson(response.getBody(), PayApiRespDTO.class);
} catch (Exception ex) {
throw new EnsException(EnsErrCd.INVALID_RESPONSE, EnsErrCd.INVALID_RESPONSE.getCodeNm(), ex);
}
return result;
}
@Override
public PayApiRespDTO<Map<String, Object>> generateResult(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
if (e == null) {
return PayApiRespDTO.<Map<String, Object>>okBuilder().build();
} else {
return PayApiRespDTO.<Map<String, Object>>errDataBuilder()
.resCode(PayUseSysResCd.FAILED_SAVE_PAYRSLT.getCode())
.message(PayUseSysResCd.FAILED_SAVE_PAYRSLT.getCodeNm())
.data(null)
.build();
}
}
@Override
public void saveHist(Map<String, Object> reqParam, Map<String, Object> data, EnsException e) {
Map<String, Object> body = (Map<String, Object>) reqParam.getOrDefault("body", new HashMap<>());
Map<String, Object> detail = (Map<String, Object>) body.getOrDefault("detail", new HashMap<>());
String billerUserKey = (String) detail.get("merchantUserKey");
String errorCode = null;
String errorMessage = null;
if (e != null) {
errorCode = e.getErrCd().getCode();
errorMessage = String.format("%s %s", e.getMessage(), CmmnUtil.printStackTraceToString(e));
}
TbIupBillPayHist tbIupBillPayHist = TbIupBillPayHist.builder()
.dataId(billerUserKey)
.paidType(PaidTypeCd.naverPay)
.hisSeCd(PayUseSysHisSeCd.payResult)
.requestData(gson.toJson(reqParam))
.responseData((String) data.get(DataKeys.responseJsonStr.name()))
.error(FieldError.initBuilder()
.errorCode(errorCode)
.errorMessage(errorMessage)
.build())
.build();
tbIupBillPayHistRepository.save(tbIupBillPayHist);
}
}

@ -0,0 +1,47 @@
package cokr.xit.ens.biz.iup.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
* <ul>
* <li> : </li>
* <li> : </li>
* <li>: 2022. 2. 15. 3:51:43
* </ul>
* @author
*/
public enum IupPrcsCd implements CodeMapperType {
TGRG("대상등록중")
,TGRI("대상이관등록대기")
,TGRF("대상등록실패")
,TGRC("대상등록완료")
,GRUR("결제URL생성중")
,GRUC("결제URL생성완료")
,CICV("변환대상입수")
,CICC("변환대상입수완료")
,COMP("변환완료")
,INCM("입수중")
,IPCP("입수완료")
,FAIL("입수오류")
;
private final String code;
private final String codeNm;
IupPrcsCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
}

@ -0,0 +1,51 @@
package cokr.xit.ens.biz.iup.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
* <ul>
* <li> : </li>
* <li> : </li>
* <li>: 2022. 3. 2. 3:51:43
* </ul>
* @author
*/
public enum IupSendSttusCd implements CodeMapperType {
TALK_SEND("알림톡발송")
,SMS_SEND("SMS발송")
,READY("송신 준비")
,NOMB("카카오 비회원")
,DENY("카카오 거부")
,SEND("카카오 송신")
,RECV("카카오 수신")
,SIGN("카카오 서명")
,NV_NOMB("네이버 비회원")
,NV_DENY("네이버 거부")
,NV_SEND("네이버 송신")
,NV_RECV("네이버 수신")
,NV_SIGN("네이버 서명")
,FAIL("송신오류")
;
private final String code;
private final String codeNm;
IupSendSttusCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
}

@ -0,0 +1,37 @@
package cokr.xit.ens.biz.iup.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
* <ul>
* <li> : </li>
* <li> : </li>
* <li>: 2022. 6. 29. 3:51:43
* </ul>
* @author
*/
public enum IupSendTrySttusCd implements CodeMapperType {
TRYING("시도중")
, CMPLT("완료")
;
private final String code;
private final String codeNm;
IupSendTrySttusCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
}

@ -0,0 +1,37 @@
package cokr.xit.ens.biz.iup.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
* <ul>
* <li> : </li>
* <li> : </li>
* <li>: 2022. 3. 2. 3:51:43
* </ul>
* @author
*/
public enum IupSendTypeCd implements CodeMapperType {
NI("알림톡")
,KP("인증톡")
;
private final String code;
private final String codeNm;
IupSendTypeCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
}

@ -0,0 +1,113 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "fs_job", schema = "", catalog = "")
public class FsJob {
@Id
@Column(name = "job_cd", nullable = false, length = 10)
private String jobCd;
@Column(name = "job_name", nullable = true)
private String jobName;
@Column(name = "job_desc", nullable = true)
private String jobDesc;
@Column(name = "enc_phone_no_yn", nullable = true)
private String encPhoneNoYn;
@Column(name = "enc_name_yn", nullable = true)
private String encNameYn;
@Column(name = "enc_birthday_yn", nullable = true)
private String encBirthdayYn;
@Column(name = "unsube_use_yn", nullable = true)
private String unsubeUseYn;
@Column(name = "unsube_type", nullable = true)
private String unsubeType;
@Column(name = "use_yn", nullable = true)
private String useYn;
@Column(name = "reg_id", nullable = true)
private String regId;
@Column(name = "reg_dt", nullable = true)
private java.sql.Date regDt;
@Column(name = "upd_id", nullable = true)
private String updId;
@Column(name = "upd_dt", nullable = true)
private java.sql.Date updDt;
@Column(name = "org_cd", nullable = true)
private String orgCd;
@Column(name = "call_center_no", nullable = true)
private String callCenterNo;
@Column(name = "redirect_url", nullable = true)
private String redirectUrl;
@Column(name = "template_cd", nullable = true)
private String templateCd;
/* =================================================
* 2023.02.14.
================================================= */
@Column(name = "bp_entrust_yn", nullable = true, length = 1)
@Setter
private String bpEntrustYn;
@Column(name = "bp_kko_prepay_api", nullable = true)
@Setter
private String bpKkoPrepayApi;
@Column(name = "bp_kko_payresult_api", nullable = true)
@Setter
private String bpKkoPayresultApi;
@Column(name = "bp_nv_prepay_api", nullable = true)
@Setter
private String bpNvPrepayApi;
@Column(name = "bp_nv_payresult_api", nullable = true)
@Setter
private String bpNvPayresultApi;
}

@ -0,0 +1,237 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_enfrc_lev_mastr", schema = "", catalog = "")
public class TbEnfrcLevMastr {
@Id
@Column(name = "enfrc_lev_mastr_id")
private String enfrcLevMastrId;
@Column(name = "enfrc_lev_year")
private String enfrcLevYear;
@Column(name = "enfrc_lev_tme")
private String enfrcLevTme;
@Column(name = "enfrc_lev_sn")
private String enfrcLevSn;
@Column(name = "pvtcpt_road_sctn_id")
private String pvtcptRoadSctnId;
@Column(name = "vhcle_no")
private String vhcleNo;
@Column(name = "dfltr_id")
private String dfltrId;
@Column(name = "pasng_chrge_sm")
private Long pasngChrgeSm;
@Column(name = "adi_pasng_chrge_sm")
private Long adiPasngChrgeSm;
@Column(name = "npy_pasng_chrge_sm")
private Long npyPasngChrgeSm;
@Column(name = "npy_co_sm")
private Integer npyCoSm;
@Column(name = "npy_occrrnc_begin_de")
private String npyOccrrncBeginDe;
@Column(name = "npy_occrrnc_end_de")
private String npyOccrrncEndDe;
@Column(name = "elctrn_ntic_sndng_posbl_at")
private String elctrnNticSndngPosblAt;
@Column(name = "n_bank_virtl_acnut_no")
private String nBankVirtlAcnutNo;
@Column(name = "k_bank_virtl_acnut_no")
private String kBankVirtlAcnutNo;
@Column(name = "w_bank_virtl_acnut_no")
private String wBankVirtlAcnutNo;
@Column(name = "s_bank_virtl_acnut_no")
private String sBankVirtlAcnutNo;
@Column(name = "pay_tmlmt")
private String payTmlmt;
@Column(name = "enfrc_lev_reqst_dt")
private String enfrcLevReqstDt;
@Column(name = "enfrc_lev_applcnt")
private String enfrcLevApplcnt;
@Column(name = "enfrc_lev_outset_reqst_dt")
private String enfrcLevOutsetReqstDt;
@Column(name = "enfrc_lev_outset_applcnt")
private String enfrcLevOutsetApplcnt;
@Column(name = "enfrc_lev_reqst_process_dt")
private String enfrcLevReqstProcessDt;
@Column(name = "enfrc_lev_reqst_opetr")
private String enfrcLevReqstOpetr;
@Column(name = "enfrc_lev_outset_process_dt")
private String enfrcLevOutsetProcessDt;
@Column(name = "enfrc_lev_outset_opetr")
private String enfrcLevOutsetOpetr;
@Column(name = "enfrc_lev_last_process_resn")
private String enfrcLevLastProcessResn;
@Column(name = "enfrc_lev_last_process_dt")
private String enfrcLevLastProcessDt;
@Column(name = "enfrc_lev_last_opetr")
private String enfrcLevLastOpetr;
@Column(name = "enfrc_lev_mastr_process_sttus")
private String enfrcLevMastrProcessSttus;
@Column(name = "enfrc_lev_wthdraw_at")
private String enfrcLevWthdrawAt;
@Column(name = "enfrc_lev_wthdraw_mastr_id")
private String enfrcLevWthdrawMastrId;
@Column(name = "creat_dt")
private Date creatDt;
@Column(name = "crtr")
private String crtr;
@Column(name = "updt_dt")
private Date updtDt;
@Column(name = "updusr")
private String updusr;
@Column(name = "delete_at")
private String deleteAt;
@Column(name = "delete_dt")
private Date deleteDt;
@Column(name = "dltr")
private String dltr;
@Column(name = "job_sttus")
private String jobSttus;
@Column(name = "job_tmlmt")
private String jobTmlmt;
@Column(name = "rciv_pasng_chrge_sm")
private Long rcivPasngChrgeSm;
@Column(name = "rciv_adi_pasng_chrge_sm")
private Long rcivAdiPasngChrgeSm;
@Column(name = "rciv_npy_pasng_chrge_sm")
private Long rcivNpyPasngChrgeSm;
@Column(name = "rciv_co_sm")
private Integer rcivCoSm;
@Column(name = "blce_pasng_chrge_sm")
private Long blcePasngChrgeSm;
@Column(name = "blce_adi_pasng_chrge_sm")
private Long blceAdiPasngChrgeSm;
@Column(name = "blce_npy_pasng_chrge_sm")
private Long blceNpyPasngChrgeSm;
@Column(name = "blce_co_sm")
private Integer blceCoSm;
@Column(name = "dfct_dsps_pasng_chrge_sm")
private Long dfctDspsPasngChrgeSm;
@Column(name = "dfct_dsps_adi_pasmny_sm")
private Long dfctDspsAdiPasmnySm;
@Column(name = "dfct_dsps_npy_pasmny_sm")
private Long dfctDspsNpyPasmnySm;
@Column(name = "dfct_dsps_co_sm")
private Integer dfctDspsCoSm;
@Column(name = "part_rciv_at")
private String partRcivAt;
@Column(name = "ntcn_sndng_de")
private String ntcnSndngDe;
@Column(name = "ntcn_sndng_process_sttus")
private String ntcnSndngProcessSttus;
@Column(name = "crtfc_sndng_de")
private String crtfcSndngDe;
@Column(name = "crtfc_sndng_process_sttus")
private String crtfcSndngProcessSttus;
@Column(name = "urgsht_sndng_de")
private String urgshtSndngDe;
@Column(name = "urgsht_dlvr_sttus")
private String urgshtDlvrSttus;
@Column(name = "urgsht_scd_sndng_de")
private String urgshtScdSndngDe;
@Column(name = "urgsht_scd_dlvr_sttus")
private String urgshtScdDlvrSttus;
@Column(name = "seizr_prvntc_sndng_de")
private String seizrPrvntcSndngDe;
@Column(name = "seizr_prvntc_sndng_process_stt")
private String seizrPrvntcSndngProcessStt;
@Column(name = "seizr_de")
private String seizrDe;
@Column(name = "tkbak_de")
private String tkbakDe;
@Column(name = "seizr_relis_de")
private String seizrRelisDe;
@Column(name = "emrgncy_relis_de")
private String emrgncyRelisDe;
@Column(name = "tkbak_scd_de")
private String tkbakScdDe;
@Column(name = "rntcar_entrps_nm")
private String rntcarEntrpsNm;
@Column(name = "lessee_change_de")
private String lesseeChangeDe;
}

@ -0,0 +1,116 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Date;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_enfrc_lev_rciv", schema = "", catalog = "")
public class TbEnfrcLevRciv {
@Id
@Column(name = "enfrc_lev_rciv_id", nullable = false, length = 12)
private String enfrcLevRcivId;
@Column(name = "enfrc_lev_mastr_id", nullable = true, length = 20)
private String enfrcLevMastrId;
@Column(name = "enfrc_lev_year", nullable = true, length = 4)
private String enfrcLevYear;
@Column(name = "enfrc_lev_tme", nullable = true, length = 1)
private String enfrcLevTme;
@Column(name = "pvtcpt_road_sctn_id", nullable = true, length = 4)
private String pvtcptRoadSctnId;
@Column(name = "rciv_de", nullable = true, length = 8)
private String rcivDe;
@Column(name = "rciv_time", nullable = true, length = 6)
private String rcivTime;
@Column(name = "rciv_pasng_chrge", nullable = true, precision = 0)
private Long rcivPasngChrge;
@Column(name = "rciv_adi_pasng_chrge", nullable = true, precision = 0)
private Long rcivAdiPasngChrge;
@Column(name = "rciv_npy_pasng_chrge", nullable = true, precision = 0)
private Long rcivNpyPasngChrge;
@Column(name = "virtl_acnut_bank_code", nullable = true, length = 3)
private String virtlAcnutBankCode;
@Column(name = "virtl_acnut_no", nullable = true, length = 20)
private String virtlAcnutNo;
@Column(name = "virtl_acnut_delng_esntl_no", nullable = true, length = 14)
private String virtlAcnutDelngEsntlNo;
@Column(name = "rciv_se_code", nullable = true, length = 1)
private String rcivSeCode;
@Column(name = "rciv_cardfa_se_code", nullable = true, length = 20)
private String rcivCardfaSeCode;
@Column(name = "creat_dt", nullable = true)
private Date creatDt;
@Column(name = "crtr", nullable = true, length = 50)
private String crtr;
@Column(name = "delete_at", nullable = true, length = 1)
private String deleteAt;
@Column(name = "delete_dt", nullable = true)
private Date deleteDt;
@Column(name = "dltr", nullable = true, length = 50)
private String dltr;
@Column(name = "enfrc_lev_id", nullable = true, length = 20)
private String enfrcLevId;
@Column(name = "excclc_stdr_de", nullable = true, length = 8)
private String excclcStdrDe;
@Column(name = "excclc_stdr_dt", nullable = true, length = 6)
private String excclcStdrDt;
}

@ -0,0 +1,86 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "TB_INPUT_DATA_BULK_TEST", schema = "", catalog = "")
public class TbInputDataBulkTest {
@Id
// @GeneratedValue(strategy=GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TbInputDataBulkTest_Generator")
@TableGenerator(table = "ens_seq_generator", name = "TbInputDataBulkTest_Generator"
,pkColumnName = "seq_name", pkColumnValue = "TbInputDataBulkTest_id"
,initialValue = 0, allocationSize = 200)
private Long id;
// @Id
@Column(name = "DATA_ID", nullable = false)
private String dataId;
@Column(name = "SID", nullable = true)
private String sid;
@Column(name = "NAME", nullable = true)
private String name;
@Column(name = "BIRTHDAY", nullable = true)
private String birthday;
@Column(name = "GENDER", nullable = true)
private String gender;
@Column(name = "MSG_DATA", nullable = true, length = 4000)
private String msgData;
@Column(name = "MSG_DTL_DATA", nullable = true)
@Lob
private String msgDtlData;
@Column(name = "REG_ID", nullable = false)
private String regId;
@Column(name = "REG_DT", nullable = false)
private java.sql.Date regDt;
@Column(name = "UPD_ID", nullable = true)
private String updId;
@Column(name = "UPD_DT", nullable = true)
private java.sql.Date updDt;
@Column(name = "PAY_STATUS_CD", nullable = true)
private String payStatusCd;
@Column(name = "PAY_URL", nullable = true)
private String payUrl;
@Column(name = "CAR_NO", nullable = true)
private String carNo;
}

@ -0,0 +1,96 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_input_data_xit", schema = "", catalog = "", indexes = {
@Index(name = "idx_TbInputDataXit_01", columnList = "linked_uuid")
})
public class TbInputDataXit {
@Id
@Column(name = "data_id", nullable = false)
private String dataId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "lnk_input_id")
private TbInputXit tbInputXit;
@Column(name = "sid", nullable = true)
private String sid;
@Column(name = "name", nullable = true)
private String name;
@Column(name = "birthday", nullable = true)
private String birthday;
@Column(name = "gender", nullable = true)
private String gender;
@Column(name = "msg_data", nullable = true, length = 4000)
private String msgData;
@Column(name = "msg_dtl_data", nullable = true)
@Lob
private String msgDtlData;
@Column(name = "reg_id", nullable = false)
private String regId;
@Column(name = "reg_dt", nullable = false)
private java.sql.Date regDt;
@Column(name = "upd_id", nullable = true)
private String updId;
@Column(name = "upd_dt", nullable = true)
private java.sql.Date updDt;
@Column(name = "pay_status_cd", nullable = true)
private String payStatusCd;
@Column(name = "pay_url", nullable = true)
private String payUrl;
@Column(name = "car_no", nullable = true)
private String carNo;
@Column(name = "moblphon_no", nullable = true)
private String moblphonNo;
@Column(name = "call_center_no", nullable = true)
private String callCenterNo;
@Column(name = "linked_uuid", length = 40)
@Setter
private String linkedUuid;
}

@ -0,0 +1,92 @@
package cokr.xit.ens.biz.iup.domain;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_input_xit", schema = "", catalog = "")
public class TbInputXit {
@Id
@Column(name = "lnk_input_id", nullable = false)
private Long lnkInputId;
@Column(name = "org_cd", nullable = false, length = 100)
private String orgCd;
@JoinColumn(name = "job_cd")
@ManyToOne(fetch = FetchType.LAZY)
private FsJob fsJob;
@Column(name = "tot_cnt", nullable = false)
private Long totCnt;
@Column(name = "prcs_cd", nullable = false)
@Enumerated(EnumType.STRING)
@Setter
private IupPrcsCd prcsCd;
@Column(name = "err_msg", nullable = true, length = 1000)
@Setter
private String errMsg;
@Column(name = "run_dt", nullable = false)
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime runDt;
@Column(name = "expires_dt", nullable = false)
private LocalDateTime expiresDt;
@Column(name = "send_type", nullable = false, length = 10)
@Enumerated(EnumType.STRING)
private IupSendTypeCd sendType;
@Column(name = "reg_id", nullable = false, length = 20)
private String regId;
@Column(name = "reg_dt", nullable = false)
private LocalDateTime regDt;
@Column(name = "upd_id", nullable = true, length = 20)
@Setter
private String updId;
@Column(name = "upd_dt", nullable = true)
@UpdateTimestamp
private LocalDateTime updDt;
@Column(name = "rcpt_dt", nullable = true, length = 30)
private String rcptDt;
@Column(name = "pay_expires_dt", nullable = false)
private LocalDateTime payExpiresDt;
}

@ -0,0 +1,33 @@
package cokr.xit.ens.biz.iup.domain;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.BillHistPayUseSysBaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import javax.persistence.*;
@Entity
@Getter
@ToString
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_iup_bill_pay_hist", schema = "", catalog = "", indexes = {
@Index(name = "idx_iup_bp_his_01", columnList = "data_id")
})
public class TbIupBillPayHist extends BillHistPayUseSysBaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "data_id", nullable = true)
private String dataId;
}

@ -0,0 +1,105 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_kakao_pay_result", schema = "", catalog = "")
public class TbKakaoPayResult {
@Id
@Column(name = "data_id", length = 30)
private String dataId;
@Column(name = "job_se", length = 1, nullable = true)
private String jobSe;
@Column(name = "pay_mn", length = 20, nullable = true)
private String payMn;
@Column(name = "pay_ty", length = 1, nullable = true)
private String payTy;
// @Column(name = "pay_detail1", length = 6, nullable = true)
@Column(name = "pay_detail1", length = 8, nullable = true)
private String payDetail1;
@Column(name = "pay_detail2", length = 20, nullable = true)
private String payDetail2;
@Column(name = "pay_detail3", length = 100, nullable = true)
private String payDetail3;
@Column(name = "pay_amount", length = 12, nullable = true)
private String payAmount;
@Column(name = "pay_fee_ty", length = 10, nullable = true)
private String payFeeTy;
@Column(name = "pay_fee_amount", length = 12, nullable = true)
private String payFeeAmount;
@Column(name = "pay_fee_vat", length = 12, nullable = true)
private String payFeeVat;
@Column(name = "excclc_prearnge_de", length = 8, nullable = true)
private String excclcPrearngeDe;
@Column(name = "pay_dt", length = 14, nullable = true)
private String payDt;
@Column(name = "pay_id", length = 20, nullable = true)
private String payId;
@Column(name = "pay_result_process_sttus", length = 1, nullable = true)
private String payResultProcessSttus;
@CreationTimestamp
@Column(name = "creat_dt", nullable = true)
private LocalDateTime creatDt;
@Column(name = "crtr", length = 50, nullable = true)
private String crtr;
@UpdateTimestamp
@Column(name = "updt_dt", nullable = true)
private LocalDateTime updtDt;
@Column(name = "updusr", length = 50, nullable = true)
private String updusr;
}

@ -0,0 +1,159 @@
package cokr.xit.ens.biz.iup.domain;
import cokr.xit.ens.core.jpa.support.BooleanToYnConverter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_naver_pay_result", schema = "", catalog = "")
public class TbNaverPayResult {
@Id
@Column(name = "data_id", length = 30)
private String dataId;
@Column(name = "job_se", length = 1, nullable = true)
private String jobSe;
@Column(name = "payment_id", length = 50)
private String paymentId;
@Column(name = "pay_hist_id", length = 50)
private String payHistId;
@Column(name = "merchant_id", length = 50)
private String merchantId;
@Column(name = "merchant_name", length = 50)
private String merchantName;
@Column(name = "merchant_pay_key", length = 64)
private String merchantPayKey;
@Column(name = "merchant_user_key", length = 50)
private String merchantUserKey;
@Column(name = "admission_type_code", length = 2)
private String admissionTypeCode;
@Column(name = "admission_ymdt", length = 14)
private String admissionYmdt;
@Column(name = "trade_confirm_ymdt", length = 50)
private String tradeConfirmYmdt;
@Column(name = "admission_state", length = 10)
private String admissionState;
@Column(name = "total_pay_amount")
private Integer totalPayAmount;
@Column(name = "primary_pay_amount")
private Integer primaryPayAmount;
@Column(name = "npoint_pay_amount")
private Integer npointPayAmount;
@Column(name = "gift_card_amount")
private Integer giftCardAmount;
@Column(name = "tax_scope_amount")
private Integer taxScopeAmount;
@Column(name = "tax_ex_scope_amount")
private Integer taxExScopeAmount;
@Column(name = "environment_deposit_amount")
private Integer environmentDepositAmount;
@Column(name = "primary_pay_means", length = 10)
private String primaryPayMeans;
@Column(name = "card_corp_code", length = 10)
private String cardCorpCode;
@Column(name = "card_no", length = 50)
private String cardNo;
@Column(name = "card_auth_no", length = 30)
private String cardAuthNo;
@Column(name = "card_inst_count")
private Integer cardInstCount;
@Column(name = "used_card_point", length = 1)
@Convert(converter = BooleanToYnConverter.class)
private Boolean usedCardPoint;
@Column(name = "bank_corp_code", length = 10)
private String bankCorpCode;
@Column(name = "bank_account_no", length = 50)
private String bankAccountNo;
@Column(name = "product_name", length = 128)
private String productName;
@Column(name = "settle_expected", length = 1)
@Convert(converter = BooleanToYnConverter.class)
private Boolean settleExpected;
@Column(name = "settle_expect_amount")
private Integer settleExpectAmount;
@Column(name = "pay_commission_amount")
private Integer payCommissionAmount;
@Column(name = "extra_deduction", length = 1)
@Convert(converter = BooleanToYnConverter.class)
private Boolean extraDeduction;
@Column(name = "use_cfm_ymdt", length = 8)
private String useCfmYmdt;
@Column(name = "merchant_extra_parameter", length = 400)
private String merchantExtraParameter;
@Column(name = "user_identifier", length = 44)
private String userIdentifier;
@Column(name = "pay_result_process_sttus", length = 1, nullable = true)
private String payResultProcessSttus;
@CreationTimestamp
@Column(name = "creat_dt", nullable = true)
private LocalDateTime creatDt;
@Column(name = "crtr", length = 50, nullable = true)
private String crtr;
@UpdateTimestamp
@Column(name = "updt_dt", nullable = true)
private LocalDateTime updtDt;
@Column(name = "updusr", length = 50, nullable = true)
private String updusr;
}

@ -0,0 +1,97 @@
package cokr.xit.ens.biz.iup.domain;
import cokr.xit.ens.biz.iup.code.IupSendSttusCd;
import cokr.xit.ens.biz.iup.code.IupSendTrySttusCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.ids.TbSendResultIds;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_send_result_v2", schema = "", catalog = "")
@IdClass(TbSendResultIds.class)
public class TbSendResult {
@Id
@Column(name = "lnk_input_id", nullable = false)
private Long lnkInputId;
@Id
@Column(name = "data_id", nullable = false)
private String dataId;
@Id
@Column(name = "prcs_odr", nullable = false)
private String prcsOdr;
@Column(name = "send_sttus_cd", nullable = true)
@Enumerated(EnumType.STRING)
private IupSendSttusCd sendSttusCd;
@Column(name = "send_try_sttus_cd", nullable = true)
@Enumerated(EnumType.STRING)
private IupSendTrySttusCd sendTrySttusCd;
@Column(name = "send_type", nullable = true)
@Enumerated(EnumType.STRING)
private IupSendTypeCd sendType;
@Column(name = "run_dt", nullable = true)
private LocalDateTime runDt;
@Column(name = "biz_send_dt", nullable = true)
private LocalDateTime bizSendDt;
@Column(name = "biz_recv_dt", nullable = true)
private LocalDateTime bizRecvDt;
@Column(name = "biz_read_dt", nullable = true)
private LocalDateTime bizReadDt;
@Column(name = "biz_err_msg", nullable = true, length = 1000)
private String bizErrMsg;
@Column(name = "reg_id", nullable = true)
private String regId;
@Column(name = "reg_dt", nullable = true)
@CreationTimestamp
private LocalDateTime regDt;
@Column(name = "lastUpdt", nullable = true)
@UpdateTimestamp
private LocalDateTime lastUpdt;
@Column(name = "expires_dt", nullable = true)
private LocalDateTime expiresDt;
@Column(name = "prcs_yn", nullable = true)
private String prcsYn;
}

@ -0,0 +1,41 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "V_KAKAO_NOTICE_INFO")
public class VKakaoNoticeInfo {
@Id
private String enfrcLevMastrId;
private String userBirth;
private String amount;
private String payExpireDate;
private String detailPasngChrgeSm;
private String detailAdiPasngChrgeSm;
}

@ -0,0 +1,43 @@
package cokr.xit.ens.biz.iup.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
import java.util.Objects;
@Entity
//@Data
@Getter
@ToString
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "v_kakao_notice_info_sn", schema = "", catalog = "")
public class VKakaoNoticeInfoSn {
@Id
@Column(name = "data_id", nullable = true, length = 24)
private String dataId;
@Column(name = "user_birth", nullable = true, length = 4000)
private String userBirth;
@Column(name = "AMOUNT", nullable = true, precision = 0)
private Long amount;
@Column(name = "pay_expire_date", nullable = true, length = 8)
private String payExpireDate;
@Column(name = "detail_pasng_chrge_sm", nullable = true, precision = 0)
private Long detailPasngChrgeSm;
@Column(name = "detail_adi_pasng_chrge_sm", nullable = true, precision = 0)
private Long detailAdiPasngChrgeSm;
}

@ -0,0 +1,28 @@
package cokr.xit.ens.biz.iup.domain.ids;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Column;
import java.io.Serializable;
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
public class TbSendResultIds implements Serializable {
@Column(name = "lnk_input_id", nullable = false)
private Long lnkInputId;
@Column(name = "data_id", nullable = false)
private String dataId;
@Column(name = "prcs_odr", nullable = false)
private String prcsOdr;
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.FsJob;
import org.springframework.data.jpa.repository.JpaRepository;
public interface FsJobRepository extends JpaRepository<FsJob, String> {
}

@ -0,0 +1,12 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbEnfrcLevMastr;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface TbEnfrcLevMastrRepository extends JpaRepository<TbEnfrcLevMastr, String> {
Optional<TbEnfrcLevMastr> findByEnfrcLevMastrIdAndEnfrcLevMastrProcessSttusAndDeleteAt(String enfrcLevMastrId, String enfrcLevMastrProcessSttus, String deleteAt);
}

@ -0,0 +1,12 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbEnfrcLevRciv;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface TbEnfrcLevRcivRepository extends JpaRepository<TbEnfrcLevRciv, String> {
List<TbEnfrcLevRciv> findAllByEnfrcLevMastrIdAndDeleteAt(String enfrcLevMastrId, String deleteAt);
}

@ -0,0 +1,8 @@
package cokr.xit.ens.biz.iup.domain.repository;
import java.util.List;
public interface TbInputDataBulkTestCustomRepository<T> {
public void saveAll(List<T> list);
}

@ -0,0 +1,75 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbInputDataBulkTest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Repository
@RequiredArgsConstructor
public class TbInputDataBulkTestCustomRepositoryImpl implements TbInputDataBulkTestCustomRepository<TbInputDataBulkTest>{
private final JdbcTemplate jdbcTemplate;
@Value("${spring.jpa.properties.hibernate.jdbc.batch_size}")
private int batchSize;
@Override
public void saveAll(List<TbInputDataBulkTest> list) {
int batchCount = 0;
List<TbInputDataBulkTest> subItems = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
subItems.add(list.get(i));
if ((i + 1) % batchSize == 0) {
batchCount = batchInsert(batchSize, batchCount, subItems);
}
}
if (!subItems.isEmpty()) {
batchCount = batchInsert(batchSize, batchCount, subItems);
}
log.info("batchCount: " + batchCount);
}
private int batchInsert(int batchSize, int batchCount, List<TbInputDataBulkTest> list) {
// jdbcTemplate.batchUpdate("INSERT INTO tb_input_data_bulk_test (birthday, car_no, data_id, gender, msg_data, msg_dtl_data, name, pay_status_cd, pay_url, reg_dt, reg_id, sid, upd_dt, upd_id, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
jdbcTemplate.batchUpdate("INSERT INTO tb_input_data_bulk_test (birthday, car_no, data_id, gender, msg_data, msg_dtl_data, name, pay_status_cd, pay_url, reg_dt, reg_id, sid, upd_dt, upd_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setString(1, list.get(i).getBirthday());
ps.setString(2, list.get(i).getCarNo());
ps.setString(3, list.get(i).getDataId());
ps.setString(4, list.get(i).getGender());
ps.setString(5, list.get(i).getMsgData());
ps.setString(6, list.get(i).getMsgDtlData());
ps.setString(7, list.get(i).getName());
ps.setString(8, list.get(i).getPayStatusCd());
ps.setString(9, list.get(i).getPayUrl());
ps.setDate(10, list.get(i).getRegDt());
ps.setString(11, list.get(i).getRegId());
ps.setString(12, list.get(i).getSid());
ps.setDate(13, list.get(i).getUpdDt());
ps.setString(14, list.get(i).getUpdId());
// ps.setLong(15, list.get(i).getId());
}
@Override
public int getBatchSize() {
return list.size();
}
});
list.clear();
batchCount++;
return batchCount;
}
}

@ -0,0 +1,7 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbInputDataBulkTest;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbInputDataBulkTestRepository extends JpaRepository<TbInputDataBulkTest, String> {
}

@ -0,0 +1,22 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import java.util.List;
import java.util.Optional;
public interface TbInputDataXitCustomRepository<T> {
Optional<TbInputDataXit> findFetchByDataId(String dataId);
List<T> findAllFetchByLnkInputId(Long lnkInputId);
String findDataIdFirstByLnkInputId(Long lnkInputId);
Optional<Long> findLastSendMastIdByLnkInputIdAndSendType(Long lnkInputId, IupSendTypeCd sendTypeCd);
List<TbInputDataXit> findAllByNoFwdPayResult();
}

@ -0,0 +1,118 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillReqSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillSeCd;
import com.querydsl.core.types.dsl.DateTemplate;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
import static cokr.xit.ens.biz.iup.domain.QFsJob.fsJob;
import static cokr.xit.ens.biz.iup.domain.QTbInputDataXit.tbInputDataXit;
import static cokr.xit.ens.biz.iup.domain.QTbInputXit.tbInputXit;
import static cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.QBillHist.billHist;
import static cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.QIntgrnSendDetail.intgrnSendDetail;
import static cokr.xit.ens.modules.kkoalimtalk.domain.QSendDetailKkoAlimtalk.sendDetailKkoAlimtalk;
@Slf4j
@Repository
@RequiredArgsConstructor
public class TbInputDataXitCustomRepositoryImpl implements TbInputDataXitCustomRepository<TbInputDataXit> {
private final JPAQueryFactory query;
@Override
public Optional<TbInputDataXit> findFetchByDataId(String dataId) {
return Optional.ofNullable(query.selectFrom(tbInputDataXit)
.innerJoin(tbInputDataXit.tbInputXit, tbInputXit)
.fetchJoin()
.innerJoin(tbInputXit.fsJob, fsJob)
.fetchJoin()
.where(tbInputDataXit.dataId.eq(dataId))
.fetchOne());
}
@Override
public List<TbInputDataXit> findAllFetchByLnkInputId(Long lnkInputId) {
return query.selectFrom(tbInputDataXit)
.innerJoin(tbInputDataXit.tbInputXit, tbInputXit).fetchJoin()
.innerJoin(tbInputXit.fsJob, fsJob).fetchJoin()
.where(tbInputDataXit.tbInputXit.lnkInputId.eq(lnkInputId))
.fetch();
}
@Override
public String findDataIdFirstByLnkInputId(Long lnkInputId) {
return query.select(tbInputDataXit.dataId)
.from(tbInputDataXit)
.where(tbInputDataXit.tbInputXit.lnkInputId.eq(lnkInputId))
.fetchFirst();
}
@Override
public Optional<Long> findLastSendMastIdByLnkInputIdAndSendType(Long lnkInputId, IupSendTypeCd sendTypeCd) {
if (IupSendTypeCd.KP.equals(sendTypeCd))
// return Optional.ofNullable(query.select(sendDetailKkoMydoc.sendMast.sendMastId)
// .from(sendDetailKkoMydoc)
//// .where(sendDetailKkoMydoc.propExternalDocumentUuid.in(findDataIdsByLnkInputId(lnkInputId)))
// .where(sendDetailKkoMydoc.propExternalDocumentUuid.eq(findExternalDocumentUuidByLnkInputId(lnkInputId)))
// .groupBy(sendDetailKkoMydoc.sendMast.sendMastId)
// .orderBy(sendDetailKkoMydoc.sendMast.sendMastId.desc())
// .fetchFirst());
return Optional.ofNullable(query.select(intgrnSendDetail.intgrnSendMast.intSendMastId)
.from(intgrnSendDetail)
.where(intgrnSendDetail.linkedUuid.eq(findExternalDocumentUuidByLnkInputId(lnkInputId)))
.groupBy(intgrnSendDetail.intgrnSendMast.intSendMastId)
.orderBy(intgrnSendDetail.intgrnSendMast.intSendMastId.desc())
.fetchFirst());
else if (IupSendTypeCd.NI.equals(sendTypeCd))
return Optional.ofNullable(query.select(sendDetailKkoAlimtalk.sendMast.sendMastId)
.from(sendDetailKkoAlimtalk)
// .where(sendDetailKkoAlimtalk.msgIdx.in(findDataIdsByLnkInputId(lnkInputId)))
.where(sendDetailKkoAlimtalk.msgIdx.eq(findExternalDocumentUuidByLnkInputId(lnkInputId)))
.groupBy(sendDetailKkoAlimtalk.sendMast.sendMastId)
.orderBy(sendDetailKkoAlimtalk.sendMast.sendMastId.desc())
.fetchFirst());
else
return Optional.ofNullable(null);
}
private String findExternalDocumentUuidByLnkInputId(Long lnkInputId) {
return query.select(tbInputDataXit.linkedUuid)
.from(tbInputDataXit)
.where(tbInputDataXit.tbInputXit.lnkInputId.eq(lnkInputId))
.fetchFirst();
}
@Override
public List<TbInputDataXit> findAllByNoFwdPayResult() {
LocalDateTime fromDate = LocalDateTime.of(2022, 07, 04, 00, 00, 00);
LocalDateTime toDate = LocalDateTime.of(2022, 07, 05, 15, 00, 00);
DateTemplate from = Expressions.dateTemplate(LocalDateTime.class, "TO_DATE({0}, {1})", fromDate.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")), "yyyyMMddHH24miss");
DateTemplate to = Expressions.dateTemplate(LocalDateTime.class, "TO_DATE({0}, {1})", toDate.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")), "yyyyMMddHH24miss");
return query.select(tbInputDataXit)
.from(tbInputDataXit)
.innerJoin(tbInputDataXit.tbInputXit, tbInputXit).fetchJoin()
// .innerJoin(kkoBillHist).on(kkoBillHist.billerUserKey.eq(tbInputDataXit.linkedUuid)).fetchJoin()
.innerJoin(billHist).on(billHist.billSe.eq(BillSeCd.bpKko).and(billHist.linkedUuid.eq(tbInputDataXit.linkedUuid))).fetchJoin()
.where(
billHist.reqSe.eq(BillReqSeCd.US_PAYRSLT)
.and(tbInputXit.runDt.between(from, to))
.and(billHist.registDt.between(from, to))
)
.fetch();
}
}

@ -0,0 +1,16 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
public interface TbInputDataXitRepository extends JpaRepository<TbInputDataXit, String>, TbInputDataXitCustomRepository<TbInputDataXit> {
List<TbInputDataXit> findAllByTbInputXit(TbInputXit tbInputXit);
Optional<TbInputDataXit> findByLinkedUuid(String linkedUuid);
}

@ -0,0 +1,13 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import java.util.List;
import java.util.Optional;
public interface TbInputXitCustomRepository<T> {
Optional<TbInputXit> findByPrcsCdAndSendTypeAndId(IupPrcsCd prcsCd, IupSendTypeCd sendType, Long lnkInputId);
List<TbInputXit> findAllByPrcsCdInAndSendType(List<IupPrcsCd> prcsCds, IupSendTypeCd sendType);
}

@ -0,0 +1,51 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import static cokr.xit.ens.biz.iup.domain.QFsJob.fsJob;
import static cokr.xit.ens.biz.iup.domain.QTbInputXit.tbInputXit;
@Slf4j
@Repository
@RequiredArgsConstructor
public class TbInputXitCustomRepositoryImpl implements TbInputXitCustomRepository<TbInputXit>{
private final JPAQueryFactory query;
@Override
public Optional<TbInputXit> findByPrcsCdAndSendTypeAndId(IupPrcsCd prcsCd, IupSendTypeCd sendType, Long lnkInputId) {
return Optional.ofNullable(query.selectFrom(tbInputXit)
.innerJoin(tbInputXit.fsJob, fsJob)
.fetchJoin()
.where(
tbInputXit.prcsCd.eq(prcsCd)
.and(tbInputXit.sendType.eq(sendType))
.and(tbInputXit.lnkInputId.eq(lnkInputId))
)
.fetchOne());
}
@Override
public List<TbInputXit> findAllByPrcsCdInAndSendType(List<IupPrcsCd> prcsCds, IupSendTypeCd sendType) {
return query.selectFrom(tbInputXit)
.innerJoin(tbInputXit.fsJob, fsJob)
.fetchJoin()
.where(
tbInputXit.prcsCd.in(prcsCds)
.and(tbInputXit.sendType.eq(sendType))
)
.fetch();
}
}

@ -0,0 +1,11 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface TbInputXitRepository extends JpaRepository<TbInputXit, Long>, TbInputXitCustomRepository<TbInputXit> {
List<TbInputXit> findAllByLnkInputIdIn(List<Long> lnkInputIds);
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbIupBillPayHist;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbIupBillPayHistRepository extends JpaRepository<TbIupBillPayHist, Long> {
}

@ -0,0 +1,8 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbKakaoPayResult;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbKakaoPayResultRepository extends JpaRepository<TbKakaoPayResult, String> {
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbKakaoPayResult;
import cokr.xit.ens.biz.iup.domain.TbNaverPayResult;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbNaverPayResultRepository extends JpaRepository<TbNaverPayResult, String> {
}

@ -0,0 +1,12 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbSendResult;
import java.util.List;
public interface TbSendResultCustomRepository {
void modifyByTbSendResults(List<TbSendResult> list);
Boolean findExistsByLnkInputIdAndPrcsOdr(Long lnkInputId, String prcsOdr);
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbSendResult;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbSendResultRepository extends JpaRepository<TbSendResult, Long>, TbSendResultCustomRepository {
}

@ -0,0 +1,53 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.TbSendResult;
import cokr.xit.ens.core.utils.CmmnUtil;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime;
import java.util.List;
import static cokr.xit.ens.biz.iup.domain.QTbSendResult.tbSendResult;
@RequiredArgsConstructor
public class TbSendResultRepositoryImpl implements TbSendResultCustomRepository {
private final JPAQueryFactory query;
@Override
public void modifyByTbSendResults(List<TbSendResult> list) {
list.forEach(data -> query.update(tbSendResult)
.set(tbSendResult.prcsOdr, data.getPrcsOdr())
.set(tbSendResult.sendSttusCd, data.getSendSttusCd())
.set(tbSendResult.sendTrySttusCd, data.getSendTrySttusCd())
.set(tbSendResult.sendType, data.getSendType())
.set(tbSendResult.runDt, data.getRunDt())
.set(tbSendResult.bizSendDt, data.getBizSendDt())
.set(tbSendResult.bizRecvDt, data.getBizRecvDt())
.set(tbSendResult.bizReadDt, data.getBizReadDt())
.set(tbSendResult.bizErrMsg, data.getBizErrMsg())
.set(tbSendResult.regId, data.getRegId())
// .set(tbSendResult.regDt, data.getRegDt())
.set(tbSendResult.lastUpdt, LocalDateTime.now())
.set(tbSendResult.expiresDt, data.getExpiresDt())
.set(tbSendResult.prcsYn, data.getPrcsYn())
.where(tbSendResult.lnkInputId.eq(data.getLnkInputId())
.and(tbSendResult.dataId.eq(data.getDataId()))
)
.execute()
);
}
@Override
public Boolean findExistsByLnkInputIdAndPrcsOdr(Long lnkInputId, String prcsOdr) {
Long result = query.select(tbSendResult.lnkInputId)
.from(tbSendResult)
.where(tbSendResult.lnkInputId.eq(lnkInputId)
.and(tbSendResult.prcsOdr.eq(prcsOdr))
)
.fetchFirst();
return CmmnUtil.isEmpty(result) ? false : true;
}
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.VKakaoNoticeInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VKakaoNoticeInfoRepository extends JpaRepository<VKakaoNoticeInfo, String> {
}

@ -0,0 +1,9 @@
package cokr.xit.ens.biz.iup.domain.repository;
import cokr.xit.ens.biz.iup.domain.VKakaoNoticeInfoSn;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VKakaoNoticeInfoSnRepository extends JpaRepository<VKakaoNoticeInfoSn, String> {
}

@ -0,0 +1,142 @@
package cokr.xit.ens.biz.iup.init;
import cokr.xit.ens.core.init.InitJpaRunner;
import cokr.xit.ens.modules.common.code.PostSeCd;
import cokr.xit.ens.modules.common.ctgy.sys.mng.model.OrgMngDTO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
@Transactional
@Profile({"prod-iup", "local-maria", "local-oracle"})
public class IupJpaRunner extends InitJpaRunner {
ObjectMapper mapper = new ObjectMapper();
@Override
protected List<OrgMngDTO> createOrgMngDTO() {
List<OrgMngDTO> list = new ArrayList<>();
list.add(createOrgMngDTO("0001", "", "관리지원센터", "N", null, null));
list.add(createOrgMngDTO("0002", "ThbGXS13oaidCCOk", "경수고속도로", "Y", "http://190.100.100.12/api/kakao/prepay", "http://190.100.100.12/api/kakao/pay-result"));
list.add(createOrgMngDTO("0003", "jTsUoCwm3BSOANcJ", "인천대교", "Y", "http://200.200.22.13:8080/IDTCS/kakao/prepay", "http://200.200.22.13:8080/IDTCS/kakao/pay-result"));
list.add(createOrgMngDTO("0004", "MfhmiR2oif0j5f3C", "인천공항하이웨이", "Y", "http://211.195.163.91:8080/api/kakao/prepay", "http://211.195.163.91:8080/api/kakao/pay-result"));
list.add(createOrgMngDTO("0005", "dtX0rzX4IyPnR0Zw", "서울고속도로", "Y", "http://172.20.11.10:8080/kakao/prepay.jsp", "http://172.20.11.10:8080/kakao/pay-result.jsp"));
return list;
}
@Override
protected List<Map<String, Object>> createTmpltMngDTO() {
List<Map<String, Object>> list = new ArrayList<>();
list.add(mapper.convertValue(createTmpltMngKkoAlimtalk("0001", "A0001", "CEPHIS001", "한국교통연구원 민자도로 관리지원센터 미납통행료 납부고지서", "~~@@!!ORG_NM!!@@~~에서 ~~@@!!TARGET_NAME!!@@~~님께 발송한 미납통행료 고지서가 도착했습니다.\n" +
"\n" +
"민자도로 미납통행료 고지서\n" +
"\n" +
"□ 차량번호 : ~~@@!!CAR_NO!!@@~~\n" +
"□ 미납발생 노선 : ~~@@!!COMPANY!!@@~~\n" +
"□ 미납발생 기간 : ~~@@!!TERM!!@@~~\n" +
"□ 납부금액 : ~~@@!!FEE!!@@~~원(~~@@!!COUNT!!@@~~건)\n" +
"□ 납부기한 : ~~@@!!DEADLINE!!@@~~\n" +
"□ 납부방법 : \n" +
"① 하단의 (납부하기) 클릭\n" +
"② 가상계좌 납부\n" +
"~~@@!!BANK_ACCOUNT!!@@~~\n" +
"\n" +
"※ 알림톡 수신 시 종이고지서는 발송되지 않습니다.\n" +
"\n" +
"문의처 : ~~@@!!REP_CALL_NO!!@@~~", "Y")
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0001", "A0002", "민자도로 미납통행료 독촉장", "소유차량(#{CAR_NO})의 미납통행료 독촉장", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "044-211-3377", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "044-211-3377", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 독촉장\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngKkoAlimtalk("0001", "A0003", "CEPHIS001", "통행료 미납에 따른 예금 압류 예고 안내", "~~@@!!ORG_NM!!@@~~ 에서 ~~@@!!TARGET_NAME!!@@~~ 님께 발송한 통행료 미납에 따른 예금 압류 예고 안내문이 도착했습니다.\n" +
"\n" +
"통행료 미납에 따른 예금 압류 예고 안내\n" +
"\n" +
"민자도로 관리지원센터에서는 ~~@@!!NAME!!@@~~님께서 통행료 납부를 하지 않을 시 유료도로법 제21조 제6항에 따라 예금압류를 진행할 예정입니다.\n" +
"예금이 압류되면 입출금, 계좌이체를 할 수 없어 채무연체 등 불이익을 입을 수 있고, 은행 영업일 기준으로 24시간 이내에 압류해제가 가능하지 않음을 알려드립니다. \n" +
"\n" +
"□ 차량번호 : ~~@@!!CAR_NO!!@@~~\n" +
"□ 미납발생 노선 : ~~@@!!COMPANY!!@@~~\n" +
"□ 미납발생 기간 : ~~@@!!TERM!!@@~~\n" +
"□ 납부금액 : ~~@@!!FEE!!@@~~원(~~@@!!COUNT!!@@~~건)\n" +
"□ 납부방법 : ~~@@!!METHOD!!@@~~\n" +
"~~@@!!BANK_ACCOUNT!!@@~~\n" +
"□ 납부기한 : ~~@@!!DEADLINE!!@@~~까지\n" +
"□ 민자도로 관리지원센터 : ~~@@!!CALL_NO!!@@~~\n" +
"\n" +
"문의처 : ~~@@!!REP_CALL_NO!!@@~~", "Y")
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0002", "B0001", "용인-서울고속도로 미납통행료 1차 안내문", "소유차량(#{CAR_NO})의 미납통행료 1차 안내문", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "1599-2509", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "1599-2509", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 1차 안내문\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0002", "B0002", "용인-서울고속도로 미납통행료 독촉장", "소유차량(#{CAR_NO})의 미납통행료 독촉장", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "1599-2509", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "1599-2509", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 독촉장\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0002", "B1001", "용인-서울고속도로 미납통행료 2차 고지서", "소유차량(#{CAR_NO})의 미납통행료 2차 고지서", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "1599-2509", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "1599-2509", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 2차 고지서\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0003", "C0001", "인천대교 고속도로 미납통행료 1차 안내문", "소유차량(#{CAR_NO})의 미납통행료 1차 안내문", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-745-8200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-745-8200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 1차 안내문\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0003", "C0002", "인천대교 고속도로 미납통행료 독촉장", "소유차량(#{CAR_NO})의 미납통행료 독촉장", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-745-8200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-745-8200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 독촉장\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0003", "C1001", "인천대교 고속도로 미납통행료 2차 고지서", "소유차량(#{CAR_NO})의 미납통행료 2차 고지서", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-745-8200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-745-8200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 2차 고지서\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0004", "D0001", "인천국제공항 고속도로 미납통행료 1차 안내문", "소유차량(#{CAR_NO})의 미납통행료 1차 안내문", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-560-6200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-560-6200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 1차 안내문\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0004", "D0002", "인천국제공항 고속도로 미납통행료 독촉장", "소유차량(#{CAR_NO})의 미납통행료 독촉장", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-560-6200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-560-6200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 독촉장\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0004", "D1001", "인천국제공항 고속도로 미납통행료 2차 고지서", "소유차량(#{CAR_NO})의 미납통행료 2차 고지서", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "032-560-6200", "문의처", "Y", "Y", "Y")
, createTmpltMngNvSigntalk(null, null, null, null, null, "032-560-6200", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 2차 고지서\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0005", "E0001", "수도권제1순환 고속도로 미납통행료 1차 안내문", "소유차량(#{CAR_NO})의 미납통행료 1차 안내문", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "영업소마다 다름", "문의처", "Y", "Y", "N")
, createTmpltMngNvSigntalk(null, null, null, null, null, "영업소마다 다름", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 1차 안내문\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0005", "E0002", "수도권제1순환 고속도로 미납통행료 독촉장", "소유차량(#{CAR_NO})의 미납통행료 독촉장", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "영업소마다 다름", "문의처", "Y", "Y", "N")
, createTmpltMngNvSigntalk(null, null, null, null, null, "영업소마다 다름", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 독촉장\"}]}"))
, Map.class));
list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.nvSigntalk, null, "0005", "E1001", "수도권제1순환 고속도로 미납통행료 2차 고지서", "소유차량(#{CAR_NO})의 미납통행료 2차 고지서", "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, "영업소마다 다름", "문의처", "Y", "Y", "N")
, createTmpltMngNvSigntalk(null, null, null, null, null, "영업소마다 다름", "Y", "Y", "N", "{\"data\":[{\"내용\":\"소유차량(#{CAR_NO})의 미납통행료 2차 고지서\"}]}")
)
, Map.class));
return list;
}
}

@ -0,0 +1,12 @@
package cokr.xit.ens.biz.iup.signtalk.model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
@Getter
@Schema(name = "IupSigntalkReqVO")
public class IupSigntalkReqVO {
@Schema(required = true, title = "연계입수 아이디", example = " ")
private Long lnkInputId;
}

@ -0,0 +1,66 @@
package cokr.xit.ens.biz.iup.signtalk.presentation;
import cokr.xit.ens.biz.iup.signtalk.model.IupSigntalkReqVO;
import cokr.xit.ens.biz.iup.signtalk.service.IupSigntalkService;
import cokr.xit.ens.core.aop.EnsResponseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "iupSigntalkController")
@Slf4j
@RequiredArgsConstructor
@RestController
public class IupSigntalkController {
private final IupSigntalkService iupSigntalkService;
@Operation(summary = "접수")
@PostMapping(value = "/iup/signtalk/accept", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EnsResponseVO> accept(@RequestBody IupSigntalkReqVO reqDTO){
EnsResponseVO responseVO = iupSigntalkService.accept(reqDTO.getLnkInputId());
return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
}
@Operation(summary = "접수(일괄)")
@PostMapping(value = "/iup/signtalk/accept/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EnsResponseVO> acceptAll(){
EnsResponseVO responseVO = iupSigntalkService.acceptAll();
return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
}
// @Operation(summary = "제작")
//// @PutMapping(value = "/iup/signtalk/re/make", produces = MediaType.APPLICATION_JSON_VALUE)
// @PostMapping(value = "/iup/signtalk/re/make", produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<EnsResponseVO> reMake(@RequestBody iupSigntalkReqVO reqDTO){
// EnsResponseVO responseVO = iupMydocService.reMake(reqDTO.getLnkInputId());
// return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
// }
@Operation(summary = "전송")
// @PutMapping(value = "/iup/signtalk/re/send", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/iup/signtalk/re/send", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EnsResponseVO> reSend(@RequestBody IupSigntalkReqVO reqDTO){
EnsResponseVO responseVO = iupSigntalkService.reSend(reqDTO.getLnkInputId());
return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
}
@Operation(summary = "전송결과가져오기")
@PostMapping(value = "/iup/signtalk/fetch", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EnsResponseVO> fetch(@RequestBody IupSigntalkReqVO reqDTO){
EnsResponseVO responseVO = iupSigntalkService.fetch(reqDTO.getLnkInputId());
return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
}
@Operation(summary = "전송결과가져오기(일괄)")
@PostMapping(value = "/iup/signtalk/fetch/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EnsResponseVO> fetchAll(){
EnsResponseVO responseVO = iupSigntalkService.fetchAll();
return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
}
}

@ -0,0 +1,47 @@
package cokr.xit.ens.biz.iup.signtalk.sched;
import cokr.xit.ens.biz.iup.signtalk.service.IupSigntalkService;
import cokr.xit.ens.core.aop.EnsResponseVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
//@Component
//@Profile("prod-iup")
@RequiredArgsConstructor
public class IupSigntalkScheduler {
private final IupSigntalkService iupMydocService;
/**
*
* -. IUP ENS .
*/
@Scheduled(cron = "0 */5 * * * *")
public void accepted(){
EnsResponseVO responseVO = iupMydocService.acceptAll();
log.info("=======================================================");
log.info("[IUP] 인증톡 접수처리 결과");
log.info(responseVO.toString());
log.info("=======================================================");
}
/**
*
* -. (/) ENS -> IUP .
*/
@Scheduled(cron = "0 */15 * * * *")
public void fetched(){
EnsResponseVO responseVO = iupMydocService.fetchAll();
log.info("=======================================================");
log.info("[IUP] 인증톡 요청문서정보 Fetch 결과");
log.info(responseVO.toString());
log.info("=======================================================");
}
}

@ -0,0 +1,493 @@
package cokr.xit.ens.biz.iup.signtalk.service;
import cokr.xit.ens.biz.iup.billpay.api.IupKkoPayUseSysApiSpec;
import cokr.xit.ens.biz.iup.billpay.service.IupBillKkoPayUseSysService;
import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.biz.iup.domain.repository.*;
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.code.BillKkoErrCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoApiRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.model.BillKkoPayResultData;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillReqSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.BillHist;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendDetail;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository.IntgrnSendDetailRepository;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.TmpltMng;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.repository.OrgMngRepository;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.repository.TmpltMngRepository;
import com.google.gson.Gson;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
@Slf4j
@Service("iupBillKkoPayUseSysService_KP")
@RequiredArgsConstructor
public class IupBillKkoPaySigntalkService extends IupBillKkoPayUseSysService {
private final IntgrnSendDetailRepository intgrnSendDetailRepository;
private final TmpltMngRepository sendTmpltMngRepository;
private final OrgMngRepository orgMngRepository;
private final TbInputDataXitRepository tbInputDataXitRepository;
private final VKakaoNoticeInfoRepository vKakaoNoticeInfoRepository;
private final VKakaoNoticeInfoSnRepository vKakaoNoticeInfoSnRepository;
// private final TbEnfrcLevRcivRepository tbEnfrcLevRcivRepository;
private final TbEnfrcLevMastrRepository tbEnfrcLevMastrRepository;
private final TbKakaoPayResultRepository tbKakaoPayResultRepository;
private final IupKkoPayUseSysApiSpec iupKkoPayApi;
private final JPAQueryFactory query;
/**
*
*
* @param mParam
* @return
*/
@Transactional(propagation = Propagation.NEVER)
public BillKkoApiRespDTO findNoticeInfo(Map<String, Object> mParam) {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
// data.get("biller_user_key");
// data.get("billed_year_month");
// data.get("ordinal");
// data.get("biller_notice_key");
Map<String, Object> parameters = (Map<String, Object>) data.get("parameters");
// data.get("user_birth");
Map<String, Object> respData = null;
BillKkoApiRespDTO respVO = null;
BillKkoErrCd kkoBillErrCd = BillKkoErrCd.OK;
final String billerUserKey = Optional.ofNullable(data.get("biller_user_key")).isPresent() ?
String.valueOf(data.get("biller_user_key")) : null;
final String userBirth = Optional.ofNullable(data.get("user_birth")).isPresent() ?
String.valueOf(data.get("user_birth")) : null;
final String orgCd = Optional.ofNullable(parameters.get("orgCd")).isPresent() ?
String.valueOf(parameters.get("orgCd")) : null;
final String billUid = Optional.ofNullable(parameters.get("billUid")).isPresent() ?
String.valueOf(parameters.get("billUid")) : null;
BillHist billHist = null;
try {
billHist = this.addBillHistByReqInfo(BillReqSeCd.NOTICE, billerUserKey, orgCd, billUid, mParam);
if (CmmnUtil.isEmpty(billerUserKey)) {
kkoBillErrCd = BillKkoErrCd.E801;
throw new EnsException(EnsErrCd.ERR401, "사용자식별키가 없습니다.");
}
if (CmmnUtil.isEmpty(orgCd)) {
kkoBillErrCd = BillKkoErrCd.E801;
throw new EnsException(EnsErrCd.ERR401, "기관코드가 없습니다.");
}
if (CmmnUtil.isEmpty(userBirth)) {
kkoBillErrCd = BillKkoErrCd.E801;
throw new EnsException(EnsErrCd.ERR401, "생년월일이 없습니다.");
}
Optional<IntgrnSendDetail> intgrnSendDetail = intgrnSendDetailRepository.findByLinkedUuid(billerUserKey);
if (!intgrnSendDetail.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 발송상세 자료가 없습니다.");
}
if (!orgCd.equals(intgrnSendDetail.get().getIntgrnSendMast().getOrgCd())) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR402, String.format("기관코드가 상이 합니다. ( 요청: %s 실제: %s )", orgCd, intgrnSendDetail.get().getIntgrnSendMast().getOrgCd()));
}
Optional<OrgMng> orgMng = orgMngRepository.findById(orgCd);
if (!orgMng.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E801;
throw new EnsException(EnsErrCd.ERR404, "일치하는 기관정보가 없습니다.");
}
Optional<TmpltMng> sendTmpltMng = sendTmpltMngRepository.findFetchByOrgCdAndTmpltCdAndUseYn(orgCd, intgrnSendDetail.get().getIntgrnSendMast().getTmpltCd(), "Y");
if (!sendTmpltMng.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E801;
throw new EnsException(EnsErrCd.ERR404, "일치하는 템플릿정보가 없습니다.");
}
Optional<TbInputDataXit> tbInputDataXit = tbInputDataXitRepository.findByLinkedUuid(billerUserKey);
if (!tbInputDataXit.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 발송상세정보가 없습니다.");
}
// final String dataId = tbInputDataXit.get().getDataId();
final String dataId = billerUserKey;
if ("Y".equals(orgMng.get().getKkoBpCsignYn())) {
Optional<VKakaoNoticeInfoSn> vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId);
if (!vKakaoNoticeInfoSn.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 단순미납부과 자료가 없습니다.");
}
if (!userBirth.equals(vKakaoNoticeInfoSn.get().getUserBirth())) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR402, String.format("생년월일이 일치하지 않습니다. (요청: %s 실제: %s)", userBirth, vKakaoNoticeInfoSn.get().getUserBirth()));
}
respData = this.respNoticeSnData(sendTmpltMng.get().getTitle(), orgMng.get(), vKakaoNoticeInfoSn.get());
} else if ("N".equals(orgMng.get().getKkoBpCsignYn())) {
if (dataId.length() < 20) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR403, "빌러코드가 20자리 미만 입니다.");
}
Optional<VKakaoNoticeInfo> vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20));
if (!vKakaoNoticeInfo.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 강제징수부과 자료가 없습니다.");
}
if (!userBirth.equals(vKakaoNoticeInfo.get().getUserBirth())) {
kkoBillErrCd = BillKkoErrCd.E404;
throw new EnsException(EnsErrCd.ERR402, String.format("생년월일이 일치하지 않습니다. (요청: %s 실제: %s)", userBirth, vKakaoNoticeInfo.get().getUserBirth()));
}
respData = this.respNoticeData(sendTmpltMng.get().getTitle(), orgMng.get(), vKakaoNoticeInfo.get());
} else {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR999, "위탁업체여부 구분값이 등록되지 않았습니다.");
}
respVO = BillKkoApiRespDTO.okBuilder()
.data(respData)
.build();
this.modifyBillHistByRespInfo(billHist, respVO, null, null);
} catch (EnsException e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(kkoBillErrCd.getCode())
.message(kkoBillErrCd.getCodeNm())
.build();
this.modifyBillHistByRespInfo(billHist, respVO, e.getErrCd(), e.getMessage());
} catch (Exception e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.E801.getCode())
.message(BillKkoErrCd.E801.getCodeNm())
.build();
this.modifyBillHistByRespInfo(billHist, respVO, EnsErrCd.ERR999, e.getMessage());
}
return respVO;
}
/**
*
*
* @param mParam
* @return
*/
@Transactional(propagation = Propagation.NEVER)
public BillKkoApiRespDTO findPrepayInfo(Map<String, Object> mParam) {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
// data.get("biller_user_key");
// data.get("billed_year_month");
// data.get("ordinal");
// data.get("biller_notice_key");
Map<String, Object> parameters = (Map<String, Object>) data.get("parameters");
// data.get("amount");
BillKkoApiRespDTO respVO = null;
BillKkoErrCd kkoBillErrCd = BillKkoErrCd.OK;
final String billerUserKey = Optional.ofNullable(data.get("biller_user_key")).isPresent() ?
String.valueOf(data.get("biller_user_key")) : null;
final int amount = Optional.ofNullable(data.get("amount")).isPresent() ?
(int) data.get("amount") : 0;
final String orgCd = Optional.ofNullable(parameters.get("orgCd")).isPresent() ?
String.valueOf(parameters.get("orgCd")) : null;
final String billUid = Optional.ofNullable(parameters.get("billUid")).isPresent() ?
String.valueOf(parameters.get("billUid")) : null;
BillHist billHist = null;
try {
billHist = this.addBillHistByReqInfo(BillReqSeCd.PREPAY, billerUserKey, orgCd, billUid, mParam);
if (CmmnUtil.isEmpty(billerUserKey)) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR401, "사용자식별키가 없습니다.");
}
if (CmmnUtil.isEmpty(orgCd)) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR401, "기관코드가 없습니다.");
}
// Optional<OrgMng> orgMng = orgMngRepository.findById(orgCd);
// if (!orgMng.isPresent()) {
// kkoBillErrCd = BillKkoErrCd.E601;
// throw new EnsException(EnsErrCd.ERR404, "일치하는 기관정보가 없습니다.");
// }
// Optional<TbInputDataXit> tbInputDataXit = tbInputDataXitRepository.findByLinkedUuid(billerUserKey);
Optional<TbInputDataXit> tbInputDataXit = this.getTbInputDataXitByLinkedUuid(billerUserKey);
if (!tbInputDataXit.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 발송상세정보가 없습니다.");
}
final FsJob fsJob = tbInputDataXit.get().getTbInputXit().getFsJob();
final String dataId = tbInputDataXit.get().getDataId();
Optional<VKakaoNoticeInfo> vKakaoNoticeInfo = Optional.ofNullable(null);
// List<TbEnfrcLevRciv> tbEnfrcLevRcivs = new ArrayList<>();
if ("Y".equals(fsJob.getBpEntrustYn())) {
Optional<VKakaoNoticeInfoSn> vKakaoNoticeInfoSn = vKakaoNoticeInfoSnRepository.findById(dataId);
if (!vKakaoNoticeInfoSn.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E502;
throw new EnsException(EnsErrCd.ERR404, "일치하는 단순미납 자료가 없습니다.");
}
respVO = iupKkoPayApi.callApiByOrg(fsJob.getBpKkoPrepayApi(), mParam);
if ("OK".equals(respVO.getRes_code()))
this.modifyBillHistByRespInfo(billHist, respVO, null, null);
else
this.modifyBillHistByRespInfo(billHist, respVO, EnsErrCd.ERR999, String.format("[%s] %s", respVO.getRes_code(), respVO.getMessage()));
return respVO;
} else if ("N".equals(fsJob.getBpEntrustYn())) {
if (dataId.length() < 20) {
kkoBillErrCd = BillKkoErrCd.E502;
throw new EnsException(EnsErrCd.ERR403, "빌러코드가 20자리 미만 입니다.");
}
vKakaoNoticeInfo = vKakaoNoticeInfoRepository.findById(dataId.substring(0, 20));
if (!vKakaoNoticeInfo.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E502;
throw new EnsException(EnsErrCd.ERR404, "일치하는 강제징수 자료가 없습니다.");
}
// tbEnfrcLevRcivs = tbEnfrcLevRcivRepository.findAllByEnfrcLevMastrIdAndDeleteAt(dataId.substring(0, 20), "N");
Optional<TbEnfrcLevMastr> tbEnfrcLevMastr = tbEnfrcLevMastrRepository.findByEnfrcLevMastrIdAndEnfrcLevMastrProcessSttusAndDeleteAt(dataId.substring(0, 20), "04", "N");
if (!tbEnfrcLevMastr.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR507, "납부가능 상태가 아닙니다.");
}
} else {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR999, "위탁업체여부 구분값이 등록되지 않았습니다.");
}
if (CmmnUtil.isEmpty(vKakaoNoticeInfo.get().getAmount())
|| amount != Integer.parseInt(vKakaoNoticeInfo.get().getAmount())) {
kkoBillErrCd = BillKkoErrCd.E403;
throw new EnsException(EnsErrCd.ERR902
, String.format("납부 가능 금액이 없거나 일치하지 않습니다. (요청금액:%s, 실제금액:%s)"
, amount
, vKakaoNoticeInfo.get().getAmount()));
}
if (amount > Integer.parseInt(vKakaoNoticeInfo.get().getAmount())) {
kkoBillErrCd = BillKkoErrCd.E501;
throw new EnsException(EnsErrCd.ERR902
, String.format("납부 가능 금액을 초과했습니다. (요청금액:%s, 실제금액:%s)"
, amount
, vKakaoNoticeInfo.get().getAmount()));
}
if (!vKakaoNoticeInfo.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E502;
throw new EnsException(EnsErrCd.ERR404, "일치하는 청구서자료가 없습니다.");
}
if (CmmnUtil.isEmpty(vKakaoNoticeInfo.get().getPayExpireDate())) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR401, "납부기한이 값이 없습니다.");
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
if (Integer.parseInt(vKakaoNoticeInfo.get().getPayExpireDate()) < Integer.parseInt(simpleDateFormat.format(new Date()))) {
kkoBillErrCd = BillKkoErrCd.E506;
throw new EnsException(EnsErrCd.ERR902, "납부기한이 경과한 자료 입니다.");
}
// if (tbEnfrcLevRcivs.size() > 0) {
// kkoBillErrCd = BillKkoErrCd.E601;
// throw new EnsException(EnsErrCd.ERR903, "납부가 완료된 자료 입니다.");
// }
respVO = BillKkoApiRespDTO.okBuilder()
.data(null)
.build();
this.modifyBillHistByRespInfo(billHist, respVO, null, null);
} catch (EnsException e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(kkoBillErrCd.getCode())
.message(kkoBillErrCd.getCodeNm())
.build();
this.modifyBillHistByRespInfo(billHist, respVO, e.getErrCd(), e.getMessage());
} catch (Exception e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.E601.getCode())
.message(BillKkoErrCd.E601.getCodeNm())
.build();
this.modifyBillHistByRespInfo(billHist, respVO, EnsErrCd.ERR999, e.getMessage());
}
return respVO;
}
/**
*
*
* @param mParam
* @return
*/
@Transactional(propagation = Propagation.NEVER)
public BillKkoApiRespDTO addPayReultIfno(Map<String, Object> mParam) {
Map<String, Object> data = (Map<String, Object>) mParam.get("data");
Gson gson = new Gson();
BillKkoPayResultData kkoBillPayResultVO = gson.fromJson(gson.toJson(data), BillKkoPayResultData.class);
Map<String, Object> parameters = kkoBillPayResultVO.getParameters();
BillKkoApiRespDTO respVO = null;
BillKkoErrCd kkoBillErrCd = BillKkoErrCd.OK;
final String orgCd = Optional.ofNullable(parameters.get("orgCd")).isPresent() ?
String.valueOf(parameters.get("orgCd")) : null;
final String billUid = Optional.ofNullable(parameters.get("billUid")).isPresent() ?
String.valueOf(parameters.get("billUid")) : null;
BillHist kkoBillHist = null;
try {
kkoBillHist = this.addBillHistByReqInfo(BillReqSeCd.PAYRSLT, kkoBillPayResultVO.getBiller_user_key(), orgCd, billUid, mParam);
if (CmmnUtil.isEmpty(kkoBillPayResultVO.getBiller_user_key())) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR401, "사용자식별키가 없습니다.");
}
if (CmmnUtil.isEmpty(orgCd)) {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR401, "기관코드가 없습니다.");
}
// Optional<OrgMng> orgMng = orgMngRepository.findById(orgCd);
// if (!orgMng.isPresent()) {
// kkoBillErrCd = BillKkoErrCd.E601;
// throw new EnsException(EnsErrCd.ERR404, "일치하는 기관정보가 없습니다.");
// }
Optional<TbInputDataXit> tbInputDataXit = this.getTbInputDataXitByLinkedUuid(kkoBillPayResultVO.getBiller_user_key());
if (!tbInputDataXit.isPresent()) {
kkoBillErrCd = BillKkoErrCd.E402;
throw new EnsException(EnsErrCd.ERR404, "일치하는 발송상세정보가 없습니다.");
}
final FsJob fsJob = tbInputDataXit.get().getTbInputXit().getFsJob();
if (!tbKakaoPayResultRepository.findById(kkoBillPayResultVO.getBiller_user_key()).isPresent())
tbKakaoPayResultRepository.save(this.createTbKakaoPayResult(kkoBillPayResultVO));
if ("Y".equals(fsJob.getBpEntrustYn())) {
respVO = iupKkoPayApi.callApiByOrg(fsJob.getBpKkoPayresultApi(), mParam);
if (!"OK".equals(respVO.getRes_code()))
this.modifyBillHistByRespInfo(kkoBillHist, respVO, EnsErrCd.ERR600, String.format("[%s] %s", respVO.getRes_code(), respVO.getMessage()));
return respVO;
} else if ("N".equals(fsJob.getBpEntrustYn())) {
} else {
kkoBillErrCd = BillKkoErrCd.E601;
throw new EnsException(EnsErrCd.ERR999, "위탁업체여부 구분값이 등록되지 않았습니다.");
}
respVO = BillKkoApiRespDTO.okBuilder()
.data(null)
.build();
this.modifyBillHistByRespInfo(kkoBillHist, respVO, null, null);
} catch (EnsException e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(kkoBillErrCd.getCode())
.message(kkoBillErrCd.getCodeNm())
.build();
this.modifyBillHistByRespInfo(kkoBillHist, respVO, e.getErrCd(), e.getMessage());
} catch (Exception e) {
respVO = BillKkoApiRespDTO.errBuilder()
.resCode(BillKkoErrCd.E601.getCode())
.message(BillKkoErrCd.E601.getCodeNm())
.build();
this.modifyBillHistByRespInfo(kkoBillHist, respVO, EnsErrCd.ERR999, e.getMessage());
}
return respVO;
}
private TbKakaoPayResult createTbKakaoPayResult(BillKkoPayResultData kkoBillPayResultVO) {
final String jobSe = "EL".equals(kkoBillPayResultVO.getBiller_user_key().substring(0, 2)) ? "2" : "1";
return TbKakaoPayResult.builder()
.dataId(kkoBillPayResultVO.getBiller_user_key())
.jobSe(jobSe)
.payMn(kkoBillPayResultVO.getPay_by())
.payTy(kkoBillPayResultVO.getPay_type())
.payDetail1(kkoBillPayResultVO.getPay_detail1())
.payDetail2(kkoBillPayResultVO.getPay_detail2())
.payDetail3(kkoBillPayResultVO.getPay_detail3())
.payAmount(kkoBillPayResultVO.getPay_amount())
.payFeeTy(kkoBillPayResultVO.getPay_fee_type())
.payFeeAmount(kkoBillPayResultVO.getPay_fee())
.payFeeVat(kkoBillPayResultVO.getPay_fee_tax())
.excclcPrearngeDe(kkoBillPayResultVO.getAdjust_date())
.payDt(kkoBillPayResultVO.getPaid_at())
.payId(kkoBillPayResultVO.getPay_id())
.payResultProcessSttus("0")
// .creatDt()
.crtr("ENS_SYS")
// .updtDt()
// .updusr()
.build();
}
private Optional<TbInputDataXit> getTbInputDataXitByLinkedUuid(String linkedUuid) {
return Optional.ofNullable(query.select(QTbInputDataXit.tbInputDataXit)
.from(QTbInputDataXit.tbInputDataXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit, QTbInputXit.tbInputXit)
.innerJoin(QTbInputDataXit.tbInputDataXit.tbInputXit.fsJob, QFsJob.fsJob)
.where(QTbInputDataXit.tbInputDataXit.linkedUuid.eq(linkedUuid))
.fetchOne());
}
}

@ -0,0 +1,167 @@
package cokr.xit.ens.biz.iup.signtalk.service;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import cokr.xit.ens.biz.iup.domain.repository.TbInputXitRepository;
import cokr.xit.ens.biz.iup.signtalk.service.support.IupSigntalkAcceptor;
import cokr.xit.ens.biz.iup.signtalk.service.support.IupSigntalkFetcher;
import cokr.xit.ens.biz.iup.signtalk.service.support.IupSigntalkSender;
import cokr.xit.ens.core.aop.EnsResponseVO;
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.intgrnnoti.service.event.IntgrnNotiSendReserveEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class IupSigntalkService {
private final TbInputXitRepository tbInputXitRepository;
private final IupSigntalkAcceptor iupSigntalkAcceptor;
private final IupSigntalkSender iupSigntalkSender;
private final IupSigntalkFetcher iupSigntalkFetcher;
private final ApplicationEventPublisher applicationEventPublisher;
/**
* (IUP -> ENS)
*/
@Transactional
public EnsResponseVO accept(Long lnkInputId) {
try {
TbInputXit tbInputXit = tbInputXitRepository.findByPrcsCdAndSendTypeAndId(IupPrcsCd.TGRG, IupSendTypeCd.KP, lnkInputId)
.orElseThrow(() -> new EnsException(EnsErrCd.ACPT404, "일치하는 자료가 없거나 \"등록(TGRG)\" 상태가 아닙니다."));
return this.accept(Arrays.asList(tbInputXit)).getResultInfo().get(0);
} catch (EnsException e) {
return EnsResponseVO.errBuilder()
.errCode(e.getErrCd())
.errMsg(e.getMessage())
.build();
}
}
/**
* (IUP -> ENS)
*/
@Transactional
public EnsResponseVO<List<EnsResponseVO>> acceptAll() {
try {
List<TbInputXit> tbInputXits = tbInputXitRepository.findAllByPrcsCdInAndSendType(Arrays.asList(IupPrcsCd.TGRG), IupSendTypeCd.KP);
if (CmmnUtil.isEmpty(tbInputXits))
throw new EnsException(EnsErrCd.ACPT404, "\"등록(TGRG)\" 상태의 자료가 없습니다.");
return this.accept(tbInputXits);
} catch (EnsException e) {
return EnsResponseVO.<List<EnsResponseVO>>errBuilder()
.errCode(e.getErrCd())
.errMsg(e.getMessage())
.build();
}
}
private EnsResponseVO<List<EnsResponseVO>> accept(List<TbInputXit> tbInputXits) {
iupSigntalkAcceptor.statReady(tbInputXits.stream().map(row -> row.getLnkInputId()).collect(Collectors.toList()));
List<EnsResponseVO> resultInfo = tbInputXits.stream()
.map(row -> iupSigntalkAcceptor.execute(row.getLnkInputId()))
.collect(Collectors.toList());
List<Long> sendMastIds = resultInfo.stream()
.filter(ensResponseVO -> EnsErrCd.OK.equals(ensResponseVO.getErrCode()))
.map(ensResponseVO -> (Long) ((Map<String, Object>) ensResponseVO.getResultInfo()).get("intSendMastId"))
.collect(Collectors.toList());
IntgrnNotiSendReserveEvent event = IntgrnNotiSendReserveEvent.builder()
.sendMastIds(sendMastIds)
.callback(() -> this.fetch(tbInputXits))
.build();
applicationEventPublisher.publishEvent(event);
return EnsResponseVO.<List<EnsResponseVO>>okBuilder().resultInfo(resultInfo).build();
}
// /**
// * 인증톡 제작 재요청
// * @param lnkInputId
// * @return
// */
// public EnsResponseVO reMake(Long lnkInputId){
// return iupSigntalkMaker.execute(lnkInputId);
// }
/**
*
*
* @param lnkInputId
* @return
*/
public EnsResponseVO reSend(Long lnkInputId) {
return iupSigntalkSender.execute(lnkInputId);
}
/**
* (/)
*/
@Transactional
public EnsResponseVO fetch(Long lnkInputId) {
TbInputXit tbInputXit = null;
try {
tbInputXit = tbInputXitRepository.findById(lnkInputId)
.orElseThrow(() -> new EnsException(EnsErrCd.ERR404, String.format("[ lnkInputId %s ]와 일치하는 자료가 없습니다.", lnkInputId)));
if (!IupSendTypeCd.KP.equals(tbInputXit.getSendType()))
new EnsException(EnsErrCd.ERR404, String.format("[ lnkInputId %s ]는 인증톡 자료가 아닙니다.", lnkInputId));
} catch (EnsException e) {
return EnsResponseVO.errBuilder()
.errCode(e.getErrCd())
.errMsg(e.getMessage())
.build();
}
return this.fetch(Arrays.asList(tbInputXit));
}
/**
* (/)
*/
public EnsResponseVO fetchAll() {
List<TbInputXit> tbInputXits = tbInputXitRepository.findAllByPrcsCdInAndSendType(Arrays.asList(IupPrcsCd.TGRC, IupPrcsCd.CICV, IupPrcsCd.CICC, IupPrcsCd.COMP, IupPrcsCd.INCM), IupSendTypeCd.KP);
return this.fetch(tbInputXits);
}
private EnsResponseVO fetch(List<TbInputXit> tbInputXits) {
iupSigntalkFetcher.statReady(tbInputXits.stream().map(row -> row.getLnkInputId()).collect(Collectors.toList()));
return EnsResponseVO.okBuilder()
.resultInfo(
tbInputXits.stream()
.map(row -> iupSigntalkFetcher.execute(row.getLnkInputId()))
.collect(Collectors.toList()
)
)
.build();
}
}

@ -0,0 +1,260 @@
package cokr.xit.ens.biz.iup.signtalk.service.support;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import cokr.xit.ens.biz.iup.domain.repository.TbInputDataXitRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbInputXitRepository;
import cokr.xit.ens.biz.iup.signtalk.service.support.accept.AcptDocKkoMd;
import cokr.xit.ens.biz.iup.signtalk.service.support.accept.AcptDocNvSt;
import cokr.xit.ens.core.aop.EnsResponseVO;
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.biztmplt.EnsPhaseProcSupport;
import cokr.xit.ens.modules.common.code.VenderCd;
import cokr.xit.ens.core.model.EnsBillAcptReqDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.BillSeCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.IntgrnNotiAcceptReqDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.config.AcptData;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.config.Document;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.config.Receiver;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.config.XitProperty;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.IntgrnNotiService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.utility.RandomString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Slf4j
@Component
@RequiredArgsConstructor
public class IupSigntalkAcceptor implements EnsPhaseProcSupport<EnsResponseVO, Long> {
private final TbInputXitRepository tbInputXitRepository;
private final TbInputDataXitRepository tbInputDataXitRepository;
private final IntgrnNotiService intgrnNotiService;
@Value("${xit.mblpage.postse.intgrn.url}")
private String MBLPAGE_URL;
@Value("${xit.mblpage.postse.intgrn.path}")
private String MBLPAGE_PATH;
/**
* Accept
*
* @param lnkInputIds
* @return
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO statReady(List<Long> lnkInputIds) {
try {
AtomicInteger index = new AtomicInteger();
String prefixLinkedUuid = String.format("B-ST%s%s", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")), RandomString.make(5));
lnkInputIds.stream()
.map(lnkInputId -> tbInputXitRepository.findById(lnkInputId).get())
.map(tbinput -> tbInputDataXitRepository.findAllByTbInputXit(tbinput))
.forEach(list -> {
list.stream()
.forEach(row -> {
log.info(row.toString());
// row.setLinkedUuid(String.format("%s%05d", prefixLinkedUuid, index.getAndIncrement() + 1));
row.setLinkedUuid(row.getDataId());
});
tbInputDataXitRepository.saveAll(list);
}
);
} catch (Exception e) {
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.ACPT500)
.errMsg(String.format("연계식별UUID 생성에 실패 했습니다. %s", e.getMessage()))
.build();
}
EnsResponseVO respVO = null;
try {
/**
*
*/
if (CmmnUtil.isEmpty(lnkInputIds))
throw new EnsException(EnsErrCd.ACPT410, "연계입수아이디(은)는 필수조건 입니다.");
/**
*
* -. "대상이관등록(TGRI)" .
*/
List<Long> resultInfo = tbInputXitRepository.findAllByLnkInputIdIn(lnkInputIds).stream()
.map(row -> {
row.setUpdId("ENS_SYS");
row.setPrcsCd(IupPrcsCd.TGRI);
return row.getLnkInputId();
})
.collect(Collectors.toList());
respVO = EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
} catch (EnsException e) {
respVO = EnsResponseVO.errBuilder().errCode(e.getErrCd()).errMsg(e.getMessage()).build();
} catch (Exception e) {
respVO = EnsResponseVO.errBuilder().errCode(EnsErrCd.ACPT999).errMsg(e.getMessage()).build();
}
return respVO;
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO statBegin(Long arg) {
log.info("no process");
return null;
}
/**
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO execute(Long lnkInputId) {
Map<String, Long> resultInfo = new HashMap<>();
resultInfo.put("lnkInputId", lnkInputId);
EnsResponseVO responseVO = null;
TbInputXit tbInputXit = null;
try {
tbInputXit = tbInputXitRepository.findById(lnkInputId)
.orElseThrow(() -> new EnsException(EnsErrCd.ACPT404, String.format("일치하는 TB_INPUT_XIT 데이터가 없습니다. [ lnkInputId %s ]", lnkInputId)));
IntgrnNotiAcceptReqDTO reqDTO = this.convertTbInputDataToAcceptReqDTO(tbInputDataXitRepository.findAllFetchByLnkInputId(tbInputXit.getLnkInputId()));
EnsResponseVO reqResp = intgrnNotiService.accept(reqDTO);
if (EnsErrCd.OK.equals(reqResp.getErrCode())) {
resultInfo.put("intSendMastId", (Long) ((Map<String, Object>) reqResp.getResultInfo()).get("intSendMastId"));
responseVO = EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
} else {
responseVO = EnsResponseVO.errRsltBuilder()
.errCode(reqResp.getErrCode())
.errMsg(reqResp.getErrMsg())
.resultInfo(reqResp.getResultInfo())
.build();
}
} catch (EnsException e) {
responseVO = EnsResponseVO.errRsltBuilder()
.errCode(e.getErrCd())
.errMsg(String.format("인증톡 \"접수\" 처리 실패. [%s] %s", e.getErrCd().getCode(), e.getMessage()))
.resultInfo(resultInfo)
.build();
} catch (Exception e) {
responseVO = EnsResponseVO.errRsltBuilder()
.errCode(EnsErrCd.ACPT500)
.errMsg(String.format("인증톡 \"접수\" 처리 실패. %s", e.getMessage()))
.resultInfo(resultInfo)
.build();
} finally {
if (EnsErrCd.OK.equals(responseVO.getErrCode())) {
tbInputXit.setUpdId("ENS_SYS");
tbInputXit.setPrcsCd(IupPrcsCd.TGRC);
tbInputXit.setErrMsg(null);
} else {
tbInputXit.setUpdId("ENS_SYS");
tbInputXit.setPrcsCd(IupPrcsCd.TGRF);
tbInputXit.setErrMsg(responseVO.getErrMsg());
}
}
return responseVO;
}
private IntgrnNotiAcceptReqDTO convertTbInputDataToAcceptReqDTO(List<TbInputDataXit> list) {
return IntgrnNotiAcceptReqDTO.builder()
.vender(VenderCd.none.getCode())
.org_cd(list.get(0).getTbInputXit().getOrgCd())
.tmplt_cd(list.get(0).getTbInputXit().getFsJob().getJobCd())
.post_bundle_title(
String.format("%s(%s건)-%s"
, IupSendTypeCd.KP.getCodeNm()
, list.get(0).getTbInputXit().getTotCnt()
, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
)
)
.send_dt(list.get(0).getTbInputXit().getRunDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")))
.close_dt(list.get(0).getTbInputXit().getExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")))
.documents(
list.stream()
.map(row -> createDocument(row))
.collect(Collectors.toList())
)
.build();
}
private Document createDocument(TbInputDataXit data) throws EnsException {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
return Document.builder()
.linked_uuid(data.getLinkedUuid())
.receiver(Receiver.builder()
.ci(null)
.jid(data.getSid())
.mblphon_no(data.getMoblphonNo())
.build())
.acpt_data(AcptData.builder()
.kko_md(new AcptDocKkoMd(data, MBLPAGE_URL + MBLPAGE_PATH).createDocument())
.kko_at(null)
// .nv_st(new AcptDocNvSt(data, NV_ST_ORG_ID, MBLPAGE_URL + MBLPAGE_PATH).createDocument())
.nv_st(new AcptDocNvSt(data, null, MBLPAGE_URL + MBLPAGE_PATH).createDocument())
.build())
.xit_property(XitProperty.builder()
.bill_acpt_data(this.createBillAcptData(data))
.tmplt_msg_data(CmmnUtil.isEmpty(data.getMsgData()) ? null : gson.fromJson(data.getMsgData().replace("~~@@!!", "#{").replace("!!@@~~", "}"), Map.class))
.mbl_page_data(CmmnUtil.isEmpty(data.getMsgDtlData()) ? null : gson.fromJson(data.getMsgDtlData(), Map.class))
.build())
.build();
}
private EnsBillAcptReqDTO createBillAcptData(TbInputDataXit data) {
return EnsBillAcptReqDTO.builder()
.billUid(null)
.billerUserKey(data.getLinkedUuid())
.billSe(BillSeCd.privt)
.build();
}
}

@ -0,0 +1,276 @@
package cokr.xit.ens.biz.iup.signtalk.service.support;
import cokr.xit.ens.biz.iup.code.IupPrcsCd;
import cokr.xit.ens.biz.iup.code.IupSendSttusCd;
import cokr.xit.ens.biz.iup.code.IupSendTrySttusCd;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.TbInputXit;
import cokr.xit.ens.biz.iup.domain.TbSendResult;
import cokr.xit.ens.biz.iup.domain.repository.TbInputDataXitRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbInputXitRepository;
import cokr.xit.ens.biz.iup.domain.repository.TbSendResultRepository;
import cokr.xit.ens.core.aop.EnsResponseVO;
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.core.utils.DateUtil;
import cokr.xit.ens.modules.common.biztmplt.EnsPhaseProcSupport;
import cokr.xit.ens.modules.common.code.PostSeCd;
import cokr.xit.ens.modules.common.code.StatCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.code.TryStatCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.IntgrnDetailStatVO;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.IntgrnNotiRsltRespDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.IntgrnNotiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Component
@RequiredArgsConstructor
public class IupSigntalkFetcher implements EnsPhaseProcSupport<EnsResponseVO, Long> {
private final TbInputXitRepository tbInputXitRepository;
private final TbInputDataXitRepository tbInputDataXitRepository;
private final TbSendResultRepository tbSendResultRepository;
private final IntgrnNotiService intgrnNotiService;
/**
* Fetch
*
* @param lnkInputIds
* @return
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO statReady(List<Long> lnkInputIds) {
EnsResponseVO respVO = null;
try {
/**
*
*/
if (CmmnUtil.isEmpty(lnkInputIds))
throw new EnsException(EnsErrCd.RSLT410, "연계입수아이디(은)는 필수조건 입니다.");
/**
*
* -. "입수중(INCM)" .
*/
List<Long> resultInfo = tbInputXitRepository.findAllByLnkInputIdIn(lnkInputIds).stream()
.map(row -> {
row.setUpdId("ENS_SYS");
row.setPrcsCd(IupPrcsCd.INCM);
return row.getLnkInputId();
})
.collect(Collectors.toList());
;
respVO = EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
} catch (EnsException e) {
respVO = EnsResponseVO.errBuilder().errCode(e.getErrCd()).errMsg(e.getMessage()).build();
} catch (Exception e) {
respVO = EnsResponseVO.errBuilder().errCode(EnsErrCd.RSLT999).errMsg(e.getMessage()).build();
}
return respVO;
}
@Override
public EnsResponseVO statBegin(Long arg) {
log.info("no process");
return null;
}
/**
* (/)
*
* @param lnkInputId
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO execute(Long lnkInputId) {
EnsResponseVO responseVO = null;
Map<String, Object> resultInfo = new HashMap<>();
resultInfo.put("lnkInputId", lnkInputId);
IntgrnNotiRsltRespDTO respDTO = null;
try {
Long intSendMastId = tbInputDataXitRepository.findLastSendMastIdByLnkInputIdAndSendType(lnkInputId, IupSendTypeCd.KP)
.orElseThrow(() -> new EnsException(EnsErrCd.RSLT404, "일치하는 ENS 접수자료가 없습니다."));
resultInfo.put("intSendMastId", intSendMastId);
EnsResponseVO apiRespVO = intgrnNotiService.sendResultProvide(intSendMastId);
respDTO = (IntgrnNotiRsltRespDTO) apiRespVO.getResultInfo();
IntgrnNotiRsltRespDTO finalRespDTO = respDTO;
List<TbSendResult> tbSendResults = respDTO.getDocuments().stream()
.map(row -> {
return TbSendResult.builder()
.lnkInputId(lnkInputId)
.dataId(row.getLinkedUuid())
// .dataId(tbInputDataXitRepository.findByLinkedUuid(row.getLinkedUuid())
// .orElse(new TbInputDataXit())
// .getDataId())
// .prcsOdr(StatCd.close.equals(finalRespDTO.getStatCd()) ? "2" : "1")
.prcsOdr(finalRespDTO.getCloseAt() ? "2" : "1")
// .sendSttusCd(iupSendSttusCd)
.sendSttusCd(this.sendSttusCd(row, finalRespDTO))
.sendTrySttusCd(TryStatCd.cmplt.equals(finalRespDTO.getTryStatCd()) ? IupSendTrySttusCd.CMPLT : IupSendTrySttusCd.TRYING)
.sendType(IupSendTypeCd.KP)
.runDt(DateUtil.toLocalDateTime(finalRespDTO.getSendDt()))
.bizSendDt(DateUtil.toLocalDateTime(row.getDocSentDt()))
.bizRecvDt(DateUtil.toLocalDateTime(row.getDocReceivedDt()))
.bizReadDt(DateUtil.toLocalDateTime(row.getDocReadFrstDt()))
.bizErrMsg(CmmnUtil.isEmpty(row.getErrorMessage()) ? null : String.format("%s %s", row.getErrorCode(), row.getErrorMessage()))
.regId("ENS_SYS")
.regDt(LocalDateTime.now())
.expiresDt(DateUtil.toLocalDateTime(finalRespDTO.getCloseDt()))
.prcsYn("N")
.build();
})
.collect(Collectors.toList());
// if (tbSendResultRepository.findExistsByLnkInputIdAndPrcsOdr(lnkInputId, StatCd.close.equals(finalRespDTO.getStatCd()) ? "2" : "1"))
if (tbSendResultRepository.findExistsByLnkInputIdAndPrcsOdr(lnkInputId, finalRespDTO.getCloseAt() ? "2" : "1"))
tbSendResultRepository.modifyByTbSendResults(tbSendResults);
else
tbSendResultRepository.saveAll(tbSendResults);
responseVO = EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
} catch (EnsException e) {
responseVO = EnsResponseVO.errBuilder()
.errCode(e.getErrCd())
.errMsg(e.getMessage())
.build();
} catch (Exception e) {
responseVO = EnsResponseVO.errBuilder()
.errCode(EnsErrCd.RSLT999)
.errMsg(String.format("[lnkInputId %s]에 대한 전송결과 FETCH 처리 실패. %s", lnkInputId, e.getMessage()))
.build();
} finally {
TbInputXit tbInputXit = tbInputXitRepository.findById(lnkInputId).orElseThrow(() -> new EnsException(EnsErrCd.RSLT404, "일치하는 tbInputXit 자료가 없습니다."));
if (EnsErrCd.OK.equals(responseVO.getErrCode())) {
tbInputXit.setUpdId("ENS_SYS");
// tbInputXit.setPrcsCd(IupPrcsCd.IPCP);
tbInputXit.setPrcsCd(this.prcsCd(respDTO, tbInputXit.getPrcsCd()));
tbInputXit.setErrMsg(null);
} else {
tbInputXit.setUpdId("ENS_SYS");
tbInputXit.setPrcsCd(IupPrcsCd.FAIL);
tbInputXit.setErrMsg(responseVO.getErrMsg());
}
}
return responseVO;
}
private IupPrcsCd prcsCd(IntgrnNotiRsltRespDTO respDTO, IupPrcsCd prcsCd) {
switch (respDTO.getStatCd()) {
case makefail:
return IupPrcsCd.FAIL;
case sendfail:
if (TryStatCd.cmplt.equals(respDTO.getTryStatCd()))
return IupPrcsCd.FAIL;
case makerdy:
return IupPrcsCd.CICV;
case making:
return IupPrcsCd.CICC;
case makeok:
return IupPrcsCd.COMP;
case sendok:
case sendcmplt:
case open:
return IupPrcsCd.INCM;
case close:
return IupPrcsCd.IPCP;
default:
return prcsCd;
}
}
private IupSendSttusCd sendSttusCd(IntgrnDetailStatVO row, IntgrnNotiRsltRespDTO respDTO) {
IupSendSttusCd iupSendSttusCd = null;
try {
switch (row.getCurStatCd().getIntgrnDtlStatCd()) {
case UNIDENTIFIED_USER:
if (PostSeCd.nvSigntalk.equals(row.getCurPostSe()))
iupSendSttusCd = IupSendSttusCd.NV_NOMB;
else
iupSendSttusCd = IupSendSttusCd.NOMB;
break;
case FORBIDDEN:
if (PostSeCd.nvSigntalk.equals(row.getCurPostSe()))
iupSendSttusCd = IupSendSttusCd.NV_DENY;
else
iupSendSttusCd = IupSendSttusCd.DENY;
break;
case SENT:
if (PostSeCd.nvSigntalk.equals(row.getCurPostSe()))
iupSendSttusCd = IupSendSttusCd.NV_SEND;
else
iupSendSttusCd = IupSendSttusCd.SEND;
break;
case RECEIVED:
case EXPIRED:
if (PostSeCd.nvSigntalk.equals(row.getCurPostSe()))
iupSendSttusCd = IupSendSttusCd.NV_RECV;
else
iupSendSttusCd = IupSendSttusCd.RECV;
break;
case READ:
if (PostSeCd.nvSigntalk.equals(row.getCurPostSe()))
iupSendSttusCd = IupSendSttusCd.NV_SIGN;
else
iupSendSttusCd = IupSendSttusCd.SIGN;
break;
case REG:
case MAKING:
case ACPT_OK:
case ACPT_CMPLT:
if (StatCd.makefail.equals(respDTO.getStatCd())
|| StatCd.sendfail.equals(respDTO.getStatCd()))
iupSendSttusCd = IupSendSttusCd.FAIL;
else
iupSendSttusCd = IupSendSttusCd.READY;
break;
case ACPT_FAIL:
case INVALID_VALUE:
case INTERNAL_ERROR:
case INVALID_REQUEST:
case FORBIDDEN_USER:
case FAIL:
iupSendSttusCd = IupSendSttusCd.FAIL;
break;
default:
break;
}
} catch (Exception e) {
log.info("IupSendSttusCd와 일치하는 값 없음. [ dataId {} IntgrnDtlStatCd {} ]", row.getLinkedUuid(), row.getCurStatCd().getIntgrnDtlStatCd());
}
return iupSendSttusCd;
}
}

@ -0,0 +1,66 @@
package cokr.xit.ens.biz.iup.signtalk.service.support;
import cokr.xit.ens.biz.iup.code.IupSendTypeCd;
import cokr.xit.ens.biz.iup.domain.repository.TbInputDataXitRepository;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
import cokr.xit.ens.modules.common.biztmplt.EnsPhaseProcSupport;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.IntgrnNotiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Component
@RequiredArgsConstructor
public class IupSigntalkSender implements EnsPhaseProcSupport<EnsResponseVO, Long> {
private final TbInputDataXitRepository tbInputDataXitRepository;
private final IntgrnNotiService intgrnNotiService;
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO statReady(List<Long> lnkInputIds) {
log.info("no process");
return null;
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO statBegin(Long arg) {
log.info("no process");
return null;
}
/**
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EnsResponseVO execute(Long lnkInputId){
EnsResponseVO responseVO = null;
try {
Long sendMastId = tbInputDataXitRepository.findLastSendMastIdByLnkInputIdAndSendType(lnkInputId, IupSendTypeCd.KP)
.orElseThrow(() -> new EnsException(EnsErrCd.SEND404, "일치하는 ENS 접수자료가 없습니다."));
responseVO = intgrnNotiService.sendBulk(sendMastId);
} catch (EnsException e){
responseVO = EnsResponseVO.errBuilder()
.errCode(e.getErrCd())
.errMsg(e.getMessage())
.build();
}
return responseVO;
}
}

@ -0,0 +1,5 @@
package cokr.xit.ens.biz.iup.signtalk.service.support.accept;
public interface Accept<T> {
T createDocument();
}

@ -0,0 +1,17 @@
package cokr.xit.ens.biz.iup.signtalk.service.support.accept;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.modules.kkoalimtalk.model.config.DocumentConfKkoAt;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class AcptDocKkoAt implements Accept<DocumentConfKkoAt> {
private final TbInputDataXit tbInputDataXit;
@Override
public DocumentConfKkoAt createDocument() {
return DocumentConfKkoAt.builder()
.build();
}
}

@ -0,0 +1,44 @@
package cokr.xit.ens.biz.iup.signtalk.service.support.accept;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.core.utils.DateUtil;
import cokr.xit.ens.modules.kkomydoc.model.config.DocumentConfKkoMd;
import cokr.xit.ens.modules.kkomydoc.model.config.Property;
import lombok.RequiredArgsConstructor;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
@RequiredArgsConstructor
public class AcptDocKkoMd implements Accept<DocumentConfKkoMd> {
private final TbInputDataXit tbInputDataXit;
private final String redirectUrl;
@Override
public DocumentConfKkoMd createDocument() {
return DocumentConfKkoMd.builder()
.hash(null)
.common_categories(Arrays.asList("NOTICE"))
.read_expired_at(DateUtil.dateToAbsTimeSec(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))))
// .read_expired_sec()
.property(this.createProperty(tbInputDataXit))
.bridge(null)
.build();
}
private Property createProperty(TbInputDataXit data) {
return Property.builder()
// .link(data.getPayUrl())
.link(redirectUrl)
.payload(null)
.message(null)
.cs_name("문의처")
.cs_number(data.getCallCenterNo())
// .external_document_uuid(data.getDataId())
// .external_document_uuid(data.getLinkedUuid())
.build();
}
}

@ -0,0 +1,38 @@
package cokr.xit.ens.biz.iup.signtalk.service.support.accept;
import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.core.utils.DateUtil;
import cokr.xit.ens.modules.nvsigntalk.model.config.DocumentConfNvSt;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
@RequiredArgsConstructor
public class AcptDocNvSt implements Accept<DocumentConfNvSt> {
private final TbInputDataXit tbInputDataXit;
private final String orgId;
private final String redirectUrl;
@Override
public DocumentConfNvSt createDocument() {
// int days = DateUtil.daysByFromBetweenTo(LocalDateTime.now(), tbInputDataXit.getTbInputXit().getPayExpiresDt());
return DocumentConfNvSt.builder()
// .valid_duration(DateUtil.daysToRelTime(days) / 1000)
.valid_duration_at(DateUtil.dateToAbsTimeSec(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))))
// .redirect_url(tbInputDataXit.getPayUrl())
.redirect_url(redirectUrl)
.publish_document_yn("y")
.document_hash(null)
.call_center_no(tbInputDataXit.getCallCenterNo())
.org_id(orgId)
.auth_require_yn("y")
.notification(null)
.calculation_key(null)
.category_key(null)
.document_key(null)
.build();
}
}

@ -0,0 +1,40 @@
package cokr.xit.ens.biz.traffic.cheonan.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
*
*/
public enum SndngProcessSttusCd implements CodeMapperType {
accept("접수")
, acptok("접수성공")
, acptfail("접수실패")
, ensmake("제작")
, ensstart("전송시작")
, ensok("전송성공")
, ensfail("전송실패")
, ensopen("열람중")
, ensclose("조회기간마감")
;
private final String code;
private final String codeNm;
SndngProcessSttusCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
}

@ -0,0 +1,66 @@
package cokr.xit.ens.biz.traffic.cheonan.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
*
*/
public enum SndngResultSttusCd implements CodeMapperType {
UNKNOWN("알수없음")
, REG("등록")
, MAKING("제작")
, ACPT_OK("접수요청성공")
, ACPT_FAIL("접수실패")
, ACPT_CMPLT("접수완료")
, UNIDENTIFIED_USER("비회원")
, FORBIDDEN("수신거부")
, INVALID_VALUE("파라미터 오류")
, INTERNAL_ERROR("API 서버 내부 오류")
, INVALID_REQUEST("유효하지 않은 요청")
, FORBIDDEN_USER("허용되지 않은 사용자")
, FAIL("전송실패")
, SENT("송신")
, RECEIVED("수신")
, READ("열람")
, EXPIRED("만료")
;
private final String code;
private final String codeNm;
SndngResultSttusCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
public static SndngResultSttusCd valueOfEnum(String statCd) {
if (statCd == null)
return SndngResultSttusCd.UNKNOWN;
SndngResultSttusCd sndngResultSttusCd = null;
try {
sndngResultSttusCd = SndngResultSttusCd.valueOf(statCd);
} catch (IllegalArgumentException e) {
sndngResultSttusCd = SndngResultSttusCd.UNKNOWN;
}
return sndngResultSttusCd;
}
}

@ -0,0 +1,49 @@
package cokr.xit.ens.biz.traffic.cheonan.code;
import cokr.xit.ens.core.code.CodeMapperType;
/**
*
*/
public enum SndngSeCd implements CodeMapperType {
UNKNOWN("알수없음")
,intgrnNoti("통합 전자고지")
,kkoMydoc("카카오페이 내문서함(인증톡)")
,kkoAlimtalk("카카오페이 알림톡")
,nvSigntalk("네이버 고지서(인증톡)")
,ktSigntalk("KT 인증톡")
,ktGibis("KT 인증톡(지비스)");
;
private final String code;
private final String codeNm;
SndngSeCd(String codeNm) {
this.code = this.name();
this.codeNm = codeNm;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getCodeNm() {
return this.codeNm;
}
public static SndngSeCd valueOfEnum(String statCd) {
if (statCd == null)
return SndngSeCd.UNKNOWN;
SndngSeCd SndngSeCd = null;
try {
SndngSeCd = SndngSeCd.valueOf(statCd);
} catch (IllegalArgumentException e) {
SndngSeCd = SndngSeCd.UNKNOWN;
}
return SndngSeCd;
}
}

@ -0,0 +1,130 @@
package cokr.xit.ens.biz.traffic.cheonan.init;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.repository.TcaNhtTmplatManageRepository;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.repository.TcaRlaybsnmManageRepository;
import cokr.xit.ens.core.init.InitJpaRunner;
import cokr.xit.ens.modules.common.code.PostSeCd;
import cokr.xit.ens.modules.common.ctgy.sys.mng.model.OrgMngDTO;
import cokr.xit.ens.modules.ktsigntalk.common.code.MTypeCd;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* -
*/
//TODO: 데이터초기화 목적으로 사용. ex) 최초 배포 시
//@Component
@Transactional
@Profile({"prod-traffic-cheonan", "local-test"})
public class TrafficCaJpaRunner extends InitJpaRunner {
ObjectMapper mapper = new ObjectMapper();
// @Value("${contract.custom.dng.nice.dici.rest.client-id}")
// private String DNG_NICE_CD_CLIENT_ID;
// @Value("${contract.custom.dng.nice.dici.rest.client-secret}")
// private String DNG_NICE_CD_CLIENT_SECRET;
// @Value("${contract.custom.dng.kakao.pay.mydoc.access-token}")
// private String DNG_KKO_MD_ACCESS_TOKEN;
// @Value("${contract.custom.dng.kakao.pay.mydoc.contract-uuid}")
// private String DNG_KKO_MD_CONTRACT_UUID;
//
// @Value("${contract.custom.sbg.nice.dici.rest.client-id}")
// private String SBG_NICE_CD_CLIENT_ID;
// @Value("${contract.custom.sbg.nice.dici.rest.client-secret}")
// private String SBG_NICE_CD_CLIENT_SECRET;
// @Value("${contract.custom.sbg.kakao.pay.mydoc.access-token}")
// private String SBG_KKO_MD_ACCESS_TOKEN;
// @Value("${contract.custom.sbg.kakao.pay.mydoc.contract-uuid}")
// private String SBG_KKO_MD_CONTRACT_UUID;
@Autowired
private TcaRlaybsnmManageRepository tcaRlaybsnmManageRepository;
@Autowired
private TcaNhtTmplatManageRepository tcaNhtTmplatManageRepository;
@Override
protected List<OrgMngDTO> createOrgMngDTO() {
// List<OrgMngDTO> list = new ArrayList<>();
// list.add(createOrgMngDTO("TCA01", "", "천안-동남구", "N", null, null, DNG_NICE_CD_CLIENT_ID, DNG_NICE_CD_CLIENT_SECRET, DNG_KKO_MD_ACCESS_TOKEN, DNG_KKO_MD_CONTRACT_UUID));
// list.add(createOrgMngDTO("TCA02", "", "천안-서북구", "N", null, null, SBG_NICE_CD_CLIENT_ID, SBG_NICE_CD_CLIENT_SECRET, SBG_KKO_MD_ACCESS_TOKEN, SBG_KKO_MD_CONTRACT_UUID));
// return list;
return tcaRlaybsnmManageRepository.findAll().stream()
.map(entity -> OrgMngDTO.builder()
.orgCd(entity.getSignguCode())
.orgNm(entity.getSignguNm())
.kkoMdAccessToken(entity.getKakaoAccessToken())
.kkoMdContractUuid(entity.getKakaoContractUuid())
.kkoBpCsignYn("N")
// .kkoBpBillerCode(KKO_BP_BILLER_CODE)
// .kkoBpAuthorization(KKO_BP_AUTHORIZATION)
// .kkoBpCsignPrepayApi(kkoBpPrepayApi)
// .kkoBpCsignPayResultApi(kkoBpPayResultApi)
// .kkoAtBsid(KKO_AT_BSID)
// .kkoAtPasswd(KKO_AT_PASSWD)
// .kkoAtSenderKey(KKO_AT_SENDER_KEY)
.niceCdSiteCode(null)
.niceCdSitePw(entity.getNiceSiteCode())
.niceCdClientId(entity.getNiceClientId())
.niceCdClientSercet(entity.getNiceClientSecret())
// .nvStXNaverClientId(NV_ST_X_NAVER_CLIENT_ID)
// .nvStXNaverClientSecret(NV_ST_X_NAVER_CLIENT_SECRET)
// .nvStOrgId(nvOrgId)
// .ktStAccessToken(null)
// .ktStServiceCd(null)
// .ktStServiceKey(null)
.ktStClientId(entity.getKtClientId())
.ktStClientSecret(entity.getKtClientSecret())
.build())
.collect(Collectors.toList());
}
@Override
protected List<Map<String, Object>> createTmpltMngDTO() {
// List<Map<String, Object>> list = new ArrayList<>();
// list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.ktGibis, null, "TCA01", "TCA0001", "주정차단속-천안-동남구", "[천안-동남구] 소유차량(#{CAR_NO})의 주정차과태료", "Y"
// , null
// , createTmpltMngKkoMydoc(null, null, null, null, null, "044-211-3377", "문의처", "Y", "Y", "Y")
// , null
// , null
// , createTmpltMngKtGibis(null, null, null, null, null, "MC001", MTypeCd.mms, 1, "044-211-3377", "044-211-3377", "Y", "Y", "Y")
// )
// , Map.class));
// list.add(mapper.convertValue(createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.ktGibis, null, "TCA02", "TCA0001", "주정차단속-천안-서북구", "[천안-서북구] 소유차량(#{CAR_NO})의 주정차과태료", "Y"
// , null
// , createTmpltMngKkoMydoc(null, null, null, null, null, "044-211-3377", "문의처", "Y", "Y", "Y")
// , null
// , null
// , createTmpltMngKtGibis(null, null, null, null, null, "MC001", MTypeCd.mms, 1, "044-211-3377", "044-211-3377", "Y", "Y", "Y")
// )
// , Map.class));
// return list;
return tcaNhtTmplatManageRepository.findAll().stream()
.map(entity -> createTmpltMngIntgrn(PostSeCd.kkoMydoc, PostSeCd.ktGibis, null, entity.getSignguCode(), entity.getNhtTmplatId(), entity.getNhtSj(), entity.getNhtCn(), "Y"
, null
, createTmpltMngKkoMydoc(null, null, null, null, null, entity.getCstmrCnterTlphonNo(), entity.getCstmrCnterNm() == null ? "문의처" : entity.getCstmrCnterNm(), "Y", "Y", "Y")
, null
, null
, createTmpltMngKtGibis(null, null, null, null, null, "?????", MTypeCd.mms, "2", 1, entity.getCstmrCnterTlphonNo(), entity.getCstmrCnterTlphonNo(), "Y", "Y", "Y")
))
.map(tmpltMngIntgrnDTO -> (Map<String, Object>) mapper.convertValue(tmpltMngIntgrnDTO, Map.class))
.collect(Collectors.toList());
}
}

@ -0,0 +1,70 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.domain;
import cokr.xit.ens.biz.traffic.cheonan.code.SndngProcessSttusCd;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldCreate;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldUpdate;
import lombok.*;
import javax.persistence.*;
/**
*
*/
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_elctrn_ntic_sndng")
public class TcaElctrnNticSndng {
@Id
@Column(name = "elctrn_ntic_sndng_id", length = 20)
private String elctrnNticSndngId;
@Column(name = "signgu_code", length = 5)
private String signguCode;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "nht_tmplat_id")
private TcaNhtTmplatManage tcaNhtTmplatManage;
@Column(name = "sndng_ty_code", length = 5)
private String sndngTyCode;
@Column(name = "sndng_co", length = 10)
private Integer sndngCo;
@Column(name = "sndng_process_sttus", length = 2)
@Setter
@Enumerated(EnumType.STRING)
private SndngProcessSttusCd sndngProcessSttus;
@Column(name = "sndng_dt", length = 14)
private String sndngDt;
@Column(name = "clos_dt", length = 14)
private String closDt;
@Embedded
private FieldCreate create;
@Embedded
@Setter
private FieldUpdate update;
@Column(name = "error_cn", length = 1000)
@Setter
private String errorCn;
@Lob
@Setter
@Column(name = "error_dtls")
private String errorDtls;
@Column(name = "ffnlg_code", length = 2)
private String ffnlgCode;
}

@ -0,0 +1,82 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.domain;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldCreate;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldUpdate;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*;
/**
*
*/
@Getter
@ToString
@Builder
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_elctrn_ntic_sndng_detail", schema = "", catalog = "", indexes = {
@Index(name = "idx_tca_ens_detail_01", columnList = "main_code"),
// @Index(name = "idx_tca_ens_detail_02", columnList = "external_document_uuid"),
})
public class TcaElctrnNticSndngDetail {
@Id
@Column(name = "elctrn_ntic_sndng_detail_id", length = 20)
private String elctrnNticSndngDetailId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "elctrn_ntic_sndng_id")
private TcaElctrnNticSndng elctrnNticSndng;
@Column(name = "signgu_code", length = 5)
private String signguCode;
@Column(name = "main_code", length = 20)
private String mainCode;
@Column(name = "ihidnum", length = 100, updatable = false)
private String ihidnum;
// @Lob
// @Column(name = "cn_detail")
// private String cnDetail;
@Lob
@Column(name = "tmplt_msg_data")
private String tmpltMsgData;
@Lob
@Column(name = "mobile_page_cn")
private String mobilePageCn;
@Embedded
private FieldCreate create;
@Embedded
private FieldUpdate update;
@Column(name = "external_document_uuid", length = 40)
@Setter
private String externalDocumentUuid;
@Column(name = "ffnlg_code", length = 2)
private String ffnlgCode;
@Column(name = "use_instt_idntfc_id")
private Integer useInsttIdntfcId;
}

@ -0,0 +1,65 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.domain;
import cokr.xit.ens.biz.traffic.cheonan.code.SndngResultSttusCd;
import cokr.xit.ens.biz.traffic.cheonan.code.SndngSeCd;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldCreate;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime;
/**
*
*/
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_elctrn_ntic_sndng_result")
public class TcaElctrnNticSndngResult {
@Id
@Column(name = "elctrn_ntic_sndng_detail_id", length = 20)
private String elctrnNticSndngDetailId;
@Column(name = "sndng_result_sttus", length = 20)
@Enumerated(EnumType.STRING)
private SndngResultSttusCd sndngResultSttus;
@Column(name = "requst_dt", length = 14)
private String requstDt;
@Column(name = "inqire_dt", length = 14)
private String inqireDt;
@Column(name = "readng_dt", length = 14)
private String readngDt;
@Column(name = "error_cn", length = 1000)
private String errorCn;
@Embedded
private FieldCreate create;
@UpdateTimestamp
@Column(name = "last_updt_dt", nullable = true)
private LocalDateTime lastUpdtDt;
@Column(name = "sndng_se", length = 10)
@Enumerated(EnumType.STRING)
private SndngSeCd sndngSe;
}

@ -0,0 +1,69 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.domain;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldCreate;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldUpdate;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
/**
* 릿
*/
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_nht_tmplat_manage")
public class TcaNhtTmplatManage {
@Id
@Column(name = "nht_tmplat_id", length = 5)
private String nhtTmplatId;
@Column(name = "signgu_code", length = 5)
private String signguCode;
@Column(name = "sndng_ty_code", length = 1)
private String sndngTyCode;
@Column(name = "nht_nm", length = 1000)
private String nhtNm;
@Column(name = "nht_sj", length = 1000)
private String nhtSj;
@Column(name = "nhtCn", length = 4000)
private String nhtCn;
@Column(name = "cstmr_cnter_nm", length = 100)
private String cstmrCnterNm;
@Column(name = "cstmr_cnter_tlphon_no", length = 14)
private String cstmrCnterTlphonNo;
@Column(name = "redirect_url", length = 255)
private String redirectUrl;
@Column(name = "use_at", length = 1)
private String useAt;
@Embedded
private FieldCreate create;
@Embedded
private FieldUpdate update;
}

@ -0,0 +1,70 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.domain;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldCreate;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.embeded.FieldUpdate;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.persistence.*;
/**
*
*/
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tb_rlaybsnm_manage")
public class TcaRlaybsnmManage {
@Id
@Column(name = "signgu_code", length = 5)
private String signguCode;
@Column(name = "ffnlg_code")
private String ffnlgCode;
@Column(name = "signgu_nm")
private String signguNm;
@Column(name = "kakao_access_token")
private String kakaoAccessToken;
@Column(name = "kakao_contract_uuid")
private String kakaoContractUuid;
@Column(name = "nice_site_code")
private String niceSiteCode;
@Column(name = "nice_client_id")
private String niceClientId;
@Column(name = "nice_client_secret")
private String niceClientSecret;
@Column(name = "kt_client_id")
private String ktClientId;
@Column(name = "kt_client_secret")
private String ktClientSecret;
@Embedded
private FieldCreate create;
@Embedded
private FieldUpdate update;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save