|
@@ -131,14 +131,14 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
//1 头条
|
|
//1 头条
|
|
if ("1".equals(mediaId)) {
|
|
if ("1".equals(mediaId)) {
|
|
//查询当日消耗 + 环比
|
|
//查询当日消耗 + 环比
|
|
- result = baseMapper.queryTtTodayCharge(statDay, hour, accountIds, null);
|
|
|
|
|
|
+ result = baseMapper.queryTtTodayCharge(statDay, hour, saleTeaMber, null);
|
|
//周消耗
|
|
//周消耗
|
|
- weekCharge = baseMapper.queryTtManydaysTotalCharge(weekFirstDay, statDay, accountIds, null);
|
|
|
|
|
|
+ weekCharge = baseMapper.queryTtManydaysTotalCharge(weekFirstDay, statDay, saleTeaMber, null);
|
|
//月消耗
|
|
//月消耗
|
|
- String monthCharge = baseMapper.queryTtManydaysTotalCharge(monthFirstday, statDay, accountIds, null);
|
|
|
|
|
|
+ String monthCharge = baseMapper.queryTtManydaysTotalCharge(monthFirstday, statDay, saleTeaMber, null);
|
|
result.put("weekCharge", new BigDecimal(weekCharge));
|
|
result.put("weekCharge", new BigDecimal(weekCharge));
|
|
result.put("monthCharge", new BigDecimal(monthCharge));
|
|
result.put("monthCharge", new BigDecimal(monthCharge));
|
|
- //现金消耗 + 环比ROI
|
|
|
|
|
|
+ //现金消耗 + 环比ROI 因为存在非本地账户,所以只能用本地账户查询现金消耗
|
|
JSONObject realCharged = baseMapper.queryTtRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, null);
|
|
JSONObject realCharged = baseMapper.queryTtRealCharged(lastMonthFirstday, monthFirstday, statDay, accountIds, null);
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realCharged", realCharged.getBigDecimal("realCharged"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
result.put("realChargedRoi", realCharged.getString("realChargedRoi"));
|
|
@@ -147,7 +147,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
if (!startTime.equals(statDay)) {
|
|
if (!startTime.equals(statDay)) {
|
|
hour = 23;
|
|
hour = 23;
|
|
}
|
|
}
|
|
- JSONObject oneResult = baseMapper.queryTtTodayCharge2(startTime, endTime, hour, accountIds, null, days);
|
|
|
|
|
|
+ JSONObject oneResult = baseMapper.queryTtTodayCharge2(startTime, endTime, hour, saleTeaMber, null, days);
|
|
result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
|
|
|
|
@@ -168,11 +168,11 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
result.put("twoChargeRoi2", twoResult2.getString("chargeRoi"));*/
|
|
result.put("twoChargeRoi2", twoResult2.getString("chargeRoi"));*/
|
|
|
|
|
|
} else if ("2".equals(mediaId)) {
|
|
} else if ("2".equals(mediaId)) {
|
|
- result = baseMapper.queryKsTodayCharge(statDay, hour, accountIds, null);
|
|
|
|
|
|
+ result = baseMapper.queryKsTodayCharge(statDay, hour, saleTeaMber, null);
|
|
//周消耗
|
|
//周消耗
|
|
- weekCharge = baseMapper.queryKsManydaysTotalCharge(weekFirstDay, statDay, accountIds, null);
|
|
|
|
|
|
+ weekCharge = baseMapper.queryKsManydaysTotalCharge(weekFirstDay, statDay, saleTeaMber, null);
|
|
//月消耗
|
|
//月消耗
|
|
- String monthCharge = baseMapper.queryKsManydaysTotalCharge(monthFirstday, statDay, accountIds, null);
|
|
|
|
|
|
+ String monthCharge = baseMapper.queryKsManydaysTotalCharge(monthFirstday, statDay, saleTeaMber, null);
|
|
result.put("weekCharge", new BigDecimal(weekCharge));
|
|
result.put("weekCharge", new BigDecimal(weekCharge));
|
|
result.put("monthCharge", new BigDecimal(monthCharge));
|
|
result.put("monthCharge", new BigDecimal(monthCharge));
|
|
//现金消耗 + 环比ROI
|
|
//现金消耗 + 环比ROI
|
|
@@ -183,7 +183,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
if (!startTime.equals(statDay)) {
|
|
if (!startTime.equals(statDay)) {
|
|
hour = 23;
|
|
hour = 23;
|
|
}
|
|
}
|
|
- JSONObject oneResult = baseMapper.queryKsTodayCharge2(startTime, endTime, hour, accountIds, null, days);
|
|
|
|
|
|
+ JSONObject oneResult = baseMapper.queryKsTodayCharge2(startTime, endTime, hour, saleTeaMber, null, days);
|
|
result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
result.put("oneChargeRoi", oneResult.getString("chargeRoi"));
|
|
/*result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
/*result.put("oneCharge", oneResult.getBigDecimal("totalCharge"));
|
|
@@ -240,46 +240,34 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
@Override
|
|
@Override
|
|
public Result<Object> getHomeCharges(String userId, String mediaId, String startTime, String endTime) throws ParseException {
|
|
public Result<Object> getHomeCharges(String userId, String mediaId, String startTime, String endTime) throws ParseException {
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = baseMapper.getRoleCodeByUserId(userId);
|
|
-
|
|
|
|
- List<Long> compayAllAccountIds = baseMapper.querySalesDirectorAccountIds(null, mediaId, null, null);
|
|
|
|
- if (Check.isNull(compayAllAccountIds)) {
|
|
|
|
- return Result.error("未查询到账户!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
JSONObject data = null;
|
|
JSONObject data = null;
|
|
//销售总监
|
|
//销售总监
|
|
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)) {
|
|
if (startTime.equals(endTime)) {
|
|
if (startTime.equals(endTime)) {
|
|
- data = getDailyCharges(null, compayAllAccountIds, userId, mediaId, null, startTime);
|
|
|
|
|
|
+ data = getDailyCharges(null, null, userId, mediaId, null, startTime);
|
|
} else {
|
|
} else {
|
|
- data = getManyDaysCharges(null, compayAllAccountIds, userId, mediaId, null, startTime, endTime);
|
|
|
|
|
|
+ data = getManyDaysCharges(null, null, userId, mediaId, null, startTime, endTime);
|
|
}
|
|
}
|
|
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(null, mediaId, saleTeaMber, null);
|
|
|
|
- if (Check.isNull(accountIds)) {
|
|
|
|
- return Result.error("未查询到账户!");
|
|
|
|
- }
|
|
|
|
if (startTime.equals(endTime)) {
|
|
if (startTime.equals(endTime)) {
|
|
//消耗数据
|
|
//消耗数据
|
|
- data = getDailyCharges(compayAllAccountIds, accountIds, userId, mediaId, null, startTime);
|
|
|
|
|
|
+ data = getDailyCharges("all", saleTeaMber, userId, mediaId, null, startTime);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- data = getManyDaysCharges(compayAllAccountIds, accountIds, userId, mediaId, null, startTime, endTime);
|
|
|
|
-
|
|
|
|
|
|
+ data = getManyDaysCharges("all", saleTeaMber, userId, mediaId, null, startTime, endTime);
|
|
}
|
|
}
|
|
//分公司总经理
|
|
//分公司总经理
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
} else if ("CompanyManager".equals(roleCode) || "admin".equals(roleCode)) {
|
|
if (startTime.equals(endTime)) {
|
|
if (startTime.equals(endTime)) {
|
|
- data = getDailyCharges(null, compayAllAccountIds, userId, mediaId, null, startTime);
|
|
|
|
|
|
+ data = getDailyCharges(null, null, userId, mediaId, null, startTime);
|
|
} else {
|
|
} else {
|
|
- data = getManyDaysCharges(null, compayAllAccountIds, userId, mediaId, null, startTime, endTime);
|
|
|
|
|
|
+ data = getManyDaysCharges(null, null, userId, mediaId, null, startTime, endTime);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return Result.error("该用户角色权限不足!");
|
|
return Result.error("该用户角色权限不足!");
|
|
@@ -287,7 +275,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
return Result.ok(data);
|
|
return Result.ok(data);
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject getManyDaysCharges(List<Long> compayAllAccountIds, List<Long> accountIds, String userId, String mediaId, String companyId, String startTime, String endTime) throws ParseException {
|
|
|
|
|
|
+ private JSONObject getManyDaysCharges(String type, List<String> saleTeaMber, String userId, String mediaId, String companyId, String startTime, String endTime) throws ParseException {
|
|
Map<String, String> map = DateUtils.getStartEndTime(startTime, endTime);
|
|
Map<String, String> map = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
|
|
|
//下个周期的开始时间
|
|
//下个周期的开始时间
|
|
@@ -299,28 +287,28 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
//1 头条
|
|
//1 头条
|
|
if ("1".equals(mediaId)) {
|
|
if ("1".equals(mediaId)) {
|
|
//查询 消耗 + 环比
|
|
//查询 消耗 + 环比
|
|
- result = baseMapper.queryTtManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, accountIds, companyId);
|
|
|
|
- List<JSONObject> list = baseMapper.queryTtManydaysCharge(startTime, endTime, accountIds, companyId);
|
|
|
|
|
|
+ result = baseMapper.queryTtManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, saleTeaMber, companyId);
|
|
|
|
+ List<JSONObject> list = baseMapper.queryTtManydaysCharge(startTime, endTime, saleTeaMber, companyId);
|
|
result.put("list", list);
|
|
result.put("list", list);
|
|
//平台消耗
|
|
//平台消耗
|
|
- if (compayAllAccountIds == null) {
|
|
|
|
|
|
+ if (type == null) {
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
} else {
|
|
} else {
|
|
- JSONObject ptdata = baseMapper.queryTtManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, compayAllAccountIds, companyId);
|
|
|
|
|
|
+ JSONObject ptdata = baseMapper.queryTtManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, null, companyId);
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
}
|
|
}
|
|
} else if ("2".equals(mediaId)) {
|
|
} else if ("2".equals(mediaId)) {
|
|
- result = baseMapper.queryKsManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, accountIds, companyId);
|
|
|
|
- List<JSONObject> list = baseMapper.queryKsManydaysCharge(startTime, endTime, accountIds, companyId);
|
|
|
|
|
|
+ result = baseMapper.queryKsManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, saleTeaMber, companyId);
|
|
|
|
+ List<JSONObject> list = baseMapper.queryKsManydaysCharge(startTime, endTime, saleTeaMber, companyId);
|
|
result.put("list", list);
|
|
result.put("list", list);
|
|
//平台消耗
|
|
//平台消耗
|
|
- if (compayAllAccountIds == null) {
|
|
|
|
|
|
+ if (type == null) {
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
} else {
|
|
} else {
|
|
- JSONObject ptdata = baseMapper.queryKsManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, compayAllAccountIds, companyId);
|
|
|
|
|
|
+ JSONObject ptdata = baseMapper.queryKsManydaysChargeAndRoi(startTime, endTime, lastTimeStart, lastTimeEnd, null, companyId);
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
}
|
|
}
|
|
@@ -329,7 +317,7 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private JSONObject getDailyCharges(List<Long> compayAllAccountIds, List<Long> accountIds, String userId, String mediaId, String companyId, String date) throws ParseException {
|
|
|
|
|
|
+ private JSONObject getDailyCharges(String type, List<String> saleTeaMber, String userId, String mediaId, String companyId, String date) throws ParseException {
|
|
//当前小时数
|
|
//当前小时数
|
|
Integer hour = DateUtils.getHour(DateUtils.formatDateTime());
|
|
Integer hour = DateUtils.getHour(DateUtils.formatDateTime());
|
|
if (!date.equals(DateUtils.date2Str())) {
|
|
if (!date.equals(DateUtils.date2Str())) {
|
|
@@ -339,28 +327,28 @@ public class ManagerSaleValueServiceImpl extends ServiceImpl<ManagerSaleValueMap
|
|
//1 头条
|
|
//1 头条
|
|
if ("1".equals(mediaId)) {
|
|
if ("1".equals(mediaId)) {
|
|
//查询当日消耗 + 环比
|
|
//查询当日消耗 + 环比
|
|
- result = baseMapper.queryTtTodayCharge(date, hour, accountIds, companyId);
|
|
|
|
- List<JSONObject> list = baseMapper.queryTtHourList(date, accountIds, companyId);
|
|
|
|
|
|
+ result = baseMapper.queryTtTodayCharge(date, hour, saleTeaMber, companyId);
|
|
|
|
+ List<JSONObject> list = baseMapper.queryTtHourList(date, saleTeaMber, companyId);
|
|
result.put("list", list);
|
|
result.put("list", list);
|
|
//平台消耗
|
|
//平台消耗
|
|
- if (compayAllAccountIds == null) {
|
|
|
|
|
|
+ if (type == null) {
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
} else {
|
|
} else {
|
|
- JSONObject ptdata = baseMapper.queryTtTodayCharge(date, hour, compayAllAccountIds, companyId);
|
|
|
|
|
|
+ JSONObject ptdata = baseMapper.queryTtTodayCharge(date, hour, null, companyId);
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
}
|
|
}
|
|
} else if ("2".equals(mediaId)) {
|
|
} else if ("2".equals(mediaId)) {
|
|
- result = baseMapper.queryKsTodayCharge(date, hour, accountIds, companyId);
|
|
|
|
- List<JSONObject> list = baseMapper.queryKsHourList(date, accountIds, companyId);
|
|
|
|
|
|
+ result = baseMapper.queryKsTodayCharge(date, hour, saleTeaMber, companyId);
|
|
|
|
+ List<JSONObject> list = baseMapper.queryKsHourList(date, saleTeaMber, companyId);
|
|
result.put("list", list);
|
|
result.put("list", list);
|
|
//平台消耗
|
|
//平台消耗
|
|
- if (compayAllAccountIds == null) {
|
|
|
|
|
|
+ if (type == null) {
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformCharge", result.getString("totalCharge"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", result.getString("chargeRoi"));
|
|
} else {
|
|
} else {
|
|
- JSONObject ptdata = baseMapper.queryKsTodayCharge(date, hour, compayAllAccountIds, companyId);
|
|
|
|
|
|
+ JSONObject ptdata = baseMapper.queryKsTodayCharge(date, hour, null, companyId);
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformCharge", ptdata.getString("totalCharge"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
result.put("platformChargeRoi", ptdata.getString("chargeRoi"));
|
|
}
|
|
}
|