Pārlūkot izejas kodu

일반회원 가입

jsshin 5 gadi atpakaļ
vecāks
revīzija
1118c590a8

+ 70 - 25
src/main/java/com/style24/front/biz/service/TsfCustomerService.java

@@ -5,11 +5,14 @@ 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.front.support.security.TsfLoginDetails;
 import com.style24.persistence.domain.Coupon;
 import com.style24.persistence.domain.Customer;
+import com.style24.persistence.domain.Login;
 import com.style24.persistence.domain.Point;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.stereotype.Service;
 
 import com.style24.front.biz.dao.TsfCustomerDao;
@@ -17,6 +20,11 @@ import com.style24.front.biz.dao.TsfCustomerDao;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 고객(회원) Service
  *
@@ -36,6 +44,10 @@ public class TsfCustomerService {
 	@Autowired
 	private GagaPasswordEncoder passwordEncoder;
 
+	@Autowired
+	private TsfLoginService loginService;
+
+
 	/**
 	 * 고객아이디 찾기
 	 *
@@ -45,9 +57,9 @@ public class TsfCustomerService {
 	 * @since 2021. 02. 08
 	 */
 	public Customer getCustomerFindId(Customer customer) {
+		TscSession.setAttribute("maskingYn","Y");
 		customer.setSiteCd(TscConstants.Site.STYLE24.value());
 		customer.encryptData(); // 데이터 암호하
-		TscSession.setAttribute("maskingYn","Y");
 		return coreCustomerService.getCustomerInfo(customer);
 	}
 
@@ -118,11 +130,11 @@ public class TsfCustomerService {
 	 * @since 2021. 02. 15
 	 */
 	public Customer getCustomerFindByCi(String ci) {
+		TscSession.setAttribute("maskingYn","Y");
 		Customer customer = new Customer();
 		customer.setCi(ci);
 		customer.setSiteCd(TscConstants.Site.STYLE24.value());
 		customer.encryptData();
-
 		return customerDao.getCustomerInfo(customer);
 	}
 
@@ -134,12 +146,12 @@ public class TsfCustomerService {
 	 * @since 2021. 02. 15
 	 */
 	public Customer getCustomerFindByCellPhnno(String cellPhnno) {
+		TscSession.setAttribute("maskingYn","Y");
 		Customer customer = new Customer();
 		customer.setCellPhnno(cellPhnno);
 		customer.setHypenCellPhone(); // 010-0000-0000
 		customer.setSiteCd(TscConstants.Site.STYLE24.value());
 		customer.encryptData();
-
 		return customerDao.getCustomerInfo(customer);
 	}
 
@@ -195,16 +207,28 @@ public class TsfCustomerService {
 	 * @since 2021. 02. 19
 	 */
 	@Transactional("shopTxnManager")
-	public void saveJoinCustomer(Customer customer) {
-		boolean isSnsJoin = isSnsJoin(customer);
-		if (isSnsJoin) {
+	public boolean saveJoinCustomer(Customer customer) {
+		boolean isJoin = true;
+		// 1. validation
+		customer.encryptData();
+		if (StringUtils.isNotBlank(customer.getSnsId())) {
 			customer.setEncodedPasswd(" ");
+			customer.setCustId(customer.getSnsType()+"_"+customer.getSnsId());
 		} else {
 			customer.setEncodedPasswd(passwordEncoder.encode(customer.getPasswd()));
 		}
-		customer.encryptData();
-		customerDao.createCustomer(customer);
-		saveJoinPostProcessing(customer);
+		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 {
+			isJoin = false;
+		}
+
+		return isJoin;
 	}
 
 	/**
@@ -224,27 +248,48 @@ public class TsfCustomerService {
 
 
 	}
+
 	/**
-	 * SNS 가입인지 확인
-	 * @param customer - 일반가입, SNS 가입
-	 * @return boolean - sns 가입이면 true 아니면 false
+	 * 로그인 처리
+	 * @param custNo - 고객번호
+	 * @param request - 요청
 	 * @author jsshin
-	 * @since 2021. 02. 19
+	 * @since 2021. 02. 18
 	 */
-	public boolean isSnsJoin(Customer customer) {
-		boolean result = false;
-
-		if (StringUtils.isNotBlank(customer.getKkJoinId())) {
-			result = true;
-		}
-		if (StringUtils.isNotBlank(customer.getNvJoinId())) {
-			result = true;
-		}
-		if (StringUtils.isNotBlank(customer.getYsJoinId())) {
-			result = true;
+	public void getLogin(String custId, HttpServletRequest request) {
+		if (StringUtils.isBlank(custId)) {
+			throw new IllegalStateException("고객 아이디가 없습니다. 로그인 다시 해보시기 바랍니다.");
 		}
 
-		return result;
+		Login loginParam = new Login();
+		loginParam.setCustId(custId);
+		Login loginInfo = loginService.getLoginCheckInfo(loginParam);
+
+		// 권한 설정
+		List<SimpleGrantedAuthority> authorities = new ArrayList<>();
+		authorities.add(new SimpleGrantedAuthority(loginInfo.getCustGb()));
+
+		TsfLoginDetails loginDetails = new TsfLoginDetails(loginInfo, authorities);
+
+		// 최종로그인일시 Update
+		loginService.updateLastLoginDate(loginInfo.getCustNo());
+
+		// 로그인이력 생성
+		loginService.createLoginHistory(loginInfo.getCustNo());
+
+		// 세션 생성
+		this.createSession(request,  loginDetails);
+	}
+
+	/**
+	 * Session 생성
+	 * @param request - HttpServletRequest
+	 * @param loginDetails - 로그인 상세 정보
+	 */
+	private void createSession(HttpServletRequest request, TsfLoginDetails loginDetails) {
+		HttpSession session = request.getSession(true);
+		session.setMaxInactiveInterval(1800);
+		session.setAttribute("session", loginDetails);
 	}
 
 }

+ 62 - 14
src/main/java/com/style24/front/biz/web/TsfCustomerController.java

@@ -6,11 +6,17 @@ 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;
@@ -26,6 +32,11 @@ import org.springframework.web.bind.annotation.RequestParam;
 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
  * 
@@ -44,14 +55,16 @@ public class TsfCustomerController extends TsfBaseController {
 	private TsfCustomerService customerService;
 
 	@Autowired
-	TscClauseService clauseService;
+	private TscClauseService clauseService;
 
 	@Autowired
-	TsfKakaoService kakaoService;
+	private TsfKakaoService kakaoService;
 
 	@Autowired
 	private NiceCertify niceCertify;
 
+
+
 	/**
 	 * 아이디 찾기 화면
 	 *
@@ -517,12 +530,13 @@ public class TsfCustomerController extends TsfBaseController {
 		GagaMap result = new GagaMap();
 
 		if (StringUtils.isBlank(customer.getCellPhnno())) {
-			throw new IllegalStateException("확인 할 이메일이 없습니다.");
+			throw new IllegalStateException("확인 할 휴대폰번호가 없습니다.");
 		}
 
 		Customer custInfo = customerService.getCustomerFindByCellPhnno(customer.getCellPhnno());
 
 		if (custInfo != null) {
+			result.setString("maskingCustId", custInfo.getMaskingCustId());
 			result.setBoolean("isFind", true);
 		} else {
 			result.setBoolean("isFind", false);
@@ -556,6 +570,7 @@ public class TsfCustomerController extends TsfBaseController {
 
 		Customer custInfo = customerService.getCustomerFindByCi(customer.getCi());
 		if (custInfo != null) {
+			result.setString("maskingCustId", custInfo.getMaskingCustId());
 			result.setBoolean("isFind", true);
 		} else {
 			result.setBoolean("isFind", false);
@@ -575,35 +590,68 @@ public class TsfCustomerController extends TsfBaseController {
 	 */
 	@PostMapping("/join/save")
 	@ResponseBody
-	public GagaMap saveJoinCustomer(@RequestBody Customer customer) {
+	public GagaMap saveJoinCustomer(@RequestBody Customer customer, HttpServletRequest request) {
 		GagaMap result = new GagaMap();
+
+		// 1.세션에 인코딩된 데이터를 가져온다.
 		String encData = TscSession.getAttribute("encData");
 		customer.setEncData(encData);
 		GagaMap authInfo = niceCertify.getCertifyCellPhoneResultInfo(customer);
+
+		// 2.인증통해 받은 데이터 매핑
+		String gender = "G007_"+authInfo.getString("sGender");
+		customer.setSexGb(gender);
 		customer.setCustNm(authInfo.getString("sName"));
 		customer.setBirthYmd(authInfo.getString("sBirthDate"));
 		customer.setForeignerYn(authInfo.getString("sforeignerYn"));
 		customer.setCi(authInfo.getString("sCi"));
-		String gender = "G007_"+authInfo.getString("sGender");
-		customer.setSexGb(gender);
+
 		customer.setSiteCd(TscConstants.Site.STYLE24.value());
 		customer.setFrontGb(TsfSession.getFrontGb());
 		customer.setAfLinkCd(TsfSession.getAttribute("afLinkCd"));
 
-		// 1.입력 받은 데이터 검증
-
-		// 2.고객정보 생성 및 혜택 처리
-		customerService.saveJoinCustomer(customer);
-
-		// 3.알림톡 및 메일 발송
+		// 3.고객정보 생성 및 혜택 처리
+		boolean isJoin = customerService.saveJoinCustomer(customer);
+		// 4.알림톡 및 메일 발송
 		try {
-			kakaoService.sendJoinCongrat(customer);
+			if(StringUtils.isNotBlank(customer.getCellPhnno())) {
+				kakaoService.sendJoinCongrat(customer);
+			}
 		} catch (Exception e) {
 			log.error("error", e);
 		}
-		result.setBoolean("isJoin", true);
+
+		if (isJoin) {
+			customerService.getLogin(customer.getCustId(),request);
+		} else {
+			TsfSession.setAttribute("maskingCustId",customer.getMaskingCustId());
+		}
+
+		result.setBoolean("isJoin", isJoin);
 
 		return result;
 	}
 
+	/**
+	 * 가입완료 페이지
+	 *
+	 * @return GagaMap - 결과정보
+	 * @author jsshin
+	 * @since 2021. 02. 18
+	 */
+	@GetMapping("/join/complete/form")
+	public ModelAndView getJoinCompleteForm() {
+		ModelAndView mav = new ModelAndView();
+
+		String maskingCustId = TsfSession.getAttribute("maskingCustId");
+
+		mav.addObject("maskingCustId", maskingCustId);
+
+		mav.setViewName(super.getDeviceViewName("customer/JoinCompleteForm"));
+
+		return mav;
+	}
+
+
+
 }

+ 23 - 13
src/main/java/com/style24/persistence/mybatis/shop/TsfCustomer.xml

@@ -151,8 +151,7 @@
 	<insert id="createCustomer" parameterType="Customer" keyProperty="custNo">
 		/* TsfCustomer.createCustomer */
 		INSERT INTO TB_CUSTOMER (
-		       CUST_NO
-		     , CUST_ID
+		       CUST_ID
 		     , CUST_NM
 		     , PASSWD
 		     , BIRTH_YMD
@@ -193,21 +192,29 @@
 		     , UPD_NO
 		     , UPD_DT
 		)
-		SELECT #{custNo}                           AS CUST_NO
-		     , #{custId}                           AS CUST_ID
+		SELECT #{custId}                           AS CUST_ID
 		     , #{encodedCustNm}                    AS CUST_NM
 		     , #{encodedPasswd}                    AS PASSWD
 		     , #{encodedBirthYmd}                  AS BIRTH_YMD
 		     , #{birthSm}                          AS BIRTH_SM
 		     , #{encodedSexGb}                     AS SEX_GB
 		     , #{encodedCellPhnno}                 AS CELL_PHNNO
-		     , #{appAgreeYn}                       AS APP_AGREE_YN
-		     , #{appAgreeDt}                       AS APP_AGREE_DT
-		     , #{smsAgreeYn}                       AS SMS_AGREE_YN
-		     , #{smsAgreeDt}                       AS SMS_AGREE_DT
+		     , IFNULL(#{appAgreeYn}, 'N')          AS APP_AGREE_YN
+		     , CASE WHEN #{appAgreeYn} = 'Y' THEN
+		            NOW()
+		       ELSE NULL
+		       END                                 AS APP_AGREE_DT
+		     , IFNULL(#{smsAgreeYn}, 'N')          AS SMS_AGREE_YN
+		     , CASE WHEN #{smsAgreeYn} = 'Y' THEN
+		            NOW()
+		       ELSE NULL
+		       END                                 AS SMS_AGREE_DT
 		     , #{encodedEmail}                     AS EMAIL
-		     , #{emailAgreeYn}                     AS EMAIL_AGREE_YN
-		     , #{emailAgreeDt}                     AS EMAIL_AGREE_DT
+		     , IFNULL(#{emailAgreeYn}, 'N')        AS EMAIL_AGREE_YN
+		     , CASE WHEN #{emailAgreeYn} = 'Y' THEN
+		            NOW()
+		       ELSE NULL
+		       END                                 AS EMAIL_AGREE_DT
 		     , #{homeZipcode}                      AS HOME_ZIPCODE
 		     , #{encodedHomeBaseAddr}              AS HOME_BASE_ADDR
 		     , #{encodedHomeDtlAddr}               AS HOME_DTL_ADDR
@@ -223,16 +230,19 @@
 		     , 'N'                                 AS TEMP_PASSWD_YN
 		     , NOW()                               AS LOGIN_LDT
 		     , #{ci}                               AS CI
-		     , NOW()                               AS AUTH_DT
+		     , CASE WHEN #{ci} != '' THEN
+		            NOW()
+		       ELSE NULL
+		       END                                 AS AUTH_DT
 		     , #{managedRsn}                       AS MANAGED_RSN
 		     , #{managedDtlRsn}                    AS MANAGED_DTL_RSN
 		     , #{managedDt}                        AS MANAGED_DT
 		     , #{secedeRsn}                        AS SECEDE_RSN
 		     , #{secedeDtlRsn}                     AS SECEDE_DTL_RSN
 		     , #{secedeDt}                         AS SECEDE_DT
-		     , #{custNo}                           AS REG_NO
+		     , 0                                   AS REG_NO
 		     , NOW()                               AS REG_DT
-		     , #{custNo}                           AS UPD_NO
+		     , 0                                   AS UPD_NO
 		     , NOW()                               AS UPD_DT
 	</insert>
 

+ 84 - 0
src/main/webapp/WEB-INF/views/web/customer/JoinCompleteFormWeb.html

@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html lang="ko"
+	  xmlns:th="http://www.thymeleaf.org"
+	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
+	  layout:decorator="web/common/layout/DefaultLayoutWeb">
+<!--
+ *******************************************************************************
+ * @source  : JoinCompleteFormWeb.html
+ * @desc    : 회원 가입완료 Page
+ *============================================================================
+ * STYLE24
+ * Copyright(C) 2021 TSIT, All rights reserved.
+ *============================================================================
+ * VER  DATE         AUTHOR      DESCRIPTION
+ * ===  ===========  ==========  =============================================
+ * 1.0  2021.02.22   jsshin     최초 작성
+ *******************************************************************************
+ -->
+
+<body>
+<th:block layout:fragment="content">
+<!--  container -->
+<div id="container" class="container mb">
+	<div class="wrap">
+		<div class="content join3">
+			<div class="cont_head">
+				<h3>style24</h3>
+			</div>
+			<div class="cont_body">
+				<div th:if="${maskingCustId != ''}" class="form_wrap form_col_c" role="form" >
+					<div class="form_head">
+						<h4>회원가입</h4>
+					</div>
+					<div class="form_info">
+						<span class="ico_content_find"></span>
+						<p>이미 가입된 아이디가 있습니다.</p>
+						<p class="t_info mt15">
+							아래의 아이디로 로그인 하시거나<br>
+							잊으신 경우 다시 찾기를 통해 이용 가능합니다.
+						</p>
+					</div>
+					<div class="print_bar mt30">
+						<p class="c_primary bold" data-font="lato">ID***24</p>
+					</div>
+					<div class="btn_group_block btn_group_md ui_row">
+						<div class="ui_col_6">
+							<button type="button" class="btn btn_dark btn_block"><span>로그인</span></button>
+						</div>
+						<div class="ui_col_6">
+							<button type="button" class="btn btn_default btn_block"><span>아이디 찾기</span></button>
+						</div>
+					</div>
+				</div>
+				<div th:unless="${maskingCustId != ''}"  class="form_wrap form_col_c" role="form">
+					<div class="form_head">
+						<h3>신규회원 혜택 안내</h3>
+					</div>
+					<div class="form_info">
+						오픈 콘텐츠 확정시 다시안내
+					</div>
+					<div class="mt40">
+						<button type="button"  class="btn btn_primary btn_block" onclick="cfnGoToPage(_PAGE_MAIN);">
+							<span>쇼핑하러 가기</span>
+						</button>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+
+<script th:inline="javascript">
+	/*<![CDATA[*/
+
+	$(document).ready(function() {
+
+	});
+	/*]]>*/
+</script>
+</th:block>
+</body>
+</html>
+
+

+ 28 - 10
src/main/webapp/WEB-INF/views/web/customer/JoinFormWeb.html

@@ -206,7 +206,7 @@
 			$usable.show();
 			custIdCheck = true;
 		}
-
+		fnPossibleJoin();
 	};
 
 	// 비밀번호 입력
@@ -300,6 +300,7 @@
 				$avlConPwd.show();
 				passwdCheck = true;
 			}
+			fnPossibleJoin();
 		}
 	};
 
@@ -340,6 +341,7 @@
 			$dupEmailDiv.hide();
 			emailCheck = true;
 		}
+		fnPossibleJoin();
 	};
 
 	//	휴대폰 확인
@@ -348,7 +350,7 @@
 		let cellPhnno = $(this).val();
 		let validation;
 
-		if (gagajf.isNull(cellPhnno)) {
+		if (!gagajf.isNull(cellPhnno)) {
 			if ( 9 < cellPhnno < 12) {
 				$failPhnno.hide();
 				validation = true;
@@ -374,11 +376,12 @@
 			$dupPhnno.show();
 			// $cellPhnno.text(result.cellPhnno);
 			// $cellPhnno.show();
-			authCheck = false;
+			phoneCheck = false;
 		} else {
 			$dupPhnno.hide();
-			authCheck = true;
+			phoneCheck = true;
 		}
+		fnPossibleJoin();
 	};
 	
 
@@ -393,7 +396,7 @@
 			let custInfo = {};
 			custInfo.encData = encData;
 			let jsonData = JSON.stringify(custInfo);
-			gagajf.ajaxJsonSubmit('/customer/authentication/validation', jsonData, fnInfoConfirmCallBack);
+			gagajf.ajaxJsonSubmit('/customer/authentication/check', jsonData, fnInfoConfirmCallBack);
 		}
 	};
 
@@ -411,18 +414,36 @@
 			$dupPhnno.hide();
 			authCheck = true;
 		}
+		fnPossibleJoin();
 	};
 
 	// 저장
 	$('#btnJoin').on('click', function () {
+		mcxDialog.confirm("회원가입을 하시겠습니까?", {
+			cancelBtnText: "취소",
+			sureBtnText: "확인",
+			sureBtnClick: function() {
+				$('#btnJoin').attr('disabled', true);
+				let jsonData = JSON.stringify($('#joinForm').serializeObject());
+				gagajf.ajaxJsonSubmit('/customer/join/save', jsonData, fnJoinSaveCallback);
+			}
+		});
+	});
 
+	var fnJoinSaveCallback = function (result) {
+		if (result.isJoin) {
+			//신규회원 혜택 안내 페이지 없음
+			cfnGoToPage(_PAGE_CUSTOMER_JOIN_COMPLETE);
+		} else {
+			$('#btnJoin').attr('disabled', false);
+		}
 
-	});
+	};
 
 
 	// 가입 가능한지 확인
 	var fnPossibleJoin = function () {
-		const $btnJoin = $('#btnJoin')
+		const $btnJoin = $('#btnJoin');
 		if (custIdCheck && passwdCheck && emailCheck && phoneCheck && authCheck ) {
 			$btnJoin.attr('disabled', false);
 		} else {
@@ -430,9 +451,6 @@
 		}
 	};
 
-	$(document).ready(function() {
-		fnPossibleJoin();
-	});
 
 /*]]>*/
 </script>