Commit a72869b97edb263793cfc514736a42f6e85ad8d9
1 parent
fef808d8
code review:修复部分统计报错
Showing
4 changed files
with
21 additions
and
33 deletions
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/package-info.java deleted
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java
| @@ -16,6 +16,13 @@ import java.util.List; | @@ -16,6 +16,13 @@ import java.util.List; | ||
| 16 | public interface MemberStatisticsService { | 16 | public interface MemberStatisticsService { |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | + * 获取会员统计 | ||
| 20 | + * | ||
| 21 | + * @return 会员统计 | ||
| 22 | + */ | ||
| 23 | + MemberSummaryRespVO getMemberSummary(); | ||
| 24 | + | ||
| 25 | + /** | ||
| 19 | * 按照省份,获得会员统计列表 | 26 | * 按照省份,获得会员统计列表 |
| 20 | * | 27 | * |
| 21 | * @return 会员统计列表 | 28 | * @return 会员统计列表 |
| @@ -38,11 +45,4 @@ public interface MemberStatisticsService { | @@ -38,11 +45,4 @@ public interface MemberStatisticsService { | ||
| 38 | */ | 45 | */ |
| 39 | MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); | 46 | MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); |
| 40 | 47 | ||
| 41 | - /** | ||
| 42 | - * 获取会员统计 | ||
| 43 | - * | ||
| 44 | - * @return 会员统计 | ||
| 45 | - */ | ||
| 46 | - MemberSummaryRespVO getMemberSummary(); | ||
| 47 | - | ||
| 48 | } | 48 | } |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java
| @@ -45,6 +45,18 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | @@ -45,6 +45,18 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | ||
| 45 | private ApiAccessLogStatisticsService apiAccessLogStatisticsService; | 45 | private ApiAccessLogStatisticsService apiAccessLogStatisticsService; |
| 46 | 46 | ||
| 47 | @Override | 47 | @Override |
| 48 | + public MemberSummaryRespVO getMemberSummary() { | ||
| 49 | + MemberSummaryRespVO vo = payWalletStatisticsService.getUserRechargeSummary(null, null); | ||
| 50 | + Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null); | ||
| 51 | + Integer userCount = memberStatisticsMapper.selectUserCount(null, null); | ||
| 52 | + // 拼接数据 | ||
| 53 | + if (vo == null) { | ||
| 54 | + vo = new MemberSummaryRespVO().setRechargeUserCount(0).setRechargePrice(0); | ||
| 55 | + } | ||
| 56 | + return vo.setUserCount(userCount).setExpensePrice(expensePrice); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 48 | public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { | 60 | public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { |
| 49 | // 统计用户 | 61 | // 统计用户 |
| 50 | Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), | 62 | Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), |
| @@ -89,19 +101,6 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | @@ -89,19 +101,6 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { | ||
| 89 | .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); | 101 | .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); |
| 90 | } | 102 | } |
| 91 | 103 | ||
| 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) { | 104 | private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { |
| 106 | Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) | 105 | Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) |
| 107 | .map(MemberSummaryRespVO::getRechargeUserCount).orElse(0); | 106 | .map(MemberSummaryRespVO::getRechargeUserCount).orElse(0); |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
| @@ -24,20 +24,18 @@ | @@ -24,20 +24,18 @@ | ||
| 24 | </select> | 24 | </select> |
| 25 | 25 | ||
| 26 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> | 26 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| 27 | - SELECT COUNT(1) | 27 | + SELECT COUNT(DISTINCT(user_id)) |
| 28 | FROM trade_order | 28 | FROM trade_order |
| 29 | WHERE deleted = FALSE | 29 | WHERE deleted = FALSE |
| 30 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 30 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 31 | - GROUP BY user_id | ||
| 32 | </select> | 31 | </select> |
| 33 | 32 | ||
| 34 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> | 33 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 35 | - SELECT COUNT(1) | 34 | + SELECT COUNT(DISTINCT(user_id)) |
| 36 | FROM trade_order | 35 | FROM trade_order |
| 37 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} | 36 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} |
| 38 | AND pay_status = TRUE | 37 | AND pay_status = TRUE |
| 39 | AND deleted = FALSE | 38 | AND deleted = FALSE |
| 40 | - GROUP BY user_id | ||
| 41 | </select> | 39 | </select> |
| 42 | 40 | ||
| 43 | <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> | 41 | <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> |