| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.domain.dto; | |||||
| import java.math.BigDecimal; | |||||
| import lombok.Data; | |||||
| /** | |||||
| */ | |||||
| @Data | |||||
| public class NeedPayDTO { | |||||
| private boolean isFullMonth; | |||||
| private BigDecimal money; | |||||
| } | |||||
| @@ -133,7 +133,7 @@ public class WxEnergyFees extends TenantEntity { | |||||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.DAY.getCode().intValue()) { | if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.DAY.getCode().intValue()) { | ||||
| BigDecimal priceD = new BigDecimal(this.price); | BigDecimal priceD = new BigDecimal(this.price); | ||||
| priceD = priceD.multiply(new BigDecimal(count)); | priceD = priceD.multiply(new BigDecimal(count)); | ||||
| return WxRentContractHelper.getNeedPay(decimalSize,new BigDecimal(0),priceD,start,end,priceCalcute,monthDays); | |||||
| return WxRentContractHelper.getNeedPay(null,decimalSize,new BigDecimal(0),priceD,start,end,priceCalcute,monthDays); | |||||
| }else { | }else { | ||||
| //按月计算 | //按月计算 | ||||
| BigDecimal priceMonth = new BigDecimal(this.price); | BigDecimal priceMonth = new BigDecimal(this.price); | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| @@ -1,14 +1,13 @@ | |||||
| package com.iformall.service.helper; | package com.iformall.service.helper; | ||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.domain.po.WxEnergyFees; | |||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.domain.vo.WxBillFeesStandardsListVo; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.service.impl.WxRentContractServiceImpl; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.joda.time.DateTime; | import org.joda.time.DateTime; | ||||
| import org.joda.time.Months; | import org.joda.time.Months; | ||||
| @@ -17,13 +16,24 @@ import org.joda.time.format.DateTimeFormatter; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.domain.dto.NeedPayDTO; | |||||
| import com.iformall.domain.po.WxEnergyFees; | |||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.domain.vo.WxBillFeesStandardsListVo; | |||||
| import com.iformall.enums.EnumContractReceivePeriodUnit; | |||||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||||
| import com.iformall.enums.EnumPriceUnit; | |||||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||||
| import com.iformall.enums.EnumRentContractAdjustRatioWay; | |||||
| import com.iformall.enums.EnumRentContractRentInputWay; | |||||
| import com.iformall.enums.EnumRentContractType; | |||||
| import com.iformall.enums.EnumRentDayPriceCalcute; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.impl.WxRentContractServiceImpl; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.DateUtils; | |||||
| public class WxRentContractHelper { | public class WxRentContractHelper { | ||||
| @@ -340,17 +350,18 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| //查询月账单需要支付的金额 | //查询月账单需要支付的金额 | ||||
| public static String getNeedPayMoney(WxRentContract wxRentContract,String price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ | |||||
| public static String getNeedPayMoney(List<Date> freeDays,WxRentContract wxRentContract,String price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod){ | |||||
| String needpay; | String needpay; | ||||
| if (null == wxRentContract.getDecimalSize()) { | if (null == wxRentContract.getDecimalSize()) { | ||||
| wxRentContract.setDecimalSize(Constant.default_short_decimal_size); | wxRentContract.setDecimalSize(Constant.default_short_decimal_size); | ||||
| } | } | ||||
| EnumRentDayPriceCalcute priceCalcute = EnumRentDayPriceCalcute.getEnum(wxRentContract.getDayPriceCalcute()); | EnumRentDayPriceCalcute priceCalcute = EnumRentDayPriceCalcute.getEnum(wxRentContract.getDayPriceCalcute()); | ||||
| //按日 | //按日 | ||||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | ||||
| BigDecimal priceD = new BigDecimal(price); | BigDecimal priceD = new BigDecimal(price); | ||||
| String needpayD = WxRentContractHelper.getNeedPay(Constant.default_long_decimal_size,new BigDecimal(0),priceD,startDate,endDate,priceCalcute,wxRentContract.getMonthAverageDays()); | |||||
| String needpayD = WxRentContractHelper.getNeedPay(freeDays,Constant.default_long_decimal_size,new BigDecimal(0),priceD,startDate,endDate,priceCalcute,wxRentContract.getMonthAverageDays()); | |||||
| //取整 | //取整 | ||||
| //needpay = new Double(needpayD).longValue(); | //needpay = new Double(needpayD).longValue(); | ||||
| //四舍五入 | //四舍五入 | ||||
| @@ -365,66 +376,13 @@ public class WxRentContractHelper { | |||||
| //生成金额直接计算 | //生成金额直接计算 | ||||
| if(!saveDb){ | 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(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),part)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(freeDays,Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays())).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| return needpay; | return needpay; | ||||
| } | } | ||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||||
| if(i == billTimeVoListSize - 1){//最后 | |||||
| //判断是否满足整月 | |||||
| Calendar instance = Calendar.getInstance(); | |||||
| instance.setTime(startDate); | |||||
| // instance.add(dayType, receivePeriod); | |||||
| // instance.add(Calendar.DATE, -1); | |||||
| instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, dayType); | |||||
| if(sd.format(instance.getTime()).equals(sd.format(endDate))){ | |||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01"); | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | |||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| }else if(i == 0){//第一期 | |||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||||
| if(isFirstDay(startDate)){ | |||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| months++; | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | |||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| }else{ | |||||
| if(isFirstDay(startDate)){ | |||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| if(isFirstDay(startDate)){ | |||||
| months++; | |||||
| } | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | |||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| } | |||||
| }else{//中间 | |||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| if(isFirstDay(startDate)){ | |||||
| months++; | |||||
| } | |||||
| //如果当月费用需要按天计算 | |||||
| if (monthCalDay) { | |||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| }else { | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| } | |||||
| //判断是否满足整月 | |||||
| needpay = new BigDecimal(getMonthNeedPay(freeDays,Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays())) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| return needpay; | return needpay; | ||||
| } | } | ||||
| @@ -479,71 +437,113 @@ public class WxRentContractHelper { | |||||
| * @param end | * @param end | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static String getMonthNeedPay(Integer decimalSize,BigDecimal price,Date start,Date end,int dayType,int receivePeriod,Integer dayPriceCalcute,Integer monthAvageDays,boolean part){ | |||||
| public static String getMonthNeedPay(List<Date> freeDays,Integer decimalSize,BigDecimal price,Date start,Date end,int dayType,int receivePeriod,Integer dayPriceCalcute,Integer monthAvageDays){ | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | ||||
| SimpleDateFormat sdD = new SimpleDateFormat("d"); | SimpleDateFormat sdD = new SimpleDateFormat("d"); | ||||
| BigDecimal total = new BigDecimal(0); | BigDecimal total = new BigDecimal(0); | ||||
| int[] diff; | int[] diff; | ||||
| List<Date> allDaysFrees = DateUtils.getAllDays(start, end); | |||||
| if (null == allDaysFrees) { | |||||
| return "0"; | |||||
| } | |||||
| List<Date> validDays = new ArrayList<Date>(); | |||||
| validDays.addAll(allDaysFrees); | |||||
| if (null != freeDays && freeDays.size() > 0 ) { | |||||
| allDaysFrees.retainAll(freeDays); | |||||
| } | |||||
| if (null != freeDays && freeDays.size() > 0 && null != allDaysFrees && allDaysFrees.size() > 0 ) { | |||||
| validDays.removeAll(allDaysFrees); | |||||
| } | |||||
| if (validDays.size() <= 0 ) { | |||||
| return "0"; | |||||
| } | |||||
| //同一天 | //同一天 | ||||
| if(sd.format(start).equals(sd.format(end))){ | if(sd.format(start).equals(sd.format(end))){ | ||||
| int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); | |||||
| return price.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| if (validDays.contains(start)) { | |||||
| int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); | |||||
| return price.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| }else { | |||||
| return "0"; | |||||
| } | |||||
| } | } | ||||
| //同月 | //同月 | ||||
| if(sdM.format(start).equals(sdM.format(end))){ | if(sdM.format(start).equals(sdM.format(end))){ | ||||
| diff = DateUtils.getDiff(start,end); | |||||
| int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| return total.toPlainString(); | |||||
| NeedPayDTO np = getMonthPay(start, end, price, decimalSize, validDays, dayPriceCalcute, monthAvageDays); | |||||
| return np.getMoney().toPlainString(); | |||||
| } | } | ||||
| //判断是否满足整月 | |||||
| boolean isFullMonth = false; | |||||
| if(part){ | |||||
| int startInt = Integer.parseInt(sdD.format(start)); | |||||
| int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(end,Calendar.DATE,1))); | |||||
| if(startInt == endInt){ | |||||
| isFullMonth = true; | |||||
| } | |||||
| }else{ | |||||
| Calendar instance = Calendar.getInstance(); | |||||
| instance.setTime(start); | |||||
| // instance.add(dayType, receivePeriod); | |||||
| // instance.add(Calendar.DATE, -1); | |||||
| instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, dayType); | |||||
| if(sd.format(instance.getTime()).equals(sd.format(end))){ | |||||
| isFullMonth = true; | |||||
| } | |||||
| Calendar instance = Calendar.getInstance(); | |||||
| instance.setTime(start); | |||||
| instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, dayType); | |||||
| if(sd.format(instance.getTime()).equals(sd.format(end))){ | |||||
| //不是一个月的。但是按整月算的 | |||||
| int months = getMonths(sdM.format(start)+"-01",sdM.format(DateUtils.getDaySet(end,Calendar.DATE,1))+"-01"); | |||||
| for (int i = 0 ; i < months; i++) { | |||||
| Date currentMonthEnd = DateUtils.getLastDayForMonth(start); | |||||
| NeedPayDTO np = getMonthPay(start, currentMonthEnd, price, decimalSize, validDays, dayPriceCalcute, monthAvageDays); | |||||
| start = DateUtils.getDaySet(currentMonthEnd,Calendar.DATE,1); | |||||
| total = total.add(np.getMoney()); | |||||
| } | |||||
| return total.toPlainString(); | |||||
| } | } | ||||
| if(isFullMonth){ | |||||
| int months = getMonths(sdM.format(start)+"-01",sdM.format(DateUtils.getDaySet(end,Calendar.DATE,1))+"-01"); | |||||
| return new BigDecimal(months).multiply(price).setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| //第一个月 | |||||
| //开始到这个月底 | |||||
| Date lastMonthDay = DateUtils.getLastDayForMonth(start); | Date lastMonthDay = DateUtils.getLastDayForMonth(start); | ||||
| diff = DateUtils.getDiff(start,lastMonthDay); | |||||
| int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| NeedPayDTO np = getMonthPay(start, lastMonthDay, price, decimalSize, validDays, dayPriceCalcute, monthAvageDays); | |||||
| total = total.add(np.getMoney()); | |||||
| //中间月份 | //中间月份 | ||||
| Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); | Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); | ||||
| int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); | |||||
| total = total.add(new BigDecimal(months).multiply(price)); | |||||
| int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); | |||||
| for (int i = 0 ; i < months; i++) { | |||||
| Date currentMonthEnd = DateUtils.getLastDayForMonth(newStartDate); | |||||
| NeedPayDTO _np = getMonthPay(newStartDate, currentMonthEnd, price, decimalSize, validDays, dayPriceCalcute, monthAvageDays); | |||||
| newStartDate = DateUtils.getDaySet(currentMonthEnd,Calendar.DATE,1); | |||||
| total = total.add(_np.getMoney()); | |||||
| } | |||||
| //最后一个月 | //最后一个月 | ||||
| diff = DateUtils.getDiff(DateUtils.getFirstDayForCurrMonth(end),end); | |||||
| dayCount = getRealDays(dayPriceCalcute, monthAvageDays, end); | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| if (newStartDate.before(end)) { | |||||
| NeedPayDTO enp = getMonthPay(DateUtils.getFirstDayForCurrMonth(end), end, price, decimalSize, validDays, dayPriceCalcute, monthAvageDays); | |||||
| total = total.add(enp.getMoney()); | |||||
| } | |||||
| return total.toPlainString(); | return total.toPlainString(); | ||||
| } | } | ||||
| private static NeedPayDTO getMonthPay(Date start,Date end, BigDecimal priceMonth,Integer decimalSize,List<Date> validDays,Integer dayPriceCalcute,Integer monthAvageDays) { | |||||
| NeedPayDTO np = new NeedPayDTO(); | |||||
| //当月实际天数 | |||||
| int md = DateUtils.getMonthDayCount(start);; | |||||
| //在有效的时间里面有多少天 | |||||
| int ms = getDays(end,validDays); | |||||
| //计算天数 | |||||
| int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); | |||||
| int sed = DateUtils.daysBetween(start,end)+1; | |||||
| //满月 | |||||
| if (md == sed) { | |||||
| //如果有免租的,则按天算 | |||||
| if (ms == md) { | |||||
| np.setFullMonth(true); | |||||
| np.setMoney(priceMonth); | |||||
| }else { | |||||
| np.setFullMonth(false); | |||||
| np.setMoney(new BigDecimal(ms).multiply(priceMonth).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| } | |||||
| }else { | |||||
| np.setFullMonth(false); | |||||
| np.setMoney(new BigDecimal(ms).multiply(priceMonth).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| } | |||||
| return np; | |||||
| } | |||||
| private static int getRealDays(Integer dayPriceCalcute,Integer monthAvageDays,Date start) { | private static int getRealDays(Integer dayPriceCalcute,Integer monthAvageDays,Date start) { | ||||
| //是不是按实际天数来计算 | //是不是按实际天数来计算 | ||||
| boolean isRealDays = true; | boolean isRealDays = true; | ||||
| @@ -582,12 +582,30 @@ public class WxRentContractHelper { | |||||
| * @param end | * @param end | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static String getNeedPay(Integer decimalSize,BigDecimal monthPrice,BigDecimal dayPrice,Date start,Date end,EnumRentDayPriceCalcute priceCalcute,Integer monthDays){ | |||||
| public static String getNeedPay(List<Date> freeDays,Integer decimalSize,BigDecimal monthPrice,BigDecimal dayPrice,Date start,Date end,EnumRentDayPriceCalcute priceCalcute,Integer monthDays){ | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | ||||
| BigDecimal total; | BigDecimal total; | ||||
| int[] diff; | int[] diff; | ||||
| List<Date> allDaysFrees = DateUtils.getAllDays(start, end); | |||||
| if (null == allDaysFrees) { | |||||
| return "0"; | |||||
| } | |||||
| List<Date> validDays = new ArrayList<Date>(); | |||||
| validDays.addAll(allDaysFrees); | |||||
| //取交集 | |||||
| if (null != freeDays && freeDays.size() > 0 ) { | |||||
| allDaysFrees.retainAll(freeDays); | |||||
| } | |||||
| //剩下的都是计费的 | |||||
| if (null != freeDays && freeDays.size() > 0 && null != allDaysFrees && allDaysFrees.size() > 0 ) { | |||||
| validDays.removeAll(allDaysFrees); | |||||
| } | |||||
| if (validDays.size() <= 0 ) { | |||||
| return "0"; | |||||
| } | |||||
| int dayCount = getRealMonthDays(priceCalcute,monthDays,start); | int dayCount = getRealMonthDays(priceCalcute,monthDays,start); | ||||
| BigDecimal price; | BigDecimal price; | ||||
| if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | ||||
| @@ -598,17 +616,25 @@ public class WxRentContractHelper { | |||||
| //同一天 | //同一天 | ||||
| if(sd.format(start).equals(sd.format(end))){ | if(sd.format(start).equals(sd.format(end))){ | ||||
| return price.toPlainString(); //算1天 | |||||
| if (validDays.contains(start)) { | |||||
| return price.toPlainString(); //算1天 | |||||
| }else { | |||||
| return "0"; | |||||
| } | |||||
| } | } | ||||
| //同月 | //同月 | ||||
| if(sdM.format(start).equals(sdM.format(end))){ | if(sdM.format(start).equals(sdM.format(end))){ | ||||
| diff = DateUtils.getDiff(start,end); | |||||
| return new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| //diff = DateUtils.getDiff(start,end); | |||||
| //return new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| return new BigDecimal(validDays.size()).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | } | ||||
| //当月截止 | |||||
| Date currEnd = DateUtils.getLastDayForMonth(start); | Date currEnd = DateUtils.getLastDayForMonth(start); | ||||
| diff = DateUtils.getDiff(start,currEnd); | |||||
| total = new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| //diff = DateUtils.getDiff(start,currEnd); | |||||
| //total = new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| int ds = getDays(currEnd,validDays); | |||||
| total = new BigDecimal(ds).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| int warnCount = 0; | int warnCount = 0; | ||||
| while (true){ | while (true){ | ||||
| @@ -623,13 +649,17 @@ public class WxRentContractHelper { | |||||
| //最后一个月 | //最后一个月 | ||||
| if(sdM.format(monthStartDate).equals(sdM.format(end))){ | if(sdM.format(monthStartDate).equals(sdM.format(end))){ | ||||
| diff = DateUtils.getDiff(monthStartDate,end); | |||||
| total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| int ms = getDays(end,validDays); | |||||
| //diff = DateUtils.getDiff(monthStartDate,end); | |||||
| //total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| total = total.add(price.multiply(new BigDecimal(ms)).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| break; | break; | ||||
| }else{ | }else{ | ||||
| currEnd = DateUtils.getLastDayForMonth(monthStartDate); | currEnd = DateUtils.getLastDayForMonth(monthStartDate); | ||||
| diff = DateUtils.getDiff(monthStartDate,currEnd); | |||||
| total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| //diff = DateUtils.getDiff(monthStartDate,currEnd); | |||||
| //total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| int ms = getDays(currEnd,validDays); | |||||
| total = total.add(price.multiply(new BigDecimal(ms)).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| } | } | ||||
| //预警 | //预警 | ||||
| @@ -642,5 +672,25 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| return total.setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | return total.setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | ||||
| } | } | ||||
| private static int getDays(Date end,List<Date> allDays) { | |||||
| if (null == allDays || allDays.size() <= 0 ) { | |||||
| return 0; | |||||
| } | |||||
| List<Date> _tempList = new ArrayList<Date>(); | |||||
| _tempList.addAll(allDays); | |||||
| Date _end = DateUtils.getDayBegin(end); | |||||
| for (int i = 0 ; i < _tempList.size(); i ++) { | |||||
| Date a = _tempList.get(i); | |||||
| if (a.equals(_end)) { | |||||
| allDays.remove(a); | |||||
| return i+1; | |||||
| }else if (a.after(_end)) { | |||||
| return i; | |||||
| }else { | |||||
| allDays.remove(a); | |||||
| } | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| } | } | ||||
| @@ -906,7 +906,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //按日 | //按日 | ||||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | ||||
| BigDecimal priceD = new BigDecimal(price); | BigDecimal priceD = new BigDecimal(price); | ||||
| String needpayD = WxRentContractHelper.getNeedPay(wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate,dayPrice,wxRentContract.getMonthAverageDays()); | |||||
| String needpayD = WxRentContractHelper.getNeedPay(null,wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate,dayPrice,wxRentContract.getMonthAverageDays()); | |||||
| needpay = needpayD; | needpay = needpayD; | ||||
| //按月计算 | //按月计算 | ||||
| }else{ | }else{ | ||||
| @@ -918,7 +918,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //生成金额直接计算 | //生成金额直接计算 | ||||
| if(!saveDb){ | if(!saveDb){ | ||||
| needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); | |||||
| needpay = WxRentContractHelper.getMonthNeedPay(null,wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays()); | |||||
| return needpay; | return needpay; | ||||
| } | } | ||||
| @@ -933,7 +933,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| months++; | months++; | ||||
| needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | ||||
| }else { | }else { | ||||
| needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); | |||||
| needpay = WxRentContractHelper.getMonthNeedPay(null,wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays()); | |||||
| } | } | ||||
| }else if(i == 0){//第一期 | }else if(i == 0){//第一期 | ||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | ||||
| @@ -942,7 +942,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| months++; | months++; | ||||
| needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | ||||
| }else{ | }else{ | ||||
| needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); | |||||
| needpay = WxRentContractHelper.getMonthNeedPay(null,wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays()); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| if(isFirstDay(startDate)){ | if(isFirstDay(startDate)){ | ||||
| @@ -952,7 +952,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | needpay = new BigDecimal(months).multiply(priceD).toPlainString(); | ||||
| }else{ | }else{ | ||||
| needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); | |||||
| needpay = WxRentContractHelper.getMonthNeedPay(null,wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays()); | |||||
| } | } | ||||
| } | } | ||||
| }else{//中间 | }else{//中间 | ||||
| @@ -1335,6 +1335,31 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return calendar.getTime(); | return calendar.getTime(); | ||||
| } | } | ||||
| private List<Date> getFreeDays(WxRentContract wxRentContract) { | |||||
| //免租期 | |||||
| WxRentContractFreePeriod fpq = new WxRentContractFreePeriod(); | |||||
| fpq.updateTenantInfo(wxRentContract); | |||||
| fpq.setRentContractId(wxRentContract.getId()); | |||||
| fpq.setSortColumn("start_date asc"); | |||||
| List<WxRentContractFreePeriod> freePeriods = wxRentContractFreePeriodMapper.findList(fpq); | |||||
| if (null == freePeriods || freePeriods.size() <= 0 ) { | |||||
| return null; | |||||
| } | |||||
| List<Date> allDate = new ArrayList<Date>(); | |||||
| for (int i = 0 ; i < freePeriods.size() ; i ++) { | |||||
| WxRentContractFreePeriod fp = freePeriods.get(i); | |||||
| List<Date> dates = DateUtils.getAllDays(fp.getStartDate(), fp.getEndDate()); | |||||
| if (null != dates && dates.size() > 0 ) { | |||||
| allDate.retainAll(dates); | |||||
| allDate.addAll(dates); | |||||
| } | |||||
| } | |||||
| if (allDate.size() <= 0 ) { | |||||
| return null; | |||||
| } | |||||
| return allDate; | |||||
| } | |||||
| public Map<String, Object> buildRent(int receivePeriod, String[] priceArrs,String[] bussinessManagerPriceArrs,String[] operationManagerPriceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, MallUserInfo user, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { | public Map<String, Object> buildRent(int receivePeriod, String[] priceArrs,String[] bussinessManagerPriceArrs,String[] operationManagerPriceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, MallUserInfo user, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { | ||||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); | WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); | ||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| @@ -1363,11 +1388,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| //免租期 | //免租期 | ||||
| WxRentContractFreePeriod fpq = new WxRentContractFreePeriod(); | |||||
| fpq.updateTenantInfo(wxRentContract); | |||||
| fpq.setRentContractId(wxRentContract.getId()); | |||||
| fpq.setSortColumn("start_date asc"); | |||||
| List<WxRentContractFreePeriod> freePeroids = wxRentContractFreePeriodMapper.findList(fpq); | |||||
| List<Date> freePeriods = getFreeDays(wxRentContract); | |||||
| int index = 0; | int index = 0; | ||||
| for (int i = 0; i < billTimeVoList.size(); i++) { | for (int i = 0; i < billTimeVoList.size(); i++) { | ||||
| @@ -1403,12 +1424,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //同一天,算一天 | //同一天,算一天 | ||||
| if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | ||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | ||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract,bussinessManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,bussinessManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | ||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract,operationManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,operationManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| if(billTimeVo.getStartDate().before(endDate)){ | if(billTimeVo.getStartDate().before(endDate)){ | ||||
| @@ -1422,39 +1443,39 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| operatingManageFeeNeedpayFront = operationManagerPriceArrs[index - 1]; | operatingManageFeeNeedpayFront = operationManagerPriceArrs[index - 1]; | ||||
| } | } | ||||
| }else { | }else { | ||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| needpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| needpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | ||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| } | } | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | ||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| } | } | ||||
| } | } | ||||
| }else{ | }else{ | ||||
| //如果是按自然月,则这一年和下一年交叉部分需要重新计算 | //如果是按自然月,则这一年和下一年交叉部分需要重新计算 | ||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | ||||
| Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate()); | Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate()); | ||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| needpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| needpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | ||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| } | } | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | ||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); | |||||
| } | } | ||||
| }else { | }else { | ||||
| //按账单日 | //按账单日 | ||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); | |||||
| needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { | ||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); | |||||
| bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | ||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); | |||||
| operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1477,12 +1498,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //计算金额 | //计算金额 | ||||
| if(!flag){ | if(!flag){ | ||||
| needpay = WxRentContractHelper.getNeedPayMoney(wxRentContract, priceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 ) { | if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 ) { | ||||
| bussinessManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(wxRentContract, bussinessManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| bussinessManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { | ||||
| operatingManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(wxRentContract, operationManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||||
| operatingManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1639,4 +1639,18 @@ public class DateUtils { | |||||
| end.add(Calendar.DATE, -1); | end.add(Calendar.DATE, -1); | ||||
| return end; | return end; | ||||
| } | } | ||||
| public static List<Date> getAllDays(Date start,Date end) { | |||||
| Calendar cal = Calendar.getInstance(); | |||||
| cal.setTime(start); | |||||
| cal.set(Calendar.HOUR_OF_DAY, 0); | |||||
| cal.set(Calendar.MINUTE, 0); | |||||
| cal.set(Calendar.SECOND, 0); | |||||
| List<Date> allDays = new ArrayList<Date>(); | |||||
| while (cal.getTime().before(end) || cal.getTime().equals(end)) { | |||||
| allDays.add(cal.getTime()); | |||||
| cal.add(Calendar.DATE, 1); | |||||
| } | |||||
| return allDays; | |||||
| } | |||||
| } | } | ||||