|
@@ -3,6 +3,8 @@ package cn.com.ctop.performanceappraisal.service.impl;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
|
import cn.com.ctop.common.module.utils.StatusCode;
|
|
|
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
|
|
|
+import cn.com.ctop.performanceaccount.mapper.PerformanceAccountMapper;
|
|
|
import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
|
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceConfig;
|
|
|
import cn.com.ctop.performanceappraisal.entity.PerformanceOptimizer;
|
|
@@ -21,13 +23,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
-import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 优化师绩效信息
|
|
@@ -46,9 +50,11 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
|
@Autowired
|
|
|
private UserEfficientVideoMapMapper userEfficientVideoMapMapper;
|
|
|
@Autowired
|
|
|
- PerformanceMapper performanceMapper;
|
|
|
+ private PerformanceMapper performanceMapper;
|
|
|
@Autowired
|
|
|
- PerformanceOptimizerMapper performanceOptimizerMapper;
|
|
|
+ private PerformanceOptimizerMapper performanceOptimizerMapper;
|
|
|
+ @Autowired
|
|
|
+ private PerformanceAccountMapper performanceAccountMapper;
|
|
|
|
|
|
|
|
|
public void YunyingPerformance(Integer year, Integer quarter, String startDate, String endDate){
|
|
@@ -64,10 +70,10 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
|
public Map<String, Object> kuaishouYunyingQuarterPerformance(Integer year, Integer quarter, String startDate, String endDate){
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//获取快手所有运营的数据
|
|
|
- List<UserDto2> userList = userEfficientVideoMapMapper.getAllKuaishouYunyingDepartUserInfo();
|
|
|
+ //List<UserDto2> userList = userEfficientVideoMapMapper.getAllKuaishouYunyingDepartUserInfo();
|
|
|
Integer mediaType = 2;
|
|
|
//循环所有快手运营
|
|
|
- for(UserDto2 userDto:userList){
|
|
|
+ //for(UserDto2 userDto:userList){
|
|
|
//userDto.setUserId("ce2cb485afd44d0e8563b4daa5ea6fcb");
|
|
|
//String orgCode = userEfficientVideoMapMapper.getDepartIdByUserId(userDto.getUserId());
|
|
|
//华北
|
|
@@ -78,8 +84,7 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
|
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;
|
|
@@ -90,7 +95,7 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
|
//ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
|
|
|
|
|
|
//获取消耗统计数据信息--该统计是按照user_allocation来统计的数据,不包含转户的情况
|
|
|
- log.info(userDto.getUserId());
|
|
|
+ //log.info(userDto.getUserId());
|
|
|
//增加转户的情况
|
|
|
//原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
|
|
|
//2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
|
|
@@ -98,229 +103,609 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
|
|
|
//原则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;
|
|
|
+ //:查询当前用户截止到目前当前季度的消耗统计数据
|
|
|
+ //List<OptimizerCostDetailVO> vos = getOptimizerTotalCostDetailGroupByUserId(mediaType + "", userDto.getUserId(), year, quarter, startDate, endDate);
|
|
|
+ //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);
|
|
|
+
|
|
|
+
|
|
|
+ ///////////////方法2
|
|
|
+ //1。获取所有快手账户
|
|
|
+ //2。循环每个账户,然后查找每个账户下在本季度是否有转户的情况存在;
|
|
|
+
|
|
|
+ //创建map,Map<String人,Map<String账户,时间段List<Map<String开始时间,String结束时间>>>>
|
|
|
+ Map<String,Map<String,List<Map<String,String>>>> userAccountMap = new HashMap<>();
|
|
|
+
|
|
|
+ //获取所有快手的账户
|
|
|
+ List<String> accountList = userEfficientVideoMapMapper.getAccountListByMediaId(mediaType);
|
|
|
+ //循环所有账户
|
|
|
+ for(String account:accountList){
|
|
|
+ String userId = userEfficientVideoMapMapper.getAccountUserId(account);
|
|
|
+ //判断本季度内是否有转户情况存在
|
|
|
+ List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(account, startDate, endDate);
|
|
|
+
|
|
|
+ //如果此账户没有转户情况发生,则存入userAccountMap当中
|
|
|
+ if(transferorAccountDTOList.size() == 0){
|
|
|
+ if(userAccountMap.get(userId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(userId, accountMap);
|
|
|
+ }else{
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = userAccountMap.get(userId);
|
|
|
+ //如果此账户本季度没有转户行为,直接创建账户即可,不用再做判断
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
}
|
|
|
- Map<String, String> DateMap = new HashMap<>();
|
|
|
+ }else{//如果此账户有转户情况
|
|
|
|
|
|
+ //循环所有转户信息
|
|
|
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());
|
|
|
+ if ( j==0 ){
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
|
|
|
+ String transferorUserId = transferorAccountDTOList.get(j).getTransferor();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(transferorUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(transferorUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+
|
|
|
+ if( userAccountMap.get(transferorUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(transferorUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(transferorUserId).get(account);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ }
|
|
|
}
|
|
|
- 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);
|
|
|
+ if(j == transferorAccountDTOList.size()-1){
|
|
|
+ Map<String,String> dateMap2 = new HashMap<>();
|
|
|
+ dateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
+ dateMap2.put("endDate",endDate);
|
|
|
+ String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(assigneeUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+ if( userAccountMap.get(assigneeUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}else{
|
|
|
- List<Map<String, String>> userAccountList = new ArrayList<>();
|
|
|
- if(DateMap.size()!= 0 ){
|
|
|
- userAccountList.add(DateMap);
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
+ if( j == (transferorAccountDTOList.size()-1) ){
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
+ }else{
|
|
|
+ dateMap.put("endDate",transferorAccountDTOList.get(j+1).getTransferorDate());
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
+ String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(assigneeUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+
|
|
|
+ if( userAccountMap.get(assigneeUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- 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));
|
|
|
}
|
|
|
+
|
|
|
+ } //转户列表循环结束
|
|
|
+ } //else判断
|
|
|
+
|
|
|
+ }//账户循环结束
|
|
|
+
|
|
|
+ for(Map.Entry<String,Map<String,List<Map<String,String>>>> entry : userAccountMap.entrySet()){
|
|
|
+ String userAccountKey = entry.getKey();
|
|
|
+ Map<String,List<Map<String,String>>> userAccountValue = entry.getValue();
|
|
|
+ BigDecimal totalCharge = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalPerformance = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for(Map.Entry<String,List<Map<String,String>>> entryAccount: userAccountValue.entrySet()){
|
|
|
+ String acountKey = entryAccount.getKey();
|
|
|
+ List<Map<String,String>> accountValue = entryAccount.getValue();
|
|
|
+
|
|
|
+ for(Map<String,String> dateMap:accountValue) {
|
|
|
+ //当前消耗
|
|
|
+ BigDecimal charge = userEfficientVideoMapMapper.getAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate")) == null ? BigDecimal.ZERO : userEfficientVideoMapMapper.getAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate"));
|
|
|
+ //此人总消耗
|
|
|
+ totalCharge = totalCharge.add(charge);
|
|
|
+
|
|
|
+ PerformanceAccount performanceAccount = new PerformanceAccount();
|
|
|
+ performanceAccount.setAccountId(Long.parseLong(acountKey));
|
|
|
+ performanceAccount.setCost(charge);
|
|
|
+ performanceAccount.setYear(year);
|
|
|
+ performanceAccount.setQuarter(quarter);
|
|
|
+ performanceAccount.setMediaType(mediaType);
|
|
|
+ performanceAccount.setUserId(userAccountKey);
|
|
|
+ performanceAccount.setStartDate(dateMap.get("startDate"));
|
|
|
+ performanceAccount.setEndDate(dateMap.get("endDate"));
|
|
|
+ performanceAccountMapper.insert(performanceAccount);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //BigDecimal totalCost = vo.getTotalCost();
|
|
|
- totalCost = totalRoyal;//新增
|
|
|
+ //运营绩效数据入库
|
|
|
+ PerformanceOptimizer performance = new PerformanceOptimizer();
|
|
|
+ performance.setAppType(mediaType);
|
|
|
+ performance.setQuarter(quarter + "");
|
|
|
+ performance.setYear(year + "");
|
|
|
+ performance.setRealname(userEfficientVideoMapMapper.getrealnameByUserId(userAccountKey));
|
|
|
+ performance.setUserId(userAccountKey);
|
|
|
+ performance.setTotalCost(totalCharge);
|
|
|
+
|
|
|
//个人季度任务
|
|
|
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);
|
|
|
+ String roleCode = userEfficientVideoMapMapper.getRoleCodeByUserId(userAccountKey);
|
|
|
+ if(!roleCode.equals("operationAssistant")){
|
|
|
+ if (totalCharge.compareTo(personalTask) > 0 ) {
|
|
|
+ totalPerformance = totalCharge.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);
|
|
|
+ totalPerformance = totalCharge.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
}
|
|
|
+ performance.setTotalRoyalty(totalPerformance);
|
|
|
+ performanceOptimizerMapper.insert(performance);
|
|
|
}
|
|
|
|
|
|
- //运营绩效数据入库
|
|
|
- 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);
|
|
|
+ //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);
|
|
|
+ //}
|
|
|
|
|
|
- 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());
|
|
|
+ //方法2
|
|
|
+ //1。获取所有快手账户
|
|
|
+ //2。循环每个账户,然后查找每个账户下在本季度是否有转户的情况存在;
|
|
|
+ Integer mediaType = 1;
|
|
|
+ //创建map,Map<String人,Map<String账户,时间段List<Map<String开始时间,String结束时间>>>>
|
|
|
+ Map<String,Map<String,List<Map<String,String>>>> userAccountMap = new HashMap<>();
|
|
|
+ OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
|
|
|
+ //获取所有头条的账户
|
|
|
+ List<String> accountList = userEfficientVideoMapMapper.getAccountListByMediaId(mediaType);
|
|
|
+ //循环所有账户
|
|
|
+ for(String account:accountList){
|
|
|
+ String userId = userEfficientVideoMapMapper.getAccountUserId(account);
|
|
|
+ //判断本季度内是否有转户情况存在
|
|
|
+ List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(account, startDate, endDate);
|
|
|
+
|
|
|
+ //如果此账户没有转户情况发生,则存入userAccountMap当中
|
|
|
+ if(transferorAccountDTOList.size() == 0){
|
|
|
+ if(userAccountMap.get(userId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(userId, accountMap);
|
|
|
+ }else{
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = userAccountMap.get(userId);
|
|
|
+ //如果此账户本季度没有转户行为,直接创建账户即可,不用再做判断
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ }
|
|
|
+ }else{//如果此账户有转户情况
|
|
|
+
|
|
|
+ //循环所有转户信息
|
|
|
+ for(int j=0; j<transferorAccountDTOList.size(); j++){
|
|
|
+ if ( j==0 ){
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", startDate);
|
|
|
+ dateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
|
|
|
+ String transferorUserId = transferorAccountDTOList.get(j).getTransferor();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(transferorUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(transferorUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+
|
|
|
+ if( userAccountMap.get(transferorUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(transferorUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(transferorUserId).get(account);
|
|
|
+ dateList.add(dateMap);
|
|
|
}
|
|
|
- DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
|
|
|
}
|
|
|
|
|
|
- //判断:如果转让人不是本人,受让人也不是,则跳过
|
|
|
- if(DateMap.size() == 0 && j != (transferorAccountDTOList.size()-1) ){
|
|
|
- continue;
|
|
|
+ if(j == transferorAccountDTOList.size()-1){
|
|
|
+ Map<String,String> dateMap2 = new HashMap<>();
|
|
|
+ dateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
+ dateMap2.put("endDate",endDate);
|
|
|
+ String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(assigneeUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+ if( userAccountMap.get(assigneeUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
|
|
|
+ dateList.add(dateMap2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- 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{
|
|
|
+ Map<String,String> dateMap = new HashMap<>();
|
|
|
+ dateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
|
|
|
+ if( j == (transferorAccountDTOList.size()-1) ){
|
|
|
+ dateMap.put("endDate",endDate);
|
|
|
}else{
|
|
|
- List<Map<String, String>> userAccountList = new ArrayList<>();
|
|
|
- if(DateMap.size()!= 0 ){
|
|
|
- userAccountList.add(DateMap);
|
|
|
- }
|
|
|
+ dateMap.put("endDate",transferorAccountDTOList.get(j+1).getTransferorDate());
|
|
|
+ }
|
|
|
|
|
|
- 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);
|
|
|
+ String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
|
|
|
+ //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
|
|
|
+ if(userAccountMap.get(assigneeUserId) == null){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{//如果已经有了这个userId,则需要判断是否有此账户
|
|
|
+
|
|
|
+ if( userAccountMap.get(assigneeUserId).get(account)==null ){
|
|
|
+ Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
|
|
|
+ List<Map<String,String>> dateList = new ArrayList<>();
|
|
|
+ dateList.add(dateMap);
|
|
|
+ accountMap.put(account, dateList);
|
|
|
+ userAccountMap.put(assigneeUserId, accountMap);
|
|
|
+ }else{
|
|
|
+ List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
|
|
|
+ dateList.add(dateMap);
|
|
|
}
|
|
|
- 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);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ } //转户列表循环结束
|
|
|
+ } //else判断
|
|
|
+
|
|
|
+ }//账户循环结束
|
|
|
+
|
|
|
+ for(Map.Entry<String,Map<String,List<Map<String,String>>>> entry : userAccountMap.entrySet()){
|
|
|
+ String userAccountKey = entry.getKey();
|
|
|
+ Map<String,List<Map<String,String>>> userAccountValue = entry.getValue();
|
|
|
+ BigDecimal totalCharge = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalPerformance = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for(Map.Entry<String,List<Map<String,String>>> entryAccount: userAccountValue.entrySet()){
|
|
|
+ String acountKey = entryAccount.getKey();
|
|
|
+ List<Map<String,String>> accountValue = entryAccount.getValue();
|
|
|
+
|
|
|
+ for(Map<String,String> dateMap:accountValue) {
|
|
|
+ //当前消耗
|
|
|
+ BigDecimal charge = userEfficientVideoMapMapper.getToutiaoAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate")) == null ? BigDecimal.ZERO : userEfficientVideoMapMapper.getToutiaoAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate"));
|
|
|
+ //此人总消耗
|
|
|
+ totalCharge = totalCharge.add(charge);
|
|
|
+
|
|
|
+ PerformanceAccount performanceAccount = new PerformanceAccount();
|
|
|
+ performanceAccount.setAccountId(Long.parseLong(acountKey));
|
|
|
+ performanceAccount.setCost(charge);
|
|
|
+ performanceAccount.setYear(year);
|
|
|
+ performanceAccount.setQuarter(quarter);
|
|
|
+ performanceAccount.setMediaType(mediaType);
|
|
|
+ performanceAccount.setUserId(userAccountKey);
|
|
|
+ performanceAccount.setStartDate(dateMap.get("startDate"));
|
|
|
+ performanceAccount.setEndDate(dateMap.get("endDate"));
|
|
|
+ performanceAccountMapper.insert(performanceAccount);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//运营绩效数据入库
|
|
|
- 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);
|
|
|
+ PerformanceOptimizer performance = new PerformanceOptimizer();
|
|
|
+ performance.setAppType(mediaType);
|
|
|
+ performance.setQuarter(quarter + "");
|
|
|
+ performance.setYear(year + "");
|
|
|
+ performance.setRealname(userEfficientVideoMapMapper.getrealnameByUserId(userAccountKey));
|
|
|
+ performance.setUserId(userAccountKey);
|
|
|
+ performance.setTotalCost(totalCharge);
|
|
|
+
|
|
|
+ //个人季度任务
|
|
|
+ BigDecimal personalTask = config.getPersonalTask();
|
|
|
+ //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
|
|
|
+ String roleCode = userEfficientVideoMapMapper.getRoleCodeByUserId(userAccountKey);
|
|
|
+ if(!roleCode.equals("operationAssistant")){
|
|
|
+ if (totalCharge.compareTo(personalTask) > 0 ) {
|
|
|
+ totalPerformance = totalCharge.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ totalPerformance = totalCharge.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ performance.setTotalRoyalty(totalPerformance);
|
|
|
+ performanceOptimizerMapper.insert(performance);
|
|
|
}
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|