Commit df16278a03daab9ce37e3ab450fde204ca43ecf8
1 parent
383439f9
统计:会员统计
Showing
34 changed files
with
731 additions
and
58 deletions
sql/mysql/statistics.sql
| @@ -28,16 +28,22 @@ CREATE INDEX trade_statistics_time_index | @@ -28,16 +28,22 @@ CREATE INDEX trade_statistics_time_index | ||
| 28 | ON trade_statistics (time); | 28 | ON trade_statistics (time); |
| 29 | 29 | ||
| 30 | -- 菜单 | 30 | -- 菜单 |
| 31 | -INSERT INTO `ruoyi-vue-pro`.system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | 31 | +INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) |
| 32 | VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', ''); | 32 | VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', ''); |
| 33 | SELECT @parentId := LAST_INSERT_ID(); | 33 | SELECT @parentId := LAST_INSERT_ID(); |
| 34 | -INSERT INTO `ruoyi-vue-pro`.system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 35 | -VALUES ('交易统计', '', 2, 4, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics'); | 34 | +-- 交易统计 |
| 35 | +INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 36 | +VALUES ('交易统计', '', 2, 1, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics'); | ||
| 36 | SELECT @parentId := LAST_INSERT_ID(); | 37 | SELECT @parentId := LAST_INSERT_ID(); |
| 37 | --- 按钮 | ||
| 38 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | 38 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 39 | VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0); | 39 | VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0); |
| 40 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | 40 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 41 | VALUES ('交易统计导出', 'statistics:trade:export', 3, 2, @parentId, '', '', '', 0); | 41 | VALUES ('交易统计导出', 'statistics:trade:export', 3, 2, @parentId, '', '', '', 0); |
| 42 | +-- 会员统计 | ||
| 43 | +INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name) | ||
| 44 | +VALUES ('会员统计', '', 2, 2, @parentId, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics'); | ||
| 45 | +SELECT @parentId := LAST_INSERT_ID(); | ||
| 46 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | ||
| 47 | +VALUES ('会员统计查询', 'statistics:member:query', 3, 1, @parentId, '', '', '', 0); | ||
| 42 | 48 | ||
| 43 | 49 |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.common.util.collection; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.common.util.collection; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.collection.CollectionUtil; | 4 | import cn.hutool.core.collection.CollectionUtil; |
| 5 | +import cn.hutool.core.util.ArrayUtil; | ||
| 5 | import com.google.common.collect.ImmutableMap; | 6 | import com.google.common.collect.ImmutableMap; |
| 6 | 7 | ||
| 7 | import java.util.*; | 8 | import java.util.*; |
| @@ -50,6 +51,13 @@ public class CollectionUtils { | @@ -50,6 +51,13 @@ public class CollectionUtils { | ||
| 50 | return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values()); | 51 | return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values()); |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 54 | + public static <T, U> List<U> convertList(T[] from, Function<T, U> func) { | ||
| 55 | + if (ArrayUtil.isEmpty(from)) { | ||
| 56 | + return new ArrayList<>(); | ||
| 57 | + } | ||
| 58 | + return convertList(Arrays.asList(from), func); | ||
| 59 | + } | ||
| 60 | + | ||
| 53 | public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) { | 61 | public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) { |
| 54 | if (CollUtil.isEmpty(from)) { | 62 | if (CollUtil.isEmpty(from)) { |
| 55 | return new ArrayList<>(); | 63 | return new ArrayList<>(); |
| @@ -162,8 +170,8 @@ public class CollectionUtils { | @@ -162,8 +170,8 @@ public class CollectionUtils { | ||
| 162 | /** | 170 | /** |
| 163 | * 对比老、新两个列表,找出新增、修改、删除的数据 | 171 | * 对比老、新两个列表,找出新增、修改、删除的数据 |
| 164 | * | 172 | * |
| 165 | - * @param oldList 老列表 | ||
| 166 | - * @param newList 新列表 | 173 | + * @param oldList 老列表 |
| 174 | + * @param newList 新列表 | ||
| 167 | * @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同 | 175 | * @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同 |
| 168 | * 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据 | 176 | * 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据 |
| 169 | * @return [新增列表、修改列表、删除列表] | 177 | * @return [新增列表、修改列表、删除列表] |
yudao-framework/yudao-spring-boot-starter-biz-ip/src/main/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtils.java
| @@ -7,12 +7,16 @@ import cn.hutool.core.text.csv.CsvUtil; | @@ -7,12 +7,16 @@ import cn.hutool.core.text.csv.CsvUtil; | ||
| 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | import cn.iocoder.yudao.framework.ip.core.Area; | 8 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 9 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; | 9 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 10 | +import lombok.NonNull; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 11 | 12 | ||
| 12 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
| 13 | import java.util.HashMap; | 14 | import java.util.HashMap; |
| 14 | import java.util.List; | 15 | import java.util.List; |
| 15 | import java.util.Map; | 16 | import java.util.Map; |
| 17 | +import java.util.function.Function; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 16 | 20 | ||
| 17 | /** | 21 | /** |
| 18 | * 区域工具类 | 22 | * 区域工具类 |
| @@ -108,7 +112,7 @@ public class AreaUtils { | @@ -108,7 +112,7 @@ public class AreaUtils { | ||
| 108 | // “递归”父节点 | 112 | // “递归”父节点 |
| 109 | area = area.getParent(); | 113 | area = area.getParent(); |
| 110 | if (area == null | 114 | if (area == null |
| 111 | - || ObjectUtils.equalsAny(area.getId(), Area.ID_GLOBAL, Area.ID_CHINA)) { // 跳过父节点为中国的情况 | 115 | + || ObjectUtils.equalsAny(area.getId(), Area.ID_GLOBAL, Area.ID_CHINA)) { // 跳过父节点为中国的情况 |
| 112 | break; | 116 | break; |
| 113 | } | 117 | } |
| 114 | sb.insert(0, separator); | 118 | sb.insert(0, separator); |
| @@ -116,4 +120,35 @@ public class AreaUtils { | @@ -116,4 +120,35 @@ public class AreaUtils { | ||
| 116 | return sb.toString(); | 120 | return sb.toString(); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 123 | + /** | ||
| 124 | + * 获取指定类型的区域列表 | ||
| 125 | + * | ||
| 126 | + * @param type 区域类型 | ||
| 127 | + * @param func 转换函数 | ||
| 128 | + * @param <T> 结果类型 | ||
| 129 | + * @return 区域列表 | ||
| 130 | + */ | ||
| 131 | + public static <T> List<T> getByType(AreaTypeEnum type, Function<Area, T> func) { | ||
| 132 | + return convertList(areas.values(), func, area -> type.getType().equals(area.getType())); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) { | ||
| 136 | + do { | ||
| 137 | + Area area = AreaUtils.getArea(id); | ||
| 138 | + if (area == null) { | ||
| 139 | + return null; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + if (type.getType().equals(area.getType())) { | ||
| 143 | + return area.getId(); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + if (area.getParent() == null || area.getParent().getId() == null) { | ||
| 147 | + return null; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + id = area.getParent().getId(); | ||
| 151 | + } while (true); | ||
| 152 | + } | ||
| 153 | + | ||
| 119 | } | 154 | } |
yudao-module-mall/yudao-module-statistics-biz/pom.xml
| @@ -59,6 +59,11 @@ | @@ -59,6 +59,11 @@ | ||
| 59 | <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> | 59 | <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> |
| 60 | </dependency> | 60 | </dependency> |
| 61 | 61 | ||
| 62 | + <dependency> | ||
| 63 | + <groupId>cn.iocoder.boot</groupId> | ||
| 64 | + <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | ||
| 65 | + </dependency> | ||
| 66 | + | ||
| 62 | <!-- Web 相关 --> | 67 | <!-- Web 相关 --> |
| 63 | <dependency> | 68 | <dependency> |
| 64 | <groupId>cn.iocoder.boot</groupId> | 69 | <groupId>cn.iocoder.boot</groupId> |
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; | ||
| 4 | +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | ||
| 5 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; | ||
| 6 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; | ||
| 8 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; |
| 7 | +import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; | ||
| 9 | import io.swagger.v3.oas.annotations.Operation; | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | 9 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | import lombok.extern.slf4j.Slf4j; | 10 | import lombok.extern.slf4j.Slf4j; |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | import org.springframework.web.bind.annotation.GetMapping; | 13 | import org.springframework.web.bind.annotation.GetMapping; |
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 15 | import org.springframework.web.bind.annotation.RestController; | 15 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | ||
| 17 | +import javax.annotation.Resource; | ||
| 17 | import java.util.List; | 18 | import java.util.List; |
| 18 | 19 | ||
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 22 | + | ||
| 19 | @Tag(name = "管理后台 - 会员统计") | 23 | @Tag(name = "管理后台 - 会员统计") |
| 20 | @RestController | 24 | @RestController |
| 21 | @RequestMapping("/statistics/member") | 25 | @RequestMapping("/statistics/member") |
| @@ -23,36 +27,47 @@ import java.util.List; | @@ -23,36 +27,47 @@ import java.util.List; | ||
| 23 | @Slf4j | 27 | @Slf4j |
| 24 | public class MemberStatisticsController { | 28 | public class MemberStatisticsController { |
| 25 | 29 | ||
| 26 | - // TODO @疯狂:一个类似 getTradeTrendSummaryComparison 的接口 | ||
| 27 | - // TODO @疯狂:一个类似 getTradeStatisticsList 的接口 | 30 | + @Resource |
| 31 | + private MemberStatisticsService memberStatisticsService; | ||
| 28 | 32 | ||
| 29 | @GetMapping("/summary") | 33 | @GetMapping("/summary") |
| 30 | @Operation(summary = "获得会员统计") | 34 | @Operation(summary = "获得会员统计") |
| 31 | - public CommonResult<TradeStatisticsComparisonRespVO<MemberSummaryRespVO>> getMemberSummary() { | ||
| 32 | - // TODO 疯狂:目前先直接计算; | ||
| 33 | - return null; | 35 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 36 | + public CommonResult<MemberSummaryRespVO> getMemberSummary() { | ||
| 37 | + return success(memberStatisticsService.getMemberSummary()); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @GetMapping("/analyse") | ||
| 41 | + @Operation(summary = "获得会员分析数据") | ||
| 42 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 43 | + public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) { | ||
| 44 | + return success(memberStatisticsService.getMemberAnalyse( | ||
| 45 | + ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | ||
| 34 | } | 46 | } |
| 35 | 47 | ||
| 36 | @GetMapping("/get-area-statistics-list") | 48 | @GetMapping("/get-area-statistics-list") |
| 37 | @Operation(summary = "按照省份,获得会员统计列表") | 49 | @Operation(summary = "按照省份,获得会员统计列表") |
| 50 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 38 | public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() { | 51 | public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() { |
| 39 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | ||
| 40 | - return null; | 52 | + return success(memberStatisticsService.getMemberAreaStatisticsList()); |
| 41 | } | 53 | } |
| 42 | 54 | ||
| 43 | @GetMapping("/get-sex-statistics-list") | 55 | @GetMapping("/get-sex-statistics-list") |
| 44 | @Operation(summary = "按照性别,获得会员统计列表") | 56 | @Operation(summary = "按照性别,获得会员统计列表") |
| 57 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 45 | public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() { | 58 | public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() { |
| 46 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | ||
| 47 | - return null; | 59 | + return success(memberStatisticsService.getMemberSexStatisticsList()); |
| 48 | } | 60 | } |
| 49 | 61 | ||
| 50 | @GetMapping("/get-terminal-statistics-list") | 62 | @GetMapping("/get-terminal-statistics-list") |
| 51 | @Operation(summary = "按照终端,获得会员统计列表") | 63 | @Operation(summary = "按照终端,获得会员统计列表") |
| 64 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | ||
| 52 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { | 65 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { |
| 53 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | ||
| 54 | // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal | 66 | // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal |
| 55 | - return null; | 67 | + List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(), |
| 68 | + t -> new MemberTerminalStatisticsRespVO() | ||
| 69 | + .setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100)); | ||
| 70 | + return success(list); | ||
| 56 | } | 71 | } |
| 57 | 72 | ||
| 58 | } | 73 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseComparisonRespVO.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 MemberAnalyseComparisonRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 11 | + private Integer userCount; | ||
| 12 | + | ||
| 13 | + @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | + private Integer activeUserCount; | ||
| 15 | + | ||
| 16 | + @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | ||
| 17 | + private Integer rechargeUserCount; | ||
| 18 | + | ||
| 19 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.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 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 会员分析 Request VO") | ||
| 12 | +@Data | ||
| 13 | +public class MemberAnalyseReqVO { | ||
| 14 | + | ||
| 15 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 16 | + @Schema(description = "时间范围") | ||
| 17 | + private LocalDateTime[] times; | ||
| 18 | + | ||
| 19 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - 会员分析 Response VO") | ||
| 8 | +@Data | ||
| 9 | +public class MemberAnalyseRespVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 12 | + private Integer visitorCount; | ||
| 13 | + | ||
| 14 | + @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 15 | + private Integer orderUserCount; | ||
| 16 | + | ||
| 17 | + @Schema(description = "成交用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 18 | + private Integer payUserCount; | ||
| 19 | + | ||
| 20 | + @Schema(description = "客单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 21 | + private Integer atv; | ||
| 22 | + | ||
| 23 | + @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | + private TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO> comparison; | ||
| 25 | + | ||
| 26 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java
| @@ -13,11 +13,4 @@ public class MemberSexStatisticsRespVO { | @@ -13,11 +13,4 @@ public class MemberSexStatisticsRespVO { | ||
| 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | private Integer userCount; | 14 | private Integer userCount; |
| 15 | 15 | ||
| 16 | - @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | - private Integer orderCreateCount; | ||
| 18 | - @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | ||
| 19 | - private Integer orderPayCount; | ||
| 20 | - @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | ||
| 21 | - private Integer orderPayPrice; | ||
| 22 | - | ||
| 23 | } | 16 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java
| @@ -15,6 +15,7 @@ public class MemberSummaryRespVO { | @@ -15,6 +15,7 @@ public class MemberSummaryRespVO { | ||
| 15 | 15 | ||
| 16 | @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 16 | @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 17 | private Integer rechargePrice; | 17 | private Integer rechargePrice; |
| 18 | + | ||
| 18 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 19 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | private Integer expensePrice; | 20 | private Integer expensePrice; |
| 20 | 21 |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | @@ -3,7 +3,7 @@ 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 MemberTerminalStatisticsRespVO { | 8 | public class MemberTerminalStatisticsRespVO { |
| 9 | 9 | ||
| @@ -13,11 +13,4 @@ public class MemberTerminalStatisticsRespVO { | @@ -13,11 +13,4 @@ public class MemberTerminalStatisticsRespVO { | ||
| 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | private Integer userCount; | 14 | private Integer userCount; |
| 15 | 15 | ||
| 16 | - @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | - private Integer orderCreateCount; | ||
| 18 | - @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | ||
| 19 | - private Integer orderPayCount; | ||
| 20 | - @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") | ||
| 21 | - private Integer orderPayPrice; | ||
| 22 | - | ||
| 23 | } | 16 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.convert.member; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.map.MapUtil; | ||
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 6 | +import cn.iocoder.yudao.framework.ip.core.Area; | ||
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | ||
| 8 | +import org.mapstruct.Mapper; | ||
| 9 | +import org.mapstruct.factory.Mappers; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | +import java.util.Map; | ||
| 13 | +import java.util.Optional; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 会员统计 Convert | ||
| 17 | + * | ||
| 18 | + * @author owen | ||
| 19 | + */ | ||
| 20 | +@Mapper | ||
| 21 | +public interface MemberStatisticsConvert { | ||
| 22 | + | ||
| 23 | + MemberStatisticsConvert INSTANCE = Mappers.getMapper(MemberStatisticsConvert.class); | ||
| 24 | + | ||
| 25 | + default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList, | ||
| 26 | + Map<Integer, Integer> userCountMap, | ||
| 27 | + Map<Integer, MemberAreaStatisticsRespVO> orderMap) { | ||
| 28 | + return CollectionUtils.convertList(areaList, area -> { | ||
| 29 | + MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())).orElseGet(MemberAreaStatisticsRespVO::new); | ||
| 30 | + return new MemberAreaStatisticsRespVO() | ||
| 31 | + .setAreaId(area.getId()).setAreaName(area.getName()) | ||
| 32 | + .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) | ||
| 33 | + .setOrderCreateCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateCount(), 0)) | ||
| 34 | + .setOrderPayCount(ObjUtil.defaultIfNull(orderVo.getOrderPayCount(), 0)) | ||
| 35 | + .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); | ||
| 36 | + }); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.infra; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import org.apache.ibatis.annotations.Mapper; | ||
| 5 | +import org.apache.ibatis.annotations.Param; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * API 访问日志统计 Mapper | ||
| 11 | + * | ||
| 12 | + * @author owen | ||
| 13 | + */ | ||
| 14 | +@Mapper | ||
| 15 | +public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> { | ||
| 16 | + | ||
| 17 | + Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | ||
| 18 | + | ||
| 19 | + Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | ||
| 20 | + | ||
| 21 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.member; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 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 org.apache.ibatis.annotations.Mapper; | ||
| 7 | +import org.apache.ibatis.annotations.Param; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 会员统计 Mapper | ||
| 14 | + * | ||
| 15 | + * @author owen | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface MemberStatisticsMapper extends BaseMapperX<Object> { | ||
| 19 | + | ||
| 20 | + List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); | ||
| 21 | + | ||
| 22 | + List<MemberSexStatisticsRespVO> selectSummaryListBySex(); | ||
| 23 | + | ||
| 24 | + Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); | ||
| 25 | + | ||
| 26 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/PayWalletStatisticsMapper.java renamed to 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.trade; | 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.controller.admin.member.vo.MemberSummaryRespVO; | ||
| 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 5 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 6 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 7 | import org.apache.ibatis.annotations.Mapper; |
| @@ -27,4 +28,9 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO | @@ -27,4 +28,9 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO | ||
| 27 | Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 28 | Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 28 | @Param("endTime") LocalDateTime endTime, | 29 | @Param("endTime") LocalDateTime endTime, |
| 29 | @Param("bizType") Integer bizType); | 30 | @Param("bizType") Integer bizType); |
| 31 | + | ||
| 32 | + MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, | ||
| 33 | + @Param("endTime") LocalDateTime endTime, | ||
| 34 | + @Param("payStatus") Boolean payStatus); | ||
| 35 | + | ||
| 30 | } | 36 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.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.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | ||
| 4 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | 5 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 5 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | ||
| 6 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 7 | import org.apache.ibatis.annotations.Param; | 7 | import org.apache.ibatis.annotations.Param; |
| 8 | 8 | ||
| 9 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| 10 | +import java.util.List; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 交易统计 Mapper | 13 | * 交易统计 Mapper |
| @@ -16,7 +17,21 @@ import java.time.LocalDateTime; | @@ -16,7 +17,21 @@ import java.time.LocalDateTime; | ||
| 16 | @Mapper | 17 | @Mapper |
| 17 | public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | 18 | public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { |
| 18 | 19 | ||
| 19 | - TradeOrderSummaryRespBO selectSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 20 | - @Param("endTime") LocalDateTime endTime); | 20 | + List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); |
| 21 | + | ||
| 22 | + Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 23 | + @Param("endTime") LocalDateTime endTime); | ||
| 24 | + | ||
| 25 | + Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 26 | + @Param("endTime") LocalDateTime endTime); | ||
| 27 | + | ||
| 28 | + Integer selectSummaryPriceByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 29 | + @Param("endTime") LocalDateTime endTime); | ||
| 30 | + | ||
| 31 | + Integer selectUserCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 32 | + @Param("endTime") LocalDateTime endTime); | ||
| 33 | + | ||
| 34 | + Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 35 | + @Param("endTime") LocalDateTime endTime); | ||
| 21 | 36 | ||
| 22 | } | 37 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java
| @@ -30,4 +30,7 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | @@ -30,4 +30,7 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | ||
| 30 | 30 | ||
| 31 | List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | 31 | List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 32 | @Param("endTime") LocalDateTime endTime); | 32 | @Param("endTime") LocalDateTime endTime); |
| 33 | + | ||
| 34 | + Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | ||
| 35 | + @Param("endTime") LocalDateTime endTime); | ||
| 33 | } | 36 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.infra; | ||
| 2 | + | ||
| 3 | +import java.time.LocalDateTime; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * API 访问日志统计 Service 接口 | ||
| 7 | + * | ||
| 8 | + * @author owen | ||
| 9 | + */ | ||
| 10 | +public interface ApiAccessLogStatisticsService { | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 获取活跃用户数量 | ||
| 14 | + * | ||
| 15 | + * @param beginTime 起始时间 | ||
| 16 | + * @param endTime 截止时间 | ||
| 17 | + * @return 活跃用户数量 | ||
| 18 | + */ | ||
| 19 | + Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 获取访问用户数量 | ||
| 23 | + * | ||
| 24 | + * @param beginTime 起始时间 | ||
| 25 | + * @param endTime 截止时间 | ||
| 26 | + * @return 访问用户数量 | ||
| 27 | + */ | ||
| 28 | + Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.infra; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | + | ||
| 7 | +import javax.annotation.Resource; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * API 访问日志统计 Service 实现类 | ||
| 12 | + * | ||
| 13 | + * @author owen | ||
| 14 | + */ | ||
| 15 | +@Service | ||
| 16 | +@Validated | ||
| 17 | +public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatisticsService { | ||
| 18 | + | ||
| 19 | + @Resource | ||
| 20 | + private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 24 | + return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 29 | + return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime); | ||
| 30 | + } | ||
| 31 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.member; | ||
| 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; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 会员统计 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author owen | ||
| 15 | + */ | ||
| 16 | +public interface MemberStatisticsService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 按照省份,获得会员统计列表 | ||
| 20 | + * | ||
| 21 | + * @return 会员统计列表 | ||
| 22 | + */ | ||
| 23 | + List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList(); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 按照性别,获得会员统计列表 | ||
| 27 | + * | ||
| 28 | + * @return 会员统计列表 | ||
| 29 | + */ | ||
| 30 | + List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 获取用户分析数据 | ||
| 34 | + * | ||
| 35 | + * @param beginTime 起始时间 | ||
| 36 | + * @param endTime 截止时间 | ||
| 37 | + * @return 用户分析数据 | ||
| 38 | + */ | ||
| 39 | + MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 获取会员统计 | ||
| 43 | + * | ||
| 44 | + * @return 会员统计 | ||
| 45 | + */ | ||
| 46 | + MemberSummaryRespVO getMemberSummary(); | ||
| 47 | + | ||
| 48 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.member; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.NumberUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; | ||
| 5 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; | ||
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | ||
| 9 | +import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; | ||
| 10 | +import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; | ||
| 11 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | ||
| 12 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | ||
| 13 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; | ||
| 14 | +import org.springframework.stereotype.Service; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | + | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import java.time.Duration; | ||
| 19 | +import java.time.LocalDateTime; | ||
| 20 | +import java.util.List; | ||
| 21 | +import java.util.Map; | ||
| 22 | +import java.util.Optional; | ||
| 23 | + | ||
| 24 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 会员统计 Service 实现类 | ||
| 28 | + * | ||
| 29 | + * @author owen | ||
| 30 | + */ | ||
| 31 | +@Service | ||
| 32 | +@Validated | ||
| 33 | +public class MemberStatisticsServiceImpl implements MemberStatisticsService { | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private MemberStatisticsMapper memberStatisticsMapper; | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private PayWalletStatisticsService payWalletStatisticsService; | ||
| 40 | + @Resource | ||
| 41 | + private TradeStatisticsService tradeStatisticsService; | ||
| 42 | + @Resource | ||
| 43 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | ||
| 44 | + @Resource | ||
| 45 | + private ApiAccessLogStatisticsService apiAccessLogStatisticsService; | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { | ||
| 49 | + // 统计用户 | ||
| 50 | + Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), | ||
| 51 | + vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), | ||
| 52 | + MemberAreaStatisticsRespVO::getUserCount, Integer::sum); | ||
| 53 | + // 统计订单 | ||
| 54 | + Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), | ||
| 55 | + vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), | ||
| 56 | + vo -> vo, | ||
| 57 | + (a, b) -> new MemberAreaStatisticsRespVO() | ||
| 58 | + .setOrderCreateCount(a.getOrderCreateCount() + b.getOrderCreateCount()) | ||
| 59 | + .setOrderPayCount(a.getOrderPayCount() + b.getOrderPayCount()) | ||
| 60 | + .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); | ||
| 61 | + // 拼接数据 | ||
| 62 | + return MemberStatisticsConvert.INSTANCE.convertList(AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area), userCountMap, orderMap); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() { | ||
| 67 | + return memberStatisticsMapper.selectSummaryListBySex(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 72 | + // 对照数据 | ||
| 73 | + MemberAnalyseComparisonRespVO vo = getMemberAnalyseComparisonData(beginTime, endTime); | ||
| 74 | + LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); | ||
| 75 | + MemberAnalyseComparisonRespVO reference = getMemberAnalyseComparisonData(referenceBeginTime, beginTime); | ||
| 76 | + | ||
| 77 | + Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); | ||
| 78 | + // 计算客单价 | ||
| 79 | + int atv = 0; | ||
| 80 | + if (payUserCount != null && payUserCount > 0) { | ||
| 81 | + Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); | ||
| 82 | + atv = NumberUtil.div(payPrice, payUserCount).intValue(); | ||
| 83 | + } | ||
| 84 | + return new MemberAnalyseRespVO() | ||
| 85 | + .setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(beginTime, endTime)) | ||
| 86 | + .setOrderUserCount(tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime)) | ||
| 87 | + .setPayUserCount(payUserCount) | ||
| 88 | + .setAtv(atv) | ||
| 89 | + .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public MemberSummaryRespVO getMemberSummary() { | ||
| 94 | + MemberSummaryRespVO vo = payWalletStatisticsService.getUserRechargeSummary(null, null); | ||
| 95 | + Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null); | ||
| 96 | + Integer userCount = memberStatisticsMapper.selectUserCount(null, null); | ||
| 97 | + | ||
| 98 | + if (vo == null) { | ||
| 99 | + vo = new MemberSummaryRespVO().setRechargeUserCount(0).setRechargePrice(0); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + return vo.setUserCount(userCount).setExpensePrice(expensePrice); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 106 | + Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) | ||
| 107 | + .map(MemberSummaryRespVO::getRechargeUserCount).orElse(0); | ||
| 108 | + return new MemberAnalyseComparisonRespVO() | ||
| 109 | + .setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | ||
| 110 | + .setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime)) | ||
| 111 | + .setRechargeUserCount(rechargeUserCount); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | +} |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/PayWalletStatisticsService.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java
| 1 | -package cn.iocoder.yudao.module.statistics.service.trade; | 1 | +package cn.iocoder.yudao.module.statistics.service.pay; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | ||
| 3 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 4 | 5 | ||
| 5 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| @@ -20,4 +21,13 @@ public interface PayWalletStatisticsService { | @@ -20,4 +21,13 @@ public interface PayWalletStatisticsService { | ||
| 20 | */ | 21 | */ |
| 21 | WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | 22 | WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 22 | 23 | ||
| 24 | + /** | ||
| 25 | + * 获取钱包充值统计 | ||
| 26 | + * | ||
| 27 | + * @param beginTime 起始时间 | ||
| 28 | + * @param endTime 截止时间 | ||
| 29 | + * @return 钱包充值统计 | ||
| 30 | + */ | ||
| 31 | + MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 32 | + | ||
| 23 | } | 33 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/PayWalletStatisticsServiceImpl.java renamed to 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.trade; | 1 | +package cn.iocoder.yudao.module.statistics.service.pay; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | ||
| 4 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | 3 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 5 | import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; | 4 | import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; |
| 6 | -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.PayWalletStatisticsMapper; | 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; |
| 6 | +import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; | ||
| 7 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | ||
| 7 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
| 8 | import org.springframework.validation.annotation.Validated; | 9 | import org.springframework.validation.annotation.Validated; |
| 9 | 10 | ||
| @@ -38,4 +39,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic | @@ -38,4 +39,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic | ||
| 38 | return paySummary; | 39 | return paySummary; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 42 | + @Override | ||
| 43 | + public MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 44 | + return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); | ||
| 45 | + } | ||
| 46 | + | ||
| 41 | } | 47 | } |
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.member.vo.MemberAreaStatisticsRespVO; | ||
| 3 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 4 | 5 | ||
| 5 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 7 | +import java.util.List; | ||
| 6 | 8 | ||
| 7 | /** | 9 | /** |
| 8 | * 交易订单统计 Service 接口 | 10 | * 交易订单统计 Service 接口 |
| @@ -20,4 +22,38 @@ public interface TradeOrderStatisticsService { | @@ -20,4 +22,38 @@ public interface TradeOrderStatisticsService { | ||
| 20 | */ | 22 | */ |
| 21 | TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); | 23 | TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 22 | 24 | ||
| 25 | + /** | ||
| 26 | + * 获取地区订单统计 | ||
| 27 | + * | ||
| 28 | + * @return 订单统计结果 | ||
| 29 | + */ | ||
| 30 | + List<MemberAreaStatisticsRespVO> getSummaryListByAreaId(); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 获取下单用户数量 | ||
| 34 | + * | ||
| 35 | + * @param beginTime 起始时间 | ||
| 36 | + * @param endTime 截止时间 | ||
| 37 | + * @return 支付下单数量 | ||
| 38 | + */ | ||
| 39 | + Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 获取支付用户数量 | ||
| 43 | + * | ||
| 44 | + * @param beginTime 起始时间 | ||
| 45 | + * @param endTime 截止时间 | ||
| 46 | + * @return 支付用户数量 | ||
| 47 | + */ | ||
| 48 | + Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 获取支付金额 | ||
| 52 | + * | ||
| 53 | + * @param beginTime 起始时间 | ||
| 54 | + * @param endTime 截止时间 | ||
| 55 | + * @return 支付用户金额 | ||
| 56 | + */ | ||
| 57 | + Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 58 | + | ||
| 23 | } | 59 | } |
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.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | ||
| 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; | 4 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; |
| 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 5 | import org.springframework.stereotype.Service; | 6 | import org.springframework.stereotype.Service; |
| @@ -7,6 +8,7 @@ import org.springframework.validation.annotation.Validated; | @@ -7,6 +8,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 7 | 8 | ||
| 8 | import javax.annotation.Resource; | 9 | import javax.annotation.Resource; |
| 9 | import java.time.LocalDateTime; | 10 | import java.time.LocalDateTime; |
| 11 | +import java.util.List; | ||
| 10 | 12 | ||
| 11 | /** | 13 | /** |
| 12 | * 交易订单统计 Service 实现类 | 14 | * 交易订单统计 Service 实现类 |
| @@ -22,7 +24,30 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ | @@ -22,7 +24,30 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ | ||
| 22 | 24 | ||
| 23 | @Override | 25 | @Override |
| 24 | public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { | 26 | public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { |
| 25 | - return tradeOrderStatisticsMapper.selectSummaryByPayTimeBetween(beginTime, endTime); | 27 | + return new TradeOrderSummaryRespBO() |
| 28 | + .setOrderCreateCount(tradeOrderStatisticsMapper.selectCountByCreateTimeBetween(beginTime, endTime)) | ||
| 29 | + .setOrderPayCount(tradeOrderStatisticsMapper.selectCountByPayTimeBetween(beginTime, endTime)) | ||
| 30 | + .setOrderPayPrice(tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public List<MemberAreaStatisticsRespVO> getSummaryListByAreaId() { | ||
| 35 | + return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 40 | + return tradeOrderStatisticsMapper.selectUserCountByCreateTimeBetween(beginTime, endTime); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 45 | + return tradeOrderStatisticsMapper.selectUserCountByPayTimeBetween(beginTime, endTime); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 50 | + return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); | ||
| 26 | } | 51 | } |
| 27 | 52 | ||
| 28 | } | 53 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java
| @@ -22,7 +22,7 @@ public interface TradeStatisticsService { | @@ -22,7 +22,7 @@ public interface TradeStatisticsService { | ||
| 22 | TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison(); | 22 | TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison(); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | - * 获得交易状况统计 | 25 | + * 获得交易状况统计对照 |
| 26 | * | 26 | * |
| 27 | * @return 统计数据对照 | 27 | * @return 统计数据对照 |
| 28 | */ | 28 | */ |
| @@ -30,6 +30,13 @@ public interface TradeStatisticsService { | @@ -30,6 +30,13 @@ public interface TradeStatisticsService { | ||
| 30 | LocalDateTime beginTime, LocalDateTime endTime); | 30 | LocalDateTime beginTime, LocalDateTime endTime); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | + * 获得交易状况统计 | ||
| 34 | + * | ||
| 35 | + * @return 统计数据对照 | ||
| 36 | + */ | ||
| 37 | + Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); | ||
| 38 | + | ||
| 39 | + /** | ||
| 33 | * 获得交易状况明细 | 40 | * 获得交易状况明细 |
| 34 | * | 41 | * |
| 35 | * @return 统计数据列表 | 42 | * @return 统计数据列表 |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.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.hutool.core.date.LocalDateTimeUtil; | 3 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | ||
| 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | 6 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; |
| 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| @@ -69,6 +70,11 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | @@ -69,6 +70,11 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { | ||
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | @Override | 72 | @Override |
| 73 | + public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) { | ||
| 74 | + return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 72 | public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { | 78 | public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { |
| 73 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); | 79 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); |
| 74 | } | 80 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
0 → 100644
| 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"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> | ||
| 4 | + <select id="selectCountByIp" resultType="java.lang.Integer"> | ||
| 5 | + SELECT COUNT(1) | ||
| 6 | + FROM infra_api_access_log | ||
| 7 | + WHERE deleted = FALSE | ||
| 8 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 9 | + GROUP BY user_ip | ||
| 10 | + </select> | ||
| 11 | + | ||
| 12 | + <select id="selectCountByUserId" resultType="java.lang.Integer"> | ||
| 13 | + SELECT COUNT(1) | ||
| 14 | + FROM infra_api_access_log | ||
| 15 | + WHERE user_id != 0 | ||
| 16 | + AND deleted = FALSE | ||
| 17 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 18 | + GROUP BY user_id | ||
| 19 | + </select> | ||
| 20 | +</mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml
0 → 100644
| 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"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper"> | ||
| 4 | + | ||
| 5 | + <select id="selectSummaryListByAreaId" | ||
| 6 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | ||
| 7 | + SELECT area_id, COUNT(1) AS userCount | ||
| 8 | + FROM member_user | ||
| 9 | + WHERE deleted = FALSE | ||
| 10 | + GROUP BY area_id | ||
| 11 | + ORDER BY userCount DESC | ||
| 12 | + </select> | ||
| 13 | + | ||
| 14 | + <select id="selectSummaryListBySex" | ||
| 15 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO"> | ||
| 16 | + SELECT sex, COUNT(1) AS userCount | ||
| 17 | + FROM member_user | ||
| 18 | + WHERE deleted = FALSE | ||
| 19 | + GROUP BY sex | ||
| 20 | + ORDER BY userCount DESC | ||
| 21 | + </select> | ||
| 22 | + | ||
| 23 | + <select id="selectUserCount" resultType="java.lang.Integer"> | ||
| 24 | + SELECT COUNT(1) | ||
| 25 | + FROM member_user | ||
| 26 | + WHERE deleted = FALSE | ||
| 27 | + <if test="beginTime != null"> | ||
| 28 | + AND create_time >= #{beginTime} | ||
| 29 | + </if> | ||
| 30 | + <if test="endTime != null"> | ||
| 31 | + AND create_time <= #{endTime} | ||
| 32 | + </if> | ||
| 33 | + </select> | ||
| 34 | +</mapper> | ||
| 0 | \ No newline at end of file | 35 | \ No newline at end of file |
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 | - <select id="selectSummaryByPayTimeBetween" | ||
| 5 | - resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO"> | ||
| 6 | - SELECT COUNT(1) AS orderPayCount, | ||
| 7 | - SUM(pay_price) AS orderPayPrice, | 4 | + <select id="selectSummaryListByAreaId" |
| 5 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | ||
| 6 | + SELECT receiver_area_id AS areaId, | ||
| 8 | (SELECT COUNT(1) | 7 | (SELECT COUNT(1) |
| 9 | - FROM trade_order | ||
| 10 | - WHERE deleted = FALSE | ||
| 11 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS orderPayPrice | 8 | + FROM trade_order AS s |
| 9 | + WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount, | ||
| 10 | + (SELECT COUNT(1) | ||
| 11 | + FROM trade_order AS s | ||
| 12 | + WHERE s.receiver_area_id = m.receiver_area_id | ||
| 13 | + AND s.pay_status = TRUE | ||
| 14 | + AND s.deleted = FALSE) AS orderPayCount, | ||
| 15 | + (SELECT SUM(s.pay_price) | ||
| 16 | + FROM trade_order AS s | ||
| 17 | + WHERE s.receiver_area_id = m.receiver_area_id | ||
| 18 | + AND s.pay_status = TRUE | ||
| 19 | + AND s.deleted = FALSE) AS orderPayPrice | ||
| 20 | + FROM trade_order m | ||
| 21 | + WHERE deleted = FALSE | ||
| 22 | + GROUP BY receiver_area_id | ||
| 23 | + </select> | ||
| 24 | + | ||
| 25 | + <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> | ||
| 26 | + SELECT COUNT(1) | ||
| 27 | + FROM trade_order | ||
| 28 | + WHERE deleted = FALSE | ||
| 29 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 30 | + GROUP BY user_id | ||
| 31 | + </select> | ||
| 32 | + | ||
| 33 | + <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> | ||
| 34 | + SELECT COUNT(1) | ||
| 12 | FROM trade_order | 35 | FROM trade_order |
| 13 | WHERE deleted = FALSE | 36 | WHERE deleted = FALSE |
| 37 | + AND pay_status = TRUE | ||
| 14 | AND pay_time BETWEEN #{beginTime} AND #{endTime} | 38 | AND pay_time BETWEEN #{beginTime} AND #{endTime} |
| 39 | + GROUP BY user_id | ||
| 40 | + </select> | ||
| 41 | + | ||
| 42 | + <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> | ||
| 43 | + SELECT COUNT(1) | ||
| 44 | + FROM trade_order | ||
| 45 | + WHERE deleted = FALSE | ||
| 46 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 47 | + </select> | ||
| 48 | + | ||
| 49 | + <select id="selectCountByPayTimeBetween" resultType="java.lang.Integer"> | ||
| 50 | + SELECT COUNT(1) | ||
| 51 | + FROM trade_order | ||
| 52 | + WHERE pay_status = TRUE | ||
| 53 | + AND deleted = FALSE | ||
| 54 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 55 | + </select> | ||
| 56 | + | ||
| 57 | + <select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer"> | ||
| 58 | + SELECT SUM(pay_price) | ||
| 59 | + FROM trade_order AS s | ||
| 60 | + WHERE s.pay_status = TRUE | ||
| 61 | + AND deleted = FALSE | ||
| 62 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | ||
| 15 | </select> | 63 | </select> |
| 16 | </mapper> | 64 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.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.TradeStatisticsMapper"> | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper"> |
| 4 | - | ||
| 5 | <select id="selectByTimeBetween" | 4 | <select id="selectByTimeBetween" |
| 6 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> | 5 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 7 | SELECT | 6 | SELECT |
| @@ -37,4 +36,16 @@ | @@ -37,4 +36,16 @@ | ||
| 37 | GROUP BY date | 36 | GROUP BY date |
| 38 | </select> | 37 | </select> |
| 39 | 38 | ||
| 39 | + <select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer"> | ||
| 40 | + SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | ||
| 41 | + SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice | ||
| 42 | + FROM trade_statistics | ||
| 43 | + WHERE deleted = FALSE | ||
| 44 | + <if test="beginTime != null"> | ||
| 45 | + AND time >= #{beginTime} | ||
| 46 | + </if> | ||
| 47 | + <if test="endTime != null"> | ||
| 48 | + AND time <= #{endTime} | ||
| 49 | + </if> | ||
| 50 | + </select> | ||
| 40 | </mapper> | 51 | </mapper> |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/PayWalletStatisticsMapper.xml renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/resources/pay/PayWalletStatisticsMapper.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.PayWalletStatisticsMapper"> | 3 | +<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper"> |
| 4 | <select id="selectRechargeSummaryByPayTimeBetween" | 4 | <select id="selectRechargeSummaryByPayTimeBetween" |
| 5 | resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO"> | 5 | resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO"> |
| 6 | SELECT COUNT(1) AS rechargePayCount, | 6 | SELECT COUNT(1) AS rechargePayCount, |
| @@ -28,4 +28,20 @@ | @@ -28,4 +28,20 @@ | ||
| 28 | AND deleted = FALSE | 28 | AND deleted = FALSE |
| 29 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 29 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 30 | </select> | 30 | </select> |
| 31 | + | ||
| 32 | + <select id="selectRechargeSummaryGroupByWalletId" | ||
| 33 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO"> | ||
| 34 | + SELECT COUNT(1) AS rechargeUserCount, | ||
| 35 | + SUM(pay_price) AS rechargePrice | ||
| 36 | + FROM pay_wallet_recharge | ||
| 37 | + WHERE pay_status = #{payStatus} | ||
| 38 | + AND deleted = FALSE | ||
| 39 | + <if test="beginTime != null"> | ||
| 40 | + AND pay_time >= #{beginTime} | ||
| 41 | + </if> | ||
| 42 | + <if test="endTime != null"> | ||
| 43 | + AND pay_time <= #{endTime} | ||
| 44 | + </if> | ||
| 45 | + GROUP BY wallet_id | ||
| 46 | + </select> | ||
| 31 | </mapper> | 47 | </mapper> |
yudao-server/src/main/resources/application-local.yaml
| @@ -167,6 +167,7 @@ logging: | @@ -167,6 +167,7 @@ logging: | ||
| 167 | cn.iocoder.yudao.module.member.dal.mysql: debug | 167 | cn.iocoder.yudao.module.member.dal.mysql: debug |
| 168 | cn.iocoder.yudao.module.trade.dal.mysql: debug | 168 | cn.iocoder.yudao.module.trade.dal.mysql: debug |
| 169 | cn.iocoder.yudao.module.promotion.dal.mysql: debug | 169 | cn.iocoder.yudao.module.promotion.dal.mysql: debug |
| 170 | + cn.iocoder.yudao.module.statistics.dal.mysql: debug | ||
| 170 | 171 | ||
| 171 | debug: false | 172 | debug: false |
| 172 | 173 |