diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java index eac4f19af..76b76ab73 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java @@ -483,7 +483,7 @@ public class WxRentContractHelper { //其他标准计费项 public static List getStandardsBillList(Integer decimalSize,List feesStandarsList,Date billStartDate,Date billEndDate,boolean isFixed, - String rentArea,Integer payPeriodRate,Integer receivePeriod,Integer dateType) { + String rentArea,Integer payPeriodRate,Integer adjustPeriod,Integer receivePeriod,Integer dateType) { if (null == feesStandarsList || feesStandarsList.size() <= 0 ) { return null; } @@ -502,7 +502,7 @@ public class WxRentContractHelper { count = rentArea; } vo.setTotal(fees.calcuteTotalMoney(decimalSize, billStartDate, billEndDate, count,true,null,null,null,null)); - vo.setReceiveDate(WxRentContractHelper.getReceiveDate(null, billStartDate, billEndDate, payPeriodRate, receivePeriod, dateType).getStartDate()); + vo.setReceiveDate(WxRentContractHelper.getReceiveDate(null, billStartDate, billEndDate, payPeriodRate,adjustPeriod, receivePeriod, dateType).getStartDate()); vo.setFeeStandards(fees); if(null != fees.getIsDespoit() && fees.getIsDespoit().intValue() == EnumYesOrNo.YES.getCode().intValue()) { @@ -878,7 +878,7 @@ public class WxRentContractHelper { * @param adjustPeriod * @return */ - public static BillTimeVo getReceiveDate(BillTimeVo currentReceiveDate,Date start,Date end,int payPeriodRate,Integer receivePeriod,Integer dayType) { + public static BillTimeVo getReceiveDate(BillTimeVo currentReceiveDate,Date start,Date end,int payPeriodRate,Integer adjustPeriod,Integer receivePeriod,Integer dayType) { if (null != currentReceiveDate) { if ((currentReceiveDate.getStartDate().equals(start) || currentReceiveDate.getStartDate().before(start) ) && (currentReceiveDate.getEndDate().equals(end) || currentReceiveDate.getEndDate().after(end) )) { @@ -886,34 +886,58 @@ public class WxRentContractHelper { } } - //如果是按月来计费,则付款截止日期从开始日期开始,每个周期的开始日期为付款的截止日期 - if (dayType.equals(EnumContractReceivePeriodUnit.MONTH.getCode())) { - Date startDate = DateUtils.getSecondsTimeAfter(1, DateUtils.getTimeAfterMonths(-1*receivePeriod, end)); - Calendar instance = Calendar.getInstance(); - instance.setTime(startDate); - instance.set(Calendar.MILLISECOND, 0); - BillTimeVo vo = new BillTimeVo(); - vo.setStartDate(instance.getTime()); - Date endDate = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod*payPeriodRate, EnumContractReceivePeriodUnit.MONTH.getCode()).getTime(); - vo.setEndDate(endDate); - return vo; - //自然季度 - }else if(dayType.equals(EnumContractReceivePeriodUnit.QUARTER.getCode())){ - Date startDate = DateUtils.getSecondsTimeAfter(1, DateUtils.getAfterQuaterStartDay(end,-1*receivePeriod).getTime()); - Calendar instance = Calendar.getInstance(); - instance.setTime(startDate); - instance.set(Calendar.MILLISECOND, 0); - BillTimeVo vo = new BillTimeVo(); - vo.setStartDate(instance.getTime()); - Date endDate = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod*payPeriodRate, EnumContractReceivePeriodUnit.QUARTER.getCode()).getTime(); - vo.setEndDate(endDate); - return vo; - }else { - BillTimeVo vo = new BillTimeVo(); + Calendar instance = Calendar.getInstance(); + instance.setTime(start); + instance.set(Calendar.MILLISECOND, 0); + BillTimeVo vo = new BillTimeVo(); + //按月计租 + if (adjustPeriod == EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) { + //按月 + if (dayType.equals(EnumContractReceivePeriodUnit.MONTH.getCode())) { + vo.setStartDate(instance.getTime()); + Date endDate = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod*payPeriodRate, EnumContractReceivePeriodUnit.MONTH.getCode()).getTime(); + vo.setEndDate(endDate); + return vo; + //自然季度 + }else if(dayType.equals(EnumContractReceivePeriodUnit.QUARTER.getCode())){ + //如果开始日期是1号,则从开始日期算起,,如果不是,则从结束日期算起 + int day = instance.get(Calendar.DAY_OF_MONTH); + if (day == 1) { + vo.setStartDate(instance.getTime()); + Date endDate = EnumContractReceivePeriodUnit.getAfterCalendarNarDay(instance.getTime(), receivePeriod*payPeriodRate, EnumContractReceivePeriodUnit.QUARTER.getCode()); + vo.setEndDate(endDate); + return vo; + }else { + Date startDate = EnumContractReceivePeriodUnit.getAfterCalendarNarDay(end, -1*receivePeriod*payPeriodRate, EnumContractReceivePeriodUnit.QUARTER.getCode()); + startDate = DateUtils.getFirstDayForCurrMonth(startDate); + vo.setStartDate(startDate); + vo.setEndDate(end); + return vo; + } + }else { + vo.setStartDate(start); + vo.setEndDate(end); + return vo; + } + }else if (adjustPeriod == EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()) { + //自然月 + int day = instance.get(Calendar.DAY_OF_MONTH); + if (day == 1) { + vo.setStartDate(instance.getTime()); + Date endDate = EnumContractReceivePeriodUnit.getAfterCalendarNarDay(instance.getTime(), receivePeriod*payPeriodRate, dayType); + vo.setEndDate(endDate); + return vo; + }else { + Date startDate = EnumContractReceivePeriodUnit.getAfterCalendarNarDay(end, -1*receivePeriod*payPeriodRate, dayType); + startDate = DateUtils.getFirstDayForCurrMonth(start); + vo.setStartDate(startDate); + vo.setEndDate(end); + return vo; + } + }else { vo.setStartDate(start); vo.setEndDate(end); return vo; } } - } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index e32edf170..7b40c7cbf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -710,7 +710,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //结算其他金额 //一次性费用的,只有一个账单。 List fixedList = WxRentContractHelper.getStandardsBillList(wxPropertyContract.getDecimalSize(),wxPropertyContract.getFeesStardarsList(),firstBillStartDate, - firstBillEndDate,true,wxPropertyContract.getRentArea(),wxPropertyContract.getPayPeriodRate(),wxPropertyContract.getReceivePeriod(),wxPropertyContract.getReceivePeriodUnit()); + firstBillEndDate,true,wxPropertyContract.getRentArea(),wxPropertyContract.getPayPeriodRate(),wxPropertyContract.getAdjustPeriod(),wxPropertyContract.getReceivePeriod(), + wxPropertyContract.getReceivePeriodUnit()); int index = 0; @@ -721,7 +722,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService String standarsTotal = "0"; //非一次性费用的,跟随物业账单的周期 - List unFixedList = WxRentContractHelper.getStandardsBillList(wxPropertyContract.getDecimalSize(),wxPropertyContract.getFeesStardarsList(),null,null,false,null,null,null,null); + List unFixedList = WxRentContractHelper.getStandardsBillList(wxPropertyContract.getDecimalSize(),wxPropertyContract.getFeesStardarsList(),null,null,false,null,null, + null,null,null); boolean flag = false; 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 981548693..f4d58d58d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1731,7 +1731,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { list.add(timeVo); - receiveDate = WxRentContractHelper.getReceiveDate(receiveDate,start, end, payPeriod,receivePeriod,dayType); + receiveDate = WxRentContractHelper.getReceiveDate(receiveDate,timeVo.getStartDate(), timeVo.getEndDate(), payPeriod,adjustPeriod,receivePeriod,dayType); timeVo.setReceiveDate(receiveDate.getStartDate()); diff --git a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java index 6adf3239d..cfa8c68df 100755 --- a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java @@ -486,7 +486,15 @@ public class DateUtils { now.set(Calendar.MONTH, now.get(Calendar.MONTH) + months); return now.getTime(); } - + + public static Date getRealTimeAfterMonths(int months, Date myDate) { + Calendar now = Calendar.getInstance(); + now.setTime(myDate); + now.set(Calendar.MILLISECOND, 0); + now.add(Calendar.MONTH, months); + return now.getTime(); + } + /** * 获得指定时间前几天,格式yyyy-MM-dd * @@ -1101,6 +1109,7 @@ public class DateUtils { Calendar cale = Calendar.getInstance(); cale.setTime(date); cale.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 + cale.set(Calendar.MILLISECOND, 0); //将毫秒至0 return cale.getTime(); } @@ -1140,6 +1149,7 @@ public class DateUtils { ca.setTime(date); ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); ca.add(Calendar.MONTH, amount); + ca.set(Calendar.MILLISECOND, 0); //将毫秒至0 return ca.getTime(); }