|
|
@@ -13,12 +13,15 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.thymeleaf.util.StringUtils;
|
|
|
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
import com.style24.core.biz.service.TscKcpService;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
+import com.style24.core.support.session.TscSession;
|
|
|
import com.style24.front.biz.dao.TsfOrderDao;
|
|
|
+import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.persistence.domain.Order;
|
|
|
import com.style24.persistence.domain.Payment;
|
|
|
|
|
|
@@ -217,27 +220,42 @@ public class TsfOrderService {
|
|
|
|
|
|
/**
|
|
|
* PG 결제승인
|
|
|
- * @param param - 필수 : payGb(결제수단 : KCP, KAKAO 등), payMeans(결제수단 : G014_30(신용카드) 등), cashReceiptYn(현금영수증여부)
|
|
|
+ * @param param - 필수 : pgGb(결제수단 : KCP, KAKAO 등), payMeans(결제수단 : G014_30(신용카드) 등)
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
public Payment orderPgPayResult(Payment param, HttpServletRequest request, HttpServletResponse response) {
|
|
|
Payment result = new Payment();
|
|
|
+
|
|
|
try {
|
|
|
- if(StringUtils.isEmpty(param.getPayGb())) {
|
|
|
+ if(StringUtils.isEmpty(param.getPgGb())) {
|
|
|
throw new IllegalArgumentException("결제수단을 선택해주세요.");
|
|
|
}
|
|
|
|
|
|
- if("KCP".equals(param.getPayGb())) {
|
|
|
+ if(TscConstants.PgGb.KCP.value().equals(param.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(param.getPgGb())) {
|
|
|
result = coreKcpService.kcpPayRequest(param, request, response);
|
|
|
- } else if ("PAYCO".equals(param.getPayGb())) {
|
|
|
- result = null;
|
|
|
- } else if ("KAKAO".equals(param.getPayGb())) {
|
|
|
+ } else if (TscConstants.PgGb.KAKAO.value().equals(param.getPgGb())) {
|
|
|
result = null;
|
|
|
- } else if ("NAVER".equals(param.getPayGb())) {
|
|
|
+ } else if (TscConstants.PgGb.NAVER.value().equals(param.getPgGb())) {
|
|
|
result = null;
|
|
|
+ } else {
|
|
|
+ throw new IllegalArgumentException("결제 수단이 잘못 입력되었습니다. 새로고침 후 다시 시도해주세요.");
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setPaySq(param.getPaySq());
|
|
|
+ result.setUpdNo(param.getCustNo());
|
|
|
+ result.setRegNo(param.getCustNo());
|
|
|
+
|
|
|
+ if(updatePaymentForOrderFinished(result) < 1) {
|
|
|
+ // TODO 전체 취소 로직 추가
|
|
|
+ coreKcpService.kcpPayRollBack(result, request);
|
|
|
+
|
|
|
+ throw new IllegalArgumentException("결제 정보 저장 실패. 새로고침 후 다시 시작해주세요.");
|
|
|
}
|
|
|
+
|
|
|
+ coreKcpService.kcpPayRollBack(result, request);
|
|
|
} catch(Exception e) {
|
|
|
e.printStackTrace();
|
|
|
throw new IllegalArgumentException(e.getMessage());
|
|
|
@@ -246,6 +264,11 @@ public class TsfOrderService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public int updatePaymentForOrderFinished(Payment param) {
|
|
|
+ return orderDao.updatePaymentForOrderFinished(param);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 주문 상태 별 수량 조회
|
|
|
*
|
|
|
@@ -309,4 +332,22 @@ public class TsfOrderService {
|
|
|
*/
|
|
|
public int updateOrderDisplayYn(Order order) { return orderDao.updateOrderDisplayYn(order); }
|
|
|
|
|
|
+ public Payment setPgDataInfo(Order order) {
|
|
|
+ Payment payment = new Payment();
|
|
|
+ if(TscConstants.PgGb.KAKAO.value().equals(order.getPgGb())) { // 카카오페이
|
|
|
+ // TODO 카카오페이 데이터 세팅
|
|
|
+ payment = null;
|
|
|
+ } else if(TscConstants.PgGb.NAVER.value().equals(order.getPgGb())) { // 네이버페이
|
|
|
+ // TODO 네이버페이 데이터 세팅
|
|
|
+ payment = null;
|
|
|
+ } else if(TscConstants.PgGb.KCP.value().equals(order.getPgGb()) || TscConstants.PgGb.PAYCO.value().equals(order.getPgGb())){ // KCP, PAYCO
|
|
|
+ payment = coreKcpService.setKcpOrderData(order);
|
|
|
+ } else {
|
|
|
+ throw new IllegalArgumentException("결제타입이 잘못 선택되었습니다. 새로고침 후 다시 시도해주세요.");
|
|
|
+ }
|
|
|
+
|
|
|
+ payment.setPgGb(order.getPgGb());
|
|
|
+ payment.setPayMeans(order.getPayMeans());
|
|
|
+ return payment;
|
|
|
+ }
|
|
|
}
|