mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
commit
1502159608
2
sql/mysql/mall.sql
Normal file
2
sql/mysql/mall.sql
Normal 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');
|
1
sql/mysql/member.sql
Normal file
1
sql/mysql/member.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE member_user ADD COLUMN register_terminal tinyint NULL COMMENT '注册终端' AFTER register_ip;
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.common.util.servlet;
|
package cn.iocoder.yudao.framework.common.util.servlet;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
@ -88,6 +89,18 @@ public class ServletUtils {
|
|||||||
return ServletUtil.getClientIP(request);
|
return ServletUtil.getClientIP(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Integer getTerminal() {
|
||||||
|
return getHeaderInt("terminal");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getHeader(String header) {
|
||||||
|
return getHeader(getRequest(), header);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getHeaderInt(String header) {
|
||||||
|
return Convert.toInt(getHeader(header));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isJsonRequest(ServletRequest request) {
|
public static boolean isJsonRequest(ServletRequest request) {
|
||||||
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
|
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
|
||||||
}
|
}
|
||||||
@ -107,4 +120,12 @@ public class ServletUtils {
|
|||||||
public static Map<String, String> getParamMap(HttpServletRequest request) {
|
public static Map<String, String> getParamMap(HttpServletRequest request) {
|
||||||
return ServletUtil.getParamMap(request);
|
return ServletUtil.getParamMap(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getHeader(HttpServletRequest request, String header) {
|
||||||
|
if (request == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return request.getHeader(header);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,16 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo;
|
package cn.iocoder.yudao.module.statistics.controller.admin.common.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
// TODO @疯狂:是不是搞成公用的哈;类似,controller/admin/common,下面直接放它
|
@Schema(description = "管理后台 - 数据对照 Response VO")
|
||||||
@Schema(description = "管理后台 - 交易统计对照 Response VO")
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TradeStatisticsComparisonRespVO<T> {
|
public class DataComparisonRespVO<T> {
|
||||||
|
|
||||||
@Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private T value;
|
private T value;
|
@ -1,10 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.controller.admin.member;
|
package cn.iocoder.yudao.module.statistics.controller.admin.member;
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService;
|
||||||
import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -15,10 +20,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 会员统计")
|
@Tag(name = "管理后台 - 会员统计")
|
||||||
@RestController
|
@RestController
|
||||||
@ -29,6 +34,10 @@ public class MemberStatisticsController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MemberStatisticsService memberStatisticsService;
|
private MemberStatisticsService memberStatisticsService;
|
||||||
|
@Resource
|
||||||
|
private TradeOrderStatisticsService tradeOrderStatisticsService;
|
||||||
|
@Resource
|
||||||
|
private ApiAccessLogStatisticsService apiAccessLogStatisticsService;
|
||||||
|
|
||||||
// TODO 芋艿:已经 review
|
// TODO 芋艿:已经 review
|
||||||
@GetMapping("/summary")
|
@GetMapping("/summary")
|
||||||
@ -43,8 +52,28 @@ public class MemberStatisticsController {
|
|||||||
@Operation(summary = "获得会员分析数据")
|
@Operation(summary = "获得会员分析数据")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||||
public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) {
|
public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) {
|
||||||
return success(memberStatisticsService.getMemberAnalyse(
|
// 1. 查询数据
|
||||||
ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1)));
|
LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0);
|
||||||
|
LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1);
|
||||||
|
// 1.1 查询分析对照数据
|
||||||
|
DataComparisonRespVO<MemberAnalyseDataRespVO> comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime);
|
||||||
|
// TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度;
|
||||||
|
// 1.2 查询成交用户数量
|
||||||
|
Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime);
|
||||||
|
// 1.3 计算客单价
|
||||||
|
int atv = 0;
|
||||||
|
if (payUserCount != null && payUserCount > 0) {
|
||||||
|
// TODO @疯狂:类似上面的 payUserCount
|
||||||
|
Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime);
|
||||||
|
atv = NumberUtil.div(payPrice, payUserCount).intValue();
|
||||||
|
}
|
||||||
|
// 1.4 查询访客数量
|
||||||
|
Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime);
|
||||||
|
// 1.5 下单用户数量
|
||||||
|
Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime);
|
||||||
|
|
||||||
|
// 2. 拼接返回
|
||||||
|
return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:已经 review
|
// TODO 芋艿:已经 review
|
||||||
@ -67,12 +96,22 @@ public class MemberStatisticsController {
|
|||||||
@Operation(summary = "按照终端,获得会员统计列表")
|
@Operation(summary = "按照终端,获得会员统计列表")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||||
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
|
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
|
||||||
// TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal
|
return success(memberStatisticsService.getRegisterTerminalStatisticsList());
|
||||||
// TODO @疯狂:在 member_user 上,增加 registerTerminal 字段,基于它来统计哈;
|
}
|
||||||
List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(),
|
|
||||||
t -> new MemberTerminalStatisticsRespVO()
|
@GetMapping("/user-count-comparison")
|
||||||
.setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100));
|
@Operation(summary = "获得用户数量对照")
|
||||||
return success(list);
|
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||||
|
public CommonResult<DataComparisonRespVO<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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,15 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 会员分析对照数据 Response VO")
|
@Schema(description = "管理后台 - 会员分析数据 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class MemberAnalyseComparisonRespVO {
|
public class MemberAnalyseDataRespVO {
|
||||||
|
|
||||||
// TODO @疯狂:这个字段,要不改成注册用户量;registerUserCount;
|
|
||||||
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer userCount;
|
private Integer registerUserCount;
|
||||||
|
|
||||||
// TODO @疯狂:这个字段,名字改成 visitUserCount;有访问,就算活跃;
|
|
||||||
@Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer activeUserCount;
|
private Integer visitUserCount;
|
||||||
|
|
||||||
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
|
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
|
||||||
private Integer rechargeUserCount;
|
private Integer rechargeUserCount;
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.controller.admin.member.vo;
|
package 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.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -8,9 +8,8 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class MemberAnalyseRespVO {
|
public class MemberAnalyseRespVO {
|
||||||
|
|
||||||
// TODO @疯狂:这个字段改成 visitUserCount,保持和 userCount 字段统一
|
|
||||||
@Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer visitorCount;
|
private Integer visitUserCount;
|
||||||
|
|
||||||
@Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer orderUserCount;
|
private Integer orderUserCount;
|
||||||
@ -22,6 +21,6 @@ public class MemberAnalyseRespVO {
|
|||||||
private Integer atv;
|
private Integer atv;
|
||||||
|
|
||||||
@Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO> comparison;
|
private DataComparisonRespVO<MemberAnalyseDataRespVO> comparison;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,10 @@ public class MemberAreaStatisticsRespVO {
|
|||||||
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer userCount;
|
private Integer userCount;
|
||||||
|
|
||||||
// TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些;
|
@Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
@Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
private Integer orderCreateUserCount;
|
||||||
private Integer orderCreateCount;
|
@Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
|
||||||
@Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
|
private Integer orderPayUserCount;
|
||||||
private Integer orderPayCount;
|
|
||||||
|
|
||||||
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
|
@Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622")
|
||||||
private Integer orderPayPrice;
|
private Integer orderPayPrice;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,9 +3,17 @@ package cn.iocoder.yudao.module.statistics.controller.admin.trade;
|
|||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
|
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.convert.trade.TradeStatisticsConvert;
|
||||||
|
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
|
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.statistics.service.trade.TradeStatisticsService;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
||||||
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -17,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -31,46 +40,82 @@ public class TradeStatisticsController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TradeStatisticsService tradeStatisticsService;
|
private TradeStatisticsService tradeStatisticsService;
|
||||||
|
@Resource
|
||||||
|
private TradeOrderStatisticsService tradeOrderStatisticsService;
|
||||||
|
@Resource
|
||||||
|
private AfterSaleStatisticsService afterSaleStatisticsService;
|
||||||
|
@Resource
|
||||||
|
private BrokerageStatisticsService brokerageStatisticsService;
|
||||||
|
|
||||||
@GetMapping("/summary")
|
@GetMapping("/summary")
|
||||||
@Operation(summary = "获得交易统计")
|
@Operation(summary = "获得交易统计")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() {
|
public CommonResult<DataComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() {
|
||||||
// TODO @疯狂:这个要不要 tradeStatisticsService 调用里面的多个方法,组合出最终的 TradeSummaryRespVO;
|
// 1.1 昨天的数据
|
||||||
return success(tradeStatisticsService.getTradeSummaryComparison());
|
TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1);
|
||||||
|
// 1.2 前天的数据(用于对照昨天的数据)
|
||||||
|
TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2);
|
||||||
|
// 2.1 本月数据
|
||||||
|
TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0);
|
||||||
|
// 2.2 上月数据(用于对照本月的数据)
|
||||||
|
TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1);
|
||||||
|
// 拼接数据
|
||||||
|
return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse
|
// TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse
|
||||||
@GetMapping("/trend/summary")
|
@GetMapping("/trend/summary")
|
||||||
@Operation(summary = "获得交易状况统计")
|
@Operation(summary = "获得交易状况统计")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
public CommonResult<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison(
|
public CommonResult<DataComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison(
|
||||||
TradeTrendReqVO reqVO) {
|
TradeTrendReqVO reqVO) {
|
||||||
return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0),
|
return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0),
|
||||||
ArrayUtil.get(reqVO.getTimes(), 1)));
|
ArrayUtil.get(reqVO.getTimes(), 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:已经 review
|
@GetMapping("/list")
|
||||||
// TODO @疯狂:这个要不直接叫 list;它即使就是把每条统计拿出来
|
|
||||||
@GetMapping("/trend/list")
|
|
||||||
@Operation(summary = "获得交易状况明细")
|
@Operation(summary = "获得交易状况明细")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList(
|
public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList(TradeTrendReqVO reqVO) {
|
||||||
TradeTrendReqVO reqVO) {
|
List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0),
|
||||||
return success(tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0),
|
ArrayUtil.get(reqVO.getTimes(), 1));
|
||||||
ArrayUtil.get(reqVO.getTimes(), 1)));
|
return success(TradeStatisticsConvert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:这个要不直接叫 export;它即使就是把每条统计导出
|
@GetMapping("/export-excel")
|
||||||
@GetMapping("/trend/export-excel")
|
|
||||||
@Operation(summary = "导出获得交易状况明细 Excel")
|
@Operation(summary = "导出获得交易状况明细 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:export')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:export')")
|
||||||
public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException {
|
public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException {
|
||||||
List<TradeTrendSummaryRespVO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0),
|
List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0),
|
||||||
ArrayUtil.get(reqVO.getTimes(), 1));
|
ArrayUtil.get(reqVO.getTimes(), 1));
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(list);
|
List<TradeTrendSummaryRespVO> voList = TradeStatisticsConvert.INSTANCE.convertList(list);
|
||||||
|
List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(voList);
|
||||||
ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data);
|
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<DataComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() {
|
||||||
|
return success(tradeOrderStatisticsService.getOrderComparison());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/order-count-trend")
|
||||||
|
@Operation(summary = "获得订单量趋势统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
|
public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) {
|
||||||
|
return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -22,7 +22,7 @@ public class TradeTrendSummaryExcelVO {
|
|||||||
private LocalDate date;
|
private LocalDate date;
|
||||||
|
|
||||||
@ExcelProperty(value = "营业额", converter = MoneyConvert.class)
|
@ExcelProperty(value = "营业额", converter = MoneyConvert.class)
|
||||||
private Integer turnover;
|
private Integer turnoverPrice;
|
||||||
|
|
||||||
@ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class)
|
@ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class)
|
||||||
private Integer orderPayPrice;
|
private Integer orderPayPrice;
|
||||||
@ -34,7 +34,7 @@ public class TradeTrendSummaryExcelVO {
|
|||||||
private Integer expensePrice;
|
private Integer expensePrice;
|
||||||
|
|
||||||
@ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class)
|
@ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class)
|
||||||
private Integer balancePrice;
|
private Integer orderWalletPayPrice;
|
||||||
|
|
||||||
@ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class)
|
@ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class)
|
||||||
private Integer brokerageSettlementPrice;
|
private Integer brokerageSettlementPrice;
|
||||||
|
@ -16,13 +16,15 @@ public class TradeTrendSummaryRespVO {
|
|||||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||||
private LocalDate date;
|
private LocalDate date;
|
||||||
|
|
||||||
// TODO @疯狂,要不加个 turnoverPrice?
|
|
||||||
@Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer turnover; // 营业额 = 商品支付金额 + 充值金额
|
private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额
|
||||||
|
|
||||||
@Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer orderPayPrice;
|
private Integer orderPayPrice;
|
||||||
|
|
||||||
|
@Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Integer orderWalletPayPrice;
|
||||||
|
|
||||||
@Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer orderRefundPrice;
|
private Integer orderRefundPrice;
|
||||||
|
|
||||||
@ -35,7 +37,4 @@ public class TradeTrendSummaryRespVO {
|
|||||||
@Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额
|
private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额
|
||||||
|
|
||||||
@Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Integer balancePrice; // TODO @疯狂:这个字段要不改成:walletPayPrice
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@ import cn.hutool.core.map.MapUtil;
|
|||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO;
|
||||||
|
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.MemberAreaStatisticsRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
@ -28,16 +31,20 @@ public interface MemberStatisticsConvert {
|
|||||||
Map<Integer, Integer> userCountMap,
|
Map<Integer, Integer> userCountMap,
|
||||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
|
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
|
||||||
return CollectionUtils.convertList(areaList, area -> {
|
return CollectionUtils.convertList(areaList, area -> {
|
||||||
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())).orElseGet(MemberAreaStatisticsRespVO::new);
|
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
|
||||||
|
.orElseGet(MemberAreaStatisticsRespVO::new);
|
||||||
return new MemberAreaStatisticsRespVO()
|
return new MemberAreaStatisticsRespVO()
|
||||||
.setAreaId(area.getId()).setAreaName(area.getName())
|
.setAreaId(area.getId()).setAreaName(area.getName())
|
||||||
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))
|
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))
|
||||||
.setOrderCreateCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateCount(), 0))
|
.setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0))
|
||||||
.setOrderPayCount(ObjUtil.defaultIfNull(orderVo.getOrderPayCount(), 0))
|
.setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0))
|
||||||
.setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0));
|
.setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount);
|
MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount);
|
||||||
|
|
||||||
|
MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv,
|
||||||
|
DataComparisonRespVO<MemberAnalyseDataRespVO> comparison);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.convert.trade;
|
package cn.iocoder.yudao.module.statistics.convert.trade;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
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.TradeSummaryRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
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.TradeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public interface TradeStatisticsConvert {
|
|||||||
|
|
||||||
TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class);
|
TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class);
|
||||||
|
|
||||||
default TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData,
|
default DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData,
|
||||||
TradeSummaryRespBO beforeYesterdayData,
|
TradeSummaryRespBO beforeYesterdayData,
|
||||||
TradeSummaryRespBO monthData,
|
TradeSummaryRespBO monthData,
|
||||||
TradeSummaryRespBO lastMonthData) {
|
TradeSummaryRespBO lastMonthData) {
|
||||||
@ -39,9 +39,9 @@ public interface TradeStatisticsConvert {
|
|||||||
.setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary());
|
.setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary());
|
||||||
}
|
}
|
||||||
|
|
||||||
TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference);
|
DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference);
|
||||||
|
|
||||||
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value,
|
DataComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value,
|
||||||
TradeTrendSummaryRespVO reference);
|
TradeTrendSummaryRespVO reference);
|
||||||
|
|
||||||
List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list);
|
List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list);
|
||||||
@ -50,4 +50,20 @@ public interface TradeStatisticsConvert {
|
|||||||
AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice,
|
AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice,
|
||||||
WalletSummaryRespBO walletSummary);
|
WalletSummaryRespBO walletSummary);
|
||||||
|
|
||||||
|
List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list);
|
||||||
|
|
||||||
|
default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) {
|
||||||
|
return new TradeTrendSummaryRespVO()
|
||||||
|
.setDate(tradeStatistics.getTime().toLocalDate())
|
||||||
|
// 营业额 = 商品支付金额 + 充值金额
|
||||||
|
.setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice())
|
||||||
|
.setOrderPayPrice(tradeStatistics.getOrderPayPrice())
|
||||||
|
.setRechargePrice(tradeStatistics.getRechargePayPrice())
|
||||||
|
// 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
||||||
|
.setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice())
|
||||||
|
.setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice())
|
||||||
|
.setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice())
|
||||||
|
.setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,6 @@ public class TradeStatisticsDO extends TenantBaseDO {
|
|||||||
* 总支付金额,单位:分
|
* 总支付金额,单位:分
|
||||||
*/
|
*/
|
||||||
private Integer orderPayPrice;
|
private Integer orderPayPrice;
|
||||||
// TODO @疯狂:这个字段改成 walletPayPrice,然后挪到 rechargePayCount 前面;
|
|
||||||
/**
|
|
||||||
* 总支付金额(余额),单位:分
|
|
||||||
*/
|
|
||||||
private Integer orderWalletPayPrice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款订单数
|
* 退款订单数
|
||||||
@ -68,6 +63,10 @@ public class TradeStatisticsDO extends TenantBaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer brokerageSettlementPrice;
|
private Integer brokerageSettlementPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总支付金额(余额),单位:分
|
||||||
|
*/
|
||||||
|
private Integer orderWalletPayPrice;
|
||||||
/**
|
/**
|
||||||
* 充值订单数
|
* 充值订单数
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -13,14 +13,15 @@ import java.time.LocalDateTime;
|
|||||||
* @author owen
|
* @author owen
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public interface ApiAccessLogStatisticsMapper extends BaseMapperX {
|
||||||
|
|
||||||
// TODO @疯狂:是不是 selectIpCount
|
Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType,
|
||||||
Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime,
|
@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
// TODO @疯狂:是不是 selectUserCount
|
Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType,
|
||||||
Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime,
|
@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.dal.mysql.member;
|
package cn.iocoder.yudao.module.statistics.dal.mysql.member;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@ -15,16 +17,20 @@ import java.util.List;
|
|||||||
* @author owen
|
* @author owen
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberStatisticsMapper extends BaseMapperX<Object> {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public interface MemberStatisticsMapper extends BaseMapperX {
|
||||||
|
|
||||||
// TODO @芋艿:已经 review
|
List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId();
|
||||||
// TODO @疯狂:要不还是搞下 bo?虽然可能冗余了点~~
|
|
||||||
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
|
||||||
|
|
||||||
List<MemberSexStatisticsRespVO> selectSummaryListBySex();
|
List<MemberSexStatisticsRespVO> selectSummaryListBySex();
|
||||||
|
|
||||||
|
List<MemberTerminalStatisticsRespVO> selectSummaryListByRegisterTerminal();
|
||||||
|
|
||||||
// TODO @芋艿:已经 review
|
// TODO @芋艿:已经 review
|
||||||
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
List<MemberRegisterCountRespVO> selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
|
package cn.iocoder.yudao.module.statistics.dal.mysql.pay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -15,7 +14,8 @@ import java.time.LocalDateTime;
|
|||||||
* @author owen
|
* @author owen
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public interface PayWalletStatisticsMapper extends BaseMapperX {
|
||||||
|
|
||||||
// TODO 芋艿:已经 review;
|
// TODO 芋艿:已经 review;
|
||||||
WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@ -37,4 +37,6 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO
|
|||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("payStatus") Boolean payStatus);
|
@Param("payStatus") Boolean payStatus);
|
||||||
|
|
||||||
|
Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,6 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO
|
|||||||
AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
Long selectCountByStatus(@Param("status") Integer status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,6 @@ public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO
|
|||||||
@Param("beginTime") LocalDateTime beginTime,
|
@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
Long selectWithdrawCountByStatus(@Param("status") Integer status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.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.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 cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -40,4 +42,32 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
|
|||||||
Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
|
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
||||||
@ -21,14 +22,20 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
|||||||
TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
TradeTrendSummaryRespVO selectByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
// TODO @芋艿:已经 review
|
default List<TradeStatisticsDO> selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
return selectList(new LambdaQueryWrapperX<TradeStatisticsDO>()
|
||||||
@Param("endTime") LocalDateTime endTime);
|
.between(TradeStatisticsDO::getTime, beginTime, endTime));
|
||||||
|
}
|
||||||
|
|
||||||
Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
|
return selectOne(new LambdaQueryWrapperX<TradeStatisticsDO>()
|
||||||
|
.between(TradeStatisticsDO::getTime, beginTime, endTime));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.job.trade;
|
package cn.iocoder.yudao.module.statistics.job.trade;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||||
@ -19,11 +21,24 @@ public class TradeStatisticsJob implements JobHandler {
|
|||||||
@Resource
|
@Resource
|
||||||
private TradeStatisticsService tradeStatisticsService;
|
private TradeStatisticsService tradeStatisticsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行交易统计任务
|
||||||
|
*
|
||||||
|
* @param param 要统计的天数,只能是正整数,1 代表昨日数据
|
||||||
|
* @return 统计结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@TenantJob
|
@TenantJob
|
||||||
public String execute(String param) {
|
public String execute(String param) {
|
||||||
String times = tradeStatisticsService.statisticsYesterdayTrade();
|
if (NumberUtil.isInteger(param)) {
|
||||||
return StrUtil.format("交易统计耗时: {}", times);
|
throw new RuntimeException("交易统计任务的参数只能为是正整数");
|
||||||
|
}
|
||||||
|
Integer days = Convert.toInt(param, 0);
|
||||||
|
if (days < 1) {
|
||||||
|
throw new RuntimeException("交易统计任务的参数只能为是正整数");
|
||||||
|
}
|
||||||
|
String result = tradeStatisticsService.statisticsTrade(days);
|
||||||
|
return StrUtil.format("交易统计:\n{}", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,26 +9,24 @@ import java.time.LocalDateTime;
|
|||||||
*/
|
*/
|
||||||
public interface ApiAccessLogStatisticsService {
|
public interface ApiAccessLogStatisticsService {
|
||||||
|
|
||||||
// TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型;
|
|
||||||
// TODO @疯狂:方法名,要不改成 getUserCount;原因:让它更业务无关
|
|
||||||
/**
|
/**
|
||||||
* 获取活跃用户数量
|
* 获取活跃用户数量
|
||||||
*
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
* @param beginTime 起始时间
|
* @param beginTime 起始时间
|
||||||
* @param endTime 截止时间
|
* @param endTime 截止时间
|
||||||
* @return 活跃用户数量
|
* @return 活跃用户数量
|
||||||
*/
|
*/
|
||||||
Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
// TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型;
|
|
||||||
// TODO @疯狂:方法名,要不改成 getIpCount;原因:让它更业务无关
|
|
||||||
/**
|
/**
|
||||||
* 获取访问用户数量
|
* 获取访问用户数量
|
||||||
*
|
*
|
||||||
|
* @param userType 用户类型
|
||||||
* @param beginTime 起始时间
|
* @param beginTime 起始时间
|
||||||
* @param endTime 截止时间
|
* @param endTime 截止时间
|
||||||
* @return 访问用户数量
|
* @return 访问用户数量
|
||||||
*/
|
*/
|
||||||
Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime);
|
Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatistics
|
|||||||
private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper;
|
private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime);
|
return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
|
public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime);
|
return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.member;
|
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.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
||||||
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.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,15 +21,15 @@ public interface MemberStatisticsService {
|
|||||||
*/
|
*/
|
||||||
MemberSummaryRespVO getMemberSummary();
|
MemberSummaryRespVO getMemberSummary();
|
||||||
|
|
||||||
// TODO 芋艿:已经 review
|
|
||||||
/**
|
/**
|
||||||
* 获取用户分析数据
|
* 获取会员分析对照数据
|
||||||
*
|
*
|
||||||
* @param beginTime 起始时间
|
* @param beginTime 起始时间
|
||||||
* @param endTime 截止时间
|
* @param endTime 截止时间
|
||||||
* @return 用户分析数据
|
* @return 会员分析对照数据
|
||||||
*/
|
*/
|
||||||
MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime);
|
DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime,
|
||||||
|
LocalDateTime endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照省份,获得会员统计列表
|
* 按照省份,获得会员统计列表
|
||||||
@ -47,4 +45,27 @@ public interface MemberStatisticsService {
|
|||||||
*/
|
*/
|
||||||
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
|
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照终端,获得会员统计列表
|
||||||
|
*
|
||||||
|
* @return 会员统计列表
|
||||||
|
*/
|
||||||
|
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户注册数量列表
|
||||||
|
*
|
||||||
|
* @param beginTime 起始时间
|
||||||
|
* @param endTime 截止时间
|
||||||
|
* @return 注册数量列表
|
||||||
|
*/
|
||||||
|
List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得用户数量量统计对照
|
||||||
|
*
|
||||||
|
* @return 用户数量量统计对照
|
||||||
|
*/
|
||||||
|
DataComparisonRespVO<MemberCountRespVO> getUserCountComparison();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.member;
|
package cn.iocoder.yudao.module.statistics.service.member;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
|
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*;
|
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.dal.mysql.member.MemberStatisticsMapper;
|
||||||
import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@ -57,63 +60,77 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
|
|||||||
@Override
|
@Override
|
||||||
public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() {
|
public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() {
|
||||||
// 统计用户
|
// 统计用户
|
||||||
// TODO @疯狂:要处理下,未知省份;就是没填写省份的情况;
|
|
||||||
// TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = =
|
// TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = =
|
||||||
Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(),
|
Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(),
|
||||||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||||
MemberAreaStatisticsRespVO::getUserCount, Integer::sum);
|
MemberAreaStatisticsRespBO::getUserCount, Integer::sum);
|
||||||
// 统计订单
|
// 统计订单
|
||||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
|
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
|
||||||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||||
vo -> vo,
|
vo -> vo,
|
||||||
(a, b) -> new MemberAreaStatisticsRespVO()
|
(a, b) -> new MemberAreaStatisticsRespVO()
|
||||||
.setOrderCreateCount(a.getOrderCreateCount() + b.getOrderCreateCount())
|
.setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount())
|
||||||
.setOrderPayCount(a.getOrderPayCount() + b.getOrderPayCount())
|
.setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount())
|
||||||
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
|
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
|
||||||
// 拼接数据
|
// 拼接数据
|
||||||
return MemberStatisticsConvert.INSTANCE.convertList(AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area), userCountMap, orderMap);
|
List<Area> areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area);
|
||||||
|
areaList.add(new Area().setId(null).setName("未知"));
|
||||||
|
return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:这个方法,要不拆成:1)controller 调用 getMemberAnalyseComparisonData;2)tradeOrderStatisticsService.getPayUserCount;3)tradeOrderStatisticsService.getOrderPayPrice;4)。。。
|
|
||||||
// TODO 就是说:分析交给 controller 去组合;
|
|
||||||
@Override
|
@Override
|
||||||
public MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime) {
|
public DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
|
// 当前数据
|
||||||
|
MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime);
|
||||||
// 对照数据
|
// 对照数据
|
||||||
MemberAnalyseComparisonRespVO vo = getMemberAnalyseComparisonData(beginTime, endTime);
|
LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠
|
||||||
// TODO @疯狂:如果时间段这么处理,会不会 beginTime 重叠了。因为是 <= 一个时间;如果数据库插入的是 ,xxxx-yy-zz 00:00:00 的话,它既满足 >= ? 也满足 <= ;(如果不好理解,微信聊)
|
LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime));
|
||||||
LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime));
|
MemberAnalyseDataRespVO reference = getMemberAnalyseData(
|
||||||
MemberAnalyseComparisonRespVO reference = getMemberAnalyseComparisonData(referenceBeginTime, beginTime);
|
LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate));
|
||||||
|
return new DataComparisonRespVO<>(vo, reference);
|
||||||
// 计算客单价
|
|
||||||
// TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度;
|
|
||||||
Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime);
|
|
||||||
int atv = 0;
|
|
||||||
if (payUserCount != null && payUserCount > 0) {
|
|
||||||
// TODO @疯狂:类似上面的 payUserCount
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) {
|
private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime))
|
Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime))
|
||||||
.map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0);
|
.map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0);
|
||||||
return new MemberAnalyseComparisonRespVO()
|
return new MemberAnalyseDataRespVO()
|
||||||
.setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
|
.setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
|
||||||
.setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime))
|
.setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime))
|
||||||
.setRechargeUserCount(rechargeUserCount);
|
.setRechargeUserCount(rechargeUserCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() {
|
public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() {
|
||||||
// TODO @疯狂:需要考虑,用户性别为空,则是“未知”
|
|
||||||
return memberStatisticsMapper.selectSummaryListBySex();
|
return memberStatisticsMapper.selectSummaryListBySex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() {
|
||||||
|
return memberStatisticsMapper.selectSummaryListByRegisterTerminal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
|
return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataComparisonRespVO<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 DataComparisonRespVO<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.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package cn.iocoder.yudao.module.statistics.service.member.bo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 会员地区统计 Response BO")
|
||||||
|
@Data
|
||||||
|
public class MemberAreaStatisticsRespBO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 省份编号
|
||||||
|
*/
|
||||||
|
private Integer areaId;
|
||||||
|
/**
|
||||||
|
* 省份名称
|
||||||
|
*/
|
||||||
|
private String areaName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员数量
|
||||||
|
*/
|
||||||
|
private Integer userCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下单的会员数量
|
||||||
|
*/
|
||||||
|
private Integer orderCreateUserCount;
|
||||||
|
/**
|
||||||
|
* 支付订单的会员数量
|
||||||
|
*/
|
||||||
|
private Integer orderPayUserCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单支付金额,单位:分
|
||||||
|
*/
|
||||||
|
private Integer orderPayPrice;
|
||||||
|
|
||||||
|
}
|
@ -32,4 +32,11 @@ public interface PayWalletStatisticsService {
|
|||||||
*/
|
*/
|
||||||
RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取充值金额合计
|
||||||
|
*
|
||||||
|
* @return 充值金额合计
|
||||||
|
*/
|
||||||
|
Integer getRechargePriceSummary();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.pay;
|
package cn.iocoder.yudao.module.statistics.service.pay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
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.dal.mysql.pay.PayWalletStatisticsMapper;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
|
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);
|
return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getRechargePriceSummary() {
|
||||||
|
return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,21 @@ package cn.iocoder.yudao.module.statistics.service.pay.bo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
// TODO @疯狂:BO 不用写 swagger 注解哈,写注释就好啦;
|
/**
|
||||||
@Schema(description = "管理后台 - 充值统计 Response VO")
|
* 充值统计 Response BO
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - ")
|
||||||
@Data
|
@Data
|
||||||
public class RechargeSummaryRespBO {
|
public class RechargeSummaryRespBO {
|
||||||
|
|
||||||
@Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221")
|
/**
|
||||||
|
* 充值会员数量
|
||||||
|
*/
|
||||||
private Integer rechargeUserCount;
|
private Integer rechargeUserCount;
|
||||||
|
|
||||||
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
/**
|
||||||
|
* 充值金额
|
||||||
|
*/
|
||||||
private Integer rechargePrice;
|
private Integer rechargePrice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@ -21,4 +22,12 @@ public interface AfterSaleStatisticsService {
|
|||||||
*/
|
*/
|
||||||
AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定状态的售后订单数量
|
||||||
|
*
|
||||||
|
* @param status 售后状态
|
||||||
|
* @return 售后订单数量
|
||||||
|
*/
|
||||||
|
Long getCountByStatus(AfterSaleStatusEnum status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.dal.mysql.trade.AfterSaleStatisticsMapper;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO;
|
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.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -25,4 +26,9 @@ public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsServic
|
|||||||
return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime);
|
return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getCountByStatus(AfterSaleStatusEnum status) {
|
||||||
|
return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,4 +21,12 @@ public interface BrokerageStatisticsService {
|
|||||||
*/
|
*/
|
||||||
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定状态的提现记录数量
|
||||||
|
*
|
||||||
|
* @param status 提现记录状态
|
||||||
|
* @return 提现记录数量
|
||||||
|
*/
|
||||||
|
Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.statistics.dal.mysql.trade.BrokerageStatisticsMapper;
|
||||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
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.BrokerageRecordStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -28,4 +29,9 @@ public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsServic
|
|||||||
beginTime, endTime);
|
beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) {
|
||||||
|
return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -60,4 +62,26 @@ public interface TradeOrderStatisticsService {
|
|||||||
*/
|
*/
|
||||||
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
|
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得交易订单数量
|
||||||
|
*
|
||||||
|
* @return 订单数量
|
||||||
|
*/
|
||||||
|
TradeOrderCountRespVO getOrderCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易订单销售额对照
|
||||||
|
*
|
||||||
|
* @return 销售额对照
|
||||||
|
*/
|
||||||
|
DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得订单量趋势统计
|
||||||
|
*
|
||||||
|
* @param reqVO 统计参数
|
||||||
|
* @return 订单量趋势统计
|
||||||
|
*/
|
||||||
|
List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,25 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
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.common.vo.DataComparisonRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
|
||||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper;
|
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.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 交易订单统计 Service 实现类
|
* 交易订单统计 Service 实现类
|
||||||
@ -50,4 +61,53 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
|
|||||||
return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime);
|
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 DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison() {
|
||||||
|
return new DataComparisonRespVO<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<DataComparisonRespVO<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 DataComparisonRespVO<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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
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.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,19 +15,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface TradeStatisticsService {
|
public interface TradeStatisticsService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得交易统计
|
|
||||||
*
|
|
||||||
* @return 统计数据对照
|
|
||||||
*/
|
|
||||||
TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得交易状况统计对照
|
* 获得交易状况统计对照
|
||||||
*
|
*
|
||||||
* @return 统计数据对照
|
* @return 统计数据对照
|
||||||
*/
|
*/
|
||||||
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(
|
DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(
|
||||||
LocalDateTime beginTime, LocalDateTime endTime);
|
LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,16 +35,34 @@ public interface TradeStatisticsService {
|
|||||||
/**
|
/**
|
||||||
* 获得交易状况明细
|
* 获得交易状况明细
|
||||||
*
|
*
|
||||||
|
* @param beginTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
* @return 统计数据列表
|
* @return 统计数据列表
|
||||||
*/
|
*/
|
||||||
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
|
List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
// TODO 芋艿:已经 review;
|
// TODO 芋艿:已经 review;
|
||||||
/**
|
/**
|
||||||
* 统计昨日交易
|
* 统计指定天数的交易数据
|
||||||
*
|
*
|
||||||
* @return 耗时
|
* @return 统计结果
|
||||||
*/
|
*/
|
||||||
String statisticsYesterdayTrade();
|
String statisticsTrade(Integer days);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计指定日期的交易数据
|
||||||
|
*
|
||||||
|
* @param days 增加的天数
|
||||||
|
* @return 交易数据
|
||||||
|
*/
|
||||||
|
TradeSummaryRespBO getTradeSummaryByDays(int days);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计指定月份的交易数据
|
||||||
|
*
|
||||||
|
* @param months 增加的月数
|
||||||
|
* @return 交易数据
|
||||||
|
*/
|
||||||
|
TradeSummaryRespBO getTradeSummaryByMonths(int months);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.statistics.service.trade;
|
package cn.iocoder.yudao.module.statistics.service.trade;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
|
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
|
||||||
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.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
||||||
import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert;
|
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.dataobject.trade.TradeStatisticsDO;
|
||||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper;
|
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.AfterSaleSummaryRespBO;
|
||||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
|
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.stereotype.Service;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -21,6 +21,8 @@ import javax.annotation.Resource;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 交易统计 Service 实现类
|
* 交易统计 Service 实现类
|
||||||
@ -44,51 +46,27 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
|||||||
private PayWalletStatisticsService payWalletStatisticsService;
|
private PayWalletStatisticsService payWalletStatisticsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() {
|
public TradeSummaryRespBO getTradeSummaryByDays(int days) {
|
||||||
// 1.1 昨天的数据
|
|
||||||
TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1);
|
|
||||||
// 1.2 前天的数据(用于对照昨天的数据)
|
|
||||||
TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2);
|
|
||||||
// 2.1 本月数据
|
|
||||||
TradeSummaryRespBO monthData = getTradeSummaryByMonths(0);
|
|
||||||
// 2.2 上月数据(用于对照本月的数据)
|
|
||||||
TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1);
|
|
||||||
// 转换返回
|
|
||||||
return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计指定日期的交易数据
|
|
||||||
*
|
|
||||||
* @param days 增加的天数
|
|
||||||
* @return 交易数据
|
|
||||||
*/
|
|
||||||
private TradeSummaryRespBO getTradeSummaryByDays(int days) {
|
|
||||||
LocalDateTime date = LocalDateTime.now().plusDays(days);
|
LocalDateTime date = LocalDateTime.now().plusDays(days);
|
||||||
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
||||||
LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date));
|
LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 统计指定月份的交易数据
|
public TradeSummaryRespBO getTradeSummaryByMonths(int months) {
|
||||||
*
|
|
||||||
* @param months 增加的月数
|
|
||||||
* @return 交易数据
|
|
||||||
*/
|
|
||||||
private TradeSummaryRespBO getTradeSummaryByMonths(int months) {
|
|
||||||
LocalDateTime monthDate = LocalDateTime.now().plusMonths(months);
|
LocalDateTime monthDate = LocalDateTime.now().plusMonths(months);
|
||||||
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
||||||
LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate));
|
LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime,
|
public DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime,
|
||||||
LocalDateTime endTime) {
|
LocalDateTime endTime) {
|
||||||
// 统计数据
|
// 统计数据
|
||||||
TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime);
|
TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime);
|
||||||
// 对照数据
|
// 对照数据
|
||||||
LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime));
|
LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime));
|
||||||
TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectByTimeBetween(referenceBeginTime, beginTime);
|
TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime);
|
||||||
return TradeStatisticsConvert.INSTANCE.convert(value, reference);
|
return TradeStatisticsConvert.INSTANCE.convert(value, reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,41 +75,60 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
|||||||
return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime);
|
return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:是不是直接返回 TradeStatisticsDO;上层在去聚合?
|
|
||||||
@Override
|
@Override
|
||||||
public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) {
|
public List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String statisticsYesterdayTrade() {
|
public String statisticsTrade(Integer days) {
|
||||||
// TODO @疯狂:如果已经统计,则跳过;
|
LocalDateTime today = LocalDateTime.now();
|
||||||
// TODO @疯狂:改成 statisticsTrade,然后传入 days,统计多少天;days 通过 job 传参;方便把历史给统计出来;或者大家有的时候要修复数据(会 fix 业务数据,然后清理统计表),重新统计的时候;
|
return IntStream.rangeClosed(1, days)
|
||||||
// 1. 从各个数据表,统计对应数据
|
.parallel()
|
||||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
.mapToObj(day -> statisticsTrade(today.minusDays(day)))
|
||||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
.sorted()
|
||||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
.collect(Collectors.joining("\n"));
|
||||||
// 1.1 统计订单
|
}
|
||||||
StopWatch stopWatch = new StopWatch("交易统计");
|
|
||||||
|
/**
|
||||||
|
* 统计交易数据
|
||||||
|
*
|
||||||
|
* @param date 需要统计的日期
|
||||||
|
* @return 统计结果
|
||||||
|
*/
|
||||||
|
private String statisticsTrade(LocalDateTime date) {
|
||||||
|
// 1. 处理统计时间范围
|
||||||
|
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date);
|
||||||
|
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date);
|
||||||
|
String dateStr = DatePattern.NORM_DATE_FORMAT.format(date);
|
||||||
|
// 2. 检查该日是否已经统计过
|
||||||
|
TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime);
|
||||||
|
if (entity != null) {
|
||||||
|
return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 从各个数据表,统计对应数据
|
||||||
|
StopWatch stopWatch = new StopWatch(dateStr);
|
||||||
|
// 3.1 统计订单
|
||||||
stopWatch.start("统计订单");
|
stopWatch.start("统计订单");
|
||||||
TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime);
|
TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
// 1.2 统计售后
|
// 3.2 统计售后
|
||||||
stopWatch.start("统计售后");
|
stopWatch.start("统计售后");
|
||||||
AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime);
|
AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
// 1.3 统计佣金
|
// 3.3 统计佣金
|
||||||
stopWatch.start("统计佣金");
|
stopWatch.start("统计佣金");
|
||||||
Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime);
|
Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
// 1.4 统计充值
|
// 3.4 统计充值
|
||||||
stopWatch.start("统计充值");
|
stopWatch.start("统计充值");
|
||||||
WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime);
|
WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
// 2. 插入数据
|
// 4. 插入数据
|
||||||
TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary,
|
entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice,
|
||||||
brokerageSettlementPrice, walletSummary);
|
walletSummary);
|
||||||
tradeStatisticsMapper.insert(entity);
|
tradeStatisticsMapper.insert(entity);
|
||||||
return stopWatch.prettyPrint();
|
return stopWatch.prettyPrint();
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,21 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper">
|
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper">
|
||||||
|
|
||||||
<select id="selectCountByIp" resultType="java.lang.Integer">
|
<select id="selectIpCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer">
|
||||||
<!-- TODO @疯狂:distinct 会不会更合适哈 -->
|
SELECT COUNT(DISTINCT user_ip)
|
||||||
SELECT COUNT(1)
|
|
||||||
FROM infra_api_access_log
|
FROM infra_api_access_log
|
||||||
WHERE create_time BETWEEN #{beginTime} AND #{endTime}
|
WHERE user_type = #{userType}
|
||||||
AND deleted = FALSE
|
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||||
GROUP BY user_ip
|
AND deleted = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCountByUserId" resultType="java.lang.Integer">
|
<select id="selectUserCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer">
|
||||||
<!-- TODO @疯狂:distinct 会不会更合适哈 -->
|
SELECT COUNT(DISTINCT user_id)
|
||||||
SELECT COUNT(1)
|
FROM infra_api_access_log
|
||||||
FROM infra_api_access_log
|
WHERE user_id > 0
|
||||||
WHERE user_id > 0
|
AND user_type = #{userType}
|
||||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
GROUP BY user_id
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper">
|
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper">
|
||||||
|
|
||||||
<select id="selectSummaryListByAreaId"
|
<select id="selectSummaryListByAreaId"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
|
resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO">
|
||||||
SELECT area_id, COUNT(1) AS userCount
|
SELECT area_id, COUNT(1) AS userCount
|
||||||
FROM member_user
|
FROM member_user
|
||||||
WHERE deleted = FALSE
|
WHERE deleted = FALSE
|
||||||
@ -18,6 +18,14 @@
|
|||||||
GROUP BY sex
|
GROUP BY sex
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSummaryListByRegisterTerminal"
|
||||||
|
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO">
|
||||||
|
SELECT register_terminal as terminal, COUNT(1) AS userCount
|
||||||
|
FROM member_user
|
||||||
|
WHERE deleted = FALSE
|
||||||
|
GROUP BY register_terminal
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectUserCount" resultType="java.lang.Integer">
|
<select id="selectUserCount" resultType="java.lang.Integer">
|
||||||
SELECT COUNT(1)
|
SELECT COUNT(1)
|
||||||
FROM member_user
|
FROM member_user
|
||||||
@ -30,4 +38,14 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
<select id="selectRechargeSummaryGroupByWalletId"
|
<select id="selectRechargeSummaryGroupByWalletId"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO">
|
resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO">
|
||||||
<!-- TODO @疯狂:是不是不用 group by,而是通过 DISTINCT wallet_id 更合适哈? -->
|
SELECT COUNT(DISTINCT wallet_id) AS rechargeUserCount,
|
||||||
SELECT COUNT(1) AS rechargeUserCount,
|
|
||||||
SUM(pay_price) AS rechargePrice
|
SUM(pay_price) AS rechargePrice
|
||||||
FROM pay_wallet_recharge
|
FROM pay_wallet_recharge
|
||||||
WHERE pay_status = #{payStatus}
|
WHERE pay_status = #{payStatus}
|
||||||
@ -44,7 +43,13 @@
|
|||||||
AND pay_time <= #{endTime}
|
AND pay_time <= #{endTime}
|
||||||
</if>
|
</if>
|
||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
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>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -11,4 +11,11 @@
|
|||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCountByStatus" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM trade_after_sale
|
||||||
|
WHERE status = #{status}
|
||||||
|
AND deleted = FALSE
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -11,4 +11,11 @@
|
|||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectWithdrawCountByStatus" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM trade_brokerage_withdraw
|
||||||
|
WHERE status = #{status}
|
||||||
|
AND deleted = FALSE
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper">
|
||||||
|
|
||||||
<select id="selectSummaryListByAreaId"
|
<select id="selectSummaryListByAreaId"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
|
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
|
||||||
SELECT receiver_area_id AS areaId,
|
SELECT receiver_area_id AS areaId,
|
||||||
(SELECT COUNT(1)
|
(SELECT COUNT(DISTINCT s.user_id)
|
||||||
FROM trade_order AS s
|
FROM trade_order AS s
|
||||||
WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount,
|
WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount,
|
||||||
(SELECT COUNT(1)
|
(SELECT COUNT(DISTINCT s.user_id)
|
||||||
FROM trade_order AS s
|
FROM trade_order AS s
|
||||||
WHERE s.receiver_area_id = m.receiver_area_id
|
WHERE s.receiver_area_id = m.receiver_area_id
|
||||||
AND s.pay_status = TRUE
|
AND s.pay_status = TRUE
|
||||||
AND s.deleted = FALSE) AS orderPayCount,
|
AND s.deleted = FALSE) AS orderPayUserCount,
|
||||||
(SELECT SUM(s.pay_price)
|
(SELECT SUM(s.pay_price)
|
||||||
FROM trade_order AS s
|
FROM trade_order AS s
|
||||||
WHERE s.receiver_area_id = m.receiver_area_id
|
WHERE s.receiver_area_id = m.receiver_area_id
|
||||||
@ -24,14 +23,14 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
|
<select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer">
|
||||||
SELECT COUNT(DISTINCT(user_id))
|
SELECT COUNT(DISTINCT (user_id))
|
||||||
FROM trade_order
|
FROM trade_order
|
||||||
WHERE deleted = FALSE
|
WHERE deleted = FALSE
|
||||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
|
<select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer">
|
||||||
SELECT COUNT(DISTINCT(user_id))
|
SELECT COUNT(DISTINCT (user_id))
|
||||||
FROM trade_order
|
FROM trade_order
|
||||||
WHERE pay_time BETWEEN #{beginTime} AND #{endTime}
|
WHERE pay_time BETWEEN #{beginTime} AND #{endTime}
|
||||||
AND pay_status = TRUE
|
AND pay_status = TRUE
|
||||||
@ -61,4 +60,52 @@
|
|||||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
|
@ -11,16 +11,16 @@
|
|||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByTimeBetween"
|
<select id="selectVoByTimeBetween"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
||||||
SELECT
|
SELECT
|
||||||
-- 营业额 = 商品支付金额 + 充值金额
|
-- 营业额 = 商品支付金额 + 充值金额
|
||||||
SUM(order_pay_price + recharge_pay_price) AS turnover,
|
SUM(order_pay_price + recharge_pay_price) AS turnoverPrice,
|
||||||
SUM(order_pay_price) AS orderPayPrice,
|
SUM(order_pay_price) AS orderPayPrice,
|
||||||
SUM(recharge_pay_price) AS rechargePrice,
|
SUM(recharge_pay_price) AS rechargePrice,
|
||||||
-- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
-- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
||||||
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
|
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
|
||||||
SUM(order_wallet_pay_price) AS balancePrice,
|
SUM(order_wallet_pay_price) AS orderWalletPayPrice,
|
||||||
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
|
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
|
||||||
SUM(after_sale_refund_price) AS orderRefundPrice
|
SUM(after_sale_refund_price) AS orderRefundPrice
|
||||||
FROM trade_statistics
|
FROM trade_statistics
|
||||||
@ -28,25 +28,6 @@
|
|||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectListByTimeBetween"
|
|
||||||
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
|
|
||||||
SELECT DATE_FORMAT(time, '%Y-%m-%d') AS date,
|
|
||||||
-- 营业额 = 商品支付金额 + 充值金额
|
|
||||||
SUM(order_pay_price + recharge_pay_price) AS turnover,
|
|
||||||
SUM(order_pay_price) AS orderPayPrice,
|
|
||||||
SUM(recharge_pay_price) AS rechargePrice,
|
|
||||||
-- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
|
||||||
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
|
|
||||||
SUM(order_wallet_pay_price) AS balancePrice,
|
|
||||||
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
|
|
||||||
SUM(after_sale_refund_price) AS orderRefundPrice
|
|
||||||
FROM trade_statistics
|
|
||||||
WHERE time BETWEEN #{beginTime} AND #{endTime}
|
|
||||||
AND deleted = FALSE
|
|
||||||
<!-- TODO @疯狂:已经不用 group by,它就是每天统计一条; -->
|
|
||||||
GROUP BY date
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer">
|
<select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer">
|
||||||
SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
|
||||||
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
|
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
|
||||||
|
@ -8,10 +8,10 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
||||||
@ -187,7 +187,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
|
order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
|
||||||
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
|
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
|
||||||
order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum));
|
order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum));
|
||||||
order.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源?
|
order.setTerminal(ServletUtils.getTerminal());
|
||||||
// 支付 + 退款信息
|
// 支付 + 退款信息
|
||||||
order.setAdjustPrice(0).setPayStatus(false);
|
order.setAdjustPrice(0).setPayStatus(false);
|
||||||
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
|
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.dataobject.user;
|
package cn.iocoder.yudao.module.member.dal.dataobject.user;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
@ -60,6 +61,11 @@ public class MemberUserDO extends TenantBaseDO {
|
|||||||
* 注册 IP
|
* 注册 IP
|
||||||
*/
|
*/
|
||||||
private String registerIp;
|
private String registerIp;
|
||||||
|
/**
|
||||||
|
* 注册终端
|
||||||
|
* 枚举 {@link TerminalEnum}
|
||||||
|
*/
|
||||||
|
private Integer registerTerminal;
|
||||||
/**
|
/**
|
||||||
* 最后登录IP
|
* 最后登录IP
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
||||||
@ -99,6 +100,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||||
user.setPassword(encodePassword(password)); // 加密密码
|
user.setPassword(encodePassword(password)); // 加密密码
|
||||||
user.setRegisterIp(registerIp);
|
user.setRegisterIp(registerIp);
|
||||||
|
user.setRegisterTerminal(ServletUtils.getTerminal());
|
||||||
memberUserMapper.insert(user);
|
memberUserMapper.insert(user);
|
||||||
|
|
||||||
// 发送 MQ 消息:用户创建
|
// 发送 MQ 消息:用户创建
|
||||||
|
Loading…
Reference in New Issue
Block a user