18582019636
2024-06-21 45f4118f98840ff098e94a5072a9f937d3810a1c
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("订单信息异常!");