Преглед изворни кода

设计绩效-修改管理消耗按月份起止时间拆分季度统计汇总

yangzian пре 2 година
родитељ
комит
431dc072e0

+ 9 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/mapper/DesignerMapper.java

@@ -61,11 +61,18 @@ public interface DesignerMapper{
 
 
     /**
-     * 查询设计 本季度 头条和快手季度消耗汇总
+     * 查询设计 本季度 头条  季度消耗汇总
      * @param userId
      * @return
      */
-    List<JSONObject>  getDesignerBytedanceAndKuaishouQuaterCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
+    List<JSONObject>  getDesignerBytedanceQuaterCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
+                                                                @Param("endTime") Integer endTime);
+/**
+     * 查询设计 本季度 快手季度消耗汇总
+     * @param userId
+     * @return
+     */
+    List<JSONObject>  getDesignerKuaishouQuaterCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
                                                                 @Param("endTime") Integer endTime);
 
     /**

+ 6 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/mapper/xml/DesignerMapper.xml

@@ -178,8 +178,8 @@
           AND  d.first_cost_day &lt;= #{endTime}
     </select>
 
-    <!-- 查询设计 本季度 头条和快手季度消耗汇总-->
-    <select id="getDesignerBytedanceAndKuaishouQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
+    <!-- 查询设计 本季度 头条季度消耗汇总-->
+    <select id="getDesignerBytedanceQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
             QUARTER( d.first_cost_day ) quaterTime,
             YEAR ( d.first_cost_day ) yearTime,
@@ -191,13 +191,14 @@
             (
             d.clip_id = #{userId} OR d.shot_id = #{userId} OR d.plan_id = #{userId}
             )
-
           AND stat_date &gt;= #{startTime}
           AND  stat_date &lt;= #{endTime}
           AND  d.first_cost_day &gt;= #{startTime}
           AND  d.first_cost_day &lt;= #{endTime}
-        UNION ALL
-        SELECT
+    </select>
+<!-- 查询设计 本季度 快手季度消耗汇总-->
+    <select id="getDesignerKuaishouQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
+               SELECT
             QUARTER( d.first_cost_day ) quaterTime,
             YEAR ( d.first_cost_day ) yearTime,
             IFNULL( sum( d.charge ), 0 ) AS cost,

+ 66 - 38
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/service/impl/DesignerServiceImpl.java

@@ -316,17 +316,48 @@ public class DesignerServiceImpl implements IDesignerService {
        //人员离职信息
        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,timeMap.get(0).get("startTime"),timeMap.get(2).get("endTime"));
-       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);
 
-       //管理消耗
-       List<JSONObject> leaderCost = designerMapper.getDesignerManagerLeaderCost(userId,timeMap.get(0).get("startTime"),timeMap.get(2).get("endTime"));
-       userFrozen.put("leaderCost",new Double(leaderCost.get(0).getString("cost")) + new Double(leaderCost.get(1).getString("cost")));
+       //季度 管理消耗汇总
+       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");
@@ -338,7 +369,7 @@ public class DesignerServiceImpl implements IDesignerService {
        String materialCostQualifiedFlag = tatolCost >= i ? "是" : "否";
        userFrozen.put("materialCostQualifiedFlag",materialCostQualifiedFlag);
 
-       //爆款素材数量
+       //爆款素材数量 分月查询
        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);
@@ -348,26 +379,6 @@ public class DesignerServiceImpl implements IDesignerService {
        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);
 
 
        //提成 分月份
@@ -384,7 +395,7 @@ public class DesignerServiceImpl implements IDesignerService {
 
            commissionJson.put("monthTime", month.get("startTime"));
            commissionJson.put("yearTime", yearTime);
-           commissionJson.put("commission", bytedanceCommission+kuaishouCommission);
+
 
            //离职 提成系数
            //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
@@ -421,14 +432,13 @@ public class DesignerServiceImpl implements IDesignerService {
                    }
                }
 
-
-
-
            }
 
 
            commissionJson.put("xishu", userHappyProbability);
            commissionJson.put("ticheng", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
+           commissionJson.put("commission", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
+           commissionJson.put("commissionOld", bytedanceCommission+kuaishouCommission);
            commissionList.add(commissionJson);
 
        }
@@ -443,8 +453,8 @@ public class DesignerServiceImpl implements IDesignerService {
        Double designerLeaderCommission = new Double("0");
 
        if (roleCode.equalsIgnoreCase("designTeamLeader")){
-           Double designerLeaderCommissionBytedance = new Double(leaderCost.get(0).getString("cost")) * 0.002 * 0.2;
-           Double designerLeaderCommissionKuaishou = new Double(leaderCost.get(1).getString("cost")) * 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);
@@ -453,16 +463,34 @@ public class DesignerServiceImpl implements IDesignerService {
        totalCommission+=designerLeaderCommission;
        userFrozen.put("totalCommission",totalCommission);
 
-
-
        //离职发放比例
        Double userHappyProbability = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
        userFrozen.put("userHappyProbability",userHappyProbability);
 
 
-       //提成发放金额 = 总提成 * 发放系数
-       BigDecimal ticheng = commissionList.stream().map(json -> json.getBigDecimal("ticheng")).reduce(BigDecimal.ZERO,BigDecimal::add);
-       Double userHappyGetMoney = ticheng.doubleValue() * coefficient;
+       /**
+        * 爆款达标 提成发放系数
+        * 在季度中
+        * 爆款 >= 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;
        userFrozen.put("userHappyGetMoney",userHappyGetMoney);
 
        return userFrozen;