Forráskód Böngészése

이태영 - 20210616 네이버페이 주문형 개발 중

xodud lee 4 éve
szülő
commit
23c8caf20c

+ 79 - 2
src/main/java/com/style24/core/biz/service/TscNaverPayService.java

@@ -11,8 +11,10 @@ import com.style24.core.biz.checkout.MallServiceLocator;
 import com.style24.core.biz.checkout.MallServiceSOAP11BindingStub;
 import com.style24.core.biz.checkout.base.AccessCredentialsType;
 import com.style24.core.biz.checkout.base.DeliveryMethodType;
-import com.style24.core.biz.checkout.mall.ShipProductOrderRequest;
-import com.style24.core.biz.checkout.mall.ShipProductOrderResponse;
+import com.style24.core.biz.checkout.mall.*;
+import com.style24.core.biz.dao.TscOrderChangeDao;
+import com.style24.persistence.domain.OrderChange;
+import org.apache.axis.AxisFault;
 import org.apache.commons.lang3.StringUtils;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +56,9 @@ public class TscNaverPayService {
 	@Autowired
 	private TscOrderDao orderDao;
 
+	@Autowired
+	private TscOrderChangeDao orderChangeDao;
+
 	private String timeStamp;
 	private String signature;
 
@@ -292,6 +297,78 @@ public class TscNaverPayService {
 		cancelNaverPayment(payment);
 	}
 
+	public void sendNaverPayOrderCancelConfirm(Order param) {
+		Collection<Order> confirmList = orderChangeDao.getOrderChangeDetailList(param);
+		try {
+			Security.addProvider(new BouncyCastleProvider());
+			AccessCredentialsType accessCredentialsType = new AccessCredentialsType();
+			MallServiceLocator MSL = new MallServiceLocator(env.getProperty("naverPay.port.address"));
+			MallServiceSOAP11BindingStub stub = new MallServiceSOAP11BindingStub();
+
+			stub = (MallServiceSOAP11BindingStub) MSL.getMallServiceSOAP11Port();
+
+			ApproveCancelApplicationRequest approveCancelApplicationRequest 	= null;
+			ApproveCancelApplicationResponse approveCancelApplicationResponse 	= null;
+
+			// 네이버페이 주문상세 정보 가져올  Request , Response 세팅
+			GetProductOrderInfoListRequest getProdOrderInfoRequest = new GetProductOrderInfoListRequest();
+			GetProductOrderInfoListResponse getProdOrderInfoResponse = new GetProductOrderInfoListResponse();
+
+			for(Order order : confirmList) {
+				//서명생성
+				generateSignature("ApproveCancelApplication", env.getProperty("naverPay.secret.key"));
+				log.debug("ApproveCancelApplication(취소요청승인 데이타 송신) :: timeStamp === " + timeStamp);
+
+				//인증정보
+				accessCredentialsType.setAccessLicense(env.getProperty("naverPay.access.license"));
+				accessCredentialsType.setSignature(signature);
+				accessCredentialsType.setTimestamp(timeStamp);
+
+				approveCancelApplicationRequest = new ApproveCancelApplicationRequest();
+				approveCancelApplicationRequest.setAccessCredentials(accessCredentialsType);
+				approveCancelApplicationRequest.setDetailLevel("Full");
+				approveCancelApplicationRequest.setVersion(env.getProperty("naverPay.version"));
+				approveCancelApplicationRequest.setRequestID("");
+				approveCancelApplicationRequest.setProductOrderID(order.getNpayOrdDtlNo());
+
+				approveCancelApplicationResponse = stub.approveCancelApplication(approveCancelApplicationRequest);
+
+				String resultStr = "";
+				if (approveCancelApplicationResponse.getResponseType() != null) {
+					resultStr = approveCancelApplicationResponse.getResponseType().toUpperCase();
+				}
+
+				//결과 출력
+				if ("SUCCESS".equals(resultStr)) {
+					log.info("취소승인 성공 주문번호 ===> " + param.getOrdNo());
+					log.info("취소승인 성공 네이버상품주문번호 ===> " + order.getNpayOrdDtlNo());
+				} else {
+					log.debug("취소승인 에러");
+					log.debug("주문번호 ===> " + param.getOrdNo());
+					log.debug("네이버주문번호 ===> " + order.getNpayOrdDtlNo());
+					log.debug("Code : " + approveCancelApplicationResponse.getError().getCode());
+					log.debug("Message : " + approveCancelApplicationResponse.getError().getMessage());
+					log.debug("Detail : " + approveCancelApplicationResponse.getError().getDetail());
+
+					Order fail = new Order();
+					fail.setErrorReason("취소 완료 주문 정보 송부 에러");
+					fail.setOrdNo(order.getOrdNo());
+					fail.setOptCd("sendNaverPayOrderCancelConfirm");
+					fail.setResultCd(approveCancelApplicationResponse.getError().getCode());
+					fail.setResultMsg(approveCancelApplicationResponse.getError().getMessage());
+					fail.setMallCd(env.getProperty("naverPay.shop.id"));
+					fail.setAccessLicense(env.getProperty("naverPay.access.license"));
+					fail.setSecretKey(env.getProperty("naverPay.secret.key"));
+					fail.setRegNo(param.getRegNo());
+
+					orderDao.createNaverPayErrorLog(fail);
+				}
+			}
+		} catch(Exception e) {
+			throw new IllegalStateException("네이버페이 취소 완료 송부 실패");
+		}
+	}
+
 	public void sendNaverPayDeliveryStartOrder(Collection<Order> params, String statGb) {
 		for(Order param : params) {
 			if ("SHIPPING".equals(statGb)) {

+ 6 - 0
src/main/java/com/style24/core/biz/service/TscOrderChangeService.java

@@ -1277,6 +1277,7 @@ public class TscOrderChangeService {
 			// 전체 취소 처리
 			ordChgSq = allCnclComplete(orderChange);
 			result.setInt("ordChgSq", ordChgSq);
+			result.setString("pgGb", refundPreInfo.getString("pgGb"));			// PG구분
 		} else {
 			// 3. 환불금액계산
 			// 2021.01.19 취소신청정보를 목록 (주문상세번호, 취소/반품수량) 으로 표현
@@ -1301,6 +1302,7 @@ public class TscOrderChangeService {
 
 			// 부분취소 처리
 			result = partialCancel(result, userNo);
+			result.setString("pgGb", refundPreInfo.getString("pgGb"));			// PG구분
 		}
 
 		return result;
@@ -3853,4 +3855,8 @@ public class TscOrderChangeService {
 
 		return sb.toString();
 	}
+
+	public Payment getPaymentInfo(Payment param) {
+		return orderChangeDao.getPaymentInfo(param);
+	}
 }

+ 2 - 1
src/main/java/com/style24/persistence/mybatis/shop/TscOrderChange.xml

@@ -423,6 +423,7 @@
 		     , OC.CHG_GB
 		     , FN_GET_CODE_NM('G680', OC.CHG_GB)       AS CHG_GB_NM
 		     , OD.GOODS_CD
+		     , OD.NPAY_ORD_DTL_NO
 		     , ODI.OPT_CD1
 		     , ODI.OPT_CD2
 		     , OCD.CHG_STAT
@@ -3803,7 +3804,7 @@
 
 	<!-- 마이페이지 취소 상세 정보 조회 -->
 	<select id="getCreCancelDetailInfo" parameterType="OrderChange" resultType="OrderChange">
-		/* TsfOrderChange.getCreCancelDetailInfo */
+		/* TscOrderChange.getCreCancelDetailInfo */
 		SELECT GROUP_CONCAT(Z.ITEM_NM ORDER BY Z.ORD_DTL_ITEM_SQ SEPARATOR '!@!')       AS ITEM_NM
 		     , GROUP_CONCAT(Z.COLOR_NM ORDER BY Z.ORD_DTL_ITEM_SQ)                      AS COLOR_NM
 		     , GROUP_CONCAT(Z.OPT_CD1 ORDER BY Z.ORD_DTL_ITEM_SQ)                       AS OPT_CD1