添加ec标签同步部分代码
This commit is contained in:
@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -16,6 +17,7 @@ import java.util.Date;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class HyPartnerLabelDO {
|
||||
@ApiModelProperty("")
|
||||
private Long id;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.cool.store.job;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hxd
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EcSyncLabelJob {
|
||||
|
||||
@Value("${ec.baseUrl:null}")
|
||||
private String baseUrl;
|
||||
|
||||
@XxlJob("SyncAppletToEcJob")
|
||||
public void syncAppletToEcJob() {
|
||||
XxlJobHelper.log("-------------------------------定时同步小程序数据到ec开始-------------------------------");
|
||||
syncEcLabelExecute();
|
||||
XxlJobHelper.log("-------------------------------定时同步小程序数据到ec结束-------------------------------");
|
||||
XxlJobHelper.handleSuccess();
|
||||
}
|
||||
|
||||
|
||||
//定时同步小程序数据到ec
|
||||
private void syncEcLabelExecute() {
|
||||
// 获取参数
|
||||
String param = XxlJobHelper.getJobParam();
|
||||
String startTime = "";
|
||||
if (StringUtil.isNotEmpty(param)) {
|
||||
XxlJobHelper.log("输入参数为:" + param);
|
||||
startTime = param;
|
||||
}
|
||||
String endTime = DateUtil.now();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
|
||||
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelGroupListDTO;
|
||||
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
||||
import com.cool.store.entity.HyPartnerLabelGroupDO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.vo.LabelGroupListVo;
|
||||
|
||||
@@ -44,4 +45,12 @@ public interface LabelGroupService {
|
||||
*/
|
||||
List<LabelGroupListVo> getAllLabelGroupList();
|
||||
|
||||
/**
|
||||
* 添加ec标签组
|
||||
* @param hyPartnerLabelGroupDO
|
||||
*/
|
||||
void addEcLabelGroup(HyPartnerLabelGroupDO hyPartnerLabelGroupDO);
|
||||
|
||||
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.entity.HyPartnerLabelDO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
|
||||
@@ -55,4 +56,9 @@ public interface LabelService {
|
||||
* @param dto
|
||||
*/
|
||||
void deleteLabel(LabelDeleteDTO dto);
|
||||
|
||||
HyPartnerLabelDO selectByPrimaryKey(Long classId);
|
||||
|
||||
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.HyPartnerBaseInfoDAO;
|
||||
import com.cool.store.dao.HyPartnerLineInfoDAO;
|
||||
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.LineStatusEnum;
|
||||
import com.cool.store.enums.WorkflowStageEnum;
|
||||
@@ -28,6 +29,8 @@ import com.cool.store.sdk.ec.request.UpdateCustomerRequest;
|
||||
import com.cool.store.sdk.ec.response.ChangeFollowUserResponse;
|
||||
import com.cool.store.sdk.ec.response.UpdateCustomerResponse;
|
||||
import com.cool.store.service.EcSyncService;
|
||||
import com.cool.store.service.LabelGroupService;
|
||||
import com.cool.store.service.LabelService;
|
||||
import com.cool.store.utils.Post;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
@@ -48,14 +51,10 @@ import java.util.List;
|
||||
public class EcSyncServiceImpl implements EcSyncService {
|
||||
|
||||
|
||||
|
||||
@Value("${ec.baseUrl:null}")
|
||||
private String baseUrl;
|
||||
|
||||
|
||||
@Value("${ec.sync.createUserId}")
|
||||
private String createUserId;
|
||||
|
||||
@Resource
|
||||
private HyPartnerLineInfoDAO hyPartnerLineInfoDAO;
|
||||
|
||||
@@ -73,10 +72,10 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
private HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
|
||||
|
||||
@Resource
|
||||
private HyPartnerLabelGroupMapper hyPartnerLabelGroupMapper;
|
||||
private LabelGroupService labelGroupService;
|
||||
|
||||
@Resource
|
||||
private HyPartnerLabelMapper hyPartnerLabelMapper;
|
||||
private LabelService labelService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -86,7 +85,7 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
insertSelectiveSync(customerInfoItem);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendFeiShuRobotMessage("推送:"+JSONObject.toJSONString(e),"27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||
sendFeiShuRobotMessage("推送:" + JSONObject.toJSONString(e), "27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -94,7 +93,7 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
|
||||
@Override
|
||||
public void getChannelSource() {
|
||||
String s = HttpUtil.get(baseUrl+"/ec/getChannelSource");
|
||||
String s = HttpUtil.get(baseUrl + "/ec/getChannelSource");
|
||||
UserSourceResponse userSourceResponse = JSONObject.parseObject(s, UserSourceResponse.class);
|
||||
for (UserSourceResponse.ChannelSource channelSource : userSourceResponse.getData()) {
|
||||
Long id = channelSource.getId();
|
||||
@@ -105,7 +104,7 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
if (ObjectUtil.isNotNull(selectByChannel)) {
|
||||
hyPartnerUserChannel.setUpdateTime(new Date()).setId(selectByChannel.getId());
|
||||
hyPartnerUserChannelMapper.updateByPrimaryKeySelective(hyPartnerUserChannel);
|
||||
}else {
|
||||
} else {
|
||||
hyPartnerUserChannel.setCreateTime(new Date());
|
||||
hyPartnerUserChannelMapper.insertSelective(hyPartnerUserChannel);
|
||||
}
|
||||
@@ -115,11 +114,23 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
@Override
|
||||
public Boolean labelInfo(List<GetTagRequest> getTagRequestList) {
|
||||
for (GetTagRequest getTagRequest : getTagRequestList) {
|
||||
Long groupId = getTagRequest.getGroupId();
|
||||
if (ObjectUtil.isNotNull(labelGroupService.selectByPrimaryKey(groupId))) {
|
||||
continue;
|
||||
}
|
||||
HyPartnerLabelGroupDO hyPartnerLabelGroupDO = new HyPartnerLabelGroupDO();
|
||||
hyPartnerLabelGroupDO.setLabelGroupName(getTagRequest.getGroupName()).setId(getTagRequest.getGroupId());
|
||||
|
||||
hyPartnerLabelGroupDO.setLabelGroupName(getTagRequest.getGroupName()).setId(groupId);
|
||||
labelGroupService.addEcLabelGroup(hyPartnerLabelGroupDO);
|
||||
for (GetTagRequest.GetTagItem item : getTagRequest.getList()) {
|
||||
if (ObjectUtil.isNotNull(labelService.selectByPrimaryKey(item.getClassId()))) {
|
||||
continue;
|
||||
}
|
||||
HyPartnerLabelDO hyPartnerLabelDO = new HyPartnerLabelDO();
|
||||
hyPartnerLabelDO.setLabelName(item.getClassName()).setId(item.getClassId()).setLabelGroupId(groupId);
|
||||
labelService.addEcLabel(hyPartnerLabelDO);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,13 +146,13 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
//获取客户来源id
|
||||
String channel = customerInfoItem.getChannel();
|
||||
HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
|
||||
Long channelId =null;
|
||||
Long channelId = null;
|
||||
if (StringUtil.isNotEmpty(channel)) {
|
||||
if (ObjectUtil.isNull(hyPartnerUserChannelDO)||ObjectUtil.isNull(hyPartnerUserChannelDO.getChannelId())) {
|
||||
if (ObjectUtil.isNull(hyPartnerUserChannelDO) || ObjectUtil.isNull(hyPartnerUserChannelDO.getChannelId())) {
|
||||
getChannelSource();
|
||||
}
|
||||
HyPartnerUserChannelDO channelDO = hyPartnerUserChannelMapper.selectByChannelName(channel);
|
||||
channelId=channelDO.getChannelId();
|
||||
channelId = channelDO.getChannelId();
|
||||
}
|
||||
String newPartnerId = UUIDUtils.get32UUID();
|
||||
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
|
||||
@@ -151,11 +162,11 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
String followUserName = customerInfoItem.getFollowUserName();
|
||||
String followUserMobile = customerInfoItem.getFollowUserMobile();
|
||||
//传递过来有跟进人的情况下查询跟进人是否存在
|
||||
if (StringUtil.isNotEmpty(followUserMobile)&&StringUtil.isNotEmpty(followUserName)) {
|
||||
if (StringUtil.isNotEmpty(followUserMobile) && StringUtil.isNotEmpty(followUserName)) {
|
||||
String userId = enterpriseUserDAO.selectByMobile(followUserMobile);
|
||||
if (StringUtil.isEmpty(userId)) {
|
||||
// 给飞书群发送消息 跟进人找不到
|
||||
sendFeiShuRobotMessage("推送:飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile,"27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||
sendFeiShuRobotMessage("推送:飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile, "27243d49-97ca-4981-8aec-7c3bf84eb660");
|
||||
throw new ApiException("飞书架构中找不到该用户:【" + followUserName + "】,该用户电话号码为:" + followUserMobile);
|
||||
}
|
||||
resultLine.setInvestmentManager(userId);
|
||||
@@ -167,16 +178,16 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
resultBase.setUsername(customerInfoItem.getName()).setMobile(customerInfoItem.getMobile());
|
||||
|
||||
HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(resultUser.getMobile());
|
||||
EcClient ecClient=new EcClient();
|
||||
EcClient ecClient = new EcClient();
|
||||
//有就更新ec没有就插入
|
||||
if (newUserInfo != null) {
|
||||
// EC与沪姨合伙人同时存在的线索用户,但用户姓名不同,将沪姨合伙人线索姓名同步至EC覆盖原EC线索姓名
|
||||
if (!newUserInfo.getUsername().equals(resultUser.getUsername())) {
|
||||
UpdateCustomerRequest updateUserRequest=new UpdateCustomerRequest();
|
||||
UpdateCustomerRequest updateUserRequest = new UpdateCustomerRequest();
|
||||
UpdateCustomerBo updateCustomerBo = new UpdateCustomerBo();
|
||||
updateCustomerBo.setUsername(newUserInfo.getUsername()).setMobile(newUserInfo.getMobile()).setCrmId(customerInfoItem.getCrmId());
|
||||
updateUserRequest.setParameter(updateCustomerBo);
|
||||
UpdateCustomerResponse updateUserExec = ecClient.exec(baseUrl,updateUserRequest);
|
||||
UpdateCustomerResponse updateUserExec = ecClient.exec(baseUrl, updateUserRequest);
|
||||
}
|
||||
String oldPartnerId = newUserInfo.getPartnerId();
|
||||
//线索表
|
||||
@@ -187,11 +198,11 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
if (StringUtil.isNotEmpty(resultLine.getInvestmentManager())) {
|
||||
resultLine.setId(partnerLine.getId()).setUpdateTime(new Date());
|
||||
//沪姨合伙人线索存在黑名单,EC该线索分配跟进人同步到沪姨合伙人但线索状态不变,还存在黑名单中
|
||||
resultLine.setLineStatus(partnerLine.getLineStatus().intValue()==LineStatusEnum.BLACKLIST.getCode().intValue()
|
||||
?LineStatusEnum.BLACKLIST.getCode():resultLine.getLineStatus());
|
||||
resultLine.setLineStatus(partnerLine.getLineStatus().intValue() == LineStatusEnum.BLACKLIST.getCode().intValue()
|
||||
? LineStatusEnum.BLACKLIST.getCode() : resultLine.getLineStatus());
|
||||
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(resultLine);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(partnerLine.getInvestmentManager());
|
||||
enterpriseUser.setMobile(getNoWith86Number(enterpriseUser.getMobile()));
|
||||
//电话相同但是名字不同
|
||||
@@ -201,7 +212,7 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(1).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl,changeFollowUserRequest);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
}
|
||||
//电话不同
|
||||
if (!enterpriseUser.getMobile().equals(followUserMobile)) {
|
||||
@@ -210,7 +221,7 @@ public class EcSyncServiceImpl implements EcSyncService {
|
||||
changeFollowUserBo.setFollowUserId(customerInfoItem.getLastFollowUserId()).setCrmId(customerInfoItem.getCrmId())
|
||||
.setType(2).setUsername(enterpriseUser.getName()).setMobile(enterpriseUser.getMobile());
|
||||
changeFollowUserRequest.setParameter(changeFollowUserBo);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl,changeFollowUserRequest);
|
||||
ChangeFollowUserResponse changeFollowUserExec = ecClient.exec(baseUrl, changeFollowUserRequest);
|
||||
}
|
||||
}
|
||||
//base表
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.cool.store.mapper.HyPartnerLabelMapper;
|
||||
import com.cool.store.service.LabelGroupService;
|
||||
import com.cool.store.vo.LabelGroupListVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -33,6 +34,10 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
||||
@Autowired
|
||||
private HyPartnerLabelMapper labelMapper;
|
||||
|
||||
|
||||
@Value("${ec.sync.createUserId:null}")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 查询标签组信息列表
|
||||
* @param dto 查询条件
|
||||
@@ -110,6 +115,18 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
||||
return labelGroupMapper.getLabelGroupList(labelGroupDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyPartnerLabelGroupDO selectByPrimaryKey(Long id){
|
||||
return labelGroupMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEcLabelGroup(HyPartnerLabelGroupDO hyPartnerLabelGroupDO) {
|
||||
hyPartnerLabelGroupDO.setCreateTime(new Date()).setCreateUserId(createUserId).setEditDate(new Date())
|
||||
.setEditUserId(createUserId);
|
||||
labelGroupMapper.insertSelective(hyPartnerLabelGroupDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个标签组内是否有未删除的标签
|
||||
* @param id 标签组 id
|
||||
|
||||
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -32,6 +33,11 @@ public class LabelServiceImpl implements LabelService {
|
||||
@Autowired
|
||||
private HyPartnerLabelMapper labelMapper;
|
||||
|
||||
|
||||
|
||||
@Value("${ec.sync.createUserId:null}")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 获取数组列表
|
||||
*
|
||||
@@ -98,6 +104,17 @@ public class LabelServiceImpl implements LabelService {
|
||||
labelMapper.updateByPrimaryKeySelective(labelDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyPartnerLabelDO selectByPrimaryKey(Long classId) {
|
||||
return labelMapper.selectByPrimaryKey(classId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO) {
|
||||
hyPartnerLabelDO.setEditDate(new Date()).setCreateTime(new Date()).setEditUserId(createUserId).setCreateUserId(createUserId);
|
||||
labelMapper.insertSelective(hyPartnerLabelDO);
|
||||
}
|
||||
|
||||
private Boolean whetherLabelRepeat(HyPartnerLabelDO label) throws ApiException {
|
||||
Long id = label.getId();
|
||||
label.setId(null);
|
||||
|
||||
Reference in New Issue
Block a user