This commit is contained in:
linfso 2024-09-09 18:46:13 +08:00
parent bce68aefd0
commit 8e8473c683
2 changed files with 42 additions and 2 deletions

View File

@ -184,10 +184,16 @@ public class EmisBaseService {
@Autowired
private EmisCountryAreaMapper emisCountryAreaMapper;
@Autowired
private EmisExchangeRateMapper emisExchangeRateMapper;
@Autowired
RedissonService redissonService;
public EmisExchangeRate getValidExchangeRate(String from, String to,String rateDate){
return emisExchangeRateMapper.getValidExchangeRate(from, to,rateDate);
}
/**
* 判断获取主单号
* @param billCode

View File

@ -3011,7 +3011,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 记录类型,用于判断是否重复
feeTypeMap.put(feeItem.getFeeCode(), 1);
// 币种进行换算
feeList.add(feeItem);
@ -3020,12 +3019,47 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
// 对非人民币重新进行计算费用总额
BigDecimal realTotalFee = BigDecimal.ZERO;
if(!CollectionUtils.isEmpty(feeList)){
for (EmisWaybillFeeitem feeItem:feeList) {
// 币种进行换算
if(!"CNY".equals(feeItem.getCurrency())){
Date calcDate = emisWaybill.getSendDate();
if(calcDate==null){
calcDate= new Date();
}
EmisExchangeRate exchangeRate= getValidExchangeRate(feeItem.getCurrency(), "CNY",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,calcDate));
if(exchangeRate!=null){
BigDecimal cnyRealFee = feeItem.getRealFee().multiply( BigDecimal.valueOf( Double.valueOf(exchangeRate.getRate()) ) );
String feeItemRemark = "汇率:"+exchangeRate.getRate()+","+ cnyRealFee.stripTrailingZeros().toPlainString();
feeItem.setRemark(feeItemRemark);
realTotalFee=realTotalFee.add(cnyRealFee);
}else{
BigDecimal cnyRealFee = feeItem.getRealFee();
realTotalFee=realTotalFee.add(cnyRealFee);
String feeItemRemark = "汇率:0.0,"+ cnyRealFee.stripTrailingZeros().toPlainString();
feeItem.setRemark(feeItemRemark);
}
}else{
realTotalFee=realTotalFee.add(feeItem.getRealFee());
}
}
log.info("费用明细:"+JSON.toJSONString(feeList));
}
// 设置费用明细
emisWaybill.setFeeitemList(feeList);
// 币种换算
emisWaybill.setFreight(BigDecimal.valueOf(totalFee));
// emisWaybill.setFreight(BigDecimal.valueOf(totalFee));
emisWaybill.setFreight(BigDecimal.valueOf(realTotalFee));
if(emisWaybill.getFreight().compareTo(BigDecimal.ZERO)==0){
throw new EmisBizError(EmisBizErrorType.CALC_QUOTE_ERROR, "报价未配置");