Commit c5f2d07c873831ab51361b04052619d43c3af87a
1 parent
26dfbfb2
商城:增加 stat 统计设计
Showing
15 changed files
with
466 additions
and
1 deletions
yudao-module-mall/pom.xml
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | <name>${project.artifactId}</name> |
| 16 | 16 | |
| 17 | 17 | <description> |
| 18 | - 商城大模块,由 product 商品、promotion 营销、trade 交易等组成 | |
| 18 | + 商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成 | |
| 19 | 19 | </description> |
| 20 | 20 | <modules> |
| 21 | 21 | <module>yudao-module-promotion-api</module> |
| ... | ... | @@ -24,6 +24,8 @@ |
| 24 | 24 | <module>yudao-module-product-biz</module> |
| 25 | 25 | <module>yudao-module-trade-api</module> |
| 26 | 26 | <module>yudao-module-trade-biz</module> |
| 27 | + <module>yudao-module-statistics-api</module> | |
| 28 | + <module>yudao-module-statistics-biz</module> | |
| 27 | 29 | </modules> |
| 28 | 30 | |
| 29 | 31 | </project> | ... | ... |
yudao-module-mall/yudao-module-statistics-api/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <parent> | |
| 6 | + <groupId>cn.iocoder.boot</groupId> | |
| 7 | + <artifactId>yudao-module-mall</artifactId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + </parent> | |
| 10 | + <modelVersion>4.0.0</modelVersion> | |
| 11 | + <artifactId>yudao-module-statistics-api</artifactId> | |
| 12 | + <packaging>jar</packaging> | |
| 13 | + | |
| 14 | + <name>${project.artifactId}</name> | |
| 15 | + <description> | |
| 16 | + statistics 模块 API,暴露给其它模块调用 | |
| 17 | + </description> | |
| 18 | + | |
| 19 | + <dependencies> | |
| 20 | + <dependency> | |
| 21 | + <groupId>cn.iocoder.boot</groupId> | |
| 22 | + <artifactId>yudao-common</artifactId> | |
| 23 | + </dependency> | |
| 24 | + | |
| 25 | + <!-- 参数校验 --> | |
| 26 | + <dependency> | |
| 27 | + <groupId>org.springframework.boot</groupId> | |
| 28 | + <artifactId>spring-boot-starter-validation</artifactId> | |
| 29 | + <optional>true</optional> | |
| 30 | + </dependency> | |
| 31 | + </dependencies> | |
| 32 | + | |
| 33 | +</project> | ... | ... |
yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java
0 → 100644
yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java
0 → 100644
yudao-module-mall/yudao-module-statistics-biz/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <parent> | |
| 6 | + <groupId>cn.iocoder.boot</groupId> | |
| 7 | + <artifactId>yudao-module-mall</artifactId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + </parent> | |
| 10 | + <modelVersion>4.0.0</modelVersion> | |
| 11 | + <artifactId>yudao-module-statistics-biz</artifactId> | |
| 12 | + <packaging>jar</packaging> | |
| 13 | + | |
| 14 | + <name>${project.artifactId}</name> | |
| 15 | + <description> | |
| 16 | + statistics 模块,主要实现统计相关功能 | |
| 17 | + 例如:统计商品、会员、交易等功能。 | |
| 18 | + </description> | |
| 19 | + | |
| 20 | + <dependencies> | |
| 21 | + <dependency> | |
| 22 | + <groupId>cn.iocoder.boot</groupId> | |
| 23 | + <artifactId>yudao-module-statistics-api</artifactId> | |
| 24 | + <version>${revision}</version> | |
| 25 | + </dependency> | |
| 26 | + <dependency> | |
| 27 | + <groupId>cn.iocoder.boot</groupId> | |
| 28 | + <artifactId>yudao-module-promotion-api</artifactId> | |
| 29 | + <version>${revision}</version> | |
| 30 | + </dependency> | |
| 31 | + <dependency> | |
| 32 | + <groupId>cn.iocoder.boot</groupId> | |
| 33 | + <artifactId>yudao-module-product-api</artifactId> | |
| 34 | + <version>${revision}</version> | |
| 35 | + </dependency> | |
| 36 | + <dependency> | |
| 37 | + <groupId>cn.iocoder.boot</groupId> | |
| 38 | + <artifactId>yudao-module-trade-api</artifactId> | |
| 39 | + <version>${revision}</version> | |
| 40 | + </dependency> | |
| 41 | + <dependency> | |
| 42 | + <groupId>cn.iocoder.boot</groupId> | |
| 43 | + <artifactId>yudao-module-member-api</artifactId> | |
| 44 | + <version>${revision}</version> | |
| 45 | + </dependency> | |
| 46 | + | |
| 47 | + <!-- 业务组件 --> | |
| 48 | + <dependency> | |
| 49 | + <groupId>cn.iocoder.boot</groupId> | |
| 50 | + <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> | |
| 51 | + </dependency> | |
| 52 | + | |
| 53 | + <!-- Web 相关 --> | |
| 54 | + <dependency> | |
| 55 | + <groupId>cn.iocoder.boot</groupId> | |
| 56 | + <artifactId>yudao-spring-boot-starter-web</artifactId> | |
| 57 | + </dependency> | |
| 58 | + <dependency> | |
| 59 | + <groupId>cn.iocoder.boot</groupId> | |
| 60 | + <artifactId>yudao-spring-boot-starter-security</artifactId> | |
| 61 | + </dependency> | |
| 62 | + | |
| 63 | + <!-- DB 相关 --> | |
| 64 | + <dependency> | |
| 65 | + <groupId>cn.iocoder.boot</groupId> | |
| 66 | + <artifactId>yudao-spring-boot-starter-mybatis</artifactId> | |
| 67 | + </dependency> | |
| 68 | + | |
| 69 | + <!-- Test 测试相关 --> | |
| 70 | + <dependency> | |
| 71 | + <groupId>cn.iocoder.boot</groupId> | |
| 72 | + <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 73 | + </dependency> | |
| 74 | + | |
| 75 | + <!-- 工具类相关 --> | |
| 76 | + <dependency> | |
| 77 | + <groupId>cn.iocoder.boot</groupId> | |
| 78 | + <artifactId>yudao-spring-boot-starter-excel</artifactId> | |
| 79 | + </dependency> | |
| 80 | + <dependency> | |
| 81 | + <groupId>cn.iocoder.boot</groupId> | |
| 82 | + <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | |
| 83 | + </dependency> | |
| 84 | + </dependencies> | |
| 85 | + | |
| 86 | +</project> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/member/package-info.java
0 → 100644
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller; | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/product/ProductStatisticsController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.product; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductSpuStatisticsDO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductStatisticsDO; | |
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 8 | +import lombok.extern.slf4j.Slf4j; | |
| 9 | +import org.springframework.validation.annotation.Validated; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +@Tag(name = "管理后台 - 商品统计") | |
| 17 | +@RestController | |
| 18 | +@RequestMapping("/statistics/product") | |
| 19 | +@Validated | |
| 20 | +@Slf4j | |
| 21 | +public class ProductStatisticsController { | |
| 22 | + | |
| 23 | + // TODO @麦子:返回 ProductStatisticsComparisonResp, 里面有两个字段,一个是选择的时间范围的合计结果,一个是对比的时间范围的合计结果; | |
| 24 | + // 例如说,选择时间范围是 2023-10-01 ~ 2023-10-02,那么对比就是 2023-09-30,再倒推 2 天; | |
| 25 | + public CommonResult<Object> getProductStatisticsComparison() { | |
| 26 | + return null; | |
| 27 | + } | |
| 28 | + | |
| 29 | + // TODO @麦子:查询指定时间范围内的商品统计数据;DO 到时需要改成 VO 哈 | |
| 30 | + public CommonResult<List<ProductStatisticsDO>> getProductStatisticsList( | |
| 31 | + LocalDateTime[] times) { | |
| 32 | + return null; | |
| 33 | + } | |
| 34 | + | |
| 35 | + // TODO @麦子:查询指定时间范围内的商品 SPU 统计数据;DO 到时需要改成 VO 哈 | |
| 36 | + // 入参是分页参数 + 时间范围 + 排序字段 | |
| 37 | + public CommonResult<PageResult<ProductSpuStatisticsDO>> getProductSpuStatisticsPage() { | |
| 38 | + return null; | |
| 39 | + } | |
| 40 | + | |
| 41 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/trade/TradeStatisticsController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsDO; | |
| 5 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.validation.annotation.Validated; | |
| 8 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 9 | +import org.springframework.web.bind.annotation.RestController; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +@Tag(name = "管理后台 - 交易统计") | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("/statistics/product") | |
| 17 | +@Validated | |
| 18 | +@Slf4j | |
| 19 | +public class TradeStatisticsController { | |
| 20 | + | |
| 21 | + // TODO @疯狂:有个 summary 接口,返回昨日、本月、支付金额、本月订单金额等数据;具体看 ui 哈; | |
| 22 | + | |
| 23 | + // TODO @疯狂:返回 ProductStatisticsComparisonResp, 里面有两个字段,一个是选择的时间范围的合计结果,一个是对比的时间范围的合计结果; | |
| 24 | + // 例如说,选择时间范围是 2023-10-01 ~ 2023-10-02,那么对比就是 2023-09-30,再倒推 2 天; | |
| 25 | + public CommonResult<Object> getTradeStatisticsComparison() { | |
| 26 | + return null; | |
| 27 | + } | |
| 28 | + | |
| 29 | + // TODO @疯狂:查询指定时间范围内的交易统计数据;DO 到时需要改成 VO 哈 | |
| 30 | + // 总收入(营业额)= 订单、充值的支付 - 订单、充值的退款 | |
| 31 | + public CommonResult<List<TradeStatisticsDO>> getTradeStatisticsList( | |
| 32 | + LocalDateTime[] times) { | |
| 33 | + return null; | |
| 34 | + } | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java
0 → 100644
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductSpuStatisticsDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.product; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 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 | + * 商品 SPU 统计 DO | |
| 13 | + * | |
| 14 | + * 以天为维度,统计商品 SPU 的数据 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("product_spu_statistics") | |
| 19 | +@KeySequence("product_spu_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 ProductSpuStatisticsDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号,主键自增 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 商品 SPU 编号 | |
| 36 | + * | |
| 37 | + * 关联 ProductSpuDO 的 id 字段 | |
| 38 | + */ | |
| 39 | + private Long spuId; | |
| 40 | + /** | |
| 41 | + * 统计日期 | |
| 42 | + */ | |
| 43 | + private LocalDateTime time; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 浏览量 | |
| 47 | + */ | |
| 48 | + private Integer browseCount; | |
| 49 | + /** | |
| 50 | + * 收藏量 | |
| 51 | + */ | |
| 52 | + private Integer favoriteCount; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 添加购物车次数 | |
| 56 | + * | |
| 57 | + * 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。 | |
| 58 | + * 直到该次被下单、或者被删除,后续再次被添加到购物车。 | |
| 59 | + */ | |
| 60 | + private Integer addCartCount; | |
| 61 | + /** | |
| 62 | + * 创建订单商品数 | |
| 63 | + */ | |
| 64 | + private Integer createOrderCount; | |
| 65 | + /** | |
| 66 | + * 支付订单商品数 | |
| 67 | + */ | |
| 68 | + private Integer payOrderCount; | |
| 69 | + /** | |
| 70 | + * 总支付金额,单位:分 | |
| 71 | + */ | |
| 72 | + private Integer payPrice; | |
| 73 | + | |
| 74 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.product; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 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 | + * | |
| 14 | + * 以天为维度,统计全部的数据 | |
| 15 | + * | |
| 16 | + * 和 {@link ProductSpuStatisticsDO} 的差异是,它是全局的统计 | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@TableName("product_spu_statistics") | |
| 21 | +@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class ProductStatisticsDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 编号,主键自增 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 统计日期 | |
| 38 | + */ | |
| 39 | + private LocalDateTime time; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 浏览量 | |
| 43 | + */ | |
| 44 | + private Integer browseCount; | |
| 45 | + /** | |
| 46 | + * 收藏量 | |
| 47 | + */ | |
| 48 | + private Integer favoriteCount; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 添加购物车次数 | |
| 52 | + * | |
| 53 | + * 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。 | |
| 54 | + * 直到该次被下单、或者被删除,后续再次被添加到购物车。 | |
| 55 | + */ | |
| 56 | + private Integer addCartCount; | |
| 57 | + /** | |
| 58 | + * 创建订单商品数 | |
| 59 | + */ | |
| 60 | + private Integer createOrderCount; | |
| 61 | + /** | |
| 62 | + * 支付订单商品数 | |
| 63 | + */ | |
| 64 | + private Integer payOrderCount; | |
| 65 | + /** | |
| 66 | + * 总支付金额,单位:分 | |
| 67 | + */ | |
| 68 | + private Integer payPrice; | |
| 69 | + | |
| 70 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 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 | + * | |
| 14 | + * 以天为维度,统计全部的数据 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("trade_statistics") | |
| 19 | +@KeySequence("trade_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 TradeStatisticsDO extends BaseDO { | |
| 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 orderCreateCount; | |
| 43 | + /** | |
| 44 | + * 支付订单商品数 | |
| 45 | + */ | |
| 46 | + private Integer orderPayCount; | |
| 47 | + /** | |
| 48 | + * 总支付金额,单位:分 | |
| 49 | + */ | |
| 50 | + private Integer orderPayPrice; | |
| 51 | + /** | |
| 52 | + * 总支付金额(余额),单位:分 | |
| 53 | + */ | |
| 54 | + private Integer orderWalletPayPrice; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 退款订单数 | |
| 58 | + */ | |
| 59 | + private Integer afterSaleCount; | |
| 60 | + /** | |
| 61 | + * 总退款金额,单位:分 | |
| 62 | + */ | |
| 63 | + private Integer afterSaleRefundPrice; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 佣金金额(已结算),单位:分 | |
| 67 | + */ | |
| 68 | + private Integer brokerageSettlementPrice; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 充值订单数 | |
| 72 | + * | |
| 73 | + * 从 PayWalletRechargeDO 计算 | |
| 74 | + */ | |
| 75 | + private Integer rechargePayCount; | |
| 76 | + /** | |
| 77 | + * 充值金额,单位:分 | |
| 78 | + */ | |
| 79 | + private Integer rechargePayPrice; | |
| 80 | + /** | |
| 81 | + * 充值退款订单数 | |
| 82 | + */ | |
| 83 | + private Integer rechargeRefundCount; | |
| 84 | + /** | |
| 85 | + * 充值退款金额,单位:分 | |
| 86 | + */ | |
| 87 | + private Integer rechargeRefundPrice; | |
| 88 | + | |
| 89 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java
0 → 100644
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java
0 → 100644