已摊销金额不能大于总金额

This commit is contained in:
wuchunlei
2026-02-09 14:48:03 +08:00
parent 84183ee596
commit df48bc5850

View File

@@ -454,11 +454,14 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
BigDecimal dayAmount = fee.divide(new BigDecimal(totalDays),3, BigDecimal.ROUND_HALF_UP);
//已摊销天数
int alreadyDays = Math.toIntExact((sdfmonth.parse(month).getTime() - sdfday.parse(startTime).getTime()) / 1000 / 60 / 60 / 24);
if (alreadyDays>0){
map.put("already",dayAmount.multiply(new BigDecimal(alreadyDays)));
}else {
if (alreadyDays<=0){
alreadyDays = 0;
}
BigDecimal alreadyFee = dayAmount.multiply(new BigDecimal(alreadyDays));
if (alreadyFee.compareTo(fee)>0){
alreadyFee = fee;
}
map.put("already",alreadyFee);
//当前月天数
int nowDays = Integer.parseInt(day.substring(8, 10));
BigDecimal now = BigDecimal.ZERO;
@@ -469,13 +472,16 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
nowDays = Integer.parseInt(day.substring(8, 10))-Integer.parseInt(startTime.substring(8, 10))+1;
now = dayAmount.multiply(new BigDecimal(nowDays));
} else if (endTime.contains(month)) {
now = fee.subtract(dayAmount.multiply(new BigDecimal(alreadyDays)));
now = fee.subtract(alreadyFee);
}else {
now = dayAmount.multiply(new BigDecimal(nowDays));
}
map.put("now",now);
if (alreadyFee.add(now).compareTo(fee)>0){
map.put("now",fee.subtract(alreadyFee));
}
//剩余未摊销
map.put("notyet",fee.subtract(now).subtract(dayAmount.multiply(new BigDecimal(alreadyDays))));
map.put("notyet",fee.subtract(now).subtract(alreadyFee));
}
}
List<Map<String,Object>> exportList = new ArrayList<>();