이지우 - 사용자 카카오톡 발신프로필 등록 로직 변경
This commit is contained in:
parent
9f14958357
commit
be056b1b9e
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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("이미 등록되어 있는 발신프로필 입니다.");
|
||||
}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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -117,6 +117,17 @@
|
||||
LEFT JOIN MJ_KAKAO_PROFILE_INFO KPI
|
||||
ON KFT.USER_ID = KPI.USER_ID
|
||||
AND KFT.SENDER_KEY = KPI.SENDER_KEY
|
||||
AND KPI.PROFILE_ID = (
|
||||
SELECT
|
||||
PROFILE_ID
|
||||
FROM
|
||||
MJ_KAKAO_PROFILE_INFO
|
||||
WHERE
|
||||
USER_ID = KFT.USER_ID
|
||||
AND SENDER_KEY = KFT.SENDER_KEY
|
||||
ORDER BY DELETE_YN ASC, LAST_UPDT_PNTTM DESC
|
||||
LIMIT 1
|
||||
)
|
||||
WHERE KFT.DELETE_YN = 'N'
|
||||
AND KFT.USER_ID = #userId#
|
||||
<isNotEmpty property="senderKey">
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user