Pu Zhibing
2025-03-27 e7a4c604b4703caf135ec3d360106e7cf028cc89
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
@@ -31,6 +31,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -106,10 +107,8 @@
        R<SysUser> sysUserR = sysUserClient.getSysUser(userid);
        SysUser sysUser = sysUserR.getData();
        Integer objectId = sysUser.getObjectId();
        Page<ShopBalanceStatement> page = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(shopBalanceStatement.getType() != null, ShopBalanceStatement::getType, shopBalanceStatement.getType())
                .orderByDesc(ShopBalanceStatement::getCreateTime)
                .page(Page.of(pageNum, pageSize));
        Page<ShopBalanceStatement> page = shopBalanceStatementService.shopCommissionStatisticslist(objectId, shopBalanceStatement.getType(), pageNum, pageSize);
        page.getRecords().forEach(s->s.setVariableAmount(s.getVariableAmount().multiply(new BigDecimal(s.getChangeDirection()))));
        return R.ok(page);
@@ -276,6 +275,30 @@
            }
        }
        List<ShopBalanceStatement> list = shopBalanceStatementService.list(queryWrapper);
        for (ShopBalanceStatement shopBalanceStatement : list) {
            shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection())));
        }
        LambdaQueryWrapper<ShopBalanceStatementCopy> queryWrapper1 = new LambdaQueryWrapper<ShopBalanceStatementCopy>()
                .eq(ShopBalanceStatementCopy::getType, type)
                .between(ShopBalanceStatementCopy::getCreateTime, date.with(LocalTime.MIN), date.with(LocalTime.MAX));
        if (null != shopId && 0 != shopId) {
            queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, shopId);
        }else{
            List<Integer> shipIds = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0)).stream().map(Shop::getId).collect(Collectors.toList());
            if(shipIds.size() > 0){
                queryWrapper1.in(ShopBalanceStatementCopy::getShopId, shipIds);
            }else{
                queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, -1);
            }
        }
        List<ShopBalanceStatementCopy> list1 = shopBalanceStatementCopyMapper.selectList(queryWrapper1);
        for (ShopBalanceStatementCopy shopBalanceStatementCopy  : list1) {
            ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
            BeanUtils.copyProperties(shopBalanceStatementCopy, shopBalanceStatement);
            shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection())));
            list.add(shopBalanceStatement);
        }
        return R.ok(list);
    }
@@ -301,8 +324,8 @@
        // 合并计算
        Map<Integer, BigDecimal> result = Stream.concat(
                copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount())),
                statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount()))
                copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection())))),
                statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection()))))
        ).collect(Collectors.groupingBy(
                Pair::getKey,
                Collectors.mapping(Pair::getValue, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
@@ -323,7 +346,6 @@
        }
        // 构建结果
        List<ShopWithdraw> list = shopWithdrawService.lambdaQuery().eq(ShopWithdraw::getShopId, shopId)
                .eq(ShopWithdraw::getAuditStatus, 0).list();
        BigDecimal withdrawAuditMoney = list.stream().map(ShopWithdraw::getMoney).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
@@ -338,7 +360,6 @@
                        ));
        commission.setWaitingAuditCommission(waitingAudit);
        commission.setTotalAmount(commission.getCommissionAmount());
        return R.ok(commission);
    }