|
@@ -151,6 +151,122 @@ public class ProjectMemberController {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取项目以及账户信息
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/getProductProjectAndAccountList")
|
|
|
|
+ public Result<List<JSONObject>> getProductProjectAndAccountList(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ if (Check.isNull(userId)) {
|
|
|
|
+ throw new Exception("请选择userId");
|
|
|
|
+ }
|
|
|
|
+ List<Integer> mediaIds = new ArrayList<>();
|
|
|
|
+ //查询用户角色
|
|
|
|
+ String roleCode = sysRoleService.getRoleCodeByUserId(userId);
|
|
|
|
+ //角色为 管理员 || 销售 || 媒介 查询全部
|
|
|
|
+ if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
|
|
|
|
+ userId = null;
|
|
|
|
+ }
|
|
|
|
+ //查询项目信息以及广告主
|
|
|
|
+ List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
|
|
|
|
+ List<JSONObject> haveList = new ArrayList<>();
|
|
|
|
+ List<JSONObject> list = new ArrayList<>();
|
|
|
|
+ if (!Check.isNull(projectList)) {
|
|
|
|
+ list = projectService.queryProductInfo(projectList);
|
|
|
|
+ if (Check.isNull(list)) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("该用户没有可用的产品");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ //项目id 查询账户人员信息
|
|
|
|
+ Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (JSONObject object : list) {
|
|
|
|
+ List<JSONObject> proList = new ArrayList<>();
|
|
|
|
+ for (JSONObject have : haveList) {
|
|
|
|
+ if (object.getLong("productId") == have.getLong("productId")) {
|
|
|
|
+ proList.add(have);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ object.put("projectList", proList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(list);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取项目以及账户信息
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/getProductProjectList")
|
|
|
|
+ public Result<List<JSONObject>> getProductProjectList(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ if (Check.isNull(userId)) {
|
|
|
|
+ throw new Exception("请选择userId");
|
|
|
|
+ }
|
|
|
|
+ List<Integer> mediaIds = new ArrayList<>();
|
|
|
|
+ //查询用户角色
|
|
|
|
+ String roleCode = sysRoleService.getRoleCodeByUserId(userId);
|
|
|
|
+ //角色为 管理员 || 销售 || 媒介 查询全部
|
|
|
|
+ if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
|
|
|
|
+ userId = null;
|
|
|
|
+ }
|
|
|
|
+ //查询项目信息以及广告主
|
|
|
|
+ List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
|
|
|
|
+ List<JSONObject> list = new ArrayList<>();
|
|
|
|
+ if (!Check.isNull(projectList)) {
|
|
|
|
+ list = projectService.queryProductInfo(projectList);
|
|
|
|
+ if (Check.isNull(list)) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("该用户没有可用的产品");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ for (JSONObject object : list) {
|
|
|
|
+ List<JSONObject> proList = new ArrayList<>();
|
|
|
|
+ for (JSONObject have : projectList) {
|
|
|
|
+ if (object.getLong("productId") == have.getLong("productId")) {
|
|
|
|
+ proList.add(have);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ object.put("projectList", proList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(list);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取项目以及账户信息
|
|
* 获取项目以及账户信息
|