feat:添加部门财务报表纬度

This commit is contained in:
dzc committed 2025-03-06 20:18:15 +08:00
1 parent 09d8c12ec5
commit 0d95161f50
4 files changed
+44 -1

No files matched your search

@@ -48,6 +48,12 @@ public class HardDeptTotalVo {
@Schema(description = "退款次数")
private Long orderRefundCont = 0L;
@Schema(description = "盈利金额")
private Long orderProfitPrice = 0L;
@Schema(description = "盈利次数")
private Long orderProfitCont = 0L;
/**
* 导出相关
*/
@@ -246,8 +246,12 @@ public class HardOrderTotalController {
BigDecimal orderPayPriceSum = BigDecimal.ZERO;
BigDecimal orderPayCountSum = BigDecimal.ZERO;
BigDecimal orderRefundPriceSum = BigDecimal.ZERO;
BigDecimal orderRefundContSum = BigDecimal.ZERO;
// 盈利
BigDecimal orderProfitPriceSum = BigDecimal.ZERO;
BigDecimal orderProfitContSum = BigDecimal.ZERO;
Long lineNumber = 1L;
for (HardDeptTotalVo v : list) {
@@ -305,6 +309,14 @@ public class HardOrderTotalController {
orderRefundContSum = orderRefundContSum.add(BigDecimal.valueOf(v.getOrderRefundCont()));
v.setOrderRefundCont(BigDecimal.valueOf(v.getOrderRefundCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderProfitPrice())) {
orderProfitPriceSum = orderProfitPriceSum.add(BigDecimal.valueOf(v.getOrderProfitPrice()));
v.setOrderProfitPrice(BigDecimal.valueOf(v.getOrderProfitPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderProfitCont())) {
orderProfitContSum = orderProfitContSum.add(BigDecimal.valueOf(v.getOrderProfitCont()));
v.setOrderProfitCont(BigDecimal.valueOf(v.getOrderProfitCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
// 批量充值
map.put("walletPriceSum", walletPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("walletCountSum", walletCountSum.toString());
@@ -320,8 +332,12 @@ public class HardOrderTotalController {
map.put("orderPayPriceSum", orderPayPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("orderPayCountSum", orderPayCountSum.toString());
map.put("orderRefundPriceSum", orderRefundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("orderRefundContSum", orderRefundContSum.toString());
map.put("orderProfitPriceSum", orderProfitPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("orderProfitContSum", orderProfitContSum.toString());
}
}
excelWriter.fill(map, writeSheet);
@@ -273,7 +273,20 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
return hardOrderMapper.sumAndCount(refundDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture);
// 查看盈利流水
CompletableFuture<List<HardOrderSumAndCountVo>> profitFuture = CompletableFuture.supplyAsync(() -> {
HardOrderSumAndCountDto refundDto = new HardOrderSumAndCountDto();
refundDto.setDeptIds(deptIds);
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
refundDto.setCreateTimeList(dto.getCreateTimeList());
}
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
refundDto.setWalletTypeId(dto.getWalletTypeId());
}
return hardOrderMapper.sumAndCount(refundDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(walletBatchFuture, walletReduceFuture, payFuture, refundFuture, walletOnceBatchFuture, walletOnceReduceFuture, profitFuture);
allFutures.join();
List<WalletTransactionSumAndCountVo> walletBatchList = walletBatchFuture.join();
List<WalletTransactionSumAndCountVo> walletReduceList = walletReduceFuture.join();
@@ -281,6 +294,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
List<WalletTransactionSumAndCountVo> walletOnceReduceList = walletOnceReduceFuture.join();
List<HardOrderSumAndCountVo> payList = payFuture.join();
List<HardOrderSumAndCountVo> refundList = refundFuture.join();
List<HardOrderSumAndCountVo> profitList = profitFuture.join();
// 聚合一下数据
for (HardDeptTotalVo v : resultList) {
if (ObjectUtil.isNotEmpty(walletBatchList)) {
@@ -319,6 +333,13 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
v.setOrderRefundCont(i.getCount());
});
}
// 查看盈利流水
if (ObjectUtil.isNotEmpty(profitList)) {
profitList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
v.setOrderProfitPrice(i.getSum());
v.setOrderProfitCont(i.getCount());
});
}
}
return resultList;
});