Jelajahi Sumber

고객 휴대전화 번호 변경 전 사용하고 있는 고객 있는지 확인

jsshin 5 tahun lalu
induk
melakukan
9c14d5bad7

+ 9 - 0
src/main/java/com/style24/admin/biz/dao/TsaCustomerDao.java

@@ -225,6 +225,15 @@ public interface TsaCustomerDao {
 	 */
 	Collection<Customer> getCustomerDormantList(CustomerSearch customerSearch);
 
+	/**
+	 * 휴대전화 번호 조회
+	 * @param customerSearch - 검색조건
+	 * @return int - 고객 수
+	 * @author jsshin
+	 * @since 2021. 02. 23
+	 */
+	int getCustomerFindByCellPhone(CustomerSearch customerSearch);
+
 	void createException();
 
 	void updateCutomerEncodeData(Customer customer);

+ 17 - 0
src/main/java/com/style24/admin/biz/service/TsaCustomerService.java

@@ -133,6 +133,7 @@ public class TsaCustomerService {
 		Integer userNo = TsaSession.getInfo().getUserNo();
 		customer.setRegNo(userNo);
 		customer.setUpdNo(userNo);
+		customer.encryptData();
 		coreCustomerService.createCustomerHistory(customer);
 		customerDao.updateCustomerCellPhnno(customer);
 	}
@@ -372,4 +373,20 @@ public class TsaCustomerService {
 	public String getTemporaryPassword(int length) {
 		return coreCustomerService.getTemporaryPassword(length);
 	}
+
+	/**
+	 * 휴대전화 번호 조회
+	 * @param  cellPhnno - 고객 번호
+	 * @return int - 고객 수
+	 * @author jsshin
+	 * @since 2021. 02. 23
+	 */
+	public int getCustomerFindByCellPhone(String cellPhnno) {
+		CustomerSearch customerSearch = new CustomerSearch();
+		customerSearch.setSiteCd(TscConstants.Site.STYLE24.value());
+		customerSearch.setCellPhnno(cellPhnno);
+		customerSearch.encryptData();
+		return customerDao.getCustomerFindByCellPhone(customerSearch);
+	}
+
 }

+ 9 - 0
src/main/java/com/style24/admin/biz/web/TsaCustomerController.java

@@ -553,10 +553,19 @@ public class TsaCustomerController extends TsaBaseController {
 	@PostMapping("/certno/send")
 	@ResponseBody
 	public GagaResponse sendCustomerCertNo(@RequestBody Customer customer) {
+
+		// 1.기존 사용하고 있는 고객이 있는지 확인
+		int custCnt = customerService.getCustomerFindByCellPhone(customer.getCellPhnno());
+
+		if (custCnt > 0) {
+			throw new IllegalStateException("해당 휴대전화번호로 사용하고 있는 고객이 있습니다.");
+		}
+
 		String certNo = GagaStringUtil.getRandomNumber(6);
 		TsaSession.setAttribute("certNo", certNo);
 		TsaSession.setAttribute("cellPhnno", customer.getCellPhnno());
 
+
 		Customer custInfo = customerService.getCustomerInfo(customer.getCustNo());
 		customer.setCustNm(custInfo.getCustNm());
 		customer.setCertNo(certNo);

+ 28 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsaCustomer.xml

@@ -972,4 +972,32 @@
 		WHERE  CUST_NO = #{custNo}
 	</update>
 
+	<!-- 휴대전화로 고객 조회 -->
+	<select id="getCustomerFindByCellPhone" parameterType="CustomerSearch" resultType="int">
+		/* TsaCustomer.getCustomerFindByCellPhone */
+		SELECT B.CNT
+		FROM (
+		      SELECT A.CNT
+		          , ROW_NUMBER() OVER (ORDER BY A.CNT DESC) AS NUMB
+		      FROM (
+		            SELECT COUNT(*) AS CNT
+		            FROM   TB_CUSTOMER
+		            WHERE  CUST_STAT = 'G104_10'   /* 활동회원*/
+		            AND    SITE_CD = #{siteCd}
+		            AND    CELL_PHNNO = #{cellPhnno}
+		            UNION ALL
+		            SELECT COUNT(*) AS CNT
+		            FROM   TB_SECEDE_CUST
+		            WHERE  SITE_CD = #{siteCd}
+		            AND    CELL_PHNNO = #{cellPhnno}
+		            UNION ALL
+		            SELECT COUNT(*) AS CNT
+		            FROM   TB_DORMANT_CUST
+		            WHERE  SITE_CD = #{siteCd}
+		            AND    CELL_PHNNO = #{cellPhnno}
+		          ) A
+		) B
+		WHERE NUMB = 1
+	</select>
+
 </mapper>