Browse Source

이태영 - 20210129 장바구니 등록 완료

xodud1202 5 years ago
parent
commit
e59c54b21a

+ 18 - 0
src/main/java/com/style24/front/biz/dao/TsfCartDao.java

@@ -68,4 +68,22 @@ public interface TsfCartDao {
      * @since 2021. 02. 01
      */
     void updateCartInfo(Cart param);
+
+    /**
+     * 장바구니 이력 정보 저장
+     * @param Cart
+     * @return void
+     * @author xodud1202
+     * @since 2021. 02. 02
+     */
+    void insertCartHst(Cart param);
+
+    /**
+     * 장바구니 상세 이력 정보 저장
+     * @param Cart
+     * @return void
+     * @author xodud1202
+     * @since 2021. 02. 02
+     */
+    void insertCartDetailHst(Cart param);
 }

+ 8 - 2
src/main/java/com/style24/front/biz/service/TsfCartService.java

@@ -141,17 +141,20 @@ public class TsfCartService {
 				throw new IllegalArgumentException("장바구니 조회에 실패하였습니다. 관리자에게 문의해주세요.");
 			} else {
 				cart.setCartSq(cartSqList.iterator().next());
-				cartDao.updateCartInfo(cart);
+				cartDao.updateCartInfo(cart);               // 장바구니 정보 수정
+				cartDao.insertCartHst(cart);                // 장바구니 수정 이력 저장
 			}
 		} else {
 			cartDao.insertCartInfo(cart);					// 장바구니 마스터 정보 저장
-
+			cartDao.insertCartHst(cart);                    // 장바구니 이력 정보 저장
 			for(Cart param : params) {
 				param.setCartSq(cart.getCartSq());
 				param.setRegNo(cart.getRegNo());
 				param.setCustNo(cart.getCustNo());
 				param.setUpdNo(cart.getUpdNo());
+
 				cartDao.insertCartDetailInfo(param);		// 장바구니 상세 저장
+				cartDao.insertCartDetailHst(param);         // 장바구니 상세 이력 저장
 			}
 		}
 	}
@@ -185,10 +188,13 @@ public class TsfCartService {
 			} else {
 				param.setCartSq(cartSqList.iterator().next());
 				cartDao.updateCartInfo(param);
+				cartDao.insertCartHst(param);                // 장바구니 수정 이력 저장
 			}
 		} else {
 			cartDao.insertCartInfo(param);					// 장바구니 마스터 정보 저장
+			cartDao.insertCartHst(param);                   // 장바구니 수정 이력 저장
 			cartDao.insertCartDetailInfo(param);			// 장바구니 상세 저장
+			cartDao.insertCartDetailHst(param);             // 장바구니 수정 이력 저장
 		}
 	}
 }

+ 2 - 0
src/main/java/com/style24/persistence/domain/Cart.java

@@ -17,9 +17,11 @@ import java.util.List;
 public class Cart extends TscBaseDomain {
 	// 장바구니 정보
 	private int cartSq;				// 장바구니 번호
+	private int cartDtlSq;          // 장바구니 상세 번호
 	private int custNo;				// 고객번호
 	private int planDtlSq;			// 기획전상세번호
 	private int goodsQty;			// 장바구니 등록 수량
+	private int ordNo;				// 주문번호
 	private String cartGb;			// 장바구니 구분 (공통코드G026)
 	private String goodsCd;			// 상품번호
 	private String productNo;		// ProductNo(WMS)

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

@@ -123,7 +123,7 @@
 	</insert>
 
 	<!-- 장바구니 상세 신규 등록 -->
-	<insert id="insertCartDetailInfo" parameterType="Cart" keyProperty="cartSq">
+	<insert id="insertCartDetailInfo" parameterType="Cart" keyProperty="cartDtlSq">
 		/* TsfCart.insertCartDetailInfo : 장바구니 상세 신규 등록 */
 		INSERT INTO TB_CART_DETAIL (
 		          CART_SQ
@@ -177,7 +177,7 @@
 	</insert>
 
 	<!-- 장바구니 상세 UPDATE -->
-	<insert id="updateCartInfo" parameterType="Cart" keyProperty="cartSq">
+	<update id="updateCartInfo" parameterType="Cart">
 		/* TsfCart.updateCartInfo : 장바구니 상세 UPDATE */
 		UPDATE TB_CART SET
 			  GOODS_QTY = GOODS_QTY + #{goodsQty}
@@ -191,5 +191,75 @@
 		WHERE CART_SQ = #{cartSq}
 		  AND GOODS_CD = #{goodsCd}
 		  AND CUST_NO = #{custNo}
+	</update>
+
+	<!-- 장바구니 이력 정보 저장 -->
+	<insert id="insertCartHst" parameterType="Cart">
+		/* TsfCart.insertCartHst : 장바구니 이력 정보 저장 */
+		INSERT INTO TB_CART_HST (  CART_SQ
+								 , CART_GB
+								 , GOODS_CD
+								 , GOODS_QTY
+								 , PRODUCT_NO
+								 , PRODUCT_CODE
+								 , DEAL_GOODS_CD
+								 , ORD_NO
+								 , CUST_NO
+								 , AF_LINK_CD
+								 , ITHR_CD
+								 , CONTENTS_LOC
+								 , PLAN_DTL_SQ
+								 , REG_NO
+								 , REG_DT
+		)
+		SELECT C.CART_SQ
+			 , C.CART_GB
+			 , C.GOODS_CD
+		     , C.GOODS_QTY
+			 , C.PRODUCT_NO
+			 , C.PRODUCT_CODE
+			 , C.DEAL_GOODS_CD
+			 , IFNULL(#{ordNo}, 0) AS ORD_NO
+			 , C.CUST_NO
+			 , C.AF_LINK_CD
+			 , C.ITHR_CD
+			 , C.CONTENTS_LOC
+			 , PLAN_DTL_SQ
+			 , #{regNo}
+			 , CURRENT_TIMESTAMP
+		FROM   TB_CART C
+		WHERE  C.CART_SQ = #{cartSq}
+	</insert>
+
+	<!-- 장바구니 상세 이력 정보 저장 -->
+	<insert id="insertCartDetailHst" parameterType="Cart">
+		/* TsfCart.insertCartDetailHst : 장바구니 상세 이력 정보 저장 */
+		INSERT INTO TB_CART_DETAIL_HST ( CART_DTL_SQ
+									   , CART_SQ
+									   , ITEM_CD
+									   , OPT_CD
+									   , OPT_CD1
+									   , OPT_CD2
+									   , SKU_MODEL_NO
+									   , PRODUCT_NO
+									   , PRODUCT_CODE
+									   , ITEM_QTY
+									   , REG_NO
+									   , REG_DT
+		)
+		SELECT CD.CART_DTL_SQ
+			 , CD.CART_SQ
+			 , CD.ITEM_CD
+			 , CD.OPT_CD
+			 , CD.OPT_CD1
+			 , CD.OPT_CD2
+			 , CD.SKU_MODEL_NO
+			 , CD.PRODUCT_NO
+			 , CD.PRODUCT_CODE
+			 , CD.ITEM_QTY
+			 , #{regNo}
+			 , CURRENT_TIMESTAMP
+		FROM   TB_CART_DETAIL CD
+		WHERE  CD.CART_DTL_SQ = #{cartDtlSq}
 	</insert>
 </mapper>

+ 69 - 1
src/main/webapp/WEB-INF/views/web/cart/cartListFormWeb.html

@@ -30,7 +30,7 @@
         <div class="wrap">
             <div class="content shopping_bag"> <!-- 페이지특정 클래스 = shop_bag -->
                 <div class="cont_head">
-                    <h2 class="t_c mb60">쇼핑백</h2>
+                    <h2 class="t_c mb60">쇼핑백<button onclick="save();">이거이거</button></h2>
                 </div>
                 <div class="cont_body">
                     <!-- CONT-BODY -->
@@ -1224,6 +1224,74 @@
                 $(this).toggleClass('active');
             });
         });
+
+        function save() {
+            // 일반 & deal 상품 장바구니 등록 (일반&딜 상품도 배열에 담아서 전송해주세요.)let compsList = [];
+            /*let temp = new Object;
+            let compsList = [];
+            temp.goodsCd = "14373703";
+            temp.optCd = "블랙140";
+            temp.goodsQty = 1;
+            temp.goodsType = "G056_D";
+            temp.dealGoodsCd = "STY"
+            temp.cartGb = "C";
+            temp.afLinkCd = "afLinkCd";
+            temp.ithrCd = "G027_ZZZ";
+            temp.contentsLoc = "G028_YYY";
+            temp.planDtlSq = "123";
+            compsList.push(temp);
+            addCart(compsList);*/
+
+            // 세트상품 장바구니  (정렬순서는 TB_GOODS_COMPOSE.DISP_ORD ASC로 입력해주세요.)
+            /*let length = 2;
+            let compsList = [];
+            for(let j = 0 ; j < length ; j++) {
+                if(j == 0) {
+                    let temp = new Object;
+                    temp.goodsCd = "STYS000000016";
+                    temp.itemCd = '14373757';
+                    temp.optCd = "핑크120";
+                    temp.goodsQty = 9;
+                    temp.goodsType = "G056_S";
+                    temp.cartGb = "C";
+                    temp.afLinkCd = "afLinkCd";
+                    temp.ithrCd = "G027_ZZZ";
+                    temp.contentsLoc = "G028_YYY";
+                    temp.planDtlSq = "123";
+                    compsList.push(temp);
+                } else if (j == 1) {
+                    let temp = new Object;
+                    temp.goodsCd = "STYS000000016";
+                    temp.itemCd = '14373758';
+                    temp.optCd = "블랙100";
+                    temp.goodsQty = 9;
+                    temp.goodsType = "G056_S";
+                    temp.cartGb = "C";
+                    temp.afLinkCd = "afLinkCd2";
+                    temp.ithrCd = "G027_ZZZ2";
+                    temp.contentsLoc = "G028_YYY2";
+                    temp.planDtlSq = "1232";
+                    compsList.push(temp);
+                }
+            }
+
+            addCart(compsList);*/
+        }
+
+        function addCart(cartList) {
+            let jsonData = JSON.stringify(cartList);
+
+            $.ajax( {
+                type: "POST",
+                url : '/cart/save',
+                data : jsonData,
+                contentType: 'application/json',
+                dataType : 'text',
+                success : function(result) {
+                    alert(result);
+                }
+            });
+        }
     </script>
 </th:block>
 </body>