|
@@ -4,12 +4,13 @@ import com.dayou.bo.BrokerageDetailBO;
|
|
|
import com.dayou.bo.LeaderRatioBO;
|
|
|
import com.dayou.brokerage.BrokerageCalculateSupport;
|
|
|
import com.dayou.brokerage.MarketerBrokerageCalculator;
|
|
|
-import com.dayou.brokerage.config.LandBrokerageDataConfiguration;
|
|
|
import com.dayou.brokerage.constants.BrokerageMode;
|
|
|
import com.dayou.brokerage.constants.BrokerageRule;
|
|
|
import com.dayou.brokerage.constants.BrokerageState;
|
|
|
import com.dayou.entity.ItemBrokerageDetail;
|
|
|
+import com.dayou.enums.GlobalConfigEnum;
|
|
|
import com.dayou.exception.BusinessException;
|
|
|
+import com.google.common.cache.LoadingCache;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -17,6 +18,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -30,17 +32,21 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport implements MarketerBrokerageCalculator {
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LoadingCache<String,BigDecimal> marketerRatioCache;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private LandBrokerageDataConfiguration landBrokerageDataConfiguration;
|
|
|
+ private LoadingCache<String,BigDecimal> globalConfigCache;
|
|
|
|
|
|
@Override
|
|
|
public BrokerageDetailBO predictPersonalAmount(BrokerageDetailBO bo) {
|
|
|
- String mergeKey = bo.mergeKey();
|
|
|
- BigDecimal ratio = landBrokerageDataConfiguration.ratioList.get(mergeKey);
|
|
|
- bo.setRate(ratio);
|
|
|
- if (ratio !=null){
|
|
|
- checkItemBrokerageStatus(bo);
|
|
|
- try {
|
|
|
+ try {
|
|
|
+ String mergeKey = bo.mergeKey();
|
|
|
+ BigDecimal ratio = marketerRatioCache.get(mergeKey);
|
|
|
+ bo.setRate(ratio);
|
|
|
+ if (ratio !=null){
|
|
|
+ checkItemBrokerageStatus(bo);
|
|
|
bo.setPredictAmount(bo.getAmount().multiply(ratio));
|
|
|
bo.setBrokerageMode(BrokerageMode.PERSONAL.getCode());
|
|
|
bo.setActualAmount(actualAmount(bo.getPredictAmount()));
|
|
@@ -49,44 +55,55 @@ public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport impl
|
|
|
bo.setMarketerStatus(BrokerageState.TO_PREDICTING.getCode());
|
|
|
bo.setAheadAmount(aheadAmount(bo.getPredictAmount()));
|
|
|
}
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.info("项目id:[{}],客户经理id:[{}],[{}]",bo.getId(),bo.getUserId(),e.getMessage());
|
|
|
+ }else {
|
|
|
+ log.info("项目id:[{}],合同金额:[{}],提成系数:[null],[未设置提成系数,无法计算客户经理提成]",bo.getId(),bo.getAmount());
|
|
|
}
|
|
|
- }else {
|
|
|
- log.info("项目id:[{}],合同金额:[{}],提成系数:[null],[未设置提成系数,无法计算客户经理提成]",bo.getId(),bo.getAmount());
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ log.info("项目id:[{}],客户经理id:[{}],[{}]",bo.getId(),bo.getUserId(),e.getMessage());
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
return bo;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public BigDecimal aheadAmount(BigDecimal predictAmount){
|
|
|
- BigDecimal aheadAmount = predictAmount.multiply(landBrokerageDataConfiguration.marketerBrokeragePercentage);
|
|
|
- return aheadAmount;
|
|
|
+ try {
|
|
|
+ BigDecimal aheadAmount = predictAmount.multiply(globalConfigCache.get(GlobalConfigEnum.Finance.MARKETER_BROKERAGE_PERCENTAGE.getCode()));
|
|
|
+ return aheadAmount;
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ log.error("获取提成缓存数据失败");
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Set<ItemBrokerageDetail> predictTeamShareAmount(BrokerageDetailBO bo, Set<LeaderRatioBO> leaderRatioBOSet) {
|
|
|
- String mergeKey = bo.mergeKey();
|
|
|
- BigDecimal ratio = landBrokerageDataConfiguration.ratioList.get(mergeKey);
|
|
|
Set<ItemBrokerageDetail> itemBrokerageDetails = Sets.newHashSet();
|
|
|
- if (ratio!=null){
|
|
|
- checkItemBrokerageStatus(bo);
|
|
|
- itemBrokerageDetails = leaderRatioBOSet.stream().map(x -> {
|
|
|
- ItemBrokerageDetail itemBrokerageDetail = new ItemBrokerageDetail();
|
|
|
- itemBrokerageDetail.setGeneralId(bo.getGeneralId());
|
|
|
- itemBrokerageDetail.setPredictAmount(bo.getAmount().multiply(ratio).multiply(x.getRatio()));
|
|
|
- itemBrokerageDetail.setUserId(x.getUserId());
|
|
|
- itemBrokerageDetail.setAheadAmount(BigDecimal.ZERO);
|
|
|
- itemBrokerageDetail.setActualAmount(actualAmount(itemBrokerageDetail.getPredictAmount()));
|
|
|
- itemBrokerageDetail.setAdvanceAmount(BigDecimal.ZERO);
|
|
|
- itemBrokerageDetail.setBrokerageMode(BrokerageMode.TEAM_SHARE.getCode());
|
|
|
- itemBrokerageDetail.setBrokerageRule(BrokerageRule.LAND_MARKETER_RULE.getCode());
|
|
|
- return itemBrokerageDetail;
|
|
|
- }).collect(Collectors.toSet());
|
|
|
+ try {
|
|
|
+ String mergeKey = bo.mergeKey();
|
|
|
+ BigDecimal ratio = marketerRatioCache.get(mergeKey);
|
|
|
+ if (ratio!=null){
|
|
|
+ checkItemBrokerageStatus(bo);
|
|
|
+ itemBrokerageDetails = leaderRatioBOSet.stream().map(x -> {
|
|
|
+ ItemBrokerageDetail itemBrokerageDetail = new ItemBrokerageDetail();
|
|
|
+ itemBrokerageDetail.setGeneralId(bo.getGeneralId());
|
|
|
+ itemBrokerageDetail.setPredictAmount(bo.getAmount().multiply(ratio).multiply(x.getRatio()));
|
|
|
+ itemBrokerageDetail.setUserId(x.getUserId());
|
|
|
+ itemBrokerageDetail.setAheadAmount(BigDecimal.ZERO);
|
|
|
+ itemBrokerageDetail.setActualAmount(actualAmount(itemBrokerageDetail.getPredictAmount()));
|
|
|
+ itemBrokerageDetail.setAdvanceAmount(BigDecimal.ZERO);
|
|
|
+ itemBrokerageDetail.setBrokerageMode(BrokerageMode.TEAM_SHARE.getCode());
|
|
|
+ itemBrokerageDetail.setBrokerageRule(BrokerageRule.LAND_MARKETER_RULE.getCode());
|
|
|
+ return itemBrokerageDetail;
|
|
|
+ }).collect(Collectors.toSet());
|
|
|
|
|
|
- }else {
|
|
|
- log.info("项目id:[{}],合同金额:[{}],提成系数:[null],[未设置提成系数,无法计算客户经理领导提成]",bo.getId(),bo.getAmount());
|
|
|
+ }else {
|
|
|
+ log.info("项目id:[{}],合同金额:[{}],提成系数:[null],[未设置提成系数,无法计算客户经理领导提成]",bo.getId(),bo.getAmount());
|
|
|
+ }
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ log.error("获取提成缓存数据失败");
|
|
|
}
|
|
|
return itemBrokerageDetails;
|
|
|
}
|