mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
统计:会员统计
This commit is contained in:
parent
383439f902
commit
df16278a03
@ -28,16 +28,22 @@ CREATE INDEX trade_statistics_time_index
|
||||
ON trade_statistics (time);
|
||||
|
||||
-- 菜单
|
||||
INSERT INTO `ruoyi-vue-pro`.system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
|
||||
VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', '');
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
INSERT INTO `ruoyi-vue-pro`.system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
|
||||
VALUES ('交易统计', '', 2, 4, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics');
|
||||
-- 交易统计
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
|
||||
VALUES ('交易统计', '', 2, 1, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics');
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
-- 按钮
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('交易统计导出', 'statistics:trade:export', 3, 2, @parentId, '', '', '', 0);
|
||||
-- 会员统计
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
|
||||
VALUES ('会员统计', '', 2, 2, @parentId, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics');
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
|
||||
VALUES ('会员统计查询', 'statistics:member:query', 3, 1, @parentId, '', '', '', 0);
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.common.util.collection;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.*;
|
||||
@ -50,6 +51,13 @@ public class CollectionUtils {
|
||||
return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values());
|
||||
}
|
||||
|
||||
public static <T, U> List<U> convertList(T[] from, Function<T, U> func) {
|
||||
if (ArrayUtil.isEmpty(from)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return convertList(Arrays.asList(from), func);
|
||||
}
|
||||
|
||||
public static <T, U> List<U> convertList(Collection<T> from, Function<T, U> func) {
|
||||
if (CollUtil.isEmpty(from)) {
|
||||
return new ArrayList<>();
|
||||
@ -162,8 +170,8 @@ public class CollectionUtils {
|
||||
/**
|
||||
* 对比老、新两个列表,找出新增、修改、删除的数据
|
||||
*
|
||||
* @param oldList 老列表
|
||||
* @param newList 新列表
|
||||
* @param oldList 老列表
|
||||
* @param newList 新列表
|
||||
* @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同
|
||||
* 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据
|
||||
* @return [新增列表、修改列表、删除列表]
|
||||
|
@ -7,12 +7,16 @@ import cn.hutool.core.text.csv.CsvUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
/**
|
||||
* 区域工具类
|
||||
@ -108,7 +112,7 @@ public class AreaUtils {
|
||||
// “递归”父节点
|
||||
area = area.getParent();
|
||||
if (area == null
|
||||
|| ObjectUtils.equalsAny(area.getId(), Area.ID_GLOBAL, Area.ID_CHINA)) { // 跳过父节点为中国的情况
|
||||
|| ObjectUtils.equalsAny(area.getId(), Area.ID_GLOBAL, Area.ID_CHINA)) { // 跳过父节点为中国的情况
|
||||
break;
|
||||
}
|
||||
sb.insert(0, separator);
|
||||
@ -116,4 +120,35 @@ public class AreaUtils {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定类型的区域列表
|
||||
*
|
||||
* @param type 区域类型
|
||||
* @param func 转换函数
|
||||
* @param <T> 结果类型
|
||||
* @return 区域列表
|
||||
*/
|
||||
public static <T> List<T> getByType(AreaTypeEnum type, Function<Area, T> func) {
|
||||
return convertList(areas.values(), func, area -> type.getType().equals(area.getType()));
|
||||
}
|
||||
|
||||
public static Integer getParentIdByType(Integer id, @NonNull AreaTypeEnum type) {
|
||||
do {
|
||||
Area area = AreaUtils.getArea(id);
|
||||
if (area == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type.getType().equals(area.getType())) {
|
||||
return area.getId();
|
||||
}
|
||||
|
||||
if (area.getParent() == null || area.getParent().getId() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
id = area.getParent().getId();
|
||||
} while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,11 @@
|
||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
@ -1,21 +1,25 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.admin.member;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
||||
import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "管理后台 - 会员统计")
|
||||
@RestController
|
||||
@RequestMapping("/statistics/member")
|
||||
@ -23,36 +27,47 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class MemberStatisticsController {
|
||||
|
||||
// TODO @疯狂:一个类似 getTradeTrendSummaryComparison 的接口
|
||||
// TODO @疯狂:一个类似 getTradeStatisticsList 的接口
|
||||
@Resource
|
||||
private MemberStatisticsService memberStatisticsService;
|
||||
|
||||
@GetMapping("/summary")
|
||||
@Operation(summary = "获得会员统计")
|
||||
public CommonResult<TradeStatisticsComparisonRespVO<MemberSummaryRespVO>> getMemberSummary() {
|
||||
// TODO 疯狂:目前先直接计算;
|
||||
return null;
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
public CommonResult<MemberSummaryRespVO> getMemberSummary() {
|
||||
return success(memberStatisticsService.getMemberSummary());
|
||||
}
|
||||
|
||||
@GetMapping("/analyse")
|
||||
@Operation(summary = "获得会员分析数据")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) {
|
||||
return success(memberStatisticsService.getMemberAnalyse(
|
||||
ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1)));
|
||||
}
|
||||
|
||||
@GetMapping("/get-area-statistics-list")
|
||||
@Operation(summary = "按照省份,获得会员统计列表")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() {
|
||||
// TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化
|
||||
return null;
|
||||
return success(memberStatisticsService.getMemberAreaStatisticsList());
|
||||
}
|
||||
|
||||
@GetMapping("/get-sex-statistics-list")
|
||||
@Operation(summary = "按照性别,获得会员统计列表")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() {
|
||||
// TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化
|
||||
return null;
|
||||
return success(memberStatisticsService.getMemberSexStatisticsList());
|
||||
}
|
||||
|
||||
@GetMapping("/get-terminal-statistics-list")
|
||||
@Operation(summary = "按照终端,获得会员统计列表")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
|
||||
// TODO 疯狂:目前先直接计算,进行统计;后续再考虑优化
|
||||
// TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal
|
||||
return null;
|
||||
List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(),
|
||||
t -> new MemberTerminalStatisticsRespVO()
|
||||
.setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100));
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 会员分析对照数据 Response VO")
|
||||
@Data
|
||||
public class MemberAnalyseComparisonRespVO {
|
||||
|
||||
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer userCount;
|
||||
|
||||
@Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer activeUserCount;
|
||||
|
||||
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
|
||||
private Integer rechargeUserCount;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 会员分析 Request VO")
|
||||
@Data
|
||||
public class MemberAnalyseReqVO {
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "时间范围")
|
||||
private LocalDateTime[] times;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 会员分析 Response VO")
|
||||
@Data
|
||||
public class MemberAnalyseRespVO {
|
||||
|
||||
@Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer visitorCount;
|
||||
|
||||
@Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderUserCount;
|
||||
|
||||
@Schema(description = "成交用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer payUserCount;
|
||||
|
||||
@Schema(description = "客单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer atv;
|
||||
|
||||
@Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO> comparison;
|
||||
|
||||
}
|
@ -13,11 +13,4 @@ public class MemberSexStatisticsRespVO {
|
||||
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer userCount;
|
||||
|
||||
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderCreateCount;
|
||||
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
|
||||
private Integer orderPayCount;
|
||||
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
|
||||
private Integer orderPayPrice;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public class MemberSummaryRespVO {
|
||||
|
||||
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer rechargePrice;
|
||||
|
||||
@Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer expensePrice;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 终端性别统计 Response VO")
|
||||
@Schema(description = "管理后台 - 会员终端统计 Response VO")
|
||||
@Data
|
||||
public class MemberTerminalStatisticsRespVO {
|
||||
|
||||
@ -13,11 +13,4 @@ public class MemberTerminalStatisticsRespVO {
|
||||
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer userCount;
|
||||
|
||||
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderCreateCount;
|
||||
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
|
||||
private Integer orderPayCount;
|
||||
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
|
||||
private Integer orderPayPrice;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.statistics.convert.member;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 会员统计 Convert
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Mapper
|
||||
public interface MemberStatisticsConvert {
|
||||
|
||||
MemberStatisticsConvert INSTANCE = Mappers.getMapper(MemberStatisticsConvert.class);
|
||||
|
||||
default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList,
|
||||
Map<Integer, Integer> userCountMap,
|
||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
|
||||
return CollectionUtils.convertList(areaList, area -> {
|
||||
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())).orElseGet(MemberAreaStatisticsRespVO::new);
|
||||
return new MemberAreaStatisticsRespVO()
|
||||
.setAreaId(area.getId()).setAreaName(area.getName())
|
||||
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))
|
||||
.setOrderCreateCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateCount(), 0))
|
||||
.setOrderPayCount(ObjUtil.defaultIfNull(orderVo.getOrderPayCount(), 0))
|
||||
.setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.infra;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* API 访问日志统计 Mapper
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Mapper
|
||||
public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> {
|
||||
|
||||
Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员统计 Mapper
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Mapper
|
||||
public interface MemberStatisticsMapper extends BaseMapperX<Object> {
|
||||
|
||||
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
||||
|
||||
List<MemberSexStatisticsRespVO> selectSummaryListBySex();
|
||||
|
||||
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
|
||||
|
||||
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 org.apache.ibatis.annotations.Mapper;
|
||||
@ -27,4 +28,9 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO
|
||||
Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("bizType") Integer bizType);
|
||||
|
||||
MemberSummaryRespVO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("payStatus") Boolean payStatus);
|
||||
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交易统计 Mapper
|
||||
@ -16,7 +17,21 @@ import java.time.LocalDateTime;
|
||||
@Mapper
|
||||
public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
||||
|
||||
TradeOrderSummaryRespBO selectSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
||||
|
||||
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectSummaryPriceByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectUserCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -30,4 +30,7 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
||||
|
||||
List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.infra;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* API 访问日志统计 Service 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface ApiAccessLogStatisticsService {
|
||||
|
||||
/**
|
||||
* 获取活跃用户数量
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 活跃用户数量
|
||||
*/
|
||||
Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取访问用户数量
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 访问用户数量
|
||||
*/
|
||||
Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.infra;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* API 访问日志统计 Service 实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatisticsService {
|
||||
|
||||
@Resource
|
||||
private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper;
|
||||
|
||||
@Override
|
||||
public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.member;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员统计 Service 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface MemberStatisticsService {
|
||||
|
||||
/**
|
||||
* 按照省份,获得会员统计列表
|
||||
*
|
||||
* @return 会员统计列表
|
||||
*/
|
||||
List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList();
|
||||
|
||||
/**
|
||||
* 按照性别,获得会员统计列表
|
||||
*
|
||||
* @return 会员统计列表
|
||||
*/
|
||||
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
|
||||
|
||||
/**
|
||||
* 获取用户分析数据
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 用户分析数据
|
||||
*/
|
||||
MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取会员统计
|
||||
*
|
||||
* @return 会员统计
|
||||
*/
|
||||
MemberSummaryRespVO getMemberSummary();
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.member;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
||||
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.service.infra.ApiAccessLogStatisticsService;
|
||||
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* 会员统计 Service 实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class MemberStatisticsServiceImpl implements MemberStatisticsService {
|
||||
|
||||
@Resource
|
||||
private MemberStatisticsMapper memberStatisticsMapper;
|
||||
|
||||
@Resource
|
||||
private PayWalletStatisticsService payWalletStatisticsService;
|
||||
@Resource
|
||||
private TradeStatisticsService tradeStatisticsService;
|
||||
@Resource
|
||||
private TradeOrderStatisticsService tradeOrderStatisticsService;
|
||||
@Resource
|
||||
private ApiAccessLogStatisticsService apiAccessLogStatisticsService;
|
||||
|
||||
@Override
|
||||
public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() {
|
||||
// 统计用户
|
||||
Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(),
|
||||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||
MemberAreaStatisticsRespVO::getUserCount, Integer::sum);
|
||||
// 统计订单
|
||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
|
||||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||
vo -> vo,
|
||||
(a, b) -> new MemberAreaStatisticsRespVO()
|
||||
.setOrderCreateCount(a.getOrderCreateCount() + b.getOrderCreateCount())
|
||||
.setOrderPayCount(a.getOrderPayCount() + b.getOrderPayCount())
|
||||
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
|
||||
// 拼接数据
|
||||
return MemberStatisticsConvert.INSTANCE.convertList(AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area), userCountMap, orderMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() {
|
||||
return memberStatisticsMapper.selectSummaryListBySex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
// 对照数据
|
||||
MemberAnalyseComparisonRespVO vo = getMemberAnalyseComparisonData(beginTime, endTime);
|
||||
LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime));
|
||||
MemberAnalyseComparisonRespVO reference = getMemberAnalyseComparisonData(referenceBeginTime, beginTime);
|
||||
|
||||
Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime);
|
||||
// 计算客单价
|
||||
int atv = 0;
|
||||
if (payUserCount != null && payUserCount > 0) {
|
||||
Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime);
|
||||
atv = NumberUtil.div(payPrice, payUserCount).intValue();
|
||||
}
|
||||
return new MemberAnalyseRespVO()
|
||||
.setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(beginTime, endTime))
|
||||
.setOrderUserCount(tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime))
|
||||
.setPayUserCount(payUserCount)
|
||||
.setAtv(atv)
|
||||
.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) {
|
||||
Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime))
|
||||
.map(MemberSummaryRespVO::getRechargeUserCount).orElse(0);
|
||||
return new MemberAnalyseComparisonRespVO()
|
||||
.setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
|
||||
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime))
|
||||
.setRechargeUserCount(rechargeUserCount);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
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.trade.bo.WalletSummaryRespBO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -20,4 +21,13 @@ public interface PayWalletStatisticsService {
|
||||
*/
|
||||
WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取钱包充值统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 钱包充值统计
|
||||
*/
|
||||
MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
package cn.iocoder.yudao.module.statistics.service.pay;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.PayWalletStatisticsMapper;
|
||||
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.service.trade.bo.WalletSummaryRespBO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -38,4 +39,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
|
||||
return paySummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberSummaryRespVO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true);
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交易订单统计 Service 接口
|
||||
@ -20,4 +22,38 @@ public interface TradeOrderStatisticsService {
|
||||
*/
|
||||
TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取地区订单统计
|
||||
*
|
||||
* @return 订单统计结果
|
||||
*/
|
||||
List<MemberAreaStatisticsRespVO> getSummaryListByAreaId();
|
||||
|
||||
/**
|
||||
* 获取下单用户数量
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 支付下单数量
|
||||
*/
|
||||
Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取支付用户数量
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 支付用户数量
|
||||
*/
|
||||
Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取支付金额
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 支付用户金额
|
||||
*/
|
||||
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -7,6 +8,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交易订单统计 Service 实现类
|
||||
@ -22,7 +24,30 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
|
||||
|
||||
@Override
|
||||
public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeOrderStatisticsMapper.selectSummaryByPayTimeBetween(beginTime, endTime);
|
||||
return new TradeOrderSummaryRespBO()
|
||||
.setOrderCreateCount(tradeOrderStatisticsMapper.selectCountByCreateTimeBetween(beginTime, endTime))
|
||||
.setOrderPayCount(tradeOrderStatisticsMapper.selectCountByPayTimeBetween(beginTime, endTime))
|
||||
.setOrderPayPrice(tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberAreaStatisticsRespVO> getSummaryListByAreaId() {
|
||||
return tradeOrderStatisticsMapper.selectSummaryListByAreaId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeOrderStatisticsMapper.selectUserCountByCreateTimeBetween(beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeOrderStatisticsMapper.selectUserCountByPayTimeBetween(beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,13 +22,20 @@ public interface TradeStatisticsService {
|
||||
TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison();
|
||||
|
||||
/**
|
||||
* 获得交易状况统计
|
||||
* 获得交易状况统计对照
|
||||
*
|
||||
* @return 统计数据对照
|
||||
*/
|
||||
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(
|
||||
LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获得交易状况统计
|
||||
*
|
||||
* @return 统计数据对照
|
||||
*/
|
||||
Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获得交易状况明细
|
||||
*
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
|
||||
@ -68,6 +69,11 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
||||
return TradeStatisticsConvert.INSTANCE.convert(value, reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
||||
|
@ -13,7 +13,7 @@ public class TradeOrderSummaryRespBO {
|
||||
/**
|
||||
* 创建订单数
|
||||
*/
|
||||
private Long orderCreateCount;
|
||||
private Integer orderCreateCount;
|
||||
/**
|
||||
* 支付订单商品数
|
||||
*/
|
||||
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.infra.ApiAccessLogStatisticsMapper">
|
||||
<select id="selectCountByIp" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM infra_api_access_log
|
||||
WHERE deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
GROUP BY user_ip
|
||||
</select>
|
||||
|
||||
<select id="selectCountByUserId" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM infra_api_access_log
|
||||
WHERE user_id != 0
|
||||
AND deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.member.MemberStatisticsMapper">
|
||||
|
||||
<select id="selectSummaryListByAreaId"
|
||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
|
||||
SELECT area_id, COUNT(1) AS userCount
|
||||
FROM member_user
|
||||
WHERE deleted = FALSE
|
||||
GROUP BY area_id
|
||||
ORDER BY userCount DESC
|
||||
</select>
|
||||
|
||||
<select id="selectSummaryListBySex"
|
||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO">
|
||||
SELECT sex, COUNT(1) AS userCount
|
||||
FROM member_user
|
||||
WHERE deleted = FALSE
|
||||
GROUP BY sex
|
||||
ORDER BY userCount DESC
|
||||
</select>
|
||||
|
||||
<select id="selectUserCount" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM member_user
|
||||
WHERE deleted = FALSE
|
||||
<if test="beginTime != null">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
@ -1,16 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.TradeOrderStatisticsMapper">
|
||||
<select id="selectSummaryByPayTimeBetween"
|
||||
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO">
|
||||
SELECT COUNT(1) AS orderPayCount,
|
||||
SUM(pay_price) AS orderPayPrice,
|
||||
<select id="selectSummaryListByAreaId"
|
||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
|
||||
SELECT receiver_area_id AS areaId,
|
||||
(SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}) AS orderPayPrice
|
||||
FROM trade_order AS s
|
||||
WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount,
|
||||
(SELECT COUNT(1)
|
||||
FROM trade_order AS s
|
||||
WHERE s.receiver_area_id = m.receiver_area_id
|
||||
AND s.pay_status = TRUE
|
||||
AND s.deleted = FALSE) AS orderPayCount,
|
||||
(SELECT SUM(s.pay_price)
|
||||
FROM trade_order AS s
|
||||
WHERE s.receiver_area_id = m.receiver_area_id
|
||||
AND s.pay_status = TRUE
|
||||
AND s.deleted = FALSE) AS orderPayPrice
|
||||
FROM trade_order m
|
||||
WHERE deleted = FALSE
|
||||
GROUP BY receiver_area_id
|
||||
</select>
|
||||
|
||||
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE deleted = FALSE
|
||||
AND pay_status = TRUE
|
||||
AND pay_time BETWEEN #{beginTime} AND #{endTime}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByPayTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE pay_status = TRUE
|
||||
AND deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT SUM(pay_price)
|
||||
FROM trade_order AS s
|
||||
WHERE s.pay_status = TRUE
|
||||
AND deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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">
|
||||
|
||||
<select id="selectByTimeBetween"
|
||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
||||
SELECT
|
||||
@ -37,4 +36,16 @@
|
||||
GROUP BY date
|
||||
</select>
|
||||
|
||||
<select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer">
|
||||
SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
||||
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
|
||||
FROM trade_statistics
|
||||
WHERE deleted = FALSE
|
||||
<if test="beginTime != null">
|
||||
AND time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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.PayWalletStatisticsMapper">
|
||||
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper">
|
||||
<select id="selectRechargeSummaryByPayTimeBetween"
|
||||
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO">
|
||||
SELECT COUNT(1) AS rechargePayCount,
|
||||
@ -28,4 +28,20 @@
|
||||
AND deleted = FALSE
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="selectRechargeSummaryGroupByWalletId"
|
||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO">
|
||||
SELECT COUNT(1) AS rechargeUserCount,
|
||||
SUM(pay_price) AS rechargePrice
|
||||
FROM pay_wallet_recharge
|
||||
WHERE pay_status = #{payStatus}
|
||||
AND deleted = FALSE
|
||||
<if test="beginTime != null">
|
||||
AND pay_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND pay_time <= #{endTime}
|
||||
</if>
|
||||
GROUP BY wallet_id
|
||||
</select>
|
||||
</mapper>
|
@ -167,6 +167,7 @@ logging:
|
||||
cn.iocoder.yudao.module.member.dal.mysql: debug
|
||||
cn.iocoder.yudao.module.trade.dal.mysql: debug
|
||||
cn.iocoder.yudao.module.promotion.dal.mysql: debug
|
||||
cn.iocoder.yudao.module.statistics.dal.mysql: debug
|
||||
|
||||
debug: false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user