diff --git a/sql/mysql/mall.sql b/sql/mysql/mall.sql new file mode 100644 index 000000000..558ec66f0 --- /dev/null +++ b/sql/mysql/mall.sql @@ -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'); \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java new file mode 100644 index 000000000..1b2361e43 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java @@ -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; + } + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java index 02a844064..f68693a6b 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java @@ -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> getUserCountComparison() { + return success(memberStatisticsService.getUserCountComparison()); + } + + @GetMapping("/register-count-list") + @Operation(summary = "获得会员注册数量列表") + @PreAuthorize("@ss.hasPermission('statistics:member:query')") + public CommonResult> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { + return success(memberStatisticsService.getMemberRegisterCountList( + ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java new file mode 100644 index 000000000..28e807e79 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java new file mode 100644 index 000000000..fb7fc2ac4 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java new file mode 100644 index 000000000..7a6fc7ab7 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java @@ -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 getWalletRechargePrice() { + return success(payWalletStatisticsService.getRechargePriceSummary()); + } + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java index aa5b711cb..cafac1aa5 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java @@ -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 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> getOrderComparison() { + return success(tradeOrderStatisticsService.getOrderComparison()); + } + + @GetMapping("/order-count-trend") + @Operation(summary = "获得订单量趋势统计") + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") + public CommonResult>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { + return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java new file mode 100644 index 000000000..1320a889e --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java new file mode 100644 index 000000000..22d8f4a14 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java new file mode 100644 index 000000000..57f054629 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java new file mode 100644 index 000000000..d69c343cb --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java index 250e89125..854dca9c1 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java @@ -12,14 +12,15 @@ import java.time.LocalDateTime; * @author owen */ @Mapper -public interface ApiAccessLogStatisticsMapper extends BaseMapperX { +@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); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java index f1ac09c4f..c158e9c03 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java @@ -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 { +@SuppressWarnings("rawtypes") +public interface MemberStatisticsMapper extends BaseMapperX { // TODO @芋艿:已经 review // TODO @疯狂:要不还是搞下 bo?虽然可能冗余了点~~ @@ -27,4 +29,7 @@ public interface MemberStatisticsMapper extends BaseMapperX { Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime); + List selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, + @Param("endTime") LocalDateTime endTime); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java index 32922814b..93bcf85ef 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java @@ -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 { +@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 selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, + @Param("endTime") LocalDateTime endTime); + + /** + * 按照支付时间统计订单(按月分组) + * + * @param beginTime 支付起始时间 + * @param endTime 支付截止时间 + * @return 订单统计列表 + */ + List 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); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java index e67f9dd27..629db5d7f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java @@ -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); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java index 4abb02e96..aed124f62 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java @@ -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); } } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java index 5b072b93c..d5496e975 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java @@ -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 getMemberSexStatisticsList(); + /** + * 获取用户注册数量列表 + * + * @param beginTime 起始时间 + * @param endTime 截止时间 + * @return 注册数量列表 + */ + List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); + + /** + * 获得用户数量量统计对照 + * + * @return 用户数量量统计对照 + */ + TradeStatisticsComparisonRespVO getUserCountComparison(); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java index a11d17aaa..628bbccdc 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java @@ -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 getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { + return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); + } + + @Override + public TradeStatisticsComparisonRespVO 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() + .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)); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java index b1d3f3773..d43a57682 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java @@ -30,4 +30,11 @@ public interface PayWalletStatisticsService { */ RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); + /** + * 获取充值金额合计 + * + * @return 充值金额合计 + */ + Integer getRechargePriceSummary(); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java index 2ccc84fe1..10f8bdc97 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java @@ -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()); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java index ea805967b..f584c3dc7 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java @@ -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); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java index cc2ec4af9..46ab5f3ad 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java @@ -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()); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java index 7d1bfa347..6845b608a 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java @@ -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); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java index 8c29166e5..d7af3d523 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java @@ -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()); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java index 9e1e16aef..b40364096 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java @@ -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 getOrderComparison(); + + /** + * 获得订单量趋势统计 + * + * @param reqVO 统计参数 + * @return 订单量趋势统计 + */ + List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java index 10dd180d0..5daa727c8 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java @@ -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 getOrderComparison() { + return new TradeStatisticsComparisonRespVO() + .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> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { + // 查询当前数据 + List 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 reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); + + return IntStream.range(0, value.size()) + .mapToObj(index -> new TradeStatisticsComparisonRespVO() + .setValue(CollUtil.get(value, index)) + .setReference(CollUtil.get(reference, index))) + .collect(Collectors.toList()); + } + + private List getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { + // 情况一:按年统计时,以月份分组 + if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); + } + // 情况二:其它以天分组(天、周、月) + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); + } + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java index 1663ea27d..73d222160 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java @@ -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 getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java index 6a751a0cd..39be4f484 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java @@ -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; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml index 13bcdb419..ac418927e 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml @@ -2,23 +2,21 @@ - + 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 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 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml index 648e93fe8..c00e2d70e 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml @@ -30,4 +30,14 @@ + + diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml index 16cfe3be4..44f164f90 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml @@ -46,4 +46,11 @@ GROUP BY wallet_id + + diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml index 000cb26fd..933c45610 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml @@ -11,4 +11,11 @@ AND deleted = FALSE + + diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml index f8f9b2c11..dff7e444f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml @@ -11,4 +11,11 @@ AND deleted = FALSE + + diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml index 2cecd468e..406af4112 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml @@ -1,7 +1,6 @@ - + + + + + + + + + +