|
@@ -93,66 +93,74 @@ public class UserController {
|
|
|
//查询主应用
|
|
//查询主应用
|
|
|
PageHelper.startPage(param.getPage(), param.getLimit());
|
|
PageHelper.startPage(param.getPage(), param.getLimit());
|
|
|
List<YtAppUserListView> result = appUserMapper.queryAll(param);
|
|
List<YtAppUserListView> result = appUserMapper.queryAll(param);
|
|
|
- String collect = result.stream().map(YtAppUserListView::getUserId).collect(Collectors.joining(","));
|
|
|
|
|
- List<YtDyzAdRecord> adRecords = adRecordMapper.getByUserIds(collect);
|
|
|
|
|
- List<YtDyzLoginRecord> dyzLogins = loginRecordMapper.getLoginRecordByIds(collect);
|
|
|
|
|
- Map<String, List<YtDyzAdRecord>> userAdMap = adRecords.stream().collect(
|
|
|
|
|
- Collectors.groupingBy(YtDyzAdRecord::getUserId));
|
|
|
|
|
- Map<String, List<YtDyzLoginRecord>> loginMap = dyzLogins.stream().collect(
|
|
|
|
|
- Collectors.groupingBy(YtDyzLoginRecord::getUserId));
|
|
|
|
|
- setUserExtInfo(result, param, userAdMap, loginMap);
|
|
|
|
|
|
|
+ setUserExtInfo(result, param);
|
|
|
return ResultTable.resultTableOk(new PageInfo<>(result));
|
|
return ResultTable.resultTableOk(new PageInfo<>(result));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 设置视频记录和登录信息
|
|
|
|
|
|
|
+ * 记录用户额外信息<br>
|
|
|
|
|
+ * 1.查询用户过往登陆信息<br>
|
|
|
|
|
+ * 2.查询并计算用户当日收益、当日视频播放数、前三日收益<br>
|
|
|
*/
|
|
*/
|
|
|
- private void setUserExtInfo(List<YtAppUserListView> result,YtAppUserListParam param,
|
|
|
|
|
- Map<String, List<YtDyzAdRecord>> userAdMap, Map<String, List<YtDyzLoginRecord>> loginMap) {
|
|
|
|
|
- List<YtDyzAdRecord> ytDyzAdRecords;
|
|
|
|
|
- DateTime currentDate = DateUtil.date();
|
|
|
|
|
|
|
+ private void setUserExtInfo(List<YtAppUserListView> result,YtAppUserListParam param) {
|
|
|
|
|
+ String userIds = result.stream().map(YtAppUserListView::getUserId).collect(Collectors.joining(","));
|
|
|
|
|
+ List<YtDyzAdRecord> adRecords = adRecordMapper.getByUserIds(userIds);
|
|
|
|
|
+ List<YtDyzLoginRecord> dyzLogins = loginRecordMapper.getLoginRecordByIds(userIds);
|
|
|
|
|
+ Map<String, List<YtDyzAdRecord>> userAdMap = adRecords.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(YtDyzAdRecord::getUserId));
|
|
|
|
|
+ Map<String, List<YtDyzLoginRecord>> loginMap = dyzLogins.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(YtDyzLoginRecord::getUserId));
|
|
|
for (YtAppUserListView user : result) {
|
|
for (YtAppUserListView user : result) {
|
|
|
if (loginMap.containsKey(user.getUserId())) {
|
|
if (loginMap.containsKey(user.getUserId())) {
|
|
|
user.setLoginRecordList(loginMap.get(user.getUserId()));
|
|
user.setLoginRecordList(loginMap.get(user.getUserId()));
|
|
|
}
|
|
}
|
|
|
- //获取当日收益收益 | 当日收益视频播放数 = 统计筛选登陆时间段
|
|
|
|
|
- int todayVideo = 0;
|
|
|
|
|
- BigDecimal todayIncome = BigDecimal.ZERO;
|
|
|
|
|
- if (userAdMap.containsKey(user.getUserId())) {
|
|
|
|
|
- // 默认筛选今日广告记录 并计算前三日收益
|
|
|
|
|
- ytDyzAdRecords = userAdMap.get(user.getUserId()).stream()
|
|
|
|
|
- .filter(s -> DateUtil.isSameDay(currentDate, DateUtil.parseDate(s.getFinishTime())))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- todayIncome = ytDyzAdRecords.stream().map(YtDyzAdRecord::getRevenue)
|
|
|
|
|
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
- // 统计4天-今日收益=前三日收益
|
|
|
|
|
- if (user.getNearlyIncome() != null && user.getNearlyIncome().compareTo(todayIncome) >= 0) {
|
|
|
|
|
- user.setNearlyIncome(user.getNearlyIncome().subtract(todayIncome));
|
|
|
|
|
|
|
+ computeTodayIncome(user, userAdMap.get(user.getUserId()), param);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 当日收益、当日视频播放数、前三日收益
|
|
|
|
|
+ */
|
|
|
|
|
+ private void computeTodayIncome(YtAppUserListView user, List<YtDyzAdRecord> adRecords, YtAppUserListParam param) {
|
|
|
|
|
+ //获取当日收益收益 | 当日收益视频播放数 = 统计筛选登陆时间段
|
|
|
|
|
+ int todayVideo = 0;
|
|
|
|
|
+ BigDecimal todayIncome = BigDecimal.ZERO;
|
|
|
|
|
+ DateTime currentDate = DateUtil.date();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(adRecords)) {
|
|
|
|
|
+ // 默认筛选今日广告记录 并计算前三日收益
|
|
|
|
|
+ List<YtDyzAdRecord> ytDyzAdRecords = adRecords.stream()
|
|
|
|
|
+ .filter(s -> DateUtil.isSameDay(currentDate, DateUtil.parseDate(s.getFinishTime())))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ todayIncome = ytDyzAdRecords.stream().map(YtDyzAdRecord::getRevenue)
|
|
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ // 统计4天-今日收益=前三日收益
|
|
|
|
|
+ if (user.getNearlyIncome() != null && user.getNearlyIncome().compareTo(todayIncome) >= 0) {
|
|
|
|
|
+ user.setNearlyIncome(user.getNearlyIncome().subtract(todayIncome));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果传递时间段 则按时间段筛选广告记录
|
|
|
|
|
+ if(param.getLastLoginTimeBegin() != null || param.getLastLoginTimeEnd() != null) {
|
|
|
|
|
+ ytDyzAdRecords = adRecords;
|
|
|
|
|
+ if (param.getLastLoginTimeBegin() != null) {
|
|
|
|
|
+ ytDyzAdRecords = ytDyzAdRecords.stream()
|
|
|
|
|
+ .filter(record -> DateUtil.afterSameDay(
|
|
|
|
|
+ DateUtil.parseDate(record.getFinishTime()), param.getLastLoginTimeBegin()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
- // 如果传递时间段 则按时间段筛选广告记录
|
|
|
|
|
- if(param.getLastLoginTimeBegin() != null || param.getLastLoginTimeEnd() != null) {
|
|
|
|
|
- if (param.getLastLoginTimeBegin() != null) {
|
|
|
|
|
- ytDyzAdRecords = userAdMap.get(user.getUserId()).stream()
|
|
|
|
|
- .filter(record -> DateUtil.afterSameDay(
|
|
|
|
|
- DateUtil.parseDate(record.getFinishTime()), param.getLastLoginTimeBegin()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- }
|
|
|
|
|
- if (param.getLastLoginTimeEnd() != null) {
|
|
|
|
|
- ytDyzAdRecords = ytDyzAdRecords.stream()
|
|
|
|
|
- .filter(record -> DateUtil.beforeSameDay(
|
|
|
|
|
- DateUtil.parseDate(record.getFinishTime()), param.getLastLoginTimeEnd()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- }
|
|
|
|
|
- todayIncome = ytDyzAdRecords.stream().map(YtDyzAdRecord::getRevenue)
|
|
|
|
|
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
+ if (param.getLastLoginTimeEnd() != null) {
|
|
|
|
|
+ ytDyzAdRecords = ytDyzAdRecords.stream()
|
|
|
|
|
+ .filter(record -> DateUtil.beforeSameDay(
|
|
|
|
|
+ DateUtil.parseDate(record.getFinishTime()), param.getLastLoginTimeEnd()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
- todayVideo = (int) ytDyzAdRecords.stream()
|
|
|
|
|
- .filter(record -> record.getAdSourceType() == AdSourceTypeEnum.rewarded_video.getAdSourceType())
|
|
|
|
|
- .count();
|
|
|
|
|
|
|
+ todayIncome = ytDyzAdRecords.stream().map(YtDyzAdRecord::getRevenue)
|
|
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
}
|
|
}
|
|
|
- user.setTodayVideo(todayVideo);
|
|
|
|
|
- user.setTodayIncome(todayIncome);
|
|
|
|
|
|
|
+ todayVideo = (int) ytDyzAdRecords.stream()
|
|
|
|
|
+ .filter(record -> record.getAdSourceType() == AdSourceTypeEnum.rewarded_video.getAdSourceType())
|
|
|
|
|
+ .count();
|
|
|
}
|
|
}
|
|
|
|
|
+ user.setTodayVideo(todayVideo);
|
|
|
|
|
+ user.setTodayIncome(todayIncome);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|