Преглед на файлове

Merge branch 'develop' of http://112.172.147.34:4936/style24/style24.front.git into develop

gagamel преди 5 години
родител
ревизия
80e24398d6

+ 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);
 }

+ 51 - 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;
+	
 	/**
 	 * 상품권정보 조회
 	 *
@@ -51,6 +56,7 @@ public class TsfGiftcardService {
 		// 고객번호 설정
 		int custNo = TsfSession.getInfo().getCustNo();
 		giftcard.setCustNo(custNo);
+		giftcard.setMonthLength(giftcard.getMonth().length());
 		
 		return giftcardDao.getGiftcardUseList(giftcard);
 	}
@@ -69,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

@@ -678,4 +678,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");
+	}
+	
+	
 }

+ 8 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsfGiftcard.xml

@@ -51,6 +51,14 @@
 									LEFT JOIN TB_GOODS D ON B.GOODS_CD = D.GOODS_CD 
 		WHERE 1=1
 		 AND A.CUST_NO = #{custNo}
+		 <choose>
+		 	<when test="monthLength > 1">
+		 		AND DATE_FORMAT(A.REG_DT,'%Y%m') = #{searchDt}
+		 	</when>
+		 	<otherwise>
+		 		 AND DATE_FORMAT(A.REG_DT,'%Y%c') = #{searchDt}
+		 	</otherwise>
+		 </choose> 
 		ORDER BY A.REG_DT DESC
 	</select>
 	

+ 82 - 12
src/main/webapp/WEB-INF/views/web/mypage/MypageGiftcardFormWeb.html

@@ -36,7 +36,7 @@
 				<div class="gift_sea_wrap clear">
 					<label for="gift_input">상품권 등록</label>
 					<input type="text" id="gift_input" placeholder="상품권 번호를 입력해주세요.">
-					<button type="button" class="btn btn_dark">등록</button>
+					<button type="button" class="btn btn_dark" onclick="giftcardSave()">등록</button>
 				</div>
 			</div>
 			<div class="com_info_txt">
@@ -55,10 +55,20 @@
 					<li><a href="javascript:void(0);" id="SearchUseGiftcard">사용내역</a></li>
 					<li><a href="javascript:void(0);" id="SearchOwnGiftcard">보유 상품권</a></li>
 				</ul>
-				<div class="form_field" id="dateField">
-					<select id="searchDt">
+				<!-- <div class="form_field" id="dateField">
+					<select id="searchDt" onchange="fnChangeDate(this)">
 						
 					</select> 
+				</div> -->
+					<div class="form_field" id="dateField">
+						<div class="select_custom type1">
+							<div class="combo">
+								<div class="select"></div> <!-- 셀렉박스 -->
+									<ul id="searchDt" class="list" style="width:200px; margin:0 auto">
+									</ul>
+							</div>
+						</div>
+					</div>
 				</div>
 			</div>
 			<div id="giftcardList">
@@ -67,19 +77,19 @@
 	</div>
 <!-- // CONT-BODY -->					
 <script th:inline="javascript">
+var date = new Date();
+var year = date.getFullYear();
+var month = date.getMonth()+1;
+
 //동적으로 날짜 년도 append
 function appendYear(){
  
-    var date = new Date();
-    var year = date.getFullYear();
-    var month = date.getMonth()+1;
-  
     for(var i=year; i<=year; i++){
        	for (var j= 1; j <=month; j++) {
-       		$("#searchDt").prepend("<option value='"+year+"-"+j+"'>"+i+"년"+ j +"월 </option>");
+       		$("#searchDt").prepend("<li onclick='fnChangeDate(this.value)' value='"+year+""+j+"'>"+i+"년"+j +"월 </li>");
 		}
     }
-	$("#searchDt").find("option:eq(0)").prop("selected", true); // 현재년도 선택
+    $(".select").append("<li class='selected' value='"+year+""+month+"'>"+year+"년"+ month +"월 </li>"); // 현재년도 선택 */
 }
  
 appendYear($("#searchDt"));
@@ -94,8 +104,9 @@ $("#SearchUseGiftcard").click(function(){
 	// 날짜 필드 
 	$("#dateField").css("display","block");
 	
-	let data = {};
-	
+	let data = {searchDt : year+""+month,
+				month : month};
+
 	var jsonData = JSON.stringify(data);
 	
 	$.ajax(
@@ -221,7 +232,62 @@ function ownGiftcard(result) {
 }
 
 function fnChangeDate(obj) {
-	console.log(obj);
+
+	var seletedDate = obj.toString();
+	var splitMonth = seletedDate.substr(4);
+	
+	data = {month : splitMonth,
+			searchDt : seletedDate};
+
+ 	var jsonData = JSON.stringify(data);
+	
+	$.ajax(
+			{
+				type 	 : "POST",
+				data	 : jsonData,
+				url 	 : '/mypage/gift/use/list',
+				contentType: 'application/json',
+					dataType : 'json',
+				success  : function(result){
+					useGiftcard(result);
+				}
+			}
+		)  
+}
+
+// 상품권 등록 버튼 누를 시 
+function giftcardSave() {
+	if($("#gift_input").val() == "" || $("#gift_input").val() == null){
+		mcxDialog.alert("상품권 번호를 입력해주세요.");
+		return;
+	}
+	
+ 	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/confirm',
+				contentType: 'application/json',
+					dataType : 'json',
+				success  : function(result){
+				
+				}
+			}
+		)   
+	
 }
 
 $(document).ready(function() {
@@ -235,6 +301,10 @@ $(document).ready(function() {
 	// 전체내역 표시
 	$("#SearchUseGiftcard").trigger('click');
 
+	// 셀렉트박스 활성화
+	$('.select_custom.type1').each(function(index) {
+		var selecter01 = new sCombo($(this));
+	});
 });
 </script>
 </th:block>