From 45f4118f98840ff098e94a5072a9f937d3810a1c Mon Sep 17 00:00:00 2001 From: 18582019636 <1657978663@qq.com> Date: 星期五, 21 六月 2024 12:00:03 +0800 Subject: [PATCH] feat: 代码初始化 --- ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/service/impl/WithdrawServiceImpl.java | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/service/impl/WithdrawServiceImpl.java b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/service/impl/WithdrawServiceImpl.java index d82aa8b..93a6cb6 100644 --- a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/service/impl/WithdrawServiceImpl.java +++ b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/service/impl/WithdrawServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.user.service.impl; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.admin.api.entity.WithdrawalSetting; import com.ruoyi.admin.api.feignClient.AdminClient; @@ -49,22 +50,33 @@ private AdminClient adminClient; @Override - public WithdrawListVO withdrawList(Long userid) { + public WithdrawListVO withdrawList(Integer userid) { WithdrawListVO withdrawList = new WithdrawListVO(); List<Order> orderList = orderService.lambdaQuery().eq(Order::getUserId, userid) .eq(Order::getState, 3).eq(Order::getIsDelete, 0).list(); // 总金额 - BigDecimal totalMoney = orderList.stream().map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalMoney = BigDecimal.ZERO; // 未提现金额 - BigDecimal undelivered = orderList.stream().filter(data -> Constants.ZERO.equals(data.getIsWithdrawal())) - .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal undelivered = BigDecimal.ZERO; // 已提现金额 - BigDecimal withdrawn = orderList.stream().filter(data -> Constants.ONE.equals(data.getIsWithdrawal())) - .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal withdrawn = BigDecimal.ZERO; + if (!orderList.isEmpty()) { + // 总金额 + totalMoney = orderList.stream().map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + // 未提现金额 + undelivered = orderList.stream().filter(data -> Constants.ZERO.equals(data.getIsWithdrawal())) + .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + // 已提现金额 + withdrawn = orderList.stream().filter(data -> Constants.ONE.equals(data.getIsWithdrawal())) + .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); + } withdrawList.setMoneyCount(new WithdrawMoneyVO(totalMoney, undelivered, withdrawn)); // 回收服务列表 - List<RecoveryServe> serveList = recoveryServeService.lambdaQuery().eq(RecoveryServe::getIsDelete, 0) - .in(RecoveryServe::getId, orderList.stream().map(Order::getServeId).collect(Collectors.toList())).list(); + List<Integer> serveIds = orderList.stream().map(Order::getServeId).collect(Collectors.toList()); + LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery() + .eq(RecoveryServe::getIsDelete, 0); + wrapper = serveIds.isEmpty() ? wrapper : wrapper.in(RecoveryServe::getId, serveIds); + List<RecoveryServe> serveList = wrapper.list(); Map<Integer, RecoveryServe> serveMap = serveList.stream().collect(Collectors.toMap(RecoveryServe::getId, serve -> serve)); // 订单列表 List<WithdrawOrderVO> list = new ArrayList<>(); @@ -86,7 +98,7 @@ @Override @Transactional(rollbackFor = Exception.class) - public Boolean confirmWithdraw(Integer orderId, Long userid) { + public Boolean confirmWithdraw(Integer orderId, Integer userid) { Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); if (null == order) { throw new GlobalException("订单信息异常!"); -- Gitblit v1.7.1