Merge branch 'tolag'
This commit is contained in:
commit
b50b71ab88
@ -18,7 +18,7 @@ import lombok.Setter;
|
||||
public class PriceResponse {
|
||||
|
||||
//private HttpStatus status;
|
||||
private int resultCode;
|
||||
private String resultCode;
|
||||
|
||||
private String message;
|
||||
|
||||
@ -40,11 +40,11 @@ public class PriceResponse {
|
||||
*
|
||||
* */
|
||||
|
||||
public PriceResponse(HttpStatus status, String message, LocalDateTime timestamp) {
|
||||
this.resultCode = status.value();
|
||||
checkMessage(status, message);
|
||||
this.localDateTime = timestamp;
|
||||
}
|
||||
// public PriceResponse(HttpStatus status, String message, LocalDateTime timestamp) {
|
||||
// this.resultCode = status.value();
|
||||
// checkMessage(status, message);
|
||||
// this.localDateTime = timestamp;
|
||||
// }
|
||||
|
||||
// public PriceResponse(HttpStatus status
|
||||
// , String message
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
package com.itn.mjonApi.mjon.api.inqry.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.StatMsg;
|
||||
import com.itn.mjonApi.mjon.api.inqry.mapper.PriceMapper;
|
||||
import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceResponse;
|
||||
import com.itn.mjonApi.mjon.api.inqry.mapper.domain.PriceVO;
|
||||
@ -36,45 +39,53 @@ public class PriceServiceImpl implements PriceService {
|
||||
PriceResponse priceResponse = new PriceResponse();
|
||||
|
||||
try {
|
||||
// 이용단가
|
||||
PriceVO priceVO = price_refine(mberId, priceMapper);
|
||||
// 발송가능건수
|
||||
sendEa_refine(priceVO);
|
||||
//사용자 잔액
|
||||
double userMoney = priceMapper.selectUserMoney(mberId);
|
||||
// 이용단가, 발송가능 건수
|
||||
PriceVO priceVO = price_refine(mberId, userMoney, priceMapper);
|
||||
|
||||
String enumStr = "STAT_200";
|
||||
|
||||
priceResponse = PriceResponse.builder()
|
||||
//defalut set
|
||||
.resultCode(StatMsg.valueOf(enumStr).getCode())
|
||||
.message(StatMsg.valueOf(enumStr).getMsg())
|
||||
.localDateTime(LocalDateTime.now())
|
||||
//1. 잔액
|
||||
.userMoney(priceMapper.selectUserMoney(mberId))
|
||||
.userMoney(userMoney)
|
||||
//2. 이용단가
|
||||
.shortPrice(priceVO.getShortPrice())
|
||||
.longPrice(priceVO.getLongPrice())
|
||||
.picturePrice(priceVO.getPicturePrice())
|
||||
//3. 발송가능건수
|
||||
.shortSendPsbltEa(0)
|
||||
.longSendPsbltEa(0)
|
||||
.pictureSendPsbltEa(0)
|
||||
.shortSendPsbltEa(priceVO.getShortSendPsbltEa())
|
||||
.longSendPsbltEa(priceVO.getLongSendPsbltEa())
|
||||
.pictureSendPsbltEa(priceVO.getPictureSendPsbltEa())
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("selectPrice Error [{}]", e.getMessage());
|
||||
}
|
||||
|
||||
return priceResponse;
|
||||
}
|
||||
|
||||
private PriceVO price_refine(String mberId, PriceMapper priceMapper) {
|
||||
|
||||
private PriceVO price_refine(String mberId, double userMoney, PriceMapper priceMapper) {
|
||||
|
||||
//시스템 단가 변수
|
||||
double sys_shortPrice = 0.0f;
|
||||
double sys_longPrice = 0.0f;
|
||||
double sys_picturePrice = 0.0f;
|
||||
|
||||
//최종 단가 변수
|
||||
double shortPrice = 0.0f;
|
||||
double longPrice = 0.0f;
|
||||
double picturePrice = 0.0f;
|
||||
|
||||
//1.시스템 기본 단가 정보 불러오기
|
||||
//2.사용자 개인 단가 정보 불러오기
|
||||
//1.시스템 기본 단가, 사용자 개인단가 정보 불러오기
|
||||
Map<String, String> priceMap = priceMapper.selectMberPriceInfo(mberId);
|
||||
|
||||
//1-2.단가 계산을 위한 set
|
||||
sys_shortPrice = Double.parseDouble(String.valueOf(priceMap.get("sysShortPrice")));
|
||||
sys_longPrice = Double.parseDouble(String.valueOf(priceMap.get("sysLongPrice")));
|
||||
sys_picturePrice = Double.parseDouble(String.valueOf(priceMap.get("sysPicturePrice")));
|
||||
@ -82,21 +93,41 @@ public class PriceServiceImpl implements PriceService {
|
||||
shortPrice = Double.parseDouble(String.valueOf(priceMap.get("shortPrice")));
|
||||
longPrice = Double.parseDouble(String.valueOf(priceMap.get("longPrice")));
|
||||
picturePrice = Double.parseDouble(String.valueOf(priceMap.get("picturePrice")));
|
||||
|
||||
// SMS 인경우
|
||||
// 사용자 개인 단가가 없으면 시스템 단가로
|
||||
|
||||
//1-3. 최종 단가 계산
|
||||
shortPrice = shortPrice == 0.0f ? sys_shortPrice : shortPrice;
|
||||
longPrice = longPrice == 0.0f ? sys_longPrice : longPrice;
|
||||
picturePrice = picturePrice == 0.0f ? sys_picturePrice : picturePrice;
|
||||
|
||||
//2. 단가별 발송 가능건수 계산을위한 변수 set
|
||||
int shortSendPsbltEa = 0;
|
||||
int longSendPsbltEa = 0;
|
||||
int pictureSendPsbltEa = 0;
|
||||
|
||||
//2-1. 소수점 연산을 위한 BigDecimal Casting
|
||||
BigDecimal userMoney_big = new BigDecimal(String.valueOf(userMoney));
|
||||
BigDecimal shortPrice_big = new BigDecimal(String.valueOf(priceMap.get("sysShortPrice")));
|
||||
BigDecimal longPrice_big = new BigDecimal(String.valueOf(priceMap.get("sysLongPrice")));
|
||||
BigDecimal picturePrice_big = new BigDecimal(String.valueOf(priceMap.get("sysPicturePrice")));
|
||||
|
||||
//2-2. userMoney가 0일경우 제외
|
||||
if(userMoney_big.compareTo(BigDecimal.ZERO) != 0) {
|
||||
shortSendPsbltEa = userMoney_big.divide(shortPrice_big, BigDecimal.ROUND_DOWN).intValue();
|
||||
longSendPsbltEa = userMoney_big.divide(longPrice_big, BigDecimal.ROUND_DOWN).intValue();
|
||||
pictureSendPsbltEa = userMoney_big.divide(picturePrice_big, BigDecimal.ROUND_DOWN).intValue();
|
||||
}
|
||||
|
||||
//result set
|
||||
PriceVO priceVO = PriceVO.builder()
|
||||
.shortPrice(shortPrice == 0.0f ? sys_shortPrice : shortPrice)
|
||||
.longPrice(longPrice == 0.0f ? sys_longPrice : longPrice)
|
||||
.picturePrice(picturePrice == 0.0f ? sys_picturePrice : picturePrice)
|
||||
.shortPrice(shortPrice)
|
||||
.longPrice(longPrice)
|
||||
.picturePrice(picturePrice)
|
||||
.shortSendPsbltEa(shortSendPsbltEa)
|
||||
.longSendPsbltEa(longSendPsbltEa)
|
||||
.pictureSendPsbltEa(pictureSendPsbltEa)
|
||||
.build();
|
||||
return priceVO;
|
||||
}
|
||||
|
||||
private PriceVO sendEa_refine(PriceVO priceVO) {
|
||||
|
||||
return priceVO;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user