|
|
@@ -898,11 +898,89 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
|
|
|
|
|
Map<String,Object> resultMap = new HashedMap(); |
|
|
Map<String,Object> resultMap = new HashedMap(); |
|
|
List<WxBillRent> resultList = new ArrayList<>(); |
|
|
List<WxBillRent> resultList = new ArrayList<>(); |
|
|
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
|
|
|
|
|
|
|
|
Date start = startdate; |
|
|
|
|
|
Date end = wxRentContract.getRentalEndDate(); |
|
|
|
|
|
while (true){ |
|
|
|
|
|
WxBillRent wxBillRent = new WxBillRent(); |
|
|
|
|
|
wxBillRent.setIsPreview(isPreview); |
|
|
|
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
|
|
|
wxBillRent.setRentContractId(wxRentContract.getId()); |
|
|
|
|
|
wxBillRent.setPay(0L); |
|
|
|
|
|
long needpay = new BigDecimal(price).multiply(new BigDecimal(receivePeriod)).longValue(); |
|
|
|
|
|
|
|
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
|
|
instance.setTime(start); |
|
|
|
|
|
instance.add(dayType, receivePeriod); |
|
|
|
|
|
if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ |
|
|
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
|
|
} |
|
|
|
|
|
Date time = instance.getTime(); |
|
|
|
|
|
wxBillRent.setReceiveDate(time); |
|
|
|
|
|
//账单开始时间 |
|
|
|
|
|
instance.clear(); |
|
|
|
|
|
instance.setTime(wxBillRent.getReceiveDate()); |
|
|
|
|
|
if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ |
|
|
|
|
|
instance.add(Calendar.DAY_OF_MONTH, 1); |
|
|
|
|
|
} |
|
|
|
|
|
wxBillRent.setStarttime(instance.getTime()); |
|
|
|
|
|
//账单结束时间 |
|
|
|
|
|
instance.clear(); |
|
|
|
|
|
instance.setTime(wxBillRent.getStarttime()); |
|
|
|
|
|
instance.add(dayType, receivePeriod); |
|
|
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
|
|
wxBillRent.setEndtime(instance.getTime()); |
|
|
|
|
|
|
|
|
|
|
|
wxBillRent.setNeedPay(needpay); |
|
|
|
|
|
wxBillRent.setOwe(needpay); |
|
|
|
|
|
wxBillRent.setReceivePay(needpay); |
|
|
|
|
|
|
|
|
|
|
|
//截止收租日在当前时间之前 |
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
if (wxBillRent.getReceiveDate().before(date)) { |
|
|
|
|
|
long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); |
|
|
|
|
|
wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); |
|
|
|
|
|
wxBillRent.setExpiredDay(day); |
|
|
|
|
|
} else {//截止收租日在当前时间之后 |
|
|
|
|
|
Calendar now = Calendar.getInstance(); |
|
|
|
|
|
now.add(dayType, receivePeriod); |
|
|
|
|
|
Date currenttime = now.getTime(); |
|
|
|
|
|
//当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 |
|
|
|
|
|
if (currenttime.before(wxBillRent.getReceiveDate())) { |
|
|
|
|
|
wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); |
|
|
|
|
|
wxBillRent.setExpiredDay(0L); |
|
|
|
|
|
} else { |
|
|
|
|
|
wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); |
|
|
|
|
|
wxBillRent.setExpiredDay(0L); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
wxBillRent.setRevenue(0L); |
|
|
|
|
|
wxBillRent.setTenantId(wxMerchant.getTenantId()); |
|
|
|
|
|
wxBillRent.setIsDel(0); |
|
|
|
|
|
wxBillRent.setMerchantId(wxMerchant.getId()); |
|
|
|
|
|
wxBillRent.setUserId(userId); |
|
|
|
|
|
wxBillRent.setShopId(wxRentContract.getShopId()); |
|
|
|
|
|
wxBillRent.setCreatetime(date); |
|
|
|
|
|
wxBillRent.setUpdatetime(date); |
|
|
|
|
|
wxBillRent.setIsDel(EnumDelStatus.NOT_DEL.getCode()); |
|
|
|
|
|
wxBillRent.setRentShopType(wxRentContract.getRentShopType()); |
|
|
|
|
|
wxBillRent.setPeriod(++billcount); |
|
|
|
|
|
wxBillRent.setShopInfo(shopInfoStr); |
|
|
|
|
|
wxBillRentMapper.insertSelective(wxBillRent); |
|
|
|
|
|
resultList.add(wxBillRent); |
|
|
|
|
|
|
|
|
|
|
|
//next |
|
|
|
|
|
start = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int extralease = lease % receivePeriod; //余 |
|
|
int extralease = lease % receivePeriod; //余 |
|
|
int extracount = extralease > 0 ? 1 : 0; |
|
|
int extracount = extralease > 0 ? 1 : 0; |
|
|
int paycount = lease / receivePeriod + extracount; |
|
|
int paycount = lease / receivePeriod + extracount; |
|
|
int index = paycount - 1; |
|
|
int index = paycount - 1; |
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
|
|
|
|
|
|
|
|
//自然月计租,而且残月,周期整除,n+1,最后一个周期作为残月 |
|
|
//自然月计租,而且残月,周期整除,n+1,最后一个周期作为残月 |
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()) |
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()) |
|
|
@@ -916,7 +994,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
for(int i = 0; i < paycount; i++){ |
|
|
for(int i = 0; i < paycount; i++){ |
|
|
WxBillRent wxBillRent = new WxBillRent(); |
|
|
WxBillRent wxBillRent = new WxBillRent(); |
|
|
wxBillRent.setIsPreview(isPreview); |
|
|
wxBillRent.setIsPreview(isPreview); |
|
|
|
|
|
|
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
wxBillRent.setRentContractId(wxRentContract.getId()); |
|
|
wxBillRent.setRentContractId(wxRentContract.getId()); |
|
|
wxBillRent.setPay(0L); |
|
|
wxBillRent.setPay(0L); |
|
|
@@ -1080,23 +1157,26 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//最后一期截止到结束日期 |
|
|
//最后一期截止到结束日期 |
|
|
if(i == paycount - 1 && isLastYesr){ |
|
|
|
|
|
wxBillRent.setEndtime(wxRentContract.getRentalEndDate()); |
|
|
|
|
|
//当天也算,加1天 |
|
|
|
|
|
Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); |
|
|
|
|
|
//按日 |
|
|
|
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ |
|
|
|
|
|
int dayCount = DateUtils.daysBetween(wxBillRent.getStarttime(),newEndDate); |
|
|
|
|
|
needpay = dayCount*price; |
|
|
|
|
|
}else{ |
|
|
|
|
|
//按月 |
|
|
|
|
|
int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); |
|
|
|
|
|
needpay = diff[0]*price; |
|
|
|
|
|
|
|
|
|
|
|
double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); |
|
|
|
|
|
needpay += diff[1] * oneDayProce; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// if(i == paycount - 1 && isLastYesr){ |
|
|
|
|
|
// wxBillRent.setEndtime(wxRentContract.getRentalEndDate()); |
|
|
|
|
|
// //当天也算,加1天 |
|
|
|
|
|
// Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); |
|
|
|
|
|
// //按日 |
|
|
|
|
|
// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ |
|
|
|
|
|
// int dayCount = DateUtils.daysBetween(wxBillRent.getStarttime(),newEndDate); |
|
|
|
|
|
// needpay = dayCount*price; |
|
|
|
|
|
// }else{ |
|
|
|
|
|
// //按月 |
|
|
|
|
|
// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
// System.out.println("----1"+sd.format(wxBillRent.getStarttime())); |
|
|
|
|
|
// System.out.println("----2"+sd.format(newEndDate)); |
|
|
|
|
|
// int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); |
|
|
|
|
|
// needpay = diff[0]*price; |
|
|
|
|
|
// |
|
|
|
|
|
// double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); |
|
|
|
|
|
// needpay += diff[1] * oneDayProce; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
wxBillRent.setNeedPay(needpay); |
|
|
wxBillRent.setNeedPay(needpay); |
|
|
wxBillRent.setOwe(needpay); |
|
|
wxBillRent.setOwe(needpay); |
|
|
|