|
|
|
@@ -20,6 +20,7 @@ import com.iformall.utils.PriceUtil; |
|
|
|
import com.iformall.utils.WordUtil; |
|
|
|
import org.apache.commons.collections.map.HashedMap; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.flowable.engine.RuntimeService; |
|
|
|
import org.flowable.engine.TaskService; |
|
|
|
@@ -123,6 +124,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
result.put("totalPeriodDay",array[1]); |
|
|
|
} |
|
|
|
|
|
|
|
//init rentPrice |
|
|
|
if(StringUtils.isNotBlank(wxRentContract.getRentPrice())){ |
|
|
|
wxRentContract.setRentPrice(Double.parseDouble(wxRentContract.getRentPrice())/100 + ""); |
|
|
|
} |
|
|
|
|
|
|
|
//init 租赁单价 |
|
|
|
String rentInfo = wxRentContract.getRentInfo(); |
|
|
|
if(StringUtils.isNotBlank(rentInfo)){ |
|
|
|
@@ -924,19 +930,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
long needpay; |
|
|
|
|
|
|
|
//当天也算,加1天 |
|
|
|
Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,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; |
|
|
|
double needpayD = this.getNeedPay(0,price,wxBillRent.getStarttime(),wxBillRent.getEndtime()); |
|
|
|
needpay = new Double(needpayD).longValue(); |
|
|
|
}else{ |
|
|
|
//按月 |
|
|
|
int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); |
|
|
|
needpay = diff[0]*price; |
|
|
|
|
|
|
|
double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); |
|
|
|
needpay += diff[1] * oneDayProce; |
|
|
|
double needpayD = this.getNeedPay(price,0,wxBillRent.getStarttime(),wxBillRent.getEndtime()); |
|
|
|
needpay = new Double(needpayD).longValue(); |
|
|
|
} |
|
|
|
|
|
|
|
wxBillRent.setNeedPay(needpay); |
|
|
|
wxBillRent.setOwe(needpay); |
|
|
|
wxBillRent.setReceivePay(needpay); |
|
|
|
@@ -1728,25 +1732,71 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return wxRentContractMapper.getShopType(wxRentContract); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception{ |
|
|
|
/** |
|
|
|
* 按日计租 根据每月的日期总数计算needpay |
|
|
|
* @param monthPrice |
|
|
|
* @param start |
|
|
|
* @param end |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public double getNeedPay(long monthPrice,long dayPrice,Date start,Date end){ |
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
// Date start = sd.parse("2019-05-24"); |
|
|
|
// Date end = sd.parse("2020-06-24"); |
|
|
|
Date start = sd.parse("2019-05-24"); |
|
|
|
Date end = sd.parse("2019-08-10"); |
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("MM"); |
|
|
|
Double total; |
|
|
|
|
|
|
|
int dayCount = DateUtils.getMonthDayCount(start); |
|
|
|
double price; |
|
|
|
if(monthPrice > 0){ |
|
|
|
price = (double) monthPrice/dayCount; |
|
|
|
}else{ |
|
|
|
price = dayPrice; |
|
|
|
} |
|
|
|
Date currEnd = DateUtils.getLastDayForMonth(start); |
|
|
|
int[] diff = DateUtils.getDiff(start,currEnd); |
|
|
|
total = (diff[1]+1) * price; |
|
|
|
|
|
|
|
Integer adjustPeriod = EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode(); |
|
|
|
Integer dayType = Calendar.MONTH; |
|
|
|
int receivePeriod = 2; |
|
|
|
if(sdM.format(start).equals(sdM.format(end))){ |
|
|
|
return total; |
|
|
|
} |
|
|
|
System.out.println("-------total:"+total); |
|
|
|
|
|
|
|
List<BillTimeVo> list = initBillTimeList(start,end,adjustPeriod,dayType,receivePeriod); |
|
|
|
for (BillTimeVo b:list) { |
|
|
|
System.out.print(sd.format(b.getStartDate())); |
|
|
|
System.out.print(" "+sd.format(b.getEndDate())); |
|
|
|
System.out.print(" "+sd.format(b.getReceiveDate())); |
|
|
|
while (true){ |
|
|
|
Date monthStartDate = DateUtils.getDaySet(currEnd,Calendar.DATE,1); |
|
|
|
dayCount = DateUtils.getMonthDayCount(monthStartDate); |
|
|
|
if(monthPrice > 0){ |
|
|
|
price = (double) monthPrice/dayCount; |
|
|
|
}else{ |
|
|
|
price = dayPrice; |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println(); |
|
|
|
System.out.println("-------monthStartDate:"+sd.format(monthStartDate)); |
|
|
|
|
|
|
|
//最后一个月 |
|
|
|
if(sdM.format(monthStartDate).equals(sdM.format(end))){ |
|
|
|
System.out.println("-----------"); |
|
|
|
System.out.println(sd.format(monthStartDate)); |
|
|
|
System.out.println(sd.format(end)); |
|
|
|
|
|
|
|
diff = DateUtils.getDiff(monthStartDate,end); |
|
|
|
total += price * (diff[1] +1); |
|
|
|
break; |
|
|
|
}else{ |
|
|
|
currEnd = DateUtils.getLastDayForMonth(monthStartDate); |
|
|
|
diff = DateUtils.getDiff(monthStartDate,currEnd); |
|
|
|
total += price * (diff[1] +1); |
|
|
|
} |
|
|
|
System.out.println("-------total:"+total); |
|
|
|
} |
|
|
|
return total; |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception{ |
|
|
|
long tprice = 100; |
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Date start = sd.parse("2019-05-28"); |
|
|
|
Date end = sd.parse("2019-07-05"); |
|
|
|
|
|
|
|
System.out.println("===="+new WxRentContractServiceImpl().getNeedPay(tprice,0,start,end));; |
|
|
|
} |
|
|
|
|
|
|
|
public static List<BillTimeVo> initBillTimeList(Date start,Date end,Integer adjustPeriod,Integer dayType,int receivePeriod){ |
|
|
|
@@ -1804,3 +1854,4 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|