|
@@ -41,27 +41,37 @@ import java.util.stream.Stream;
|
|
|
*/
|
|
|
@Service
|
|
|
public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements TBCrmService {
|
|
|
+
|
|
|
@Resource
|
|
|
private TBServiceService tbServiceService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TBUserArchivesAllocationService tbUserArchivesAllocationService;
|
|
|
+
|
|
|
@Resource
|
|
|
private SysRoleService sysRoleService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TBUserArchivesService tbUserArchivesService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TBServiceRegionDetailService tbServiceRegionDetailService;
|
|
|
+
|
|
|
@Resource
|
|
|
private SysUserService sysUserService;
|
|
|
+
|
|
|
@Resource
|
|
|
private FxxkApiUtils fxxkApiUtils;
|
|
|
+
|
|
|
@Resource
|
|
|
private SysCustomService sysCustomService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TBProductService tbProductService;
|
|
|
|
|
|
@Override
|
|
|
- public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType, String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
|
|
|
+ public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
|
|
|
+ String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
|
|
|
if (city != null && city.length() > 0) {
|
|
|
city = SystemConstant.translateSpecificSign(city);
|
|
|
}
|
|
@@ -70,18 +80,21 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
}
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
|
|
|
- return this.baseMapper.findServiceScopePage(new Page<>(pageNumber, pageSize), serviceUnitId, city, productType, customName, bindStatus, dpr);
|
|
|
+ return this.baseMapper.findServiceScopePage(new Page<>(pageNumber, pageSize), serviceUnitId, city, productType,
|
|
|
+ customName, bindStatus, dpr);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<CrmServiceResult> findUnbindOrderPage(Long crmUserId, ProductTypeEnum productType, String customName, String crmNo, Long startTime, Long endTime, Integer pageNumber, Integer pageSize) {
|
|
|
+ public IPage<CrmServiceResult> findUnbindOrderPage(Long crmUserId, ProductTypeEnum productType, String customName,
|
|
|
+ String crmNo, Long startTime, Long endTime, Integer pageNumber, Integer pageSize) {
|
|
|
if (customName != null && customName.length() > 0) {
|
|
|
customName = SystemConstant.translateSpecificSign(customName);
|
|
|
}
|
|
|
if (crmNo != null && crmNo.length() > 0) {
|
|
|
crmNo = SystemConstant.translateSpecificSign(crmNo);
|
|
|
}
|
|
|
- return this.baseMapper.findUnbindOrderPage(new Page<>(pageNumber, pageSize), crmUserId, productType, customName, crmNo, startTime, endTime);
|
|
|
+ return this.baseMapper.findUnbindOrderPage(new Page<>(pageNumber, pageSize), crmUserId, productType, customName,
|
|
|
+ crmNo, startTime, endTime);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -136,7 +149,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
public CrmSubTotalResult findCrmSubTotalData(Long serviceUnitId, String city, ProductTypeEnum productType, String customName, Boolean bindStatus) {
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
|
|
|
- List<CrmServiceResult> crmServiceResultList = this.baseMapper.findServiceScopeList(serviceUnitId, city, productType, customName, bindStatus, dpr);
|
|
|
+ List<CrmServiceResult> crmServiceResultList = this.baseMapper.findServiceScopeList(serviceUnitId, city,
|
|
|
+ productType, customName, bindStatus, dpr);
|
|
|
int totalCrmCount = crmServiceResultList.size();
|
|
|
int bindCrmCount = 0;
|
|
|
int unbindCrmCount = 0;
|
|
@@ -153,7 +167,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
|
|
|
@Override
|
|
|
public TBCrm findByCrmNo(String crmNo) {
|
|
|
- List<TBCrm> tbCrmList = this.list(new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getCrmNo, crmNo).eq(TBCrm::getEnable, true));
|
|
|
+ List<TBCrm> tbCrmList = this.list(
|
|
|
+ new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getCrmNo, crmNo).eq(TBCrm::getEnable, true));
|
|
|
if (CollectionUtils.isEmpty(tbCrmList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("派单不存在[" + crmNo + "]");
|
|
|
}
|
|
@@ -164,28 +179,31 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId,Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime) {
|
|
|
- if (custom != null && custom.length() > 0){
|
|
|
+ public IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId, Boolean isBind, Long leadId, Long crmUserId,
|
|
|
+ ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime) {
|
|
|
+ if (custom != null && custom.length() > 0) {
|
|
|
custom = SystemConstant.translateSpecificSign(custom);
|
|
|
}
|
|
|
- if (crmNo != null && crmNo.length() > 0){
|
|
|
+ if (crmNo != null && crmNo.length() > 0) {
|
|
|
crmNo = SystemConstant.translateSpecificSign(crmNo);
|
|
|
}
|
|
|
- return this.baseMapper.query(iPage, serviceId,isBind, leadId, crmUserId, Objects.nonNull(type) ? type.name() : null, custom, crmNo, startTime, endTime);
|
|
|
+ return this.baseMapper.query(iPage, serviceId, isBind, leadId, crmUserId,
|
|
|
+ Objects.nonNull(type) ? type.name() : null, custom, crmNo, startTime, endTime);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int count(Long serviceId, Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime) {
|
|
|
- if (custom != null && custom.length() > 0){
|
|
|
+ public int count(Long serviceId, Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom,
|
|
|
+ String crmNo, Long startTime, Long endTime) {
|
|
|
+ if (custom != null && custom.length() > 0) {
|
|
|
custom = SystemConstant.translateSpecificSign(custom);
|
|
|
}
|
|
|
- if (crmNo != null && crmNo.length() > 0){
|
|
|
+ if (crmNo != null && crmNo.length() > 0) {
|
|
|
crmNo = SystemConstant.translateSpecificSign(crmNo);
|
|
|
}
|
|
|
- return this.baseMapper.count(serviceId,isBind, leadId, crmUserId, Objects.nonNull(type) ? type.name() : null, custom, crmNo, startTime, endTime);
|
|
|
+ return this.baseMapper.count(serviceId, isBind, leadId, crmUserId, Objects.nonNull(type) ? type.name() : null,
|
|
|
+ custom, crmNo, startTime, endTime);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 新增修改派单信息表
|
|
|
*
|
|
@@ -277,15 +295,14 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
CrmProjectResult crmProjectResult = crmProjectResults.get(0);
|
|
|
String tbCrmNo = crmProjectResult.getCrmNo();
|
|
|
|
|
|
- List<TBUserArchivesAllocation> archivesAllocationList = tbUserArchivesAllocationService.list(new QueryWrapper<TBUserArchivesAllocation>()
|
|
|
- .lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrmNo));
|
|
|
+ List<TBUserArchivesAllocation> archivesAllocationList = tbUserArchivesAllocationService.list(
|
|
|
+ new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrmNo));
|
|
|
|
|
|
RoleResult effectRole = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER);
|
|
|
Long effectRoleId = effectRole.getRoleId();
|
|
|
|
|
|
List<UserArchivesDto> effectEngineerList = archivesAllocationList.stream()
|
|
|
- .filter(e -> effectRoleId.equals(e.getRoleId()))
|
|
|
- .flatMap(e -> {
|
|
|
+ .filter(e -> effectRoleId.equals(e.getRoleId())).flatMap(e -> {
|
|
|
UserArchivesDto dto = new UserArchivesDto();
|
|
|
Long userArchivesId = e.getArchivesId();
|
|
|
dto.setUserArchivesId(userArchivesId);
|
|
@@ -297,8 +314,7 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
RoleResult assistant = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.ASSISTANT_ENGINEER);
|
|
|
Long assistantRoleId = assistant.getRoleId();
|
|
|
List<UserArchivesDto> assistantEngineerList = archivesAllocationList.stream()
|
|
|
- .filter(e -> assistantRoleId.equals(e.getRoleId()))
|
|
|
- .flatMap(e -> {
|
|
|
+ .filter(e -> assistantRoleId.equals(e.getRoleId())).flatMap(e -> {
|
|
|
UserArchivesDto dto = new UserArchivesDto();
|
|
|
Long userArchivesId = e.getArchivesId();
|
|
|
dto.setUserArchivesId(userArchivesId);
|
|
@@ -313,12 +329,11 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public SopCrmInfo findSopCrmInfoBySop(String sopNo) {
|
|
|
List<SopCrmInfo> sopCrmInfoList = this.baseMapper.findSopCrmInfoBySopNo(sopNo);
|
|
|
if (CollectionUtils.isEmpty(sopCrmInfoList)) {
|
|
|
-// throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
+ // throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
return null;
|
|
|
} else if (sopCrmInfoList.size() > 1) {
|
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("sop单号为[%s]的派单信息异常", sopNo));
|
|
@@ -337,33 +352,28 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
TBCrm tbCrm = this.findByCrmNo(crmNo);
|
|
|
switch (status) {
|
|
|
- case UN_PUBLISH: // 撤回
|
|
|
- tbCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
|
- break;
|
|
|
- case PUBLISH: // 发布
|
|
|
- tbCrm.setStatus(CrmStatusEnum.PUBLISH);
|
|
|
- tbCrm.setPublishUserId(requestUser.getId());
|
|
|
- tbCrm.setPublishTime(System.currentTimeMillis());
|
|
|
- break;
|
|
|
- case FINISH: // 完结
|
|
|
- tbCrm.setStatus(CrmStatusEnum.FINISH);
|
|
|
- // crm完结 释放工程师资源
|
|
|
- List<CrmArchivesAllocationResult> crmArchivesAllocationResultList = tbUserArchivesAllocationService.findAllocationByCrmNo(crmNo);
|
|
|
- List<Long> engineerArchivesIdList = crmArchivesAllocationResultList
|
|
|
- .stream()
|
|
|
- .filter(e -> !RoleTypeEnum.REGION_COORDINATOR.equals(e.getType()))
|
|
|
- .map(CrmArchivesAllocationResult::getArchivesId)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(engineerArchivesIdList)) {
|
|
|
- UpdateWrapper<TBUserArchives> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda()
|
|
|
- .set(TBUserArchives::getStatus, UserArchivesStatusEnum.FREE)
|
|
|
- .in(TBUserArchives::getId, engineerArchivesIdList);
|
|
|
- tbUserArchivesService.update(updateWrapper);
|
|
|
- }
|
|
|
- break;
|
|
|
+ case UN_PUBLISH: // 撤回
|
|
|
+ tbCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
|
+ break;
|
|
|
+ case PUBLISH: // 发布
|
|
|
+ tbCrm.setStatus(CrmStatusEnum.PUBLISH);
|
|
|
+ tbCrm.setPublishUserId(requestUser.getId());
|
|
|
+ tbCrm.setPublishTime(System.currentTimeMillis());
|
|
|
+ break;
|
|
|
+ case FINISH: // 完结
|
|
|
+ tbCrm.setStatus(CrmStatusEnum.FINISH);
|
|
|
+ // crm完结 释放工程师资源
|
|
|
+ List<CrmArchivesAllocationResult> crmArchivesAllocationResultList = tbUserArchivesAllocationService.findAllocationByCrmNo(
|
|
|
+ crmNo);
|
|
|
+ List<Long> engineerArchivesIdList = crmArchivesAllocationResultList.stream().filter(e -> !RoleTypeEnum.REGION_COORDINATOR.equals(e.getType()))
|
|
|
+ .map(CrmArchivesAllocationResult::getArchivesId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(engineerArchivesIdList)) {
|
|
|
+ UpdateWrapper<TBUserArchives> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(TBUserArchives::getStatus, UserArchivesStatusEnum.FREE).in(TBUserArchives::getId, engineerArchivesIdList);
|
|
|
+ tbUserArchivesService.update(updateWrapper);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
this.updateById(tbCrm);
|
|
|
}
|
|
@@ -383,47 +393,39 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
|
|
|
if (oldServiceUnitId != null && oldServiceUnitId > 0) {
|
|
|
// 之前派单有划定在服务单元 -> 解绑派单所有资源信息
|
|
|
- List<TBUserArchivesAllocation> dbAllocationList = tbUserArchivesAllocationService.list(new QueryWrapper<TBUserArchivesAllocation>().lambda()
|
|
|
- .eq(TBUserArchivesAllocation::getCrmNo, crmNo)
|
|
|
- .eq(TBUserArchivesAllocation::getServiceId, oldServiceUnitId));
|
|
|
+ List<TBUserArchivesAllocation> dbAllocationList = tbUserArchivesAllocationService.list(
|
|
|
+ new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, crmNo).eq(TBUserArchivesAllocation::getServiceId, oldServiceUnitId));
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(dbAllocationList)) {
|
|
|
// 释放工程师资源
|
|
|
List<Long> archivesIdList = dbAllocationList.stream().map(TBUserArchivesAllocation::getArchivesId).distinct().collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(archivesIdList)) {
|
|
|
UpdateWrapper<TBUserArchives> archivesUpdateWrapper = new UpdateWrapper<>();
|
|
|
- archivesUpdateWrapper.lambda()
|
|
|
- .in(TBUserArchives::getId, archivesIdList)
|
|
|
+ archivesUpdateWrapper.lambda().in(TBUserArchives::getId, archivesIdList)
|
|
|
.set(TBUserArchives::getStatus, UserArchivesStatusEnum.FREE);
|
|
|
tbUserArchivesService.update(archivesUpdateWrapper);
|
|
|
}
|
|
|
// 删除之前的派单分配详情
|
|
|
- tbUserArchivesAllocationService.removeByIds(dbAllocationList.stream().map(TBUserArchivesAllocation::getId).distinct().collect(Collectors.toList()));
|
|
|
+ tbUserArchivesAllocationService.removeByIds(
|
|
|
+ dbAllocationList.stream().map(TBUserArchivesAllocation::getId).distinct().collect(Collectors.toList()));
|
|
|
}
|
|
|
UpdateWrapper<TBCrm> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda()
|
|
|
- .eq(TBCrm::getId, tbCrm.getId())
|
|
|
- .set(TBCrm::getServiceId, null)
|
|
|
- .set(TBCrm::getLeadId, null)
|
|
|
- .set(TBCrm::getRegionId, null)
|
|
|
- .set(TBCrm::getRegionDetailId, null)
|
|
|
+ updateWrapper.lambda().eq(TBCrm::getId, tbCrm.getId()).set(TBCrm::getServiceId, null)
|
|
|
+ .set(TBCrm::getLeadId, null).set(TBCrm::getRegionId, null).set(TBCrm::getRegionDetailId, null)
|
|
|
.set(TBCrm::getRegionCoordinatorId, null);
|
|
|
this.update(updateWrapper);
|
|
|
}
|
|
|
if (newServiceUnitId != null && newServiceUnitId > 0) {
|
|
|
// 为派单划定的新服务单元绑定大区信息
|
|
|
UpdateWrapper<TBCrm> bindServiceWrapper = new UpdateWrapper<>();
|
|
|
- bindServiceWrapper.lambda()
|
|
|
- .eq(TBCrm::getId, tbCrm.getId())
|
|
|
- .set(TBCrm::getServiceId, newServiceUnitId);
|
|
|
+ bindServiceWrapper.lambda().eq(TBCrm::getId, tbCrm.getId()).set(TBCrm::getServiceId, newServiceUnitId);
|
|
|
this.update(bindServiceWrapper);
|
|
|
|
|
|
- ServiceRegionDetailResult regionDetail = tbServiceRegionDetailService.findRegionDetail(newServiceUnitId, crmNo);
|
|
|
+ ServiceRegionDetailResult regionDetail = tbServiceRegionDetailService.findRegionDetail(newServiceUnitId,
|
|
|
+ crmNo);
|
|
|
if (Objects.nonNull(regionDetail)) {
|
|
|
UpdateWrapper<TBCrm> matchWrapper = new UpdateWrapper<>();
|
|
|
- matchWrapper.lambda()
|
|
|
- .eq(TBCrm::getId, tbCrm.getId())
|
|
|
- .set(TBCrm::getLeadId, regionDetail.getLeadId())
|
|
|
+ matchWrapper.lambda().eq(TBCrm::getId, tbCrm.getId()).set(TBCrm::getLeadId, regionDetail.getLeadId())
|
|
|
.set(TBCrm::getRegionId, regionDetail.getServiceRegionId())
|
|
|
.set(TBCrm::getRegionDetailId, regionDetail.getServiceRegionDetailId());
|
|
|
this.update(matchWrapper);
|
|
@@ -434,19 +436,30 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Map<String, Object> syncCrmFromFxxk(Map<String, Object> map) {
|
|
|
+ SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
+ // 已有派单信息
|
|
|
+ List<TBCrm> tbCrmList = this.list();
|
|
|
+ List<String> crmNoList = tbCrmList.stream().map(TBCrm::getCrmNo).collect(Collectors.toList());
|
|
|
+
|
|
|
List<String> errorMsgList = new ArrayList<>();
|
|
|
List<FxxkCrm> fxxkCrmList = fxxkApiUtils.findCustomList();
|
|
|
int totalCount = fxxkCrmList.size();
|
|
|
+ // 成功同步的派单数
|
|
|
int successCount = 0;
|
|
|
+ // 已有的派单数(派单号相同不重新同步)
|
|
|
+ int alreadyCount = 0;
|
|
|
try {
|
|
|
for (FxxkCrm fxxkCrm : fxxkCrmList) {
|
|
|
String basicInfoMissingError = "";
|
|
|
-
|
|
|
String crmNo = fxxkCrm.getCrmNo();
|
|
|
+ if (crmNoList.contains(crmNo)) {
|
|
|
+ alreadyCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String crmName = fxxkCrm.getCrmName();
|
|
|
Long beginTime = fxxkCrm.getBeginTime();
|
|
|
String managerName = fxxkCrm.getManagerName();
|
|
|
-// String managerMobileNumber = fxxkCrm.getManagerMobileNumber();
|
|
|
+ String managerMobileNumber = fxxkCrm.getManagerMobileNumber();
|
|
|
ProductTypeEnum customType = fxxkCrm.getCustomType();
|
|
|
String customName = fxxkCrm.getCustomName();
|
|
|
Long examStartTime = fxxkCrm.getExamStartTime();
|
|
@@ -461,9 +474,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
if (managerName == null || managerName.length() == 0) {
|
|
|
basicInfoMissingError = basicInfoMissingError + "缺少客户经理";
|
|
|
}
|
|
|
-// if (managerMobileNumber == null || managerMobileNumber.length() == 0) {
|
|
|
-// basicInfoMissingError = basicInfoMissingError + "缺少客户经理电话";
|
|
|
-// }
|
|
|
+ if (managerMobileNumber == null || managerMobileNumber.length() == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少客户经理电话";
|
|
|
+ }
|
|
|
if (customType == null) {
|
|
|
basicInfoMissingError = basicInfoMissingError + "缺少客户类型或客户类型不为['高校教务处'或'研究生招办']";
|
|
|
}
|
|
@@ -486,48 +499,30 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
|
|
|
// 客户经理校验
|
|
|
Long crmUserId = null;
|
|
|
-// SysUser sysUser = sysUserService.getOne(new QueryWrapper<SysUser>().lambda()
|
|
|
-// .eq(SysUser::getMobileNumber, managerMobileNumber)
|
|
|
-// .eq(SysUser::getRealName, managerName));
|
|
|
-// if (Objects.isNull(sysUser) || !sysUser.getEnable()) {
|
|
|
-// matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s(%s)]在质控平台不存在或已禁用(姓名 + 手机号)\n", managerName, managerMobileNumber);
|
|
|
-// } else {
|
|
|
-// List<RoleDto> roleDtoList = sysRoleService.listRolesByUserId(sysUser.getId());
|
|
|
-// if (roleDtoList.stream().noneMatch(e -> RoleTypeEnum.ACCOUNT_MANAGER.equals(e.getType()))) {
|
|
|
-// matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s(%s)]在质控平台缺少[%s]角色)\n", managerName, managerMobileNumber, RoleTypeEnum.ACCOUNT_MANAGER);
|
|
|
-// } else {
|
|
|
-// crmUserId = sysUser.getId();
|
|
|
-// }
|
|
|
-// }
|
|
|
- List<SysUser> sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getRealName,managerName));
|
|
|
- if (CollectionUtils.isEmpty(sysUserList)){
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s]在质控平台不存在或已禁用(姓名)\n", managerName);
|
|
|
- } else if (sysUserList.size() > 1){
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s]在质控平台对应多个(可能是重名)\n", managerName);
|
|
|
+ SysUser sysUser = sysUserService.getOne(
|
|
|
+ new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, managerMobileNumber).eq(SysUser::getRealName, managerName));
|
|
|
+ if (Objects.isNull(sysUser) || !sysUser.getEnable()) {
|
|
|
+ matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s(%s)]在质控平台不存在或已禁用(姓名 + 手机号)\n",
|
|
|
+ managerName, managerMobileNumber);
|
|
|
} else {
|
|
|
- SysUser sysUser = sysUserList.get(0);
|
|
|
- if (Objects.isNull(sysUser) || !sysUser.getEnable()) {
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s]在质控平台不存在或已禁用(姓名)\n", managerName);
|
|
|
+ List<RoleDto> roleDtoList = sysRoleService.listRolesByUserId(sysUser.getId());
|
|
|
+ if (roleDtoList.stream().noneMatch(e -> RoleTypeEnum.ACCOUNT_MANAGER.equals(e.getType()))) {
|
|
|
+ matchInfoError =
|
|
|
+ matchInfoError + String.format("纷享销客中的客户经理[%s(%s)]在质控平台缺少[%s]角色)\n", managerName,
|
|
|
+ managerMobileNumber, RoleTypeEnum.ACCOUNT_MANAGER);
|
|
|
} else {
|
|
|
- List<RoleDto> roleDtoList = sysRoleService.listRolesByUserId(sysUser.getId());
|
|
|
- if (roleDtoList.stream().noneMatch(e -> RoleTypeEnum.ACCOUNT_MANAGER.equals(e.getType()))) {
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s]在质控平台缺少[%s]角色)\n", managerName, RoleTypeEnum.ACCOUNT_MANAGER);
|
|
|
- } else {
|
|
|
- crmUserId = sysUser.getId();
|
|
|
- }
|
|
|
+ crmUserId = sysUser.getId();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 客户名称校验
|
|
|
Long customId = null;
|
|
|
- List<SysCustom> sysCustomList = sysCustomService.list(new QueryWrapper<SysCustom>()
|
|
|
- .lambda()
|
|
|
- .eq(SysCustom::getName, customName)
|
|
|
- .eq(SysCustom::getType, customType)
|
|
|
- .eq(SysCustom::getEnable, true));
|
|
|
+ List<SysCustom> sysCustomList = sysCustomService.list(
|
|
|
+ new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType).eq(SysCustom::getEnable, true));
|
|
|
|
|
|
if (CollectionUtils.isEmpty(sysCustomList)) {
|
|
|
- matchInfoError = matchInfoError + String.format("纷享销客中的客户[%s(%s)]在质控平台不存在或已禁用(客户名称 + 客户类型)\n", customName, customType.getTitle());
|
|
|
+ matchInfoError = matchInfoError + String.format("纷享销客中的客户[%s(%s)]在质控平台不存在或已禁用(客户名称 + 客户类型)\n",
|
|
|
+ customName, customType.getTitle());
|
|
|
} else if (sysCustomList.size() > 1) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
|
|
|
} else {
|
|
@@ -537,53 +532,47 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
|
|
|
// 实施产品校验
|
|
|
Long productId = null;
|
|
|
- List<TBProduct> tbProductList = tbProductService.list(new QueryWrapper<TBProduct>()
|
|
|
- .lambda()
|
|
|
- .eq(TBProduct::getCode, customType)
|
|
|
- .eq(TBProduct::getEnable, true));
|
|
|
+ List<TBProduct> tbProductList = tbProductService.list(
|
|
|
+ new QueryWrapper<TBProduct>().lambda().eq(TBProduct::getEnable, true));
|
|
|
if (CollectionUtils.isEmpty(tbProductList)) {
|
|
|
- matchInfoError = matchInfoError + String.format("质控平台客户类型为[%s]的产品不存在\n", customType);
|
|
|
+ matchInfoError = matchInfoError + "质控平台缺少可用产品\n";
|
|
|
} else {
|
|
|
productId = tbProductList.get(0).getId();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if (matchInfoError.length() > 0) {
|
|
|
// 质控平台基础信息缺失异常 -> 补充质控平台系统的派单相关信息
|
|
|
- matchInfoError = String.format("纷享销客派单[%s]中的相关信息在质控平台中缺失,请先补充质控平台系统的派单相关信息: %s \n", crmNo, matchInfoError);
|
|
|
+ matchInfoError = String.format("纷享销客派单[%s]中的相关信息在质控平台中缺失,请先补充质控平台系统的派单相关信息: %s \n", crmNo,
|
|
|
+ matchInfoError);
|
|
|
errorMsgList.add(matchInfoError);
|
|
|
} else {
|
|
|
- // 没有任何异常 -> 组装信息(派单号重复的不同步)
|
|
|
- List<TBCrm> tbCrmList = this.list(new QueryWrapper<TBCrm>()
|
|
|
- .lambda()
|
|
|
- .eq(TBCrm::getCrmNo, crmNo)
|
|
|
- .eq(TBCrm::getSync, true));
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(tbCrmList)) {
|
|
|
- // 新增
|
|
|
- TBCrm tbCrm = new TBCrm();
|
|
|
- tbCrm.setCrmNo(crmNo);
|
|
|
- tbCrm.setName(crmName);
|
|
|
- tbCrm.setBeginTime(beginTime);
|
|
|
- tbCrm.setCrmUserId(crmUserId);
|
|
|
- tbCrm.setCustomId(customId);
|
|
|
- tbCrm.setExamStartTime(examStartTime);
|
|
|
- tbCrm.setExamEndTime(examEndTime);
|
|
|
- tbCrm.setProductId(productId);
|
|
|
- tbCrm.setSync(true);
|
|
|
- tbCrm.setEnable(true);
|
|
|
- tbCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
|
- this.save(tbCrm);
|
|
|
- }
|
|
|
+ // 新增
|
|
|
+ TBCrm tbCrm = new TBCrm();
|
|
|
+ tbCrm.setCrmNo(crmNo);
|
|
|
+ tbCrm.setName(crmName);
|
|
|
+ tbCrm.setBeginTime(beginTime);
|
|
|
+ tbCrm.setCrmUserId(crmUserId);
|
|
|
+ tbCrm.setCustomId(customId);
|
|
|
+ tbCrm.setExamStartTime(examStartTime);
|
|
|
+ tbCrm.setExamEndTime(examEndTime);
|
|
|
+ tbCrm.setProductId(productId);
|
|
|
+ tbCrm.setSync(true);
|
|
|
+ tbCrm.setEnable(true);
|
|
|
+ tbCrm.setStatus(CrmStatusEnum.UN_PUBLISH);
|
|
|
+ tbCrm.insertInfo(requestUser.getId());
|
|
|
+ tbCrm.updateInfo(requestUser.getId());
|
|
|
+ this.save(tbCrm);
|
|
|
successCount++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ String errorMsg = "";
|
|
|
if (errorMsgList.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.join(";\n", errorMsgList));
|
|
|
+ errorMsg = String.join(";\n", errorMsgList);
|
|
|
}
|
|
|
map.put(SystemConstant.SUCCESS, successCount);
|
|
|
- map.put(SystemConstant.RESULT_ERROR, totalCount - successCount);
|
|
|
+ map.put(SystemConstant.RESULT_ERROR, totalCount - successCount - alreadyCount);
|
|
|
+ map.put(SystemConstant.ALREADY_COUNT, alreadyCount);
|
|
|
+ map.put(SystemConstant.ERROR_MSG, errorMsg);
|
|
|
return map;
|
|
|
} catch (Exception e) {
|
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|