feat:批量扣款统计、单次扣款统计

This commit is contained in:
dzc committed 2025-02-19 10:34:03 +08:00
1 parent 4fb5549df7
commit 4919d83314
2 files changed
+83 -3

No files matched your search

@@ -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;
@@ -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<List<WalletTransactionSumAndCountVo>> 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<List<WalletTransactionSumAndCountVo>> 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<List<WalletTransactionSumAndCountVo>> 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<Void> allFutures = CompletableFuture.allOf(walletBatchFuture, payFuture, refundFuture);
CompletableFuture<Void> allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture);
allFutures.join();
List<WalletTransactionSumAndCountVo> walletBatchList = walletBatchFuture.join();
List<WalletTransactionSumAndCountVo> walletReduceList = walletReduceFuture.join();
List<WalletTransactionSumAndCountVo> walletOnceBatchList = walletOnceBatchFuture.join();
List<WalletTransactionSumAndCountVo> walletOnceReduceList = walletOnceReduceFuture.join();
List<HardOrderSumAndCountVo> payList = payFuture.join();
List<HardOrderSumAndCountVo> 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());