|
|
|
@ -23,6 +23,7 @@ import kr.xit.biz.ens.model.cmm.SndngMssageParam;
|
|
|
|
|
import kr.xit.biz.ens.model.cntc.CntcDTO;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.v1.KkopayDocAttrDTO;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO;
|
|
|
|
|
import kr.xit.core.exception.BizRuntimeException;
|
|
|
|
|
import kr.xit.core.model.ApiResponseDTO;
|
|
|
|
|
import kr.xit.core.service.AbstractService;
|
|
|
|
@ -51,8 +52,12 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
public class EnsBatchStatusService extends AbstractService implements IEnsBatchStatusService {
|
|
|
|
|
@Value("${app.contract.host}")
|
|
|
|
|
private String apiHost;
|
|
|
|
|
|
|
|
|
|
@Value("${app.contract.kakao.api.pay.bulkstatus}")
|
|
|
|
|
private String apiKkoBulkStatus;
|
|
|
|
|
private String apiKkopayBulkStatus;
|
|
|
|
|
|
|
|
|
|
@Value("${app.contract.kakao.api.talk.bulkstatus}")
|
|
|
|
|
private String apiKkotalkBulkStatus;
|
|
|
|
|
|
|
|
|
|
@Value("${app.contract.kakao.bulk-max-cnt}")
|
|
|
|
|
private int bulkKkoMaxCnt;
|
|
|
|
@ -97,10 +102,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
|
|
|
|
|
* 모바일 페이지 생성 : tb_ens_mobile_page_manage
|
|
|
|
|
* 연계발송결과 생성 : tb_cntc_sndng_result
|
|
|
|
|
*/
|
|
|
|
|
case KAKAO -> statusKakao(dto);
|
|
|
|
|
case KAKAO -> statusKakaopay(dto);
|
|
|
|
|
|
|
|
|
|
case KAKAO_NEW
|
|
|
|
|
-> statusKakao(dto);
|
|
|
|
|
-> statusKakaotalk(dto);
|
|
|
|
|
//break;
|
|
|
|
|
case KT_BC -> {}
|
|
|
|
|
|
|
|
|
@ -122,10 +127,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
|
|
|
|
|
* @param dto BatchEnsRequest
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private void statusKakao(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiKkoBulkStatus;
|
|
|
|
|
private void statusKakaopay(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiKkopayBulkStatus;
|
|
|
|
|
|
|
|
|
|
final List<String> docsBinderUuids = mapper.selectKakaoStatusTgts(dto);
|
|
|
|
|
final List<String> docsBinderUuids = mapper.selectKakaopayStatusTgts(dto);
|
|
|
|
|
final List<List<String>> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt);
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
@ -153,11 +158,12 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
|
|
|
|
|
// 결과 반영
|
|
|
|
|
resList.forEach(o ->
|
|
|
|
|
o.getDocuments().forEach(t -> {
|
|
|
|
|
mapper.updateKakaoStatusInfo(t);
|
|
|
|
|
mapper.updateKakaopayStatusInfo(t);
|
|
|
|
|
KkopayDocAttrDTO.DocStatus statusData = t.getStatus_data();
|
|
|
|
|
if(Checks.isNotEmpty(statusData)) {
|
|
|
|
|
mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder()
|
|
|
|
|
.documentBinderUuid(t.getDocument_binder_uuid())
|
|
|
|
|
mapper.updateCntcSndngResultByKkopay(
|
|
|
|
|
CntcDTO.SndngResult.builder()
|
|
|
|
|
.docKeyId(t.getDocument_binder_uuid())
|
|
|
|
|
.sndngResultSttus(StringUtils.defaultString(
|
|
|
|
|
String.valueOf(statusData.getDoc_box_status()), "FAIL"))
|
|
|
|
|
.requstDt(Checks.isEmpty(statusData.getDoc_box_sent_at()) ? null
|
|
|
|
@ -169,8 +175,9 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
|
|
|
|
|
.errorCn(t.getError_message())
|
|
|
|
|
.build());
|
|
|
|
|
}else{
|
|
|
|
|
mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder()
|
|
|
|
|
.documentBinderUuid(t.getDocument_binder_uuid())
|
|
|
|
|
mapper.updateCntcSndngResultByKkopay(
|
|
|
|
|
CntcDTO.SndngResult.builder()
|
|
|
|
|
.docKeyId(t.getDocument_binder_uuid())
|
|
|
|
|
.sndngResultSttus(t.getError_code())
|
|
|
|
|
.errorCn(t.getError_message())
|
|
|
|
|
.build());
|
|
|
|
@ -178,4 +185,67 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* 문서중개자 전송후 상태 조회
|
|
|
|
|
*
|
|
|
|
|
* @param dto BatchEnsRequest
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private void statusKakaotalk(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiKkotalkBulkStatus;
|
|
|
|
|
|
|
|
|
|
final List<String> envelopeIds = mapper.selectKakaotalkStatusTgts(dto);
|
|
|
|
|
final List<List<String>> partitions = ListUtils.partition(envelopeIds, bulkKkoMaxCnt);
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
final List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
.map(envelopes -> apiWebClient.exchange(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
KkotalkDTO.BulkStatusRequest.builder()
|
|
|
|
|
.signguCode(dto.getSignguCode())
|
|
|
|
|
.ffnlgCode(dto.getFfnlgCode())
|
|
|
|
|
.envelopes(envelopes)
|
|
|
|
|
.build(),
|
|
|
|
|
ApiResponseDTO.class,
|
|
|
|
|
CmmEnsBizUtils.getHeadeMap())
|
|
|
|
|
).toList();
|
|
|
|
|
|
|
|
|
|
final List<KkotalkDTO.BulkStatusResponse> resList = new ArrayList<>();
|
|
|
|
|
//noinspection rawtypes
|
|
|
|
|
for(ApiResponseDTO apiResult : apiResults) {
|
|
|
|
|
if(apiResult.getData() != null) {
|
|
|
|
|
resList.add(toObjByObj(apiResult.getData(), KkotalkDTO.BulkStatusResponse.class));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 결과 반영
|
|
|
|
|
resList.forEach(o ->
|
|
|
|
|
o.getEnvelopeStatus().forEach(t -> {
|
|
|
|
|
mapper.updateKakaotalkStatusInfo(t);
|
|
|
|
|
//EnvelopeStatus statusData = t;
|
|
|
|
|
if(Checks.isNotEmpty(t)) {
|
|
|
|
|
mapper.updateCntcSndngResultByKkotalk(
|
|
|
|
|
CntcDTO.SndngResult.builder()
|
|
|
|
|
.docKeyId(t.getEnvelopeId())
|
|
|
|
|
.sndngResultSttus(StringUtils.defaultString(
|
|
|
|
|
String.valueOf(t.getStatus()), "FAIL"))
|
|
|
|
|
.requstDt(t.getSentAt())
|
|
|
|
|
.inqireDt(t.getReceivedAt())
|
|
|
|
|
.readngDt(t.getReadAt())
|
|
|
|
|
.errorCn(t.getErrorMessage())
|
|
|
|
|
.build());
|
|
|
|
|
}else{
|
|
|
|
|
mapper.updateCntcSndngResultByKkotalk(
|
|
|
|
|
CntcDTO.SndngResult.builder()
|
|
|
|
|
.docKeyId(t.getEnvelopeId())
|
|
|
|
|
.sndngResultSttus(t.getErrorCode())
|
|
|
|
|
.errorCn(t.getErrorMessage())
|
|
|
|
|
.build());
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|