浏览代码

이태영 - 20200302 장바구니 수량 변경 임시 커밋

xodud1202 5 年之前
父节点
当前提交
8a5aed59e1

+ 29 - 3
src/main/java/com/style24/front/biz/dao/TsfCartDao.java

@@ -33,7 +33,7 @@ public interface TsfCartDao {
 	 * @author xodud1202
 	 * @since 2021. 02. 01
 	 */
-	Collection<Integer> selectHasSetItemCartList(Cart param);
+	Collection<Cart> selectHasSetItemCartList(Cart param);
 
 	/**
 	 * 장바구니 등록 상품 확인
@@ -63,7 +63,7 @@ public interface TsfCartDao {
 	void insertCartDetailInfo(Cart param);
 
 	/**
-	 * 장바구니 상세 신규 등록
+	 * 장바구니 수정
 	 * @param Cart
 	 * @return void
 	 * @author xodud1202
@@ -71,9 +71,27 @@ public interface TsfCartDao {
 	 */
 	void updateCartInfo(Cart param);
 
+	/**
+	 * 장바구니 수정
+	 * @param param
+	 * @return void
+	 * @author xodud1202
+	 * @since 2021. 03. 01
+	 */
+	void updateCart(Cart param);
+
+	/**
+	 * 장바구니 상세 수정
+	 * @param param
+	 * @return void
+	 * @author xodud1202
+	 * @since 2021. 03. 01
+	 */
+	void updateCartDetail(Cart param);
+
 	/**
 	 * 장바구니 이력 정보 저장
-	 * @param Cart
+	 * @param param
 	 * @return void
 	 * @author xodud1202
 	 * @since 2021. 02. 02
@@ -192,6 +210,14 @@ public interface TsfCartDao {
 	 */
 	void deleteCart(Cart param);
 
+	/**
+	 * 장바구니 삭제
+	 * @param param - 장바구니 정보
+	 * @author xodud1202
+	 * @date 2021. 03. 01
+	 */
+	void deleteCartDetail(Cart param);
+
 	/**
 	 * 장바구니 상품 마스터 정보 조회
 	 * @param param

+ 124 - 3
src/main/java/com/style24/front/biz/service/TsfCartService.java

@@ -102,6 +102,8 @@ public class TsfCartService {
 			}
 
 			cart.setGoodsCd(param.getGoodsCd());
+
+			// 장바구니에 있는 같은 상품(옵션이 상이해도 같은 상품이므로 상품 전체 조회)
 			int goodsCartCnt = cartDao.getHasGoodsCartCnt(param);
 			if (param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
 				throw new IllegalArgumentException("1일 구매한도 수량이 초과되었습니다.");
@@ -179,13 +181,13 @@ public class TsfCartService {
 		}
 
 		// 같은 장바구니 상품 확인
-		Collection<Integer> cartSqList = cartDao.selectHasSetItemCartList(cart);
+		Collection<Cart> cartSqList = cartDao.selectHasSetItemCartList(cart);
 
 		if (cartSqList != null && cartSqList.size() > 0) {		// 장바구니 기존재
-			if (cartSqList.size() > 1) {							// 장바구니 조회 결과 이상시 insert or select 수정 필요
+			if (cartSqList.size() > 1) {						// 장바구니 조회 결과 이상시 insert or select 수정 필요
 				throw new IllegalArgumentException("장바구니 조회에 실패하였습니다. 관리자에게 문의해주세요.");
 			} else {
-				cart.setCartSq(cartSqList.iterator().next());
+				cart.setCartSq(cartSqList.iterator().next().getCartSq());
 				cartDao.updateCartInfo(cart);               // 장바구니 정보 수정
 				cartDao.insertCartHst(cart);                // 장바구니 수정 이력 저장
 			}
@@ -652,6 +654,7 @@ public class TsfCartService {
 	public void deleteCart(Cart param) {
 		cartDao.deleteCart(param);
 	}
+
 	/**
 	 * 로그인 후 장바구니 Update
 	 * 		회원 로그인 후 호출됨으로 세션 정보 있음
@@ -743,4 +746,122 @@ public class TsfCartService {
 
 		return cart;
 	}
+
+	@Transactional("shopTxnManager")
+	public void updateCartOption(Cart param) {
+		param.setJsessionId(TsfSession.getSessionId());
+		param.setFrontGb(TsfSession.getFrontGb());
+
+		if(TsfSession.isLogin()) {
+			param.setCustNo(TsfSession.getInfo().getCustNo());
+			param.setRegNo(param.getCustNo());
+			param.setUpdNo(param.getCustNo());
+		} else {
+			param.setCustNo(0);
+			param.setRegNo(0);
+			param.setUpdNo(0);
+		}
+
+		// 재고 체크
+		Goods goods = new Goods();
+		goods.setGoodsCd(param.getGoodsCd());
+		goods.setFrontGb(TsfSession.getFrontGb());
+
+		goods = goodsService.getGoodsInfo(goods);
+
+		if (goods == null) {
+			throw new IllegalArgumentException("상품 정보가 존재하지 않습니다.");
+		}
+		if (TscConstants.GoodsStat.SOLDOUT.value().equals(goods.getGoodsStat())) {
+			throw new IllegalArgumentException("품절입니다.");
+		}
+		
+		// 현재 장바구니 수량
+		int goodsCartCnt = cartDao.getHasGoodsCartCnt(param);
+
+		if (param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
+			throw new IllegalArgumentException("1일 구매한도 수량이 초과되었습니다.");
+		}
+
+		// 구성 상품 재고 확인
+		for(int i = 0 ; i < param.getCartDtlSqArr().length ; i++) {
+			// 상품 재고 확인
+			GoodsStock checkParam = new GoodsStock();
+			checkParam.setGoodsCd(param.getGoodsCd());
+			checkParam.setItemCd(param.getItemCds()[i]);
+			checkParam.setOptCd(param.getOptCds()[i]);
+			checkParam.setGoodsQty(param.getGoodsQty());
+			checkParam.setGoodsType(param.getGoodsType());
+			String stockResult = goodsService.getCheckStock(checkParam);
+
+			if (!"SUCCESS".equals(stockResult)) {
+				throw new IllegalArgumentException(stockResult);
+			}
+		}
+
+		StringBuilder sb = new StringBuilder();
+		if(TscConstants.GoodsType.SET.value().equals(param.getGoodsType())) {
+			// 장바구니 보유 CART_SQ 쿼리
+			for(int i = 0 ; i < param.getCartDtlSqArr().length ; i++) {
+				sb.append("SELECT CD.CART_SQ \n FROM TB_CART C \n INNER JOIN TB_CART_DETAIL CD \n ON C.CART_SQ = CD.CART_SQ \n WHERE C.CUST_NO = ");
+				// TODO 로그인 정보 확인
+				if (param.getCustNo() == 0) {
+					sb.append(param.getCustNo()).append("\n AND JSESSION_ID = '").append(param.getJsessionId()).append("'");
+				} else {
+					sb.append(param.getCustNo());
+				}
+				sb.append("\n AND CD.ITEM_CD = '").append(param.getItemCds()[i]).append("' \n AND CD.OPT_CD = '").append(param.getOptCds()[i]).append("'");
+				if (i < param.getCartDtlSqArr().length - 1) {
+					sb.append("\n UNION ALL \n");
+				}
+			}
+
+			param.setItemCdSql(sb.toString());
+			param.setCartGb(TscConstants.CartGb.CART.value());
+
+			// 장바구니내 같은 상품 확인
+			param.setNotCartSq(param.getCartSq());				// 수정 장바구니 번호 제외
+			Collection<Cart> cartList = cartDao.selectHasSetItemCartList(param);
+
+			// 동일 상품 존재시
+			if (cartList != null && cartList.size() > 0) {		// 장바구니 기존재
+				if (cartList.size() > 1) {						// 장바구니 조회 결과 이상시 insert or select 수정 필요
+					throw new IllegalArgumentException("장바구니 조회에 실패하였습니다. 관리자에게 문의해주세요.");
+				} else {
+					// 기존 존재 장바구니 UPDATE
+					Cart cart = new Cart();
+					cart.setCartSq(cartList.iterator().next().getCartSq());
+					cart.setGoodsQty(param.getGoodsQty());
+					cart.setAfLinkCd(param.getAfLinkCd());
+					cart.setIthrCd(param.getIthrCd());
+					cart.setContentsLoc(param.getContentsLoc());
+					cart.setPlanDtlSq(param.getPlanDtlSq());
+					cart.setUpdNo(param.getUpdNo());
+					cart.setGoodsCd(param.getGoodsCd());
+					cart.setCustNo(param.getCustNo());
+					cart.setRegNo(param.getRegNo());
+
+					cartDao.updateCartInfo(cart);               // 장바구니 정보 수정
+					cartDao.insertCartHst(cart);                // 장바구니 수정 이력 저장
+
+					// 장바구니 삭제
+					int[] cartSqArr = {param.getCartSq()};
+					param.setCartSqArr(cartSqArr);
+					cartDao.deleteCart(param);
+					cartDao.deleteCartDetail(param);
+				}
+			} else {		// 동일 상품 없을 시 UPDATE
+				cartDao.updateCart(param);						// 장바구니 마스터 정보 저장
+				cartDao.insertCartHst(param);                   // 장바구니 이력 정보 저장
+				for(int i = 0 ; i < param.getCartDtlSqArr().length ; i++) {
+					param.setItemCd(param.getItemCds()[i]);
+					param.setCartDtlSq(param.getCartDtlSqArr()[i]);
+					param.setOptCd(param.getOptCds()[i]);
+
+					cartDao.updateCartDetail(param);		// 장바구니 상세 저장
+					cartDao.insertCartDetailHst(param);         // 장바구니 상세 이력 저장
+				}
+			}
+		}
+	}
 }

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

@@ -221,7 +221,7 @@ public class TsfGoodsService {
 
 	/**
 	 * 상품 재고 체크
-	 * @param goodsStock
+	 * @param param
 	 * goodsCd   (원상품코드) 필수
 	 * goodsType (상품타입) 필수
 	 * optCd     (옵션코드) 필수
@@ -242,7 +242,7 @@ public class TsfGoodsService {
 		}
 
 		if(param.getGoodsType().equals(TscConstants.GoodsType.SET.value())) {		// 세트상품이면 구성 상품코드로 조회
-			GoodsStock stockCheck = new GoodsStock();		// 재고 조회 결과
+			GoodsStock stockCheck = new GoodsStock();								// 재고 조회 결과
 			stockCheck.setGoodsCd(param.getItemCd());
 			stockCheck.setOptCd(param.getOptCd());
 
@@ -260,7 +260,7 @@ public class TsfGoodsService {
 				return param.getItemCd() + "의 재고가 충분하지 않습니다.";
 			}
 		} else {
-			GoodsStock stockCheck = new GoodsStock();		// 재고 조회 결과
+			GoodsStock stockCheck = new GoodsStock();								// 재고 조회 결과
 			stockCheck.setGoodsCd(param.getGoodsCd());
 			stockCheck.setOptCd(param.getOptCd());
 

+ 17 - 5
src/main/java/com/style24/front/biz/web/TsfCartController.java

@@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
 
+import com.gagaframework.web.rest.server.GagaResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Controller;
@@ -162,8 +163,6 @@ public class TsfCartController extends TsfBaseController {
 	/**
 	 * 장바구니 삭제
 	 * @param param
-	 * rdCpnNm : 시리얼쿠폰명
-	 * cartSqArr[] : 장바구니 번호 배열
 	 * @return GagaMap
 	 * @author xodud1202
 	 * @since 2021. 02. 23
@@ -178,9 +177,7 @@ public class TsfCartController extends TsfBaseController {
 	/**
 	 * 장바구니 삭제
 	 * @param param
-	 * rdCpnNm : 시리얼쿠폰명
-	 * cartSqArr[] : 장바구니 번호 배열
-	 * @return GagaMap
+	 * @return String
 	 * @author xodud1202
 	 * @since 2021. 02. 23
 	 */
@@ -193,4 +190,19 @@ public class TsfCartController extends TsfBaseController {
 		model.addAttribute("setType", TscConstants.GoodsType.SET.value());
 		return super.getDeviceViewName("cart/cartChangeOptionPopup");
 	}
+
+	/**
+	 * 장바구니 옵션 변경
+	 * @param param
+	 * @return GagaMap
+	 * @author xodud1202
+	 * @since 2021. 02. 23
+	 */
+	@ResponseBody
+	@PostMapping("/change/option")
+	public GagaResponse updateCartOption(@RequestBody Cart param) {
+		log.info("CHECK INFO >> {} / {} / {} / {}", param.getCartSq(), param.getCartDtlSqArr().toString(), param.getOptCds().toString(), param.getGoodsQty());
+		cartService.updateCartOption(param);
+		return super.ok(message.getMessage("SUCC_0001"));
+	}
 }

+ 11 - 6
src/main/java/com/style24/persistence/domain/Cart.java

@@ -17,7 +17,10 @@ import lombok.Data;
 @Data
 public class Cart extends TscBaseDomain {
 	// 장바구니 정보
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private int[] cartSqArr;		// 장바구니 일련번호 배열 (일시품절제외 조회)
 	private int cartSq;				// 장바구니 번호
+	private int notCartSq;			// 제외 장바구니 번호
 	private int cartDtlSq;			// 장바구니 상세 번호
 	private int custNo;				// 고객번호
 	private int planDtlSq;			// 기획전상세번호
@@ -37,6 +40,12 @@ public class Cart extends TscBaseDomain {
 	private String cartColorNm;		// 장바구니 컬러명
 
 	// 장바구니 상세 정보
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private int[] cartDtlSqArr;		// 장바구니 일련번호 배열 (일시품절제외 조회)
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] optCds;		// 옵션코드
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] itemCds;		// 장바구니 단품코드
 	private String itemCd;			// 단품코드(상품). 일반상품과 딜상품은 상품코드와 동일
 	private String optCd;			// 옵션코드
 	private String optCd1;			// 옵션코드1
@@ -59,19 +68,15 @@ public class Cart extends TscBaseDomain {
 	private String colorNm;			// 컬러명
 	private String imgPath;			// 상품 이미지 경로
 	private String soldoutYn;		// 옵션
+	private String frontGb;			// 접속 디바이스 정보
 
+	// 장바구니 상품 정보 리스트
 	Collection<Cart> cartCompsList;		// 장바구니 상품 구성 상품리스트
 	Collection<Cart> cartColorList;		// 장바구니 상품 컬러리스트
 	Collection<Cart> cartSizeList;		// 장바구니 상품 사이즈리스트
 	Collection<GoodsImg> cartImgList;	// 장바구니 상품 이미지 리스트
 
-	// 다다익선 정보
-
-	// 즉시할인쿠폰 정보
-
 	// 시리얼쿠폰 정보
-	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
-	private int[] cartSqArr;		// 장바구니 일련번호 배열 (일시품절제외 조회)
 	private String cpnNm;
 	private String rdCpnNm;
 	private String usedDt;

+ 70 - 20
src/main/java/com/style24/persistence/mybatis/shop/TsfCart.xml

@@ -31,28 +31,35 @@
 		   AND C.CUST_NO = #{custNo}
 			</otherwise>
 		</choose>
+		<if test="cartSq != null and cartSq != 0">
+			AND C.CART_SQ <![CDATA[ <> ]]> #{cartSq}
+		</if>
 	</select>
 
 	<!-- 장바구니 등록 세트 상품 확인 -->
-	<select id="selectHasSetItemCartList" parameterType="Cart" resultType="int">
+	<select id="selectHasSetItemCartList" parameterType="Cart" resultType="Cart">
 		/* TsfCart.selectHasSetItemCartList : 장바구니 등록 세트 상품 확인 */
 		SELECT CART_SQ
-		  FROM (SELECT COUNT(1) AS CNT
+		FROM   (SELECT COUNT(1) AS CNT
 					 , CART_SQ
 					 , #{goodsCd} AS GOODS_CD
-				  FROM (
-					  ${itemCdSql}
+				FROM   (
+						${itemCdSql}
 					   ) A
-				 WHERE 1=1
-				 GROUP BY CART_SQ ) AS A
-		  INNER JOIN (SELECT GC.GOODS_CD
+				WHERE  1=1
+				GROUP  BY CART_SQ ) AS A
+		INNER  JOIN ( SELECT GC.GOODS_CD
 						   , COUNT(1) AS CNT
-						FROM TB_GOODS_COMPOSE GC
-					   WHERE GC.GOODS_CD = #{goodsCd}
-						 AND GC.USE_YN = 'Y'
-					   GROUP BY GC.GOODS_CD ) B
-			 ON A.GOODS_CD = B.GOODS_CD
-			AND A.CNT = B.CNT
+					  FROM   TB_GOODS_COMPOSE GC
+					  WHERE  GC.GOODS_CD = #{goodsCd}
+					  AND    GC.USE_YN = 'Y'
+					  GROUP  BY GC.GOODS_CD ) B
+		ON     A.GOODS_CD = B.GOODS_CD
+		AND    A.CNT = B.CNT
+		WHERE  1=1
+		<if test="notCartSq != null and notCartSq > 0">
+		AND    A.CART_SQ <![CDATA[ <> ]]> #{notCartSq}
+		</if>
 	</select>
 
 	<!-- 장바구니 등록 일반 or 딜 상품 확인 -->
@@ -156,9 +163,9 @@
 		 ORDER BY GC.DISP_ORD
 	</insert>
 
-	<!-- 장바구니 상세 UPDATE -->
+	<!-- 장바구니 UPDATE -->
 	<update id="updateCartInfo" parameterType="Cart">
-		/* TsfCart.updateCartInfo : 장바구니 상세 UPDATE */
+		/* TsfCart.updateCartInfo : 장바구니 UPDATE */
 		UPDATE TB_CART SET
 			  GOODS_QTY = GOODS_QTY + #{goodsQty}
 			, DEAL_GOODS_CD = #{dealGoodsCd}
@@ -169,8 +176,41 @@
 			, UPD_NO = #{updNo}
 			, UPD_DT = CURRENT_TIMESTAMP
 		WHERE CART_SQ = #{cartSq}
-		  AND GOODS_CD = #{goodsCd}
-		  AND CUST_NO = #{custNo}
+		AND   GOODS_CD = #{goodsCd}
+		AND   CUST_NO = #{custNo}
+	</update>
+
+	<!-- 장바구니 UPDATE -->
+	<update id="updateCart" parameterType="Cart">
+		/* TsfCart.updateCart : 장바구니 UPDATE */
+		UPDATE TB_CART SET
+			  GOODS_QTY = #{goodsQty}
+			, DEAL_GOODS_CD = #{dealGoodsCd}
+			, AF_LINK_CD = #{afLinkCd}
+			, ITHR_CD = #{ithrCd}
+			, CONTENTS_LOC = #{contentsLoc}
+			, PLAN_DTL_SQ = #{planDtlSq}
+			, UPD_NO = #{updNo}
+			, UPD_DT = CURRENT_TIMESTAMP
+		WHERE CART_SQ = #{cartSq}
+		AND   GOODS_CD = #{goodsCd}
+		AND   CUST_NO = #{custNo}
+	</update>
+
+	<!-- 장바구니 상세 UPDATE -->
+	<update id="updateCartDetail" parameterType="Cart">
+		/* TsfCart.updateCartDetail : 장바구니 상세 UPDATE */
+		UPDATE TB_CART_DETAIL A, (SELECT GOODS_CD, OPT_CD1, OPT_CD2, SKU_MODEL_NO, PRODUCT_NO, PRODUCT_CODE FROM TB_OPTION WHERE GOODS_CD = #{itemCd} AND OPT_CD = #{optCd}) B SET
+			  A.OPT_CD = #{optCd}
+			, A.OPT_CD1 = B.OPT_CD1
+			, A.OPT_CD2 = B.OPT_CD2
+			, A.SKU_MODEL_NO = B.SKU_MODEL_NO
+			, A.PRODUCT_NO = B.PRODUCT_NO
+			, A.PRODUCT_CODE = B.PRODUCT_CODE
+			, A.UPD_NO = #{updNo}
+			, A.UPD_DT = CURRENT_TIMESTAMP
+		WHERE A.CART_DTL_SQ = #{cartDtlSq}
+		  AND A.ITEM_CD = B.GOODS_CD
 	</update>
 
 	<!-- 장바구니 이력 정보 저장 -->
@@ -595,7 +635,7 @@
 			 , Z.OPT_ADD_PRICE
 			 , SYS_IMG_NM
 		ORDER  BY Z.DELV_FEE_CD
-			 , Z.CART_SQ
+			 , Z.CART_SQ DESC
 	</select>
 
 	<!-- 장바구니 업체별 배송비 -->
@@ -633,6 +673,16 @@
 			#{item}
 		</foreach>
 	</delete>
+
+	<!-- 장바구니 삭제 -->
+	<delete id="deleteCartDetail" parameterType="Cart">
+		<!-- TsfCart.deleteCartDetail : 장바구니 삭제 -->
+		DELETE FROM TB_CART_DETAIL
+		WHERE  CART_SQ IN
+		<foreach collection="cartSqArr" item="item" index="index"  open="(" close=")" separator=",">
+			#{item}
+		</foreach>
+	</delete>
 	
 	<!-- 장바구니담긴상품 고객번호 Update -->
 	<update id="updateCartOfCustNo" parameterType="Cart">
@@ -819,8 +869,8 @@
 			 , MAX(CD.CART_DTL_SQ) AS CART_DTL_SQ
 			 , MAX(ST.DISP_ORD) AS DISP_ORD
 			 , MAX(CD.OPT_CD1) AS CART_OPT_CD1
-			 , MAX(CASE WHEN SELF_GOODS_YN = 'Y' THEN (SELECT COLOR_KNM FROM TB_COLOR WHERE COLOR_CD = CD.OPT_CD1)
-						ELSE CD.OPT_CD1 END) AS CART_COLOR_NM
+			 , IFNULL(MAX( CASE WHEN SELF_GOODS_YN = 'Y' THEN (SELECT COLOR_KNM FROM TB_COLOR WHERE COLOR_CD = CD.OPT_CD1)
+								ELSE CD.OPT_CD1 END), MAX(CD.OPT_CD1)) AS CART_COLOR_NM
 		FROM   TB_GOODS G
 		INNER  JOIN VW_STOCK ST
 		ON     G.GOODS_CD = ST.GOODS_CD

+ 106 - 146
src/main/webapp/WEB-INF/views/web/cart/cartChangeOptionPopupWeb.html

@@ -1,7 +1,7 @@
 <html lang="ko"
 	  xmlns:th="http://www.thymeleaf.org">
 <!-- 옵션변경 팝업 -->
-<div class="modal-dialog" role="document">
+<div class="modal-dialog cartOptionModal" role="document">
 	<div class="modal-content">
 		<div class="modal-header">
 			<h5 class="modal-title" id="optModifyLabel">옵션변경</h5>
@@ -39,35 +39,38 @@
 							<th:block th:each="comp, status : ${cart.cartCompsList}">
 								<!-- 세트상품 옵션 -->
 								<th:block th:if="${setType.equals(cart.goodsType)}">
-									<div class="opt_select">
+									<div class="opt_select setOption">
 										<div class="opt_header">
 											<span class="title" th:text="${comp.goodsNm}"></span>
 										</div>
 
+										<!-- 컬러 변경시 만들어줄 size option -->
 										<th:block th:each="color, index : ${comp.cartColorList}">
-											<span th:classappend="|color_${color.goodsCd}_${color.optCd1}|" style="display:none;">
-												<select id="">
+											<span style="display:none;">
+												<select th:classappend="|color_${color.goodsCd}_${color.optCd1}|">
 													<th:block th:each="size, i : ${color.cartSizeList}">
 														<th:block th:if="${color.optCd1.equals(size.optCd1)}">
-															<option th:value="${size.optCd}" th:text="${size.optCd2}" th:selected="${color.cartColorNm != null}"></option>
+															<option th:value="${size.optCd}" th:text="${size.optCd2}"></option>
 														</th:block>
 													</th:block>
 												</select>
 											</span>
 										</th:block>
+
 										<div class="form_field">
-											<select id="">
+											<select class="setColorSelect">
+												<option th:data="${comp.goodsCd}" value="aa">TEST</option>
 												<th:block th:each="color, index : ${comp.cartColorList}">
-													<option th:value="${color.optCd1}" rel="icon-temperature" th:text="${color.colorNm}" th:selected="${color.cartColorNm != null}"></option>
+													<option th:data="${comp.goodsCd}" th:value="${color.optCd1}" rel="icon-temperature" th:text="${color.colorNm}" th:selected="${color.cartColorNm != null}"></option>
 												</th:block>
 											</select>
 										</div>
 										<div class="form_field">
 											<th:block th:each="color, index : ${comp.cartColorList}">
-											<select id="">
+											<select th:data="${color.goodsCd}" th:class="|size_${comp.goodsCd} setSizeSelect|">
 												<th:block th:each="size, i : ${color.cartSizeList}">
 													<th:block th:if="${color.optCd1.equals(size.optCd1)}">
-														<option th:value="${size.optCd}" th:text="${size.optCd2}" th:selected="${size.cartOptCd != null}"></option>
+														<option th:data="${comp.cartDtlSq}" th:value="${size.optCd}" th:text="${size.optCd2}" th:selected="${size.cartOptCd != null}"></option>
 													</th:block>
 												</th:block>
 											</select>
@@ -83,23 +86,24 @@
 											<span class="title">컬러</span>
 											<th:block th:each="color, index : ${comp.cartColorList}">
 												<th:block th:if="${color.cartColorNm != null}">
-											<span class="color" th:text="${color.cartColorNm}"></span>
+													<span class="color" th:text="${color.cartColorNm}"></span>
 												</th:block>
 											</th:block>
 										</div>
 										<ul>
-											<li th:each="color, index : ${comp.cartColorList}">
-												<a href="" th:classappend="${color.cartColorNm != null} ? 'on'">
+											<li th:each="color, index : ${comp.cartColorList}" class="selfGoodsColor">
+												<a href="" th:classappend="${color.cartColorNm != null} ? 'on'" class="selfGoodsColorSelect" th:data="${color.optCd1}">
 													<img th:src="${cart.imgPath + '/' + color.sysImgNm}" src="#" th:alt="${color.colorNm}" alt="" />
 												</a>
 											</li>
 										</ul>
 									</div>
+
 									<div class="opt_size">
 										<div class="opt_header">
 											<span class="title">사이즈</span>
 										</div>
-										<div class="form_field">
+										<div class="form_field selfGoodsSize">
 											<th:block th:each="color, index : ${comp.cartColorList}">
 												<th:block th:if="${color.cartColorNm != null}">
 													<th:block th:each="size, index : ${color.cartSizeList}">
@@ -110,10 +114,6 @@
 													</th:block>
 												</th:block>
 											</th:block>
-											<!--<div>
-												<input type="radio" name="rdi-optsize" id="rdi-optsize2" value="" disabled>
-												<label for="rdi-optsize2"><span>95</span></label>
-											</div>-->
 										</div>
 									</div>
 								</th:block>
@@ -140,7 +140,8 @@
 								</div>
 								<div class="number_count">
 									<span class="minus"><span class="sr-only">감소</span></span>
-									<input type="text" name="" maxlength="3" style='ime-mode:disabled' th:value="${cart.goodsQty}" />
+									<input type="text" name="goodsQty" maxlength="3" style='ime-mode:disabled' th:value="${cart.goodsQty}" />
+									<!-- <input type="text" name="goodsQty" maxlength="3" style='ime-mode:disabled' th:value="2" /> -->
 									<span class="plus"><span class="sr-only">추가</span></span>
 								</div>
 							</div>
@@ -152,135 +153,94 @@
 				</div>
 			</div>
 		</div>
-		<!--<th:block th:if="${cart.selfGoodsYn.equals('N')}">
-			<div class="modal-body">
-				<div class="pop_cont">
-					<div class="prod_info">
-						<div class="prod_preview">
-							<div class="area_pic">
-								<ul class="pic_list">
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail1.jpg" alt=""></span></li>
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail2.jpg" alt=""></span></li>
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail3.jpg" alt=""></span></li>
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail4.jpg" alt=""></span></li>
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail5.jpg" alt=""></span></li>
-									<li><span class="thumb"><img src="/images/pc/thumb/tmp_pdDetail6.jpg" alt=""></span></li>
-								</ul>
-							</div>
-							<div class="area_order">
-								<div class="opt_color">
-									<div class="opt_header">
-										<span class="title">컬러</span>
-										<span class="color">그레이</span>
-									</div>
-									<ul>
-										<li>
-											<a href="" class="on">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="그레이">
-											</a>
-										</li>
-										<li>
-											<a href="">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="베이지">
-											</a>
-										</li>
-										<li>
-											<a href="">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="그린">
-											</a>
-										</li>
-										<li>
-											<a href="">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="핑크">
-											</a>
-										</li>
-										<li>
-											<a href="">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="민트">
-											</a>
-										</li>
-										<li>
-											<a href="">
-												<img src="/images/pc/thumb/tmp_cartColor1.jpg" alt="블랙">
-											</a>
-										</li>
-									</ul>
-								</div>
-								<div class="opt_size">
-									<div class="opt_header">
-										<span class="title">사이즈</span>
-									</div>
-									<div class="form_field">
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize1" value="" checked="">
-											<label for="rdi-optsize1"><span>90</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize2" value="" disabled>
-											<label for="rdi-optsize2"><span>95</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize3" value="">
-											<label for="rdi-optsize3"><span>100</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize4" value="">
-											<label for="rdi-optsize4"><span>105</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize5" value="">
-											<label for="rdi-optsize5"><span>110</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize6" value="">
-											<label for="rdi-optsize6"><span>115</span></label>
-										</div>
-										<div>
-											<input type="radio" name="rdi-optsize" id="rdi-optsize7" value="">
-											<label for="rdi-optsize7"><span>free</span></label>
-										</div>
-									</div>
-								</div>
-								<div class="opt_select">
-									<div class="opt_header">
-										<span class="title">옵션선택</span>
-									</div>
-									<div class="form_field">
-										<select id="">
-											<option value="" rel="icon-temperature">카키/95</option>
-											<option value="">카키/100</option>
-											<option value="">카키/105</option>
-											<option value="">카키/110</option>
-											<option value="">옐로우/95</option>
-											<option value="">옐로우/100</option>
-											<option value="">옐로우/105</option>
-											<option value="">옐로우/110</option>
-										</select>
-									</div>
-								</div>
-								<div class="opt_count">
-									<div class="opt_header">
-										<span class="title">수량</span>
-									</div>
-									<div class="number_count">
-										<span class="minus"><span class="sr-only">감소</span></span>
-										<input type="text" name="" maxlength="3" style='ime-mode:disabled' value="1" />
-										<span class="plus"><span class="sr-only">추가</span></span>
-									</div>
-								</div>
-								<div class="btn_group_block">
-									<button class="btn btn_dark btn_block" id=""><span>옵션변경</span></button>
-								</div>
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-		</th:block>-->
+	</div>
+<!-- //옵션변경 팝업 -->
 
 
-	</div>
+<script th:inline="javascript">
+	$(document).ready(function() {
+
+	})
+
+	// 세트상품 컬러 변경시
+	$(".setColorSelect").on("change", function(e) {
+		let goodsCd = $(this).find("option:checked").attr("data");
+		$(".setOption .size_" + goodsCd).html("");
+		$(".setOption .size_" + goodsCd).html($(".color_" + goodsCd + "_" + $(this).val()).html());
+	});
+
+	// 자사 일반 상품 컬러 선택시
+	$(".selfGoodsColorSelect").on("click", function(e) {
+		let html = "";
+		let cart = [[${cart}]];
+		let color =  [[${cart.cartCompsList[0].cartColorList}]];
+		let optCd1 = $(this).attr("data");
+
+		for(let i = 0 ; i < color.length ; i++) {
+			let size = color[i].cartSizeList;
+			for(let j = 0 ; j < size.length ; j++) {
+				if(optCd1 == size[j].optCd1) {
+					html += "<div>";
+					html += "<input type='radio' name='rdi-optsize' id='" + size[j].goodsCd + "-" + size[j].optCd + "' value='" + size[j].optCd + "' ";
+					if(size[j].soldoutYn == "Y" || cart.goodsQty < size[j].currStockQty) {
+						html += "disabled = 'disabled'";
+					}
+					html += " />\n";
+					html += "<label for='" + size[j].goodsCd + "-" + size[j].optCd + "'><span>" + size[j].optCd2 + "</span></label>\n"
+					html += "</div>\n";
+				}
+			}
+		}
+
+		$(".selfGoodsSize").html(html);
+	});
+
+	function fnChangeCartOption(cartSq) {
+		let cart = [[${cart}]];
+		let cartDtlSqArr = [], itemCds = [], optCds = [];
+		let data;
+
+		if(cart.goodsType == "G056_S") {
+			$(".setSizeSelect").each(function() {
+				optCds.push($(this).val());
+				itemCds.push($(this).attr("data"));
+				cartDtlSqArr.push($(this).find("option:checked").attr("data"));
+			});
+
+			data = {
+				  cartSq : cart.cartSq
+				, goodsCd : cart.goodsCd
+				, goodsType : cart.goodsType
+				, cartDtlSqArr : cartDtlSqArr
+				, itemCds : itemCds
+				, optCds : optCds
+				, goodsQty : $("input[name=goodsQty]").val()
+			}
+		} else if(cart.goodsType != "G056_S" && cart.selfGoodsYn == "Y") {
+			alert("자사 일반");
+		} else {
+			alert("입점업체");
+		}
+
+		$.ajax( {
+			type: "POST",
+			url : '/cart/change/option',
+			contentType: 'application/json',
+			dataType : 'json',
+			data : JSON.stringify(data),
+			success : function(result) {
+				alert(result.message);
+				$(".closeCartOptionModal").trigger("click");
+				getCartList();
+			}
+		});
+	}
+
+	$(".closeCartOptionModal").on("click", function() {
+		$(".cartOptionModal").html("");
+	});
+</script>
+
 </div>
-<a href="#close-modal" rel="modal:close" class="close-modal ">Close</a>
-<!-- //옵션변경 팝업 -->
+<a href="#close-modal" rel="modal:close" class="close-modal closeCartOptionModal">Close</a>
 </html>

+ 33 - 34
src/main/webapp/WEB-INF/views/web/cart/cartListAjaxFormWeb.html

@@ -416,12 +416,13 @@
 		notApplyTmtbAreaList();
 
 		/* 세트상품 장바구니 */
-		/*let compsList = [];
+		/* let compsList = [];
 		let temp = new Object;
-		temp.goodsCd = "NWM01QTS59";
-		temp.optCd = "14159706-1";
-		temp.goodsQty = 9;
-		temp.goodsType = "G056_N";
+		temp.goodsCd = "STYS00000042";
+		temp.itemCd = "14373746";
+		temp.optCd = "베이지110";
+		temp.goodsQty = 1;
+		temp.goodsType = "G056_S";
 		temp.cartGb = "C";
 		temp.afLinkCd = "afLinkCd";
 		temp.ithrCd = "G027_ZZZ";
@@ -429,7 +430,31 @@
 		temp.planDtlSq = "123";
 		compsList.push(temp);
 
-		cfnAddCart(compsList);*/
+		temp.goodsCd = "STYS00000042";
+		temp.itemCd = "14373769";
+		temp.optCd = "블루110";
+		temp.goodsQty = 1;
+		temp.goodsType = "G056_S";
+		temp.cartGb = "C";
+		temp.afLinkCd = "afLinkCd";
+		temp.ithrCd = "G027_ZZZ";
+		temp.contentsLoc = "G028_YYY";
+		temp.planDtlSq = "123";
+		compsList.push(temp);
+
+		temp.goodsCd = "STYS00000042";
+		temp.itemCd = "14373770";
+		temp.optCd = "아이보리110";
+		temp.goodsQty = 1;
+		temp.goodsType = "G056_S";
+		temp.cartGb = "C";
+		temp.afLinkCd = "afLinkCd";
+		temp.ithrCd = "G027_ZZZ";
+		temp.contentsLoc = "G028_YYY";
+		temp.planDtlSq = "123";
+		compsList.push(temp);
+
+		cfnAddCart(compsList); */
 	});
 
 	function notApplyTmtbAreaList() {
@@ -627,7 +652,7 @@
 				}
 			}
 		});
-	};
+	}
 
 	//다다익선 적용내역 보기
 	$(document).on('click','.shopping_bag .part_deliver .btn_moresale',function(e){
@@ -911,35 +936,9 @@
 			success : function(result) {
 				//fnChangeCartListInfo(result);
 				$("#optModifyPop").html(result);
+				$("#optModifyPop").modal("show");
 			}
 		});
-
-		$("#optModifyPop").modal("show");
-		return false;
 	}
-
-	//상품옵션변경 팝업 > 수량조절
-	$(document).on('click','.opt_modify_pop .number_count .minus',function(e){
-		var $input = $(this).parent().find('input');
-		var count = parseInt($input.val()) - 1;
-		count = count < 1 ? 1 : count;
-		$input.val(count);
-		$input.change();
-		return false;
-	}).on('click','.opt_modify_pop .number_count .plus',function(e){
-		var $input = $(this).parent().find('input');
-		$input.val(parseInt($input.val()) + 1);
-		$input.change();
-		return false;
-	});
-
-	//상품옵션변경 팝업 > 컬러선택 표기
-	$(document).on('click','.opt_modify_pop .opt_color ul li a',function(e){
-		$(this).parents('.opt_color').find('li a').removeClass('on');
-		$(this).addClass('on');
-		var optColor = $(this).find("img").attr('alt');
-		$(this).parent().parent().parent().find(".color").text(optColor);
-		return false;
-	});
 </script>
 </html>

+ 22 - 5
src/main/webapp/WEB-INF/views/web/cart/cartListFormWeb.html

@@ -275,8 +275,6 @@
 <link rel="stylesheet" type="text/css" href="/ux/pc/css/swiper.min.css" />
 
 <script type="text/javascript">
-    /* xodud1202 수정 */
-
     $(document).ready(function() {
         // 장바구니 상품 정보 select
         getCartList();
@@ -296,10 +294,29 @@
         });
     }
 
-    /* // xodud1202 수정 */
-
-
+    //상품옵션변경 팝업 > 수량조절
+    $(document).on('click','.opt_modify_pop .number_count .minus',function(e){
+        var $input = $(this).parent().find('input');
+        var count = parseInt($input.val()) - 1;
+        count = count < 1 ? 1 : count;
+        $input.val(count);
+        $input.change();
+        return false;
+    }).on('click','.opt_modify_pop .number_count .plus',function(e){
+        var $input = $(this).parent().find('input');
+        $input.val(parseInt($input.val()) + 1);
+        $input.change();
+        return false;
+    });
 
+    //상품옵션변경 팝업 > 컬러선택 표기
+    $(document).on('click','.opt_modify_pop .opt_color ul li a',function(e){
+        $(this).parents('.opt_color').find('li a').removeClass('on');
+        $(this).addClass('on');
+        var optColor = $(this).find("img").attr('alt');
+        $(this).parent().parent().parent().find(".color").text(optColor);
+        return false;
+    });
 
     $(function(){
         //추천상품 슬라이드