문자발송시 이벤트 누락 및 오류 개선
This commit is contained in:
parent
a2ba4a9865
commit
726a803e3e
@ -110,9 +110,9 @@ public class MjonMsgSendVO{
|
||||
|
||||
|
||||
/**
|
||||
* @description : event 여부 / group tb에 넣는 용도
|
||||
* @description : event 여부 / group tb에 넣는 용도 / 기본값 N
|
||||
*/
|
||||
private String eventYn;
|
||||
private String eventYn="N";
|
||||
|
||||
|
||||
|
||||
|
||||
@ -759,8 +759,10 @@ public final class MsgSendUtils {
|
||||
// 최적의 메시지 리스트에 추가
|
||||
if (sum + floatEachPrice <= targetCash) {
|
||||
sum += floatEachPrice;
|
||||
|
||||
msg.setEachPrice(eachPrice);
|
||||
msg.setEventYn("Y");
|
||||
|
||||
optimalList.add(msg);
|
||||
iterator.remove();
|
||||
} else {
|
||||
@ -768,22 +770,19 @@ public final class MsgSendUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// 잔액 부족 시 이벤트 종료 처리하는 VO 생성
|
||||
// 이벤트 잔액 처리하는 매소드 terminateEvent
|
||||
double remainAmt = targetCash - sum;
|
||||
log.info("remainAmt :: [{}]", remainAmt);
|
||||
if (remainAmt < MIN_EVENT_REMAIN_CASH) {
|
||||
MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt);
|
||||
return OptimalMsgResultDTO.builder()
|
||||
.optimalMsgList(optimalList)
|
||||
.eventInfo(returnEventMberInfo)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 결과 반환
|
||||
MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt);
|
||||
return OptimalMsgResultDTO.builder()
|
||||
.optimalMsgList(optimalList)
|
||||
.eventInfo(null)
|
||||
.eventInfo(returnEventMberInfo)
|
||||
.build();
|
||||
|
||||
// 결과 반환
|
||||
// return OptimalMsgResultDTO.builder()
|
||||
// .optimalMsgList(optimalList)
|
||||
// .eventInfo(null)
|
||||
// .build();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -836,9 +835,14 @@ public final class MsgSendUtils {
|
||||
// 이벤트 상태를 종료로 변경
|
||||
MjonEventVO returnEventMberInfo = new MjonEventVO();
|
||||
returnEventMberInfo.setEventInfoId(eventMberInfo.getEventInfoId());
|
||||
returnEventMberInfo.setEventStatus("E");
|
||||
returnEventMberInfo.setMberId(eventMberInfo.getMberId());
|
||||
returnEventMberInfo.setEventRemainCash(targetCash);
|
||||
returnEventMberInfo.setEventMemo("발송 최소 금액("+ MIN_EVENT_REMAIN_CASH +") 부족 혹은 이벤트 종료일 초과되어 이벤트 종료 시킴");
|
||||
returnEventMberInfo.setEventStatus("Y");
|
||||
|
||||
if (targetCash < MIN_EVENT_REMAIN_CASH) {
|
||||
returnEventMberInfo.setEventStatus("E");
|
||||
returnEventMberInfo.setEventMemo("발송 최소 금액("+ MIN_EVENT_REMAIN_CASH +") 부족 혹은 이벤트 종료일 초과되어 이벤트 종료 시킴");
|
||||
}
|
||||
return returnEventMberInfo;
|
||||
}
|
||||
|
||||
|
||||
@ -629,6 +629,7 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
||||
return statusResponse; // 이벤트 상태가 종료이거나 endDate가 없는 경우 처리하지 않음
|
||||
}
|
||||
log.info(" + 이벤트 진행 대상자 :: [{}]", userId);
|
||||
log.info(" + 이벤트 진행 대상자 eventMberInfo.getMberId() :: [{}]", eventMberInfo.getMberId());
|
||||
|
||||
// 최적화된 메시지 리스트 및 이벤트 정보 가져오기
|
||||
OptimalMsgResultDTO result = MsgSendUtils.getOptimalMsgList(eventMberInfo, mjonMsgSendVOList);
|
||||
@ -642,8 +643,7 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
||||
}
|
||||
|
||||
// 이벤트 상태 종료 시 업데이트
|
||||
if (returnEventMberInfo != null && "E".equals(returnEventMberInfo.getEventStatus())) {
|
||||
returnEventMberInfo.setMberId(userId);
|
||||
if (returnEventMberInfo != null) {
|
||||
mjonEventService.updateEventEndStatus(returnEventMberInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -4125,12 +4125,13 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
Map<String, List<MjonMsgSendVO>> priceGroupedMessages = mjonMsgSendVOList.stream()
|
||||
.collect(Collectors.groupingBy(MjonMsgSendVO::getEachPrice));
|
||||
|
||||
// instTotalCnt : 화면에서 보여줄 총 발송건수
|
||||
int instTotalCnt = 0;
|
||||
// Step 2: 그룹화 된 데이터를 그룹별로 insert 처리
|
||||
for (Map.Entry<String, List<MjonMsgSendVO>> entry : priceGroupedMessages.entrySet()) {
|
||||
String price = entry.getKey(); // 가격 (String)
|
||||
List<MjonMsgSendVO> groupedMsgList = entry.getValue(); // 해당 가격의 메시지 리스트
|
||||
|
||||
|
||||
// msgGroupId 생성
|
||||
String nextMsgGroupId = idgenMjonMsgGroupId.getNextStringId();
|
||||
groupedMsgList.forEach(t -> t.setMsgGroupId(nextMsgGroupId));
|
||||
@ -4139,12 +4140,17 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
int instCnt = this.insertMsgData_advc(groupedMsgList);
|
||||
|
||||
if (instCnt > 0) {
|
||||
|
||||
instTotalCnt += instCnt;
|
||||
this.insertMsgGroupDataTb_advc(instCnt, mjonMsgVO, groupedMsgList);
|
||||
|
||||
// 금액 및 포인트 insert
|
||||
priceAndPoint.insertCashAndPoint(userId, -Float.parseFloat(mjonMsgVO.getTotPrice()),
|
||||
"SMS 문자 총 " + groupedMsgList.size() + "건 중 " + instCnt + "건 발송", mjonMsgVO.getMsgGroupId());
|
||||
priceAndPoint.insertCashAndPoint(
|
||||
userId
|
||||
, -Float.parseFloat(mjonMsgVO.getTotPrice()),
|
||||
"SMS 문자 총 " + groupedMsgList.size() + "건 중 " + instCnt + "건 발송"
|
||||
, mjonMsgVO.getMsgGroupId()
|
||||
);
|
||||
// spam 문자 저장
|
||||
handleSpamMsg_advc(mjonMsgVO, groupedMsgList.get(0));
|
||||
}
|
||||
@ -4167,7 +4173,6 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
|
||||
// TEST발송 시 발송 후 캐시가 있어야함.
|
||||
returnMap.put("afterCash", priceAndPoint.getBefCash(userId));
|
||||
log.debug("총 단가 합계: [{}]", mjonMsgVO.getTotPrice());
|
||||
//
|
||||
|
||||
boolean isNotified = mjonCommon.processUserAndCheckSms(mjonMsgVO, userId);
|
||||
@ -4203,46 +4208,11 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
// 개별단가
|
||||
mjonMsgVO.setEachPrice(mjonMsgSendVO.getEachPrice());
|
||||
|
||||
//이벤트 회원인 경우 이벤트 캐시도 함께 차감.
|
||||
MjonEventVO mjonEventVO = new MjonEventVO();
|
||||
mjonEventVO.setMberId(mjonMsgSendVO.getUserId());
|
||||
MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo(mjonEventVO);
|
||||
|
||||
String str = String.valueOf(mjonMsgSendVO.getEachPrice());
|
||||
// 소수점 제거
|
||||
String EachPrice = str.split("\\.")[0];
|
||||
|
||||
|
||||
if(eventMberInfo != null) {
|
||||
String eventShortPrice = String.valueOf(eventMberInfo.getEventShortPrice());
|
||||
eventShortPrice = eventShortPrice.split("\\.")[0];
|
||||
|
||||
String eventLongPrice = String.valueOf(eventMberInfo.getEventLongPrice());
|
||||
eventLongPrice = eventLongPrice.split("\\.")[0];
|
||||
|
||||
String eventPicturePrice = String.valueOf(eventMberInfo.getEventPicturePrice());
|
||||
eventPicturePrice = eventPicturePrice.split("\\.")[0];
|
||||
|
||||
String eventPicture2Price = String.valueOf(eventMberInfo.getEventPicture2Price());
|
||||
eventPicture2Price = eventPicture2Price.split("\\.")[0];
|
||||
|
||||
String eventPicture3Price = String.valueOf(eventMberInfo.getEventPicture3Price());
|
||||
eventPicture3Price = eventPicture3Price.split("\\.")[0];
|
||||
|
||||
if(EachPrice.equals(eventShortPrice)) {
|
||||
mjonMsgVO.setEventYn("Y");
|
||||
}else if(EachPrice.equals(eventLongPrice)) {
|
||||
mjonMsgVO.setEventYn("Y");
|
||||
}else if(EachPrice.equals(eventPicturePrice)) {
|
||||
mjonMsgVO.setEventYn("Y");
|
||||
}else if(EachPrice.equals(eventPicture2Price)) {
|
||||
mjonMsgVO.setEventYn("Y");
|
||||
}else if(EachPrice.equals(eventPicture3Price)) {
|
||||
mjonMsgVO.setEventYn("Y");
|
||||
}else {
|
||||
mjonMsgVO.setEventYn("N");
|
||||
}
|
||||
}
|
||||
mjonMsgVO.setEventYn(mjonMsgSendVO.getEventYn());
|
||||
|
||||
// event Chk
|
||||
// String eventYn = getEventYn(mjonMsgSendVO.getUserId(), mjonMsgSendVO.getEachPrice());
|
||||
// mjonMsgVO.setEventYn(eventYn);
|
||||
|
||||
|
||||
// 전송사 코드 번호를 셋팅해 준다.
|
||||
@ -4264,6 +4234,52 @@ 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) {
|
||||
|
||||
// 시작 시간 측정
|
||||
|
||||
@ -124,36 +124,6 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +180,9 @@
|
||||
<isNotEmpty property="eventEndDate">
|
||||
,EVENT_END_DATE = #eventEndDate#
|
||||
</isNotEmpty>
|
||||
<isNotEmpty property="eventStatus">
|
||||
, EVENT_STATUS = #eventStatus#
|
||||
</isNotEmpty>
|
||||
, LAST_UPDT_PNTTM = NOW()
|
||||
WHERE MBER_ID = #mberId#
|
||||
AND EVENT_INFO_ID = #eventInfoId#
|
||||
|
||||
Loading…
Reference in New Issue
Block a user