|
|
@@ -6,21 +6,17 @@ import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.thymeleaf.util.StringUtils;
|
|
|
|
|
|
-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;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.persistence.domain.Cart;
|
|
|
-import com.style24.persistence.domain.Coupon;
|
|
|
import com.style24.persistence.domain.Goods;
|
|
|
import com.style24.persistence.domain.GoodsStock;
|
|
|
import com.style24.persistence.domain.Login;
|
|
|
@@ -28,6 +24,8 @@ import com.style24.persistence.domain.Order;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import com.gagaframework.web.parameter.GagaMap;
|
|
|
+
|
|
|
/**
|
|
|
* 장바구니 Service
|
|
|
*
|
|
|
@@ -65,7 +63,7 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// 장바구니 상품 및 재고 가능 여부 체크
|
|
|
- for(Cart param : params) {
|
|
|
+ for (Cart param : params) {
|
|
|
cart.setJsessionId(TscSession.getSessionId());
|
|
|
cart.setRegNo(login.getCustNo());
|
|
|
cart.setUpdNo(login.getCustNo());
|
|
|
@@ -78,7 +76,7 @@ public class TsfCartService {
|
|
|
if (goods == null) {
|
|
|
throw new IllegalArgumentException("상품 정보가 존재하지 않습니다.");
|
|
|
}
|
|
|
- if(TscConstants.GoodsStat.SOLDOUT.value().equals(goods.getGoodsStat())) {
|
|
|
+ if (TscConstants.GoodsStat.SOLDOUT.value().equals(goods.getGoodsStat())) {
|
|
|
throw new IllegalArgumentException("품절입니다.");
|
|
|
}
|
|
|
|
|
|
@@ -91,13 +89,13 @@ public class TsfCartService {
|
|
|
checkParam.setGoodsType(param.getGoodsType());
|
|
|
String stockResult = goodsService.getCheckStock(checkParam);
|
|
|
|
|
|
- if(!"SUCCESS".equals(stockResult)) {
|
|
|
+ if (!"SUCCESS".equals(stockResult)) {
|
|
|
throw new IllegalArgumentException(stockResult);
|
|
|
}
|
|
|
|
|
|
cart.setGoodsCd(param.getGoodsCd());
|
|
|
int goodsCartCnt = cartDao.getHasGoodsCartCnt(param);
|
|
|
- if(param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
|
|
|
+ if (param.getGoodsQty() + goodsCartCnt > goods.getDayMaxOrdQty()) {
|
|
|
throw new IllegalArgumentException("1일 구매한도 수량이 초과되었습니다.");
|
|
|
}
|
|
|
|
|
|
@@ -105,7 +103,7 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// 장바구니 정보 수정
|
|
|
- if(cart.getGoodsType().equals(TscConstants.GoodsType.SET.value())) {
|
|
|
+ if (cart.getGoodsType().equals(TscConstants.GoodsType.SET.value())) {
|
|
|
// 세트상품일 경우
|
|
|
saveSetTypeCartInfo(params);
|
|
|
} else {
|
|
|
@@ -137,16 +135,16 @@ public class TsfCartService {
|
|
|
|
|
|
// 장바구니 보유 CART_SQ 쿼리
|
|
|
int i = 1;
|
|
|
- for(Cart param : params) {
|
|
|
+ for (Cart param : params) {
|
|
|
sb.append("SELECT CD.CART_SQ \n FROM TB_CART_DETAIL CD \n INNER JOIN TB_CART C \n ON CD.CART_SQ = C.CART_SQ \n WHERE C.CUST_NO = ");
|
|
|
// TODO 로그인 정보 확인
|
|
|
- if(cart.getCustNo() == 0) {
|
|
|
+ if (cart.getCustNo() == 0) {
|
|
|
sb.append(cart.getCustNo()).append("\n AND JSESSION_ID = '").append(cart.getJsessionId()).append("'");
|
|
|
} else {
|
|
|
sb.append(cart.getCustNo());
|
|
|
}
|
|
|
sb.append("\n AND CD.ITEM_CD = '").append(param.getItemCd()).append("' \n AND CD.OPT_CD = '").append(param.getOptCd()).append("'");
|
|
|
- if(i < params.size()) {
|
|
|
+ if (i < params.size()) {
|
|
|
i++;
|
|
|
sb.append("\n UNION ALL \n");
|
|
|
}
|
|
|
@@ -162,10 +160,10 @@ public class TsfCartService {
|
|
|
cart.setGoodsType(params.iterator().next().getGoodsType());
|
|
|
cart.setItemCdSql(sb.toString());
|
|
|
|
|
|
- if("C".equals(params.iterator().next().getCartGb())) {
|
|
|
+ if ("C".equals(params.iterator().next().getCartGb())) {
|
|
|
cart.setCartGb(TscConstants.CartGb.CART.value());
|
|
|
- } else if("O".equals(params.iterator().next().getCartGb())) {
|
|
|
- if("P".equals(TsfSession.getFrontGb())) {
|
|
|
+ } else if ("O".equals(params.iterator().next().getCartGb())) {
|
|
|
+ if ("P".equals(TsfSession.getFrontGb())) {
|
|
|
cart.setCartGb(TscConstants.CartGb.PC_ORDER.value());
|
|
|
} else {
|
|
|
cart.setCartGb(TscConstants.CartGb.MOB_ORDER.value());
|
|
|
@@ -177,8 +175,8 @@ public class TsfCartService {
|
|
|
// 같은 장바구니 상품 확인
|
|
|
Collection<Integer> cartSqList = cartDao.selectHasSetItemCartList(cart);
|
|
|
|
|
|
- if(cartSqList != null && cartSqList.size() > 0) { // 장바구니 기존재
|
|
|
- if(cartSqList.size() > 1) { // 장바구니 조회 결과 이상시 insert or select 수정 필요
|
|
|
+ if (cartSqList != null && cartSqList.size() > 0) { // 장바구니 기존재
|
|
|
+ if (cartSqList.size() > 1) { // 장바구니 조회 결과 이상시 insert or select 수정 필요
|
|
|
throw new IllegalArgumentException("장바구니 조회에 실패하였습니다. 관리자에게 문의해주세요.");
|
|
|
} else {
|
|
|
cart.setCartSq(cartSqList.iterator().next());
|
|
|
@@ -188,7 +186,7 @@ public class TsfCartService {
|
|
|
} else {
|
|
|
cartDao.insertCartInfo(cart); // 장바구니 마스터 정보 저장
|
|
|
cartDao.insertCartHst(cart); // 장바구니 이력 정보 저장
|
|
|
- for(Cart param : params) {
|
|
|
+ for (Cart param : params) {
|
|
|
param.setCartSq(cart.getCartSq());
|
|
|
param.setRegNo(cart.getRegNo());
|
|
|
param.setCustNo(cart.getCustNo());
|
|
|
@@ -216,10 +214,10 @@ public class TsfCartService {
|
|
|
param.setJsessionId(TscSession.getSessionId());
|
|
|
|
|
|
|
|
|
- if("C".equals(param.getCartGb())) {
|
|
|
+ if ("C".equals(param.getCartGb())) {
|
|
|
param.setCartGb(TscConstants.CartGb.CART.value());
|
|
|
- } else if("O".equals(param.getCartGb())) {
|
|
|
- if("P".equals(TsfSession.getFrontGb())) {
|
|
|
+ } else if ("O".equals(param.getCartGb())) {
|
|
|
+ if ("P".equals(TsfSession.getFrontGb())) {
|
|
|
param.setCartGb(TscConstants.CartGb.PC_ORDER.value());
|
|
|
} else {
|
|
|
param.setCartGb(TscConstants.CartGb.MOB_ORDER.value());
|
|
|
@@ -231,8 +229,8 @@ public class TsfCartService {
|
|
|
// 같은 장바구니 상품 확인
|
|
|
Collection<Integer> cartSqList = cartDao.selectHasNormalDealItemCartList(param);
|
|
|
|
|
|
- if(cartSqList != null && cartSqList.size() > 0) { // 장바구니 기존재
|
|
|
- if(cartSqList.size() > 1) { // 장바구니 조회 결과 이상시 insert or select 수정 필요
|
|
|
+ if (cartSqList != null && cartSqList.size() > 0) { // 장바구니 기존재
|
|
|
+ if (cartSqList.size() > 1) { // 장바구니 조회 결과 이상시 insert or select 수정 필요
|
|
|
throw new IllegalArgumentException("장바구니 조회에 실패하였습니다. 관리자에게 문의해주세요.");
|
|
|
} else {
|
|
|
param.setCartSq(cartSqList.iterator().next());
|
|
|
@@ -265,8 +263,8 @@ public class TsfCartService {
|
|
|
Collection<Order> cartGoodsList = cartDao.getCartGoodsList(order);
|
|
|
|
|
|
// 품절 아닌 상품만 체크
|
|
|
- for(Order goods : cartGoodsList) {
|
|
|
- if("N".equals(goods.getSoldoutYn())) {
|
|
|
+ for (Order goods : cartGoodsList) {
|
|
|
+ if ("N".equals(goods.getSoldoutYn())) {
|
|
|
cartSqs.add(goods.getCartSq());
|
|
|
}
|
|
|
}
|
|
|
@@ -365,7 +363,7 @@ public class TsfCartService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(applyInfo.getAmtTmtbSq() == section.getTmtbSq()) {
|
|
|
+ if (applyInfo.getAmtTmtbSq() == section.getTmtbSq()) {
|
|
|
// 금액 적용 다다익선
|
|
|
if(section.getSectionVal() <= applyInfo.getAmtTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
if(applyInfo.getAmtSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
@@ -423,7 +421,7 @@ public class TsfCartService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(resultAmt.getTmtbDcAmt() > 0) {
|
|
|
+ if (resultAmt.getTmtbDcAmt() > 0) {
|
|
|
resultAmt.setCurrPrice(resultAmt.getTmtbDcAmt());
|
|
|
}
|
|
|
}
|
|
|
@@ -466,9 +464,9 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// 장바구니 정보에 수량 다다익선 정보 입력
|
|
|
- for(Order cart : cartGoodsList) {
|
|
|
- for(Order apply : tmtbApplyList) {
|
|
|
- if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
+ for (Order cart : cartGoodsList) {
|
|
|
+ for (Order apply : tmtbApplyList) {
|
|
|
+ if (cart.getCartSq() == apply.getCartSq()) {
|
|
|
cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
cart.setQtyTmtbNm(apply.getQtyTmtbNm());
|
|
|
@@ -496,8 +494,8 @@ public class TsfCartService {
|
|
|
// 1. 장바구니 상품 배송단위별 건수 체크 로직 (자사:총알배송, 자사:일반배송, 입점업체, 예약배송)
|
|
|
Order delvOrder = new Order();
|
|
|
|
|
|
- Collection<Order> wmsCartList = new ArrayList<Order>();
|
|
|
- Collection<Order> delvCartList = new ArrayList<Order>();
|
|
|
+ Collection<Order> wmsCartList = new ArrayList<Order>();
|
|
|
+ Collection<Order> delvCartList = new ArrayList<Order>();
|
|
|
|
|
|
for (Order order : cartGoodsList) {
|
|
|
// 1.1 세트상품 옵션별 배열로 담기
|
|
|
@@ -531,7 +529,7 @@ public class TsfCartService {
|
|
|
List<Integer> cartSqArr = new ArrayList<Integer>();
|
|
|
|
|
|
// 장바구니 일련번호 세팅
|
|
|
- for(Order param : params) {
|
|
|
+ for (Order param : params) {
|
|
|
cartSqArr.add(param.getCartSq());
|
|
|
}
|
|
|
delvInfo.setCartSqArr(cartSqArr.stream().mapToInt(Integer::intValue).toArray());
|
|
|
@@ -541,16 +539,16 @@ public class TsfCartService {
|
|
|
|
|
|
// 업체별 상품 합계 금액 저장
|
|
|
int compCnt = 0;
|
|
|
- for(Order delv : delvFeeInfo) {
|
|
|
+ for (Order delv : delvFeeInfo) {
|
|
|
compCnt = 0;
|
|
|
- for(Order param : params) {
|
|
|
- if(param.getDelvFeeCd().equals(delv.getDelvFeeCd())) {
|
|
|
+ for (Order param : params) {
|
|
|
+ if (param.getDelvFeeCd().equals(delv.getDelvFeeCd())) {
|
|
|
compCnt++;
|
|
|
if("N".equals(param.getSoldoutYn())) {
|
|
|
delv.setCompSumPrice(delv.getCompSumPrice() + param.getCurrPrice());
|
|
|
}
|
|
|
|
|
|
- if(compCnt == 1) {
|
|
|
+ if (compCnt == 1) {
|
|
|
param.setFirstCompYn("Y");
|
|
|
}
|
|
|
/* else {
|
|
|
@@ -561,13 +559,13 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// 장바구니 업체별 합계 금액으로 무료배송 여부 저장
|
|
|
- for(Order delv : delvFeeInfo) {
|
|
|
- for(Order param : params) {
|
|
|
- if(param.getDelvFeeCd().equals(delv.getDelvFeeCd())) { // TODO 자사 배송비는 어떤 금액으로 처리하는지 확인 후 조건 수정 필요 (WMS는 DELV_FEE_CD 동일한거 없음)
|
|
|
+ for (Order delv : delvFeeInfo) {
|
|
|
+ for (Order param : params) {
|
|
|
+ if (param.getDelvFeeCd().equals(delv.getDelvFeeCd())) { // TODO 자사 배송비는 어떤 금액으로 처리하는지 확인 후 조건 수정 필요 (WMS는 DELV_FEE_CD 동일한거 없음)
|
|
|
param.setCompCnt(delv.getCompCnt());
|
|
|
- if(TscConstants.DelvFeeCrite.FREE.value().equals(delv.getDelvFeeCrite())) {
|
|
|
+ if (TscConstants.DelvFeeCrite.FREE.value().equals(delv.getDelvFeeCrite())) {
|
|
|
param.setDelvFee(0);
|
|
|
- } else if(TscConstants.DelvFeeCrite.NORMAL.value().equals(delv.getDelvFeeCrite()) && delv.getCompSumPrice() > delv.getMinOrdAmt()) {
|
|
|
+ } else if (TscConstants.DelvFeeCrite.NORMAL.value().equals(delv.getDelvFeeCrite()) && delv.getCompSumPrice() > delv.getMinOrdAmt()) {
|
|
|
param.setDelvFee(0);
|
|
|
} else {
|
|
|
param.setDelvFee(delv.getDelvFee());
|
|
|
@@ -590,9 +588,9 @@ public class TsfCartService {
|
|
|
}
|
|
|
|
|
|
// TODO 자사 배송비는 어떤 금액으로 처리하는지 확인 후 수정 필요
|
|
|
- for(Order param : params) {
|
|
|
- if("WMS".equals(param.getDelvFeeCd())) {
|
|
|
- if(wmsSumPrice > 40000) {
|
|
|
+ for (Order param : params) {
|
|
|
+ if ("WMS".equals(param.getDelvFeeCd())) {
|
|
|
+ if (wmsSumPrice > 40000) {
|
|
|
param.setDelvFee(0);
|
|
|
} else {
|
|
|
param.setDelvFee(2500);
|
|
|
@@ -613,7 +611,7 @@ public class TsfCartService {
|
|
|
order.setSumRealPayAmt(order.getSumRealPayAmt() + cart.getTmtbDcAmt());
|
|
|
|
|
|
// 배송비 합계
|
|
|
- if("Y".equals(cart.getFirstCompYn())) {
|
|
|
+ if ("Y".equals(cart.getFirstCompYn())) {
|
|
|
order.setTotDelvFee(order.getTotDelvFee() + cart.getDelvFee());
|
|
|
}
|
|
|
}
|
|
|
@@ -629,4 +627,46 @@ public class TsfCartService {
|
|
|
public void deleteCart(Cart param) {
|
|
|
cartDao.deleteCart(param);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 로그인 후 장바구니 Update
|
|
|
+ * 회원 로그인 후 호출됨으로 세션 정보 있음
|
|
|
+ * @param custNo - 고객번호
|
|
|
+ * @author gagamel
|
|
|
+ * @since 2021. 2. 24
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void updateCartToAfterLogin(Integer custNo) {
|
|
|
+ Cart cart = new Cart();
|
|
|
+ cart.setJsessionId(TsfSession.getSessionId());
|
|
|
+ cart.setCustNo(custNo);
|
|
|
+ cart.setUpdNo(custNo);
|
|
|
+ log.info("cart: {}", cart);
|
|
|
+
|
|
|
+ // 로그인 후 고객번호 Update
|
|
|
+ int procCnt = cartDao.updateCartOfCustNo(cart);
|
|
|
+
|
|
|
+ if (procCnt > 0) {
|
|
|
+ // 로그인 후 처리할 장바구니 목록
|
|
|
+ Collection<Cart> cartList = cartDao.getCartListAfterLogin(cart);
|
|
|
+
|
|
|
+ for (Cart updCart : cartList) {
|
|
|
+ updCart.setCustNo(custNo);
|
|
|
+
|
|
|
+ // 로그인 후 장바구니 수정
|
|
|
+ cartDao.updateCartAfterLogin(updCart);
|
|
|
+
|
|
|
+ // 로그인 후 장바구니단품 삭제
|
|
|
+ cartDao.deleteCartItemAfterLogin(updCart);
|
|
|
+
|
|
|
+ // 로그인 후 장바구니 삭제
|
|
|
+ cartDao.deleteCartAfterLogin(updCart);
|
|
|
+
|
|
|
+ // 로그인 후 장바구니 이력 생성(삭제할 장바구니번호가 있을 때만)
|
|
|
+ if (updCart.getDelCartSq() > 0) {
|
|
|
+ cartDao.createCartHistoryAfterLogin(updCart);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|