|
|
@@ -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;
|
|
|
}
|