|
@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.achievements.service.impl;
|
|
|
import cn.com.ctop.common.module.achievements.mapper.DesignerMapper;
|
|
|
import cn.com.ctop.common.module.achievements.service.IDesignerService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.function.ToDoubleFunction;
|
|
@@ -42,7 +45,7 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
private ToDoubleFunction<JSONObject> getJSONObject;
|
|
|
|
|
|
@Override
|
|
|
- public Result getDesignBasicsInfoList(String userId,int pageNum,int pageSize) {
|
|
|
+ public PageInfo<JSONObject> getDesignBasicsInfoList(String userId,int pageNum,int pageSize) {
|
|
|
String departName = null;
|
|
|
Set<String> userIdList = new HashSet<>();
|
|
|
//查询用户角色
|
|
@@ -59,7 +62,8 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
|
List<JSONObject> list = designerMapper.getDesignerUserInfo(departName,userIdList);
|
|
|
PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
|
|
|
- return Result.successMsg("设计基础信息查询成功",pageInfo);
|
|
|
+
|
|
|
+ return pageInfo;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -72,7 +76,7 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
* @author: zianY
|
|
|
*/
|
|
|
@Override
|
|
|
- public Result getHotVideoData(String userId) {
|
|
|
+ public List<Map<String,Object>> getHotVideoData(String userId,String yearTime,String monthTime) {
|
|
|
String roleName = null;
|
|
|
//查询用户角色
|
|
|
String roleCode = roleService.getRoleCodeByUserId(userId);
|
|
@@ -83,62 +87,66 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
}else if (roleCode.contains("plan")){
|
|
|
roleName = "plan";
|
|
|
}else {
|
|
|
- return Result.successMsg("请核实人员["+userId+"]角色信息。",userId);
|
|
|
+ roleName = "all";
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//取当前时间的季度的月份
|
|
|
- Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
|
|
|
- String[] quarterStr = (String[])timeMap.get("quarter");
|
|
|
+ List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
|
|
|
+
|
|
|
+
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
List<Map<String,Object>> byteDanceList = new ArrayList<>();
|
|
|
Map<String,Object> bytedanceMap = new HashMap<>();
|
|
|
List<Map<String,Object>> kuaishouList = new ArrayList<>();
|
|
|
Map<String,Object> kuaishouMap = new HashMap<>();
|
|
|
- for (String month : quarterStr ){
|
|
|
+ for (Map<String,Integer> month : timeMap ){
|
|
|
//头条
|
|
|
- JSONObject bytedanceJson = designerMapper.getHotVideoData(userId,roleName,"1",timeMap.get("yearTime")+"",month);
|
|
|
+ JSONObject bytedanceJson = designerMapper.getHotVideoData(userId,roleName,1,month.get("startTime"),month.get("endTime"));
|
|
|
bytedanceJson.put("monthTime",month);
|
|
|
byteDanceList.add(bytedanceJson);
|
|
|
bytedanceMap.put("byteDance",byteDanceList);
|
|
|
//快手
|
|
|
- JSONObject kuaishouJson = designerMapper.getHotVideoData(userId,roleName,"2",timeMap.get("yearTime")+"",month);
|
|
|
+ JSONObject kuaishouJson = designerMapper.getHotVideoData(userId,roleName,2,month.get("startTime"),month.get("endTime"));
|
|
|
kuaishouJson.put("monthTime",month);
|
|
|
kuaishouList.add(kuaishouJson);
|
|
|
kuaishouMap.put("kuaishou",kuaishouList);
|
|
|
}
|
|
|
resultList.add(bytedanceMap);
|
|
|
resultList.add(kuaishouMap);
|
|
|
- return Result.successMsg("设计基础信息查询成功",resultList);
|
|
|
+ return resultList;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Result getDesignerAchievements(String userId) {
|
|
|
- //取当前时间的季度的月份
|
|
|
- Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
|
|
|
- String[] quarterStr = (String[])timeMap.get("quarter");
|
|
|
+ public Map<String,Object> getDesignerAchievements(String userId,String yearTime,String monthTime) {
|
|
|
+
|
|
|
+ //取当前时间的季度的月份
|
|
|
+ List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
|
|
|
+
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
List<Map<String,Object>> byteDanceList = new ArrayList<>();
|
|
|
List<Map<String,Object>> kuaishouList = new ArrayList<>();
|
|
|
|
|
|
- for (String month : quarterStr ){
|
|
|
+ for (Map<String,Integer> month : timeMap ){
|
|
|
Map<String,Object> bytedanceMap = new HashMap<>();
|
|
|
Map<String,Object> kuaishouMap = new HashMap<>();
|
|
|
//头条
|
|
|
- List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId,timeMap.get("yearTime")+"",month);
|
|
|
+ List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId,month.get("startTime"),month.get("endTime"));
|
|
|
bytedanceMap.put("monthTime",month );
|
|
|
- bytedanceMap.put("yearTime",timeMap.get("yearTime")+"" );
|
|
|
+ bytedanceMap.put("yearTime",yearTime);
|
|
|
bytedanceMap.put("byteDance",bytedanceJson);
|
|
|
byteDanceList.add(bytedanceMap);
|
|
|
//快手
|
|
|
- List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsBytedance(userId,timeMap.get("yearTime")+"",month);
|
|
|
+ List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId,month.get("startTime"),month.get("endTime"));
|
|
|
kuaishouMap.put("monthTime",month );
|
|
|
- bytedanceMap.put("yearTime",timeMap.get("yearTime")+"" );
|
|
|
+ bytedanceMap.put("yearTime",yearTime);
|
|
|
kuaishouMap.put("kuaiShou",kuaishouJson);
|
|
|
kuaishouList.add(kuaishouMap);
|
|
|
}
|
|
|
resultMap.put("byteDanceData",byteDanceList);
|
|
|
resultMap.put("kuaiShouData",kuaishouList);
|
|
|
- return Result.successMsg("设计绩效信息查询成功",resultMap);
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -151,9 +159,9 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
* createTime 员工入职时间
|
|
|
* @return
|
|
|
*/
|
|
|
- public Double getMaterialCost(String frozenTime, String createTime){
|
|
|
+ public Double getMaterialCost(String frozenTime, String createTime,int yearTime,int monthTime){
|
|
|
|
|
|
- //String frozenTime = "";
|
|
|
+//String frozenTime = "";
|
|
|
//String createTime = "2022-11-02 12:23:23";
|
|
|
|
|
|
//绩效 = 在职月份 * 80w 额度
|
|
@@ -163,36 +171,79 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
/**
|
|
|
* 人员离职
|
|
|
*/
|
|
|
- if (!Check.isNull(frozenTime)){
|
|
|
- //离职时间 是否在当前季度
|
|
|
- if (DateUtils.isThisQuarter(frozenTime)){
|
|
|
- Map<String,Object> map = DateUtils.getCurrentQuarterMonths(frozenTime);
|
|
|
- //月份
|
|
|
- String monthTime = map.get("monthTime")+"" ;
|
|
|
- //季度
|
|
|
+ if (frozenTime != null){
|
|
|
+ String yearF = DateUtils.getYear("yyyy-MM-dd", frozenTime);
|
|
|
+ if (!yearF.equals(String.valueOf(yearTime))){
|
|
|
+ log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。",frozenTime,monthTime);
|
|
|
+ return 0 * cost;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Date date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
+ // 判断时间所在的季度
|
|
|
+ int quarterTime = DateUtils.getQuarter(date);
|
|
|
+
|
|
|
+ //季度查询时间 超过 离职时间 则比例为0 绩效 无
|
|
|
+ if (quarterTime < monthTime){
|
|
|
+ i = 0;
|
|
|
+ log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (quarterTime > monthTime){
|
|
|
+ log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //离职时间 是否是当前季度
|
|
|
+ if (quarterTime == monthTime){
|
|
|
+ Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
+ //离职时间所在 月份
|
|
|
+ String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
|
|
|
+ //离职时间所在的季度 的全部 月份
|
|
|
String[] quarter =(String[]) map.get("quarter");
|
|
|
//判断当前离职所在的月份 与当前季度中的月份集合 并获取下标 下标+1 则是 在职月份i
|
|
|
- int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(monthTime));
|
|
|
+ int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
|
|
|
i = j + 1;
|
|
|
- log.info("离职-----离职时间是:{}在本季度范围内!系数为{}个月的绩效数据--->{}",frozenTime,i,i*cost);
|
|
|
- return i * cost;
|
|
|
- };
|
|
|
- log.info("离职-----离职时间是:{}不在本季度范围内!绩效按照240计算。当前时间是:{},",frozenTime,new Date());
|
|
|
+ log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
|
|
|
+
|
|
|
+ }
|
|
|
+ //return i * cost;
|
|
|
+
|
|
|
}else {
|
|
|
- //入职时间 是否在当前季度
|
|
|
- if (DateUtils.isThisQuarter(createTime)){
|
|
|
- Map<String,Object> map = DateUtils.getCurrentQuarterMonths(createTime);
|
|
|
+ String yearC = DateUtils.getYear("yyyy-MM-dd", createTime);
|
|
|
+ if (!yearC.equals(String.valueOf(yearTime))){
|
|
|
+ log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。",createTime,monthTime);
|
|
|
+ return i * cost;
|
|
|
+ }
|
|
|
+ Date date = DateUtils.str2Date(createTime,new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
+ // 判断时间所在的季度
|
|
|
+ int quarterTime = DateUtils.getQuarter(date);
|
|
|
+ //查询入职前的 比例
|
|
|
+ //季度查询时间 超过 入职时间 绩效0
|
|
|
+ if (quarterTime < monthTime){
|
|
|
+ log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},",createTime,monthTime,new Date());
|
|
|
+ }
|
|
|
+ //查询入职后的 比例
|
|
|
+ if (quarterTime > monthTime){
|
|
|
+ i = 0;
|
|
|
+ log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ //入职时间 在当前季度
|
|
|
+ if (quarterTime == monthTime){
|
|
|
+ Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
//月份
|
|
|
- String monthTime = map.get("monthTime")+"" ;
|
|
|
+ //入职时间所在 月份
|
|
|
+ String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
|
|
|
//季度
|
|
|
String[] quarter =(String[]) map.get("quarter");
|
|
|
//判断当前离职所在的月份 与当前季度中的月份集合 并获取下标 下标+1 则是 在职月份i
|
|
|
- int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(monthTime));
|
|
|
- i = 3 - j;
|
|
|
- log.info("在职-----入职时间是:{}在本季度范围内!系数为{}个月的绩效数据--->{}",createTime,i,i*cost);
|
|
|
+ int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
|
|
|
+ i = j + 1;
|
|
|
+ log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
|
|
|
return i * cost;
|
|
|
};
|
|
|
- log.info("在职-----入职时间是:{}不在本季度范围内!绩效按照240计算。当前时间是:{},",createTime,new Date());
|
|
|
}
|
|
|
return i * cost;
|
|
|
}
|
|
@@ -203,26 +254,47 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
* frozenTime 离职时间
|
|
|
* @return
|
|
|
*/
|
|
|
- public Double userHappyProbability(String frozenTime){
|
|
|
+ public Double userHappyProbability(String frozenTime,int monthTime){
|
|
|
|
|
|
//离职发放比例
|
|
|
Double userHappyProbability = new Double("1");
|
|
|
if (!Check.isNull(frozenTime)){
|
|
|
- //离职时间所在季度的最后一天
|
|
|
- String endDay = DateUtils.getQuarterEndDay(frozenTime);
|
|
|
- //离职月份
|
|
|
+ //根据时间获取季度
|
|
|
+ //离职时间所在的季度 是否和 查询季度相同 相同则判断 不同 则比例为1
|
|
|
+
|
|
|
+ //当前季度的 月份
|
|
|
+ Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
+ //季度
|
|
|
+ String[] quarter =(String[]) map.get("quarter");
|
|
|
String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
|
|
|
- // 离职时间 > = 最后一天 发放比例为1
|
|
|
- if (DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd")).getTime() >=
|
|
|
- DateUtils.str2Date(endDay,new SimpleDateFormat("yyyy-MM-dd")).getTime()){
|
|
|
- userHappyProbability = new Double("1");
|
|
|
+ if (Arrays.binarySearch(quarter,month) < 0){
|
|
|
+ return userHappyProbability;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //离职 获取 天
|
|
|
+ String day = DateUtils.getDay("yyyy-MM-dd",frozenTime);
|
|
|
+
|
|
|
//15日之前离职 不发
|
|
|
+ if (Integer.valueOf(day) < 15){
|
|
|
+ userHappyProbability = new Double("0");
|
|
|
+ }
|
|
|
+
|
|
|
// 15号之后离职,发50%
|
|
|
- if (Integer.valueOf(month) >= 15){
|
|
|
+ if (Integer.valueOf(day) >= 15){
|
|
|
userHappyProbability = new Double("0.5");
|
|
|
}
|
|
|
|
|
|
+ //离职时间所在季度的最后一天
|
|
|
+ String endDay = DateUtils.getQuarterEndDay(frozenTime);
|
|
|
+ //最后一天离职 发放比例为1
|
|
|
+ // 离职时间 > = 最后一天
|
|
|
+ if (DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd")).getTime() >=
|
|
|
+ DateUtils.str2Date(endDay,new SimpleDateFormat("yyyy-MM-dd")).getTime()){
|
|
|
+ userHappyProbability = new Double("1");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return userHappyProbability;
|
|
@@ -235,24 +307,57 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Result getDesignerCommission(String userId) {
|
|
|
- //取当前时间的季度的月份
|
|
|
- Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
|
|
|
- String[] quarterStr = (String[])timeMap.get("quarter");
|
|
|
+ public JSONObject getDesignerCommission(String userId,String yearTime,String monthTime) {
|
|
|
+
|
|
|
+ String roleCode = roleService.getRoleCodeByUserId(userId);
|
|
|
|
|
|
+ //取当前时间的季度的月份
|
|
|
+ List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
|
|
|
//人员离职信息
|
|
|
JSONObject userFrozen = designerMapper.getUserFrozenInfo(userId);
|
|
|
|
|
|
+ List<Map<String,Object>> quarterCostList = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> leaderCostList = new ArrayList<>();
|
|
|
+ List<JSONObject> listBytedanceCost = new ArrayList<>();
|
|
|
+ List<JSONObject> listKuaishouCost = new ArrayList<>();
|
|
|
+ for (Map<String,Integer> month : timeMap ) {
|
|
|
+ //季度 分媒体 素材消耗 分月查询
|
|
|
+ List<JSONObject> bytedanceQuarterCost = designerMapper.getDesignerBytedanceQuaterCost(userId,month.get("startTime"),month.get("endTime"));
|
|
|
+ List<JSONObject> kuaishouQuarterCost = designerMapper.getDesignerKuaishouQuaterCost(userId,month.get("startTime"),month.get("endTime"));
|
|
|
+ listBytedanceCost.addAll(bytedanceQuarterCost);
|
|
|
+ listKuaishouCost.addAll(kuaishouQuarterCost);
|
|
|
+
|
|
|
+
|
|
|
+ //管理消耗 分月查询
|
|
|
+ List<JSONObject> leaderCost = designerMapper.getDesignerManagerLeaderCost(userId,month.get("startTime"),month.get("endTime"));
|
|
|
+ Map<String,Object> leaderCostMap = new HashMap<>();
|
|
|
+ leaderCostMap.put("bytedanceCost",leaderCost.get(0).getString("cost"));
|
|
|
+ leaderCostMap.put("kuaishouCost",leaderCost.get(1).getString("cost"));
|
|
|
+ leaderCostList.add(leaderCostMap);
|
|
|
+
|
|
|
+ }
|
|
|
+ Double bytedanceCost = listBytedanceCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ Double kuaishouCost = listKuaishouCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ Map<String,Object> bytedanceMap = new HashMap<>();
|
|
|
+ Map<String,Object> kuaishouMap = new HashMap<>();
|
|
|
+ bytedanceMap.put("type","byteDance");
|
|
|
+ bytedanceMap.put("cost",bytedanceCost);
|
|
|
+ kuaishouMap.put("type","kuaiShou");
|
|
|
+ kuaishouMap.put("cost",kuaishouCost);
|
|
|
+ quarterCostList.add(bytedanceMap);
|
|
|
+ quarterCostList.add(kuaishouMap);
|
|
|
|
|
|
//季度 分媒体 素材消耗
|
|
|
- List<JSONObject> quarterCost = designerMapper.getDesignerBytedanceAndKuaishouQuaterCost(userId);
|
|
|
- userFrozen.put("quarterCostList",quarterCost);
|
|
|
+ userFrozen.put("quarterCostList",quarterCostList);
|
|
|
|
|
|
//季度素材 总消耗
|
|
|
- Double tatolCost = quarterCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ Double tatolCost = quarterCostList.stream().mapToDouble(json -> new Double(json.get("cost")+"")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
userFrozen.put("tatolQuarterCost",tatolCost);
|
|
|
|
|
|
- //消耗是否达标
|
|
|
+ //季度 管理消耗汇总
|
|
|
+ Double bytedanceLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("bytedanceCost")+"")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ Double kuaishouLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("kuaishouCost")+"")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ userFrozen.put("leaderCost",bytedanceLeaderCost + kuaishouLeaderCost);
|
|
|
|
|
|
//离职时间
|
|
|
String frozenTime = userFrozen.getString("frozenTime");
|
|
@@ -260,89 +365,135 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
String createTime = userFrozen.getString("createTime");
|
|
|
|
|
|
//判断素材消耗是否达标
|
|
|
- Double i = getMaterialCost(frozenTime,createTime);
|
|
|
+ Double i = getMaterialCost(frozenTime,createTime,Integer.valueOf(yearTime),Integer.valueOf(monthTime));
|
|
|
String materialCostQualifiedFlag = tatolCost >= i ? "是" : "否";
|
|
|
userFrozen.put("materialCostQualifiedFlag",materialCostQualifiedFlag);
|
|
|
|
|
|
- //爆款素材数量
|
|
|
- JSONObject hotVideoNum = designerMapper.getUserHotMaterialQuarter(userId);
|
|
|
+ //爆款素材数量 分月查询
|
|
|
+ JSONObject hotVideoNum = designerMapper.getUserHotMaterialQuarter(userId,timeMap.get(0).get("startTime"),timeMap.get(2).get("endTime"));
|
|
|
int hotVideoN = Check.isNull(hotVideoNum) ? 0 : hotVideoNum.getInteger("hotVideoNum");
|
|
|
userFrozen.put("hotVideoNum",hotVideoN);
|
|
|
|
|
|
|
|
|
-
|
|
|
//爆款总量 开屏爆款数量 + 爆款数量
|
|
|
int hotVideoTotalNum = userFrozen.getInteger("openHotVideoNum") + hotVideoN;
|
|
|
userFrozen.put("hotVideoTotalNum",hotVideoTotalNum);
|
|
|
|
|
|
- /**
|
|
|
- * 爆款达标 提成发放系数
|
|
|
- * 在季度中
|
|
|
- * 爆款 >= 10个 消耗>=240w 绩效 100%
|
|
|
- * 爆款 < 10 消耗 >= 240w 绩效50%
|
|
|
- * 爆款<=0 绩效 >= 240w 不发
|
|
|
- * 爆款>=10 绩效<=240w 不发
|
|
|
- * 其中的绩效240 根据入职或离职时间按月计算 使用字段materialCostQualifiedFlag
|
|
|
- *
|
|
|
- */
|
|
|
- Double coefficient = new Double("0");
|
|
|
- if (materialCostQualifiedFlag.equals("是")){
|
|
|
- if (hotVideoTotalNum >= 10){
|
|
|
- coefficient = new Double("1");
|
|
|
- }
|
|
|
- if (hotVideoTotalNum > 0 && hotVideoTotalNum < 10){
|
|
|
- coefficient = new Double("0.5");
|
|
|
- }
|
|
|
- }
|
|
|
- userFrozen.put("coefficient",coefficient);
|
|
|
|
|
|
|
|
|
//提成 分月份
|
|
|
List<JSONObject> commissionList = new ArrayList<>();
|
|
|
- for (String month : quarterStr ) {
|
|
|
+ for (Map<String,Integer> month : timeMap ) {
|
|
|
JSONObject commissionJson = new JSONObject();
|
|
|
//头条提成
|
|
|
- List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId, timeMap.get("yearTime") + "", month);
|
|
|
+ List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId, month.get("startTime"),month.get("endTime"));
|
|
|
Double bytedanceCommission = bytedanceJson.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
|
|
|
//快手提成
|
|
|
- List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsBytedance(userId, timeMap.get("yearTime") + "", month);
|
|
|
+ List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId, month.get("startTime"),month.get("endTime"));
|
|
|
Double kuaishouCommission = kuaishouJson.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
|
|
|
- commissionJson.put("monthTime", month);
|
|
|
- commissionJson.put("yearTime", timeMap.get("yearTime") + "");
|
|
|
- commissionJson.put("commission", bytedanceCommission+kuaishouCommission);
|
|
|
+ commissionJson.put("monthTime", month.get("startTime"));
|
|
|
+ commissionJson.put("yearTime", yearTime);
|
|
|
+
|
|
|
+
|
|
|
+ //离职 提成系数
|
|
|
+ //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
|
|
|
+ Double userHappyProbability = new Double(1);
|
|
|
+ if (!Check.isNull(frozenTime)){
|
|
|
+
|
|
|
+ //离职时间
|
|
|
+ int frozenT = DateUtils.getDateInteger(frozenTime);
|
|
|
+
|
|
|
+ // 日期转换 20221021 ===>>> 2022-10-21
|
|
|
+ String day = DateUtils.getStrDateToInt(month.get("startTime"));
|
|
|
+ //获取月份的 中间的日期 20221015
|
|
|
+ int middleDay = DateUtils.subMonthMiddleDay(day);
|
|
|
+
|
|
|
+ //设计组长 看月份 如果6月离职的,则只计算4、5月份的,与日期无关
|
|
|
+ if (roleCode.equalsIgnoreCase("designTeamLeader")){
|
|
|
+ if (frozenT > month.get("endTime")){
|
|
|
+ userHappyProbability = new Double(1);
|
|
|
+ }else {
|
|
|
+ userHappyProbability = new Double(0);
|
|
|
+ }
|
|
|
+ //如果当月15日之前离职,当月不发;
|
|
|
+ // 15号之后离职,发50%;
|
|
|
+ // 若月底最后一天离职,则发放100
|
|
|
+ }else {
|
|
|
+ if (frozenT < middleDay){
|
|
|
+ userHappyProbability = new Double(0);
|
|
|
+ }
|
|
|
+ if (frozenT > middleDay && frozenT < month.get("endTime")){
|
|
|
+ userHappyProbability = new Double(0.5);
|
|
|
+ }
|
|
|
+ if (frozenT == month.get("endTime")){
|
|
|
+ userHappyProbability = new Double(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ commissionJson.put("xishu", userHappyProbability);
|
|
|
+ commissionJson.put("ticheng", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
|
|
|
+ commissionJson.put("commission", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
|
|
|
+ commissionJson.put("commissionOld", bytedanceCommission+kuaishouCommission);
|
|
|
commissionList.add(commissionJson);
|
|
|
+
|
|
|
}
|
|
|
userFrozen.put("commissionList",commissionList);
|
|
|
|
|
|
|
|
|
//季度提成汇总
|
|
|
- Double totalCommission = commissionList.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
|
|
|
+ BigDecimal totalCommissionBd = commissionList.stream().map(json -> json.getBigDecimal("commission")).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
+ Double totalCommission = totalCommissionBd.doubleValue();
|
|
|
|
|
|
- //如果是负责人 (设计组长) 负责人提成千三的20%
|
|
|
+ //负责人提成 如果是负责人 (设计组长) 管理消耗 千三的20%
|
|
|
Double designerLeaderCommission = new Double("0");
|
|
|
- String roleCode = roleService.getRoleCodeByUserId(userId);
|
|
|
+
|
|
|
if (roleCode.equalsIgnoreCase("designTeamLeader")){
|
|
|
- designerLeaderCommission = totalCommission * 0.003 * 0.2;
|
|
|
+ Double designerLeaderCommissionBytedance = bytedanceLeaderCost * 0.002 * 0.2;
|
|
|
+ Double designerLeaderCommissionKuaishou = kuaishouLeaderCost * 0.003 * 0.2;
|
|
|
+ designerLeaderCommission = designerLeaderCommissionBytedance + designerLeaderCommissionKuaishou;
|
|
|
}
|
|
|
userFrozen.put("designerLeaderCommission",designerLeaderCommission);
|
|
|
|
|
|
-
|
|
|
//提成汇总 = 季度汇总 + 负责人提成
|
|
|
totalCommission+=designerLeaderCommission;
|
|
|
userFrozen.put("totalCommission",totalCommission);
|
|
|
|
|
|
+ //离职发放比例
|
|
|
+ Double userHappyProbability = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
|
|
|
+ userFrozen.put("userHappyProbability",userHappyProbability);
|
|
|
|
|
|
|
|
|
- //离职发放比例
|
|
|
- Double userHappyProbability = userHappyProbability(frozenTime);
|
|
|
+ /**
|
|
|
+ * 爆款达标 提成发放系数
|
|
|
+ * 在季度中
|
|
|
+ * 爆款 >= 10个 消耗>=240w 绩效 100%
|
|
|
+ * 爆款 < 10 消耗 >= 240w 绩效50%
|
|
|
+ * 爆款<=0 绩效 >= 240w 不发
|
|
|
+ * 爆款>=10 绩效<=240w 不发
|
|
|
+ * 其中的绩效240 根据入职或离职时间按月计算 使用字段materialCostQualifiedFlag
|
|
|
+ *
|
|
|
+ */
|
|
|
+ Double coefficient = new Double("0");
|
|
|
+ if (materialCostQualifiedFlag.equals("是")){
|
|
|
+ if (hotVideoTotalNum >= 10){
|
|
|
+ coefficient = new Double("1");
|
|
|
+ }
|
|
|
+ if (hotVideoTotalNum > 0 && hotVideoTotalNum < 10){
|
|
|
+ coefficient = new Double("0.5");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userFrozen.put("coefficient",coefficient);
|
|
|
|
|
|
- //提成发放金额 = 总提成* 发放系数 * 离职发放比例
|
|
|
- Double userHappyGetMoney = totalCommission * coefficient * userHappyProbability;
|
|
|
+ //提成发放金额 = 总提成 * 爆款达标发放系数
|
|
|
+ Double userHappyGetMoney = totalCommission * coefficient;
|
|
|
userFrozen.put("userHappyGetMoney",userHappyGetMoney);
|
|
|
|
|
|
- return Result.successMsg("查询成功",userFrozen);
|
|
|
+ return userFrozen;
|
|
|
|
|
|
|
|
|
}
|
|
@@ -365,6 +516,59 @@ public class DesignerServiceImpl implements IDesignerService {
|
|
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result getDesignerBasicsAndHotVideoInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
|
|
|
+ //基础信息 + 爆款信息
|
|
|
+ PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
|
|
|
+ for (JSONObject jsonObject : baseics.getList()) {
|
|
|
+ List<Map<String,Object>> hotVideo = getHotVideoData(jsonObject.getString("userId"),yearTime,monthTime);
|
|
|
+ jsonObject.put("hotVideoInfo",hotVideo);
|
|
|
+ }
|
|
|
+ return Result.successMsg("基础+爆款查询成功。",baseics);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getDesignerBasicsAndAch(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
|
|
|
+ //基础信息 + 绩效
|
|
|
+ PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
|
|
|
+ for (JSONObject jsonObject : baseics.getList()) {
|
|
|
+ //绩效
|
|
|
+ Map<String,Object> achievementsMap = getDesignerAchievements(jsonObject.getString("userId"),yearTime,monthTime);
|
|
|
+ jsonObject.put("achievementsMap",achievementsMap);
|
|
|
+ }
|
|
|
+ return Result.successMsg("基础+绩效查询成功。",baseics);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getDesignerBasicsAndAchAndComInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
|
|
|
+ //基础信息 +提成
|
|
|
+ PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
|
|
|
+ for (JSONObject jsonObject : baseics.getList()) {
|
|
|
+ //提成
|
|
|
+ JSONObject userFrozen = getDesignerCommission(jsonObject.getString("userId"),yearTime,monthTime);
|
|
|
+ jsonObject.put("userFrozen",userFrozen);
|
|
|
+ }
|
|
|
+ return Result.successMsg("基础+提成查询成功。",baseics);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getUserByRoleName(String roleName){
|
|
|
+ List<JSONObject> list = designerMapper.getUserByRoleName(roleName);
|
|
|
+ return Result.successMsg("查询成功。",list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|