|
@@ -13,6 +13,7 @@ import org.dromara.business.domain.enums.GameStatus;
|
|
|
import org.dromara.business.domain.vo.*;
|
|
import org.dromara.business.domain.vo.*;
|
|
|
import org.dromara.business.mapper.*;
|
|
import org.dromara.business.mapper.*;
|
|
|
import org.dromara.business.service.IBlindLevelsService;
|
|
import org.dromara.business.service.IBlindLevelsService;
|
|
|
|
|
+import org.dromara.business.utils.DateTimeRangeUtils;
|
|
|
import org.dromara.business.utils.RedisKeys;
|
|
import org.dromara.business.utils.RedisKeys;
|
|
|
import org.dromara.business.utils.RedisUtil;
|
|
import org.dromara.business.utils.RedisUtil;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -76,6 +77,10 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
|
|
|
|
|
private final IBlindLevelsService blindLevelsService;
|
|
private final IBlindLevelsService blindLevelsService;
|
|
|
|
|
|
|
|
|
|
+ private final ItemsMapper itemsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final RewardClaimsMapper rewardClaimsMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
|
@@ -315,15 +320,31 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), Tournaments::getName, bo.getName());
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), Tournaments::getName, bo.getName());
|
|
|
lqw.like(bo.getId() != null, Tournaments::getId, bo.getId());
|
|
lqw.like(bo.getId() != null, Tournaments::getId, bo.getId());
|
|
|
- lqw.like(bo.getStartTime() != null, Tournaments::getStartTime, bo.getStartTime());
|
|
|
|
|
|
|
+
|
|
|
lqw.eq(bo.getGameType() != null, Tournaments::getGameType, bo.getGameType());
|
|
lqw.eq(bo.getGameType() != null, Tournaments::getGameType, bo.getGameType());
|
|
|
lqw.eq(bo.getStartingChips() != null, Tournaments::getStartingChips, bo.getStartingChips());
|
|
lqw.eq(bo.getStartingChips() != null, Tournaments::getStartingChips, bo.getStartingChips());
|
|
|
lqw.eq(bo.getLevelDuration() != null, Tournaments::getLevelDuration, bo.getLevelDuration());
|
|
lqw.eq(bo.getLevelDuration() != null, Tournaments::getLevelDuration, bo.getLevelDuration());
|
|
|
lqw.eq(bo.getLateRegistrationLevel() != null, Tournaments::getLateRegistrationLevel, bo.getLateRegistrationLevel());
|
|
lqw.eq(bo.getLateRegistrationLevel() != null, Tournaments::getLateRegistrationLevel, bo.getLateRegistrationLevel());
|
|
|
lqw.eq(bo.getMaxPlayers() != null, Tournaments::getMaxPlayers, bo.getMaxPlayers());
|
|
lqw.eq(bo.getMaxPlayers() != null, Tournaments::getMaxPlayers, bo.getMaxPlayers());
|
|
|
- lqw.eq(bo.getStatus() != null, Tournaments::getStatus, bo.getStatus());
|
|
|
|
|
- lqw.eq(bo.getCreatedAt() != null, Tournaments::getCreatedAt, bo.getCreatedAt());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*lqw.eq(bo.getCreatedAt() != null, Tournaments::getCreatedAt, bo.getCreatedAt());*/
|
|
|
lqw.eq(bo.getUpdatedAt() != null, Tournaments::getUpdatedAt, bo.getUpdatedAt());
|
|
lqw.eq(bo.getUpdatedAt() != null, Tournaments::getUpdatedAt, bo.getUpdatedAt());
|
|
|
|
|
+ if(StringUtils.isNotBlank(bo.getFlagType())){
|
|
|
|
|
+ // 修改为时间范围查询:
|
|
|
|
|
+ if (bo.getStartTime() != null) {
|
|
|
|
|
+ lqw.ge(Tournaments::getStartTime, bo.getStartTime()); // 大于等于开始时间
|
|
|
|
|
+ lqw.le(Tournaments::getStartTime, bo.getEndTime()); // 小于等于结束时间
|
|
|
|
|
+ }
|
|
|
|
|
+ /* if (bo.getEndTime() != null) {
|
|
|
|
|
+ lqw.le(Tournaments::getStartTime, bo.getEndTime()); // 小于等于结束时间
|
|
|
|
|
+ }*/
|
|
|
|
|
+ lqw.notIn(Tournaments::getStatus, Arrays.asList(0L, 5L));
|
|
|
|
|
+ // 添加 is_delete=false 条件,过滤已删除的记录
|
|
|
|
|
+ lqw.eq(Tournaments::getIsDelete, false);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ lqw.like(bo.getStartTime() != null, Tournaments::getStartTime, bo.getStartTime());
|
|
|
|
|
+ lqw.eq(bo.getStatus() != null, Tournaments::getStatus, bo.getStatus());
|
|
|
|
|
+ }
|
|
|
return lqw;
|
|
return lqw;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -597,6 +618,13 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteTournament(Long id) {
|
|
public Boolean deleteTournament(Long id) {
|
|
|
|
|
+ if(id==null || id==0L){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("channelType", "tournament_delete");
|
|
|
|
|
+ jsonObject.put("value", id);
|
|
|
|
|
+ redisUtil.publish(RedisKeys.CHANNEL_ADMIN, jsonObject);
|
|
|
return baseMapper.deleteTournament(id) > 0;
|
|
return baseMapper.deleteTournament(id) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -613,23 +641,120 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- private List<ItemsPrizeDto> parsePrizeList(String itemsPrizeListJson, ObjectMapper mapper) throws Exception {
|
|
|
|
|
- if (itemsPrizeListJson == null || itemsPrizeListJson.isBlank()) {
|
|
|
|
|
- throw new IllegalArgumentException("itemsPrizeList 不能为空");
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public TableDataInfo<TournamentsVo> queryStatisticsPageList(TournamentsBo bo, PageQuery pageQuery) {
|
|
|
|
|
+ String startDate = "";
|
|
|
|
|
+ String endDate = "";
|
|
|
|
|
+ String flagType = bo.getFlagType();
|
|
|
|
|
+ if(StringUtils.isNotBlank(flagType) && (flagType.equals("day") || flagType.equals("week") || flagType.equals("month") || flagType.equals("three"))){
|
|
|
|
|
+ startDate = DateTimeRangeUtils.getStartString(flagType);
|
|
|
|
|
+ endDate = DateTimeRangeUtils.getEndString(flagType);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果同时传入了自定义时间,则检查是否在flagType范围内
|
|
|
|
|
+ String customStartDate = bo.getStartTime();
|
|
|
|
|
+ String customEndDate = bo.getEndTime();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果自定义时间在flagType范围内,则使用自定义时间
|
|
|
|
|
+ if (StringUtils.isNotBlank(customStartDate) && StringUtils.isNotBlank(customEndDate)) {
|
|
|
|
|
+ // 解析时间字符串
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ LocalDateTime customStart = LocalDateTime.parse(customStartDate, formatter);
|
|
|
|
|
+ LocalDateTime customEnd = LocalDateTime.parse(customEndDate, formatter);
|
|
|
|
|
+ LocalDateTime flagStart = LocalDateTime.parse(startDate, formatter);
|
|
|
|
|
+ LocalDateTime flagEnd = LocalDateTime.parse(endDate, formatter);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证自定义时间是否在flagType范围内
|
|
|
|
|
+ if (!customStart.isBefore(flagStart) && !customEnd.isAfter(flagEnd) && !customStart.isAfter(customEnd)) {
|
|
|
|
|
+ // 自定义时间在有效范围内,使用自定义时间
|
|
|
|
|
+ startDate = customStartDate;
|
|
|
|
|
+ endDate = customEndDate;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ startDate = bo.getStartTime();
|
|
|
|
|
+ endDate = bo.getEndTime();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String cleanedJson = itemsPrizeListJson.trim();
|
|
|
|
|
- if (cleanedJson.startsWith(",")) {
|
|
|
|
|
- cleanedJson = cleanedJson.substring(1);
|
|
|
|
|
|
|
+ bo.setStartTime(startDate);
|
|
|
|
|
+ bo.setEndTime(endDate);
|
|
|
|
|
+ LambdaQueryWrapper<Tournaments> lqw = buildQueryWrapper(bo);
|
|
|
|
|
+ Page<TournamentsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
+ for (TournamentsVo record : result.getRecords()) {
|
|
|
|
|
+ Long tournamentId = record.getId();
|
|
|
|
|
+ String statusText= GameStatus.getDescriptionFromCode(record.getStatus());
|
|
|
|
|
+ record.setStatusText(statusText);
|
|
|
|
|
+
|
|
|
|
|
+ int totalSignNum = participantsMapper.selectParticipantsTotal(tournamentId);
|
|
|
|
|
+ record.setSignNum(totalSignNum);
|
|
|
|
|
+
|
|
|
|
|
+ //赛事报名条件
|
|
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfo(tournamentId);
|
|
|
|
|
+ String tournamentCondition="";
|
|
|
|
|
+ Long tournamentConditionValue=0L;
|
|
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
|
|
+ record.setItemsId(tournamentEntryConditionsVo.getItemId());
|
|
|
|
|
+ record.setItemsNum(tournamentEntryConditionsVo.getRequiredQuantity());
|
|
|
|
|
+ record.setItemsName(tournamentEntryConditionsVo.getItemsName());
|
|
|
|
|
+ // 绑定报名条件
|
|
|
|
|
+ tournamentCondition=tournamentEntryConditionsVo.getItemsName();
|
|
|
|
|
+ //计算 条件数
|
|
|
|
|
+ ItemsVo itemsVo = itemsMapper.selectVoByIdInfo(tournamentEntryConditionsVo.getItemId());
|
|
|
|
|
+ if(itemsVo!=null){
|
|
|
|
|
+ tournamentConditionValue=itemsVo.getItemValue()*tournamentEntryConditionsVo.getRequiredQuantity();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ record.setTournamentCondition(tournamentCondition);
|
|
|
|
|
+ record.setTournamentConditionValue(tournamentConditionValue);
|
|
|
|
|
+ //总报名价值
|
|
|
|
|
+ long signValue = totalSignNum * tournamentConditionValue;
|
|
|
|
|
+ record.setSignValue(signValue);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //排名
|
|
|
|
|
+ List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentId(tournamentId);
|
|
|
|
|
+ if(prizeDistributionsVos!=null){
|
|
|
|
|
+ List<ItemsPrizeDto> itemsPrizeList=new ArrayList<>();
|
|
|
|
|
+ StringBuilder prizeDisplayBuilder = new StringBuilder();
|
|
|
|
|
+ // 提取并按排名正序排序后,取出 id 列表
|
|
|
|
|
+ List<Long> ids = prizeDistributionsVos.stream()
|
|
|
|
|
+ .sorted(Comparator.comparing(PrizeDistributionsVo::getPaiming))
|
|
|
|
|
+ .map(PrizeDistributionsVo::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ int i=0;
|
|
|
|
|
+ for (Long id2 : ids) {
|
|
|
|
|
+ i++;
|
|
|
|
|
+ //奖品
|
|
|
|
|
+ PrizeDistributionItemsVo prizeDistributionItemsVos = prizeDistributionItemsMapper.selectByPrizeDistributionId(id2);
|
|
|
|
|
+ if(prizeDistributionItemsVos!=null){
|
|
|
|
|
+ ItemsPrizeDto itemsPrizeBo = new ItemsPrizeDto();
|
|
|
|
|
+ itemsPrizeBo.setRanking(Long.valueOf(i));
|
|
|
|
|
+ itemsPrizeBo.setItemId(prizeDistributionItemsVos.getItemId());
|
|
|
|
|
+ itemsPrizeBo.setQuantity(prizeDistributionItemsVos.getQuantity());
|
|
|
|
|
+ itemsPrizeBo.setItemsName(prizeDistributionItemsVos.getItemsName());
|
|
|
|
|
+ itemsPrizeList.add(itemsPrizeBo);
|
|
|
|
|
+ // 拼接 name*quantity 格式字符串
|
|
|
|
|
+ if (prizeDisplayBuilder.length() > 0) {
|
|
|
|
|
+ prizeDisplayBuilder.append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+ prizeDisplayBuilder.append(prizeDistributionItemsVos.getItemsName())
|
|
|
|
|
+ .append("*")
|
|
|
|
|
+ .append(prizeDistributionItemsVos.getQuantity());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ record.setItemsPrizeList(itemsPrizeList);
|
|
|
|
|
+ record.setPrizeDisplay(prizeDisplayBuilder.toString()); // 假设 TournamentsVo 中有 prizeDisplay 字段
|
|
|
|
|
+ }
|
|
|
|
|
+ //奖励名次 数量
|
|
|
|
|
+ int rewardClaimsCount= rewardClaimsMapper.selectRewardClaimsCount(tournamentId);
|
|
|
|
|
+ record.setRewardClaimsCount(rewardClaimsCount);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return mapper.readValue(
|
|
|
|
|
- cleanedJson,
|
|
|
|
|
- mapper.getTypeFactory().constructCollectionType(List.class, ItemsPrizeDto.class)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ return TableDataInfo.build(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private Date parseDateTime(String dateTimeStr) throws ParseException {
|
|
private Date parseDateTime(String dateTimeStr) throws ParseException {
|
|
|
if (dateTimeStr == null || dateTimeStr.isBlank()) {
|
|
if (dateTimeStr == null || dateTimeStr.isBlank()) {
|
|
|
throw new IllegalArgumentException("startTime 不能为空");
|
|
throw new IllegalArgumentException("startTime 不能为空");
|