cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java
@@ -609,4 +609,17 @@ .eq("cityCode", cityCode) ); } /** * 根据城市code获取用户的id集合 * @param cityCode 城市code * @return */ @PostMapping("/appUser/getAppUserIds") public List<Integer> getAppUserIds(@RequestBody String cityCode){ List<TAppUser> list = appUserService.list(new QueryWrapper<TAppUser>().eq("cityCode", cityCode).eq("state", 1)); return list.stream().map(TAppUser::getId).collect(Collectors.toList()); } } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java
@@ -17,6 +17,7 @@ import com.dsh.communityWorldCup.feignclient.other.model.Site; import com.dsh.communityWorldCup.feignclient.other.model.Store; import com.dsh.communityWorldCup.model.*; import com.dsh.communityWorldCup.service.IWorldCupCompetitorService; import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; import com.dsh.communityWorldCup.service.IWorldCupService; import com.dsh.communityWorldCup.service.IWorldCupStoreService; @@ -83,6 +84,9 @@ @Autowired private IWorldCupStoreService worldCupStoreService; @Autowired private IWorldCupCompetitorService worldCupCompetitorService; @@ -384,4 +388,38 @@ List<Integer> collect = worldCupList.stream().map(WorldCup::getId).collect(Collectors.toList()); return worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("storeId", storeId).in("worldCupId", collect)); } @ResponseBody @PostMapping("/api/worldCup/getEntrantRank") @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<EntrantRankVo> getEntrantRank(EntrantRank entrantRank){ EntrantRankVo entrantRank1 = worldCupCompetitorService.getEntrantRank(entrantRank); return ResultUtil.success(entrantRank1); } @ResponseBody @PostMapping("/api/worldCup/getMyWorldCupList") @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<WorldCupListVo>> getMyWorldCupList(MyWorldCupList myWorldCupList){ List<WorldCupListVo> myWorldCupList1 = worldCupPaymentParticipantService.getMyWorldCupList(myWorldCupList); return ResultUtil.success(myWorldCupList1); } // public ResultUtil<MyWorldCupInfo> getMyWorldCupInfo(@RequestBody String id){ // // } } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/account/AppUserClient.java
@@ -39,5 +39,12 @@ AppUser getAppUser(Integer appUserId); /** * 根据城市code获取用户的id集合 * @param cityCode 城市code * @return */ @PostMapping("/base/appUser/getAppUserIds") List<Integer> getAppUserIds(String cityCode); } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/competition/ParticipantClient.java
@@ -12,6 +12,11 @@ public interface ParticipantClient { /** * 获取参赛人员信息 * @param id 参赛人员id * @return */ @PostMapping("/participant/getParticipant") Participant getParticipant(Integer id); cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/mapper/WorldCupCompetitorMapper.java
@@ -2,10 +2,21 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dsh.communityWorldCup.entity.WorldCupCompetitor; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; /** * @author zhibing.pu * @Date 2024/2/19 15:45 */ public interface WorldCupCompetitorMapper extends BaseMapper<WorldCupCompetitor> { /** * 获取参赛次数排名 * @param appUserIds * @return */ List<Map<String, Object>> getNumberOfGamesRanked(@Param("appUserIds") List<Integer> appUserIds); } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/mapper/WorldCupPaymentParticipantMapper.java
@@ -2,7 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant; import com.dsh.communityWorldCup.model.MyWorldCupList; import com.dsh.communityWorldCup.model.WorldCupListVo; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @author zhibing.pu @@ -20,4 +24,12 @@ */ WorldCupPaymentParticipant getWorldCupPaymentParticipant(@Param("worldCupId") Integer worldCupId, @Param("participantType") Integer participantType, @Param("participantId") Integer participantId); /** * 获取社区世界杯我的报名列表 * @param myWorldCupList * @return */ List<WorldCupListVo> getMyWorldCupList(@Param("item") MyWorldCupList myWorldCupList); } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/EntrantRank.java
New file @@ -0,0 +1,19 @@ package com.dsh.communityWorldCup.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zhibing.pu * @Date 2024/2/28 14:57 */ @Data @ApiModel public class EntrantRank { @ApiModelProperty(value = "参赛人id", required = true, dataType = "int") private Integer id; @ApiModelProperty(value = "是否是学员", required = true, dataType = "int") private Integer isStudent; private Integer appUserId; } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/EntrantRankVo.java
New file @@ -0,0 +1,28 @@ package com.dsh.communityWorldCup.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zhibing.pu * @Date 2024/2/28 14:52 */ @Data @ApiModel public class EntrantRankVo { @ApiModelProperty("姓名") private String name; @ApiModelProperty("全国排名") private Integer nationalRank; @ApiModelProperty("城市名称") private String cityName; @ApiModelProperty("城市排名") private Integer cityRank; @ApiModelProperty("胜利场次") private Integer win; @ApiModelProperty("失败场次") private Integer lose; @ApiModelProperty("胜率") private Double winRate; } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MyWorldCupInfo.java
New file @@ -0,0 +1,46 @@ package com.dsh.communityWorldCup.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zhibing.pu * @Date 2024/2/28 16:49 */ @Data @ApiModel public class MyWorldCupInfo { @ApiModelProperty("世界杯id") private Integer id; @ApiModelProperty("图片") private String infoImg; @ApiModelProperty("名称") private String name; @ApiModelProperty("热度") private Integer heat; @ApiModelProperty("开始时间") private String startTime; @ApiModelProperty("结束时间") private String endTime; @ApiModelProperty("报名截止时间") private String registrationClosingTime; @ApiModelProperty("报名年龄") private String age; @ApiModelProperty("报名性别(0=全部,1=男,2=女)") private Integer gender; @ApiModelProperty("参赛地址") private String address; @ApiModelProperty("参与赛点") private String stores; @ApiModelProperty("比赛费用(现金)") private Double cash; @ApiModelProperty("比赛费用(玩湃币)") private Double paiCoin; @ApiModelProperty("比赛费用(课时)") private Double classHour; @ApiModelProperty("简介") private String intro; @ApiModelProperty("富文本") private String content; } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/MyWorldCupList.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/28 16:25 */ @Data @ApiModel public class MyWorldCupList { @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; @ApiModelProperty(value = "状态(1=未开始,2=进行中)") private Integer state; private Integer appUserId; } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/WorldCupListVo.java
@@ -12,7 +12,7 @@ @ApiModel public class WorldCupListVo { @ApiModelProperty("世界杯id") private Integer id; private String id; @ApiModelProperty("名称") private String name; @ApiModelProperty("报名截止时间") cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupCompetitorService.java
@@ -2,10 +2,20 @@ 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; /** * @author zhibing.pu * @Date 2024/2/19 15:47 */ public interface IWorldCupCompetitorService extends IService<WorldCupCompetitor> { /** * 获取参赛人员名次 * @param entrantRank * @return */ EntrantRankVo getEntrantRank(EntrantRank entrantRank); } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupPaymentParticipantService.java
@@ -2,6 +2,12 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant; import com.dsh.communityWorldCup.model.MyWorldCupInfo; import com.dsh.communityWorldCup.model.MyWorldCupList; import com.dsh.communityWorldCup.model.WorldCupListVo; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; /** * @author zhibing.pu @@ -18,4 +24,20 @@ * @return */ WorldCupPaymentParticipant getWorldCupPaymentParticipant(Integer worldCupId, Integer participantType, Integer participantId); /** * 获取社区世界杯我的报名列表 * @param myWorldCupList * @return */ List<WorldCupListVo> getMyWorldCupList(MyWorldCupList myWorldCupList); /** * 获取已报名的世界杯详情 * @param id * @return */ MyWorldCupInfo getMyWorldCupInfo(String id); } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -1,10 +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.WorldCupCompetitor; import com.dsh.communityWorldCup.feignclient.account.AppUserClient; import com.dsh.communityWorldCup.feignclient.account.StudentClient; import com.dsh.communityWorldCup.feignclient.account.model.AppUser; 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.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.service.IWorldCupCompetitorService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.List; import java.util.Map; /** * @author zhibing.pu @@ -12,4 +29,91 @@ */ @Service public class WorldCupCompetitorServiceImpl extends ServiceImpl<WorldCupCompetitorMapper, WorldCupCompetitor> implements IWorldCupCompetitorService { @Resource private StudentClient studentClient; @Resource private ParticipantClient participantClient; @Resource private AppUserClient appUserClient; /** * 获取参赛人员名次信息 * @param entrantRank * @return */ @Override public EntrantRankVo getEntrantRank(EntrantRank entrantRank) { EntrantRankVo entrantRankVo = new EntrantRankVo(); if(entrantRank.getIsStudent() == 0){ //参赛人员 Participant participant = participantClient.getParticipant(entrantRank.getId()); entrantRankVo.setName(participant.getName()); }else{ //学员 TStudent tStudent = studentClient.queryById(entrantRank.getId()); entrantRankVo.setName(tStudent.getName()); } //全国排名---直接数据库分组查询后排序 entrantRankVo.setNationalRank(0); List<Map<String, Object>> mapList = this.baseMapper.getNumberOfGamesRanked(null); for (int i = 0; i < mapList.size(); i++) { Map<String, Object> map = mapList.get(i); Integer participantType = Integer.valueOf(map.get("participantType").toString()); Integer participantId = Integer.valueOf(map.get("participantId").toString()); Integer num = Integer.valueOf(map.get("num").toString()); if(null != participantId && participantId.equals(entrantRank.getId()) && participantType.equals(entrantRank.getIsStudent())){ entrantRankVo.setNationalRank(i + 1); } } /** * 城市排名 * 1、先查询出当前用户对应的城市 * 2、再根据城市查询对应的所有人员 * 3、再根据查询出来的参赛人分组查询出参赛次数后排序 */ entrantRankVo.setCityRank(0); AppUser appUser = appUserClient.getAppUser(entrantRank.getAppUserId()); entrantRankVo.setCityName(appUser.getCity()); List<Integer> appUserIds = appUserClient.getAppUserIds(appUser.getCityCode()); List<Map<String, Object>> mapList1 = this.baseMapper.getNumberOfGamesRanked(appUserIds); for (int i = 0; i < mapList1.size(); i++) { Map<String, Object> map = mapList1.get(i); Integer participantType = Integer.valueOf(map.get("participantType").toString()); Integer participantId = Integer.valueOf(map.get("participantId").toString()); Integer num = Integer.valueOf(map.get("num").toString()); if(null != participantId && participantId.equals(entrantRank.getId()) && participantType.equals(entrantRank.getIsStudent())){ entrantRankVo.setCityRank(i + 1); } } QueryWrapper<WorldCupCompetitor> wrapper = new QueryWrapper<>(); if(entrantRank.getIsStudent() == 0){ wrapper.eq("participantType", 2); }else{ wrapper.eq("participantType", 1); } int win = this.count(wrapper.eq("participantId", entrantRank.getId()).eq("matchResult", 1)); entrantRankVo.setWin(win); wrapper = new QueryWrapper<>(); if(entrantRank.getIsStudent() == 0){ wrapper.eq("participantType", 2); }else{ wrapper.eq("participantType", 1); } int lose = this.count(wrapper.eq("participantId", entrantRank.getId()).eq("matchResult", -1)); entrantRankVo.setLose(lose); if((win + lose) == 0){ entrantRankVo.setWinRate(0D); }else{ entrantRankVo.setWinRate(new BigDecimal(win).divide(new BigDecimal(win + lose), new MathContext(4, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).doubleValue()); } return entrantRankVo; } } cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java
@@ -3,8 +3,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant; import com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper; import com.dsh.communityWorldCup.model.MyWorldCupList; import com.dsh.communityWorldCup.model.WorldCupListVo; import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; import org.springframework.stereotype.Service; import java.util.List; /** * @author zhibing.pu @@ -25,4 +29,18 @@ public WorldCupPaymentParticipant getWorldCupPaymentParticipant(Integer worldCupId, Integer participantType, Integer participantId) { return this.baseMapper.getWorldCupPaymentParticipant(worldCupId, participantType, participantId); } /** * 获取社区世界杯我的报名列表 * @param myWorldCupList * @return */ @Override public List<WorldCupListVo> getMyWorldCupList(MyWorldCupList myWorldCupList) { int pageNo = (myWorldCupList.getPageNo() - 1) * myWorldCupList.getPageSize(); myWorldCupList.setPageNo(pageNo); myWorldCupList.setIsStudent(myWorldCupList.getIsStudent() == 0 ? 2 : 1); return this.baseMapper.getMyWorldCupList(myWorldCupList); } } cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupCompetitorMapper.xml
@@ -1,6 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.dsh.communityWorldCup.mapper.WorldCupCompetitor"> <mapper namespace="com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper"> <select id="getNumberOfGamesRanked" resultType="map"> select * from ( select CASE WHEN participantType = 2 THEN 0 ELSE 1 END as participantType, participantId, count(*) as num from t_world_cup_competitor where 1 = 1 <if test="null != appUserIds and appUserIds.size() > 0"> and appUserId in <foreach collection="appUserIds" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> </if> group by participantType, participantId ) as aa order by aa.num desc </select> </mapper> cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml
@@ -39,7 +39,7 @@ a.lat, ifnull(b.num, 0) + a.basePeople as heat from t_world_cup a left join (select worldCupId, count(*) as num from t_world_cup_payment_participant where worldCupPaymentId in (select id from t_world_cup_payment where payStatus = 2 and state = 1) group by worldCupId) b on (a.id = b.worldCupId) left join (select worldCupId, count(*) as num from t_world_cup_payment_participant where worldCupPaymentId in (select id from t_world_cup_payment where payStatus = 2 and refundTime is null and state = 1) group by worldCupId) b on (a.id = b.worldCupId) where a.status in (1, 2) order by a.createTime desc <if test="null != item.content and '' != item.content"> and a.name like CONCAT('%', #{item.content}, '%') cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml
@@ -4,11 +4,35 @@ <select id="getWorldCupPaymentParticipant" resultType="com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper"> <select id="getWorldCupPaymentParticipant" resultType="com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant"> select * from t_world_cup_payment_participant where worldCupId = #{worldCupId} and participantType = #{participantType} and participantId = #{participantId} and worldCupPaymentId in ( select id from t_world_cup_payment where worldCupId = #{worldCupId} and payStatus = 2 and state = 1 ) </select> <select id="getMyWorldCupList" resultType="com.dsh.communityWorldCup.model.WorldCupListVo"> select a.id, c.name, DATE_FORMATc.registrationClosingTime, '%Y-%m-%d %H:%i') as registrationClosingTime, CONCAT(c.startAge, '-', c.endAge) as age, c.coverImg, c.intro as content, c.lon, c.lat, ifnull(d.num, 0) + c.basePeople as heat from t_world_cup_payment_participant a left join t_world_cup_payment b on (a.worldCupPaymentId = b.id) left join t_world_cup c on (b.worldCupId = c.id) left join (select worldCupId, count(*) as num from t_world_cup_payment_participant where worldCupPaymentId in (select id from t_world_cup_payment where payStatus = 2 and refundTime is null and state = 1) group by worldCupId) d on (c.id = d.worldCupId) where a.participantType = #{item.isStudent} and a.participantId = #{item.id} and b.payStatus = 2 and b.refundTime is null and b.state = 1 <if test="null != item.state"> and c.status = #{item.state} </if> order by b.createTime desc limit #{item.pageNo}, #{item.pageSize} </select> </mapper> cloud-server-other/src/main/java/com/dsh/other/entity/HomeModule.java
@@ -51,33 +51,39 @@ @ApiModelProperty("按钮图片") private String buttonImage; /** * 跳转模块(0=不跳转,1=加入玩湃,2=开始课程,3=使用福利,4=探索玩湃) */ @TableField("jumpModule") @ApiModelProperty("跳转模块(0=不跳转,1=加入玩湃,2=开始课程,3=使用福利,4=探索玩湃)") private Integer jumpModule; /** * 跳转页面(1=主页,2=课程列表,3=赛事活动列表,4=线上课得积分,5=看视频得奖励,6=预约场地,7=智慧球场,8=成为会员,9=充值中心,10=积分商城,11=本周福利,12=门店列表,13=常见问题,14=公告发布) */ @TableField("jumpPage") @ApiModelProperty("跳转页面(1=主页,2=课程列表,3=赛事活动列表,4=线上课得积分,5=看视频得奖励,6=预约场地,7=智慧球场,8=成为会员,9=充值中心,10=积分商城,11=本周福利,12=门店列表,13=常见问题,14=公告发布)") private Integer jumpPage; /** * 跳转类型(1=主页,2=列表,3=详情,4=限时折扣,5=赠送课时,6=指定折扣) */ @TableField("jumpType") @ApiModelProperty("跳转类型(1=主页,2=列表,3=详情,4=限时折扣,5=赠送课时,6=指定折扣)") private Integer jumpType; /** * 跳转详情id */ @TableField("detailID") @ApiModelProperty("跳转详情id") private String detailID; /** * 富文本内容 */ @TableField("content") @ApiModelProperty("富文本内容") private String content; /** * 跳转页面id */ @TableField("jumpPage") private Integer jumpPage; /** * 跳转模块 */ @TableField("model") private String model; /** * 跳转类型 */ @TableField("type") private String type; /** * 跳转类型 */ @TableField("turnId") private String turnId; /** * 跳转页面 */ @TableField("page") private String page; /** * 跳转类型id */ @TableField("typeId") private Integer typeId; }