Bläddra i källkod

이태영 - 20210129 장바구니 상품 기존재 체크 쿼리 수정

xodud1202 5 år sedan
förälder
incheckning
66201c611a

+ 15 - 4
src/main/java/com/style24/front/biz/service/TsfCartService.java

@@ -103,15 +103,26 @@ public class TsfCartService {
 		cart.setRegNo(0);
 		cart.setCustNo(0);
 		cart.setUpdNo(0);
+		cart.setJsessionId(TscSession.getSessionId());
 
+		// 장바구니 보유 CART_SQ 쿼리
+		int i = 1;
 		for(Cart param : params) {
-			sb.append("UNION ALL SELECT '").append(param.getGoodsCd()).append("' AS GOODS_CD, '")
-					.append(param.getItemCd()).append("' AS ITEM_CD, '")
-					.append(param.getOptCd()).append("' AS OPT_CD\n");
+			sb.append("SELECT CD.CART_SQ \n FROM TB_CART_DETAIL CD \n INNER JOIN TB_CART C \n ON CD.CART_SQ = C.CART_SQ \n WHERE C.CUST_NO = ");
+			// TODO 로그인 정보 확인
+			if(cart.getCustNo() == 0) {
+				sb.append(cart.getCustNo()).append("\n AND JSESSION_ID = '").append(cart.getJsessionId()).append("'");
+			} else {
+				sb.append(cart.getCustNo());
+			}
+			sb.append("\n AND CD.ITEM_CD = '").append(param.getItemCd()).append("' \n AND CD.OPT_CD = '").append(param.getOptCd()).append("'");
+			if(i < params.size()) {
+				i++;
+				sb.append("\n UNION ALL \n");
+			}
 		}
 
 		// cart 정보 세팅
-		cart.setJsessionId(TscSession.getSessionId());
 		cart.setContentsLoc(params.iterator().next().getContentsLoc());
 		cart.setAfLinkCd(params.iterator().next().getAfLinkCd());
 		cart.setIthrCd(params.iterator().next().getIthrCd());

+ 2 - 69
src/main/java/com/style24/persistence/mybatis/TsfCart.xml

@@ -14,7 +14,6 @@
 		WHERE  NUMB BETWEEN #{pageable.startRow} AND #{pageable.endRow}
 	</sql>
 	
-	
 
 	<!-- 등록 상품 장바구니 수량 조회 -->
 	<select id="getHasGoodsCartCnt" parameterType="Cart" resultType="int">
@@ -34,41 +33,6 @@
 		</choose>
 	</select>
 
-	<!-- 장바구니 등록 세트 상품 확인 -->
-	<select id="selectHasSetItemCartList" parameterType="Cart" resultType="int">
-		/* TsfCart.selectHasSetItemCartList : 장바구니 등록 세트 상품 확인 */
-		SELECT C.CART_SQ
-		  FROM (SELECT GROUP_CONCAT(C.GOODS_CD, CD.ITEM_CD, CD.OPT_CD) AS SIZE_OPTION
-				     , C.CART_SQ
-			      FROM TB_CART C
-				 INNER JOIN (SELECT CD.ITEM_CD, CD.OPT_CD, CD.CART_SQ
-				    		   FROM TB_GOODS_COMPOSE GC
-				     		  INNER JOIN TB_CART_DETAIL CD
-				    			 ON GC.COMPS_GOODS_CD = CD.ITEM_CD
-				 				AND GC.GOODS_CD = #{goodsCd}
-				     		  ORDER BY CD.CART_SQ, GC.DISP_ORD) CD
-					ON C.CART_SQ = CD.CART_SQ
-			     WHERE 1=1
-			<choose>
-				<when test="regNo == 0">
-					AND C.JSESSION_ID = #{jsessionId}
-					AND C.CUST_NO = 0
-				</when>
-				<otherwise>
-					AND C.REG_NO = #{regNo}
-				</otherwise>
-			</choose>
-				   AND C.CART_GB = 'G026_BC'
-				   AND C.GOODS_CD = #{goodsCd}
-			     GROUP BY C.CART_SQ) C
-		 WHERE 1=1
-		   AND C.SIZE_OPTION = (SELECT GROUP_CONCAT(A.GOODS_CD, A.ITEM_CD, A.OPT_CD)
-							      FROM (SELECT NULL AS GOODS_CD, NULL AS ITEM_CD, NULL AS OPT_CD
-										${itemCdSql}
-							           ) A
-							     WHERE A.ITEM_CD IS NOT NULL)
-	</select>
-
 	<!-- 장바구니 등록 세트 상품 확인 -->
 	<select id="selectHasSetItemCartList" parameterType="Cart" resultType="int">
 		/* TsfCart.selectHasSetItemCartList : 장바구니 등록 세트 상품 확인 */
@@ -76,39 +40,8 @@
 		  FROM (SELECT COUNT(1) AS CNT
 					 , CART_SQ
 					 , #{goodsCd} AS GOODS_CD
-				  FROM (SELECT CD.CART_SQ
-						  FROM TB_CART_DETAIL CD
-						 INNER JOIN TB_CART C
-						    ON CD.CART_SQ = C.CART_SQ
-						 WHERE C.GOODS_CD = #{goodsCd}
-						   AND CD.ITEM_CD = #{itemCd}
-						   AND CD.OPT_CD = #{optCd}
-						<choose>
-							<when test="custNo == 0">
-						   AND C.JSESSION_ID = #{jsessionId}
-						   AND C.CUST_NO = 0
-							</when>
-							<otherwise>
-						   AND C.CUST_NO = #{custNo}
-							</otherwise>
-						</choose>
-						 UNION ALL
-						SELECT CD.CART_SQ
-						  FROM TB_CART_DETAIL CD
-						 INNER JOIN TB_CART C
-						    ON CD.CART_SQ = C.CART_SQ
-						 WHERE C.GOODS_CD = #{goodsCd}
-						   AND CD.ITEM_CD = #{itemCd}
-						   AND CD.OPT_CD = #{optCd}
-						<choose>
-							<when test="custNo == 0">
-						   AND C.JSESSION_ID = #{jsessionId}
-						   AND C.CUST_NO = 0
-							</when>
-							<otherwise>
-						   AND C.CUST_NO = #{custNo}
-							</otherwise>
-						</choose>
+				  FROM (
+					  ${itemCdSql}
 				       ) A
 				 WHERE 1=1
 				 GROUP BY CART_SQ ) AS A

+ 14 - 12
src/main/webapp/WEB-INF/views/web/cart/cartListFormWeb.html

@@ -1249,28 +1249,30 @@
                 if(j == 0) {
                     let temp = new Object;
                     temp.goodsCd = "STYS000000016";
-                    temp.itemCd = '14373757';
-                    temp.optCd = "핑크120";
+                    temp.itemCd = '14373758';
+                    temp.optCd = "블랙100";
                     temp.goodsQty = 9;
                     temp.goodsType = "G056_S";
                     temp.cartGb = "C";
-                    temp.afLinkCd = "afLinkCd";
-                    temp.ithrCd = "G027_ZZZ";
-                    temp.contentsLoc = "G028_YYY";
-                    temp.planDtlSq = "123";
+                    temp.afLinkCd = "afLinkCd2";
+                    temp.ithrCd = "G027_ZZZ2";
+                    temp.contentsLoc = "G028_YYY2";
+                    temp.planDtlSq = "1232";
+
                     compsList.push(temp);
                 } else if (j == 1) {
                     let temp = new Object;
                     temp.goodsCd = "STYS000000016";
-                    temp.itemCd = '14373758';
-                    temp.optCd = "블랙100";
+                    temp.itemCd = '14373757';
+                    temp.optCd = "핑크120";
                     temp.goodsQty = 9;
                     temp.goodsType = "G056_S";
                     temp.cartGb = "C";
-                    temp.afLinkCd = "afLinkCd2";
-                    temp.ithrCd = "G027_ZZZ2";
-                    temp.contentsLoc = "G028_YYY2";
-                    temp.planDtlSq = "1232";
+                    temp.afLinkCd = "afLinkCd";
+                    temp.ithrCd = "G027_ZZZ";
+                    temp.contentsLoc = "G028_YYY";
+                    temp.planDtlSq = "123";
+
                     compsList.push(temp);
                 }
             }