|
@@ -66,47 +66,45 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result<Object> getDayAndMonthlyCharges(String userId, String mediaId, String companyId) throws ParseException {
|
|
|
|
|
|
+ public Result<Object> getDayAndMonthlyCharges(String userId, String mediaId, String companyId, String operate) throws ParseException {
|
|
Result<Object> result = new Result<>();
|
|
Result<Object> result = new Result<>();
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
- Long weekly = baseMapper.getWeekly(userId, companyId, mediaId);
|
|
|
|
- Long monthly = baseMapper.getMonthly(userId, companyId, mediaId);
|
|
|
|
|
|
+ Boolean bjCompany = false;
|
|
|
|
+ if ("d57fecdcf7a94d009736d9c850731582".equals(companyId) && !Check.isNull(operate)) {
|
|
|
|
+ bjCompany = true;
|
|
|
|
+ }
|
|
|
|
+ List<String> oneUserIds = new ArrayList<>();
|
|
|
|
+ List<String> twoUserIds = new ArrayList<>();
|
|
//销售总监
|
|
//销售总监
|
|
if ("saleDirector".equals(roleCode) || "saleAm".equals(roleCode)) {
|
|
if ("saleDirector".equals(roleCode) || "saleAm".equals(roleCode)) {
|
|
//丁兆明特殊处理
|
|
//丁兆明特殊处理
|
|
if ("b161b7d9793942f980dbfe8c931cd1b0".equals(userId) || "228c45f913924639bf20c79ce5dadb16".equals(userId)) {
|
|
if ("b161b7d9793942f980dbfe8c931cd1b0".equals(userId) || "228c45f913924639bf20c79ce5dadb16".equals(userId)) {
|
|
//账户集合
|
|
//账户集合
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null);
|
|
|
|
|
|
+ List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, null);
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
return Result.error("未查询到账户!");
|
|
return Result.error("未查询到账户!");
|
|
}
|
|
}
|
|
- JSONObject data = getManagerData(accountIds, userId, mediaId, companyId);
|
|
|
|
- data.put("weeklyGoalValue", weekly);
|
|
|
|
- data.put("monthlyGoalValue", monthly);
|
|
|
|
|
|
+ JSONObject data = getManagerData(accountIds, userId, mediaId, companyId, bjCompany, null);
|
|
return Result.ok(data);
|
|
return Result.ok(data);
|
|
}
|
|
}
|
|
//查询销售总监及旗下的人员 集
|
|
//查询销售总监及旗下的人员 集
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
saleTeaMber.add(userId);
|
|
saleTeaMber.add(userId);
|
|
//账户集合
|
|
//账户集合
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber);
|
|
|
|
|
|
+ List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, null);
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
return Result.error("未查询到账户!");
|
|
return Result.error("未查询到账户!");
|
|
}
|
|
}
|
|
- JSONObject data = getManagerData(accountIds, userId, mediaId, companyId);
|
|
|
|
- data.put("weeklyGoalValue", weekly);
|
|
|
|
- data.put("monthlyGoalValue", monthly);
|
|
|
|
|
|
+ JSONObject data = getManagerData(accountIds, userId, mediaId, companyId, bjCompany, saleTeaMber);
|
|
result = Result.ok(data);
|
|
result = Result.ok(data);
|
|
//分公司总经理
|
|
//分公司总经理
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
//账户集合
|
|
//账户集合
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null);
|
|
|
|
|
|
+ List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, null);
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
return Result.error("未查询到账户!");
|
|
return Result.error("未查询到账户!");
|
|
}
|
|
}
|
|
- JSONObject data = getManagerData(accountIds, userId, mediaId, companyId);
|
|
|
|
- data.put("weeklyGoalValue", weekly);
|
|
|
|
- data.put("monthlyGoalValue", monthly);
|
|
|
|
|
|
+ JSONObject data = getManagerData(accountIds, userId, mediaId, companyId, bjCompany, null);
|
|
result = Result.ok(data);
|
|
result = Result.ok(data);
|
|
} else {
|
|
} else {
|
|
result = Result.error("该用户角色权限不足!");
|
|
result = Result.error("该用户角色权限不足!");
|
|
@@ -115,7 +113,8 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject getManagerData(List<Long> accountIds, String userId, String mediaId, String companyId) throws ParseException {
|
|
|
|
|
|
+
|
|
|
|
+ private JSONObject getManagerData(List<Long> accountIds, String userId, String mediaId, String companyId, boolean bjCompany, List<String> saleTeaMber) throws ParseException {
|
|
//当天日期
|
|
//当天日期
|
|
String statDay = DateUtils.date2Str();
|
|
String statDay = DateUtils.date2Str();
|
|
//当前小时数
|
|
//当前小时数
|
|
@@ -129,6 +128,12 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
|
|
|
|
JSONObject result = null;
|
|
JSONObject result = null;
|
|
String weekCharge = null;
|
|
String weekCharge = null;
|
|
|
|
+ //运营一部:李超及其下级 李超 id:f6a6843879c949618e4a859140c8a127
|
|
|
|
+ List<Long> oneAccountIds = null;
|
|
|
|
+ String lichaoId = "f6a6843879c949618e4a859140c8a127";
|
|
|
|
+ //运营二部:兰兰及其下级 兰兰id:461857c245f54ba5813bcb5900a23092
|
|
|
|
+ List<Long> twoAccountIds = null;
|
|
|
|
+ String lanlanId = "461857c245f54ba5813bcb5900a23092";
|
|
//1 头条
|
|
//1 头条
|
|
if ("1".equals(mediaId)) {
|
|
if ("1".equals(mediaId)) {
|
|
//查询当日消耗 + 环比
|
|
//查询当日消耗 + 环比
|
|
@@ -143,6 +148,19 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
JSONObject realCharged = baseMapper.queryTtRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, companyId);
|
|
JSONObject realCharged = baseMapper.queryTtRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, companyId);
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
|
|
+ if (bjCompany) {
|
|
|
|
+ //运营一部:李超及其下级 李超 id:f6a6843879c949618e4a859140c8a127
|
|
|
|
+ oneAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, lichaoId);
|
|
|
|
+ JSONObject oneResult = baseMapper.queryTtTodayCharge(statDay, hour, oneAccountIds, companyId);
|
|
|
|
+ result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
|
|
+ result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
|
|
+
|
|
|
|
+ //运营二部:兰兰及其下级 兰兰id:461857c245f54ba5813bcb5900a23092
|
|
|
|
+ twoAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, lanlanId);
|
|
|
|
+ JSONObject twoResult = baseMapper.queryTtTodayCharge(statDay, hour, twoAccountIds, companyId);
|
|
|
|
+ result.put("twoCharge", twoResult.getBigDecimal("totalCharge"));
|
|
|
|
+ result.put("twoChargeRoi", twoResult.getString("chargeRoi"));
|
|
|
|
+ }
|
|
} else if ("2".equals(mediaId)) {
|
|
} else if ("2".equals(mediaId)) {
|
|
result = baseMapper.queryKsTodayCharge(statDay, hour, accountIds, companyId);
|
|
result = baseMapper.queryKsTodayCharge(statDay, hour, accountIds, companyId);
|
|
//周消耗
|
|
//周消耗
|
|
@@ -155,6 +173,19 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
JSONObject realCharged = baseMapper.queryKsRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, companyId);
|
|
JSONObject realCharged = baseMapper.queryKsRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, companyId);
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
|
|
+ if (bjCompany) {
|
|
|
|
+ //运营一部:李超及其下级 李超 id:f6a6843879c949618e4a859140c8a127
|
|
|
|
+ oneAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, lichaoId);
|
|
|
|
+ JSONObject oneResult = baseMapper.queryKsTodayCharge(statDay, hour, oneAccountIds, companyId);
|
|
|
|
+ result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
|
|
+ result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
|
|
+
|
|
|
|
+ //运营二部:兰兰及其下级 兰兰id:461857c245f54ba5813bcb5900a23092
|
|
|
|
+ twoAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, lanlanId);
|
|
|
|
+ JSONObject twoResult = baseMapper.queryKsTodayCharge(statDay, hour, twoAccountIds, companyId);
|
|
|
|
+ result.put("twoCharge", twoResult.getBigDecimal("totalCharge"));
|
|
|
|
+ result.put("twoChargeRoi", twoResult.getString("chargeRoi"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
result.put("weeklyGoalValue", baseMapper.getWeekly(userId, companyId, mediaId));
|
|
result.put("weeklyGoalValue", baseMapper.getWeekly(userId, companyId, mediaId));
|
|
result.put("monthlyGoalValue", baseMapper.getMonthly(userId, companyId, mediaId));
|
|
result.put("monthlyGoalValue", baseMapper.getMonthly(userId, companyId, mediaId));
|
|
@@ -193,7 +224,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
public Result<Object> getHomeCharges(String userId, String mediaId, String companyId, String startTime, String endTime) throws ParseException {
|
|
public Result<Object> getHomeCharges(String userId, String mediaId, String companyId, String startTime, String endTime) throws ParseException {
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
|
|
|
|
- List<Long> compayAllAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null);
|
|
|
|
|
|
+ List<Long> compayAllAccountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, null);
|
|
if (Check.isNull(compayAllAccountIds)) {
|
|
if (Check.isNull(compayAllAccountIds)) {
|
|
return Result.error("未查询到账户!");
|
|
return Result.error("未查询到账户!");
|
|
}
|
|
}
|
|
@@ -214,7 +245,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
saleTeaMber.add(userId);
|
|
saleTeaMber.add(userId);
|
|
//账户集合
|
|
//账户集合
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber);
|
|
|
|
|
|
+ List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, null);
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
return Result.error("未查询到账户!");
|
|
return Result.error("未查询到账户!");
|
|
}
|
|
}
|
|
@@ -321,17 +352,35 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PageInfo getProjectChargeTop(String userId, String mediaId, String companyId, String startTime, String endTime, Integer pageNo, Integer pageSize) throws Exception {
|
|
|
|
- String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
|
|
|
|
+ public PageInfo getProjectChargeTop(String userId, String mediaId, String companyId, String startTime, String endTime, String operate, Integer pageNo, Integer pageSize) throws Exception {
|
|
|
|
+ Boolean bjCompany = false;
|
|
|
|
+ String operateUser = null;
|
|
|
|
+ if ("d57fecdcf7a94d009736d9c850731582".equals(companyId) && !Check.isNull(operate)) {
|
|
|
|
+ bjCompany = true;
|
|
|
|
+ if ("1".equals(operate)) {
|
|
|
|
+ //运营一部:李超及其下级 李超 id:f6a6843879c949618e4a859140c8a127
|
|
|
|
+ operateUser = "f6a6843879c949618e4a859140c8a127";
|
|
|
|
+ } else {
|
|
|
|
+ //运营二部:兰兰及其下级 兰兰id:461857c245f54ba5813bcb5900a23092
|
|
|
|
+ operateUser = "461857c245f54ba5813bcb5900a23092";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //账户集合
|
|
|
|
+ List<Long> accountIds = null;
|
|
//当天日期
|
|
//当天日期
|
|
String today = DateUtils.formatDate(new Date());
|
|
String today = DateUtils.formatDate(new Date());
|
|
JSONObject data = null;
|
|
JSONObject data = null;
|
|
|
|
+ String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
//销售总监
|
|
//销售总监
|
|
if ("saleDirector".equals(roleCode) || "saleAm".equals(roleCode)) {
|
|
if ("saleDirector".equals(roleCode) || "saleAm".equals(roleCode)) {
|
|
//丁兆明特殊处理
|
|
//丁兆明特殊处理
|
|
if ("b161b7d9793942f980dbfe8c931cd1b0".equals(userId) || "228c45f913924639bf20c79ce5dadb16".equals(userId)) {
|
|
if ("b161b7d9793942f980dbfe8c931cd1b0".equals(userId) || "228c45f913924639bf20c79ce5dadb16".equals(userId)) {
|
|
- //账户集合
|
|
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null);
|
|
|
|
|
|
+ if (bjCompany) {
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, operateUser);
|
|
|
|
+ } else {
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
throw new Exception("未查询到账户!");
|
|
throw new Exception("未查询到账户!");
|
|
}
|
|
}
|
|
@@ -343,14 +392,17 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
return getProjectDailyCharges(accountIds, companyId, mediaId, startTime, endTime, pageNo, pageSize);
|
|
return getProjectDailyCharges(accountIds, companyId, mediaId, startTime, endTime, pageNo, pageSize);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//查询销售总监及旗下的人员 集
|
|
//查询销售总监及旗下的人员 集
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
List<String> saleTeaMber = baseMapper.querySaleDirctorItsTeamMember(userId);
|
|
saleTeaMber.add(userId);
|
|
saleTeaMber.add(userId);
|
|
- //账户集合
|
|
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber);
|
|
|
|
- if (Check.isNull(accountIds)) {
|
|
|
|
- throw new Exception("未查询到账户!");
|
|
|
|
|
|
+ if (bjCompany) {
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, operateUser);
|
|
|
|
+ } else {
|
|
|
|
+ //账户集合
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, saleTeaMber, null);
|
|
|
|
+ if (Check.isNull(accountIds)) {
|
|
|
|
+ throw new Exception("未查询到账户!");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (startTime.equals(endTime) && today.equals(startTime)) {
|
|
if (startTime.equals(endTime) && today.equals(startTime)) {
|
|
return getProjectDailyCharges(accountIds, companyId, mediaId, startTime, null, pageNo, pageSize);
|
|
return getProjectDailyCharges(accountIds, companyId, mediaId, startTime, null, pageNo, pageSize);
|
|
@@ -361,8 +413,11 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
}
|
|
}
|
|
//分公司总经理
|
|
//分公司总经理
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
- //账户集合
|
|
|
|
- List<Long> accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null);
|
|
|
|
|
|
+ if (bjCompany) {
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, operateUser);
|
|
|
|
+ } else {
|
|
|
|
+ accountIds = baseMapper.querySalesDirectorAccountIds(companyId, mediaId, null, null);
|
|
|
|
+ }
|
|
if (Check.isNull(accountIds)) {
|
|
if (Check.isNull(accountIds)) {
|
|
throw new Exception("未查询到账户!");
|
|
throw new Exception("未查询到账户!");
|
|
}
|
|
}
|