| | |
| | | public Boolean insertByBo(SysCompanyBo bo) |
| | | { |
| | | SysCompany add = Convert.convert(SysCompany.class, bo); |
| | | add.setCompanyStatus(1); |
| | | validEntityBeforeSave(add); |
| | | add.setCompanyStatus(0); |
| | | boolean save = this.save(add); |
| | | addCompanyUser(add); |
| | | addCompanyUser(add, 0); |
| | | return save; |
| | | } |
| | | |
| | |
| | | if (!delUser) { |
| | | throw new BaseException("原企业用户清除失败,请联系管理员!"); |
| | | } |
| | | this.addCompanyUser(update); |
| | | this.addCompanyUser(update, update.getCompanyStatus()==0 ? 1 : 0); |
| | | } |
| | | validEntityBeforeSave(update); |
| | | return this.updateById(update); |
| | | } |
| | | |
| | | @Override//状态开关 |
| | | @Transactional |
| | | public Boolean updStatus(SysCompanyBo bo) |
| | | { |
| | | if (bo.getCompanyId()==null || bo.getCompanyStatus()==null) { |
| | | throw new BaseException("参数有误,状态修改失败!"); |
| | | } |
| | | SysCompany company = this.getById(bo.getCompanyId()); |
| | | company.setCompanyStatus(bo.getCompanyStatus()); |
| | | updCompanyUserStatus(company.getCompanyPhone(), bo.getCompanyStatus()); |
| | | return this.updateById(company); |
| | | } |
| | | |
| | | @Override//删除 |
| | |
| | | }); |
| | | List<SysCompany> companies = Convert.toList(SysCompany.class, resultVo.getVoList()); |
| | | boolean b = this.saveOrUpdateBatch(companies); |
| | | companies.forEach(this::addCompanyUser); |
| | | for (SysCompany company : companies) { |
| | | addCompanyUser(company,1); |
| | | } |
| | | return b; |
| | | } |
| | | |
| | |
| | | int phoneCount = this.count(lq().eq(SysCompany::getCompanyPhone, entity.getCompanyPhone())); |
| | | if (phoneCount>0){ |
| | | throw new BaseException(String.format("%1$s,企业联系电话已存在!", entity.getCompanyName())); |
| | | } |
| | | SysUser user = new SysUser(); |
| | | user.setPhonenumber(entity.getCompanyPhone()); |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | throw new BaseException(String.format("%1$s,企业联系电话已存在,请更换手机号!", entity.getCompanyName())); |
| | | } |
| | | } else { |
| | | int codeCount = this.count(lq().eq(SysCompany::getCompanyCode, entity.getCompanyCode()).ne(SysCompany::getCompanyId,entity.getCompanyId())); |
| | |
| | | errorList.add(new ImportError(0, "企业名已存在!")); |
| | | } |
| | | int phoneCount = this.count(lq().eq(SysCompany::getCompanyPhone, entity.getCompanyPhone())); |
| | | SysUser user = new SysUser(); |
| | | user.setPhonenumber(entity.getCompanyPhone()); |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | errorList.add(new ImportError(3, "企业联系电话系统中已存在,请更换电话!")); |
| | | } |
| | | if (phoneCount>0){ |
| | | errorList.add(new ImportError(3, "企业联系电话已存在!")); |
| | | } |
| | |
| | | * @param entity 企业信息 |
| | | */ |
| | | @Async |
| | | protected void addCompanyUser(SysCompany entity) |
| | | protected void addCompanyUser(SysCompany entity, Integer isImport) |
| | | { |
| | | |
| | | SysUser user = new SysUser(); |
| | | if (isImport==1){ |
| | | user.setStatus("0"); |
| | | } else { |
| | | user.setStatus("1"); |
| | | } |
| | | SysCompany one = this.getOne(lq().eq(SysCompany::getCompanyCode, entity.getCompanyCode())); |
| | | String phone = entity.getCompanyPhone(); |
| | | user.setPhonenumber(phone); |
| | |
| | | user.setPassword(phone); |
| | | user.setDeptId(one.getCompanyId()); |
| | | user.setUserType("02"); |
| | | user.setRecommendUser(user.getPassword()); |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) |
| | | { |
| | | return; |
| | |
| | | { |
| | | return; |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setRecommendUser(user.getPassword()); |
| | | userService.insertUser(user); |
| | | } |
| | | |
| | | @Async |
| | | protected void updCompanyUserStatus(String phone, Integer status) |
| | | { |
| | | userService.update(userService.lu().set(SysUser::getStatus,status).eq(SysUser::getPhonenumber, phone)); |
| | | } |
| | | |
| | | /** |
| | | * 删除企业用户 |
| | | * @param companyId 企业id |