Pārlūkot izejas kodu

상품권 등록 예외처리 수정 커밋

card007 4 gadi atpakaļ
vecāks
revīzija
0413a775df

+ 28 - 8
src/main/java/com/style24/front/biz/service/TsfGiftcardService.java

@@ -2,11 +2,13 @@ package com.style24.front.biz.service;
 
 import java.util.Collection;
 
-import com.style24.core.biz.thirdparty.Yes24Giftcard;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.rest.server.GagaResponseStatus;
+import com.style24.core.biz.thirdparty.Yes24Giftcard;
 import com.style24.front.biz.dao.TsfGiftcardDao;
 import com.style24.front.support.security.session.TsfSession;
 import com.style24.persistence.domain.GiftCard;
@@ -86,7 +88,9 @@ public class TsfGiftcardService {
 	 * @since 2021. 3. 15
 	 */
 	@Transactional("shopTxnManager")
-	public void createGiftcardUseConfirm(GiftCard giftcard) throws Exception {
+	public GagaMap createGiftcardUseConfirm(GiftCard giftcard) throws Exception {
+		GagaMap map = new GagaMap();
+		GagaMap error = new GagaMap();
 		// 고객번호 설정
 		int custNo = TsfSession.getInfo().getCustNo();
 		String ip = TsfSession.getIpAddress();
@@ -99,26 +103,39 @@ public class TsfGiftcardService {
 		String pubNo = giftcard.getGfcdNo();
 		String result =yes24Gift.soapDataTransfer(pubNo,ip,custNo);
 
+		// result message 설정
+		map.set("status", GagaResponseStatus.FAIL.getCode());
+
 		if (result.equals("01")) {
 			giftcard.setResultVal(result);  // 승인 결과 insert
 			giftcardDao.saveGiftcardApi(giftcard);
-			throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
+			// throw new IllegalArgumentException("존재하지 않는 상품권입니다.");
+			error.set("message", "존재하지 않는 상품권입니다.");
+			map.set("error", error);
 		} else if (result.equals("02")) {
 			giftcard.setResultVal(result);  
 			giftcardDao.saveGiftcardApi(giftcard);
-			throw new IllegalArgumentException("이미 등록된 상품권입니다.");
+			// throw new IllegalArgumentException("이미 등록된 상품권입니다.");
+			error.set("message", "이미 등록된 상품권입니다.");
+			map.set("error", error);
 		} else if (result.equals("03")) {
 			giftcard.setResultVal(result);  
 			giftcardDao.saveGiftcardApi(giftcard);
-			throw new IllegalArgumentException("삭제된 상품권입니다.");
+			// throw new IllegalArgumentException("삭제된 상품권입니다.");
+			error.set("message", "삭제된 상품권입니다.");
+			map.set("error", error);
 		} else if (result.equals("04")) {
 			giftcard.setResultVal(result);  
 			giftcardDao.saveGiftcardApi(giftcard);
-			throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
+			// throw new IllegalArgumentException("기간이 만료된 상품권입니다.");
+			error.set("message", "기간이 만료된 상품권입니다.");
+			map.set("error", error);
 		} else if (result.equals("99")) {
 			giftcard.setResultVal(result);  
 			giftcardDao.saveGiftcardApi(giftcard);
-			throw new IllegalArgumentException("시스템 오류입니다.");
+			// throw new IllegalArgumentException("시스템 오류입니다.");
+			error.set("message", "시스템 오류입니다.");
+			map.set("error", error);
 		} else{
 					
 			giftcard.setResultVal("00");  
@@ -143,9 +160,12 @@ public class TsfGiftcardService {
 			giftcard.setGfcdAmt(Integer.parseInt(param[1]));
 			
 			giftcardDao.createCustGiftcardHistory(giftcard);
-			
+
+			map.set("status", GagaResponseStatus.SUCCESS.getCode());
+			map.set("message", "상품권이 등록되었습니다.");
 		}
 
+		return map;
 	}
 	
 	 /**

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

@@ -1621,9 +1621,8 @@ public class TsfMypageController extends TsfBaseController {
 	 */
 	@PostMapping("/gift/use/confirm")
 	@ResponseBody
-	public GagaResponse createGiftcardUseConfirm(@RequestBody GiftCard giftcard) throws Exception {
-		giftcardService.createGiftcardUseConfirm(giftcard);
-		return super.ok(message.getMessage("SUCC_0001"));
+	public GagaMap createGiftcardUseConfirm(@RequestBody GiftCard giftcard) throws Exception {
+		return giftcardService.createGiftcardUseConfirm(giftcard);
 	}
 
 	/**