Kaynağa Gözat

Merge remote-tracking branch 'origin/develop' into jsh77b

jsh77b 4 yıl önce
ebeveyn
işleme
231849b6d0

+ 9 - 0
src/main/java/com/style24/core/biz/dao/TscDeliveryDao.java

@@ -48,5 +48,14 @@ public interface TscDeliveryDao {
 	 */
 	Order getSoldoutInfo(Order order);
 	
+	/**
+	 * 알림톡(배송완료 상품평) 정보 조회
+	 *
+	 * @param Order 
+	 * @return Order
+	 * @author moon
+	 * @since 2021. 09. 08
+	 */
+	Order getOrdNoInfoKakao(Order order);
 	
 }

+ 33 - 0
src/main/java/com/style24/core/biz/service/TscPointService.java

@@ -6,9 +6,14 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.style24.core.biz.dao.TscPointDao;
 import com.style24.core.support.env.TscConstants;
+import com.style24.core.biz.service.TscKakaotalkService;
+import com.style24.core.biz.dao.TscDeliveryDao;
+
 import com.style24.persistence.domain.Order;
 import com.style24.persistence.domain.Point;
 
+import com.style24.core.support.env.TscConstants.MallGb;
+
 import lombok.extern.slf4j.Slf4j;
 
 import java.util.Collection;
@@ -33,6 +38,14 @@ public class TscPointService {
 	@Autowired
 	private TscOrderService orderService;
 
+	@Autowired
+	private TscKakaotalkService kakaotalkService;	
+	
+	@Autowired
+	private TscDeliveryDao deliveryDao;	
+		
+	
+	
 	/**
 	 * 포인트 적립 / 차감
 	 * @param point - 포인트 정보
@@ -115,6 +128,26 @@ public class TscPointService {
 		// 3.구매확정 포인트 히스토리 수정
 		pointDao.updateOrderDecisionPointHst(point);
 
+		// 3-1 알림톡 추가 (배송완료(상품평등록안내)알림톡) 2021-09-08 박중재팀장님 요청!!  
+		try {
+			// 배송완료(상품평등록안내)알림톡
+			Order sweetTracker = new Order();
+			sweetTracker.setOrdDtlNo(point.getOrdDtlNo());
+			Order info = deliveryDao.getOrdNoInfoKakao(sweetTracker);
+			if("Y".equals(info.getAllYn())) {
+				if(MallGb.SELFMALL.value().equals(info.getMallGb()) && "O".equals(info.getOrdExchGb())) {
+					Order orderSend = new Order();
+					orderSend.setOrdNo(info.getOrdNo());
+					orderSend.setCustNo(info.getCustNo());
+					orderSend.setOrdNm(info.getOrdNm());
+					orderSend.setOrdPhnno(info.getOrdPhnno());
+					kakaotalkService.sendDeliveryComplete(orderSend, point.getRegNo());
+				}
+			}
+		}catch(Exception e) {
+			log.debug("배송완료 알림톡 Exception ordDtlNo: "+point.getOrdDtlNo()+" "+e.getStackTrace());
+		}
+		
 		// 4.주문상세 상태 변경 및 히스토리 생성
 		Order order = new Order();
 		order.setOrdDtlStat(TscConstants.OrderDetailStat.PURCHASE_CONFIRM.value());

+ 57 - 49
src/main/java/com/style24/core/support/controller/TscBaseController.java

@@ -1,5 +1,8 @@
 package com.style24.core.support.controller;
 
+import java.lang.reflect.UndeclaredThrowableException;
+import java.sql.SQLException;
+import java.sql.SQLRecoverableException;
 import java.util.Set;
 
 import javax.validation.ConstraintViolation;
@@ -7,15 +10,20 @@ import javax.validation.Validation;
 import javax.validation.Validator;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.ibatis.binding.BindingException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.propertyeditors.StringTrimmerEditor;
 import org.springframework.core.env.Environment;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.WebDataBinder;
 import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.InitBinder;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.fasterxml.jackson.databind.JsonMappingException;
 import com.style24.core.biz.thirdparty.KollusApi;
 import com.style24.core.support.message.TscMessageByLocale;
 
@@ -98,55 +106,55 @@ public class TscBaseController {
 //		errorLogging(ex);
 //		return GagaResponse.error(GagaResponseStatus.BAD_REQUEST.getCode(), ex.getMessage());
 //	}
-//
-//	/**
-//	 * HttpRequestMethodNotSupportedException Handler
-//	 * 
-//	 * @param e - HttpRequestMethodNotSupportedException, SQLRecoverableException
-//	 * @return forwarding URI
-//	 */
-//	@ExceptionHandler({HttpRequestMethodNotSupportedException.class, SQLRecoverableException.class})
-//	public String handleException(HttpRequestMethodNotSupportedException ex) {
-//		return "forward:/error/500";
-//	}
-//
-//	@ExceptionHandler(Throwable.class)
-//	@ResponseBody
-//	public GagaResponse handleException(Throwable throwable) {
-//		errorLogging(throwable);
-//
-//		Throwable rootCause = ExceptionUtils.getRootCause(throwable);
-//
-//		if (rootCause != null) {
-//			throwable = rootCause;
-//		}
-//
-//		if (throwable instanceof SQLException || throwable instanceof BindingException
-//			|| throwable instanceof JsonMappingException
-//			|| throwable instanceof UndeclaredThrowableException) {
-//			String message = String.format("데이터 처리중 에러가 발생하였습니다. 시스템 관리자에게 문의하세요.");
-//			return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), message);
-//		}
-//
-//		return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), throwable.getMessage());
-//	}
-//
-//	private void errorLogging(Throwable throwable) {
-//		if (log.isErrorEnabled()) {
-//			Throwable rootCause = ExceptionUtils.getRootCause(throwable);
-//
-//			if (rootCause != null) {
-//				throwable = rootCause;
-//			}
-//
-//			if (throwable.getMessage() != null) {
-//				log.error(throwable.getMessage(), throwable);
-//			} else {
-//				log.error("ERROR", throwable);
-//			}
-//		}
-//	}
-//
+
+	/**
+	 * HttpRequestMethodNotSupportedException Handler
+	 * 
+	 * @param e - HttpRequestMethodNotSupportedException, SQLRecoverableException
+	 * @return forwarding URI
+	 */
+	@ExceptionHandler({HttpRequestMethodNotSupportedException.class, SQLRecoverableException.class})
+	public String handleException(HttpRequestMethodNotSupportedException ex) {
+		return "forward:/error";
+	}
+
+	@ExceptionHandler(Throwable.class)
+	@ResponseBody
+	public GagaResponse handleException(Throwable throwable) {
+		errorLogging(throwable);
+
+		Throwable rootCause = ExceptionUtils.getRootCause(throwable);
+
+		if (rootCause != null) {
+			throwable = rootCause;
+		}
+
+		if (throwable instanceof SQLException || throwable instanceof BindingException
+			|| throwable instanceof JsonMappingException
+			|| throwable instanceof UndeclaredThrowableException) {
+			String message = String.format("데이터 처리중 에러가 발생하였습니다. 시스템 관리자에게 문의하세요.");
+			return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), message);
+		}
+
+		return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), throwable.getMessage());
+	}
+
+	private void errorLogging(Throwable throwable) {
+		if (log.isErrorEnabled()) {
+			Throwable rootCause = ExceptionUtils.getRootCause(throwable);
+
+			if (rootCause != null) {
+				throwable = rootCause;
+			}
+
+			if (throwable.getMessage() != null) {
+				log.error(throwable.getMessage(), throwable);
+			} else {
+				log.error("ERROR", throwable);
+			}
+		}
+	}
+
 //	@ExceptionHandler(MethodArgumentNotValidException.class)
 //	@ResponseBody
 //	public Object processValidationError(MethodArgumentNotValidException ex) {

+ 12 - 0
src/main/java/com/style24/persistence/mybatis/shop/TscDelivery.xml

@@ -65,4 +65,16 @@
 		
 	</select>
 	
+	<!-- 주문상세번호 조회 -->	
+	<select id="getOrdNoInfoKakao" resultType="Order">
+		/*TscDelivery.getOrdNoInfoKakao*/
+		<![CDATA[
+		SELECT A.ORD_NO, A.CUST_NO, A.ORD_PHNNO , A.ORD_NM, A.MALL_GB, B.ORD_EXCH_GB, B.ORD_DTL_STAT
+		     , CASE WHEN (SELECT COUNT(*) FROM TB_ORDER_DETAIL C WHERE C.ORD_NO = A.ORD_NO AND C.ORD_DTL_STAT='G013_70') > 0 THEN 'N' ELSE 'Y' END  AS ALL_YN  
+		  FROM TB_ORDER A
+		  JOIN TB_ORDER_DETAIL B ON A.ORD_NO = B.ORD_NO 
+		 WHERE B.ORD_DTL_NO = #{ordDtlNo}
+		]]>
+	</select>
+		
 </mapper>