Commit a37427c355badec7d705bb052fac4a5e8b8c6676
1 parent
c5824eed
stat:增加用户统计的设计
Showing
8 changed files
with
226 additions
and
0 deletions
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | |
| 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; | |
| 8 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RestController; | |
| 16 | + | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +@Tag(name = "管理后台 - 会员统计") | |
| 20 | +@RestController | |
| 21 | +@RequestMapping("/statistics/member") | |
| 22 | +@Validated | |
| 23 | +@Slf4j | |
| 24 | +public class MemberStatisticsController { | |
| 25 | + | |
| 26 | + // TODO @疯狂:一个类似 getTradeTrendSummaryComparison 的接口 | |
| 27 | + // TODO @疯狂:一个类似 getTradeStatisticsList 的接口 | |
| 28 | + | |
| 29 | + @GetMapping("/summary") | |
| 30 | + @Operation(summary = "获得会员统计") | |
| 31 | + public CommonResult<TradeStatisticsComparisonRespVO<MemberSummaryRespVO>> getMemberSummary() { | |
| 32 | + // TODO 疯狂:目前先直接计算; | |
| 33 | + return null; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @GetMapping("/get-area-statistics-list") | |
| 37 | + @Operation(summary = "按照省份,获得会员统计列表") | |
| 38 | + public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() { | |
| 39 | + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 40 | + return null; | |
| 41 | + } | |
| 42 | + | |
| 43 | + @GetMapping("/get-sex-statistics-list") | |
| 44 | + @Operation(summary = "按照性别,获得会员统计列表") | |
| 45 | + public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() { | |
| 46 | + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 47 | + return null; | |
| 48 | + } | |
| 49 | + | |
| 50 | + @GetMapping("/get-terminal-statistics-list") | |
| 51 | + @Operation(summary = "按照终端,获得会员统计列表") | |
| 52 | + public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { | |
| 53 | + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 54 | + // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal | |
| 55 | + return null; | |
| 56 | + } | |
| 57 | + | |
| 58 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 会员地区统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class MemberAreaStatisticsRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | + private Integer areaId; | |
| 12 | + @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") | |
| 13 | + private String areaName; | |
| 14 | + | |
| 15 | + @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 16 | + private Integer userCount; | |
| 17 | + | |
| 18 | + @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + private Integer orderCreateCount; | |
| 20 | + @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | |
| 21 | + private Integer orderPayCount; | |
| 22 | + @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | |
| 23 | + private Integer orderPayPrice; | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 会员性别统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class MemberSexStatisticsRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | + private Integer sex; | |
| 12 | + | |
| 13 | + @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Integer userCount; | |
| 15 | + | |
| 16 | + @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + private Integer orderCreateCount; | |
| 18 | + @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | |
| 19 | + private Integer orderPayCount; | |
| 20 | + @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | |
| 21 | + private Integer orderPayPrice; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 会员统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class MemberSummaryRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Integer userCount; | |
| 12 | + | |
| 13 | + @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | |
| 14 | + private Integer rechargeUserCount; | |
| 15 | + | |
| 16 | + @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + private Integer rechargePrice; | |
| 18 | + @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + private Integer expensePrice; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 终端性别统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class MemberTerminalStatisticsRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "终端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | + private Integer terminal; | |
| 12 | + | |
| 13 | + @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Integer userCount; | |
| 15 | + | |
| 16 | + @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + private Integer orderCreateCount; | |
| 18 | + @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | |
| 19 | + private Integer orderPayCount; | |
| 20 | + @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | |
| 21 | + private Integer orderPayPrice; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java
| ... | ... | @@ -6,6 +6,7 @@ import lombok.Data; |
| 6 | 6 | @Schema(description = "管理后台 - 交易统计 Response VO") |
| 7 | 7 | @Data |
| 8 | 8 | public class TradeSummaryRespVO { |
| 9 | + | |
| 9 | 10 | @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 10 | 11 | private Integer yesterdayOrderCount; |
| 11 | 12 | @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| ... | ... | @@ -15,4 +16,5 @@ public class TradeSummaryRespVO { |
| 15 | 16 | private Integer monthOrderCount; |
| 16 | 17 | @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 17 | 18 | private Integer monthPayPrice; |
| 19 | + | |
| 18 | 20 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.dataobject.member; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 会员统计 DO | |
| 13 | + * <p> | |
| 14 | + * 以天为维度,统计全部的数据 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("member_statistics") | |
| 19 | +@KeySequence("member_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class MemberStatisticsDO extends TenantBaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号,主键自增 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 统计日期 | |
| 36 | + */ | |
| 37 | + private LocalDateTime time; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 注册用户数量 | |
| 41 | + */ | |
| 42 | + private Integer userRegisterCount; | |
| 43 | + /** | |
| 44 | + * 访问用户数量(UV) | |
| 45 | + */ | |
| 46 | + private Integer userVisitCount; | |
| 47 | + /** | |
| 48 | + * 访问页面数量(PV) | |
| 49 | + */ | |
| 50 | + private Integer pageVisitCount; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 充值用户数量 | |
| 54 | + */ | |
| 55 | + private Integer rechargeUserCount; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 创建订单用户数 | |
| 59 | + */ | |
| 60 | + private Integer orderCreateUserCount; | |
| 61 | + /** | |
| 62 | + * 支付订单用户数 | |
| 63 | + */ | |
| 64 | + private Integer orderPayUserCount; | |
| 65 | + /** | |
| 66 | + * 总支付金额,单位:分 | |
| 67 | + */ | |
| 68 | + private Integer orderPayPrice; | |
| 69 | + | |
| 70 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| ... | ... | @@ -37,6 +37,10 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 37 | 37 | @Resource |
| 38 | 38 | private TradeStatisticsMapper tradeStatisticsMapper; |
| 39 | 39 | |
| 40 | + // TODO @疯狂:统计逻辑,自己服务 mapper 去统计,不要调用其它服务 API; | |
| 41 | + // 主要的考虑点,其它服务是在线的业务,统计是离线业务,尽量不占用他们的 db 资源; | |
| 42 | + // 统计服务,从建议使用从库,或者从 mysql 抽取到单独的 clickhouse 或者其它的大数据组件; | |
| 43 | + | |
| 40 | 44 | @Resource |
| 41 | 45 | private TradeOrderApi tradeOrderApi; |
| 42 | 46 | @Resource | ... | ... |