--- src/main/java/itn/com/cmm/util/MsgSendUtils.java
+++ src/main/java/itn/com/cmm/util/MsgSendUtils.java
... | ... | @@ -726,11 +726,11 @@ |
| 726 | 726 |
} |
| 727 | 727 |
|
| 728 | 728 |
// 이벤트 잔액과 종료 조건 확인 |
| 729 |
- double targetCash = eventMberInfo.getEventRemainCash(); |
|
| 729 |
+ double remainCash = eventMberInfo.getEventRemainCash(); |
|
| 730 | 730 |
String eventEndDate = eventMberInfo.getEventEndDate(); |
| 731 | 731 |
|
| 732 |
- if (isEventExpired(targetCash, eventEndDate)) {
|
|
| 733 |
- MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, targetCash); |
|
| 732 |
+ if (isEventExpired(remainCash, eventEndDate)) {
|
|
| 733 |
+ MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainCash); |
|
| 734 | 734 |
return OptimalMsgResultDTO.builder() |
| 735 | 735 |
.optimalMsgList(optimalList) |
| 736 | 736 |
.eventInfo(returnEventMberInfo) |
... | ... | @@ -757,7 +757,7 @@ |
| 757 | 757 |
float floatEachPrice = Float.parseFloat(eachPrice); |
| 758 | 758 |
|
| 759 | 759 |
// 최적의 메시지 리스트에 추가 |
| 760 |
- if (sum + floatEachPrice <= targetCash) {
|
|
| 760 |
+ if (sum + floatEachPrice <= remainCash) {
|
|
| 761 | 761 |
sum += floatEachPrice; |
| 762 | 762 |
|
| 763 | 763 |
msg.setEachPrice(eachPrice); |
... | ... | @@ -771,11 +771,11 @@ |
| 771 | 771 |
} |
| 772 | 772 |
|
| 773 | 773 |
// 이벤트 잔액 처리하는 매소드 terminateEvent |
| 774 |
- double remainAmt = targetCash - sum; |
|
| 775 |
- MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt); |
|
| 774 |
+// double remainAmt = targetCash - sum; |
|
| 775 |
+// MjonEventVO returnEventMberInfo = terminateEvent(eventMberInfo, remainAmt); |
|
| 776 | 776 |
return OptimalMsgResultDTO.builder() |
| 777 | 777 |
.optimalMsgList(optimalList) |
| 778 |
- .eventInfo(returnEventMberInfo) |
|
| 778 |
+// .eventInfo(returnEventMberInfo) |
|
| 779 | 779 |
.build(); |
| 780 | 780 |
|
| 781 | 781 |
// 결과 반환 |
... | ... | @@ -826,20 +826,20 @@ |
| 826 | 826 |
* @date : 2024.11.26 |
| 827 | 827 |
* @description : 이벤트 종료 VO 생성 |
| 828 | 828 |
* @param eventMberInfo |
| 829 |
- * @param targetCash |
|
| 829 |
+ * @param remainCash |
|
| 830 | 830 |
* @return |
| 831 | 831 |
*/ |
| 832 |
- private static MjonEventVO terminateEvent(MjonEventVO eventMberInfo, double targetCash) {
|
|
| 832 |
+ public static MjonEventVO terminateEvent(MjonEventVO eventMberInfo, double remainCash) {
|
|
| 833 | 833 |
// TODO Auto-generated method stub |
| 834 | 834 |
|
| 835 | 835 |
// 이벤트 상태를 종료로 변경 |
| 836 | 836 |
MjonEventVO returnEventMberInfo = new MjonEventVO(); |
| 837 | 837 |
returnEventMberInfo.setEventInfoId(eventMberInfo.getEventInfoId()); |
| 838 | 838 |
returnEventMberInfo.setMberId(eventMberInfo.getMberId()); |
| 839 |
- returnEventMberInfo.setEventRemainCash(targetCash); |
|
| 839 |
+ returnEventMberInfo.setEventRemainCash(remainCash); |
|
| 840 | 840 |
returnEventMberInfo.setEventStatus("Y");
|
| 841 | 841 |
|
| 842 |
- if (targetCash < MIN_EVENT_REMAIN_CASH) {
|
|
| 842 |
+ if (remainCash < MIN_EVENT_REMAIN_CASH) {
|
|
| 843 | 843 |
returnEventMberInfo.setEventStatus("E");
|
| 844 | 844 |
returnEventMberInfo.setEventMemo("발송 최소 금액("+ MIN_EVENT_REMAIN_CASH +") 부족 혹은 이벤트 종료일 초과되어 이벤트 종료 시킴");
|
| 845 | 845 |
} |
... | ... | @@ -965,13 +965,25 @@ |
| 965 | 965 |
return mmsTitleTemp; |
| 966 | 966 |
} |
| 967 | 967 |
|
| 968 |
+ /** |
|
| 969 |
+ * @methodName : eventYN |
|
| 970 |
+ * @author : 이호영 |
|
| 971 |
+ * @date : 2025.02.10 |
|
| 972 |
+ * @description : 이벤트 확인 |
|
| 973 |
+ * @param eventMberInfo |
|
| 974 |
+ * @return |
|
| 975 |
+ */ |
|
| 976 |
+ public static Boolean isNotEvent(MjonEventVO eventMberInfo) {
|
|
| 977 |
+ |
|
| 968 | 978 |
|
| 969 |
- |
|
| 970 |
- |
|
| 971 |
- |
|
| 972 |
- |
|
| 973 |
- |
|
| 974 |
- |
|
| 979 |
+ if (eventMberInfo == null |
|
| 980 |
+ || "E".equals(eventMberInfo.getEventStatus()) |
|
| 981 |
+ || org.apache.commons.lang3.StringUtils.isEmpty(eventMberInfo.getEventEndDate()) |
|
| 982 |
+ ) {
|
|
| 983 |
+ return true; |
|
| 984 |
+ } |
|
| 985 |
+ return false; |
|
| 986 |
+ } |
|
| 975 | 987 |
|
| 976 | 988 |
|
| 977 | 989 |
|
--- src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
+++ src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
... | ... | @@ -616,16 +616,13 @@ |
| 616 | 616 |
|
| 617 | 617 |
// 이벤트 메시지 처리 |
| 618 | 618 |
public StatusResponse processEventMessages(String userId, MjonMsgVO mjonMsgVO, |
| 619 |
- List<MjonMsgSendVO> mjonMsgSendVOList) throws Exception {
|
|
| 619 |
+ List<MjonMsgSendVO> mjonMsgSendVOList, MjonEventVO eventMberInfo) throws Exception {
|
|
| 620 |
+ |
|
| 620 | 621 |
StatusResponse statusResponse = new StatusResponse(); |
| 621 | 622 |
|
| 622 | 623 |
try {
|
| 623 |
- // 이벤트 정보 가져오기 |
|
| 624 |
- MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo_advc(userId); |
|
| 625 |
- if (eventMberInfo == null |
|
| 626 |
- || "E".equals(eventMberInfo.getEventStatus()) |
|
| 627 |
- || org.apache.commons.lang3.StringUtils.isEmpty(eventMberInfo.getEventEndDate()) |
|
| 628 |
- ) {
|
|
| 624 |
+ // 이벤트 여부 확인 |
|
| 625 |
+ if (MsgSendUtils.isNotEvent(eventMberInfo)) {
|
|
| 629 | 626 |
return statusResponse; // 이벤트 상태가 종료이거나 endDate가 없는 경우 처리하지 않음 |
| 630 | 627 |
} |
| 631 | 628 |
log.info(" + 이벤트 진행 대상자 :: [{}]", userId);
|
... | ... | @@ -642,10 +639,8 @@ |
| 642 | 639 |
mjonMsgSendVOList.addAll(optimalMsgList); // 기존 리스트와 병합 |
| 643 | 640 |
} |
| 644 | 641 |
|
| 645 |
- // 이벤트 상태 종료 시 업데이트 |
|
| 646 |
- if (returnEventMberInfo != null) {
|
|
| 647 |
- mjonEventService.updateEventEndStatus(returnEventMberInfo); |
|
| 648 |
- } |
|
| 642 |
+ // 이벤트 관련 데이터가 있으면 updqte |
|
| 643 |
+ eventChkAndInsertAmount(returnEventMberInfo); |
|
| 649 | 644 |
|
| 650 | 645 |
} catch (IllegalArgumentException e) {
|
| 651 | 646 |
|
... | ... | @@ -656,5 +651,60 @@ |
| 656 | 651 |
|
| 657 | 652 |
return statusResponse; |
| 658 | 653 |
} |
| 654 |
+ |
|
| 655 |
+ |
|
| 656 |
+ /** |
|
| 657 |
+ * @methodName : checkEventAndDeductAmount |
|
| 658 |
+ * @author : 이호영 |
|
| 659 |
+ * @date : 2025.02.10 |
|
| 660 |
+ * @description : |
|
| 661 |
+ * @param eventMberInfo |
|
| 662 |
+ * @param eachPrice |
|
| 663 |
+ * @throws Exception |
|
| 664 |
+ */ |
|
| 665 |
+ public void checkEventAndDeductAmount(MjonEventVO eventMberInfo, List<MjonMsgSendVO> groupedMsgList) throws Exception {
|
|
| 666 |
+ |
|
| 667 |
+ // 이벤트 그룹인지 확인 |
|
| 668 |
+ if("Y".equals(groupedMsgList.get(0).getEventYn())) {
|
|
| 669 |
+ // 이벤트 남은 금액 |
|
| 670 |
+ double remainCash = eventMberInfo.getEventRemainCash(); |
|
| 671 |
+ // 현재 그룹에서 발송한 총 금액 |
|
| 672 |
+ float sendTotalPrice = MsgSendUtils.setPriceforVO(groupedMsgList); |
|
| 673 |
+ |
|
| 674 |
+ // 이벤트 남은 금액에서 현재 그룹에 총 발송금액 차감 |
|
| 675 |
+ remainCash -= sendTotalPrice; |
|
| 676 |
+ |
|
| 677 |
+ MjonEventVO returnEventMberInfo = returnEventMberInfo = MsgSendUtils.terminateEvent(eventMberInfo, remainCash); |
|
| 678 |
+ |
|
| 679 |
+ eventChkAndInsertAmount(returnEventMberInfo); |
|
| 680 |
+ } |
|
| 681 |
+ |
|
| 682 |
+ } |
|
| 683 |
+ |
|
| 684 |
+ |
|
| 685 |
+ /** |
|
| 686 |
+ * @methodName : eventChkAndInsertAmount |
|
| 687 |
+ * @author : 이호영 |
|
| 688 |
+ * @date : 2025.02.10 |
|
| 689 |
+ * @description : 이벤트 관련 데이터가 있으면 update |
|
| 690 |
+ * @param returnEventMberInfo |
|
| 691 |
+ * @throws Exception |
|
| 692 |
+ */ |
|
| 693 |
+ private void eventChkAndInsertAmount(MjonEventVO returnEventMberInfo) throws Exception {
|
|
| 694 |
+ // 이벤트 상태 종료 시 업데이트 |
|
| 695 |
+ if (returnEventMberInfo != null) {
|
|
| 696 |
+ mjonEventService.updateEventEndStatus(returnEventMberInfo); |
|
| 697 |
+ } |
|
| 698 |
+ } |
|
| 699 |
+ |
|
| 700 |
+ |
|
| 701 |
+ |
|
| 702 |
+ |
|
| 703 |
+ |
|
| 704 |
+ |
|
| 705 |
+ |
|
| 706 |
+ |
|
| 707 |
+ |
|
| 708 |
+ |
|
| 659 | 709 |
|
| 660 | 710 |
} |
--- src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
+++ src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
... | ... | @@ -4100,12 +4100,16 @@ |
| 4100 | 4100 |
mjonMsgSendVOList.get(i).setMsgId(idList.get(i)); |
| 4101 | 4101 |
} |
| 4102 | 4102 |
|
| 4103 |
+ |
|
| 4104 |
+ |
|
| 4105 |
+ // 이벤트 정보 가져오기 |
|
| 4106 |
+ MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo_advc(userId); |
|
| 4103 | 4107 |
/* |
| 4104 | 4108 |
* 이벤트 영역 이벤트 정보 가져오기 이벤트 상태가 "E"가 아닌 경우에만 호출 이벤트 금액이 있을 시 발송 LIST에서 => |
| 4105 | 4109 |
* optimalMsgList로 데이터 이동 이동하면서 이벤트 금액으로 설정 |
| 4106 | 4110 |
*/ |
| 4107 | 4111 |
// mjonCommon 호출 |
| 4108 |
- statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList); |
|
| 4112 |
+ statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList, eventMberInfo); |
|
| 4109 | 4113 |
if (statusResponse.getStatus() != null && !statusResponse.getStatus().equals(HttpStatus.OK)) {
|
| 4110 | 4114 |
log.error("이벤트 처리 중 오류 발생: {}", statusResponse.getMessage());
|
| 4111 | 4115 |
return statusResponse; |
... | ... | @@ -4154,6 +4158,12 @@ |
| 4154 | 4158 |
"SMS 문자 총 " + groupedMsgList.size() + "건 중 " + instCnt + "건 발송" |
| 4155 | 4159 |
, mjonMsgVO.getMsgGroupId() |
| 4156 | 4160 |
); |
| 4161 |
+ |
|
| 4162 |
+ // event chk |
|
| 4163 |
+ if (!MsgSendUtils.isNotEvent(eventMberInfo)) {
|
|
| 4164 |
+ mjonCommon.checkEventAndDeductAmount(eventMberInfo, groupedMsgList); |
|
| 4165 |
+ } |
|
| 4166 |
+ |
|
| 4157 | 4167 |
// spam 문자 저장 |
| 4158 | 4168 |
handleSpamMsg_advc(mjonMsgVO, groupedMsgList.get(0)); |
| 4159 | 4169 |
} |
... | ... | @@ -4235,52 +4245,6 @@ |
| 4235 | 4245 |
|
| 4236 | 4246 |
mjonMsgDAO.insertGroupMsgData(mjonMsgVO); |
| 4237 | 4247 |
|
| 4238 |
- } |
|
| 4239 |
- |
|
| 4240 |
- private String getEventYn(String p_userId, String p_eachPrice) throws Exception {
|
|
| 4241 |
- |
|
| 4242 |
- String returnValue="N"; |
|
| 4243 |
- |
|
| 4244 |
- //이벤트 회원인 경우 이벤트 캐시도 함께 차감. |
|
| 4245 |
- MjonEventVO mjonEventVO = new MjonEventVO(); |
|
| 4246 |
- mjonEventVO.setMberId(p_userId); |
|
| 4247 |
- |
|
| 4248 |
- // 이벤트 멤버 정보를 조회 |
|
| 4249 |
- MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo(mjonEventVO); |
|
| 4250 |
- |
|
| 4251 |
- // mjonMsgSendVO에서 EachPrice 값을 가져와 BigDecimal로 변환하고, 불필요한 소수점 0 제거 |
|
| 4252 |
- BigDecimal eachPrice = new BigDecimal(p_eachPrice).stripTrailingZeros(); |
|
| 4253 |
- |
|
| 4254 |
- if(eventMberInfo != null) {
|
|
| 4255 |
- |
|
| 4256 |
- // eventMberInfo에서 각 가격 값을 가져와 BigDecimal로 변환하고, 불필요한 소수점 0 제거 |
|
| 4257 |
- BigDecimal eventShortPrice = new BigDecimal(eventMberInfo.getEventShortPrice()).stripTrailingZeros(); |
|
| 4258 |
- BigDecimal eventLongPrice = new BigDecimal(eventMberInfo.getEventLongPrice()).stripTrailingZeros(); |
|
| 4259 |
- BigDecimal eventPicturePrice = new BigDecimal(eventMberInfo.getEventPicturePrice()).stripTrailingZeros(); |
|
| 4260 |
- BigDecimal eventPicture2Price = new BigDecimal(eventMberInfo.getEventPicture2Price()).stripTrailingZeros(); |
|
| 4261 |
- BigDecimal eventPicture3Price = new BigDecimal(eventMberInfo.getEventPicture3Price()).stripTrailingZeros(); |
|
| 4262 |
- |
|
| 4263 |
-// log.info(" + eventShortPrice :: [{}]", eventShortPrice);
|
|
| 4264 |
-// log.info(" + eventLongPrice :: [{}]", eventLongPrice);
|
|
| 4265 |
-// log.info(" + eventPicturePrice :: [{}]", eventPicturePrice);
|
|
| 4266 |
-// log.info(" + eventPicture2Price :: [{}]", eventPicture2Price);
|
|
| 4267 |
-// log.info(" + eventPicture3Price :: [{}]", eventPicture3Price);
|
|
| 4268 |
- |
|
| 4269 |
-// log.info(" + eachPrice :: [{}]", eachPrice);
|
|
| 4270 |
- |
|
| 4271 |
- // 각 가격과 비교 (stripTrailingZeros() 적용으로 7.50과 7.5를 같은 값으로 인식) |
|
| 4272 |
- if (eachPrice.compareTo(eventShortPrice) == 0 || |
|
| 4273 |
- eachPrice.compareTo(eventLongPrice) == 0 || |
|
| 4274 |
- eachPrice.compareTo(eventPicturePrice) == 0 || |
|
| 4275 |
- eachPrice.compareTo(eventPicture2Price) == 0 || |
|
| 4276 |
- eachPrice.compareTo(eventPicture3Price) == 0) {
|
|
| 4277 |
- |
|
| 4278 |
- returnValue = "Y"; // 매칭되는 가격이 있으면 이벤트 여부를 'Y'로 설정 |
|
| 4279 |
- } |
|
| 4280 |
- } |
|
| 4281 |
- |
|
| 4282 |
-// log.info(" + getEventYn returnValue :: [{}]", returnValue);
|
|
| 4283 |
- return returnValue; |
|
| 4284 | 4248 |
} |
| 4285 | 4249 |
|
| 4286 | 4250 |
private int insertMsgData_advc(List<MjonMsgSendVO> mjonMsgSendVOList) {
|
... | ... | @@ -4553,7 +4517,6 @@ |
| 4553 | 4517 |
mjonSpamMsgVO.setFilePath3(mjonMsgSendVO.getFilePath3()); |
| 4554 | 4518 |
|
| 4555 | 4519 |
int resultCnt = mjonSpamMsgService.insertSpamKeyWordMsgData(mjonMsgVO); |
| 4556 |
- System.out.println("스팸 문구 발송 내용 등록: " + resultCnt);
|
|
| 4557 | 4520 |
} |
| 4558 | 4521 |
} |
| 4559 | 4522 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?