--- src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
+++ src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
... | ... | @@ -4111,7 +4111,10 @@ |
| 4111 | 4111 |
return statusResponse; |
| 4112 | 4112 |
} |
| 4113 | 4113 |
|
| 4114 |
- if (!isCashSufficient(mjonMsgVO)) {
|
|
| 4114 |
+ /* |
|
| 4115 |
+ * @ 금액체크 |
|
| 4116 |
+ * */ |
|
| 4117 |
+ if (!isCashSufficient(mjonMsgVO, mjonMsgSendVOList)) {
|
|
| 4115 | 4118 |
log.error("Insufficient balance for message sending.");
|
| 4116 | 4119 |
return new StatusResponse(HttpStatus.BAD_REQUEST, "문자 발송에 필요한 보유 잔액이 부족 합니다."); |
| 4117 | 4120 |
} |
... | ... | @@ -4476,7 +4479,7 @@ |
| 4476 | 4479 |
* |
| 4477 | 4480 |
* return statusResponse; } |
| 4478 | 4481 |
*/ |
| 4479 |
- |
|
| 4482 |
+/* |
|
| 4480 | 4483 |
private Map<String, String> fncSendMsgRtnMap(MjonMsgVO mjonMsgVO) throws Exception {
|
| 4481 | 4484 |
Map<String, String> returnMap = new HashMap<String, String>(); |
| 4482 | 4485 |
|
... | ... | @@ -4525,7 +4528,7 @@ |
| 4525 | 4528 |
returnMap.put("resultBlockSts", Integer.toString(resultBlockSts));
|
| 4526 | 4529 |
|
| 4527 | 4530 |
return returnMap; |
| 4528 |
- } |
|
| 4531 |
+ }*/ |
|
| 4529 | 4532 |
|
| 4530 | 4533 |
private void handleSpamMsg(MjonMsgVO mjonMsgVO) {
|
| 4531 | 4534 |
try {
|
... | ... | @@ -4617,23 +4620,24 @@ |
| 4617 | 4620 |
} |
| 4618 | 4621 |
|
| 4619 | 4622 |
// 보유 금액이 충분한지 확인하는 메서드 |
| 4620 |
- private boolean isCashSufficient(MjonMsgVO mjonMsgVO) throws Exception {
|
|
| 4623 |
+ private boolean isCashSufficient(MjonMsgVO mjonMsgVO, List<MjonMsgSendVO> mjonMsgSendVOList) throws Exception {
|
|
| 4624 |
+ |
|
| 4625 |
+ |
|
| 4621 | 4626 |
String userMoney = priceAndPoint.getBefCash(mjonMsgVO.getUserId()); |
| 4622 | 4627 |
// 쉼표 제거 |
| 4623 | 4628 |
userMoney = userMoney.replace(",", "");
|
| 4624 | 4629 |
|
| 4625 |
- String totalPrice = mjonMsgVO.getTotPrice(); |
|
| 4626 |
- // 쉼표 제거 |
|
| 4627 |
- totalPrice = totalPrice.replace(",", "");
|
|
| 4628 |
- |
|
| 4630 |
+ // 사용자 보유 금액 BigDecimal 변환 (HALF_EVEN 적용) |
|
| 4629 | 4631 |
BigDecimal befCash = new BigDecimal(userMoney).setScale(2, RoundingMode.HALF_EVEN); |
| 4630 |
- BigDecimal totMsgPrice = new BigDecimal(totalPrice).setScale(2, RoundingMode.HALF_EVEN); |
|
| 4631 | 4632 |
|
| 4632 |
-// String userMoney = priceAndPoint.getBefCash(mjonMsgVO.getUserId()); |
|
| 4633 |
-// BigDecimal befCash = new BigDecimal(userMoney).setScale(2, RoundingMode.HALF_EVEN); |
|
| 4634 |
-// BigDecimal totMsgPrice = new BigDecimal(mjonMsgVO.getTotPrice()).setScale(2, RoundingMode.HALF_EVEN); |
|
| 4633 |
+ // 총 메시지 금액 계산 (HALF_EVEN 적용) |
|
| 4634 |
+ BigDecimal totalEachPrice = mjonMsgSendVOList.stream() |
|
| 4635 |
+ .map(msg -> new BigDecimal(String.valueOf(msg.getEachPrice()))) // 변환 오류 방지 |
|
| 4636 |
+ .reduce(BigDecimal.ZERO, BigDecimal::add) |
|
| 4637 |
+ .setScale(2, RoundingMode.HALF_EVEN); // 일관성 유지 |
|
| 4635 | 4638 |
|
| 4636 |
- return befCash.compareTo(totMsgPrice) >= 0; |
|
| 4639 |
+ // 비교 수행 |
|
| 4640 |
+ return befCash.compareTo(totalEachPrice) >= 0; |
|
| 4637 | 4641 |
} |
| 4638 | 4642 |
|
| 4639 | 4643 |
/** |
... | ... | @@ -4788,7 +4792,6 @@ |
| 4788 | 4792 |
* |
| 4789 | 4793 |
* @throws Exception |
| 4790 | 4794 |
* |
| 4791 |
- */ |
|
| 4792 | 4795 |
public StatusResponse fncSendMsg(MjonMsgVO mjonMsgVO) throws Exception {
|
| 4793 | 4796 |
log.info(" :: fncSendMsg :: ");
|
| 4794 | 4797 |
|
... | ... | @@ -4839,6 +4842,7 @@ |
| 4839 | 4842 |
log.info("Message sending process completed.");
|
| 4840 | 4843 |
return new StatusResponse(HttpStatus.OK, "문자 전송이 완료되었습니다.", getReturnMap(resultSts, resultBlockSts)); |
| 4841 | 4844 |
} |
| 4845 |
+ */ |
|
| 4842 | 4846 |
|
| 4843 | 4847 |
/** |
| 4844 | 4848 |
* @param mjonMsgVO |
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?