sud小游戏-后台-ludo用户记录
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.accompany.admin.vo.miniGame;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class MiniGameLudoUserRecordAdminVo {
|
||||
|
||||
@ApiModelProperty("记录id")
|
||||
private Long id;
|
||||
@ApiModelProperty("uid")
|
||||
private Long uid;
|
||||
@ApiModelProperty("用户id")
|
||||
private Long erbanNo;
|
||||
@ApiModelProperty("分区id")
|
||||
private Integer partitionId;
|
||||
@ApiModelProperty("分区")
|
||||
private String partitionDesc;
|
||||
|
||||
@ApiModelProperty("入口")
|
||||
private Integer entrance;
|
||||
@ApiModelProperty("入口描述")
|
||||
private String entranceDesc;
|
||||
|
||||
@ApiModelProperty("房间uid")
|
||||
private Long roomUid;
|
||||
@ApiModelProperty("门票")
|
||||
private BigDecimal ticket;
|
||||
@ApiModelProperty("排名")
|
||||
private Integer rank;
|
||||
@ApiModelProperty("是否赢家")
|
||||
private Boolean isWinner;
|
||||
@ApiModelProperty("是否逃跑")
|
||||
private Boolean isEscaped;
|
||||
@ApiModelProperty("是否托管")
|
||||
private Boolean isManaged;
|
||||
|
||||
@ApiModelProperty("游戏id")
|
||||
private String mgId;
|
||||
@ApiModelProperty("轮次id")
|
||||
private String roundId;
|
||||
@ApiModelProperty("游戏模式")
|
||||
private Integer mode;
|
||||
@ApiModelProperty("开始时间")
|
||||
private String startTime;
|
||||
@ApiModelProperty("结束时间")
|
||||
private String endTime;
|
||||
@ApiModelProperty("游戏时长(秒)")
|
||||
private Integer durationSecond;
|
||||
@ApiModelProperty("游戏时长(格式化)")
|
||||
private String durationFormatter;
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.accompany.admin.vo.miniGame;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@ApiModel
|
||||
@Data
|
||||
public class MiniGameLudoUserRecordStatAdminVo {
|
||||
|
||||
@ApiModelProperty("总游戏时长(秒)")
|
||||
private Integer totalDurationSecond = 0;
|
||||
@ApiModelProperty("总游戏时长(格式化)")
|
||||
private String totalDurationFormatter = "0";
|
||||
@ApiModelProperty("游戏次数")
|
||||
private Integer roundCount = 0;
|
||||
@ApiModelProperty("付费游戏次数")
|
||||
private Integer paidRoundCount = 0;
|
||||
|
||||
@ApiModelProperty("记录分页")
|
||||
public Page<MiniGameLudoUserRecordAdminVo> page;
|
||||
|
||||
public MiniGameLudoUserRecordStatAdminVo(Page<MiniGameLudoUserRecordAdminVo> page) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package com.accompany.admin.service.miniGame;
|
||||
|
||||
import com.accompany.admin.vo.miniGame.MiniGameLudoUserRecordAdminVo;
|
||||
import com.accompany.admin.vo.miniGame.MiniGameLudoUserRecordStatAdminVo;
|
||||
import com.accompany.business.model.miniGame.MiniGameLudoUserRecord;
|
||||
import com.accompany.business.mybatismapper.miniGame.MiniGameLudoUserRecordMapper;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service
|
||||
public class MiniGameLudoUserRecordAdminService {
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private MiniGameLudoUserRecordMapper mapper;
|
||||
|
||||
public MiniGameLudoUserRecordStatAdminVo stat(Integer partitionId, Long erbanNo, Integer entrance, String startTime, String endTime, Integer pageNo, Integer pageSize) {
|
||||
Page<MiniGameLudoUserRecordAdminVo> page = page(partitionId, erbanNo, startTime, endTime, entrance, pageNo, pageSize);
|
||||
if (CollectionUtils.isEmpty(page.getRecords()) || pageNo != 1){
|
||||
return new MiniGameLudoUserRecordStatAdminVo(page);
|
||||
}
|
||||
MiniGameLudoUserRecordStatAdminVo vo = statSum(partitionId, erbanNo, entrance, startTime, endTime);
|
||||
vo.setPage(page);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private MiniGameLudoUserRecordStatAdminVo statSum(Integer partitionId, Long erbanNo, Integer entrance, String startTime, String endTime) {
|
||||
Long uid = null;
|
||||
if (null != erbanNo){
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
uid = u.getUid();
|
||||
}
|
||||
MiniGameLudoUserRecord statSum = mapper.statSum(partitionId, uid, entrance, startTime, endTime);
|
||||
if (null == statSum){
|
||||
return new MiniGameLudoUserRecordStatAdminVo();
|
||||
}
|
||||
MiniGameLudoUserRecordStatAdminVo adminVo = new MiniGameLudoUserRecordStatAdminVo();
|
||||
adminVo.setRoundCount(statSum.getPartitionId());
|
||||
adminVo.setPaidRoundCount(statSum.getMode());
|
||||
adminVo.setTotalDurationSecond(statSum.getDurationSecond());
|
||||
adminVo.setTotalDurationFormatter(DateTimeUtil.millisToStr(statSum.getDurationSecond() * 1000));
|
||||
return adminVo;
|
||||
}
|
||||
|
||||
public Page<MiniGameLudoUserRecordAdminVo> page(Integer partitionId, Long erbanNo, String startTime, String endTime, Integer entrance, Integer pageNo, Integer pageSize){
|
||||
Page<MiniGameLudoUserRecordAdminVo> voPage = new Page<>(pageNo, pageSize);
|
||||
|
||||
Long uid = null;
|
||||
if (null != erbanNo){
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (null == u){
|
||||
return voPage;
|
||||
}
|
||||
if (null != partitionId && !u.getPartitionId().equals(partitionId)){
|
||||
return voPage;
|
||||
}
|
||||
uid = u.getUid();
|
||||
}
|
||||
|
||||
Page<MiniGameLudoUserRecord> poPage = new Page<>(pageNo, pageSize);
|
||||
LambdaQueryWrapper<MiniGameLudoUserRecord> queryWrapper = new LambdaQueryWrapper<MiniGameLudoUserRecord>()
|
||||
.eq(partitionId != null, MiniGameLudoUserRecord::getPartitionId, partitionId)
|
||||
.eq(uid != null, MiniGameLudoUserRecord::getUid, uid)
|
||||
.eq(entrance != null, MiniGameLudoUserRecord::getEntrance, entrance)
|
||||
.ge(StringUtils.hasText(startTime), MiniGameLudoUserRecord::getStartTime, startTime)
|
||||
.le(StringUtils.hasText(endTime), MiniGameLudoUserRecord::getEndTime, endTime);
|
||||
mapper.selectPage(poPage, queryWrapper);
|
||||
|
||||
if (CollectionUtils.isEmpty(poPage.getRecords())){
|
||||
return voPage;
|
||||
}
|
||||
|
||||
List<Long> uidList = poPage.getRecords().stream().map(MiniGameLudoUserRecord::getUid).distinct().toList();
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(uidList);
|
||||
|
||||
List<MiniGameLudoUserRecordAdminVo> voList = poPage.getRecords().stream().map(po -> {
|
||||
MiniGameLudoUserRecordAdminVo vo = new MiniGameLudoUserRecordAdminVo();
|
||||
BeanUtils.copyProperties(po, vo);
|
||||
|
||||
Users u = usersMap.get(po.getUid());
|
||||
if (null != u){
|
||||
vo.setErbanNo(u.getErbanNo());
|
||||
}
|
||||
|
||||
vo.setPartitionDesc(PartitionEnum.getByPartitionId(po.getPartitionId()).getDesc());
|
||||
|
||||
MiniGameLudoUserRecord.EntranceEnum entranceEnum = MiniGameLudoUserRecord.EntranceEnum.fromValue(po.getEntrance());
|
||||
if (null != entranceEnum){
|
||||
vo.setEntranceDesc(entranceEnum.getDesc());
|
||||
}
|
||||
|
||||
vo.setStartTime(DateTimeUtil.convertDateTime(po.getStartTime()));
|
||||
vo.setEndTime(DateTimeUtil.convertDateTime(po.getEndTime()));
|
||||
|
||||
vo.setDurationFormatter(DateTimeUtil.millisToStr(po.getDurationSecond() * 1000));
|
||||
|
||||
return vo;
|
||||
}).toList();
|
||||
voPage.setRecords(voList);
|
||||
voPage.setTotal(poPage.getTotal());
|
||||
|
||||
return voPage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.accompany.admin.controller.miniGame;
|
||||
|
||||
import com.accompany.admin.service.miniGame.MiniGameLudoUserRecordAdminService;
|
||||
import com.accompany.admin.vo.miniGame.MiniGameLudoUserRecordStatAdminVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "游戏ludo数据统计", value = "游戏ludo数据统计")
|
||||
@RestController
|
||||
@RequestMapping("/admin/miniGame/ludo")
|
||||
public class MiniGameLudoAdminController {
|
||||
|
||||
@Autowired
|
||||
private MiniGameLudoUserRecordAdminService service;
|
||||
|
||||
@ApiOperation("统计")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "partitionId", value = "分区id", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "erbanNo", value = "用户id", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "entrance", value = "入口", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码", required = true),
|
||||
@ApiImplicitParam(name = "pageSize", value = "页长", required = true)
|
||||
})
|
||||
@GetMapping("/stat")
|
||||
public BusiResult<MiniGameLudoUserRecordStatAdminVo> stat(Integer partitionId, Long erbanNo, String startTime, String endTime, Integer entrance, Integer pageNo, Integer pageSize) {
|
||||
MiniGameLudoUserRecordStatAdminVo vo = service.stat(partitionId, erbanNo, entrance, startTime, endTime, pageNo, pageSize);
|
||||
return BusiResult.success(vo);
|
||||
}
|
||||
}
|
@@ -44,6 +44,21 @@ public class MiniGameLudoUserRecord {
|
||||
private int value;
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 根据value查找对应的枚举值
|
||||
*
|
||||
* @param value 枚举值
|
||||
* @return 对应的枚举项,如果未找到则返回null
|
||||
*/
|
||||
public static EntranceEnum fromValue(int value) {
|
||||
for (EntranceEnum entrance : EntranceEnum.values()) {
|
||||
if (entrance.value == value) {
|
||||
return entrance;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,14 @@ package com.accompany.business.mybatismapper.miniGame;
|
||||
|
||||
import com.accompany.business.model.miniGame.MiniGameLudoUserRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface MiniGameLudoUserRecordMapper extends BaseMapper<MiniGameLudoUserRecord> {
|
||||
|
||||
MiniGameLudoUserRecord statSum(@Param("partitionId") Integer partitionId,
|
||||
@Param("uid") Long uid,
|
||||
@Param("entrance") Integer entrance,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
}
|
||||
|
@@ -3,4 +3,25 @@
|
||||
|
||||
<mapper namespace="com.accompany.business.mybatismapper.miniGame.MiniGameLudoUserRecordMapper">
|
||||
|
||||
<select id="statSum" resultType="com.accompany.business.model.miniGame.MiniGameLudoUserRecord">
|
||||
select count(distinct round_id) as partition_id, count(distinct (case when ticket > 0 then round_id else null end)) as mode, sum(duration_second) as duration_second
|
||||
from mini_game_ludo_user_record
|
||||
where 1=1
|
||||
<if test="null != uid">
|
||||
and uid = #{uid}
|
||||
</if>
|
||||
<if test="null != partitionId">
|
||||
and partition_id = #{partitionId}
|
||||
</if>
|
||||
<if test="null != entrance">
|
||||
and entrance = #{entrance}
|
||||
</if>
|
||||
<if test="null != startTime">
|
||||
and start_time >= #{startTime}
|
||||
</if>
|
||||
<if test="null != endTime">
|
||||
and start_time <![CDATA[<=]]> #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user