Przeglądaj źródła

제휴링크코드 로직 수정

gagamel 4 lat temu
rodzic
commit
cd764436cd

+ 11 - 3
src/main/java/com/style24/front/biz/dao/TsfCommonDao.java

@@ -1,13 +1,13 @@
 package com.style24.front.biz.dao;
 
-import com.style24.persistence.domain.SupplyCompany;
+import java.util.Collection;
+
 import org.springframework.stereotype.Repository;
 
 import com.style24.core.support.annotation.ShopDs;
 import com.style24.persistence.domain.InflowHst;
 import com.style24.persistence.domain.Order;
-
-import java.util.Collection;
+import com.style24.persistence.domain.SupplyCompany;
 
 /**
  * 공통 Dao
@@ -46,6 +46,14 @@ public interface TsfCommonDao {
 	 */
 	String getAfLinkName(String afLinkCd);
 
+	/**
+	 * 유효한 웹제휴채널 여부 조회
+	 * @return Y/N
+	 * @author gagamel
+	 * @since 2021. 8. 31
+	 */
+	String getAvailableAfLinkYn(String afLinkCd);
+
 //	/**
 //	 * 기본답변문구내용 조회
 //	 *

+ 14 - 3
src/main/java/com/style24/front/biz/service/TsfCommonService.java

@@ -1,6 +1,7 @@
 package com.style24.front.biz.service;
 
-import com.style24.persistence.domain.SupplyCompany;
+import java.util.Collection;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -12,11 +13,10 @@ import com.style24.front.biz.dao.TsfCommonDao;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.InflowHst;
 import com.style24.persistence.domain.Order;
+import com.style24.persistence.domain.SupplyCompany;
 
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.Collection;
-
 /**
  * 공통 Service
  *
@@ -45,6 +45,17 @@ public class TsfCommonService {
 //		return commonDao.getSiteName(siteCd);
 //	}
 
+	/**
+	 * 유효한 웹제휴링크코드 여부 조회
+	 * @param afLinkCd - 제휴링크코드
+	 * @return Y/N
+	 * @author gagamel
+	 * @date 2021. 08. 31
+	 */
+	public String getAvailableAfLinkYn(String afLinkCd) {
+		return commonDao.getAvailableAfLinkYn(afLinkCd);
+	}
+
 	/**
 	 * 유입경로이력(웹제휴채널) 생성
 	 * @param afLinkCd - 제휴링크코드

+ 17 - 6
src/main/java/com/style24/front/support/interceptor/TsfAflinkInterceptor.java

@@ -41,8 +41,17 @@ public class TsfAflinkInterceptor extends HandlerInterceptorAdapter {
 		String afLinkCd = params.getString("afLinkCd");
 
 		if (StringUtils.isNotBlank(afLinkCd)) {
-			if (!afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) {
-				TsfSession.setAttribute("afLinkCd", afLinkCd);
+			// 유효한 웹제휴채널코드 여부 조회
+			String isAvailAfLinkCdYn = commonService.getAvailableAfLinkYn(afLinkCd);
+			log.info("isAvailAfLinkCdYn: {}", isAvailAfLinkCdYn);
+
+			// 유효한 웹제휴채널코드이면
+			if (isAvailAfLinkCdYn.equals("Y")) {
+				if (!afLinkCd.equals(TsfSession.getAttribute("afLinkCd"))) {
+					TsfSession.setAttribute("afLinkCd", afLinkCd);
+				}
+			} else {
+				afLinkCd = "";
 			}
 		} else {
 			if (TsfSession.getAttribute("isApp").equals("true")) { // 앱이면
@@ -68,10 +77,12 @@ public class TsfAflinkInterceptor extends HandlerInterceptorAdapter {
 		}
 
 		try {
-			InflowHst inflow = new InflowHst();
-			inflow.setAfLinkCd(afLinkCd);
-			inflow.setPageUrl(request.getRequestURL() + queryString);
-			commonService.createInflowHistory(inflow);
+			if (StringUtils.isNotBlank(afLinkCd)) {
+				InflowHst inflow = new InflowHst();
+				inflow.setAfLinkCd(afLinkCd);
+				inflow.setPageUrl(request.getRequestURL() + queryString);
+				commonService.createInflowHistory(inflow);
+			}
 		} catch (Exception e) {
 			// Do nothing
 		}

+ 9 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsfCommon.xml

@@ -52,6 +52,15 @@
 		WHERE  AF_LINK_CD = #{afLinkCd}
 	</select>
 	
+	<!-- 유효한 웹제휴채널 여부 조회 -->
+	<select id="getAvailableAfLinkYn" parameterType="String" resultType="String">
+		/* TsfCommon.getAvailableAfLinkYn */
+		SELECT CASE WHEN COUNT(*) > 0 THEN 'Y' ELSE 'N' END
+		FROM   TB_AF_LINK
+		WHERE  AF_LINK_CD = #{afLinkCd}
+		AND    USE_YN = 'Y'
+	</select>
+	
 	<!-- 주문배송지정보수정 -->
 	<update id="updateDeliverAddr" parameterType="Order">
 		/* TsfCommon.updateDeliverAddr */