Sfoglia il codice sorgente

盯盘-运营经理-管理员

yangzian 3 anni fa
parent
commit
694649eb29

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -21,6 +21,7 @@ public interface MaterialStareMapper {
     String getUserCompanyByUserId(@Param("userId")String userId);
     Set<String> getAffiliateId(@Param("leaderId")String leaderId,@Param("companyId")String companyId);
     Set<String> querySubordinateRecursive(@Param("companyId")String companyId,@Param("leaderIds")Set<String> leaderIds);
+    Set<String> getKuaiShouAllOperators(@Param("companyId")String companyId,@Param("startDate")Long start, @Param("endDate")Long endDate,@Param("userIds")Set<String> userIds);
 
 
 

+ 39 - 5
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -715,6 +715,29 @@
 
 
 
+    <!-- 快手 同公司所有下级运营人员 -->
+    <select id="getKuaiShouAllOperators" resultType="java.lang.String">
+        SELECT DISTINCT
+        d.user_id
+        FROM
+        application.kuaishou_account_report_daily_dw d
+        WHERE
+         d.charge > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_date &lt;= #{endDate}
+        </if>
+        AND d.user_id in
+        <foreach collection="userIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+
 
 
 
@@ -727,7 +750,8 @@
         from `jeecg-boot`.sys_user a
                  left join `jeecg-boot`.sys_user_role b on a.id = b.user_id
                  left join `jeecg-boot`.sys_role c on b.role_id = c.id
-        where a.id = #{userId}
+        where
+         a.id = #{userId}
             LIMIT 1
     </select>
 
@@ -754,10 +778,15 @@
         SELECT DISTINCT
             u.id
         FROM
-            sys_user u,
-            user_company c
+        `jeecg-boot`.sys_user u,
+        `jeecg-boot`.user_company c,
+        `jeecg-boot`.sys_user_role r,
+        `jeecg-boot`.sys_role sr
         WHERE
             u.id = c.user_id
+            and c.user_id = r.user_id
+            and r.role_id = sr.id
+            AND sr.role_name LIKE '%运营%'
         <if test="leaderId != null and leaderId != '' ">
             AND u.leader_id = #{leaderId}
         </if>
@@ -772,10 +801,15 @@
         SELECT DISTINCT
         u.id
         FROM
-        sys_user u,
-        user_company c
+        `jeecg-boot`.sys_user u,
+        `jeecg-boot`.user_company c,
+        `jeecg-boot`.sys_user_role r,
+        `jeecg-boot`.sys_role sr
         WHERE
         u.id = c.user_id
+        and c.user_id = r.user_id
+        and r.role_id = sr.id
+        AND sr.role_name LIKE '%运营%'
         AND u.STATUS = 1
         AND u.del_flag = 0
         <if test="companyId != null and companyId != '' ">

+ 13 - 3
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -188,9 +188,16 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     public Result kuaiShouOperateDateTotal(String mediaType, String startTime, String endTime, String userId) {
         Map resultMap = new HashMap();
         DecimalFormat decimalFormat = new DecimalFormat("0.00%");
+        //查询用户所属公司
+        String companyId = materialStareMapper.getUserCompanyByUserId(userId);
+        Set<String> operatorUserIds = null;
         try {
             //查询当前人员所有下级
-            Set<String> operatorUserIds = getAffiliateId(userId);
+            operatorUserIds= getAffiliateId(userId);
+
+            //有消耗的账户
+            operatorUserIds = materialStareMapper.getKuaiShouAllOperators(companyId,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
             SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
             // ==>> 20220202
             String now = sdf.format(new Date());
@@ -696,14 +703,17 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         //查询用户角色
         String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
         //管理员查询公司下所有用户
-        if ("admin".equals(roleCode)) {
+       /* if ("admin".equals(roleCode)) {
             return materialStareMapper.getCompanyAllUserId(companyId);
-        }
+        }*/
 
         Set<String> result;
         //查询当前用户是否存在下级
         Set<String> subordinate = materialStareMapper.getAffiliateId(userId,companyId);
         if (subordinate.isEmpty()) {
+            if ("admin".equals(roleCode)) {
+                return materialStareMapper.getCompanyAllUserId(companyId);
+            }
             subordinate.add(userId);
             return subordinate;
         } else {