Selaa lähdekoodia

회원상세 Lms, 이메일 팝업 변경

jsshin 5 vuotta sitten
vanhempi
commit
5b5a917d13

+ 53 - 1
src/main/java/com/style24/admin/biz/service/TsaCustomerService.java

@@ -1,6 +1,7 @@
 package com.style24.admin.biz.service;
 
 import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.security.GagaPasswordEncoder;
 import com.style24.admin.biz.dao.TsaCustomerDao;
 import com.style24.admin.support.security.session.TsaSession;
 import com.style24.core.biz.service.TscCustomerService;
@@ -40,6 +41,12 @@ public class TsaCustomerService {
 	@Autowired
 	private TscCustomerService coreCustomerService;
 
+	@Autowired
+	private GagaPasswordEncoder passwordEncoder;
+
+	@Autowired
+	private TsaKakaoService kakaoService;
+
 	/**
 	 * 활동회원 건수
 	 * @param customerSearch - 검색조건
@@ -85,25 +92,57 @@ public class TsaCustomerService {
 	 */
 	@Transactional("shopTxnManager")
 	public void saveCustomerInfo(Customer customer) {
+		boolean isDupEmail = false;
+
+		// 이메일 변경시 유효성 체크
+		if ("Y".equals(customer.getEmailModifyYn())) {
+			isDupEmail =  getCustomerByEmail(customer.getCustNo(), customer.getEmail());
+		}
+
+		if (isDupEmail) {
+			throw new IllegalStateException("이미 사용중인 이메일 입니다.");
+		}
+
 		Integer userNo = TsaSession.getInfo().getUserNo();
 		customer.setRegNo(userNo);
 		customer.setUpdNo(userNo);
 		customer.encryptData();  // 암호화 처리
+
 		// 1.고객 이력 생성
 		coreCustomerService.createCustomerHistory(customer);
 
 		// 2.마케팅수신동의 이력 화면단에서 수신 변경이 없으면 ''처리
 		if (StringUtils.isNotBlank(customer.getSmsAgreeYn())
 				|| StringUtils.isNotBlank(customer.getEmailAgreeYn())
-				|| StringUtils.isNotBlank(customer.getAppAgreeYn())) {
+				|| StringUtils.isNotBlank(customer.getAppAgreeYn())
+				|| StringUtils.isNotBlank(customer.getMkAgreeYn())) {
 			coreCustomerService.createCustomerMarketHst(customer);
 		}
+
 		// 3.고객정보 수정
 		customerDao.updateCustomerInfo(customer);
 		// 임시 암호화
 		//customerDao.updateCutomerEncodeData(customer);
 	}
 
+	/**
+	 * 이메일 유효성 확인
+	 * @param custNo - 고객번호
+	 * @param email - 이메일
+	 * @return boolean - 결과 사용중인 이메일 있으면 1 없으면 0
+	 * @author jsshin
+	 * @since 2021. 03. 15
+	 */
+	private boolean getCustomerByEmail(Integer custNo, String email) {
+		Customer customer = new Customer();
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.setCustNo(custNo);
+		customer.setEmail(email);
+		customer.encryptData();
+		int result = coreCustomerService.getCustomerByEmail(customer);
+		return result > 0 ;
+	}
+
 	/**
 	 * 회원 비밀번호 수정
 	 * @param customer - 고객정보
@@ -113,10 +152,23 @@ public class TsaCustomerService {
 	@Transactional("shopTxnManager")
 	public void saveCustomerPassword(Customer customer) {
 		Integer userNo = TsaSession.getInfo().getUserNo();
+
+		String tempPasswd = getTemporaryPassword(10);
+		customer.setPasswd(tempPasswd);
+		customer.setEncodedPasswd(passwordEncoder.encode(tempPasswd));
+
+		log.info("tempPasswd  ====> {}", tempPasswd);
+
 		customer.setRegNo(userNo);
 		customer.setUpdNo(userNo);
 		customer.setTempPasswdYn("Y");
 		coreCustomerService.saveCustomerPassword(customer);
+
+		// TODO: 2021.3.29 카카오 서비스 개발 후 풀어줘야함 - jsshin
+		if (StringUtils.isNotBlank(customer.getCellPhnno())) {
+		//	kakaoService.sendCustomerTempPassword(customer);
+		}
+		// TODO: 2021.1.20 메일발송 서비스 붙여야함 - jsshin
 	}
 
 	/**

+ 1 - 0
src/main/java/com/style24/admin/biz/service/TsaKakaoService.java

@@ -112,6 +112,7 @@ public class TsaKakaoService {
 	 * @author jsshin
 	 * @since 2021. 01. 25
 	 */
+	@Transactional("shopTxnManager")
 	public void sendCustomerCertNo(Customer customer) {
 		SsgDirectMessage dm = new SsgDirectMessage();
 		dm.setFdestine(customer.getCellPhnno());

+ 12 - 25
src/main/java/com/style24/admin/biz/web/TsaCustomerController.java

@@ -77,9 +77,6 @@ public class TsaCustomerController extends TsaBaseController {
 	@Autowired
 	private TsaSystemService systemService;
 
-	@Autowired
-	private GagaPasswordEncoder passwordEncoder;
-
 	@Autowired
 	private TsaKakaoService kakaoService;
 
@@ -446,22 +443,12 @@ public class TsaCustomerController extends TsaBaseController {
 	 */
 	@PostMapping("/password/reset")
 	@ResponseBody
-	public GagaResponse resetCustomerPassword(@RequestBody Customer customer) throws Exception {
-		String tempPasswd = customerService.getTemporaryPassword(10);
-		log.info("tempPasswd  ====> {}", tempPasswd);
+	public GagaResponse resetCustomerPassword(@RequestBody Customer customer) {
 
-		customer.setTempPasswdYn("Y"); // 임시비밀번호여부
-		customer.setPasswd(tempPasswd);
-		customer.setEncodedPasswd(passwordEncoder.encode(tempPasswd));
+		Customer custInfo = customerService.getCustomerInfo(customer.getCustNo());
 
 		// 비밀번호 수정
-		customerService.saveCustomerPassword(customer);
-
-		// 카카오 알림톡
-		if (StringUtils.isNotBlank(customer.getCellPhnno())) {
-			kakaoService.sendCustomerTempPassword(customer);
-		}
-		// TODO: 2021.1.20 메일발송 서비스 붙여야함 - jsshin
+		customerService.saveCustomerPassword(custInfo);
 
 		return ok(message.getMessage("SUCC_0005"));
 	}
@@ -471,7 +458,7 @@ public class TsaCustomerController extends TsaBaseController {
 	 *
 	 * @param elementCellPhnno - 휴대폰
 	 * @param elementCustNo - 고객일련번호
-	 * @param division - 호출화면구분
+	 * @param maskingCellPhnno - 마스킹된 휴대폰
 	 * @return ModelAndView
 	 * @author jsshin
 	 * @since 2021. 01. 21
@@ -479,17 +466,17 @@ public class TsaCustomerController extends TsaBaseController {
 	@GetMapping("/lms/popup/form")
 	public ModelAndView lmsPopupForm(@RequestParam(value = "elementCellPhnno", required = false) String elementCellPhnno
 									, @RequestParam(value = "elementCustNo") String elementCustNo
-									, @RequestParam(value = "division", required = false) String division) {
+									, @RequestParam(value = "elementMaskingCellPhnno", required = false) String maskingCellPhnno) {
 		ModelAndView mav = new ModelAndView();
 		// 휴대폰 번호
 		mav.addObject("elementCellPhnno", elementCellPhnno);
 
+		// 휴대폰 번호
+		mav.addObject("maskingCellPhnno", StringUtils.defaultString(maskingCellPhnno,""));
+
 		// 고객 아이디
 		mav.addObject("elementCustNo", elementCustNo);
 
-		// 접속유형 구분값
-		mav.addObject("division", division);
-
 		mav.addObject("callBack", TscConstants.CALLCENTER_TEL_NO);
 
 		mav.setViewName("customer/LmsPopupForm");
@@ -629,21 +616,21 @@ public class TsaCustomerController extends TsaBaseController {
 	@GetMapping("/email/popup/form")
 	public ModelAndView emailPopupForm(@RequestParam(value = "elementEmail") String elementEmail
 									, @RequestParam(value = "elementCustNo") String elementCustNo
-									, @RequestParam(value = "division", required = false) String division) {
+									, @RequestParam(value = "elementMaskingEmail", required = false) String elementMaskingEmail) {
 
 		ModelAndView mav = new ModelAndView();
 
 		// 받는사람 이메일
 		mav.addObject("elementEmail", elementEmail);
 
+		// 마스킹된 이메일
+		mav.addObject("elementMaskingEmail", StringUtils.defaultString(elementMaskingEmail,""));
+
 		// 고객 번호
 		mav.addObject("elementCustNo", elementCustNo);
 
 		mav.addObject("sendEmail", TscConstants.REP_EMAIL);
 
-		// 접속유형 구분값
-		mav.addObject("division", division);
-
 		mav.setViewName("customer/EmailPopupForm");
 
 		return mav;

+ 49 - 47
src/main/webapp/WEB-INF/views/customer/CustomerDetailForm.html

@@ -158,7 +158,8 @@
 									<tr>
 										<th class="dashR">휴대전화번호<em class="required" title="필수"></em></th>
 										<td class="dashR">
-											<input type="text" name="cellPhnno" class="w130" readonly="readonly"/>
+											<input type="hidden" name="cellPhnno"/>
+											<input type="text" name="maskingCellPhnno" class="w130" readonly="readonly"/>
 											<button type="button" id="btnCustSendLms" class="btn btn-info btn-lg">LMS전송</button>
 											<button type="button" id="btnCustCrtfd" class="btn btn-info btn-lg">번호변경</button>
 										</td>
@@ -171,6 +172,9 @@
 									<tr>
 										<th class="dashR">이메일<em class="required" title="필수"></em></th>
 										<td class="dashR">
+											<input type="hidden" name="emailModifyYn"/>
+											<input type="hidden" name="maskingEmail"/>
+											<input type="hidden" name="orgEmail"/>
 											<input type="hidden" name="email" data-valid-name="이메일"/>
 											<input type="text" id="emailId" name="emailId" class="w200" maxlength="30"/>
 											@
@@ -605,7 +609,6 @@
 				return gagaAgGrid.toDateTimeFormat(params.value);
 			}
 		},
-// 		{headerName: "확인NO", field: "ansNo", width: 100, cellClass: 'text-center'},
 		{headerName: "확인자", field: "ansNm", width: 100, cellClass: 'text-center'}
 	];
 
@@ -630,7 +633,6 @@
 				return gagaAgGrid.toDateTimeFormat(params.value);
 			}
 		},
-		{headerName: "확인NO", field: "ansNo", width: 100, cellClass: 'text-center'},
 		{headerName: "확인자", field: "ansNm", width: 100, cellClass: 'text-center'}
 	];
 
@@ -898,11 +900,6 @@
 
 	// 기본정보 - 비밀번호 초기화 버튼
 	$('#btnResetPassword').on('click', function () {
-
-		if (!fnCheckValidationEmail('#custInfoForm')) {
-			return false;
-		}
-
 		mcxDialog.confirm("초기화 하시겠습니까?", {
 			cancelBtnText: "취소",
 			sureBtnText: "확인",
@@ -924,6 +921,7 @@
 		let param = {};
 		param.elementCellPhnno = '#custInfoForm input[name=cellPhnno]';
 		param.elementCustNo = '#custInfoForm input[name=custNo]';
+		param.elementMaskingCellPhnno = '#custInfoForm input[name=maskingCellPhnno]';
 
 		cfnOpenLmsPopup(param);
 	});
@@ -937,20 +935,18 @@
 		let elementCustNo = '#custInfoForm input[name=custNo]';
 
 		const actionUrl = '/customer/cellphone/change/popup/form?elementCellPhnno=' + encodeURIComponent(elementCellPhnno)
-						+ '&elementCustNo=' + encodeURIComponent(elementCustNo)
+						+ '&elementCustNo=' + encodeURIComponent(elementCustNo);
+
 		cfnOpenModalPopup(actionUrl, 'popupCellphoneForm');
 	});
 
 	// 기본정보 - 이메일발송 버튼
 	$('#btnCustSendEmail').on('click', function () {
 
-		if (!fnCheckValidationEmail('#custInfoForm')) {
-			return false;
-		}
-
 		let param = {};
-		param.elementEmail = '#custInfoForm input[name=email]';
+		param.elementEmail = '#custInfoForm input[name=orgEmail]';
 		param.elementCustNo ='#custInfoForm input[name=custNo]';
+		param.elementMaskingEmail = '#custInfoForm input[name=maskingEmail]';
 
 		cfnOpenEmailPopup(param);
 	});
@@ -1020,15 +1016,16 @@
 		// customer.homeBaseAddr = orgData.homeBaseAddr;
 		// customer.homeDtlAddr = orgData.homeDtlAddr;
 
+		let jsonData = JSON.stringify(customer);
+		console.log(jsonData);
 		mcxDialog.confirm("기본정보를 수정 하시겠습니까?", {
 			cancelBtnText: "취소",
 			sureBtnText: "확인",
 			sureBtnClick: function () {
-				let jsonData = JSON.stringify(customer);
-				//console.log(jsonData);
-				gagajf.ajaxJsonSubmit('/customer/info/save', jsonData);
-				uifnPopupClose('customerDetailForm');
-				$('#btnSearch').trigger('click');
+				gagajf.ajaxJsonSubmit('/customer/info/save', jsonData , function () {
+					uifnPopupClose('customerDetailForm');
+					$('#btnSearch').trigger('click');
+				});
 			}
 		});
 
@@ -1221,7 +1218,7 @@
 
 					fnGetSecedeRsnYn(data.custStat, data.secedeRsn);	// 탈퇴여부
 
-					let snsType = fnGetSnsType(data.nvJoinId, data.kkJoinId, data.ysJoinId);
+					let snsType = fnGetSnsType(data.snsType);
 					$('#snsType').text(snsType);
 
 					$('#homeZipcode').val(data.homeZipcode);
@@ -1229,11 +1226,11 @@
 					$('#homeDtlAddr').val(data.homeDtlAddr);
 					$('#sexGb').text(gagaAgGrid.lookupValue(genderGbList, data.sexGb));
 					$('#birthYmd').val(gagaAgGrid.toDateFormat(data.birthYmd));
-					fnDisplayEmailAgree(data.emailAgreeYn); 	 	// 이메일 수신여부
-					fnDisplaySmsAgree(data.smsAgreeYn);				// SMS 수신여부
-					fnDisplayEmail(data.maskingEmail);				// EMAIL
-					fnDisplayCellPhnno(data.maskingCellPhnno);		// 핸드폰
-					fnDisplayManaged(data.managedRsn);				// 관리대상
+					fnDisplayEmailAgree(data.emailAgreeYn);
+					fnDisplaySmsAgree(data.smsAgreeYn);
+					fnDisplayEmail(data.email, data.maskingEmail);
+					fnDisplayCellPhnno(data.cellPhnno, data.maskingCellPhnno);
+					fnDisplayManaged(data.managedRsn);
 
 					orgData = data;									// 기존 데이터
 
@@ -1359,10 +1356,18 @@
 		let emailDomain = $(formId + ' input[name=emailDomain]').val();
 		$(formId + ' input[name=email]').val(emailId + '@' + emailDomain);
 
-		if (!gagajf.testRegexp($(formId + ' input[name=email]'), /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) {
-			result = false;
+		if (orgData.maskingEmail === $(formId + ' input[name=email]').val()) {
+			return true;
+		} else {
+			if (!gagajf.testRegexp($(formId + ' input[name=email]'), /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) {
+				result = false;
+			}
+			// 수정되었으면 Y로 변경
+			if (result) {
+				console.log('result', result);
+				$(formId + ' input[name=emailModifyYn]').val('Y');
+			}
 		}
-
 		return result;
 	};
 
@@ -1396,17 +1401,20 @@
 	}
 
 	// 휴대전화번호
-	var fnDisplayCellPhnno = function (cellPhnno) {
+	var fnDisplayCellPhnno = function (cellPhnno, maskingCellPhnno) {
 		$('#custInfoForm input[name=cellPhnno]').val(cellPhnno);
+		$('#custInfoForm input[name=maskingCellPhnno]').val(maskingCellPhnno);
 	};
 
 	// 이메일
-	var fnDisplayEmail = function (email) {
-		if (!gagajf.isNull(email)) {
-			let emailSplit = email.split("@");
+	var fnDisplayEmail = function (email, maskingEmail) {
+		if (!gagajf.isNull(maskingEmail)) {
+			let emailSplit = maskingEmail.split("@");
 			$('#emailId').val(emailSplit[0]);
 			$('#emailDomain').val(emailSplit[1]);
+			$('#custInfoForm input[name=maskingEmail]').val(maskingEmail);
 		}
+		$('#custInfoForm input[name=orgEmail]').val(email);
 	};
 
 	// 이메일 수신동의
@@ -1435,24 +1443,18 @@
 	};
 
 	// SNS가입유형
-	var fnGetSnsType = function (nvJoinId, kkJoinId, ysJoinId) {
-		let snsType = '';
-		if (!gagajf.isNull(nvJoinId)) {
-			snsType = 'NAVER'
+	var fnGetSnsType = function (snsType) {
+		let snsText = '';
+		if (snsType === 'NV') {
+			snsText = '네이버'
 		}
-		if (!gagajf.isNull(kkJoinId)) {
-			if (!gagajf.isNull(snsType)) {
-				snsType += ','
-			}
-			snsType += 'KAKAO';
+		if (snsType === 'KK') {
+			snsType = '카카오';
 		}
-		if (!gagajf.isNull(ysJoinId)) {
-			if (!gagajf.isNull(snsType)) {
-				snsType += ','
-			}
-			snsType += 'YES24';
+		if (snsType === 'YS') {
+			snsText = 'YES24';
 		}
-		return snsType;
+		return snsText;
 	};
 
 	// 생년월일 달력 설정

+ 6 - 2
src/main/webapp/WEB-INF/views/customer/EmailPopupForm.html

@@ -74,6 +74,7 @@
 	/*<![CDATA[*/
 	const elementEmail = [[${elementEmail}]];
 	const elementCustNo = [[${elementCustNo}]];
+	const elementMaskingEmail = [[${elementMaskingEmail}]];
 
 	// 메시지 전송
 	$("#btnSendEmail").on("click",function() {
@@ -122,10 +123,13 @@
 	// 데이터 셋팅
 	var fnInitDataSet = function () {
 		let email = $(elementEmail).val();
-
-		if(!gagajf.isNull(email)) {
+		if (gagajf.isNull(elementMaskingEmail)) {
 			$('#emailForm input[name=email]').val(email);
 			$('#emailForm span[name=email]').text(email);
+		} else {
+			let mkEmail = $(elementMaskingEmail).val();
+			$('#emailForm input[name=email]').val(email);
+			$('#emailForm span[name=email]').text(mkEmail);
 		}
 	}
 

+ 12 - 3
src/main/webapp/WEB-INF/views/customer/LmsPopupForm.html

@@ -33,8 +33,12 @@
 					<tbody>
 					<tr >
 						<th>수신자번호<em class="required" title="필수"></em></th>
-						<td>
-							<input type="text" class="w150" name="cellPhnno" data-valid-name="수신번호"  required="required"  maxlength="13"/>
+						<td th:if="${maskingCellPhnno == ''}">
+							<input type="text" class="w150" name="cellPhnno" data-valid-name="수신번호"  required="required"  maxlength="13" readonly="readonly"/>
+						</td>
+						<td th:unless="${maskingCellPhnno == ''}">
+							<input type="hidden" name="cellPhnno"/>
+							<input type="text" class="w150" name="maskingCellPhnno" readonly="readonly"/>
 						</td>
 					</tr>
 					<tr>
@@ -67,6 +71,7 @@
 	/*<![CDATA[*/
 	const elementCellPhnno = [[${elementCellPhnno}]];
 	const elementCustNo = [[${elementCustNo}]];
+	const maskingCellPhnno = [[${maskingCellPhnno}]];
 
 	// 메시지 전송
 	$("#btnSendSms").on("click",function() {
@@ -108,8 +113,12 @@
 
 	var fnInitDataSet = function () {
 		let cellPhnno = $(elementCellPhnno).val();
-		if(!gagajf.isNull(cellPhnno)) {
+		if (gagajf.isNull(maskingCellPhnno)) {
+			$('#lmsForm input[name=cellPhnno]').val(cellPhnno);
+		} else {
+			let mkCellPhno = $(maskingCellPhnno).val();
 			$('#lmsForm input[name=cellPhnno]').val(cellPhnno);
+			$('#lmsForm input[name=maskingCellPhnno]').val(mkCellPhno);
 		}
 	}
 

+ 13 - 9
src/main/webapp/ux/js/admin.popup.js

@@ -388,19 +388,21 @@ function cfnCouponCreatePopup(cpnId, callbackfun){
  * @access : public
  * @desc   : LMS 팝업
  * <pre>
- *     var param = new Object();
- *     param.elementContent = 'textarea[name=content]';
+ *     var param = {};
  *     param.elementCellPhnno = 'input[name=cellPhnno]';
  *     param.elementCustNo = 'input[name=custNo]';
+ *     param.elementMaskingCellPhnno = 'textarea[name=elementMaskingCellPhnno]'; //선택
  *     cfnOpenLmsPopup(param);
  * </pre>
  * @since  : 2020/02/13
  * @author : jsshin
  */
-var cfnOpenLmsPopup = function(param, division) {
+var cfnOpenLmsPopup = function(param) {
 	var actionUrl = '/customer/lms/popup/form?elementCellPhnno=' + encodeURIComponent(param.elementCellPhnno)
-			+ '&elementCustNo=' + encodeURIComponent(param.elementCustNo)
-			+ '&division=' + division;
+			+ '&elementCustNo=' + encodeURIComponent(param.elementCustNo);
+	if (!gagajf.isNull(param.elementMaskingCellPhnno)) {
+		actionUrl +='&elementMaskingCellPhnno=' + encodeURIComponent(param.elementMaskingCellPhnno);
+	}
 	cfnOpenModalPopup(actionUrl, 'popupLmsForm');
 }
 
@@ -409,19 +411,21 @@ var cfnOpenLmsPopup = function(param, division) {
  * @access : public
  * @desc   : 메일 팝업
  * <pre>
- *     var param = new Object();
+ *     var param = {};
  *     param.elementRecipEmail = 'input[name=email]';
- *     param.elementCustNm = 'input[name=cellPhnno]';
  *     param.elementCustNo = 'input[name=custNo]';
+ *     param.elementMaskingEmail = 'input[name=maskingEmail]' 선택사항
  *     cfnOpenEmailPopup(param);
  * </pre>
  * @since  : 2020/02/13
  * @author : jsshin
  */
-var cfnOpenEmailPopup = function(param, division) {
+var cfnOpenEmailPopup = function(param) {
 	var actionUrl = '/customer/email/popup/form?elementEmail=' + encodeURIComponent(param.elementEmail)
 	+ '&elementCustNo=' + encodeURIComponent(param.elementCustNo);
-	+ '&division=' + division;
+	if(!gagajf.isNull(param.elementMaskingEmail)) {
+		actionUrl += '&elementMaskingEmail=' + encodeURIComponent(param.elementMaskingEmail);
+	}
 	cfnOpenModalPopup(actionUrl, 'popupEmailForm');
 }