mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
code review:交易统计
This commit is contained in:
parent
1ac2f2b5c2
commit
970e524088
@ -36,9 +36,11 @@ public class TradeStatisticsController {
|
|||||||
@Operation(summary = "获得交易统计")
|
@Operation(summary = "获得交易统计")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() {
|
public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() {
|
||||||
|
// TODO @疯狂:这个要不要 tradeStatisticsService 调用里面的多个方法,组合出最终的 TradeSummaryRespVO;
|
||||||
return success(tradeStatisticsService.getTradeSummaryComparison());
|
return success(tradeStatisticsService.getTradeSummaryComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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')")
|
||||||
@ -48,6 +50,8 @@ public class TradeStatisticsController {
|
|||||||
ArrayUtil.get(reqVO.getTimes(), 1)));
|
ArrayUtil.get(reqVO.getTimes(), 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
|
// TODO @疯狂:这个要不直接叫 list;它即使就是把每条统计拿出来
|
||||||
@GetMapping("/trend/list")
|
@GetMapping("/trend/list")
|
||||||
@Operation(summary = "获得交易状况明细")
|
@Operation(summary = "获得交易状况明细")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||||
@ -57,6 +61,7 @@ public class TradeStatisticsController {
|
|||||||
ArrayUtil.get(reqVO.getTimes(), 1)));
|
ArrayUtil.get(reqVO.getTimes(), 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @疯狂:这个要不直接叫 export;它即使就是把每条统计导出
|
||||||
@GetMapping("/trend/export-excel")
|
@GetMapping("/trend/export-excel")
|
||||||
@Operation(summary = "导出获得交易状况明细 Excel")
|
@Operation(summary = "导出获得交易状况明细 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('statistics:trade:export')")
|
@PreAuthorize("@ss.hasPermission('statistics:trade:export')")
|
||||||
|
@ -16,25 +16,26 @@ 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 turnover; // 营业额 = 商品支付金额 + 充值金额
|
||||||
|
|
||||||
@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 orderRefundPrice;
|
||||||
|
|
||||||
|
@Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Integer brokerageSettlementPrice;
|
||||||
|
|
||||||
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer rechargePrice;
|
private Integer rechargePrice;
|
||||||
|
|
||||||
@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")
|
@Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer balancePrice;
|
private Integer balancePrice; // TODO @疯狂:这个字段要不改成:walletPayPrice
|
||||||
|
|
||||||
@Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Integer brokerageSettlementPrice;
|
|
||||||
|
|
||||||
@Schema(description = "商品退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Integer orderRefundPrice;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ public class TradeStatisticsDO extends TenantBaseDO {
|
|||||||
* 总支付金额,单位:分
|
* 总支付金额,单位:分
|
||||||
*/
|
*/
|
||||||
private Integer orderPayPrice;
|
private Integer orderPayPrice;
|
||||||
|
// TODO @疯狂:这个字段改成 walletPayPrice,然后挪到 rechargePayCount 前面;
|
||||||
/**
|
/**
|
||||||
* 总支付金额(余额),单位:分
|
* 总支付金额(余额),单位:分
|
||||||
*/
|
*/
|
||||||
|
@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
// TODO @芋艿:api 访问日志,现在会清理,可能要单独有个偏业务的访问表;
|
||||||
/**
|
/**
|
||||||
* API 访问日志的统计 Mapper
|
* API 访问日志的统计 Mapper
|
||||||
*
|
*
|
||||||
|
@ -17,14 +17,17 @@ import java.time.LocalDateTime;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review;
|
||||||
WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("payStatus") Boolean payStatus);
|
@Param("payStatus") Boolean payStatus);
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review;
|
||||||
WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("refundStatus") Integer refundStatus);
|
@Param("refundStatus") Integer refundStatus);
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review;
|
||||||
Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime,
|
@Param("endTime") LocalDateTime endTime,
|
||||||
@Param("bizType") Integer bizType);
|
@Param("bizType") Integer bizType);
|
||||||
|
@ -16,6 +16,7 @@ import java.time.LocalDateTime;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
||||||
|
|
||||||
|
// TODO 芋艿:已 review
|
||||||
AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@ -20,9 +20,11 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
|
|||||||
// TODO 芋艿:已经 review
|
// TODO 芋艿:已经 review
|
||||||
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
|
|||||||
TradeTrendSummaryRespVO selectByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
TradeTrendSummaryRespVO selectByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
// TODO @芋艿:已经 review
|
||||||
List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||||
@Param("endTime") LocalDateTime endTime);
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import java.time.LocalDateTime;
|
|||||||
*/
|
*/
|
||||||
public interface PayWalletStatisticsService {
|
public interface PayWalletStatisticsService {
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
/**
|
/**
|
||||||
* 获取钱包统计
|
* 获取钱包统计
|
||||||
*
|
*
|
||||||
@ -21,6 +22,7 @@ public interface PayWalletStatisticsService {
|
|||||||
*/
|
*/
|
||||||
WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
/**
|
/**
|
||||||
* 获取钱包充值统计
|
* 获取钱包充值统计
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
|||||||
*/
|
*/
|
||||||
public interface AfterSaleStatisticsService {
|
public interface AfterSaleStatisticsService {
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
/**
|
/**
|
||||||
* 获取售后单统计
|
* 获取售后单统计
|
||||||
*
|
*
|
||||||
|
@ -9,6 +9,7 @@ import java.time.LocalDateTime;
|
|||||||
*/
|
*/
|
||||||
public interface BrokerageStatisticsService {
|
public interface BrokerageStatisticsService {
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review
|
||||||
/**
|
/**
|
||||||
* 获取已结算的佣金金额
|
* 获取已结算的佣金金额
|
||||||
*
|
*
|
||||||
|
@ -45,6 +45,7 @@ public interface TradeStatisticsService {
|
|||||||
*/
|
*/
|
||||||
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
|
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
// TODO 芋艿:已经 review;
|
||||||
/**
|
/**
|
||||||
* 统计昨日交易
|
* 统计昨日交易
|
||||||
*
|
*
|
||||||
|
@ -57,6 +57,30 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
|||||||
return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData);
|
return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计指定日期的交易数据
|
||||||
|
*
|
||||||
|
* @param days 增加的天数
|
||||||
|
* @return 交易数据
|
||||||
|
*/
|
||||||
|
private TradeSummaryRespBO getTradeSummaryByDays(int days) {
|
||||||
|
LocalDateTime date = LocalDateTime.now().plusDays(days);
|
||||||
|
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
||||||
|
LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计指定月份的交易数据
|
||||||
|
*
|
||||||
|
* @param months 增加的月数
|
||||||
|
* @return 交易数据
|
||||||
|
*/
|
||||||
|
private TradeSummaryRespBO getTradeSummaryByMonths(int months) {
|
||||||
|
LocalDateTime monthDate = LocalDateTime.now().plusMonths(months);
|
||||||
|
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
||||||
|
LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime,
|
public TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime,
|
||||||
LocalDateTime endTime) {
|
LocalDateTime endTime) {
|
||||||
@ -73,6 +97,7 @@ 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<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||||
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
||||||
@ -80,6 +105,9 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String statisticsYesterdayTrade() {
|
public String statisticsYesterdayTrade() {
|
||||||
|
// TODO @疯狂:如果已经统计,则跳过;
|
||||||
|
// TODO @疯狂:改成 statisticsTrade,然后传入 days,统计多少天;days 通过 job 传参;方便把历史给统计出来;或者大家有的时候要修复数据(会 fix 业务数据,然后清理统计表),重新统计的时候;
|
||||||
|
// 1. 从各个数据表,统计对应数据
|
||||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
||||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
||||||
@ -108,28 +136,4 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
|||||||
return stopWatch.prettyPrint();
|
return stopWatch.prettyPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计指定日期的交易数据
|
|
||||||
*
|
|
||||||
* @param days 增加的天数
|
|
||||||
* @return 交易数据
|
|
||||||
*/
|
|
||||||
private TradeSummaryRespBO getTradeSummaryByDays(int days) {
|
|
||||||
LocalDateTime date = LocalDateTime.now().plusDays(days);
|
|
||||||
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
|
||||||
LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计指定月份的交易数据
|
|
||||||
*
|
|
||||||
* @param months 增加的月数
|
|
||||||
* @return 交易数据
|
|
||||||
*/
|
|
||||||
private TradeSummaryRespBO getTradeSummaryByMonths(int months) {
|
|
||||||
LocalDateTime monthDate = LocalDateTime.now().plusMonths(months);
|
|
||||||
return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(
|
|
||||||
LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?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.pay.PayWalletStatisticsMapper">
|
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper">
|
||||||
|
|
||||||
<select id="selectRechargeSummaryByPayTimeBetween"
|
<select id="selectRechargeSummaryByPayTimeBetween"
|
||||||
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO">
|
resultType="cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO">
|
||||||
SELECT COUNT(1) AS rechargePayCount,
|
SELECT COUNT(1) AS rechargePayCount,
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
FROM trade_statistics
|
FROM trade_statistics
|
||||||
WHERE time BETWEEN #{beginTime} AND #{endTime}
|
WHERE time BETWEEN #{beginTime} AND #{endTime}
|
||||||
AND deleted = FALSE
|
AND deleted = FALSE
|
||||||
|
<!-- TODO @疯狂:已经不用 group by,它就是每天统计一条; -->
|
||||||
GROUP BY date
|
GROUP BY date
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user