From a02fffcb7676216623009de3638cc1dd251e3d9d Mon Sep 17 00:00:00 2001 From: wyh Date: Fri, 24 Jan 2025 19:20:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=9C=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itn/let/module/base/PriceAndPoint.java | 36 ++++++++++ src/main/webapp/js/web/msgdata/msgDataView.js | 68 ++++++++++++++++++- 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/src/main/java/itn/let/module/base/PriceAndPoint.java b/src/main/java/itn/let/module/base/PriceAndPoint.java index dc2785de..d661aa35 100644 --- a/src/main/java/itn/let/module/base/PriceAndPoint.java +++ b/src/main/java/itn/let/module/base/PriceAndPoint.java @@ -9,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import egovframework.rte.fdl.idgnr.EgovIdGnrService; +import itn.let.mjo.event.service.MjonEventService; +import itn.let.mjo.event.service.MjonEventVO; +import itn.let.mjo.event.service.impl.MjonEventDAO; import itn.let.mjo.msg.service.MjonMsgVO; import itn.let.mjo.msgdata.service.impl.MjonMsgDataDAO; import itn.let.mjo.pay.service.MjonPayVO; @@ -37,6 +40,9 @@ public class PriceAndPoint { @Autowired private MjonPayDAO mjonPayDAO; + + @Autowired + private MjonEventService mjonEventService; @Resource(name = "egovMjonCashIdGnrService") private EgovIdGnrService idgenMjonCashId; @@ -119,6 +125,36 @@ public class PriceAndPoint { mjonPayDAO.insertCash(mjonPayVO); //캐시 mjonPayDAO.updateMemberCash(mjonPayVO); //회원정보 업데이트 + //이벤트 회원인 경우 이벤트 캐시도 함께 차감. + MjonEventVO mjonEventVO = new MjonEventVO(); + mjonEventVO.setMberId(mjonPayVO.getUserId()); + mjonEventVO.setEventStatus("Y"); + MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo(mjonEventVO); + + if(eventMberInfo != null) { + + float evntRemainCash = (float) eventMberInfo.getEventRemainCash(); + totPrice = (float) Math.abs(mjonPayVO.getCash()); + + float totRemainCash = evntRemainCash - totPrice; + mjonEventVO.setEventInfoId(eventMberInfo.getEventInfoId()); + + if(totRemainCash <= 0.0) {//차감액이 남아있지 않으면 이벤트를 종료 + + //이벤트 상태값을 종료로 변경한다. + mjonEventVO.setEventStatus("E"); + mjonEventVO.setEventRemainCash(0.0); + mjonEventService.updateEventEndStatus(mjonEventVO); + + }else {//이벤트 회원 캐시 차감시킴 + + mjonEventVO.setEventRemainCash(totRemainCash); + mjonEventService.updateEventRemainCash(mjonEventVO); + + } + + } + } diff --git a/src/main/webapp/js/web/msgdata/msgDataView.js b/src/main/webapp/js/web/msgdata/msgDataView.js index 3e222fe8..ff5c020a 100644 --- a/src/main/webapp/js/web/msgdata/msgDataView.js +++ b/src/main/webapp/js/web/msgdata/msgDataView.js @@ -1067,13 +1067,35 @@ function fn_sendMsgData(){ var eventRemainCash = parseFloat(form.eventRemainCash.value); console.log('eventStatus : ', eventStatus); - if(eventStatus == 'Y' - && parseFloat(eventRemainCash) < parseFloat(totPriceOnly)) + if(eventStatus == 'Y' && parseFloat(eventRemainCash) < parseFloat(totPriceOnly)) { + + // 이벤트 금액 부족 상태 요청하신 모두 발송할 수 없습니다 console.log('eventRemainCash : ', eventRemainCash); if(!confirm("고객님의 이벤트 캐시 잔액(" + eventRemainCash + "원) 부족으로 요청하신 문자("+numberWithCommas($selectedData.length)+"건)를 모두 발송할 수 없습니다. 이벤트 캐시 초과 건에 대해서는 일반 단가를 적용하여 발송하시겠습니까?")){ return false; } + + // 이벤트 캐시 초과 건에 대해서는 일반 단가를 적용하여 발송하시겠습니까 + + var evnMsgType = $("#msgType").val(); // 문자전송 타입 + var norEachPrice = getNorEachPrice(evnMsgType); // 일반전송 금액 + var eventEachPrice = getEventEachPrice(evnMsgType); // 이벤트 전송 금액 + var eventCount = eventRemainCash/eventEachPrice; // 이벤트금액으로 전송가능한 수량 + console.log('eventCount : ', parseInt(eventCount)); + var norCount = numberWithCommas($selectedData.length)-parseInt(eventCount); // 일반금액으로 전송수량 + console.log('norCount : ', parseInt(norCount)); + + var norAccount = norCount * norEachPrice; // 일반금액으로 변경한 발송금액 + var totAccount = userMoneyOnly - norAccount // + console.log('norAccount : ', norAccount); + console.log('userMoneyOnly : ', userMoneyOnly); + console.log('totAccount : ', totAccount); + + if(totAccount < 0){ + alert("고객님의 이벤트 캐시 잔액(" + parseInt(totAccount)*-1 + "원) 부족으로 요청하신 문자("+numberWithCommas($selectedData.length)+"건)를 모두 발송할 수 없습니다."); + return false; + } } console.log(' !!! imgFilePath : ', imgFilePath); @@ -1411,6 +1433,48 @@ function getNorEachPrice(evnMsgType){ return norEachPrice; } + +//이벤트가 아닌 일반 개별 단가 셋팅해주기 +function getEventEachPrice(evnMsgType){ + + var eventEachPrice = 0; + var evnImgCnt = $("#imgCnt").val(); + + //일반 단가로 변경해주기 + if(evnMsgType == '4'){ + + eventEachPrice = $("#sPrice").val(); + console.log("eventEachPrice Short::: "+eventEachPrice); + + }else if(evnMsgType == '6'){ + + if(evnImgCnt == 0){//장문 가격 + + eventEachPrice = $("#mPrice").val(); + console.log("eventEachPrice Long ::: "+eventEachPrice); + + }else if(evnImgCnt == 1){ + + eventEachPrice = $("#pPrice").val(); + console.log("eventEachPrice p1 ::: "+eventEachPrice); + + }else if(evnImgCnt == 2){ + + eventEachPrice = $("#p2Price").val(); + console.log("eventEachPrice p2 ::: "+eventEachPrice); + + }else if(evnImgCnt == 3){ + + eventEachPrice = $("#p3Price").val(); + console.log("eventEachPrice p3 ::: "+eventEachPrice); + + } + + } + + return eventEachPrice; +} + //빈 값이나 null 값을 제거하는 함수 function removeEmptyValues(obj) { Object.keys(obj).forEach(function(key) {