|
|
@@ -1,15 +1,20 @@
|
|
|
package com.style24.batch.biz.service;
|
|
|
|
|
|
+import com.gagaframework.web.parameter.GagaMap;
|
|
|
import com.nhncorp.psinfra.toolkit.SimpleCryptLib;
|
|
|
import com.style24.batch.biz.checkout.MallServiceLocator;
|
|
|
import com.style24.batch.biz.checkout.MallServiceSOAP11BindingStub;
|
|
|
import com.style24.batch.biz.checkout.base.AccessCredentialsType;
|
|
|
import com.style24.batch.biz.checkout.base.ChangedProductOrderInfo;
|
|
|
import com.style24.batch.biz.checkout.base.ProductOrderChangeType;
|
|
|
+import com.style24.batch.biz.checkout.base.ProductOrderInfo;
|
|
|
import com.style24.batch.biz.checkout.mall.GetChangedProductOrderListRequest;
|
|
|
import com.style24.batch.biz.checkout.mall.GetChangedProductOrderListResponse;
|
|
|
+import com.style24.batch.biz.checkout.mall.GetProductOrderInfoListRequest;
|
|
|
+import com.style24.batch.biz.checkout.mall.GetProductOrderInfoListResponse;
|
|
|
import com.style24.batch.biz.dao.TsbNaverPayDao;
|
|
|
import com.style24.batch.biz.dao.TsbOrderDao;
|
|
|
+import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.persistence.domain.Order;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.axis.AxisFault;
|
|
|
@@ -17,14 +22,13 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.security.Security;
|
|
|
import java.security.SignatureException;
|
|
|
import java.text.ParsePosition;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 네이버페이 Service
|
|
|
@@ -41,14 +45,9 @@ public class TsbNaverPayService {
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
|
|
|
- private Calendar from;
|
|
|
- private Calendar to;
|
|
|
|
|
|
- private String stdt;
|
|
|
- private String eddt;
|
|
|
-
|
|
|
- private String timeStamp;
|
|
|
- private String signature;
|
|
|
+ private Calendar from, to;
|
|
|
+ private String stdt, eddt, timeStamp, signature;
|
|
|
|
|
|
public Order setInitData() {
|
|
|
Order time = this.getSelectDt();
|
|
|
@@ -59,7 +58,7 @@ public class TsbNaverPayService {
|
|
|
stdt = "20200616000000";
|
|
|
eddt = "20200616235959";
|
|
|
|
|
|
- log.debug("stdt : eddt ---> " + stdt + " : " + eddt);
|
|
|
+ log.info("stdt : eddt ---> " + stdt + " : " + eddt);
|
|
|
}
|
|
|
|
|
|
Date tmp1 = new SimpleDateFormat("yyyyMMddHHmmss").parse(stdt, new ParsePosition(0));
|
|
|
@@ -93,6 +92,15 @@ public class TsbNaverPayService {
|
|
|
return naverPayDao.getSelectDt();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 네이버페이 주문 변경 리스트 조회
|
|
|
+ * @param option, from, to
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ * @author xodud1202
|
|
|
+ * @since 2021. 05. 28
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
public ChangedProductOrderInfo[] changedProductOrderList(ProductOrderChangeType option, Calendar from, Calendar to) throws Exception {
|
|
|
ChangedProductOrderInfo[] result = null;
|
|
|
|
|
|
@@ -113,7 +121,7 @@ public class TsbNaverPayService {
|
|
|
|
|
|
//서명생성
|
|
|
generateSignature("GetChangedProductOrderList", secretKey);
|
|
|
- log.debug("GetChangedProductOrderList(변경 상품주문 조회) :: timeStamp === " + timeStamp);
|
|
|
+ log.info("GetChangedProductOrderList(변경 상품주문 조회) :: timeStamp === " + timeStamp);
|
|
|
|
|
|
//인증정보
|
|
|
accessCredentialsType.setAccessLicense(accessLicense);
|
|
|
@@ -139,45 +147,159 @@ public class TsbNaverPayService {
|
|
|
}
|
|
|
|
|
|
//결과 출력
|
|
|
- /*if ("SUCCESS".equals(resultStr)) {
|
|
|
+ if ("SUCCESS".equals(resultStr)) {
|
|
|
result = response.getChangedProductOrderInfoList();
|
|
|
} else {
|
|
|
- CommonTemp commonTemp = new CommonTemp();
|
|
|
+ Order fail = new Order();
|
|
|
+
|
|
|
+ log.info("response.getResponseType()) : " + response.getResponseType());
|
|
|
+ log.info("option.toString() : " + option.toString());
|
|
|
+ log.info("Code : " + response.getError().getCode());
|
|
|
+ log.info("Message : " + response.getError().getMessage());
|
|
|
+ log.info("Detail : " + response.getError().getDetail());
|
|
|
+
|
|
|
+ fail.setErrorReason("변경상품주문조회 에러");
|
|
|
+ fail.setOptCd(option.toString());
|
|
|
+ fail.setResultCd(response.getError().getCode());
|
|
|
+ fail.setResultMsg(response.getError().getMessage());
|
|
|
+ fail.setSiteCd(mallId);
|
|
|
+ fail.setAccessLicense(accessLicense);
|
|
|
+ fail.setSecretKey(secretKey);
|
|
|
+ fail.setRegNo(0);
|
|
|
+
|
|
|
+ naverPayDao.createNaverPayErrorLog(fail);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 결제 정보 수정
|
|
|
+ * @param changedProductOrderList
|
|
|
+ * @return
|
|
|
+ * @author xodud1202
|
|
|
+ * @since 2021. 05. 28
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public Order createOrderInfo(ChangedProductOrderInfo[] changedProductOrderList) throws Exception {
|
|
|
+ String[] productOrderIdList = new String[changedProductOrderList.length];
|
|
|
+ String orderStat = TscConstants.OrderDetailStat.PAYMENT_COMPLETE.value(); // 결제완료
|
|
|
+
|
|
|
+ for (int i=0; i<changedProductOrderList.length; i++) {
|
|
|
+ productOrderIdList[i] = changedProductOrderList[i].getProductOrderID();
|
|
|
+ }
|
|
|
+
|
|
|
+ ProductOrderInfo[] productOrderInfo = productOrderInfoList(productOrderIdList);
|
|
|
+
|
|
|
+ byte[] encryptKey = null;
|
|
|
+ encryptKey = SimpleCryptLib.generateKey(timeStamp, env.getProperty("naver.pay.secret.key"));
|
|
|
|
|
|
- log.debug("response.getResponseType()) : " + response.getResponseType());
|
|
|
- log.debug("option.toString() : " + option.toString());
|
|
|
- log.debug("Code : " + response.getError().getCode());
|
|
|
- log.debug("Message : " + response.getError().getMessage());
|
|
|
- log.debug("Detail : " + response.getError().getDetail());
|
|
|
+ // SMS 주문번호 보내기 ??
|
|
|
+ List<Order> naverPayList = new ArrayList<Order>();
|
|
|
|
|
|
- commonTemp.setData_01("변경상품주문조회 에러");
|
|
|
- commonTemp.setData_02(option.toString());
|
|
|
- commonTemp.setData_03(response.getError().getCode());
|
|
|
- commonTemp.setData_04(response.getError().getMessage());
|
|
|
- commonTemp.setData_05("");
|
|
|
+ String rcpDtlAddr = "";
|
|
|
+ String orderNo = "";
|
|
|
+ String naverSeq = "";
|
|
|
|
|
|
- commonTemp.setData_06(siteName);
|
|
|
- commonTemp.setData_07(mallId);
|
|
|
- commonTemp.setData_08(accessLicense);
|
|
|
- commonTemp.setData_09(secretKey);
|
|
|
- commonTemp.setData_10("");
|
|
|
+ if (productOrderInfo != null) {
|
|
|
+ for (int i=0; i<productOrderInfo.length; i++) {
|
|
|
+ rcpDtlAddr = "";
|
|
|
|
|
|
- commonTempService.insertCommonTempNpayLog(commonTemp);
|
|
|
- }*/
|
|
|
+ Order naverParams = new Order();
|
|
|
+ orderNo = productOrderInfo[i].getProductOrder().getMerchantCustomCode1(); // 가맹점 주문번호
|
|
|
+ // naverSeq = productOrderInfo[i].getProductOrder().getProductOrderID(); // 네이버주문번호순번
|
|
|
+
|
|
|
+ if (orderNo != null) {
|
|
|
+ naverParams.setOrdNo(Integer.parseInt(orderNo));
|
|
|
+ naverParams.setNpayOrdNo(Integer.parseInt(productOrderInfo[i].getOrder().getOrderID())); // 네이버 주문번호
|
|
|
+
|
|
|
+ // 2019.01.04 전석훈 추가
|
|
|
+ naverParams.setSiteCd(productOrderInfo[i].getProductOrder().getMallID());
|
|
|
+
|
|
|
+ // 이어서 추가 >> 주문 데이터 확인하는데 세트상품 확인 방법 체크할것.
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
+ /**
|
|
|
+ * 주문상세 정보 조회
|
|
|
+ * @param productOrderIdList
|
|
|
+ * @return
|
|
|
+ * @author xodud1202
|
|
|
+ * @since 2021. 05. 28
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public ProductOrderInfo[] productOrderInfoList(String[] productOrderIdList) {
|
|
|
+ ProductOrderInfo[] result = null;
|
|
|
+ try {
|
|
|
+ if (productOrderIdList != null) {
|
|
|
+ Security.addProvider(new BouncyCastleProvider());
|
|
|
+ AccessCredentialsType accessCredentialsType = new AccessCredentialsType();
|
|
|
+ MallServiceLocator MSL = new MallServiceLocator(env.getProperty("naver.pay.port.address"));
|
|
|
+ MallServiceSOAP11BindingStub stub = new MallServiceSOAP11BindingStub();
|
|
|
+ stub = (MallServiceSOAP11BindingStub) MSL.getMallServiceSOAP11Port();
|
|
|
+ GetProductOrderInfoListRequest request = new GetProductOrderInfoListRequest();
|
|
|
+ GetProductOrderInfoListResponse response = new GetProductOrderInfoListResponse();
|
|
|
+
|
|
|
+ //서명생성
|
|
|
+ generateSignature("GetProductOrderInfoList", env.getProperty("naver.pay.secret.key"));
|
|
|
+ log.info("GetProductOrderInfoList(상품주문 내역 상세 조회) :: timeStamp === " + timeStamp);
|
|
|
+
|
|
|
+ //인증정보
|
|
|
+ accessCredentialsType.setAccessLicense(env.getProperty("naver.pay.access.license"));
|
|
|
+ accessCredentialsType.setSignature(signature);
|
|
|
+ accessCredentialsType.setTimestamp(timeStamp);
|
|
|
+
|
|
|
+ request.setAccessCredentials(accessCredentialsType);
|
|
|
+ request.setDetailLevel("Full");
|
|
|
+ request.setVersion(env.getProperty("naver.pay.version"));
|
|
|
+ request.setRequestID("");
|
|
|
+ request.setProductOrderIDList(productOrderIdList);
|
|
|
+
|
|
|
+ //GetChangedProductOrderList Response 수신
|
|
|
+ response = stub.getProductOrderInfoList(request);
|
|
|
+
|
|
|
+ String resultStr = "";
|
|
|
+ if (response.getResponseType() != null) {
|
|
|
+ resultStr = response.getResponseType().toUpperCase();
|
|
|
+ }
|
|
|
+
|
|
|
+ //결과 출력
|
|
|
+ if ("SUCCESS".equals(resultStr)) {
|
|
|
+ result = response.getProductOrderInfoList();
|
|
|
+ } else {
|
|
|
+ log.info("상품주문내역조회 에러");
|
|
|
+ log.info("Code : " + response.getError().getCode());
|
|
|
+ log.info("Message : " + response.getError().getMessage());
|
|
|
+ log.info("Detail : " + response.getError().getDetail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("***** productOrderInfoList end *****");
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 서명생성
|
|
|
+ * @param operationName
|
|
|
+ * @param secreKey
|
|
|
+ * @author xodud1202
|
|
|
+ * @since 2021. 05. 28
|
|
|
*/
|
|
|
- private void generateSignature(String operationName, String secreKey) {
|
|
|
+ private void generateSignature(String operationName, String secretKey) {
|
|
|
timeStamp = SimpleCryptLib.getTimestamp();
|
|
|
|
|
|
String data = timeStamp + env.getProperty("naver.pay.service.name") + operationName;
|
|
|
|
|
|
try {
|
|
|
- signature = SimpleCryptLib.generateSign(data, secreKey);
|
|
|
+ signature = SimpleCryptLib.generateSign(data, secretKey);
|
|
|
} catch (SignatureException e) {
|
|
|
log.error(e.getMessage()); //서명정보 실패
|
|
|
}
|