Commit 7f72298b authored by 332784038@qq.com's avatar 332784038@qq.com Committed by wux

调用汇率的业务逻辑修改调用新的汇率计算逻辑公式:

调整汇率计算为新的逻辑公式: 待计算原币种金额 * 目标支付币种金额基础值 / 原币种金额基础值(注:这里的币种金额基础值为后台设定的汇兑基础值) ,最终结果保留两位小数点四舍五入
parent cbedcb77
...@@ -2528,8 +2528,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2528,8 +2528,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (Objects.isNull(exchangeRateRespDTO)) { if (Objects.isNull(exchangeRateRespDTO)) {
throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao()); throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao());
} }
oldFreightAndClearanceFee = // oldFreightAndClearanceFee = oldFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate()));
oldFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate())); // 调整汇率计算为新的逻辑公式: 待计算原币种金额 * 目标支付币种金额基础值 / 原币种金额基础值(注:这里的币种金额基础值为后台设定的汇兑基础值) ,最终结果保留两位小数点四舍五入
oldFreightAndClearanceFee = oldFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getTargetCurrencyAmount()).divide(exchangeRateRespDTO.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP));
} else { } else {
oldFreightAndClearanceFee = oldFreightAndClearanceFee =
oldFreightAndClearanceFee.add(feeDto.getAmount()); oldFreightAndClearanceFee.add(feeDto.getAmount());
...@@ -2550,7 +2551,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2550,7 +2551,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (Objects.isNull(exchangeRateRespDTO)) { if (Objects.isNull(exchangeRateRespDTO)) {
throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao()); throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao());
} }
newFreightAndClearanceFee = newFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate())); // newFreightAndClearanceFee = newFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate()));
// 调整汇率计算为新的逻辑公式: 待计算原币种金额 * 目标支付币种金额基础值 / 原币种金额基础值(注:这里的币种金额基础值为后台设定的汇兑基础值) ,最终结果保留两位小数点四舍五入
newFreightAndClearanceFee = newFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getTargetCurrencyAmount()).divide(exchangeRateRespDTO.getSourceCurrencyAmount(), 2 ,RoundingMode.HALF_UP));
} else { } else {
newFreightAndClearanceFee = newFreightAndClearanceFee.add(feeDto.getAmount()); newFreightAndClearanceFee = newFreightAndClearanceFee.add(feeDto.getAmount());
} }
...@@ -4072,12 +4075,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -4072,12 +4075,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
BigDecimal totalOnePrice = BigDecimal.ZERO; BigDecimal totalOnePrice = BigDecimal.ZERO;
if (Objects.nonNull(param.getOneFreight()) && param.getOneFreight().compareTo(BigDecimal.ZERO) > 0) { if (Objects.nonNull(param.getOneFreight()) && param.getOneFreight().compareTo(BigDecimal.ZERO) > 0) {
ExchangeRateRespDTO freightExchangeRate = currencyApi.getCurrencyRate(Long.valueOf(param.getFreightCurrency().toString()), targetId); ExchangeRateRespDTO freightExchangeRate = currencyApi.getCurrencyRate(Long.valueOf(param.getFreightCurrency().toString()), targetId);
totalOnePrice = totalOnePrice.add(param.getOneFreight().multiply(freightExchangeRate.getCurrencyRate()).setScale(2, RoundingMode.HALF_UP)); // 调整汇率计算为新的逻辑公式: 待计算原币种金额 * 目标支付币种金额基础值 / 原币种金额基础值(注:这里的币种金额基础值为后台设定的汇兑基础值) ,最终结果保留两位小数点四舍五入
totalOnePrice = totalOnePrice.add(param.getOneFreight().multiply(freightExchangeRate.getTargetCurrencyAmount()).divide(freightExchangeRate.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP));
} }
if (param.getCharging() == 0) { if (param.getCharging() == 0) {
if (Objects.nonNull(param.getOneClearanceFee()) && param.getOneClearanceFee().compareTo(BigDecimal.ZERO) > 0) { if (Objects.nonNull(param.getOneClearanceFee()) && param.getOneClearanceFee().compareTo(BigDecimal.ZERO) > 0) {
ExchangeRateRespDTO clearanceExchangeRate = currencyApi.getCurrencyRate(Long.valueOf(param.getClearanceFeeCurrency().toString()), targetId); ExchangeRateRespDTO clearanceExchangeRate = currencyApi.getCurrencyRate(Long.valueOf(param.getClearanceFeeCurrency().toString()), targetId);
totalOnePrice = totalOnePrice.add(param.getOneClearanceFee().multiply(clearanceExchangeRate.getCurrencyRate()).setScale(2, RoundingMode.HALF_UP)); // 调整汇率计算为新的逻辑公式: 待计算原币种金额 * 目标支付币种金额基础值 / 原币种金额基础值(注:这里的币种金额基础值为后台设定的汇兑基础值) ,最终结果保留两位小数点四舍五入
totalOnePrice = totalOnePrice.add(param.getOneClearanceFee().multiply(clearanceExchangeRate.getTargetCurrencyAmount()).divide(clearanceExchangeRate.getSourceCurrencyAmount(), 2, RoundingMode.HALF_UP));
} }
} }
orderItemDO.setTotalOnePrice(totalOnePrice); orderItemDO.setTotalOnePrice(totalOnePrice);
......
...@@ -471,7 +471,7 @@ public class ProdCostCalculation { ...@@ -471,7 +471,7 @@ public class ProdCostCalculation {
if (costDto.getTotalWorth().compareTo(BigDecimal.ZERO) > 0) { if (costDto.getTotalWorth().compareTo(BigDecimal.ZERO) > 0) {
// 因为货值为RMB计算,保价费应换算为目标货币(默认为美元) // 因为货值为RMB计算,保价费应换算为目标货币(默认为美元)
BigDecimal insuranceFee = costDto.getTotalWorth().multiply(new BigDecimal("1.1")) BigDecimal insuranceFee = costDto.getTotalWorth().multiply(new BigDecimal("1.1"))
.multiply(new BigDecimal("0.002")).multiply(exchangeRateRespDTO.getCurrencyRate()).setScale(0, RoundingMode.HALF_UP); .multiply(new BigDecimal("0.002")).multiply(exchangeRateRespDTO.getTargetCurrencyAmount()).divide(exchangeRateRespDTO.getSourceCurrencyAmount(),0, RoundingMode.HALF_UP);
costDto.setInsuranceFee(insuranceFee); costDto.setInsuranceFee(insuranceFee);
feeDto.setAmount(insuranceFee); feeDto.setAmount(insuranceFee);
} else { } else {
...@@ -1582,9 +1582,9 @@ public class ProdCostCalculation { ...@@ -1582,9 +1582,9 @@ public class ProdCostCalculation {
if (Objects.nonNull(priceStepDO)) { if (Objects.nonNull(priceStepDO)) {
BigDecimal productClearancePrice = BigDecimal productClearancePrice =
productExchangeRate.getCurrencyRate(). priceStepDO.getClearancePrice().
multiply(priceStepDO.getClearancePrice()). multiply(productExchangeRate.getTargetCurrencyAmount()).
setScale(2, BigDecimal.ROUND_HALF_UP); divide(productExchangeRate.getSourceCurrencyAmount(),2, BigDecimal.ROUND_HALF_UP);
if (lineClearanceBasePrice.getClearancePrice(). if (lineClearanceBasePrice.getClearancePrice().
compareTo(BigDecimal.ZERO) > 0) { compareTo(BigDecimal.ZERO) > 0) {
...@@ -1634,9 +1634,9 @@ public class ProdCostCalculation { ...@@ -1634,9 +1634,9 @@ public class ProdCostCalculation {
clearanceBasePrice.getClearancePriceUnit(), clearanceBasePrice.getClearancePriceUnit(),
1L); 1L);
BigDecimal productClearancePrice = BigDecimal productClearancePrice =
productExchangeRate.getCurrencyRate(). clearanceBasePrice.getClearancePrice().
multiply(clearanceBasePrice.getClearancePrice()). multiply(productExchangeRate.getTargetCurrencyAmount()).
setScale(2, divide(productExchangeRate.getSourceCurrencyAmount(),2,
BigDecimal.ROUND_HALF_UP); BigDecimal.ROUND_HALF_UP);
BigDecimal lineClearancePrice = BigDecimal lineClearancePrice =
lineClearanceBasePrice.getProductClearanceAsExchangePrice(); lineClearanceBasePrice.getProductClearanceAsExchangePrice();
......
...@@ -1196,11 +1196,13 @@ public class CouponServiceImpl extends AbstractService<CouponMapper, CouponDO> i ...@@ -1196,11 +1196,13 @@ public class CouponServiceImpl extends AbstractService<CouponMapper, CouponDO> i
freightRateRespDTO.setSourceCurrencyId(dto.getReduceCurrencyId().longValue()); freightRateRespDTO.setSourceCurrencyId(dto.getReduceCurrencyId().longValue());
freightRateRespDTO.setTargetCurrencyId(rmbCurrency.longValue()); freightRateRespDTO.setTargetCurrencyId(rmbCurrency.longValue());
freightRateRespDTO.setCurrencyRate(new BigDecimal("1")); freightRateRespDTO.setCurrencyRate(new BigDecimal("1"));
freightRateRespDTO.setSourceCurrencyAmount(new BigDecimal("1"));
freightRateRespDTO.setTargetCurrencyAmount(new BigDecimal("1"));
} }
} }
BigDecimal freightRMBReduceAmount = dto.getReduceAmount().compareTo(BigDecimal.ZERO) > 0 && Objects.nonNull(dto.getReduceCurrencyId()) && BigDecimal freightRMBReduceAmount = dto.getReduceAmount().compareTo(BigDecimal.ZERO) > 0 && Objects.nonNull(dto.getReduceCurrencyId()) &&
Objects.nonNull(freightRateRespDTO.getCurrencyRate()) && freightRateRespDTO.getCurrencyRate().compareTo(BigDecimal.ZERO) > 0 ? Objects.nonNull(freightRateRespDTO.getCurrencyRate()) && freightRateRespDTO.getCurrencyRate().compareTo(BigDecimal.ZERO) > 0 ?
dto.getReduceAmount().multiply(freightRateRespDTO.getCurrencyRate()).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO; dto.getReduceAmount().multiply(freightRateRespDTO.getTargetCurrencyAmount()).divide(freightRateRespDTO.getSourceCurrencyAmount(),2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
ExchangeRateRespDTO clearanceFeeRateRespDTO = new ExchangeRateRespDTO(); ExchangeRateRespDTO clearanceFeeRateRespDTO = new ExchangeRateRespDTO();
if (Objects.nonNull(dto.getClearanceReduceCurrencyId())) { if (Objects.nonNull(dto.getClearanceReduceCurrencyId())) {
clearanceFeeRateRespDTO = currencyApi.getCurrencyRate(dto.getClearanceReduceCurrencyId().longValue(), rmbCurrency.longValue()); clearanceFeeRateRespDTO = currencyApi.getCurrencyRate(dto.getClearanceReduceCurrencyId().longValue(), rmbCurrency.longValue());
...@@ -1210,11 +1212,13 @@ public class CouponServiceImpl extends AbstractService<CouponMapper, CouponDO> i ...@@ -1210,11 +1212,13 @@ public class CouponServiceImpl extends AbstractService<CouponMapper, CouponDO> i
clearanceFeeRateRespDTO.setSourceCurrencyId(rmbCurrency.longValue()); clearanceFeeRateRespDTO.setSourceCurrencyId(rmbCurrency.longValue());
clearanceFeeRateRespDTO.setTargetCurrencyId(rmbCurrency.longValue()); clearanceFeeRateRespDTO.setTargetCurrencyId(rmbCurrency.longValue());
clearanceFeeRateRespDTO.setCurrencyRate(new BigDecimal("1")); clearanceFeeRateRespDTO.setCurrencyRate(new BigDecimal("1"));
clearanceFeeRateRespDTO.setSourceCurrencyAmount(new BigDecimal("1"));
clearanceFeeRateRespDTO.setTargetCurrencyAmount(new BigDecimal("1"));
} }
} }
BigDecimal clearanceFeeRMBReduceAmount = dto.getClearanceReduceAmount().compareTo(BigDecimal.ZERO) > 0 && Objects.nonNull(dto.getClearanceReduceCurrencyId()) && BigDecimal clearanceFeeRMBReduceAmount = dto.getClearanceReduceAmount().compareTo(BigDecimal.ZERO) > 0 && Objects.nonNull(dto.getClearanceReduceCurrencyId()) &&
Objects.nonNull(clearanceFeeRateRespDTO.getCurrencyRate()) && clearanceFeeRateRespDTO.getCurrencyRate().compareTo(BigDecimal.ZERO) > 0 ? Objects.nonNull(clearanceFeeRateRespDTO.getCurrencyRate()) && clearanceFeeRateRespDTO.getCurrencyRate().compareTo(BigDecimal.ZERO) > 0 ?
dto.getClearanceReduceAmount().multiply(clearanceFeeRateRespDTO.getCurrencyRate()).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO; dto.getClearanceReduceAmount().multiply(clearanceFeeRateRespDTO.getTargetCurrencyAmount()).divide(clearanceFeeRateRespDTO.getSourceCurrencyAmount(),2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
dto.setTotalRMBReduceAmount(freightRMBReduceAmount.add(clearanceFeeRMBReduceAmount)); dto.setTotalRMBReduceAmount(freightRMBReduceAmount.add(clearanceFeeRMBReduceAmount));
// 封装优惠详情 // 封装优惠详情
CouponInfoVO infoVO = new CouponInfoVO(); CouponInfoVO infoVO = new CouponInfoVO();
......
...@@ -2369,9 +2369,9 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -2369,9 +2369,9 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
int result = 0; int result = 0;
if (productPrice.getClearancePriceUnit() != channelPrice.getClearancePriceUnit()) { if (productPrice.getClearancePriceUnit() != channelPrice.getClearancePriceUnit()) {
ExchangeRateRespDTO productExchangeRate = currencyApi.getCurrencyRate(productPrice.getClearancePriceUnit(), 1L); ExchangeRateRespDTO productExchangeRate = currencyApi.getCurrencyRate(productPrice.getClearancePriceUnit(), 1L);
BigDecimal productClearancePrice = productExchangeRate.getCurrencyRate().multiply(productPrice.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal productClearancePrice = productPrice.getClearancePrice().multiply(productExchangeRate.getTargetCurrencyAmount()).divide(productExchangeRate.getSourceCurrencyAmount(),2, BigDecimal.ROUND_HALF_UP);
ExchangeRateRespDTO channelExchangeRate = currencyApi.getCurrencyRate(channelPrice.getClearancePriceUnit(), 1L); ExchangeRateRespDTO channelExchangeRate = currencyApi.getCurrencyRate(channelPrice.getClearancePriceUnit(), 1L);
BigDecimal channelClearancePrice = channelExchangeRate.getCurrencyRate().multiply(channelPrice.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal channelClearancePrice = channelPrice.getClearancePrice().multiply(channelExchangeRate.getTargetCurrencyAmount()).divide(channelExchangeRate.getSourceCurrencyAmount(),2, BigDecimal.ROUND_HALF_UP);
result = productClearancePrice.compareTo(channelClearancePrice); result = productClearancePrice.compareTo(channelClearancePrice);
} else { } else {
result = productPrice.getClearancePrice().compareTo(channelPrice.getClearancePrice()); result = productPrice.getClearancePrice().compareTo(channelPrice.getClearancePrice());
......
...@@ -522,7 +522,7 @@ public class AirBillReceivableExcelExportListener { ...@@ -522,7 +522,7 @@ public class AirBillReceivableExcelExportListener {
private BigDecimal changeAmountToDestCurrency(Long fromCurrencyId,Long toCurrencyId,BigDecimal fromAmount){ private BigDecimal changeAmountToDestCurrency(Long fromCurrencyId,Long toCurrencyId,BigDecimal fromAmount){
BigDecimal destAmount = BigDecimal.ZERO; BigDecimal destAmount = BigDecimal.ZERO;
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId);
destAmount = fromAmount.multiply(currencyRate.getCurrencyRate()); destAmount = fromAmount.multiply(currencyRate.getTargetCurrencyAmount()).divide(currencyRate.getSourceCurrencyAmount(),2,RoundingMode.HALF_UP);
return destAmount; return destAmount;
} }
......
...@@ -631,7 +631,7 @@ public class ShipmentReceivableExcelExportListener2 { ...@@ -631,7 +631,7 @@ public class ShipmentReceivableExcelExportListener2 {
BigDecimal fromAmount) { BigDecimal fromAmount) {
BigDecimal destAmount = BigDecimal.ZERO; BigDecimal destAmount = BigDecimal.ZERO;
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId);
destAmount = fromAmount.multiply(currencyRate.getCurrencyRate()); destAmount = fromAmount.multiply(currencyRate.getTargetCurrencyAmount()).divide(currencyRate.getSourceCurrencyAmount(),2,RoundingMode.HALF_UP);
return destAmount; return destAmount;
} }
......
...@@ -1338,7 +1338,7 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin ...@@ -1338,7 +1338,7 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin
private BigDecimal changeAmountToDestCurrency(Long fromCurrencyId, Long toCurrencyId, BigDecimal fromAmount) { private BigDecimal changeAmountToDestCurrency(Long fromCurrencyId, Long toCurrencyId, BigDecimal fromAmount) {
BigDecimal destAmount = BigDecimal.ZERO; BigDecimal destAmount = BigDecimal.ZERO;
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId); ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(fromCurrencyId, toCurrencyId);
destAmount = fromAmount.multiply(currencyRate.getCurrencyRate()); destAmount = fromAmount.multiply(currencyRate.getTargetCurrencyAmount()).divide(currencyRate.getSourceCurrencyAmount(),2,RoundingMode.HALF_UP);
return destAmount; return destAmount;
} }
} }
...@@ -52,6 +52,7 @@ import javax.servlet.ServletOutputStream; ...@@ -52,6 +52,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
...@@ -570,7 +571,7 @@ public class ReceiptController { ...@@ -570,7 +571,7 @@ public class ReceiptController {
} else { } else {
if (StrUtil.isNotBlank(currencyRespDTO.getFuhao())) { if (StrUtil.isNotBlank(currencyRespDTO.getFuhao())) {
ExchangeRateRespDTO exchangeRateRespDTO = currencyApi.getCurrencyRateByCode(currencyRespDTO.getFuhao(), "$"); ExchangeRateRespDTO exchangeRateRespDTO = currencyApi.getCurrencyRateByCode(currencyRespDTO.getFuhao(), "$");
usdTotal = usdTotal.add(receivableBackVO.getTotalAmount().multiply(exchangeRateRespDTO.getCurrencyRate())); usdTotal = usdTotal.add(receivableBackVO.getTotalAmount().multiply(exchangeRateRespDTO.getTargetCurrencyAmount()).divide(exchangeRateRespDTO.getSourceCurrencyAmount(),2, RoundingMode.HALF_UP));
} }
} }
...@@ -603,7 +604,7 @@ public class ReceiptController { ...@@ -603,7 +604,7 @@ public class ReceiptController {
if (StrUtil.isNotBlank(currencyRespDTO.getFuhao())) { if (StrUtil.isNotBlank(currencyRespDTO.getFuhao())) {
ExchangeRateRespDTO exchangeRateRespDTO = currencyApi.getCurrencyRateByCode(currencyRespDTO.getFuhao(), "$"); ExchangeRateRespDTO exchangeRateRespDTO = currencyApi.getCurrencyRateByCode(currencyRespDTO.getFuhao(), "$");
usdTotal = usdTotal.add(receivableBackVO.getTotalAmount().multiply(exchangeRateRespDTO.getCurrencyRate())); usdTotal = usdTotal.add(receivableBackVO.getTotalAmount().multiply(exchangeRateRespDTO.getTargetCurrencyAmount()).divide(exchangeRateRespDTO.getSourceCurrencyAmount(),2,RoundingMode.HALF_UP));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment