feat: NICE CI accept 진행

dev
Jonguk. Lim 1 month ago
parent bb0cce3a6b
commit ee392bb1e9

@ -1,7 +1,7 @@
Insert into TB_INPUT_XIT
(LNK_INPUT_ID, ORG_CD, JOB_CD, TOT_CNT, PRCS_CD, RUN_DT, EXPIRES_DT, SEND_TYPE, REG_ID, REG_DT, PAY_EXPIRES_DT)
Values
(302400012001, '0001', 'A0001', 2, 'TRRG', SYSDATE, SYSDATE + 1
(302400012002, '0001', 'A0001', 2, 'TGRG', SYSDATE, SYSDATE + 1
, 'NI', 'cntc', SYSDATE, SYSDATE+30);
Insert into TB_INPUT_DATA_XIT
@ -9,7 +9,7 @@ Insert into TB_INPUT_DATA_XIT
GENDER, MSG_DATA, REG_ID, REG_DT, UPD_ID,
UPD_DT, PAY_STATUS_CD, PAY_URL, CAR_NO)
Values
(302400012001, 'EL3004202408080439501', '8312181111111', '홍길동', '19831218',
(302400012002, 'EL3004202408080439501', '8312181111111', '홍길동', '19831218',
'1', '{"~~@@!!CAR_NO!!@@~~":"24주9434","~~@@!!COMPANY!!@@~~":"수도권제1순환","~~@@!!TERM!!@@~~":"2020년 11월 16일~2021년 04월 15일","~~@@!!DEGREE!!@@~~":"24주9434","~~@@!!FEE!!@@~~":"147,400","~~@@!!COUNT!!@@~~":"69","~~@@!!METHOD!!@@~~":"가상계좌 및 카카오페이","~~@@!!BANK_ACCOUNT!!@@~~":"-(가상계좌) : 농협은행 792000-37-048721\n국민은행 731190-72-112238\n우리은행 283753-54-918171\n신한은행 562146-27-216570","~~@@!!DEADLINE!!@@~~":"2024년09월10일","~~@@!!CALL_NO!!@@~~":"044-211-3377"}', 'cephis00', SYSDATE, '',
'', '', '', '24주9434');
@ -18,10 +18,10 @@ Insert into TB_INPUT_DATA_XIT
GENDER, MSG_DATA, REG_ID, REG_DT, UPD_ID,
UPD_DT, PAY_STATUS_CD, PAY_URL, CAR_NO)
Values
(302400012001, 'EL3004202408080441611', '8312181111111', '홍길동', '19831218',
(302400012002, 'EL3004202408080441611', '8312181111111', '홍길동', '19831218',
'1', '{"~~@@!!CAR_NO!!@@~~":"806노9066","~~@@!!COMPANY!!@@~~":"수도권제1순환","~~@@!!TERM!!@@~~":"2024년 03월 21일~2024년 06월 04일","~~@@!!DEGREE!!@@~~":"806노9066","~~@@!!FEE!!@@~~":"988,600","~~@@!!COUNT!!@@~~":"61","~~@@!!METHOD!!@@~~":"가상계좌 및 카카오페이","~~@@!!BANK_ACCOUNT!!@@~~":"-(가상계좌) : 농협은행 792000-37-100871\n국민은행 731190-72-160185\n우리은행 282376-85-718212\n신한은행 562146-27-582924","~~@@!!DEADLINE!!@@~~":"2024년09월10일","~~@@!!CALL_NO!!@@~~":"044-211-3377"}', 'cephis00', SYSDATE, '',
'', '', '', '806노9066');
commit;
@ -177,7 +177,3 @@ Insert into ENS_BILL_HIS
Values
(40336145, TO_TIMESTAMP('2024/10/02 PM 4:45:05.331000','YYYY/MM/DD AM fmHH12fm:MI:SS.FF'), TO_TIMESTAMP('2024/10/02 PM 4:45:05.331000','YYYY/MM/DD AM fmHH12fm:MI:SS.FF'), 'bpKko', 'intgrnNoti-1727843102-fn.x8QpG4JnaBd6psESO6l',
'EL3020202408060407773', 'VD_URL', '{"data":{"biller_user_key":"EL3020202408060407773","expire_at":"20241010235900","parameters":{"orgCd":"0001"},"custom_url":{"notice_url":"https://phts-manager.koti.re.kr/iup/kakao/notice","prepay_url":"https://phts-manager.koti.re.kr/iup/kakao/prepay","pay_result_url":"https://phts-manager.koti.re.kr/iup/kakao/pay-result"}}}', '{"res_code":"OK","message":"정상응답","data":{"url":"https://billgates-web.kakao.com/r/platform/pages/paynow/search/1832/11/1a481760-b0da-4a77-9a7a-74951db5fa01"}}', '0001');

@ -113,14 +113,17 @@ public class KkoPayUrlService implements PayUrlService<PayUrlData<BillKkoPay>, S
* API RE API
*/
Optional.ofNullable(data.getBillDetail())
// GET billerUserKey
.map(billKkoPay -> {
log.info("KkoPayUrlService::callApi - createMessage: {}", billKkoPay.getBillerUserKey());
return safely(() -> createMessage(billKkoPay.getBillerUserKey()));
})
// ens_org_mng 테이블 kko_bp_url_api -> PayUrlData<BillKkoPay> url로 set
.map(param -> {
log.info("KkoPayUrlService::callApi - loadReqData: {}", param);
return safely(() -> loadReqData(data, useSysUrl, param));
})
//
.map(param -> {
log.info("KkoPayUrlService::callApi - payUseSysApi.payUrl", param);
return safely(() -> payUseSysApi.payUrl(useSysUrl, param, null));

@ -4,6 +4,7 @@ import java.util.*;
import org.apache.ibatis.annotations.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*;
import cokr.xit.ens.modules.nice.model.*;
/**
@ -31,4 +32,5 @@ public interface INiceCiMapper {
int saveBillKko(final NiceCiDTO.BillKkoDTO billKkoDTO);
int updatePayUrlOfDataInput(final NiceCiDTO.InputDataXit inputDataXit);
int updatePrcsCdOfInputXit(final NiceCiDTO.InputXit inputXit);
Optional<OrgMng> selectKkoBpApiUrlFromEnsOrgMng(String orgCd);
}

@ -3,6 +3,7 @@ package cokr.xit.ens.modules.nice.service;
import java.util.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.*;
import org.springframework.transaction.annotation.*;
@ -10,10 +11,14 @@ import com.google.gson.*;
import cokr.xit.ens.biz.iup.code.*;
import cokr.xit.ens.core.aop.*;
import cokr.xit.ens.core.exception.*;
import cokr.xit.ens.core.exception.code.*;
import cokr.xit.ens.core.utils.*;
import cokr.xit.ens.modules.common.code.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.kko.service.process.model.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.api.*;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*;
import cokr.xit.ens.modules.common.ctgy.sys.mng.service.*;
import cokr.xit.ens.modules.nice.mapper.*;
import cokr.xit.ens.modules.nice.model.*;
@ -52,6 +57,9 @@ public class NiceCiAcceptService {
private final NiceCiApiService niceCiApiService;
private final INiceCiMapper niceCiMapper;
private final PayUseSysApi payUseSysApi;
private Gson gson = new GsonBuilder().disableHtmlEscaping().create();
/**
@ -67,7 +75,8 @@ public class NiceCiAcceptService {
*
* -- 2. bill
* -- 3.
* -- 4. tb_input_data_xit pay_url URL UPDATE
* -- 4. KkoPayUrlService.callApi() tb_input_data_xit pay_url URL UPDATE
* KkoPayUrlServiceTest
* -- 5. tb_input_xit prcs_cd='GRUC' / prcs_cd='TGRF'
* @return
* </pre>
@ -78,6 +87,13 @@ public class NiceCiAcceptService {
niceCiParam.setPrcsCd(IupPrcsCd.TGRG.getCode());
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiAcceptTgts(niceCiParam);
if(list.isEmpty()){
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.ERR404)
.errMsg(EnsErrCd.ERR404.getCodeNm())
.build();
}
list.forEach(d -> {
niceCiParam.setLnkInputId(d.getLnkInputId());
d.setInputDataXits(niceCiMapper.selectNiceCiAcceptDatas(niceCiParam));
@ -92,19 +108,25 @@ public class NiceCiAcceptService {
.payResultUrl(BILL_HOST + BILL_PAYREUSLT_URL)
.build());
final String expireAt = DateUtil.getTodayAndNowTime("YYYYMMddHHmmss");
final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(list.get(0).getOrgCd())
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm()));
for(NiceCiDTO.InputXit xit : list){
try {
List<NiceCiDTO.InputDataXit> inputDataXits = xit.getInputDataXits();
for (NiceCiDTO.InputDataXit data : inputDataXits) {
final long bilId = keySequenceService.getKeySequence("bill_id");
String payUrl = getPayUrl(data, orgMng);
data.setPayUrl(payUrl);
niceCiMapper.updatePayUrlOfDataInput(data);
final String billUid = IdGenerator.getShortUUID(prefixBillUid);
// FIXME: bill_se_cd, org_cd 설정 및 확인 필요???
niceCiMapper.insertBill(
NiceCiDTO.BillDTO.builder()
.billId(bilId)
.billId(keySequenceService.getKeySequence("Bill_id"))
.billUid(billUid)
.billerUserKey(data.getDataId())
.billSeCd(BillSeCd.privt.getCode())
@ -114,7 +136,7 @@ public class NiceCiAcceptService {
// FIXME: biller_notice_key, custom_url, expire_at 설정 및 확인 필요???
niceCiMapper.saveBillKko(
NiceCiDTO.BillKkoDTO.builder()
.billId(bilId)
.billId(keySequenceService.getKeySequence("BillKko_id"))
.billerUserKey(data.getDataId())
.billerNoticeKey(billUid)
.customUrl(customUrl)
@ -123,12 +145,19 @@ public class NiceCiAcceptService {
.build()
);
data.setPayUrl(customUrl);
niceCiMapper.updatePayUrlOfDataInput(data);
}
}
xit.setPrcsCd(IupPrcsCd.GRUC.getCode());
niceCiMapper.updatePrcsCdOfInputXit(xit);
// FIXME: API 호출 에러
} catch (EnsException e) {
if(EnsErrCd.API_COMM_ERROR.equals(e.getErrCd())){
xit.setPrcsCd(IupPrcsCd.TGRF.getCode());
niceCiMapper.updatePrcsCdOfInputXit(xit);
};
} catch (Exception e){
xit.setPrcsCd(IupPrcsCd.TGRF.getCode());
niceCiMapper.updatePrcsCdOfInputXit(xit);
@ -141,5 +170,24 @@ public class NiceCiAcceptService {
.build();
}
private String getPayUrl(final NiceCiDTO.InputDataXit data, final OrgMng orgMng){
Map<String, Object> map = new HashMap<>();
map.put("billerUserKey", data.getDataId());
Map<String, Object> param = new HashMap<>();
param.put("data", map);
ResponseEntity<String> resEntity = payUseSysApi.payUrl(orgMng.getKkoBpUrlApi(), param,
null);
// 마스터 상태 실패처리
if(resEntity.getStatusCode() != HttpStatus.OK){
throw new EnsException(EnsErrCd.API_COMM_ERROR, EnsErrCd.API_COMM_ERROR.getCodeNm());
}
String rsltStr = resEntity.getBody();
log.info(rsltStr);
//try {
Map<String, Object> m = gson.fromJson(rsltStr, Map.class);
log.info("{}", m);
return "";
}
}

@ -161,4 +161,14 @@
WHERE lnk_input_id = #{lnkInputId}
</update>
<select id="selectKkoBpApiUrlFromEnsOrgMng" parameterType="string" resultType="cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng">
/** iup-niceci-mapper|selectKkoBpApiUrlFromEnsOrgMng-API url 조회|julim */
SELECT kko_bp_url_api AS kkoBpUrlApi
, kko_bp_biller_code AS kkoBpBillerCode
, kko_bp_authorization AS kkoBpAuthorization
FROM ens_org_mng
WHERE org_cd = #{orgCd}
</select>
</mapper>

Loading…
Cancel
Save