Browse Source

간편 가입 개발 중

jsshin 5 years ago
parent
commit
a865516a2f

+ 13 - 0
src/main/java/com/style24/front/biz/dao/TsfCustomerDao.java

@@ -1,6 +1,7 @@
 package com.style24.front.biz.dao;
 
 import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.CustSnsInfo;
 import com.style24.persistence.domain.Customer;
 
 /**
@@ -47,4 +48,16 @@ public interface TsfCustomerDao {
 	 * @since 2021. 02. 22
 	 */
 	int createCustomerSns(Customer customer);
+
+	/**
+	 * 활동, 휴면 테이블 조회
+	 * @param customer - 고객정보
+	 * @return 고객정보
+	 * @author jsshin
+	 * @since 2021. 02. 24
+	 */
+	Customer getCusomterActiveAndDormant(Customer customer);
+
+
+	Customer getCusomterSnsFind(CustSnsInfo custSnsInfo);
 }

+ 160 - 7
src/main/java/com/style24/front/biz/service/TsfCustomerService.java

@@ -1,12 +1,16 @@
 package com.style24.front.biz.service;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.web.parameter.GagaMap;
 import com.gagaframework.web.security.GagaPasswordEncoder;
 import com.style24.core.biz.service.TscCustomerService;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.session.TscSession;
+import com.style24.core.support.util.CryptoUtils;
 import com.style24.front.support.security.TsfLoginDetails;
+import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.Coupon;
+import com.style24.persistence.domain.CustSnsInfo;
 import com.style24.persistence.domain.Customer;
 import com.style24.persistence.domain.Login;
 import com.style24.persistence.domain.Point;
@@ -47,6 +51,9 @@ public class TsfCustomerService {
 	@Autowired
 	private TsfLoginService loginService;
 
+	@Autowired
+	private ObjectMapper objectMapper;
+
 
 	/**
 	 * 고객아이디 찾기
@@ -60,9 +67,27 @@ public class TsfCustomerService {
 		TscSession.setAttribute("maskingYn","Y");
 		customer.setSiteCd(TscConstants.Site.STYLE24.value());
 		customer.encryptData(); // 데이터 암호하
+		return customerDao.getCusomterActiveAndDormant(customer);
+	}
+
+	/**
+	 * 고객정보찾기 -
+	 *
+	 * @param custNo - 고객번호
+	 * @return Customer 고객정보
+	 * @author jsshin
+	 * @since 2021. 02. 24
+	 */
+	public Customer getCustomerFindByCustNo(Integer custNo) {
+		Customer customer = new Customer();
+		customer.setCustNo(custNo);
+		customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.encryptData();
 		return coreCustomerService.getCustomerInfo(customer);
 	}
 
+
 	/**
 	 * 임시비밀번호 조회
 	 * @param length - 비밀번호 자릿수
@@ -122,9 +147,27 @@ public class TsfCustomerService {
 		return result > 0;
 	}
 
+	/**
+	 * 해당 휴대전화로 가입된 이력이 있는지 확인
+	 * @param cellPhnno - 휴대전화
+	 * @return boolean - 있으면 TRUE/ 없으면 FALSE
+	 * @author jsshin
+	 * @since 2021. 02. 15
+	 */
+	public boolean getCustomerFindByCellPhnnoCount(String cellPhnno) {
+		Customer customer = new Customer();
+		customer.setCellPhnno(cellPhnno);
+		customer.setHypenCellPhone(); // 010-0000-0000
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.encryptData();
+		int result = customerDao.getCustomerInfoCount(customer);
+
+		return result > 0;
+	}
+
 	/**
 	 * 해당 CI로 가입된 이력이 있는지 확인
-	 * @param ci - ci
+	 * @param ci - 연계정보
 	 * @return boolean - 있으면 TRUE/ 없으면 FALSE
 	 * @author jsshin
 	 * @since 2021. 02. 15
@@ -141,7 +184,7 @@ public class TsfCustomerService {
 	/**
 	 * 해당 휴대폰 번호로 가입된 이력이 있는지 확인
 	 * @param cellPhnno - 휴대전화번호
-	 * @return boolean - 있으면 TRUE/ 없으면 FALSE
+	 * @return Customer - 고객정보
 	 * @author jsshin
 	 * @since 2021. 02. 15
 	 */
@@ -201,7 +244,7 @@ public class TsfCustomerService {
 	}
 
 	/**
-	 * 회원가입 처리
+	 * 회원가입 처리 - 일반가입
 	 * @param customer - 일반가입
 	 * @return boolean - 가입 성공 true / 실패 false
 	 * @author jsshin
@@ -213,17 +256,48 @@ public class TsfCustomerService {
 		// 1. validation
 		customer.setHypenCellPhone();
 		customer.encryptData();
-		if (StringUtils.isNotBlank(customer.getSnsId())) {
-			customer.setEncodedPasswd(" ");
-			customer.setCustId(customer.getSnsType()+"_"+customer.getSnsId());
+		customer.setEncodedPasswd(passwordEncoder.encode(customer.getPasswd()));
+
+		customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
+		customer.setCustGb(TscConstants.CustGb.NORMAL.value());
+		customer.setCustGrade(TscConstants.CustGrade.WELCOME.value());
+
+		int custCnt = customerDao.createCustomer(customer);
+
+		if (custCnt > 0) {
+			saveJoinPostProcessing(customer);
 		} else {
-			customer.setEncodedPasswd(passwordEncoder.encode(customer.getPasswd()));
+			isJoin = false;
 		}
+
+		return isJoin;
+	}
+
+	/**
+	 * 회원가입 처리 - SNS 간편가입
+	 * @param customer - SNS 정보
+	 * @return boolean - 가입 성공 true / 실패 false
+	 * @author jsshin
+	 * @since 2021. 02. 19
+	 */
+	public boolean saveJoinCustomerSns (Customer customer) {
+		boolean isJoin = true;
+		customer.setEncodedPasswd(" ");
+		customer.setCustId(customer.getSnsType()+"_"+customer.getSnsId());
+		customer.setEncodedPasswd(passwordEncoder.encode(customer.getPasswd()));
+		customer.encryptData();
+
+		String gender = "G007_"+customer.getSexGb();
+		customer.setSexGb(gender);
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.setFrontGb(TsfSession.getFrontGb());
+		customer.setAfLinkCd(TsfSession.getAttribute("afLinkCd"));
 		customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
 		customer.setCustGb(TscConstants.CustGb.NORMAL.value());
 		customer.setCustGrade(TscConstants.CustGrade.WELCOME.value());
 
 		int custCnt = customerDao.createCustomer(customer);
+		customerDao.createCustomerSns(customer);
 
 		if (custCnt > 0) {
 			saveJoinPostProcessing(customer);
@@ -232,6 +306,7 @@ public class TsfCustomerService {
 		}
 
 		return isJoin;
+
 	}
 
 	/**
@@ -252,6 +327,84 @@ public class TsfCustomerService {
 
 	}
 
+
+	/**
+	 * Sns 정보에대한 상태 처리
+	 * @param custSnsInfo
+	 * @author jsshin
+	 * @since 2021. 02. 19
+	 */
+	@Transactional("shopTxnManager")
+	public GagaMap customerSnsProcessing (CustSnsInfo custSnsInfo) {
+		GagaMap resultMap = new GagaMap();
+		Customer custInfo;
+
+		// 1. snsId, snsType 값으로 연동되어져 있는지 확인
+		custInfo = customerDao.getCusomterSnsFind(custSnsInfo);
+		if (custInfo != null) {
+			resultMap.setString("custStat", "SUCC_CUST");
+			return resultMap;
+		}
+
+		// 2. CI(연계정보)로 가입 되어져 있는 고객이 있는지 ?
+		custInfo = getCustomerFindByCi(custSnsInfo.getCi());
+
+		if (custInfo != null) { // 2-1. 고객정보 있는경우
+			if (TscConstants.CustStat.SECEDE.value().equals(custInfo.getCustStat())) {
+				resultMap.setString("custStat", "SECEDE_CUST"); // 탈퇴 회원
+				return resultMap;
+			}
+			if (TscConstants.CustStat.DORMANT.value().equals(custInfo.getCustStat())) {
+				resultMap.setString("custStat", "DORMANT_CUST"); // 휴면 회원
+				return resultMap;
+			}
+			if (TscConstants.CustStat.ACTIVE.value().equals(custInfo.getCustStat())) {
+
+				if (StringUtils.isBlank(custSnsInfo.getCellPhnno())) {
+					resultMap.setString("custStat", "EMPTY_PHONE_CUST");
+					return resultMap;
+				}
+				custInfo.setSnsId(custSnsInfo.getSnsId());
+				custInfo.setSnsType(custSnsInfo.getSnsType());
+				customerDao.createCustomerSns(custInfo);
+				resultMap.setString("custStat", "SUCC_CUST");
+				return resultMap;
+			}
+		} else { // 2-2. 고객정보 없는 경우
+
+			if (StringUtils.isBlank(custSnsInfo.getCellPhnno())) { // 휴대전화번호가 없는 경우
+				resultMap.setString("custStat", "EMPTY_PHONE_CUST");
+				return resultMap;
+			}
+
+			boolean isFindByPhone =getCustomerFindByCellPhnnoCount(custSnsInfo.getCellPhnno().replace("-",""));
+			if (isFindByPhone) {
+				resultMap.setString("custStat", "DUP_PHONE_CUST");
+				return resultMap;
+			}
+
+			boolean isFindByEmail = getCustomerFindByEmail(custSnsInfo.getEmail());
+			if (isFindByEmail) {
+				resultMap.setString("custStat", "DUP_EMAIL_CUST"); // 이메일 중복
+				return resultMap;
+			}
+
+			Customer customer = objectMapper.convertValue(custSnsInfo, Customer.class);
+
+			boolean isJoin = saveJoinCustomerSns(customer);
+
+			if (isJoin) {
+				resultMap.setString("custStat", "SUCC_CUST");
+			} else {
+				resultMap.setString("custStat", "FAIL_CUST");
+			}
+
+		}
+
+		return resultMap;
+	}
+
+
 	/**
 	 * 로그인 처리
 	 * @param custId - 고객아이디

+ 66 - 16
src/main/java/com/style24/front/biz/thirdparty/KaKaoLogin.java

@@ -24,6 +24,7 @@ import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.PostConstruct;
 import java.net.URI;
+import java.util.Locale;
 
 
 /**
@@ -72,6 +73,13 @@ public class KaKaoLogin {
 		log.info("\n--- Kakao initialization completed ----\n");
 	}
 
+	/**
+	 * 카카오 로그인 창
+	 * @param state - 콜백 시 해당 값으로 비교 및 모바일을 redirect 값이 있음
+	 * @return String - 호출 url정보
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
 	public String getAuthorizeUrl(String state) {
 		StringBuilder apiUrlBuilder = new StringBuilder();
 		String redirectUri = GagaFileUtil.getConcatenationPath(PROTOCOL + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
@@ -86,6 +94,15 @@ public class KaKaoLogin {
 		return apiUrlBuilder.toString();
 	}
 
+	/**
+	 * 카카오 전달 받은 코드 값으로 토근값을 받아옴(API)
+	 *
+	 * @param code - 카카오에서 전달 해준 값
+	 * @param state - 콜백 시 해당 값으로 비교 및 모바일을 redirect 값이 있음
+	 * @return GagaMap - 통신으로 받아온 정보
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
 	public GagaMap getAccessTocken(String code, String state) {
 		GagaMap resultMap = new GagaMap();
 		String redirectUri = GagaFileUtil.getConcatenationPath(PROTOCOL + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
@@ -119,17 +136,23 @@ public class KaKaoLogin {
 			log.info("responseEntity.getBody(): {} ", jsonResult);
 
 			Gson gson = new GsonBuilder().create();
-			JsonObject obj = gson.fromJson(jsonResult, JsonObject.class);
-
-			resultMap.setString("access_token", obj.get("access_token").toString());
-			resultMap.setString("refresh_token", obj.get("refresh_token").toString());
+			resultMap = gson.fromJson(jsonResult, GagaMap.class); //access_token, refresh_token
 			resultMap.setString("requestGb", requestGb);
+
 		} catch (Exception e) {
 			log.error(e.getMessage());
 		}
 		return resultMap;
 	}
 
+	/**
+	 * 카카오 사용자 정보
+	 *
+	 * @param accessToken - 해당 값으로 사용자 정보를 가져옴
+	 * @return GagaMap - 사용자 정보
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
 	public GagaMap getKakaoUserInfo(String accessToken) {
 		GagaMap resultMap = new GagaMap();
 		try {
@@ -156,19 +179,24 @@ public class KaKaoLogin {
 			GagaMap properties = gson.fromJson(obj.get("properties"), GagaMap.class);
 			GagaMap kakaoAccount = gson.fromJson(obj.get("kakao_account"), GagaMap.class);
 
+			Locale locale = Locale.KOREA;
+			String cellPhnno = getPhoneNumber(kakaoAccount.getString("phone_number"), locale.getCountry());
+			String birthYmd = kakaoAccount.getString("birthyear") + kakaoAccount.getString("birthday");
 
+			String sexGb = "";
+			if (StringUtils.isNotBlank(kakaoAccount.getString("gender"))) {
+				sexGb = kakaoAccount.getString("gender").equals("male") ? "M" : "F";
+			}
 
-			String birthYmd = kakaoAccount.getString("birthyear") + kakaoAccount.getString("birthday");
-			String sexGb = kakaoAccount.getString("gender").equals("male") ? "M":"F";
-			String birthSm = kakaoAccount.getString("birthday_type").equals("SOLAR") ? "S":"L";
-			String cellPhnno = getPhoneNumber(kakaoAccount.getString("phone_number"));
+			String birthSm = "";
+			if (StringUtils.isNotBlank(kakaoAccount.getString("birthday_type"))) {
+				birthSm = kakaoAccount.getString("birthday_type").equals("SOLAR") ? "S":"L";
+			}
 
 			resultMap.setString("snsId", obj.get("id").toString());
 			resultMap.setString("custNm", properties.getString("nickname"));
-
 			resultMap.setString("email", kakaoAccount.getString("email"));
 			resultMap.setString("ci", kakaoAccount.getString("ci"));
-
 			resultMap.setString("cellPhnno", cellPhnno);
 			resultMap.setString("birthYmd", birthYmd);
 			resultMap.setString("birthSm", birthSm);
@@ -180,6 +208,14 @@ public class KaKaoLogin {
 		return resultMap;
 	}
 
+	/**
+	 * 카카오 access_token 새로 발급
+	 *
+	 * @param refreshToken - 해당 값으로 사용자 정보를 가져옴
+	 * @return GagaMap - access_token 값을 준다.
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
 	public GagaMap getRefreshTocken(String refreshToken) {
 		GagaMap resultMap = new GagaMap();
 		try {
@@ -203,15 +239,21 @@ public class KaKaoLogin {
 			log.info("responseEntity.getBody(): {} ", jsonResult);
 
 			Gson gson = new GsonBuilder().create();
-			JsonObject obj =  gson.fromJson(jsonResult, JsonObject.class);
-			resultMap.setString("access_token", obj.get("access_token").toString());
-
+			resultMap = gson.fromJson(jsonResult, GagaMap.class); //access_token
 		} catch (Exception e) {
 			log.error(e.getMessage());
 		}
 		return resultMap;
 	}
 
+	/**
+	 * 카카오 계정 연동해제
+	 *
+	 * @param accessToken - 토근값
+	 * @return GagaMap - snsId 값이 있으면 연동해제 성공
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
 	public GagaMap saveUnlink(String accessToken) {
 		GagaMap resultMap = new GagaMap();
 		try {
@@ -241,13 +283,21 @@ public class KaKaoLogin {
 		return resultMap;
 	}
 
-
-	public String getPhoneNumber(String cellPhnno) throws Exception {
+	/**
+	 * 국가번호 붙여서 넘겨온 전화번호 변호
+	 * +82) 010 1234 5678 -> 010-1234-5678
+	 * @param cellPhnno - 휴대전화번호
+	 * @param country - 국가
+	 * @return String - 010-1234-5678
+	 * @author jsshin
+	 * @since 2021. 02. 05
+	 */
+	public String getPhoneNumber(String cellPhnno, String country) throws Exception {
 		String result = "";
 		if (StringUtils.isNotBlank(cellPhnno)) {
 			PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
 			Phonenumber.PhoneNumber numberProto = phoneUtil.parse(cellPhnno, "KR");
-			result = phoneUtil.format(numberProto, PhoneNumberUtil.PhoneNumberFormat.NATIONAL).replaceAll("-", "");
+			result = phoneUtil.format(numberProto, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
 		}
 
 		return result;

+ 12 - 23
src/main/java/com/style24/front/biz/web/TsfCustomerController.java

@@ -1,22 +1,15 @@
 package com.style24.front.biz.web;
 
 import com.gagaframework.web.parameter.GagaMap;
-import com.gagaframework.web.security.GagaPasswordEncoder;
 import com.style24.core.biz.service.TscClauseService;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.session.TscSession;
 import com.style24.front.biz.service.TsfKakaoService;
-import com.style24.front.biz.service.TsfLoginService;
 import com.style24.front.biz.thirdparty.NiceCertify;
-import com.style24.front.support.env.TsfConstants;
-import com.style24.front.support.security.TsfLoginDetails;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.Customer;
-import com.style24.persistence.domain.Login;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -33,9 +26,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
+
 
 /**
  * 고객(회원) Controller
@@ -281,11 +272,9 @@ public class TsfCustomerController extends TsfBaseController {
 			return mav;
 		}
 
-		Customer params = new Customer();
-		params.setCustNo(Integer.valueOf(custNo));
-
 		// 고객정보 찾기
-		Customer custInfo = customerService.getCustomerFindId(params);
+		Customer custInfo = customerService.getCustomerFindByCustNo(Integer.valueOf(custNo));
+
 		if (custInfo != null) {
 			mav.addObject("custId", custInfo.getCustId());
 		}
@@ -312,10 +301,9 @@ public class TsfCustomerController extends TsfBaseController {
 			throw new IllegalStateException("고객 정보가 없습니다. 다시 확인 해주세요.");
 		}
 
-		Customer params = new Customer();
-		params.setCustNo(Integer.valueOf(custNo));
 		// 고객정보 찾기
-		Customer custInfo = customerService.getCustomerFindId(params);
+		Customer custInfo = customerService.getCustomerFindByCustNo(Integer.valueOf(custNo));
+
 		if (custInfo != null) {
 			customer.setTempPasswdYn("N"); // 임시비밀번호여부
 			customer.setRegNo(custInfo.getCustNo());
@@ -325,6 +313,7 @@ public class TsfCustomerController extends TsfBaseController {
 			customerService.saveCustomerPassword(customer);
 			isSuccess = true;
 		}
+
 		result.setBoolean("isSuccess", isSuccess);
 		return result;
 	}
@@ -402,7 +391,7 @@ public class TsfCustomerController extends TsfBaseController {
 		ModelAndView mav = new ModelAndView();
 		GagaMap result = niceCertify.certifyCellPhone();
 
-		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.value().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl); // 모바일만 사용
 		}
 
@@ -424,7 +413,7 @@ public class TsfCustomerController extends TsfBaseController {
 		ModelAndView mav = new ModelAndView();
 		GagaMap result = niceCertify.certifyIpin();
 
-		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.value().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl); // 모바일만 사용
 		}
 
@@ -459,7 +448,7 @@ public class TsfCustomerController extends TsfBaseController {
 			authMethod = TscConstants.AuthMethod.IPIN.value();
 		}
 
-		if (TscConstants.FrontGb.MOBIEL.vale().equals(TsfSession.getFrontGb())) {
+		if (TscConstants.FrontGb.MOBIEL.value().equals(TsfSession.getFrontGb())) {
 			mav.addObject("redirectUrl", redirectUrl);
 		}
 
@@ -561,7 +550,7 @@ public class TsfCustomerController extends TsfBaseController {
 
 		GagaMap authInfo = niceCertify.getCertifyCellPhoneResultInfo(customer);
 		customer.setCi(authInfo.getString("sCi"));
-		//customer.setCellPhnno(authInfo.getString("sMobileNo"));
+		customer.setCellPhnno(authInfo.getString("sMobileNo"));
 		//customer.setCellPhnno("01025906246");
 
 		if ("N".equals(authInfo.getString("adult"))) {
@@ -617,7 +606,7 @@ public class TsfCustomerController extends TsfBaseController {
 		if (isJoin) {
 			// 4.알림톡 발송
 			try {
-				if(StringUtils.isNotBlank(customer.getCellPhnno())) {
+				if (StringUtils.isNotBlank(customer.getCellPhnno())) {
 					kakaoService.sendJoinCongrat(customer);
 				}
 			} catch (Exception e) {
@@ -626,7 +615,7 @@ public class TsfCustomerController extends TsfBaseController {
 
 			// 5. 이메일 발송
 			try {
-				if(StringUtils.isNotBlank(customer.getEmail())) {
+				if (StringUtils.isNotBlank(customer.getEmail())) {
 					// TODO : 2021.02.23 이메일 모듈 개발 필요 jsshin
 				}
 			} catch (Exception e) {

+ 34 - 14
src/main/java/com/style24/front/biz/web/TsfIndexController.java

@@ -9,9 +9,15 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.web.parameter.GagaMap;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.style24.core.support.env.TscConstants;
+import com.style24.front.biz.service.TsfCustomerService;
 import com.style24.front.biz.thirdparty.KaKaoLogin;
 import com.style24.front.biz.thirdparty.NaverLogin;
+import com.style24.persistence.domain.CustSnsInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -46,12 +52,18 @@ public class TsfIndexController extends TsfBaseController {
 	@Autowired
 	private TscMessageByLocale message;
 
+	@Autowired
+	private TsfCustomerService customerService;
+
 	@Autowired
 	private KaKaoLogin kakaoLogin;
 
 	@Autowired
 	private NaverLogin naverLogin;
 
+	@Autowired
+	private ObjectMapper objectMapper;
+
 	/**
 	 * 에러 페이지
 	 * @return
@@ -156,7 +168,7 @@ public class TsfIndexController extends TsfBaseController {
 
 		if (StringUtils.isNotBlank(rememberMe)) {
 			// RememberMe 세션 저장
-			TsfSession.setAttribute("rememberMe", String.valueOf(rememberMe));
+			TsfSession.setAttribute("rememberMe", rememberMe);
 		}
 		// CSRF 방지를 위한 상태 토큰 생성 코드
 		SecureRandom random = new SecureRandom();
@@ -178,11 +190,12 @@ public class TsfIndexController extends TsfBaseController {
 	 */
 	@GetMapping("/signin/naverlogin")
 	public String signinNaverLogin(@RequestParam(value = "rememberMe", required = false) String rememberMe, @RequestParam(value = "requestGb", required = false) String requestGb) {
+
 		if (StringUtils.isNotBlank(rememberMe)) {
 			// RememberMe 세션 저장
-			TsfSession.setAttribute("rememberMe", String.valueOf(rememberMe));
+			TsfSession.setAttribute("rememberMe", rememberMe);
 		}
-
+		// CSRF 방지를 위한 상태 토큰 생성 코드
 		SecureRandom random = new SecureRandom();
 		String state = new BigInteger(130, random).toString(32);
 		state += "!@!" + requestGb;
@@ -220,17 +233,20 @@ public class TsfIndexController extends TsfBaseController {
 
 		GagaMap userInfo = new GagaMap();
 		boolean isSnsLoing = false;
-		if (StringUtils.isNotBlank(code) && "KK".equals(snsType)) {
-			GagaMap tokenInfo = kakaoLogin.getAccessTocken(code, state);
-			userInfo = kakaoLogin.getKakaoUserInfo(tokenInfo.getString("access_token"));
-			userInfo.setString("accessToken", tokenInfo.getString("access_token"));
-			userInfo.setString("refreshToken", tokenInfo.getString("refresh_token"));
-			userInfo.setString("snsType", snsType);
-			userInfo.setString("requestGb", tokenInfo.getString("requestGb"));
-			isSnsLoing = true;
+		if (StringUtils.isNotBlank(code) && TscConstants.SnsType.KAKAO.value().equals(snsType)) {
+			String sessionState = TsfSession.getAttribute("state");
+			if (sessionState.equals(state)) {
+				GagaMap tokenInfo = kakaoLogin.getAccessTocken(code, state);
+				userInfo = kakaoLogin.getKakaoUserInfo(tokenInfo.getString("access_token"));
+				userInfo.setString("accessToken", tokenInfo.getString("access_token"));
+				userInfo.setString("refreshToken", tokenInfo.getString("refresh_token"));
+				userInfo.setString("snsType", snsType);
+				userInfo.setString("requestGb", tokenInfo.getString("requestGb"));
+				isSnsLoing = true;
+			}
 		}
 
-		if (StringUtils.isNotBlank(state) && "NV".equals(snsType)) {
+		if (StringUtils.isNotBlank(code) && TscConstants.SnsType.NAVER.value().equals(snsType)) {
 			String sessionState = TsfSession.getAttribute("state");
 			if (sessionState.equals(state)) {
 				GagaMap tokenInfo = naverLogin.getAccessTocken(code, state);
@@ -244,7 +260,11 @@ public class TsfIndexController extends TsfBaseController {
 		}
 
 		// SNS 로그인 성공시 정보 세션 저장
+		GagaMap resultMap = new GagaMap();
 		if (isSnsLoing) {
+			CustSnsInfo custSnsInfo = objectMapper.convertValue(userInfo, CustSnsInfo.class);
+			//상태 체크
+			resultMap = customerService.customerSnsProcessing(custSnsInfo);
 
 		}
 
@@ -253,8 +273,8 @@ public class TsfIndexController extends TsfBaseController {
 			userInfo.setBoolean("rememberMe", true);
 		}
 
-		mav.addObject("userInfo", userInfo);
-
+		mav.addObject("resultMap", resultMap);
+		mav.addObject("snsId", userInfo.getString("snsId"));
 		mav.addObject("snsType", snsType);
 
 		mav.setViewName(super.getDeviceViewName("SnsCallBackForm"));

+ 38 - 0
src/main/java/com/style24/persistence/domain/CustSnsInfo.java

@@ -0,0 +1,38 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.style24.persistence.TscBaseDomain;
+import lombok.Data;
+
+/**
+ * 고객 Sns 정보 Domain
+ * @JsonSerialize 애노테이션을 지정해야 세션을 레디스에 저장할 수 있다.
+ * @author jsshin
+ * @since 2021. 02. 24
+ */
+@SuppressWarnings("serial")
+@Data
+@JsonSerialize
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustSnsInfo extends TscBaseDomain {
+
+	// 세션을 JSON 형식으로 레디스에 저장하려면 기본 생성자를 반드시 명시해야 한다
+	public CustSnsInfo (){
+
+	}
+	private String snsId;
+	private String snsType;
+	private String accessToken;
+	private String refreshToken;
+	private String custNm;
+	private String email;
+	private String ci;
+	private String cellPhnno;
+	private String birthYmd;
+	private String birthSm;
+	private String sexGb;
+	private Integer custNo;
+
+	private String requestGb;
+}

+ 69 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsfCustomer.xml

@@ -264,4 +264,73 @@
 		)
 	</insert>
 
+	<select id="getCusomterActiveAndDormant" parameterType="Customer" resultType="Customer">
+		/* TsfCustomer.getCusomterActiveAndDormant */
+		SELECT CUST_NO
+		     , CUST_ID
+		     , EMAIL
+		     , CELL_PHNNO
+		     , CUST_STAT
+		     , DATE_FORMAT(JOIN_DT, '%Y%m%d%H%i%S')   AS JOIN_DT
+		     , ''                                     AS DORMANT_DT
+		FROM   TB_CUSTOMER
+		WHERE  CUST_STAT = 'G104_10'
+		<if test="custId != null and custId !=''">
+		AND    CUST_ID = #{custId}
+		</if>
+		<if test="encodedCustNm != null and encodedCustNm != ''">
+		AND    CUST_NM = #{encodedCustNm}
+		</if>
+		<if test="encodedEmail != null and encodedEmail != ''">
+		AND    EMAIL = #{encodedEmail}
+		</if>
+		<if test="encodedBirthYmd != null and encodedBirthYmd != ''">
+		AND    BIRTH_YMD = #{encodedBirthYmd}
+		</if>
+		<if test="ci != null and ci != ''">
+		AND    CI = #{ci}
+		</if>
+		UNION ALL
+		SELECT CUST_NO
+		     , CUST_ID
+		     , EMAIL
+		     , CELL_PHNNO
+		     , CUST_STAT
+		     , ''                                      AS JOIN_DT
+		     , DATE_FORMAT(DORMANT_DT, '%Y%m%d%H%i%S') AS DORMANT_DT
+		FROM   TB_DORMANT_CUST
+		WHERE  1 = 1
+		<if test="custId != null and custId !=''">
+		AND    CUST_ID = #{custId}
+		</if>
+		<if test="encodedCustNm != null and encodedCustNm != ''">
+		AND    CUST_NM = #{encodedCustNm}
+		</if>
+		<if test="encodedEmail != null and encodedEmail != ''">
+		AND    EMAIL = #{encodedEmail}
+		</if>
+		<if test="encodedBirthYmd != null and encodedBirthYmd != ''">
+		AND    BIRTH_YMD = #{encodedBirthYmd}
+		</if>
+		<if test="ci != null and ci != ''">
+		AND    CI = #{ci}
+		</if>
+	</select>
+
+	<select id="getCusomterSnsFind" parameterType="CustSnsInfo" resultType="Customer">
+		SELECT C.CUST_NO
+		     , C.CUST_ID
+		     , C.CUST_NM
+		     , C.CELL_PHNNO
+		     , C.EMAIL
+		     , C.CUST_STAT
+		     , C.CI
+		FROM   TB_CUSTOMER C
+		LEFT JOIN
+		       TB_CUSTOMER_SNS CS
+		ON     C.CUST_NO = CS.CUST_NO
+		WHERE  CS.SNS_TYPE = #{snsType}
+		AND    CS.SNS_ID = #{snsId}
+	</select>
+
 </mapper>