统计:会员终端统计接口实现

This commit is contained in:
owen 2023-10-16 14:23:53 +08:00
parent 6f08645f61
commit b6d400e04a
5 changed files with 24 additions and 8 deletions

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
@ -25,7 +24,6 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@Tag(name = "管理后台 - 会员统计") @Tag(name = "管理后台 - 会员统计")
@RestController @RestController
@ -98,12 +96,7 @@ public class MemberStatisticsController {
@Operation(summary = "按照终端,获得会员统计列表") @Operation(summary = "按照终端,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')") @PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
// TODO 疯狂这个可以晚点写因为 user = = 上还没记录 terminal return success(memberStatisticsService.getRegisterTerminalStatisticsList());
// TODO @疯狂 member_user 增加 registerTerminal 字段基于它来统计哈
List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(),
t -> new MemberTerminalStatisticsRespVO()
.setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100));
return success(list);
} }
@GetMapping("/user-count-comparison") @GetMapping("/user-count-comparison")

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.member;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -23,6 +24,8 @@ public interface MemberStatisticsMapper extends BaseMapperX {
List<MemberSexStatisticsRespVO> selectSummaryListBySex(); List<MemberSexStatisticsRespVO> selectSummaryListBySex();
List<MemberTerminalStatisticsRespVO> selectSummaryListByRegisterTerminal();
// TODO @芋艿已经 review // TODO @芋艿已经 review
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime); @Param("endTime") LocalDateTime endTime);

View File

@ -45,6 +45,13 @@ public interface MemberStatisticsService {
*/ */
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
/**
* 按照终端获得会员统计列表
*
* @return 会员统计列表
*/
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList();
/** /**
* 获取用户注册数量列表 * 获取用户注册数量列表
* *

View File

@ -104,6 +104,11 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
return memberStatisticsMapper.selectSummaryListBySex(); return memberStatisticsMapper.selectSummaryListBySex();
} }
@Override
public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() {
return memberStatisticsMapper.selectSummaryListByRegisterTerminal();
}
@Override @Override
public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) {
return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime);

View File

@ -18,6 +18,14 @@
GROUP BY sex GROUP BY sex
</select> </select>
<select id="selectSummaryListByRegisterTerminal"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO">
SELECT register_terminal as terminal, COUNT(1) AS userCount
FROM member_user
WHERE deleted = FALSE
GROUP BY register_terminal
</select>
<select id="selectUserCount" resultType="java.lang.Integer"> <select id="selectUserCount" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM member_user FROM member_user