fix(tenant-withdraw): 增加下级租户提现订单数据权限过滤

This commit is contained in:
2026-01-06 19:14:15 +08:00
parent ca6e3d20f6
commit d7ed10f45d
3 changed files with 26 additions and 0 deletions

View File

@@ -111,4 +111,7 @@ public class KeyboardTenantWithdrawOrderPageReqVO extends PageParam {
@Schema(description = "更新时间") @Schema(description = "更新时间")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
@Schema(description = "租户ID列表用于下级租户过滤", hidden = true)
private List<Long> tenantIds;
} }

View File

@@ -19,6 +19,7 @@ public interface KeyboardTenantWithdrawOrderMapper extends BaseMapperX<KeyboardT
default PageResult<KeyboardTenantWithdrawOrderDO> selectPage(KeyboardTenantWithdrawOrderPageReqVO reqVO) { default PageResult<KeyboardTenantWithdrawOrderDO> selectPage(KeyboardTenantWithdrawOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardTenantWithdrawOrderDO>() return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardTenantWithdrawOrderDO>()
.inIfPresent(KeyboardTenantWithdrawOrderDO::getTenantId, reqVO.getTenantIds())
.eqIfPresent(KeyboardTenantWithdrawOrderDO::getWithdrawNo, reqVO.getWithdrawNo()) .eqIfPresent(KeyboardTenantWithdrawOrderDO::getWithdrawNo, reqVO.getWithdrawNo())
.eqIfPresent(KeyboardTenantWithdrawOrderDO::getBizNo, reqVO.getBizNo()) .eqIfPresent(KeyboardTenantWithdrawOrderDO::getBizNo, reqVO.getBizNo())
.eqIfPresent(KeyboardTenantWithdrawOrderDO::getCurrency, reqVO.getCurrency()) .eqIfPresent(KeyboardTenantWithdrawOrderDO::getCurrency, reqVO.getCurrency())

View File

@@ -7,9 +7,11 @@ import com.yolo.keyboard.dal.dataobject.tenantwithdraworder.KeyboardTenantWithdr
import com.yolo.keyboard.dal.mysql.tenantwithdraworder.KeyboardTenantWithdrawOrderMapper; import com.yolo.keyboard.dal.mysql.tenantwithdraworder.KeyboardTenantWithdrawOrderMapper;
import com.yolo.keyboard.framework.common.pojo.PageResult; import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.common.util.object.BeanUtils; import com.yolo.keyboard.framework.common.util.object.BeanUtils;
import com.yolo.keyboard.framework.tenant.core.context.TenantContextHolder;
import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO; import com.yolo.keyboard.module.system.dal.dataobject.tenant.TenantDO;
import com.yolo.keyboard.module.system.dal.mysql.tenant.TenantMapper; import com.yolo.keyboard.module.system.dal.mysql.tenant.TenantMapper;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -84,6 +86,26 @@ public class KeyboardTenantWithdrawOrderServiceImpl implements KeyboardTenantWit
@Override @Override
public PageResult<KeyboardTenantWithdrawOrderRespVO> getTenantWithdrawOrderPage(KeyboardTenantWithdrawOrderPageReqVO pageReqVO) { public PageResult<KeyboardTenantWithdrawOrderRespVO> getTenantWithdrawOrderPage(KeyboardTenantWithdrawOrderPageReqVO pageReqVO) {
// 根据当前租户级别过滤下级租户的提现申请
Long currentTenantId = TenantContextHolder.getTenantId();
if (currentTenantId != null) {
TenantDO currentTenant = tenantMapper.selectById(currentTenantId);
if (currentTenant != null && currentTenant.getTenantLevel() != null
&& currentTenant.getTenantLevel() != 0) {
// 非系统管理员:只能查看直属下级租户的提现申请
List<TenantDO> subordinateTenants = tenantMapper.selectList(
new LambdaQueryWrapper<TenantDO>().eq(TenantDO::getParentId, currentTenantId));
List<Long> subordinateTenantIds = subordinateTenants.stream()
.map(TenantDO::getId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(subordinateTenantIds)) {
// 没有下级租户,返回空结果
return PageResult.empty(0L);
}
pageReqVO.setTenantIds(subordinateTenantIds);
}
}
// 分页查询租户提现订单数据 // 分页查询租户提现订单数据
PageResult<KeyboardTenantWithdrawOrderDO> pageResult = tenantWithdrawOrderMapper.selectPage(pageReqVO); PageResult<KeyboardTenantWithdrawOrderDO> pageResult = tenantWithdrawOrderMapper.selectPage(pageReqVO);
if (CollUtil.isEmpty(pageResult.getList())) { if (CollUtil.isEmpty(pageResult.getList())) {