Explorar o código

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

commit
xodud1202 %!s(int64=5) %!d(string=hai) anos
pai
achega
0f00b7e6b0

+ 143 - 0
src/main/java/com/style24/front/biz/service/TsfCustomerService.java

@@ -3,6 +3,7 @@ package com.style24.front.biz.service;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.web.parameter.GagaMap;
 import com.gagaframework.web.security.GagaPasswordEncoder;
+import com.kcp.J_PP_CLI_N;
 import com.style24.core.biz.service.TscCustomerService;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.session.TscSession;
@@ -18,12 +19,18 @@ import com.style24.persistence.domain.WishList;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -56,6 +63,8 @@ public class TsfCustomerService {
 	@Autowired
 	private ObjectMapper objectMapper;
 
+	@Autowired
+	private Environment env;
 
 	/**
 	 * 고객아이디 찾기
@@ -776,4 +785,138 @@ public class TsfCustomerService {
 
 		return result;
 	}
+
+	/**
+	 * KCP 계좌인증 처리
+	 *
+	 * @param request
+	 * @result GagaMap
+	 * @author jsshin
+	 * @since 2021. 03. 17
+	 */
+	public GagaMap checkAccount(HttpServletRequest request) {
+		try {
+			request.setCharacterEncoding("euc-kr");
+		} catch (Exception e) {
+			e.getMessage();
+		}
+		GagaMap resultMap = new GagaMap();
+		J_PP_CLI_N c_PayPlus = new J_PP_CLI_N();
+		// c_PayPlus.mf_init( "", env.getProperty("pg.kcp.gw.url"), env.getProperty("pg.kcp.gw.port"), 0, env.getProperty("pg.kcp.log.dir") );
+		c_PayPlus.mf_init( "", "paygw.kcp.co.kr", "8090", 0, env.getProperty("pg.kcp.log.dir") );
+		c_PayPlus.mf_init_set();
+//		String siteCd = env.getProperty("pg.kcp.site.cd");
+//		String siteKey = env.getProperty("pg.kcp.site.key");
+		String kcpSiteCd = "U3476";
+		String kcpsiteKey = "4aVa--.Xz8Fc78nwYPsrmmY__";
+
+		String custIp = request.getRemoteAddr();
+		String tranCd = "00100000";
+		String ordNo = "0";
+		String bankCode = "04";//map.getString("bankList");   //"04";
+		String accountNo = "27560104388848";//map.getString("accountNumber"); //"27560104388848";
+
+
+		int payx_data_set;
+		int common_data_set;
+
+		payx_data_set = c_PayPlus.mf_add_set("payx_data");
+		common_data_set = c_PayPlus.mf_add_set("common");
+
+		c_PayPlus.mf_set_us(common_data_set, "amount", "0");
+		c_PayPlus.mf_set_us(common_data_set, "cust_ip", custIp);
+		c_PayPlus.mf_set_us(common_data_set, "escw_mod", "N");
+
+		c_PayPlus.mf_add_rs(payx_data_set, common_data_set);
+
+		// 주문 정보
+		int ordr_data_set = c_PayPlus.mf_add_set("ordr_data");
+
+		c_PayPlus.mf_set_us(ordr_data_set, "ordr_idxx", ordNo);
+
+		// 계좌 정보
+		int acnt_data_set = c_PayPlus.mf_add_set("bank");
+		log.info("accountHolder {}" , request.getParameter("accountHolder"));
+		c_PayPlus.mf_set_us(acnt_data_set, "bk_owner_nm", request.getParameter("accountHolder"));				// 예금주명
+		c_PayPlus.mf_set_us(acnt_data_set, "bk_txtype", "74200000");	    // 지불 타입 (계좌 인증)
+		c_PayPlus.mf_set_us(acnt_data_set, "bk_code", bankCode);					// 은행 코드
+		c_PayPlus.mf_set_us(acnt_data_set, "bk_account_no", accountNo);			// 발급 계좌
+		c_PayPlus.mf_add_rs(payx_data_set, acnt_data_set);
+
+		c_PayPlus.mf_do_tx(kcpSiteCd, kcpsiteKey, tranCd, custIp, ordNo, "3", "0" );
+
+		log.info("recCd =====> {}", c_PayPlus.m_res_cd);
+		log.info("resMsg =====> {}", c_PayPlus.m_res_msg);
+		try {
+			log.info("resMsg 1. kr =====> {}", euckrToUtf8(c_PayPlus.m_res_msg));
+			log.info("resMsg 2. kr =====> {}", euckrToUtf82(c_PayPlus.m_res_msg));
+			log.info("resMsg 3. kr =====> {}", utf83(c_PayPlus.m_res_msg));
+			log.info("resMsg 4. kr =====> {}", new String(c_PayPlus.m_res_msg.getBytes("utf-8"), "utf-8"));
+
+		} catch (Exception e) {
+			log.error(e.getMessage());
+		}
+
+		log.info("res_en_msg =====> {}", c_PayPlus.getRecvMsgOfKey("res_en_msg"));
+		resultMap.set("ResMsg", c_PayPlus.getRecvMsgOfKey("res_en_msg"));				// 결과 메시지
+
+		if ("0000".equals(c_PayPlus.m_res_cd)) {
+			resultMap.setBoolean("isPossible", true);
+			log.info("tno ====> {}", c_PayPlus.mf_get_res("tno"));				// KCP 거래 고유 번호
+			log.info("app_time ====> {}", c_PayPlus.mf_get_res("app_time"));
+		} else {
+			resultMap.setBoolean("isPossible", false);
+		}
+
+		return resultMap;
+	}
+
+	private String euckrToUtf8(String euc_kr_str) throws UnsupportedEncodingException {
+		//euc_kr_str - euc-kr 문자열
+
+		CharBuffer cbuffer = CharBuffer.wrap((new String(euc_kr_str.getBytes(Charset.forName("EUC-KR")), "EUC-KR")).toCharArray());
+
+		Charset utf8charset = StandardCharsets.UTF_8;
+
+		ByteBuffer bbuffer = utf8charset.encode(cbuffer);
+
+
+
+		//변환된 UTF-8 문자열
+
+		return  new String(bbuffer.array());
+	}
+
+	private String utf8ToEuckr(String euc_kr_str) throws UnsupportedEncodingException {
+		//euc_kr_str - euc-kr 문자열
+
+		CharBuffer cbuffer = CharBuffer.wrap((new String(euc_kr_str.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)).toCharArray());
+
+		Charset utf8charset = Charset.forName("EUC-KR");
+
+		ByteBuffer bbuffer = utf8charset.encode(cbuffer);
+
+
+
+		//변환된 UTF-8 문자열
+
+		return  new String(bbuffer.array());
+	}
+
+	private String utf8ToEuckr2(String value) throws UnsupportedEncodingException {
+		byte[] eucKr = value.getBytes("EUC-KR");
+		return eucKr.toString();
+	}
+
+	private String euckrToUtf82(String value) throws UnsupportedEncodingException {
+		byte[] utf8 = value.getBytes("UTF-8");
+		return utf8.toString();
+	}
+
+	private String utf83(String value) throws UnsupportedEncodingException {
+		CharBuffer cbuffer = CharBuffer.wrap((new String(value.getBytes("EUC-KR"), "EUC-KR")).toCharArray());
+		Charset utf8charset = Charset.forName("UTF-8");
+		ByteBuffer bbuffer = utf8charset.encode(cbuffer);
+		return new String(bbuffer.array());
+	}
 }

+ 30 - 3
src/main/java/com/style24/front/biz/thirdparty/Yes24Login.java

@@ -2,6 +2,7 @@ package com.style24.front.biz.thirdparty;
 
 import com.gagaframework.web.parameter.GagaMap;
 import com.gagaframework.web.util.GagaFileUtil;
+import com.style24.core.support.util.CryptoUtils;
 import com.style24.front.support.security.session.TsfSession;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +30,7 @@ public class Yes24Login {
 	public static final String PROTOCOL = "http://";
 
 	/**
-	 * YES24 로그인 
+	 * YES24 로그인 화면
 	 * @param state - 콜백 시 해당 값으로 비교 및 모바일을 redirect 값이 있음
 	 * @return String - 호출 url정보
 	 * @author jsshin
@@ -38,19 +39,45 @@ public class Yes24Login {
 	public String getAuthorizeUrl(String state) {
 		String authorizeUrl = "https://www.yes24.com/Templates/FTLoginPartner.aspx";
 		String callBackUrl = "/signin/yes24LoginCallback";
+		String id = TsfSession.getFrontGb().equals("P") ? "PID" : "MID";
 		StringBuilder apiUrlBuilder = new StringBuilder();
 		String redirectUri = GagaFileUtil.getConcatenationPath(PROTOCOL + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
 		apiUrlBuilder.append(authorizeUrl)
-				.append("?PID=101582")
+				.append("?"+id+"=101582")
 				.append("&ReturnURL=")
 				.append(redirectUri);
 		log.info("apiUrlBuilder ===> {}", apiUrlBuilder.toString());
 		return apiUrlBuilder.toString();
 	}
 
-	public GagaMap getAccessInfo(String ci) {
+	/**
+	 * YES24 정보
+	 * @param inpin - yes24 전달 해준 암호화된 : "요청날짜|CI"
+	 * @return String - 호출 url정보
+	 * @author jsshin
+	 * @since 2021. 03. 03
+	 */
+	public GagaMap getAccessInfo(String inpin) {
 		GagaMap result = new GagaMap();
+		//1. ipin 복호화
+		String decryptIpin = CryptoUtils.decryptAES(inpin);
+		log.info("decryptIpin {}", decryptIpin);
+
+		//2. ipin 값에서 ci 값 분리
+		String decryptIpinValues[] = decryptIpin.split("|");
+		log.info("decryptIpinValues.length {}", decryptIpinValues.length);
+		log.info("decryptIpinValues0 {}", decryptIpinValues[0]);
+		log.info("decryptIpinValues1 {}", decryptIpinValues[1]);
+
+		//3. ci값 추출 후 통신
+		String encryptCi = CryptoUtils.encryptAES(decryptIpinValues[0]);
+
+
 
 		return result;
 	}
+
+
+
+
 }

+ 34 - 40
src/main/java/com/style24/front/biz/web/TsfIndexController.java

@@ -1,24 +1,18 @@
 package com.style24.front.biz.web;
 
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.SecureRandom;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.web.parameter.GagaMap;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.gagaframework.web.rest.server.GagaResponseStatus;
 import com.style24.core.support.env.TscConstants;
+import com.style24.core.support.message.TscMessageByLocale;
 import com.style24.front.biz.service.TsfCustomerService;
 import com.style24.front.biz.thirdparty.KaKaoLogin;
 import com.style24.front.biz.thirdparty.NaverLogin;
 import com.style24.front.biz.thirdparty.Yes24Login;
+import com.style24.front.support.controller.TsfBaseController;
+import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.CustSnsInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -29,13 +23,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.servlet.ModelAndView;
 
-import com.style24.core.support.message.TscMessageByLocale;
-import com.style24.front.support.controller.TsfBaseController;
-import com.style24.front.support.security.session.TsfSession;
-
-import lombok.extern.slf4j.Slf4j;
-
-import com.gagaframework.web.rest.server.GagaResponseStatus;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.SecureRandom;
 
 /**
  * Index Controller
@@ -334,34 +328,34 @@ public class TsfIndexController extends TsfBaseController {
 		GagaMap userInfo = new GagaMap();
 
 		if (StringUtils.isNotBlank(ipin)) {
-			log.info(ipin);
+
 		}
 
 
 		GagaMap resultMap = new GagaMap();
 
 		// SNS 로그인 성공시 정보 세션 저장
-		if (isSnsLoing) {
-			CustSnsInfo custSnsInfo = objectMapper.convertValue(userInfo, CustSnsInfo.class);
-			log.info("custSnsInfo ==> {}", custSnsInfo.toString());
-
-			//SNS 로그인 처리
-			resultMap = customerService.customerSnsProcessing(custSnsInfo);
-			resultMap.setString("snsId", custSnsInfo.getSnsId());
-			resultMap.setString("snsType", custSnsInfo.getSnsType());
-
-			String custStat = resultMap.getString("custStat");
-
-			// 신규가입 이면 바로 로그인 처리
-			if ("NEW_CUST".equals(custStat)) {
-				customerService.getLogin(Integer.parseInt(resultMap.getString("custNo")), request);
-			}
-
-			// 가입 폼으로 이동
-			if ("EMPTY_PHONE_CUST".equals(custStat)) {
-				session.setAttribute("custSnsInfo", custSnsInfo);
-			}
-		}
+//		if (isSnsLoing) {
+//			CustSnsInfo custSnsInfo = objectMapper.convertValue(userInfo, CustSnsInfo.class);
+//			log.info("custSnsInfo ==> {}", custSnsInfo.toString());
+//
+//			//SNS 로그인 처리
+//			resultMap = customerService.customerSnsProcessing(custSnsInfo);
+//			resultMap.setString("snsId", custSnsInfo.getSnsId());
+//			resultMap.setString("snsType", custSnsInfo.getSnsType());
+//
+//			String custStat = resultMap.getString("custStat");
+//
+//			// 신규가입 이면 바로 로그인 처리
+//			if ("NEW_CUST".equals(custStat)) {
+//				customerService.getLogin(Integer.parseInt(resultMap.getString("custNo")), request);
+//			}
+//
+//			// 가입 폼으로 이동
+//			if ("EMPTY_PHONE_CUST".equals(custStat)) {
+//				session.setAttribute("custSnsInfo", custSnsInfo);
+//			}
+//		}
 		mav.addObject("resultMap", resultMap);
 		mav.setViewName(super.getDeviceViewName("SnsCallBackForm"));
 

+ 21 - 3
src/main/java/com/style24/front/biz/web/TsfMypageController.java

@@ -47,7 +47,11 @@ import com.style24.persistence.domain.Order;
 import com.style24.persistence.domain.Point;
 import com.style24.persistence.domain.WishList;
 
-import lombok.extern.slf4j.Slf4j;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * 마이페이지 Controller
@@ -527,7 +531,6 @@ public class TsfMypageController extends TsfBaseController {
 		map.setString("bankNm", "김지철");
 		map.setString("accountNo", "110500288201");
 		map.setString("bankCd", "88");
-		//coreOrderService.checkAccount(map);
 		// 테스트용 (삭제예정)
 		
 		int custNo = TsfSession.getInfo().getCustNo();
@@ -800,7 +803,7 @@ public class TsfMypageController extends TsfBaseController {
 			return mav;
 		}
 
-		mav.addObject("bankList", rendererService.getCommonCodeList("G050", "Y"));
+		mav.addObject("bankList", rendererService.getCommonCodeList("G940", "Y"));
 		mav.addObject("genderGbList", rendererService.getCommonCodeList("G007", "Y"));
 
 		mav.setViewName(super.getDeviceViewName("/mypage/MypageCustModifyForm"));
@@ -840,5 +843,20 @@ public class TsfMypageController extends TsfBaseController {
 		customer.setBirthYmd(authInfo.getString("sBirthDate"));
 		return customerService.updateCustomerAuth(customer);
 	}
+
+	/**
+	 * 마이페이지 - 계좌인증
+	 *
+	 * @return GagaMap - 결과
+	 * @author jsshin
+	 * @since 2021. 03. 16
+	 */
+	@RequestMapping("/account/check")
+	@ResponseBody
+	public GagaMap getAccountCheck(HttpServletRequest request, HttpServletResponse response) throws Exception {
+		log.info("request2 accountHolder {}",request.getParameter("accountHolder"));
+		GagaMap result = customerService.checkAccount(request);
+		return result;
+	}
 	/*신주승 끝*/
 }

+ 5 - 7
src/main/java/com/style24/front/support/config/TsfMybatisWmsConfig.java

@@ -1,7 +1,7 @@
 package com.style24.front.support.config;
 
-import javax.sql.DataSource;
-
+import com.style24.core.support.annotation.WmsDs;
+import com.style24.core.support.env.TscConstants;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.mybatis.spring.SqlSessionFactoryBean;
 import org.mybatis.spring.SqlSessionTemplate;
@@ -12,15 +12,13 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import com.style24.core.support.annotation.ShopDs;
-import com.style24.core.support.annotation.WmsDs;
-import com.style24.core.support.env.TscConstants;
+import javax.sql.DataSource;
 
 /**
- * shopDs용 Mybatis Configuration
+ * wmsDs용 Mybatis Configuration
  * 
  * @author gagamel
- * @since 2020. 9. 11
+ * @since 2020. 11. 26
  */
 @Configuration
 @MapperScan(basePackages = TscConstants.BASE_PACKAGE, annotationClass = WmsDs.class, sqlSessionFactoryRef = "wmsSqlSessionFactory")

+ 45 - 0
src/main/webapp/WEB-INF/views/web/Yes24CallBackFormWeb.html

@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="ko"
+	xmlns:th="http://www.thymeleaf.org">
+<!--
+ *******************************************************************************
+ * @source  : Yes24CallBackFormWeb.html
+ * @desc    : Yes24 동의화면 Page
+ *============================================================================
+ * STYLE24
+ * Copyright(C) 2020 TSIT, All rights reserved.
+ *============================================================================
+ * VER  DATE         AUTHOR      DESCRIPTION
+ * ===  ===========  ==========  =============================================
+ * 1.0  2021.02.15   gagamel     최초 작성
+ *******************************************************************************
+ -->
+<head th:replace="~{web/common/fragments/HeadWeb :: head}"></head>
+<th:block th:replace="~{web/common/fragments/VariablesWeb :: variables}"></th:block>
+<th:block th:replace="~{web/common/fragments/ScriptsWeb :: scripts}"></th:block>
+<body>
+
+
+<script th:inline="javascript">
+/*<![CDATA[*/
+
+	// const resultMap = [[${resultMap}]];
+	// if (gagajf.isNull(resultMap.snsId) && gagajf.isNull(resultMap.snsType)){
+	// 	mcxDialog.alertC("인증에 실패하였습니다.<br> 로그인 정보를 확인해주시기 바랍니다.", {
+	// 		sureBtnText: "확인",
+	// 		sureBtnClick: function() {
+	// 			self.close();
+	// 		}
+	// 	});
+	// } else {
+	// 	opener.fnSnsSigninCallback(resultMap);
+	// 	self.close();
+	// }
+
+
+/*]]>*/
+</script>
+
+
+</body>
+</html>

+ 58 - 3
src/main/webapp/WEB-INF/views/web/mypage/MypageCustModifyFormWeb.html

@@ -16,6 +16,7 @@
  * 1.0  2021.03.15   jsshin      최초 작성
  *******************************************************************************
  -->
+<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
 <body>
 <th:block layout:fragment="content">
 	<div class="my_cont">
@@ -23,7 +24,7 @@
 			<h3>회원정보 수정</h3>
 		</div>
 		<div class="sec_body mypage_body">
-			<form id="custModiFyForm" class="form_wrap" role="form" method="post">
+			<form id="custModiFyForm" class="form_wrap" role="form" method="post" action="/mypage/account/check" accept-charset="EUC-KR" onsubmit="document.charset='euc-kr';">
 				<div class="order_list">
 					<section class="order_row">
 						<div class="order_tit">
@@ -113,7 +114,7 @@
 										<th>은행명</th>
 										<td>
 											<div class="form_field">
-												<select id="bankList">
+												<select id="bankList" name="bankList">
 													<option value="">선택</option>
 													<option th:if="${bankList}" th:each="oneData, status : ${bankList}" th:value="${oneData.cd}" th:text="${oneData.cdNm}"></option>
 												</select>
@@ -123,8 +124,11 @@
 									<tr>
 										<th>계좌번호</th>
 										<td>
-											<input type="text" id="accountNumber" name="accountNumber" class="form_control" value="" placeholder=""/>
+											<input type="text" id="accountNumber" name="accountNumber" class="form_control" value="27560104388848" placeholder=""/>
 										</td>
+										<button type="button" id="btnAccountCheck" class="btn btn_dark submit_btn">
+											<span>계좌인증</span>
+										</button>
 									</tr>
 								</tbody>
 							</table>
@@ -270,6 +274,53 @@
 		console.log('jsonData', jsonData);
 	});
 
+	$('#btnAccountCheck').on('click', function () {
+		let custInfo = {};
+		let jsonData = JSON.stringify(custInfo)
+		//gagajf.ajaxJsonSubmit('/mypage/account/check', jsonData, fnAccountCheckCallback);
+		//ajaxSubmit('/mypage/account/check','html','accountHolder')
+		$('#custModiFyForm').submit();
+	});
+
+	var fnAccountCheckCallback = function (result) {
+		console.log('result', result);
+
+	}
+
+	var ajaxSubmit = function(actionUrl, type, callback, params) {
+		$.ajax({
+			type : "POST",
+			url : actionUrl,
+			data : $('#custModiFyForm').serialize(),
+			dataType : type,
+			contentType: 'application/x-www-form-urlencoded;charset=euc-kr',
+			beforeSend : function(xhr) {
+				// Button disabled
+				xhr.overrideMimeType('application/x-www-form-urlencoded;charset=euc-kr');
+				// ProgressBar show
+			},
+			complete : function() {
+				// Button enabled
+
+				// ProgressBar hide
+			},
+			success : function(result) {
+				console.log(result);
+				if (type === "html") {
+					if (!gagajf.isNull(callback))
+						$(document.getElementById(callback)).html(result);
+				} else {
+					// Callback 함수 호출
+					if (typeof(callback) === "function")
+						callback.call(this, result);
+				}
+			},
+			error : function() {
+				alert("오류로 인해 처리되지 않았습니다.");
+			}
+		});
+	}
+
 	$(document).ready(function() {
 		// 마이페이지 LNB 설정
 		fnSetMypageLnbList(10);
@@ -281,6 +332,10 @@
 		fnGetCustInfo();
 
 	});
+
+
+
+
 	/*]]>*/
 </script>
 </th:block>