code review:修复部分统计报错

This commit is contained in:
YunaiV 2023-10-12 21:54:06 +08:00
parent fef808d88c
commit a72869b97e
4 changed files with 21 additions and 33 deletions

View File

@ -1,9 +0,0 @@
/**
* TODO
* 1. 会员总数据
* 2. 性别统计
* 3. 渠道统计
* 4. 地域统计
* 5. 会员概览
*/
package cn.iocoder.yudao.module.statistics.controller.admin.member;

View File

@ -15,6 +15,13 @@ import java.util.List;
*/ */
public interface MemberStatisticsService { public interface MemberStatisticsService {
/**
* 获取会员统计
*
* @return 会员统计
*/
MemberSummaryRespVO getMemberSummary();
/** /**
* 按照省份获得会员统计列表 * 按照省份获得会员统计列表
* *
@ -38,11 +45,4 @@ public interface MemberStatisticsService {
*/ */
MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获取会员统计
*
* @return 会员统计
*/
MemberSummaryRespVO getMemberSummary();
} }

View File

@ -44,6 +44,18 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
@Resource @Resource
private ApiAccessLogStatisticsService apiAccessLogStatisticsService; private ApiAccessLogStatisticsService apiAccessLogStatisticsService;
@Override
public MemberSummaryRespVO getMemberSummary() {
MemberSummaryRespVO vo = payWalletStatisticsService.getUserRechargeSummary(null, null);
Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null);
Integer userCount = memberStatisticsMapper.selectUserCount(null, null);
// 拼接数据
if (vo == null) {
vo = new MemberSummaryRespVO().setRechargeUserCount(0).setRechargePrice(0);
}
return vo.setUserCount(userCount).setExpensePrice(expensePrice);
}
@Override @Override
public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() {
// 统计用户 // 统计用户
@ -89,19 +101,6 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
.setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference));
} }
@Override
public MemberSummaryRespVO getMemberSummary() {
MemberSummaryRespVO vo = payWalletStatisticsService.getUserRechargeSummary(null, null);
Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null);
Integer userCount = memberStatisticsMapper.selectUserCount(null, null);
if (vo == null) {
vo = new MemberSummaryRespVO().setRechargeUserCount(0).setRechargePrice(0);
}
return vo.setUserCount(userCount).setExpensePrice(expensePrice);
}
private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) {
Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime))
.map(MemberSummaryRespVO::getRechargeUserCount).orElse(0); .map(MemberSummaryRespVO::getRechargeUserCount).orElse(0);

View File

@ -24,20 +24,18 @@
</select> </select>
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(DISTINCT(user_id))
FROM trade_order FROM trade_order
WHERE deleted = FALSE WHERE deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime} AND create_time BETWEEN #{beginTime} AND #{endTime}
GROUP BY user_id
</select> </select>
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(DISTINCT(user_id))
FROM trade_order FROM trade_order
WHERE pay_time BETWEEN #{beginTime} AND #{endTime} WHERE pay_time BETWEEN #{beginTime} AND #{endTime}
AND pay_status = TRUE AND pay_status = TRUE
AND deleted = FALSE AND deleted = FALSE
GROUP BY user_id
</select> </select>
<select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer">