mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
统计:Review修改
This commit is contained in:
parent
66cdf4ca4c
commit
4be709b815
@ -132,25 +132,34 @@ public class AreaUtils {
|
|||||||
return convertList(areas.values(), func, area -> type.getType().equals(area.getType()));
|
return convertList(areas.values(), func, area -> type.getType().equals(area.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:注释写下;
|
/**
|
||||||
|
* 根据区域编号、上级区域类型,获取上级区域编号
|
||||||
|
*
|
||||||
|
* @param id 区域编号
|
||||||
|
* @param type 区域类型
|
||||||
|
* @return 上级区域编号
|
||||||
|
*/
|
||||||
public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) {
|
public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) {
|
||||||
// TODO @疯狂:这种不要用 while true;因为万一脏数据,可能会死循环;可以转换成 for (int i = 0; i < Byte.MAX; i++) 一般是优先层级;
|
for (int i = 0; i < Byte.MAX_VALUE; i++) {
|
||||||
do {
|
|
||||||
Area area = AreaUtils.getArea(id);
|
Area area = AreaUtils.getArea(id);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 匹配到
|
||||||
if (type.getType().equals(area.getType())) {
|
if (type.getType().equals(area.getType())) {
|
||||||
return area.getId();
|
return area.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 找到根节点,返回空
|
||||||
if (area.getParent() == null || area.getParent().getId() == null) {
|
if (area.getParent() == null || area.getParent().getId() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 继续向上查找
|
||||||
id = area.getParent().getId();
|
id = area.getParent().getId();
|
||||||
} while (true);
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@ -36,4 +38,6 @@ public interface MemberStatisticsConvert {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
|
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
|
||||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@ -29,8 +29,7 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO
|
|||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("bizType") Integer bizType);
|
@Param("bizType") Integer bizType);
|
||||||
|
|
||||||
// TODO @疯狂:是不是搞个单独的 BO 呀;
|
RechargeSummaryRespBO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime,
|
||||||
MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime,
|
|
||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("payStatus") Boolean payStatus);
|
@Param("payStatus") Boolean payStatus);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO
|
|||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,10 +18,6 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
||||||
|
|
||||||
// TODO @疯狂:这个要不要也挪到 xml 里,保持统一?
|
|
||||||
@Select("SELECT IFNULL(SUM(order_create_count), 0) AS count, IFNULL(SUM(order_pay_price), 0) AS summary " +
|
|
||||||
"FROM trade_statistics " +
|
|
||||||
"WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE")
|
|
||||||
TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert
|
|||||||
import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper;
|
import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper;
|
||||||
import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -91,20 +92,16 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemberSummaryRespVO getMemberSummary() {
|
public MemberSummaryRespVO getMemberSummary() {
|
||||||
MemberSummaryRespVO vo = payWalletStatisticsService.getUserRechargeSummary(null, null);
|
RechargeSummaryRespBO rechargeSummary = payWalletStatisticsService.getUserRechargeSummary(null, null);
|
||||||
Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null);
|
Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null);
|
||||||
Integer userCount = memberStatisticsMapper.selectUserCount(null, null);
|
Integer userCount = memberStatisticsMapper.selectUserCount(null, null);
|
||||||
|
|
||||||
if (vo == null) {
|
return MemberStatisticsConvert.INSTANCE.convert(rechargeSummary, expensePrice, userCount);
|
||||||
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(RechargeSummaryRespBO::getRechargeUserCount).orElse(0);
|
||||||
return new MemberAnalyseComparisonRespVO()
|
return new MemberAnalyseComparisonRespVO()
|
||||||
.setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
|
.setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
|
||||||
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime))
|
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.pay;
|
package cn.iocoder.yudao.module.statistics.service.pay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -28,6 +28,6 @@ public interface PayWalletStatisticsService {
|
|||||||
* @param endTime 截止时间
|
* @param endTime 截止时间
|
||||||
* @return 钱包充值统计
|
* @return 钱包充值统计
|
||||||
*/
|
*/
|
||||||
MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.statistics.service.pay;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
|
||||||
import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper;
|
import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -39,7 +39,7 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
public RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true);
|
return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.iocoder.yudao.module.statistics.service.pay.bo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 充值统计 Response VO")
|
||||||
|
@Data
|
||||||
|
public class RechargeSummaryRespBO {
|
||||||
|
|
||||||
|
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
|
||||||
|
private Integer rechargeUserCount;
|
||||||
|
|
||||||
|
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Integer rechargePrice;
|
||||||
|
|
||||||
|
}
|
@ -8,8 +8,6 @@
|
|||||||
FROM member_user
|
FROM member_user
|
||||||
WHERE deleted = FALSE
|
WHERE deleted = FALSE
|
||||||
GROUP BY area_id
|
GROUP BY area_id
|
||||||
<!-- TODO @疯狂:order by 是不是交给内存哈 -->
|
|
||||||
ORDER BY userCount DESC
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectSummaryListBySex"
|
<select id="selectSummaryListBySex"
|
||||||
@ -18,8 +16,6 @@
|
|||||||
FROM member_user
|
FROM member_user
|
||||||
WHERE deleted = FALSE
|
WHERE deleted = FALSE
|
||||||
GROUP BY sex
|
GROUP BY sex
|
||||||
<!-- TODO @疯狂:order by 是不是交给内存哈 -->
|
|
||||||
ORDER BY userCount DESC
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserCount" resultType="java.lang.Integer">
|
<select id="selectUserCount" resultType="java.lang.Integer">
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRechargeSummaryGroupByWalletId"
|
<select id="selectRechargeSummaryGroupByWalletId"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO">
|
resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO">
|
||||||
SELECT COUNT(1) AS rechargeUserCount,
|
SELECT COUNT(1) AS rechargeUserCount,
|
||||||
SUM(pay_price) AS rechargePrice
|
SUM(pay_price) AS rechargePrice
|
||||||
FROM pay_wallet_recharge
|
FROM pay_wallet_recharge
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper">
|
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper">
|
||||||
|
|
||||||
|
<select id="selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween"
|
||||||
|
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO">
|
||||||
|
SELECT IFNULL(SUM(order_create_count), 0) AS count,
|
||||||
|
IFNULL(SUM(order_pay_price), 0) AS summary
|
||||||
|
FROM trade_statistics
|
||||||
|
WHERE time BETWEEN #{beginTime} AND #{endTime}
|
||||||
|
AND deleted = FALSE
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectByTimeBetween"
|
<select id="selectByTimeBetween"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
||||||
SELECT
|
SELECT
|
||||||
|
Loading…
Reference in New Issue
Block a user