From 306f7a644139beff495e00e7e4ab70c773acb3d9 Mon Sep 17 00:00:00 2001 From: zhengfangyuan Date: Tue, 15 Nov 2022 15:14:33 +0800 Subject: [PATCH] fix bug --- .../impl/WxRentContractServiceImpl.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 83ef1f758..c52b590a6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1546,7 +1546,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ Double priceD = new Double(price); double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate); - needpay = new Double(needpayD).longValue(); + //取整 + //needpay = new Double(needpayD).longValue(); + //四舍五入 + needpay = new BigDecimal(needpayD).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); }else{ Double priceD = new Double(price); if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType())) { @@ -1568,7 +1571,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { //生成金额直接计算 if(!saveDb){ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); return needpay; } @@ -1585,7 +1589,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { int months = getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01"); needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } }else if(i == 0){//第一期 if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ @@ -1594,7 +1599,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { months++; needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } }else{ if(isFirstDay(startDate)){ @@ -1604,7 +1610,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { } needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } } }else{//中间 @@ -1614,9 +1621,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } //如果当月费用需要按天计算 if (monthCalDay) { - //取整 //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); - //四舍五入 needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); }else { needpay = new Double(months * priceD).longValue();