|
|
@@ -2,8 +2,15 @@ package org.dromara.business.service.impl;
|
|
|
|
|
|
import org.dromara.business.domain.Participants;
|
|
|
import org.dromara.business.domain.bo.ParticipantsBo;
|
|
|
+import org.dromara.business.domain.enums.GameStatus;
|
|
|
import org.dromara.business.domain.vo.ParticipantsVo;
|
|
|
+import org.dromara.business.domain.vo.TournamentEntryConditionsVo;
|
|
|
+import org.dromara.business.domain.vo.TournamentsVo;
|
|
|
+import org.dromara.business.domain.vo.UserVo;
|
|
|
import org.dromara.business.mapper.ParticipantsMapper;
|
|
|
+import org.dromara.business.mapper.TournamentEntryConditionsMapper;
|
|
|
+import org.dromara.business.mapper.TournamentsMapper;
|
|
|
+import org.dromara.business.mapper.UserMapper;
|
|
|
import org.dromara.business.service.IParticipantsService;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
@@ -15,6 +22,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
|
@@ -32,6 +42,12 @@ public class ParticipantsServiceImpl implements IParticipantsService {
|
|
|
|
|
|
private final ParticipantsMapper baseMapper;
|
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
+
|
|
|
+ private final TournamentsMapper tournamentsMapper;
|
|
|
+
|
|
|
+ private final TournamentEntryConditionsMapper tournamentEntryConditionsMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询【请填写功能名称】
|
|
|
*
|
|
|
@@ -52,8 +68,46 @@ public class ParticipantsServiceImpl implements IParticipantsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public TableDataInfo<ParticipantsVo> queryPageList(ParticipantsBo bo, PageQuery pageQuery) {
|
|
|
+
|
|
|
+ //根据用户名找到userId
|
|
|
+ if(StringUtils.isNotBlank(bo.getUserName())){
|
|
|
+ UserVo userVo = userMapper.selUserInfo(bo.getUserName());
|
|
|
+ if(userVo!=null){
|
|
|
+ bo.setPlayerId(userVo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
LambdaQueryWrapper<Participants> lqw = buildQueryWrapper(bo);
|
|
|
Page<ParticipantsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<ParticipantsVo> resultRecords = result.getRecords();
|
|
|
+ for (ParticipantsVo resultRecord : resultRecords) {
|
|
|
+
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(resultRecord.getPlayerId());
|
|
|
+ if(userVo!=null){
|
|
|
+ resultRecord.setUserName(userVo.getNickName());
|
|
|
+ resultRecord.setPhone(userVo.getPhone());
|
|
|
+ }
|
|
|
+ TournamentsVo tournamentsVo = tournamentsMapper.selectVoByIdInfo(resultRecord.getTournamentId());
|
|
|
+ if(tournamentsVo!=null){
|
|
|
+ resultRecord.setTournamentId(tournamentsVo.getId());
|
|
|
+ resultRecord.setTournamentsName(tournamentsVo.getName());
|
|
|
+
|
|
|
+ String statusText= GameStatus.getDescriptionFromCode(tournamentsVo.getStatus());
|
|
|
+ resultRecord.setStatusText(statusText);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //赛事报名条件
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfo(resultRecord.getTournamentId());
|
|
|
+ String tournamentCondition="";
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
+ tournamentCondition=tournamentEntryConditionsVo.getItemsName()+"*"+tournamentEntryConditionsVo.getRequiredQuantity();
|
|
|
+ }
|
|
|
+ resultRecord.setTournamentCondition(tournamentCondition);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
@@ -65,22 +119,63 @@ public class ParticipantsServiceImpl implements IParticipantsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<ParticipantsVo> queryList(ParticipantsBo bo) {
|
|
|
+ //根据用户名找到userId
|
|
|
+ if(StringUtils.isNotBlank(bo.getUserName())){
|
|
|
+ UserVo userVo = userMapper.selUserInfo(bo.getUserName());
|
|
|
+ if(userVo!=null){
|
|
|
+ bo.setPlayerId(userVo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
LambdaQueryWrapper<Participants> lqw = buildQueryWrapper(bo);
|
|
|
- return baseMapper.selectVoList(lqw);
|
|
|
+ List<ParticipantsVo> participantsVoList = baseMapper.selectVoPageList(lqw);
|
|
|
+ for (ParticipantsVo resultRecord : participantsVoList) {
|
|
|
+
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(resultRecord.getPlayerId());
|
|
|
+ if(userVo!=null){
|
|
|
+ resultRecord.setUserName(userVo.getNickName());
|
|
|
+ resultRecord.setPhone(userVo.getPhone());
|
|
|
+ }
|
|
|
+ TournamentsVo tournamentsVo = tournamentsMapper.selectVoByIdInfo(resultRecord.getTournamentId());
|
|
|
+ if(tournamentsVo!=null){
|
|
|
+ resultRecord.setTournamentId(tournamentsVo.getId());
|
|
|
+ resultRecord.setTournamentsName(tournamentsVo.getName());
|
|
|
+
|
|
|
+ String statusText= GameStatus.getDescriptionFromCode(tournamentsVo.getStatus());
|
|
|
+ resultRecord.setStatusText(statusText);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //赛事报名条件
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfo(resultRecord.getTournamentId());
|
|
|
+ String tournamentCondition="";
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
+ tournamentCondition=tournamentEntryConditionsVo.getItemsName()+"*"+tournamentEntryConditionsVo.getRequiredQuantity();
|
|
|
+ }
|
|
|
+ resultRecord.setTournamentCondition(tournamentCondition);
|
|
|
+
|
|
|
+ }
|
|
|
+ return participantsVoList;
|
|
|
}
|
|
|
|
|
|
private LambdaQueryWrapper<Participants> buildQueryWrapper(ParticipantsBo bo) {
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<Participants> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.orderByAsc(Participants::getId);
|
|
|
+ lqw.orderByDesc(Participants::getRegistrationTime);
|
|
|
lqw.eq(bo.getTournamentId() != null, Participants::getTournamentId, bo.getTournamentId());
|
|
|
lqw.eq(bo.getPlayerId() != null, Participants::getPlayerId, bo.getPlayerId());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), Participants::getName, bo.getName());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getMobile()), Participants::getMobile, bo.getMobile());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getMobile()), Participants::getMobile, bo.getMobile());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAvatar()), Participants::getAvatar, bo.getAvatar());
|
|
|
lqw.eq(bo.getCurrentChips() != null, Participants::getCurrentChips, bo.getCurrentChips());
|
|
|
- lqw.eq(bo.getRegistrationTime() != null, Participants::getRegistrationTime, bo.getRegistrationTime());
|
|
|
- lqw.eq(bo.getStatus() != null, Participants::getStatus, bo.getStatus());
|
|
|
+ if (bo.getRegistrationTime() != null) {
|
|
|
+ String dateStr = bo.getRegistrationTime();
|
|
|
+ // 假设格式为 yyyy-MM-dd
|
|
|
+ String startOfDay = dateStr + " 00:00:00";
|
|
|
+ String endOfDay = dateStr + " 23:59:59";
|
|
|
+
|
|
|
+ lqw.ge(Participants::getRegistrationTime, startOfDay);
|
|
|
+ lqw.le(Participants::getRegistrationTime, endOfDay);
|
|
|
+ } lqw.eq(bo.getStatus() != null, Participants::getStatus, bo.getStatus());
|
|
|
return lqw;
|
|
|
}
|
|
|
|