From 221c7960d8c8df9ca95742c989e0340f6aa1e1e0 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 14 Aug 2019 14:27:07 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=81=94=E8=90=A5=E8=B7=B3=E7=82=B9=E7=8E=87?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/domain/po/WxRentContract.java | 2 -- .../impl/WxRentContractServiceImpl.java | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 185e5d61d..07a486e38 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -7,12 +7,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import org.apache.commons.lang3.StringUtils; - import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index fad09b239..f195e4f18 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -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 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 {