|
@ -152,6 +152,34 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
originalEntity.setCode(formDTO.getCode()); |
|
|
originalEntity.setCode(formDTO.getCode()); |
|
|
originalEntity.setContacts(formDTO.getContacts()); |
|
|
originalEntity.setContacts(formDTO.getContacts()); |
|
|
originalEntity.setMobile(formDTO.getMobile()); |
|
|
originalEntity.setMobile(formDTO.getMobile()); |
|
|
|
|
|
if(StringUtils.isNotBlank(formDTO.getAreaCode())&&formDTO.getAreaCode().equals(originalEntity.getAreaCode())){ |
|
|
|
|
|
//如果修改了areaCode。
|
|
|
|
|
|
customerAgencyDao.updateSubAgencyAreaCode(originalEntity.getCustomerId(),originalEntity.getAreaCode(),formDTO.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
//判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
|
|
|
|
|
|
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) { |
|
|
|
|
|
//校验areaCode是否被使用过
|
|
|
|
|
|
if (!"other".equals(formDTO.getAreaCode())) { |
|
|
|
|
|
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(formDTO.getAreaCode(),formDTO.getAgencyId()); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(agencyIds)) { |
|
|
|
|
|
//已经被占用,提示
|
|
|
|
|
|
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setAreaCode(formDTO.getAreaCode()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//如果选择的是other,需要自定义一个编码
|
|
|
|
|
|
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO(); |
|
|
|
|
|
addAreaCodeFormDTO.setCurrentAreaLevel(formDTO.getLevel()); |
|
|
|
|
|
addAreaCodeFormDTO.setParentAreaCode(formDTO.getAreaCode()); |
|
|
|
|
|
addAreaCodeFormDTO.setName(formDTO.getAgencyName()); |
|
|
|
|
|
Result<String> addAreaCodeResult = epmetCommonServiceOpenFeignClient.addAreaCode(addAreaCodeFormDTO); |
|
|
|
|
|
if (!addAreaCodeResult.success() || StringUtils.isBlank(addAreaCodeResult.getData())) { |
|
|
|
|
|
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
originalEntity.setAreaCode(addAreaCodeResult.getData()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//1:更新当前组织信息
|
|
|
//1:更新当前组织信息
|
|
|
if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) { |
|
|
if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) { |
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|