From 99afdc3011199969df1dad54a9f9053fa846fa20 Mon Sep 17 00:00:00 2001 From: hylee Date: Fri, 15 Mar 2024 10:27:26 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=A9=EC=8A=A4=20back=EB=8B=A8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B8=88=EC=95=A1=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fax/user/service/impl/FaxServiceImpl.java | 60 ++++++++++++++++++- .../WEB-INF/jsp/web/fax/faxDataView.jsp | 4 +- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/main/java/itn/let/fax/user/service/impl/FaxServiceImpl.java b/src/main/java/itn/let/fax/user/service/impl/FaxServiceImpl.java index d11c564f..0ef15559 100644 --- a/src/main/java/itn/let/fax/user/service/impl/FaxServiceImpl.java +++ b/src/main/java/itn/let/fax/user/service/impl/FaxServiceImpl.java @@ -2,6 +2,8 @@ package itn.let.fax.user.service.impl; import java.io.File; import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.ArrayList; @@ -37,12 +39,15 @@ import itn.let.fax.user.service.FaxReceiverVO; import itn.let.fax.user.service.FaxService; import itn.let.fax.user.service.FaxTranVO; import itn.let.mail.service.StatusResponse; +import itn.let.mjo.msg.service.MjonMsgVO; +import itn.let.mjo.msgdata.service.MjonMsgDataService; import itn.let.mjo.msgdata.service.MjonMsgDataVO; import itn.let.mjo.msgdata.service.impl.MjonMsgDataDAO; import itn.let.mjo.pay.service.MjonPayVO; import itn.let.mjo.pay.service.impl.MjonPayDAO; import itn.let.module.base.PriceAndPoint; import itn.let.sym.site.service.JoinSettingVO; +import itn.let.uss.umt.service.MberManageVO; import itn.let.utl.fcc.service.EgovStringUtil; @@ -98,7 +103,11 @@ public class FaxServiceImpl extends EgovAbstractServiceImpl implements FaxServic @Resource(name = "egovMjonCashIdGnrService") private EgovIdGnrService idgenMjonCashId; - + + + @Resource(name = "MjonMsgDataService") + private MjonMsgDataService mjonMsgDataService; + @Autowired private PriceAndPoint priceAndPoint; @@ -319,6 +328,11 @@ public class FaxServiceImpl extends EgovAbstractServiceImpl implements FaxServic @Override public StatusResponse sendData(FaxTranVO faxTranVO, String userId) throws Exception { + // 단가확인 + Boolean priceChk = this.getPriceChk(faxTranVO, userId); + if(!priceChk) { + return new StatusResponse(HttpStatus.BAD_REQUEST, "팩스 발송에 필요한 회원님의 보유 잔액이 부족 합니다.", LocalDateTime.now()); + } // 팩스발송 정보 삽입 faxTranVO.setFaxTranSeq(idgenPgiFaxTranId.getNextStringId()); @@ -346,6 +360,49 @@ public class FaxServiceImpl extends EgovAbstractServiceImpl implements FaxServic } + private Boolean getPriceChk(FaxTranVO faxTranVO, String userId) throws Exception { + + Boolean returnVal = true; + + MjonMsgVO mjonMsgVO = new MjonMsgVO(); + mjonMsgVO.setUserId(userId); + + String userMoney = mjonMsgDataService.selectBeforeCashData(mjonMsgVO); + String userPoint = mjonMsgDataService.selectBeforePointData(mjonMsgVO); + mjonMsgVO.setBefPoint(userPoint); //현재 보유 포인트 정보 저장 + + BigDecimal befCash = new BigDecimal(userMoney).setScale(2, RoundingMode.HALF_EVEN); + + + + + + int callToSize = faxTranVO.getCallToList().split(",").length; + + // 사용자 단가 + Float faxPrice = this.getFaxPrice(userId); + + // 변환 완료 테이블에서 변환된 페이지 갯수 가져오기 + // FROM PGI_FAXCONVERT + int resPage = faxDao.findAllConvertTb(faxTranVO.getFaxConvertSeq()).getResPage(); + System.out.println(" + resPage :: "+ resPage); + + Float faxPriceTotalP = callToSize*faxPrice*resPage; + + + // faxPrice를 BigDecimal로 변환 + BigDecimal faxPriceBD = new BigDecimal(faxPriceTotalP.toString()); + + System.out.println(" + befCash :: "+ befCash); + System.out.println(" + faxPriceBD :: "+ faxPriceBD); + System.out.println(" + faxPriceBD.compareTo(befCash) :: "+ faxPriceBD.compareTo(befCash)); + if (faxPriceBD.compareTo(befCash) > 0) { + returnVal = false; + } + + return returnVal; + } + @Override public Map selectFaxSendDetailList(FaxGroupDataVO faxGroupDataVO) throws Exception { @@ -491,7 +548,6 @@ public class FaxServiceImpl extends EgovAbstractServiceImpl implements FaxServic //2.사용자 개인 단가 정보 불러오기 faxPrice = mjonMsgDataDAO.selectMberManageInfo(userId).getFaxPrice(); - // SMS 인경우 // 사용자 개인 단가가 없으면 시스템 단가로 if(faxPrice == 0.0f) return sysJoinSetVO.getFaxPrice(); diff --git a/src/main/webapp/WEB-INF/jsp/web/fax/faxDataView.jsp b/src/main/webapp/WEB-INF/jsp/web/fax/faxDataView.jsp index e41469b9..38ce82ff 100644 --- a/src/main/webapp/WEB-INF/jsp/web/fax/faxDataView.jsp +++ b/src/main/webapp/WEB-INF/jsp/web/fax/faxDataView.jsp @@ -51,9 +51,9 @@ return false; } - if(!moneyChk()){ + /* if(!moneyChk()){ return false; - } + } */ if(!valueChk()){