Commit 1502159608f303edfb5ec558b001543501182693
Committed by
Gitee
!669 商城首页
Merge pull request !669 from 疯狂的世界/feature/mall_product
Showing
56 changed files
with
950 additions
and
264 deletions
sql/mysql/mall.sql
0 → 100644
sql/mysql/member.sql
0 → 100644
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java
| 1 | package cn.iocoder.yudao.framework.common.util.servlet; | 1 | package cn.iocoder.yudao.framework.common.util.servlet; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.convert.Convert; | ||
| 3 | import cn.hutool.core.io.IoUtil; | 4 | import cn.hutool.core.io.IoUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.hutool.extra.servlet.ServletUtil; | 6 | import cn.hutool.extra.servlet.ServletUtil; |
| @@ -27,7 +28,7 @@ public class ServletUtils { | @@ -27,7 +28,7 @@ public class ServletUtils { | ||
| 27 | * 返回 JSON 字符串 | 28 | * 返回 JSON 字符串 |
| 28 | * | 29 | * |
| 29 | * @param response 响应 | 30 | * @param response 响应 |
| 30 | - * @param object 对象,会序列化成 JSON 字符串 | 31 | + * @param object 对象,会序列化成 JSON 字符串 |
| 31 | */ | 32 | */ |
| 32 | @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 | 33 | @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 |
| 33 | public static void writeJSON(HttpServletResponse response, Object object) { | 34 | public static void writeJSON(HttpServletResponse response, Object object) { |
| @@ -40,7 +41,7 @@ public class ServletUtils { | @@ -40,7 +41,7 @@ public class ServletUtils { | ||
| 40 | * | 41 | * |
| 41 | * @param response 响应 | 42 | * @param response 响应 |
| 42 | * @param filename 文件名 | 43 | * @param filename 文件名 |
| 43 | - * @param content 附件内容 | 44 | + * @param content 附件内容 |
| 44 | */ | 45 | */ |
| 45 | public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException { | 46 | public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException { |
| 46 | // 设置 header 和 contentType | 47 | // 设置 header 和 contentType |
| @@ -88,6 +89,18 @@ public class ServletUtils { | @@ -88,6 +89,18 @@ public class ServletUtils { | ||
| 88 | return ServletUtil.getClientIP(request); | 89 | return ServletUtil.getClientIP(request); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 92 | + public static Integer getTerminal() { | ||
| 93 | + return getHeaderInt("terminal"); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public static String getHeader(String header) { | ||
| 97 | + return getHeader(getRequest(), header); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public static Integer getHeaderInt(String header) { | ||
| 101 | + return Convert.toInt(getHeader(header)); | ||
| 102 | + } | ||
| 103 | + | ||
| 91 | public static boolean isJsonRequest(ServletRequest request) { | 104 | public static boolean isJsonRequest(ServletRequest request) { |
| 92 | return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE); | 105 | return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE); |
| 93 | } | 106 | } |
| @@ -107,4 +120,12 @@ public class ServletUtils { | @@ -107,4 +120,12 @@ public class ServletUtils { | ||
| 107 | public static Map<String, String> getParamMap(HttpServletRequest request) { | 120 | public static Map<String, String> getParamMap(HttpServletRequest request) { |
| 108 | return ServletUtil.getParamMap(request); | 121 | return ServletUtil.getParamMap(request); |
| 109 | } | 122 | } |
| 123 | + | ||
| 124 | + public static String getHeader(HttpServletRequest request, String header) { | ||
| 125 | + if (request == null) { | ||
| 126 | + return null; | ||
| 127 | + } | ||
| 128 | + return request.getHeader(header); | ||
| 129 | + } | ||
| 130 | + | ||
| 110 | } | 131 | } |
yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.enums; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 时间范围类型的枚举 | ||
| 11 | + * | ||
| 12 | + * @author owen | ||
| 13 | + */ | ||
| 14 | +@AllArgsConstructor | ||
| 15 | +@Getter | ||
| 16 | +public enum TimeRangeTypeEnum implements IntArrayValuable { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 天 | ||
| 20 | + */ | ||
| 21 | + DAY(1), | ||
| 22 | + /** | ||
| 23 | + * 周 | ||
| 24 | + */ | ||
| 25 | + WEEK(7), | ||
| 26 | + /** | ||
| 27 | + * 月 | ||
| 28 | + */ | ||
| 29 | + MONTH(30), | ||
| 30 | + /** | ||
| 31 | + * 年 | ||
| 32 | + */ | ||
| 33 | + YEAR(365), | ||
| 34 | + ; | ||
| 35 | + | ||
| 36 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray(); | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 状态 | ||
| 41 | + */ | ||
| 42 | + private final Integer type; | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public int[] array() { | ||
| 46 | + return ARRAYS; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeStatisticsComparisonRespVO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java
| 1 | -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.common.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.NoArgsConstructor; | 6 | import lombok.NoArgsConstructor; |
| 7 | 7 | ||
| 8 | -// TODO @疯狂:是不是搞成公用的哈;类似,controller/admin/common,下面直接放它 | ||
| 9 | -@Schema(description = "管理后台 - 交易统计对照 Response VO") | 8 | +@Schema(description = "管理后台 - 数据对照 Response VO") |
| 10 | @Data | 9 | @Data |
| 11 | @NoArgsConstructor | 10 | @NoArgsConstructor |
| 12 | @AllArgsConstructor | 11 | @AllArgsConstructor |
| 13 | -public class TradeStatisticsComparisonRespVO<T> { | 12 | +public class DataComparisonRespVO<T> { |
| 14 | 13 | ||
| 15 | @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 14 | @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | private T value; | 15 | private T value; |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java
| 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member; | 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.ArrayUtil; | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | 4 | +import cn.hutool.core.util.NumberUtil; |
| 5 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 6 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; |
| 9 | +import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | ||
| 10 | +import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; | ||
| 7 | import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; | 11 | import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; |
| 12 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | ||
| 8 | import io.swagger.v3.oas.annotations.Operation; | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | import io.swagger.v3.oas.annotations.tags.Tag; | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 10 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| @@ -15,10 +20,10 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -15,10 +20,10 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
| 15 | import org.springframework.web.bind.annotation.RestController; | 20 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 21 | ||
| 17 | import javax.annotation.Resource; | 22 | import javax.annotation.Resource; |
| 23 | +import java.time.LocalDateTime; | ||
| 18 | import java.util.List; | 24 | import java.util.List; |
| 19 | 25 | ||
| 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 26 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 22 | 27 | ||
| 23 | @Tag(name = "管理后台 - 会员统计") | 28 | @Tag(name = "管理后台 - 会员统计") |
| 24 | @RestController | 29 | @RestController |
| @@ -29,6 +34,10 @@ public class MemberStatisticsController { | @@ -29,6 +34,10 @@ public class MemberStatisticsController { | ||
| 29 | 34 | ||
| 30 | @Resource | 35 | @Resource |
| 31 | private MemberStatisticsService memberStatisticsService; | 36 | private MemberStatisticsService memberStatisticsService; |
| 37 | + @Resource | ||
| 38 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | ||
| 39 | + @Resource | ||
| 40 | + private ApiAccessLogStatisticsService apiAccessLogStatisticsService; | ||
| 32 | 41 | ||
| 33 | // TODO 芋艿:已经 review | 42 | // TODO 芋艿:已经 review |
| 34 | @GetMapping("/summary") | 43 | @GetMapping("/summary") |
| @@ -43,8 +52,28 @@ public class MemberStatisticsController { | @@ -43,8 +52,28 @@ public class MemberStatisticsController { | ||
| 43 | @Operation(summary = "获得会员分析数据") | 52 | @Operation(summary = "获得会员分析数据") |
| 44 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") | 53 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 45 | public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) { | 54 | public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) { |
| 46 | - return success(memberStatisticsService.getMemberAnalyse( | ||
| 47 | - ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | 55 | + // 1. 查询数据 |
| 56 | + LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); | ||
| 57 | + LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); | ||
| 58 | + // 1.1 查询分析对照数据 | ||
| 59 | + DataComparisonRespVO<MemberAnalyseDataRespVO> comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime); | ||
| 60 | + // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; | ||
| 61 | + // 1.2 查询成交用户数量 | ||
| 62 | + Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); | ||
| 63 | + // 1.3 计算客单价 | ||
| 64 | + int atv = 0; | ||
| 65 | + if (payUserCount != null && payUserCount > 0) { | ||
| 66 | + // TODO @疯狂:类似上面的 payUserCount | ||
| 67 | + Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); | ||
| 68 | + atv = NumberUtil.div(payPrice, payUserCount).intValue(); | ||
| 69 | + } | ||
| 70 | + // 1.4 查询访客数量 | ||
| 71 | + Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime); | ||
| 72 | + // 1.5 下单用户数量 | ||
| 73 | + Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime); | ||
| 74 | + | ||
| 75 | + // 2. 拼接返回 | ||
| 76 | + return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData)); | ||
| 48 | } | 77 | } |
| 49 | 78 | ||
| 50 | // TODO 芋艿:已经 review | 79 | // TODO 芋艿:已经 review |
| @@ -67,12 +96,22 @@ public class MemberStatisticsController { | @@ -67,12 +96,22 @@ public class MemberStatisticsController { | ||
| 67 | @Operation(summary = "按照终端,获得会员统计列表") | 96 | @Operation(summary = "按照终端,获得会员统计列表") |
| 68 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") | 97 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 69 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { | 98 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { |
| 70 | - // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal | ||
| 71 | - // TODO @疯狂:在 member_user 上,增加 registerTerminal 字段,基于它来统计哈; | ||
| 72 | - List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(), | ||
| 73 | - t -> new MemberTerminalStatisticsRespVO() | ||
| 74 | - .setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100)); | ||
| 75 | - return success(list); | 99 | + return success(memberStatisticsService.getRegisterTerminalStatisticsList()); |
| 100 | + } | ||
| 101 | + | ||
| 102 | + @GetMapping("/user-count-comparison") | ||
| 103 | + @Operation(summary = "获得用户数量对照") | ||
| 104 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 105 | + public CommonResult<DataComparisonRespVO<MemberCountRespVO>> getUserCountComparison() { | ||
| 106 | + return success(memberStatisticsService.getUserCountComparison()); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @GetMapping("/register-count-list") | ||
| 110 | + @Operation(summary = "获得会员注册数量列表") | ||
| 111 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 112 | + public CommonResult<List<MemberRegisterCountRespVO>> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { | ||
| 113 | + return success(memberStatisticsService.getMemberRegisterCountList( | ||
| 114 | + ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | ||
| 76 | } | 115 | } |
| 77 | 116 | ||
| 78 | } | 117 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseComparisonRespVO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java
| @@ -3,17 +3,15 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | @@ -3,17 +3,15 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | -@Schema(description = "管理后台 - 会员分析对照数据 Response VO") | 6 | +@Schema(description = "管理后台 - 会员分析数据 Response VO") |
| 7 | @Data | 7 | @Data |
| 8 | -public class MemberAnalyseComparisonRespVO { | 8 | +public class MemberAnalyseDataRespVO { |
| 9 | 9 | ||
| 10 | - // TODO @疯狂:这个字段,要不改成注册用户量;registerUserCount; | ||
| 11 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 10 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 12 | - private Integer userCount; | 11 | + private Integer registerUserCount; |
| 13 | 12 | ||
| 14 | - // TODO @疯狂:这个字段,名字改成 visitUserCount;有访问,就算活跃; | ||
| 15 | @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 13 | @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | - private Integer activeUserCount; | 14 | + private Integer visitUserCount; |
| 17 | 15 | ||
| 18 | @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | 16 | @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") |
| 19 | private Integer rechargeUserCount; | 17 | private Integer rechargeUserCount; |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java
| 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; |
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| @@ -8,9 +8,8 @@ import lombok.Data; | @@ -8,9 +8,8 @@ import lombok.Data; | ||
| 8 | @Data | 8 | @Data |
| 9 | public class MemberAnalyseRespVO { | 9 | public class MemberAnalyseRespVO { |
| 10 | 10 | ||
| 11 | - // TODO @疯狂:这个字段改成 visitUserCount,保持和 userCount 字段统一 | ||
| 12 | @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 11 | @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | - private Integer visitorCount; | 12 | + private Integer visitUserCount; |
| 14 | 13 | ||
| 15 | @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 14 | @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | private Integer orderUserCount; | 15 | private Integer orderUserCount; |
| @@ -22,6 +21,6 @@ public class MemberAnalyseRespVO { | @@ -22,6 +21,6 @@ public class MemberAnalyseRespVO { | ||
| 22 | private Integer atv; | 21 | private Integer atv; |
| 23 | 22 | ||
| 24 | @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) | 23 | @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) |
| 25 | - private TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO> comparison; | 24 | + private DataComparisonRespVO<MemberAnalyseDataRespVO> comparison; |
| 26 | 25 | ||
| 27 | } | 26 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java
| @@ -15,11 +15,10 @@ public class MemberAreaStatisticsRespVO { | @@ -15,11 +15,10 @@ public class MemberAreaStatisticsRespVO { | ||
| 15 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 15 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | private Integer userCount; | 16 | private Integer userCount; |
| 17 | 17 | ||
| 18 | - // TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些; | ||
| 19 | - @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 20 | - private Integer orderCreateCount; | ||
| 21 | - @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | ||
| 22 | - private Integer orderPayCount; | 18 | + @Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | + private Integer orderCreateUserCount; | ||
| 20 | + @Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | ||
| 21 | + private Integer orderPayUserCount; | ||
| 23 | 22 | ||
| 24 | @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | 23 | @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") |
| 25 | private Integer orderPayPrice; | 24 | private Integer orderPayPrice; |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.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 MemberCountRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 11 | + private Integer visitUserCount; | ||
| 12 | + | ||
| 13 | + @Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | + private Integer createUserCount; | ||
| 15 | + | ||
| 16 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDate; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; | ||
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 会员注册数量 Response VO") | ||
| 13 | +@Data | ||
| 14 | +public class MemberRegisterCountRespVO { | ||
| 15 | + | ||
| 16 | + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) | ||
| 17 | + @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 18 | + private LocalDate date; | ||
| 19 | + | ||
| 20 | + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 21 | + private Integer count; | ||
| 22 | + | ||
| 23 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.pay; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | ||
| 5 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 6 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 7 | +import lombok.extern.slf4j.Slf4j; | ||
| 8 | +import org.springframework.validation.annotation.Validated; | ||
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.RestController; | ||
| 12 | + | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | + | ||
| 15 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 16 | + | ||
| 17 | +@Tag(name = "管理后台 - 支付统计") | ||
| 18 | +@RestController | ||
| 19 | +@RequestMapping("/statistics/pay") | ||
| 20 | +@Validated | ||
| 21 | +@Slf4j | ||
| 22 | +public class PayStatisticsController { | ||
| 23 | + | ||
| 24 | + @Resource | ||
| 25 | + private PayWalletStatisticsService payWalletStatisticsService; | ||
| 26 | + | ||
| 27 | + @GetMapping("/wallet-recharge-price") | ||
| 28 | + @Operation(summary = "获取充值金额") | ||
| 29 | + public CommonResult<Integer> getWalletRechargePrice() { | ||
| 30 | + return success(payWalletStatisticsService.getRechargePriceSummary()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java
| @@ -3,9 +3,17 @@ package cn.iocoder.yudao.module.statistics.controller.admin.trade; | @@ -3,9 +3,17 @@ package cn.iocoder.yudao.module.statistics.controller.admin.trade; | ||
| 3 | import cn.hutool.core.util.ArrayUtil; | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; |
| 7 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; | 8 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 9 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | ||
| 10 | +import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService; | ||
| 11 | +import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService; | ||
| 12 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | ||
| 8 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; | 13 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; |
| 14 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | ||
| 15 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | ||
| 16 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | ||
| 9 | import io.swagger.v3.oas.annotations.Operation; | 17 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
| @@ -17,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; | @@ -17,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; | ||
| 17 | 25 | ||
| 18 | import javax.annotation.Resource; | 26 | import javax.annotation.Resource; |
| 19 | import javax.servlet.http.HttpServletResponse; | 27 | import javax.servlet.http.HttpServletResponse; |
| 28 | +import javax.validation.Valid; | ||
| 20 | import java.io.IOException; | 29 | import java.io.IOException; |
| 21 | import java.util.List; | 30 | import java.util.List; |
| 22 | 31 | ||
| @@ -31,46 +40,82 @@ public class TradeStatisticsController { | @@ -31,46 +40,82 @@ public class TradeStatisticsController { | ||
| 31 | 40 | ||
| 32 | @Resource | 41 | @Resource |
| 33 | private TradeStatisticsService tradeStatisticsService; | 42 | private TradeStatisticsService tradeStatisticsService; |
| 43 | + @Resource | ||
| 44 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | ||
| 45 | + @Resource | ||
| 46 | + private AfterSaleStatisticsService afterSaleStatisticsService; | ||
| 47 | + @Resource | ||
| 48 | + private BrokerageStatisticsService brokerageStatisticsService; | ||
| 34 | 49 | ||
| 35 | @GetMapping("/summary") | 50 | @GetMapping("/summary") |
| 36 | @Operation(summary = "获得交易统计") | 51 | @Operation(summary = "获得交易统计") |
| 37 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | 52 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 38 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { | ||
| 39 | - // TODO @疯狂:这个要不要 tradeStatisticsService 调用里面的多个方法,组合出最终的 TradeSummaryRespVO; | ||
| 40 | - return success(tradeStatisticsService.getTradeSummaryComparison()); | 53 | + public CommonResult<DataComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { |
| 54 | + // 1.1 昨天的数据 | ||
| 55 | + TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); | ||
| 56 | + // 1.2 前天的数据(用于对照昨天的数据) | ||
| 57 | + TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); | ||
| 58 | + // 2.1 本月数据 | ||
| 59 | + TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); | ||
| 60 | + // 2.2 上月数据(用于对照本月的数据) | ||
| 61 | + TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); | ||
| 62 | + // 拼接数据 | ||
| 63 | + return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); | ||
| 41 | } | 64 | } |
| 42 | 65 | ||
| 43 | // TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse | 66 | // TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse |
| 44 | @GetMapping("/trend/summary") | 67 | @GetMapping("/trend/summary") |
| 45 | @Operation(summary = "获得交易状况统计") | 68 | @Operation(summary = "获得交易状况统计") |
| 46 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | 69 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 47 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( | 70 | + public CommonResult<DataComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( |
| 48 | TradeTrendReqVO reqVO) { | 71 | TradeTrendReqVO reqVO) { |
| 49 | return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0), | 72 | return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0), |
| 50 | ArrayUtil.get(reqVO.getTimes(), 1))); | 73 | ArrayUtil.get(reqVO.getTimes(), 1))); |
| 51 | } | 74 | } |
| 52 | 75 | ||
| 53 | - // TODO 芋艿:已经 review | ||
| 54 | - // TODO @疯狂:这个要不直接叫 list;它即使就是把每条统计拿出来 | ||
| 55 | - @GetMapping("/trend/list") | 76 | + @GetMapping("/list") |
| 56 | @Operation(summary = "获得交易状况明细") | 77 | @Operation(summary = "获得交易状况明细") |
| 57 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | 78 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 58 | - public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList( | ||
| 59 | - TradeTrendReqVO reqVO) { | ||
| 60 | - return success(tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | ||
| 61 | - ArrayUtil.get(reqVO.getTimes(), 1))); | 79 | + public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList(TradeTrendReqVO reqVO) { |
| 80 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | ||
| 81 | + ArrayUtil.get(reqVO.getTimes(), 1)); | ||
| 82 | + return success(TradeStatisticsConvert.INSTANCE.convertList(list)); | ||
| 62 | } | 83 | } |
| 63 | 84 | ||
| 64 | - // TODO @疯狂:这个要不直接叫 export;它即使就是把每条统计导出 | ||
| 65 | - @GetMapping("/trend/export-excel") | 85 | + @GetMapping("/export-excel") |
| 66 | @Operation(summary = "导出获得交易状况明细 Excel") | 86 | @Operation(summary = "导出获得交易状况明细 Excel") |
| 67 | @PreAuthorize("@ss.hasPermission('statistics:trade:export')") | 87 | @PreAuthorize("@ss.hasPermission('statistics:trade:export')") |
| 68 | public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { | 88 | public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { |
| 69 | - List<TradeTrendSummaryRespVO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | 89 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), |
| 70 | ArrayUtil.get(reqVO.getTimes(), 1)); | 90 | ArrayUtil.get(reqVO.getTimes(), 1)); |
| 71 | // 导出 Excel | 91 | // 导出 Excel |
| 72 | - List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(list); | 92 | + List<TradeTrendSummaryRespVO> voList = TradeStatisticsConvert.INSTANCE.convertList(list); |
| 93 | + List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(voList); | ||
| 73 | ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); | 94 | ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); |
| 74 | } | 95 | } |
| 75 | 96 | ||
| 97 | + @GetMapping("/order-count") | ||
| 98 | + @Operation(summary = "获得交易订单数量") | ||
| 99 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | ||
| 100 | + public CommonResult<TradeOrderCountRespVO> getOrderCount() { | ||
| 101 | + TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount(); | ||
| 102 | + vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY)) | ||
| 103 | + .setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); | ||
| 104 | + return success(vo); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @GetMapping("/order-comparison") | ||
| 108 | + @Operation(summary = "获得交易订单数量") | ||
| 109 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | ||
| 110 | + public CommonResult<DataComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() { | ||
| 111 | + return success(tradeOrderStatisticsService.getOrderComparison()); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @GetMapping("/order-count-trend") | ||
| 115 | + @Operation(summary = "获得订单量趋势统计") | ||
| 116 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | ||
| 117 | + public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { | ||
| 118 | + return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); | ||
| 119 | + } | ||
| 120 | + | ||
| 76 | } | 121 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.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 TradeOrderCountRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 11 | + private Long undelivered; | ||
| 12 | + | ||
| 13 | + @Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | + private Long pickUp; | ||
| 15 | + | ||
| 16 | + @Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | + private Long afterSaleApply; | ||
| 18 | + | ||
| 19 | + @Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 20 | + private Long auditingWithdraw; | ||
| 21 | + | ||
| 22 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.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 TradeOrderSummaryRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 11 | + private Integer orderPayCount; | ||
| 12 | + | ||
| 13 | + @Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | + private Integer orderPayPrice; | ||
| 15 | + | ||
| 16 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - 交易订单量趋势统计 Request VO") | ||
| 15 | +@Data | ||
| 16 | +public class TradeOrderTrendReqVO { | ||
| 17 | + | ||
| 18 | + @Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 19 | + @NotNull(message = "日期范围类型不能为空") | ||
| 20 | + @InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}") | ||
| 21 | + private Integer type; | ||
| 22 | + | ||
| 23 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 24 | + @Schema(description = "起始时间") | ||
| 25 | + private LocalDateTime beginTime; | ||
| 26 | + | ||
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 28 | + @Schema(description = "截止时间") | ||
| 29 | + private LocalDateTime endTime; | ||
| 30 | + | ||
| 31 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.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 TradeOrderTrendRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 11 | + private String date; | ||
| 12 | + | ||
| 13 | + @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | + private Integer orderPayCount; | ||
| 15 | + | ||
| 16 | + @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | + private Integer orderPayPrice; | ||
| 18 | + | ||
| 19 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java
| @@ -22,7 +22,7 @@ public class TradeTrendSummaryExcelVO { | @@ -22,7 +22,7 @@ public class TradeTrendSummaryExcelVO { | ||
| 22 | private LocalDate date; | 22 | private LocalDate date; |
| 23 | 23 | ||
| 24 | @ExcelProperty(value = "营业额", converter = MoneyConvert.class) | 24 | @ExcelProperty(value = "营业额", converter = MoneyConvert.class) |
| 25 | - private Integer turnover; | 25 | + private Integer turnoverPrice; |
| 26 | 26 | ||
| 27 | @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) | 27 | @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) |
| 28 | private Integer orderPayPrice; | 28 | private Integer orderPayPrice; |
| @@ -34,7 +34,7 @@ public class TradeTrendSummaryExcelVO { | @@ -34,7 +34,7 @@ public class TradeTrendSummaryExcelVO { | ||
| 34 | private Integer expensePrice; | 34 | private Integer expensePrice; |
| 35 | 35 | ||
| 36 | @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) | 36 | @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) |
| 37 | - private Integer balancePrice; | 37 | + private Integer orderWalletPayPrice; |
| 38 | 38 | ||
| 39 | @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) | 39 | @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) |
| 40 | private Integer brokerageSettlementPrice; | 40 | private Integer brokerageSettlementPrice; |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java
| @@ -16,13 +16,15 @@ public class TradeTrendSummaryRespVO { | @@ -16,13 +16,15 @@ public class TradeTrendSummaryRespVO { | ||
| 16 | @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) | 16 | @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) |
| 17 | private LocalDate date; | 17 | private LocalDate date; |
| 18 | 18 | ||
| 19 | - // TODO @疯狂,要不加个 turnoverPrice? | ||
| 20 | @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 19 | @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 21 | - private Integer turnover; // 营业额 = 商品支付金额 + 充值金额 | 20 | + private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额 |
| 22 | 21 | ||
| 23 | @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 22 | @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 24 | private Integer orderPayPrice; | 23 | private Integer orderPayPrice; |
| 25 | 24 | ||
| 25 | + @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 26 | + private Integer orderWalletPayPrice; | ||
| 27 | + | ||
| 26 | @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 28 | @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 27 | private Integer orderRefundPrice; | 29 | private Integer orderRefundPrice; |
| 28 | 30 | ||
| @@ -35,7 +37,4 @@ public class TradeTrendSummaryRespVO { | @@ -35,7 +37,4 @@ public class TradeTrendSummaryRespVO { | ||
| 35 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 37 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 36 | private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 | 38 | private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 37 | 39 | ||
| 38 | - @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 39 | - private Integer balancePrice; // TODO @疯狂:这个字段要不改成:walletPayPrice | ||
| 40 | - | ||
| 41 | } | 40 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java
| @@ -4,6 +4,9 @@ import cn.hutool.core.map.MapUtil; | @@ -4,6 +4,9 @@ import cn.hutool.core.map.MapUtil; | ||
| 4 | import cn.hutool.core.util.ObjUtil; | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | import cn.iocoder.yudao.framework.ip.core.Area; | 6 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; | ||
| 7 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | 10 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 8 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | 11 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; |
| 9 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; | 12 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| @@ -28,16 +31,20 @@ public interface MemberStatisticsConvert { | @@ -28,16 +31,20 @@ public interface MemberStatisticsConvert { | ||
| 28 | Map<Integer, Integer> userCountMap, | 31 | Map<Integer, Integer> userCountMap, |
| 29 | Map<Integer, MemberAreaStatisticsRespVO> orderMap) { | 32 | Map<Integer, MemberAreaStatisticsRespVO> orderMap) { |
| 30 | return CollectionUtils.convertList(areaList, area -> { | 33 | return CollectionUtils.convertList(areaList, area -> { |
| 31 | - MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())).orElseGet(MemberAreaStatisticsRespVO::new); | 34 | + MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())) |
| 35 | + .orElseGet(MemberAreaStatisticsRespVO::new); | ||
| 32 | return new MemberAreaStatisticsRespVO() | 36 | return new MemberAreaStatisticsRespVO() |
| 33 | .setAreaId(area.getId()).setAreaName(area.getName()) | 37 | .setAreaId(area.getId()).setAreaName(area.getName()) |
| 34 | .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) | 38 | .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) |
| 35 | - .setOrderCreateCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateCount(), 0)) | ||
| 36 | - .setOrderPayCount(ObjUtil.defaultIfNull(orderVo.getOrderPayCount(), 0)) | 39 | + .setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0)) |
| 40 | + .setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0)) | ||
| 37 | .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); | 41 | .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); |
| 38 | }); | 42 | }); |
| 39 | } | 43 | } |
| 40 | 44 | ||
| 41 | MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); | 45 | MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); |
| 42 | 46 | ||
| 47 | + MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv, | ||
| 48 | + DataComparisonRespVO<MemberAnalyseDataRespVO> comparison); | ||
| 49 | + | ||
| 43 | } | 50 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java
| 1 | package cn.iocoder.yudao.module.statistics.convert.trade; | 1 | package cn.iocoder.yudao.module.statistics.convert.trade; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | ||
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; |
| 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; |
| 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; | 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 8 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 7 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 8 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | ||
| 9 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 9 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 10 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | 10 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 11 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | 11 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 12 | import org.mapstruct.Mapper; | 12 | import org.mapstruct.Mapper; |
| 13 | import org.mapstruct.factory.Mappers; | 13 | import org.mapstruct.factory.Mappers; |
| 14 | 14 | ||
| @@ -25,10 +25,10 @@ public interface TradeStatisticsConvert { | @@ -25,10 +25,10 @@ public interface TradeStatisticsConvert { | ||
| 25 | 25 | ||
| 26 | TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); | 26 | TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); |
| 27 | 27 | ||
| 28 | - default TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData, | ||
| 29 | - TradeSummaryRespBO beforeYesterdayData, | ||
| 30 | - TradeSummaryRespBO monthData, | ||
| 31 | - TradeSummaryRespBO lastMonthData) { | 28 | + default DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData, |
| 29 | + TradeSummaryRespBO beforeYesterdayData, | ||
| 30 | + TradeSummaryRespBO monthData, | ||
| 31 | + TradeSummaryRespBO lastMonthData) { | ||
| 32 | return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); | 32 | return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -39,10 +39,10 @@ public interface TradeStatisticsConvert { | @@ -39,10 +39,10 @@ public interface TradeStatisticsConvert { | ||
| 39 | .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); | 39 | .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); | 42 | + DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); |
| 43 | 43 | ||
| 44 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, | ||
| 45 | - TradeTrendSummaryRespVO reference); | 44 | + DataComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, |
| 45 | + TradeTrendSummaryRespVO reference); | ||
| 46 | 46 | ||
| 47 | List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list); | 47 | List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list); |
| 48 | 48 | ||
| @@ -50,4 +50,20 @@ public interface TradeStatisticsConvert { | @@ -50,4 +50,20 @@ public interface TradeStatisticsConvert { | ||
| 50 | AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, | 50 | AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, |
| 51 | WalletSummaryRespBO walletSummary); | 51 | WalletSummaryRespBO walletSummary); |
| 52 | 52 | ||
| 53 | + List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list); | ||
| 54 | + | ||
| 55 | + default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { | ||
| 56 | + return new TradeTrendSummaryRespVO() | ||
| 57 | + .setDate(tradeStatistics.getTime().toLocalDate()) | ||
| 58 | + // 营业额 = 商品支付金额 + 充值金额 | ||
| 59 | + .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) | ||
| 60 | + .setOrderPayPrice(tradeStatistics.getOrderPayPrice()) | ||
| 61 | + .setRechargePrice(tradeStatistics.getRechargePayPrice()) | ||
| 62 | + // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | ||
| 63 | + .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) | ||
| 64 | + .setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice()) | ||
| 65 | + .setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice()) | ||
| 66 | + .setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice()); | ||
| 67 | + } | ||
| 68 | + | ||
| 53 | } | 69 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java
| @@ -48,11 +48,6 @@ public class TradeStatisticsDO extends TenantBaseDO { | @@ -48,11 +48,6 @@ public class TradeStatisticsDO extends TenantBaseDO { | ||
| 48 | * 总支付金额,单位:分 | 48 | * 总支付金额,单位:分 |
| 49 | */ | 49 | */ |
| 50 | private Integer orderPayPrice; | 50 | private Integer orderPayPrice; |
| 51 | - // TODO @疯狂:这个字段改成 walletPayPrice,然后挪到 rechargePayCount 前面; | ||
| 52 | - /** | ||
| 53 | - * 总支付金额(余额),单位:分 | ||
| 54 | - */ | ||
| 55 | - private Integer orderWalletPayPrice; | ||
| 56 | 51 | ||
| 57 | /** | 52 | /** |
| 58 | * 退款订单数 | 53 | * 退款订单数 |
| @@ -69,6 +64,10 @@ public class TradeStatisticsDO extends TenantBaseDO { | @@ -69,6 +64,10 @@ public class TradeStatisticsDO extends TenantBaseDO { | ||
| 69 | private Integer brokerageSettlementPrice; | 64 | private Integer brokerageSettlementPrice; |
| 70 | 65 | ||
| 71 | /** | 66 | /** |
| 67 | + * 总支付金额(余额),单位:分 | ||
| 68 | + */ | ||
| 69 | + private Integer orderWalletPayPrice; | ||
| 70 | + /** | ||
| 72 | * 充值订单数 | 71 | * 充值订单数 |
| 73 | * <p> | 72 | * <p> |
| 74 | * 从 PayWalletRechargeDO 计算 | 73 | * 从 PayWalletRechargeDO 计算 |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java
| @@ -13,14 +13,15 @@ import java.time.LocalDateTime; | @@ -13,14 +13,15 @@ import java.time.LocalDateTime; | ||
| 13 | * @author owen | 13 | * @author owen |
| 14 | */ | 14 | */ |
| 15 | @Mapper | 15 | @Mapper |
| 16 | -public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> { | 16 | +@SuppressWarnings("rawtypes") |
| 17 | +public interface ApiAccessLogStatisticsMapper extends BaseMapperX { | ||
| 17 | 18 | ||
| 18 | - // TODO @疯狂:是不是 selectIpCount | ||
| 19 | - Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, | ||
| 20 | - @Param("endTime") LocalDateTime endTime); | 19 | + Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, |
| 20 | + @Param("beginTime") LocalDateTime beginTime, | ||
| 21 | + @Param("endTime") LocalDateTime endTime); | ||
| 21 | 22 | ||
| 22 | - // TODO @疯狂:是不是 selectUserCount | ||
| 23 | - Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, | ||
| 24 | - @Param("endTime") LocalDateTime endTime); | 23 | + Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, |
| 24 | + @Param("beginTime") LocalDateTime beginTime, | ||
| 25 | + @Param("endTime") LocalDateTime endTime); | ||
| 25 | 26 | ||
| 26 | } | 27 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java
| 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.member; | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.member; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; |
| 5 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; | ||
| 7 | +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; | ||
| 6 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 7 | import org.apache.ibatis.annotations.Param; | 9 | import org.apache.ibatis.annotations.Param; |
| 8 | 10 | ||
| @@ -15,16 +17,20 @@ import java.util.List; | @@ -15,16 +17,20 @@ import java.util.List; | ||
| 15 | * @author owen | 17 | * @author owen |
| 16 | */ | 18 | */ |
| 17 | @Mapper | 19 | @Mapper |
| 18 | -public interface MemberStatisticsMapper extends BaseMapperX<Object> { | 20 | +@SuppressWarnings("rawtypes") |
| 21 | +public interface MemberStatisticsMapper extends BaseMapperX { | ||
| 19 | 22 | ||
| 20 | - // TODO @芋艿:已经 review | ||
| 21 | - // TODO @疯狂:要不还是搞下 bo?虽然可能冗余了点~~ | ||
| 22 | - List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); | 23 | + List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId(); |
| 23 | 24 | ||
| 24 | List<MemberSexStatisticsRespVO> selectSummaryListBySex(); | 25 | List<MemberSexStatisticsRespVO> selectSummaryListBySex(); |
| 25 | 26 | ||
| 27 | + List<MemberTerminalStatisticsRespVO> selectSummaryListByRegisterTerminal(); | ||
| 28 | + | ||
| 26 | // TODO @芋艿:已经 review | 29 | // TODO @芋艿:已经 review |
| 27 | Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, | 30 | Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, |
| 28 | @Param("endTime") LocalDateTime endTime); | 31 | @Param("endTime") LocalDateTime endTime); |
| 29 | 32 | ||
| 33 | + List<MemberRegisterCountRespVO> selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 34 | + @Param("endTime") LocalDateTime endTime); | ||
| 35 | + | ||
| 30 | } | 36 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java
| 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.pay; | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.pay; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | ||
| 5 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; | 4 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| 6 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 7 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| @@ -15,7 +14,8 @@ import java.time.LocalDateTime; | @@ -15,7 +14,8 @@ import java.time.LocalDateTime; | ||
| 15 | * @author owen | 14 | * @author owen |
| 16 | */ | 15 | */ |
| 17 | @Mapper | 16 | @Mapper |
| 18 | -public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | 17 | +@SuppressWarnings("rawtypes") |
| 18 | +public interface PayWalletStatisticsMapper extends BaseMapperX { | ||
| 19 | 19 | ||
| 20 | // TODO 芋艿:已经 review; | 20 | // TODO 芋艿:已经 review; |
| 21 | WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 21 | WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| @@ -37,4 +37,6 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO | @@ -37,4 +37,6 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO | ||
| 37 | @Param("endTime") LocalDateTime endTime, | 37 | @Param("endTime") LocalDateTime endTime, |
| 38 | @Param("payStatus") Boolean payStatus); | 38 | @Param("payStatus") Boolean payStatus); |
| 39 | 39 | ||
| 40 | + Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); | ||
| 41 | + | ||
| 40 | } | 42 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java
| @@ -20,4 +20,6 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO | @@ -20,4 +20,6 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO | ||
| 20 | AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 20 | AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 21 | @Param("endTime") LocalDateTime endTime); | 21 | @Param("endTime") LocalDateTime endTime); |
| 22 | 22 | ||
| 23 | + Long selectCountByStatus(@Param("status") Integer status); | ||
| 24 | + | ||
| 23 | } | 25 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java
| @@ -20,4 +20,6 @@ public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO | @@ -20,4 +20,6 @@ public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO | ||
| 20 | @Param("beginTime") LocalDateTime beginTime, | 20 | @Param("beginTime") LocalDateTime beginTime, |
| 21 | @Param("endTime") LocalDateTime endTime); | 21 | @Param("endTime") LocalDateTime endTime); |
| 22 | 22 | ||
| 23 | + Long selectWithdrawCountByStatus(@Param("status") Integer status); | ||
| 24 | + | ||
| 23 | } | 25 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java
| @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; | ||
| 5 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 7 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 7 | import org.apache.ibatis.annotations.Param; | 9 | import org.apache.ibatis.annotations.Param; |
| @@ -40,4 +42,32 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD | @@ -40,4 +42,32 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD | ||
| 40 | Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 42 | Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 41 | @Param("endTime") LocalDateTime endTime); | 43 | @Param("endTime") LocalDateTime endTime); |
| 42 | 44 | ||
| 45 | + /** | ||
| 46 | + * 按照支付时间统计订单(按天分组) | ||
| 47 | + * | ||
| 48 | + * @param beginTime 支付起始时间 | ||
| 49 | + * @param endTime 支付截止时间 | ||
| 50 | + * @return 订单统计列表 | ||
| 51 | + */ | ||
| 52 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, | ||
| 53 | + @Param("endTime") LocalDateTime endTime); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 按照支付时间统计订单(按月分组) | ||
| 57 | + * | ||
| 58 | + * @param beginTime 支付起始时间 | ||
| 59 | + * @param endTime 支付截止时间 | ||
| 60 | + * @return 订单统计列表 | ||
| 61 | + */ | ||
| 62 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, | ||
| 63 | + @Param("endTime") LocalDateTime endTime); | ||
| 64 | + | ||
| 65 | + Long selectCountByStatus(@Param("status") Integer status); | ||
| 66 | + | ||
| 67 | + Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status); | ||
| 68 | + | ||
| 69 | + TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status, | ||
| 70 | + @Param("beginTime") LocalDateTime beginTime, | ||
| 71 | + @Param("endTime") LocalDateTime endTime); | ||
| 72 | + | ||
| 43 | } | 73 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java
| 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.trade; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 5 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 6 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 6 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | 7 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| @@ -21,14 +22,20 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | @@ -21,14 +22,20 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | ||
| 21 | TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 22 | TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 22 | @Param("endTime") LocalDateTime endTime); | 23 | @Param("endTime") LocalDateTime endTime); |
| 23 | 24 | ||
| 24 | - TradeTrendSummaryRespVO selectByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 25 | - @Param("endTime") LocalDateTime endTime); | 25 | + TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 26 | + @Param("endTime") LocalDateTime endTime); | ||
| 26 | 27 | ||
| 27 | - // TODO @芋艿:已经 review | ||
| 28 | - List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 29 | - @Param("endTime") LocalDateTime endTime); | 28 | + default List<TradeStatisticsDO> selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { |
| 29 | + return selectList(new LambdaQueryWrapperX<TradeStatisticsDO>() | ||
| 30 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | ||
| 31 | + } | ||
| 30 | 32 | ||
| 31 | Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 33 | Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 32 | @Param("endTime") LocalDateTime endTime); | 34 | @Param("endTime") LocalDateTime endTime); |
| 33 | 35 | ||
| 36 | + default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 37 | + return selectOne(new LambdaQueryWrapperX<TradeStatisticsDO>() | ||
| 38 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | ||
| 39 | + } | ||
| 40 | + | ||
| 34 | } | 41 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java
| 1 | package cn.iocoder.yudao.module.statistics.job.trade; | 1 | package cn.iocoder.yudao.module.statistics.job.trade; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.convert.Convert; | ||
| 4 | +import cn.hutool.core.util.NumberUtil; | ||
| 3 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; | 6 | import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
| 5 | import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; | 7 | import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; |
| @@ -19,11 +21,24 @@ public class TradeStatisticsJob implements JobHandler { | @@ -19,11 +21,24 @@ public class TradeStatisticsJob implements JobHandler { | ||
| 19 | @Resource | 21 | @Resource |
| 20 | private TradeStatisticsService tradeStatisticsService; | 22 | private TradeStatisticsService tradeStatisticsService; |
| 21 | 23 | ||
| 24 | + /** | ||
| 25 | + * 执行交易统计任务 | ||
| 26 | + * | ||
| 27 | + * @param param 要统计的天数,只能是正整数,1 代表昨日数据 | ||
| 28 | + * @return 统计结果 | ||
| 29 | + */ | ||
| 22 | @Override | 30 | @Override |
| 23 | @TenantJob | 31 | @TenantJob |
| 24 | public String execute(String param) { | 32 | public String execute(String param) { |
| 25 | - String times = tradeStatisticsService.statisticsYesterdayTrade(); | ||
| 26 | - return StrUtil.format("交易统计耗时: {}", times); | 33 | + if (NumberUtil.isInteger(param)) { |
| 34 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | ||
| 35 | + } | ||
| 36 | + Integer days = Convert.toInt(param, 0); | ||
| 37 | + if (days < 1) { | ||
| 38 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | ||
| 39 | + } | ||
| 40 | + String result = tradeStatisticsService.statisticsTrade(days); | ||
| 41 | + return StrUtil.format("交易统计:\n{}", result); | ||
| 27 | } | 42 | } |
| 28 | 43 | ||
| 29 | } | 44 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java
| @@ -9,26 +9,24 @@ import java.time.LocalDateTime; | @@ -9,26 +9,24 @@ import java.time.LocalDateTime; | ||
| 9 | */ | 9 | */ |
| 10 | public interface ApiAccessLogStatisticsService { | 10 | public interface ApiAccessLogStatisticsService { |
| 11 | 11 | ||
| 12 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | ||
| 13 | - // TODO @疯狂:方法名,要不改成 getUserCount;原因:让它更业务无关 | ||
| 14 | /** | 12 | /** |
| 15 | * 获取活跃用户数量 | 13 | * 获取活跃用户数量 |
| 16 | * | 14 | * |
| 15 | + * @param userType 用户类型 | ||
| 17 | * @param beginTime 起始时间 | 16 | * @param beginTime 起始时间 |
| 18 | * @param endTime 截止时间 | 17 | * @param endTime 截止时间 |
| 19 | * @return 活跃用户数量 | 18 | * @return 活跃用户数量 |
| 20 | */ | 19 | */ |
| 21 | - Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime); | 20 | + Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); |
| 22 | 21 | ||
| 23 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | ||
| 24 | - // TODO @疯狂:方法名,要不改成 getIpCount;原因:让它更业务无关 | ||
| 25 | /** | 22 | /** |
| 26 | * 获取访问用户数量 | 23 | * 获取访问用户数量 |
| 27 | * | 24 | * |
| 25 | + * @param userType 用户类型 | ||
| 28 | * @param beginTime 起始时间 | 26 | * @param beginTime 起始时间 |
| 29 | * @param endTime 截止时间 | 27 | * @param endTime 截止时间 |
| 30 | * @return 访问用户数量 | 28 | * @return 访问用户数量 |
| 31 | */ | 29 | */ |
| 32 | - Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime); | 30 | + Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); |
| 33 | 31 | ||
| 34 | } | 32 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java
| @@ -20,13 +20,13 @@ public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatistics | @@ -20,13 +20,13 @@ public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatistics | ||
| 20 | private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; | 20 | private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; |
| 21 | 21 | ||
| 22 | @Override | 22 | @Override |
| 23 | - public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 24 | - return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime); | 23 | + public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { |
| 24 | + return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); | ||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | @Override | 27 | @Override |
| 28 | - public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 29 | - return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime); | 28 | + public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { |
| 29 | + return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | } | 32 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java
| 1 | package cn.iocoder.yudao.module.statistics.service.member; | 1 | package cn.iocoder.yudao.module.statistics.service.member; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; | ||
| 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; | 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; |
| 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; | ||
| 7 | 5 | ||
| 8 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 9 | import java.util.List; | 7 | import java.util.List; |
| @@ -23,15 +21,15 @@ public interface MemberStatisticsService { | @@ -23,15 +21,15 @@ public interface MemberStatisticsService { | ||
| 23 | */ | 21 | */ |
| 24 | MemberSummaryRespVO getMemberSummary(); | 22 | MemberSummaryRespVO getMemberSummary(); |
| 25 | 23 | ||
| 26 | - // TODO 芋艿:已经 review | ||
| 27 | /** | 24 | /** |
| 28 | - * 获取用户分析数据 | 25 | + * 获取会员分析对照数据 |
| 29 | * | 26 | * |
| 30 | * @param beginTime 起始时间 | 27 | * @param beginTime 起始时间 |
| 31 | * @param endTime 截止时间 | 28 | * @param endTime 截止时间 |
| 32 | - * @return 用户分析数据 | 29 | + * @return 会员分析对照数据 |
| 33 | */ | 30 | */ |
| 34 | - MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); | 31 | + DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, |
| 32 | + LocalDateTime endTime); | ||
| 35 | 33 | ||
| 36 | /** | 34 | /** |
| 37 | * 按照省份,获得会员统计列表 | 35 | * 按照省份,获得会员统计列表 |
| @@ -47,4 +45,27 @@ public interface MemberStatisticsService { | @@ -47,4 +45,27 @@ public interface MemberStatisticsService { | ||
| 47 | */ | 45 | */ |
| 48 | List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); | 46 | List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); |
| 49 | 47 | ||
| 48 | + /** | ||
| 49 | + * 按照终端,获得会员统计列表 | ||
| 50 | + * | ||
| 51 | + * @return 会员统计列表 | ||
| 52 | + */ | ||
| 53 | + List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList(); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 获取用户注册数量列表 | ||
| 57 | + * | ||
| 58 | + * @param beginTime 起始时间 | ||
| 59 | + * @param endTime 截止时间 | ||
| 60 | + * @return 注册数量列表 | ||
| 61 | + */ | ||
| 62 | + List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获得用户数量量统计对照 | ||
| 66 | + * | ||
| 67 | + * @return 用户数量量统计对照 | ||
| 68 | + */ | ||
| 69 | + DataComparisonRespVO<MemberCountRespVO> getUserCountComparison(); | ||
| 70 | + | ||
| 50 | } | 71 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java
| 1 | package cn.iocoder.yudao.module.statistics.service.member; | 1 | package cn.iocoder.yudao.module.statistics.service.member; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.NumberUtil; | 3 | +import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 5 | +import cn.iocoder.yudao.framework.ip.core.Area; | ||
| 4 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; | 6 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 5 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | 7 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 8 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 6 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; | 9 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; |
| 7 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | 10 | +import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; |
| 8 | import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; | 11 | import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; |
| 9 | import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; | 12 | import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; |
| 13 | +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; | ||
| 10 | import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | 14 | import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; |
| 11 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; | 15 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| 12 | import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | 16 | import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; |
| 13 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; | 17 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; |
| 14 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 15 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 16 | -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | ||
| 17 | 20 | ||
| 18 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| 19 | import java.time.Duration; | 22 | import java.time.Duration; |
| @@ -57,63 +60,77 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | @@ -57,63 +60,77 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | ||
| 57 | @Override | 60 | @Override |
| 58 | public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { | 61 | public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { |
| 59 | // 统计用户 | 62 | // 统计用户 |
| 60 | - // TODO @疯狂:要处理下,未知省份;就是没填写省份的情况; | ||
| 61 | // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = | 63 | // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = |
| 62 | Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), | 64 | Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), |
| 63 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), | 65 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), |
| 64 | - MemberAreaStatisticsRespVO::getUserCount, Integer::sum); | 66 | + MemberAreaStatisticsRespBO::getUserCount, Integer::sum); |
| 65 | // 统计订单 | 67 | // 统计订单 |
| 66 | Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), | 68 | Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), |
| 67 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), | 69 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), |
| 68 | vo -> vo, | 70 | vo -> vo, |
| 69 | (a, b) -> new MemberAreaStatisticsRespVO() | 71 | (a, b) -> new MemberAreaStatisticsRespVO() |
| 70 | - .setOrderCreateCount(a.getOrderCreateCount() + b.getOrderCreateCount()) | ||
| 71 | - .setOrderPayCount(a.getOrderPayCount() + b.getOrderPayCount()) | 72 | + .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) |
| 73 | + .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) | ||
| 72 | .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); | 74 | .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); |
| 73 | // 拼接数据 | 75 | // 拼接数据 |
| 74 | - return MemberStatisticsConvert.INSTANCE.convertList(AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area), userCountMap, orderMap); | 76 | + List<Area> areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); |
| 77 | + areaList.add(new Area().setId(null).setName("未知")); | ||
| 78 | + return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap); | ||
| 75 | } | 79 | } |
| 76 | 80 | ||
| 77 | - // TODO @疯狂:这个方法,要不拆成:1)controller 调用 getMemberAnalyseComparisonData;2)tradeOrderStatisticsService.getPayUserCount;3)tradeOrderStatisticsService.getOrderPayPrice;4)。。。 | ||
| 78 | - // TODO 就是说:分析交给 controller 去组合; | ||
| 79 | @Override | 81 | @Override |
| 80 | - public MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime) { | 82 | + public DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { |
| 83 | + // 当前数据 | ||
| 84 | + MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime); | ||
| 81 | // 对照数据 | 85 | // 对照数据 |
| 82 | - MemberAnalyseComparisonRespVO vo = getMemberAnalyseComparisonData(beginTime, endTime); | ||
| 83 | - // TODO @疯狂:如果时间段这么处理,会不会 beginTime 重叠了。因为是 <= 一个时间;如果数据库插入的是 ,xxxx-yy-zz 00:00:00 的话,它既满足 >= ? 也满足 <= ;(如果不好理解,微信聊) | ||
| 84 | - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); | ||
| 85 | - MemberAnalyseComparisonRespVO reference = getMemberAnalyseComparisonData(referenceBeginTime, beginTime); | ||
| 86 | - | ||
| 87 | - // 计算客单价 | ||
| 88 | - // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; | ||
| 89 | - Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); | ||
| 90 | - int atv = 0; | ||
| 91 | - if (payUserCount != null && payUserCount > 0) { | ||
| 92 | - // TODO @疯狂:类似上面的 payUserCount | ||
| 93 | - Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); | ||
| 94 | - atv = NumberUtil.div(payPrice, payUserCount).intValue(); | ||
| 95 | - } | ||
| 96 | - return new MemberAnalyseRespVO() | ||
| 97 | - .setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(beginTime, endTime)) | ||
| 98 | - .setOrderUserCount(tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime)) | ||
| 99 | - .setPayUserCount(payUserCount) | ||
| 100 | - .setAtv(atv) | ||
| 101 | - .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); | 86 | + LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠 |
| 87 | + LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime)); | ||
| 88 | + MemberAnalyseDataRespVO reference = getMemberAnalyseData( | ||
| 89 | + LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate)); | ||
| 90 | + return new DataComparisonRespVO<>(vo, reference); | ||
| 102 | } | 91 | } |
| 103 | 92 | ||
| 104 | - private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { | 93 | + private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) { |
| 105 | Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) | 94 | Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) |
| 106 | .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); | 95 | .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); |
| 107 | - return new MemberAnalyseComparisonRespVO() | ||
| 108 | - .setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | ||
| 109 | - .setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime)) | 96 | + return new MemberAnalyseDataRespVO() |
| 97 | + .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | ||
| 98 | + .setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)) | ||
| 110 | .setRechargeUserCount(rechargeUserCount); | 99 | .setRechargeUserCount(rechargeUserCount); |
| 111 | } | 100 | } |
| 112 | 101 | ||
| 113 | @Override | 102 | @Override |
| 114 | public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() { | 103 | public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() { |
| 115 | - // TODO @疯狂:需要考虑,用户性别为空,则是“未知” | ||
| 116 | return memberStatisticsMapper.selectSummaryListBySex(); | 104 | return memberStatisticsMapper.selectSummaryListBySex(); |
| 117 | } | 105 | } |
| 118 | 106 | ||
| 107 | + @Override | ||
| 108 | + public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() { | ||
| 109 | + return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @Override | ||
| 113 | + public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 114 | + return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @Override | ||
| 118 | + public DataComparisonRespVO<MemberCountRespVO> getUserCountComparison() { | ||
| 119 | + // 今日时间范围 | ||
| 120 | + LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); | ||
| 121 | + LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday); | ||
| 122 | + // 昨日时间范围 | ||
| 123 | + LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1)); | ||
| 124 | + LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday); | ||
| 125 | + return new DataComparisonRespVO<MemberCountRespVO>() | ||
| 126 | + .setValue(getUserCount(beginOfToday, endOfToday)) | ||
| 127 | + .setReference(getUserCount(beginOfYesterday, endOfYesterday)); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 131 | + return new MemberCountRespVO() | ||
| 132 | + .setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | ||
| 133 | + .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); | ||
| 134 | + } | ||
| 135 | + | ||
| 119 | } | 136 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.member.bo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Schema(description = "管理后台 - 会员地区统计 Response BO") | ||
| 7 | +@Data | ||
| 8 | +public class MemberAreaStatisticsRespBO { | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 省份编号 | ||
| 12 | + */ | ||
| 13 | + private Integer areaId; | ||
| 14 | + /** | ||
| 15 | + * 省份名称 | ||
| 16 | + */ | ||
| 17 | + private String areaName; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 会员数量 | ||
| 21 | + */ | ||
| 22 | + private Integer userCount; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 下单的会员数量 | ||
| 26 | + */ | ||
| 27 | + private Integer orderCreateUserCount; | ||
| 28 | + /** | ||
| 29 | + * 支付订单的会员数量 | ||
| 30 | + */ | ||
| 31 | + private Integer orderPayUserCount; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 订单支付金额,单位:分 | ||
| 35 | + */ | ||
| 36 | + private Integer orderPayPrice; | ||
| 37 | + | ||
| 38 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java
| @@ -32,4 +32,11 @@ public interface PayWalletStatisticsService { | @@ -32,4 +32,11 @@ public interface PayWalletStatisticsService { | ||
| 32 | */ | 32 | */ |
| 33 | RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); | 33 | RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 34 | 34 | ||
| 35 | + /** | ||
| 36 | + * 获取充值金额合计 | ||
| 37 | + * | ||
| 38 | + * @return 充值金额合计 | ||
| 39 | + */ | ||
| 40 | + Integer getRechargePriceSummary(); | ||
| 41 | + | ||
| 35 | } | 42 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java
| 1 | package cn.iocoder.yudao.module.statistics.service.pay; | 1 | package cn.iocoder.yudao.module.statistics.service.pay; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | 3 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 4 | +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; | ||
| 4 | import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; | 5 | import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; |
| 5 | import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; | 6 | import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; |
| 6 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; | 7 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| @@ -43,4 +44,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic | @@ -43,4 +44,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic | ||
| 43 | return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); | 44 | return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 47 | + @Override | ||
| 48 | + public Integer getRechargePriceSummary() { | ||
| 49 | + return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus()); | ||
| 50 | + } | ||
| 51 | + | ||
| 46 | } | 52 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java
| @@ -3,15 +3,21 @@ package cn.iocoder.yudao.module.statistics.service.pay.bo; | @@ -3,15 +3,21 @@ package cn.iocoder.yudao.module.statistics.service.pay.bo; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | -// TODO @疯狂:BO 不用写 swagger 注解哈,写注释就好啦; | ||
| 7 | -@Schema(description = "管理后台 - 充值统计 Response VO") | 6 | +/** |
| 7 | + * 充值统计 Response BO | ||
| 8 | + */ | ||
| 9 | +@Schema(description = "管理后台 - ") | ||
| 8 | @Data | 10 | @Data |
| 9 | public class RechargeSummaryRespBO { | 11 | public class RechargeSummaryRespBO { |
| 10 | 12 | ||
| 11 | - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | 13 | + /** |
| 14 | + * 充值会员数量 | ||
| 15 | + */ | ||
| 12 | private Integer rechargeUserCount; | 16 | private Integer rechargeUserCount; |
| 13 | 17 | ||
| 14 | - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 18 | + /** |
| 19 | + * 充值金额 | ||
| 20 | + */ | ||
| 15 | private Integer rechargePrice; | 21 | private Integer rechargePrice; |
| 16 | 22 | ||
| 17 | } | 23 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | 3 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 4 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | ||
| 4 | 5 | ||
| 5 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 6 | 7 | ||
| @@ -21,4 +22,12 @@ public interface AfterSaleStatisticsService { | @@ -21,4 +22,12 @@ public interface AfterSaleStatisticsService { | ||
| 21 | */ | 22 | */ |
| 22 | AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | 23 | AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 23 | 24 | ||
| 25 | + /** | ||
| 26 | + * 获取指定状态的售后订单数量 | ||
| 27 | + * | ||
| 28 | + * @param status 售后状态 | ||
| 29 | + * @return 售后订单数量 | ||
| 30 | + */ | ||
| 31 | + Long getCountByStatus(AfterSaleStatusEnum status); | ||
| 32 | + | ||
| 24 | } | 33 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; | 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; |
| 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 5 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | ||
| 5 | import org.springframework.stereotype.Service; | 6 | import org.springframework.stereotype.Service; |
| 6 | import org.springframework.validation.annotation.Validated; | 7 | import org.springframework.validation.annotation.Validated; |
| 7 | 8 | ||
| @@ -25,4 +26,9 @@ public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsServic | @@ -25,4 +26,9 @@ public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsServic | ||
| 25 | return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); | 26 | return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 29 | + @Override | ||
| 30 | + public Long getCountByStatus(AfterSaleStatusEnum status) { | ||
| 31 | + return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus()); | ||
| 32 | + } | ||
| 33 | + | ||
| 28 | } | 34 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | ||
| 4 | + | ||
| 3 | import java.time.LocalDateTime; | 5 | import java.time.LocalDateTime; |
| 4 | 6 | ||
| 5 | /** | 7 | /** |
| @@ -19,4 +21,12 @@ public interface BrokerageStatisticsService { | @@ -19,4 +21,12 @@ public interface BrokerageStatisticsService { | ||
| 19 | */ | 21 | */ |
| 20 | Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | 22 | Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 21 | 23 | ||
| 24 | + /** | ||
| 25 | + * 获取指定状态的提现记录数量 | ||
| 26 | + * | ||
| 27 | + * @param status 提现记录状态 | ||
| 28 | + * @return 提现记录数量 | ||
| 29 | + */ | ||
| 30 | + Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); | ||
| 31 | + | ||
| 22 | } | 32 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; | ||
| 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; | 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; |
| 4 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; | 4 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 5 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; | 5 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | ||
| 6 | import org.springframework.stereotype.Service; | 7 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.validation.annotation.Validated; | 8 | import org.springframework.validation.annotation.Validated; |
| 8 | 9 | ||
| @@ -28,4 +29,9 @@ public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsServic | @@ -28,4 +29,9 @@ public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsServic | ||
| 28 | beginTime, endTime); | 29 | beginTime, endTime); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 32 | + @Override | ||
| 33 | + public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) { | ||
| 34 | + return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus()); | ||
| 35 | + } | ||
| 36 | + | ||
| 31 | } | 37 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 3 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; | ||
| 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 6 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 5 | 7 | ||
| 6 | import java.time.LocalDateTime; | 8 | import java.time.LocalDateTime; |
| @@ -60,4 +62,26 @@ public interface TradeOrderStatisticsService { | @@ -60,4 +62,26 @@ public interface TradeOrderStatisticsService { | ||
| 60 | */ | 62 | */ |
| 61 | Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); | 63 | Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); |
| 62 | 64 | ||
| 65 | + /** | ||
| 66 | + * 获得交易订单数量 | ||
| 67 | + * | ||
| 68 | + * @return 订单数量 | ||
| 69 | + */ | ||
| 70 | + TradeOrderCountRespVO getOrderCount(); | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 交易订单销售额对照 | ||
| 74 | + * | ||
| 75 | + * @return 销售额对照 | ||
| 76 | + */ | ||
| 77 | + DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison(); | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 获得订单量趋势统计 | ||
| 81 | + * | ||
| 82 | + * @param reqVO 统计参数 | ||
| 83 | + * @return 订单量趋势统计 | ||
| 84 | + */ | ||
| 85 | + List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); | ||
| 86 | + | ||
| 63 | } | 87 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.date.LocalDateTimeUtil; | ||
| 5 | +import cn.hutool.core.util.ObjUtil; | ||
| 6 | +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; | ||
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | ||
| 3 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 9 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; | ||
| 4 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; | 10 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; |
| 11 | +import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; | ||
| 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 12 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 13 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; | ||
| 6 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
| 8 | 16 | ||
| 9 | import javax.annotation.Resource; | 17 | import javax.annotation.Resource; |
| 18 | +import java.time.Duration; | ||
| 10 | import java.time.LocalDateTime; | 19 | import java.time.LocalDateTime; |
| 11 | import java.util.List; | 20 | import java.util.List; |
| 21 | +import java.util.stream.Collectors; | ||
| 22 | +import java.util.stream.IntStream; | ||
| 12 | 23 | ||
| 13 | /** | 24 | /** |
| 14 | * 交易订单统计 Service 实现类 | 25 | * 交易订单统计 Service 实现类 |
| @@ -50,4 +61,53 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ | @@ -50,4 +61,53 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ | ||
| 50 | return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); | 61 | return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); |
| 51 | } | 62 | } |
| 52 | 63 | ||
| 64 | + @Override | ||
| 65 | + public TradeOrderCountRespVO getOrderCount() { | ||
| 66 | + Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); | ||
| 67 | + Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus()); | ||
| 68 | + | ||
| 69 | + return new TradeOrderCountRespVO() | ||
| 70 | + .setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L)) | ||
| 71 | + .setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison() { | ||
| 76 | + return new DataComparisonRespVO<TradeOrderSummaryRespVO>() | ||
| 77 | + .setValue(getPayPriceSummary(LocalDateTime.now())) | ||
| 78 | + .setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1))); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) { | ||
| 82 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); | ||
| 83 | + LocalDateTime endTime = LocalDateTimeUtil.beginOfDay(date); | ||
| 84 | + | ||
| 85 | + return tradeOrderStatisticsMapper.selectPaySummaryByStatusAndPayTimeBetween(PayOrderStatusEnum.SUCCESS.getStatus(), beginTime, endTime); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { | ||
| 90 | + // 查询当前数据 | ||
| 91 | + List<TradeOrderTrendRespVO> value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime()); | ||
| 92 | + // 查询对照数据 | ||
| 93 | + LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1); | ||
| 94 | + LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime())); | ||
| 95 | + List<TradeOrderTrendRespVO> reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); | ||
| 96 | + | ||
| 97 | + return IntStream.range(0, value.size()) | ||
| 98 | + .mapToObj(index -> new DataComparisonRespVO<TradeOrderTrendRespVO>() | ||
| 99 | + .setValue(CollUtil.get(value, index)) | ||
| 100 | + .setReference(CollUtil.get(reference, index))) | ||
| 101 | + .collect(Collectors.toList()); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + private List<TradeOrderTrendRespVO> getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 105 | + // 情况一:按年统计时,以月份分组 | ||
| 106 | + if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { | ||
| 107 | + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); | ||
| 108 | + } | ||
| 109 | + // 情况二:其它以天分组(天、周、月) | ||
| 110 | + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); | ||
| 111 | + } | ||
| 112 | + | ||
| 53 | } | 113 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | ||
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; |
| 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | ||
| 6 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | ||
| 6 | 7 | ||
| 7 | import java.time.LocalDateTime; | 8 | import java.time.LocalDateTime; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| @@ -15,25 +16,18 @@ import java.util.List; | @@ -15,25 +16,18 @@ import java.util.List; | ||
| 15 | public interface TradeStatisticsService { | 16 | public interface TradeStatisticsService { |
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | - * 获得交易统计 | ||
| 19 | - * | ||
| 20 | - * @return 统计数据对照 | ||
| 21 | - */ | ||
| 22 | - TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison(); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | * 获得交易状况统计对照 | 19 | * 获得交易状况统计对照 |
| 26 | * | 20 | * |
| 27 | * @return 统计数据对照 | 21 | * @return 统计数据对照 |
| 28 | */ | 22 | */ |
| 29 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison( | 23 | + DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison( |
| 30 | LocalDateTime beginTime, LocalDateTime endTime); | 24 | LocalDateTime beginTime, LocalDateTime endTime); |
| 31 | 25 | ||
| 32 | /** | 26 | /** |
| 33 | * 获得交易状况统计 | 27 | * 获得交易状况统计 |
| 34 | * | 28 | * |
| 35 | * @param beginTime 开始时间 | 29 | * @param beginTime 开始时间 |
| 36 | - * @param endTime 结束时间 | 30 | + * @param endTime 结束时间 |
| 37 | * @return 统计数据对照 | 31 | * @return 统计数据对照 |
| 38 | */ | 32 | */ |
| 39 | Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); | 33 | Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); |
| @@ -41,16 +35,34 @@ public interface TradeStatisticsService { | @@ -41,16 +35,34 @@ public interface TradeStatisticsService { | ||
| 41 | /** | 35 | /** |
| 42 | * 获得交易状况明细 | 36 | * 获得交易状况明细 |
| 43 | * | 37 | * |
| 38 | + * @param beginTime 开始时间 | ||
| 39 | + * @param endTime 结束时间 | ||
| 44 | * @return 统计数据列表 | 40 | * @return 统计数据列表 |
| 45 | */ | 41 | */ |
| 46 | - List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); | 42 | + List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); |
| 47 | 43 | ||
| 48 | // TODO 芋艿:已经 review; | 44 | // TODO 芋艿:已经 review; |
| 49 | /** | 45 | /** |
| 50 | - * 统计昨日交易 | 46 | + * 统计指定天数的交易数据 |
| 47 | + * | ||
| 48 | + * @return 统计结果 | ||
| 49 | + */ | ||
| 50 | + String statisticsTrade(Integer days); | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 统计指定日期的交易数据 | ||
| 54 | + * | ||
| 55 | + * @param days 增加的天数 | ||
| 56 | + * @return 交易数据 | ||
| 57 | + */ | ||
| 58 | + TradeSummaryRespBO getTradeSummaryByDays(int days); | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 统计指定月份的交易数据 | ||
| 51 | * | 62 | * |
| 52 | - * @return 耗时 | 63 | + * @param months 增加的月数 |
| 64 | + * @return 交易数据 | ||
| 53 | */ | 65 | */ |
| 54 | - String statisticsYesterdayTrade(); | 66 | + TradeSummaryRespBO getTradeSummaryByMonths(int months); |
| 55 | 67 | ||
| 56 | } | 68 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| 1 | package cn.iocoder.yudao.module.statistics.service.trade; | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.date.DatePattern; | ||
| 3 | import cn.hutool.core.date.LocalDateTimeUtil; | 4 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | 5 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | ||
| 6 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | ||
| 7 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | ||
| 8 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; |
| 9 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 10 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; | 8 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 11 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 9 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 12 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; | 10 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; |
| 13 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | 11 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; |
| 14 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | 12 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 15 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 13 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 14 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | ||
| 15 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | ||
| 16 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 17 | import org.springframework.util.StopWatch; | 17 | import org.springframework.util.StopWatch; |
| 18 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| @@ -21,6 +21,8 @@ import javax.annotation.Resource; | @@ -21,6 +21,8 @@ import javax.annotation.Resource; | ||
| 21 | import java.time.Duration; | 21 | import java.time.Duration; |
| 22 | import java.time.LocalDateTime; | 22 | import java.time.LocalDateTime; |
| 23 | import java.util.List; | 23 | import java.util.List; |
| 24 | +import java.util.stream.Collectors; | ||
| 25 | +import java.util.stream.IntStream; | ||
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | * 交易统计 Service 实现类 | 28 | * 交易统计 Service 实现类 |
| @@ -44,51 +46,27 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | @@ -44,51 +46,27 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | ||
| 44 | private PayWalletStatisticsService payWalletStatisticsService; | 46 | private PayWalletStatisticsService payWalletStatisticsService; |
| 45 | 47 | ||
| 46 | @Override | 48 | @Override |
| 47 | - public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { | ||
| 48 | - // 1.1 昨天的数据 | ||
| 49 | - TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1); | ||
| 50 | - // 1.2 前天的数据(用于对照昨天的数据) | ||
| 51 | - TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2); | ||
| 52 | - // 2.1 本月数据 | ||
| 53 | - TradeSummaryRespBO monthData = getTradeSummaryByMonths(0); | ||
| 54 | - // 2.2 上月数据(用于对照本月的数据) | ||
| 55 | - TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1); | ||
| 56 | - // 转换返回 | ||
| 57 | - return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * 统计指定日期的交易数据 | ||
| 62 | - * | ||
| 63 | - * @param days 增加的天数 | ||
| 64 | - * @return 交易数据 | ||
| 65 | - */ | ||
| 66 | - private TradeSummaryRespBO getTradeSummaryByDays(int days) { | 49 | + public TradeSummaryRespBO getTradeSummaryByDays(int days) { |
| 67 | LocalDateTime date = LocalDateTime.now().plusDays(days); | 50 | LocalDateTime date = LocalDateTime.now().plusDays(days); |
| 68 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( | 51 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( |
| 69 | LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); | 52 | LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); |
| 70 | } | 53 | } |
| 71 | 54 | ||
| 72 | - /** | ||
| 73 | - * 统计指定月份的交易数据 | ||
| 74 | - * | ||
| 75 | - * @param months 增加的月数 | ||
| 76 | - * @return 交易数据 | ||
| 77 | - */ | ||
| 78 | - private TradeSummaryRespBO getTradeSummaryByMonths(int months) { | 55 | + @Override |
| 56 | + public TradeSummaryRespBO getTradeSummaryByMonths(int months) { | ||
| 79 | LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); | 57 | LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); |
| 80 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( | 58 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( |
| 81 | LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); | 59 | LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); |
| 82 | } | 60 | } |
| 83 | 61 | ||
| 84 | @Override | 62 | @Override |
| 85 | - public TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime, | ||
| 86 | - LocalDateTime endTime) { | 63 | + public DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime, |
| 64 | + LocalDateTime endTime) { | ||
| 87 | // 统计数据 | 65 | // 统计数据 |
| 88 | - TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); | 66 | + TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime); |
| 89 | // 对照数据 | 67 | // 对照数据 |
| 90 | LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); | 68 | LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); |
| 91 | - TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectByTimeBetween(referenceBeginTime, beginTime); | 69 | + TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime); |
| 92 | return TradeStatisticsConvert.INSTANCE.convert(value, reference); | 70 | return TradeStatisticsConvert.INSTANCE.convert(value, reference); |
| 93 | } | 71 | } |
| 94 | 72 | ||
| @@ -97,41 +75,60 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | @@ -97,41 +75,60 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | ||
| 97 | return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); | 75 | return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); |
| 98 | } | 76 | } |
| 99 | 77 | ||
| 100 | - // TODO @疯狂:是不是直接返回 TradeStatisticsDO;上层在去聚合? | ||
| 101 | @Override | 78 | @Override |
| 102 | - public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { | 79 | + public List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { |
| 103 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); | 80 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); |
| 104 | } | 81 | } |
| 105 | 82 | ||
| 106 | @Override | 83 | @Override |
| 107 | - public String statisticsYesterdayTrade() { | ||
| 108 | - // TODO @疯狂:如果已经统计,则跳过; | ||
| 109 | - // TODO @疯狂:改成 statisticsTrade,然后传入 days,统计多少天;days 通过 job 传参;方便把历史给统计出来;或者大家有的时候要修复数据(会 fix 业务数据,然后清理统计表),重新统计的时候; | ||
| 110 | - // 1. 从各个数据表,统计对应数据 | ||
| 111 | - LocalDateTime yesterday = LocalDateTime.now().minusDays(1); | ||
| 112 | - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); | ||
| 113 | - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); | ||
| 114 | - // 1.1 统计订单 | ||
| 115 | - StopWatch stopWatch = new StopWatch("交易统计"); | 84 | + public String statisticsTrade(Integer days) { |
| 85 | + LocalDateTime today = LocalDateTime.now(); | ||
| 86 | + return IntStream.rangeClosed(1, days) | ||
| 87 | + .parallel() | ||
| 88 | + .mapToObj(day -> statisticsTrade(today.minusDays(day))) | ||
| 89 | + .sorted() | ||
| 90 | + .collect(Collectors.joining("\n")); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 统计交易数据 | ||
| 95 | + * | ||
| 96 | + * @param date 需要统计的日期 | ||
| 97 | + * @return 统计结果 | ||
| 98 | + */ | ||
| 99 | + private String statisticsTrade(LocalDateTime date) { | ||
| 100 | + // 1. 处理统计时间范围 | ||
| 101 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); | ||
| 102 | + LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); | ||
| 103 | + String dateStr = DatePattern.NORM_DATE_FORMAT.format(date); | ||
| 104 | + // 2. 检查该日是否已经统计过 | ||
| 105 | + TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); | ||
| 106 | + if (entity != null) { | ||
| 107 | + return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + // 3. 从各个数据表,统计对应数据 | ||
| 111 | + StopWatch stopWatch = new StopWatch(dateStr); | ||
| 112 | + // 3.1 统计订单 | ||
| 116 | stopWatch.start("统计订单"); | 113 | stopWatch.start("统计订单"); |
| 117 | TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); | 114 | TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); |
| 118 | stopWatch.stop(); | 115 | stopWatch.stop(); |
| 119 | - // 1.2 统计售后 | 116 | + // 3.2 统计售后 |
| 120 | stopWatch.start("统计售后"); | 117 | stopWatch.start("统计售后"); |
| 121 | AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); | 118 | AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); |
| 122 | stopWatch.stop(); | 119 | stopWatch.stop(); |
| 123 | - // 1.3 统计佣金 | 120 | + // 3.3 统计佣金 |
| 124 | stopWatch.start("统计佣金"); | 121 | stopWatch.start("统计佣金"); |
| 125 | Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); | 122 | Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); |
| 126 | stopWatch.stop(); | 123 | stopWatch.stop(); |
| 127 | - // 1.4 统计充值 | 124 | + // 3.4 统计充值 |
| 128 | stopWatch.start("统计充值"); | 125 | stopWatch.start("统计充值"); |
| 129 | WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); | 126 | WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); |
| 130 | stopWatch.stop(); | 127 | stopWatch.stop(); |
| 131 | 128 | ||
| 132 | - // 2. 插入数据 | ||
| 133 | - TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, | ||
| 134 | - brokerageSettlementPrice, walletSummary); | 129 | + // 4. 插入数据 |
| 130 | + entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, | ||
| 131 | + walletSummary); | ||
| 135 | tradeStatisticsMapper.insert(entity); | 132 | tradeStatisticsMapper.insert(entity); |
| 136 | return stopWatch.prettyPrint(); | 133 | return stopWatch.prettyPrint(); |
| 137 | } | 134 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
| @@ -2,23 +2,21 @@ | @@ -2,23 +2,21 @@ | ||
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> |
| 4 | 4 | ||
| 5 | - <select id="selectCountByIp" resultType="java.lang.Integer"> | ||
| 6 | - <!-- TODO @疯狂:distinct 会不会更合适哈 --> | ||
| 7 | - SELECT COUNT(1) | 5 | + <select id="selectIpCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> |
| 6 | + SELECT COUNT(DISTINCT user_ip) | ||
| 8 | FROM infra_api_access_log | 7 | FROM infra_api_access_log |
| 9 | - WHERE create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 10 | - AND deleted = FALSE | ||
| 11 | - GROUP BY user_ip | 8 | + WHERE user_type = #{userType} |
| 9 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 10 | + AND deleted = FALSE | ||
| 12 | </select> | 11 | </select> |
| 13 | 12 | ||
| 14 | - <select id="selectCountByUserId" resultType="java.lang.Integer"> | ||
| 15 | - <!-- TODO @疯狂:distinct 会不会更合适哈 --> | ||
| 16 | - SELECT COUNT(1) | 13 | + <select id="selectUserCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> |
| 14 | + SELECT COUNT(DISTINCT user_id) | ||
| 17 | FROM infra_api_access_log | 15 | FROM infra_api_access_log |
| 18 | WHERE user_id > 0 | 16 | WHERE user_id > 0 |
| 17 | + AND user_type = #{userType} | ||
| 19 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 18 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 20 | AND deleted = FALSE | 19 | AND deleted = FALSE |
| 21 | - GROUP BY user_id | ||
| 22 | </select> | 20 | </select> |
| 23 | 21 | ||
| 24 | </mapper> | 22 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper"> | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper"> |
| 4 | 4 | ||
| 5 | <select id="selectSummaryListByAreaId" | 5 | <select id="selectSummaryListByAreaId" |
| 6 | - resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | 6 | + resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO"> |
| 7 | SELECT area_id, COUNT(1) AS userCount | 7 | SELECT area_id, COUNT(1) AS userCount |
| 8 | FROM member_user | 8 | FROM member_user |
| 9 | WHERE deleted = FALSE | 9 | WHERE deleted = FALSE |
| @@ -18,6 +18,14 @@ | @@ -18,6 +18,14 @@ | ||
| 18 | GROUP BY sex | 18 | GROUP BY sex |
| 19 | </select> | 19 | </select> |
| 20 | 20 | ||
| 21 | + <select id="selectSummaryListByRegisterTerminal" | ||
| 22 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO"> | ||
| 23 | + SELECT register_terminal as terminal, COUNT(1) AS userCount | ||
| 24 | + FROM member_user | ||
| 25 | + WHERE deleted = FALSE | ||
| 26 | + GROUP BY register_terminal | ||
| 27 | + </select> | ||
| 28 | + | ||
| 21 | <select id="selectUserCount" resultType="java.lang.Integer"> | 29 | <select id="selectUserCount" resultType="java.lang.Integer"> |
| 22 | SELECT COUNT(1) | 30 | SELECT COUNT(1) |
| 23 | FROM member_user | 31 | FROM member_user |
| @@ -30,4 +38,14 @@ | @@ -30,4 +38,14 @@ | ||
| 30 | </if> | 38 | </if> |
| 31 | </select> | 39 | </select> |
| 32 | 40 | ||
| 41 | + <select id="selectListByCreateTimeBetween" | ||
| 42 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO"> | ||
| 43 | + SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date, | ||
| 44 | + count(1) AS count | ||
| 45 | + FROM member_user | ||
| 46 | + WHERE create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 47 | + AND deleted = FALSE | ||
| 48 | + GROUP BY date | ||
| 49 | + </select> | ||
| 50 | + | ||
| 33 | </mapper> | 51 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
| @@ -32,9 +32,8 @@ | @@ -32,9 +32,8 @@ | ||
| 32 | 32 | ||
| 33 | <select id="selectRechargeSummaryGroupByWalletId" | 33 | <select id="selectRechargeSummaryGroupByWalletId" |
| 34 | resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO"> | 34 | resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO"> |
| 35 | - <!-- TODO @疯狂:是不是不用 group by,而是通过 DISTINCT wallet_id 更合适哈? --> | ||
| 36 | - SELECT COUNT(1) AS rechargeUserCount, | ||
| 37 | - SUM(pay_price) AS rechargePrice | 35 | + SELECT COUNT(DISTINCT wallet_id) AS rechargeUserCount, |
| 36 | + SUM(pay_price) AS rechargePrice | ||
| 38 | FROM pay_wallet_recharge | 37 | FROM pay_wallet_recharge |
| 39 | WHERE pay_status = #{payStatus} | 38 | WHERE pay_status = #{payStatus} |
| 40 | <if test="beginTime != null"> | 39 | <if test="beginTime != null"> |
| @@ -44,7 +43,13 @@ | @@ -44,7 +43,13 @@ | ||
| 44 | AND pay_time <= #{endTime} | 43 | AND pay_time <= #{endTime} |
| 45 | </if> | 44 | </if> |
| 46 | AND deleted = FALSE | 45 | AND deleted = FALSE |
| 47 | - GROUP BY wallet_id | 46 | + </select> |
| 47 | + | ||
| 48 | + <select id="selectRechargePriceSummary" resultType="java.lang.Integer"> | ||
| 49 | + SELECT IFNULL(SUM(pay_price), 0) | ||
| 50 | + FROM pay_wallet_recharge | ||
| 51 | + WHERE pay_status = #{payStatus} | ||
| 52 | + AND deleted = FALSE | ||
| 48 | </select> | 53 | </select> |
| 49 | 54 | ||
| 50 | </mapper> | 55 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
| @@ -11,4 +11,11 @@ | @@ -11,4 +11,11 @@ | ||
| 11 | AND deleted = FALSE | 11 | AND deleted = FALSE |
| 12 | </select> | 12 | </select> |
| 13 | 13 | ||
| 14 | + <select id="selectCountByStatus" resultType="java.lang.Long"> | ||
| 15 | + SELECT COUNT(1) | ||
| 16 | + FROM trade_after_sale | ||
| 17 | + WHERE status = #{status} | ||
| 18 | + AND deleted = FALSE | ||
| 19 | + </select> | ||
| 20 | + | ||
| 14 | </mapper> | 21 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
| @@ -11,4 +11,11 @@ | @@ -11,4 +11,11 @@ | ||
| 11 | AND deleted = FALSE | 11 | AND deleted = FALSE |
| 12 | </select> | 12 | </select> |
| 13 | 13 | ||
| 14 | + <select id="selectWithdrawCountByStatus" resultType="java.lang.Long"> | ||
| 15 | + SELECT COUNT(1) | ||
| 16 | + FROM trade_brokerage_withdraw | ||
| 17 | + WHERE status = #{status} | ||
| 18 | + AND deleted = FALSE | ||
| 19 | + </select> | ||
| 20 | + | ||
| 14 | </mapper> | 21 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> |
| 4 | - | ||
| 5 | <select id="selectSummaryListByAreaId" | 4 | <select id="selectSummaryListByAreaId" |
| 6 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | 5 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> |
| 7 | SELECT receiver_area_id AS areaId, | 6 | SELECT receiver_area_id AS areaId, |
| 8 | - (SELECT COUNT(1) | 7 | + (SELECT COUNT(DISTINCT s.user_id) |
| 9 | FROM trade_order AS s | 8 | FROM trade_order AS s |
| 10 | - WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount, | ||
| 11 | - (SELECT COUNT(1) | 9 | + WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount, |
| 10 | + (SELECT COUNT(DISTINCT s.user_id) | ||
| 12 | FROM trade_order AS s | 11 | FROM trade_order AS s |
| 13 | WHERE s.receiver_area_id = m.receiver_area_id | 12 | WHERE s.receiver_area_id = m.receiver_area_id |
| 14 | AND s.pay_status = TRUE | 13 | AND s.pay_status = TRUE |
| 15 | - AND s.deleted = FALSE) AS orderPayCount, | 14 | + AND s.deleted = FALSE) AS orderPayUserCount, |
| 16 | (SELECT SUM(s.pay_price) | 15 | (SELECT SUM(s.pay_price) |
| 17 | FROM trade_order AS s | 16 | FROM trade_order AS s |
| 18 | WHERE s.receiver_area_id = m.receiver_area_id | 17 | WHERE s.receiver_area_id = m.receiver_area_id |
| @@ -24,14 +23,14 @@ | @@ -24,14 +23,14 @@ | ||
| 24 | </select> | 23 | </select> |
| 25 | 24 | ||
| 26 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> | 25 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| 27 | - SELECT COUNT(DISTINCT(user_id)) | 26 | + SELECT COUNT(DISTINCT (user_id)) |
| 28 | FROM trade_order | 27 | FROM trade_order |
| 29 | WHERE deleted = FALSE | 28 | WHERE deleted = FALSE |
| 30 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 29 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 31 | </select> | 30 | </select> |
| 32 | 31 | ||
| 33 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> | 32 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 34 | - SELECT COUNT(DISTINCT(user_id)) | 33 | + SELECT COUNT(DISTINCT (user_id)) |
| 35 | FROM trade_order | 34 | FROM trade_order |
| 36 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} | 35 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} |
| 37 | AND pay_status = TRUE | 36 | AND pay_status = TRUE |
| @@ -61,4 +60,52 @@ | @@ -61,4 +60,52 @@ | ||
| 61 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 60 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 62 | </select> | 61 | </select> |
| 63 | 62 | ||
| 63 | + <select id="selectListByPayTimeBetweenAndGroupByDay" | ||
| 64 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | ||
| 65 | + SELECT DATE_FORMAT(pay_time, '%Y-%m-%d') AS date, | ||
| 66 | + COUNT(1) AS orderPayCount, | ||
| 67 | + SUM(pay_price) AS orderPayPrice | ||
| 68 | + FROM trade_order | ||
| 69 | + WHERE pay_status = TRUE | ||
| 70 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 71 | + AND deleted = FALSE | ||
| 72 | + GROUP BY date | ||
| 73 | + </select> | ||
| 74 | + | ||
| 75 | + <select id="selectListByPayTimeBetweenAndGroupByMonth" | ||
| 76 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | ||
| 77 | + SELECT DATE_FORMAT(pay_time, '%Y-%m') AS date, | ||
| 78 | + COUNT(1) AS orderPayCount, | ||
| 79 | + SUM(pay_price) AS orderPayPrice | ||
| 80 | + FROM trade_order | ||
| 81 | + WHERE pay_status = TRUE | ||
| 82 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 83 | + AND deleted = FALSE | ||
| 84 | + GROUP BY date | ||
| 85 | + </select> | ||
| 86 | + | ||
| 87 | + <select id="selectCountByStatus" resultType="java.lang.Long"> | ||
| 88 | + SELECT COUNT(1) | ||
| 89 | + FROM trade_order | ||
| 90 | + WHERE status = #{status} AND deleted = FALSE | ||
| 91 | + </select> | ||
| 92 | + | ||
| 93 | + <select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long"> | ||
| 94 | + SELECT COUNT(1) | ||
| 95 | + FROM trade_order | ||
| 96 | + WHERE status = #{status} | ||
| 97 | + AND pick_up_store_id IS NOT NULL | ||
| 98 | + AND deleted = FALSE | ||
| 99 | + </select> | ||
| 100 | + | ||
| 101 | + <select id="selectPaySummaryByStatusAndPayTimeBetween" | ||
| 102 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO"> | ||
| 103 | + SELECT IFNULL(SUM(pay_price), 0) AS orderPayPrice, | ||
| 104 | + COUNT(1) AS orderPayCount | ||
| 105 | + FROM trade_order | ||
| 106 | + WHERE status = #{status} | ||
| 107 | + AND pay_time BETWEEN #{beginTime} AND #{endTime} | ||
| 108 | + AND deleted = FALSE | ||
| 109 | + </select> | ||
| 110 | + | ||
| 64 | </mapper> | 111 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml
| @@ -11,16 +11,16 @@ | @@ -11,16 +11,16 @@ | ||
| 11 | AND deleted = FALSE | 11 | AND deleted = FALSE |
| 12 | </select> | 12 | </select> |
| 13 | 13 | ||
| 14 | - <select id="selectByTimeBetween" | 14 | + <select id="selectVoByTimeBetween" |
| 15 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> | 15 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 16 | SELECT | 16 | SELECT |
| 17 | -- 营业额 = 商品支付金额 + 充值金额 | 17 | -- 营业额 = 商品支付金额 + 充值金额 |
| 18 | - SUM(order_pay_price + recharge_pay_price) AS turnover, | 18 | + SUM(order_pay_price + recharge_pay_price) AS turnoverPrice, |
| 19 | SUM(order_pay_price) AS orderPayPrice, | 19 | SUM(order_pay_price) AS orderPayPrice, |
| 20 | SUM(recharge_pay_price) AS rechargePrice, | 20 | SUM(recharge_pay_price) AS rechargePrice, |
| 21 | -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | 21 | -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 22 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, | 22 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, |
| 23 | - SUM(order_wallet_pay_price) AS balancePrice, | 23 | + SUM(order_wallet_pay_price) AS orderWalletPayPrice, |
| 24 | SUM(brokerage_settlement_price) AS brokerageSettlementPrice, | 24 | SUM(brokerage_settlement_price) AS brokerageSettlementPrice, |
| 25 | SUM(after_sale_refund_price) AS orderRefundPrice | 25 | SUM(after_sale_refund_price) AS orderRefundPrice |
| 26 | FROM trade_statistics | 26 | FROM trade_statistics |
| @@ -28,25 +28,6 @@ | @@ -28,25 +28,6 @@ | ||
| 28 | AND deleted = FALSE | 28 | AND deleted = FALSE |
| 29 | </select> | 29 | </select> |
| 30 | 30 | ||
| 31 | - <select id="selectListByTimeBetween" | ||
| 32 | - resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> | ||
| 33 | - SELECT DATE_FORMAT(time, '%Y-%m-%d') AS date, | ||
| 34 | - -- 营业额 = 商品支付金额 + 充值金额 | ||
| 35 | - SUM(order_pay_price + recharge_pay_price) AS turnover, | ||
| 36 | - SUM(order_pay_price) AS orderPayPrice, | ||
| 37 | - SUM(recharge_pay_price) AS rechargePrice, | ||
| 38 | - -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | ||
| 39 | - SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, | ||
| 40 | - SUM(order_wallet_pay_price) AS balancePrice, | ||
| 41 | - SUM(brokerage_settlement_price) AS brokerageSettlementPrice, | ||
| 42 | - SUM(after_sale_refund_price) AS orderRefundPrice | ||
| 43 | - FROM trade_statistics | ||
| 44 | - WHERE time BETWEEN #{beginTime} AND #{endTime} | ||
| 45 | - AND deleted = FALSE | ||
| 46 | - <!-- TODO @疯狂:已经不用 group by,它就是每天统计一条; --> | ||
| 47 | - GROUP BY date | ||
| 48 | - </select> | ||
| 49 | - | ||
| 50 | <select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer"> | 31 | <select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer"> |
| 51 | SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | 32 | SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 52 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice | 33 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| @@ -8,10 +8,10 @@ import cn.hutool.core.util.ObjectUtil; | @@ -8,10 +8,10 @@ import cn.hutool.core.util.ObjectUtil; | ||
| 8 | import cn.hutool.core.util.RandomUtil; | 8 | import cn.hutool.core.util.RandomUtil; |
| 9 | import cn.hutool.extra.spring.SpringUtil; | 9 | import cn.hutool.extra.spring.SpringUtil; |
| 10 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 10 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 11 | -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | ||
| 12 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 11 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 13 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 14 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; | 13 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 14 | +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | ||
| 15 | import cn.iocoder.yudao.module.member.api.address.AddressApi; | 15 | import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| 16 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; | 16 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 17 | import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; | 17 | import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; |
| @@ -187,7 +187,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | @@ -187,7 +187,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { | ||
| 187 | order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); | 187 | order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); |
| 188 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); | 188 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); |
| 189 | order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); | 189 | order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); |
| 190 | - order.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源? | 190 | + order.setTerminal(ServletUtils.getTerminal()); |
| 191 | // 支付 + 退款信息 | 191 | // 支付 + 退款信息 |
| 192 | order.setAdjustPrice(0).setPayStatus(false); | 192 | order.setAdjustPrice(0).setPayStatus(false); |
| 193 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); | 193 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
| 1 | package cn.iocoder.yudao.module.member.dal.dataobject.user; | 1 | package cn.iocoder.yudao.module.member.dal.dataobject.user; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | ||
| 4 | import cn.iocoder.yudao.framework.ip.core.Area; | 5 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | 6 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 6 | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | 7 | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| @@ -61,6 +62,11 @@ public class MemberUserDO extends TenantBaseDO { | @@ -61,6 +62,11 @@ public class MemberUserDO extends TenantBaseDO { | ||
| 61 | */ | 62 | */ |
| 62 | private String registerIp; | 63 | private String registerIp; |
| 63 | /** | 64 | /** |
| 65 | + * 注册终端 | ||
| 66 | + * 枚举 {@link TerminalEnum} | ||
| 67 | + */ | ||
| 68 | + private Integer registerTerminal; | ||
| 69 | + /** | ||
| 64 | * 最后登录IP | 70 | * 最后登录IP |
| 65 | */ | 71 | */ |
| 66 | private String loginIp; | 72 | private String loginIp; |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
| @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; | @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; | ||
| 7 | import cn.hutool.core.util.StrUtil; | 7 | import cn.hutool.core.util.StrUtil; |
| 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | ||
| 10 | import cn.iocoder.yudao.module.infra.api.file.FileApi; | 11 | import cn.iocoder.yudao.module.infra.api.file.FileApi; |
| 11 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; | 12 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; |
| 12 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; | 13 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; |
| @@ -99,6 +100,7 @@ public class MemberUserServiceImpl implements MemberUserService { | @@ -99,6 +100,7 @@ public class MemberUserServiceImpl implements MemberUserService { | ||
| 99 | user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 | 100 | user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 |
| 100 | user.setPassword(encodePassword(password)); // 加密密码 | 101 | user.setPassword(encodePassword(password)); // 加密密码 |
| 101 | user.setRegisterIp(registerIp); | 102 | user.setRegisterIp(registerIp); |
| 103 | + user.setRegisterTerminal(ServletUtils.getTerminal()); | ||
| 102 | memberUserMapper.insert(user); | 104 | memberUserMapper.insert(user); |
| 103 | 105 | ||
| 104 | // 发送 MQ 消息:用户创建 | 106 | // 发送 MQ 消息:用户创建 |