免费公里数

This commit is contained in:
曹磊 2024-07-16 15:18:16 +08:00
parent 68ad7921f8
commit c6d740cc26
1 changed files with 9 additions and 2 deletions

View File

@ -225,6 +225,9 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
public TravelPriceVo calcTravelPrice(Long artificerId, String toLongitude, String toLatitude, String serveTime, Integer tripWay){
Artificer artificerInfo = artificerService.getById(artificerId);
Integer mfgls = artificerInfo.getTripWayNum();//免费公里数
if(mfgls == null){
mfgls = 0;
}
BigDecimal freeKilometers = new BigDecimal(mfgls);
String longitude = artificerInfo.getLongitude();
String latitude = artificerInfo.getLatitude();
@ -276,7 +279,9 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
// fixedPrice = NumberUtil.mul(fixedPrice, 2);
// }
//最终价格
vo.setTravelPrice(NumberUtil.decimalFormat("0.00", fixedPrice));
// vo.setTravelPrice(NumberUtil.decimalFormat("0", fixedPrice));
fixedPrice = fixedPrice.setScale(0,BigDecimal.ROUND_UP);
vo.setTravelPrice(fixedPrice.toString());
}else if(TravelEnum.PricingType.TRENDS.getValue().equals(pricingType)){
//动态的
BigDecimal nightTravelExpenses = new BigDecimal("0");//白天
@ -295,7 +300,9 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
//最终价格
//计算公式为起步价 + 夜间出行费 + ((公里数 -起步公里数 - 免费公里数) * 每公里价格)= 最终价格
BigDecimal travelPrice = NumberUtil.add(startingPrice, nightTravelExpenses, NumberUtil.mul(NumberUtil.sub(NumberUtil.sub(kilometerNum,startKilometers), freeKilometers), pricePerKilometer));
vo.setTravelPrice(NumberUtil.decimalFormat("0.00", travelPrice));
// vo.setTravelPrice(NumberUtil.decimalFormat("0.00", travelPrice));
travelPrice = travelPrice.setScale(0,BigDecimal.ROUND_UP);
vo.setTravelPrice(travelPrice.toString());
}
return vo;