|
|
@@ -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;
|
|
|
+ }
|
|
|
+ //=========================查询下级的项目以及账户===============================================
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|