mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
统计:交易统计定时任务
This commit is contained in:
parent
df4716d5a1
commit
a9e822762d
@ -43,6 +43,11 @@
|
||||
<artifactId>yudao-module-member-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-pay-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
|
@ -1,13 +1,18 @@
|
||||
package cn.iocoder.yudao.module.statistics.convert.trade;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
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.TradeTrendSummaryExcelVO;
|
||||
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 cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -21,9 +26,9 @@ public interface TradeStatisticsConvert {
|
||||
TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class);
|
||||
|
||||
default TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData,
|
||||
TradeSummaryRespBO beforeYesterdayData,
|
||||
TradeSummaryRespBO monthData,
|
||||
TradeSummaryRespBO lastMonthData) {
|
||||
TradeSummaryRespBO beforeYesterdayData,
|
||||
TradeSummaryRespBO monthData,
|
||||
TradeSummaryRespBO lastMonthData) {
|
||||
return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData));
|
||||
}
|
||||
|
||||
@ -36,7 +41,13 @@ public interface TradeStatisticsConvert {
|
||||
|
||||
TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference);
|
||||
|
||||
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, TradeTrendSummaryRespVO reference);
|
||||
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value,
|
||||
TradeTrendSummaryRespVO reference);
|
||||
|
||||
List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list);
|
||||
|
||||
TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespDTO orderSummary,
|
||||
AfterSaleSummaryRespDTO afterSaleSummary, Integer brokerageSettlementPrice,
|
||||
WalletSummaryRespDTO walletSummary);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.statistics.job.trade;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 交易统计 Job
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Component
|
||||
public class TradeStatisticsJob implements JobHandler {
|
||||
|
||||
@Resource
|
||||
private TradeStatisticsService tradeStatisticsService;
|
||||
|
||||
@Override
|
||||
@TenantJob
|
||||
public String execute(String param) {
|
||||
String times = tradeStatisticsService.statisticsYesterdayTrade();
|
||||
return StrUtil.format("交易统计耗时: {}", times);
|
||||
}
|
||||
|
||||
}
|
@ -36,4 +36,11 @@ public interface TradeStatisticsService {
|
||||
*/
|
||||
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计昨日交易
|
||||
*
|
||||
* @return 耗时
|
||||
*/
|
||||
String statisticsYesterdayTrade();
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,22 @@ package cn.iocoder.yudao.module.statistics.service.trade;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
|
||||
import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert;
|
||||
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper;
|
||||
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.TradeAfterSaleApi;
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.api.brokerage.TradeBrokerageApi;
|
||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -28,6 +37,15 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
||||
@Resource
|
||||
private TradeStatisticsMapper tradeStatisticsMapper;
|
||||
|
||||
@Resource
|
||||
private TradeOrderApi tradeOrderApi;
|
||||
@Resource
|
||||
private TradeAfterSaleApi tradeAfterSaleApi;
|
||||
@Resource
|
||||
private TradeBrokerageApi tradeBrokerageApi;
|
||||
@Resource
|
||||
private PayWalletApi payWalletApi;
|
||||
|
||||
@Override
|
||||
public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() {
|
||||
// 昨天的数据
|
||||
@ -59,6 +77,36 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
|
||||
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String statisticsYesterdayTrade() {
|
||||
// 处理统计参数
|
||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
||||
// 统计
|
||||
StopWatch stopWatch = new StopWatch("交易统计");
|
||||
stopWatch.start("统计订单");
|
||||
TradeOrderSummaryRespDTO orderSummary = tradeOrderApi.getOrderSummary(beginTime, endTime);
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("统计售后");
|
||||
AfterSaleSummaryRespDTO afterSaleSummary = tradeAfterSaleApi.getAfterSaleSummary(beginTime, endTime);
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("统计佣金");
|
||||
Integer brokerageSettlementPrice = tradeBrokerageApi.getBrokerageSettlementPriceSummary(beginTime, endTime);
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("统计充值");
|
||||
WalletSummaryRespDTO walletSummary = payWalletApi.getWalletSummary(beginTime, endTime);
|
||||
stopWatch.stop();
|
||||
// 插入数据
|
||||
TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary);
|
||||
tradeStatisticsMapper.insert(entity);
|
||||
// 返回计时结果
|
||||
return stopWatch.prettyPrint();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定日期的交易数据
|
||||
*
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.trade.api.aftersale;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 售后 API 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface TradeAfterSaleApi {
|
||||
|
||||
/**
|
||||
* 获取售后单统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 售后统计结果
|
||||
*/
|
||||
AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.trade.api.aftersale.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 售后统计 Response DTO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
public class AfterSaleSummaryRespDTO {
|
||||
|
||||
/**
|
||||
* 退款订单数
|
||||
*/
|
||||
private Integer afterSaleCount;
|
||||
/**
|
||||
* 总退款金额,单位:分
|
||||
*/
|
||||
private Integer afterSaleRefundPrice;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.trade.api.brokerage;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分销 API 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface TradeBrokerageApi {
|
||||
|
||||
/**
|
||||
* 获取已结算的佣金金额
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 已结算的佣金金额
|
||||
*/
|
||||
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
package cn.iocoder.yudao.module.trade.api.order;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单 API 接口
|
||||
*
|
||||
@ -15,4 +19,13 @@ public interface TradeOrderApi {
|
||||
*/
|
||||
Integer getOrderStatus(Long id);
|
||||
|
||||
/**
|
||||
* 获取订单统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 订单统计结果
|
||||
*/
|
||||
TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.trade.api.order.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单统计 Response DTO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
public class TradeOrderSummaryRespDTO {
|
||||
|
||||
/**
|
||||
* 创建订单数
|
||||
*/
|
||||
private Long orderCreateCount;
|
||||
/**
|
||||
* 支付订单商品数
|
||||
*/
|
||||
private Integer orderPayCount;
|
||||
/**
|
||||
* 总支付金额,单位:分
|
||||
*/
|
||||
private Integer orderPayPrice;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.trade.api.aftersale;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 售后 API 接口实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TradeAfterSaleApiImpl implements TradeAfterSaleApi {
|
||||
|
||||
@Resource
|
||||
private AfterSaleService afterSaleService;
|
||||
|
||||
@Override
|
||||
public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return afterSaleService.getAfterSaleSummary(beginTime, endTime);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.trade.api.brokerage;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单 API 接口实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TradeBrokerageApiImpl implements TradeBrokerageApi {
|
||||
|
||||
@Resource
|
||||
private BrokerageRecordService brokerageRecordService;
|
||||
|
||||
@Override
|
||||
public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return brokerageRecordService.getBrokerageSettlementPriceSummary(beginTime, endTime);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.trade.api.order;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -7,6 +8,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
|
||||
|
||||
@ -31,4 +34,9 @@ public class TradeOrderApiImpl implements TradeOrderApi {
|
||||
return order.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeOrderQueryService.getOrderSummary(beginTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.aftersale;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
|
||||
@Mapper
|
||||
@ -48,4 +53,12 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> {
|
||||
.in(AfterSaleDO::getStatus, statuses));
|
||||
}
|
||||
|
||||
default AfterSaleSummaryRespDTO selectSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<AfterSaleDO>lambdaJoin()
|
||||
.selectCount(AfterSaleDO::getId, AfterSaleSummaryRespDTO::getAfterSaleCount)
|
||||
.selectSum(AfterSaleDO::getRefundPrice, AfterSaleSummaryRespDTO::getAfterSaleRefundPrice)
|
||||
.between(AfterSaleDO::getRefundTime, beginTime, endTime)), 0),
|
||||
AfterSaleSummaryRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@ -108,4 +110,14 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
||||
@Param("status") Integer status,
|
||||
@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
default Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(Integer bizType, Integer status,
|
||||
LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return Convert.toInt(CollUtil.getFirst(selectObjs(MPJWrappers.<BrokerageRecordDO>lambdaJoin()
|
||||
.selectSum(BrokerageRecordDO::getPrice)
|
||||
.eq(BrokerageRecordDO::getBizType, bizType)
|
||||
.eq(BrokerageRecordDO::getStatus, status)
|
||||
.between(BrokerageRecordDO::getUnfreezeTime, beginTime, endTime))), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.order;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -82,4 +86,17 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
|
||||
.eq(TradeOrderDO::getCommentStatus, commentStatus));
|
||||
}
|
||||
|
||||
default TradeOrderSummaryRespDTO selectSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<TradeOrderDO>lambdaJoin()
|
||||
.selectCount(TradeOrderDO::getId, TradeOrderSummaryRespDTO::getOrderPayCount)
|
||||
.selectSum(TradeOrderDO::getPayPrice, TradeOrderSummaryRespDTO::getOrderPayPrice)
|
||||
.between(TradeOrderDO::getPayTime, beginTime, endTime)), 0),
|
||||
TradeOrderSummaryRespDTO.class);
|
||||
}
|
||||
|
||||
default Long selectCountByCreateTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return selectCount(new LambdaQueryWrapperX<TradeOrderDO>()
|
||||
.between(TradeOrderDO::getCreateTime, beginTime, endTime));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.aftersale;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
||||
@ -9,6 +10,8 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCre
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 售后订单 Service 接口
|
||||
*
|
||||
@ -27,7 +30,7 @@ public interface AfterSaleService {
|
||||
/**
|
||||
* 【会员】获得售后订单分页
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
* @param pageParam 分页参数
|
||||
* @return 售后订单分页
|
||||
*/
|
||||
@ -37,7 +40,7 @@ public interface AfterSaleService {
|
||||
* 【会员】获得售后单
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 售后编号
|
||||
* @param id 售后编号
|
||||
* @return 售后订单
|
||||
*/
|
||||
AfterSaleDO getAfterSale(Long userId, Long id);
|
||||
@ -53,7 +56,7 @@ public interface AfterSaleService {
|
||||
/**
|
||||
* 【会员】创建售后订单
|
||||
*
|
||||
* @param userId 会员用户编号
|
||||
* @param userId 会员用户编号
|
||||
* @param createReqVO 创建 Request 信息
|
||||
* @return 售后编号
|
||||
*/
|
||||
@ -63,14 +66,14 @@ public interface AfterSaleService {
|
||||
* 【管理员】同意售后订单
|
||||
*
|
||||
* @param userId 管理员用户编号
|
||||
* @param id 售后编号
|
||||
* @param id 售后编号
|
||||
*/
|
||||
void agreeAfterSale(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 【管理员】拒绝售后订单
|
||||
*
|
||||
* @param userId 管理员用户编号
|
||||
* @param userId 管理员用户编号
|
||||
* @param auditReqVO 审批 Request 信息
|
||||
*/
|
||||
void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO);
|
||||
@ -78,7 +81,7 @@ public interface AfterSaleService {
|
||||
/**
|
||||
* 【会员】退回货物
|
||||
*
|
||||
* @param userId 会员用户编号
|
||||
* @param userId 会员用户编号
|
||||
* @param deliveryReqVO 退货 Request 信息
|
||||
*/
|
||||
void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO);
|
||||
@ -87,14 +90,14 @@ public interface AfterSaleService {
|
||||
* 【管理员】确认收货
|
||||
*
|
||||
* @param userId 管理员编号
|
||||
* @param id 售后编号
|
||||
* @param id 售后编号
|
||||
*/
|
||||
void receiveAfterSale(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 【管理员】拒绝收货
|
||||
*
|
||||
* @param userId 管理员用户编号
|
||||
* @param userId 管理员用户编号
|
||||
* @param refuseReqVO 拒绝收货 Request 信息
|
||||
*/
|
||||
void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO);
|
||||
@ -104,7 +107,7 @@ public interface AfterSaleService {
|
||||
*
|
||||
* @param userId 管理员用户编号
|
||||
* @param userIp 管理员用户 IP
|
||||
* @param id 售后编号
|
||||
* @param id 售后编号
|
||||
*/
|
||||
void refundAfterSale(Long userId, String userIp, Long id);
|
||||
|
||||
@ -112,7 +115,7 @@ public interface AfterSaleService {
|
||||
* 【会员】取消售后
|
||||
*
|
||||
* @param userId 会员用户编号
|
||||
* @param id 售后编号
|
||||
* @param id 售后编号
|
||||
*/
|
||||
void cancelAfterSale(Long userId, Long id);
|
||||
|
||||
@ -124,4 +127,13 @@ public interface AfterSaleService {
|
||||
*/
|
||||
Long getApplyingAfterSaleCount(Long userId);
|
||||
|
||||
/**
|
||||
* 获取售后单统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 售后统计结果
|
||||
*/
|
||||
AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
|
||||
@ -410,4 +411,9 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
||||
return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return tradeAfterSaleMapper.selectSummaryByRefundTimeBetween(beginTime,endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -156,4 +156,13 @@ public interface BrokerageRecordService {
|
||||
*/
|
||||
AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId);
|
||||
|
||||
/**
|
||||
* 获取已结算的佣金金额
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 已结算的佣金金额
|
||||
*/
|
||||
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -356,6 +356,13 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return brokerageRecordMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween(
|
||||
BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(),
|
||||
beginTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
|
@ -1,12 +1,14 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -33,7 +35,7 @@ public interface TradeOrderQueryService {
|
||||
* 获得指定用户,指定的交易订单
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 交易订单编号
|
||||
* @param id 交易订单编号
|
||||
* @return 交易订单
|
||||
*/
|
||||
TradeOrderDO getOrder(Long userId, Long id);
|
||||
@ -50,7 +52,7 @@ public interface TradeOrderQueryService {
|
||||
* 【会员】获得交易订单分页
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param reqVO 分页请求
|
||||
* @param reqVO 分页请求
|
||||
* @return 交易订单
|
||||
*/
|
||||
PageResult<TradeOrderDO> getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO);
|
||||
@ -68,7 +70,7 @@ public interface TradeOrderQueryService {
|
||||
/**
|
||||
* 【前台】获得订单的物流轨迹
|
||||
*
|
||||
* @param id 订单编号
|
||||
* @param id 订单编号
|
||||
* @param userId 用户编号
|
||||
* @return 物流轨迹数组
|
||||
*/
|
||||
@ -119,4 +121,13 @@ public interface TradeOrderQueryService {
|
||||
*/
|
||||
List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 获取订单统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 订单统计结果
|
||||
*/
|
||||
TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||
@ -20,6 +21,7 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -143,6 +145,14 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
|
||||
.setPhone(order.getReceiverMobile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
TradeOrderSummaryRespDTO dto = tradeOrderMapper.selectSummaryByPayTimeBetween(beginTime, endTime);
|
||||
dto.setOrderCreateCount(tradeOrderMapper.selectCountByCreateTimeBetween(beginTime, endTime));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
// =================== Order Item ===================
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包 API 接口
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
public interface PayWalletApi {
|
||||
|
||||
/**
|
||||
* 获取钱包统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 钱包统计
|
||||
*/
|
||||
WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 钱包统计 Response DTO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
public class WalletSummaryRespDTO {
|
||||
/**
|
||||
* 总支付金额(余额),单位:分
|
||||
*/
|
||||
private Integer orderWalletPayPrice;
|
||||
|
||||
/**
|
||||
* 充值订单数
|
||||
*/
|
||||
private Integer rechargePayCount;
|
||||
/**
|
||||
* 充值金额,单位:分
|
||||
*/
|
||||
private Integer rechargePayPrice;
|
||||
/**
|
||||
* 充值退款订单数
|
||||
*/
|
||||
private Integer rechargeRefundCount;
|
||||
/**
|
||||
* 充值退款金额,单位:分
|
||||
*/
|
||||
private Integer rechargeRefundPrice;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包 API 接口实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayWalletApiImpl implements PayWalletApi {
|
||||
|
||||
@Resource
|
||||
private PayWalletRechargeService payWalletRechargeService;
|
||||
@Resource
|
||||
private PayWalletTransactionService payWalletTransactionService;
|
||||
|
||||
@Override
|
||||
public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
WalletSummaryRespDTO walletSummary = payWalletRechargeService.getWalletSummary(beginTime, endTime);
|
||||
walletSummary.setOrderWalletPayPrice(payWalletTransactionService.getPriceSummary(PayWalletBizTypeEnum.PAYMENT, beginTime, endTime));
|
||||
return walletSummary;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +1,48 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Mapper
|
||||
public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> {
|
||||
|
||||
default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj){
|
||||
default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) {
|
||||
return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>()
|
||||
.eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus));
|
||||
}
|
||||
|
||||
default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj){
|
||||
default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj) {
|
||||
return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>()
|
||||
.eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus));
|
||||
}
|
||||
|
||||
default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
|
||||
.selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargePayCount)
|
||||
.selectSum(PayWalletRechargeDO::getPayPrice, WalletSummaryRespDTO::getRechargePayPrice)
|
||||
.eq(PayWalletRechargeDO::getPayStatus, true)
|
||||
.between(PayWalletRechargeDO::getPayTime, beginTime, endTime)), 0),
|
||||
WalletSummaryRespDTO.class);
|
||||
}
|
||||
|
||||
default WalletSummaryRespDTO selectRechargeSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
|
||||
.selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargeRefundCount)
|
||||
.selectSum(PayWalletRechargeDO::getRefundPayPrice, WalletSummaryRespDTO::getRechargeRefundPrice)
|
||||
.eq(PayWalletRechargeDO::getRefundStatus, PayRefundStatusEnum.SUCCESS.getStatus())
|
||||
.between(PayWalletRechargeDO::getRefundTime, beginTime, endTime)), 0),
|
||||
WalletSummaryRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,9 +6,12 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapper
|
||||
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
|
||||
@ -35,6 +38,15 @@ public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransac
|
||||
PayWalletTransactionDO::getBizType, bizType);
|
||||
}
|
||||
|
||||
default Integer selectSummaryByBizTypeAndCreateTimeBetween(Integer type, LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return Optional.ofNullable(selectOne(MPJWrappers.<PayWalletTransactionDO>lambdaJoin()
|
||||
.selectSum(PayWalletTransactionDO::getPrice)
|
||||
.eq(PayWalletTransactionDO::getBizType, type)
|
||||
.between(PayWalletTransactionDO::getCreateTime, beginTime, endTime)))
|
||||
.map(PayWalletTransactionDO::getPrice)
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包充值 Service 接口
|
||||
*
|
||||
@ -42,4 +45,14 @@ public interface PayWalletRechargeService {
|
||||
* @param payRefundId 退款单id
|
||||
*/
|
||||
void updateWalletRechargeRefunded(Long id, Long payRefundId);
|
||||
|
||||
/**
|
||||
* 获取钱包统计
|
||||
*
|
||||
* @param beginTime 起始时间
|
||||
* @param endTime 截止时间
|
||||
* @return 钱包统计
|
||||
*/
|
||||
WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||
@ -40,7 +41,7 @@ import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
|
||||
|
||||
/**
|
||||
* TODO 放到 配置文件中
|
||||
*/
|
||||
@ -94,9 +95,9 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId);
|
||||
|
||||
// 2. 更新钱包充值的支付状态
|
||||
int updateCount = walletRechargeMapper.updateByIdAndPaid(id,false,
|
||||
int updateCount = walletRechargeMapper.updateByIdAndPaid(id, false,
|
||||
new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now())
|
||||
.setPayChannelCode(payOrderDO.getChannelCode()));
|
||||
.setPayChannelCode(payOrderDO.getChannelCode()));
|
||||
if (updateCount == 0) {
|
||||
throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
|
||||
}
|
||||
@ -124,7 +125,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
// 3 创建退款单
|
||||
String walletRechargeId = String.valueOf(id);
|
||||
String refundId = walletRechargeId + "-refund";
|
||||
Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO()
|
||||
Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO()
|
||||
.setAppId(WALLET_PAY_APP_ID).setUserIp(userIp)
|
||||
.setMerchantOrderId(walletRechargeId)
|
||||
.setMerchantRefundId(refundId)
|
||||
@ -257,4 +258,15 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
return payOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
WalletSummaryRespDTO paySummary = walletRechargeMapper.selectRechargeSummaryByPayTimeBetween(beginTime, endTime);
|
||||
WalletSummaryRespDTO refundSummary = walletRechargeMapper.selectRechargeSummaryByRefundTimeBetween(beginTime, endTime);
|
||||
|
||||
paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount());
|
||||
paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
|
||||
|
||||
return paySummary;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包 Service 接口
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包余额流水 Service 接口
|
||||
@ -43,10 +44,20 @@ public interface PayWalletTransactionService {
|
||||
/**
|
||||
* 获取钱包流水
|
||||
*
|
||||
* @param bizId 业务编号
|
||||
* @param bizId 业务编号
|
||||
* @param type 业务类型
|
||||
* @return 钱包流水
|
||||
*/
|
||||
PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type);
|
||||
|
||||
/**
|
||||
* 获取支付金额合计
|
||||
*
|
||||
* @param bizType 业务类型
|
||||
* @param beginTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 支付金额合计
|
||||
*/
|
||||
Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime);
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 钱包流水 Service 实现类
|
||||
@ -60,4 +61,9 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
|
||||
return payWalletTransactionMapper.selectByBiz(bizId, type.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
return payWalletTransactionMapper.selectSummaryByBizTypeAndCreateTimeBetween(bizType.getType(), beginTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user