|
|
@@ -155,8 +155,97 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
}
|
|
|
Long pId = corpsDesc.getId();
|
|
|
String tenantId = corpsDesc.getTenantId();
|
|
|
+
|
|
|
+ //保护客户联系人信息
|
|
|
+ R saveOrUpdateAttn = this.saveOrUpdateAttn(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ if (saveOrUpdateAttn.getCode() != 200) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return saveOrUpdateAttn;
|
|
|
+ }
|
|
|
+ if ("1".equals(corpsDesc.getBillType())) {
|
|
|
+ User user = new User();
|
|
|
+ user.setTenantId(AuthUtil.getTenantId());
|
|
|
+ user.setUserType(1);
|
|
|
+ user.setAccount(corpsDesc.getTel());
|
|
|
+ user.setName(corpsDesc.getCname());
|
|
|
+ user.setRealName(corpsDesc.getCname());
|
|
|
+ user.setUserType(4);
|
|
|
+ user.setPhone(corpsDesc.getTel());
|
|
|
+ R<String> r = sysClient.getRoleIds(AuthUtil.getTenantId(), "客户");
|
|
|
+ if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
+ user.setRoleId(r.getData());
|
|
|
+ }
|
|
|
+ user.setDeptId(AuthUtil.getDeptId());
|
|
|
+ user.setPostId(AuthUtil.getPostId());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<CorpsAttn> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(CorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsAttn::getIsDeleted, 0)
|
|
|
+ .eq(CorpsAttn::getTel, corpsDesc.getTel())
|
|
|
+ .eq(CorpsAttn::getPid, corpsDesc.getId());
|
|
|
+ CorpsAttn attn = corpsAttnService.getOne(lambdaQueryWrapper);
|
|
|
+ if (ObjectUtils.isNotNull(attn)) {
|
|
|
+ R<User> userR = userClient.userInfoById(attn.getUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(userR.getData())) {
|
|
|
+ user.setId(attn.getUserId());
|
|
|
+ R<Boolean> result = userClient.updateUser(user);
|
|
|
+
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new ServiceException(result.getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ user.setPassword(LandConstant.USER_PASSWORD);
|
|
|
+ R<Boolean> result = userClient.saveUser(user);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new ServiceException(result.getMsg());
|
|
|
+ }
|
|
|
+ R<User> userTemp = userClient.userByAccount(AuthUtil.getTenantId(), corpsDesc.getTel());
|
|
|
+ if (!userTemp.isSuccess()) {
|
|
|
+ throw new ServiceException(userTemp.getMsg());
|
|
|
+ }
|
|
|
+ attn.setUserId(userTemp.getData().getId());
|
|
|
+ corpsAttnService.updateById(attn);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ user.setPassword(LandConstant.USER_PASSWORD);
|
|
|
+ R<Boolean> result = userClient.saveUser(user);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new ServiceException(result.getMsg());
|
|
|
+ }
|
|
|
+ R<User> userTemp = userClient.userByAccount(AuthUtil.getTenantId(), corpsDesc.getTel());
|
|
|
+ if (!userTemp.isSuccess()) {
|
|
|
+ throw new ServiceException(userTemp.getMsg());
|
|
|
+ }
|
|
|
+ CorpsAttn corpsAttn = new CorpsAttn();
|
|
|
+ corpsAttn.setCode(corpsDesc.getCname());
|
|
|
+ corpsAttn.setCname(corpsDesc.getCname());
|
|
|
+ corpsAttn.setAttn(corpsDesc.getAttn());
|
|
|
+ corpsAttn.setTel(corpsDesc.getTel());
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setPid(corpsDesc.getId());
|
|
|
+ corpsAttn.setUserId(userTemp.getData().getId());
|
|
|
+ corpsAttn.setCreateTime(new Date());
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAttnService.save(corpsAttn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存客户银行信息
|
|
|
+ this.saveOrUpdateBank(corpsDesc, userId, pId, tenantId, date);
|
|
|
//保存客户文件信息
|
|
|
this.saveOrUpdateFiles(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ //保存客户优势项目信息
|
|
|
+ R saveOrUpdateItems = this.saveOrUpdateItems(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ if (saveOrUpdateItems.getCode() != 200) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return saveOrUpdateItems;
|
|
|
+ }
|
|
|
+ //保存客户地址信息
|
|
|
+ R addr = corpsAddrService.saveOrUpdateAddr(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ if (!addr.isSuccess()) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return addr;
|
|
|
+ }
|
|
|
//保存客户与类别对应关系
|
|
|
this.saveOrUpdateTypeDesc(corpsDesc, userId, pId, date, tenantId);
|
|
|
return R.data(corpsDesc);
|
|
|
@@ -1009,6 +1098,43 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public R submitWeb(CorpsDesc corpsDesc) {
|
|
|
+ Long userId = SecureUtil.getUserId();
|
|
|
+ Date date = new Date();
|
|
|
+ if (null == corpsDesc.getInitials() || "" == corpsDesc.getInitials()) {//首字母为空
|
|
|
+ //获得名称首字母
|
|
|
+ String initials = getSpells(corpsDesc.getCname());
|
|
|
+ corpsDesc.setInitials(initials.substring(0, 1));
|
|
|
+ }
|
|
|
+ //保存客户信息
|
|
|
+ String[] deptIds = SecureUtil.getDeptId().split(",");
|
|
|
+ if (corpsDesc.getId() == null) {
|
|
|
+ corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
+ if (deptIds.length > 0) {
|
|
|
+ corpsDesc.setCreateDept(Long.valueOf(deptIds[0]));
|
|
|
+ }
|
|
|
+ corpsDesc.setCreateTime(date);
|
|
|
+ corpsDesc.setCreateUser(userId);
|
|
|
+ baseMapper.insert(corpsDesc);
|
|
|
+ } else {
|
|
|
+ corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
+ corpsDesc.setUpdateTime(date);
|
|
|
+ if (deptIds.length > 0) {
|
|
|
+ corpsDesc.setCreateDept(Long.valueOf(deptIds[0]));
|
|
|
+ }
|
|
|
+ corpsDesc.setUpdateUser(userId);
|
|
|
+ baseMapper.updateById(corpsDesc);
|
|
|
+ }
|
|
|
+ Long pId = corpsDesc.getId();
|
|
|
+ String tenantId = corpsDesc.getTenantId();
|
|
|
+ //保存客户文件信息
|
|
|
+ this.saveOrUpdateFiles(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ //保存客户与类别对应关系
|
|
|
+ this.saveOrUpdateTypeDesc(corpsDesc, userId, pId, date, tenantId);
|
|
|
+ return R.data(corpsDesc);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<CorpsDescDto> selectPartsCorpsDescPage(IPage<CorpsDescDto> page, CorpsDescDto corpsDescDto) {
|
|
|
//获取客户子类别
|
|
|
if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeId())) {
|