Commit 704087ce861abd5b940e3ae35891130692cc4866
Merge branch 'feature/mall_product' of https://gitee.com/CrazyWorld/ruoyi-vue-pr…
…o into feature/mall_product # Conflicts: # yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java
Showing
70 changed files
with
1150 additions
and
319 deletions
sql/mysql/statistics.sql
| ... | ... | @@ -28,16 +28,22 @@ CREATE INDEX trade_statistics_time_index |
| 28 | 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 | 32 | VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', ''); |
| 33 | 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 | 37 | SELECT @parentId := LAST_INSERT_ID(); |
| 37 | --- 按钮 | |
| 38 | 38 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 39 | 39 | VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0); |
| 40 | 40 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 41 | 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 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.CollectionUtil; |
| 5 | +import cn.hutool.core.util.ArrayUtil; | |
| 5 | 6 | import com.google.common.collect.ImmutableMap; |
| 6 | 7 | |
| 7 | 8 | import java.util.*; |
| ... | ... | @@ -50,6 +51,13 @@ public class CollectionUtils { |
| 50 | 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 | 61 | public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) { |
| 54 | 62 | if (CollUtil.isEmpty(from)) { |
| 55 | 63 | return new ArrayList<>(); |
| ... | ... | @@ -169,8 +177,8 @@ public class CollectionUtils { |
| 169 | 177 | /** |
| 170 | 178 | * 对比老、新两个列表,找出新增、修改、删除的数据 |
| 171 | 179 | * |
| 172 | - * @param oldList 老列表 | |
| 173 | - * @param newList 新列表 | |
| 180 | + * @param oldList 老列表 | |
| 181 | + * @param newList 新列表 | |
| 174 | 182 | * @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同 |
| 175 | 183 | * 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据 |
| 176 | 184 | * @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 | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 9 | 9 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 10 | +import lombok.NonNull; | |
| 10 | 11 | import lombok.extern.slf4j.Slf4j; |
| 11 | 12 | |
| 12 | 13 | import java.util.ArrayList; |
| 13 | 14 | import java.util.HashMap; |
| 14 | 15 | import java.util.List; |
| 15 | 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 | 112 | // “递归”父节点 |
| 109 | 113 | area = area.getParent(); |
| 110 | 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 | 116 | break; |
| 113 | 117 | } |
| 114 | 118 | sb.insert(0, separator); |
| ... | ... | @@ -116,4 +120,35 @@ public class AreaUtils { |
| 116 | 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 | 59 | <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> |
| 60 | 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 | 67 | <!-- Web 相关 --> |
| 63 | 68 | <dependency> |
| 64 | 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 | 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 | 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 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | 9 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | 10 | import lombok.extern.slf4j.Slf4j; |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 12 | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | 13 | import org.springframework.web.bind.annotation.GetMapping; |
| 14 | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 15 | 15 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | |
| 17 | +import javax.annotation.Resource; | |
| 17 | 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 | 23 | @Tag(name = "管理后台 - 会员统计") |
| 20 | 24 | @RestController |
| 21 | 25 | @RequestMapping("/statistics/member") |
| ... | ... | @@ -23,36 +27,47 @@ import java.util.List; |
| 23 | 27 | @Slf4j |
| 24 | 28 | public class MemberStatisticsController { |
| 25 | 29 | |
| 26 | - // TODO @疯狂:一个类似 getTradeTrendSummaryComparison 的接口 | |
| 27 | - // TODO @疯狂:一个类似 getTradeStatisticsList 的接口 | |
| 30 | + @Resource | |
| 31 | + private MemberStatisticsService memberStatisticsService; | |
| 28 | 32 | |
| 29 | 33 | @GetMapping("/summary") |
| 30 | 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 | 48 | @GetMapping("/get-area-statistics-list") |
| 37 | 49 | @Operation(summary = "按照省份,获得会员统计列表") |
| 50 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 38 | 51 | public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() { |
| 39 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 40 | - return null; | |
| 52 | + return success(memberStatisticsService.getMemberAreaStatisticsList()); | |
| 41 | 53 | } |
| 42 | 54 | |
| 43 | 55 | @GetMapping("/get-sex-statistics-list") |
| 44 | 56 | @Operation(summary = "按照性别,获得会员统计列表") |
| 57 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 45 | 58 | public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() { |
| 46 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 47 | - return null; | |
| 59 | + return success(memberStatisticsService.getMemberSexStatisticsList()); | |
| 48 | 60 | } |
| 49 | 61 | |
| 50 | 62 | @GetMapping("/get-terminal-statistics-list") |
| 51 | 63 | @Operation(summary = "按照终端,获得会员统计列表") |
| 64 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 52 | 65 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { |
| 53 | - // TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化 | |
| 54 | 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 | 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | 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 | 15 | |
| 16 | 16 | @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 17 | 17 | private Integer rechargePrice; |
| 18 | + | |
| 18 | 19 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | 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 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -@Schema(description = "管理后台 - 终端性别统计 Response VO") | |
| 6 | +@Schema(description = "管理后台 - 会员终端统计 Response VO") | |
| 7 | 7 | @Data |
| 8 | 8 | public class MemberTerminalStatisticsRespVO { |
| 9 | 9 | |
| ... | ... | @@ -13,11 +13,4 @@ public class MemberTerminalStatisticsRespVO { |
| 13 | 13 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | 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/convert/trade/TradeStatisticsConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.convert.trade; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 3 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 4 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; |
| 5 | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 6 | 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; |
| 7 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 8 | 8 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 9 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | |
| 9 | 10 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 10 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 11 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 11 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 12 | 12 | import org.mapstruct.Mapper; |
| 13 | 13 | import org.mapstruct.factory.Mappers; |
| 14 | 14 | |
| ... | ... | @@ -46,8 +46,8 @@ public interface TradeStatisticsConvert { |
| 46 | 46 | |
| 47 | 47 | List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list); |
| 48 | 48 | |
| 49 | - TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespDTO orderSummary, | |
| 50 | - AfterSaleSummaryRespDTO afterSaleSummary, Integer brokerageSettlementPrice, | |
| 51 | - WalletSummaryRespDTO walletSummary); | |
| 49 | + TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespBO orderSummary, | |
| 50 | + AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, | |
| 51 | + WalletSummaryRespBO walletSummary); | |
| 52 | 52 | |
| 53 | 53 | } | ... | ... |
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/pay/PayWalletStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.pay; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | |
| 5 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | +import org.apache.ibatis.annotations.Param; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 交易统计 Mapper | |
| 14 | + * | |
| 15 | + * @author owen | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | |
| 19 | + | |
| 20 | + WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 21 | + @Param("endTime") LocalDateTime endTime, | |
| 22 | + @Param("payStatus") Boolean payStatus); | |
| 23 | + | |
| 24 | + WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 25 | + @Param("endTime") LocalDateTime endTime, | |
| 26 | + @Param("refundStatus") Integer refundStatus); | |
| 27 | + | |
| 28 | + Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 29 | + @Param("endTime") LocalDateTime endTime, | |
| 30 | + @Param("bizType") Integer bizType); | |
| 31 | + | |
| 32 | + MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, | |
| 33 | + @Param("endTime") LocalDateTime endTime, | |
| 34 | + @Param("payStatus") Boolean payStatus); | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | |
| 2 | + | |
| 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.trade.bo.AfterSaleSummaryRespBO; | |
| 6 | +import org.apache.ibatis.annotations.Mapper; | |
| 7 | +import org.apache.ibatis.annotations.Param; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 交易统计 Mapper | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | |
| 18 | + | |
| 19 | + AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 20 | + @Param("endTime") LocalDateTime endTime); | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | +import org.apache.ibatis.annotations.Param; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 交易统计 Mapper | |
| 12 | + * | |
| 13 | + * @author owen | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | |
| 17 | + | |
| 18 | + Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(@Param("bizType") Integer bizType, | |
| 19 | + @Param("status") Integer status, | |
| 20 | + @Param("beginTime") LocalDateTime beginTime, | |
| 21 | + @Param("endTime") LocalDateTime endTime); | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.dal.mysql.trade; | |
| 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.dal.dataobject.trade.TradeStatisticsDO; | |
| 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 TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | |
| 19 | + | |
| 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); | |
| 36 | + | |
| 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 | 30 | |
| 31 | 31 | List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 32 | 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/pay/PayWalletStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.pay; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | |
| 4 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 钱包统计 Service 接口 | |
| 10 | + * | |
| 11 | + * @author owen | |
| 12 | + */ | |
| 13 | +public interface PayWalletStatisticsService { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 获取钱包统计 | |
| 17 | + * | |
| 18 | + * @param beginTime 起始时间 | |
| 19 | + * @param endTime 截止时间 | |
| 20 | + * @return 钱包统计 | |
| 21 | + */ | |
| 22 | + WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 获取钱包充值统计 | |
| 26 | + * | |
| 27 | + * @param beginTime 起始时间 | |
| 28 | + * @param endTime 截止时间 | |
| 29 | + * @return 钱包充值统计 | |
| 30 | + */ | |
| 31 | + MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.pay; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | |
| 4 | +import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; | |
| 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; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | +import org.springframework.validation.annotation.Validated; | |
| 10 | + | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import java.time.LocalDateTime; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 钱包统计 Service 实现类 | |
| 16 | + * | |
| 17 | + * @author owen | |
| 18 | + */ | |
| 19 | +@Service | |
| 20 | +@Validated | |
| 21 | +public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsService { | |
| 22 | + | |
| 23 | + @Resource | |
| 24 | + private PayWalletStatisticsMapper payWalletStatisticsMapper; | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 28 | + WalletSummaryRespBO paySummary = payWalletStatisticsMapper.selectRechargeSummaryByPayTimeBetween( | |
| 29 | + beginTime, endTime, true); | |
| 30 | + WalletSummaryRespBO refundSummary = payWalletStatisticsMapper.selectRechargeSummaryByRefundTimeBetween( | |
| 31 | + beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); | |
| 32 | + Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( | |
| 33 | + beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); | |
| 34 | + | |
| 35 | + paySummary.setOrderWalletPayPrice(walletPayPrice); | |
| 36 | + paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount()); | |
| 37 | + paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); | |
| 38 | + | |
| 39 | + return paySummary; | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 44 | + return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); | |
| 45 | + } | |
| 46 | + | |
| 47 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 4 | + | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 售后统计 Service 接口 | |
| 9 | + * | |
| 10 | + * @author owen | |
| 11 | + */ | |
| 12 | +public interface AfterSaleStatisticsService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 获取售后单统计 | |
| 16 | + * | |
| 17 | + * @param beginTime 起始时间 | |
| 18 | + * @param endTime 截止时间 | |
| 19 | + * @return 售后统计结果 | |
| 20 | + */ | |
| 21 | + AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; | |
| 4 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.validation.annotation.Validated; | |
| 7 | + | |
| 8 | +import javax.annotation.Resource; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 售后统计 Service 实现类 | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@Service | |
| 17 | +@Validated | |
| 18 | +public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsService { | |
| 19 | + | |
| 20 | + @Resource | |
| 21 | + private AfterSaleStatisticsMapper afterSaleStatisticsMapper; | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 25 | + return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); | |
| 26 | + } | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import java.time.LocalDateTime; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 分销统计 Service 接口 | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +public interface BrokerageStatisticsService { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 获取已结算的佣金金额 | |
| 14 | + * | |
| 15 | + * @param beginTime 起始时间 | |
| 16 | + * @param endTime 截止时间 | |
| 17 | + * @return 已结算的佣金金额 | |
| 18 | + */ | |
| 19 | + Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; | |
| 4 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; | |
| 6 | +import org.springframework.stereotype.Service; | |
| 7 | +import org.springframework.validation.annotation.Validated; | |
| 8 | + | |
| 9 | +import javax.annotation.Resource; | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 分销统计 Service 实现类 | |
| 14 | + * | |
| 15 | + * @author owen | |
| 16 | + */ | |
| 17 | +@Service | |
| 18 | +@Validated | |
| 19 | +public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsService { | |
| 20 | + | |
| 21 | + @Resource | |
| 22 | + private BrokerageStatisticsMapper brokerageStatisticsMapper; | |
| 23 | + | |
| 24 | + @Override | |
| 25 | + public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 26 | + return brokerageStatisticsMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( | |
| 27 | + BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), | |
| 28 | + beginTime, endTime); | |
| 29 | + } | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | |
| 4 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 交易订单统计 Service 接口 | |
| 11 | + * | |
| 12 | + * @author owen | |
| 13 | + */ | |
| 14 | +public interface TradeOrderStatisticsService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 获取订单统计 | |
| 18 | + * | |
| 19 | + * @param beginTime 起始时间 | |
| 20 | + * @param endTime 截止时间 | |
| 21 | + * @return 订单统计结果 | |
| 22 | + */ | |
| 23 | + TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 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 | + | |
| 59 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | |
| 4 | +import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; | |
| 5 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | |
| 6 | +import org.springframework.stereotype.Service; | |
| 7 | +import org.springframework.validation.annotation.Validated; | |
| 8 | + | |
| 9 | +import javax.annotation.Resource; | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 交易订单统计 Service 实现类 | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Service | |
| 19 | +@Validated | |
| 20 | +public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsService { | |
| 21 | + | |
| 22 | + @Resource | |
| 23 | + private TradeOrderStatisticsMapper tradeOrderStatisticsMapper; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime 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); | |
| 51 | + } | |
| 52 | + | |
| 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 | 22 | TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison(); |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * 获得交易状况统计 | |
| 25 | + * 获得交易状况统计对照 | |
| 26 | 26 | * |
| 27 | 27 | * @return 统计数据对照 |
| 28 | 28 | */ |
| ... | ... | @@ -30,6 +30,13 @@ public interface TradeStatisticsService { |
| 30 | 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 | 42 | * @return 统计数据列表 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| ... | ... | @@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | -import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; | |
| 6 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 5 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | |
| 6 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 7 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; |
| 8 | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 9 | 9 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| ... | ... | @@ -11,11 +11,8 @@ import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 11 | 11 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 12 | 12 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; |
| 13 | 13 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 14 | -import cn.iocoder.yudao.module.trade.api.aftersale.TradeAfterSaleApi; | |
| 15 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 16 | -import cn.iocoder.yudao.module.trade.api.brokerage.TradeBrokerageApi; | |
| 17 | -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; | |
| 18 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 14 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 15 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; | |
| 19 | 16 | import org.springframework.stereotype.Service; |
| 20 | 17 | import org.springframework.util.StopWatch; |
| 21 | 18 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -37,18 +34,14 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 37 | 34 | @Resource |
| 38 | 35 | private TradeStatisticsMapper tradeStatisticsMapper; |
| 39 | 36 | |
| 40 | - // TODO @疯狂:统计逻辑,自己服务 mapper 去统计,不要调用其它服务 API; | |
| 41 | - // 主要的考虑点,其它服务是在线的业务,统计是离线业务,尽量不占用他们的 db 资源; | |
| 42 | - // 统计服务,从建议使用从库,或者从 mysql 抽取到单独的 clickhouse 或者其它的大数据组件; | |
| 43 | - | |
| 44 | 37 | @Resource |
| 45 | - private TradeOrderApi tradeOrderApi; | |
| 38 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | |
| 46 | 39 | @Resource |
| 47 | - private TradeAfterSaleApi tradeAfterSaleApi; | |
| 40 | + private AfterSaleStatisticsService afterSaleStatisticsService; | |
| 48 | 41 | @Resource |
| 49 | - private TradeBrokerageApi tradeBrokerageApi; | |
| 42 | + private BrokerageStatisticsService brokerageStatisticsService; | |
| 50 | 43 | @Resource |
| 51 | - private PayWalletApi payWalletApi; | |
| 44 | + private PayWalletStatisticsService payWalletStatisticsService; | |
| 52 | 45 | |
| 53 | 46 | @Override |
| 54 | 47 | public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { |
| ... | ... | @@ -77,6 +70,11 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 77 | 70 | } |
| 78 | 71 | |
| 79 | 72 | @Override |
| 73 | + public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 74 | + return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 80 | 78 | public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { |
| 81 | 79 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); |
| 82 | 80 | } |
| ... | ... | @@ -90,19 +88,19 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 90 | 88 | // 统计 |
| 91 | 89 | StopWatch stopWatch = new StopWatch("交易统计"); |
| 92 | 90 | stopWatch.start("统计订单"); |
| 93 | - TradeOrderSummaryRespDTO orderSummary = tradeOrderApi.getOrderSummary(beginTime, endTime); | |
| 91 | + TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); | |
| 94 | 92 | stopWatch.stop(); |
| 95 | 93 | |
| 96 | 94 | stopWatch.start("统计售后"); |
| 97 | - AfterSaleSummaryRespDTO afterSaleSummary = tradeAfterSaleApi.getAfterSaleSummary(beginTime, endTime); | |
| 95 | + AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); | |
| 98 | 96 | stopWatch.stop(); |
| 99 | 97 | |
| 100 | 98 | stopWatch.start("统计佣金"); |
| 101 | - Integer brokerageSettlementPrice = tradeBrokerageApi.getBrokerageSettlementPriceSummary(beginTime, endTime); | |
| 99 | + Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); | |
| 102 | 100 | stopWatch.stop(); |
| 103 | 101 | |
| 104 | 102 | stopWatch.start("统计充值"); |
| 105 | - WalletSummaryRespDTO walletSummary = payWalletApi.getWalletSummary(beginTime, endTime); | |
| 103 | + WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); | |
| 106 | 104 | stopWatch.stop(); |
| 107 | 105 | // 插入数据 |
| 108 | 106 | TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java
| 1 | -package cn.iocoder.yudao.module.trade.api.aftersale.dto; | |
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade.bo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| ... | ... | @@ -8,7 +8,7 @@ import lombok.Data; |
| 8 | 8 | * @author owen |
| 9 | 9 | */ |
| 10 | 10 | @Data |
| 11 | -public class AfterSaleSummaryRespDTO { | |
| 11 | +public class AfterSaleSummaryRespBO { | |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * 退款订单数 | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java
| 1 | -package cn.iocoder.yudao.module.trade.api.order.dto; | |
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade.bo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | - * 订单统计 Response DTO | |
| 6 | + * 订单统计 Response BO | |
| 7 | 7 | * |
| 8 | 8 | * @author owen |
| 9 | 9 | */ |
| 10 | 10 | @Data |
| 11 | -public class TradeOrderSummaryRespDTO { | |
| 11 | +public class TradeOrderSummaryRespBO { | |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * 创建订单数 |
| 15 | 15 | */ |
| 16 | - private Long orderCreateCount; | |
| 16 | + private Integer orderCreateCount; | |
| 17 | 17 | /** |
| 18 | 18 | * 支付订单商品数 |
| 19 | 19 | */ | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java
| 1 | -package cn.iocoder.yudao.module.pay.api.wallet.dto; | |
| 1 | +package cn.iocoder.yudao.module.statistics.service.trade.bo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| ... | ... | @@ -8,7 +8,7 @@ import lombok.Data; |
| 8 | 8 | * @author owen |
| 9 | 9 | */ |
| 10 | 10 | @Data |
| 11 | -public class WalletSummaryRespDTO { | |
| 11 | +public class WalletSummaryRespBO { | |
| 12 | 12 | /** |
| 13 | 13 | * 总支付金额(余额),单位:分 |
| 14 | 14 | */ | ... | ... |
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 | 35 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.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.pay.PayWalletStatisticsMapper"> | |
| 4 | + <select id="selectRechargeSummaryByPayTimeBetween" | |
| 5 | + resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO"> | |
| 6 | + SELECT COUNT(1) AS rechargePayCount, | |
| 7 | + SUM(pay_price) AS rechargePayPrice | |
| 8 | + FROM pay_wallet_recharge | |
| 9 | + WHERE pay_status = #{payStatus} | |
| 10 | + AND deleted = FALSE | |
| 11 | + AND pay_time BETWEEN #{beginTime} AND #{endTime} | |
| 12 | + </select> | |
| 13 | + | |
| 14 | + <select id="selectRechargeSummaryByRefundTimeBetween" | |
| 15 | + resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO"> | |
| 16 | + SELECT COUNT(1) AS rechargeRefundCount, | |
| 17 | + SUM(pay_price) AS rechargeRefundPrice | |
| 18 | + FROM pay_wallet_recharge | |
| 19 | + WHERE refund_status = #{refundStatus} | |
| 20 | + AND deleted = FALSE | |
| 21 | + AND refund_time BETWEEN #{beginTime} AND #{endTime} | |
| 22 | + </select> | |
| 23 | + | |
| 24 | + <select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer"> | |
| 25 | + SELECT SUM(price) | |
| 26 | + FROM pay_wallet_transaction | |
| 27 | + WHERE biz_type = #{bizType} | |
| 28 | + AND deleted = FALSE | |
| 29 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 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> | |
| 47 | +</mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.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.trade.AfterSaleStatisticsMapper"> | |
| 4 | + <select id="selectSummaryByRefundTimeBetween" | |
| 5 | + resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO"> | |
| 6 | + SELECT COUNT(1) AS afterSaleCount, | |
| 7 | + SUM(refund_price) AS afterSaleRefundPrice | |
| 8 | + FROM trade_after_sale | |
| 9 | + WHERE deleted = FALSE | |
| 10 | + AND refund_time BETWEEN #{beginTime} AND #{endTime} | |
| 11 | + </select> | |
| 12 | +</mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.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.trade.BrokerageStatisticsMapper"> | |
| 4 | + <select id="selectSummaryPriceByStatusAndUnfreezeTimeBetween" resultType="java.lang.Integer"> | |
| 5 | + SELECT SUM(price) | |
| 6 | + FROM trade_brokerage_record | |
| 7 | + WHERE biz_type = #{bizType} | |
| 8 | + AND status = #{status} | |
| 9 | + AND deleted = FALSE | |
| 10 | + AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} | |
| 11 | + </select> | |
| 12 | +</mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.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.trade.TradeOrderStatisticsMapper"> | |
| 4 | + <select id="selectSummaryListByAreaId" | |
| 5 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | |
| 6 | + SELECT receiver_area_id AS areaId, | |
| 7 | + (SELECT COUNT(1) | |
| 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) | |
| 35 | + FROM trade_order | |
| 36 | + WHERE deleted = FALSE | |
| 37 | + AND pay_status = TRUE | |
| 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} | |
| 63 | + </select> | |
| 64 | +</mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper"> |
| 4 | - | |
| 5 | 4 | <select id="selectByTimeBetween" |
| 6 | 5 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 7 | 6 | SELECT |
| ... | ... | @@ -37,4 +36,16 @@ |
| 37 | 36 | GROUP BY date |
| 38 | 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 | 51 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.aftersale; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 4 | - | |
| 5 | -import java.time.LocalDateTime; | |
| 6 | - | |
| 7 | 3 | /** |
| 8 | 4 | * 售后 API 接口 |
| 9 | 5 | * |
| ... | ... | @@ -11,13 +7,4 @@ import java.time.LocalDateTime; |
| 11 | 7 | */ |
| 12 | 8 | public interface TradeAfterSaleApi { |
| 13 | 9 | |
| 14 | - /** | |
| 15 | - * 获取售后单统计 | |
| 16 | - * | |
| 17 | - * @param beginTime 起始时间 | |
| 18 | - * @param endTime 截止时间 | |
| 19 | - * @return 售后统计结果 | |
| 20 | - */ | |
| 21 | - AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | - | |
| 23 | 10 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.brokerage; |
| 2 | 2 | |
| 3 | -import java.time.LocalDateTime; | |
| 4 | - | |
| 5 | 3 | /** |
| 6 | 4 | * 分销 API 接口 |
| 7 | 5 | * |
| ... | ... | @@ -9,13 +7,4 @@ import java.time.LocalDateTime; |
| 9 | 7 | */ |
| 10 | 8 | public interface TradeBrokerageApi { |
| 11 | 9 | |
| 12 | - /** | |
| 13 | - * 获取已结算的佣金金额 | |
| 14 | - * | |
| 15 | - * @param beginTime 起始时间 | |
| 16 | - * @param endTime 截止时间 | |
| 17 | - * @return 已结算的佣金金额 | |
| 18 | - */ | |
| 19 | - Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 20 | - | |
| 21 | 10 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; |
| 4 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 5 | 4 | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | 5 | import java.util.Collection; |
| 8 | 6 | import java.util.List; |
| 9 | 7 | |
| ... | ... | @@ -39,6 +37,16 @@ public interface TradeOrderApi { |
| 39 | 37 | */ |
| 40 | 38 | TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 41 | 39 | |
| 40 | + /** | |
| 41 | + * 更新拼团相关信息到订单 | |
| 42 | + * | |
| 43 | + * @param orderId 订单编号 | |
| 44 | + * @param activityId 拼团活动编号 | |
| 45 | + * @param combinationRecordId 拼团记录编号 | |
| 46 | + * @param headId 团长编号 | |
| 47 | + */ | |
| 48 | + void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); | |
| 49 | + | |
| 42 | 50 | // TODO 芋艿:需要优化下; |
| 43 | 51 | /** |
| 44 | 52 | * 取消支付订单 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.aftersale; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 4 | 3 | import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; |
| 5 | 4 | import org.springframework.stereotype.Service; |
| 6 | 5 | import org.springframework.validation.annotation.Validated; |
| 7 | 6 | |
| 8 | 7 | import javax.annotation.Resource; |
| 9 | -import java.time.LocalDateTime; | |
| 10 | 8 | |
| 11 | 9 | /** |
| 12 | 10 | * 售后 API 接口实现类 |
| ... | ... | @@ -20,9 +18,4 @@ public class TradeAfterSaleApiImpl implements TradeAfterSaleApi { |
| 20 | 18 | @Resource |
| 21 | 19 | private AfterSaleService afterSaleService; |
| 22 | 20 | |
| 23 | - @Override | |
| 24 | - public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 25 | - return afterSaleService.getAfterSaleSummary(beginTime, endTime); | |
| 26 | - } | |
| 27 | - | |
| 28 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java
| ... | ... | @@ -5,7 +5,6 @@ import org.springframework.stereotype.Service; |
| 5 | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | 6 | |
| 7 | 7 | import javax.annotation.Resource; |
| 8 | -import java.time.LocalDateTime; | |
| 9 | 8 | |
| 10 | 9 | /** |
| 11 | 10 | * 订单 API 接口实现类 |
| ... | ... | @@ -19,9 +18,4 @@ public class TradeBrokerageApiImpl implements TradeBrokerageApi { |
| 19 | 18 | @Resource |
| 20 | 19 | private BrokerageRecordService brokerageRecordService; |
| 21 | 20 | |
| 22 | - @Override | |
| 23 | - public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 24 | - return brokerageRecordService.getBrokerageSettlementPriceSummary(beginTime, endTime); | |
| 25 | - } | |
| 26 | - | |
| 27 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; |
| 4 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | |
| 6 | 6 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 7 | 7 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; |
| 8 | 8 | import org.springframework.stereotype.Service; |
| 9 | 9 | import org.springframework.validation.annotation.Validated; |
| 10 | 10 | |
| 11 | 11 | import javax.annotation.Resource; |
| 12 | -import java.time.LocalDateTime; | |
| 13 | 12 | import java.util.Collection; |
| 14 | 13 | import java.util.List; |
| 15 | 14 | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; | |
| 17 | + | |
| 16 | 18 | /** |
| 17 | 19 | * 订单 API 接口实现类 |
| 18 | 20 | * |
| ... | ... | @@ -43,6 +45,11 @@ public class TradeOrderApiImpl implements TradeOrderApi { |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | @Override |
| 48 | + public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) { | |
| 49 | + tradeOrderUpdateService.updateOrderCombinationInfo(orderId, activityId, combinationRecordId, headId); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 46 | 53 | public void cancelPaidOrder(Long userId, Long orderId) { |
| 47 | 54 | tradeOrderUpdateService.cancelPaidOrder(userId, orderId); |
| 48 | 55 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.bean.BeanUtil; | |
| 4 | -import cn.hutool.core.collection.CollUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 9 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 10 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 11 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; |
| 12 | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | -import com.github.yulichang.toolkit.MPJWrappers; | |
| 14 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 15 | 11 | |
| 16 | -import java.time.LocalDateTime; | |
| 17 | 12 | import java.util.Collection; |
| 18 | 13 | |
| 19 | 14 | @Mapper |
| ... | ... | @@ -53,12 +48,4 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> { |
| 53 | 48 | .in(AfterSaleDO::getStatus, statuses)); |
| 54 | 49 | } |
| 55 | 50 | |
| 56 | - default AfterSaleSummaryRespDTO selectSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 57 | - return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<AfterSaleDO>lambdaJoin() | |
| 58 | - .selectCount(AfterSaleDO::getId, AfterSaleSummaryRespDTO::getAfterSaleCount) | |
| 59 | - .selectSum(AfterSaleDO::getRefundPrice, AfterSaleSummaryRespDTO::getAfterSaleRefundPrice) | |
| 60 | - .between(AfterSaleDO::getRefundTime, beginTime, endTime)), 0), | |
| 61 | - AfterSaleSummaryRespDTO.class); | |
| 62 | - } | |
| 63 | - | |
| 64 | 51 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | -import cn.hutool.core.collection.CollUtil; | |
| 5 | -import cn.hutool.core.convert.Convert; | |
| 6 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| ... | ... | @@ -111,13 +109,4 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> { |
| 111 | 109 | @Param("beginTime") LocalDateTime beginTime, |
| 112 | 110 | @Param("endTime") LocalDateTime endTime); |
| 113 | 111 | |
| 114 | - default Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(Integer bizType, Integer status, | |
| 115 | - LocalDateTime beginTime, LocalDateTime endTime) { | |
| 116 | - return Convert.toInt(CollUtil.getFirst(selectObjs(MPJWrappers.<BrokerageRecordDO>lambdaJoin() | |
| 117 | - .selectSum(BrokerageRecordDO::getPrice) | |
| 118 | - .eq(BrokerageRecordDO::getBizType, bizType) | |
| 119 | - .eq(BrokerageRecordDO::getStatus, status) | |
| 120 | - .between(BrokerageRecordDO::getUnfreezeTime, beginTime, endTime))), 0); | |
| 121 | - } | |
| 122 | - | |
| 123 | 112 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.order; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.bean.BeanUtil; | |
| 4 | -import cn.hutool.core.collection.CollUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 9 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 10 | 7 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 11 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 12 | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | -import com.github.yulichang.toolkit.MPJWrappers; | |
| 14 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 15 | 11 | |
| 16 | 12 | import java.time.LocalDateTime; |
| ... | ... | @@ -93,19 +89,6 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 93 | 89 | .eq(TradeOrderDO::getSeckillActivityId, seckillActivityId)); |
| 94 | 90 | } |
| 95 | 91 | |
| 96 | - default TradeOrderSummaryRespDTO selectSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 97 | - return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<TradeOrderDO>lambdaJoin() | |
| 98 | - .selectCount(TradeOrderDO::getId, TradeOrderSummaryRespDTO::getOrderPayCount) | |
| 99 | - .selectSum(TradeOrderDO::getPayPrice, TradeOrderSummaryRespDTO::getOrderPayPrice) | |
| 100 | - .between(TradeOrderDO::getPayTime, beginTime, endTime)), 0), | |
| 101 | - TradeOrderSummaryRespDTO.class); | |
| 102 | - } | |
| 103 | - | |
| 104 | - default Long selectCountByCreateTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 105 | - return selectCount(new LambdaQueryWrapperX<TradeOrderDO>() | |
| 106 | - .between(TradeOrderDO::getCreateTime, beginTime, endTime)); | |
| 107 | - } | |
| 108 | - | |
| 109 | 92 | default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { |
| 110 | 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); |
| 111 | 94 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.service.aftersale; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 6 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; |
| ... | ... | @@ -10,8 +9,6 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCre |
| 10 | 9 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; |
| 11 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; |
| 12 | 11 | |
| 13 | -import java.time.LocalDateTime; | |
| 14 | - | |
| 15 | 12 | /** |
| 16 | 13 | * 售后订单 Service 接口 |
| 17 | 14 | * |
| ... | ... | @@ -127,13 +124,4 @@ public interface AfterSaleService { |
| 127 | 124 | */ |
| 128 | 125 | Long getApplyingAfterSaleCount(Long userId); |
| 129 | 126 | |
| 130 | - /** | |
| 131 | - * 获取售后单统计 | |
| 132 | - * | |
| 133 | - * @param beginTime 起始时间 | |
| 134 | - * @param endTime 截止时间 | |
| 135 | - * @return 售后统计结果 | |
| 136 | - */ | |
| 137 | - AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 138 | - | |
| 139 | 127 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 10 | -import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 11 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; |
| 12 | 11 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 13 | 12 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; |
| ... | ... | @@ -411,9 +410,4 @@ public class AfterSaleServiceImpl implements AfterSaleService { |
| 411 | 410 | return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES); |
| 412 | 411 | } |
| 413 | 412 | |
| 414 | - @Override | |
| 415 | - public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 416 | - return tradeAfterSaleMapper.selectSummaryByRefundTimeBetween(beginTime,endTime); | |
| 417 | - } | |
| 418 | - | |
| 419 | 413 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java
| ... | ... | @@ -156,13 +156,4 @@ public interface BrokerageRecordService { |
| 156 | 156 | */ |
| 157 | 157 | AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); |
| 158 | 158 | |
| 159 | - /** | |
| 160 | - * 获取已结算的佣金金额 | |
| 161 | - * | |
| 162 | - * @param beginTime 起始时间 | |
| 163 | - * @param endTime 截止时间 | |
| 164 | - * @return 已结算的佣金金额 | |
| 165 | - */ | |
| 166 | - Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 167 | - | |
| 168 | 159 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java
| ... | ... | @@ -356,13 +356,6 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 356 | 356 | return respVO; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - @Override | |
| 360 | - public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 361 | - return brokerageRecordMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( | |
| 362 | - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), | |
| 363 | - beginTime, endTime); | |
| 364 | - } | |
| 365 | - | |
| 366 | 359 | /** |
| 367 | 360 | * 获得自身的代理对象,解决 AOP 生效问题 |
| 368 | 361 | * | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 6 | 5 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; |
| 10 | 9 | |
| 11 | -import java.time.LocalDateTime; | |
| 12 | 10 | import java.util.Collection; |
| 13 | 11 | import java.util.List; |
| 14 | 12 | |
| ... | ... | @@ -148,13 +146,4 @@ public interface TradeOrderQueryService { |
| 148 | 146 | */ |
| 149 | 147 | List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds); |
| 150 | 148 | |
| 151 | - /** | |
| 152 | - * 获取订单统计 | |
| 153 | - * | |
| 154 | - * @param beginTime 起始时间 | |
| 155 | - * @param endTime 截止时间 | |
| 156 | - * @return 订单统计结果 | |
| 157 | - */ | |
| 158 | - TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 159 | - | |
| 160 | 149 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.hutool.extra.spring.SpringUtil; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 9 | 9 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 10 | -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 11 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 12 | 11 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 13 | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; |
| ... | ... | @@ -25,7 +24,6 @@ import org.springframework.cache.annotation.Cacheable; |
| 25 | 24 | import org.springframework.stereotype.Service; |
| 26 | 25 | |
| 27 | 26 | import javax.annotation.Resource; |
| 28 | -import java.time.LocalDateTime; | |
| 29 | 27 | import java.util.*; |
| 30 | 28 | |
| 31 | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -188,13 +186,6 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { |
| 188 | 186 | .setPhone(receiverMobile)); |
| 189 | 187 | } |
| 190 | 188 | |
| 191 | - @Override | |
| 192 | - public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 193 | - TradeOrderSummaryRespDTO dto = tradeOrderMapper.selectSummaryByPayTimeBetween(beginTime, endTime); | |
| 194 | - dto.setOrderCreateCount(tradeOrderMapper.selectCountByCreateTimeBetween(beginTime, endTime)); | |
| 195 | - return dto; | |
| 196 | - } | |
| 197 | - | |
| 198 | 189 | |
| 199 | 190 | // =================== Order Item =================== |
| 200 | 191 | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.api.wallet; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | - | |
| 5 | -import java.time.LocalDateTime; | |
| 6 | - | |
| 7 | 3 | /** |
| 8 | 4 | * 钱包 API 接口 |
| 9 | 5 | * |
| ... | ... | @@ -11,13 +7,4 @@ import java.time.LocalDateTime; |
| 11 | 7 | */ |
| 12 | 8 | public interface PayWalletApi { |
| 13 | 9 | |
| 14 | - /** | |
| 15 | - * 获取钱包统计 | |
| 16 | - * | |
| 17 | - * @param beginTime 起始时间 | |
| 18 | - * @param endTime 截止时间 | |
| 19 | - * @return 钱包统计 | |
| 20 | - */ | |
| 21 | - WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | - | |
| 23 | 10 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.api.wallet; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | -import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | |
| 5 | 3 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; |
| 6 | 4 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; |
| 7 | 5 | import org.springframework.stereotype.Service; |
| 8 | 6 | import org.springframework.validation.annotation.Validated; |
| 9 | 7 | |
| 10 | 8 | import javax.annotation.Resource; |
| 11 | -import java.time.LocalDateTime; | |
| 12 | 9 | |
| 13 | 10 | /** |
| 14 | 11 | * 钱包 API 接口实现类 |
| ... | ... | @@ -24,11 +21,4 @@ public class PayWalletApiImpl implements PayWalletApi { |
| 24 | 21 | @Resource |
| 25 | 22 | private PayWalletTransactionService payWalletTransactionService; |
| 26 | 23 | |
| 27 | - @Override | |
| 28 | - public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | - WalletSummaryRespDTO walletSummary = payWalletRechargeService.getWalletSummary(beginTime, endTime); | |
| 30 | - walletSummary.setOrderWalletPayPrice(payWalletTransactionService.getPriceSummary(PayWalletBizTypeEnum.PAYMENT, beginTime, endTime)); | |
| 31 | - return walletSummary; | |
| 32 | - } | |
| 33 | - | |
| 34 | 24 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.dal.mysql.wallet; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.bean.BeanUtil; | |
| 4 | -import cn.hutool.core.collection.CollUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 8 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; |
| 9 | -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; | |
| 10 | -import com.github.yulichang.toolkit.MPJWrappers; | |
| 11 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 7 | |
| 13 | -import java.time.LocalDateTime; | |
| 14 | - | |
| 15 | 8 | @Mapper |
| 16 | 9 | public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> { |
| 17 | 10 | |
| ... | ... | @@ -25,24 +18,6 @@ public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO |
| 25 | 18 | .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); |
| 26 | 19 | } |
| 27 | 20 | |
| 28 | - default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | - return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin() | |
| 30 | - .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargePayCount) | |
| 31 | - .selectSum(PayWalletRechargeDO::getPayPrice, WalletSummaryRespDTO::getRechargePayPrice) | |
| 32 | - .eq(PayWalletRechargeDO::getPayStatus, true) | |
| 33 | - .between(PayWalletRechargeDO::getPayTime, beginTime, endTime)), 0), | |
| 34 | - WalletSummaryRespDTO.class); | |
| 35 | - } | |
| 36 | - | |
| 37 | - default WalletSummaryRespDTO selectRechargeSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 38 | - return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin() | |
| 39 | - .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargeRefundCount) | |
| 40 | - .selectSum(PayWalletRechargeDO::getRefundPayPrice, WalletSummaryRespDTO::getRechargeRefundPrice) | |
| 41 | - .eq(PayWalletRechargeDO::getRefundStatus, PayRefundStatusEnum.SUCCESS.getStatus()) | |
| 42 | - .between(PayWalletRechargeDO::getRefundTime, beginTime, endTime)), 0), | |
| 43 | - WalletSummaryRespDTO.class); | |
| 44 | - } | |
| 45 | - | |
| 46 | 21 | } |
| 47 | 22 | |
| 48 | 23 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java
| ... | ... | @@ -6,12 +6,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 9 | -import com.github.yulichang.toolkit.MPJWrappers; | |
| 10 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 10 | |
| 12 | -import java.time.LocalDateTime; | |
| 13 | 11 | import java.util.Objects; |
| 14 | -import java.util.Optional; | |
| 15 | 12 | |
| 16 | 13 | @Mapper |
| 17 | 14 | public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> { |
| ... | ... | @@ -38,15 +35,6 @@ public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransac |
| 38 | 35 | PayWalletTransactionDO::getBizType, bizType); |
| 39 | 36 | } |
| 40 | 37 | |
| 41 | - default Integer selectSummaryByBizTypeAndCreateTimeBetween(Integer type, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 42 | - return Optional.ofNullable(selectOne(MPJWrappers.<PayWalletTransactionDO>lambdaJoin() | |
| 43 | - .selectSum(PayWalletTransactionDO::getPrice) | |
| 44 | - .eq(PayWalletTransactionDO::getBizType, type) | |
| 45 | - .between(PayWalletTransactionDO::getCreateTime, beginTime, endTime))) | |
| 46 | - .map(PayWalletTransactionDO::getPrice) | |
| 47 | - .orElse(0); | |
| 48 | - } | |
| 49 | - | |
| 50 | 38 | } |
| 51 | 39 | |
| 52 | 40 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | 3 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; |
| 5 | 4 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; |
| 6 | 5 | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | 6 | /** |
| 10 | 7 | * 钱包充值 Service 接口 |
| 11 | 8 | * |
| ... | ... | @@ -16,8 +13,8 @@ public interface PayWalletRechargeService { |
| 16 | 13 | /** |
| 17 | 14 | * 创建钱包充值记录(发起充值) |
| 18 | 15 | * |
| 19 | - * @param userId 用户 id | |
| 20 | - * @param userType 用户类型 | |
| 16 | + * @param userId 用户 id | |
| 17 | + * @param userType 用户类型 | |
| 21 | 18 | * @param createReqVO 钱包充值请求 VO |
| 22 | 19 | * @return 钱包充值记录 |
| 23 | 20 | */ |
| ... | ... | @@ -27,32 +24,25 @@ public interface PayWalletRechargeService { |
| 27 | 24 | /** |
| 28 | 25 | * 更新钱包充值成功 |
| 29 | 26 | * |
| 30 | - * @param id 钱包充值记录 id | |
| 27 | + * @param id 钱包充值记录 id | |
| 31 | 28 | * @param payOrderId 支付订单 id |
| 32 | 29 | */ |
| 33 | 30 | void updateWalletRechargerPaid(Long id, Long payOrderId); |
| 34 | 31 | |
| 35 | 32 | /** |
| 36 | 33 | * 发起钱包充值退款 |
| 37 | - * @param id 钱包充值编号 | |
| 34 | + * | |
| 35 | + * @param id 钱包充值编号 | |
| 38 | 36 | * @param userIp 用户 ip 地址 |
| 39 | 37 | */ |
| 40 | 38 | void refundWalletRecharge(Long id, String userIp); |
| 41 | 39 | |
| 42 | 40 | /** |
| 43 | 41 | * 更新钱包充值记录为已退款 |
| 44 | - * @param id 钱包充值 id | |
| 42 | + * | |
| 43 | + * @param id 钱包充值 id | |
| 45 | 44 | * @param payRefundId 退款单id |
| 46 | 45 | */ |
| 47 | 46 | void updateWalletRechargeRefunded(Long id, Long payRefundId); |
| 48 | 47 | |
| 49 | - /** | |
| 50 | - * 获取钱包统计 | |
| 51 | - * | |
| 52 | - * @param beginTime 起始时间 | |
| 53 | - * @param endTime 截止时间 | |
| 54 | - * @return 钱包统计 | |
| 55 | - */ | |
| 56 | - WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 57 | - | |
| 58 | 48 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.hutool.core.lang.Assert; |
| 4 | 4 | import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 7 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 8 | 7 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; |
| 10 | 9 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; |
| ... | ... | @@ -258,15 +257,4 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 258 | 257 | return payOrder; |
| 259 | 258 | } |
| 260 | 259 | |
| 261 | - @Override | |
| 262 | - public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 263 | - WalletSummaryRespDTO paySummary = walletRechargeMapper.selectRechargeSummaryByPayTimeBetween(beginTime, endTime); | |
| 264 | - WalletSummaryRespDTO refundSummary = walletRechargeMapper.selectRechargeSummaryByRefundTimeBetween(beginTime, endTime); | |
| 265 | - | |
| 266 | - paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount()); | |
| 267 | - paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); | |
| 268 | - | |
| 269 | - return paySummary; | |
| 270 | - } | |
| 271 | - | |
| 272 | 260 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | 3 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 5 | 4 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | 5 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 7 | 6 | |
| 8 | -import java.time.LocalDateTime; | |
| 9 | - | |
| 10 | 7 | /** |
| 11 | 8 | * 钱包 Service 接口 |
| 12 | 9 | * | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | -import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| 6 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; |
| 7 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 7 | 7 | import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.Valid; |
| 10 | -import java.time.LocalDateTime; | |
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * 钱包余额流水 Service 接口 |
| ... | ... | @@ -50,14 +49,4 @@ public interface PayWalletTransactionService { |
| 50 | 49 | */ |
| 51 | 50 | PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); |
| 52 | 51 | |
| 53 | - /** | |
| 54 | - * 获取支付金额合计 | |
| 55 | - * | |
| 56 | - * @param bizType 业务类型 | |
| 57 | - * @param beginTime 开始时间 | |
| 58 | - * @param endTime 结束时间 | |
| 59 | - * @return 支付金额合计 | |
| 60 | - */ | |
| 61 | - Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 62 | - | |
| 63 | 52 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
| ... | ... | @@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j; |
| 13 | 13 | import org.springframework.stereotype.Service; |
| 14 | 14 | |
| 15 | 15 | import javax.annotation.Resource; |
| 16 | -import java.time.LocalDateTime; | |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * 钱包流水 Service 实现类 |
| ... | ... | @@ -61,9 +60,4 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ |
| 61 | 60 | return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | - @Override | |
| 65 | - public Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 66 | - return payWalletTransactionMapper.selectSummaryByBizTypeAndCreateTimeBetween(bizType.getType(), beginTime, endTime); | |
| 67 | - } | |
| 68 | - | |
| 69 | 63 | } | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -167,6 +167,7 @@ logging: |
| 167 | 167 | cn.iocoder.yudao.module.member.dal.mysql: debug |
| 168 | 168 | cn.iocoder.yudao.module.trade.dal.mysql: debug |
| 169 | 169 | cn.iocoder.yudao.module.promotion.dal.mysql: debug |
| 170 | + cn.iocoder.yudao.module.statistics.dal.mysql: debug | |
| 170 | 171 | |
| 171 | 172 | debug: false |
| 172 | 173 | ... | ... |