|
@@ -5,13 +5,15 @@ import beilv.common.utils.ShiroUtils;
|
|
import beilv.competition.domain.Competition;
|
|
import beilv.competition.domain.Competition;
|
|
import beilv.competition.mapper.CompetitionMapper;
|
|
import beilv.competition.mapper.CompetitionMapper;
|
|
import beilv.competition.service.ICompetitionService;
|
|
import beilv.competition.service.ICompetitionService;
|
|
-import beilv.stadium.domain.Stadium;
|
|
|
|
|
|
+import beilv.competition.task.CloseReg;
|
|
import beilv.stadium.mapper.StadiumMapper;
|
|
import beilv.stadium.mapper.StadiumMapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Timer;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 赛事发布Service业务层处理
|
|
* 赛事发布Service业务层处理
|
|
@@ -21,6 +23,7 @@ import java.util.List;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class CompetitionServiceImpl implements ICompetitionService {
|
|
public class CompetitionServiceImpl implements ICompetitionService {
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private CompetitionMapper competitionMapper;
|
|
private CompetitionMapper competitionMapper;
|
|
|
|
|
|
@@ -32,6 +35,24 @@ public class CompetitionServiceImpl implements ICompetitionService {
|
|
private final static String BAO_MING_JIE_SHU = "competiton_state_3";
|
|
private final static String BAO_MING_JIE_SHU = "competiton_state_3";
|
|
private final static String YI_GUAN_BI = "competiton_state_4";
|
|
private final static String YI_GUAN_BI = "competiton_state_4";
|
|
|
|
|
|
|
|
+ @PostConstruct
|
|
|
|
+ public void init() {
|
|
|
|
+ // 找到所有报名中的赛事
|
|
|
|
+ Competition competition = new Competition();
|
|
|
|
+ competition.setCompetitionState("competiton_state_2");
|
|
|
|
+ List<Competition> competitionList = this.selectCompetitionList(competition);
|
|
|
|
+ competitionList.forEach(item -> {
|
|
|
|
+ Date date = new Date(item.getApplyStartTime().getTime() - (long) (item.getApplyBeforeTime() * 60 * 60 * 1000));
|
|
|
|
+ if (new Date().getTime() >= date.getTime()) {
|
|
|
|
+ item.setCompetitionState("competiton_state_3");
|
|
|
|
+ competitionMapper.updateCompetition(item);
|
|
|
|
+ } else {
|
|
|
|
+ Timer timer = new Timer();
|
|
|
|
+ timer.schedule(new CloseReg(competitionMapper, item.getId()), date);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询赛事发布
|
|
* 查询赛事发布
|
|
*
|
|
*
|
|
@@ -113,24 +134,23 @@ public class CompetitionServiceImpl implements ICompetitionService {
|
|
competition.setPublishName(ShiroUtils.getSysUser().getUserName());
|
|
competition.setPublishName(ShiroUtils.getSysUser().getUserName());
|
|
competition.setId(Integer.valueOf(id));
|
|
competition.setId(Integer.valueOf(id));
|
|
competition.setCompetitionState(BAO_MING_ZHONG);
|
|
competition.setCompetitionState(BAO_MING_ZHONG);
|
|
|
|
+ Timer timer = new Timer();
|
|
|
|
+ timer.schedule(new CloseReg(competitionMapper, Integer.parseInt(id)), new Date(competition.getApplyStartTime().getTime() - (long) (competition.getApplyBeforeTime() * 60 * 1000)));
|
|
return competitionMapper.publishCompetition(competition);
|
|
return competitionMapper.publishCompetition(competition);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int closeCompetitionById(String id) {
|
|
public int closeCompetitionById(String id) {
|
|
-
|
|
|
|
- //查询是否存在为退款的订单
|
|
|
|
- if(competitionMapper.selectStadumIsOpenById(id)){
|
|
|
|
|
|
+ // 查询是否存在为退款的订单
|
|
|
|
+ if (competitionMapper.selectStadumIsOpenById(id)) {
|
|
//修改赛事状态
|
|
//修改赛事状态
|
|
Competition competition = new Competition();
|
|
Competition competition = new Competition();
|
|
competition.setId(Integer.valueOf(id));
|
|
competition.setId(Integer.valueOf(id));
|
|
competition.setCompetitionState(YI_GUAN_BI);
|
|
competition.setCompetitionState(YI_GUAN_BI);
|
|
return competitionMapper.publishCompetition(competition);
|
|
return competitionMapper.publishCompetition(competition);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|