MrShi
2024-12-06 242bea686a5a3cd4c0488cdbe72acdc17fc3b698
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -25,10 +25,12 @@
import com.doumee.dao.admin.request.UpdateCompanySortDTO;
import com.doumee.dao.admin.response.CompanyDTO;
import com.doumee.dao.business.MemberMapper;
import com.doumee.dao.business.YwContractMapper;
import com.doumee.dao.business.dao.CompanyMapper;
import com.doumee.dao.business.dao.join.CompanyJoinMapper;
import com.doumee.dao.business.model.Company;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.YwContract;
import com.doumee.dao.business.vo.CompanyTree;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.CompanyService;
@@ -63,6 +65,9 @@
    @Autowired
    private CompanyJoinMapper companyJoinMapper;
    @Autowired
    private YwContractMapper ywContractMapper;
    /**
     * 创建财务公司
@@ -77,6 +82,13 @@
                .eq(Company::getType,company.getType())
                .eq(Company::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~");
        }
        if(StringUtils.isNotBlank(company.getCode())){
            if(companyMapper.selectCount(new QueryWrapper<Company>().lambda()
                    .eq(Company::getCode,company.getCode())
                    .eq(Company::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~");
            }
        }
        company.setCreateDate(new Date());
        company.setCreator(company.getLoginUserInfo().getId());
@@ -105,6 +117,13 @@
                .eq(Company::getName,company.getName())
                .eq(Company::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,组织名称不能重复~");
        }
        if(StringUtils.isNotBlank(company.getCode())){
            if(companyMapper.selectCount(new QueryWrapper<Company>().lambda()
                    .eq(Company::getCode,company.getCode())
                    .eq(Company::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~");
            }
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(user ==null){
@@ -260,6 +279,9 @@
                .eq(Member::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该部门下存在人员信息,不能进行删除操作!");
        }
        if(ywContractMapper.selectCount(new QueryWrapper<YwContract>().lambda().eq(YwContract::getCompanyId,id))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "当前公司已关联业务,不可删除");
        }
        Company company = new Company();
        company.setId(id);
@@ -308,6 +330,15 @@
                .eq(Company::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,组织名称不能重复~");
        }
        if(StringUtils.isNotBlank(company.getCode())){
            if(companyMapper.selectCount(new QueryWrapper<Company>().lambda()
                    .eq(Company::getCode,company.getCode())
                    .ne(Company::getId,company.getId())
                    .eq(Company::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~");
            }
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(user == null){
            user = company.getLoginUserInfo();
@@ -367,6 +398,14 @@
                .eq(Company::getIsdeleted,Constants.ZERO)) >0){
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,名称不能重复~");
        }
        if(StringUtils.isNotBlank(company.getCode())){
            if(companyMapper.selectCount(new QueryWrapper<Company>().lambda()
                    .eq(Company::getCode,company.getCode())
                    .ne(Company::getId,company.getId())
                    .eq(Company::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,纳税识别号不能重复~");
            }
        }
        companyMapper.updateById(company);
        return company.getId();
    }