|
|
@@ -0,0 +1,478 @@
|
|
|
+package org.dromara.business.service.impl;
|
|
|
+
|
|
|
+import org.dromara.business.domain.ScheduleEventGroupConfig;
|
|
|
+import org.dromara.business.domain.ScheduleEventGroupItem;
|
|
|
+import org.dromara.business.domain.ScheduleTournamentsReletion;
|
|
|
+import org.dromara.business.domain.bo.ScheduleEventGroupConfigBo;
|
|
|
+import org.dromara.business.domain.bo.ScheduleEventGroupItemBo;
|
|
|
+import org.dromara.business.domain.dto.ItemsPrizeDto;
|
|
|
+import org.dromara.business.domain.dto.TournamentsDto;
|
|
|
+import org.dromara.business.domain.vo.*;
|
|
|
+import org.dromara.business.mapper.*;
|
|
|
+import org.dromara.business.service.IScheduleEventGroupConfigService;
|
|
|
+import org.dromara.business.service.ITournamentsService;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 赛事组别配置主Service业务层处理
|
|
|
+ *
|
|
|
+ * @author Lion Li
|
|
|
+ * @date 2025-12-26
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class ScheduleEventGroupConfigServiceImpl implements IScheduleEventGroupConfigService {
|
|
|
+
|
|
|
+ private final ScheduleEventGroupConfigMapper baseMapper;
|
|
|
+
|
|
|
+ private final ScheduleEventGroupItemMapper scheduleEventGroupItemMapper;
|
|
|
+
|
|
|
+ private final TournamentsTemplateMapper tournamentsTemplateMapper;
|
|
|
+
|
|
|
+ private final TournamentEntryConditionsTemplateMapper tournamentEntryConditionsMapper;
|
|
|
+
|
|
|
+ private final TournamentBlindStructuresTemplateMapper tournamentBlindStructuresMapper;
|
|
|
+
|
|
|
+ private final PrizeDistributionsTemplateMapper prizeDistributionsMapper;
|
|
|
+
|
|
|
+ private final PrizeDistributionItemsTemplateMapper prizeDistributionItemsMapper;
|
|
|
+
|
|
|
+ private final TournamentCategoryTagTemplateMapper tournamentCategoryTagTemplateMapper;
|
|
|
+
|
|
|
+ private final ITournamentsService iTournamentsService;
|
|
|
+
|
|
|
+ private final ScheduleTournamentsReletionMapper scheduleTournamentsReletionMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询赛事组别配置主
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 赛事组别配置主
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ScheduleEventGroupConfigVo queryById(Long id){
|
|
|
+ ScheduleEventGroupConfigVo scheduleEventGroupConfigVo = baseMapper.selectScheduleEventGroupById(id);
|
|
|
+ if(scheduleEventGroupConfigVo!=null){
|
|
|
+ List<ScheduleEventGroupItemVo> scheduleEventGroupItemVoList = scheduleEventGroupItemMapper.selectScheduleEventGroupConfigByConfigId(id);
|
|
|
+ scheduleEventGroupConfigVo.setGroups(scheduleEventGroupItemVoList);
|
|
|
+ }
|
|
|
+ return scheduleEventGroupConfigVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询赛事组别配置主列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 赛事组别配置主分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<ScheduleEventGroupConfigVo> queryPageList(ScheduleEventGroupConfigBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<ScheduleEventGroupConfig> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<ScheduleEventGroupConfigVo> result = baseMapper.selectScheduleEventGroupPage(pageQuery.build(), lqw);
|
|
|
+ result.getRecords().forEach(item -> {
|
|
|
+ List<ScheduleEventGroupItemVo> scheduleEventGroupItemVoList = scheduleEventGroupItemMapper.selectScheduleEventGroupConfigByConfigId(item.getId());
|
|
|
+ item.setGroups(scheduleEventGroupItemVoList);
|
|
|
+ //查询对应模版名称
|
|
|
+ TournamentsVo tournamentsVo = tournamentsTemplateMapper.selectVoByIdInfoTemplate(item.getRegularTemplateId());
|
|
|
+ if(tournamentsVo!=null){
|
|
|
+ item.setRegularTemplateName(tournamentsVo.getName());
|
|
|
+ }
|
|
|
+ TournamentsVo finalTournamentsVo = tournamentsTemplateMapper.selectVoByIdInfoTemplate(item.getFinalTemplateId());
|
|
|
+ if(finalTournamentsVo!=null){
|
|
|
+ item.setFinalTemplateName(finalTournamentsVo.getName());
|
|
|
+ //赛事报名条件
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfoTemplate(finalTournamentsVo.getId());
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
+ item.setItemsNum(tournamentEntryConditionsVo.getRequiredQuantity());
|
|
|
+ item.setItemsName(tournamentEntryConditionsVo.getItemsName());
|
|
|
+ }
|
|
|
+ //绑定的盲注信息
|
|
|
+ TournamentBlindStructuresVo tournamentBlindStructuresVo = tournamentBlindStructuresMapper.selectTournamentBlindStructureByTournamentIdTemplate(finalTournamentsVo.getId());
|
|
|
+ if(tournamentBlindStructuresVo!=null){
|
|
|
+ item.setBlindStructuresName(tournamentBlindStructuresVo.getBlindStructuresName());
|
|
|
+ }
|
|
|
+ //排名
|
|
|
+ List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentIdTemplate(finalTournamentsVo.getId());
|
|
|
+ if(prizeDistributionsVos!=null){
|
|
|
+ List<ItemsPrizeDto> itemsPrizeList=new ArrayList<>();
|
|
|
+
|
|
|
+ // 提取并按排名正序排序后,取出 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.selectByPrizeDistributionIdTemplate(id2);
|
|
|
+ ItemsPrizeDto itemsPrizeBo = new ItemsPrizeDto();
|
|
|
+ itemsPrizeBo.setRanking(Long.valueOf(i));
|
|
|
+ itemsPrizeBo.setItemId(prizeDistributionItemsVos.getItemId());
|
|
|
+ itemsPrizeBo.setQuantity(prizeDistributionItemsVos.getQuantity());
|
|
|
+ itemsPrizeList.add(itemsPrizeBo);
|
|
|
+
|
|
|
+ }
|
|
|
+ item.setItemsPrizeList(itemsPrizeList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的赛事组别配置主列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 赛事组别配置主列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ScheduleEventGroupConfigVo> queryList(ScheduleEventGroupConfigBo bo) {
|
|
|
+ LambdaQueryWrapper<ScheduleEventGroupConfig> lqw = buildQueryWrapper(bo);
|
|
|
+ return baseMapper.selectScheduleEventGroupList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<ScheduleEventGroupConfig> buildQueryWrapper(ScheduleEventGroupConfigBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<ScheduleEventGroupConfig> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(ScheduleEventGroupConfig::getId);
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getName()), ScheduleEventGroupConfig::getName, bo.getName());
|
|
|
+ lqw.eq(bo.getRegularTemplateId() != null, ScheduleEventGroupConfig::getRegularTemplateId, bo.getRegularTemplateId());
|
|
|
+ lqw.eq(bo.getFinalTemplateId() != null, ScheduleEventGroupConfig::getFinalTemplateId, bo.getFinalTemplateId());
|
|
|
+ lqw.eq(bo.getStartDate() != null, ScheduleEventGroupConfig::getStartDate, bo.getStartDate());
|
|
|
+ lqw.eq(bo.getCreatedAt() != null, ScheduleEventGroupConfig::getCreatedAt, bo.getCreatedAt());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增赛事组别配置主
|
|
|
+ *
|
|
|
+ * @param bo 赛事组别配置主
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(ScheduleEventGroupConfigBo bo) {
|
|
|
+ ScheduleEventGroupConfig add = MapstructUtils.convert(bo, ScheduleEventGroupConfig.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insertScheduleEventGroup(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ List<ScheduleEventGroupItemBo> eventGroupItemBoList = bo.getGroups();
|
|
|
+ for (ScheduleEventGroupItemBo scheduleEventGroupItemBo : eventGroupItemBoList) {
|
|
|
+ ScheduleEventGroupItem scheduleEventGroupItem = new ScheduleEventGroupItem();
|
|
|
+ scheduleEventGroupItem.setConfigId(add.getId());
|
|
|
+ scheduleEventGroupItem.setGroupName(scheduleEventGroupItemBo.getGroupName());
|
|
|
+ scheduleEventGroupItem.setIntervalDays(scheduleEventGroupItemBo.getIntervalDays());
|
|
|
+ scheduleEventGroupItem.setDurationMinutes(scheduleEventGroupItemBo.getDurationMinutes());
|
|
|
+ scheduleEventGroupItem.setExecutionTime(scheduleEventGroupItemBo.getExecutionTime());
|
|
|
+ scheduleEventGroupItem.setStatus("ACTIVE");
|
|
|
+ scheduleEventGroupItemMapper.insertScheduleEventGroupConfig(scheduleEventGroupItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改赛事组别配置主
|
|
|
+ *
|
|
|
+ * @param bo 赛事组别配置主
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(ScheduleEventGroupConfigBo bo) {
|
|
|
+ ScheduleEventGroupConfig update = MapstructUtils.convert(bo, ScheduleEventGroupConfig.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ int updated = baseMapper.updateScheduleEventGroup(update);
|
|
|
+ if (updated > 0) {
|
|
|
+ scheduleEventGroupItemMapper.delScheduleEventGroupByConfigId(update.getId());
|
|
|
+ List<ScheduleEventGroupItemBo> eventGroupItemBoList = bo.getGroups();
|
|
|
+ for (ScheduleEventGroupItemBo scheduleEventGroupItemBo : eventGroupItemBoList) {
|
|
|
+ ScheduleEventGroupItem scheduleEventGroupItem = new ScheduleEventGroupItem();
|
|
|
+ scheduleEventGroupItem.setConfigId(update.getId());
|
|
|
+ scheduleEventGroupItem.setGroupName(scheduleEventGroupItemBo.getGroupName());
|
|
|
+ scheduleEventGroupItem.setIntervalDays(scheduleEventGroupItemBo.getIntervalDays());
|
|
|
+ scheduleEventGroupItem.setDurationMinutes(scheduleEventGroupItemBo.getDurationMinutes());
|
|
|
+ scheduleEventGroupItem.setExecutionTime(scheduleEventGroupItemBo.getExecutionTime());
|
|
|
+ scheduleEventGroupItem.setStatus("ACTIVE");
|
|
|
+ scheduleEventGroupItemMapper.insertScheduleEventGroupConfig(scheduleEventGroupItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return updated > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(ScheduleEventGroupConfig entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除赛事组别配置主信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ for (Long id : ids) {
|
|
|
+ scheduleEventGroupItemMapper.delScheduleEventGroupByConfigId(id);
|
|
|
+ }
|
|
|
+ return baseMapper.deleteScheduleEventGroup(ids) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void generateXiLieTournament(Long eventId) {
|
|
|
+ log.info("开始生成系列赛,eventId: {}", eventId);
|
|
|
+
|
|
|
+ // 校验对应日期是否生成过赛事
|
|
|
+ ScheduleEventGroupConfigVo scheduleEventGroupConfigVo = baseMapper.selectScheduleEventGroupById(eventId);
|
|
|
+ if (scheduleEventGroupConfigVo == null) {
|
|
|
+ log.warn("未找到对应的赛事组别配置,eventId: {}", eventId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("赛事组别配置信息 - id: {}, 名称: {}, 开始日期: {}, 决赛开始日期: {}",
|
|
|
+ scheduleEventGroupConfigVo.getId(),
|
|
|
+ scheduleEventGroupConfigVo.getName(),
|
|
|
+ scheduleEventGroupConfigVo.getStartDate(),
|
|
|
+ scheduleEventGroupConfigVo.getFinalStartDate());
|
|
|
+
|
|
|
+ // 决赛模版
|
|
|
+ Long finalTemplateId = scheduleEventGroupConfigVo.getFinalTemplateId();
|
|
|
+ // 常规赛模版
|
|
|
+ Long regularTemplateId = scheduleEventGroupConfigVo.getRegularTemplateId();
|
|
|
+ String finalStartDate = scheduleEventGroupConfigVo.getFinalStartDate();
|
|
|
+
|
|
|
+ if (finalTemplateId == null) {
|
|
|
+ log.warn("决赛模板ID为空,无法生成系列赛,eventId: {}", eventId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 先生成决赛
|
|
|
+ log.info("开始生成决赛,模板ID: {}, 开始时间: {}", finalTemplateId, finalStartDate);
|
|
|
+ Long finalTournamentId = generateXiLieTournamentDetail(
|
|
|
+ scheduleEventGroupConfigVo.getId(),
|
|
|
+ finalTemplateId,
|
|
|
+ finalStartDate,
|
|
|
+ null,
|
|
|
+ null);
|
|
|
+
|
|
|
+ if (finalTournamentId == null) {
|
|
|
+ log.error("决赛生成失败,模板ID: {}", finalTemplateId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("决赛生成成功,赛事ID: {}", finalTournamentId);
|
|
|
+
|
|
|
+ String startDate = scheduleEventGroupConfigVo.getStartDate();
|
|
|
+ if (StringUtils.isBlank(startDate)) {
|
|
|
+ log.warn("开始日期为空,无法生成常规赛,eventId: {}", eventId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 赛事详情的日期相关
|
|
|
+ List<ScheduleEventGroupItemVo> scheduleEventGroupItemVoList =
|
|
|
+ scheduleEventGroupItemMapper.selectScheduleEventGroupConfigByConfigId(scheduleEventGroupConfigVo.getId());
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(scheduleEventGroupItemVoList)) {
|
|
|
+ log.warn("未找到赛事组别配置项,eventId: {}", eventId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("找到 {} 个赛事组别配置项", scheduleEventGroupItemVoList.size());
|
|
|
+
|
|
|
+ for (ScheduleEventGroupItemVo scheduleEventGroupItemVo : scheduleEventGroupItemVoList) {
|
|
|
+ // 生成的相关时间
|
|
|
+ String groupName = scheduleEventGroupItemVo.getGroupName();
|
|
|
+ String executionTime = scheduleEventGroupItemVo.getExecutionTime();
|
|
|
+ Long intervalDays = scheduleEventGroupItemVo.getIntervalDays();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(executionTime)) {
|
|
|
+ log.warn("执行时间为空,跳过配置项: {}, 组名: {}", scheduleEventGroupItemVo.getId(), groupName);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 计算实际执行日期:start_date + interval_days
|
|
|
+ LocalDate actualDate = LocalDate.parse(startDate).plusDays(intervalDays != null ? intervalDays : 0);
|
|
|
+
|
|
|
+ // 将日期和时间拼接
|
|
|
+ LocalDateTime actualDateTime = LocalDateTime.of(actualDate, LocalTime.parse(executionTime));
|
|
|
+
|
|
|
+ // 如果需要转换为字符串格式
|
|
|
+ String actualDateTimeStr = actualDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+
|
|
|
+ log.info("生成常规赛 - 组名: {}, 执行时间: {}, 模板ID: {}", groupName, actualDateTimeStr, regularTemplateId);
|
|
|
+
|
|
|
+ if (regularTemplateId != null) {
|
|
|
+ // 生成对应系列赛
|
|
|
+ Long regularTournamentId = generateXiLieTournamentDetail(
|
|
|
+ scheduleEventGroupConfigVo.getId(),
|
|
|
+ regularTemplateId,
|
|
|
+ actualDateTimeStr,
|
|
|
+ finalTournamentId,
|
|
|
+ groupName);
|
|
|
+
|
|
|
+ if (regularTournamentId != null) {
|
|
|
+ log.info("常规赛生成成功 - 组名: {}, 赛事ID: {}", groupName, regularTournamentId);
|
|
|
+ } else {
|
|
|
+ log.error("常规赛生成失败 - 组名: {}, 模板ID: {}", groupName, regularTemplateId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.warn("常规赛模板ID为空,跳过生成常规赛,组名: {}", groupName);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("处理赛事组别配置项时发生错误,配置项ID: {}, 组名: {}", scheduleEventGroupItemVo.getId(), groupName, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("系列赛生成完成,eventId: {}", eventId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成赛事
|
|
|
+ * @param templateId
|
|
|
+ * @param beginTime
|
|
|
+ * @param targetTournamentId
|
|
|
+ * @param groupName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Long generateXiLieTournamentDetail(Long eventId,Long templateId,String beginTime,Long targetTournamentId,String groupName) {
|
|
|
+ try {
|
|
|
+ TournamentsVo tournamentsVo = tournamentsTemplateMapper.selectVoByIdInfoTemplate(templateId);
|
|
|
+ if(tournamentsVo==null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 模拟构造 TournamentsDto 数据
|
|
|
+ TournamentsDto bo = new TournamentsDto();
|
|
|
+ //晋级目标赛事,没有则为空 为决赛
|
|
|
+
|
|
|
+ bo.setName(tournamentsVo.getName());
|
|
|
+ // 设置基础字段
|
|
|
+ if(StringUtils.isNotBlank(groupName)){
|
|
|
+ bo.setName(tournamentsVo.getName()+"("+groupName+"组)");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义你想要的日期时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ // 使用指定的格式器格式化 LocalDateTime 对象
|
|
|
+ bo.setStartTime(beginTime);
|
|
|
+
|
|
|
+ bo.setGameType(tournamentsVo.getGameType()); // 假设有5种类型
|
|
|
+ bo.setStartingChips(tournamentsVo.getStartingChips());
|
|
|
+ bo.setLevelDuration(tournamentsVo.getLevelDuration());
|
|
|
+ bo.setLateRegistrationLevel(tournamentsVo.getLateRegistrationLevel());
|
|
|
+ bo.setMaxPlayers(tournamentsVo.getMaxPlayers());
|
|
|
+ bo.setStatus(0L); // 默认状态为进行中等
|
|
|
+ bo.setCompetitionIcon(tournamentsVo.getCompetitionIcon());
|
|
|
+ bo.setRewardPlayers(tournamentsVo.getRewardPlayers());
|
|
|
+ bo.setSignTime(tournamentsVo.getSignTime());
|
|
|
+ bo.setRobotCount(tournamentsVo.getRobotCount());
|
|
|
+
|
|
|
+ bo.setDelayCardNum(tournamentsVo.getDelayCardNum());
|
|
|
+ bo.setDelayCardTime(tournamentsVo.getDelayCardTime());
|
|
|
+ bo.setActionTime(tournamentsVo.getActionTime());
|
|
|
+ bo.setMinPlayers(tournamentsVo.getMinPlayers());
|
|
|
+
|
|
|
+ bo.setGameVariant(tournamentsVo.getGameVariant());
|
|
|
+ bo.setQualifierType(tournamentsVo.getQualifierType());
|
|
|
+ bo.setQualifierValue(tournamentsVo.getQualifierValue());
|
|
|
+ //查询模版 赛事对应盲注
|
|
|
+ TournamentBlindStructuresVo tournamentBlindStructuresVo = tournamentBlindStructuresMapper.selectTournamentBlindStructureByTournamentIdTemplate(tournamentsVo.getId());
|
|
|
+
|
|
|
+ if(tournamentBlindStructuresVo!=null){
|
|
|
+ // 设置盲注结构 ID
|
|
|
+ bo.setBlindStructureId(tournamentBlindStructuresVo.getBlindStructureId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询模版 设置报名条件
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfoTemplate(tournamentsVo.getId());
|
|
|
+ bo.setItemsId(tournamentEntryConditionsVo.getItemId());
|
|
|
+ bo.setItemsNum(tournamentEntryConditionsVo.getRequiredQuantity());
|
|
|
+
|
|
|
+ //查询模版对应的排名
|
|
|
+ List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentIdTemplate(tournamentsVo.getId());
|
|
|
+
|
|
|
+ List<PrizeDistributionsVo> sortedList = prizeDistributionsVos.stream()
|
|
|
+ .sorted(Comparator.comparing(
|
|
|
+ PrizeDistributionsVo::getPaiming,
|
|
|
+ Comparator.nullsLast(Long::compareTo) // null 值排在最后
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ // 设置奖励列表
|
|
|
+ List<ItemsPrizeDto> prizeList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (PrizeDistributionsVo prizeDistributionsVo : sortedList) {
|
|
|
+
|
|
|
+ PrizeDistributionItemsVo prizeDistributionItemsVo = prizeDistributionItemsMapper.selectByPrizeDistributionIdTemplate(prizeDistributionsVo.getId());
|
|
|
+
|
|
|
+ ItemsPrizeDto prize = new ItemsPrizeDto();
|
|
|
+ prize.setRanking(prizeDistributionsVo.getPaiming());
|
|
|
+ prize.setItemId(prizeDistributionItemsVo.getItemId());
|
|
|
+ prize.setQuantity(prizeDistributionItemsVo.getQuantity());
|
|
|
+ prize.setItemsName(prizeDistributionItemsVo.getItemsName());
|
|
|
+ prizeList.add(prize);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ bo.setItemsPrizeList(prizeList);
|
|
|
+ bo.setCompetitionBg(tournamentsVo.getCompetitionBg());
|
|
|
+ //查询类目和标签ID
|
|
|
+ List<Long> categoryList = tournamentCategoryTagTemplateMapper.selectCategoryOrTagId("CATEGORY", tournamentsVo.getId());
|
|
|
+ bo.setCategoryId(categoryList);
|
|
|
+ List<Long> tagList = tournamentCategoryTagTemplateMapper.selectCategoryOrTagId("TAG", tournamentsVo.getId());
|
|
|
+ bo.setTagId(tagList);
|
|
|
+ bo.setRebuy(tournamentsVo.getRebuy());
|
|
|
+ bo.setDelayShow(tournamentsVo.getDelayShow());
|
|
|
+ bo.setRemark(tournamentsVo.getRemark());
|
|
|
+ bo.setStatus(0L);
|
|
|
+ bo.setTargetTournamentId(targetTournamentId);
|
|
|
+ // 调用已有的插入方法
|
|
|
+ if (!iTournamentsService.insertByBo(bo)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存对应生成赛事记录信息
|
|
|
+ ScheduleTournamentsReletion scheduleTournamentsReletion2=new ScheduleTournamentsReletion();
|
|
|
+ scheduleTournamentsReletion2.setTournamentsId(bo.getId());
|
|
|
+ scheduleTournamentsReletion2.setTournamentsTemplateId(templateId);
|
|
|
+ scheduleTournamentsReletion2.setScBeginTime(beginTime);
|
|
|
+ scheduleTournamentsReletion2.setConfigId(eventId);
|
|
|
+ scheduleTournamentsReletionMapper.insertScheduleRelation(scheduleTournamentsReletion2);
|
|
|
+
|
|
|
+ return bo.getId();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|