活动更改

main
rong.liu 12 months ago
parent 8cdbb5fa2b
commit 0318f7181b
  1. 7
      competition/src/main/java/com/huoran/competition/controller/CompetitionController.java
  2. 4
      competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java
  3. 4
      competition/src/main/java/com/huoran/competition/entity/Competition.java
  4. 22
      competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java
  5. 5
      competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java
  6. 3
      competition/src/main/java/com/huoran/competition/entity/vo/RegistrationVO.java
  7. 14
      competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml
  8. 1
      competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionRegistrationMapper.xml
  9. 2
      competition/src/main/java/com/huoran/competition/service/CompetitionRegistrationService.java
  10. 98
      competition/src/main/java/com/huoran/competition/service/impl/CompetitionRegistrationServiceImpl.java

@ -145,7 +145,7 @@ public class CompetitionController {
return R.ok(); return R.ok();
} }
@ApiOperation(value = "根据id查询活动", response = Competition.class) @ApiOperation(value = "活动详情", response = Competition.class)
@PostMapping("/getCompetition") @PostMapping("/getCompetition")
public R getCompetition(@ApiParam(name = "competitionId", value = "活动ID", required = true) @RequestParam("competitionId") String competitionId, HttpServletRequest request) { public R getCompetition(@ApiParam(name = "competitionId", value = "活动ID", required = true) @RequestParam("competitionId") String competitionId, HttpServletRequest request) {
String accountId = TokenUtils.getIdByJwtToken(request); String accountId = TokenUtils.getIdByJwtToken(request);
@ -155,6 +155,11 @@ public class CompetitionController {
wrapper.eq("competition_id", competitionId); wrapper.eq("competition_id", competitionId);
wrapper.eq("account_id", accountId); wrapper.eq("account_id", accountId);
CompetitionRegistration registration = competitionRegistrationService.getOne(wrapper); CompetitionRegistration registration = competitionRegistrationService.getOne(wrapper);
competition.setApplicantNum(competitionRegistrationService.registrationPopulation(competitionId));
if (registration != null) { if (registration != null) {
CompetitionTeam team = competitionTeamService.getById(registration.getTeamId()); CompetitionTeam team = competitionTeamService.getById(registration.getTeamId());
if (team != null) { if (team != null) {

@ -51,8 +51,8 @@ public class CompetitionRegistrationController {
@NoRepeatSubmit @NoRepeatSubmit
@ApiOperation(value = "个人活动报名") @ApiOperation(value = "个人活动报名")
@PostMapping("/addCompetitionRegistration") @PostMapping("/individualEventRegistration")
public R addCompetitionRegistration( public R individualEventRegistration(
@ApiParam(name = "competitionRegistration", value = "报名人员对象", required = true) @ApiParam(name = "competitionRegistration", value = "报名人员对象", required = true)
@RequestBody CompetitionRegistration competitionRegistration, HttpServletRequest request) { @RequestBody CompetitionRegistration competitionRegistration, HttpServletRequest request) {
if (competitionRegistration.getAccountId()==null){ if (competitionRegistration.getAccountId()==null){

@ -124,7 +124,9 @@ public class Competition implements Serializable {
@ApiModelProperty(value = "报名人数")
@TableField(exist = false)
private Integer applicantNum;
@ApiModelProperty(value = "赛制") @ApiModelProperty(value = "赛制")
@TableField(exist = false) @TableField(exist = false)

@ -34,9 +34,6 @@ public class CompetitionRegistration implements Serializable {
@ApiModelProperty(value = "活动主键Id(c_competition表主键)") @ApiModelProperty(value = "活动主键Id(c_competition表主键)")
private Integer competitionId; private Integer competitionId;
@ApiModelProperty(value = "用户主键Id")
private Integer userId;
@ApiModelProperty(value = "是否禁用(0未禁用,1禁用)") @ApiModelProperty(value = "是否禁用(0未禁用,1禁用)")
private Integer isDisable; private Integer isDisable;
@ -44,32 +41,15 @@ public class CompetitionRegistration implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String registrationInvitationCode; private String registrationInvitationCode;
@ApiModelProperty("内部标识") @ApiModelProperty("内部标识(默认为0,内部添加为1)")
private Integer identification; private Integer identification;
@ApiModelProperty(value = "用户名称")
private String username;
@ApiModelProperty(value = "学校名称")
private String school;
@ApiModelProperty(value = "账号")
private Integer account;
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "账号id") @ApiModelProperty(value = "账号id")
private Integer accountId; private Integer accountId;
@ApiModelProperty(value = "学号")
private Integer workNumber;
@ApiModelProperty(value = "团队id,默认为0无团队") @ApiModelProperty(value = "团队id,默认为0无团队")
private Integer teamId; private Integer teamId;
@TableField(exist = false)
private boolean join;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)

@ -147,5 +147,10 @@ public class CompetitionVO implements Serializable {
@ApiModelProperty(value = "创建来源(0默认平台创建)") @ApiModelProperty(value = "创建来源(0默认平台创建)")
private String createSource; private String createSource;
@ApiModelProperty(value = "数量上限限制")
private Integer quantityLimit;
@ApiModelProperty(value = "是否展示报名人员(0否,1是)")
private String whetherToShowApplicants;
} }

@ -40,6 +40,9 @@ public class RegistrationVO {
@Excel(name = "团队名称", orderNum = "7", mergeVertical = true, isImportField = "teamName", width = 30) @Excel(name = "团队名称", orderNum = "7", mergeVertical = true, isImportField = "teamName", width = 30)
private String teamName; private String teamName;
@ApiModelProperty(value = "头像")
private String userAvatars;
@ApiModelProperty(value = "团队id") @ApiModelProperty(value = "团队id")
private Integer teamId; private Integer teamId;

@ -649,6 +649,12 @@
c.publish_status, c.publish_status,
c.play_start_time, c.play_start_time,
c.play_end_time, c.play_end_time,
c.sign_up_start_time,
c.sign_up_end_time,
c.is_need_code,
c.invitation_code,
c.quantity_limit,
c.whether_to_show_applicants,
c.create_time, c.create_time,
c.sponsor, c.sponsor,
IFNULL( IFNULL(
@ -657,7 +663,7 @@
) AS applicant_num, ) AS applicant_num,
c.is_open, c.is_open,
create_source, create_source,
( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' end) as createSource, ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource,
IF IF
( (
( SELECT r.id FROM c_competition_registration r WHERE r.competition_id = c.id AND r.account_id = #{req.accountId} ) IS NULL, ( SELECT r.id FROM c_competition_registration r WHERE r.competition_id = c.id AND r.account_id = #{req.accountId} ) IS NULL,
@ -705,6 +711,12 @@
c.publish_status, c.publish_status,
c.play_start_time, c.play_start_time,
c.play_end_time, c.play_end_time,
c.sign_up_start_time,
c.sign_up_end_time,
c.is_need_code,
c.invitation_code,
c.quantity_limit,
c.whether_to_show_applicants,
c.create_time, c.create_time,
c.sponsor, c.sponsor,
IFNULL( IFNULL(

@ -39,6 +39,7 @@
u.user_name AS username, u.user_name AS username,
u.user_id, u.user_id,
qa.account_id, qa.account_id,
u.user_avatars,
qa.create_time, qa.create_time,
qa.identification,ct.team_name,ct.captain, qa.identification,ct.team_name,ct.captain,
CASE CASE

@ -36,4 +36,6 @@ public interface CompetitionRegistrationService extends IService<CompetitionRegi
R apply(CompetitionRegistration competitionRegistration); R apply(CompetitionRegistration competitionRegistration);
CompetitionRegistration enquireWhetherToRegister(Integer accountId,String competitionId); CompetitionRegistration enquireWhetherToRegister(Integer accountId,String competitionId);
Integer registrationPopulation(String competitionId) ;
} }

@ -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();
}
} }

Loading…
Cancel
Save