From a9e822762dab8370ed1408b5bd9f89344cc141bd Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 3 Oct 2023 21:21:11 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=9A=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E7=BB=9F=E8=AE=A1=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-module-statistics-biz/pom.xml | 5 ++ .../convert/trade/TradeStatisticsConvert.java | 19 ++++++-- .../job/trade/TradeStatisticsJob.java | 29 +++++++++++ .../service/trade/TradeStatisticsService.java | 7 +++ .../trade/TradeStatisticsServiceImpl.java | 48 +++++++++++++++++++ .../api/aftersale/TradeAfterSaleApi.java | 23 +++++++++ .../dto/AfterSaleSummaryRespDTO.java | 22 +++++++++ .../api/brokerage/TradeBrokerageApi.java | 21 ++++++++ .../module/trade/api/order/TradeOrderApi.java | 13 +++++ .../order/dto/TradeOrderSummaryRespDTO.java | 26 ++++++++++ .../api/aftersale/TradeAfterSaleApiImpl.java | 28 +++++++++++ .../api/brokerage/TradeBrokerageApiImpl.java | 27 +++++++++++ .../trade/api/order/TradeOrderApiImpl.java | 8 ++++ .../dal/mysql/aftersale/AfterSaleMapper.java | 13 +++++ .../brokerage/BrokerageRecordMapper.java | 12 +++++ .../dal/mysql/order/TradeOrderMapper.java | 17 +++++++ .../service/aftersale/AfterSaleService.java | 32 +++++++++---- .../aftersale/AfterSaleServiceImpl.java | 6 +++ .../brokerage/BrokerageRecordService.java | 9 ++++ .../brokerage/BrokerageRecordServiceImpl.java | 7 +++ .../service/order/TradeOrderQueryService.java | 17 +++++-- .../order/TradeOrderQueryServiceImpl.java | 10 ++++ .../module/pay/api/wallet/PayWalletApi.java | 23 +++++++++ .../api/wallet/dto/WalletSummaryRespDTO.java | 34 +++++++++++++ .../pay/api/wallet/PayWalletApiImpl.java | 34 +++++++++++++ .../mysql/wallet/PayWalletRechargeMapper.java | 29 ++++++++++- .../wallet/PayWalletTransactionMapper.java | 12 +++++ .../wallet/PayWalletRechargeService.java | 13 +++++ .../wallet/PayWalletRechargeServiceImpl.java | 20 ++++++-- .../pay/service/wallet/PayWalletService.java | 3 ++ .../service/wallet/PayWalletServiceImpl.java | 1 + .../wallet/PayWalletTransactionService.java | 13 ++++- .../PayWalletTransactionServiceImpl.java | 6 +++ 33 files changed, 563 insertions(+), 24 deletions(-) create mode 100644 yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java create mode 100644 yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java create mode 100644 yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java create mode 100644 yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java create mode 100644 yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java create mode 100644 yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java diff --git a/yudao-module-mall/yudao-module-statistics-biz/pom.xml b/yudao-module-mall/yudao-module-statistics-biz/pom.xml index 3a0343664..dd04c47c8 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/pom.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/pom.xml @@ -43,6 +43,11 @@ yudao-module-member-api ${revision} + + cn.iocoder.boot + yudao-module-pay-api + ${revision} + diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java index 9ce4b901a..1f36f26b9 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java @@ -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 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 convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); - TradeStatisticsComparisonRespVO convert(TradeTrendSummaryRespVO value, TradeTrendSummaryRespVO reference); + TradeStatisticsComparisonRespVO convert(TradeTrendSummaryRespVO value, + TradeTrendSummaryRespVO reference); List convertList02(List list); + + TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespDTO orderSummary, + AfterSaleSummaryRespDTO afterSaleSummary, Integer brokerageSettlementPrice, + WalletSummaryRespDTO walletSummary); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java new file mode 100644 index 000000000..b97ba2338 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java @@ -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); + } + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java index d32651932..b7ddcb1ea 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java @@ -36,4 +36,11 @@ public interface TradeStatisticsService { */ List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); + /** + * 统计昨日交易 + * + * @return 耗时 + */ + String statisticsYesterdayTrade(); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java index 541120eb1..5a0679365 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java @@ -2,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 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(); + } + /** * 统计指定日期的交易数据 * diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java new file mode 100644 index 000000000..c3fd3f67b --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java @@ -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); + +} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java new file mode 100644 index 000000000..ab70019b0 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java new file mode 100644 index 000000000..3fa51159c --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java @@ -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); + +} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java index d1f49cd80..f2e57bacd 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java @@ -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); + } diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java new file mode 100644 index 000000000..a10d43596 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java @@ -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; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java new file mode 100644 index 000000000..297e8f1ad --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java @@ -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); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java new file mode 100644 index 000000000..c93d33ef2 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java @@ -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); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java index 826a9cd21..d9ab02e34 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java @@ -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); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java index 68a09a82a..5b9a22280 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java @@ -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 { .in(AfterSaleDO::getStatus, statuses)); } + default AfterSaleSummaryRespDTO selectSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.lambdaJoin() + .selectCount(AfterSaleDO::getId, AfterSaleSummaryRespDTO::getAfterSaleCount) + .selectSum(AfterSaleDO::getRefundPrice, AfterSaleSummaryRespDTO::getAfterSaleRefundPrice) + .between(AfterSaleDO::getRefundTime, beginTime, endTime)), 0), + AfterSaleSummaryRespDTO.class); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java index cda81a195..c059bffe0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java @@ -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 { @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.lambdaJoin() + .selectSum(BrokerageRecordDO::getPrice) + .eq(BrokerageRecordDO::getBizType, bizType) + .eq(BrokerageRecordDO::getStatus, status) + .between(BrokerageRecordDO::getUnfreezeTime, beginTime, endTime))), 0); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index 743f31baa..72343380a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -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 { .eq(TradeOrderDO::getCommentStatus, commentStatus)); } + default TradeOrderSummaryRespDTO selectSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.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() + .between(TradeOrderDO::getCreateTime, beginTime, endTime)); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java index bf26800d3..76c331847 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java @@ -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); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java index 19248d1a1..20f93841b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java @@ -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); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java index 1cf1e2443..22c2c67ac 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java @@ -156,4 +156,13 @@ public interface BrokerageRecordService { */ AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); + /** + * 获取已结算的佣金金额 + * + * @param beginTime 起始时间 + * @param endTime 截止时间 + * @return 已结算的佣金金额 + */ + Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java index 8b60c4f6a..ace734913 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java @@ -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 生效问题 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java index 442f83d3b..fedc3d245 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java @@ -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 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 getOrderItemListByOrderId(Collection orderIds); + /** + * 获取订单统计 + * + * @param beginTime 起始时间 + * @param endTime 截止时间 + * @return 订单统计结果 + */ + TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index c0dfbfd8c..508d5578c 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -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 diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java new file mode 100644 index 000000000..bc6215f10 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java @@ -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); + +} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java new file mode 100644 index 000000000..c72a5de63 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java @@ -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; + +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java new file mode 100644 index 000000000..3157d1338 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java @@ -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; + } + +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java index 65994b2f3..7c422a1cd 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java @@ -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 { - default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj){ + default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) { return update(updateObj, new LambdaQueryWrapperX() .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() .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); } + default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.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.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); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java index 7831e77bd..bcb9464d6 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java @@ -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 { @@ -35,6 +38,15 @@ public interface PayWalletTransactionMapper extends BaseMapperXlambdaJoin() + .selectSum(PayWalletTransactionDO::getPrice) + .eq(PayWalletTransactionDO::getBizType, type) + .between(PayWalletTransactionDO::getCreateTime, beginTime, endTime))) + .map(PayWalletTransactionDO::getPrice) + .orElse(0); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java index 908a77f78..975e881a6 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java @@ -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); + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java index f193b9ef9..71c03df67 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java @@ -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; + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java index 508822551..96a623bb2 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java @@ -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 接口 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java index c14d20cfa..d98c9c9f9 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java @@ -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; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java index d47c149b1..c970de189 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java @@ -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); + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java index ad802be41..85e8f6c87 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java @@ -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); + } + } From 5819b08740bfee488fad51550913ad9a6088ed34 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 3 Oct 2023 21:25:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BA=A4=E6=98=93=EF=BC=9AReview=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/order/TradeOrderUpdateServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 79f4a82f2..402603ca6 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -234,7 +234,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile()); order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位 } - // TODO @疯狂:是不是可以在这里设置下推广人哈; + + // 设置订单推广人 + BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); + if (brokerageUser != null && brokerageUser.getBindUserId() != null) { + order.setBrokerageUserId(brokerageUser.getBindUserId()); + } + tradeOrderMapper.insert(order); return order; } @@ -304,12 +310,6 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // 6. 插入订单日志 TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); - // 7. 设置订单推广人 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); - if (brokerageUser != null && brokerageUser.getBindUserId() != null) { - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setBrokerageUserId(brokerageUser.getBindUserId())); - } - // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! } From 8e905f706d64203950715753ac7d93937bd1d56a Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 4 Oct 2023 09:11:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BA=A4=E6=98=93=EF=BC=9A=E6=A0=B8?= =?UTF-8?q?=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/order/vo/AppTradeOrderDetailRespVO.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java index 98ea560d3..3033cf022 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java @@ -113,6 +113,9 @@ public class AppTradeOrderDetailRespVO { @Schema(description = "自提门店编号", example = "1088") private Long pickUpStoreId; + @Schema(description = "自提核销码", example = "40964096") + private String pickUpVerifyCode; + // ========== 售后基本信息 ========== // ========== 营销基本信息 ========== From 7a15b340b02eaaa43a25134e399c1c308db807a8 Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 4 Oct 2023 10:51:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BA=A4=E6=98=93=EF=BC=9A=E6=A0=B8?= =?UTF-8?q?=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/enums/ErrorCodeConstants.java | 1 + .../order/TradeOrderOperateTypeEnum.java | 1 + .../admin/order/TradeOrderController.java | 8 ++++++- .../admin/order/vo/TradeOrderPageReqVO.java | 3 +++ .../dal/mysql/order/TradeOrderMapper.java | 5 ++++ .../order/TradeOrderUpdateService.java | 14 +++++++++++ .../order/TradeOrderUpdateServiceImpl.java | 24 +++++++++++++++++++ 7 files changed, 55 insertions(+), 1 deletion(-) diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index d50ff34dc..8fb0bf40e 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java @@ -32,6 +32,7 @@ public interface ErrorCodeConstants { ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格"); ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元"); ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态"); + ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】"); // ========== After Sale 模块 1-011-000-100 ========== ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java index 616bd2d79..2e0c06f2c 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java @@ -19,6 +19,7 @@ public enum TradeOrderOperateTypeEnum { ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), MEMBER_RECEIVE(30, "用户已收货"), SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), + PICK_UP_RECEIVE(32, "自提收货"), MEMBER_COMMENT(33, "用户评价"), SYSTEM_COMMENT(34, "到期未评价,系统自动评价"), MEMBER_CANCEL(40, "取消订单"), diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 367013771..bea620af8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java @@ -126,6 +126,12 @@ public class TradeOrderController { return success(true); } - // TODO :核销逻辑 + @PutMapping("/pick-up") + @Operation(summary = "订单核销") + @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") + public CommonResult pickUpOrder(@RequestParam("id") Long id) { + tradeOrderUpdateService.pickUpOrder(id); + return success(true); + } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java index dca688588..074a1e544 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java @@ -40,6 +40,9 @@ public class TradeOrderPageReqVO extends PageParam { @Schema(description = "自提门店编号", example = "[1,2]") private List pickUpStoreIds; + @Schema(description = "自提核销码", example = "12345678") + private String pickUpVerifyCode; + @Schema(description = "订单类型", example = "1") private Integer type; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index c5ab11f77..d68f81c61 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -41,6 +41,7 @@ public interface TradeOrderMapper extends BaseMapperX { .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) + .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(TradeOrderDO::getId)); } @@ -105,4 +106,8 @@ public interface TradeOrderMapper extends BaseMapperX { .between(TradeOrderDO::getCreateTime, beginTime, endTime)); } + default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { + return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 96dfb2de7..ffadb15e4 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -115,6 +115,20 @@ public interface TradeOrderUpdateService { */ void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); + /** + * 【管理员】核销订单 + * + * @param id 订单编号 + */ + void pickUpOrder(Long id); + + /** + * 【管理员】核销订单 + * + * @param pickUpVerifyCode 自提核销码 + */ + void pickUpOrder(String pickUpVerifyCode); + // =================== Order Item =================== /** diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 402603ca6..abd585bcc 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.extra.spring.SpringUtil; @@ -763,6 +764,29 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { // TODO @puhui999:操作日志 } + @Override + public void pickUpOrder(Long id) { + getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); + } + + @Override + public void pickUpOrder(String pickUpVerifyCode) { + getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); + } + + @Transactional(rollbackFor = Exception.class) + @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.PICK_UP_RECEIVE) + public void pickUpOrder(TradeOrderDO order) { + if (order == null) { + throw exception(ORDER_NOT_FOUND); + } + if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { + throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); + } + // todo 校验核销操作人? + receiveOrder0(order); + } + // =================== Order Item =================== @Override