| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- package com.style24.front.biz.web;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.Date;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.gagaframework.web.rest.server.GagaResponse;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.core.env.Environment;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import org.thymeleaf.util.StringUtils;
- import com.gagaframework.web.parameter.GagaMap;
- import com.style24.core.biz.service.TscKcpService;
- import com.style24.core.biz.service.TscOrderService;
- import com.style24.core.support.env.TscConstants;
- import com.style24.core.support.message.TscMessageByLocale;
- import com.style24.core.support.util.CryptoUtils;
- import com.style24.front.biz.service.TsfCartService;
- import com.style24.front.biz.service.TsfCouponService;
- import com.style24.front.biz.service.TsfOrderService;
- import com.style24.front.support.controller.TsfBaseController;
- 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.GiftCard;
- import com.style24.persistence.domain.Goods;
- import com.style24.persistence.domain.Login;
- import com.style24.persistence.domain.Order;
- import com.style24.persistence.domain.Payment;
- import com.style24.persistence.domain.WishList;
- import lombok.extern.slf4j.Slf4j;
- /**
- * 장바구니 Controller
- *
- * @author gagamel
- * @since 2020. 12. 29
- */
- @Controller
- @RequestMapping("/cart")
- @Slf4j
- public class TsfCartController extends TsfBaseController {
- @Autowired
- private TscMessageByLocale message;
- @Autowired
- private TsfCartService cartService;
- @Autowired
- private TsfCouponService couponService;
- @Autowired
- private TscOrderService coreOrderService;
- @Autowired
- private TscKcpService coreKcpService;
- @Autowired
- private TsfOrderService orderService;
- @Autowired
- private Environment env;
- /**
- * 장바구니 화면
- * @return
- * @author xodud1202
- * @since 2021. 01. 28
- */
- @GetMapping("/list/form")
- public ModelAndView cartListForm() {
- ModelAndView mav = new ModelAndView();
- mav.setViewName(super.getDeviceViewName("cart/CartListForm"));
- return mav;
- }
- /**
- * 장바구니 등록
- * @param param
- * goodsCd : 상품코드 (세트 : 세트상품코드, 딜상품 : 원상품코드, 일반상품 : 상품코드)
- * dealGoodsCd : 딜상품코드
- * itemCd : 구성상품코드 (세트. 세트 아닐 경우 입력X)
- * optCd : 옵션코드
- * goodsType : 상품타입 (공통코드 G026)
- * goodsQty : 장바구니 등록 수량
- * cartGb : O = 바로주문, C = 장바구니
- * afLinkCd : 제휴링크코드
- * ithr_cd : 유입경고
- * contents_loc : 컨텐츠 위치
- * planDtlSq : 기획전상세번호
- * dealGoodsCd : 딜상품코드 (딜상품코드)
- * @return ModelAndView
- * @author xodud1202
- * @since 2021. 01. 28
- */
- @ResponseBody
- @PostMapping("/save")
- public GagaMap createCart(@RequestBody Collection<Cart> params) {
- GagaMap result = new GagaMap();
- try {
- result = cartService.saveCartInfo(params);
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalArgumentException();
- }
- return result;
- }
- // @ResponseBody
- @PostMapping("/goods/list")
- public String selectCartGoodsList(Order param, Model model) {
- // 총알배송 가능 여부 체크
- int shotCanYn = coreOrderService.getDailyDeliveryCheck(param);
- // 10시 이전에만 총알 배송 가능 여부 체크
- if(shotCanYn == 1) {
- SimpleDateFormat format = new SimpleDateFormat ( "MM/dd");
- Date time = new Date();
- param.setShotCanYn("Y");
- param.setShotDelvDt(format.format(time));
- } else {
- SimpleDateFormat format = new SimpleDateFormat ( "MM/dd");
- Date time = new Date();
- param.setShotCanYn("N");
- param.setShotDelvDt(format.format(time));
- }
- if(param.getShotDelvUseYn() == null) {
- param.setShotDelvUseYn(param.getShotCanYn());
- }
- // 장바구니 정보 조회
- Order order = cartService.getCartGoodsList(param);
- order.setShotDelvUseYn(param.getShotDelvUseYn());
- order.setShotCanYn(param.getShotCanYn());
- order.setShotDelvDt(param.getShotDelvDt());
- model.addAttribute("loginInfo", TsfSession.getInfo());
- model.addAttribute("order", order);
- model.addAttribute("IMG_PATH", env.getProperty("upload.goods.view"));
- GiftCard temp = new GiftCard();
- temp.setModType("STPC"); // 요청 구분 (STSQ : 조회, STSC : 전체취소, STPC : 부분취소)
- temp.setOrdNo(3); // 주문번호
- temp.setUsGfcdAmt(142); // 부분취소 요청 금액
- GiftCard aa = coreKcpService.kcpCashReceiptCancel(temp);
- return super.getDeviceViewName("cart/CartListAjaxForm");
- }
- /**
- * 장바구니 로그인 정보 조회
- * @param param
- * @return
- */
- @ResponseBody
- @PostMapping("/login/info")
- public Login selectLoginInfo(Order param) {
- Login result = new Login();
- if(TsfSession.isLogin()) {
- result = TsfSession.getInfo();
- } else {
- result.setCustNo(0);
- }
- return result;
- }
- /**
- * 장바구니 체크박스 change시에 계산로직 진행
- * @param param
- * @return
- */
- @ResponseBody
- @PostMapping("/change/goods/list")
- public Order selectCartGoodsJsonList(@RequestBody Order param) {
- Order order = cartService.getCartGoodsList(param);
- order.setImgPath1(env.getProperty("upload.goods.view"));
- return order;
- }
- /**
- * 프로모션 할인 쿠폰 조회
- * @param param
- * rdCpnNm : 시리얼쿠폰명
- * cartSqArr[] : 장바구니 번호 배열
- * @return GagaMap
- * @author xodud1202
- * @since 2021. 02. 17
- */
- @ResponseBody
- @PostMapping("/list/serialCpnApply")
- public GagaMap serialCpnApply(@RequestBody Coupon param) {
- GagaMap result = new GagaMap();
- // 시리얼 쿠폰 정보 조회 및 쿠폰 지급 미대상인 경우 쿠폰 지급
- Coupon useSerial = couponService.serialCpnApplyInfo(param);
- result.put("serialCpnInfo", useSerial);
- return result;
- }
- /**
- * 장바구니 삭제
- * @param param
- * @return GagaMap
- * @author xodud1202
- * @since 2021. 02. 23
- */
- @ResponseBody
- @PostMapping("/deleteCart")
- public GagaMap deleteCart(@RequestBody Cart param) {
- cartService.deleteCart(param);
- return new GagaMap();
- }
- /**
- * 장바구니 옵션변경 팝업
- * @param param
- * @return String
- * @author xodud1202
- * @since 2021. 02. 23
- */
- // @ResponseBody
- @PostMapping("/goods/info")
- public String getCartGoodsInfo(Cart param, Model model) {
- Cart cart = cartService.getCartGoodsInfo(param);
- model.addAttribute("cart", cart);
- model.addAttribute("setType", TscConstants.GoodsType.SET.value());
- return super.getDeviceViewName("cart/CartChangeOptionPopup");
- }
- /**
- * 장바구니 옵션 변경
- * @param param
- * @return GagaMap
- * @author xodud1202
- * @since 2021. 02. 23
- */
- @ResponseBody
- @PostMapping("/change/option")
- public GagaMap updateCartOption(@RequestBody Cart param) {
- GagaMap result = new GagaMap();
- result = cartService.updateCartOption(param);
- if("SUCCESS".equals(result.get("status"))) {
- result.put("message", message.getMessage("SUCC_0009"));
- }
- return result;
- }
- /**
- * 장바구니 주문하기 시점 재고 및 상태 체크
- * @param param
- * @return
- * @author xodud1202
- * @since 2021. 04. 02
- */
- @ResponseBody
- @PostMapping("/order/list/check")
- public Collection<Order> selectOrderListCheck(@RequestBody Order param) {
- return cartService.getOrderListConditionCheck(param);
- }
- /**
- * 장바구니 최소 주문 수량으로 변경
- * @param param
- * @return
- * @author xodud1202
- * @since 2021. 04. 02
- */
- @ResponseBody
- @PostMapping("/update/goodsQty")
- public Order updateCartGoodsQty(@RequestBody Cart param) {
- return cartService.updateCartGoodsQty(param);
- }
- /**
- * 퀵메뉴 장바구니 리스트
- * @return
- * @author sowon
- * @since 2021. 4. 1
- */
- @GetMapping("/quick/cart/list")
- @ResponseBody
- public Order getCartList() {
- Order cart = new Order();
- int custNo = 0;
- if(TsfSession.isLogin()) {
- custNo = TsfSession.getInfo().getCustNo();
- }
- // 장바구니 상품목록
- cart = cartService.getCartGoodsList(cart);
- cart.setImgPath1(env.getProperty("upload.goods.view"));
- // 현재 주문 가능 수량순으로 정렬
- Collections.sort((ArrayList<Order>) cart.getDelvAllCartList(), new Comparator<Order>() {
- @Override
- public int compare(Order c1, Order c2) {
- return c1.getOrdCanQty() - c2.getOrdCanQty();
- // return c2.getQtyTmtbSq() - c1.getQtyTmtbSq(); //역순 정렬
- }
- });
- return cart;
- }
- }
|