|
@@ -2,12 +2,24 @@ package org.dromara.business.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.dromara.business.domain.UserComplaints;
|
|
import org.dromara.business.domain.UserComplaints;
|
|
|
|
|
+import org.dromara.business.domain.bo.ItemsBo;
|
|
|
|
|
+import org.dromara.business.domain.bo.UserBo;
|
|
|
import org.dromara.business.domain.bo.UserComplaintsBo;
|
|
import org.dromara.business.domain.bo.UserComplaintsBo;
|
|
|
import org.dromara.business.domain.enums.ComplaintsStatus;
|
|
import org.dromara.business.domain.enums.ComplaintsStatus;
|
|
|
-import org.dromara.business.domain.vo.UserComplaintsVo;
|
|
|
|
|
|
|
+import org.dromara.business.domain.enums.RewardStatusEnum;
|
|
|
|
|
+import org.dromara.business.domain.vo.*;
|
|
|
|
|
+import org.dromara.business.mapper.RewardClaimsMapper;
|
|
|
import org.dromara.business.mapper.UserComplaintsMapper;
|
|
import org.dromara.business.mapper.UserComplaintsMapper;
|
|
|
|
|
+import org.dromara.business.service.IItemsService;
|
|
|
import org.dromara.business.service.IUserComplaintsService;
|
|
import org.dromara.business.service.IUserComplaintsService;
|
|
|
|
|
+import org.dromara.business.service.IUserService;
|
|
|
|
|
+import org.dromara.business.utils.PageUtils;
|
|
|
|
|
+import org.dromara.business.utils.RedisKeys;
|
|
|
|
|
+import org.dromara.business.utils.RedisUtil;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -16,11 +28,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 用户申诉Service业务层处理
|
|
* 用户申诉Service业务层处理
|
|
@@ -35,6 +48,17 @@ public class UserComplaintsServiceImpl implements IUserComplaintsService {
|
|
|
|
|
|
|
|
private final UserComplaintsMapper baseMapper;
|
|
private final UserComplaintsMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IUserService iUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RewardClaimsMapper rewardClaimsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final IItemsService itemsService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询用户申诉
|
|
* 查询用户申诉
|
|
|
*
|
|
*
|
|
@@ -189,4 +213,106 @@ public class UserComplaintsServiceImpl implements IUserComplaintsService {
|
|
|
}
|
|
}
|
|
|
return baseMapper.deleteUserComplaintsById(ids) > 0;
|
|
return baseMapper.deleteUserComplaintsById(ids) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public TableDataInfo<PlayerVo> getAllUserRankByTournamentId(UserComplaintsBo bo, PageQuery pageQuery) {
|
|
|
|
|
+ Long tournamentId=bo.getTournamentId();
|
|
|
|
|
+ String leaderboardJson = redisUtil.get(RedisKeys.tournamentLeaderboard(tournamentId));
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ if(StringUtils.isEmpty(leaderboardJson)){
|
|
|
|
|
+ return TableDataInfo.build();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<PlayerVo> players = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ players = objectMapper.readValue(leaderboardJson,
|
|
|
|
|
+ objectMapper.getTypeFactory().constructCollectionType(List.class, PlayerVo.class));
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有用户
|
|
|
|
|
+ List<UserVo> userVoList = iUserService.queryList(new UserBo());
|
|
|
|
|
+
|
|
|
|
|
+ List<RewardClaimsVo> rewardClaimsVosList = rewardClaimsMapper.selectByCriteria(tournamentId);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建 id -> UserVo 的映射表(提升性能:O(1) 查找)
|
|
|
|
|
+ Map<Long, UserVo> userMap = userVoList.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(UserVo::getId, user -> user)); // 假设 UserVo 的 ID 是 getUserId()
|
|
|
|
|
+
|
|
|
|
|
+ //获奖信息
|
|
|
|
|
+ Map<Long, RewardClaimsVo> RewardClaimsMap = rewardClaimsVosList.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(RewardClaimsVo::getPlayerId, r -> r)); // 假设 UserVo 的 ID 是 getUserId()
|
|
|
|
|
+
|
|
|
|
|
+ //奖品的基本信息
|
|
|
|
|
+ List<ItemsVo> itemsVoList = itemsService.queryList(new ItemsBo());
|
|
|
|
|
+
|
|
|
|
|
+ //奖品的基本信息
|
|
|
|
|
+ Map<Long, ItemsVo> itemsVoMap = itemsVoList.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(ItemsVo::getId, r -> r)); // 假设 UserVo 的 ID 是 getUserId()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 为每个 PlayerVo 补充用户信息
|
|
|
|
|
+ for (PlayerVo player : players) {
|
|
|
|
|
+ player.setTournamentId(tournamentId);
|
|
|
|
|
+ UserVo userVo = userMap.get(player.getId()); // 假设 PlayerVo 的 id 是用户ID
|
|
|
|
|
+ if (userVo != null) {
|
|
|
|
|
+ player.setPlayerName(userVo.getNickName()); // 设置用户名
|
|
|
|
|
+ player.setPhone(userVo.getPhone()); // 设置手机号
|
|
|
|
|
+ // 其他字段也可以继续设置
|
|
|
|
|
+ }
|
|
|
|
|
+ RewardClaimsVo rewardClaimsVo = RewardClaimsMap.get(player.getId());
|
|
|
|
|
+ if(rewardClaimsVo!=null){
|
|
|
|
|
+ player.setClaimed(rewardClaimsVo.getClaimed());
|
|
|
|
|
+ player.setClaimedText(RewardStatusEnum.getDescriptionByCode(String.valueOf(rewardClaimsVo.getClaimed())));
|
|
|
|
|
+ //todo 奖励奖品信息
|
|
|
|
|
+ String rewardJson = rewardClaimsVo.getRewardJson();
|
|
|
|
|
+ if(StringUtils.isNotBlank(rewardJson)){
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ List<RewardVo> items = mapper.readValue(rewardJson, new TypeReference<List<RewardVo>>() {});
|
|
|
|
|
+ for (RewardVo item : items) {
|
|
|
|
|
+ ItemsVo itemsVo1 = itemsVoMap.get(item.getItemId());
|
|
|
|
|
+ if(itemsVo1!=null){
|
|
|
|
|
+ item.setItemName(itemsVo1.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ player.setRewardVoList(items);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 判断有没有申诉的
|
|
|
|
|
+ UserComplaintsVo complaintsVo = baseMapper.selectUserComplaintsPageByTournamentId(tournamentId,player.getId());
|
|
|
|
|
+ if(complaintsVo!=null){
|
|
|
|
|
+ player.setClaimed(Long.valueOf(RewardStatusEnum.COMPLAINTS.getCode()));
|
|
|
|
|
+ player.setClaimedText(RewardStatusEnum.COMPLAINTS.getDescription());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 打印结果
|
|
|
|
|
+ for (PlayerVo player : players) {
|
|
|
|
|
+ System.out.println("ID: " + player.getId());
|
|
|
|
|
+ System.out.println("Name: " + player.getName());
|
|
|
|
|
+ System.out.println("Username: " + player.getPlayerName());
|
|
|
|
|
+ System.out.println("Phonenumber: " + player.getPhone());
|
|
|
|
|
+ System.out.println("Chips: " + player.getChips());
|
|
|
|
|
+ System.out.println("Rank: " + player.getRank());
|
|
|
|
|
+ System.out.println("--------------------");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 调用分页方法
|
|
|
|
|
+ TableDataInfo<PlayerVo> pageInfo = PageUtils.toTablePage(players, pageQuery.getPageNum(), pageQuery.getPageSize());
|
|
|
|
|
+
|
|
|
|
|
+ return pageInfo;
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new RuntimeException("解析 Redis 数据失败", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ System.out.println(RedisKeys.tournamentLeaderboard(1L));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|