|
|
|
@@ -1028,6 +1028,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
int index = 0; |
|
|
|
for (int i = 0; i < billTimeVoList.size(); i++) { |
|
|
|
BillTimeVo billTimeVo = billTimeVoList.get(i); |
|
|
|
//计算金额 |
|
|
|
long needpay = 0; |
|
|
|
|
|
|
|
if(yearList.size() > 1) { |
|
|
|
if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { |
|
|
|
@@ -1040,16 +1042,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 |
|
|
|
logger.info("==========cross:"+sd.format(endDate)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是计算账单金额&cross 拆分日期进行计算 |
|
|
|
if(!saveDb) { |
|
|
|
logger.info("==========s:"+sd.format(billTimeVo.getStartDate())); |
|
|
|
logger.info("==========e:"+sd.format(billTimeVo.getEndDate())); |
|
|
|
logger.info("==========:"+sd.format(endDate)); |
|
|
|
long needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); |
|
|
|
long needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); |
|
|
|
needpay = needpayFront+needpayAfter; |
|
|
|
}else{ |
|
|
|
//计算金额 |
|
|
|
needpay = getNeedPayMoney(wxRentContract,priceArrs[index],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取price 、shopInfo |
|
|
|
long price = priceArrs[index]; |
|
|
|
|
|
|
|
WxBillRent wxBillRent = new WxBillRent(); |
|
|
|
wxBillRent.setIsPreview(isPreview); |
|
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
|
@@ -1059,57 +1067,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
wxBillRent.setEndtime(billTimeVo.getEndDate()); |
|
|
|
wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); |
|
|
|
|
|
|
|
long needpay; |
|
|
|
//按日 |
|
|
|
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ |
|
|
|
Double priceD = new Double(price); |
|
|
|
double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,wxBillRent.getStarttime(),wxBillRent.getEndtime()); |
|
|
|
needpay = new Double(needpayD).longValue(); |
|
|
|
}else{ |
|
|
|
//年 需要除12 |
|
|
|
Double priceD = new Double(price); |
|
|
|
if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ |
|
|
|
priceD = new Double(price)/12; |
|
|
|
} |
|
|
|
|
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); |
|
|
|
if(i == billTimeVoList.size()-1){//最后 |
|
|
|
if(isFirstDay(billTimeVo.getStartDate())){ |
|
|
|
int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); |
|
|
|
months++; |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else { |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); |
|
|
|
} |
|
|
|
}else if(i == 0){//第一期 |
|
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ |
|
|
|
if(isFirstDay(billTimeVo.getStartDate())){ |
|
|
|
int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); |
|
|
|
months++; |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else{ |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(isFirstDay(billTimeVo.getStartDate())){ |
|
|
|
int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); |
|
|
|
if(isFirstDay(billTimeVo.getStartDate())){ |
|
|
|
months++; |
|
|
|
} |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else{ |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{//中间 |
|
|
|
int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); |
|
|
|
if(isFirstDay(billTimeVo.getStartDate())){ |
|
|
|
months++; |
|
|
|
} |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wxBillRent.setNeedPay(needpay); |
|
|
|
wxBillRent.setOwe(needpay); |
|
|
|
wxBillRent.setReceivePay(needpay); |
|
|
|
@@ -1142,8 +1099,58 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
public long getNeedPay(){ |
|
|
|
public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize){ |
|
|
|
long needpay; |
|
|
|
//按日 |
|
|
|
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ |
|
|
|
Double priceD = new Double(price); |
|
|
|
double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate); |
|
|
|
needpay = new Double(needpayD).longValue(); |
|
|
|
}else{ |
|
|
|
//年 需要除12 |
|
|
|
Double priceD = new Double(price); |
|
|
|
if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ |
|
|
|
priceD = new Double(price)/12; |
|
|
|
} |
|
|
|
|
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); |
|
|
|
if(i == billTimeVoListSize - 1){//最后 |
|
|
|
if(isFirstDay(startDate)){ |
|
|
|
int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); |
|
|
|
months++; |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else { |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); |
|
|
|
} |
|
|
|
}else if(i == 0){//第一期 |
|
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ |
|
|
|
if(isFirstDay(startDate)){ |
|
|
|
int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); |
|
|
|
months++; |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else{ |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(isFirstDay(startDate)){ |
|
|
|
int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); |
|
|
|
if(isFirstDay(startDate)){ |
|
|
|
months++; |
|
|
|
} |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
}else{ |
|
|
|
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{//中间 |
|
|
|
int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); |
|
|
|
if(isFirstDay(startDate)){ |
|
|
|
months++; |
|
|
|
} |
|
|
|
needpay = new Double(months * priceD).longValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
return needpay; |
|
|
|
} |
|
|
|
|
|
|
|
public void setExpiredDay(WxBillRent wxBillRent,int dayType, int receivePeriod){ |
|
|
|
|