|
|
@@ -20,6 +20,7 @@ import com.style24.core.biz.service.TscNaverPayService;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.front.biz.dao.TsfOrderDao;
|
|
|
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.GoodsStock;
|
|
|
import com.style24.persistence.domain.KakaoPay;
|
|
|
@@ -56,6 +57,9 @@ public class TsfOrderService {
|
|
|
|
|
|
@Autowired
|
|
|
private TsfGoodsService goodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TsfCartService cartService;
|
|
|
|
|
|
/**
|
|
|
* 마이페이지 주문 정보 조회
|
|
|
@@ -454,51 +458,71 @@ public class TsfOrderService {
|
|
|
* @author jsh77b
|
|
|
* @since 2021. 03. 09
|
|
|
*/
|
|
|
- public void orderValidationCheck(Order order) {
|
|
|
+ public String orderValidationCheck(Order order) {
|
|
|
// 1. 주문상세체크
|
|
|
Collection<Order> orderDetailList = order.getOrderDetailList();
|
|
|
|
|
|
- String goodsCd = "";
|
|
|
- String goodsType = "";
|
|
|
- String itemCd = "";
|
|
|
- String optCd = "";
|
|
|
- int goodsQty = 0;
|
|
|
int custCpnSq = 0;
|
|
|
int usPntAmt = 0;
|
|
|
int usGfcdAmt = 0;
|
|
|
|
|
|
+ String resultStr = "SUCCESS";
|
|
|
+
|
|
|
for (Order orderDetail : orderDetailList) {
|
|
|
|
|
|
- // 2.1 상품 재고 확인
|
|
|
- GoodsStock checkParam = new GoodsStock();
|
|
|
+ // TODO
|
|
|
+ // 2.1 상품 재고 확인 (상품정보유효성체크)
|
|
|
+ Collection<Cart> params = new ArrayList<Cart>();
|
|
|
+ Cart cart = new Cart();
|
|
|
+ cart.setGoodsCd(orderDetail.getGoodsCd());
|
|
|
+ cart.setGoodsType(orderDetail.getGoodsType());
|
|
|
+ cart.setGoodsQty(orderDetail.getGoodsQty());
|
|
|
+ cart.setCheckGb("O");
|
|
|
|
|
|
- for (int i=0 ; i<orderDetail.getItemCdArr().length ; i++) {
|
|
|
- goodsCd = orderDetail.getGoodsCd();
|
|
|
- goodsType = orderDetail.getGoodsType();
|
|
|
- itemCd = orderDetail.getItemCdArr()[i];
|
|
|
- optCd = orderDetail.getOptCdArr()[i];
|
|
|
- goodsQty = orderDetail.getGoodsQty();
|
|
|
-
|
|
|
- checkParam.setGoodsCd(goodsCd);
|
|
|
- checkParam.setItemCd(itemCd);
|
|
|
- checkParam.setOptCd(optCd);
|
|
|
- checkParam.setGoodsQty(goodsQty);
|
|
|
- checkParam.setGoodsType(goodsType);
|
|
|
+ // 세트상품
|
|
|
+ if ("G056_S".equals(orderDetail.getGoodsType())) {
|
|
|
+
|
|
|
+ Collection<Cart> cartCompsList = new ArrayList<Cart>();
|
|
|
|
|
|
- // TODO 2021.03.29 재고체크
|
|
|
- //String stockResult = goodsService.getCheckStock(checkParam);
|
|
|
- //if (!"SUCCESS".equals(stockResult)) {
|
|
|
- //throw new IllegalArgumentException(stockResult);
|
|
|
- //}
|
|
|
+ // 세트상품일때 구성상품정보 추가
|
|
|
+ for (int i=0 ; i<orderDetail.getItemCdArr().length ; i++) {
|
|
|
+ Cart itemCart = new Cart();
|
|
|
+ itemCart.setGoodsCd(orderDetail.getGoodsCd());
|
|
|
+ itemCart.setGoodsType(orderDetail.getGoodsType());
|
|
|
+ itemCart.setItemCd(orderDetail.getItemCdArr()[i]);
|
|
|
+ itemCart.setOptCd(orderDetail.getOptCdArr()[i]);
|
|
|
+ itemCart.setGoodsQty(orderDetail.getGoodsQty());
|
|
|
+ itemCart.setCartGb("O");
|
|
|
+ cartCompsList.add(itemCart);
|
|
|
+ }
|
|
|
+ // 구성상품정보추가
|
|
|
+ cart.setCartCompsList(cartCompsList);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cart.setItemCd(orderDetail.getItemCdArr()[0]);
|
|
|
+ cart.setOptCd(orderDetail.getOptCdArr()[0]);
|
|
|
+ cart.setGoodsQty(orderDetail.getGoodsQty());
|
|
|
+ cart.setCartGb("O");
|
|
|
}
|
|
|
+
|
|
|
+ // 유효성체크 목록 담기 1개 기준 체크
|
|
|
+ params.add(cart);
|
|
|
|
|
|
+ GagaMap resultMap = cartService.saveCartInfo(params);
|
|
|
+
|
|
|
+ if (!"SUCCESS".equals(resultMap.get("message").toString())) {
|
|
|
+ resultStr = resultMap.get("message").toString();
|
|
|
+ return resultStr;
|
|
|
+ }
|
|
|
+
|
|
|
// 2.2 보유 상품쿠폰체크
|
|
|
custCpnSq = orderDetail.getGoodsCpnSq();
|
|
|
if (custCpnSq > 0) {
|
|
|
orderDetail.setCustCpnSq(custCpnSq);
|
|
|
orderDetail.setCustNo(order.getCustNo());
|
|
|
if (orderDao.getCheckCustCpnSq(orderDetail) < 1) {
|
|
|
- throw new IllegalArgumentException("보유하신 상품쿠폰이 존재하지 않습니다.");
|
|
|
+ resultStr = "보유하신 상품쿠폰이 존재하지 않습니다.";
|
|
|
+ return resultStr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -508,7 +532,8 @@ public class TsfOrderService {
|
|
|
orderDetail.setCustCpnSq(custCpnSq);
|
|
|
orderDetail.setCustNo(order.getCustNo());
|
|
|
if (orderDao.getCheckCustCpnSq(orderDetail) < 1) {
|
|
|
- throw new IllegalArgumentException("보유하신 장바구니쿠폰이 존재하지 않습니다.");
|
|
|
+ resultStr = "보유하신 장바구니쿠폰이 존재하지 않습니다.";
|
|
|
+ return resultStr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -535,13 +560,15 @@ public class TsfOrderService {
|
|
|
// 3. 보유포인트금액 > 포인트사용금액 체크
|
|
|
int rmPntAmt = coreOrderDao.getCustPointInfo(order);
|
|
|
if (rmPntAmt < usPntAmt) {
|
|
|
- throw new IllegalArgumentException("보유하신 포인트 금액이 부족합니다.");
|
|
|
+ resultStr = "보유하신 포인트 금액이 부족합니다.";
|
|
|
+ return resultStr;
|
|
|
}
|
|
|
|
|
|
// 4. 보유상품권금액 > 상품권사용금액 체크
|
|
|
int rmGfcdAmt = coreOrderDao.getGiftcardInfo(order);
|
|
|
if (rmGfcdAmt < usGfcdAmt) {
|
|
|
- throw new IllegalArgumentException("보유하신 상품권 금액이 부족합니다.");
|
|
|
+ resultStr = "보유하신 상품권 금액이 부족합니다.";
|
|
|
+ return resultStr;
|
|
|
}
|
|
|
|
|
|
// 5. 장바구니 보유쿠폰 체크 (배송목록체크)
|
|
|
@@ -553,36 +580,22 @@ public class TsfOrderService {
|
|
|
delvFeeCd.setCustCpnSq(custCpnSq);
|
|
|
delvFeeCd.setCustNo(order.getCustNo());
|
|
|
if (orderDao.getCheckCustCpnSq(delvFeeCd) < 1) {
|
|
|
- throw new IllegalArgumentException("보유하신 배송비쿠폰이 존재하지 않습니다.");
|
|
|
+ resultStr = "보유하신 배송비쿠폰이 존재하지 않습니다.";
|
|
|
+ return resultStr;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// TODO 5. 사은품채고체크
|
|
|
+ int rtnCnt = orderDao.getCheckFreegiftVal(order);
|
|
|
+ if (rtnCnt > 0) {
|
|
|
+ resultStr = "선택하신 사은품의 재고가 부족 합니다.";
|
|
|
+ return resultStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
- // public ModelAndView getOrderList(Order order) {
|
|
|
- // ModelAndView mav = new ModelAndView();
|
|
|
- // // 페이징 처리 및 주문정보 조회
|
|
|
- // List<Integer> ordNoList = new ArrayList<>();
|
|
|
- //
|
|
|
- // for (Order tmpOrder : this.getPagingOrdNoList(order)) {
|
|
|
- // ordNoList.add(tmpOrder.getOrdNo());
|
|
|
- // }
|
|
|
- //
|
|
|
- // if (ordNoList.size() > 0) {
|
|
|
- // order.setOrdNoList(ordNoList.stream().mapToInt(Integer::intValue).toArray());
|
|
|
- // }
|
|
|
- //
|
|
|
- // mav.addObject("orderList", this.getOrderListForMypage(order));
|
|
|
- // mav.addObject("orderInfo", order);
|
|
|
- //
|
|
|
- // mav.setViewName(super.getDeviceViewName("mypage/MypageOrderList"));
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|