stat:增加用户统计的设计

This commit is contained in:
YunaiV 2023-10-04 18:53:49 +08:00
parent c5824eedf7
commit a37427c355
8 changed files with 226 additions and 0 deletions

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Tag(name = "管理后台 - 会员统计")
@RestController
@RequestMapping("/statistics/member")
@Validated
@Slf4j
public class MemberStatisticsController {
// TODO @疯狂一个类似 getTradeTrendSummaryComparison 的接口
// TODO @疯狂一个类似 getTradeStatisticsList 的接口
@GetMapping("/summary")
@Operation(summary = "获得会员统计")
public CommonResult<TradeStatisticsComparisonRespVO<MemberSummaryRespVO>> getMemberSummary() {
// TODO 疯狂目前先直接计算
return null;
}
@GetMapping("/get-area-statistics-list")
@Operation(summary = "按照省份,获得会员统计列表")
public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() {
// TODO 疯狂目前先直接计算进行统计后续再考虑优化
return null;
}
@GetMapping("/get-sex-statistics-list")
@Operation(summary = "按照性别,获得会员统计列表")
public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() {
// TODO 疯狂目前先直接计算进行统计后续再考虑优化
return null;
}
@GetMapping("/get-terminal-statistics-list")
@Operation(summary = "按照终端,获得会员统计列表")
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
// TODO 疯狂目前先直接计算进行统计后续再考虑优化
// TODO 疯狂这个可以晚点写因为 user = = 上还没记录 terminal
return null;
}
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 会员地区统计 Response VO")
@Data
public class MemberAreaStatisticsRespVO {
@Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer areaId;
@Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省")
private String areaName;
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer userCount;
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderCreateCount;
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
private Integer orderPayCount;
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
private Integer orderPayPrice;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 会员性别统计 Response VO")
@Data
public class MemberSexStatisticsRespVO {
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer sex;
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer userCount;
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderCreateCount;
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
private Integer orderPayCount;
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
private Integer orderPayPrice;
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 会员统计 Response VO")
@Data
public class MemberSummaryRespVO {
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer userCount;
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
private Integer rechargeUserCount;
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer rechargePrice;
@Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer expensePrice;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 终端性别统计 Response VO")
@Data
public class MemberTerminalStatisticsRespVO {
@Schema(description = "终端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer terminal;
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer userCount;
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderCreateCount;
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
private Integer orderPayCount;
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
private Integer orderPayPrice;
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
@Schema(description = "管理后台 - 交易统计 Response VO") @Schema(description = "管理后台 - 交易统计 Response VO")
@Data @Data
public class TradeSummaryRespVO { public class TradeSummaryRespVO {
@Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer yesterdayOrderCount; private Integer yesterdayOrderCount;
@Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ -15,4 +16,5 @@ public class TradeSummaryRespVO {
private Integer monthOrderCount; private Integer monthOrderCount;
@Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer monthPayPrice; private Integer monthPayPrice;
} }

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.statistics.dal.dataobject.member;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* 会员统计 DO
* <p>
* 以天为维度统计全部的数据
*
* @author 芋道源码
*/
@TableName("member_statistics")
@KeySequence("member_statistics_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberStatisticsDO extends TenantBaseDO {
/**
* 编号主键自增
*/
@TableId
private Long id;
/**
* 统计日期
*/
private LocalDateTime time;
/**
* 注册用户数量
*/
private Integer userRegisterCount;
/**
* 访问用户数量UV
*/
private Integer userVisitCount;
/**
* 访问页面数量PV
*/
private Integer pageVisitCount;
/**
* 充值用户数量
*/
private Integer rechargeUserCount;
/**
* 创建订单用户数
*/
private Integer orderCreateUserCount;
/**
* 支付订单用户数
*/
private Integer orderPayUserCount;
/**
* 总支付金额单位
*/
private Integer orderPayPrice;
}

View File

@ -37,6 +37,10 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Resource @Resource
private TradeStatisticsMapper tradeStatisticsMapper; private TradeStatisticsMapper tradeStatisticsMapper;
// TODO @疯狂统计逻辑自己服务 mapper 去统计不要调用其它服务 API
// 主要的考虑点其它服务是在线的业务统计是离线业务尽量不占用他们的 db 资源
// 统计服务从建议使用从库或者从 mysql 抽取到单独的 clickhouse 或者其它的大数据组件
@Resource @Resource
private TradeOrderApi tradeOrderApi; private TradeOrderApi tradeOrderApi;
@Resource @Resource