瀏覽代碼

绩效逻辑修改

sunzhen 5 年之前
父節點
當前提交
7c6e3149dd

+ 121 - 22
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java

@@ -704,7 +704,16 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= top30 - 1; i++) {
             //总消耗--获取这个人的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -727,12 +736,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        planList.subList(0, top30 - 1).clear();
+        planList.subList(0, top30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= middle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null){
@@ -793,7 +810,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= shotTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -816,12 +841,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        shotList.subList(0, shotTop30 - 1).clear();
+        shotList.subList(0, shotTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= shotMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -881,7 +914,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= clipTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -904,12 +945,19 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        clipList.subList(0, clipTop30 - 1).clear();
+        clipList.subList(0, clipTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= clipMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1009,6 +1057,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 //增加平面人数、和项目单独的绩效
                 planeProjectCost.setProjectPlaneCount(planeList.size());
                 planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")).multiply(new BigDecimal("0.003")).setScale(4,BigDecimal.ROUND_HALF_UP));
+                planeProjectCost.setType(1);
                 if (null == planeMap.get(plane.getUserId())) {
                     plane.setEffiRate(averageQuarterCost);
                     planeMap.put(plane.getUserId(), plane);
@@ -1029,7 +1078,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             planeProjectCost.setUserId(designLeader.getUserId());
             //增加平面人数、和项目单独的绩效
             planeProjectCost.setProjectPlaneCount(1);
-            planeProjectCost.setProjectPerformance(quarterCost.multiply(new BigDecimal("0.2")).multiply(new BigDecimal("0.003")));
+            planeProjectCost.setProjectPerformance(quarterCost.multiply(new BigDecimal("0.15")).multiply(new BigDecimal("0.003")).setScale(4,BigDecimal.ROUND_HALF_UP));
             planeProjectCost.setType(2);
 
             if (null == designLeaderMap.get(designLeader.getUserId())) {
@@ -1117,7 +1166,16 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= top30 - 1; i++) {
             //头条编导总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1140,12 +1198,21 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        planList.subList(0, top30 - 1).clear();
+        planList.subList(0, top30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= middle50 - 1; i++) {
             //这个编导的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(2‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1202,7 +1269,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= shotTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1225,12 +1300,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        shotList.subList(0, shotTop30 - 1).clear();
+        shotList.subList(0, shotTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= shotMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1265,7 +1348,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //有效视频数量 //1头条 2快手
             int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(1, thisYear, thisQuarter, userDto.getUserId(), "clip");
             //总视频数量
-            int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "clip");
+            int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 1, userDto.getUserId(), "clip");
             //视频有效率
             BigDecimal effiRate=BigDecimal.ZERO;
             if (videoCount != 0){
@@ -1287,7 +1370,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= clipTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1310,12 +1401,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        clipList.subList(0, clipTop30 - 1).clear();
+        clipList.subList(0, clipTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= clipMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1364,7 +1463,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
 
             UserDto2 designLeader = userEfficientVideoMapMapper.getProjectDesignResponsibleInfo(projectDTO.getProjectId());
             List<UserDto2> planeList = userEfficientVideoMapMapper.getPlaneByProjectId(projectDTO.getProjectId());
-            BigDecimal quarterCost = userEfficientVideoMapMapper.getProjectQuarterCostById(startTime, endTime, projectDTO.getProjectId());
+            BigDecimal quarterCost = userEfficientVideoMapMapper.getToutiaoProjectQuarterCostById(startTime, endTime, projectDTO.getProjectId());
             quarterCost = quarterCost==null?BigDecimal.ZERO:quarterCost;
             //此项目当中平面数量,平面数量为0的时候说明此project当中没有平面设计师;项目没有平面的情况下,项目leader绩效提成为20%
             int size = planeList.size();
@@ -1415,7 +1514,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 planeProjectCost.setUserId(plane.getUserId());
                 //增加平面人数、和项目单独的绩效
                 planeProjectCost.setProjectPlaneCount(planeList.size());
-                planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")));
+                planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")).multiply(new BigDecimal("0.002")).setScale(4,BigDecimal.ROUND_HALF_UP));
                 planeProjectCost.setType(1);
 
                 if (null == planeMap.get(plane.getUserId())) {

+ 8 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -55,6 +55,8 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     BigDecimal getProjectQuarterCostById(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Long projectId);
 
+    BigDecimal getToutiaoProjectQuarterCostById(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Long projectId);
+
     List<UserDto2> getPlaneByProjectId(@Param("projectId") Long projectId);
 
     List<UserDto2> getKuaishouDesignLeaderList();
@@ -242,6 +244,12 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     BigDecimal getQuarterTotalCostByRoleCode(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("startDate")String startDate, @Param("endDate")String endDate,@Param("roleCode")String roleCode,@Param("userId")String userId);
 
+    List<String> getQuarterSignature(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("roleCode")String roleCode,@Param("userId")String userId);
+
+    BigDecimal getQuarterTotalCostByCode(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("signature")String signature);
+
+    BigDecimal getToutiaoQuarterTotalCostByCode(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("signature")String signature);
+
     BigDecimal getToutiaoQuarterTotalCostByRoleCode(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("startDate")String startDate, @Param("endDate")String endDate,@Param("roleCode")String roleCode,@Param("userId")String userId);
 }
 

+ 60 - 6
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -209,18 +209,46 @@
         and c.shot_id = #{userId}
     </select>
 
+    <select id="getQuarterSignature" resultType="string">
+        select
+            video_signature
+            from
+            ctop_user_video_map
+            where year = #{year} and quarter = #{quarter}
+            and user_id = #{userId} and role_id = #{roleCode}
+    </select>
+
+    <select id="getQuarterTotalCostByCode" resultType="java.math.BigDecimal">
+        select
+        sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative a
+        where signature = #{signature}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
+    <select id="getToutiaoQuarterTotalCostByCode" resultType="java.math.BigDecimal">
+        select
+        sum(a.cost) as charge
+        from ctop_bytedance_report_creative_daily a
+        where signature = #{signature}
+        and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
     <!-- 根据userId和角色名获取其在本季度所有视频总消耗 -->
     <select id="getQuarterTotalCostByRoleCode" resultType="java.math.BigDecimal">
         select
         sum(a.charge) as charge
         from ctop_kuaishou_report_daily_creative a
-        where signature in (
+        left join  (
             select
-            efficient_video_signature
+            video_signature
             from
-            ctop_user_efficient_video_map
+            ctop_user_video_map
             where year = #{year} and quarter = #{quarter}
-            and user_id = #{userId} and role_id = #{roleCode})
+            and user_id = #{userId} and role_id = #{roleCode}) b on a.signature = b.video_signature
+        where b.video_signature is not null
         and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
         and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
     </select>
@@ -366,11 +394,27 @@
     </select>
 
     <!-- 根据projectId计算项目总消耗 -->
+    <select id="getToutiaoProjectQuarterCostById" resultType="java.math.BigDecimal">
+            select
+            sum(dailiAccount.cost) as charge
+            from
+            ctop_bytedance_report_advertiser_daily dailiAccount
+            left join
+            ctop_user_allocation allocation on dailiAccount.advertiser_id = allocation.account_id
+        where
+        allocation.project_id = #{projectId}
+        AND
+        date_format(dailiAccount.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        AND
+        date_format(dailiAccount.stat_datetime,'%Y-%m-%d') &lt; #{endDate}
+    </select>
+
+    <!-- 根据projectId计算项目总消耗 -->
     <select id="getProjectQuarterCostById" resultType="java.math.BigDecimal">
             select
             sum(dailiAccount.charge) as charge
             from
-            ctop_kuaishou_report_daily_account dailiAccount
+            ctop_kuaishou_report_daily_creative dailiAccount
             left join
             ctop_user_allocation allocation on dailiAccount.account_id = allocation.account_id
         where
@@ -617,7 +661,17 @@
     select
     sum(a.cost) as charge
     from ctop_bytedance_report_creative_daily a
-    where signature in (select efficient_video_signature from ctop_user_efficient_video_map where year =#{year} and quarter =#{quarter} and user_id = #{userId} and role_id = #{roleCode})
+    left join  (
+                select
+                video_signature
+                from
+                ctop_user_video_map
+                where year =#{year}
+                and quarter =#{quarter}
+                and user_id = #{userId}
+                and role_id = #{roleCode}
+                ) b on on a.signature = b.video_signature
+    where b.video_signature is not null
     and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
     and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
     </select>