feat: 카카오톡 status 반영

main
Jonguk. Lim 3 months ago
parent 1cbbb8c8b4
commit 833080747a

@ -84,5 +84,8 @@ where teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc=';
select DATE_FORMAT(DATE_ADD(clos_dt, INTERVAL 1 DAY), '%Y-%m-%dT%H:%i:%s') select DATE_FORMAT(DATE_ADD(clos_dt, INTERVAL 1 DAY), '%Y-%m-%dT%H:%i:%s')
, DATE_FORMAT(clos_dt, '%Y-%m-%dT%H:%i:%s') , DATE_FORMAT(null, '%Y-%m-%dT%H:%i:%s')
, DATE_FORMAT('', '%Y-%m-%dT%H:%i:%s')
, DATE_FORMAT('2024-09-05T23:59:59', '%Y%m%d%H%i%s')
, sysdate()
from tb_ens_unity_sndng_mastr; from tb_ens_unity_sndng_mastr;

@ -13,6 +13,7 @@ import kr.xit.biz.ens.model.cmm.TmplatManage;
import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.cntc.CntcDTO;
import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO;
import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO;
import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO;
import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData;
/** /**
@ -336,24 +337,41 @@ public interface IEnsBatchMapper {
/** /**
* <pre> * <pre>
* *
* - tb_ens_sndng_mastr, tb_ens_kakao_my_doc * - tb_ens_sndng_mastr, tb_ens_kakao_my_doc
* @param dto EnsDTO.BatchEnsRequest * @param dto EnsDTO.BatchEnsRequest
* @return List<String> * @return List<String>
* </pre> * </pre>
*/ */
List<String> selectKakaoStatusTgts(final SndngMssageParam dto); List<String> selectKakaopayStatusTgts(final SndngMssageParam dto);
/**
* <pre>
*
* - tb_ens_sndng_mastr, tb_ens_kakao_d10
* @param dto EnsDTO.BatchEnsRequest
* @return List<String>
* </pre>
*/
List<String> selectKakaotalkStatusTgts(final SndngMssageParam dto);
/** /**
* <pre> * <pre>
* *
* - tb_ens_kakao_my_doc * - tb_ens_kakao_my_doc
* @param dto EnsDTO.KakaoMyDoc * @param dto EnsDTO.KakaoMyDoc
* @return int * @return int
* </pre> * </pre>
*/ */
// FIXME: kakao v1 or v2 int updateKakaopayStatusInfo(final KkopayDocBulkDTO.BulkStatus dto);
int updateKakaoStatusInfo(final KkopayDocBulkDTO.BulkStatus dto); /**
* <pre>
*
* - tb_ens_kakao_d10
* @param dto EnsDTO.KakaoMyDoc
* @return int
* </pre>
*/
int updateKakaotalkStatusInfo(final KkotalkDTO.EnvelopeStatusResponse dto);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// status // status
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -374,12 +392,19 @@ public interface IEnsBatchMapper {
int insertCntcSndngResult(final CntcDTO.SndngResult dto); int insertCntcSndngResult(final CntcDTO.SndngResult dto);
/** /**
* - * -
* - tb_cntc_sndng_result, tb_ens_kakao_my_doc * - tb_cntc_sndng_result, tb_ens_kakao_my_doc
* @param dto SndngResult * @param dto SndngResult
* @return int * @return int
*/ */
int updateCntcSndngResultByKkoMyDoc(final CntcDTO.SndngResult dto); int updateCntcSndngResultByKkopay(final CntcDTO.SndngResult dto);
/**
* -
* - tb_cntc_sndng_result, tb_ens_kakao_d10
* @param dto SndngResult
* @return int
*/
int updateCntcSndngResultByKkotalk(final CntcDTO.SndngResult dto);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// result // result
//---------------------------------------------------------------------- //----------------------------------------------------------------------

@ -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.cntc.CntcDTO;
import kr.xit.biz.ens.model.kakao.v1.KkopayDocAttrDTO; 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.v1.KkopayDocBulkDTO;
import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.service.AbstractService; import kr.xit.core.service.AbstractService;
@ -51,8 +52,12 @@ import lombok.RequiredArgsConstructor;
public class EnsBatchStatusService extends AbstractService implements IEnsBatchStatusService { public class EnsBatchStatusService extends AbstractService implements IEnsBatchStatusService {
@Value("${app.contract.host}") @Value("${app.contract.host}")
private String apiHost; private String apiHost;
@Value("${app.contract.kakao.api.pay.bulkstatus}") @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}") @Value("${app.contract.kakao.bulk-max-cnt}")
private int bulkKkoMaxCnt; private int bulkKkoMaxCnt;
@ -97,10 +102,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
* : tb_ens_mobile_page_manage * : tb_ens_mobile_page_manage
* : tb_cntc_sndng_result * : tb_cntc_sndng_result
*/ */
case KAKAO -> statusKakao(dto); case KAKAO -> statusKakaopay(dto);
case KAKAO_NEW case KAKAO_NEW
-> statusKakao(dto); -> statusKakaotalk(dto);
//break; //break;
case KT_BC -> {} case KT_BC -> {}
@ -122,10 +127,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
* @param dto BatchEnsRequest * @param dto BatchEnsRequest
* </pre> * </pre>
*/ */
private void statusKakao(final SndngMssageParam dto) { private void statusKakaopay(final SndngMssageParam dto) {
final String url = apiHost + apiKkoBulkStatus; 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); final List<List<String>> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt);
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -153,27 +158,92 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS
// 결과 반영 // 결과 반영
resList.forEach(o -> resList.forEach(o ->
o.getDocuments().forEach(t -> { o.getDocuments().forEach(t -> {
mapper.updateKakaoStatusInfo(t); mapper.updateKakaopayStatusInfo(t);
KkopayDocAttrDTO.DocStatus statusData = t.getStatus_data(); KkopayDocAttrDTO.DocStatus statusData = t.getStatus_data();
if(Checks.isNotEmpty(statusData)) { if(Checks.isNotEmpty(statusData)) {
mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder() mapper.updateCntcSndngResultByKkopay(
.documentBinderUuid(t.getDocument_binder_uuid()) CntcDTO.SndngResult.builder()
.sndngResultSttus(StringUtils.defaultString( .docKeyId(t.getDocument_binder_uuid())
String.valueOf(statusData.getDoc_box_status()), "FAIL")) .sndngResultSttus(StringUtils.defaultString(
.requstDt(Checks.isEmpty(statusData.getDoc_box_sent_at()) ? null String.valueOf(statusData.getDoc_box_status()), "FAIL"))
: statusData.getDoc_box_sent_at().toString()) .requstDt(Checks.isEmpty(statusData.getDoc_box_sent_at()) ? null
.inqireDt(Checks.isEmpty(statusData.getDoc_box_received_at()) ? null : statusData.getDoc_box_sent_at().toString())
: statusData.getDoc_box_received_at().toString()) .inqireDt(Checks.isEmpty(statusData.getDoc_box_received_at()) ? null
.readngDt(Checks.isEmpty(statusData.getDoc_box_read_at()) ? null : statusData.getDoc_box_received_at().toString())
: statusData.getDoc_box_read_at().toString()) .readngDt(Checks.isEmpty(statusData.getDoc_box_read_at()) ? null
.errorCn(t.getError_message()) : statusData.getDoc_box_read_at().toString())
.build()); .errorCn(t.getError_message())
.build());
}else{
mapper.updateCntcSndngResultByKkopay(
CntcDTO.SndngResult.builder()
.docKeyId(t.getDocument_binder_uuid())
.sndngResultSttus(t.getError_code())
.errorCn(t.getError_message())
.build());
}
})
);
}
/**
* <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{ }else{
mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder() mapper.updateCntcSndngResultByKkotalk(
.documentBinderUuid(t.getDocument_binder_uuid()) CntcDTO.SndngResult.builder()
.sndngResultSttus(t.getError_code()) .docKeyId(t.getEnvelopeId())
.errorCn(t.getError_message()) .sndngResultSttus(t.getErrorCode())
.build()); .errorCn(t.getErrorMessage())
.build());
} }
}) })
); );

@ -1015,38 +1015,51 @@
<select id="selectStatusBulkTgts" resultType="kr.xit.biz.ens.model.cmm.SndngMssageParam"> <select id="selectStatusBulkTgts" resultType="kr.xit.biz.ens.model.cmm.SndngMssageParam">
/** ens-mysql-mapper|selectStatusBulkTgts-상태 요청 대상 조회|julim */ /** ens-mysql-mapper|selectStatusBulkTgts-상태 요청 대상 조회|julim */
SELECT tesm.sndng_mastr_id SELECT tesm.sndng_mastr_id
, tesm.unity_sndng_mastr_id , tesm.unity_sndng_mastr_id
, tesm.tmplat_id , tesm.tmplat_id
, tesm.sndng_co , tesm.sndng_co
, tesm.try_seq , tesm.try_seq
, tesm.sndng_process_sttus , tesm.sndng_process_sttus
, teusm.try1 , teusm.try1
, teusm.try2 , teusm.try2
, teusm.try3 , teusm.try3
, teusm.try_cnt , teusm.try_cnt
FROM tb_ens_sndng_mastr tesm FROM tb_ens_sndng_mastr tesm
JOIN tb_ens_unity_sndng_mastr teusm JOIN tb_ens_unity_sndng_mastr teusm
ON tesm.unity_sndng_mastr_id = teusm.unity_sndng_mastr_id ON tesm.unity_sndng_mastr_id = teusm.unity_sndng_mastr_id
WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2') WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2')
AND tesm.signgu_code = #{signguCode} AND tesm.signgu_code = #{signguCode}
AND tesm.ffnlg_code = #{ffnlgCode} AND tesm.ffnlg_code = #{ffnlgCode}
</select> </select>
<select id="selectKakaoStatusTgts" resultType="string"> <select id="selectKakaopayStatusTgts" resultType="string">
/** ens-mysql-mapper|selectKakaoStatusTgts-카카오 문서 상태 조회 대상 목록 조회|julim */ /** ens-mysql-mapper|selectKakaopayStatusTgts-카카오페이 문서 상태 조회 대상 목록 조회|julim */
SELECT document_binder_uuid SELECT tekmd.document_binder_uuid
FROM tb_ens_sndng_mastr tesm FROM tb_ens_sndng_mastr tesm
JOIN tb_ens_kakao_my_doc tekmd JOIN tb_ens_kakao_my_doc tekmd
ON tesm.sndng_mastr_id = tekmd.sndng_mastr_id ON tesm.sndng_mastr_id = tekmd.sndng_mastr_id
WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2') WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2')
AND tesm.unity_sndng_mastr_id = #{unitySndngMastrId} AND tesm.unity_sndng_mastr_id = #{unitySndngMastrId}
AND IFNULL(tekmd.document_binder_uuid, '') != '' AND IFNULL(tekmd.document_binder_uuid, '') != ''
AND tesm.signgu_code = #{signguCode} AND tesm.signgu_code = #{signguCode}
AND tesm.ffnlg_code = #{ffnlgCode} AND tesm.ffnlg_code = #{ffnlgCode}
</select> </select>
<update id="updateKakaoStatusInfo"> <select id="selectKakaotalkStatusTgts" resultType="string">
/** ens-mysql-mapper|updateKakaoStatusInfo-카카오 문서 상태 조회 결과 반영|julim */ /** ens-mysql-mapper|selectKakaotalkStatusTgts-카카오톡 전자고지 상태 조회 대상 목록 조회|julim */
SELECT tekd.envelope_id
FROM tb_ens_sndng_mastr tesm
JOIN tb_ens_kakao_d10 tekd
ON tesm.sndng_mastr_id = tekd.sndng_mastr_id
WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2')
AND tesm.unity_sndng_mastr_id = #{unitySndngMastrId}
AND IFNULL(tekd.envelope_id, '') != ''
AND tesm.signgu_code = #{signguCode}
AND tesm.ffnlg_code = #{ffnlgCode}
</select>
<update id="updateKakaopayStatusInfo">
/** ens-mysql-mapper|updateKakaopayStatusInfo-카카오페이 문서 상태 조회 결과 반영|julim */
UPDATE tb_ens_kakao_my_doc UPDATE tb_ens_kakao_my_doc
SET doc_box_status = #{status_data.doc_box_status} /* 진행상태 */ SET doc_box_status = #{status_data.doc_box_status} /* 진행상태 */
, doc_box_sent_at = #{status_data.doc_box_sent_at} /* 송신시간 */ , doc_box_sent_at = #{status_data.doc_box_sent_at} /* 송신시간 */
@ -1060,10 +1073,31 @@
, updt_dt = now() , updt_dt = now()
, updusr = 'batch' , updusr = 'batch'
WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id
FROM tb_ens_kakao_my_doc tekmd FROM tb_ens_kakao_my_doc tekmd
WHERE tekmd.document_binder_uuid = #{document_binder_uuid}) WHERE tekmd.document_binder_uuid = #{document_binder_uuid})
</update> </update>
<update id="updateKakaotalkStatusInfo">
/** ens-mysql-mapper|updateKakaotalkStatusInfo-카카오톡 문서 상태 조회 결과 반영|jhseo */
UPDATE tb_ens_kakao_d10
SET status = #{status} /* 진행상태 */
, sent_at = #{sentAt} /* 문서 송신 일시 */
, received_at = #{receivedAt} /* 문서 수신 일시 */
, read_at = #{readAt} /* 문서 열람 일시 */
, read_expires_at = #{readExpiredAt} /* 문서 열람 만료 일시 */
, authenticated_at = #{authenticatedAt} /* 문서 열람 인증 일시 */
, ott_verified_at = #{ottVerifiedAt} /* 토큰 검증 일시 */
, is_notification_unavailable = #{isNotificationUnavailable} /* 사용자의 알림톡 수신 가능 여부 */
, user_notified_at = #{userNotifiedAt} /* 사용자의 알림톡 수신 일시 */
, distribution_received_at = #{distributionReceivedAt} /* 유통정보의 수신 시각 */
, error_code = #{errorCode} /* 에러 코드 */
, error_message = #{errorMessage} /* 에러 메시지 */
, updt_dt = now()
, updusr = 'batch'
WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id
FROM tb_ens_kakao_d10 tekmd
WHERE tekmd.envelope_id = #{envelopeId})
</update>
<!-- =================================================================================== --> <!-- =================================================================================== -->
<!-- ================================ status ============================================= --> <!-- ================================ status ============================================= -->
<!-- =================================================================================== --> <!-- =================================================================================== -->
@ -1102,19 +1136,34 @@
WHERE unity_sndng_detail_id = #{unitySndngDetailId} WHERE unity_sndng_detail_id = #{unitySndngDetailId}
</insert> </insert>
<update id="updateCntcSndngResultByKkoMyDoc"> <update id="updateCntcSndngResultByKkopay">
/** ens-mysql-mapper|updateCntcSndngResult-연계발송결과반영|julim */ /** ens-mysql-mapper|updateCntcSndngResultByKkopay-카카오페이 연계발송결과반영|julim */
UPDATE tb_cntc_sndng_result UPDATE tb_cntc_sndng_result
SET sndng_result_sttus = #{sndngResultSttus} SET sndng_result_sttus = #{sndngResultSttus}
, requst_dt = from_unixtime(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */ , requst_dt = from_unixtime(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */
, inqire_dt = from_unixtime(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */ , inqire_dt = from_unixtime(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */
, readng_dt = from_unixtime(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */ , readng_dt = from_unixtime(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */
, error_cn = #{errorCn} , error_cn = #{errorCn}
, updt_dt = now() , updt_dt = now()
, updusr = 'batch' , updusr = 'batch'
WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id
FROM tb_ens_kakao_my_doc tekmd FROM tb_ens_kakao_my_doc tekmd
WHERE tekmd.document_binder_uuid = #{documentBinderUuid}) WHERE tekmd.document_binder_uuid = #{docKeyId})
</update>
<update id="updateCntcSndngResultByKkotalk">
/** ens-mysql-mapper|updateCntcSndngResultByKkotalk-카카오톡 연계발송결과반영|jhseo */
UPDATE tb_cntc_sndng_result
SET sndng_result_sttus = #{sndngResultSttus}
, requst_dt = DATE_FORMAT(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */
, inqire_dt = DATE_FORMAT(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */
, readng_dt = DATE_FORMAT(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */
, error_cn = #{errorCn}
, updt_dt = now()
, updusr = 'batch'
WHERE unity_sndng_detail_id = (SELECT tekd.unity_sndng_detail_id
FROM tb_ens_kakao_d10 tekd
WHERE tekd.envelope_id = #{docKeyId})
</update> </update>
<!-- =================================================================================== --> <!-- =================================================================================== -->
<!-- ================================ result ============================================= --> <!-- ================================ result ============================================= -->

@ -1,13 +1,19 @@
package kr.xit.biz.ens.model.cntc; package kr.xit.biz.ens.model.cntc;
import java.io.Serializable;
import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import kr.xit.biz.common.AuditFields; import kr.xit.biz.common.AuditFields;
import lombok.*; import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.Length;
import java.io.Serializable;
/** /**
* <pre> * <pre>
@ -199,7 +205,7 @@ public class CntcDTO {
/** /**
* documentBinderUuid * documentBinderUuid
*/ */
private String documentBinderUuid; private String docKeyId;
} }
@Data @Data

Loading…
Cancel
Save