From 4919d83314551f54c3ee6cf0ce8836abbae60750 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 19 Feb 2025 10:34:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=89=B9=E9=87=8F=E6=89=A3=E6=AC=BE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E3=80=81=E5=8D=95=E6=AC=A1=E6=89=A3=E6=AC=BE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hard/api/vo/order/HardDeptTotalVo.java | 18 +++++ .../impl/order/HardOrderTotalServiceImpl.java | 68 ++++++++++++++++++- 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java index bc7bb55a8..dd80811d8 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardDeptTotalVo.java @@ -18,6 +18,24 @@ public class HardDeptTotalVo { @Schema(description = "批量充值次数") private Long walletCount = 0L; + @Schema(description = "批量扣减金额") + private Long walletReducePrice = 0L; + + @Schema(description = "批量扣减次数") + private Long walletReduceCount = 0L; + + @Schema(description = "单次充值金额") + private Long walletOncePrice = 0L; + + @Schema(description = "单次充值次数") + private Long walletOnceCount = 0L; + + @Schema(description = "单次扣减金额") + private Long walletOnceReducePrice = 0L; + + @Schema(description = "单次扣减次数") + private Long walletOnceReduceCount = 0L; + @Schema(description = "消费金额") private Long orderPayPrice = 0L; diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java index 8a8b09be1..c98ffd0ba 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.admin.api.entity.SysDept; import com.bsd.pjcloud.admin.api.feign.RemoteDeptService; -import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.common.core.util.CollectionUtils; import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum; import com.bsd.pjcloud.hard.api.dto.HardManagerDto; @@ -33,7 +32,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -162,6 +160,49 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto(); walletDto.setDeptIds(deptIds); walletDto.setBizTypes(List.of(WalletBizEnum.BATCH.getCode())); + walletDto.setType(WalletTransactionSumAndCountDto.TYPE_INCOME); + if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { + walletDto.setCreateTimeList(dto.getCreateTimeList()); + } + if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) { + walletDto.setWalletTypeId(dto.getWalletTypeId()); + } + return remoteWalletTransactionService.sumAndCount(walletDto).getData(); + }); + // 查询钱包批量扣减流水 + CompletableFuture> walletReduceFuture = CompletableFuture.supplyAsync(() -> { + WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto(); + walletDto.setDeptIds(deptIds); + walletDto.setBizTypes(List.of(WalletBizEnum.BATCH.getCode())); + walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE); + if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { + walletDto.setCreateTimeList(dto.getCreateTimeList()); + } + if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) { + walletDto.setWalletTypeId(dto.getWalletTypeId()); + } + return remoteWalletTransactionService.sumAndCount(walletDto).getData(); + }); + // 查询钱包单次充值流水 + CompletableFuture> walletOnceBatchFuture = CompletableFuture.supplyAsync(() -> { + WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto(); + walletDto.setDeptIds(deptIds); + walletDto.setBizTypes(List.of(WalletBizEnum.UPDATE.getCode())); + walletDto.setType(WalletTransactionSumAndCountDto.TYPE_INCOME); + if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { + walletDto.setCreateTimeList(dto.getCreateTimeList()); + } + if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) { + walletDto.setWalletTypeId(dto.getWalletTypeId()); + } + return remoteWalletTransactionService.sumAndCount(walletDto).getData(); + }); + // 查询钱包单次扣减流水 + CompletableFuture> walletOnceReduceFuture = CompletableFuture.supplyAsync(() -> { + WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto(); + walletDto.setDeptIds(deptIds); + walletDto.setBizTypes(List.of(WalletBizEnum.UPDATE.getCode())); + walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE); if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) { walletDto.setCreateTimeList(dto.getCreateTimeList()); } @@ -196,9 +237,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { } return hardOrderMapper.sumAndCount(refundDto); }); - CompletableFuture allFutures = CompletableFuture.allOf(walletBatchFuture, payFuture, refundFuture); + CompletableFuture allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture); allFutures.join(); List walletBatchList = walletBatchFuture.join(); + List walletReduceList = walletReduceFuture.join(); + List walletOnceBatchList = walletOnceBatchFuture.join(); + List walletOnceReduceList = walletOnceReduceFuture.join(); List payList = payFuture.join(); List refundList = refundFuture.join(); // 聚合一下数据 @@ -209,6 +253,24 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { v.setWalletCount(i.getCount()); }); } + if (ObjectUtil.isNotEmpty(walletReduceList)) { + walletReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { + v.setWalletReducePrice(i.getSum()); + v.setWalletReduceCount(i.getCount()); + }); + } + if (ObjectUtil.isNotEmpty(walletOnceBatchList)) { + walletOnceBatchList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { + v.setWalletOncePrice(i.getSum()); + v.setWalletOnceCount(i.getCount()); + }); + } + if (ObjectUtil.isNotEmpty(walletOnceReduceList)) { + walletOnceReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { + v.setWalletOnceReducePrice(i.getSum()); + v.setWalletOnceReduceCount(i.getCount()); + }); + } if (ObjectUtil.isNotEmpty(payList)) { payList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> { v.setOrderPayPrice(i.getSum());