itn 2023-08-14
결제하기 화면 다음 결제시 결제수단 UPDATE 기능추가
@4e0024044f8e228e510019ac71f5789944032005
src/main/java/itn/let/mjo/pay/web/MjonPayV2Controller.java
--- src/main/java/itn/let/mjo/pay/web/MjonPayV2Controller.java
+++ src/main/java/itn/let/mjo/pay/web/MjonPayV2Controller.java
@@ -192,6 +192,82 @@
 		return "/web/pay/PayViewV2";
 	}
 
+	/**
+   	 * 다음 결제시 결제수단 SELECT
+   	 * @throws Exception
+   	 */
+   	@RequestMapping(value = "/web/member/pay/selectNextPayMethodAjax.do")
+   	public ModelAndView selectNextPayMethodAjax(MjonPayVO mjonPayVO, 
+            HttpServletRequest request ) throws Exception {
+
+       	ModelAndView modelAndView = new ModelAndView();
+       	modelAndView.setViewName("jsonView");
+
+		boolean isSuccess = true;
+		String msg = "";
+		String nextPayMethod = "";
+       	
+   		LoginVO	loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
+   		String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
+
+   		if(userId == null) {
+   			isSuccess = false;
+   			msg = "로그인이 필요합니다.";   			
+   		}
+   		
+   		try {
+   			// 다음 결제시 결제수단 SELECT
+   			nextPayMethod = userManageService.selectNextPayMethod(userId);
+   		}
+   		catch(Exception e) {
+   			isSuccess = false;
+   			msg = e.getMessage();
+   		}		
+
+   		modelAndView.addObject("isSuccess", isSuccess);
+   		modelAndView.addObject("msg", msg);
+   		modelAndView.addObject("nextPayMethod", nextPayMethod);
+   		
+   		return modelAndView;
+   	}    
+   	
+	/**
+   	 * 다음 결제시 결제수단 UPDATE
+   	 * @throws Exception
+   	 */
+   	@RequestMapping(value = "/web/member/pay/updateNextPayMethodAjax.do")
+   	public ModelAndView updateNextPayMethodAjax(UserManageVO userManageVO, 
+            HttpServletRequest request ) throws Exception {
+
+       	ModelAndView modelAndView = new ModelAndView();
+       	modelAndView.setViewName("jsonView");
+
+		boolean isSuccess = true;
+		String msg = "";
+       	
+   		LoginVO	loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
+   		String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
+
+   		if(userId == null) {
+   			isSuccess = false;
+   			msg = "로그인이 필요합니다.";   			
+   		}
+   		
+   		try {
+   			// 다음 결제시 결제수단 SELECT
+   			userManageVO.setMberId(userId);
+   			userManageService.updateNextPayMethod(userManageVO);
+   		}
+   		catch(Exception e) {
+   			isSuccess = false;
+   			msg = e.getMessage();
+   		}		
+
+   		modelAndView.addObject("isSuccess", isSuccess);
+   		modelAndView.addObject("msg", msg);
+   		
+   		return modelAndView;
+   	}        
     
     /////////////////////////////////////////////////////////////////////////////////////////
     //
src/main/java/itn/let/uss/umt/service/EgovUserManageService.java
--- src/main/java/itn/let/uss/umt/service/EgovUserManageService.java
+++ src/main/java/itn/let/uss/umt/service/EgovUserManageService.java
@@ -159,6 +159,12 @@
 
 	void updateCrtfcDnValue(UserManageVO userManageVO) throws Exception;
 
+	// 다음 결제시 결제수단 SELECT
+	public String selectNextPayMethod(String mberId) throws Exception;
+
+	// 다음 결제시 결제수단 UPDATE
+	void updateNextPayMethod(UserManageVO userManageVO) throws Exception;
+	
 	public int selectAdminDiChk(UserManageVO userManageVO);
 	
 	public boolean selectUserStatusInfo(String userId) throws Exception;
src/main/java/itn/let/uss/umt/service/UserManageVO.java
--- src/main/java/itn/let/uss/umt/service/UserManageVO.java
+++ src/main/java/itn/let/uss/umt/service/UserManageVO.java
@@ -206,7 +206,14 @@
 	private String recommendId;		// 추천아이디
 	private String atSmishingYn;		// 알림톡 스미싱 의심여부
 	private String spamYn;
+	private String nextPayMethod;
 	
+	public String getNextPayMethod() {
+		return nextPayMethod;
+	}
+	public void setNextPayMethod(String nextPayMethod) {
+		this.nextPayMethod = nextPayMethod;
+	}
 	public String getSpamYn() {
 		return spamYn;
 	}
src/main/java/itn/let/uss/umt/service/impl/EgovUserManageServiceImpl.java
--- src/main/java/itn/let/uss/umt/service/impl/EgovUserManageServiceImpl.java
+++ src/main/java/itn/let/uss/umt/service/impl/EgovUserManageServiceImpl.java
@@ -439,6 +439,18 @@
 		userManageDAO.updateCrtfcDnValue(userManageVO);
 	}
 
+	// 다음 결제시 결제수단 SELECT
+	@Override
+	public String selectNextPayMethod(String mberId) throws Exception{
+		return userManageDAO.selectNextPayMethod(mberId);
+	}
+
+	// 다음 결제시 결제수단 UPDATE
+	@Override
+	public void updateNextPayMethod(UserManageVO userManageVO) throws Exception{
+		userManageDAO.updateNextPayMethod(userManageVO);
+	}
+	
 	@Override
 	public int selectAdminDiChk(UserManageVO userManageVO) {
 		return userManageDAO.selectAdminDiChk(userManageVO);
src/main/java/itn/let/uss/umt/service/impl/UserManageDAO.java
--- src/main/java/itn/let/uss/umt/service/impl/UserManageDAO.java
+++ src/main/java/itn/let/uss/umt/service/impl/UserManageDAO.java
@@ -228,6 +228,16 @@
     	update("userManageDAO.updateCrtfcDnValue",userManageVO);
     }
 
+	// 다음 결제시 결제수단 SELECT
+	public String selectNextPayMethod(String mberId) throws Exception{
+		return (String) select("userManageDAO.selectNextPayMethod", mberId);
+	}
+
+	// 다음 결제시 결제수단 UPDATE
+    public void updateNextPayMethod(UserManageVO userManageVO){
+    	update("userManageDAO.updateNextPayMethod",userManageVO);
+    }
+	
     /**
      * Admin DI Chk
      * @param userManageVO 본인 인증 값 :: KMS DI 값 -> CRTFC_DN_VALUE 
src/main/resources/egovframework/sqlmap/let/uss/umt/EgovUserManage_SQL_Mysql.xml
--- src/main/resources/egovframework/sqlmap/let/uss/umt/EgovUserManage_SQL_Mysql.xml
+++ src/main/resources/egovframework/sqlmap/let/uss/umt/EgovUserManage_SQL_Mysql.xml
@@ -412,6 +412,21 @@
        
     </update>
     
+	<!-- 다음 결제시 결제수단 SELECT -->
+	<select id="userManageDAO.selectNextPayMethod" parameterClass="String" resultClass="String">
+		SELECT 
+			IFNULL(NEXT_PAY_METHOD, '') AS nextPayMethod
+		FROM LETTNGNRLMBER 
+		WHERE MBER_ID = #mberId#
+	</select>
+
+	<!-- 다음 결제시 결제수단 UPDATE -->
+    <update id="userManageDAO.updateNextPayMethod">
+            UPDATE LETTNGNRLMBER
+            SET NEXT_PAY_METHOD            = #nextPayMethod#
+            WHERE MBER_ID = #mberId#
+    </update>
+        
     <select id="userManageDAO.selectAdminDiChk" resultClass="int">
 		SELECT 
 			count(*)
src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
--- src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
+++ src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
@@ -28,10 +28,123 @@
 	if (tabType == "2") {
 		$("#btnDdedicatedAccount").trigger("click");
 	}
+
+	//다음 결제시 결제수단 SELECT
+	getNextPayMethod();
 	
 	// 등급제 대상 여부
 	getMberGrdChk();	
 });
+
+//다음 결제시 결제수단 SELECT
+function getNextPayMethod() {
+	var nextPayMethod = "";
+	$.ajax({
+	    type: "POST",
+	    url: "/web/member/pay/selectNextPayMethodAjax.do",
+	    data: {},
+	    dataType:'json',
+	    async: false,
+	    success: function (data) {
+			if (data.isSuccess) { 
+				if (data.nextPayMethod != '') {
+					nextPayMethod = data.nextPayMethod;
+					
+					// 버튼 영역
+					$(".btn_tab").removeClass("active");
+					// 금액 영역
+					$(".area_tabcont").removeClass("on");
+					
+					if (nextPayMethod == "CARD") {
+						$(".btn_charge1").addClass("active");
+						$("#tab2_1").addClass("area_tabcont on");
+					}
+					else if (nextPayMethod == "VBANK") {
+						$(".btn_charge2").addClass("active");
+						$("#tab2_2").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "CELLPHONE") {
+						$(".btn_charge3").addClass("active");
+						$("#tab2_3").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "BANK") {
+						$(".btn_charge4").addClass("active");
+						$("#tab2_4").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "NAV") {
+						$(".btn_charge5").addClass("active");
+						$("#tab2_5").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "KKO") {
+						$(".btn_charge6").addClass("active");
+						$("#tab2_6").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "TOS") {
+						$(".btn_charge7").addClass("active");
+						$("#tab2_7").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "PYC") {
+						$(".btn_charge8").addClass("active");
+						$("#tab2_8").addClass("area_tabcont on");
+					}		
+					
+					// 체크박스
+					$("input:checkbox[id='agree']").prop("checked", true); 
+				}
+			} 
+		},
+	    error: function (e) {
+	    	
+	    }
+	});		
+}
+
+// 다음 결제시 결제수단 UPDATE
+function setNextPayMethod() {
+	var nextPayMethod = "";
+	if ($("input:checkbox[id='agree']").is(":checked") == true) {
+		var $currentTab = $('.area_tab').children('.active').index();
+		if ($currentTab == 0) {	
+			nextPayMethod = "CARD";
+		} else if ($currentTab == 1) {	
+			nextPayMethod = "VBANK";		
+		} else if ($currentTab==2) {	
+			nextPayMethod = "CELLPHONE";		
+		} else if ($currentTab==3) {	
+			nextPayMethod = "BANK";		
+		} else {	
+			if ($currentTab == 4) {
+				nextPayMethod = "NAV";	// 네이버페이
+			} else if ($currentTab==5) {
+				nextPayMethod = "KKO";	// 카카오페이
+			} else if ($currentTab==6) {
+				nextPayMethod = "TOS";	// 토스페이
+			} else if ($currentTab==7) {
+				nextPayMethod = "PYC";	// 페이코
+			}	
+		}	
+	}
+	else {
+		nextPayMethod = "";		
+	}
+	
+	// 업데이트		
+	$.ajax({
+	    type: "POST",
+	    url: "/web/member/pay/updateNextPayMethodAjax.do",
+	    data: {"nextPayMethod" : nextPayMethod},
+	    dataType:'json',
+	    async: false,
+	    success: function (data) {
+			if (data.isSuccess) { 
+
+			} 
+		},
+	    error: function (e) {
+	    	
+	    }
+	});					
+}
 
 
 //결제수단 상태 체크
@@ -120,6 +233,9 @@
 		alert("충전금액을 선택해주세요.");
 		return false;
 	}
+	
+	// 다음 결제시 결제수단 UPDATE
+	setNextPayMethod();	
 
 	var payMethod = "";
 	document.pgForm.action = "/web/member/pay/PayActionAjax.do";
@@ -414,6 +530,9 @@
 		
 	}
 	
+	// 다음 결제시 결제수단 UPDATE
+	setNextPayMethod();	
+	
 	var data = new FormData(document.pgForm);
 	url = "/web/member/pay/updateVacsAccountUsrIdAjax.do";
 	
@@ -693,10 +812,10 @@
 							<li class="btn_charge3 btn_tab"><button type="button" onclick="TabTypePay(this,'3');"><i></i>휴대폰결제</button></li>
 							<li class="btn_charge4 btn_tab"><button type="button" onclick="TabTypePay(this,'4');"><i></i>즉시이체</button></li>
 							
-							<li class="btn_charge5 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'6');"><i></i></button></li>
-							<li class="btn_charge6 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'7');"><i></i></button></li>
-							<li class="btn_charge7 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'8');"><i></i></button></li>
-							<li class="btn_charge8 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'9');"><i></i></button></li>							
+							<li class="btn_charge5 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'5');"><i></i></button></li>
+							<li class="btn_charge6 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'6');"><i></i></button></li>
+							<li class="btn_charge7 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'7');"><i></i></button></li>
+							<li class="btn_charge8 btn_tab simple_pay"><button type="button" onclick="TabTypePay(this,'8');"><i></i></button></li>							
 						</ul>
 						<div class="checkbox_wrap"><input type="checkbox" id="agree"><label for="agree">선택한 수단을 다음 충전 시에도 이용합니다.</label></div>
 
@@ -1013,7 +1132,7 @@
 						<!-- //즉시이체 -->
 
 						<!-- 네이버페이 -->
-						<div class="area_tabcont" id="tab2_6">
+						<div class="area_tabcont" id="tab2_5">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 네이버페이</p>
 							<table class="tType1">
 								<colgroup>
@@ -1082,7 +1201,7 @@
 						<!-- //네이버페이 -->
 
 						<!-- 카카오페이 -->
-						<div class="area_tabcont current" id="tab2_7">
+						<div class="area_tabcont current" id="tab2_6">
 							<!-- 신규계좌발급 시 -->
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 카카오페이</p>
 							<table class="tType1">
@@ -1151,7 +1270,7 @@
 						<!-- //카카오페이 -->
 
 						<!-- 토스페이 -->
-						<div class="area_tabcont current" id="tab2_8">
+						<div class="area_tabcont current" id="tab2_7">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 토스페이</p>
 							<table class="tType1">
 								<caption></caption>
@@ -1210,7 +1329,7 @@
 						<!-- //토스페이 -->
 
 						<!-- 페이코 -->
-						<div class="area_tabcont current" id="tab2_9">
+						<div class="area_tabcont current" id="tab2_8">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> PAYCO</p>
 							<table class="tType1">
 								<caption></caption>
Add a comment
List