From 0f01f80b483a7881d5f1008c092e1fbf13b7393f Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 25 Apr 2019 11:58:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=B4=A6=E6=9C=9F=E8=B0=83=E6=95=B4][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E4=BF=AE=E6=94=B9=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxRentContractServiceImpl.java | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 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 9a4d7f72c..106fbc2ee 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -679,7 +679,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); } else { //按日计租 - Map resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false); + Map resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false,0); rentList = ( List)resultMap.get("billList"); } } @@ -795,7 +795,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { instance.add(Calendar.MONTH, month * i); startDate = instance.getTime(); } - Map 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 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 billRentList = (List)resultMap.get("billList"); billcount = (Integer)resultMap.get("billcount"); resultList.addAll(billRentList); @@ -811,7 +811,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return false; } - public Map buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map shopInfo,boolean isLastYesr) { + public Map buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map 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)); //分做四舍五入