| @@ -8,6 +8,7 @@ import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumEnergyPublicCalcuteRule; | |||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||
| import com.iformall.enums.EnumFeesStandardsTimeUnit; | |||
| import com.iformall.enums.EnumRentDayPriceCalcute; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.helper.WxRentContractHelper; | |||
| import com.iformall.utils.Constant; | |||
| @@ -117,7 +118,7 @@ public class WxEnergyFees extends TenantEntity { | |||
| return ""; | |||
| } | |||
| public String calcuteTotalMoney(Integer decimalSize,Date start,Date end,String count,boolean isFixed) { | |||
| public String calcuteTotalMoney(Integer decimalSize,Date start,Date end,String count,boolean isFixed,EnumRentDayPriceCalcute priceCalcute,Integer monthDays ) { | |||
| if (isFixed) { | |||
| return this.price; | |||
| } | |||
| @@ -127,7 +128,11 @@ public class WxEnergyFees extends TenantEntity { | |||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.DAY.getCode().intValue()) { | |||
| BigDecimal priceD = new BigDecimal(this.price); | |||
| priceD = priceD.multiply(new BigDecimal(count)); | |||
| return WxRentContractHelper.getNeedPay(decimalSize,new BigDecimal(0),priceD,start,end); | |||
| return WxRentContractHelper.getNeedPay(decimalSize,new BigDecimal(0),priceD,start,end,priceCalcute,monthDays); | |||
| }if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.ONECE.getCode().intValue()) { | |||
| BigDecimal priceD = new BigDecimal(this.price); | |||
| priceD = priceD.multiply(new BigDecimal(count)); | |||
| return priceD.toPlainString(); | |||
| }else { | |||
| //按月计算 | |||
| BigDecimal priceMonth = new BigDecimal(this.price); | |||
| @@ -88,6 +88,7 @@ public enum EnumBillAllType { | |||
| retList.add(EnumFeesStandardsTimeUnit.DAY); | |||
| retList.add(EnumFeesStandardsTimeUnit.MONTH); | |||
| retList.add(EnumFeesStandardsTimeUnit.YEAR); | |||
| retList.add(EnumFeesStandardsTimeUnit.ONECE); | |||
| return retList; | |||
| } | |||
| } | |||
| @@ -3,7 +3,6 @@ package com.iformall.enums; | |||
| import java.math.BigDecimal; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumFeesStandardsCalcuteUnit { | |||
| @@ -12,7 +12,8 @@ import com.iformall.utils.Constant; | |||
| public enum EnumFeesStandardsTimeUnit { | |||
| DAY(1, "每日"), | |||
| MONTH(2, "每月"), | |||
| YEAR(3,"每年"); | |||
| YEAR(3,"每年"), | |||
| ONECE(4,"单次"); | |||
| public static EnumFeesStandardsTimeUnit getEnum(Integer code) { | |||
| for (EnumFeesStandardsTimeUnit value : values()) { | |||
| @@ -382,10 +382,12 @@ public class WxRentContractHelper { | |||
| if (null == wxRentContract.getDecimalSize()) { | |||
| wxRentContract.setDecimalSize(Constant.default_short_decimal_size); | |||
| } | |||
| EnumRentDayPriceCalcute priceCalcute = EnumRentDayPriceCalcute.getEnum(wxRentContract.getDayPriceCalcute()); | |||
| //按日 | |||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | |||
| BigDecimal priceD = new BigDecimal(price); | |||
| String needpayD = WxRentContractHelper.getNeedPay(Constant.default_long_decimal_size,new BigDecimal(0),priceD,startDate,endDate); | |||
| String needpayD = WxRentContractHelper.getNeedPay(Constant.default_long_decimal_size,new BigDecimal(0),priceD,startDate,endDate,priceCalcute,wxRentContract.getMonthAverageDays()); | |||
| //取整 | |||
| //needpay = new Double(needpayD).longValue(); | |||
| //四舍五入 | |||
| @@ -491,7 +493,7 @@ public class WxRentContractHelper { | |||
| if (fees.getFixedPrice().intValue() == EnumYesOrNo.YES.getCode().intValue() && null != billStartDate && null != billEndDate) { | |||
| vo.setStart(billStartDate); | |||
| vo.setEnd(billEndDate); | |||
| vo.setTotal(fees.calcuteTotalMoney(decimalSize, billStartDate, billEndDate, "1",true)); | |||
| vo.setTotal(fees.calcuteTotalMoney(decimalSize, billStartDate, billEndDate, "1",true,null,null)); | |||
| vo.setReceiveDate(DateUtils.getDaySet(billStartDate,Calendar.DATE,-1)); | |||
| vo.setFeeStandards(fees); | |||
| retList.add(vo); | |||
| @@ -610,6 +612,14 @@ public class WxRentContractHelper { | |||
| return months; | |||
| } | |||
| private static int getRealMonthDays(EnumRentDayPriceCalcute priceCalcute,Integer monthDays,Date day) { | |||
| if (priceCalcute.getCode().intValue() == EnumRentDayPriceCalcute.REAL_DAYS.getCode().intValue()) { | |||
| return DateUtils.getMonthDayCount(day); | |||
| }else { | |||
| return monthDays; | |||
| } | |||
| } | |||
| /** | |||
| * 按日计租 根据每月的日期总数计算needpay | |||
| * @param monthPrice | |||
| @@ -617,13 +627,13 @@ public class WxRentContractHelper { | |||
| * @param end | |||
| * @return | |||
| */ | |||
| public static String getNeedPay(Integer decimalSize,BigDecimal monthPrice,BigDecimal dayPrice,Date start,Date end){ | |||
| public static String getNeedPay(Integer decimalSize,BigDecimal monthPrice,BigDecimal dayPrice,Date start,Date end,EnumRentDayPriceCalcute priceCalcute,Integer monthDays){ | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | |||
| BigDecimal total; | |||
| int[] diff; | |||
| int dayCount = DateUtils.getMonthDayCount(start); | |||
| int dayCount = getRealMonthDays(priceCalcute,monthDays,start); | |||
| BigDecimal price; | |||
| if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | |||
| price = monthPrice.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP); | |||
| @@ -648,7 +658,8 @@ public class WxRentContractHelper { | |||
| int warnCount = 0; | |||
| while (true){ | |||
| Date monthStartDate = DateUtils.getDaySet(currEnd,Calendar.DATE,1); | |||
| dayCount = DateUtils.getMonthDayCount(monthStartDate); | |||
| dayCount = getRealMonthDays(priceCalcute,monthDays,monthStartDate); | |||
| //dayCount = DateUtils.getMonthDayCount(monthStartDate); | |||
| if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | |||
| price = monthPrice.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP); | |||
| }else{ | |||
| @@ -884,17 +884,18 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| private String calcuteStandardsFee(List<WxBillFeesStandardsListVo> unFixedList,Date start,Date end,WxPropertyContract wxPropertyContract) { | |||
| EnumRentDayPriceCalcute dayPrice = EnumRentDayPriceCalcute.getEnum(wxPropertyContract.getDayPriceCalcute()); | |||
| if (null != unFixedList) { | |||
| BigDecimal total = new BigDecimal(0); | |||
| for (int j = 0 ; j < unFixedList.size(); j ++) { | |||
| WxBillFeesStandardsListVo bfsvo = unFixedList.get(j); | |||
| WxEnergyFees feeStandars = bfsvo.getFeeStandards(); | |||
| if(EnumFeesStandardsCalcuteUnit.MM.getCode().intValue() == feeStandars.getCalcuteUnit().intValue()) { | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,wxPropertyContract.getRentArea(),false)); | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,wxPropertyContract.getRentArea(),false,dayPrice,wxPropertyContract.getMonthAverageDays())); | |||
| }else if (EnumFeesStandardsCalcuteUnit.HU.getCode().intValue() == feeStandars.getCalcuteUnit().intValue()) { | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,"1",false)); | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,"1",false,dayPrice,wxPropertyContract.getMonthAverageDays())); | |||
| }else { | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,"1",false)); | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,"1",false,dayPrice,wxPropertyContract.getMonthAverageDays())); | |||
| } | |||
| bfsvo.setStart(start); | |||
| bfsvo.setEnd(end); | |||
| @@ -907,11 +908,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| public String getNeedPayMoney(WxPropertyContract wxRentContract,String price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod){ | |||
| String needpay; | |||
| EnumRentDayPriceCalcute dayPrice = EnumRentDayPriceCalcute.getEnum(wxRentContract.getDayPriceCalcute()); | |||
| String needpay; | |||
| //按日 | |||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | |||
| BigDecimal priceD = new BigDecimal(price); | |||
| String needpayD = WxRentContractHelper.getNeedPay(wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate); | |||
| String needpayD = WxRentContractHelper.getNeedPay(wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate,dayPrice,wxRentContract.getMonthAverageDays()); | |||
| needpay = needpayD; | |||
| //按月计算 | |||
| }else{ | |||