feat: 카카오톡 make, send 반영

main
Jonguk. Lim 3 months ago
parent adffdca5c5
commit 57b309c931

@ -23,7 +23,8 @@ select *
select * select *
from tb_ens_ci; from tb_ens_ci;
select *
from tb_ens_tmplat_manage;
/** 접수 reset */ /** 접수 reset */
select * from tb_elctrn_ntic_sndng; select * from tb_elctrn_ntic_sndng;
@ -60,4 +61,28 @@ where teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc=';
FROM tb_ens_ihidnum_manage teim FROM tb_ens_ihidnum_manage teim
LEFT JOIN tb_ens_ci_manage tecm LEFT JOIN tb_ens_ci_manage tecm
ON teim.ihidnum_manage_id = tecm.ihidnum_manage_id ON teim.ihidnum_manage_id = tecm.ihidnum_manage_id
WHERE teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc='; WHERE teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc=';
common_categories,
read_expired_at, /* 처리마감시간 */
-- recv_ci, /* 받는이 CI */
recv_phone_number, /* 받는이 전화번호 */
recv_name, /* 받는이 이름 */
recv_birthday, /* 받는이 생년월일 */
recv_is_required_verify_name,/* 성명검증옵션 */
prop_link, /* 모바일페이지 URL */
prop_payload,
prop_message,
prop_cs_number, /* 고객센터 전화번호 */
prop_cs_name, /* 고객센터 명 */
-- external_document_uuid,/* 외부문서 식별번호 */
regist_dt,
register
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')
from tb_ens_unity_sndng_mastr;

@ -192,7 +192,7 @@ public class KkotalkEltrcDocController {
* @return KkotalkDocDTO.BulkStatusResponse * @return KkotalkDocDTO.BulkStatusResponse
*/ */
@Operation(summary = "대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출", description = "카카오페이 전자문서 서버로 대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출") @Operation(summary = "대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출", description = "카카오페이 전자문서 서버로 대량 문서 상태 조회 요청 -> batch statusBulks 에서 호출")
@PostMapping(value = "/documents/bulk/status", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/envelopes/bulk/status", produces = MediaType.APPLICATION_JSON_VALUE)
public IApiResponse findBulkStatus( public IApiResponse findBulkStatus(
@RequestBody final KkotalkDTO.BulkStatusRequest reqDTO @RequestBody final KkotalkDTO.BulkStatusRequest reqDTO
) { ) {

@ -126,7 +126,7 @@ app:
host: http://211.43.10.163:10210/ONLWeb host: http://211.43.10.163:10210/ONLWeb
api: api:
# 모바일페이지 : 본문자수신등록 callback url - 토큰인증확인 조회, 열람확인결과 전송 # 모바일페이지 : 본문자수신등록 callback url - 토큰인증확인 조회, 열람확인결과 전송
dp-callback-url: http://${app.api-ip}:8080/api/web/mbl/v1/kt/dpMblPage.do chuncheon-callback-url: http://${app.api-ip}:8080/api/web/mbl/v1/kt/dpMblPage.do
me-callback-url: http://${app.api-ip}:8080/api/web/mbl/v1/kt/meMblPage.do me-callback-url: http://${app.api-ip}:8080/api/web/mbl/v1/kt/meMblPage.do
#dp-callback-url: http://211.119.124.73:8081/api/biz/mbl/v1/kt/dpMblPage #dp-callback-url: http://211.119.124.73:8081/api/biz/mbl/v1/kt/dpMblPage
#me-callback-url: http://211.119.124.73:8081/api/biz/mbl/v1/kt/meMblPage #me-callback-url: http://211.119.124.73:8081/api/biz/mbl/v1/kt/meMblPage

@ -153,6 +153,8 @@ public interface IEnsBatchMapper {
* </pre> * </pre>
*/ */
<T> int insertKakaoMyDocs(final T t); <T> int insertKakaoMyDocs(final T t);
<T> int insertKakaoD10(final T t);
/** /**
* <pre> * <pre>
@ -162,7 +164,8 @@ public interface IEnsBatchMapper {
* @return int * @return int
* </pre> * </pre>
*/ */
<T> int insertMobilePageManage(final T t); <T> int insertKkopayMobilePageManage(final T t);
<T> int insertKkotalkMobilePageManage(final T t);
/** /**
* <pre> * <pre>
@ -258,8 +261,17 @@ public interface IEnsBatchMapper {
* @return List<EnsDTO.SendKakaoTgt> * @return List<EnsDTO.SendKakaoTgt>
* </pre> * </pre>
*/ */
<T> List<EnsDTO.SendKakaoTgt> selectKakaoSendTgts(final T t); <T> List<EnsDTO.SendKakaoTgt> selectKakaopaySendTgts(final T t);
/**
* <pre>
*
* - tb_ens_sndng_mastr, tb_ens_kakao_d10, tb_ens_ci
* @param t status
* @return List<EnsDTO.SendKakaotalkTgt>
* </pre>
*/
<T> List<EnsDTO.SendKakaotalkTgt> selectKakaotalkSendTgts(final T t);
/** /**
* <pre> * <pre>
* : * :
@ -278,9 +290,17 @@ public interface IEnsBatchMapper {
* @return int * @return int
* </pre> * </pre>
*/ */
<T> int updateKakaoSendBulksResult(final T t); <T> int updateKakaopaySendBulksResult(final T t);
/**
* <pre>
*
* - tb_ens_kakao_d10
* @param t ID, , , ID
* @return int
* </pre>
*/
<T> int updateKakaotalkSendBulksResult(final T t);
/** /**
* <pre> * <pre>
* *

@ -113,6 +113,58 @@ public class EnsDTO {
private long closDt; private long closDt;
} }
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public static class SendKakaotalkTgt extends EnsDTO.KakaotalkD10 {
/**
* id
*/
private String sndngMastrId;
/**
* id
*/
private String unitySndngMastrId;
/**
*
*/
private String signguCode;
/**
*
*/
private String ffnlgCode;
/**
* 릿 ID
*/
private String tmplatId;
/**
*
*/
private String sndngTyCode;
/**
*
*/
private int sndngCo;
/**
*
*/
//private String sndngProcessSttus;
/**
* ci
*/
private String ci;
/**
*
*/
private String closDt;
}
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -393,6 +445,110 @@ public class EnsDTO {
} }
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public static class KakaotalkD10 extends AuditFields implements Serializable {
/**
* id
*/
private String sndngDetailId;
/**
* id
*/
private String unitySndngDetailId;
/**
* id
*/
private String sndngMastrId;
/**
*
*/
private String signguCode;
/**
*
*/
private String ffnlgCode;
/**
* :
*/
private String title;
/**
* -
* 6
*/
private String readExpiresAt;
/**
* - : 6
* 9999-12-31T23:59:59, null
*/
private String reviewExpiresAt;
/**
* () hash -
*/
private String hash;
/**
* -
*/
/**
* CI
*/
private String ci;
/**
*
* ci
*/
private String phoneNumber;
/**
*
* ci
*/
private String name;
/**
* (YYYYMMDD )
* ci
*/
private String birthday;
/**
*
*/
private String payload;
/**
*
*/
private Boolean useNonPersonalizedNotification;
/**
*
*/
private String externalId;
/**
* -
* : ()
*/
private String guide;
/**
* :
*/
private String contentLink;
}
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor

@ -21,6 +21,7 @@ import kr.xit.biz.ens.model.EnsDTO;
import kr.xit.biz.ens.model.cmm.SndngMssageParam; 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.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO;
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;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.service.AbstractService; import kr.xit.core.service.AbstractService;
@ -77,17 +78,17 @@ public class EnsBatchExtractService extends AbstractService implements
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
// FIXME: kakao v1 or v2 // FIXME: kakao v1 or v2
public void saveKkoSendResult(final String mstId, String unitySndMstId, final List<KkopayDocBulkDTO.BulkSendResponses> resList) { public void saveKkopaySendResult(final String mstId, String unitySndMstId, final List<KkopayDocBulkDTO.BulkSendResponses> resList) {
// 결과 반영 // 결과 반영
resList.forEach(o -> resList.forEach(o ->
o.getDocuments().forEach( o.getDocuments().forEach(
t -> { t -> {
// 카카오페이 문서요청 결과 반영 // 카카오페이 문서요청 결과 반영
mapper.updateKakaoSendBulksResult(t); mapper.updateKakaopaySendBulksResult(t);
String code = null; String code = null;
// 모바일 페이지 컨텐트 생성 // 모바일 페이지 컨텐트 생성
if (Checks.isNotEmpty(t.getDocument_binder_uuid())) { if (Checks.isNotEmpty(t.getDocument_binder_uuid())) {
mapper.insertMobilePageManage(t.getExternal_document_uuid()); mapper.insertKkopayMobilePageManage(t.getExternal_document_uuid());
code = ApiConstants.KkopayDocStatus.SENT.getCode(); code = ApiConstants.KkopayDocStatus.SENT.getCode();
}else{ }else{
code = t.getError_code(); code = t.getError_code();
@ -102,6 +103,47 @@ public class EnsBatchExtractService extends AbstractService implements
updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO, "카카오 문서 발송요청 실패(발송마스터 데이타 오류)"); updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO, "카카오 문서 발송요청 실패(발송마스터 데이타 오류)");
} }
/**
* <pre>
*
* 1. : tb_ens_kakao_my_doc
* 2. : tb_ens_mobile_page_manage
* 3. : tb_cntc_sndng_result
* -> 'SENT'
* @param mstId ID
* @param resList List<KkopayDocBulkDTO.BulkSendResponses>
* @param unitySndMstId String ID
* </pre>
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveKkotalkSendResult(final String mstId, String unitySndMstId, final List<KkotalkDTO.BulkSendResponse> resList) {
resList.get(0).getEnvelopeIds();
// 결과 반영
resList.forEach(o ->
o.getEnvelopeIds().forEach(
t -> {
// 카카오톡 전자고지 요청 결과 반영
mapper.updateKakaotalkSendBulksResult(t);
String code = null;
// 모바일 페이지 컨텐트 생성
if (Checks.isNotEmpty(t.getEnvelopeId())) {
mapper.insertKkotalkMobilePageManage(t.getExternalId());
// FIXME: 코드값 확인후 지정
code = ApiConstants.KkotalkDocStatus.READ.getCode();
}else{
code = t.getErrorCode();
}
// 연계발송결과 생성
insertCntcSndngResult(SndngSeCode.KAKAO_NEW.getCode(),
t.getExternalId(), code, t.getErrorMessage());
})
);
// 마스터 상태 변경
updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO_NEW, "카카오톡 전자고지 발송요청 실패(발송마스터 데이타 오류)");
}
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveKtBcResult(final SndngMssageParam dto, final List<KtMainSendReqData> sendReqs) { public void saveKtBcResult(final SndngMssageParam dto, final List<KtMainSendReqData> sendReqs) {

@ -40,8 +40,10 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class EnsBatchMakeService extends AbstractService implements IEnsBatchMakeService { public class EnsBatchMakeService extends AbstractService implements IEnsBatchMakeService {
@Value("${app.contract.kt.api.dp-callback-url}") // FIXME: KT callback url 확인 적용
private String DP_CALLBACK_URL; @Value("${app.contract.kt.api.chuncheon-callback-url}")
private String CHUNCHEON_CALLBACK_URL;
// FIXME: KT callback url 확인 적용
@Value("${app.contract.kt.api.me-callback-url}") @Value("${app.contract.kt.api.me-callback-url}")
private String ME_CALLBACK_URL; private String ME_CALLBACK_URL;
@ -75,11 +77,12 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Map<String, List<SndngMssageParam>> findMakes(final EnsDTO.BatchEnsRequest reqDTO) { public Map<String, List<SndngMssageParam>> findMakes(final EnsDTO.BatchEnsRequest reqDTO) {
final Map<String, List<SndngMssageParam>> tgtMap = new HashMap<>(); final Map<String, List<SndngMssageParam>> tgtMap = new HashMap<>();
final String sndngProcessSttus2 = ApiConstants.SndngProcessStatus.SENDING1.getCode(); // FIXME :: 순차 발송 값 바인딩 잘못함 순차발송이 필요한 경우 수정 필요
final String sndngProcessSttus3 = ApiConstants.SndngProcessStatus.SENDING2.getCode(); // final String sndngProcessSttus2 = ApiConstants.SndngProcessStatus.SENDING1.getCode();
// final String sndngProcessSttus3 = ApiConstants.SndngProcessStatus.SENDING2.getCode();
tgtMap.put("tty1", mapper.selectMakeTgts(reqDTO)); tgtMap.put("tty1", mapper.selectMakeTgts(reqDTO));
tgtMap.put("tty2", mapper.selectMakeTgts(sndngProcessSttus2)); //tgtMap.put("tty2", mapper.selectMakeTgts(sndngProcessSttus2));
//tgtMap.put("tty3", mapper.selectMakeTgts(sndngProcessSttus3)); //tgtMap.put("tty3", mapper.selectMakeTgts(sndngProcessSttus3));
return tgtMap; return tgtMap;
} }
@ -201,10 +204,13 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak
return switch (SndngSeCode.compare(seCode)) { return switch (SndngSeCode.compare(seCode)) {
case KAKAO -> mapper.insertKakaoMyDocs(dto); case KAKAO -> mapper.insertKakaoMyDocs(dto);
case KAKAO_NEW -> mapper.insertKakaoD10(dto);
case KT_BC -> { case KT_BC -> {
if(SignguCode.TRAFFIC.getCode().equals(dto.getSignguCode())){ // FIXME: KT callback url 확인 적용
dto.setUrl(DP_CALLBACK_URL); if(SignguCode.CHUNCHEON.getCode().equals(dto.getSignguCode())){
dto.setUrl(CHUNCHEON_CALLBACK_URL);
} }
// FIXME: KT callback url 확인 적용
if(SignguCode.FUNERAL.getCode().equals(dto.getSignguCode())){ if(SignguCode.FUNERAL.getCode().equals(dto.getSignguCode())){
dto.setUrl(ME_CALLBACK_URL); dto.setUrl(ME_CALLBACK_URL);
} }

@ -2,9 +2,12 @@ package kr.xit.biz.ens.service;
import static kr.xit.core.support.utils.JsonUtils.*; import static kr.xit.core.support.utils.JsonUtils.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -32,6 +35,8 @@ import kr.xit.biz.ens.model.EnsKtBcDTO;
import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.cmm.SndngMssageParam;
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.biz.ens.model.kakao.v2.KkotalkDocDTO;
import kr.xit.biz.ens.model.kt.KtCommonDTO.ErrorMsg; import kr.xit.biz.ens.model.kt.KtCommonDTO.ErrorMsg;
import kr.xit.biz.ens.model.kt.KtCommonDTO.KtCommonResponse; import kr.xit.biz.ens.model.kt.KtCommonDTO.KtCommonResponse;
import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData;
@ -66,8 +71,13 @@ import lombok.extern.slf4j.Slf4j;
public class EnsBatchSendService extends AbstractService implements IEnsBatchSendService { public class EnsBatchSendService extends AbstractService implements IEnsBatchSendService {
@Value("${app.contract.host}") @Value("${app.contract.host}")
private String apiHost; private String apiHost;
@Value("${app.contract.kakao.api.pay.bulksend}") @Value("${app.contract.kakao.api.pay.bulksend}")
private String apiKkoBulkSend; private String apiKkopayBulkSend;
@Value("${app.contract.kakao.api.talk.bulksend}")
private String apiKkotalkBulkSend;
@Value("${app.contract.kt.api.bulksend}") @Value("${app.contract.kt.api.bulksend}")
private String apiKtBcBulkSend; private String apiKtBcBulkSend;
@ -145,7 +155,8 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
* : tb_ens_mobile_page_manage * : tb_ens_mobile_page_manage
* : tb_cntc_sndng_result * : tb_cntc_sndng_result
*/ */
case KAKAO -> sendBulkKakaoMyDocs(dto); case KAKAO -> sendBulkKakaopay(dto);
case KAKAO_NEW -> sendBulkKakaotalk(dto);
case KT_BC -> sendBulkKtBc(dto); case KT_BC -> sendBulkKtBc(dto);
default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", seCode)); default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", seCode));
} }
@ -161,32 +172,32 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
* 1. * 1.
* - {@link IEnsBatchMapper#selectKakaoSendTgts(Object) selectKakaoSendTgts} * - {@link IEnsBatchMapper#selectKakaoSendTgts(Object) selectKakaoSendTgts}
* 2. set, validtion check * 2. set, validtion check
* - {@link #setKkoMyDocSendBulks} * - {@link #setKkopaySendBulks}
* - {@link #validatedKkoMyDocSendBulks} * - {@link #validatedKkopaySendBulks}
* 3. API * 3. API
* -> * ->
* 4. * 4.
* - bulk * - bulk
* - * -
* -> {@link EnsBatchExtractService#saveKkoSendResult(String, String, List) saveKkoMyDocResult} * -> {@link EnsBatchExtractService#saveKkopaySendResult(String, String, List) saveKkoMyDocResult}
* - : tb_ens_kakao_my_doc * - : tb_ens_kakao_my_doc
* - : tb_ens_mobile_page_manage * - : tb_ens_mobile_page_manage
* - : tb_cntc_sndng_result * - : tb_cntc_sndng_result
* @param dto SndngMssageParam * @param dto SndngMssageParam
* </pre> * </pre>
*/ */
private void sendBulkKakaoMyDocs(final SndngMssageParam dto) { private void sendBulkKakaopay(final SndngMssageParam dto) {
final String url = apiHost + apiKkoBulkSend; final String url = apiHost + apiKkopayBulkSend;
final List<SendKakaoTgt> list = mapper.selectKakaoSendTgts(dto); final List<SendKakaoTgt> list = mapper.selectKakaopaySendTgts(dto);
if(list.isEmpty()) return; if(list.isEmpty()) return;
final String mstId = list.get(0).getSndngMastrId(); final String mstId = list.get(0).getSndngMastrId();
final List<KkopayDocBulkDTO.BulkSendReq> bulkList = setKkoMyDocSendBulks(list); final List<KkopayDocBulkDTO.BulkSendReq> bulkList = setKkopaySendBulks(list);
// validation check // validation check
try { try {
validatedKkoMyDocSendBulks(bulkList); validatedKkopaySendBulks(bulkList);
} catch (Exception e) { } catch (Exception e) {
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "", e.getMessage(), "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)"); extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "", e.getMessage(), "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)");
throw e; throw e;
@ -224,7 +235,79 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
if(!isSuccess){ if(!isSuccess){
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "", errMsg, errMsg); extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "", errMsg, errMsg);
} }
extractService.saveKkoSendResult(mstId, dto.getUnitySndngMastrId(), resList); extractService.saveKkopaySendResult(mstId, dto.getUnitySndngMastrId(), resList);
}
/**
* <pre>
* send
* 1.
* - {@link IEnsBatchMapper#selectKakaoSendTgts(Object) selectKakaoSendTgts}
* 2. set, validtion check
* - {@link #setKkoNewSendBulks}
* - {@link #validatedKkoNewSendBulks}
* 3. API
* ->
* 4.
* - bulk
* -
* -> {@link EnsBatchExtractService#saveKkopaySendResult(String, String, List) saveKkoNewSendResult}
* - : tb_ens_kakao_my_doc
* - : tb_ens_mobile_page_manage
* - : tb_cntc_sndng_result
* @param dto SndngMssageParam
* </pre>
*/
private void sendBulkKakaotalk(final SndngMssageParam dto) {
final String url = apiHost + apiKkotalkBulkSend;
final List<EnsDTO.SendKakaotalkTgt> list = mapper.selectKakaotalkSendTgts(dto);
if(list.isEmpty()) return;
final String mstId = list.get(0).getSndngMastrId();
final List<KkotalkDocDTO.Envelope> bulkList = setKkotalkSendBulks(list);
// validation check
try {
validatedKkotalkSendBulks(bulkList);
} catch (Exception e) {
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO_NEW, "", e.getMessage(), "[send]카카오톡 전자고지 발송(bulks)요청 실패(파라메터 오류)");
throw e;
}
final List<List<KkotalkDocDTO.Envelope>> partitions = ListUtils.partition(bulkList, bulkKkoMaxCnt);
//noinspection rawtypes
final List<ApiResponseDTO> apiResults = partitions.stream()
.map(bulkSendList -> apiWebClient.exchange(
url,
HttpMethod.POST,
KkotalkDTO.BulkSendRequest.builder()
.signguCode(dto.getSignguCode())
.ffnlgCode(dto.getFfnlgCode())
.envelopes(bulkSendList)
.build(),
ApiResponseDTO.class,
CmmEnsBizUtils.getHeadeMap())
)
.toList();
final List<KkotalkDTO.BulkSendResponse> resList = new ArrayList<>();
boolean isSuccess = false;
String errMsg = null;
//noinspection rawtypes
for(ApiResponseDTO apiResult : apiResults) {
if(apiResult.getData() != null) {
resList.add(toObjByObj(apiResult.getData(), KkotalkDTO.BulkSendResponse.class));
isSuccess = true;
continue;
}
errMsg = apiResult.getMessage();
}
// 카카오 send 결과 반영
if(!isSuccess){
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO_NEW, "", errMsg, errMsg);
}
extractService.saveKkoNewSendResult(mstId, dto.getUnitySndngMastrId(), resList);
} }
/** /**
@ -233,7 +316,7 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
* @param list List<EnsDTO.SendKakaoTgt> * @param list List<EnsDTO.SendKakaoTgt>
* @return List<KkopayDocBulkDTO.BulkSendReq> * @return List<KkopayDocBulkDTO.BulkSendReq>
*/ */
private static List<KkopayDocBulkDTO.BulkSendReq> setKkoMyDocSendBulks(List<SendKakaoTgt> list) { private static List<KkopayDocBulkDTO.BulkSendReq> setKkopaySendBulks(List<SendKakaoTgt> list) {
final List<KkopayDocBulkDTO.BulkSendReq> bulkList = new ArrayList<>(); final List<KkopayDocBulkDTO.BulkSendReq> bulkList = new ArrayList<>();
for (SendKakaoTgt sendTgtDTO : list) { for (SendKakaoTgt sendTgtDTO : list) {
@ -283,12 +366,54 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
return bulkList; return bulkList;
} }
/**
* GET
* - CI
* @param list List<EnsDTO.SendKakaoNewTgt>
* @return List<KkoNewDocAttrDTO.Send>
*/
private static List<KkotalkDocDTO.Envelope> setKkotalkSendBulks(List<EnsDTO.SendKakaotalkTgt> list) {
final List<KkotalkDocDTO.Envelope> bulkList = new ArrayList<>();
for (EnsDTO.SendKakaotalkTgt sendTgtDTO : list) {
/*
: CI
*/
KkotalkDocDTO.Envelope bulkReqDTO = null;
if(StringUtils.isNotEmpty(sendTgtDTO.getCi())){
bulkReqDTO = KkotalkDocDTO.Envelope.builder()
.ci(sendTgtDTO.getCi())
.build();
}else{
bulkReqDTO = KkotalkDocDTO.Envelope.builder()
.build();
}
final KkotalkDocDTO.Content content = KkotalkDocDTO.Content.builder()
.link(sendTgtDTO.getContentLink())
.build();
bulkReqDTO.setExternalId(sendTgtDTO.getUnitySndngDetailId());
bulkReqDTO.setTitle(sendTgtDTO.getTitle());
bulkReqDTO.setPayload(sendTgtDTO.getPayload());
bulkReqDTO.setReadExpiresAt(sendTgtDTO.getReadExpiresAt());
bulkReqDTO.setReviewExpiresAt(sendTgtDTO.getReviewExpiresAt());
bulkReqDTO.setHash(sendTgtDTO.getHash());
bulkReqDTO.setGuide(sendTgtDTO.getGuide());
bulkReqDTO.setContent(content);
bulkList.add(bulkReqDTO);
}
return bulkList;
}
/** /**
* *
* *
* @param bulkList List<KkopayDocBulkDTO.BulkSendReq> * @param bulkList List<KkopayDocBulkDTO.BulkSendReq>
*/ */
private void validatedKkoMyDocSendBulks(List<KkopayDocBulkDTO.BulkSendReq> bulkList) { private void validatedKkopaySendBulks(List<KkopayDocBulkDTO.BulkSendReq> bulkList) {
List<String> errors = new ArrayList<>(); List<String> errors = new ArrayList<>();
int idx = 0; int idx = 0;
@ -334,6 +459,59 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
} }
} }
/**
*
*
* @param bulkList List<KkoNewDocBulkDTO.Send>
*/
private void validatedKkotalkSendBulks(List<KkotalkDocDTO.Envelope> bulkList) {
List<String> errors = new ArrayList<>();
int idx = 0;
for (KkotalkDocDTO.Envelope dto : bulkList) {
final Set<ConstraintViolation<KkotalkDocDTO.Envelope>> errList = validator.validate(dto);
if(!errList.isEmpty()) {
int finalIdx = idx;
errors.addAll(errList.stream()
.map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1,
row.getMessageTemplate()))
.toList()
);
}
if(dto.getReadExpiresAt() == null){
Objects.requireNonNull(errors).add("최초 열람 만료 일시는 필수입니다.");
}
if(dto.getReadExpiresAt() != null && dto.getReviewExpiresAt() != null){
DateTimeFormatter pattern1 = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
LocalDateTime parse1 = LocalDateTime.parse(dto.getReadExpiresAt(), pattern1);
LocalDateTime parse2 = LocalDateTime.parse(dto.getReviewExpiresAt(), pattern1);
if(parse1.isAfter(parse2)) Objects.requireNonNull(errors).add("재열람 만료 일시는 최초 열람 만료 일시보다 이전일 수 없습니다.");
}
if (Checks.isEmpty(dto.getCi())) {
// if (Checks.isEmpty(dto.getName())) {
// errors.add(
// String.format("받는이 이름은 필수입니다(receiver.name[%d] 번째 오류)", idx + 1));
// }
// if (Checks.isEmpty(dto.getPhoneNumber())) {
// errors.add(String.format("받는이 전화번호는 필수입니다(receiver.phone_number[%d] 번째 오류)",
// idx + 1));
// }
// if (Checks.isEmpty(dto.getBirthday())) {
// errors.add(
// String.format("받는이 생년월일은 필수입니다(receiver.birthday[%d] 번째 오류)", idx + 1));
// }
}
idx++;
}
if (!errors.isEmpty()) {
throw BizRuntimeException.create(errors.toString());
}
}
/** /**
* <pre> * <pre>
* KT BC send * KT BC send

@ -5,6 +5,7 @@ import java.util.List;
import kr.xit.biz.common.ApiConstants.SndngSeCode; import kr.xit.biz.common.ApiConstants.SndngSeCode;
import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.cmm.SndngMssageParam;
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.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData;
/** /**
@ -29,7 +30,8 @@ public interface IEnsBatchExtractService {
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// REQUIRES_NEW service method // REQUIRES_NEW service method
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
void saveKkoSendResult(final String mstId, String unitySndMstId, final List<KkopayDocBulkDTO.BulkSendResponses> resList); void saveKkopaySendResult(final String mstId, String unitySndMstId, final List<KkopayDocBulkDTO.BulkSendResponses> resList);
void saveKkotalkSendResult(final String mstId, String unitySndMstId, final List<KkotalkDTO.BulkSendResponse> resList);
void saveKtBcResult(final SndngMssageParam dto, final List<KtMainSendReqData> sendReqs); void saveKtBcResult(final SndngMssageParam dto, final List<KtMainSendReqData> sendReqs);

@ -24,8 +24,12 @@ app:
kakao: kakao:
bulk-max-cnt: 10 bulk-max-cnt: 10
api: api:
bulksend: /api/ens/kakao/v1/documents/bulk pay:
bulkstatus: /api/ens/kakao/v1/documents/bulk/status bulksend: /api/ens/kakao/v1/documents/bulk
bulkstatus: /api/ens/kakao/v1/documents/bulk/status
talk:
bulksend: /api/ens/kakao/v2//envelopes/bulk
bulkstatus: /api/ens/kakao/v2/envelopes/bulk/status
kt: kt:
bulk-max-cnt: 10 bulk-max-cnt: 10
api: api:

@ -541,6 +541,58 @@
, updusr = 'batch' , updusr = 'batch'
WHERE unity_sndng_mastr_id = #{unitySndngMastrId} WHERE unity_sndng_mastr_id = #{unitySndngMastrId}
</update> </update>
<insert id="insertKakaoD10">
/** ens-mysql-mapper|insertKakaoD10-카카오톡 D10_2 생성|julim */
INSERT
INTO tb_ens_kakao_d10 (
sndng_detail_id, /* 발송상세ID */
unity_sndng_detail_id, /* 통합발송상세ID */
sndng_mastr_id, /* 발송마스터ID */
signgu_code, /* 시군구코드 */
ffnlg_code, /* 과태료코드 */
title, /* 제목 */
link,
hash,
guide, /* 메세지 */
payload,
read_expires_at, /* 최초 열람 만료 일시 */
review_expires_at, /* 재열람 만료 일시 */
ci, /* 받는이 ci */
phone_number, /* 수신인 전화번호 */
name, /* 수신인 이름 */
birthday, /* 수신인 생년월일 */
external_id, /* 문서 매핑 식별 ID */
regist_dt,
register
)
SELECT LPAD(NEXTVAL(sndng_detail_id_seq), 20, '0')
, teusd.unity_sndng_detail_id
, #{sndngMastrId}
, teusm.signgu_code
, teusm.ffnlg_code
, tetm.tmplat_sj
, tetm.redirect_url
, SHA2(teusd.unity_sndng_detail_id, 256)
, tetm.tmplat_cn
, ''
, DATE_FORMAT(teusm.clos_dt, '%Y-%m-%dT%H:%i:%s')
, DATE_FORMAT(DATE_ADD(teusm.clos_dt, INTERVAL 1 DAY), '%Y-%m-%dT%H:%i:%s')
, ''
, teusd.moblphon_no
, teusd.nm
, ''
, teusd.unity_sndng_detail_id
, now()
, 'batch'
FROM tb_ens_unity_sndng_mastr teusm
LEFT JOIN tb_ens_tmplat_manage tetm
ON teusm.tmplat_id = tetm.tmplat_id
LEFT JOIN tb_ens_unity_sndng_detail teusd
ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
AND teusm.sndng_process_sttus = #{sndngProcessSttus}
</insert>
<!-- =================================================================================== --> <!-- =================================================================================== -->
<!-- ================================ make ============================================= --> <!-- ================================ make ============================================= -->
<!-- =================================================================================== --> <!-- =================================================================================== -->
@ -591,42 +643,76 @@
</if> </if>
</select> </select>
<select id="selectKakaoSendTgts" resultType="kr.xit.biz.ens.model.EnsDTO$SendKakaoTgt"> <select id="selectKakaopaySendTgts" resultType="kr.xit.biz.ens.model.EnsDTO$SendKakaoTgt">
/** ens-mysql-mapper|selectKakaoSendTgts-카카오 문서요청 대상 목록 조회|julim */ /** ens-mysql-mapper|selectKakaopaySendTgts-카카오 문서요청 대상 목록 조회|julim */
SELECT tesm.sndng_mastr_id /* 발송마스터 ID */ SELECT tesm.sndng_mastr_id /* 발송마스터 ID */
, tesm.unity_sndng_mastr_id /* 통합발송마스터 ID */ , tesm.unity_sndng_mastr_id /* 통합발송마스터 ID */
, tesm.signgu_code /* 시군구 코드 */ , tesm.signgu_code /* 시군구 코드 */
, tesm.ffnlg_code /* 과태료 코드 */ , tesm.ffnlg_code /* 과태료 코드 */
, tesm.tmplat_id /* 템플릿 Id */ , tesm.tmplat_id /* 템플릿 Id */
, tesm.sndng_ty_code /* 발송유형 코드 */ , tesm.sndng_ty_code /* 발송유형 코드 */
, tesm.sndng_co /* 발송건수 */ , tesm.sndng_co /* 발송건수 */
, unix_timestamp(tesm.clos_dt) AS closDt /* 마감일시 */ , unix_timestamp(tesm.clos_dt) AS closDt /* 마감일시 */
, tekmd.sndng_detail_id /* 발송상세 ID */ , tekmd.sndng_detail_id /* 발송상세 ID */
, tekmd.unity_sndng_detail_id /* 통합발송상세 ID */ , tekmd.unity_sndng_detail_id /* 통합발송상세 ID */
, tekmd.title /* 제목 */ , tekmd.title /* 제목 */
, tekmd.hash , tekmd.hash
, tekmd.common_categories , tekmd.common_categories
, tekmd.recv_phone_number /* 받는이 전화번호 */ , tekmd.recv_phone_number /* 받는이 전화번호 */
, tekmd.recv_name /* 받는이 이름 */ , tekmd.recv_name /* 받는이 이름 */
, tekmd.recv_birthday /* 받는이 생년월일 */ , tekmd.recv_birthday /* 받는이 생년월일 */
, tekmd.prop_link /* redirect url */ , tekmd.prop_link /* redirect url */
, tekmd.prop_payload , tekmd.prop_payload
, tekmd.prop_message , tekmd.prop_message
, tekmd.prop_cs_name /* 콜센터 명 */ , tekmd.prop_cs_name /* 콜센터 명 */
, tekmd.prop_cs_number /* 콜센터 전화번호 */ , tekmd.prop_cs_number /* 콜센터 전화번호 */
, tec.ci /* ci */ , tec.ci /* ci */
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
LEFT JOIN tb_ens_ci tec LEFT JOIN tb_ens_ci tec
ON tekmd.unity_sndng_detail_id = tec.unity_sndng_detail_id ON tekmd.unity_sndng_detail_id = tec.unity_sndng_detail_id
WHERE tesm.sndng_mastr_id = #{sndngMastrId} WHERE tesm.sndng_mastr_id = #{sndngMastrId}
AND tesm.signgu_code = #{signguCode} AND tesm.signgu_code = #{signguCode}
AND tesm.ffnlg_code = #{ffnlgCode} AND tesm.ffnlg_code = #{ffnlgCode}
ORDER BY tesm.unity_sndng_mastr_id ORDER BY tesm.unity_sndng_mastr_id
, tekmd.unity_sndng_detail_id , tekmd.unity_sndng_detail_id
</select> </select>
<select id="selectKakaotalkSendTgts" resultType="kr.xit.biz.ens.model.EnsDTO$SendKakaotalkTgt">
/** ens-oracle-mapper|selectKakaotalkSendTgts-카카오톡 문서요청 대상 목록 조회|jhseo */
SELECT tesm.sndng_mastr_id /* 발송마스터 ID */
, tesm.unity_sndng_mastr_id /* 통합발송마스터 ID */
, tesm.signgu_code /* 시군구 코드 */
, tesm.ffnlg_code /* 과태료 코드 */
, tesm.tmplat_id /* 템플릿 Id */
, tesm.sndng_ty_code /* 발송유형 코드 */
, tesm.sndng_co /* 발송건수 */
, tekmd.sndng_detail_id /* 발송상세 ID */
, tekmd.unity_sndng_detail_id /* 통합발송상세 ID */
, tekmd.title /* 제목 */
, tekmd.hash
, tekmd.phone_number /* 받는이 전화번호 */
, tekmd.name /* 받는이 이름 */
, tekmd.birthday /* 받는이 생년월일 */
, tekmd.link as contentlink /* redirect url */
, tekmd.payload
, tekmd.guide
, tekmd.read_expires_at /* 최초 열람 만료 일시 */
, tekmd.review_expires_at /* 재열람 만료 일시 */
, tec.ci
FROM tb_ens_sndng_mastr tesm
JOIN tb_ens_kakao_d10 tekmd
ON tesm.sndng_mastr_id = tekmd.sndng_mastr_id
LEFT JOIN tb_ens_ci tec
ON tekmd.unity_sndng_detail_id = tec.unity_sndng_detail_id
WHERE tesm.sndng_mastr_id = #{sndngMastrId}
AND tesm.signgu_code = #{signguCode}
AND tesm.ffnlg_code = #{ffnlgCode}
ORDER BY tesm.unity_sndng_mastr_id
, tekmd.unity_sndng_detail_id
</select>
<select id="selectPostTgts" resultType="kr.xit.biz.ens.model.EnsDTO$PostSndng"> <select id="selectPostTgts" resultType="kr.xit.biz.ens.model.EnsDTO$PostSndng">
/** ens-mysql-mapper|selectPostTgts-E-Green 발송 대상 목록 조회|julim */ /** ens-mysql-mapper|selectPostTgts-E-Green 발송 대상 목록 조회|julim */
SELECT tesm.unity_sndng_mastr_id SELECT tesm.unity_sndng_mastr_id
@ -789,8 +875,8 @@
WHERE tesm.sndng_mastr_id = #{sndngMastrId} WHERE tesm.sndng_mastr_id = #{sndngMastrId}
</select> </select>
<update id="updateKakaoSendBulksResult"> <update id="updateKakaopaySendBulksResult">
/** ens-mysql-mapper|updateKakaoSendBulksResult-카카오페이 문서요청 결과 반영|julim */ /** ens-mysql-mapper|updateKakaopaySendBulksResult-카카오페이 문서요청 결과 반영|julim */
UPDATE tb_ens_kakao_my_doc UPDATE tb_ens_kakao_my_doc
SET external_document_uuid = #{external_document_uuid} SET external_document_uuid = #{external_document_uuid}
, document_binder_uuid = #{document_binder_uuid} , document_binder_uuid = #{document_binder_uuid}
@ -801,25 +887,58 @@
WHERE unity_sndng_detail_id = #{external_document_uuid} WHERE unity_sndng_detail_id = #{external_document_uuid}
</update> </update>
<insert id="insertMobilePageManage"> <update id="updateKakaotalkSendBulksResult">
/** ens-mysql-mapper|insertMobilePageManage-모바일페이지관리 데이타 생성|julim */ /** ens-mysql-mapper|updateKakaotalkSendBulksResult-카카오톡 문서요청 결과 반영|jhseo */
UPDATE tb_ens_kakao_d10
SET external_id = #{externalId}
, envelope_id = #{envelopeId}
, error_code = #{error_code}
, error_message = #{error_message}
, updt_dt = now()
, updusr = 'batch'
WHERE unity_sndng_detail_id = #{externalId}
</update>
<insert id="insertKkopayMobilePageManage">
/** ens-mysql-mapper|insertKkopayMobilePageManage-카카오페이모바일페이지관리 데이타 생성|julim */
INSERT INSERT
INTO tb_ens_mobile_page_manage ( INTO tb_ens_mobile_page_manage (
sndng_detail_id, /* 발송상세 ID*/ sndng_detail_id, /* 발송상세 ID*/
sndng_se_code, /* 발송 구분 코드 */ sndng_se_code, /* 발송 구분 코드 */
mobile_page_cn, /* 모바일 페이지 내용 */ mobile_page_cn, /* 모바일 페이지 내용 */
regist_dt, regist_dt,
register register
) )
SELECT tekmd.sndng_detail_id SELECT tekmd.sndng_detail_id
, 'KKO-MY-DOC' , 'KKO-MY-DOC'
, teusd.mobile_page_cn , teusd.mobile_page_cn
, date_format(now(), '%Y%m%d%H%i%s') , date_format(now(), '%Y%m%d%H%i%s')
, 'batch' , 'batch'
FROM tb_ens_kakao_my_doc tekmd FROM tb_ens_kakao_my_doc tekmd
JOIN tb_ens_unity_sndng_detail teusd JOIN tb_ens_unity_sndng_detail teusd
ON tekmd.unity_sndng_detail_id = teusd.unity_sndng_detail_id ON tekmd.unity_sndng_detail_id = teusd.unity_sndng_detail_id
WHERE teusd.unity_sndng_detail_id = #{unitySndngDetailId} WHERE teusd.unity_sndng_detail_id = #{unitySndngDetailId}
</insert>
<insert id="insertKkotalkMobilePageManage">
/** ens-oracle-mapper|insertKkotalkMobilePageManage-카카오톡모바일페이지관리 데이타 생성|jhseo */
INSERT
INTO tb_ens_mobile_page_manage (
sndng_detail_id, /* 발송상세 ID*/
sndng_se_code, /* 발송 구분 코드 */
mobile_page_cn, /* 모바일 페이지 내용 */
regist_dt,
register
)
SELECT tekmd.sndng_detail_id
, 'KKO-NEW'
, teusd.mobile_page_cn
, date_format(now(), '%Y%m%d%H%i%s')
, 'batch'
FROM tb_ens_kakao_d10 tekmd
JOIN tb_ens_unity_sndng_detail teusd
ON tekmd.unity_sndng_detail_id = teusd.unity_sndng_detail_id
WHERE teusd.unity_sndng_detail_id = #{unitySndngDetailId}
</insert> </insert>
<update id="updateProcessSttusSndngMst"> <update id="updateProcessSttusSndngMst">

@ -211,9 +211,9 @@ public class ApiConstants {
@Getter @Getter
public enum SignguCode { public enum SignguCode {
/** /**
* *
*/ */
TRAFFIC("88328"), CHUNCHEON("51110"),
/** /**
* : NICE CI * : NICE CI
*/ */

@ -87,7 +87,7 @@ public class KkotalkDTO extends KkotalkDocDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public static class BulkSendResponse extends KkotalkErrorDTO { public static class BulkSendResponse {
private List<EnvelopeRes> envelopeIds; private List<EnvelopeRes> envelopeIds;
} }

@ -348,7 +348,7 @@ public class KkotalkDocDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
//@JsonInclude(JsonInclude.Include.NON_EMPTY) //@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class EnvelopeRes { public static class EnvelopeRes extends KkotalkErrorDTO{
/** /**
* ID, 34 * ID, 34
*/ */

Loading…
Cancel
Save