문자발송로직 impl 화 완료 -> 리펙토링 진행 중

This commit is contained in:
hehihoho3@gmail.com 2024-09-27 14:31:27 +09:00
parent f1b873cb9c
commit 3c6e83d10b
10 changed files with 6223 additions and 4105 deletions

View File

@ -0,0 +1,468 @@
package itn.com.cmm.util;
import java.io.UnsupportedEncodingException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.msg.service.MjonMsgVO;
import itn.let.mjo.msgdata.service.ReplacementListsVO;
import lombok.extern.slf4j.Slf4j;
/**
*
* @author : 이호영
* @fileName : MsgSendUtils.java
* @date : 2024.09.23
* @description : 메세지발송 데이터 다루는 유틸
* ===========================================================
* DATE AUTHOR NOTE
* ----------------------------------------------------------- *
* 2024.09.23 이호영 최초 생성
*
*
*
*/
@Slf4j
public final class MsgSendUtils {
/**
* @methodName : getSmsTxtBytes
* @author : 이호영
* @date : 2024.09.23
* @description : sms 텍스트 바이트 계산 return;
* @param smsTxt
* @return
* @throws UnsupportedEncodingException
*/
public static int getSmsTxtBytes(String smsTxt) throws UnsupportedEncodingException { //문자열 길이 체크 해주기
int smsBytes = 0;
//문자 바이트 계산에 필요한 캐릭터 : 한글 2Byte로 계산
String charset = "euc-kr";
if(StringUtils.isNotEmpty(smsTxt)) {
String smsCont = smsTxt.replace("\r\n", "\n");
smsBytes = smsCont.getBytes(charset).length;
}
return smsBytes;
}
/**
* @methodName : getMsgType
* @author : 이호영
* @date : 2024.09.23
* @description : msgType 재정의
* @param mjonMsgVO
* @param smsTxtByte
* @return
*/
public static String getMsgType(MjonMsgVO mjonMsgVO, int smsTxtByte) {
String msgType = mjonMsgVO.getMsgType();
// 내문자저장함에 저장 문자를 발송하는 경우 문자 타입이 숫자가 아닌 문자로 넘어와서 변경 처리함
if ("P".equals(msgType) || "L".equals(msgType)) {
msgType = "6";
} else if ("S".equals(msgType)) {
msgType = "4";
}
// 그림 이미지가 첨부된 경우 장문으로 설정
if (mjonMsgVO.getFileName1() != null || (mjonMsgVO.getImgFilePath() != null && mjonMsgVO.getImgFilePath().length > 0)) {
msgType = "6";
} else if (smsTxtByte > 2000) {
// 2000 Byte를 초과할 경우 에러 처리 ( 부분은 호출부에서 검사하도록 유지할 수도 있음)
return "INVALID"; // 값은 호출부에서 에러 처리를 하도록 활용할 있습니다.
} else if (smsTxtByte > 90) {
// 90Byte 초과 장문으로 설정
msgType = "6";
} else {
// 단문으로 설정
msgType = "4";
}
return msgType;
}
public static float getValidPrice(Float personalPrice, Float defaultPrice) {
return (personalPrice != null && personalPrice > 0) ? personalPrice : defaultPrice;
}
/**
* @methodName : determinePriceByMsgType
* @author : 이호영
* @date : 2024.09.24
* @description : 문자 메시지 타입에 따라 단가를 결정하는 메서드
* @param mjonMsgVO
* @param shortPrice
* @param longPrice
* @param picturePrice
* @param picture2Price
* @param picture3Price
* @return
*/
public static float determinePriceByMsgType(MjonMsgVO mjonMsgVO, float shortPrice, float longPrice,
float picturePrice, float picture2Price, float picture3Price) {
float price = 0;
String msgType = mjonMsgVO.getMsgType();
if ("4".equals(msgType)) {
price = shortPrice;
} else if ("6".equals(msgType)) {
// 파일 첨부 여부에 따라 장문 단가 설정
if (mjonMsgVO.getFileName3() != null) {
price = picture3Price;
} else if (mjonMsgVO.getFileName2() != null) {
price = picture2Price;
} else if (mjonMsgVO.getFileName1() != null) {
price = picturePrice;
} else {
price = longPrice;
}
}
return price;
}
public static boolean isReplacementRequired(MjonMsgVO mjonMsgVO) {
return "Y".equals(mjonMsgVO.getTxtReplYn());
}
public static boolean isReplacementDataValid(MjonMsgVO mjonMsgVO) {
String[] nameList = mjonMsgVO.getNameList();
String[] rep1 = mjonMsgVO.getRep1List();
String[] rep2 = mjonMsgVO.getRep2List();
String[] rep3 = mjonMsgVO.getRep3List();
String[] rep4 = mjonMsgVO.getRep4List();
// 치환 문자 리스트가 유효한지 확인
return !(isEmpty(nameList)
&& isEmpty(rep1)
&& isEmpty(rep2)
&& isEmpty(rep3)
&& isEmpty(rep4));
}
// 배열이 비어있는지 확인하는 메서드
public static boolean isEmpty(String[] array) {
return array == null || array.length == 0;
}
public static ReplacementListsVO createReplacementLists(MjonMsgVO mjonMsgVO) throws UnsupportedEncodingException {
ReplacementListsVO lists = new ReplacementListsVO();
lists.initializeLists(mjonMsgVO); // 배열을 초기화합니다.
return lists;
// return populateReplacementLists(mjonMsgVO, lists); // 데이터를 배열에 채웁니다.
}
/**
* @methodName : populateReplacementLists
* @author : 이호영
* @date : 2024.09.26
* @description : 배열에 데이터를 채우는 메서드
* @param mjonMsgVO
* @param lists
* @param statusResponse
* @return
* @throws UnsupportedEncodingException
*/
public static void populateReplacementLists(MjonMsgVO mjonMsgVO, ReplacementListsVO lists, StatusResponse statusResponse){
String[] nameList = mjonMsgVO.getNameList();
String[] phone = mjonMsgVO.getCallToList();
String[] rep1 = mjonMsgVO.getRep1List();
String[] rep2 = mjonMsgVO.getRep2List();
String[] rep3 = mjonMsgVO.getRep3List();
String[] rep4 = mjonMsgVO.getRep4List();
String smsTxt = mjonMsgVO.getSmsTxt();
int fileCount = Integer.parseInt(mjonMsgVO.getFileCnt());
// 이름 치환
int shortCnt = 0;
int longCnt = 0;
int imgCnt = 0;
for (int i = 0; i < phone.length; i++) {
smsTxt = smsTxt.replaceAll(String.valueOf((char) 13), "");
if (smsTxt.contains("[*이름*]")) {
if (nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", StringUtil.getString(nameList[i].replaceAll("§", ",")));
} else {
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", "");
}
}
// 문자 1 치환
if (smsTxt.contains("[*1*]")) {
if (rep1.length > i && StringUtil.isNotEmpty(rep1[i])) {
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", StringUtil.getString(rep1[i].replaceAll("§", ",")));
} else {
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", "");
}
}
// 문자 2 치환
if (smsTxt.contains("[*2*]")) {
if (rep2.length > i && StringUtil.isNotEmpty(rep2[i])) {
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", StringUtil.getString(rep2[i].replaceAll("§", ",")));
} else {
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", "");
}
}
// 문자 3 치환
if (smsTxt.contains("[*3*]")) {
if (rep3.length > i && StringUtil.isNotEmpty(rep3[i])) {
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", StringUtil.getString(rep3[i].replaceAll("§", ",")));
} else {
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", "");
}
}
// 문자 4 치환
if (smsTxt.contains("[*4*]")) {
if (rep4.length > i && StringUtil.isNotEmpty(rep4[i])) {
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", StringUtil.getString(rep4[i].replaceAll("§", ",")));
} else {
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", "");
}
}
try {
int bytes = getSmsTxtBytes(smsTxt);
if(bytes < 2000) {
if(fileCount > 0) {
populateImgLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
imgCnt++;
}else if(bytes > 90) {//장문문자 리스트 만들기
populateLongLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
longCnt++;
} else {//단문문자 리스트 만들기
populateShortLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
shortCnt++;
}
}else {
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 후 전송 문자 길이를 초과하였습니다.");
}
} catch (UnsupportedEncodingException e) {
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "전송 중 오류가 발생하였습니다.");
e.printStackTrace();
}
}
lists.setShortCnt(shortCnt);
lists.setLongCnt(longCnt);
lists.setImgCnt(imgCnt);
}
private static void populateShortLists(ReplacementListsVO lists, String[] nameList, String[] phone, String[] rep1,
String[] rep2, String[] rep3, String[] rep4, String smsTxt, int i) {
// 이름 치환
if (smsTxt.contains("[*이름*]")) {
if (nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
lists.getShortNameList()[i] = StringUtil.getString(nameList[i].replaceAll("§", ","));
} else {
lists.getShortNameList()[i] = " ";
}
} else {
lists.getShortNameList()[i] = getSafeValue(nameList, i);
}
lists.getShortPhone()[i] = getSafeValue(phone, i);
// 문자 1 치환
if (smsTxt.contains("[*1*]")) {
lists.getShortRep1()[i] = getReplacementValue(rep1, i, "[*1*]");
} else {
lists.getShortRep1()[i] = getSafeValue(rep1, i);
}
// 문자 2 치환
if (smsTxt.contains("[*2*]")) {
lists.getShortRep2()[i] = getReplacementValue(rep2, i, "[*2*]");
} else {
lists.getShortRep2()[i] = getSafeValue(rep2, i);
}
// 문자 3 치환
if (smsTxt.contains("[*3*]")) {
lists.getShortRep3()[i] = getReplacementValue(rep3, i, "[*3*]");
} else {
lists.getShortRep3()[i] = getSafeValue(rep3, i);
}
// 문자 4 치환
if (smsTxt.contains("[*4*]")) {
lists.getShortRep4()[i] = getReplacementValue(rep4, i, "[*4*]");
} else {
lists.getShortRep4()[i] = getSafeValue(rep4, i);
}
}
// 장문 리스트에 데이터를 채우는 메서드
private static void populateLongLists(ReplacementListsVO lists, String[] nameList, String[] phone, String[] rep1, String[] rep2, String[] rep3, String[] rep4, String smsTxt, int i) {
// 이름 치환
if (smsTxt.contains("[*이름*]")) {
if (nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
lists.getLongNameList()[i] = StringUtil.getString(nameList[i].replaceAll("§", ","));
} else {
lists.getLongNameList()[i] = " ";
}
} else {
lists.getLongNameList()[i] = getSafeValue(nameList, i);
}
lists.getLongPhone()[i] = getSafeValue(phone, i);
// 문자 1 치환
if (smsTxt.contains("[*1*]")) {
lists.getLongRep1()[i] = getReplacementValue(rep1, i, "[*1*]");
} else {
lists.getLongRep1()[i] = getSafeValue(rep1, i);
}
// 문자 2 치환
if (smsTxt.contains("[*2*]")) {
lists.getLongRep2()[i] = getReplacementValue(rep2, i, "[*2*]");
} else {
lists.getLongRep2()[i] = getSafeValue(rep2, i);
}
// 문자 3 치환
if (smsTxt.contains("[*3*]")) {
lists.getLongRep3()[i] = getReplacementValue(rep3, i, "[*3*]");
} else {
lists.getLongRep3()[i] = getSafeValue(rep3, i);
}
// 문자 4 치환
if (smsTxt.contains("[*4*]")) {
lists.getLongRep4()[i] = getReplacementValue(rep4, i, "[*4*]");
} else {
lists.getLongRep4()[i] = getSafeValue(rep4, i);
}
}
// 그림 문자 리스트에 데이터를 채우는 메서드
private static void populateImgLists(ReplacementListsVO lists, String[] nameList, String[] phone, String[] rep1, String[] rep2, String[] rep3, String[] rep4, String smsTxt, int i) {
// 이름 치환
if (smsTxt.contains("[*이름*]")) {
if (nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
lists.getImgNameList()[i] = StringUtil.getString(nameList[i].replaceAll("§", ","));
} else {
lists.getImgNameList()[i] = " ";
}
} else {
lists.getImgNameList()[i] = getSafeValue(nameList, i);
}
lists.getImgPhone()[i] = getSafeValue(phone, i);
// 문자 1 치환
if (smsTxt.contains("[*1*]")) {
lists.getImgRep1()[i] = getReplacementValue(rep1, i, "[*1*]");
} else {
lists.getImgRep1()[i] = getSafeValue(rep1, i);
}
// 문자 2 치환
if (smsTxt.contains("[*2*]")) {
lists.getImgRep2()[i] = getReplacementValue(rep2, i, "[*2*]");
} else {
lists.getImgRep2()[i] = getSafeValue(rep2, i);
}
// 문자 3 치환
if (smsTxt.contains("[*3*]")) {
lists.getImgRep3()[i] = getReplacementValue(rep3, i, "[*3*]");
} else {
lists.getImgRep3()[i] = getSafeValue(rep3, i);
}
// 문자 4 치환
if (smsTxt.contains("[*4*]")) {
lists.getImgRep4()[i] = getReplacementValue(rep4, i, "[*4*]");
} else {
lists.getImgRep4()[i] = getSafeValue(rep4, i);
}
}
// 배열 인덱스를 안전하게 접근하는 메서드
private static String getSafeValue(String[] array, int index) {
return (array != null && array.length > index) ? array[index] : " ";
}
// 치환 처리에 특수문자 제거 로직이 포함된 메서드
private static String getReplacementValue(String[] array, int index, String placeholder) {
if (array != null && array.length > index && StringUtil.isNotEmpty(array[index])) {
return StringUtil.getString(array[index].replaceAll("§", ","));
} else {
return " ";
}
}
/**
* @methodName : checkReplacementDataValidity
* @author : 이호영
* @date : 2024.09.25
* @description : 치환문자가 사용될 데이터가 올바른지 확인하는 메서드
* @param mjonMsgVO
* @param modelAndView
* @return boolean
*/
public static boolean checkReplacementDataValidity(MjonMsgVO mjonMsgVO, StatusResponse statusResponse) {
String[] nameList = mjonMsgVO.getNameList();
String[] phone = mjonMsgVO.getCallToList();
String[] rep1 = mjonMsgVO.getRep1List();
String[] rep2 = mjonMsgVO.getRep2List();
String[] rep3 = mjonMsgVO.getRep3List();
String[] rep4 = mjonMsgVO.getRep4List();
boolean isRepCountOk = true;
// 치환 문자 전체 필수 체크
if (mjonMsgVO.getSmsTxt().contains("[*이름*]") && nameList.length != phone.length) {
isRepCountOk = false;
}
if (mjonMsgVO.getSmsTxt().contains("[*1*]") && rep1.length != phone.length) {
isRepCountOk = false;
}
if (mjonMsgVO.getSmsTxt().contains("[*2*]") && rep2.length != phone.length) {
isRepCountOk = false;
}
if (mjonMsgVO.getSmsTxt().contains("[*3*]") && rep3.length != phone.length) {
isRepCountOk = false;
}
if (mjonMsgVO.getSmsTxt().contains("[*4*]") && rep4.length != phone.length) {
isRepCountOk = false;
}
// 검증 결과가 false인 경우 에러 메시지 반환
if (!isRepCountOk) {
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 없습니다.");
return false;
}
return true;
}
private static void statusResponseSet (StatusResponse statusResponse, HttpStatus httpStatus, String msg ) {
statusResponse.setStatus(httpStatus);
statusResponse.setMessage(msg);
}
}

View File

@ -85,13 +85,19 @@ public class StatusResponse {
this.timestamp = timestamp;
this.messageTemp = messageTemp;
}
@Builder
public StatusResponse(HttpStatus status, String msg, Object data) {
public StatusResponse(HttpStatus status, String message) {
this.status = status;
this.message = msg;
this.object = data;
this.message = message;
}
public StatusResponse(HttpStatus status, String message, Object object) {
this.status = status;
this.message = message;
this.object = object;
}

View File

@ -2,7 +2,10 @@ package itn.let.mjo.msgdata.service;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import itn.let.lett.service.LetterVO;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.addr.service.AddrVO;
import itn.let.mjo.msg.service.MjonMsgVO;
import itn.let.sym.site.service.JoinSettingVO;
@ -179,6 +182,8 @@ public interface MjonMsgDataService {
//팩스 거래명세서 합산 정보
public List<MjonMsgVO> selectPayUserSumFaxList(MjonMsgVO mjonMsgVO) throws Exception;
public StatusResponse sendMsgData_advc(MjonMsgVO mjonMsgVO, HttpServletRequest request) throws Exception;
}

View File

@ -0,0 +1,59 @@
package itn.let.mjo.msgdata.service;
import itn.let.mjo.msg.service.MjonMsgVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class ReplacementListsVO {
String[] shortNameList;
String[] shortPhone;
String[] shortRep1;
String[] shortRep2;
String[] shortRep3;
String[] shortRep4;
int shortCnt;
String[] longNameList;
String[] longPhone;
String[] longRep1;
String[] longRep2;
String[] longRep3;
String[] longRep4;
int longCnt;
String[] imgNameList;
String[] imgPhone;
String[] imgRep1;
String[] imgRep2;
String[] imgRep3;
String[] imgRep4;
int imgCnt;
// 배열을 초기화하는 메서드
public void initializeLists(MjonMsgVO mjonMsgVO) {
shortNameList = new String[Integer.parseInt(mjonMsgVO.getShortMsgCnt())];
shortPhone = new String[shortNameList.length];
shortRep1 = new String[shortNameList.length];
shortRep2 = new String[shortNameList.length];
shortRep3 = new String[shortNameList.length];
shortRep4 = new String[shortNameList.length];
longNameList = new String[Integer.parseInt(mjonMsgVO.getLongMsgCnt())];
longPhone = new String[longNameList.length];
longRep1 = new String[longNameList.length];
longRep2 = new String[longNameList.length];
longRep3 = new String[longNameList.length];
longRep4 = new String[longNameList.length];
imgNameList = new String[mjonMsgVO.getCallToList().length];
imgPhone = new String[imgNameList.length];
imgRep1 = new String[imgNameList.length];
imgRep2 = new String[imgNameList.length];
imgRep3 = new String[imgNameList.length];
imgRep4 = new String[imgNameList.length];
}
}

View File

@ -1795,7 +1795,7 @@ public class MjonMsgDataController {
* @return
* @throws Exception
*/
@RequestMapping(value= {"/web/mjon/msgdata/selectMsgAddrListAjax_advc.do"})
@RequestMapping(value= {"/web/mjon/msgdata/selectMsgAddrListAjaxQ.do"})
public ResponseEntity<StatusResponse> selectMsgAddrListAjax_advc(@ModelAttribute("searchVO") AddrVO addrVO) {
Map<String, Object> response = new HashMap<>();
@ -2197,7 +2197,7 @@ public class MjonMsgDataController {
* 현재 로그인 세션도 만료 처리함
* */
boolean mberSttus = userManageService.selectUserStatusInfo(userId);
if(!mberSttus) {
modelAndView.addObject("message", "현재 고객님께서는 문자온 서비스 이용이 정지된 상태로 문자를 발송하실 수 없습니다. 이용정지 해제를 원하시면 고객센터로 연락주시기 바랍니다.");
@ -2247,14 +2247,10 @@ public class MjonMsgDataController {
//메세지 타입이 단문이면 진짜 단문인지 한번더 확인해 준다.
if(msgType.equals("4")) {
//메세지 길이가 90Byte를초과 하거나, 그림 이미지가 있는경우 메세지 타입을 6으로 변경해준다.
if(FrBytes > 90 || mjonMsgVO.getImgFilePath().length > 0) {
msgType = "6";
}
}
mjonMsgVO.setMsgType(msgType);
@ -3155,6 +3151,25 @@ public class MjonMsgDataController {
return modelAndView;
}
/**
* 문자 발송 기능
* @param searchVO
* @param model
* @return "/web/mjon/msgdata/sendMsgDataAjax.do"
* @throws Exception
*/
@RequestMapping(value= {"/web/mjon/msgdata/sendMsgDataAjax_advc.do"})
public ResponseEntity<StatusResponse> sendMsgData_advc(@ModelAttribute("searchVO") MjonMsgVO mjonMsgVO,
RedirectAttributes redirectAttributes,
HttpServletRequest request,
ModelMap model) throws Exception{
return ResponseEntity.ok().body(mjonMsgDataService.sendMsgData_advc(mjonMsgVO, request)) ;
}
/**
* 관리자로 문자 발송해주기
* 사용자가 보낸 문자를 문자온 법인폰으로 발송해주는 기능 함수.

View File

@ -250,6 +250,7 @@ var excelAddr = []; //엑셀 불러오기에서 내용 저장하는 배열 변
//전체 데이터 갯수 구하는 함수
function updateTotCnt(data){
console.log(' :: updateTotCnt :: ');
var rowTotCnt = data;
$("#rowTotCnt").text(numberWithCommas(rowTotCnt));
@ -746,8 +747,8 @@ $(document).ready(function (){
//문자 내용 입력시 바이트수 계산하기
$('#smsTxtArea').keyup(function(e){
console.log("11$('.preview_auto').test() :: ",$('.realtime').html())
console.log("11$('.preview_auto').test() :: ",$('.realtime').text())
// console.log("11$('.preview_auto').test() :: ",$('.realtime').html())
// console.log("11$('.preview_auto').test() :: ",$('.realtime').text())
var contents = $(this).val();
var adrYn = $("input[name=send_adYn]:checked").val();
@ -2200,7 +2201,7 @@ function fnByteString(contents){
}
//수신목록 전체 데이터 갯수 구하기
updateTotCnt(totRows);
// updateTotCnt(totRows);
//일괄변환 문구 결제금액 처리
if(contents.indexOf("[*이름*]") > -1

View File

@ -1050,20 +1050,25 @@ function fn_sendMsgData(){
alert("현재 문자 발송하기 기능 점검 중입니다.\n\n1분 후 다시 시도해주세요.");
return false;
}
var testString = document.msgForm.smsTxtArea.value;
var form = document.msgForm;
//회원 보유 잔액 비교
var totPriceOnly = stringReplaceAll(form.totPrice.value, ",", "");
var userMoneyOnly = stringReplaceAll(form.myPrice.value, ",", "");
if(parseFloat(userMoneyOnly) < parseFloat(totPriceOnly)){
alert("문자 발송에 필요한 회원님의 보유 잔액이 부족 합니다.");
return false;
}
var loginVO = '${LoginVO}';
if (!loginVO) {
alert("문자발송 서비스는 로그인 후 이용 가능합니다.");
return false;
}
// 폼 유효성 검사
if (!validateForm(form)) return false;
var adverYn = $("input[name='send_adYn']:checked").val();
var spamStatus = false;
var exceptSpamYn = $("#exceptSpamYn").val(); //금지어 필터링 예외 여부 - N 일 경우만 스팸 검사를 진행
@ -1104,69 +1109,6 @@ function fn_sendMsgData(){
// return false;
//}
if(form.callFromList.value == ""){
alert("발신번호를 입력해 주세요.");
return false;
}
var titleStatus = form.title_status.value;
if(titleStatus == 'N'){//장문 제목 사용안함으로 선택시 제목에 있는 데이터 지워주기
form.mmsSubject.value = "";
}else{//장문 제목에 치환문자 포함된 경우 입력 못하도록 처리.
var mmsSubject = form.mmsSubject.value;
if(getSpacialStringChk(mmsSubject)){
alert("문자 제목에는 치환문자(엑셀 내 *이름*, *1*, *2*, *3*, *4* 등)를 사용하실 수 없습니다.");
return false;
}
}
//문자내용 첫글자에 특수기호 포함 여부 체크
var strCont = form.smsTxtArea.value;
var rtnStr = strChinJpnCheck(strCont);
//문자제목에 이모지가 있는지 체크
var titleStatusYn = $("input[name='title_status']:checked").val();
if(titleStatusYn == 'Y') {
if(!emojiCheck(form.mmsSubject.value)) return false;
}
//문자내용에 이모지가 있는지 체크
if(!emojiCheck(strCont)) return false;
if(rtnStr.length > 0){
alert("입력하신 문구 중 \" " + rtnStr + " \" 는 일부 휴대폰에서 표기되지 않을 수 있습니다.");
}
/* var strCont = form.smsTxtArea.value;
var repStr = strFirstCharCheck(strCont);
if(repStr.length > 0){
alert("문자 내용 첫 글자는 특수기호가 들어갈 수 없습니다.");
$('#smsTxtArea').val(strCont.replace(repStr, ""));
fnByteString(strCont.replace(repStr, ""));
return false;
} */
if(imgFilePath.length == 0){ // 그림문자일 경우 내용이 없어도 됨 , 장문 문자일 경우만 문자내용 체크함
if(form.smsTxtArea.value == ""){
alert("문자 내용을 입력해 주세요.");
return false;
}
}
//광고 문자 내용 합쳐주기
@ -1312,7 +1254,8 @@ function fn_sendMsgData(){
}
console.log(' : 전송하시겠습니까 : ')
if(confirm("문자를 전송하시겠습니까?")){
imgFilePath = [];
$('.thumb_wrap').find('.thumb_img').each(function(idx, el) {
@ -1390,7 +1333,7 @@ function fn_sendMsgData(){
//문자내용이 입력된 경우 스팸 필터링 실행
if(!form.smsTxtArea.value == "" && exceptSpamYn == "N"){
console.log(' : selectSpamTxtChkAjax : ')
var spmData = new FormData(form);
url = "/web/mjon/msgdata/selectSpamTxtChkAjax.do";
@ -1452,6 +1395,7 @@ function fn_sendMsgData(){
}
var eventRemainCash = parseFloat(form.eventRemainCash.value);
console.log('eventStatus : ', eventStatus);
if(eventStatus == 'Y'){
@ -1629,8 +1573,9 @@ function fn_sendMsgData(){
var form = document.msgForm;
var data = new FormData(form);
url = "/web/mjon/msgdata/sendMsgDataAjax.do";
// url = "/web/mjon/msgdata/sendMsgDataAjax.do";
url = "/web/mjon/msgdata/sendMsgDataAjax_advc.do";
console.log('url :: ', url);
$.ajax({
type: "POST",
url: url,
@ -1641,6 +1586,7 @@ function fn_sendMsgData(){
contentType: false,
cache: false,
success: function (returnData, status) {
console.log('returnData : ', returnData);
if(status == 'success'){ // status 확인 필요한가. 석세스 안뜨면 에러 가지 않나
if("fail" == returnData.result){
@ -1794,7 +1740,7 @@ function fn_sendMsgData(){
form.eventStatus.value = 'N';
form.eventYn.value = 'N';
sendMsgAjax(0,0);
sendMsgAjax_advc(0,0);
}else{
@ -1815,14 +1761,14 @@ function fn_sendMsgData(){
}else{
//발송 Ajax 호출해주기
sendMsgAjax(0,0);
sendMsgAjax_advc(0,0);
}
}else{
//발송 Ajax 호출해주기
sendMsgAjax(0,0);
sendMsgAjax_advc(0,0);
}
@ -1831,6 +1777,46 @@ function fn_sendMsgData(){
}
//폼 유효성 검사 함수
function validateForm(form) {
if(form.callFromList.value == ""){
alert("발신번호를 입력해 주세요.");
return false;
}
if (form.title_status.value === 'N') {
form.mmsSubject.value = "";
} else if (getSpacialStringChk(form.mmsSubject.value)) {
alert("문자 제목에는 치환문자(엑셀 내 *이름*, *1*, *2*, *3*, *4* 등)를 사용하실 수 없습니다.");
return false;
}
//문자제목에 이모지가 있는지 체크
var titleStatusYn = $("input[name='title_status']:checked").val();
if(titleStatusYn == 'Y') {
if(!emojiCheck(form.mmsSubject.value)) return false;
}
// 문자내용에 이모지가 있는지 체크
var strCont = form.smsTxtArea.value;
if (!emojiCheck(strCont)) return false;
var rtnStr = strChinJpnCheck(strCont);
if(rtnStr.length > 0){
alert("입력하신 문구 중 \" " + rtnStr + " \" 는 일부 휴대폰에서 표기되지 않을 수 있습니다.");
}
if (imgFilePath.length === 0 && !form.smsTxtArea.value) {
alert("문자 내용을 입력해 주세요.");
return false;
}
return true;
}
//이벤트가 아닌 일반 개별 단가 셋팅해주기
function getNorEachPrice(evnMsgType){
@ -1873,13 +1859,103 @@ function getNorEachPrice(evnMsgType){
}
function sendMsgAjax(paramSmsCnt, paramBlockCnt){
function sendMsgAjax_advc(paramSmsCnt, paramBlockCnt){
console.log('sendMsgAjax : ');
var form = document.msgForm;
var reserYn = $("#reserveYn").val();
var data = new FormData(form);
url = "/web/mjon/msgdata/sendMsgDataAjax.do";
// url = "/web/mjon/msgdata/sendMsgDataAjax.do";
url = "/web/mjon/msgdata/sendMsgDataAjax_advc.do";
$.ajax({
type: "POST",
url: url,
data: data,
dataType:'json',
async: true,
processData: false,
contentType: false,
cache: false,
success: function (data) {
console.log('data : ', data);
/* message:"특정문구 일괄변환 치환문자 데이터가 없습니다."
status:"BAD_REQUEST" */
var status = data.status;
// if(status == 'success'){ // status 확인 필요한가. 석세스 안뜨면 에러 가지 않나
if("OK" == status){
var smsCnt = Number(data.object.resultSts);
var blockCnt = Number(data.object.resultBlockSts);
smsCnt = Number(smsCnt) + Number(paramSmsCnt);
blockCnt = Number(blockCnt) + Number(paramBlockCnt);
if((smsCnt + blockCnt) == 0){
$('.pop_msg_spam').css({'display':'block','opacity':'1','left':'50%','top':'50%','transform':'translate(-50%,-50%)'});
$('.pop_msg_spam .msg_text').html("문자 발송(예약)에 실패하였습니다.<br/> 다시 시도해주세요. <br/>* 정상적으로 발송 시도하였으나 실패하신 경우 혹시 문자내용에 사용불가 이모지 <br/>또는 복사-붙여넣기로 인한 보이지 않는 특수문자가 포함되었는지 확인 후 다시 시도해주세요.");
$('.mask').addClass('on');
}else{
$('.pop_msg_success').css({'display':'block','opacity':'1','left':'50%','top':'50%','transform':'translate(-50%,-50%)'});
//예약발송 건의 경우 결과 팝업 문구 변경
if(reserYn == 'Y'){
$('.pop_msg_success .msg_text').html("예약 성공 : <strong>"+ smsCnt + "</strong>건,수신거부 : <span>" + blockCnt + "</span>건의<br>문자가 예약 되었습니다.");
}else{
$('.pop_msg_success .msg_text').html("발송 성공 : <strong>"+ smsCnt + "</strong>건,수신거부 : <span>" + blockCnt + "</span>건의<br>문자가 발송 되었습니다.");
}
$('.mask').addClass('on');
}
}else if("BAD_REQUEST" == status){
alert(data.message);
return false;
}else if("UNAUTHORIZED" == status){
alert(data.message);
//문자발송 URL Move
goMsgUrlMove();
return false;
}else if("NO_CONTENT" == status){
$('.pop_msg_fails').css({'display':'block','opacity':'1','left':'50%','top':'50%','transform':'translate(-50%,-50%)'});
$('.pop_msg_fails .msg_text').html(returnData.message);
$('.mask').addClass('on');
}
// } else if(status== 'fail'){
// alert(returnData.message);
// }
},
beforeSend : function(xmlHttpRequest) {
//로딩창 show
$('.loading_layer').addClass('active');
},
complete : function(xhr, textStatus) {
//로딩창 hide
$('.loading_layer').removeClass('active');
},
error: function (e) { alert("문자 발송에 실패하였습니다."); console.log("ERROR : ", e); }
});
}
function sendMsgAjax(paramSmsCnt, paramBlockCnt){
var form = document.msgForm;
var reserYn = $("#reserveYn").val();
var data = new FormData(form);
url = "/web/mjon/msgdata/sendMsgDataAjax.do";
$.ajax({
type: "POST",

View File

@ -1082,7 +1082,10 @@ function fn_sendMsgData(){
var form = document.msgForm;
var data = new FormData(form);
url = "/web/mjon/msgdata/sendMsgDataAjax.do";
// url = "/web/mjon/msgdata/sendMsgDataAjax.do";
url = "/web/mjon/msgdata/sendMsgDataAjax_advc.do";
console.log('url : ', url);
$.ajax({
type: "POST",
@ -1094,6 +1097,8 @@ function fn_sendMsgData(){
contentType: false,
cache: false,
success: function (returnData, status) {
console.log('returnData : ', returnData);
console.log('status : ', status);
if(status == 'success'){ // status 확인 필요한가. 석세스 안뜨면 에러 가지 않나
if("fail" == returnData.result){