|
@@ -3,15 +3,11 @@ package com.fdkankan.manage_jp.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fdkankan.manage_jp.common.ResultCode;
|
|
import com.fdkankan.manage_jp.common.ResultCode;
|
|
-import com.fdkankan.manage_jp.entity.TmContractor;
|
|
|
|
-import com.fdkankan.manage_jp.entity.TmContractorNum;
|
|
|
|
-import com.fdkankan.manage_jp.entity.User;
|
|
|
|
|
|
+import com.fdkankan.manage_jp.entity.*;
|
|
import com.fdkankan.manage_jp.exception.BusinessException;
|
|
import com.fdkankan.manage_jp.exception.BusinessException;
|
|
import com.fdkankan.manage_jp.mapper.ITmContractorMapper;
|
|
import com.fdkankan.manage_jp.mapper.ITmContractorMapper;
|
|
-import com.fdkankan.manage_jp.service.ITmContractorNumService;
|
|
|
|
-import com.fdkankan.manage_jp.service.ITmContractorService;
|
|
|
|
|
|
+import com.fdkankan.manage_jp.service.*;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.fdkankan.manage_jp.service.IUserService;
|
|
|
|
import com.fdkankan.manage_jp.vo.request.ContractorParam;
|
|
import com.fdkankan.manage_jp.vo.request.ContractorParam;
|
|
import com.fdkankan.manage_jp.vo.request.SceneParam;
|
|
import com.fdkankan.manage_jp.vo.request.SceneParam;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -39,6 +35,8 @@ public class TmContractorServiceImpl extends ServiceImpl<ITmContractorMapper, Tm
|
|
ITmContractorNumService tmContractorNumService;
|
|
ITmContractorNumService tmContractorNumService;
|
|
@Autowired
|
|
@Autowired
|
|
IUserService userService;
|
|
IUserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICompanyService companyService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<TmContractor> pageList(ContractorParam param) {
|
|
public Page<TmContractor> pageList(ContractorParam param) {
|
|
@@ -56,21 +54,33 @@ public class TmContractorServiceImpl extends ServiceImpl<ITmContractorMapper, Tm
|
|
if(!numList.isEmpty()){
|
|
if(!numList.isEmpty()){
|
|
throw new BusinessException(ResultCode.SCENE_CONTRACTOR_ERROR);
|
|
throw new BusinessException(ResultCode.SCENE_CONTRACTOR_ERROR);
|
|
}
|
|
}
|
|
|
|
+ Company company = companyService.getBySceneNum(param.getNum());
|
|
|
|
+ if(company == null || company.getManagerId() == null){
|
|
|
|
+ throw new BusinessException(ResultCode.SCENE_COMPANY_ERROR);
|
|
|
|
+ }
|
|
|
|
+ User mainContractorUser = userService.getById(company.getManagerId());
|
|
|
|
+ if(mainContractorUser == null){
|
|
|
|
+ throw new BusinessException(ResultCode.MAIN_CONTRACTOR_USER_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
User contractorUser = userService.getByUserName(param.getUserName());
|
|
User contractorUser = userService.getByUserName(param.getUserName());
|
|
if(contractorUser == null){
|
|
if(contractorUser == null){
|
|
throw new BusinessException(ResultCode.CONTRACTOR_USER_ERROR);
|
|
throw new BusinessException(ResultCode.CONTRACTOR_USER_ERROR);
|
|
}
|
|
}
|
|
|
|
|
|
- TmContractor tmContractor = this.getByMainContractor(user.getId(),contractorUser.getId());
|
|
|
|
|
|
+ TmContractor tmContractor = this.getByMainContractor(mainContractorUser.getId(),contractorUser.getId());
|
|
if(tmContractor == null){
|
|
if(tmContractor == null){
|
|
tmContractor = new TmContractor();
|
|
tmContractor = new TmContractor();
|
|
}
|
|
}
|
|
- tmContractor.setMainContractorUserId(user.getId());
|
|
|
|
- tmContractor.setMainContractorName(user.getNickName());
|
|
|
|
- tmContractor.setMainContractorAccount(user.getUserName());
|
|
|
|
|
|
+ tmContractor.setMainContractorUserId(mainContractorUser.getId());
|
|
|
|
+ tmContractor.setMainContractorName(mainContractorUser.getNickName());
|
|
|
|
+ tmContractor.setMainContractorAccount(mainContractorUser.getUserName());
|
|
|
|
+ tmContractor.setMainContractorCompanyId(mainContractorUser.getCompanyId());
|
|
tmContractor.setContractorUserId(contractorUser.getId());
|
|
tmContractor.setContractorUserId(contractorUser.getId());
|
|
tmContractor.setContractorName(contractorUser.getNickName());
|
|
tmContractor.setContractorName(contractorUser.getNickName());
|
|
tmContractor.setContractorAccount(contractorUser.getUserName());
|
|
tmContractor.setContractorAccount(contractorUser.getUserName());
|
|
|
|
+ tmContractor.setContractorCompanyId(contractorUser.getCompanyId());
|
|
|
|
+ tmContractor.setSysUserId(user.getId());
|
|
this.saveOrUpdate(tmContractor);
|
|
this.saveOrUpdate(tmContractor);
|
|
|
|
|
|
TmContractorNum tmContractorNum = new TmContractorNum();
|
|
TmContractorNum tmContractorNum = new TmContractorNum();
|
|
@@ -94,4 +104,11 @@ public class TmContractorServiceImpl extends ServiceImpl<ITmContractorMapper, Tm
|
|
wrapper.eq(TmContractor::getContractorUserId,userId);
|
|
wrapper.eq(TmContractor::getContractorUserId,userId);
|
|
return this.list(wrapper);
|
|
return this.list(wrapper);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<TmContractor> getByCompanyId(Long companyId) {
|
|
|
|
+ LambdaQueryWrapper<TmContractor> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(TmContractor::getContractorCompanyId,companyId);
|
|
|
|
+ return this.list(wrapper);
|
|
|
|
+ }
|
|
}
|
|
}
|