Commit c5824eedf7cf8a58f865855fd48bae3250a8cfb1
Merge branch 'feature/mall_product' of https://gitee.com/CrazyWorld/ruoyi-vue-pr…
…o into feature/mall_product # Conflicts: # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
Showing
40 changed files
with
626 additions
and
32 deletions
yudao-module-mall/yudao-module-statistics-biz/pom.xml
| ... | ... | @@ -43,6 +43,11 @@ |
| 43 | 43 | <artifactId>yudao-module-member-api</artifactId> |
| 44 | 44 | <version>${revision}</version> |
| 45 | 45 | </dependency> |
| 46 | + <dependency> | |
| 47 | + <groupId>cn.iocoder.boot</groupId> | |
| 48 | + <artifactId>yudao-module-pay-api</artifactId> | |
| 49 | + <version>${revision}</version> | |
| 50 | + </dependency> | |
| 46 | 51 | |
| 47 | 52 | <!-- 业务组件 --> |
| 48 | 53 | <dependency> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.convert.trade; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 3 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; |
| 4 | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; |
| 6 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 8 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 7 | 9 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 10 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 11 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 8 | 12 | import org.mapstruct.Mapper; |
| 9 | 13 | import org.mapstruct.factory.Mappers; |
| 10 | 14 | |
| 15 | +import java.time.LocalDateTime; | |
| 11 | 16 | import java.util.List; |
| 12 | 17 | |
| 13 | 18 | /** |
| ... | ... | @@ -21,9 +26,9 @@ public interface TradeStatisticsConvert { |
| 21 | 26 | TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); |
| 22 | 27 | |
| 23 | 28 | default TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData, |
| 24 | - TradeSummaryRespBO beforeYesterdayData, | |
| 25 | - TradeSummaryRespBO monthData, | |
| 26 | - TradeSummaryRespBO lastMonthData) { | |
| 29 | + TradeSummaryRespBO beforeYesterdayData, | |
| 30 | + TradeSummaryRespBO monthData, | |
| 31 | + TradeSummaryRespBO lastMonthData) { | |
| 27 | 32 | return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); |
| 28 | 33 | } |
| 29 | 34 | |
| ... | ... | @@ -36,7 +41,13 @@ public interface TradeStatisticsConvert { |
| 36 | 41 | |
| 37 | 42 | TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); |
| 38 | 43 | |
| 39 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, TradeTrendSummaryRespVO reference); | |
| 44 | + TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, | |
| 45 | + TradeTrendSummaryRespVO reference); | |
| 40 | 46 | |
| 41 | 47 | List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list); |
| 48 | + | |
| 49 | + TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespDTO orderSummary, | |
| 50 | + AfterSaleSummaryRespDTO afterSaleSummary, Integer brokerageSettlementPrice, | |
| 51 | + WalletSummaryRespDTO walletSummary); | |
| 52 | + | |
| 42 | 53 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.job.trade; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; | |
| 5 | +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; | |
| 6 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import javax.annotation.Resource; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 交易统计 Job | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@Component | |
| 17 | +public class TradeStatisticsJob implements JobHandler { | |
| 18 | + | |
| 19 | + @Resource | |
| 20 | + private TradeStatisticsService tradeStatisticsService; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + @TenantJob | |
| 24 | + public String execute(String param) { | |
| 25 | + String times = tradeStatisticsService.statisticsYesterdayTrade(); | |
| 26 | + return StrUtil.format("交易统计耗时: {}", times); | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | ... | ... |
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 { |
| 36 | 36 | */ |
| 37 | 37 | List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); |
| 38 | 38 | |
| 39 | + /** | |
| 40 | + * 统计昨日交易 | |
| 41 | + * | |
| 42 | + * @return 耗时 | |
| 43 | + */ | |
| 44 | + String statisticsYesterdayTrade(); | |
| 45 | + | |
| 39 | 46 | } | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | +import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; | |
| 6 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 5 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; |
| 6 | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 7 | 9 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 8 | 10 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 11 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 9 | 12 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; |
| 10 | 13 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 14 | +import cn.iocoder.yudao.module.trade.api.aftersale.TradeAfterSaleApi; | |
| 15 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 16 | +import cn.iocoder.yudao.module.trade.api.brokerage.TradeBrokerageApi; | |
| 17 | +import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; | |
| 18 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 11 | 19 | import org.springframework.stereotype.Service; |
| 20 | +import org.springframework.util.StopWatch; | |
| 12 | 21 | import org.springframework.validation.annotation.Validated; |
| 13 | 22 | |
| 14 | 23 | import javax.annotation.Resource; |
| ... | ... | @@ -28,6 +37,15 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 28 | 37 | @Resource |
| 29 | 38 | private TradeStatisticsMapper tradeStatisticsMapper; |
| 30 | 39 | |
| 40 | + @Resource | |
| 41 | + private TradeOrderApi tradeOrderApi; | |
| 42 | + @Resource | |
| 43 | + private TradeAfterSaleApi tradeAfterSaleApi; | |
| 44 | + @Resource | |
| 45 | + private TradeBrokerageApi tradeBrokerageApi; | |
| 46 | + @Resource | |
| 47 | + private PayWalletApi payWalletApi; | |
| 48 | + | |
| 31 | 49 | @Override |
| 32 | 50 | public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { |
| 33 | 51 | // 昨天的数据 |
| ... | ... | @@ -59,6 +77,36 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 59 | 77 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); |
| 60 | 78 | } |
| 61 | 79 | |
| 80 | + @Override | |
| 81 | + public String statisticsYesterdayTrade() { | |
| 82 | + // 处理统计参数 | |
| 83 | + LocalDateTime yesterday = LocalDateTime.now().minusDays(1); | |
| 84 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); | |
| 85 | + LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); | |
| 86 | + // 统计 | |
| 87 | + StopWatch stopWatch = new StopWatch("交易统计"); | |
| 88 | + stopWatch.start("统计订单"); | |
| 89 | + TradeOrderSummaryRespDTO orderSummary = tradeOrderApi.getOrderSummary(beginTime, endTime); | |
| 90 | + stopWatch.stop(); | |
| 91 | + | |
| 92 | + stopWatch.start("统计售后"); | |
| 93 | + AfterSaleSummaryRespDTO afterSaleSummary = tradeAfterSaleApi.getAfterSaleSummary(beginTime, endTime); | |
| 94 | + stopWatch.stop(); | |
| 95 | + | |
| 96 | + stopWatch.start("统计佣金"); | |
| 97 | + Integer brokerageSettlementPrice = tradeBrokerageApi.getBrokerageSettlementPriceSummary(beginTime, endTime); | |
| 98 | + stopWatch.stop(); | |
| 99 | + | |
| 100 | + stopWatch.start("统计充值"); | |
| 101 | + WalletSummaryRespDTO walletSummary = payWalletApi.getWalletSummary(beginTime, endTime); | |
| 102 | + stopWatch.stop(); | |
| 103 | + // 插入数据 | |
| 104 | + TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); | |
| 105 | + tradeStatisticsMapper.insert(entity); | |
| 106 | + // 返回计时结果 | |
| 107 | + return stopWatch.prettyPrint(); | |
| 108 | + } | |
| 109 | + | |
| 62 | 110 | /** |
| 63 | 111 | * 统计指定日期的交易数据 |
| 64 | 112 | * | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.aftersale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 4 | + | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 售后 API 接口 | |
| 9 | + * | |
| 10 | + * @author owen | |
| 11 | + */ | |
| 12 | +public interface TradeAfterSaleApi { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 获取售后单统计 | |
| 16 | + * | |
| 17 | + * @param beginTime 起始时间 | |
| 18 | + * @param endTime 截止时间 | |
| 19 | + * @return 售后统计结果 | |
| 20 | + */ | |
| 21 | + AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/dto/AfterSaleSummaryRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.aftersale.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 售后统计 Response DTO | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +@Data | |
| 11 | +public class AfterSaleSummaryRespDTO { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 退款订单数 | |
| 15 | + */ | |
| 16 | + private Integer afterSaleCount; | |
| 17 | + /** | |
| 18 | + * 总退款金额,单位:分 | |
| 19 | + */ | |
| 20 | + private Integer afterSaleRefundPrice; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.brokerage; | |
| 2 | + | |
| 3 | +import java.time.LocalDateTime; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 分销 API 接口 | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +public interface TradeBrokerageApi { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 获取已结算的佣金金额 | |
| 14 | + * | |
| 15 | + * @param beginTime 起始时间 | |
| 16 | + * @param endTime 截止时间 | |
| 17 | + * @return 已结算的佣金金额 | |
| 18 | + */ | |
| 19 | + Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.order; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 4 | + | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 3 | 7 | /** |
| 4 | 8 | * 订单 API 接口 |
| 5 | 9 | * |
| ... | ... | @@ -16,4 +20,13 @@ public interface TradeOrderApi { |
| 16 | 20 | */ |
| 17 | 21 | Integer getOrderStatus(Long id); |
| 18 | 22 | |
| 23 | + /** | |
| 24 | + * 获取订单统计 | |
| 25 | + * | |
| 26 | + * @param beginTime 起始时间 | |
| 27 | + * @param endTime 截止时间 | |
| 28 | + * @return 订单统计结果 | |
| 29 | + */ | |
| 30 | + TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 31 | + | |
| 19 | 32 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderSummaryRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.order.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 订单统计 Response DTO | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +@Data | |
| 11 | +public class TradeOrderSummaryRespDTO { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 创建订单数 | |
| 15 | + */ | |
| 16 | + private Long orderCreateCount; | |
| 17 | + /** | |
| 18 | + * 支付订单商品数 | |
| 19 | + */ | |
| 20 | + private Integer orderPayCount; | |
| 21 | + /** | |
| 22 | + * 总支付金额,单位:分 | |
| 23 | + */ | |
| 24 | + private Integer orderPayPrice; | |
| 25 | + | |
| 26 | +} | ... | ... |
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 { |
| 32 | 32 | ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格"); |
| 33 | 33 | ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元"); |
| 34 | 34 | ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态"); |
| 35 | + ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】"); | |
| 35 | 36 | |
| 36 | 37 | // ========== After Sale 模块 1-011-000-100 ========== |
| 37 | 38 | ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); | ... | ... |
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 { |
| 19 | 19 | ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), |
| 20 | 20 | MEMBER_RECEIVE(30, "用户已收货"), |
| 21 | 21 | SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), |
| 22 | + PICK_UP_RECEIVE(32, "自提收货"), | |
| 22 | 23 | MEMBER_COMMENT(33, "用户评价"), |
| 23 | 24 | SYSTEM_COMMENT(34, "到期未评价,系统自动评价"), |
| 24 | 25 | MEMBER_CANCEL(40, "取消订单"), | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/aftersale/TradeAfterSaleApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.aftersale; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 4 | +import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.validation.annotation.Validated; | |
| 7 | + | |
| 8 | +import javax.annotation.Resource; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 售后 API 接口实现类 | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@Service | |
| 17 | +@Validated | |
| 18 | +public class TradeAfterSaleApiImpl implements TradeAfterSaleApi { | |
| 19 | + | |
| 20 | + @Resource | |
| 21 | + private AfterSaleService afterSaleService; | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 25 | + return afterSaleService.getAfterSaleSummary(beginTime, endTime); | |
| 26 | + } | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/TradeBrokerageApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.api.brokerage; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | + | |
| 7 | +import javax.annotation.Resource; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 订单 API 接口实现类 | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 15 | +@Service | |
| 16 | +@Validated | |
| 17 | +public class TradeBrokerageApiImpl implements TradeBrokerageApi { | |
| 18 | + | |
| 19 | + @Resource | |
| 20 | + private BrokerageRecordService brokerageRecordService; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 24 | + return brokerageRecordService.getBrokerageSettlementPriceSummary(beginTime, endTime); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.api.order; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 3 | 4 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 4 | 5 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 5 | 6 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -7,6 +8,8 @@ import org.springframework.validation.annotation.Validated; |
| 7 | 8 | |
| 8 | 9 | import javax.annotation.Resource; |
| 9 | 10 | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 10 | 13 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 11 | 14 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; |
| 12 | 15 | |
| ... | ... | @@ -31,4 +34,9 @@ public class TradeOrderApiImpl implements TradeOrderApi { |
| 31 | 34 | return order.getStatus(); |
| 32 | 35 | } |
| 33 | 36 | |
| 37 | + @Override | |
| 38 | + public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 39 | + return tradeOrderQueryService.getOrderSummary(beginTime, endTime); | |
| 40 | + } | |
| 41 | + | |
| 34 | 42 | } | ... | ... |
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 { |
| 126 | 126 | return success(true); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - // TODO :核销逻辑 | |
| 129 | + @PutMapping("/pick-up") | |
| 130 | + @Operation(summary = "订单核销") | |
| 131 | + @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") | |
| 132 | + public CommonResult<Boolean> pickUpOrder(@RequestParam("id") Long id) { | |
| 133 | + tradeOrderUpdateService.pickUpOrder(id); | |
| 134 | + return success(true); | |
| 135 | + } | |
| 130 | 136 | |
| 131 | 137 | } | ... | ... |
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 { |
| 40 | 40 | @Schema(description = "自提门店编号", example = "[1,2]") |
| 41 | 41 | private List<Long> pickUpStoreIds; |
| 42 | 42 | |
| 43 | + @Schema(description = "自提核销码", example = "12345678") | |
| 44 | + private String pickUpVerifyCode; | |
| 45 | + | |
| 43 | 46 | @Schema(description = "订单类型", example = "1") |
| 44 | 47 | private Integer type; |
| 45 | 48 | ... | ... |
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 { |
| 113 | 113 | @Schema(description = "自提门店编号", example = "1088") |
| 114 | 114 | private Long pickUpStoreId; |
| 115 | 115 | |
| 116 | + @Schema(description = "自提核销码", example = "40964096") | |
| 117 | + private String pickUpVerifyCode; | |
| 118 | + | |
| 116 | 119 | // ========== 售后基本信息 ========== |
| 117 | 120 | |
| 118 | 121 | // ========== 营销基本信息 ========== | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.bean.BeanUtil; | |
| 4 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 9 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 7 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 8 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; |
| 9 | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | +import com.github.yulichang.toolkit.MPJWrappers; | |
| 10 | 14 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 15 | |
| 16 | +import java.time.LocalDateTime; | |
| 12 | 17 | import java.util.Collection; |
| 13 | 18 | |
| 14 | 19 | @Mapper |
| ... | ... | @@ -48,4 +53,12 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> { |
| 48 | 53 | .in(AfterSaleDO::getStatus, statuses)); |
| 49 | 54 | } |
| 50 | 55 | |
| 56 | + default AfterSaleSummaryRespDTO selectSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 57 | + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<AfterSaleDO>lambdaJoin() | |
| 58 | + .selectCount(AfterSaleDO::getId, AfterSaleSummaryRespDTO::getAfterSaleCount) | |
| 59 | + .selectSum(AfterSaleDO::getRefundPrice, AfterSaleSummaryRespDTO::getAfterSaleRefundPrice) | |
| 60 | + .between(AfterSaleDO::getRefundTime, beginTime, endTime)), 0), | |
| 61 | + AfterSaleSummaryRespDTO.class); | |
| 62 | + } | |
| 63 | + | |
| 51 | 64 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | +import cn.hutool.core.collection.CollUtil; | |
| 5 | +import cn.hutool.core.convert.Convert; | |
| 4 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| ... | ... | @@ -108,4 +110,14 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> { |
| 108 | 110 | @Param("status") Integer status, |
| 109 | 111 | @Param("beginTime") LocalDateTime beginTime, |
| 110 | 112 | @Param("endTime") LocalDateTime endTime); |
| 113 | + | |
| 114 | + default Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(Integer bizType, Integer status, | |
| 115 | + LocalDateTime beginTime, LocalDateTime endTime) { | |
| 116 | + return Convert.toInt(CollUtil.getFirst(selectObjs(MPJWrappers.<BrokerageRecordDO>lambdaJoin() | |
| 117 | + .selectSum(BrokerageRecordDO::getPrice) | |
| 118 | + .eq(BrokerageRecordDO::getBizType, bizType) | |
| 119 | + .eq(BrokerageRecordDO::getStatus, status) | |
| 120 | + .between(BrokerageRecordDO::getUnfreezeTime, beginTime, endTime))), 0); | |
| 121 | + } | |
| 122 | + | |
| 111 | 123 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.order; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.bean.BeanUtil; | |
| 4 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 6 | 9 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 7 | 10 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 8 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 9 | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | +import com.github.yulichang.toolkit.MPJWrappers; | |
| 10 | 14 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 15 | |
| 12 | 16 | import java.time.LocalDateTime; |
| ... | ... | @@ -37,6 +41,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 37 | 41 | .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) |
| 38 | 42 | .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) |
| 39 | 43 | .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) |
| 44 | + .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) | |
| 40 | 45 | .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) |
| 41 | 46 | .orderByDesc(TradeOrderDO::getId)); |
| 42 | 47 | } |
| ... | ... | @@ -88,4 +93,21 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 88 | 93 | .eq(TradeOrderDO::getSeckillActivityId, seckillActivityId)); |
| 89 | 94 | } |
| 90 | 95 | |
| 96 | + default TradeOrderSummaryRespDTO selectSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 97 | + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<TradeOrderDO>lambdaJoin() | |
| 98 | + .selectCount(TradeOrderDO::getId, TradeOrderSummaryRespDTO::getOrderPayCount) | |
| 99 | + .selectSum(TradeOrderDO::getPayPrice, TradeOrderSummaryRespDTO::getOrderPayPrice) | |
| 100 | + .between(TradeOrderDO::getPayTime, beginTime, endTime)), 0), | |
| 101 | + TradeOrderSummaryRespDTO.class); | |
| 102 | + } | |
| 103 | + | |
| 104 | + default Long selectCountByCreateTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 105 | + return selectCount(new LambdaQueryWrapperX<TradeOrderDO>() | |
| 106 | + .between(TradeOrderDO::getCreateTime, beginTime, endTime)); | |
| 107 | + } | |
| 108 | + | |
| 109 | + default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { | |
| 110 | + return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); | |
| 111 | + } | |
| 112 | + | |
| 91 | 113 | } | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 5 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; |
| 6 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 7 | 8 | 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 |
| 9 | 10 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; |
| 10 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; |
| 11 | 12 | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | + | |
| 12 | 15 | /** |
| 13 | 16 | * 售后订单 Service 接口 |
| 14 | 17 | * |
| ... | ... | @@ -27,7 +30,7 @@ public interface AfterSaleService { |
| 27 | 30 | /** |
| 28 | 31 | * 【会员】获得售后订单分页 |
| 29 | 32 | * |
| 30 | - * @param userId 用户编号 | |
| 33 | + * @param userId 用户编号 | |
| 31 | 34 | * @param pageParam 分页参数 |
| 32 | 35 | * @return 售后订单分页 |
| 33 | 36 | */ |
| ... | ... | @@ -37,7 +40,7 @@ public interface AfterSaleService { |
| 37 | 40 | * 【会员】获得售后单 |
| 38 | 41 | * |
| 39 | 42 | * @param userId 用户编号 |
| 40 | - * @param id 售后编号 | |
| 43 | + * @param id 售后编号 | |
| 41 | 44 | * @return 售后订单 |
| 42 | 45 | */ |
| 43 | 46 | AfterSaleDO getAfterSale(Long userId, Long id); |
| ... | ... | @@ -53,7 +56,7 @@ public interface AfterSaleService { |
| 53 | 56 | /** |
| 54 | 57 | * 【会员】创建售后订单 |
| 55 | 58 | * |
| 56 | - * @param userId 会员用户编号 | |
| 59 | + * @param userId 会员用户编号 | |
| 57 | 60 | * @param createReqVO 创建 Request 信息 |
| 58 | 61 | * @return 售后编号 |
| 59 | 62 | */ |
| ... | ... | @@ -63,14 +66,14 @@ public interface AfterSaleService { |
| 63 | 66 | * 【管理员】同意售后订单 |
| 64 | 67 | * |
| 65 | 68 | * @param userId 管理员用户编号 |
| 66 | - * @param id 售后编号 | |
| 69 | + * @param id 售后编号 | |
| 67 | 70 | */ |
| 68 | 71 | void agreeAfterSale(Long userId, Long id); |
| 69 | 72 | |
| 70 | 73 | /** |
| 71 | 74 | * 【管理员】拒绝售后订单 |
| 72 | 75 | * |
| 73 | - * @param userId 管理员用户编号 | |
| 76 | + * @param userId 管理员用户编号 | |
| 74 | 77 | * @param auditReqVO 审批 Request 信息 |
| 75 | 78 | */ |
| 76 | 79 | void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO); |
| ... | ... | @@ -78,7 +81,7 @@ public interface AfterSaleService { |
| 78 | 81 | /** |
| 79 | 82 | * 【会员】退回货物 |
| 80 | 83 | * |
| 81 | - * @param userId 会员用户编号 | |
| 84 | + * @param userId 会员用户编号 | |
| 82 | 85 | * @param deliveryReqVO 退货 Request 信息 |
| 83 | 86 | */ |
| 84 | 87 | void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO); |
| ... | ... | @@ -87,14 +90,14 @@ public interface AfterSaleService { |
| 87 | 90 | * 【管理员】确认收货 |
| 88 | 91 | * |
| 89 | 92 | * @param userId 管理员编号 |
| 90 | - * @param id 售后编号 | |
| 93 | + * @param id 售后编号 | |
| 91 | 94 | */ |
| 92 | 95 | void receiveAfterSale(Long userId, Long id); |
| 93 | 96 | |
| 94 | 97 | /** |
| 95 | 98 | * 【管理员】拒绝收货 |
| 96 | 99 | * |
| 97 | - * @param userId 管理员用户编号 | |
| 100 | + * @param userId 管理员用户编号 | |
| 98 | 101 | * @param refuseReqVO 拒绝收货 Request 信息 |
| 99 | 102 | */ |
| 100 | 103 | void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO); |
| ... | ... | @@ -104,7 +107,7 @@ public interface AfterSaleService { |
| 104 | 107 | * |
| 105 | 108 | * @param userId 管理员用户编号 |
| 106 | 109 | * @param userIp 管理员用户 IP |
| 107 | - * @param id 售后编号 | |
| 110 | + * @param id 售后编号 | |
| 108 | 111 | */ |
| 109 | 112 | void refundAfterSale(Long userId, String userIp, Long id); |
| 110 | 113 | |
| ... | ... | @@ -112,7 +115,7 @@ public interface AfterSaleService { |
| 112 | 115 | * 【会员】取消售后 |
| 113 | 116 | * |
| 114 | 117 | * @param userId 会员用户编号 |
| 115 | - * @param id 售后编号 | |
| 118 | + * @param id 售后编号 | |
| 116 | 119 | */ |
| 117 | 120 | void cancelAfterSale(Long userId, Long id); |
| 118 | 121 | |
| ... | ... | @@ -124,4 +127,13 @@ public interface AfterSaleService { |
| 124 | 127 | */ |
| 125 | 128 | Long getApplyingAfterSaleCount(Long userId); |
| 126 | 129 | |
| 130 | + /** | |
| 131 | + * 获取售后单统计 | |
| 132 | + * | |
| 133 | + * @param beginTime 起始时间 | |
| 134 | + * @param endTime 截止时间 | |
| 135 | + * @return 售后统计结果 | |
| 136 | + */ | |
| 137 | + AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 138 | + | |
| 127 | 139 | } | ... | ... |
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; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 10 | +import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO; | |
| 10 | 11 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; |
| 11 | 12 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; |
| 12 | 13 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; |
| ... | ... | @@ -410,4 +411,9 @@ public class AfterSaleServiceImpl implements AfterSaleService { |
| 410 | 411 | return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES); |
| 411 | 412 | } |
| 412 | 413 | |
| 414 | + @Override | |
| 415 | + public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 416 | + return tradeAfterSaleMapper.selectSummaryByRefundTimeBetween(beginTime,endTime); | |
| 417 | + } | |
| 418 | + | |
| 413 | 419 | } | ... | ... |
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 { |
| 156 | 156 | */ |
| 157 | 157 | AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); |
| 158 | 158 | |
| 159 | + /** | |
| 160 | + * 获取已结算的佣金金额 | |
| 161 | + * | |
| 162 | + * @param beginTime 起始时间 | |
| 163 | + * @param endTime 截止时间 | |
| 164 | + * @return 已结算的佣金金额 | |
| 165 | + */ | |
| 166 | + Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 167 | + | |
| 159 | 168 | } | ... | ... |
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 { |
| 356 | 356 | return respVO; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | + @Override | |
| 360 | + public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 361 | + return brokerageRecordMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( | |
| 362 | + BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), | |
| 363 | + beginTime, endTime); | |
| 364 | + } | |
| 365 | + | |
| 359 | 366 | /** |
| 360 | 367 | * 获得自身的代理对象,解决 AOP 生效问题 |
| 361 | 368 | * | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 4 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 6 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 7 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 8 | 9 | import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; |
| 9 | 10 | |
| 11 | +import java.time.LocalDateTime; | |
| 10 | 12 | import java.util.Collection; |
| 11 | 13 | import java.util.List; |
| 12 | 14 | |
| ... | ... | @@ -33,7 +35,7 @@ public interface TradeOrderQueryService { |
| 33 | 35 | * 获得指定用户,指定的交易订单 |
| 34 | 36 | * |
| 35 | 37 | * @param userId 用户编号 |
| 36 | - * @param id 交易订单编号 | |
| 38 | + * @param id 交易订单编号 | |
| 37 | 39 | * @return 交易订单 |
| 38 | 40 | */ |
| 39 | 41 | TradeOrderDO getOrder(Long userId, Long id); |
| ... | ... | @@ -50,7 +52,7 @@ public interface TradeOrderQueryService { |
| 50 | 52 | * 【会员】获得交易订单分页 |
| 51 | 53 | * |
| 52 | 54 | * @param userId 用户编号 |
| 53 | - * @param reqVO 分页请求 | |
| 55 | + * @param reqVO 分页请求 | |
| 54 | 56 | * @return 交易订单 |
| 55 | 57 | */ |
| 56 | 58 | PageResult<TradeOrderDO> getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); |
| ... | ... | @@ -68,7 +70,7 @@ public interface TradeOrderQueryService { |
| 68 | 70 | /** |
| 69 | 71 | * 【前台】获得订单的物流轨迹 |
| 70 | 72 | * |
| 71 | - * @param id 订单编号 | |
| 73 | + * @param id 订单编号 | |
| 72 | 74 | * @param userId 用户编号 |
| 73 | 75 | * @return 物流轨迹数组 |
| 74 | 76 | */ |
| ... | ... | @@ -128,4 +130,13 @@ public interface TradeOrderQueryService { |
| 128 | 130 | */ |
| 129 | 131 | List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds); |
| 130 | 132 | |
| 133 | + /** | |
| 134 | + * 获取订单统计 | |
| 135 | + * | |
| 136 | + * @param beginTime 起始时间 | |
| 137 | + * @param endTime 截止时间 | |
| 138 | + * @return 订单统计结果 | |
| 139 | + */ | |
| 140 | + TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 141 | + | |
| 131 | 142 | } | ... | ... |
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; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 8 | 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 9 | +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; | |
| 9 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 10 | 11 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 11 | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; |
| ... | ... | @@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; |
| 21 | 22 | import org.springframework.stereotype.Service; |
| 22 | 23 | |
| 23 | 24 | import javax.annotation.Resource; |
| 25 | +import java.time.LocalDateTime; | |
| 24 | 26 | import java.util.*; |
| 25 | 27 | |
| 26 | 28 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -156,6 +158,14 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { |
| 156 | 158 | .setPhone(order.getReceiverMobile())); |
| 157 | 159 | } |
| 158 | 160 | |
| 161 | + @Override | |
| 162 | + public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 163 | + TradeOrderSummaryRespDTO dto = tradeOrderMapper.selectSummaryByPayTimeBetween(beginTime, endTime); | |
| 164 | + dto.setOrderCreateCount(tradeOrderMapper.selectCountByCreateTimeBetween(beginTime, endTime)); | |
| 165 | + return dto; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 159 | 169 | // =================== Order Item =================== |
| 160 | 170 | |
| 161 | 171 | @Override | ... | ... |
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 { |
| 115 | 115 | */ |
| 116 | 116 | void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); |
| 117 | 117 | |
| 118 | + /** | |
| 119 | + * 【管理员】核销订单 | |
| 120 | + * | |
| 121 | + * @param id 订单编号 | |
| 122 | + */ | |
| 123 | + void pickUpOrder(Long id); | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * 【管理员】核销订单 | |
| 127 | + * | |
| 128 | + * @param pickUpVerifyCode 自提核销码 | |
| 129 | + */ | |
| 130 | + void pickUpOrder(String pickUpVerifyCode); | |
| 131 | + | |
| 118 | 132 | // =================== Order Item =================== |
| 119 | 133 | |
| 120 | 134 | /** | ... | ... |
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; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.map.MapUtil; |
| 6 | +import cn.hutool.core.util.ObjUtil; | |
| 6 | 7 | import cn.hutool.core.util.ObjectUtil; |
| 7 | 8 | import cn.hutool.core.util.RandomUtil; |
| 8 | 9 | import cn.hutool.extra.spring.SpringUtil; |
| ... | ... | @@ -233,7 +234,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 233 | 234 | order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile()); |
| 234 | 235 | order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位 |
| 235 | 236 | } |
| 236 | - // TODO @疯狂:是不是可以在这里设置下推广人哈; | |
| 237 | + // 设置订单推广人 | |
| 238 | + BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); | |
| 239 | + if (brokerageUser != null && brokerageUser.getBindUserId() != null) { | |
| 240 | + order.setBrokerageUserId(brokerageUser.getBindUserId()); | |
| 241 | + } | |
| 237 | 242 | return order; |
| 238 | 243 | } |
| 239 | 244 | |
| ... | ... | @@ -294,12 +299,6 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 294 | 299 | // 6. 插入订单日志 |
| 295 | 300 | TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); |
| 296 | 301 | |
| 297 | - // 7. 设置订单推广人 | |
| 298 | - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); | |
| 299 | - if (brokerageUser != null && brokerageUser.getBindUserId() != null) { | |
| 300 | - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setBrokerageUserId(brokerageUser.getBindUserId())); | |
| 301 | - } | |
| 302 | - | |
| 303 | 302 | // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! |
| 304 | 303 | } |
| 305 | 304 | |
| ... | ... | @@ -751,6 +750,29 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 751 | 750 | // TODO @puhui999:操作日志 |
| 752 | 751 | } |
| 753 | 752 | |
| 753 | + @Override | |
| 754 | + public void pickUpOrder(Long id) { | |
| 755 | + getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); | |
| 756 | + } | |
| 757 | + | |
| 758 | + @Override | |
| 759 | + public void pickUpOrder(String pickUpVerifyCode) { | |
| 760 | + getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); | |
| 761 | + } | |
| 762 | + | |
| 763 | + @Transactional(rollbackFor = Exception.class) | |
| 764 | + @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.PICK_UP_RECEIVE) | |
| 765 | + public void pickUpOrder(TradeOrderDO order) { | |
| 766 | + if (order == null) { | |
| 767 | + throw exception(ORDER_NOT_FOUND); | |
| 768 | + } | |
| 769 | + if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { | |
| 770 | + throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); | |
| 771 | + } | |
| 772 | + // todo 校验核销操作人? | |
| 773 | + receiveOrder0(order); | |
| 774 | + } | |
| 775 | + | |
| 754 | 776 | // =================== Order Item =================== |
| 755 | 777 | |
| 756 | 778 | @Override | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.api.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | + | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 钱包 API 接口 | |
| 9 | + * | |
| 10 | + * @author owen | |
| 11 | + */ | |
| 12 | +public interface PayWalletApi { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 获取钱包统计 | |
| 16 | + * | |
| 17 | + * @param beginTime 起始时间 | |
| 18 | + * @param endTime 截止时间 | |
| 19 | + * @return 钱包统计 | |
| 20 | + */ | |
| 21 | + WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/WalletSummaryRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.api.wallet.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 钱包统计 Response DTO | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +@Data | |
| 11 | +public class WalletSummaryRespDTO { | |
| 12 | + /** | |
| 13 | + * 总支付金额(余额),单位:分 | |
| 14 | + */ | |
| 15 | + private Integer orderWalletPayPrice; | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 充值订单数 | |
| 19 | + */ | |
| 20 | + private Integer rechargePayCount; | |
| 21 | + /** | |
| 22 | + * 充值金额,单位:分 | |
| 23 | + */ | |
| 24 | + private Integer rechargePayPrice; | |
| 25 | + /** | |
| 26 | + * 充值退款订单数 | |
| 27 | + */ | |
| 28 | + private Integer rechargeRefundCount; | |
| 29 | + /** | |
| 30 | + * 充值退款金额,单位:分 | |
| 31 | + */ | |
| 32 | + private Integer rechargeRefundPrice; | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.api.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | +import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; | |
| 6 | +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | +import org.springframework.validation.annotation.Validated; | |
| 9 | + | |
| 10 | +import javax.annotation.Resource; | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 钱包 API 接口实现类 | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Service | |
| 19 | +@Validated | |
| 20 | +public class PayWalletApiImpl implements PayWalletApi { | |
| 21 | + | |
| 22 | + @Resource | |
| 23 | + private PayWalletRechargeService payWalletRechargeService; | |
| 24 | + @Resource | |
| 25 | + private PayWalletTransactionService payWalletTransactionService; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | + WalletSummaryRespDTO walletSummary = payWalletRechargeService.getWalletSummary(beginTime, endTime); | |
| 30 | + walletSummary.setOrderWalletPayPrice(payWalletTransactionService.getPriceSummary(PayWalletBizTypeEnum.PAYMENT, beginTime, endTime)); | |
| 31 | + return walletSummary; | |
| 32 | + } | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.dal.mysql.wallet; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.bean.BeanUtil; | |
| 4 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 5 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; |
| 9 | +import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; | |
| 10 | +import com.github.yulichang.toolkit.MPJWrappers; | |
| 6 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 12 | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | + | |
| 8 | 15 | @Mapper |
| 9 | 16 | public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> { |
| 10 | 17 | |
| 11 | - default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj){ | |
| 18 | + default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) { | |
| 12 | 19 | return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>() |
| 13 | 20 | .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); |
| 14 | 21 | } |
| 15 | 22 | |
| 16 | - default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj){ | |
| 23 | + default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj) { | |
| 17 | 24 | return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>() |
| 18 | 25 | .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); |
| 19 | 26 | } |
| 20 | 27 | |
| 28 | + default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin() | |
| 30 | + .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargePayCount) | |
| 31 | + .selectSum(PayWalletRechargeDO::getPayPrice, WalletSummaryRespDTO::getRechargePayPrice) | |
| 32 | + .eq(PayWalletRechargeDO::getPayStatus, true) | |
| 33 | + .between(PayWalletRechargeDO::getPayTime, beginTime, endTime)), 0), | |
| 34 | + WalletSummaryRespDTO.class); | |
| 35 | + } | |
| 36 | + | |
| 37 | + default WalletSummaryRespDTO selectRechargeSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 38 | + return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin() | |
| 39 | + .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargeRefundCount) | |
| 40 | + .selectSum(PayWalletRechargeDO::getRefundPayPrice, WalletSummaryRespDTO::getRechargeRefundPrice) | |
| 41 | + .eq(PayWalletRechargeDO::getRefundStatus, PayRefundStatusEnum.SUCCESS.getStatus()) | |
| 42 | + .between(PayWalletRechargeDO::getRefundTime, beginTime, endTime)), 0), | |
| 43 | + WalletSummaryRespDTO.class); | |
| 44 | + } | |
| 45 | + | |
| 21 | 46 | } |
| 22 | 47 | |
| 23 | 48 | ... | ... |
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; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 9 | +import com.github.yulichang.toolkit.MPJWrappers; | |
| 9 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 11 | |
| 12 | +import java.time.LocalDateTime; | |
| 11 | 13 | import java.util.Objects; |
| 14 | +import java.util.Optional; | |
| 12 | 15 | |
| 13 | 16 | @Mapper |
| 14 | 17 | public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> { |
| ... | ... | @@ -35,6 +38,15 @@ public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransac |
| 35 | 38 | PayWalletTransactionDO::getBizType, bizType); |
| 36 | 39 | } |
| 37 | 40 | |
| 41 | + default Integer selectSummaryByBizTypeAndCreateTimeBetween(Integer type, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 42 | + return Optional.ofNullable(selectOne(MPJWrappers.<PayWalletTransactionDO>lambdaJoin() | |
| 43 | + .selectSum(PayWalletTransactionDO::getPrice) | |
| 44 | + .eq(PayWalletTransactionDO::getBizType, type) | |
| 45 | + .between(PayWalletTransactionDO::getCreateTime, beginTime, endTime))) | |
| 46 | + .map(PayWalletTransactionDO::getPrice) | |
| 47 | + .orElse(0); | |
| 48 | + } | |
| 49 | + | |
| 38 | 50 | } |
| 39 | 51 | |
| 40 | 52 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 3 | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; |
| 4 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; |
| 5 | 6 | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 6 | 9 | /** |
| 7 | 10 | * 钱包充值 Service 接口 |
| 8 | 11 | * |
| ... | ... | @@ -42,4 +45,14 @@ public interface PayWalletRechargeService { |
| 42 | 45 | * @param payRefundId 退款单id |
| 43 | 46 | */ |
| 44 | 47 | void updateWalletRechargeRefunded(Long id, Long payRefundId); |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 获取钱包统计 | |
| 51 | + * | |
| 52 | + * @param beginTime 起始时间 | |
| 53 | + * @param endTime 截止时间 | |
| 54 | + * @return 钱包统计 | |
| 55 | + */ | |
| 56 | + WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); | |
| 57 | + | |
| 45 | 58 | } | ... | ... |
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; |
| 4 | 4 | import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 7 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 7 | 8 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; |
| 8 | 9 | import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; |
| 9 | 10 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; |
| ... | ... | @@ -40,7 +41,7 @@ import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; |
| 40 | 41 | @Service |
| 41 | 42 | @Slf4j |
| 42 | 43 | public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 43 | - | |
| 44 | + | |
| 44 | 45 | /** |
| 45 | 46 | * TODO 放到 配置文件中 |
| 46 | 47 | */ |
| ... | ... | @@ -94,9 +95,9 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 94 | 95 | PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); |
| 95 | 96 | |
| 96 | 97 | // 2. 更新钱包充值的支付状态 |
| 97 | - int updateCount = walletRechargeMapper.updateByIdAndPaid(id,false, | |
| 98 | + int updateCount = walletRechargeMapper.updateByIdAndPaid(id, false, | |
| 98 | 99 | new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) |
| 99 | - .setPayChannelCode(payOrderDO.getChannelCode())); | |
| 100 | + .setPayChannelCode(payOrderDO.getChannelCode())); | |
| 100 | 101 | if (updateCount == 0) { |
| 101 | 102 | throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); |
| 102 | 103 | } |
| ... | ... | @@ -124,7 +125,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 124 | 125 | // 3 创建退款单 |
| 125 | 126 | String walletRechargeId = String.valueOf(id); |
| 126 | 127 | String refundId = walletRechargeId + "-refund"; |
| 127 | - Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() | |
| 128 | + Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() | |
| 128 | 129 | .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) |
| 129 | 130 | .setMerchantOrderId(walletRechargeId) |
| 130 | 131 | .setMerchantRefundId(refundId) |
| ... | ... | @@ -257,4 +258,15 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 257 | 258 | return payOrder; |
| 258 | 259 | } |
| 259 | 260 | |
| 261 | + @Override | |
| 262 | + public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 263 | + WalletSummaryRespDTO paySummary = walletRechargeMapper.selectRechargeSummaryByPayTimeBetween(beginTime, endTime); | |
| 264 | + WalletSummaryRespDTO refundSummary = walletRechargeMapper.selectRechargeSummaryByRefundTimeBetween(beginTime, endTime); | |
| 265 | + | |
| 266 | + paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount()); | |
| 267 | + paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); | |
| 268 | + | |
| 269 | + return paySummary; | |
| 270 | + } | |
| 271 | + | |
| 260 | 272 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 3 | 4 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 4 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 6 | 7 | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 7 | 10 | /** |
| 8 | 11 | * 钱包 Service 接口 |
| 9 | 12 | * | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | +import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; | ... | ... |
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; |
| 7 | 7 | import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.Valid; |
| 10 | +import java.time.LocalDateTime; | |
| 10 | 11 | |
| 11 | 12 | /** |
| 12 | 13 | * 钱包余额流水 Service 接口 |
| ... | ... | @@ -43,10 +44,20 @@ public interface PayWalletTransactionService { |
| 43 | 44 | /** |
| 44 | 45 | * 获取钱包流水 |
| 45 | 46 | * |
| 46 | - * @param bizId 业务编号 | |
| 47 | + * @param bizId 业务编号 | |
| 47 | 48 | * @param type 业务类型 |
| 48 | 49 | * @return 钱包流水 |
| 49 | 50 | */ |
| 50 | 51 | PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); |
| 51 | 52 | |
| 53 | + /** | |
| 54 | + * 获取支付金额合计 | |
| 55 | + * | |
| 56 | + * @param bizType 业务类型 | |
| 57 | + * @param beginTime 开始时间 | |
| 58 | + * @param endTime 结束时间 | |
| 59 | + * @return 支付金额合计 | |
| 60 | + */ | |
| 61 | + Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 62 | + | |
| 52 | 63 | } | ... | ... |
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; |
| 13 | 13 | import org.springframework.stereotype.Service; |
| 14 | 14 | |
| 15 | 15 | import javax.annotation.Resource; |
| 16 | +import java.time.LocalDateTime; | |
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * 钱包流水 Service 实现类 |
| ... | ... | @@ -60,4 +61,9 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ |
| 60 | 61 | return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); |
| 61 | 62 | } |
| 62 | 63 | |
| 64 | + @Override | |
| 65 | + public Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 66 | + return payWalletTransactionMapper.selectSummaryByBizTypeAndCreateTimeBetween(bizType.getType(), beginTime, endTime); | |
| 67 | + } | |
| 68 | + | |
| 63 | 69 | } | ... | ... |