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