|
|
@@ -5,8 +5,10 @@ import com.gagaframework.web.util.GagaFileUtil;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
import com.google.gson.JsonObject;
|
|
|
+import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.core.support.util.CryptoUtils;
|
|
|
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;
|
|
|
@@ -19,8 +21,14 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import org.w3c.dom.Document;
|
|
|
+import org.w3c.dom.Node;
|
|
|
+import org.w3c.dom.NodeList;
|
|
|
+import org.xml.sax.InputSource;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
+import java.io.StringReader;
|
|
|
import java.net.URI;
|
|
|
|
|
|
|
|
|
@@ -94,7 +102,8 @@ public class Yes24Login {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * YES24 정보
|
|
|
+ * YES24 고객 정보
|
|
|
+ *
|
|
|
* @param inpin - yes24 전달 해준 암호화된 : "요청날짜|CI"
|
|
|
* @return String - 호출 url정보
|
|
|
* @author jsshin
|
|
|
@@ -102,15 +111,12 @@ public class Yes24Login {
|
|
|
*/
|
|
|
public GagaMap getUserInfo(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[1]);
|
|
|
@@ -121,26 +127,153 @@ public class Yes24Login {
|
|
|
|
|
|
// Header
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.set("Host", "wsyes24.yes24.com");
|
|
|
- headers.set("Content-Type", "application/x-www-form-urlencoded");
|
|
|
- headers.set("Content-Length", "length");
|
|
|
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
|
|
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
|
|
|
URI url = URI.create(userInfoUrl);
|
|
|
|
|
|
// POST방식으로 호출
|
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
|
|
|
- log.info("getAccessTocken responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
|
|
|
+ log.info("getUserInfo responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
|
|
|
+ String responseEntityBody = responseEntity.getBody();
|
|
|
+ log.info("getUserInfo responseEntity.getBody(): {} ", responseEntityBody);
|
|
|
+
|
|
|
+ // 4. XML 데이터 파싱
|
|
|
+ result = getCustInfoXmlParsing(responseEntityBody);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * YES24 고객 정보
|
|
|
+ *
|
|
|
+ * @param responseEntityBody - yes24 전달 고객정보 XML
|
|
|
+ * @return GagaMap - 고객정보
|
|
|
+ * @author jsshin
|
|
|
+ * @since 2021. 03. 26
|
|
|
+ */
|
|
|
+ public GagaMap getCustInfoXmlParsing(String responseEntityBody) throws Exception{
|
|
|
+ InputSource is = new InputSource(new StringReader(responseEntityBody));
|
|
|
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
|
|
|
+ Node node = document.getDocumentElement();
|
|
|
+ NodeList nodeList = node.getChildNodes();
|
|
|
+ GagaMap nodeMap = new GagaMap();
|
|
|
+ for(int i = 0; i < nodeList.getLength(); i++) {
|
|
|
+ Node item = nodeList.item(i);
|
|
|
+ if (!"#text".equals(item.getNodeName())) {
|
|
|
+ nodeMap.setString(item.getNodeName(), item.getTextContent());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GagaMap resultMap = new GagaMap();
|
|
|
+ String memNo = nodeMap.getString("str_MEM_NO");
|
|
|
+ String snsId = nodeMap.getString("str_MEM_ID");
|
|
|
+ String custNm = nodeMap.getString("str_MEM_NM");
|
|
|
+ String email = nodeMap.getString("str_MEM_EML");
|
|
|
+ String cellphnno = nodeMap.getString("str_ADDR_MOB_NO").replaceAll("-","");
|
|
|
+ String birthYmd = nodeMap.getString("str_BIRTH_DM").replaceAll("-","");
|
|
|
+ String sexGb = nodeMap.getString("str_SEX").equals("M")? TscConstants.Gender.MALE.value() : TscConstants.Gender.FEMALE.value();
|
|
|
+ String ci = nodeMap.getString("str_IPIN_CI");
|
|
|
+ String homeZipcode = nodeMap.getString("str_ADDR_ZIP");
|
|
|
+ String homeBaseAddr = nodeMap.getString("str_ADDR_ADDR1");
|
|
|
+ String homeDtlAddr = nodeMap.getString("str_ADDR_ADDR2");
|
|
|
+
|
|
|
+ resultMap.setString("memNo", memNo);
|
|
|
+ resultMap.setString("snsId", snsId);
|
|
|
+ resultMap.setString("custNm", custNm);
|
|
|
+ resultMap.setString("email", email);
|
|
|
+ resultMap.setString("ci", ci);
|
|
|
+ resultMap.setString("cellPhnno", cellphnno);
|
|
|
+ resultMap.setString("birthYmd", birthYmd);
|
|
|
+ resultMap.setString("sexGb", sexGb);
|
|
|
+ resultMap.setString("homeZipcode", homeZipcode);
|
|
|
+ resultMap.setString("homeBaseAddr", homeBaseAddr);
|
|
|
+ resultMap.setString("homeDtlAddr",homeDtlAddr);
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * YES24 고객 연동처리
|
|
|
+ *
|
|
|
+ * @param custSnsInfo - 고객정보
|
|
|
+ * @return String - 호출 url정보
|
|
|
+ * @author jsshin
|
|
|
+ * @since 2021. 03. 03
|
|
|
+ */
|
|
|
+ public void saveLink(CustSnsInfo custSnsInfo) {
|
|
|
+ // 1. Ci 다시 암호화
|
|
|
+ String encryptCi = CryptoUtils.encryptAES(custSnsInfo.getCi());
|
|
|
+ String joinGb = TsfSession.getFrontGb().equals("P") ? "P" : "M";
|
|
|
+
|
|
|
+ try {
|
|
|
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
+ params.add("str_ci", encryptCi);
|
|
|
+ params.add("mem_id", custSnsInfo.getSnsId());
|
|
|
+ params.add("partner_id", custSnsInfo.getSnsType()+'_'+custSnsInfo.getMemNo());
|
|
|
+ params.add("join_gb", joinGb);
|
|
|
+ params.add("str_Type", type);
|
|
|
+
|
|
|
+ // Header
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
|
|
|
- String jsonResult = responseEntity.getBody();
|
|
|
- log.info("getAccessTocken responseEntity.getBody(): {} ", jsonResult);
|
|
|
+ HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
|
|
|
+ URI url = URI.create(linkUrl);
|
|
|
+
|
|
|
+ // POST방식으로 호출
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
|
|
|
+ log.info("saveLink responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
|
|
|
+ String responseEntityBody = responseEntity.getBody();
|
|
|
+ log.info("saveLink responseEntity.getBody(): {} ", responseEntityBody);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return result;
|
|
|
+ /**
|
|
|
+ * YES24 고객 연동해지
|
|
|
+ *
|
|
|
+ * @param custSnsInfo - 고객정보
|
|
|
+ * @return String - 호출 url정보
|
|
|
+ * @author jsshin
|
|
|
+ * @since 2021. 03. 03
|
|
|
+ */
|
|
|
+ public void saveUnLink(CustSnsInfo custSnsInfo) {
|
|
|
+ String joinGb = TsfSession.getFrontGb().equals("P") ? "P" : "M";
|
|
|
+
|
|
|
+ // 1. Ci 다시 암호화
|
|
|
+ String encryptCi = CryptoUtils.encryptAES(custSnsInfo.getCi());
|
|
|
+
|
|
|
+ try {
|
|
|
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
+ params.add("str_ci", encryptCi);
|
|
|
+ params.add("mem_id", custSnsInfo.getSnsId());
|
|
|
+ params.add("partner_id", custSnsInfo.getSnsType()+'_'+custSnsInfo.getMemNo());
|
|
|
+ params.add("join_gb", joinGb);
|
|
|
+ params.add("str_Type", type);
|
|
|
+
|
|
|
+ // Header
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
+
|
|
|
+ HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
|
|
|
+ URI url = URI.create(unlinkUrl);
|
|
|
+
|
|
|
+ // POST방식으로 호출
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
|
|
|
+ log.info("getUserInfo responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
|
|
|
+ String responseEntityBody = responseEntity.getBody();
|
|
|
+ log.info("getUserInfo responseEntity.getBody(): {} ", responseEntityBody);
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|