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