feat(tenant-balance): 实现查询下级租户余额分页接口

This commit is contained in:
2025-12-25 21:57:57 +08:00
parent e2269e1ff4
commit 1694603465
2 changed files with 35 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ package com.yolo.keyboard.service.tenantbalance;
import cn.hutool.core.collection.CollUtil;
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
import com.yolo.keyboard.dal.mysql.tenantbalancetransaction.TenantBalanceTransactionMapper;
import com.yolo.keyboard.framework.common.util.collection.CollectionUtils;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.tenant.core.context.TenantContextHolder;
import com.yolo.keyboard.utils.BizNoGenerator;
import org.springframework.stereotype.Service;
@@ -19,6 +21,8 @@ import com.yolo.keyboard.framework.common.pojo.PageParam;
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
import com.yolo.keyboard.dal.mysql.tenantbalance.TenantBalanceMapper;
import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO;
import com.yolo.keyboard.module.system.dal.mysql.tenant.TenantMapper;
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
@@ -40,6 +44,9 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
@Resource
private TenantBalanceTransactionMapper tenantBalanceTransactionMapper;
@Resource
private TenantMapper tenantMapper;
@Override
public Long createTenantBalance(TenantBalanceSaveReqVO createReqVO) {
// 插入
@@ -125,12 +132,32 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
@Override
public TenantBalanceDO getSelfBalance() {
return null;
Long tenantId = TenantContextHolder.getRequiredTenantId();
return tenantBalanceMapper.selectById(tenantId);
}
@Override
public PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO) {
return null;
// 1. 获取当前租户ID
Long currentTenantId = TenantContextHolder.getRequiredTenantId();
// 2. 查询当前租户的下级租户列表
List<TenantDO> subordinateTenants = tenantMapper.selectList(TenantDO::getParentId, currentTenantId);
// 3. 提取下级租户的ID列表
List<Long> tenantIds = CollectionUtils.convertList(subordinateTenants, TenantDO::getId);
// 4. 如果没有下级租户,则直接返回空的分页结果
if (CollUtil.isEmpty(tenantIds)) {
return PageResult.empty();
}
// 5. 根据下级租户ID列表查询对应的余额信息并进行分页
PageResult<TenantBalanceDO> pageResult = tenantBalanceMapper.selectPage(pageReqVO,
new LambdaQueryWrapperX<TenantBalanceDO>().in(TenantBalanceDO::getId, tenantIds));
// 6. 将查询结果转换为响应VO并返回
return BeanUtils.toBean(pageResult, TenantBalanceRespVO.class);
}
}