|
@@ -8,20 +8,29 @@ 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.entity.UserTarget;
|
|
|
import com.dayou.enums.GlobalConfigEnum;
|
|
|
import com.dayou.exception.BusinessException;
|
|
|
+import com.dayou.service.IMarketStatService;
|
|
|
+import com.dayou.service.IPostCultivateService;
|
|
|
+import com.dayou.service.IUserService;
|
|
|
+import com.dayou.service.IUserTargetService;
|
|
|
import com.google.common.cache.LoadingCache;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.dayou.brokerage.constants.BrokerageMsg.*;
|
|
|
+import static com.dayou.brokerage.constants.BrokerageRule.LAND_SUPERVISOR_RULE;
|
|
|
import static com.dayou.common.Constants.HUNDRED;
|
|
|
+import static com.dayou.common.Constants.SUPERVISOR;
|
|
|
|
|
|
/**
|
|
|
* 类说明:土地规划部市场人员提成计算处理器
|
|
@@ -39,7 +48,16 @@ public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport impl
|
|
|
private LoadingCache<String,BigDecimal> marketerRatioCache;
|
|
|
|
|
|
@Autowired
|
|
|
- private LoadingCache<String,BigDecimal> globalConfigCache;
|
|
|
+ private IUserTargetService userTargetService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMarketStatService marketStatService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPostCultivateService postCultivateService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
|
|
|
@Override
|
|
|
public BrokerageDetailBO predictPersonalAmount(BrokerageDetailBO bo) {
|
|
@@ -70,14 +88,8 @@ public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport impl
|
|
|
|
|
|
@Override
|
|
|
public BigDecimal aheadAmount(BigDecimal predictAmount){
|
|
|
- try {
|
|
|
- BigDecimal aheadAmount = predictAmount.multiply(globalConfigCache.get(GlobalConfigEnum.Finance.MARKETER_BROKERAGE_PERCENTAGE.getCode()).divide(HUNDRED));
|
|
|
- return aheadAmount;
|
|
|
- } catch (ExecutionException e) {
|
|
|
- log.error("获取提成缓存数据失败");
|
|
|
- return BigDecimal.ZERO;
|
|
|
- }
|
|
|
-
|
|
|
+ BigDecimal aheadAmount = predictAmount.multiply(MARKETER_AHEAD_SCALE);
|
|
|
+ return aheadAmount;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -90,14 +102,21 @@ public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport impl
|
|
|
checkItemBrokerageStatus(bo);
|
|
|
itemBrokerageDetails = leaderRatioBOSet.stream().map(x -> {
|
|
|
ItemBrokerageDetail itemBrokerageDetail = new ItemBrokerageDetail();
|
|
|
- itemBrokerageDetail.setGeneralId(bo.getGeneralId());
|
|
|
- itemBrokerageDetail.setPredictAmount(bo.getAmount().multiply(ratio.divide(HUNDRED)).multiply(x.getRatio().divide(HUNDRED)));
|
|
|
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());
|
|
|
+ itemBrokerageDetail.setBrokerageRule(x.getBrokerageRule());
|
|
|
+ BrokerageRule brokerageRuleEnum = BrokerageRule.brokerageRule(x.getBrokerageRule());
|
|
|
+ switch (brokerageRuleEnum){
|
|
|
+ case LAND_SUPERVISOR_RULE:
|
|
|
+ itemBrokerageDetail.setPredictAmount(supervisorAmount(bo, x, ratio));
|
|
|
+ break;
|
|
|
+ case LAND_MANAGER_RULE:
|
|
|
+ itemBrokerageDetail.setPredictAmount(managerAmount(bo, x));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ itemBrokerageDetail.setActualAmount(actualAmount(itemBrokerageDetail.getPredictAmount()));
|
|
|
return itemBrokerageDetail;
|
|
|
}).collect(Collectors.toSet());
|
|
|
|
|
@@ -111,6 +130,61 @@ public class LandMarketerBrokerageHandler extends BrokerageCalculateSupport impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public BigDecimal supervisorAmount(BrokerageDetailBO bo, LeaderRatioBO leaderRatioBO,BigDecimal ratio) {
|
|
|
+ //营销主管的团队提成规则 : (合同额(团队签的)*项目类型提成系数 * 40% *0.5 )+ [合同额(团队签的)*项目类型提成系数*40%*0.5 * 实发系数(取决于团队回款目标是否完成)]
|
|
|
+ BigDecimal amount = bo.getAmount()
|
|
|
+ .multiply(ratio.divide(HUNDRED))
|
|
|
+ .multiply(leaderRatioBO.getRatio().divide(HUNDRED))
|
|
|
+ .multiply(SUPERVISOR_BROKERAGE_SCALE);
|
|
|
+
|
|
|
+ Long supervisorId = leaderRatioBO.getUserId();
|
|
|
+ //团队回款目标
|
|
|
+ BigDecimal teamPaymentTarget = BigDecimal.valueOf(userTargetService.getTeamTarget(supervisorId).getPaymentTarget());
|
|
|
+ BigDecimal teamCurrentYearPayment = marketStatService.currentYearTeamPayment(supervisorId);
|
|
|
+ if (checkTeamMonthlyPayment(teamCurrentYearPayment, teamPaymentTarget)){
|
|
|
+ return amount.multiply(BigDecimal.valueOf(2L));
|
|
|
+ }
|
|
|
+ return amount;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BigDecimal managerAmount(BrokerageDetailBO bo, LeaderRatioBO leaderRatioBO) {
|
|
|
+ //部门经理的团队提成规则 :部门产值*3%+区域产值1.5% + (部门产值*浮动提成比例*0.2)+(部门产值*浮动提成比例*0.8*实发比例) 实发比例(取决于团队回款目标是否完成)
|
|
|
+ //部门产值
|
|
|
+ BigDecimal departmentAmount = bo.getAmount()
|
|
|
+ .multiply(leaderRatioBO.getRatio().divide(HUNDRED))
|
|
|
+ .multiply(new BigDecimal("2"));
|
|
|
+ BigDecimal areaAmount = BigDecimal.ZERO;
|
|
|
+ //开单人员的营销主管集合
|
|
|
+ Set<LeaderRatioBO> leaders = userService.getLeaderRatioBO(bo.getUserId()).stream().filter(x->x.getPostName().equals(SUPERVISOR)).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(leaders)){
|
|
|
+ //区域产值
|
|
|
+ areaAmount = bo.getAmount().multiply(leaderRatioBO.getRatio().divide(HUNDRED));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取发展的营销主管个数
|
|
|
+ Integer cultivateNum = postCultivateService.countCultivate(SUPERVISOR, leaderRatioBO.getUserId());
|
|
|
+ BigDecimal cultivateRate ;
|
|
|
+ if (cultivateNum<4){
|
|
|
+ cultivateRate = CULTIVATE_LOW_4;
|
|
|
+ }else if(cultivateNum>=4 && cultivateNum<=6){
|
|
|
+ cultivateRate = CULTIVATE_4_6;
|
|
|
+ }else {
|
|
|
+ cultivateRate = CULTIVATE_HIGH_6;
|
|
|
+ }
|
|
|
+ BigDecimal floatAmount = bo.getAmount().multiply(cultivateRate).multiply(MANAGER_FLOAT_RATIO_2);
|
|
|
+
|
|
|
+ //团队回款目标
|
|
|
+ BigDecimal teamPaymentTarget = BigDecimal.valueOf(userTargetService.getTeamTarget(leaderRatioBO.getUserId()).getPaymentTarget());
|
|
|
+ BigDecimal teamCurrentYearPayment = marketStatService.currentYearTeamPayment(leaderRatioBO.getUserId());
|
|
|
+ if (checkTeamMonthlyPayment(teamCurrentYearPayment, teamPaymentTarget)){
|
|
|
+ floatAmount = floatAmount.add(bo.getAmount().multiply(cultivateRate).multiply(MANAGER_FLOAT_RATIO_8));
|
|
|
+ }
|
|
|
+ return departmentAmount.add(areaAmount).add(floatAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public BigDecimal actualAmount(BigDecimal predictAmount) {
|
|
|
//客户经理的提成不存在考核,即 预计提成金额 == 实际提成金额
|
|
|
return predictAmount;
|