|
|
|
@@ -248,6 +248,39 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设置的跳点率 |
|
|
|
* ["1000-1200:10",">3000:20"] |
|
|
|
* @param record |
|
|
|
*/ |
|
|
|
public void getPayRatio(WxRentContract record){ |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); |
|
|
|
List<String> ratioList = JSONArray.parseArray(record.getBusDiscountRatio(), String.class); |
|
|
|
|
|
|
|
for (String e:ratioList) { |
|
|
|
String[] array = e.split(":"); |
|
|
|
Integer ratio = Integer.parseInt(array[1]); |
|
|
|
|
|
|
|
if(e.indexOf("-") >= 0){ |
|
|
|
String[] revenueArray = array[0].split("-"); |
|
|
|
BigDecimal start = new BigDecimal(revenueArray[0]); |
|
|
|
BigDecimal end = new BigDecimal(revenueArray[1]); |
|
|
|
if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ |
|
|
|
record.setPayRatio(ratio); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
}if(e.indexOf(">") >= 0){ |
|
|
|
String[] revenueArray = array[0].split(">"); |
|
|
|
BigDecimal end = new BigDecimal(revenueArray[1]); |
|
|
|
if (revenue.compareTo(end) >= 0){ |
|
|
|
record.setPayRatio(ratio); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
public ResultData save(WxRentContract record,Long userId,String userName,Date oldRentStartDate) { |
|
|
|
@@ -271,9 +304,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
} |
|
|
|
|
|
|
|
if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { |
|
|
|
getPayRatio(record); |
|
|
|
BigDecimal hundred = new BigDecimal(100); |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); |
|
|
|
BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); |
|
|
|
|
|
|
|
BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); |
|
|
|
record.setPrice(price.multiply(hundred).longValue()); |
|
|
|
} else { |
|
|
|
|