카톡 환불 메소드 주기 수정 runKakaoOneTime

//	@Scheduled(cron = "0 0/3 * * * ?") 	// 3분마다 실행
	@Scheduled(cron = "0 0 0/2 * * ?") // 매시간 정각마다 실행
This commit is contained in:
leejunho 2025-10-13 10:44:08 +09:00 committed by hehihoho3@gmail.com
commit 708aca25bc
7 changed files with 53 additions and 167 deletions

View File

@ -148,24 +148,8 @@ public class KakaoApiProfile {
kakaoReturnVO.setBizReturnMsg(msg);
if(code.equals("200")) {
JSONObject tempCate = (JSONObject) object.get("data");
String senderKey = tempCate.get("senderKey").toString();
kakaoVO.setSenderKey(senderKey);
int profileCnt = kakaoApiService.selectKakaoProfileCnt(kakaoVO);
//중복된 발신프로필이 없으면 추가 입력
if(profileCnt == 0) {
kakaoApiService.insertKakaoProfileInfo(kakaoVO);
}else {//중복이 있는 경우 처리
kakaoReturnVO.setBizReturnCode("310");
kakaoReturnVO.setBizReturnMsg("이미 등록되어 있는 발신프로필 입니다");
return kakaoReturnVO;
}
kakaoReturnVO.setSenderKey((String) ((JSONObject) object.get("data")).get("senderKey"));
}
}else {
kakaoReturnVO.setBizReturnCode(statusCode);

View File

@ -4,7 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import itn.let.kakao.kakaoComm.KakaoSendAdvcVO;
import itn.let.kakao.kakaoComm.KakaoReturnVO;
import itn.let.kakao.kakaoComm.KakaoVO;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.msgdata.service.MjonMsgReturnVO;
@ -29,4 +29,7 @@ public interface KakaoAlimTalkService {
public List<KakaoVO> selectKakaoSentRefundListForSingle() throws Exception;
public void kakaoSingleRefund(KakaoVO kakaoVO) throws Exception;
//발신 프로필 등록 처리
public KakaoReturnVO createKaKaoProfile(KakaoVO kakaoVO) throws Exception;
}

View File

@ -19,8 +19,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
import egovframework.rte.fdl.idgnr.EgovIdGnrService;
@ -28,9 +26,11 @@ import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
import itn.com.cmm.LoginVO;
import itn.com.utl.fcc.service.EgovStringUtil;
import itn.let.kakao.kakaoComm.BizKakaoPriceVO;
import itn.let.kakao.kakaoComm.KakaoReturnVO;
import itn.let.kakao.kakaoComm.KakaoSendAdvcVO;
import itn.let.kakao.kakaoComm.KakaoSendUtil;
import itn.let.kakao.kakaoComm.KakaoVO;
import itn.let.kakao.kakaoComm.kakaoApi.service.KakaoApiService;
import itn.let.kakao.user.kakaoAt.service.KakaoAlimTalkService;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.mjocommon.MjonCommon;
@ -85,6 +85,9 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
/** userManageService */
@Resource(name = "userManageService")
private EgovUserManageService userManageService;
@Resource(name = "kakaoApiService")
private KakaoApiService kakaoApiService;
@Autowired
private MjonPayDAO mjonPayDAO;
@ -1086,5 +1089,31 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
// return befCash.compareTo(totalEachPrice) >= 0;
// }
@Override
public KakaoReturnVO createKaKaoProfile(KakaoVO kakaoVO) throws Exception {
KakaoReturnVO returnVO = new KakaoReturnVO();
/* senderKey 사용 우무 */
int profileCnt = kakaoApiService.selectKakaoProfileCnt(kakaoVO);
if(profileCnt > 0) {
returnVO.setBizReturnMsg("이미 등록된 발신프로필입니다. 동일 채널ID는 중복 등록이 불가합니다.");
}else {
List<KakaoVO> delProfileList = new ArrayList<KakaoVO>();
delProfileList = selectDeleteProfileInfo(kakaoVO);
if(delProfileList.size() != 0) {
kakaoVO.setProfileId(delProfileList.get(0).getProfileId());
kakaoVO.setDeleteYn("N");
updateKakaoProfileStatus(kakaoVO);
returnVO.setBizReturnMsg("삭제 발신프로필의 복구가 완료 되었습니다.");
}else {
kakaoApiService.insertKakaoProfileInfo(kakaoVO);
returnVO.setBizReturnMsg("발신프로필의 등록이 완료 되었습니다.");
}
}
return returnVO;
}
}

View File

@ -96,7 +96,10 @@ public class KakaoAlimTalkController {
KakaoReturnVO tmpProfileVO = kakaoApiProfile.kakaoApiProfileList(kakaoProfileVO);
resultApiProfileList.add(tmpProfileVO);
/* API를 통하여 정상적으로 조회된 프로필만 add 처리 */
if("200".equals(tmpProfileVO.getBizReturnCode())) {
resultApiProfileList.add(tmpProfileVO);
}
}
@ -137,21 +140,8 @@ public class KakaoAlimTalkController {
KakaoReturnVO kakaoInfo = kakaoApiProfile.kakaoApiProfileToken(kakaoVO); //발신프로필 인증 토큰 요청하기
String bizReturnCd = kakaoInfo.getBizReturnCode();
String bizReturnMsg = kakaoInfo.getBizReturnMsg();
List<KakaoVO> delProfileList = new ArrayList<KakaoVO>();
if(bizReturnCd.equals("310") && bizReturnMsg.equals("이미 등록되어 있는 발신프로필 입니다")) {
kakaoVO.setUserId(userId);
delProfileList = kakaoAlimTalkService.selectDeleteProfileInfo(kakaoVO);
}
int listSize = delProfileList.size();
modelAndView.addObject("kakaoInfo", kakaoInfo);
modelAndView.addObject("result", "success");
modelAndView.addObject("delInfoCnt", listSize);
}catch(Exception ex){
ex.printStackTrace();
@ -269,68 +259,14 @@ public class KakaoAlimTalkController {
kakaoVO.setLastUpdusrId(userId);
KakaoReturnVO kakaoInfo = kakaoApiProfile.kakaoApiProfileCreate(kakaoVO);
String bizReturnCd = kakaoInfo.getBizReturnCode();
String bizReturnMsg = kakaoInfo.getBizReturnMsg();
System.out.println(bizReturnCd);
System.out.println(bizReturnMsg);
/*
* 기존에 등록된 발신프로필이라고 결과가 오는 경우 데이터베이스에서 삭제 기록을 조회해 본다.
* 삭제 기록이 있는 경우 복구를 해주고(deleteYn 값을 'N'으로 변경)
* 기록이 없는 경우 사이트에 등록되었을 있음.
*
* */
List<KakaoVO> delProfileList = new ArrayList<KakaoVO>();
if((bizReturnCd.equals("509") && bizReturnMsg.equals("이미 사용중인 카카오톡 채널입니다.")) || (bizReturnCd.equals("310") && bizReturnMsg.equals("이미 등록되어 있는 발신프로필 입니다"))) {
delProfileList = kakaoAlimTalkService.selectDeleteProfileInfo(kakaoVO);
}
//삭제처리된 발신프로필이 있는 경우
if(delProfileList != null && delProfileList.size() > 0) {
int resultCnt = 0;
for(int i=0; i< delProfileList.size(); i++) {
KakaoVO tmpKakaoVO = new KakaoVO();
tmpKakaoVO.setUserId(userId);
tmpKakaoVO.setProfileId(delProfileList.get(i).getProfileId());
tmpKakaoVO.setDeleteYn("N");
int count = kakaoAlimTalkService.updateKakaoProfileStatus(tmpKakaoVO);
resultCnt = resultCnt + count;
}
KakaoReturnVO kakaoReturnVO = new KakaoReturnVO();
if(resultCnt > 0) {
kakaoReturnVO.setBizReturnCode("200");
kakaoReturnVO.setBizReturnMsg("삭제 발신프로필의 복구가 완료 되었습니다.");
modelAndView.addObject("kakaoInfo", kakaoReturnVO);
modelAndView.addObject("result", "success");
}else {
kakaoReturnVO.setBizReturnCode("200");
kakaoReturnVO.setBizReturnMsg("삭제 발신프로필의 복구에 오류가 발생하였습니다.");
modelAndView.addObject("kakaoInfo", kakaoReturnVO);
modelAndView.addObject("result", "zeroUpdate");
}
}else {//삭제된 내역이 없는 경우 사이트에 발신프로필이 등록되어 있을 있다.
modelAndView.addObject("kakaoInfo", kakaoInfo);
modelAndView.addObject("result", "success");
if("200".equals(kakaoInfo.getBizReturnCode())) {
kakaoVO.setSenderKey(kakaoInfo.getSenderKey());
KakaoReturnVO internalReuslt = kakaoAlimTalkService.createKaKaoProfile(kakaoVO);
kakaoInfo.setBizReturnMsg(internalReuslt.getBizReturnMsg());
}
modelAndView.addObject("kakaoInfo", kakaoInfo);
modelAndView.addObject("result", "success");
}
}catch(Exception ex){

View File

@ -480,8 +480,9 @@ public class SchedulerUtil {
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(dataSource);
}
@Scheduled(cron = "0 0/3 * * * ?") // 3분마다 실행
// @Scheduled(cron = "0 0/3 * * * ?") // 3분마다 실행
@Scheduled(cron = "0 0 0/2 * * ?") // 매시간 정각마다 실행
@SchedulerLock(name = "runKakaoOneTime", lockAtMostForString = ONE_MIN, lockAtLeastForString = ONE_MIN)
public void runKakaoOneTime() throws Exception {

View File

@ -135,30 +135,8 @@ function tokenSend(){
}else{
if(code == '310'){
var infoSize = returnData.delInfoCnt;
if(infoSize > 0){
if(confirm("기존에 삭제된 채널ID가 있습니다. 복구 하시겠습니까?")){
fnUpdateProfileStatus();
}
}else{
alert("이미 등록된 채널ID 입니다. 타 사이트에 등록된 채널ID를 확인해 주세요.");
return false;
}
}else{//인증 토큰 발송에 오류가 있는 경우 카카오의 오류 메세지를 표시
alert("인증번호 받기 처리 중 오류가 발생하였습니다. 오류 코드 : " + msg);
return false;
}
alert(msg);
return false;
}
}else{
@ -172,37 +150,6 @@ function tokenSend(){
});
}
function fnUpdateProfileStatus(){
var data = new FormData(bizForm);
$.ajax({
url : "<c:url value='/web/mjon/kakao/profile/updateKaKaoProfileStatusAjax.do'/>"
, type : 'POST'
, data : data
, dataType:'json'
, async: false
, processData: false
, contentType: false
, cache: false
, success: function (returnData, status) {
if(returnData.result == "success") {//인증번호 발송 완료
alert(returnData.kakaoInfo.bizReturnMsg);
location.reload();
}else{
alert(returnData.kakaoInfo.bizReturnMsg);
return false;
}
}
,error : function(request , status, error){
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
}
});
}
function sendProfile(){
var firstSelect = $("select[name='firstCatagoryList']").val();
var secondSelect = $("select[name='secondCatagoryList']").val();
@ -259,23 +206,9 @@ function sendProfile(){
if(returnData.result == "loginFail") {//차단 발신번호인 경우 등록 불가
alert("로그인후 진행");
}else if(returnData.result == "success") {
var code = returnData.kakaoInfo.bizReturnCode
if(code == "200"){
alert(returnData.kakaoInfo.bizReturnMsg);
location.reload();
}else if(code == "310"){//타사이트에 등록되어 있는 경우 알림메세지 표시
alert("이미 등록된 채널ID 입니다. 타 사이트에 등록된 채널ID를 확인해 주세요.");
return false;
}else{
alert(returnData.kakaoInfo.bizReturnMsg);
return false;
}
}else if(returnData.result == "zeroUpdate"){
}else{
alert(returnData.kakaoInfo.bizReturnMsg);
return false;
location.reload();
}
},
beforeSend : function(xmlHttpRequest) {

Binary file not shown.