|  |  |  | 
|---|
|  |  |  | import doumeemes.dao.business.model.Company; | 
|---|
|  |  |  | import doumeemes.dao.business.model.CompanyLog; | 
|---|
|  |  |  | import doumeemes.dao.business.model.CompanyOpen; | 
|---|
|  |  |  | import doumeemes.dao.ext.vo.CompanyExtListVO; | 
|---|
|  |  |  | import doumeemes.service.business.CompanyLogService; | 
|---|
|  |  |  | import doumeemes.service.business.CompanyOpenService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import doumeemes.service.ext.DepartmentExtService; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.context.annotation.Lazy; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | CompanyLogService companyLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Lazy | 
|---|
|  |  |  | private DepartmentExtService departmentExtService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(CompanyOpen companyOpen) { | 
|---|
|  |  |  | 
|---|
|  |  |  | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | UpdateWrapper<CompanyOpen> wrapper = new UpdateWrapper<>(); | 
|---|
|  |  |  | wrapper.lambda().eq(CompanyOpen::getCompanyId,companyOpen.getCompanyId()) | 
|---|
|  |  |  | .set(CompanyOpen::getUserNum,companyOpen.getUserNum()) | 
|---|
|  |  |  | .set(CompanyOpen::getValidDate,companyOpen.getValidDate()) | 
|---|
|  |  |  | .set(CompanyOpen::getOepnType,companyOpen.getOepnType()); | 
|---|
|  |  |  | companyOpenMapper.update(null,wrapper); | 
|---|
|  |  |  | 
|---|
|  |  |  | company.setId(companyOpen.getCompanyId()); | 
|---|
|  |  |  | company.setOepnValidDate(companyOpen.getValidDate()); | 
|---|
|  |  |  | company.setOepnType(companyOpen.getOepnType()); | 
|---|
|  |  |  | company.setOpenUserNum(companyOpen.getUserNum()); | 
|---|
|  |  |  | companyMapper.updateById(company); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Company company1 = companyMapper.selectById(companyOpen.getCompanyId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CompanyLog companyLog = new CompanyLog(); | 
|---|
|  |  |  | companyLog.setDeleted((byte) Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | companyLog.setRemark("有效期从"+format.format(cyResult.getOepnValidDate())+"日调整至"+format.format(companyOpen.getValidDate())); | 
|---|
|  |  |  | companyLog.setCompanyId(company.getId()); | 
|---|
|  |  |  | companyLog.setUpdateType(Constants.CompanyUpdateType.UPDATE_VAIL_DATE.getKey()); | 
|---|
|  |  |  | companyLog.setDetail("有效期从"+format.format(cyResult.getOepnValidDate())+"日调整至"+format.format(companyOpen.getValidDate())); | 
|---|
|  |  |  | companyLog.setDetail("有效期从"+format.format(cyResult.getOepnValidDate())+"日调整至"+format.format(companyOpen.getValidDate())+"\n"+ | 
|---|
|  |  |  | "用户开通人数从"+cyResult.getOpenUserNum()+"调整至"+companyOpen.getUserNum()); | 
|---|
|  |  |  | companyLogService.create(companyLog); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | initRedisCache(company1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void initRedisCache(Company com) { | 
|---|
|  |  |  | CompanyExtListVO c = new CompanyExtListVO(); | 
|---|
|  |  |  | BeanUtils.copyProperties(com,c); | 
|---|
|  |  |  | departmentExtService.loadComDepart(c); | 
|---|
|  |  |  | departmentExtService.initCompnayCodesByCom(com); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<CompanyOpen> wrapper = new QueryWrapper<>(companyOpen); | 
|---|
|  |  |  | return companyOpenMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<CompanyOpen> findPage(PageWrap<CompanyOpen> pageWrap) { | 
|---|
|  |  |  | IPage<CompanyOpen> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|