팩스 back단에서 금액체크
This commit is contained in:
parent
a4215242e7
commit
99afdc3011
@ -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<String, Object> 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();
|
||||
|
||||
@ -51,9 +51,9 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!moneyChk()){
|
||||
/* if(!moneyChk()){
|
||||
return false;
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
if(!valueChk()){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user