puzhibing
2024-02-29 7e1737e6b43827d5f766a49a4005077c5fa5eae3
新增加接口
9个文件已修改
6个文件已添加
643 ■■■■■ 已修改文件
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPayment.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/mapper/WorldCupCompetitorMapper.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecord.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecordList.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecordVo.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MyWorldCupInfo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/ParticipantVo.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/WorldCupRank.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/WorldCupRankVo.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupCompetitorService.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupPaymentParticipantService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupCompetitorMapper.xml 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java
@@ -418,8 +418,69 @@
    }
    @ResponseBody
    @PostMapping("/api/worldCup/getParticipant")
    @ApiOperation(value = "获取已报名的参赛人员【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<ParticipantVo>> getParticipant(){
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<ParticipantVo> participant = worldCupPaymentParticipantService.getParticipant(uid);
            return ResultUtil.success(participant);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
//    public ResultUtil<MyWorldCupInfo> getMyWorldCupInfo(@RequestBody String id){
//
//    }
    @ResponseBody
    @PostMapping("/api/worldCup/getMyWorldCupInfo")
    @ApiOperation(value = "获取已报名世界杯详情【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "列表中的id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<MyWorldCupInfo> getMyWorldCupInfo(@RequestBody String id){
        MyWorldCupInfo myWorldCupInfo = worldCupPaymentParticipantService.getMyWorldCupInfo(id);
        return ResultUtil.success(myWorldCupInfo);
    }
    @ResponseBody
    @PostMapping("/api/worldCup/getWorldCupMatchRecord")
    @ApiOperation(value = "获取比赛记录【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<MatchRecordVo> getWorldCupMatchRecord(MatchRecord matchRecord){
        MatchRecordVo matchRecord1 = worldCupCompetitorService.getMatchRecord(matchRecord);
        return ResultUtil.success(matchRecord1);
    }
    @ResponseBody
    @PostMapping("/api/worldCup/getWorldCupRank")
    @ApiOperation(value = "获取比赛排名【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<WorldCupRankVo>> getWorldCupRank(WorldCupRank worldCupRank){
        List<WorldCupRankVo> worldCupRank1 = worldCupCompetitorService.getWorldCupRank(worldCupRank);
        return ResultUtil.success(worldCupRank1);
    }
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPayment.java
@@ -42,6 +42,11 @@
    @TableField("payType")
    private Integer payType;
    /**
     * 支付单价
     */
    @TableField("unitPrice")
    private BigDecimal unitPrice;
    /**
     * 支付金额
     */
    @TableField("amount")
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/mapper/WorldCupCompetitorMapper.java
@@ -2,6 +2,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsh.communityWorldCup.entity.WorldCupCompetitor;
import com.dsh.communityWorldCup.model.MatchRecord;
import com.dsh.communityWorldCup.model.MatchRecordList;
import com.dsh.communityWorldCup.model.WorldCupRank;
import com.dsh.communityWorldCup.model.WorldCupRankVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -19,4 +23,20 @@
     * @return
     */
    List<Map<String, Object>> getNumberOfGamesRanked(@Param("appUserIds") List<Integer> appUserIds);
    /**
     * 获取比赛记录
     * @param matchRecord
     * @return
     */
    List<MatchRecordList> getMatchRecord(@Param("item") MatchRecord matchRecord);
    /**
     * 获取参赛排名
     * @param worldCupRank
     * @return
     */
    List<Map<String, Object>> getWorldCupRank(@Param("item") WorldCupRank worldCupRank, @Param("appUserIds") List<Integer> appUserIds);
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecord.java
New file
@@ -0,0 +1,22 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/2/29 10:19
 */
@Data
@ApiModel
public class MatchRecord {
    @ApiModelProperty(value = "参赛人id", required = true, dataType = "int")
    private Integer id;
    @ApiModelProperty(value = "是否是学员", required = true, dataType = "int")
    private Integer isStudent;
    @ApiModelProperty(value = "页码,首页1", required = true, dataType = "int")
    private Integer pageNo;
    @ApiModelProperty(value = "每页条数", required = true, dataType = "int")
    private Integer pageSize;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecordList.java
New file
@@ -0,0 +1,26 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/2/29 10:12
 */
@Data
@ApiModel
public class MatchRecordList {
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("我方分数")
    private Integer ourScore;
    @ApiModelProperty("对手分数")
    private Integer opponentScore;
    @ApiModelProperty("比赛时间")
    private String startTime;
    @ApiModelProperty("比赛结果(1=胜,-1=负)")
    private Integer matchResult;
    @ApiModelProperty("获得积分")
    private Integer award;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MatchRecordVo.java
New file
@@ -0,0 +1,20 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
 * @author zhibing.pu
 * @Date 2024/2/29 10:08
 */
@Data
@ApiModel
public class MatchRecordVo {
    @ApiModelProperty("总场次")
    private Integer totalSession;
    @ApiModelProperty("记录列表")
    private List<MatchRecordList> list;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MyWorldCupInfo.java
@@ -4,6 +4,8 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
 * @author zhibing.pu
 * @Date 2024/2/28 16:49
@@ -33,14 +35,18 @@
    private String address;
    @ApiModelProperty("参与赛点")
    private String stores;
    @ApiModelProperty("比赛费用(现金)")
    private Double cash;
    @ApiModelProperty("比赛费用(玩湃币)")
    private Double paiCoin;
    @ApiModelProperty("比赛费用(课时)")
    private Double classHour;
    @ApiModelProperty("参赛人员列表")
    private List<ParticipantVo> participants;
    @ApiModelProperty("比赛费用单价")
    private Double unitPrice;
    @ApiModelProperty("支付费用")
    private Double expense;
    @ApiModelProperty("简介")
    private String intro;
    @ApiModelProperty("富文本")
    private String content;
    @ApiModelProperty("比赛状态(1=未开始,2=已开始,3=已结束,4=已取消)")
    private Integer status;
    @ApiModelProperty("是否可取消(0=否,1=是)")
    private Integer revocable;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/ParticipantVo.java
New file
@@ -0,0 +1,36 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @date 2023/7/6 16:52
 */
@Data
@ApiModel
public class ParticipantVo {
    @ApiModelProperty("人员id")
    private Integer id;
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("年龄")
    private Integer age;
    @ApiModelProperty("身份证号码")
    private String idcard;
    @ApiModelProperty("电话号码")
    private String phone;
    @ApiModelProperty("身高")
    private Integer height;
    @ApiModelProperty("体重")
    private Double weight;
    @ApiModelProperty("生日")
    private String birthday;
    @ApiModelProperty("性别(1=男,2=女)")
    private Integer gender;
    @ApiModelProperty("剩余课时")
    private Integer residueClassHour;
    @ApiModelProperty("是否为学员")
    private Integer isStudent;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/WorldCupRank.java
New file
@@ -0,0 +1,25 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/2/29 10:47
 */
@Data
@ApiModel
public class WorldCupRank {
    @ApiModelProperty(value = "参赛人id", required = true, dataType = "int")
    private Integer id;
    @ApiModelProperty(value = "是否是学员", required = true, dataType = "int")
    private Integer isStudent;
    @ApiModelProperty(value = "年份,2024", required = false, dataType = "int")
    private Integer year;
    @ApiModelProperty(value = "范围,1=全国,2=成都", required = true, dataType = "int")
    private Integer radius;
    @ApiModelProperty(value = "排序,1=场次,2=胜率", required = true, dataType = "int")
    private Integer sort;
    private Integer appUserId;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/WorldCupRankVo.java
New file
@@ -0,0 +1,24 @@
package com.dsh.communityWorldCup.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/2/29 10:35
 */
@Data
@ApiModel
public class WorldCupRankVo {
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("头像")
    private String avatar;
    @ApiModelProperty("总场次")
    private Integer totalSession;
    @ApiModelProperty("胜率")
    private Double winRate;
    @ApiModelProperty("是否是自己(0=否,1=是)")
    private Integer oneself;
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupCompetitorService.java
@@ -2,8 +2,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.dsh.communityWorldCup.entity.WorldCupCompetitor;
import com.dsh.communityWorldCup.model.EntrantRank;
import com.dsh.communityWorldCup.model.EntrantRankVo;
import com.dsh.communityWorldCup.model.*;
import java.util.List;
/**
 * @author zhibing.pu
@@ -18,4 +19,20 @@
     * @return
     */
    EntrantRankVo getEntrantRank(EntrantRank entrantRank);
    /**
     * 获取比赛记录
     * @param matchRecord
     * @return
     */
    MatchRecordVo getMatchRecord(MatchRecord matchRecord);
    /**
     * 获取参赛排名
     * @param worldCupRank
     * @return
     */
    List<WorldCupRankVo> getWorldCupRank(WorldCupRank worldCupRank);
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupPaymentParticipantService.java
@@ -4,6 +4,7 @@
import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant;
import com.dsh.communityWorldCup.model.MyWorldCupInfo;
import com.dsh.communityWorldCup.model.MyWorldCupList;
import com.dsh.communityWorldCup.model.ParticipantVo;
import com.dsh.communityWorldCup.model.WorldCupListVo;
import org.springframework.web.bind.annotation.RequestBody;
@@ -40,4 +41,12 @@
     * @return
     */
    MyWorldCupInfo getMyWorldCupInfo(String id);
    /**
     * 获取已报过名的参赛人员
     * @param uid   当前用户
     * @return
     */
    List<ParticipantVo> getParticipant(Integer uid);
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -11,8 +11,7 @@
import com.dsh.communityWorldCup.feignclient.competition.model.Participant;
import com.dsh.communityWorldCup.feignclient.other.StoreClient;
import com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper;
import com.dsh.communityWorldCup.model.EntrantRank;
import com.dsh.communityWorldCup.model.EntrantRankVo;
import com.dsh.communityWorldCup.model.*;
import com.dsh.communityWorldCup.service.IWorldCupCompetitorService;
import org.springframework.stereotype.Service;
@@ -20,6 +19,7 @@
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -116,4 +116,133 @@
        }
        return entrantRankVo;
    }
    /**
     * 获取比赛记录
     * @param matchRecord
     * @return
     */
    @Override
    public MatchRecordVo getMatchRecord(MatchRecord matchRecord) {
        matchRecord.setIsStudent(matchRecord.getIsStudent() == 0 ? 2 : 1);
        int pageNo = (matchRecord.getPageNo() - 1) * matchRecord.getPageSize();
        matchRecord.setPageNo(pageNo);
        MatchRecordVo matchRecordVo = new MatchRecordVo();
        int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("participantId", matchRecord.getId())
                .eq("participantType", matchRecord.getIsStudent()));
        matchRecordVo.setTotalSession(count);
        List<MatchRecordList> matchRecord1 = this.baseMapper.getMatchRecord(matchRecord);
        matchRecordVo.setList(matchRecord1);
        return matchRecordVo;
    }
    /**
     * 获取参赛排名
     * @param worldCupRank
     * @return
     */
    @Override
    public List<WorldCupRankVo> getWorldCupRank(WorldCupRank worldCupRank) {
        worldCupRank.setIsStudent(worldCupRank.getIsStudent() == 0 ? 2 : 1);
        List<Integer> appUserIds = null;
        if(worldCupRank.getRadius() == 2){
            AppUser appUser = appUserClient.getAppUser(worldCupRank.getAppUserId());
            appUserIds = appUserClient.getAppUserIds(appUser.getCityCode());
        }
        List<Map<String, Object>> lists = this.baseMapper.getWorldCupRank(worldCupRank, appUserIds);
        List<WorldCupRankVo> list = new ArrayList<>();
        for (int i = 0; i < lists.size(); i++) {
            Map<String, Object> map = lists.get(i);
            Integer participantType = Integer.valueOf(map.get("participantType").toString());
            Integer participantId = Integer.valueOf(map.get("participantId").toString());
            Integer appUserId = Integer.valueOf(map.get("appUserId").toString());
            Integer totalSession = Integer.valueOf(map.get("totalSession").toString());
            Double winRate = Double.valueOf(map.get("winRate").toString());
            //自己排名在20内的标识
            boolean b = false;
            if(i <= 19){
                WorldCupRankVo worldCupRankVo = new WorldCupRankVo();
                worldCupRankVo.setTotalSession(totalSession);
                worldCupRankVo.setWinRate(winRate);
                //学员
                if(participantType == 1){
                    TStudent tStudent = studentClient.queryById(participantId);
                    worldCupRankVo.setAvatar(tStudent.getHeadImg());
                    String name = tStudent.getName();
                    if(name.length() > 2){
                        name = name.charAt(0) + "*" + name.substring(2);
                    }else{
                        name = name.charAt(0) + "*";
                    }
                    worldCupRankVo.setName(name);
                }
                //参赛人员
                if(participantType == 2){
                    AppUser appUser1 = appUserClient.getAppUser(appUserId);
                    Participant participant = participantClient.getParticipant(participantId);
                    worldCupRankVo.setAvatar(appUser1.getHeadImg());
                    String name = participant.getName();
                    if(name.length() > 2){
                        name = name.charAt(0) + "*" + name.substring(2);
                    }else{
                        name = name.charAt(0) + "*";
                    }
                    worldCupRankVo.setName(name);
                }
                if(worldCupRank.getIsStudent().equals(participantType) && worldCupRank.getId().equals(participantId)){
                    worldCupRankVo.setOneself(1);
                    b = true;
                }else{
                    worldCupRankVo.setOneself(0);
                }
                list.add(worldCupRankVo);
            }
            //排名20内,且包含自己直接返回
            if(i == 19 && b){
                break;
            }
            //排名前20的数据添加完成后且包含自己,需要将自己找出来后添加到21位
            if(i > 19 && !b){
                if(worldCupRank.getIsStudent().equals(participantType) && worldCupRank.getId().equals(participantId)){
                    WorldCupRankVo worldCupRankVo = new WorldCupRankVo();
                    worldCupRankVo.setTotalSession(totalSession);
                    worldCupRankVo.setWinRate(winRate);
                    //学员
                    if(participantType == 1){
                        TStudent tStudent = studentClient.queryById(participantId);
                        worldCupRankVo.setAvatar(tStudent.getHeadImg());
                        String name = tStudent.getName();
                        if(name.length() > 2){
                            name = name.charAt(0) + "*" + name.substring(2);
                        }else{
                            name = name.charAt(0) + "*";
                        }
                        worldCupRankVo.setName(name);
                    }
                    //参赛人员
                    if(participantType == 2){
                        AppUser appUser1 = appUserClient.getAppUser(appUserId);
                        Participant participant = participantClient.getParticipant(participantId);
                        worldCupRankVo.setAvatar(appUser1.getHeadImg());
                        String name = participant.getName();
                        if(name.length() > 2){
                            name = name.charAt(0) + "*" + name.substring(2);
                        }else{
                            name = name.charAt(0) + "*";
                        }
                        worldCupRankVo.setName(name);
                    }
                    worldCupRankVo.setOneself(1);
                    list.add(worldCupRankVo);
                    break;
                }
            }
        }
        return list;
    }
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java
@@ -1,14 +1,27 @@
package com.dsh.communityWorldCup.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.communityWorldCup.entity.WorldCup;
import com.dsh.communityWorldCup.entity.WorldCupPayment;
import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant;
import com.dsh.communityWorldCup.feignclient.account.StudentClient;
import com.dsh.communityWorldCup.feignclient.account.model.TStudent;
import com.dsh.communityWorldCup.feignclient.competition.ParticipantClient;
import com.dsh.communityWorldCup.feignclient.competition.model.Participant;
import com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper;
import com.dsh.communityWorldCup.model.MyWorldCupList;
import com.dsh.communityWorldCup.model.WorldCupListVo;
import com.dsh.communityWorldCup.model.*;
import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService;
import com.dsh.communityWorldCup.service.IWorldCupPaymentService;
import com.dsh.communityWorldCup.service.IWorldCupService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author zhibing.pu
@@ -16,6 +29,20 @@
 */
@Service
public class WorldCupPaymentParticipantServiceImpl extends ServiceImpl<WorldCupPaymentParticipantMapper, WorldCupPaymentParticipant> implements IWorldCupPaymentParticipantService {
    @Autowired
    private IWorldCupPaymentService worldCupPaymentService;
    @Resource
    private StudentClient studentClient;
    @Resource
    private ParticipantClient participantClient;
    @Autowired
    private IWorldCupService worldCupService;
    /**
@@ -43,4 +70,114 @@
        myWorldCupList.setIsStudent(myWorldCupList.getIsStudent() == 0 ? 2 : 1);
        return this.baseMapper.getMyWorldCupList(myWorldCupList);
    }
    /**
     * 获取已报名的世界杯详情
     * @param id    社区世界杯支付对应的参与者记录id
     * @return
     */
    @Override
    public MyWorldCupInfo getMyWorldCupInfo(String id) {
        WorldCupPaymentParticipant worldCupPaymentParticipant = this.getById(id);
        Integer worldCupId = worldCupPaymentParticipant.getWorldCupId();
        WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentParticipant.getWorldCupPaymentId());
        WorldCupInfo worldCupInfo = worldCupService.getWorldCupInfo(worldCupId);
        WorldCup worldCup = worldCupService.getById(worldCupId);
        MyWorldCupInfo myWorldCupInfo = new MyWorldCupInfo();
        BeanUtils.copyProperties(worldCupInfo, myWorldCupInfo);
        myWorldCupInfo.setUnitPrice(worldCupPayment.getUnitPrice().doubleValue());
        myWorldCupInfo.setExpense(worldCupPayment.getAmount().doubleValue());
        myWorldCupInfo.setStatus(worldCup.getStatus());
        myWorldCupInfo.setRevocable(1);
        //开始前一天不能取消
        if(worldCup.getStartTime().getTime() < System.currentTimeMillis() + 86400000L){
            myWorldCupInfo.setRevocable(0);
        }
        List<ParticipantVo> datas = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().eq("worldCupPaymentId", worldCupPaymentParticipant.getWorldCupPaymentId()));
        for (WorldCupPaymentParticipant wcpp : list1) {
            Integer participantType = wcpp.getParticipantType();
            Integer participantId = wcpp.getParticipantId();
            ParticipantVo participantVo = new ParticipantVo();
            //学员
            if(1 == participantType){
                TStudent tStudent = studentClient.queryById(participantId);
                participantVo.setId(tStudent.getId());
                participantVo.setName(tStudent.getName());
                int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday()));
                participantVo.setAge(age);
                participantVo.setIdcard(tStudent.getIdCard());
                participantVo.setPhone(tStudent.getPhone());
                participantVo.setIsStudent(1);
                datas.add(participantVo);
            }
            //参赛人员
            if(2 == participantType){
                Participant participant = participantClient.getParticipant(participantId);
                participantVo.setId(participant.getId());
                participantVo.setName(participant.getName());
                int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(participant.getBirthday()));
                participantVo.setAge(age);
                participantVo.setIdcard(participant.getIdcard());
                participantVo.setPhone(participant.getPhone());
                participantVo.setIsStudent(0);
                datas.add(participantVo);
            }
        }
        myWorldCupInfo.setParticipants(datas);
        return myWorldCupInfo;
    }
    /**
     * 获取已报过名的参赛人员
     * @param uid   当前用户
     * @return
     */
    @Override
    public List<ParticipantVo> getParticipant(Integer uid) {
        List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("appUserId", uid)
                .eq("payStatus", 2).eq("state", 1));
        List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
        List<ParticipantVo> datas = new ArrayList<>();
        Set<Integer> csry = new HashSet<>();
        Set<Integer> xy = new HashSet<>();
        if(collect.size() > 0){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
            for (WorldCupPaymentParticipant worldCupPaymentParticipant : list1) {
                Integer participantType = worldCupPaymentParticipant.getParticipantType();
                Integer participantId = worldCupPaymentParticipant.getParticipantId();
                ParticipantVo participantVo = new ParticipantVo();
                //学员
                if(1 == participantType && !xy.contains(participantId)){
                    TStudent tStudent = studentClient.queryById(participantId);
                    participantVo.setId(tStudent.getId());
                    participantVo.setName(tStudent.getName());
                    int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday()));
                    participantVo.setAge(age);
                    participantVo.setIdcard(tStudent.getIdCard());
                    participantVo.setPhone(tStudent.getPhone());
                    participantVo.setIsStudent(1);
                    datas.add(participantVo);
                }
                //参赛人员
                if(2 == participantType && !csry.contains(participantId)){
                    Participant participant = participantClient.getParticipant(participantId);
                    participantVo.setId(participant.getId());
                    participantVo.setName(participant.getName());
                    int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(participant.getBirthday()));
                    participantVo.setAge(age);
                    participantVo.setIdcard(participant.getIdcard());
                    participantVo.setPhone(participant.getPhone());
                    participantVo.setIsStudent(0);
                    datas.add(participantVo);
                }
            }
        }
        return datas;
    }
}
cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupCompetitorMapper.xml
@@ -20,4 +20,78 @@
        ) as aa order by aa.num desc
    </select>
    <select id="getMatchRecord" resultType="com.dsh.communityWorldCup.model.MatchRecordList">
        select
            b.`name`,
            a.ourScore,
            a.opponentScore,
            DATE_FORMAT(a.startTime, '%Y-%m-%d %H:%i') as startTime,
            a.matchResult,
            (a.participationIntegral + a.winIntegral) as award
        from t_world_cup_competitor a
        left join t_world_cup b on (a.worldCupId = b.id)
        where a.participantId = #{item.id} and a.participantType = #{item.isStudent}
        order by a.startTime desc limit #{item.pageNo}, #{item.pageSize}
    </select>
    <select id="getWorldCupRank" resultType="java.util.Map">
        select * from (
            select
            a.participantType,
            a.participantId,
            a.appUserId,
            a.num as totalSession,
            (ifnull(b.num, 0) / a.num * 100) as winRate
            from (
                select
                participantType,
                participantId,
                appUserId,
                count(*) as num
                from t_world_cup_competitor
                where 1 = 1
                <if test="null != item.year">
                    and DATE_FORMAT(a.startTime, '%Y') = #{item.year}
                </if>
                <if test="null != appUserIds and appUserIds.size() > 0">
                    and appUserId in
                    <foreach collection="appUserIds" item="iten" index="index" open="(" separator="," close=")">
                        #{iten}
                    </foreach>
                </if>
                group by participantType, participantId, appUserId
            ) as a
            left join (
                select
                participantType,
                participantId,
                appUserId,
                count(*) as num
                from t_world_cup_competitor
                where matchResult = 1
                <if test="null != item.year">
                    and DATE_FORMAT(a.startTime, '%Y') = #{item.year}
                </if>
                <if test="null != appUserIds and appUserIds.size() > 0">
                    and appUserId in
                    <foreach collection="appUserIds" item="iten" index="index" open="(" separator="," close=")">
                        #{iten}
                    </foreach>
                </if>
                group by participantType, participantId, appUserId
            ) as b on (a.participantId = b.participantId and a.participantType = b.participantType)
        ) as aa
        <if test="null != item.sort and item.sort == 1">
            order by aa.totalSession desc
        </if>
        <if test="null != item.sort and item.sort == 2">
            order by aa.winRate desc
        </if>
    </select>
</mapper>