|
|
@ -24,6 +24,7 @@ import com.huoran.competition.service.CompetitionTeamService; |
|
|
|
import com.huoran.competition.service.TeamParticipantService; |
|
|
|
import com.huoran.competition.service.TeamParticipantService; |
|
|
|
import com.huoran.competition.utils.ExcelStyleUtil; |
|
|
|
import com.huoran.competition.utils.ExcelStyleUtil; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -91,7 +92,7 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public R cancelRegistration(String contestId, Integer accountId) { |
|
|
|
public R cancelRegistration(String contestId, Integer accountId) { |
|
|
|
//删除团队
|
|
|
|
//删除团队
|
|
|
|
QueryWrapper<CompleteCompetitionSetup> setupQueryWrapper = new QueryWrapper<>(); |
|
|
|
/*QueryWrapper<CompleteCompetitionSetup> setupQueryWrapper = new QueryWrapper<>(); |
|
|
|
setupQueryWrapper.eq("competition_id", contestId); |
|
|
|
setupQueryWrapper.eq("competition_id", contestId); |
|
|
|
CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); |
|
|
|
CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); |
|
|
|
//团队赛类型
|
|
|
|
//团队赛类型
|
|
|
@ -113,7 +114,7 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
} |
|
|
|
} |
|
|
|
competitionTeamService.removeById(one); |
|
|
|
competitionTeamService.removeById(one); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
boolean ret = baseMapper.cancelRegistration(contestId, accountId); |
|
|
|
boolean ret = baseMapper.cancelRegistration(contestId, accountId); |
|
|
|
|
|
|
|
|
|
|
|
return ret ? R.ok() : R.error(); |
|
|
|
return ret ? R.ok() : R.error(); |
|
|
@ -191,55 +192,40 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public R apply(CompetitionRegistration competitionRegistration) { |
|
|
|
public R apply(CompetitionRegistration competitionRegistration) { |
|
|
|
//查询活动设置
|
|
|
|
|
|
|
|
QueryWrapper<CompleteCompetitionSetup> setupQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
setupQueryWrapper.eq("competition_id", competitionRegistration.getCompetitionId()); |
|
|
|
|
|
|
|
CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); |
|
|
|
|
|
|
|
//团队赛限制验证
|
|
|
|
|
|
|
|
if (setup.getCompetitionType() == 1) { |
|
|
|
|
|
|
|
if (competitionRegistration.getTeamId() != null) { |
|
|
|
|
|
|
|
//团队数量限制
|
|
|
|
|
|
|
|
if (setup.getQuantityLimit() != null) { |
|
|
|
|
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); |
|
|
|
|
|
|
|
wrapper.groupBy("team_id"); |
|
|
|
|
|
|
|
List<CompetitionRegistration> competitionRegistrations = baseMapper.selectList(wrapper); |
|
|
|
|
|
|
|
if (competitionRegistrations != null && competitionRegistration.isJoin() && competitionRegistrations.size() >= setup.getQuantityLimit()) { |
|
|
|
|
|
|
|
throw new CustomException(ExceptionEnum.TEAM_LIMIT2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//团队人数限制
|
|
|
|
Competition competition = competitionMapper.selectById(competitionRegistration.getCompetitionId()); |
|
|
|
if (setup.getMaxTeamSize() != null) { |
|
|
|
|
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); |
|
|
|
|
|
|
|
wrapper.eq("team_id", competitionRegistration.getTeamId()); |
|
|
|
|
|
|
|
List<CompetitionRegistration> competitionRegistrations = baseMapper.selectList(wrapper); |
|
|
|
|
|
|
|
if (competitionRegistrations != null && competitionRegistration.isJoin() && competitionRegistrations.size() >= setup.getMaxTeamSize()) { |
|
|
|
|
|
|
|
throw new CustomException(ExceptionEnum.TEAM_LIMIT1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//个人赛人数限制
|
|
|
|
//个人赛人数限制
|
|
|
|
if (setup.getQuantityLimit() != null) { |
|
|
|
if (competition.getQuantityLimit() != null) { |
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); |
|
|
|
wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); |
|
|
|
List<CompetitionRegistration> competitionRegistrations = baseMapper.selectList(wrapper); |
|
|
|
List<CompetitionRegistration> competitionRegistrations = baseMapper.selectList(wrapper); |
|
|
|
if (competitionRegistrations != null && competitionRegistrations.size() >= setup.getQuantityLimit()) { |
|
|
|
if (competitionRegistrations != null && competitionRegistrations.size() >= competition.getQuantityLimit()) { |
|
|
|
throw new CustomException(ExceptionEnum.TEAM_LIMIT3); |
|
|
|
throw new CustomException(ExceptionEnum.TEAM_LIMIT3); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//内部添加,一路绿灯
|
|
|
|
//内部添加,一路绿灯
|
|
|
|
|
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = getCompetitionRegistrationQueryWrapper(competitionRegistration, competition); |
|
|
|
|
|
|
|
int count = baseMapper.selectCount(wrapper); |
|
|
|
|
|
|
|
//添加前判断是否已报名
|
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
throw new CustomException(ExceptionEnum.HAVE_BEEN_REGISTERED); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
int save = baseMapper.insert(competitionRegistration); |
|
|
|
|
|
|
|
return save > 0 ? R.ok() : R.error(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
|
|
|
private static QueryWrapper<CompetitionRegistration> getCompetitionRegistrationQueryWrapper(CompetitionRegistration competitionRegistration, Competition competition) { |
|
|
|
if (competitionRegistration.getIdentification() == null || competitionRegistration.getIdentification() != 1) { |
|
|
|
if (competitionRegistration.getIdentification() == null || competitionRegistration.getIdentification() != 1) { |
|
|
|
//是否需要报名邀请码
|
|
|
|
//是否需要报名邀请码
|
|
|
|
Integer code = setup.getIsNeedCode(); |
|
|
|
Integer code = competition.getIsNeedCode(); |
|
|
|
if (code == 1) { |
|
|
|
if (code == 1) { |
|
|
|
//验证报名邀请码
|
|
|
|
//验证报名邀请码
|
|
|
|
if (!setup.getInvitationCode().equals(competitionRegistration.getRegistrationInvitationCode())) { |
|
|
|
if (!competition.getInvitationCode().equals(competitionRegistration.getRegistrationInvitationCode())) { |
|
|
|
throw new CustomException(ExceptionEnum.CODE); |
|
|
|
throw new CustomException(ExceptionEnum.CODE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -251,37 +237,7 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<CompetitionRegistration> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("account_id", accountId); |
|
|
|
wrapper.eq("account_id", accountId); |
|
|
|
wrapper.eq("competition_id", competitionId); |
|
|
|
wrapper.eq("competition_id", competitionId); |
|
|
|
int count = baseMapper.selectCount(wrapper); |
|
|
|
return wrapper; |
|
|
|
//添加前判断是否已报名
|
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
throw new CustomException(ExceptionEnum.HAVE_BEEN_REGISTERED); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Competition competition = competitionMapper.selectById(competitionId); |
|
|
|
|
|
|
|
//活动范围(0:本校内 1:全平台 2:指定区域、院校)
|
|
|
|
|
|
|
|
/*if (competition.getCompetitionScope() == 2) { |
|
|
|
|
|
|
|
Integer schoolId = userClient.getSchoolIdByAccountId(accountId.toString()); |
|
|
|
|
|
|
|
//拿到当前用户所在学校省市信息
|
|
|
|
|
|
|
|
School school = this.getSchool(schoolId); |
|
|
|
|
|
|
|
if (school!=null){ |
|
|
|
|
|
|
|
boolean check = competitionRangeService.checkWhetherToParticipate(school, competitionId); |
|
|
|
|
|
|
|
if (check) { |
|
|
|
|
|
|
|
throw new CustomException(ExceptionEnum.UNABLE_TO_REGISTER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
//报名成功后每个阶段添加为默认参数人员
|
|
|
|
|
|
|
|
List<CompetitionStage> competitionStages = competitionStageMapper.selectCompetitionStageBySetupId(setup.getSetupId()); |
|
|
|
|
|
|
|
for (CompetitionStage competitionStage : competitionStages) { |
|
|
|
|
|
|
|
TeamParticipant teamParticipant = new TeamParticipant(); |
|
|
|
|
|
|
|
teamParticipant.setTeamId(competitionRegistration.getTeamId()); |
|
|
|
|
|
|
|
teamParticipant.setStageId(competitionStage.getStageId()); |
|
|
|
|
|
|
|
teamParticipant.setCompetitionId(competitionRegistration.getCompetitionId()); |
|
|
|
|
|
|
|
teamParticipant.setAccountId(accountId); |
|
|
|
|
|
|
|
teamParticipantService.save(teamParticipant); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int save = baseMapper.insert(competitionRegistration); |
|
|
|
|
|
|
|
return save > 0 ? R.ok() : R.error(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -292,4 +248,12 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR |
|
|
|
CompetitionRegistration registration = baseMapper.selectOne(queryWrapper); |
|
|
|
CompetitionRegistration registration = baseMapper.selectOne(queryWrapper); |
|
|
|
return registration; |
|
|
|
return registration; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Integer registrationPopulation(String competitionId) { |
|
|
|
|
|
|
|
QueryWrapper<CompetitionRegistration> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.eq("competition_id", competitionId); |
|
|
|
|
|
|
|
List<CompetitionRegistration> competitionRegistrations = baseMapper.selectList(queryWrapper); |
|
|
|
|
|
|
|
return competitionRegistrations.size(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|