|
@@ -46,34 +46,37 @@ public class TmContractorServiceImpl extends ServiceImpl<ITmContractorMapper, Tm
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public void collaborate(SceneParam param, User user) {
|
|
public void collaborate(SceneParam param, User user) {
|
|
- if(StringUtils.isBlank(param.getNum()) || StringUtils.isBlank(param.getUserName())){
|
|
|
|
|
|
+ if(param.getNumList().isEmpty() || StringUtils.isBlank(param.getUserName())){
|
|
throw new BusinessException(ResultCode.PARAM_ERROR);
|
|
throw new BusinessException(ResultCode.PARAM_ERROR);
|
|
}
|
|
}
|
|
- List<TmContractorNum> numList = tmContractorNumService.getByNum(param.getNum());
|
|
|
|
- if(!numList.isEmpty()){
|
|
|
|
- throw new BusinessException(ResultCode.SCENE_CONTRACTOR_ERROR);
|
|
|
|
- }
|
|
|
|
- User contractorUser = userService.getByUserName(param.getUserName());
|
|
|
|
- if(contractorUser == null){
|
|
|
|
- throw new BusinessException(ResultCode.CONTRACTOR_USER_ERROR);
|
|
|
|
- }
|
|
|
|
|
|
+ for (String num : param.getNumList()) {
|
|
|
|
+ List<TmContractorNum> numList = tmContractorNumService.getByNum(num);
|
|
|
|
+ if(!numList.isEmpty()){
|
|
|
|
+ throw new BusinessException(ResultCode.SCENE_CONTRACTOR_ERROR);
|
|
|
|
+ }
|
|
|
|
+ User contractorUser = userService.getByUserName(param.getUserName());
|
|
|
|
+ if(contractorUser == null){
|
|
|
|
+ throw new BusinessException(ResultCode.CONTRACTOR_USER_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TmContractor tmContractor = this.getByMainContractor(user.getId(),contractorUser.getId());
|
|
|
|
+ if(tmContractor == null){
|
|
|
|
+ tmContractor = new TmContractor();
|
|
|
|
+ }
|
|
|
|
+ tmContractor.setMainContractorUserId(user.getId());
|
|
|
|
+ tmContractor.setMainContractorName(user.getNickName());
|
|
|
|
+ tmContractor.setMainContractorAccount(user.getUserName());
|
|
|
|
+ tmContractor.setContractorUserId(contractorUser.getId());
|
|
|
|
+ tmContractor.setContractorName(contractorUser.getNickName());
|
|
|
|
+ tmContractor.setContractorAccount(contractorUser.getUserName());
|
|
|
|
+ this.saveOrUpdate(tmContractor);
|
|
|
|
|
|
- TmContractor tmContractor = this.getByMainContractor(user.getId(),contractorUser.getId());
|
|
|
|
- if(tmContractor == null){
|
|
|
|
- tmContractor = new TmContractor();
|
|
|
|
|
|
+ TmContractorNum tmContractorNum = new TmContractorNum();
|
|
|
|
+ tmContractorNum.setContractorId(tmContractor.getId());
|
|
|
|
+ tmContractorNum.setNum(num);
|
|
|
|
+ tmContractorNumService.save(tmContractorNum);
|
|
}
|
|
}
|
|
- tmContractor.setMainContractorUserId(user.getId());
|
|
|
|
- tmContractor.setMainContractorName(user.getNickName());
|
|
|
|
- tmContractor.setMainContractorAccount(user.getUserName());
|
|
|
|
- tmContractor.setContractorUserId(contractorUser.getId());
|
|
|
|
- tmContractor.setContractorName(contractorUser.getNickName());
|
|
|
|
- tmContractor.setContractorAccount(contractorUser.getUserName());
|
|
|
|
- this.saveOrUpdate(tmContractor);
|
|
|
|
|
|
|
|
- TmContractorNum tmContractorNum = new TmContractorNum();
|
|
|
|
- tmContractorNum.setContractorId(tmContractor.getId());
|
|
|
|
- tmContractorNum.setNum(param.getNum());
|
|
|
|
- tmContractorNumService.save(tmContractorNum);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private TmContractor getByMainContractor(Long userId, Long userId2) {
|
|
private TmContractor getByMainContractor(Long userId, Long userId2) {
|