Prechádzať zdrojové kódy

이태영 - 20210205 장바구니 화면 로직 수정 중

xodud1202 5 rokov pred
rodič
commit
1500bebc5f

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

@@ -95,7 +95,7 @@ public interface TsfCartDao {
      * @author xodud1202
      * @since 2021. 02. 04
      */
-    Collection<Order> selectMoreBetterBaseCartList(Order param);
+    Collection<Order> selectMoreBetterApplyCartList(Order param);
 
    /**
     * 다다익선 적용 상품 SUM DATA 조회
@@ -104,7 +104,7 @@ public interface TsfCartDao {
     * @author xodud1202
     * @since 2021. 02. 04
     */
-   Collection<Order> selectApplyMoreBetterCartInfoList(List<Integer> param);
+   Collection<Order> selectApplyMoreBetterCartInfoList(Order param);
 
     /**
      * 다다익선 SECTION 적용 조건 조회

+ 113 - 53
src/main/java/com/style24/front/biz/service/TsfCartService.java

@@ -67,11 +67,8 @@ public class TsfCartService {
 			if (goods == null) {
 				throw new IllegalArgumentException("상품 정보가 존재하지 않습니다.");
 			}
-
-			cart.setGoodsCd(param.getGoodsCd());
-			int goodsCartCnt = cartDao.getHasGoodsCartCnt(param);
-			if(param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
-				throw new IllegalArgumentException("1일 구매한도 수량이 초과되었습니다.");
+			if(TscConstants.GoodsStat.SOLDOUT.value().equals(goods.getGoodsStat())) {
+				throw new IllegalArgumentException("품절입니다.");
 			}
 
 			// 상품 재고 확인
@@ -87,6 +84,12 @@ public class TsfCartService {
 				throw new IllegalArgumentException(stockResult);
 			}
 
+			cart.setGoodsCd(param.getGoodsCd());
+			int goodsCartCnt = cartDao.getHasGoodsCartCnt(param);
+			if(param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
+				throw new IllegalArgumentException("1일 구매한도 수량이 초과되었습니다.");
+			}
+
 			cart = param;
 		}
 
@@ -218,13 +221,16 @@ public class TsfCartService {
 	}
 
 	public GagaMap selecCartGoodsList() {
-		GagaMap result = new GagaMap();
+		GagaMap result = new GagaMap();							// return
+		List<Integer> cartSqs = new ArrayList<Integer>();		// 품절 제외 장바구니 리스트
+		Order order = new Order();								// 조회 조건
 
-		Order order = new Order();
+		// Device check
+		order.setFrontGb(TsfSession.getFrontGb());
 
 		// TODO 로그인 체크
+		order.setJsessionId(TscSession.getSessionId());
 		order.setJsessionId("aaec62cc-5f91-47bb-ba65-ebc9a61385cf");
-		//order.setJsessionId(TscSession.getSessionId());
 		order.setCustNo(0);
 		order.setRegNo(0);
 		order.setUpdNo(0);
@@ -232,80 +238,134 @@ public class TsfCartService {
 		// 장바구니 상품 조회
 		Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(order);
 
-		// 즉시할인쿠폰 적용가 조회
-		List<Integer> cartSqArr2 = new ArrayList<Integer>();
-		for(Order temp : cartGoodsList) {
-			cartSqArr2.add(temp.getCartSq());
+		// 품절체크
+		for(Order goods : cartGoodsList) {
+			// 상품 재고 확인
+			GoodsStock checkParam = new GoodsStock();
+			checkParam.setGoodsCd(goods.getGoodsCd());
+			checkParam.setItemCd(goods.getItemCd());
+			checkParam.setOptCd(goods.getOptCd());
+			checkParam.setGoodsQty(goods.getGoodsQty());
+			checkParam.setGoodsType(goods.getGoodsType());
+			String stockResult = goodsService.getCheckStock(checkParam);
+
+			if("SUCCESS".equals(stockResult)) {
+				goods.setSoldoutYn("N");
+				cartSqs.add(goods.getCartSq());
+			} else {
+				goods.setSoldoutYn("Y");
+			}
 		}
-		order.setCartSqArr(cartSqArr2.stream().mapToInt(Integer::intValue).toArray());
 
-		// 즉시 할인가 조회
-		Collection<Order> cpn1ApplyGoodsList = coreOrderService.getCpn1ApplyGoodsList(order);
+		order.setCartSqs(cartSqs.stream().mapToInt(Integer::intValue).toArray());
 
-		// 즉시 할인가 적용 금액 // pcCurrPrice
-		for(Order goods : cartGoodsList) {
-			for(Order amt : cpn1ApplyGoodsList) {
-				if(goods.getGoodsCd().equals(amt.getGoodsCd())) {
-					goods.setPcCurrPrice(amt.getPcCurrPrice());		// 즉시할인금액
-					// TODO 모바일 금액 추가 필요
+		// 다다익선 할인 상품 조회
+		Collection<Order> moreBetterAmtList = selecMoreBetterAmtList(order);
+
+		result.put("cartGoodsList", cartGoodsList);
+
+		return result;
+	}
+
+	/**
+	 * 다다익선 할인 금액 조회
+	 * @param Order
+	 * param.cartSqs[] : 필수
+	 * @return String
+	 * @author xodud1202
+	 * @since 2021. 01. 28
+	 */
+	public Collection<Order> selecMoreBetterAmtList(Order param) {
+		Collection<Order> result = new ArrayList<Order>();
+
+		// 장바구니 상품 조회
+		param.setFrontGb(TsfSession.getFrontGb());
+		Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(param);
+
+		// 장바구니 내 적용 가능 다다익선 조회 (등록된 기본,적용 상품 정보 전체 조회)
+		Collection<Order> tmtbApplyList = cartDao.selectMoreBetterApplyCartList(param);
+
+		// 장바구니에 담긴 상품 금액 (즉시할인가 + 상품 옵션가)를 tmtbApplyList 에 저장 (추후 계산식을 위함)
+		for(Order cart : cartGoodsList) {
+			for(Order apply : tmtbApplyList) {
+				if(cart.getCartSq() == apply.getCartSq() && TscConstants.GoodsType.SET.value().equals(cart.getGoodsType())) {
+					apply.setCurrPrice(cart.getCurrPrice());
+				} else if(cart.getCartSq() == apply.getCartSq() && !TscConstants.GoodsType.SET.value().equals(cart.getGoodsType())) {
+					apply.setCurrPrice(cart.getCurrPrice() + cart.getOptAddPrice());
 				}
 			}
 		}
 
-		// 장바구니 내 적용 가능 다다익선 조회 (등록된 기본 상품 정보 조회)
-		Collection<Order> tmtbBaseList = cartDao.selectMoreBetterBaseCartList(order);
-
-		// 기본 상품이 등록된 장바구니의 다다익선 정보 지정
-		List<Integer> baseSq = new ArrayList<Integer>();
-		for(Order tmtbBase : tmtbBaseList) {
-			baseSq.add(tmtbBase.getTmtbSq());
+		// 장바구니 등록 다다익선 일련번호 지정
+		List<Integer> applySq = new ArrayList<Integer>();
+		for(Order tmtbApply : tmtbApplyList) {
+			if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getGoodsGb())) {
+				applySq.add(tmtbApply.getTmtbSq());
+			}
 		}
+		param.setTmtbSqs(applySq.stream().mapToInt(Integer::intValue).toArray());
 
-		// 기본 상품이 걸려있는 다다익선별 총합 데이터 조회
-		Collection<Order> tmtbSumDataList = cartDao.selectApplyMoreBetterCartInfoList(baseSq);
+		// 장바구니 등록 다다익선 총합 금액
+		Collection<Order> tmtbSumDataList = cartDao.selectApplyMoreBetterCartInfoList(param);
 		// 기본상품 목록에 총합 데이터 등록
-		for(Order baseInfo : tmtbBaseList) {
+		for(Order applyInfo : tmtbApplyList) {
 			for(Order tmtbSumInfo : tmtbSumDataList) {
-				if(baseInfo.getTmtbSq() == tmtbSumInfo.getTmtbSq()) {
-					baseInfo.setTmtbSumAmt(tmtbSumInfo.getTmtbSumAmt());
-					baseInfo.setTmtbSumQty(tmtbSumInfo.getTmtbSumQty());
+				if(applyInfo.getTmtbSq() == tmtbSumInfo.getTmtbSq()) {
+					applyInfo.setTmtbSumAmt(tmtbSumInfo.getTmtbSumAmt());
+					applyInfo.setTmtbSumQty(tmtbSumInfo.getTmtbSumQty());
 				}
 			}
 		}
 
 		// 섹션 정보 조회 후 할인 여부 판단
-		Collection<Order> tmtbSectionList = cartDao.selectTmtbSectionValList(baseSq);
-		for(Order baseInfo : tmtbBaseList) {						// 기준 상품 및 다다익선 정보 조회
+		Collection<Order> tmtbSectionList = cartDao.selectTmtbSectionValList(applySq);
+		for(Order applyInfo : tmtbApplyList) {						// 기준 상품 및 다다익선 정보 조회
 			for(Order section : tmtbSectionList) {					// 다다익선 할인 조건 조회
-				if(baseInfo.getTmtbSq() == section.getTmtbSq()) {
-					if(TscConstants.ApplyGb.QTY.value().equals(baseInfo.getApplyGb())) {		// 수량 적용
-						if(section.getSectionVal() < baseInfo.getTmtbSumQty()) {				// 장바구니 수량 할인 기준 달성시
-							if(baseInfo.getApplyQtySectionVal() < section.getSectionVal()) {	// 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
-								baseInfo.setApplyQtySectionVal(section.getSectionVal());
-								baseInfo.setApplyQtySectionYn("Y");
+				if(applyInfo.getTmtbSq() == section.getTmtbSq()) {
+					applyInfo.setTmtbNm(section.getTmtbNm());
+
+					if(TscConstants.ApplyGb.QTY.value().equals(applyInfo.getApplyGb())) {		// 수량 적용
+						if(section.getSectionVal() < applyInfo.getTmtbSumQty()) {				// 장바구니 수량 할인 기준 달성시
+							if(applyInfo.getSectionVal() < section.getSectionVal()) {			// 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
+								applyInfo.setSectionVal(section.getSectionVal());
+								applyInfo.setApplyQtySectionVal(section.getTmtbSumQty());
+								applyInfo.setApplyAmtSectionVal(section.getTmtbSumAmt());
+								applyInfo.setApplyQtySectionYn("Y");
 							}
-						} else {
-							baseInfo.setApplyQtySectionYn("N");
 						}
-					} else if (TscConstants.ApplyGb.AMT.value().equals(baseInfo.getApplyGb())) {
-						if(section.getSectionVal() < baseInfo.getTmtbSumQty()) {				// 장바구니 수량 할인 기준 달성시
-							if(baseInfo.getApplyAmtSectionVal() < section.getSectionVal()) {	// 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
-								baseInfo.setApplyAmtSectionVal(section.getSectionVal());
-								baseInfo.setApplyAmtSectionYn("Y");
+					} else if (TscConstants.ApplyGb.AMT.value().equals(applyInfo.getApplyGb())) {
+						if(section.getSectionVal() < applyInfo.getTmtbSumQty()) {				// 장바구니 수량 할인 기준 달성시
+							if(applyInfo.getSectionVal() < section.getSectionVal()) {	// 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
+								applyInfo.setSectionVal(section.getSectionVal());
+								applyInfo.setApplyAmtSectionVal(section.getSectionVal());
+								applyInfo.setApplyAmtSectionYn("Y");
 							}
-						} else {
-							baseInfo.setApplyAmtSectionYn("N");
 						}
 					}
 				}
 			}
 		}
 
-		// 다다익선 할인 상품 조회 (적용상품까지 모두 화면에 노출되어야함)
+		// 다다익선 적용 상품 할인 금액 계산
+		// resultAmt.currPrice = 즉시할인 + 옵션가 (수량계산안한값)
+		// resultAmt.getApplyAmtSectionVal = 다다익선 등록 상품 총합계금액 (수량, 금액 모두 들어있음)
+		// resultAmt.getApplyQtySectionVal = 다다익선 등록 상품 총합계수량 (수량만)
+		// resultAmt.getApplyAmtSectionYn() = 다다익선 금액할인 만족 여부
+		// resultAmt.getApplyQtySectionYn() = 다다익선 수량할인 만족 여부
+		for(Order resultAmt : tmtbApplyList) {
+			if("Y".equals(resultAmt.getApplyQtySectionYn())) {
+				if(TscConstants.DcWay.AMT.value().equals(resultAmt.getDcWay())) {		// 할인 방식 금액일경우
 
+				} else {		// 할인 방식 할인율일 경우
 
+				}
+			}
+
+		}
+
+		// 할인 cartGoodsList에 할인 금액 세팅
+		// 장바구니 등록 상품 중 tmtbSq는 이제 존재하나 setApplyAmtSectionYn가 없는 경우 N으로 등록해주어야함 >> 장바구니 화면에서 추천상품 보여주기 위함
 
-		result.put("cartGoodsList", cartGoodsList);
 
 		return result;
 	}

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

@@ -69,6 +69,15 @@ public class TsfGoodsService {
 	 * @since 2021. 01. 28
 	 */
 	public String getCheckStock(GoodsStock param) {
+		// 상품 마스터 정보 확인
+		Goods goodsInfo = new Goods();
+		goodsInfo.setGoodsCd(param.getGoodsCd());
+		goodsInfo = getGoodsInfo(goodsInfo);
+
+		if(TscConstants.GoodsStat.SOLDOUT.value().equals(goodsInfo.getGoodsStat())) {
+			return param.getGoodsCd() + "는 품절 상품입니다.";
+		}
+
 		if(param.getGoodsType().equals(TscConstants.GoodsType.SET.value())) {		// 세트상품이면 구성 상품코드로 조회
 			GoodsStock stockCheck = new GoodsStock();		// 재고 조회 결과
 			stockCheck.setGoodsCd(param.getItemCd());
@@ -83,10 +92,6 @@ public class TsfGoodsService {
 
 			compsInfo = goodsDao.getGoodsCompsInfo(compsInfo);						// 구성상품 정보 조회
 
-			log.info("CHECK param.getGoodsQty() INFO >> " + param.getGoodsQty());
-			log.info("CHECK compsInfo.getQty() INFO >> " + compsInfo.getQty());
-			log.info("CHECK stockCheck.getCurrStockQty() INFO >> " + stockCheck.getCurrStockQty());
-
 			// 재고 체크
 			if(param.getGoodsQty() * compsInfo.getQty() > stockCheck.getCurrStockQty()) {
 				return param.getItemCd() + "의 재고가 충분하지 않습니다.";

+ 1 - 0
src/main/java/com/style24/persistence/domain/Goods.java

@@ -21,6 +21,7 @@ public class Goods extends TscBaseDomain {
 	private String compsGoodsCd;	// 세트 구성품 상품번호
 	private String optCd;			// 옵션코드
 	private String optCd1;			// 옵션코드1
+	private String goodsStat;		// 상품 상태(공통코드G008)
 	private int dayMaxOrdQty;		// 일일 최대 구매 수량
 	private int qty;				// 세트 상품 구성 수량
 }

+ 25 - 9
src/main/java/com/style24/persistence/mybatis/shop/TsfCart.xml

@@ -248,13 +248,15 @@
 	</insert>
 
 	<!-- 다다익선 기본 상품 조회 -->
-	<select id="selectMoreBetterBaseCartList" parameterType="Order" resultType="Order">
-		/* TsfCart.selectMoreBetterBaseCartList : 다다익선 기본 상품 조회 */
+	<select id="selectMoreBetterApplyCartList" parameterType="Order" resultType="Order">
+		/* TsfCart.selectMoreBetterApplyCartList : 다다익선 기본 상품 조회 */
 		SELECT C.CART_SQ
 			 , T.TMTB_SQ
 			 , T.APPLY_GB
 		     , TAG.GOODS_CD
+		     , TAG.GOODS_GB
 			 , T.TMTB_NM
+			 , C.GOODS_QTY
 		FROM   TB_CART C
 		INNER  JOIN TB_TMTB_APPLY_GOODS TAG
 		ON	   C.GOODS_CD = TAG.GOODS_CD
@@ -272,17 +274,22 @@
 		AND    NOT_APPLY.TMTB_SQ IS NULL
 		AND    T.TMTB_ST_DT <![CDATA[<=]]> NOW()
 		AND    T.TMTB_ED_DT >= NOW()
-		AND    C.JSESSION_ID = 'aaec62cc-5f91-47bb-ba65-ebc9a61385cf'
 		AND    C.CART_GB = 'G026_BC'
 		AND    G.GOODS_STAT = 'G008_90'
 		AND    G.SELF_MALL_YN = 'Y'
+		<if test="cartSqs != null and cartSqs.length > 0">
+		AND   C.CART_SQ IN
+			<foreach collection="cartSqs" item="item" index="index"  open="(" close=")" separator=",">
+				#{item}
+			</foreach>
+		</if>
 	</select>
 
 	<!-- 다다익선 적용 상품 SUM DATA 조회 -->
-	<select id="selectApplyMoreBetterCartInfoList" parameterType="int" resultType="Order">
+	<select id="selectApplyMoreBetterCartInfoList" parameterType="Order" resultType="Order">
 		/* TsfCart.selectApplyMoreBetterCartInfoList : 다다익선 적용 상품 SUM DATA 조회 */
 		SELECT TAG.TMTB_SQ
-			 , SUM(G.CURR_PRICE * C.GOODS_QTY) AS TMTB_SUM_AMT
+			 , SUM(FN_GET_APPLY_CPN1_PRICE(CA.GOODS_CD, #{frontGb}) * C.GOODS_QTY) AS TMTB_SUM_AMT
 			 , SUM(C.GOODS_QTY) AS TMTB_SUM_QTY
 		FROM   TB_TMTB_APPLY_GOODS TAG
 		INNER  JOIN TB_CART C
@@ -295,13 +302,19 @@
 		WHERE  1=1
 		AND    NOT_APPLY.TMTB_SQ IS NULL
 		AND    TAG.DEL_YN = 'N'
-		AND    C.JSESSION_ID = 'aaec62cc-5f91-47bb-ba65-ebc9a61385cf'
+		AND    C.JSESSION_ID = #{jsessionId}
 		AND    C.CART_GB = 'G026_BC'
 		AND    G.GOODS_STAT = 'G008_90'
 		AND    G.SELF_MALL_YN = 'Y'
-		<if test="list != null and list.size() > 0">
+		<if test="tmtbSqs != null and tmtbSqs.length > 0">
 		AND    TAG.TMTB_SQ IN
-			<foreach collection="list" item="item" index="index"  open="(" close=")" separator=",">
+			<foreach collection="tmtbSqs" item="item" index="index"  open="(" close=")" separator=",">
+				#{item}
+			</foreach>
+		</if>
+		<if test="cartSqs != null and cartSqs.length > 0">
+		AND    C.CART_SQ IN
+			<foreach collection="cartSqs" item="item" index="index"  open="(" close=")" separator=",">
 				#{item}
 			</foreach>
 		</if>
@@ -324,7 +337,7 @@
 		WHERE  1=1
 		AND    NOT_APPLY.TMTB_SQ IS NULL
 		AND    TAG.DEL_YN = 'N'
-		AND    C.JSESSION_ID = 'aaec62cc-5f91-47bb-ba65-ebc9a61385cf'
+		AND    C.JSESSION_ID = #{jsessionId}
 		AND    C.CART_GB = 'G026_BC'
 		AND    G.GOODS_STAT = 'G008_90'
 		AND    G.SELF_MALL_YN = 'Y'
@@ -342,7 +355,10 @@
 		SELECT TC.SECTION_GB
 			 , TC.SECTION_VAL
 			 , TC.TMTB_SQ
+			 , TV.
 		FROM   TB_TMTB_SECTION TC
+		INNER  JOIN TB_TMTB_VAL TV
+		ON     TC.TMTB_SECTION_SQ = TV.TMTB_SECTION_SQ
 		WHERE  1=1
 		AND    TC.DEL_YN = 'N'
 		<if test="list != null and list.size() > 0">

+ 6 - 4
src/main/java/com/style24/persistence/mybatis/shop/TsfGoods.xml

@@ -24,9 +24,10 @@
 		     , G.PRODUCT_CODE
 			 , G.GOODS_TYPE
 			 , G.DAY_MAX_ORD_QTY
+			 , G.GOODS_STAT
 		  FROM TB_GOODS G
-		 WHERE G.SELF_MALL_YN = 'Y'			<!-- 자사몰 노출 여부 -->
-		   AND G.GOODS_STAT = 'G008_90'		<!-- 상품 승인완료 -->
+		 WHERE G.SELF_MALL_YN = 'Y'							<!-- 자사몰 노출 여부 -->
+		   AND G.GOODS_STAT IN ('G008_90', 'G008_70')		<!-- 상품 승인완료, 일시품절 (품절도 프론트에서 보여져야함) -->
 		   AND G.GOODS_CD = #{goodsCd}
 	</select>
 
@@ -39,12 +40,13 @@
 			 , GC.QTY
 		     , G.PRODUCT_NO
 			 , G.PRODUCT_CODE
+			 , G.GOODS_STAT
 		  FROM TB_GOODS_COMPOSE GC
 		 INNER JOIN TB_GOODS G
 		    ON GC.COMPS_GOODS_CD = G.GOODS_CD
 		 WHERE GC.USE_YN = 'Y'
-		   AND G.SELF_MALL_YN = 'Y'			<!-- 자사몰 노출 여부 -->
-		   AND G.GOODS_STAT = 'G008_90'		<!-- 상품 승인완료 -->
+		   AND G.SELF_MALL_YN = 'Y'							<!-- 자사몰 노출 여부 -->
+		   AND G.GOODS_STAT IN ('G008_90', 'G008_70')		<!-- 상품 승인완료, 일시품절 (품절도 프론트에서 보여져야함) -->
 		   AND GC.GOODS_TYPE = #{goodsType}
 		   AND GC.GOODS_CD = #{goodsCd}
 		   AND GC.COMPS_GOODS_CD = #{compsGoodsCd}