|
@@ -12,10 +12,13 @@ import com.gubersail.admin.corp.mapper.CorpsTypeDescMapper;
|
|
|
import com.gubersail.admin.corp.service.ICorpsTypeService;
|
|
|
import com.gubersail.admin.fc.customer.mapper.FcCustomerDescMapper;
|
|
|
import com.gubersail.admin.fc.customer.service.FcCustomerDescService;
|
|
|
+import com.gubersail.admin.zcrm.customer.mapper.ViewCustomerSelMapper;
|
|
|
import com.gubersail.dealer.admin.api.corps.entity.*;
|
|
|
import com.gubersail.dealer.admin.api.fc.customer.entity.FcCustomerDesc;
|
|
|
import com.gubersail.dealer.admin.api.fc.customer.vo.FcCustomerDescVo;
|
|
|
+import com.gubersail.dealer.admin.api.zcrm.customer.entity.ViewCustomerSel;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
@@ -27,6 +30,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -50,6 +54,9 @@ public class FcCustomerDescServiceImpl extends ServiceImpl<FcCustomerDescMapper,
|
|
|
private final CorpsTypeDescMapper corpsTypeDescMapper;
|
|
|
|
|
|
|
|
|
+ private final ViewCustomerSelMapper viewCustomerSelMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<FcCustomerDescVo> selectCorpsDescPage(IPage<FcCustomerDescVo> page, FcCustomerDescVo corpsDesc) {
|
|
|
if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeId())) {
|
|
@@ -83,23 +90,23 @@ public class FcCustomerDescServiceImpl extends ServiceImpl<FcCustomerDescMapper,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R submit(FcCustomerDescVo corpsDesc) {
|
|
|
- Long userId = SecureUtil.getUserId();
|
|
|
+ BladeUser bladeUser = AuthUtil.getUser();
|
|
|
Date date = new Date();
|
|
|
List<FcCustomerDesc> pjCorpsDesc = baseMapper.selectList(new LambdaQueryWrapper<FcCustomerDesc>()
|
|
|
- .eq(FcCustomerDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FcCustomerDesc::getTenantId, bladeUser.getTenantId())
|
|
|
.eq(FcCustomerDesc::getIsDeleted, 0)
|
|
|
- .eq(FcCustomerDesc::getSalesCompanyId, AuthUtil.getTenantId())
|
|
|
+ .eq(FcCustomerDesc::getSalesCompanyId, bladeUser.getTenantId())
|
|
|
.eq(FcCustomerDesc::getCname, corpsDesc.getCname()));
|
|
|
if (corpsDesc.getId() == null) {
|
|
|
if (!pjCorpsDesc.isEmpty()) {
|
|
|
throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
|
|
|
}
|
|
|
- corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
- corpsDesc.setCreateDept(Long.valueOf(SecureUtil.getDeptId()));
|
|
|
+ corpsDesc.setTenantId(bladeUser.getTenantId());
|
|
|
+ corpsDesc.setCreateDept(Long.valueOf(bladeUser.getDeptId()));
|
|
|
corpsDesc.setCreateTime(date);
|
|
|
- corpsDesc.setCreateUser(userId);
|
|
|
- corpsDesc.setSalesCompanyId(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- corpsDesc.setSalesCompanyName(sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())).getData().getFullName());
|
|
|
+ corpsDesc.setCreateUser(bladeUser.getUserId());
|
|
|
+ corpsDesc.setSalesCompanyId(Long.valueOf(bladeUser.getDeptId()));
|
|
|
+ corpsDesc.setSalesCompanyName(sysClient.getDept(Long.valueOf(bladeUser.getDeptId())).getData().getFullName());
|
|
|
corpsDesc.setEnableOrNot(1);
|
|
|
baseMapper.insert(corpsDesc);
|
|
|
} else {
|
|
@@ -107,29 +114,47 @@ public class FcCustomerDescServiceImpl extends ServiceImpl<FcCustomerDescMapper,
|
|
|
if (!pjCorpsDesc.isEmpty() && !ids.contains(corpsDesc.getId())) {
|
|
|
throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
|
|
|
}
|
|
|
- corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
+ corpsDesc.setTenantId(bladeUser.getTenantId());
|
|
|
corpsDesc.setUpdateTime(date);
|
|
|
- corpsDesc.setCreateDept(Long.valueOf(SecureUtil.getDeptId()));
|
|
|
- corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setCreateDept(Long.valueOf(bladeUser.getDeptId()));
|
|
|
+ corpsDesc.setUpdateUser(bladeUser.getUserId());
|
|
|
baseMapper.updateById(corpsDesc);
|
|
|
}
|
|
|
Long pId = corpsDesc.getId();
|
|
|
String tenantId = corpsDesc.getTenantId();
|
|
|
//保存客户联系人信息
|
|
|
- R saveOrUpdateAttn = this.saveOrUpdateAttn(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ R saveOrUpdateAttn = this.saveOrUpdateAttn(corpsDesc, bladeUser.getUserId(), pId, tenantId, date);
|
|
|
if (saveOrUpdateAttn.getCode() != 200) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return saveOrUpdateAttn;
|
|
|
}
|
|
|
|
|
|
//保存客户地址信息
|
|
|
- this.saveOrUpdateAddr(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ this.saveOrUpdateAddr(corpsDesc, bladeUser.getUserId(), pId, tenantId, date);
|
|
|
|
|
|
//保存客户文件信息
|
|
|
- this.saveOrUpdateFiles(corpsDesc, userId, pId, tenantId, date);
|
|
|
+ this.saveOrUpdateFiles(corpsDesc, bladeUser.getUserId(), pId, tenantId, date);
|
|
|
|
|
|
//保存客户与类别对应关系
|
|
|
- this.saveOrUpdateTypeDesc(corpsDesc, userId, pId, date, tenantId);
|
|
|
+ this.saveOrUpdateTypeDesc(corpsDesc, bladeUser.getUserId(), pId, date, tenantId);
|
|
|
+ long count = viewCustomerSelMapper.selectCount(new LambdaQueryWrapper<ViewCustomerSel>().eq(ViewCustomerSel::getCustomerId, corpsDesc.getId()));
|
|
|
+ if (count <= 0) {
|
|
|
+ ViewCustomerSel viewCustomerSel = new ViewCustomerSel();
|
|
|
+ viewCustomerSel.setOrgId(1002504294421734L);
|
|
|
+ viewCustomerSel.setOrgCode("001");
|
|
|
+ viewCustomerSel.setOrgName("库比森轮胎(江苏)有限公司");
|
|
|
+ viewCustomerSel.setCustomerId(corpsDesc.getId());
|
|
|
+ viewCustomerSel.setCustomerCode(String.valueOf(corpsDesc.getId()));
|
|
|
+ viewCustomerSel.setCustomerName(corpsDesc.getCname());
|
|
|
+ viewCustomerSel.setCustomercategoryId(Long.valueOf(corpsDesc.getCorpsTypeId()));
|
|
|
+ viewCustomerSel.setCustomercategoryCode(String.valueOf(corpsDesc.getCorpsTypeId()));
|
|
|
+ viewCustomerSel.setCustomercategoryName(corpsDesc.getCorpsTypeName());
|
|
|
+ viewCustomerSel.setRemark(corpsDesc.getRemarks());
|
|
|
+ viewCustomerSel.setCreateDept(Long.valueOf(bladeUser.getDeptId()));
|
|
|
+ viewCustomerSel.setCreateTime(LocalDateTime.now());
|
|
|
+ viewCustomerSel.setCreateUser(bladeUser.getUserId());
|
|
|
+ viewCustomerSelMapper.insert(viewCustomerSel);
|
|
|
+ }
|
|
|
|
|
|
return R.data(corpsDesc);
|
|
|
}
|