카톡발송 화면 json 로직 수정 및 발송 VO 생성
This commit is contained in:
parent
b87785778e
commit
301135e190
68
src/main/java/itn/let/kakao/kakaoComm/KakaoSendAdvcVO.java
Normal file
68
src/main/java/itn/let/kakao/kakaoComm/KakaoSendAdvcVO.java
Normal file
@ -0,0 +1,68 @@
|
||||
package itn.let.kakao.kakaoComm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @FileName : KakaoSendVO.java
|
||||
* @Project : mjon
|
||||
* @Date : 2025. 3. 25.
|
||||
* @작성자 : 이호영
|
||||
|
||||
* @프로그램 설명 : 문자온 발송부분만 ADVC
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class KakaoSendAdvcVO implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 343099046833205405L;
|
||||
|
||||
private String msgId; // 문자ID
|
||||
private String msgGroupId; // 전송그룹ID
|
||||
private String userId; // 사용자ID
|
||||
private String agentCode; // 전송사코드
|
||||
private String senderKey; // 발신프로필 키
|
||||
private String templateCode; // 템플릿 코드
|
||||
private String callTo; // 수신번호
|
||||
private String callFrom; // 발신번호
|
||||
private String msgType; // 메시지 타입
|
||||
private String templateContent; // 템플릿 내용
|
||||
private String templateTitle; // 템플릿 제목
|
||||
private String subMsgSendYn; // 대체문자 전송 여부
|
||||
private String subMsgTxt; // 대체문자 내용
|
||||
private String subMsgType; // 대체문자 타입
|
||||
private String bizJsonName; // JSON 파일명
|
||||
private String reqDate; // 예약일시
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MsgSendVO[" +
|
||||
"\n msgId=[" + msgId + "]" +
|
||||
"\n , msgGroupId=[" + msgGroupId + "]" +
|
||||
"\n , userId=[" + userId + "]" +
|
||||
"\n , agentCode=[" + agentCode + "]" +
|
||||
"\n , senderKey=[" + senderKey + "]" +
|
||||
"\n , templateCode=[" + templateCode + "]" +
|
||||
"\n , callTo=[" + callTo + "]" +
|
||||
"\n , callFrom=[" + callFrom + "]" +
|
||||
"\n , msgType=[" + msgType + "]" +
|
||||
"\n , templateContent=[" + templateContent + "]" +
|
||||
"\n , templateTitle=[" + templateTitle + "]" +
|
||||
"\n , subMsgSendYn=[" + subMsgSendYn + "]" +
|
||||
"\n , subMsgTxt=[" + subMsgTxt + "]" +
|
||||
"\n , subMsgType=[" + subMsgType + "]" +
|
||||
"\n , bizJsonName=[" + bizJsonName + "]" +
|
||||
"\n , reqDate=[" + reqDate + "]" +
|
||||
"\n ]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
package itn.let.kakao.kakaoComm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -10,9 +13,11 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import itn.com.cmm.util.StringUtil;
|
||||
import itn.let.kakao.kakaoComm.kakaoApi.KakaoApiJsonSave;
|
||||
import itn.let.mail.service.StatusResponse;
|
||||
import itn.let.mjo.msg.service.MjonMsgVO;
|
||||
import itn.let.mjo.msgdata.service.MjonMsgDataService;
|
||||
import itn.let.mjo.spammsg.web.ComGetSpamStringParser;
|
||||
import itn.let.module.base.PriceAndPoint;
|
||||
import itn.let.sym.site.service.JoinSettingVO;
|
||||
import itn.let.uss.umt.service.MberManageVO;
|
||||
|
||||
@ -25,6 +30,140 @@ public class KakaoSendUtil {
|
||||
@Resource(name = "MjonMsgDataService")
|
||||
private MjonMsgDataService mjonMsgDataService;
|
||||
|
||||
@Autowired
|
||||
private PriceAndPoint priceAndPoint;
|
||||
|
||||
/**
|
||||
* @methodName : kakaoSendPrice_advc
|
||||
* @author : 이호영
|
||||
* @date : 2025. 3. 7.
|
||||
* @description : 기존 kakaoSendPrice 개선
|
||||
* @return : KakaoVO
|
||||
* @param kakaoVO
|
||||
* @param statusResponse
|
||||
* @return
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public KakaoVO populateSendLists(KakaoVO kakaoVO, StatusResponse statusResponse) throws Exception {
|
||||
|
||||
//사용자 현재 보유 금액 불러오기(문자 발송 금액 차감 이전 금액)
|
||||
// String befCash = kakaoVO.getBefCash();
|
||||
|
||||
MjonMsgVO mjonMsgVO = new MjonMsgVO();
|
||||
mjonMsgVO.setUserId(kakaoVO.getUserId());
|
||||
String userMoney = priceAndPoint.getBefCash(kakaoVO.getUserId());
|
||||
String userPoint = priceAndPoint.getBefPoint(kakaoVO.getUserId());
|
||||
|
||||
//1.시스템 기본 단가 정보 불러오기
|
||||
JoinSettingVO sysJoinSetVO = mjonMsgDataService.selectJoinSettingInfo();
|
||||
|
||||
//2.사용자 개인 단가 정보 불러오기
|
||||
MberManageVO mberManageVO = mjonMsgDataService.selectMberManageInfo(kakaoVO.getUserId());
|
||||
Float kakaoAtPrice = mberManageVO.getKakaoAtPrice();
|
||||
|
||||
/** 대체문자 여부 체크(있으면 대체문자 가격으로 없으면 카카오톡 가격으로) */
|
||||
//대체문자 발송 여부 확인
|
||||
if("Y".equals(kakaoVO.getSubMsgSendYn())) {
|
||||
|
||||
// MsgSendUtils.getSmsTxtBytes
|
||||
|
||||
|
||||
String charset = "euc-kr"; //문자 바이트 계산에 필요한 캐릭터 셋 : 한글 2Byte로 계산
|
||||
int callToCnt = kakaoVO.getCallToList().length;
|
||||
String sendType = "";
|
||||
|
||||
for(int count =0; count < callToCnt; count++) {
|
||||
|
||||
|
||||
String tempSubMagTxt = kakaoVO.getSubMsgTxt().replace("\r\n", "\n");
|
||||
|
||||
|
||||
if(kakaoVO.getSubMsgTxtReplYn().equals("Y")) {
|
||||
tempSubMagTxt = kakaoSubMagTxtRepl(tempSubMagTxt, kakaoVO, count);
|
||||
}
|
||||
int bytes = tempSubMagTxt.getBytes(charset).length;
|
||||
|
||||
if(bytes < 2000) {
|
||||
if(bytes > 90) {
|
||||
sendType = "MMS";
|
||||
break;
|
||||
}else {
|
||||
sendType = "SMS";
|
||||
}
|
||||
}else {
|
||||
kakaoVO.setResultCode("2000");
|
||||
return kakaoVO;
|
||||
}
|
||||
}
|
||||
|
||||
if(sendType.equals("MMS")) {
|
||||
//협의 단가가 없으면 시스템 단가로 지정
|
||||
if(mberManageVO.getLongPrice() < 1) {
|
||||
kakaoAtPrice = sysJoinSetVO.getLongPrice();
|
||||
|
||||
kakaoVO.setSmsPrice(sysJoinSetVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(sysJoinSetVO.getLongPrice());
|
||||
kakaoVO.setKakaoAtPrice(sysJoinSetVO.getKakaoAtPrice());
|
||||
}else {
|
||||
kakaoAtPrice = mberManageVO.getLongPrice();
|
||||
|
||||
kakaoVO.setSmsPrice(mberManageVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(mberManageVO.getLongPrice());
|
||||
|
||||
if(mberManageVO.getKakaoAtPrice() < 1) {
|
||||
kakaoVO.setKakaoAtPrice(sysJoinSetVO.getKakaoAtPrice());
|
||||
}else {
|
||||
kakaoVO.setKakaoAtPrice(mberManageVO.getKakaoAtPrice());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//협의 단가가 없으면 시스템 단가로 지정
|
||||
if(mberManageVO.getShortPrice() < 1) {
|
||||
kakaoAtPrice = sysJoinSetVO.getShortPrice();
|
||||
|
||||
kakaoVO.setSmsPrice(sysJoinSetVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(sysJoinSetVO.getLongPrice());
|
||||
kakaoVO.setKakaoAtPrice(sysJoinSetVO.getKakaoAtPrice());
|
||||
}else {
|
||||
kakaoAtPrice = mberManageVO.getShortPrice();
|
||||
|
||||
kakaoVO.setSmsPrice(mberManageVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(mberManageVO.getLongPrice());
|
||||
if(mberManageVO.getKakaoAtPrice() < 1) {
|
||||
kakaoVO.setKakaoAtPrice(sysJoinSetVO.getKakaoAtPrice());
|
||||
}else {
|
||||
kakaoVO.setKakaoAtPrice(mberManageVO.getKakaoAtPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(kakaoAtPrice < 1) { //협의 단가가 없으면 시스템 단가로 지정
|
||||
kakaoAtPrice = sysJoinSetVO.getKakaoAtPrice();
|
||||
|
||||
kakaoVO.setSmsPrice(sysJoinSetVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(sysJoinSetVO.getLongPrice());
|
||||
kakaoVO.setKakaoAtPrice(sysJoinSetVO.getKakaoAtPrice());
|
||||
}else {
|
||||
kakaoVO.setSmsPrice(mberManageVO.getShortPrice());
|
||||
kakaoVO.setMmsPrice(mberManageVO.getLongPrice());
|
||||
kakaoVO.setKakaoAtPrice(mberManageVO.getKakaoAtPrice());
|
||||
}
|
||||
}
|
||||
|
||||
/** 전송인원 확인*/
|
||||
int totCallCnt = kakaoVO.getCallToList().length;
|
||||
Float kakaoTotPrice = totCallCnt * kakaoAtPrice; // 총결제 금액 = 총 전송수량 * 카카오 알림톡 단가
|
||||
String totPrice = kakaoTotPrice.toString();
|
||||
System.out.println("@@@@@@@ : "+kakaoTotPrice +" = "+totCallCnt+" * "+kakaoAtPrice);
|
||||
|
||||
kakaoVO.setEachPrice(kakaoAtPrice.toString());
|
||||
kakaoVO.setBefCash(userMoney); // 고객 충전금액
|
||||
kakaoVO.setBefPoint(userPoint); // 고객 충전 포인트
|
||||
kakaoVO.setTotPrice(totPrice); // 총 카카오 전송 금액
|
||||
|
||||
return kakaoVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Method Name : kakaoSendPrice
|
||||
@ -34,13 +173,11 @@ public class KakaoSendUtil {
|
||||
*/
|
||||
public KakaoVO kakaoSendPrice(KakaoVO kakaoVO) throws Exception {
|
||||
|
||||
System.out.println(" :: kakaoSendPrice :: ");
|
||||
|
||||
//사용자 현재 보유 금액 불러오기(문자 발송 금액 차감 이전 금액)
|
||||
String befCash = kakaoVO.getBefCash();
|
||||
// String befCash = kakaoVO.getBefCash();
|
||||
|
||||
//VO에서 현재 보유금액이 없으면 디비에서 조회해서 불러옴
|
||||
if("".equals(befCash) || befCash == null) {
|
||||
|
||||
}
|
||||
MjonMsgVO mjonMsgVO = new MjonMsgVO();
|
||||
mjonMsgVO.setUserId(kakaoVO.getUserId());
|
||||
String userMoney = mjonMsgDataService.selectBeforeCashData(mjonMsgVO);
|
||||
@ -55,6 +192,7 @@ public class KakaoSendUtil {
|
||||
|
||||
/** 대체문자 여부 체크(있으면 대체문자 가격으로 없으면 카카오톡 가격으로) */
|
||||
//대체문자 발송 여부 확인
|
||||
System.out.println(" :: kakaoVO.getSubMsgSendYn() :: "+ kakaoVO.getSubMsgSendYn());
|
||||
if(kakaoVO.getSubMsgSendYn().equals("Y")) {
|
||||
|
||||
|
||||
@ -66,6 +204,8 @@ public class KakaoSendUtil {
|
||||
String tempSubMagTxt = kakaoVO.getSubMsgTxt().replace("\r\n", "\n");
|
||||
if(kakaoVO.getSubMsgTxtReplYn().equals("Y")) {
|
||||
tempSubMagTxt = kakaoSubMagTxtRepl(tempSubMagTxt, kakaoVO, count);
|
||||
// tempSubMagTxt = kakaoSubMagTxtRepl_advc(tempSubMagTxt, kakaoVO, count);
|
||||
System.out.println("+ tempSubMagTxt :: "+ tempSubMagTxt);
|
||||
}
|
||||
int bytes = tempSubMagTxt.getBytes(charset).length;
|
||||
|
||||
@ -401,6 +541,7 @@ public class KakaoSendUtil {
|
||||
varValInfo = kakaoVO.getVarValList().get(count);
|
||||
}
|
||||
String jsonFileName = kakaoApiJsonSave.kakaoApiJsonSave(kakaoVO, varValInfo);
|
||||
// String jsonFileName = kakaoApiJsonSave.kakaoApiJsonSave_advc(kakaoVO, varValInfo);
|
||||
// String jsonFileName = kakaoApiJsonSave.kakaoApiJsonSave(kakaoVO, kakaoVO.getVarValList().get(count));
|
||||
setSendMsgVO.setBizJsonName(jsonFileName); //json 파일명
|
||||
}
|
||||
@ -509,6 +650,7 @@ public class KakaoSendUtil {
|
||||
|
||||
|
||||
public String kakaoSubMagTxtRepl(String tempSubMagTxt, KakaoVO kakaoVO, int count) {
|
||||
System.out.println("tempSubMagTxt : "+ tempSubMagTxt);
|
||||
|
||||
// String tempSubMagTxt = kakaoVO.getSubMsgTxt().replace("\r\n", "\n");
|
||||
// String tempSubMagTxt = msgTxt;
|
||||
@ -551,6 +693,7 @@ public class KakaoSendUtil {
|
||||
return tempSubMagTxt;
|
||||
}
|
||||
|
||||
|
||||
public String kakaoFTSubMagTxtRepl(String tempSubMagTxt, KakaoVO kakaoVO, int count) throws Exception{
|
||||
|
||||
List<String[]> varValList = kakaoVO.getVarValList();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,124 @@ public class KakaoApiJsonSave {
|
||||
|
||||
static String json;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String kakaoApiJsonSave_advc(KakaoVO kakaoVO, String[] varValInfo) {
|
||||
// json파일 저장
|
||||
|
||||
|
||||
Date nowDate = new Date();
|
||||
SimpleDateFormat todayFrom = new SimpleDateFormat("yyyyMMdd");
|
||||
SimpleDateFormat timeFrom = new SimpleDateFormat("HHmmss");
|
||||
String jsonFileName = mjonBizJsonDir+"/"+kakaoVO.getUserId()+"/"+todayFrom.format(nowDate)+"/"+kakaoVO.getSendType(); // 아이디/날짜/타입
|
||||
|
||||
String fileName = timeFrom.format(nowDate)+"_"+kakaoVO.getDestPhone()+".json";
|
||||
|
||||
|
||||
// File userIdFile = new File(jsonFileName);
|
||||
// if(!userIdFile.exists()) {
|
||||
// userIdFile.mkdirs(); // 없으면 하위 디렉토리 까지 생성
|
||||
// jsonFileName = jsonFileName +"/"+fileName;
|
||||
// }else {
|
||||
//
|
||||
// jsonFileName = jsonFileName +"/"+fileName;
|
||||
// System.out.println("jsonFileName : "+jsonFileName);
|
||||
// File file1 = new File(jsonFileName);
|
||||
// if (file1.isFile()) {
|
||||
// return jsonFileName;
|
||||
// }
|
||||
// }
|
||||
|
||||
KakaoReturnVO templateDetail = kakaoApiTemplate.selectKakaoApiTemplateDetail(kakaoVO);
|
||||
|
||||
// 버튼리스트 JSON 생성
|
||||
JSONArray buttonList = new JSONArray();
|
||||
for(KakaoButtonVO buttonInfoVO : templateDetail.getButtonList()) {
|
||||
JSONObject buttonInfo = new JSONObject();
|
||||
|
||||
buttonInfo.put("name", buttonInfoVO.getName());
|
||||
buttonInfo.put("type", buttonInfoVO.getLinkType());
|
||||
|
||||
if(buttonInfoVO.getLinkType().equals("WL")) {
|
||||
buttonInfo.put("url_mobile", buttonInfoVO.getLinkMo());
|
||||
buttonInfo.put("url_pc", buttonInfoVO.getLinkPc());
|
||||
}else if(buttonInfoVO.getLinkType().equals("AL")) {
|
||||
buttonInfo.put("scheme_ios", buttonInfoVO.getLinkIos());
|
||||
buttonInfo.put("scheme_android", buttonInfoVO.getLinkAnd());
|
||||
}else if(buttonInfoVO.getLinkType().equals("BC")) {
|
||||
// 상담톡 진행시 등록해야함
|
||||
}else if(buttonInfoVO.getLinkType().equals("BT")) {
|
||||
// 봇 전환 시 전달
|
||||
}
|
||||
buttonList.add(buttonInfo);
|
||||
}
|
||||
|
||||
// 강조유형 JSON 생성
|
||||
JSONObject templateDetailInfo = new JSONObject();
|
||||
String emphasizeType = templateDetail.getTemplateEmphasizeType();
|
||||
|
||||
if(emphasizeType.equals("TEXT")) {
|
||||
|
||||
String templateTitle = templateDetail.getTemplateTitle();
|
||||
if(kakaoVO.getVarNmList().size() != 0) {
|
||||
String[] varNm = new String[kakaoVO.getVarNmList().size()];
|
||||
int q=0;
|
||||
for(String temp : kakaoVO.getVarNmList()) {
|
||||
temp = temp.replaceAll("\\#\\{" , "§§");
|
||||
temp = temp.replaceAll("\\}" , "§");
|
||||
varNm[q] = temp;
|
||||
q++;
|
||||
}
|
||||
List<String[]> varValList = kakaoVO.getVarValList(); // value 값
|
||||
|
||||
templateTitle = templateTitle.replaceAll(String.valueOf((char)13), "");
|
||||
templateTitle = templateTitle.replaceAll("\\#\\{" , "§§");
|
||||
templateTitle = templateTitle.replaceAll("\\}" , "§");
|
||||
|
||||
for(int i=0; i < varNm.length; i++) {
|
||||
for(int j=0; j < varValInfo.length; j++) {
|
||||
if (templateTitle.indexOf(varNm[i]) > -1) {
|
||||
if(varValInfo[j] != null) {
|
||||
templateTitle = templateTitle.replaceAll(varNm[i] , StringUtil.getString(varValInfo[j]));
|
||||
}else {
|
||||
templateTitle = templateTitle.replaceAll(varNm[i] , "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templateDetailInfo.put("title", templateTitle);
|
||||
}else {
|
||||
templateDetailInfo.put("title", templateTitle);
|
||||
}
|
||||
}else if(emphasizeType.equals("IMAGE")) {
|
||||
templateDetailInfo.put("msg_type", "ai");
|
||||
}else if(emphasizeType.equals("NONE")) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
|
||||
if(buttonList.size() != 0) {
|
||||
jo.put("button", buttonList);
|
||||
}
|
||||
if(templateDetailInfo.size() != 0) {
|
||||
jo.put("extra", templateDetailInfo);
|
||||
}
|
||||
|
||||
// 입력 json 데이터를 파일로 변경
|
||||
String jsonStr = jo.toString();
|
||||
// System.out.println("jsonStr : "+jsonStr);
|
||||
|
||||
// File outPut = new File(jsonFileName);
|
||||
// outPut.createNewFile();
|
||||
|
||||
// BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outPut), "utf-8"));
|
||||
// bw.write(jsonStr);
|
||||
// bw.close();
|
||||
|
||||
return jsonFileName;
|
||||
}
|
||||
|
||||
public String kakaoApiJsonSave(KakaoVO kakaoVO, String[] varValInfo) {
|
||||
// json파일 저장
|
||||
|
||||
@ -140,7 +257,7 @@ public class KakaoApiJsonSave {
|
||||
|
||||
// 입력 json 데이터를 파일로 변경
|
||||
String jsonStr = jo.toString();
|
||||
System.out.println("jsonFileName : "+jsonFileName);
|
||||
// System.out.println("jsonFileName : "+jsonFileName);
|
||||
|
||||
File outPut = new File(jsonFileName);
|
||||
outPut.createNewFile();
|
||||
|
||||
@ -2,7 +2,11 @@ package itn.let.kakao.user.kakaoAt.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import itn.let.kakao.kakaoComm.KakaoSendAdvcVO;
|
||||
import itn.let.kakao.kakaoComm.KakaoVO;
|
||||
import itn.let.mail.service.StatusResponse;
|
||||
import itn.let.mjo.msgdata.service.MjonMsgReturnVO;
|
||||
|
||||
public interface KakaoAlimTalkService {
|
||||
@ -25,4 +29,6 @@ public interface KakaoAlimTalkService {
|
||||
//카카오 친구톡 전송 실패 환불리스트 조회
|
||||
public void selectKakaoFtSentRefundList() throws Exception;
|
||||
|
||||
StatusResponse insertKakaoAtSandAjax_advc(KakaoVO kakaoVO, HttpServletRequest request) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@ -4,16 +4,27 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import egovframework.rte.fdl.idgnr.EgovIdGnrService;
|
||||
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.KakaoSendAdvcVO;
|
||||
import itn.let.kakao.kakaoComm.KakaoSendUtil;
|
||||
import itn.let.kakao.kakaoComm.KakaoVO;
|
||||
import itn.let.kakao.user.kakaoAt.service.KakaoAlimTalkService;
|
||||
import itn.let.mail.service.StatusResponse;
|
||||
import itn.let.mjo.mjocommon.MjonHolidayApi;
|
||||
import itn.let.mjo.msg.service.MjonMsgVO;
|
||||
import itn.let.mjo.msg.service.impl.MjonMsgDAO;
|
||||
@ -24,9 +35,13 @@ import itn.let.mjo.msgholiday.service.MsgHolidayVO;
|
||||
import itn.let.mjo.msgholiday.service.impl.MsgHolidayDAO;
|
||||
import itn.let.mjo.pay.service.MjonPayService;
|
||||
import itn.let.mjo.pay.service.MjonPayVO;
|
||||
import itn.let.module.base.PriceAndPoint;
|
||||
import itn.let.sym.site.service.JoinSettingVO;
|
||||
import itn.let.sym.site.service.impl.SiteManagerDAO;
|
||||
import itn.let.uss.umt.service.EgovUserManageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service("kakaoAlimTalkService")
|
||||
public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements KakaoAlimTalkService{
|
||||
|
||||
@ -54,6 +69,16 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
|
||||
@Resource(name = "egovMjonCashIdGnrService")
|
||||
private EgovIdGnrService idgenMjonCashId;
|
||||
|
||||
/** userManageService */
|
||||
@Resource(name = "userManageService")
|
||||
private EgovUserManageService userManageService;
|
||||
|
||||
@Autowired
|
||||
private PriceAndPoint priceAndPoint;
|
||||
|
||||
@Autowired
|
||||
KakaoSendUtil kakaoSendUtil;
|
||||
|
||||
//발신프로필 상태값 변경(삭제/복구 기능)
|
||||
@Override
|
||||
public int updateKakaoProfileStatus(KakaoVO kakaoVO) throws Exception{
|
||||
@ -816,4 +841,119 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusResponse insertKakaoAtSandAjax_advc(KakaoVO kakaoVO, HttpServletRequest request) throws Exception {
|
||||
|
||||
// log.info(" :: [{}]", kakaoVO.toString());
|
||||
|
||||
// KakaoSendAdvcVO
|
||||
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
|
||||
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()
|
||||
? (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser()
|
||||
: null;
|
||||
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
|
||||
|
||||
if (userId.equals("")) {
|
||||
return new StatusResponse(HttpStatus.BAD_REQUEST, "로그인 후 이용이 가능합니다.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 회원 정지된 상태이면 문자 발송이 안되도록 처리함 현재 로그인 세션도 만료 처리함
|
||||
*/
|
||||
boolean mberSttus = userManageService.selectUserStatusInfo(userId);
|
||||
if (!mberSttus) {
|
||||
request.getSession().invalidate();
|
||||
// UNAUTHORIZED : 인증되지 않은 사용자가 접근하려고 할 때
|
||||
return new StatusResponse(HttpStatus.UNAUTHORIZED,
|
||||
"현재 고객님께서는 문자온 서비스 이용이 정지된 상태로 알림톡을 발송하실 수 없습니다. 이용정지 해제를 원하시면 고객센터로 연락주시기 바랍니다.");
|
||||
}
|
||||
|
||||
|
||||
StatusResponse statusResponse = new StatusResponse();
|
||||
|
||||
|
||||
/** 카카오톡 전송 기본 설정 -------------------------------------------*/
|
||||
kakaoVO.setSendType("AT");
|
||||
kakaoVO.setMsgType("8");
|
||||
kakaoVO.setUserId(userId);
|
||||
|
||||
|
||||
/** 전송금액 설정 --------------------------------------------------*/
|
||||
// KakaoVO priceSet = kakaoSendUtil.populateSendLists(kakaoVO, statusResponse);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** 카카오톡 전송 기본 설정 -------------------------------------------*/
|
||||
kakaoVO.setSendType("AT");
|
||||
kakaoVO.setMsgType("8");
|
||||
kakaoVO.setUserId(userId);
|
||||
|
||||
|
||||
|
||||
// priceAndPoint.getBefCash(userId);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return statusResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -35,9 +35,11 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -57,6 +59,7 @@ import itn.com.cmm.util.MJUtil;
|
||||
import itn.com.cmm.util.StringUtil;
|
||||
import itn.com.utl.fcc.service.EgovStringUtil;
|
||||
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.KakaoApiJsonSave;
|
||||
@ -65,6 +68,7 @@ import itn.let.kakao.kakaoComm.kakaoApi.KakaoApiProfileCategory;
|
||||
import itn.let.kakao.kakaoComm.kakaoApi.KakaoApiTemplate;
|
||||
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;
|
||||
import itn.let.mjo.mjocommon.MjonHolidayApi;
|
||||
import itn.let.mjo.msgdata.service.MjonMsgDataService;
|
||||
@ -1057,6 +1061,16 @@ public class KakaoAlimTalkSendController {
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@RequestMapping(value= {"/web/mjon/kakao/alimtalk/kakaoAlimTalkMsgSendAjax_advc.do"}, method = RequestMethod.POST)
|
||||
public ResponseEntity<StatusResponse> kakaoAlimTalkMsgSendAjax_advc(
|
||||
@RequestBody KakaoVO kakaoVO,
|
||||
HttpServletRequest request
|
||||
) throws Exception {
|
||||
|
||||
System.out.println(" + kakaoAlimTalkMsgSendAjax_advc + ");
|
||||
return ResponseEntity.ok().body(kakaoAlimTalkService.insertKakaoAtSandAjax_advc(kakaoVO, request)) ;
|
||||
}
|
||||
|
||||
@RequestMapping(value= {"/web/mjon/kakao/alimtalk/kakaoAlimTalkMsgSendAjax.do"}, method = RequestMethod.POST)
|
||||
// @ResponseBody
|
||||
public ModelAndView kakaoAlimTalkMsgSendAjax(
|
||||
@ -1064,6 +1078,10 @@ public class KakaoAlimTalkSendController {
|
||||
HttpServletRequest request,
|
||||
@ModelAttribute("kakaoVO") KakaoVO kakaoVO
|
||||
) throws Exception {
|
||||
// 시작 시간
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
System.out.println(" :: kakaoAlimTalkMsgSendAjax :: ");
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("jsonView");
|
||||
|
||||
@ -1109,6 +1127,10 @@ public class KakaoAlimTalkSendController {
|
||||
/** 전송금액 설정 --------------------------------------------------*/
|
||||
KakaoVO priceSet = kakaoSendUtil.kakaoSendPrice(kakaoVO);
|
||||
|
||||
if (true) {
|
||||
throw new IllegalStateException("배열 크기 초과");
|
||||
}
|
||||
|
||||
|
||||
if(priceSet.getResultCode() != null && priceSet.getResultCode().equals("2000")) {
|
||||
|
||||
@ -1400,6 +1422,17 @@ public class KakaoAlimTalkSendController {
|
||||
} catch (Exception e) {
|
||||
throw new Exception("++++++++++++++++++++++ getAdminPhoneSendMsgData Error !!! " + e);
|
||||
}
|
||||
// 종료 시간
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
// 실행 시간 계산 (초 단위)
|
||||
double executionTimeSeconds = (endTime - startTime) / 1000.0;
|
||||
|
||||
System.out.println("실행 시간: " + String.format("%.3f", executionTimeSeconds) + "초");
|
||||
|
||||
|
||||
String returnTxt = String.format("%.3f", executionTimeSeconds) + "초";
|
||||
modelAndView.addObject("seconds", returnTxt);
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ function sendTemplateInfo(){
|
||||
|
||||
// 초기화
|
||||
$('.varValList').remove();
|
||||
$('#bizForm #varNmList').val('');
|
||||
// $('#bizForm #varNmList').val('');
|
||||
|
||||
|
||||
// 대체문자 전송 확인
|
||||
@ -614,79 +614,65 @@ function sendTemplateInfo(){
|
||||
$('#bizForm #reqDate').val("");
|
||||
}
|
||||
|
||||
var dataList = [];
|
||||
// 치환문자 있는 데이터 파씽
|
||||
if($('#bizForm #txtReplYn').val() === 'Y'){
|
||||
fn_excelDataTransParsing();
|
||||
// fn_excelDataTransParsing();
|
||||
// 치환문자 있는 수신자 리스트
|
||||
fn_transCallToListParsing();
|
||||
dataList = fn_transCallToListParsing();
|
||||
}else{
|
||||
// 치환문자 없는 수신자 리스트
|
||||
fn_callToListParsing();
|
||||
dataList = fn_callToListParsing();
|
||||
}
|
||||
|
||||
$('#bizForm #senderKey').val($('#selectKakaoProfileList').val());
|
||||
$('#bizForm #templateCode').val($('#selectTemplateList').val());
|
||||
|
||||
|
||||
|
||||
|
||||
// 채널 ID
|
||||
$('#bizForm #senderKey').val($('#selectKakaoProfileList').val());
|
||||
// 채널 > 템플릿
|
||||
$('#bizForm #templateCode').val($('#selectTemplateList').val());
|
||||
// 발신번호
|
||||
$('#bizForm #callFrom').val(removeDash($('#callFromList option:selected').val()));
|
||||
|
||||
// 폼 데이터를 배열로 직렬화
|
||||
var form = $('#bizForm');
|
||||
var formDataArray = form.serializeArray();
|
||||
|
||||
// 배열을 객체로 변환
|
||||
var formData = {};
|
||||
$.each(formDataArray, function(index, field) {
|
||||
formData[field.name] = field.value;
|
||||
});
|
||||
|
||||
// 빈 값 제거 (참고 코드 기반)
|
||||
for (var key in formData) {
|
||||
if (formData[key] === '' || formData[key] === null || formData[key] === undefined) {
|
||||
delete formData[key];
|
||||
}
|
||||
}
|
||||
|
||||
// delete formData['varNmList'];
|
||||
|
||||
// 선택된 데이터 추가 (varListMap)
|
||||
formData["varListMap"] = dataList;
|
||||
console.log('formData : ', formData);
|
||||
|
||||
if(confirm("알림톡을 발송하시겠습니까?")){
|
||||
var spamChk = true;
|
||||
//2023.09.06 알림톡 스팸체크 기능 제거요청으로 인한 주석처리
|
||||
/*var spamChk = false;
|
||||
var spmData = new FormData(document.bizForm);
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST"
|
||||
, url: "/web/mjon/alimtalk/selectSpamKakaoAlimtalkMsgChkAjax.do"
|
||||
, data: spmData
|
||||
, dataType:'json'
|
||||
, async: false
|
||||
, processData: false
|
||||
, contentType: false
|
||||
, cache: false
|
||||
, success: function (returnData, status) {
|
||||
if(status == 'success'){ // status 확인 필요한가. 석세스 안뜨면 에러 가지 않나
|
||||
|
||||
if("fail" == returnData.result){
|
||||
alert(returnData.message);
|
||||
return false;
|
||||
}else if("loginFail" == returnData.result){
|
||||
alert(returnData.message);
|
||||
return false;
|
||||
}else if("spams" == returnData.result){
|
||||
alert("전송 내용에 스팸문구가 포함되어 있습니다.")
|
||||
return false;
|
||||
}else{
|
||||
spamChk = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} else if(status== 'fail'){
|
||||
alert(returnData.message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
, error: function (e) {
|
||||
alert("문자 발송에 실패하였습니다.");
|
||||
console.log("ERROR : ", e);
|
||||
return false;
|
||||
}
|
||||
}); */
|
||||
|
||||
if(spamChk){
|
||||
var data = new FormData(document.bizForm);
|
||||
$.ajax({
|
||||
type: "POST"
|
||||
, url: "/web/mjon/kakao/alimtalk/kakaoAlimTalkMsgSendAjax.do"
|
||||
, data: data
|
||||
, dataType: 'json'
|
||||
, async: true
|
||||
, processData: false
|
||||
, contentType: false
|
||||
, cache: false
|
||||
, success: function (returnData, status) {
|
||||
if(status == 'success'){
|
||||
if("loginFail" == returnData.result){
|
||||
type: "POST",
|
||||
url: "/web/mjon/kakao/alimtalk/kakaoAlimTalkMsgSendAjax_advc.do",
|
||||
data: JSON.stringify(formData),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
console.log('data : ', data);
|
||||
// if(data == 'success'){
|
||||
/* if("loginFail" == returnData.result){
|
||||
|
||||
alert(returnData.message);
|
||||
return false;
|
||||
@ -715,8 +701,8 @@ function sendTemplateInfo(){
|
||||
}
|
||||
|
||||
$('.mask').addClass('on');
|
||||
}
|
||||
}
|
||||
} */
|
||||
// }
|
||||
}
|
||||
,beforeSend : function(xmlHttpRequest) {
|
||||
//로딩창 show
|
||||
@ -732,14 +718,13 @@ function sendTemplateInfo(){
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 치환문자 있는 수신자 목록 파씽
|
||||
*/
|
||||
function fn_transCallToListParsing(){
|
||||
var callToList = [];
|
||||
/* var callToList = [];
|
||||
// excel body
|
||||
$('.excelBody').each(function(indexBody, itemBody){
|
||||
$(itemBody).find('.list_table_name').each(function(indexRow, itemRow){
|
||||
@ -750,7 +735,31 @@ function fn_transCallToListParsing(){
|
||||
});
|
||||
});
|
||||
$('#bizForm #callToList').val(callToList);
|
||||
*/
|
||||
|
||||
var dataList = [];
|
||||
|
||||
var headers = [];
|
||||
$('#excelHead .list_table_name').each(function() {
|
||||
headers.push($(this).text().trim());
|
||||
});
|
||||
|
||||
$('.excelBody').each(function() {
|
||||
var row = {};
|
||||
$(this).find('.list_table_name').each(function(index) {
|
||||
var key = headers[index];
|
||||
var value = $(this).text().trim();
|
||||
if (index === 0) {
|
||||
row["callToList"] = value; // 수신번호는 별도로 처리
|
||||
} else {
|
||||
row[key] = value; //
|
||||
}
|
||||
});
|
||||
console.log(row)
|
||||
dataList.push(row);
|
||||
});
|
||||
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -758,13 +767,25 @@ function fn_transCallToListParsing(){
|
||||
*/
|
||||
function fn_callToListParsing(){
|
||||
|
||||
var callToList = [];
|
||||
var dataList = [];
|
||||
/* var callToList = [];
|
||||
// excel body
|
||||
$('.phoneArea').each(function(index, item){
|
||||
callToList.push($(item).text().replaceAll('\\t', ''));
|
||||
});
|
||||
|
||||
$('#bizForm #callToList').val(callToList);
|
||||
$('#bizForm #callToList').val(callToList); */
|
||||
|
||||
$('.phoneArea').each(function(index, item){
|
||||
var row = {};
|
||||
var value = $(item).text().replaceAll('\\t', '')
|
||||
row["callToList"] = value; // 수신번호는 별도로 처리
|
||||
dataList.push(row);
|
||||
});
|
||||
|
||||
return dataList;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -777,9 +798,8 @@ function fn_excelDataTransParsing(){
|
||||
// title 배열
|
||||
var varHead = [];
|
||||
// 값 배열
|
||||
var varVal = [];
|
||||
// var varVal = [];
|
||||
|
||||
var inputTag = '<input type="hidden" class="varValList" name="varValList[$INDEX$]" value="$VAL$">';
|
||||
|
||||
// excel title
|
||||
$('#excelHead').find('div').each(function(index, item){
|
||||
@ -803,7 +823,7 @@ function fn_excelDataTransParsing(){
|
||||
$("#bizForm").append(inputTag.replace('$VAL$',varValTemp ).replace('$INDEX$',index ));
|
||||
}); */
|
||||
|
||||
$('.excelBody').each(function(index, item){
|
||||
/* $('.excelBody').each(function(index, item){
|
||||
|
||||
var valLeng = $('#excelHead').find('.list_table_name').length-1;
|
||||
varValTemp = '';
|
||||
@ -821,7 +841,7 @@ function fn_excelDataTransParsing(){
|
||||
console.log('varValTemp : ',varValTemp);
|
||||
varVal.push(varValTemp);
|
||||
});
|
||||
$('#bizForm #varValList').val(varVal);
|
||||
$('#bizForm #varValList').val(varVal); */
|
||||
}
|
||||
|
||||
|
||||
@ -1136,8 +1156,8 @@ function checkNumber(event) {
|
||||
<input type="hidden" id="divideTime" name="divideTime" value=""> <!--전송일자-->
|
||||
|
||||
<input type="hidden" id="callFrom" name="callFrom" value=""> <!--완 보내는사람 -->
|
||||
<input type="hidden" id="callToList" name="callToList" value=""> <!--완 받는사람 리스트-->
|
||||
<input type="hidden" id="varNmList" name="varNmList" value=""> <!--완 변수 이름 리스트-->
|
||||
<!-- <input type="hidden" id="callToList" name="callToList" value=""> 완 받는사람 리스트 -->
|
||||
<!-- <input type="hidden" id="varNmList" name="varNmList" value=""> 완 변수 이름 리스트 -->
|
||||
<input type="hidden" id="varValList" name="varValList" value=""> <!--완 변수 리스트-->
|
||||
|
||||
<input type="hidden" id="atSmishingYn" name="atSmishingYn" value="${atSmishingYn}"> <!--알림톡 스미싱 여부-->
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user