|
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
@@ -220,7 +221,9 @@ public class TsfCartService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 장바구니 상품 리스트 조회 서비스
|
|
|
public GagaMap getCartGoodsList() {
|
|
public GagaMap getCartGoodsList() {
|
|
|
|
|
+ //ModelAndView result = new ModelAndView();
|
|
|
GagaMap result = new GagaMap(); // return
|
|
GagaMap result = new GagaMap(); // return
|
|
|
List<Integer> cartSqs = new ArrayList<Integer>(); // 품절 제외 장바구니 리스트
|
|
List<Integer> cartSqs = new ArrayList<Integer>(); // 품절 제외 장바구니 리스트
|
|
|
Order order = new Order(); // 조회 조건
|
|
Order order = new Order(); // 조회 조건
|
|
@@ -236,7 +239,7 @@ public class TsfCartService {
|
|
|
order.setUpdNo(0);
|
|
order.setUpdNo(0);
|
|
|
|
|
|
|
|
// 장바구니 상품 조회
|
|
// 장바구니 상품 조회
|
|
|
- Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(order);
|
|
|
|
|
|
|
+ Collection<Order> cartGoodsList = cartDao.getCartGoodsList(order);
|
|
|
|
|
|
|
|
// 품절체크
|
|
// 품절체크
|
|
|
for(Order goods : cartGoodsList) {
|
|
for(Order goods : cartGoodsList) {
|
|
@@ -257,12 +260,25 @@ public class TsfCartService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- order.setCartSqs(cartSqs.stream().mapToInt(Integer::intValue).toArray());
|
|
|
|
|
|
|
+ order.setCartSqArr(cartSqs.stream().mapToInt(Integer::intValue).toArray());
|
|
|
|
|
|
|
|
// 다다익선 할인 상품 조회
|
|
// 다다익선 할인 상품 조회
|
|
|
Collection<Order> moreBetterAmtList = getMoreBetterAmtList(order);
|
|
Collection<Order> moreBetterAmtList = getMoreBetterAmtList(order);
|
|
|
|
|
+ for(Order cart : moreBetterAmtList) {
|
|
|
|
|
+ if(cart.getItemNm().contains("!@!")) {
|
|
|
|
|
+ cart.setItemNmArr(cart.getItemNm().split("!@!"));
|
|
|
|
|
+ cart.setOptCdArr(cart.getOptCd().split(","));
|
|
|
|
|
+ cart.setItemQtyArr(cart.getItemQtyr().split(","));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String[] arr = {cart.getItemNm()}, arr2 = {cart.getOptCd()},arr3 = {cart.getItemQtyr()};
|
|
|
|
|
+ cart.setItemNmArr(arr);
|
|
|
|
|
+ cart.setOptCdArr(arr2);
|
|
|
|
|
+ cart.setItemQtyArr(arr3);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- result.put("cartGoodsList", cartGoodsList);
|
|
|
|
|
|
|
+ result.put("cartList", moreBetterAmtList);
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -270,13 +286,13 @@ public class TsfCartService {
|
|
|
/**
|
|
/**
|
|
|
* 다다익선 할인 금액 조회
|
|
* 다다익선 할인 금액 조회
|
|
|
* @param Order
|
|
* @param Order
|
|
|
- * param.cartSqs[] : 필수
|
|
|
|
|
|
|
+ * param.cartSqArr[] : 필수
|
|
|
* @return String
|
|
* @return String
|
|
|
* @author xodud1202
|
|
* @author xodud1202
|
|
|
* @since 2021. 01. 28
|
|
* @since 2021. 01. 28
|
|
|
*/
|
|
*/
|
|
|
public Collection<Order> getMoreBetterAmtList(Order param) {
|
|
public Collection<Order> getMoreBetterAmtList(Order param) {
|
|
|
- Collection<Order> result = new ArrayList<Order>();
|
|
|
|
|
|
|
+ //Collection<Order> result = new ArrayList<Order>();
|
|
|
|
|
|
|
|
// 장바구니 상품 조회
|
|
// 장바구니 상품 조회
|
|
|
param.setFrontGb(TsfSession.getFrontGb());
|
|
param.setFrontGb(TsfSession.getFrontGb());
|
|
@@ -327,8 +343,8 @@ public class TsfCartService {
|
|
|
applyInfo.setTmtbNm(section.getTmtbNm());
|
|
applyInfo.setTmtbNm(section.getTmtbNm());
|
|
|
|
|
|
|
|
if(TscConstants.ApplyGb.QTY.value().equals(applyInfo.getApplyGb())) { // 수량 적용
|
|
if(TscConstants.ApplyGb.QTY.value().equals(applyInfo.getApplyGb())) { // 수량 적용
|
|
|
- if(section.getSectionVal() < applyInfo.getTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
|
|
- if(applyInfo.getSectionVal() < section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
|
|
|
|
+ if(section.getSectionVal() <= applyInfo.getTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
|
|
+ if(applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
applyInfo.setSectionVal(section.getSectionVal());
|
|
applyInfo.setSectionVal(section.getSectionVal());
|
|
|
applyInfo.setApplyQtySectionVal(section.getTmtbSumQty());
|
|
applyInfo.setApplyQtySectionVal(section.getTmtbSumQty());
|
|
|
applyInfo.setApplyAmtSectionVal(section.getTmtbSumAmt());
|
|
applyInfo.setApplyAmtSectionVal(section.getTmtbSumAmt());
|
|
@@ -336,16 +352,24 @@ public class TsfCartService {
|
|
|
applyInfo.setDcWay(section.getDcWay());
|
|
applyInfo.setDcWay(section.getDcWay());
|
|
|
applyInfo.setDcVal(section.getDcVal());
|
|
applyInfo.setDcVal(section.getDcVal());
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(applyInfo.getGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
|
|
+ applyInfo.setApplyQtySectionYn("N");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else if (TscConstants.ApplyGb.AMT.value().equals(applyInfo.getApplyGb())) {
|
|
} else if (TscConstants.ApplyGb.AMT.value().equals(applyInfo.getApplyGb())) {
|
|
|
- if(section.getSectionVal() < applyInfo.getTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
|
|
- if(applyInfo.getSectionVal() < section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
|
|
|
|
+ if(section.getSectionVal() <= applyInfo.getTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
|
|
+ if(applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
applyInfo.setSectionVal(section.getSectionVal());
|
|
applyInfo.setSectionVal(section.getSectionVal());
|
|
|
applyInfo.setApplyAmtSectionVal(section.getSectionVal());
|
|
applyInfo.setApplyAmtSectionVal(section.getSectionVal());
|
|
|
applyInfo.setApplyAmtSectionYn("Y");
|
|
applyInfo.setApplyAmtSectionYn("Y");
|
|
|
applyInfo.setDcWay(section.getDcWay());
|
|
applyInfo.setDcWay(section.getDcWay());
|
|
|
applyInfo.setDcVal(section.getDcVal());
|
|
applyInfo.setDcVal(section.getDcVal());
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(applyInfo.getGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
|
|
+ applyInfo.setApplyQtySectionYn("N");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -363,8 +387,8 @@ public class TsfCartService {
|
|
|
boolean check = true;
|
|
boolean check = true;
|
|
|
for(Order resultAmt : tmtbApplyList) {
|
|
for(Order resultAmt : tmtbApplyList) {
|
|
|
if("Y".equals(resultAmt.getApplyQtySectionYn())) {
|
|
if("Y".equals(resultAmt.getApplyQtySectionYn())) {
|
|
|
- i++;
|
|
|
|
|
if(TscConstants.DcWay.AMT.value().equals(resultAmt.getDcWay())) { // 할인 방식 금액일경우
|
|
if(TscConstants.DcWay.AMT.value().equals(resultAmt.getDcWay())) { // 할인 방식 금액일경우
|
|
|
|
|
+ i++;
|
|
|
if(i == 1) {
|
|
if(i == 1) {
|
|
|
leftAmt = resultAmt.getDcVal();
|
|
leftAmt = resultAmt.getDcVal();
|
|
|
check = false;
|
|
check = false;
|
|
@@ -374,22 +398,35 @@ public class TsfCartService {
|
|
|
check = true;
|
|
check = true;
|
|
|
i = 0;
|
|
i = 0;
|
|
|
resultAmt.setTmtbDcAmt(leftAmt);
|
|
resultAmt.setTmtbDcAmt(leftAmt);
|
|
|
|
|
+ leftAmt = 0;
|
|
|
} else {
|
|
} else {
|
|
|
int tempAmt = resultAmt.getDcVal() * (((resultAmt.getCurrPrice() + resultAmt.getOptAddPrice()) * resultAmt.getGoodsQty()) / resultAmt.getTmtbSumAmt());
|
|
int tempAmt = resultAmt.getDcVal() * (((resultAmt.getCurrPrice() + resultAmt.getOptAddPrice()) * resultAmt.getGoodsQty()) / resultAmt.getTmtbSumAmt());
|
|
|
leftAmt -= tempAmt;
|
|
leftAmt -= tempAmt;
|
|
|
resultAmt.setTmtbDcAmt(tempAmt);
|
|
resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
}
|
|
}
|
|
|
} else { // 할인 방식 할인율일 경우
|
|
} else { // 할인 방식 할인율일 경우
|
|
|
- leftAmt = 0;
|
|
|
|
|
|
|
+ int tempAmt = (resultAmt.getCurrPrice() + resultAmt.getOptAddPrice()) * resultAmt.getGoodsQty();
|
|
|
|
|
+ tempAmt = tempAmt - (tempAmt * (resultAmt.getDcVal()/100));
|
|
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 할인 cartGoodsList에 할인 금액 세팅
|
|
|
|
|
- // 장바구니 등록 상품 중 tmtbSq는 존재하나 setApplyAmtSectionYn가 없는 경우 N으로 등록해주어야함 >> 장바구니 화면에서 추천상품 보여주기 위함
|
|
|
|
|
- // (기본상품만 N처리해주면될듯함.)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 데이터 통합
|
|
|
|
|
+ for(Order cart : cartGoodsList) {
|
|
|
|
|
+ for(Order apply : tmtbApplyList) {
|
|
|
|
|
+ if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
|
|
+ cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
|
|
+ cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
|
|
+ cart.setApplyAmtSectionYn(apply.getApplyQtySectionYn());
|
|
|
|
|
+ cart.setCurrPrice((apply.getCurrPrice() + apply.getOptAddPrice()) * apply.getGoodsQty());
|
|
|
|
|
+ cart.setTmtbNm(apply.getTmtbNm());
|
|
|
|
|
+ cart.setTmtbSq(apply.getTmtbSq());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ //return result;
|
|
|
|
|
+ return cartGoodsList;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|