|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
|
+import com.qmth.sop.business.bean.dto.RoleDto;
|
|
|
import com.qmth.sop.business.bean.dto.SopCrmInfo;
|
|
|
import com.qmth.sop.business.bean.dto.UserArchivesDto;
|
|
|
import com.qmth.sop.business.bean.params.ServiceScopeParam;
|
|
@@ -14,6 +15,8 @@ import com.qmth.sop.business.bean.result.*;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
|
import com.qmth.sop.business.mapper.TBCrmMapper;
|
|
|
import com.qmth.sop.business.service.*;
|
|
|
+import com.qmth.sop.business.sync.FxxkApiUtils;
|
|
|
+import com.qmth.sop.business.sync.been.FxxkCrm;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.*;
|
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
@@ -50,6 +53,12 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
private TBServiceRegionService tbServiceRegionService;
|
|
|
@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) {
|
|
@@ -396,4 +405,135 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
|
|
|
public List<TBCrm> findByTBCrmListByServiceUnitIdAndAddress(Long serviceUnitId, String province, String city) {
|
|
|
return this.baseMapper.findByTBCrmListByServiceUnitIdAndAddress(serviceUnitId, province, city);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void syncCrmFromFxxk() {
|
|
|
+ List<String> errorMsgList = new ArrayList<>();
|
|
|
+ List<FxxkCrm> fxxkCrmList = fxxkApiUtils.findCustomList();
|
|
|
+ for (FxxkCrm fxxkCrm : fxxkCrmList) {
|
|
|
+ String basicInfoMissingError = "";
|
|
|
+
|
|
|
+ String crmNo = fxxkCrm.getCrmNo();
|
|
|
+ String crmName = fxxkCrm.getCrmName();
|
|
|
+ Long beginTime = fxxkCrm.getBeginTime();
|
|
|
+ String managerName = fxxkCrm.getManagerName();
|
|
|
+ String managerMobileNumber = fxxkCrm.getManagerMobileNumber();
|
|
|
+ ProductTypeEnum customType = fxxkCrm.getCustomType();
|
|
|
+ String customName = fxxkCrm.getCustomName();
|
|
|
+ Long examStartTime = fxxkCrm.getExamStartTime();
|
|
|
+ Long examEndTime = fxxkCrm.getExamEndTime();
|
|
|
+
|
|
|
+ if (crmName == null || crmName.length() == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少派单名称";
|
|
|
+ }
|
|
|
+ if (beginTime == null || beginTime == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少派单开始时间";
|
|
|
+ }
|
|
|
+ if (managerName == null || managerName.length() == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少客户经理";
|
|
|
+ }
|
|
|
+ if (managerMobileNumber == null || managerMobileNumber.length() == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少客户经理电话";
|
|
|
+ }
|
|
|
+ if (customType == null) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少客户类型或客户类型不为['高校教务处'或'研究生招办']";
|
|
|
+ }
|
|
|
+ if (customName == null || customName.length() == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少客户名称";
|
|
|
+ }
|
|
|
+ if (examStartTime == null || examStartTime == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少考试开始时间";
|
|
|
+ }
|
|
|
+ if (examEndTime == null || examEndTime == 0) {
|
|
|
+ basicInfoMissingError = basicInfoMissingError + "缺少考试结束时间";
|
|
|
+ }
|
|
|
+ if (basicInfoMissingError.length() > 0) {
|
|
|
+ // fxxk 项目派单基础信息缺失异常 -> 补充fxxk系统的派单基础信息
|
|
|
+ basicInfoMissingError = "纷享销客派单基础信息异常请补充: " + basicInfoMissingError + "\n";
|
|
|
+ errorMsgList.add(basicInfoMissingError);
|
|
|
+ } else {
|
|
|
+ // 基础信息正常再继续解析需要和质控平台对接的信息
|
|
|
+ String matchInfoError = "";
|
|
|
+
|
|
|
+ // 客户经理校验
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 客户名称校验
|
|
|
+ Long customId = null;
|
|
|
+ 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());
|
|
|
+ } else if (sysCustomList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
|
|
|
+ } else {
|
|
|
+ SysCustom sysCustom = sysCustomList.get(0);
|
|
|
+ customId = sysCustom.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 实施产品校验
|
|
|
+ Long productId = null;
|
|
|
+ List<TBProduct> tbProductList = tbProductService.list(new QueryWrapper<TBProduct>()
|
|
|
+ .lambda()
|
|
|
+ .eq(TBProduct::getCode, customType)
|
|
|
+ .eq(TBProduct::getEnable, true));
|
|
|
+ if (CollectionUtils.isEmpty(tbProductList)) {
|
|
|
+ matchInfoError = matchInfoError + String.format("质控平台客户类型为[%s]的产品不存在\n", customType);
|
|
|
+ } else {
|
|
|
+ productId = tbProductList.get(0).getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (matchInfoError.length() > 0) {
|
|
|
+ // 质控平台基础信息缺失异常 -> 补充质控平台系统的派单相关信息
|
|
|
+ matchInfoError = "请先补充质控平台系统的派单相关信息: " + matchInfoError + "\n";
|
|
|
+ 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.setServiceId(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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (errorMsgList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";\n", errorMsgList));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|