|
@@ -0,0 +1,221 @@
|
|
|
|
|
+package org.dromara.physical.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import org.dromara.business.domain.enums.GameStatus;
|
|
|
|
|
+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.UserMapper;
|
|
|
|
|
+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.dromara.physical.domain.PhysicalParticipants;
|
|
|
|
|
+import org.dromara.physical.domain.bo.PhysicalParticipantsBo;
|
|
|
|
|
+import org.dromara.physical.domain.vo.PhysicalParticipantsVo;
|
|
|
|
|
+import org.dromara.physical.domain.vo.PhysicalTournamentEntryConditionsVo;
|
|
|
|
|
+import org.dromara.physical.domain.vo.PhysicalTournamentsVo;
|
|
|
|
|
+import org.dromara.physical.mapper.PhysicalParticipantsMapper;
|
|
|
|
|
+import org.dromara.physical.mapper.PhysicalTournamentEntryConditionsMapper;
|
|
|
|
|
+import org.dromara.physical.mapper.PhysicalTournamentsMapper;
|
|
|
|
|
+import org.dromara.physical.service.IPhysicalParticipantsService;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 线下用户报名Service业务层处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author Lion Li
|
|
|
|
|
+ * @date 2025-11-28
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@Service
|
|
|
|
|
+public class PhysicalParticipantsServiceImpl implements IPhysicalParticipantsService {
|
|
|
|
|
+
|
|
|
|
|
+ private final PhysicalParticipantsMapper baseMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final PhysicalTournamentsMapper physicalTournamentsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final PhysicalTournamentEntryConditionsMapper physicalTournamentEntryConditionsMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询线下用户报名
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 主键
|
|
|
|
|
+ * @return 线下用户报名
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public PhysicalParticipantsVo queryById(Long id){
|
|
|
|
|
+ return baseMapper.selectVoById(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询线下用户报名列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 查询条件
|
|
|
|
|
+ * @param pageQuery 分页参数
|
|
|
|
|
+ * @return 线下用户报名分页列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public TableDataInfo<PhysicalParticipantsVo> queryPageList(PhysicalParticipantsBo bo, PageQuery pageQuery) {
|
|
|
|
|
+
|
|
|
|
|
+ //根据用户名找到userId
|
|
|
|
|
+ if(StringUtils.isNotBlank(bo.getUserName())){
|
|
|
|
|
+ UserVo userVo = userMapper.selUserInfo(bo.getUserName());
|
|
|
|
|
+ if(userVo!=null){
|
|
|
|
|
+ bo.setPlayerId(userVo.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<PhysicalParticipants> lqw = buildQueryWrapper(bo);
|
|
|
|
|
+ Page<PhysicalParticipantsVo> result = baseMapper.selectPhysicalParticipantsAllPage(pageQuery.build(), lqw);
|
|
|
|
|
+ List<PhysicalParticipantsVo> participantsVoList = result.getRecords();
|
|
|
|
|
+ for (PhysicalParticipantsVo resultRecord : participantsVoList) {
|
|
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(resultRecord.getPlayerId());
|
|
|
|
|
+ if(userVo!=null){
|
|
|
|
|
+ resultRecord.setUserName(userVo.getNickName());
|
|
|
|
|
+ resultRecord.setPhone(userVo.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ PhysicalTournamentsVo tournamentsVo = physicalTournamentsMapper.selectPhysicalTournamentsByIdInfo(resultRecord.getTournamentId());
|
|
|
|
|
+ if(tournamentsVo!=null){
|
|
|
|
|
+ resultRecord.setTournamentId(tournamentsVo.getId());
|
|
|
|
|
+ resultRecord.setTournamentsName(tournamentsVo.getName());
|
|
|
|
|
+
|
|
|
|
|
+ String statusText= GameStatus.getDescriptionFromCode(tournamentsVo.getStatus());
|
|
|
|
|
+ resultRecord.setStatusText(statusText);
|
|
|
|
|
+ }
|
|
|
|
|
+ PhysicalTournamentEntryConditionsVo tournamentEntryConditionsVo = physicalTournamentEntryConditionsMapper.selectPhysicalConditionsByTournamentId(resultRecord.getTournamentId());
|
|
|
|
|
+ String tournamentCondition="";
|
|
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
|
|
+ tournamentCondition=tournamentEntryConditionsVo.getItemsName()+"*"+tournamentEntryConditionsVo.getRequiredQuantity();
|
|
|
|
|
+ }
|
|
|
|
|
+ resultRecord.setTournamentCondition(tournamentCondition);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return TableDataInfo.build(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询符合条件的线下用户报名列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 查询条件
|
|
|
|
|
+ * @return 线下用户报名列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<PhysicalParticipantsVo> queryList(PhysicalParticipantsBo bo) {
|
|
|
|
|
+ //根据用户名找到userId
|
|
|
|
|
+ if(StringUtils.isNotBlank(bo.getUserName())){
|
|
|
|
|
+ UserVo userVo = userMapper.selUserInfo(bo.getUserName());
|
|
|
|
|
+ if(userVo!=null){
|
|
|
|
|
+ bo.setPlayerId(userVo.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaQueryWrapper<PhysicalParticipants> lqw = buildQueryWrapper(bo);
|
|
|
|
|
+ List<PhysicalParticipantsVo> physicalParticipantsVoList = baseMapper.selectPhysicalParticipantsList(lqw);
|
|
|
|
|
+ for (PhysicalParticipantsVo resultRecord : physicalParticipantsVoList) {
|
|
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(resultRecord.getPlayerId());
|
|
|
|
|
+ if(userVo!=null){
|
|
|
|
|
+ resultRecord.setUserName(userVo.getNickName());
|
|
|
|
|
+ resultRecord.setPhone(userVo.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ PhysicalTournamentsVo tournamentsVo = physicalTournamentsMapper.selectPhysicalTournamentsByIdInfo(resultRecord.getTournamentId());
|
|
|
|
|
+ if(tournamentsVo!=null){
|
|
|
|
|
+ resultRecord.setTournamentId(tournamentsVo.getId());
|
|
|
|
|
+ resultRecord.setTournamentsName(tournamentsVo.getName());
|
|
|
|
|
+
|
|
|
|
|
+ String statusText= GameStatus.getDescriptionFromCode(tournamentsVo.getStatus());
|
|
|
|
|
+ resultRecord.setStatusText(statusText);
|
|
|
|
|
+ }
|
|
|
|
|
+ //赛事报名条件
|
|
|
|
|
+ PhysicalTournamentEntryConditionsVo tournamentEntryConditionsVo = physicalTournamentEntryConditionsMapper.selectPhysicalConditionsByTournamentId(resultRecord.getTournamentId());
|
|
|
|
|
+ String tournamentCondition="";
|
|
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
|
|
+ tournamentCondition=tournamentEntryConditionsVo.getItemsName()+"*"+tournamentEntryConditionsVo.getRequiredQuantity();
|
|
|
|
|
+ }
|
|
|
|
|
+ resultRecord.setTournamentCondition(tournamentCondition);
|
|
|
|
|
+ }
|
|
|
|
|
+ return physicalParticipantsVoList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private LambdaQueryWrapper<PhysicalParticipants> buildQueryWrapper(PhysicalParticipantsBo bo) {
|
|
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
|
|
+ LambdaQueryWrapper<PhysicalParticipants> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.orderByDesc(PhysicalParticipants::getRegistrationTime);
|
|
|
|
|
+ lqw.eq(bo.getTournamentId() != null, PhysicalParticipants::getTournamentId, bo.getTournamentId());
|
|
|
|
|
+ lqw.eq(bo.getPlayerId() != null, PhysicalParticipants::getPlayerId, bo.getPlayerId());
|
|
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getName()), PhysicalParticipants::getName, bo.getName());
|
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getMobile()), PhysicalParticipants::getMobile, bo.getMobile());
|
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getAvatar()), PhysicalParticipants::getAvatar, bo.getAvatar());
|
|
|
|
|
+ lqw.eq(bo.getCurrentChips() != null, PhysicalParticipants::getCurrentChips, bo.getCurrentChips());
|
|
|
|
|
+ lqw.eq(bo.getRebuy() != null, PhysicalParticipants::getRebuy, bo.getRebuy());
|
|
|
|
|
+ lqw.eq(bo.getEliminatedTime() != null, PhysicalParticipants::getEliminatedTime, bo.getEliminatedTime());
|
|
|
|
|
+ lqw.eq(bo.getRegistrationTime() != null, PhysicalParticipants::getRegistrationTime, bo.getRegistrationTime());
|
|
|
|
|
+ lqw.eq(bo.getStatus() != null, PhysicalParticipants::getStatus, bo.getStatus());
|
|
|
|
|
+ lqw.eq(bo.getFinalRank() != null, PhysicalParticipants::getFinalRank, bo.getFinalRank());
|
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getFinalReward()), PhysicalParticipants::getFinalReward, bo.getFinalReward());
|
|
|
|
|
+ return lqw;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增线下用户报名
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 线下用户报名
|
|
|
|
|
+ * @return 是否新增成功
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean insertByBo(PhysicalParticipantsBo bo) {
|
|
|
|
|
+ PhysicalParticipants add = MapstructUtils.convert(bo, PhysicalParticipants.class);
|
|
|
|
|
+ validEntityBeforeSave(add);
|
|
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ bo.setId(add.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return flag;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改线下用户报名
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 线下用户报名
|
|
|
|
|
+ * @return 是否修改成功
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateByBo(PhysicalParticipantsBo bo) {
|
|
|
|
|
+ PhysicalParticipants update = MapstructUtils.convert(bo, PhysicalParticipants.class);
|
|
|
|
|
+ validEntityBeforeSave(update);
|
|
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存前的数据校验
|
|
|
|
|
+ */
|
|
|
|
|
+ private void validEntityBeforeSave(PhysicalParticipants entity){
|
|
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验并批量删除线下用户报名信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
|
|
+ * @return 是否删除成功
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
+ if(isValid){
|
|
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
+ }
|
|
|
|
|
+ return baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|