|
@@ -1188,6 +1188,97 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result getKuaiShouOperateAccountInfo(Integer pageNum, int pageSize, String startTime, String endTime, String projectId, String userId) {
|
|
|
+ String mediaType = null;
|
|
|
+ //查询用户角色
|
|
|
+ String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
|
|
|
+ //判断是否运营相关角色,并获取媒体类型
|
|
|
+ if (!Check.isNull(roleCode)) {
|
|
|
+ if ("touTiaoOperationManager".equals(roleCode)) {
|
|
|
+ mediaType = "1";
|
|
|
+ } else if ("kuaishouOperationManager".equals(roleCode)) {
|
|
|
+ mediaType = "2";
|
|
|
+ } else if (roleCode.toLowerCase().contains("perat")) {
|
|
|
+ String leaderRoleCode = materialStareMapper.getOperatLeaderRole(userId);
|
|
|
+ if (!Check.isNull(leaderRoleCode)) {
|
|
|
+ if ("touTiaoOperationManager".equals(leaderRoleCode)) {
|
|
|
+ mediaType = "1";
|
|
|
+ } else if ("kuaishouOperationManager".equals(leaderRoleCode)) {
|
|
|
+ mediaType = "2";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result.successMsg("非运营相关角色,不显示数据", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("1".equals(mediaType)) {
|
|
|
+ return getBytedanceOperateAccountInfo(pageNum, pageSize, startTime, endTime, projectId, userId);
|
|
|
+ } else {
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00%");
|
|
|
+ try {
|
|
|
+ //查询当前人员所有下级
|
|
|
+ Set<String> operatorUserIds = getAffiliateId(userId);
|
|
|
+ //2022-02-15 ==>> 20220215
|
|
|
+ long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
+ long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
+
|
|
|
+ //计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
|
|
|
+ Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
+ long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
+ long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
+ Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween")) + 1;
|
|
|
+
|
|
|
+ //计算同比 时间值 只支持7天
|
|
|
+ long startEqually = new Long("0");
|
|
|
+ long endEqually = new Long("0");
|
|
|
+ if (daysBetween <= 7) {
|
|
|
+ startEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7));
|
|
|
+ endEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7));
|
|
|
+ }
|
|
|
+
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //查询运营数据-账户 维度
|
|
|
+ List<KuaiShouOperateAccountVo> listOperate = materialStareMapper.getKuaiShouOperateAccountInfo(startDate, entDate, projectId, null, operatorUserIds);
|
|
|
+ for (KuaiShouOperateAccountVo accountInfo : listOperate) {
|
|
|
+
|
|
|
+ //查询 有效 上新视频 爆款视频
|
|
|
+ JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null, null, String.valueOf(accountInfo.getAccountId()), startDate, entDate);
|
|
|
+ accountInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
|
|
|
+ accountInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
|
|
|
+ accountInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
|
|
|
+
|
|
|
+ long accountId = accountInfo.getAccountId();
|
|
|
+ List<KuaiShouOperateAccountVo> accountYearOnYearInfo = materialStareMapper.getKuaiShouOperateAccountInfo(lastTimeStart, lastTimeEnd, projectId, accountId, operatorUserIds);
|
|
|
+ //环比 = (当前 - 上阶段 ) / 上阶段
|
|
|
+ String yearOnYear = "0";
|
|
|
+ if (!Check.isNull(accountYearOnYearInfo)) {
|
|
|
+ Double yearOnYearD = (accountInfo.getTotalCost() - accountYearOnYearInfo.get(0).getTotalCost()) / accountYearOnYearInfo.get(0).getTotalCost();
|
|
|
+ yearOnYear = decimalFormat.format(yearOnYearD);
|
|
|
+ }
|
|
|
+ accountInfo.setYearOnYear(yearOnYear);
|
|
|
+
|
|
|
+ //同比 日期超过 7 天 则不显示
|
|
|
+ String equallyRate = "-";
|
|
|
+ if (daysBetween <= 7) {
|
|
|
+ List<KuaiShouOperateAccountVo> accountEquallyInfo = materialStareMapper.getKuaiShouOperateAccountInfo(startEqually, endEqually, projectId, accountId, operatorUserIds);
|
|
|
+ if (!Check.isNull(accountEquallyInfo)) {
|
|
|
+ Double equallyRateD = (accountInfo.getTotalCost() - accountEquallyInfo.get(0).getTotalCost()) / accountEquallyInfo.get(0).getTotalCost();
|
|
|
+ equallyRate = decimalFormat.format(equallyRateD);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountInfo.setEquallyRate(equallyRate);
|
|
|
+ }
|
|
|
+
|
|
|
+ PageInfo<KuaiShouOperateAccountVo> pageInfo = new PageInfo<>(listOperate);
|
|
|
+ return Result.successMsg("运营账户列表数据查询成功。", pageInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.errorMsg("哎呀,查询失败了。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Result getBytedanceOperateAccountInfo(Integer pageNum, int pageSize, String startTime, String endTime, String projectId, String userId) {
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
|
|
|
try {
|
|
|
//查询当前人员所有下级
|
|
@@ -1209,20 +1300,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
startEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7));
|
|
|
endEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7));
|
|
|
}
|
|
|
-
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
//查询运营数据-账户 维度
|
|
|
- List<KuaiShouOperateAccountVo> listOperate = materialStareMapper.getKuaiShouOperateAccountInfo(startDate, entDate, projectId, null, operatorUserIds);
|
|
|
+ List<KuaiShouOperateAccountVo> listOperate = materialStareMapper.getBytedanceOperateAccountInfo(startDate, entDate, projectId, null, operatorUserIds);
|
|
|
for (KuaiShouOperateAccountVo accountInfo : listOperate) {
|
|
|
|
|
|
- //查询 有效 上新视频 爆款视频
|
|
|
- JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null, null, String.valueOf(accountInfo.getAccountId()), startDate, entDate);
|
|
|
- accountInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
|
|
|
- accountInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
|
|
|
- accountInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
|
|
|
-
|
|
|
long accountId = accountInfo.getAccountId();
|
|
|
- List<KuaiShouOperateAccountVo> accountYearOnYearInfo = materialStareMapper.getKuaiShouOperateAccountInfo(lastTimeStart, lastTimeEnd, projectId, accountId, operatorUserIds);
|
|
|
+ List<KuaiShouOperateAccountVo> accountYearOnYearInfo = materialStareMapper.getBytedanceOperateAccountInfo(lastTimeStart, lastTimeEnd, projectId, accountId, operatorUserIds);
|
|
|
//环比 = (当前 - 上阶段 ) / 上阶段
|
|
|
String yearOnYear = "0";
|
|
|
if (!Check.isNull(accountYearOnYearInfo)) {
|
|
@@ -1234,7 +1318,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//同比 日期超过 7 天 则不显示
|
|
|
String equallyRate = "-";
|
|
|
if (daysBetween <= 7) {
|
|
|
- List<KuaiShouOperateAccountVo> accountEquallyInfo = materialStareMapper.getKuaiShouOperateAccountInfo(startEqually, endEqually, projectId, accountId, operatorUserIds);
|
|
|
+ List<KuaiShouOperateAccountVo> accountEquallyInfo = materialStareMapper.getBytedanceOperateAccountInfo(startEqually, endEqually, projectId, accountId, operatorUserIds);
|
|
|
if (!Check.isNull(accountEquallyInfo)) {
|
|
|
Double equallyRateD = (accountInfo.getTotalCost() - accountEquallyInfo.get(0).getTotalCost()) / accountEquallyInfo.get(0).getTotalCost();
|
|
|
equallyRate = decimalFormat.format(equallyRateD);
|
|
@@ -1242,7 +1326,6 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
}
|
|
|
accountInfo.setEquallyRate(equallyRate);
|
|
|
}
|
|
|
-
|
|
|
PageInfo<KuaiShouOperateAccountVo> pageInfo = new PageInfo<>(listOperate);
|
|
|
return Result.successMsg("运营账户列表数据查询成功。", pageInfo);
|
|
|
} catch (Exception e) {
|