|
|
|
@@ -268,7 +268,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
* @param record |
|
|
|
*/ |
|
|
|
public Integer getPayRatio(WxBillRent record,WxRentContract wxRentContract,EnumMissTimeType timeType){ |
|
|
|
if(wxRentContract.getPayRatio() != null){ |
|
|
|
if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() > 0){ |
|
|
|
return wxRentContract.getPayRatio(); |
|
|
|
} |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); |
|
|
|
@@ -286,11 +286,11 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
|
|
|
|
//残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) |
|
|
|
if(EnumMissTimeType.YEAR.getCode().equals(timeType.getCode())){ |
|
|
|
start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365)).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365)).multiply(new BigDecimal(dayCount)); |
|
|
|
start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
}else if(EnumMissTimeType.MONTH.getCode().equals(timeType.getCode())){ |
|
|
|
start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30)).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30)).multiply(new BigDecimal(dayCount)); |
|
|
|
start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
} |
|
|
|
if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ |
|
|
|
return ratio; |
|
|
|
@@ -301,9 +301,9 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
|
|
|
|
//残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) |
|
|
|
if(EnumMissTimeType.YEAR.getCode().equals(timeType.getCode())){ |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365)).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
}else if(EnumMissTimeType.MONTH.getCode().equals(timeType.getCode())){ |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30)).multiply(new BigDecimal(dayCount)); |
|
|
|
end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); |
|
|
|
} |
|
|
|
if (revenue.compareTo(end) >= 0){ |
|
|
|
return ratio; |
|
|
|
@@ -313,32 +313,36 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
public ResultData updateRevenue(WxBillRent record, MallUserInfo user) { |
|
|
|
WxBillRent wxBillRent = wxBillRentMapper.selectByPrimaryKey(record.getId()); |
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getRentContractId()); |
|
|
|
SimpleDateFormat sdD = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(wxBillRent.getRentContractId()); |
|
|
|
SimpleDateFormat sdD = new SimpleDateFormat("d"); |
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); |
|
|
|
|
|
|
|
int startInt = Integer.parseInt(sdD.format(wxBillRent.getStarttime())); |
|
|
|
int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))); |
|
|
|
int months = getMonths(sdM.format(wxBillRent.getStarttime())+"-01",sdM.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))+"-01"); |
|
|
|
|
|
|
|
Integer ratio = getPayRatio(record,wxRentContract,null); |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ |
|
|
|
Integer ratio = 0; |
|
|
|
if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() >0){ |
|
|
|
ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); |
|
|
|
}else if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ |
|
|
|
if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ |
|
|
|
if(startInt == endInt && months == 12){ |
|
|
|
//刚好1年 |
|
|
|
ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); |
|
|
|
}else{ |
|
|
|
ratio = getPayRatio(record,wxRentContract,EnumMissTimeType.YEAR); |
|
|
|
ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.YEAR); |
|
|
|
} |
|
|
|
}else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ |
|
|
|
if(startInt == endInt && months == 1){ |
|
|
|
//刚好1个月 |
|
|
|
ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); |
|
|
|
}else{ |
|
|
|
ratio = getPayRatio(record,wxRentContract,EnumMissTimeType.MONTH); |
|
|
|
ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.MONTH); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -353,7 +357,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
} |
|
|
|
|
|
|
|
Long oldPrice = wxBillRent.getReceivePay(); |
|
|
|
Long newPrice = record.getReceivePay(); |
|
|
|
Long newPrice = newReceivePay; |
|
|
|
wxBillRent.setRevenue(record.getRevenue()); |
|
|
|
//wxBillRent.setReceivePay(oldPrice.equals(newPrice) ? oldPrice : newPrice); |
|
|
|
wxBillRent.setUpdatetime(new Date()); |
|
|
|
|