문자발송금액 누락 오류 완료
This commit is contained in:
parent
2ef4731e34
commit
b15c76365a
@ -726,11 +726,11 @@ public final class MsgSendUtils {
|
||||
}
|
||||
|
||||
// 이벤트 잔액과 종료 조건 확인
|
||||
double targetCash = eventMberInfo.getEventRemainCash();
|
||||
double remainCash = eventMberInfo.getEventRemainCash();
|
||||
String eventEndDate = eventMberInfo.getEventEndDate();
|
||||
|
||||
if (isEventExpired(targetCash, eventEndDate)) {
|
||||
MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, targetCash);
|
||||
if (isEventExpired(remainCash, eventEndDate)) {
|
||||
MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainCash);
|
||||
return OptimalMsgResultDTO.builder()
|
||||
.optimalMsgList(optimalList)
|
||||
.eventInfo(returnEventMberInfo)
|
||||
@ -757,7 +757,7 @@ public final class MsgSendUtils {
|
||||
float floatEachPrice = Float.parseFloat(eachPrice);
|
||||
|
||||
// 최적의 메시지 리스트에 추가
|
||||
if (sum + floatEachPrice <= targetCash) {
|
||||
if (sum + floatEachPrice <= remainCash) {
|
||||
sum += floatEachPrice;
|
||||
|
||||
msg.setEachPrice(eachPrice);
|
||||
@ -771,11 +771,11 @@ public final class MsgSendUtils {
|
||||
}
|
||||
|
||||
// 이벤트 잔액 처리하는 매소드 terminateEvent
|
||||
double remainAmt = targetCash - sum;
|
||||
MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt);
|
||||
// double remainAmt = targetCash - sum;
|
||||
// MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt);
|
||||
return OptimalMsgResultDTO.builder()
|
||||
.optimalMsgList(optimalList)
|
||||
.eventInfo(returnEventMberInfo)
|
||||
// .eventInfo(returnEventMberInfo)
|
||||
.build();
|
||||
|
||||
// 결과 반환
|
||||
@ -826,20 +826,20 @@ public final class MsgSendUtils {
|
||||
* @date : 2024.11.26
|
||||
* @description : 이벤트 종료 VO 생성
|
||||
* @param eventMberInfo
|
||||
* @param targetCash
|
||||
* @param remainCash
|
||||
* @return
|
||||
*/
|
||||
private static MjonEventVO terminateEvent(MjonEventVO eventMberInfo, double targetCash) {
|
||||
public static MjonEventVO terminateEvent(MjonEventVO eventMberInfo, double remainCash) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// 이벤트 상태를 종료로 변경
|
||||
MjonEventVO returnEventMberInfo = new MjonEventVO();
|
||||
returnEventMberInfo.setEventInfoId(eventMberInfo.getEventInfoId());
|
||||
returnEventMberInfo.setMberId(eventMberInfo.getMberId());
|
||||
returnEventMberInfo.setEventRemainCash(targetCash);
|
||||
returnEventMberInfo.setEventRemainCash(remainCash);
|
||||
returnEventMberInfo.setEventStatus("Y");
|
||||
|
||||
if (targetCash < MIN_EVENT_REMAIN_CASH) {
|
||||
if (remainCash < MIN_EVENT_REMAIN_CASH) {
|
||||
returnEventMberInfo.setEventStatus("E");
|
||||
returnEventMberInfo.setEventMemo("발송 최소 금액("+ MIN_EVENT_REMAIN_CASH +") 부족 혹은 이벤트 종료일 초과되어 이벤트 종료 시킴");
|
||||
}
|
||||
@ -965,13 +965,25 @@ public final class MsgSendUtils {
|
||||
return mmsTitleTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @methodName : eventYN
|
||||
* @author : 이호영
|
||||
* @date : 2025.02.10
|
||||
* @description : 이벤트 확인
|
||||
* @param eventMberInfo
|
||||
* @return
|
||||
*/
|
||||
public static Boolean isNotEvent(MjonEventVO eventMberInfo) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (eventMberInfo == null
|
||||
|| "E".equals(eventMberInfo.getEventStatus())
|
||||
|| org.apache.commons.lang3.StringUtils.isEmpty(eventMberInfo.getEventEndDate())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -616,16 +616,13 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
||||
|
||||
// 이벤트 메시지 처리
|
||||
public StatusResponse processEventMessages(String userId, MjonMsgVO mjonMsgVO,
|
||||
List<MjonMsgSendVO> mjonMsgSendVOList) throws Exception {
|
||||
List<MjonMsgSendVO> mjonMsgSendVOList, MjonEventVO eventMberInfo) throws Exception {
|
||||
|
||||
StatusResponse statusResponse = new StatusResponse();
|
||||
|
||||
try {
|
||||
// 이벤트 정보 가져오기
|
||||
MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo_advc(userId);
|
||||
if (eventMberInfo == null
|
||||
|| "E".equals(eventMberInfo.getEventStatus())
|
||||
|| org.apache.commons.lang3.StringUtils.isEmpty(eventMberInfo.getEventEndDate())
|
||||
) {
|
||||
// 이벤트 여부 확인
|
||||
if (MsgSendUtils.isNotEvent(eventMberInfo)) {
|
||||
return statusResponse; // 이벤트 상태가 종료이거나 endDate가 없는 경우 처리하지 않음
|
||||
}
|
||||
log.info(" + 이벤트 진행 대상자 :: [{}]", userId);
|
||||
@ -642,10 +639,8 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
||||
mjonMsgSendVOList.addAll(optimalMsgList); // 기존 리스트와 병합
|
||||
}
|
||||
|
||||
// 이벤트 상태 종료 시 업데이트
|
||||
if (returnEventMberInfo != null) {
|
||||
mjonEventService.updateEventEndStatus(returnEventMberInfo);
|
||||
}
|
||||
// 이벤트 관련 데이터가 있으면 updqte
|
||||
eventChkAndInsertAmount(returnEventMberInfo);
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
@ -657,4 +652,59 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
||||
return statusResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @methodName : checkEventAndDeductAmount
|
||||
* @author : 이호영
|
||||
* @date : 2025.02.10
|
||||
* @description :
|
||||
* @param eventMberInfo
|
||||
* @param eachPrice
|
||||
* @throws Exception
|
||||
*/
|
||||
public void checkEventAndDeductAmount(MjonEventVO eventMberInfo, List<MjonMsgSendVO> groupedMsgList) throws Exception {
|
||||
|
||||
// 이벤트 그룹인지 확인
|
||||
if("Y".equals(groupedMsgList.get(0).getEventYn())) {
|
||||
// 이벤트 남은 금액
|
||||
double remainCash = eventMberInfo.getEventRemainCash();
|
||||
// 현재 그룹에서 발송한 총 금액
|
||||
float sendTotalPrice = MsgSendUtils.setPriceforVO(groupedMsgList);
|
||||
|
||||
// 이벤트 남은 금액에서 현재 그룹에 총 발송금액 차감
|
||||
remainCash -= sendTotalPrice;
|
||||
|
||||
MjonEventVO returnEventMberInfo = returnEventMberInfo = MsgSendUtils.terminateEvent(eventMberInfo, remainCash);
|
||||
|
||||
eventChkAndInsertAmount(returnEventMberInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @methodName : eventChkAndInsertAmount
|
||||
* @author : 이호영
|
||||
* @date : 2025.02.10
|
||||
* @description : 이벤트 관련 데이터가 있으면 update
|
||||
* @param returnEventMberInfo
|
||||
* @throws Exception
|
||||
*/
|
||||
private void eventChkAndInsertAmount(MjonEventVO returnEventMberInfo) throws Exception {
|
||||
// 이벤트 상태 종료 시 업데이트
|
||||
if (returnEventMberInfo != null) {
|
||||
mjonEventService.updateEventEndStatus(returnEventMberInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4100,12 +4100,16 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
mjonMsgSendVOList.get(i).setMsgId(idList.get(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 이벤트 정보 가져오기
|
||||
MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo_advc(userId);
|
||||
/*
|
||||
* 이벤트 영역 이벤트 정보 가져오기 이벤트 상태가 "E"가 아닌 경우에만 호출 이벤트 금액이 있을 시 발송 LIST에서 =>
|
||||
* optimalMsgList로 데이터 이동 이동하면서 이벤트 금액으로 설정
|
||||
*/
|
||||
// mjonCommon 호출
|
||||
statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList);
|
||||
statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList, eventMberInfo);
|
||||
if (statusResponse.getStatus() != null && !statusResponse.getStatus().equals(HttpStatus.OK)) {
|
||||
log.error("이벤트 처리 중 오류 발생: {}", statusResponse.getMessage());
|
||||
return statusResponse;
|
||||
@ -4154,6 +4158,12 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
"SMS 문자 총 " + groupedMsgList.size() + "건 중 " + instCnt + "건 발송"
|
||||
, mjonMsgVO.getMsgGroupId()
|
||||
);
|
||||
|
||||
// event chk
|
||||
if (!MsgSendUtils.isNotEvent(eventMberInfo)) {
|
||||
mjonCommon.checkEventAndDeductAmount(eventMberInfo, groupedMsgList);
|
||||
}
|
||||
|
||||
// spam 문자 저장
|
||||
handleSpamMsg_advc(mjonMsgVO, groupedMsgList.get(0));
|
||||
}
|
||||
@ -4237,52 +4247,6 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
|
||||
}
|
||||
|
||||
private String getEventYn(String p_userId, String p_eachPrice) throws Exception {
|
||||
|
||||
String returnValue="N";
|
||||
|
||||
//이벤트 회원인 경우 이벤트 캐시도 함께 차감.
|
||||
MjonEventVO mjonEventVO = new MjonEventVO();
|
||||
mjonEventVO.setMberId(p_userId);
|
||||
|
||||
// 이벤트 멤버 정보를 조회
|
||||
MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo(mjonEventVO);
|
||||
|
||||
// mjonMsgSendVO에서 EachPrice 값을 가져와 BigDecimal로 변환하고, 불필요한 소수점 0 제거
|
||||
BigDecimal eachPrice = new BigDecimal(p_eachPrice).stripTrailingZeros();
|
||||
|
||||
if(eventMberInfo != null) {
|
||||
|
||||
// eventMberInfo에서 각 가격 값을 가져와 BigDecimal로 변환하고, 불필요한 소수점 0 제거
|
||||
BigDecimal eventShortPrice = new BigDecimal(eventMberInfo.getEventShortPrice()).stripTrailingZeros();
|
||||
BigDecimal eventLongPrice = new BigDecimal(eventMberInfo.getEventLongPrice()).stripTrailingZeros();
|
||||
BigDecimal eventPicturePrice = new BigDecimal(eventMberInfo.getEventPicturePrice()).stripTrailingZeros();
|
||||
BigDecimal eventPicture2Price = new BigDecimal(eventMberInfo.getEventPicture2Price()).stripTrailingZeros();
|
||||
BigDecimal eventPicture3Price = new BigDecimal(eventMberInfo.getEventPicture3Price()).stripTrailingZeros();
|
||||
|
||||
// log.info(" + eventShortPrice :: [{}]", eventShortPrice);
|
||||
// log.info(" + eventLongPrice :: [{}]", eventLongPrice);
|
||||
// log.info(" + eventPicturePrice :: [{}]", eventPicturePrice);
|
||||
// log.info(" + eventPicture2Price :: [{}]", eventPicture2Price);
|
||||
// log.info(" + eventPicture3Price :: [{}]", eventPicture3Price);
|
||||
|
||||
// log.info(" + eachPrice :: [{}]", eachPrice);
|
||||
|
||||
// 각 가격과 비교 (stripTrailingZeros() 적용으로 7.50과 7.5를 같은 값으로 인식)
|
||||
if (eachPrice.compareTo(eventShortPrice) == 0 ||
|
||||
eachPrice.compareTo(eventLongPrice) == 0 ||
|
||||
eachPrice.compareTo(eventPicturePrice) == 0 ||
|
||||
eachPrice.compareTo(eventPicture2Price) == 0 ||
|
||||
eachPrice.compareTo(eventPicture3Price) == 0) {
|
||||
|
||||
returnValue = "Y"; // 매칭되는 가격이 있으면 이벤트 여부를 'Y'로 설정
|
||||
}
|
||||
}
|
||||
|
||||
// log.info(" + getEventYn returnValue :: [{}]", returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private int insertMsgData_advc(List<MjonMsgSendVO> mjonMsgSendVOList) {
|
||||
|
||||
// 시작 시간 측정
|
||||
@ -4553,7 +4517,6 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
mjonSpamMsgVO.setFilePath3(mjonMsgSendVO.getFilePath3());
|
||||
|
||||
int resultCnt = mjonSpamMsgService.insertSpamKeyWordMsgData(mjonMsgVO);
|
||||
System.out.println("스팸 문구 발송 내용 등록: " + resultCnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user