|
@@ -2,7 +2,6 @@ package com.gubersail.app.corp.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
@@ -21,7 +20,6 @@ import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -57,11 +55,27 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
|
|
|
if (desc != null) {
|
|
|
BeanUtil.copyProperties(desc, corpsDescVO);
|
|
|
//获取客户联系人
|
|
|
- corpsDescVO.setCorpsAttnList(corpsAttnService.list(new LambdaQueryWrapper<AppPjCorpsAttn>()
|
|
|
- .eq(AppPjCorpsAttn::getPid, corpsDesc.getId()).eq(AppPjCorpsAttn::getIsDeleted, 0)));
|
|
|
+ AppPjCorpsAttn attn = corpsAttnService.getOne(new LambdaQueryWrapper<AppPjCorpsAttn>()
|
|
|
+ .eq(AppPjCorpsAttn::getTel, desc.getTel())
|
|
|
+ .eq(AppPjCorpsAttn::getPid, desc.getId())
|
|
|
+ .eq(AppPjCorpsAttn::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (attn != null) {
|
|
|
+ corpsDescVO.setContacts(attn.getCname());
|
|
|
+ corpsDescVO.setContactsPhone(attn.getTel());
|
|
|
+ }
|
|
|
//获取客户地址
|
|
|
- corpsDescVO.setCorpsAddrList(corpsAddrService.list(new LambdaQueryWrapper<AppPjCorpsAddr>()
|
|
|
- .eq(AppPjCorpsAddr::getPid, corpsDesc.getId()).eq(AppPjCorpsAddr::getIsDeleted, 0)));
|
|
|
+ AppPjCorpsAddr addr = corpsAddrService.getOne(new LambdaQueryWrapper<AppPjCorpsAddr>()
|
|
|
+ .eq(AppPjCorpsAddr::getDefaultAddres, "1")
|
|
|
+ .eq(AppPjCorpsAddr::getPid, desc.getId())
|
|
|
+ .eq(AppPjCorpsAddr::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsAddr::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (addr != null) {
|
|
|
+ corpsDescVO.setDetailedAddress(addr.getDetailedAddress());
|
|
|
+ corpsDescVO.setAddress(addr.getBelongtoarea());
|
|
|
+ }
|
|
|
//获取客户附件
|
|
|
corpsDescVO.setCorpsFilesList(corpsFilesService.list(new LambdaQueryWrapper<AppPjCorpsFiles>()
|
|
|
.eq(AppPjCorpsFiles::getPid, corpsDesc.getId()).eq(AppPjCorpsFiles::getIsDeleted, 0)));
|
|
@@ -89,52 +103,6 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 自定义分页
|
|
|
- *
|
|
|
- * @param page
|
|
|
- * @param corpsDesc
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public IPage<AppCorpsDescVO> selectCorpsDescPage(IPage<AppCorpsDescVO> page, AppCorpsDescVO corpsDesc) {
|
|
|
- //获取客户子类别
|
|
|
- if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeId())) {
|
|
|
- Long corpsTypeId = Long.parseLong(corpsDesc.getCorpsTypeId());
|
|
|
- List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
|
|
|
- corpsTypeIdList.add(corpsTypeId);
|
|
|
- corpsDesc.setTypeList(corpsTypeIdList);
|
|
|
- } else if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())) {
|
|
|
- LambdaQueryWrapper<AppPjCorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(AppPjCorpsType::getCname, corpsDesc.getCorpsTypeName());
|
|
|
- lambdaQueryWrapper.eq(AppPjCorpsType::getIsDeleted, 0);
|
|
|
- lambdaQueryWrapper.eq(AppPjCorpsType::getTenantId, SecureUtil.getTenantId());
|
|
|
- List<AppPjCorpsType> corpsTypeList = corpsTypeService.list(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeList)) {
|
|
|
- List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- corpsTypeList.forEach(item -> {
|
|
|
- corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
|
|
|
- corpsTypeIdList.add(item.getId());
|
|
|
- });
|
|
|
- corpsDesc.setTypeList(corpsTypeIdList);
|
|
|
- }
|
|
|
- }
|
|
|
- corpsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsDesc.setIsDeleted(0);
|
|
|
- corpsDesc.setStrTenantId(Arrays.asList(AuthUtil.getDeptId().split(",")));
|
|
|
- if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("老板")
|
|
|
- && !AuthUtil.getUserRole().contains("销售总览")) {
|
|
|
- if (AuthUtil.getUserRole().contains("业务员")) {
|
|
|
- corpsDesc.setSalesmanId(AuthUtil.getUserId());
|
|
|
- }
|
|
|
- }
|
|
|
- corpsDesc.setSalesCompanyId(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
- IPage<AppCorpsDescVO> page1 = page.setRecords(baseMapper.selectCorpsDescPage(page, corpsDesc));
|
|
|
- return page1;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 新增或修改
|
|
|
*/
|
|
|
@Override
|
|
@@ -161,6 +129,7 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
|
|
|
corpsDesc.setSalesCompanyId(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
corpsDesc.setSalesCompanyName(sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())).getData().getFullName());
|
|
|
corpsDesc.setEnableOrNot(1);
|
|
|
+ corpsDesc.setTel(corpsDescVO.getContactsPhone());
|
|
|
//查询当前登录人信息
|
|
|
R<User> userR = userClient.userInfoById(AuthUtil.getUserId());
|
|
|
if (!userR.isSuccess() || ObjectUtils.isNull(userR.getData())) {
|
|
@@ -176,19 +145,68 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
|
|
|
corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
corpsDesc.setUpdateTime(date);
|
|
|
corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setTel(corpsDescVO.getContactsPhone());
|
|
|
}
|
|
|
this.saveOrUpdate(corpsDesc);
|
|
|
Long pId = corpsDesc.getId();
|
|
|
String tenantId = corpsDesc.getTenantId();
|
|
|
- //保存客户联系人信息
|
|
|
- R saveOrUpdateAttn = this.saveOrUpdateAttn(corpsDescVO, userId, pId, tenantId, date);
|
|
|
- if (saveOrUpdateAttn.getCode() != 200) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return saveOrUpdateAttn;
|
|
|
+ AppPjCorpsAttn corpsAttn = corpsAttnService.getOne(new LambdaQueryWrapper<AppPjCorpsAttn>()
|
|
|
+ .eq(AppPjCorpsAttn::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppPjCorpsAttn::getPid, corpsDesc.getId())
|
|
|
+ .eq(AppPjCorpsAttn::getTel, corpsDescVO.getContactsPhone())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (ObjectUtils.isNotNull(corpsAttn)) {
|
|
|
+ corpsAttn.setCname(corpsDescVO.getContacts());
|
|
|
+ corpsAttn.setUpdateTime(date);
|
|
|
+ corpsAttn.setUpdateUser(userId);
|
|
|
+ corpsAttnService.updateById(corpsAttn);
|
|
|
+ if (ObjectUtils.isNull(corpsAttn.getUserId())) {
|
|
|
+ corpsAttnService.createUser(corpsAttn);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ corpsAttn = new AppPjCorpsAttn();
|
|
|
+ corpsAttn.setTenantId(tenantId);
|
|
|
+ corpsAttn.setCreateTime(date);
|
|
|
+ corpsAttn.setCreateUser(userId);
|
|
|
+ corpsAttn.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ corpsAttn.setSalesCompanyId(corpsDesc.getSalesCompanyId());
|
|
|
+ corpsAttn.setSalesCompanyName(corpsDesc.getSalesCompanyName());
|
|
|
+ corpsAttn.setCname(corpsDescVO.getContacts());
|
|
|
+ corpsAttn.setTel(corpsDescVO.getContactsPhone());
|
|
|
+ corpsAttn.setPid(pId);
|
|
|
+ corpsAttnService.save(corpsAttn);
|
|
|
+ corpsAttnService.createUser(corpsAttn);
|
|
|
}
|
|
|
-
|
|
|
- //保存客户地址信息
|
|
|
- this.saveOrUpdateAddr(corpsDescVO, userId, pId, tenantId, date);
|
|
|
+ AppPjCorpsAddr corpsAddr = corpsAddrService.getOne(new LambdaQueryWrapper<AppPjCorpsAddr>()
|
|
|
+ .eq(AppPjCorpsAddr::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsAddr::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AppPjCorpsAddr::getPid, corpsDesc.getId())
|
|
|
+ .eq(AppPjCorpsAddr::getDefaultAddres, "1")
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (ObjectUtils.isNotNull(corpsAddr)) {
|
|
|
+ corpsAddr.setContacts(corpsDescVO.getContacts());
|
|
|
+ corpsAddr.setTel(corpsDescVO.getContactsPhone());
|
|
|
+ corpsAddr.setBelongtoarea(corpsDescVO.getAddress());
|
|
|
+ corpsAddr.setDetailedAddress(corpsDescVO.getDetailedAddress());
|
|
|
+ corpsAddr.setUpdateTime(date);
|
|
|
+ corpsAddr.setUpdateUser(userId);
|
|
|
+ } else {
|
|
|
+ corpsAddr = new AppPjCorpsAddr();
|
|
|
+ corpsAddr.setTenantId(tenantId);
|
|
|
+ corpsAddr.setCreateTime(date);
|
|
|
+ corpsAddr.setCreateUser(userId);
|
|
|
+ corpsAddr.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ corpsAddr.setSalesCompanyId(corpsDesc.getSalesCompanyId());
|
|
|
+ corpsAddr.setSalesCompanyName(corpsDesc.getSalesCompanyName());
|
|
|
+ corpsAddr.setContacts(corpsDescVO.getContacts());
|
|
|
+ corpsAddr.setTel(corpsDescVO.getContactsPhone());
|
|
|
+ corpsAddr.setBelongtoarea(corpsDescVO.getAddress());
|
|
|
+ corpsAddr.setDetailedAddress(corpsDescVO.getDetailedAddress());
|
|
|
+ corpsAddr.setDefaultAddres("1");
|
|
|
+ corpsAddr.setPid(pId);
|
|
|
+ }
|
|
|
+ corpsAddrService.saveOrUpdate(corpsAddr);
|
|
|
|
|
|
//保存客户文件信息
|
|
|
this.saveOrUpdateFiles(corpsDescVO, userId, pId, tenantId, date);
|
|
@@ -199,6 +217,30 @@ public class AppCorpsDescServiceImpl extends ServiceImpl<AppCorpsDescMapper, App
|
|
|
return R.data(corpsDesc);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R review(Long id, String type) {
|
|
|
+ AppPjCorpsDesc corpsDesc = baseMapper.selectById(id);
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ corpsDesc.setUpdateTime(new Date());
|
|
|
+ corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setCheckStatus("审核通过");
|
|
|
+ List<AppPjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<AppPjCorpsAttn>()
|
|
|
+ .eq(AppPjCorpsAttn::getPid, id)
|
|
|
+ .eq(AppPjCorpsAttn::getIsDeleted, 0)
|
|
|
+ .eq(AppPjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .and(i -> i.isNull(AppPjCorpsAttn::getUserId).or().eq(AppPjCorpsAttn::getUserId, 0)));
|
|
|
+ if (!corpsAttnList.isEmpty()) {
|
|
|
+ corpsAttnService.createUserBatch(corpsAttnList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ corpsDesc.setUpdateTime(new Date());
|
|
|
+ corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setCheckStatus("审核驳回");
|
|
|
+ }
|
|
|
+ baseMapper.updateById(corpsDesc);
|
|
|
+ return R.data(corpsDesc);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存客户联系人信息
|
|
|
*
|