diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java new file mode 100644 index 000000000..f4f0f3d92 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java @@ -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> getMemberSummary() { + // TODO 疯狂:目前先直接计算; + return null; + } + + @GetMapping("/get-area-statistics-list") + @Operation(summary = "按照省份,获得会员统计列表") + public CommonResult> getMemberAreaStatisticsList() { + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 + return null; + } + + @GetMapping("/get-sex-statistics-list") + @Operation(summary = "按照性别,获得会员统计列表") + public CommonResult> getMemberSexStatisticsList() { + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 + return null; + } + + @GetMapping("/get-terminal-statistics-list") + @Operation(summary = "按照终端,获得会员统计列表") + public CommonResult> getMemberTerminalStatisticsList() { + // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 + // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal + return null; + } + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java new file mode 100644 index 000000000..1fd09ac9d --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java new file mode 100644 index 000000000..83a0b17e8 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java new file mode 100644 index 000000000..ab79dfeeb --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java new file mode 100644 index 000000000..06112e3b0 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java index d59461b35..5e0e7c62d 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java +++ b/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; @Schema(description = "管理后台 - 交易统计 Response VO") @Data public class TradeSummaryRespVO { + @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer yesterdayOrderCount; @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @@ -15,4 +16,5 @@ public class TradeSummaryRespVO { private Integer monthOrderCount; @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer monthPayPrice; + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java new file mode 100644 index 000000000..bda806bd8 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java @@ -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 + *

+ * 以天为维度,统计全部的数据 + * + * @author 芋道源码 + */ +@TableName("member_statistics") +@KeySequence("member_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java index 5a0679365..fdaf50f1d 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ b/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 { @Resource private TradeStatisticsMapper tradeStatisticsMapper; + // TODO @疯狂:统计逻辑,自己服务 mapper 去统计,不要调用其它服务 API; + // 主要的考虑点,其它服务是在线的业务,统计是离线业务,尽量不占用他们的 db 资源; + // 统计服务,从建议使用从库,或者从 mysql 抽取到单独的 clickhouse 或者其它的大数据组件; + @Resource private TradeOrderApi tradeOrderApi; @Resource