1.排行榜查询数据不准确修复

This commit is contained in:
张松
2025-01-07 13:20:00 +08:00
parent 52f6016e39
commit a490541ccb
3 changed files with 19 additions and 22 deletions

View File

@@ -35,7 +35,7 @@ public interface UserDao extends BaseMapper<UserEntity> {
int insertUser(UserEntity userEntity);
List<UserEntity> selectInviteUserList(String userName,String phone);
List<UserEntity> selectInviteUserList();
int selectUserOnLineCount(String qdCode);

View File

@@ -1523,19 +1523,31 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Override
public Result selectInviteUserList(Integer page, Integer limit, String userName, String phone) {
LambdaQueryWrapper<UserEntity> queryWrapper = new LambdaQueryWrapper<>();
if(StrUtil.isNotBlank(userName)) {
queryWrapper.like(UserEntity::getUserName, userName);
}
if (StrUtil.isNotBlank(phone)) {
queryWrapper.like(UserEntity::getPhone, phone);
}
queryWrapper.orderByDesc(UserEntity::getCreateTime);
PageHelper.startPage(page,limit);
List<UserEntity> userEntities = baseMapper.selectInviteUserList(userName, phone);
if (!userEntities.isEmpty()) {
Set<Long> userIdList = userEntities.stream().map(UserEntity::getUserId).collect(Collectors.toSet());
List<UserEntity> userEntityList = list(queryWrapper);
Map<Long, Integer> countInfoMap = baseMapper.selectInviteUserList().stream().collect(Collectors.toMap(UserEntity::getUserId, UserEntity::getCounts));
if (!userEntityList.isEmpty()) {
Set<Long> userIdList = userEntityList.stream().map(UserEntity::getUserId).collect(Collectors.toSet());
Map<Long, UserMoney> infoMap = userMoneyService.list(new LambdaQueryWrapper<UserMoney>()
.in(UserMoney::getUserId, userIdList))
.stream().collect(Collectors.toMap(UserMoney::getUserId, item -> item));
userEntities.forEach(item -> {
userEntityList.forEach(item -> {
UserMoney userMoney = infoMap.get(item.getUserId());
item.setMoney(userMoney == null ? BigDecimal.ZERO : userMoney.getInviteIncomeMoney());
item.setCounts(countInfoMap.get(item.getUserId()));
});
}
return Result.success().put("data", PageUtils.page(new PageInfo<>(userEntities),true));
return Result.success().put("data", PageUtils.page(new PageInfo<>(userEntityList),true));
}
@Override