|
|
@@ -1,5 +1,7 @@
|
|
|
package com.style24.front.biz.service;
|
|
|
|
|
|
+import com.gagaframework.web.parameter.GagaMap;
|
|
|
+import com.style24.core.biz.service.TscOrderService;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.core.support.session.TscSession;
|
|
|
import com.style24.front.biz.dao.TsfCartDao;
|
|
|
@@ -8,12 +10,16 @@ import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.persistence.domain.Cart;
|
|
|
import com.style24.persistence.domain.Goods;
|
|
|
import com.style24.persistence.domain.GoodsStock;
|
|
|
+import com.style24.persistence.domain.Order;
|
|
|
+
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 장바구니 Service
|
|
|
@@ -31,13 +37,15 @@ public class TsfCartService {
|
|
|
@Autowired
|
|
|
private TsfGoodsService goodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TscOrderService coreOrderService;
|
|
|
+
|
|
|
/**
|
|
|
* 장바구니 저장
|
|
|
* 단품 : goodsCd, optCd, optCd1, optCd2
|
|
|
* 세트 : goodsCd,
|
|
|
* @param cart
|
|
|
*/
|
|
|
- @Transactional("shopTxnManager")
|
|
|
public String saveCartInfo(Collection<Cart> params) {
|
|
|
Cart cart = new Cart();
|
|
|
// JSESSION_ID 저장
|
|
|
@@ -83,7 +91,7 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// 장바구니 정보 수정
|
|
|
- if(cart.getGoodsType().equals(TscConstants.GOODS_TYPE.SET.value())) {
|
|
|
+ if(cart.getGoodsType().equals(TscConstants.GoodsType.SET.value())) {
|
|
|
// 세트상품일 경우
|
|
|
saveSetTypeCartInfo(params);
|
|
|
} else {
|
|
|
@@ -208,4 +216,98 @@ public class TsfCartService {
|
|
|
cartDao.insertCartDetailHst(param); // 장바구니 수정 이력 저장
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public GagaMap selecCartGoodsList() {
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+
|
|
|
+ Order order = new Order();
|
|
|
+
|
|
|
+ // TODO 로그인 체크
|
|
|
+ order.setJsessionId("aaec62cc-5f91-47bb-ba65-ebc9a61385cf");
|
|
|
+ //order.setJsessionId(TscSession.getSessionId());
|
|
|
+ order.setCustNo(0);
|
|
|
+ order.setRegNo(0);
|
|
|
+ order.setUpdNo(0);
|
|
|
+
|
|
|
+ // 장바구니 상품 조회
|
|
|
+ Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(order);
|
|
|
+
|
|
|
+ // 즉시할인쿠폰 적용가 조회
|
|
|
+ List<Integer> cartSqArr2 = new ArrayList<Integer>();
|
|
|
+ for(Order temp : cartGoodsList) {
|
|
|
+ cartSqArr2.add(temp.getCartSq());
|
|
|
+ }
|
|
|
+ order.setCartSqArr(cartSqArr2.stream().mapToInt(Integer::intValue).toArray());
|
|
|
+
|
|
|
+ // 즉시 할인가 조회
|
|
|
+ Collection<Order> cpn1ApplyGoodsList = coreOrderService.getCpn1ApplyGoodsList(order);
|
|
|
+
|
|
|
+ // 즉시 할인가 적용 금액 // pcCurrPrice
|
|
|
+ for(Order goods : cartGoodsList) {
|
|
|
+ for(Order amt : cpn1ApplyGoodsList) {
|
|
|
+ if(goods.getGoodsCd().equals(amt.getGoodsCd())) {
|
|
|
+ goods.setPcCurrPrice(amt.getPcCurrPrice()); // 즉시할인금액
|
|
|
+ // TODO 모바일 금액 추가 필요
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 장바구니 내 적용 가능 다다익선 조회 (등록된 기본 상품 정보 조회)
|
|
|
+ Collection<Order> tmtbBaseList = cartDao.selectMoreBetterBaseCartList(order);
|
|
|
+
|
|
|
+ // 기본 상품이 등록된 장바구니의 다다익선 정보 지정
|
|
|
+ List<Integer> baseSq = new ArrayList<Integer>();
|
|
|
+ for(Order tmtbBase : tmtbBaseList) {
|
|
|
+ baseSq.add(tmtbBase.getTmtbSq());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 기본 상품이 걸려있는 다다익선별 총합 데이터 조회
|
|
|
+ Collection<Order> tmtbSumDataList = cartDao.selectApplyMoreBetterCartInfoList(baseSq);
|
|
|
+
|
|
|
+ // 기본상품 목록에 총합 데이터 등록
|
|
|
+ for(Order baseInfo : tmtbBaseList) {
|
|
|
+ for(Order tmtbSumInfo : tmtbSumDataList) {
|
|
|
+ if(baseInfo.getTmtbSq() == tmtbSumInfo.getTmtbSq()) {
|
|
|
+ baseInfo.setTmtbSumAmt(tmtbSumInfo.getTmtbSumAmt());
|
|
|
+ baseInfo.setTmtbSumQty(tmtbSumInfo.getTmtbSumQty());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 섹션 정보 조회 후 할인 여부 판단
|
|
|
+ Collection<Order> tmtbSectionList = cartDao.selectTmtbSectionValList(baseSq);
|
|
|
+ for(Order baseInfo : tmtbBaseList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ } 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 {
|
|
|
+ baseInfo.setApplyAmtSectionYn("N");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 다다익선 할인 된 상품 조회 (적용상품까지 모두 화면에 노출되어야함)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ result.put("cartGoodsList", cartGoodsList);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|