1.排行榜查询数据不准确修复
This commit is contained in:
@@ -35,7 +35,7 @@ public interface UserDao extends BaseMapper<UserEntity> {
|
|||||||
|
|
||||||
int insertUser(UserEntity userEntity);
|
int insertUser(UserEntity userEntity);
|
||||||
|
|
||||||
List<UserEntity> selectInviteUserList(String userName,String phone);
|
List<UserEntity> selectInviteUserList();
|
||||||
|
|
||||||
int selectUserOnLineCount(String qdCode);
|
int selectUserOnLineCount(String qdCode);
|
||||||
|
|
||||||
|
|||||||
@@ -1523,19 +1523,31 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result selectInviteUserList(Integer page, Integer limit, String userName, String phone) {
|
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);
|
PageHelper.startPage(page,limit);
|
||||||
List<UserEntity> userEntities = baseMapper.selectInviteUserList(userName, phone);
|
List<UserEntity> userEntityList = list(queryWrapper);
|
||||||
if (!userEntities.isEmpty()) {
|
|
||||||
Set<Long> userIdList = userEntities.stream().map(UserEntity::getUserId).collect(Collectors.toSet());
|
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>()
|
Map<Long, UserMoney> infoMap = userMoneyService.list(new LambdaQueryWrapper<UserMoney>()
|
||||||
.in(UserMoney::getUserId, userIdList))
|
.in(UserMoney::getUserId, userIdList))
|
||||||
.stream().collect(Collectors.toMap(UserMoney::getUserId, item -> item));
|
.stream().collect(Collectors.toMap(UserMoney::getUserId, item -> item));
|
||||||
userEntities.forEach(item -> {
|
userEntityList.forEach(item -> {
|
||||||
UserMoney userMoney = infoMap.get(item.getUserId());
|
UserMoney userMoney = infoMap.get(item.getUserId());
|
||||||
item.setMoney(userMoney == null ? BigDecimal.ZERO : userMoney.getInviteIncomeMoney());
|
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
|
@Override
|
||||||
|
|||||||
@@ -299,22 +299,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="selectInviteUserList" resultType="com.sqx.modules.app.entity.UserEntity">
|
<select id="selectInviteUserList" resultType="com.sqx.modules.app.entity.UserEntity">
|
||||||
SELECT
|
SELECT any_value(user_id) as userId, COUNT(*) AS counts FROM tb_user GROUP BY inviter_code order by counts desc
|
||||||
u.*,
|
|
||||||
IFNULL( b.counts, 0 ) AS counts,
|
|
||||||
0 AS money
|
|
||||||
FROM
|
|
||||||
tb_user u
|
|
||||||
LEFT JOIN ( SELECT inviter_code, COUNT(*) AS counts FROM tb_user u1 GROUP BY inviter_code ) AS b ON u.invitation_code = b.inviter_code
|
|
||||||
WHERE
|
|
||||||
1 = 1
|
|
||||||
<if test="userName!=null and userName!=''">
|
|
||||||
and user_name like concat('%',#{userName},'%')
|
|
||||||
</if>
|
|
||||||
<if test="phone!=null and phone!=''">
|
|
||||||
and phone like concat('%',#{phone},'%')
|
|
||||||
</if>
|
|
||||||
order by money desc,counts desc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserOnLineCount" resultType="Integer">
|
<select id="selectUserOnLineCount" resultType="Integer">
|
||||||
|
|||||||
Reference in New Issue
Block a user