From 5aed628da0d09da95fb1f3c5dd2c4cb60646b9ce Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Fri, 11 Oct 2024 16:14:51 +0900 Subject: [PATCH] refactor: Nice CI Accept, Send code refactoring --- .../nice/service/NiceCiAcceptService.java | 72 ++++++++++--------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java index b0fd3f3..93352ac 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java @@ -107,41 +107,8 @@ public class NiceCiAcceptService { final String prefixBillUid = PostSeCd.intgrnNoti.getCode() + "-" + IdGenerator.getCurrentTimeSec(); for(NiceCiDTO.InputXit xit : list){ - final KkoPayUrlRespData kkoPayUrlRespData = buildKkoPayUrlRespData(xit.getPayExpiresDt()); - final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(xit.getOrgCd()) - .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); - - NiceCiDTO.BillHistDTO billHistDTO = null; try { - List inputDataXits = xit.getInputDataXits(); - for (NiceCiDTO.InputDataXit data : inputDataXits) { - - //---------------------------------------------------------- - // pay Url API call & Get Result - //---------------------------------------------------------- - PayApiRespDTO> respDTO = getPayUrl(data, billHistDTO, orgMng, kkoPayUrlRespData); - - //---------------------------------------------------------- - // API Call 후처리 - response 반영 & 결제 이력 생성 - //---------------------------------------------------------- - // FIXME: API 호출 결과 SET - 연계 설정후 확인 필요 - data.setPayUrl(String.valueOf(respDTO.getData())); - niceCiMapper.updatePayUrlOfDataInput(data); - - final String billUid = IdGenerator.getShortUUID(prefixBillUid); - // FIXME: API 호출 결과 로그 저장 - billHistDTO.setBillUid(billUid); - billHistDTO.setResponseData(String.valueOf(respDTO.getData())); - billHistoryService.updateBillHistory(billHistDTO); - - // FIXME: bill_se_cd, org_cd 설정 및 확인 필요??? - insertBillRecord(data, xit, billUid); - - // FIXME: biller_notice_key, custom_url, expire_at 설정 및 확인 필요??? - insertBillKkoRecord(data, kkoPayUrlRespData, billUid); - } - xit.setPrcsCd(IupPrcsCd.GRUC.getCode()); - niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + processAccept(xit, prefixBillUid); // FIXME: API 호출 에러 } catch (EnsException e) { @@ -163,6 +130,43 @@ public class NiceCiAcceptService { .build(); } + private void processAccept(NiceCiDTO.InputXit xit, String prefixBillUid) throws Exception { + final KkoPayUrlRespData kkoPayUrlRespData = buildKkoPayUrlRespData(xit.getPayExpiresDt()); + final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(xit.getOrgCd()) + .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); + + //List inputDataXits = xit.getInputDataXits(); + for (NiceCiDTO.InputDataXit data : xit.getInputDataXits()) { + NiceCiDTO.BillHistDTO billHistDTO = new NiceCiDTO.BillHistDTO(); + + //---------------------------------------------------------- + // pay Url API call & Get Result + //---------------------------------------------------------- + PayApiRespDTO> respDTO = getPayUrl(data, billHistDTO, orgMng, kkoPayUrlRespData); + + //---------------------------------------------------------- + // API Call 후처리 - response 반영 & 결제 이력 생성 + //---------------------------------------------------------- + // FIXME: API 호출 결과 SET - 연계 설정후 확인 필요 + data.setPayUrl(String.valueOf(respDTO.getData())); + niceCiMapper.updatePayUrlOfDataInput(data); + + final String billUid = IdGenerator.getShortUUID(prefixBillUid); + // FIXME: API 호출 결과 로그 저장 + billHistDTO.setBillUid(billUid); + billHistDTO.setResponseData(String.valueOf(respDTO.getData())); + billHistoryService.updateBillHistory(billHistDTO); + + // FIXME: bill_se_cd, org_cd 설정 및 확인 필요??? + insertBillRecord(data, xit, billUid); + + // FIXME: biller_notice_key, custom_url, expire_at 설정 및 확인 필요??? + insertBillKkoRecord(data, kkoPayUrlRespData, billUid); + } + xit.setPrcsCd(IupPrcsCd.GRUC.getCode()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + } + /** * NICE CI payUrn Call * @param dataXit NiceCiDTO.InputDataXit