Parcourir la source

상품권 api 중간 커밋

sowon4187 il y a 5 ans
Parent
commit
aaf5dea292

+ 12 - 0
pom.xml

@@ -123,6 +123,18 @@
 			<scope>system</scope>
 			<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/jPpcliE.jar</systemPath>
 		</dependency>
+		<!-- 상품권 인증  -->
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxws</artifactId>
+			<version>2.7.11</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-transports-http</artifactId>
+			<version>2.7.11</version>
+		</dependency>
+
 		<!--//NICE 본인인증-->
 		<!-- \\\ WEB-INF lib -->
 	</dependencies>

+ 9 - 0
src/main/java/com/style24/front/biz/dao/TsfGiftcardDao.java

@@ -40,4 +40,13 @@ public interface TsfGiftcardDao {
 	 * @since 2021. 3. 12
 	 */	
 	Collection<GiftCard> getGiftcardOwnList(GiftCard giftcard);
+	
+	/**
+	 * 상품권정보 저장
+	 *
+	 * @param GiftCard
+	 * @author sowon
+	 * @since 2021. 3. 15
+	 */	
+	 void getGiftcardUseConfirm(GiftCard giftcard);
 }

+ 50 - 0
src/main/java/com/style24/front/biz/service/TsfGiftcardService.java

@@ -1,11 +1,13 @@
 package com.style24.front.biz.service;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.style24.front.biz.dao.TsfGiftcardDao;
+import com.style24.front.biz.thirdparty.Yes24Giftcard;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.GiftCard;
 
@@ -24,6 +26,9 @@ public class TsfGiftcardService {
 	@Autowired
 	private TsfGiftcardDao giftcardDao;
 	
+	@Autowired
+	private Yes24Giftcard yes24Gift;
+	
 	/**
 	 * 상품권정보 조회
 	 *
@@ -70,5 +75,50 @@ public class TsfGiftcardService {
 		
 		return giftcardDao.getGiftcardOwnList(giftcard);
 	}
+	
+	/**
+	 * 상품권 저장
+	 * 
+	 * @param GiftCard
+	 * @author sowon
+	 * @throws Exception 
+	 * @since 2021. 3. 15
+	 */	
+	public void getGiftcardUseConfirm(GiftCard giftcard) throws Exception{
+		// 고객번호 설정
+		int custNo = TsfSession.getInfo().getCustNo();
+		giftcard.setCustNo(custNo);
+		
+		String ip = TsfSession.getIpAddress();
+		String pubNo = giftcard.getGfcdNo();
+//		String result =yes24Gift.soapDataTransfer(pubNo,ip,custNo);
+	    
+		String result ="00|승인금액|사용시작일|사용종료일|승인번호";
+		String[] param = result.split("|");
+		String cfcdNo = param[3];
+		System.out.println(cfcdNo);
+		
+//		if(result.equals("01")) {
+//			throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
+//		}else if(result.equals("02")) {
+//			throw new IllegalArgumentException("이미 등록된 상품권입니다.");
+//		}else if(result.equals("03")) {
+//			throw new IllegalArgumentException("삭제된 상품권입니다.");
+//		}else if(result.equals("04")) {
+//			throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
+//		}else if(result.equals("99")) {
+//			throw new IllegalArgumentException("시스템 오류입니다.");
+//		}else {
+//			
+//			String[] param = result.split("|");
+//			
+//			
+//		}
+		
+		
+		
+	}
+	
+	
 
 }

+ 104 - 0
src/main/java/com/style24/front/biz/thirdparty/Yes24Giftcard.java

@@ -0,0 +1,104 @@
+package com.style24.front.biz.thirdparty;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Component
+@Slf4j
+public class Yes24Giftcard {
+
+	public String soapDataTransfer(String pubNo, String ip, Integer userId) throws Exception {
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		Document doc = null;
+
+		// request SOAP message DOMSource create
+		String message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+				+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+				+ "<soap:Body>" + "<Approval xmlns=\"http://tempuri.org/\">" + "<ticPubNo>" + pubNo + "</ticPubNo>"
+				+ "<ipAddress>" + ip + "</ipAddress>" + "<iStyle24UserID>" + userId + "</iStyle24UserID>"
+				+ "</Approval>" + "</soap:Body>" + "</soap:Envelope>";
+
+		OutputStreamWriter wr = null;
+		BufferedReader in = null;
+
+		String strURL = "http://api.yes24.com/Yes24GiftTicketAPI/Yes24GiftTicketService.asmx";
+
+		URL url = new URL(strURL); // 보낼 주소
+		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+		conn.setDoOutput(true);
+		conn.setRequestMethod("POST");
+		conn.addRequestProperty("Content-Type", "text/xml");
+		wr = new OutputStreamWriter(conn.getOutputStream());
+		wr.write(message);
+		wr.flush();
+		int code = conn.getResponseCode();
+
+		String inputLine = null;
+		StringBuffer buffer = new StringBuffer();
+		in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+		while ((inputLine = in.readLine()) != null) {
+			buffer.append(inputLine);
+		}
+		System.out.println(buffer.toString()); // 결과 값
+
+		// xml 파싱하기
+		InputSource is = new InputSource(new StringReader(buffer.toString()));
+
+		Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
+
+		NodeList nodeList = null;
+		ArrayList<Map<String, String>> xmlList = new ArrayList<Map<String, String>>();
+		String getNodeName = "";
+		String childnodevalue = "";
+		if (document.getFirstChild().getChildNodes().getLength() > 0) {
+			getNodeName = document.getFirstChild().getFirstChild().getNodeName();
+
+			nodeList = document.getElementsByTagName(getNodeName);
+			
+			for (int i = 0; i < nodeList.getLength(); i++) {
+				NodeList childList = nodeList.item(i).getChildNodes();
+
+				for (int j = 0; j < childList.getLength(); j++) {
+					String childnodename = childList.item(j).getNodeName();
+					childnodevalue = childList.item(j).getTextContent();
+				}
+			}
+		} 
+
+		return childnodevalue;
+	}
+
+}

+ 17 - 0
src/main/java/com/style24/front/biz/web/TsfMypageController.java

@@ -677,4 +677,21 @@ public class TsfMypageController extends TsfBaseController {
 		result.set("giftcardOwnList",giftcardService.getGiftcardOwnList(giftcard));
 		return result;
 	}
+	
+	/**
+	 * 마이페이지 상품권 저장
+	 *
+	 * @return
+	 * @author sowon	
+	 * @throws Exception 
+	 * @since 2021. 03. 15
+	 */
+	@PostMapping("/gift/use/confirm")
+	@ResponseBody
+	public String getGiftcardUseConfirm(@RequestBody GiftCard giftcard) throws Exception {
+		giftcardService.getGiftcardUseConfirm(giftcard);
+		return message.getMessage("SUCC_0001");
+	}
+	
+	
 }

+ 13 - 5
src/main/webapp/WEB-INF/views/web/mypage/MypageGiftcardFormWeb.html

@@ -262,23 +262,31 @@ function giftcardSave() {
 		return;
 	}
 	
-/* 	data = {month : splitMonth,
-			searchDt : seletedDate};
+ 	data = {gfcdNo : $("#gift_input").val()};
 
  	var jsonData = JSON.stringify(data);
+ 	
+/*  	mcxDialog.confirm('저장 하시겠습니까?', {
+		cancelBtnText: "취소",
+		sureBtnText: "확인",
+		sureBtnClick: function() {
+			var jsonData = JSON.stringify(changeData);
+			gagajf.ajaxJsonSubmit('/mypage/gift/use/confirm', jsonData, fnCornerSearch);
+		}
+	}); */
 	
 	$.ajax(
 			{
 				type 	 : "POST",
 				data	 : jsonData,
-				url 	 : '/mypage/gift/use/list',
+				url 	 : '/mypage/gift/use/confirm',
 				contentType: 'application/json',
 					dataType : 'json',
 				success  : function(result){
-					useGiftcard(result);
+				
 				}
 			}
-		)   */
+		)   
 	
 }