zhangmei
2025-03-27 1fad0578c97abbb7fc30f59eb1de0f23f08ddde1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTenantServiceImpl.java
@@ -6,8 +6,9 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.constant.DictConstants;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.dto.TTenantDTO;
import com.ruoyi.system.mapper.TContractMapper;
import com.ruoyi.system.mapper.THouseMapper;
import com.ruoyi.system.mapper.TTenantMapper;
@@ -23,7 +24,6 @@
import com.ruoyi.system.vo.TBillVO;
import com.ruoyi.system.vo.TenantVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -49,7 +49,14 @@
    @Override
    public PageInfo<TenantVO> pageList(TTenantQuery query) {
        PageInfo<TenantVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TenantVO> list = this.baseMapper.pageList(query,pageInfo);
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        List<TenantVO> list = null;
        if (StringUtils.isBlank(businessDeptId) || "0".equals(businessDeptId)) {
            list = this.baseMapper.pageList(query, pageInfo);
        } else {
            query.setBusinessDeptId(businessDeptId);
            list = this.baseMapper.pageListByBusinessDeptId(query,pageInfo);
        }
        for (TenantVO tenantVO : list) {
            tenantVO.setTenantAttributesName(StringUtils.isNotBlank(tenantVO.getTenantAttributes())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_ATTRIBUTE,tenantVO.getTenantAttributes()):"");
            tenantVO.setTenantTypeName(StringUtils.isNotBlank(tenantVO.getTenantType())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_TYPE,tenantVO.getTenantType()):"");
@@ -113,14 +120,20 @@
    @Override
    public PageInfo<TBillVO> listBill(TBillAppletQuery query) {
        List<String> contractIds = contractMapper.selectList(new LambdaQueryWrapper<TContract>()
                        .eq(TContract::getTenantId, query.getId())).stream().map(TContract::getId)
        List<TContract> tContracts = contractMapper.selectList(new LambdaQueryWrapper<TContract>()
                .eq(TContract::getTenantId, query.getId()));
        List<String> contractIds = tContracts.stream().map(TContract::getId)
                .collect(Collectors.toList());
        if (contractIds.isEmpty())contractIds.add("0");
        PageInfo<TBillVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TBillVO> list = this.baseMapper.listBill(query,pageInfo);
        for (TBillVO tBillVO : list) {
            tBillVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tBillVO.getPayFeesStatus()));
            TContract contract = tContracts.stream().filter(e -> e.getId().equals(tBillVO.getContractId()))
                    .findFirst().orElse(null);
            if (contract!=null){
                tBillVO.setHouse(houseMapper.selectById(contract.getHouseId()));
            }
            tBillVO.setPayFeesStatus(tBillVO.getPayFeesStatus());
        }
        pageInfo.setRecords(list);
        return pageInfo;
@@ -133,4 +146,15 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public boolean isExit(TTenantDTO dto) {
        if(StringUtils.isNotEmpty(dto.getId())){
            // 修改
            return this.count(Wrappers.lambdaQuery(TTenant.class).ne(TTenant::getId, dto.getId()).eq(TTenant::getPhone, dto.getPhone())) > 0;
        }else {
            // 新增
            return this.count(Wrappers.lambdaQuery(TTenant.class).eq(TTenant::getPhone, dto.getPhone())) > 0;
        }
    }
}