Parcourir la source

Merge branch 'sowon' into develop

sowon4187 il y a 4 ans
Parent
commit
a4ea3ce035

+ 19 - 1
src/main/java/com/style24/front/biz/dao/TsfRecentlyGoodsDao.java

@@ -44,7 +44,7 @@ public interface TsfRecentlyGoodsDao {
 	 * @author gagamel
 	 * @since 2021. 5. 13
 	 */
-	public void updateRecentlyGoodsAfterLogin(RecentlyGoods recentlyGoods);
+	void updateRecentlyGoodsAfterLogin(RecentlyGoods recentlyGoods);
 
 	/**
 	 * 최근본상품 목록
@@ -54,5 +54,23 @@ public interface TsfRecentlyGoodsDao {
 	 * @date 2021. 5. 13
 	 */
 	Collection<RecentlyGoods> getRecentlyGoodsList(RecentlyGoods recentlyGoods);
+	
+	/**
+	 * 최근 본 상품 목록 등록 여부 
+	 * @param recentlyGoods - 최근본상품 정보
+	 * @return
+	 * @author sowon
+	 * @date 2021. 6. 23
+	 */
+	int getRecentlyGoodsOwnCount(RecentlyGoods recentlyGoods);
+
+	/**
+	 * 기존 최근 본 상품 update
+	 * @param recentlyGoods - 최근본상품 정보
+	 * @author sowon
+	 * @date 2021. 6. 23
+	 */
+	void updateRecentlyGoods(RecentlyGoods recentlyGoods);
+
 
 }

+ 10 - 5
src/main/java/com/style24/front/biz/service/TsfRecentlyGoodsService.java

@@ -43,15 +43,20 @@ public class TsfRecentlyGoodsService {
 
 		// 최근본상품 건수
 		int totCnt = recentlyGoodsDao.getRecentlyGoodsTotalCount(recentlyGoods);
-		log.info("최근본상품 건수: {}", totCnt);
 
-		if (totCnt >= 50) {
+		if (totCnt > 50) {
 			// 맨 처음 등록된 상품 삭제
 			recentlyGoodsDao.deleteRecentlyFirstGoods(recentlyGoods);
 		}
-
-		// 최근본상품 생성
-		recentlyGoodsDao.createRecentlyGoods(recentlyGoods);
+		
+		// 등록 여부 
+		int ownCnt = recentlyGoodsDao.getRecentlyGoodsOwnCount(recentlyGoods);
+		if (ownCnt > 0) {
+			recentlyGoodsDao.updateRecentlyGoods(recentlyGoods);
+		}else {
+			// 최근본상품 생성
+			recentlyGoodsDao.createRecentlyGoods(recentlyGoods);
+		}
 	}
 
 	/**

+ 24 - 3
src/main/java/com/style24/persistence/mybatis/shop/TsfRecentlyGoods.xml

@@ -29,8 +29,7 @@
 		                                   OR
 		                                   CUST_NO = #{custNo}
 		                                  )
-		                           ORDER  BY RGOODS_SQ
-		                           LIMIT 1
+		                           ORDER  BY REG_DT LIMIT 1
 		                           ) Z
 		                     )
 	</delete>
@@ -81,7 +80,7 @@
 		     , GI.SYS_IMG_NM
 		FROM   (
 		        SELECT GOODS_CD
-		             , RANK() OVER(ORDER BY REG_DT DESC, GOODS_CD) AS DISP_ORD
+		             , RANK() OVER(ORDER BY UPD_DT DESC) AS DISP_ORD
 		        FROM   TB_RECENTLY_GOODS
 		        WHERE  1 = 1
 		        <choose>
@@ -105,4 +104,26 @@
 		ORDER  BY A.DISP_ORD
 	</select>
 	
+	<!-- 최근 본 상품 목록 등록 여부 -->
+	<select id="getRecentlyGoodsOwnCount" parameterType="RecentlyGoods" resultType="int">
+		/* TsfRecentlyGoods.getRecentlyGoodsOwnCount */
+		SELECT COUNT(*)
+		    FROM   TB_RECENTLY_GOODS
+		    WHERE  1 = 1
+		    AND    (
+		            (GOODS_CD =  #{goodsCd} AND JSESSION_ID =   #{jsessionId})
+		            OR
+		            (GOODS_CD =  #{goodsCd} AND CUST_NO =  #{custNo})
+		           )
+	</select>
+	
+	<update id="updateRecentlyGoods"  parameterType="RecentlyGoods">
+		/* TsfRecentlyGoods.updateRecentlyGoods */
+		UPDATE TB_RECENTLY_GOODS
+		SET    UPD_DT = NOW()
+		WHERE  1=1
+		AND    GOODS_CD    = #{goodsCd}
+		AND    CUST_NO     = #{custNo}
+	</update>
+	
 </mapper>

+ 8 - 4
src/main/webapp/WEB-INF/views/web/common/fragments/FooterWeb.html

@@ -977,9 +977,9 @@
 						$('#quickMenuTodayGoods').html('');
 						
 						$('#quick01').find('span').html(result.length);
-						
+						let tag = '';
 						if (result.length > 0) {
-							let tag = '<div class="product_count"><span class="c_primary">' + result.length + '</span>개의 상품</div>\n';
+							tag += '<div class="product_count"><span class="c_primary">' + result.length + '</span>개의 상품</div>\n';
 							tag += '	<div class="itemsGrp">\n';
 							
 							$.each(result, function (idx, item) {
@@ -996,10 +996,14 @@
 							
 							tag += '	</div>\n';
 							
-							$('#quickMenuTodayGoods').html(tag);
 						} else {
-							$('#quickMenuTodayGoods').addClass('nodata');
+							tag += '<div class="no_item">';
+							tag += '	최근 본 상품이 없습니다.';
+							tag += '</div>';
+							
+							$('#quickMenuTodayGoods').attr('class','quick_body nodata');
 						}
+						$('#quickMenuTodayGoods').html(tag);
 					}
 			});
 // 	});