Ver código fonte

상품권 api 저장완료

sowon4187 5 anos atrás
pai
commit
0eea01bb09

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

@@ -49,4 +49,15 @@ public interface TsfGiftcardDao {
 	 * @since 2021. 3. 15
 	 */	
 	 void getGiftcardUseConfirm(GiftCard giftcard);
+	 
+	 /**
+	 * 상품권 api 저장
+	 *
+	 * @param GiftCard
+	 * @author sowon
+	 * @since 2021. 3. 15
+	 */
+	 void saveGiftcardApi(GiftCard giftcard);
+	 
+	 
 }

+ 56 - 47
src/main/java/com/style24/front/biz/service/TsfGiftcardService.java

@@ -25,100 +25,109 @@ public class TsfGiftcardService {
 
 	@Autowired
 	private TsfGiftcardDao giftcardDao;
-	
+
 	@Autowired
 	private Yes24Giftcard yes24Gift;
-	
+
 	/**
 	 * 상품권정보 조회
 	 *
 	 * @param GiftCard
 	 * @author sowon
 	 * @since 2021. 3. 12
-	 */	
+	 */
 	public GiftCard getGiftcardInfo(GiftCard giftcard) {
-		
+
 		// 고객번호 설정
 		int custNo = TsfSession.getInfo().getCustNo();
 		giftcard.setCustNo(custNo);
-		
-		return giftcardDao.getGiftcardInfo(giftcard);		
+
+		return giftcardDao.getGiftcardInfo(giftcard);
 	}
-	
+
 	/**
 	 * 상품권 사용 정보 조회
 	 *
 	 * @param GiftCard
 	 * @author sowon
 	 * @since 2021. 3. 12
-	 */	
-	public Collection<GiftCard> getGiftcardUseList(GiftCard giftcard){
+	 */
+	public Collection<GiftCard> getGiftcardUseList(GiftCard giftcard) {
 		// 고객번호 설정
 		int custNo = TsfSession.getInfo().getCustNo();
 		giftcard.setCustNo(custNo);
 		giftcard.setMonthLength(giftcard.getMonth().length());
-		
+
 		return giftcardDao.getGiftcardUseList(giftcard);
 	}
-	
+
 	/**
 	 * 상품권 보유 조회
 	 *
 	 * @param GiftCard
 	 * @author sowon
 	 * @since 2021. 3. 12
-	 */	
-	public Collection<GiftCard> getGiftcardOwnList(GiftCard giftcard){
+	 */
+	public Collection<GiftCard> getGiftcardOwnList(GiftCard giftcard) {
 		// 고객번호 설정
 		int custNo = TsfSession.getInfo().getCustNo();
 		giftcard.setCustNo(custNo);
-		
+
 		return giftcardDao.getGiftcardOwnList(giftcard);
 	}
-	
+
 	/**
 	 * 상품권 저장
 	 * 
 	 * @param GiftCard
 	 * @author sowon
-	 * @throws Exception 
+	 * @throws Exception
 	 * @since 2021. 3. 15
-	 */	
-	public void getGiftcardUseConfirm(GiftCard giftcard) throws Exception{
+	 */
+	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("|");
-//			
-//			
-//		}
-		
+		giftcard.setCustNo(custNo);
+		giftcard.setIpAddr(ip);  // 아이피주소
 		
 		
+		String pubNo = giftcard.getGfcdNo();
+		String result =yes24Gift.soapDataTransfer(pubNo,ip,custNo);
+
+		if (result.equals("01")) {
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
+		} else if (result.equals("02")) {
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			throw new IllegalArgumentException("이미 등록된 상품권입니다.");
+		} else if (result.equals("03")) {
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			throw new IllegalArgumentException("삭제된 상품권입니다.");
+		} else if (result.equals("04")) {
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
+		} else if (result.equals("99")) {
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			throw new IllegalArgumentException("시스템 오류입니다.");
+		} else {
+			String[] param = result.split("[|]");
+			//System.out.println(param[0]); -- 승인번호 00
+			giftcard.setResultVal(result);  //승인금액
+			giftcardDao.saveGiftcardApi(giftcard);
+			
+			// tb_cust_giftcard에 등록
+			giftcard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
+			
+			giftcard.setUseStDate(param[2]);
+			giftcard.setUseExpDate(param[3]);
+		}
+
 	}
-	
-	
 
 }

+ 8 - 2
src/main/java/com/style24/front/biz/web/TsfMypageController.java

@@ -43,6 +43,7 @@ import com.style24.persistence.domain.WishList;
 import lombok.extern.slf4j.Slf4j;
 
 import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.rest.server.GagaResponse;
 import com.gagaframework.web.rest.server.GagaResponseStatus;
 
 /**
@@ -689,9 +690,14 @@ public class TsfMypageController extends TsfBaseController {
 	 */
 	@PostMapping("/gift/use/confirm")
 	@ResponseBody
-	public String getGiftcardUseConfirm(@RequestBody GiftCard giftcard) throws Exception {
+	public GagaResponse getGiftcardUseConfirm(@RequestBody GiftCard giftcard) throws Exception {
+		
 		giftcardService.getGiftcardUseConfirm(giftcard);
-		return message.getMessage("SUCC_0001");
+
+
+		return super.ok(message.getMessage("SUCC_0001"));
+		
+
 	}
 	
 	

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

@@ -82,6 +82,26 @@
 		  AND CUST_NO = #{custNo}
 	</select>
 	
+	<insert id="saveGiftcardApi" parameterType="GiftCard">
+		INSERT INTO TB_GIFTCARD_API_HST
+		(
+		   GFCD_NO
+		 , IP_ADDR
+		 , CUST_NO
+		 , RESULT_VAL
+		 , REG_NO
+		 , REG_DT
+		)
+	VALUES(
+			#{gfcdNo}
+	      , #{ipAddr}
+	      , #{custNo}
+	      , #{resultVal}
+	      , 0
+	      , CURRENT_TIMESTAMP
+	     )
+	</insert>
+	
 	
 	<!-- 페이징을 위한 select절 상단 -->
 	<sql id="selectForPagingHeader">

+ 14 - 3
src/main/webapp/WEB-INF/views/web/mypage/MypageGiftcardFormWeb.html

@@ -275,7 +275,7 @@ function giftcardSave() {
 		}
 	}); */
 	
-	$.ajax(
+	/* $.ajax(
 			{
 				type 	 : "POST",
 				data	 : jsonData,
@@ -283,10 +283,21 @@ function giftcardSave() {
 				contentType: 'application/json',
 					dataType : 'json',
 				success  : function(result){
-				
+					alert(result.message);
 				}
 			}
-		)   
+		)    */
+		
+ 	mcxDialog.confirm("상품권을 등록 하시겠습니까?", {
+		cancelBtnText: "취소",
+		sureBtnText: "확인",
+		sureBtnClick: function() {
+			
+			gagajf.ajaxJsonSubmit('/mypage/gift/use/confirm', jsonData, function() {
+				cfnGoToPage(_PAGE_MYPAGE_GIFTCARD);
+			});
+		}
+	});
 	
 }