商城:增加商城首页

This commit is contained in:
owen 2023-10-16 09:51:20 +08:00
parent 1ac2f2b5c2
commit f5dac38ca5
37 changed files with 591 additions and 40 deletions

2
sql/mysql/mall.sql Normal file
View File

@ -0,0 +1,2 @@
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('商城首页', '', 2, 1, 2362, 'home', 'ep:home-filled', 'mall/home/index', 'MallHome');

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.statistics.enums;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 时间范围类型的枚举
*
* @author owen
*/
@AllArgsConstructor
@Getter
public enum TimeRangeTypeEnum implements IntArrayValuable {
/**
*
*/
DAY(1),
/**
*
*/
WEEK(7),
/**
*
*/
MONTH(30),
/**
*
*/
YEAR(365),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray();
/**
* 状态
*/
private final Integer type;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -4,6 +4,7 @@ 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.*;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -75,4 +76,19 @@ public class MemberStatisticsController {
return success(list);
}
@GetMapping("/user-count-comparison")
@Operation(summary = "获得用户数量对照")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<TradeStatisticsComparisonRespVO<MemberCountRespVO>> getUserCountComparison() {
return success(memberStatisticsService.getUserCountComparison());
}
@GetMapping("/register-count-list")
@Operation(summary = "获得会员注册数量列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberRegisterCountRespVO>> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) {
return success(memberStatisticsService.getMemberRegisterCountList(
ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1)));
}
}

View File

@ -0,0 +1,16 @@
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 MemberCountRespVO {
@Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer visitUserCount;
@Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer createUserCount;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
@Schema(description = "管理后台 - 会员注册数量 Response VO")
@Data
public class MemberRegisterCountRespVO {
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT)
@Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private LocalDate date;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer count;
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 支付统计")
@RestController
@RequestMapping("/statistics/pay")
@Validated
@Slf4j
public class PayStatisticsController {
@Resource
private PayWalletStatisticsService payWalletStatisticsService;
@GetMapping("/wallet-recharge-price")
@Operation(summary = "获取充值金额")
public CommonResult<Integer> getWalletRechargePrice() {
return success(payWalletStatisticsService.getRechargePriceSummary());
}
}

View File

@ -5,7 +5,12 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert;
import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@ -17,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
@ -31,6 +37,12 @@ public class TradeStatisticsController {
@Resource
private TradeStatisticsService tradeStatisticsService;
@Resource
private TradeOrderStatisticsService tradeOrderStatisticsService;
@Resource
private AfterSaleStatisticsService afterSaleStatisticsService;
@Resource
private BrokerageStatisticsService brokerageStatisticsService;
@GetMapping("/summary")
@Operation(summary = "获得交易统计")
@ -68,4 +80,28 @@ public class TradeStatisticsController {
ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data);
}
@GetMapping("/order-count")
@Operation(summary = "获得交易订单数量")
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<TradeOrderCountRespVO> getOrderCount() {
TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount();
vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY))
.setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING));
return success(vo);
}
@GetMapping("/order-comparison")
@Operation(summary = "获得交易订单数量")
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() {
return success(tradeOrderStatisticsService.getOrderComparison());
}
@GetMapping("/order-count-trend")
@Operation(summary = "获得订单量趋势统计")
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<List<TradeStatisticsComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) {
return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO));
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 交易订单数量 Response VO")
@Data
public class TradeOrderCountRespVO {
@Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long undelivered;
@Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long pickUp;
@Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long afterSaleApply;
@Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long auditingWithdraw;
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 交易订单统计 Response VO")
@Data
public class TradeOrderSummaryRespVO {
@Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderPayCount;
@Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderPayPrice;
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
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 TradeOrderTrendReqVO {
@Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "日期范围类型不能为空")
@InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}")
private Integer type;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "起始时间")
private LocalDateTime beginTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "截止时间")
private LocalDateTime endTime;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 订单量趋势统计 Response VO")
@Data
public class TradeOrderTrendRespVO {
@Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private String date;
@Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderPayCount;
@Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderPayPrice;
}

View File

@ -12,14 +12,15 @@ import java.time.LocalDateTime;
* @author owen
*/
@Mapper
public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> {
@SuppressWarnings("rawtypes")
public interface ApiAccessLogStatisticsMapper extends BaseMapperX {
// TODO @疯狂是不是 selectIpCount
Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Integer selectIpCountByCreateTimeBetween(@Param("userType") Integer userType,
@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
// TODO @疯狂是不是 selectUserCount
Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Integer selectUserCountByCreateTimeBetween(@Param("userType") Integer userType,
@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
}

View File

@ -2,6 +2,7 @@ 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.MemberRegisterCountRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -15,7 +16,8 @@ import java.util.List;
* @author owen
*/
@Mapper
public interface MemberStatisticsMapper extends BaseMapperX<Object> {
@SuppressWarnings("rawtypes")
public interface MemberStatisticsMapper extends BaseMapperX {
// TODO @芋艿已经 review
// TODO @疯狂要不还是搞下 bo虽然可能冗余了点~~
@ -27,4 +29,7 @@ public interface MemberStatisticsMapper extends BaseMapperX<Object> {
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
List<MemberRegisterCountRespVO> selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
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;
@ -15,7 +14,8 @@ import java.time.LocalDateTime;
* @author owen
*/
@Mapper
public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
@SuppressWarnings("rawtypes")
public interface PayWalletStatisticsMapper extends BaseMapperX {
WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime,
@ -34,4 +34,6 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO
@Param("endTime") LocalDateTime endTime,
@Param("payStatus") Boolean payStatus);
Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus);
}

View File

@ -19,4 +19,6 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO
AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Long selectCountByStatus(@Param("status") Integer status);
}

View File

@ -20,4 +20,6 @@ public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO
@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Long selectWithdrawCountByStatus(@Param("status") Integer status);
}

View File

@ -2,6 +2,8 @@ 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.controller.admin.trade.vo.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -38,4 +40,32 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
/**
* 按照支付时间统计订单按天分组
*
* @param beginTime 支付起始时间
* @param endTime 支付截止时间
* @return 订单统计列表
*/
List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
/**
* 按照支付时间统计订单按月分组
*
* @param beginTime 支付起始时间
* @param endTime 支付截止时间
* @return 订单统计列表
*/
List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
Long selectCountByStatus(@Param("status") Integer status);
Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status);
TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status,
@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
}

View File

@ -14,21 +14,23 @@ public interface ApiAccessLogStatisticsService {
/**
* 获取活跃用户数量
*
* @param userType 用户类型
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 活跃用户数量
*/
Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime);
Integer getActiveUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime);
// TODO @疯狂需要传递 userType因为访问日志可能涉及多种用户类型
// TODO @疯狂方法名要不改成 getIpCount原因让它更业务无关
/**
* 获取访问用户数量
*
* @param userType 用户类型
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 访问用户数量
*/
Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime);
Integer getVisitorUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -20,13 +20,13 @@ public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatistics
private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper;
@Override
public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime);
public Integer getActiveUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) {
return apiAccessLogStatisticsMapper.selectUserCountByCreateTimeBetween(userType, beginTime, endTime);
}
@Override
public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime);
public Integer getVisitorUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) {
return apiAccessLogStatisticsMapper.selectIpCountByCreateTimeBetween(userType, beginTime, endTime);
}
}

View File

@ -1,9 +1,7 @@
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 cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
import java.time.LocalDateTime;
import java.util.List;
@ -47,4 +45,20 @@ public interface MemberStatisticsService {
*/
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
/**
* 获取用户注册数量列表
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 注册数量列表
*/
List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获得用户数量量统计对照
*
* @return 用户数量量统计对照
*/
TradeStatisticsComparisonRespVO<MemberCountRespVO> getUserCountComparison();
}

View File

@ -1,10 +1,13 @@
package cn.iocoder.yudao.module.statistics.service.member;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
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;
@ -13,7 +16,6 @@ import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsServ
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert;
import javax.annotation.Resource;
import java.time.Duration;
@ -94,7 +96,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
atv = NumberUtil.div(payPrice, payUserCount).intValue();
}
return new MemberAnalyseRespVO()
.setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(beginTime, endTime))
.setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime))
.setOrderUserCount(tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime))
.setPayUserCount(payUserCount)
.setAtv(atv)
@ -106,7 +108,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
.map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0);
return new MemberAnalyseComparisonRespVO()
.setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime))
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime))
.setRechargeUserCount(rechargeUserCount);
}
@ -116,4 +118,28 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
return memberStatisticsMapper.selectSummaryListBySex();
}
@Override
public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) {
return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime);
}
@Override
public TradeStatisticsComparisonRespVO<MemberCountRespVO> getUserCountComparison() {
// 今日时间范围
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday);
// 昨日时间范围
LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1));
LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday);
return new TradeStatisticsComparisonRespVO<MemberCountRespVO>()
.setValue(getUserCount(beginOfToday, endOfToday))
.setReference(getUserCount(beginOfYesterday, endOfYesterday));
}
private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return new MemberCountRespVO()
.setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setVisitUserCount(apiAccessLogStatisticsService.getVisitorUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime));
}
}

View File

@ -30,4 +30,11 @@ public interface PayWalletStatisticsService {
*/
RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获取充值金额合计
*
* @return 充值金额合计
*/
Integer getRechargePriceSummary();
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.statistics.service.pay;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper;
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
@ -43,4 +44,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true);
}
@Override
public Integer getRechargePriceSummary() {
return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus());
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
import java.time.LocalDateTime;
@ -20,4 +21,12 @@ public interface AfterSaleStatisticsService {
*/
AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获取指定状态的售后订单数量
*
* @param status 售后状态
* @return 售后订单数量
*/
Long getCountByStatus(AfterSaleStatusEnum status);
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper;
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -25,4 +26,9 @@ public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsServic
return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime);
}
@Override
public Long getCountByStatus(AfterSaleStatusEnum status) {
return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus());
}
}

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import java.time.LocalDateTime;
/**
@ -18,4 +20,12 @@ public interface BrokerageStatisticsService {
*/
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获取指定状态的提现记录数量
*
* @param status 提现记录状态
* @return 提现记录数量
*/
Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status);
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -28,4 +29,9 @@ public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsServic
beginTime, endTime);
}
@Override
public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) {
return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus());
}
}

View File

@ -1,6 +1,7 @@
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.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import java.time.LocalDateTime;
@ -60,4 +61,26 @@ public interface TradeOrderStatisticsService {
*/
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 获得交易订单数量
*
* @return 订单数量
*/
TradeOrderCountRespVO getOrderCount();
/**
* 交易订单销售额对照
*
* @return 销售额对照
*/
TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison();
/**
* 获得订单量趋势统计
*
* @param reqVO 统计参数
* @return 订单量趋势统计
*/
List<TradeStatisticsComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO);
}

View File

@ -1,14 +1,24 @@
package cn.iocoder.yudao.module.statistics.service.trade;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper;
import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
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.stream.Collectors;
import java.util.stream.IntStream;
/**
* 交易订单统计 Service 实现类
@ -50,4 +60,53 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime);
}
@Override
public TradeOrderCountRespVO getOrderCount() {
Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus());
Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus());
return new TradeOrderCountRespVO()
.setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L))
.setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L));
}
@Override
public TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison() {
return new TradeStatisticsComparisonRespVO<TradeOrderSummaryRespVO>()
.setValue(getPayPriceSummary(LocalDateTime.now()))
.setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1)));
}
private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) {
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date);
LocalDateTime endTime = LocalDateTimeUtil.beginOfDay(date);
return tradeOrderStatisticsMapper.selectPaySummaryByStatusAndPayTimeBetween(PayOrderStatusEnum.SUCCESS.getStatus(), beginTime, endTime);
}
@Override
public List<TradeStatisticsComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) {
// 查询当前数据
List<TradeOrderTrendRespVO> value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime());
// 查询对照数据
LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1);
LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime()));
List<TradeOrderTrendRespVO> reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime);
return IntStream.range(0, value.size())
.mapToObj(index -> new TradeStatisticsComparisonRespVO<TradeOrderTrendRespVO>()
.setValue(CollUtil.get(value, index))
.setReference(CollUtil.get(reference, index)))
.collect(Collectors.toList());
}
private List<TradeOrderTrendRespVO> getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) {
// 情况一按年统计时以月份分组
if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) {
return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime);
}
// 情况二其它以天分组
return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime);
}
}

View File

@ -33,7 +33,7 @@ public interface TradeStatisticsService {
* 获得交易状况统计
*
* @param beginTime 开始时间
* @param endTime 结束时间
* @param endTime 结束时间
* @return 统计数据对照
*/
Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime);
@ -41,6 +41,8 @@ public interface TradeStatisticsService {
/**
* 获得交易状况明细
*
* @param beginTime 开始时间
* @param endTime 结束时间
* @return 统计数据列表
*/
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);

View File

@ -2,17 +2,17 @@ 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;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import org.springframework.validation.annotation.Validated;

View File

@ -2,23 +2,21 @@
<!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">
<!-- TODO @疯狂distinct 会不会更合适哈 -->
SELECT COUNT(1)
<select id="selectIpCountByCreateTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT user_ip)
FROM infra_api_access_log
WHERE create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY user_ip
WHERE user_type = #{userType}
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select>
<select id="selectCountByUserId" resultType="java.lang.Integer">
<!-- TODO @疯狂distinct 会不会更合适哈 -->
SELECT COUNT(1)
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT user_id)
FROM infra_api_access_log
WHERE user_id > 0
AND user_type = #{userType}
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY user_id
</select>
</mapper>

View File

@ -30,4 +30,14 @@
</if>
</select>
<select id="selectListByCreateTimeBetween"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO">
SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date,
count(1) AS count
FROM member_user
WHERE create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY date
</select>
</mapper>

View File

@ -46,4 +46,11 @@
GROUP BY wallet_id
</select>
<select id="selectRechargePriceSummary" resultType="java.lang.Integer">
SELECT IFNULL(SUM(pay_price), 0)
FROM pay_wallet_recharge
WHERE pay_status = #{payStatus}
AND deleted = FALSE
</select>
</mapper>

View File

@ -11,4 +11,11 @@
AND deleted = FALSE
</select>
<select id="selectCountByStatus" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_after_sale
WHERE status = #{status}
AND deleted = FALSE
</select>
</mapper>

View File

@ -11,4 +11,11 @@
AND deleted = FALSE
</select>
<select id="selectWithdrawCountByStatus" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_brokerage_withdraw
WHERE status = #{status}
AND deleted = FALSE
</select>
</mapper>

View File

@ -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.TradeOrderStatisticsMapper">
<select id="selectSummaryListByAreaId"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
SELECT receiver_area_id AS areaId,
@ -24,14 +23,14 @@
</select>
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT(user_id))
SELECT COUNT(DISTINCT (user_id))
FROM trade_order
WHERE deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime}
</select>
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT(user_id))
SELECT COUNT(DISTINCT (user_id))
FROM trade_order
WHERE pay_time BETWEEN #{beginTime} AND #{endTime}
AND pay_status = TRUE
@ -61,4 +60,52 @@
AND create_time BETWEEN #{beginTime} AND #{endTime}
</select>
<select id="selectListByPayTimeBetweenAndGroupByDay"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO">
SELECT DATE_FORMAT(pay_time, '%Y-%m-%d') AS date,
COUNT(1) AS orderPayCount,
SUM(pay_price) AS orderPayPrice
FROM trade_order
WHERE pay_status = TRUE
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY date
</select>
<select id="selectListByPayTimeBetweenAndGroupByMonth"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO">
SELECT DATE_FORMAT(pay_time, '%Y-%m') AS date,
COUNT(1) AS orderPayCount,
SUM(pay_price) AS orderPayPrice
FROM trade_order
WHERE pay_status = TRUE
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
GROUP BY date
</select>
<select id="selectCountByStatus" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status} AND deleted = FALSE
</select>
<select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND pick_up_store_id IS NOT NULL
AND deleted = FALSE
</select>
<select id="selectPaySummaryByStatusAndPayTimeBetween"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO">
SELECT IFNULL(SUM(pay_price), 0) AS orderPayPrice,
COUNT(1) AS orderPayCount
FROM trade_order
WHERE status = #{status}
AND pay_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
</select>
</mapper>