|
|
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
@@ -359,20 +360,34 @@ public class TsfOrderService {
|
|
|
@Transactional("shopTxnManager")
|
|
|
public Payment orderPgPayResult(Payment param, HttpServletRequest request, HttpServletResponse response) {
|
|
|
Payment result = new Payment();
|
|
|
-
|
|
|
- if(!TscConstants.FrontGb.PC.value().equals(TsfSession.getFrontGb()) && StringUtils.isEmpty(param.getPgGb())) {
|
|
|
+
|
|
|
+ // PC 아니고 PG_GB 없으면 KCP, 신용카드로 설정
|
|
|
+ if (!TscConstants.FrontGb.PC.value().equals(TsfSession.getFrontGb()) && StringUtils.isEmpty(param.getPgGb())) {
|
|
|
param.setPgGb(TscConstants.PgGb.KCP.value());
|
|
|
param.setPayMeans(TscConstants.PayMeans.CREDIT_CARD.value());
|
|
|
}
|
|
|
+
|
|
|
+ // 2021.10.25 주문번호
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
+ int ordNo = 0;
|
|
|
+ String pgGb = "";
|
|
|
|
|
|
try {
|
|
|
- if(StringUtils.isEmpty(param.getPgGb())) {
|
|
|
- throw new IllegalArgumentException("결제수단을 선택해주세요.");
|
|
|
+ // 결제수단체크
|
|
|
+ if (StringUtils.isEmpty(param.getPgGb())) {
|
|
|
+ // 2021.10.26 결제실패내용등록
|
|
|
+ errMsg.append("@errMsg=").append("결제수단을 선택해주세요.");
|
|
|
+ errMsg.append("@ordNo=").append(ordNo);
|
|
|
+ errMsg.append("@pgGb=").append(pgGb);
|
|
|
+ errMsg.append("@stopNo=").append(1);
|
|
|
+
|
|
|
+ throw new IllegalArgumentException(errMsg.toString());
|
|
|
}
|
|
|
-
|
|
|
- if(TscConstants.PgGb.KCP.value().equals(param.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(param.getPgGb())) {
|
|
|
- if(TscConstants.PayMeans.GIFTCARD.value().equals(param.getPayMeans())) {
|
|
|
- // 상품권 100% 결제 (PG PASS)
|
|
|
+
|
|
|
+ // 결제수단이 KCP, PAYCO 일때 실행
|
|
|
+ if (TscConstants.PgGb.KCP.value().equals(param.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(param.getPgGb())) {
|
|
|
+ // 상품권 100% 결제 (PG PASS)
|
|
|
+ if (TscConstants.PayMeans.GIFTCARD.value().equals(param.getPayMeans())) {
|
|
|
result.setPayAmt(0);
|
|
|
result.setPgCpnAmt(0);
|
|
|
result.setNpayPntAmt(0);
|
|
|
@@ -385,30 +400,47 @@ public class TsfOrderService {
|
|
|
result.setPgGb(TscConstants.PgGb.ISTYLE.value());
|
|
|
result.setOrdNo(Integer.parseInt(request.getParameter("ordr_idxx")));
|
|
|
result.setPayMeans(param.getPayMeans());
|
|
|
- } else {
|
|
|
- // 일반 KCP 결제
|
|
|
+ }
|
|
|
+ // 일반 KCP, PAYCO 결제
|
|
|
+ else {
|
|
|
result = coreKcpService.kcpPayRequest(param, request, response);
|
|
|
}
|
|
|
- } else if (TscConstants.PgGb.KAKAO.value().equals(param.getPgGb())) {
|
|
|
+ }
|
|
|
+ // KAKAO 결제 일때 실행
|
|
|
+ else if (TscConstants.PgGb.KAKAO.value().equals(param.getPgGb())) {
|
|
|
result = coreKakaoPayService.approveKakaoPayment(param);
|
|
|
- } else if (TscConstants.PgGb.NAVER.value().equals(param.getPgGb())) {
|
|
|
+ }
|
|
|
+ // NPAY 결제형 일때 실행
|
|
|
+ else if (TscConstants.PgGb.NAVER.value().equals(param.getPgGb())) {
|
|
|
result = coreNaverPayService.approveNaverPayment(param);
|
|
|
- } else {
|
|
|
- throw new IllegalArgumentException("결제 수단이 잘못 입력되었습니다. 새로고침 후 다시 시도해주세요.");
|
|
|
}
|
|
|
-
|
|
|
+ // 그외 결제수단은 실패
|
|
|
+ else {
|
|
|
+ // 2021.10.26 결제실패내용등록
|
|
|
+ errMsg.append("@errMsg=").append("결제 수단이 잘못 입력되었습니다. 새로고침 후 다시 시도해주세요.");
|
|
|
+ errMsg.append("@ordNo=").append(ordNo);
|
|
|
+ errMsg.append("@pgGb=").append(pgGb);
|
|
|
+ errMsg.append("@stopNo=").append(2);
|
|
|
+
|
|
|
+ throw new IllegalArgumentException(errMsg.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2021.10.25 주문번호등록
|
|
|
+ ordNo = result.getOrdNo();
|
|
|
+ pgGb = result.getPgGb();
|
|
|
+
|
|
|
// 결제 수단이 없는 경우(KAKAO, NAVER) CARD로 세팅
|
|
|
- if(StringUtils.isEmpty(param.getPayMeans())) {
|
|
|
+ if (StringUtils.isEmpty(param.getPayMeans())) {
|
|
|
result.setPayMeans(TscConstants.PayMeans.CREDIT_CARD.value());
|
|
|
}
|
|
|
|
|
|
- if(TscConstants.FrontGb.PC.value().equals(TsfSession.getFrontGb())) {
|
|
|
+ if (TscConstants.FrontGb.PC.value().equals(TsfSession.getFrontGb())) {
|
|
|
result.setUpdNo(param.getCustNo());
|
|
|
result.setRegNo(param.getCustNo());
|
|
|
}
|
|
|
|
|
|
// 페이코의 경우처럼 result로 shop_user_id가 안넘어 오는 경우가 있음. custNo가 없을 경우 한번 더 체크.
|
|
|
- if(result.getCustNo() < 1) {
|
|
|
+ if (result.getCustNo() < 1) {
|
|
|
result.setCustNo(param.getCustNo());
|
|
|
result.setRegNo(param.getCustNo());
|
|
|
result.setUpdNo(param.getCustNo());
|
|
|
@@ -422,13 +454,17 @@ public class TsfOrderService {
|
|
|
}
|
|
|
|
|
|
// TB_PAYMENT 등록. 실패시 PG 환불.
|
|
|
- if(TscConstants.PgGb.NAVER.value().equals(param.getPgGb()) && !"SUCCESS".equals(result.getCode().toUpperCase())) {
|
|
|
+ if (TscConstants.PgGb.NAVER.value().equals(param.getPgGb()) && !"SUCCESS".equals(result.getCode().toUpperCase())) {
|
|
|
result.setPgGb(param.getPgGb());
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- if(coreOrderDao.updatePaymentOrderComplete(result) < 1) {
|
|
|
- if(TscConstants.PgGb.KCP.value().equals(param.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(param.getPgGb())) {
|
|
|
+
|
|
|
+ // 결제완료 업데이트
|
|
|
+ int resultCnt = coreOrderDao.updatePaymentOrderComplete(result);
|
|
|
+
|
|
|
+ // 결제실패일때 실행
|
|
|
+ if (resultCnt < 1) {
|
|
|
+ if (TscConstants.PgGb.KCP.value().equals(param.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(param.getPgGb())) {
|
|
|
if(TscConstants.PayMeans.GIFTCARD.value().equals(param.getPayMeans())) {
|
|
|
// 상품권 100% 결제 (PG PASS)
|
|
|
result.setPayStat(TscConstants.PaymentStat.PAY_BEFORE_CANCEL.value());
|
|
|
@@ -443,15 +479,31 @@ public class TsfOrderService {
|
|
|
param.setLeftAmt(0);
|
|
|
coreNaverPayService.naverPayRollBack(param);
|
|
|
}
|
|
|
-
|
|
|
- throw new IllegalArgumentException("결제 정보 저장 실패. 새로고침 후 다시 시작해주세요.");
|
|
|
- } else {
|
|
|
+
|
|
|
+ // 2021.10.26 결제실패내용등록
|
|
|
+ errMsg.append("@errMsg=").append("결제 정보 저장 실패. 새로고침 후 다시 시작해주세요.");
|
|
|
+ errMsg.append("@ordNo=").append(ordNo);
|
|
|
+ errMsg.append("@pgGb=").append(pgGb);
|
|
|
+ errMsg.append("@stopNo=").append(3);
|
|
|
+
|
|
|
+ throw new IllegalArgumentException(errMsg.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+ // 결제성공일때 실행
|
|
|
+ else {
|
|
|
// TB_DELIVERY_FEE PAY_SQ 등록
|
|
|
coreOrderDao.updateDeliveryFeePaySq(result);
|
|
|
}
|
|
|
} catch(Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- throw new IllegalArgumentException(e.getMessage());
|
|
|
+
|
|
|
+ // 2021.10.26 결제실패내용등록
|
|
|
+ errMsg.append("@errMsg=").append(e.getMessage());
|
|
|
+ errMsg.append("@ordNo=").append(ordNo);
|
|
|
+ errMsg.append("@pgGb=").append(pgGb);
|
|
|
+ errMsg.append("@stopNo=").append(4);
|
|
|
+
|
|
|
+ throw new IllegalArgumentException(errMsg.toString());
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
@@ -2523,4 +2575,19 @@ public class TsfOrderService {
|
|
|
throw new Error(e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 2021.10.25 결제실패 등록
|
|
|
+ // @Transactional("shopTxnManager", Propagtion.REQUIRES_NEW)
|
|
|
+ // @Transactional(propagation=Propagation.REQUIRES_NEW)
|
|
|
+ @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void createPaymentFail(Order order) {
|
|
|
+ Order po = new Order();
|
|
|
+ po.setOrdNo(order.getOrdNo());
|
|
|
+ po.setStepNo(order.getStepNo());
|
|
|
+ po.setPgGb(order.getPgGb());
|
|
|
+ po.setErrMsg(order.getErrMsg());
|
|
|
+ po.setRegNo(order.getRegNo());
|
|
|
+
|
|
|
+ coreOrderDao.createPaymentFail(po);
|
|
|
+ }
|
|
|
}
|