| @@ -679,7 +679,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||
| } else { | |||
| //按日计租 | |||
| Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false); | |||
| Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false,0); | |||
| rentList = ( List<WxBillRent>)resultMap.get("billList"); | |||
| } | |||
| } | |||
| @@ -795,7 +795,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.add(Calendar.MONTH, month * i); | |||
| startDate = instance.getTime(); | |||
| } | |||
| Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], startDate, Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview, shopInfos.isEmpty() ? null : shopInfos.get(i),i==size-1?true:false); | |||
| Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], startDate, Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview, shopInfos.isEmpty() ? null : shopInfos.get(i),i==size-1?true:false,size); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| billcount = (Integer)resultMap.get("billcount"); | |||
| resultList.addAll(billRentList); | |||
| @@ -811,7 +811,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return false; | |||
| } | |||
| public Map<String, Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo,boolean isLastYesr) { | |||
| public Map<String, Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo,boolean isLastYesr,int yearSize) { | |||
| System.out.println("------lease:"+lease+"receivePeriod:"+receivePeriod+"price:"+price+"start:"+DateUtils.date2String(startdate,"yyyy-MM-dd") | |||
| +"dayType:"+dayType+"billcount:"+billcount); | |||
| @@ -840,7 +840,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| int paycount = lease / receivePeriod + extracount; | |||
| int index = paycount - 1; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| //自然月,而且残月,周期整除,n+1,最后一个周期作为残月 | |||
| //自然月计租,而且残月,周期整除,n+1,最后一个周期作为残月 | |||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()) | |||
| && !isFirstDay(wxRentContract.getRentalStartDate()) | |||
| && (wxRentContract.getLease() % wxRentContract.getReceivePeriod() == 0) | |||
| @@ -933,7 +933,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if(receivePeriod > 1) { | |||
| needPayDouble += price * extralease; | |||
| } | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| if(!isFirstDay(wxRentContract.getRentalStartDate())) { //残月才加 | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| } | |||
| }else{ | |||
| //[A/31 *(31-12+1)]+A+A | |||
| needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxBillRent.getStarttime())-startDateInt+1); | |||
| @@ -961,32 +963,58 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| Date firstDay = DateUtils.getFirstDayForCurrMonth(wxBillRent.getStarttime()); | |||
| instance.clear(); | |||
| instance.setTime(firstDay); | |||
| //最后一期有余,加上残月,(不整除时,最后一个月有余,否则为0) | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr) { | |||
| instance.add(dayType, extralease); | |||
| }else{ | |||
| if(isFirstDay(wxRentContract.getRentalStartDate())){ | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr && extralease > 0) { | |||
| instance.add(dayType, extralease); | |||
| }else{ | |||
| instance.add(dayType, receivePeriod); | |||
| } | |||
| }else { | |||
| instance.add(dayType, receivePeriod); | |||
| } | |||
| }else{ | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr) { | |||
| instance.add(dayType, extralease); | |||
| }else{ | |||
| instance.add(dayType, receivePeriod); | |||
| } | |||
| } | |||
| if(isLastYesr) { | |||
| instance.add(Calendar.DAY_OF_MONTH, rentStartDateInt - 1); | |||
| } | |||
| } | |||
| if(isLastYesr) { | |||
| instance.add(Calendar.DAY_OF_MONTH, rentStartDateInt - 1); | |||
| } | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| //逻辑同计算endtime | |||
| double needPayDouble = 0; | |||
| double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxBillRent.getEndtime()); | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr) { | |||
| needPayDouble += price * extralease; | |||
| }else{ | |||
| if(isFirstDay(wxRentContract.getRentalStartDate())){ | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr && extralease > 0) { | |||
| needPayDouble += price * extralease; | |||
| }else{ | |||
| needPayDouble += price * receivePeriod; | |||
| } | |||
| }else { | |||
| needPayDouble += price * receivePeriod; | |||
| } | |||
| } | |||
| if(isLastYesr) { | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| }else{ | |||
| if(receivePeriod > 1) { | |||
| if(isLastYesr) { | |||
| needPayDouble += price * extralease; | |||
| }else{ | |||
| needPayDouble += price * receivePeriod; | |||
| } | |||
| } | |||
| if(isLastYesr) { | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| } | |||
| } | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||