浏览代码

快手-盯盘-获取用户下级的项目以及账户信息

yangzian 3 年之前
父节点
当前提交
36acd030d1

+ 23 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java

@@ -3,12 +3,17 @@ package org.jeecg.ctop.material.controller;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.ctop.material.constants.Check;
+import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.MaterialStareService;
 import org.jeecg.ctop.material.service.impl.MaterialStareServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -278,6 +283,22 @@ public class KuaiShouMaterialStareController {
 
 
 
+    /**
+     * 获取用户下级的项目以及账户信息
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/participateListByMediaIdAllSubordinate")
+    public Result<List<JSONObject>> participateListByMediaIdAllSubordinate(@RequestBody JSONObject requestJson) {
+        return materialStareService.participateListByMediaIdAllSubordinate(requestJson);
+    }
+
+
+
+
+
+
 
 
 
@@ -298,4 +319,6 @@ public class KuaiShouMaterialStareController {
 
 
 
+
+
 }

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

@@ -88,6 +88,9 @@ public interface MaterialStareMapper {
 
 
 
+    List<JSONObject> getProjectByUserIdAndMediaIdsSubordinate(@Param("userIds") Set<String> userIds, @Param("mediaIds") List<Integer> mediaIds);
+    List<JSONObject> getAccountListByProjectListSubordinate(@Param("userIds") Set<String> userIds,@Param("list") List list);
+
 
 
 

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

@@ -1048,4 +1048,63 @@
         </foreach>
     </select>
 
+
+
+
+    <select id="getProjectByUserIdAndMediaIdsSubordinate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t2.id as 'projectId',
+        t2.project_name as 'projectName',
+        t2.product_id as 'productId',
+        (select name from ctop_advertiser where id = t2.advertiser_id) as 'advertiserName'
+        from ctop_project_member t1
+        left join ctop_project t2
+        on t1.project_id = t2.id
+        where 1 = 1
+        <if test="userIds != null and userIds.size() != 0 ">
+            and t1.user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test="mediaIds != null and mediaIds.size() != 0 ">
+            and t2.media_id in
+            <foreach collection="mediaIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t2.id
+        order by t2.create_time desc
+    </select>
+
+
+
+    <select id="getAccountListByProjectListSubordinate" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t1.project_id as 'projectId',
+        t1.account_id as 'accountId',
+        (select realname from sys_user where id = t1.user_id ) as 'userName',
+        t1.auth_name as 'authName',
+        t1.account_status as 'accountStatus'
+        from ctop_user_allocation t1
+        where t1.account_status = 0
+        and t1.project_id in
+        <foreach collection="list" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        and t1.user_id in
+        <foreach collection="userIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        order by t1.create_time desc
+    </select>
+
+
+
+
 </mapper>

+ 8 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/MaterialStareService.java

@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject;
 import org.jeecg.common.api.vo.Result;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * 盯盘接口
@@ -38,4 +41,9 @@ public interface MaterialStareService {
 
 
 
+    Result<List<JSONObject>> participateListByMediaIdAllSubordinate(JSONObject requestJson);
+
+    List<JSONObject> getProjectByUserIdAndMediaIdsSubordinate(Set<String> userIds, List<Integer> mediaIds);
+    Map<Long, List<JSONObject>> getAccountListByProjectListSubordinate(Set<String> userIds,List<JSONObject> projectList);
+
 }

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

@@ -755,4 +755,94 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     }
 //===========================================查询下级员工========================
 
+
+
+    //=========================查询下级的项目以及账户===============================================
+    @Override
+    public Result<List<JSONObject>> participateListByMediaIdAllSubordinate(JSONObject requestJson) {
+        Result<List<JSONObject>> result = new Result<>();
+
+        try {
+            String userId = requestJson.getString("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("请选择userId");
+            }
+
+            //获取所有下级
+            Set<String> userIds = getAffiliateId(userId);
+
+            List<Integer> mediaIds = new ArrayList<>();
+            String type = requestJson.getString("type");
+            if (!Check.isNull(type)) {
+                if ("kuaishou".equals(type)) {
+                    mediaIds.add(2);
+                    mediaIds.add(4);
+                } else if ("bytedance".equals(type)) {
+                    mediaIds.add(1);
+                    mediaIds.add(3);
+                }
+            }
+            //查询用户角色
+            String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
+            //角色为 管理员 || 销售 || 媒介 查询全部
+            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+                userIds = null;
+            }
+            //查询项目信息以及广告主
+            List<JSONObject> projectList = getProjectByUserIdAndMediaIdsSubordinate(userIds, mediaIds);
+            List<JSONObject> haveList = new ArrayList<>();
+            if (!Check.isNull(projectList)) {
+                //项目id 查询账户人员信息
+                Map<Long, List<JSONObject>> accountMap = getAccountListByProjectListSubordinate(userIds,projectList);
+                for (int i = 0; i < projectList.size(); i++) {
+                    JSONObject project = projectList.get(i);
+                    if (!Check.isNull(project)) {
+                        List<JSONObject> accountList = accountMap.get(project.getLong("projectId"));
+                        if (!Check.isNull(accountList)) {
+                            project.put("accountList", accountList);
+                            haveList.add(project);
+                        }
+                    }
+                }
+            }
+            result.setSuccess(true);
+            result.setResult(haveList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+    public List<JSONObject> getProjectByUserIdAndMediaIdsSubordinate(Set<String> userIds, List<Integer> mediaIds) {
+        return materialStareMapper.getProjectByUserIdAndMediaIdsSubordinate(userIds, mediaIds);
+    }
+
+    @Override
+    public Map<Long, List<JSONObject>> getAccountListByProjectListSubordinate(Set<String> userIds,List<JSONObject> projectList) {
+        Map<Long, List<JSONObject>> map = new HashMap<>();
+        List list = new ArrayList();
+        for (int i = 0; i < projectList.size(); i++) {
+            JSONObject jsonObject = projectList.get(i);
+            if (!Check.isNull(jsonObject)) {
+                list.add(jsonObject.getLong("projectId"));
+                map.put(jsonObject.getLong("projectId"), new ArrayList<>());
+            }
+        }
+        List<JSONObject> jsonList = materialStareMapper.getAccountListByProjectListSubordinate(userIds,list);
+        for (int i = 0; i < jsonList.size(); i++) {
+            JSONObject jsonObject = jsonList.get(i);
+            if (!Check.isNull(jsonObject)) {
+                Long projectId = jsonObject.getLong("projectId");
+                List<JSONObject> jsonObjects = map.get(projectId);
+                jsonObjects.add(jsonObject);
+            }
+        }
+        return map;
+    }
+    //=========================查询下级的项目以及账户===============================================
+
+
+
 }