|
@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
|
|
import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceConfig;
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceConfig;
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceOptimizer;
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceOptimizer;
|
|
|
|
+import cn.com.ctop.performanceappraisal.mapper.PerformanceMapper;
|
|
import cn.com.ctop.performanceappraisal.mapper.PerformanceOptimizerMapper;
|
|
import cn.com.ctop.performanceappraisal.mapper.PerformanceOptimizerMapper;
|
|
import cn.com.ctop.performanceappraisal.service.IOptimizerConfigService;
|
|
import cn.com.ctop.performanceappraisal.service.IOptimizerConfigService;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceConfigService;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceConfigService;
|
|
@@ -13,18 +14,20 @@ import cn.com.ctop.performanceappraisal.service.IPerformanceOptimizerService;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceService;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceService;
|
|
import cn.com.ctop.performanceappraisal.vo.OptimizerCostDetailVO;
|
|
import cn.com.ctop.performanceappraisal.vo.OptimizerCostDetailVO;
|
|
import cn.com.ctop.performanceappraisal.vo.UserPerformanceDetailVO;
|
|
import cn.com.ctop.performanceappraisal.vo.UserPerformanceDetailVO;
|
|
|
|
+import cn.com.ctop.userefficientvideomap.entity.TransferorAccountDTO;
|
|
|
|
+import cn.com.ctop.userefficientvideomap.entity.UserDto2;
|
|
|
|
+import cn.com.ctop.userefficientvideomap.mapper.UserEfficientVideoMapMapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 优化师绩效信息
|
|
* 优化师绩效信息
|
|
@@ -34,11 +37,340 @@ import java.util.Map;
|
|
* @date 2019-12-13
|
|
* @date 2019-12-13
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@Slf4j
|
|
public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOptimizerMapper, PerformanceOptimizer> implements IPerformanceOptimizerService {
|
|
public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOptimizerMapper, PerformanceOptimizer> implements IPerformanceOptimizerService {
|
|
@Autowired
|
|
@Autowired
|
|
IPerformanceService performanceService;
|
|
IPerformanceService performanceService;
|
|
@Autowired
|
|
@Autowired
|
|
private IOptimizerConfigService optimizerConfigService;
|
|
private IOptimizerConfigService optimizerConfigService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserEfficientVideoMapMapper userEfficientVideoMapMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ PerformanceMapper performanceMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ PerformanceOptimizerMapper performanceOptimizerMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void YunyingPerformance(Integer year, Integer quarter, String startDate, String endDate){
|
|
|
|
+ //Map<String,String> map = DateUtils.quarterStartEndDate(year, quarter);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //快手运营季度绩效计算
|
|
|
|
+ public Map<String, Object> kuaishouYunyingQuarterPerformance(Integer year, Integer quarter, String startDate, String endDate){
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ //获取快手所有运营的数据
|
|
|
|
+ List<UserDto2> userList = userEfficientVideoMapMapper.getAllKuaishouYunyingDepartUserInfo();
|
|
|
|
+ Integer mediaType = 2;
|
|
|
|
+ //循环所有快手运营
|
|
|
|
+ for(UserDto2 userDto:userList){
|
|
|
|
+ //userDto.setUserId("ce2cb485afd44d0e8563b4daa5ea6fcb");
|
|
|
|
+ //String orgCode = userEfficientVideoMapMapper.getDepartIdByUserId(userDto.getUserId());
|
|
|
|
+ //华北
|
|
|
|
+ //查询当前媒体配置信息
|
|
|
|
+ OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
|
|
|
|
+
|
|
|
|
+ if (null == config) {
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_CONFIG_IS_NULL.getCode());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ //:查询当前用户截止到目前当前季度的消耗统计数据
|
|
|
|
+ List<OptimizerCostDetailVO> vos = getOptimizerTotalCostDetailGroupByUserId(mediaType + "", userDto.getUserId(), year, quarter, startDate, endDate);
|
|
|
|
+ //if (null == vos || vos.size() <= 0) {
|
|
|
|
+ // ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_PERSONNAL_DATA_IS_NULL.getCode());
|
|
|
|
+ // return result;
|
|
|
|
+ //}
|
|
|
|
+ //2: 查询媒体季度任务完成情况
|
|
|
|
+ //UserPerformanceDetailVO performanceDetailVO = getPerformanceDetailVO(mediaType, vos.get(0), config);
|
|
|
|
+ //result.put("userDetail", performanceDetailVO);
|
|
|
|
+ //ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
|
|
|
|
+
|
|
|
|
+ //获取消耗统计数据信息--该统计是按照user_allocation来统计的数据,不包含转户的情况
|
|
|
|
+ log.info(userDto.getUserId());
|
|
|
|
+ //增加转户的情况
|
|
|
|
+ //原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
|
|
|
|
+ //2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
|
|
|
|
+
|
|
|
|
+ //原则b:1.找出改运营手下所有账户,循环每一个账户,然后进行转户判断
|
|
|
|
+ //2.将该账户下所有转户信息拉取出来,去除受让时间小于季度开始时间 以及 转让时间大于季度结束时间的条目(sql去掉),得到该账户所有信息
|
|
|
|
+ //3. 创建userMap,根据userId获取自己季度内的各时间段
|
|
|
|
+ BigDecimal totalRoyal = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal totalRoyalty = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal totalCost = BigDecimal.ZERO;
|
|
|
|
+ if(vos.size() != 0){
|
|
|
|
+ OptimizerCostDetailVO vo = vos.get(0);
|
|
|
|
+ //循环accountId
|
|
|
|
+ List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
|
|
|
|
+ Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ for(int i=0; i<accountList.size();i++){
|
|
|
|
+ List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
|
|
|
|
+
|
|
|
|
+ if(transferorAccountDTOList.size() == 0){
|
|
|
|
+ accountRangeMap.put(accountList.get(i),null);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> DateMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ for(int j=0; j<transferorAccountDTOList.size(); j++){
|
|
|
|
+ String transferor = transferorAccountDTOList.get(j).getTransferor();
|
|
|
|
+ //String assignee = transferorAccountDTOList.get(j).getAssignee();
|
|
|
|
+ //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
|
|
|
|
+ if( transferor.equals(userDto.getUserId()) ){
|
|
|
|
+ if (j==0){
|
|
|
|
+ DateMap.put("startDate", startDate);
|
|
|
|
+ }else {
|
|
|
|
+ DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
|
|
|
|
+ }
|
|
|
|
+ DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //判断:如果转让人不是本人,受让人也不是,则跳过
|
|
|
|
+ if(DateMap.size() == 0 && j != (transferorAccountDTOList.size()-1) ){ //!assignee.equals(userDto.getUserId())
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (accountRangeMap.get(accountList.get(i)) != null){
|
|
|
|
+ accountRangeMap.get(accountList.get(i)).add(DateMap);
|
|
|
|
+
|
|
|
|
+ if(j == (transferorAccountDTOList.size()-1)){
|
|
|
|
+ DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
|
+ DateMap.put("endDate", endDate);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ List<Map<String, String>> userAccountList = new ArrayList<>();
|
|
|
|
+ if(DateMap.size()!= 0 ){
|
|
|
|
+ userAccountList.add(DateMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> DateMap2 = new HashMap<>();
|
|
|
|
+ if(j == (transferorAccountDTOList.size()-1)){
|
|
|
|
+ DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
|
+ DateMap2.put("endDate", endDate);
|
|
|
|
+ userAccountList.add(DateMap2);
|
|
|
|
+ }
|
|
|
|
+ accountRangeMap.put(accountList.get(i), userAccountList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
|
|
|
|
+ String mapKey = entry.getKey();
|
|
|
|
+ List<Map<String, String>> mapValue = entry.getValue();
|
|
|
|
+ if (mapValue == null){
|
|
|
|
+ totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
|
|
|
|
+ }else{
|
|
|
|
+ for (Map<String, String> map:mapValue){
|
|
|
|
+ totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //BigDecimal totalCost = vo.getTotalCost();
|
|
|
|
+ totalCost = totalRoyal;//新增
|
|
|
|
+ //个人季度任务
|
|
|
|
+ BigDecimal personalTask = config.getPersonalTask();
|
|
|
|
+ //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
|
|
|
|
+
|
|
|
|
+ if(!userDto.getRoleCode().equals("operationAssistant")){
|
|
|
|
+ if (totalCost.compareTo(personalTask) > 0 ) {
|
|
|
|
+ totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ } else {
|
|
|
|
+ totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //运营绩效数据入库
|
|
|
|
+ PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
|
|
|
|
+ performanceOptimizer.setAppType(mediaType);
|
|
|
|
+ performanceOptimizer.setQuarter(quarter + "");
|
|
|
|
+ performanceOptimizer.setYear(year + "");
|
|
|
|
+ performanceOptimizer.setRealname(userDto.getRealname());
|
|
|
|
+ performanceOptimizer.setTotalCost(totalCost);
|
|
|
|
+ performanceOptimizer.setTotalRoyalty(totalRoyalty);
|
|
|
|
+ performanceOptimizer.setUserId(userDto.getUserId());
|
|
|
|
+ performanceOptimizerMapper.insert(performanceOptimizer);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //头条运营季度绩效计算
|
|
|
|
+ public void toutiaoYunyingQuarterPerformance(Integer year, Integer quarter, String startDate, String endDate){
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ //获取快手所有运营的数据
|
|
|
|
+ List<UserDto2> userList = userEfficientVideoMapMapper.getAllToutiaoYunyingDepartUserInfo();
|
|
|
|
+ Integer mediaType = 1;
|
|
|
|
+ //循环所有toutiao运营
|
|
|
|
+ for(UserDto2 userDto:userList){
|
|
|
|
+ //查询当前媒体配置信息
|
|
|
|
+ OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
|
|
|
|
+
|
|
|
|
+ if (null == config) {
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_CONFIG_IS_NULL.getCode());
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info(userDto.getUserId());
|
|
|
|
+ //增加转户的情况
|
|
|
|
+ //原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
|
|
|
|
+ //2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
|
|
|
|
+
|
|
|
|
+ //原则b:1.找出改运营手下所有账户,循环每一个账户,然后进行转户判断
|
|
|
|
+ //2.将该账户下所有转户信息拉取出来,去除受让时间小于季度开始时间 以及 转让时间大于季度结束时间的条目(sql去掉),得到该账户所有信息
|
|
|
|
+ //3. 创建userMap,根据userId获取自己季度内的各时间段
|
|
|
|
+ BigDecimal totalRoyal = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal totalRoyalty = BigDecimal.ZERO;
|
|
|
|
+ BigDecimal totalCost = BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+ //循环accountId
|
|
|
|
+ List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
|
|
|
|
+ Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
|
|
|
|
+ if(accountList.size()!=0){
|
|
|
|
+ for(int i=0; i<accountList.size();i++){
|
|
|
|
+ List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
|
|
|
|
+
|
|
|
|
+ if(transferorAccountDTOList.size() == 0){
|
|
|
|
+ accountRangeMap.put(accountList.get(i),null);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> DateMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ for(int j=0; j<transferorAccountDTOList.size(); j++){
|
|
|
|
+ String transferor = transferorAccountDTOList.get(j).getTransferor();
|
|
|
|
+ //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
|
|
|
|
+ if( transferor.equals(userDto.getUserId()) ){
|
|
|
|
+ if (j==0){
|
|
|
|
+ DateMap.put("startDate", startDate);
|
|
|
|
+ }else {
|
|
|
|
+ DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
|
|
|
|
+ }
|
|
|
|
+ DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //判断:如果转让人不是本人,受让人也不是,则跳过
|
|
|
|
+ if(DateMap.size() == 0 && j != (transferorAccountDTOList.size()-1) ){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (accountRangeMap.get(accountList.get(i)) != null){
|
|
|
|
+ accountRangeMap.get(accountList.get(i)).add(DateMap);
|
|
|
|
+
|
|
|
|
+ if(j == (transferorAccountDTOList.size()-1)){
|
|
|
|
+ DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
|
+ DateMap.put("endDate", endDate);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ List<Map<String, String>> userAccountList = new ArrayList<>();
|
|
|
|
+ if(DateMap.size()!= 0 ){
|
|
|
|
+ userAccountList.add(DateMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> DateMap2 = new HashMap<>();
|
|
|
|
+ if(j == (transferorAccountDTOList.size()-1)){
|
|
|
|
+ DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
|
+ DateMap2.put("endDate", endDate);
|
|
|
|
+ userAccountList.add(DateMap2);
|
|
|
|
+ }
|
|
|
|
+ accountRangeMap.put(accountList.get(i), userAccountList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
|
|
|
|
+ String mapKey = entry.getKey();
|
|
|
|
+ List<Map<String, String>> mapValue = entry.getValue();
|
|
|
|
+ if (mapValue == null){
|
|
|
|
+ totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO : userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate) );
|
|
|
|
+ }else{
|
|
|
|
+ for (Map<String, String> map:mapValue){
|
|
|
|
+ totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ totalCost = totalRoyal;//新增
|
|
|
|
+ //个人季度任务
|
|
|
|
+ BigDecimal personalTask = config.getPersonalTask();
|
|
|
|
+ //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
|
|
|
|
+
|
|
|
|
+ if(!userDto.getRoleCode().equals("operationAssistant")){
|
|
|
|
+ if (totalCost.compareTo(personalTask) > 0 ) {
|
|
|
|
+ totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ } else {
|
|
|
|
+ totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //运营绩效数据入库
|
|
|
|
+ PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
|
|
|
|
+ performanceOptimizer.setAppType(mediaType);
|
|
|
|
+ performanceOptimizer.setQuarter(quarter + "");
|
|
|
|
+ performanceOptimizer.setYear(year + "");
|
|
|
|
+ performanceOptimizer.setRealname(userDto.getRealname());
|
|
|
|
+ performanceOptimizer.setTotalCost(totalCost);
|
|
|
|
+ performanceOptimizer.setTotalRoyalty(totalRoyalty);
|
|
|
|
+ performanceOptimizer.setUserId(userDto.getUserId());
|
|
|
|
+ performanceOptimizerMapper.insert(performanceOptimizer);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //快手运营leader绩效计算
|
|
|
|
+ public void kuaishouYunyingLeaderQuarterPerformance(Integer year, Integer quarter){
|
|
|
|
+ Integer mediaType = 2;
|
|
|
|
+ //获取快手组下所有运营组长信息列表
|
|
|
|
+ List<UserDto2> yunyingLeaderList = userEfficientVideoMapMapper.getKuaishouYunyingLeaderUserInfo();
|
|
|
|
+ for(UserDto2 userDto2:yunyingLeaderList){
|
|
|
|
+ BigDecimal royalty = BigDecimal.ZERO;
|
|
|
|
+ List<UserDto2> userList = userEfficientVideoMapMapper.getYunyingLeaderMember(userDto2.getDepId());
|
|
|
|
+
|
|
|
|
+ for (UserDto2 user:userList){
|
|
|
|
+ BigDecimal userRoality = userEfficientVideoMapMapper.getYunyingRoyalty(user.getUserId(), year, quarter);
|
|
|
|
+ if (userRoality == null){
|
|
|
|
+ userRoality= BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
+ royalty = royalty.add(userRoality);
|
|
|
|
+ }
|
|
|
|
+ //运营leader绩效数据入库
|
|
|
|
+ PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
|
|
|
|
+ performanceOptimizer.setAppType(mediaType);
|
|
|
|
+ performanceOptimizer.setQuarter(quarter + "");
|
|
|
|
+ performanceOptimizer.setYear(year + "");
|
|
|
|
+ performanceOptimizer.setRealname(userDto2.getRealname());
|
|
|
|
+ performanceOptimizer.setTotalCost(royalty);
|
|
|
|
+ performanceOptimizer.setTotalRoyalty( royalty.multiply(new BigDecimal("0.2")) );
|
|
|
|
+ performanceOptimizer.setUserId(userDto2.getUserId());
|
|
|
|
+ performanceOptimizerMapper.insert(performanceOptimizer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //TODO 头条运营leader绩效计算
|
|
|
|
+ public void toutiaoYunyingLeaderQuarterPerformance(){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private List<OptimizerCostDetailVO> getOptimizerTotalCostDetailGroupByUserId(String mediaType, String userId, Integer year, Integer quarter, String startDate, String endDate) {
|
|
|
|
+ if (null != mediaType && mediaType.equals(CtopAdConstant.PLATFORM_TYPE_KUAISHOU)) {
|
|
|
|
+ //快手
|
|
|
|
+ return performanceMapper.getKuaishouOptimizerTotalCostDetailGroupByUserId(startDate, endDate, year+"", quarter+"", userId, null, null);
|
|
|
|
+ } else {
|
|
|
|
+ //头条
|
|
|
|
+ return performanceMapper.getBytedanceOptimizerTotalCostDetailGroupByUserId(startDate, endDate, year+"", quarter+"", userId, null, null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> getPerformanceDetail(String mediaType, Integer pageNo, Integer pageSize) {
|
|
public Map<String, Object> getPerformanceDetail(String mediaType, Integer pageNo, Integer pageSize) {
|
|
@@ -205,6 +537,7 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
private UserPerformanceDetailVO getPerformanceDetailVO(String appType, OptimizerCostDetailVO kuaishouCostVo, OptimizerConfig kuaishouConfig) {
|
|
private UserPerformanceDetailVO getPerformanceDetailVO(String appType, OptimizerCostDetailVO kuaishouCostVo, OptimizerConfig kuaishouConfig) {
|
|
OptimizerCostDetailVO totalCostVo = performanceService.getOptimizerTotalCost(appType);
|
|
OptimizerCostDetailVO totalCostVo = performanceService.getOptimizerTotalCost(appType);
|
|
UserPerformanceDetailVO performanceDetailVO = new UserPerformanceDetailVO();
|
|
UserPerformanceDetailVO performanceDetailVO = new UserPerformanceDetailVO();
|
|
|
|
+ //计算绩效
|
|
kuaishouCostVo.setTotalRoyalty(getTotalRoyalty(kuaishouConfig, kuaishouCostVo, totalCostVo));
|
|
kuaishouCostVo.setTotalRoyalty(getTotalRoyalty(kuaishouConfig, kuaishouCostVo, totalCostVo));
|
|
performanceDetailVO.setRealName(kuaishouCostVo.getRealName());
|
|
performanceDetailVO.setRealName(kuaishouCostVo.getRealName());
|
|
performanceDetailVO.setTotalPersonalCost(kuaishouCostVo.getTotalCost());
|
|
performanceDetailVO.setTotalPersonalCost(kuaishouCostVo.getTotalCost());
|
|
@@ -275,16 +608,17 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
//个人季度任务
|
|
//个人季度任务
|
|
BigDecimal personalTask = config.getPersonalTask();
|
|
BigDecimal personalTask = config.getPersonalTask();
|
|
//媒体季度任务
|
|
//媒体季度任务
|
|
- BigDecimal mediaTask = config.getMediaTask();
|
|
|
|
|
|
+ //BigDecimal mediaTask = config.getMediaTask();
|
|
//个人任务未完成
|
|
//个人任务未完成
|
|
- if (totalCost.compareTo(personalTask) < 0) {
|
|
|
|
- return royalty;
|
|
|
|
- }
|
|
|
|
- //季度任务未完成
|
|
|
|
- if (quarterCost.getTotalCost().compareTo(mediaTask) < 0) {
|
|
|
|
- return totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
- }
|
|
|
|
|
|
+ //if (totalCost.compareTo(personalTask) < 0) {
|
|
|
|
+ // return royalty;
|
|
|
|
+ //}
|
|
|
|
+ //季度任务不在普通运营的业务范围内
|
|
|
|
+ //if (quarterCost.getTotalCost().compareTo(mediaTask) < 0) {
|
|
|
|
+ // return totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ //}
|
|
PerformanceConfig performanceConfig = performanceConfigService.getNowConfig();
|
|
PerformanceConfig performanceConfig = performanceConfigService.getNowConfig();
|
|
|
|
+ //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
|
|
if (null != performanceConfig && performanceConfig.getMediaTaskRaise() == 1) {
|
|
if (null != performanceConfig && performanceConfig.getMediaTaskRaise() == 1) {
|
|
return totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
return totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
} else {
|
|
} else {
|