Commit ab9f41af by 王祖波

同步建联

parent 4fedbb9c
......@@ -60,6 +60,25 @@ public class ContactLogDTO implements Serializable {
*/
private Date potentialTime;
/**
* 来源日志id
*/
private Long sourceLogId;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 跟进记录组
*/
private String followTypes;
/**
* 企业id
*/
private String enterpriseId;
......@@ -168,4 +187,35 @@ public class ContactLogDTO implements Serializable {
this.enterpriseId = enterpriseId;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getFollowTypes() {
return followTypes;
}
public void setFollowTypes(String followTypes) {
this.followTypes = followTypes;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.enums.contact;
import java.util.Objects;
public enum ContactBizTypeEnum {
// 业务类型 1潜客(0001)2机会人群(0010)
POTENTIAL_CUSTOMER("10",1,"潜客"),
OPPORTUNITY_CUSTOMER("20",2,"机会人群");
private final String codePre;
private final int type;
private final String description;
public String getCodePre() {
return codePre;
}
public int getType() {
return type;
}
public String getDescription() {
return description;
}
public Long getEsClerkContactTime(Long contactTime) {
if (Objects.equals(contactTime, -1L)) {
return null;
}
return Long.parseLong(this.getCodePre() + contactTime);
}
ContactBizTypeEnum(String codePre, int type, String description) {
this.codePre = codePre;
this.type = type;
this.description = description;
}
public static ContactBizTypeEnum fromCode(String code) {
for (ContactBizTypeEnum type : values()) {
if (Objects.equals(type.codePre,code)) {
return type;
}
}
return ContactBizTypeEnum.POTENTIAL_CUSTOMER;
}
public static ContactBizTypeEnum fromType(int type) {
for (ContactBizTypeEnum bizTypeEnum : values()) {
if (bizTypeEnum.type == type) {
return bizTypeEnum;
}
}
return ContactBizTypeEnum.POTENTIAL_CUSTOMER;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -25,6 +27,22 @@ public class ContactFollowBatchQDTO implements Serializable {
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 跟进记录
*/
......@@ -67,6 +85,30 @@ public class ContactFollowBatchQDTO implements Serializable {
this.followType = followType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getFollowRemark() {
return followRemark;
}
......
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -23,6 +25,24 @@ public class ContactFollowQDTO implements Serializable {
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 跟进记录
*/
......@@ -76,6 +96,30 @@ public class ContactFollowQDTO implements Serializable {
this.followType = followType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getFollowRemark() {
return followRemark;
}
......
......@@ -17,6 +17,12 @@ public class ContactLogCheckQDTO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)null为都校验
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType;
public String getMemberId() {
return memberId;
}
......@@ -40,4 +46,12 @@ public class ContactLogCheckQDTO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactAutoTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum;
import java.io.Serializable;
import java.util.List;
public class ContactLogQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -24,11 +27,42 @@ public class ContactLogQDTO implements Serializable {
private String enterpriseId;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType = ContactFollowTypeEnum.CONTACT.getCode();
/**
* 跟进记录
*/
private String followRemark;
/**
* 跟进上传素材,数组格式
*/
private List<String> followMaterialList;
/**
* 自动建联类型
* @see ContactAutoTypeEnum
*/
private Integer contactAutoType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 来源建联id
*/
private Long sourceLogId;
public ContactLogQDTO() {
}
......@@ -72,6 +106,30 @@ public class ContactLogQDTO implements Serializable {
this.enterpriseId = enterpriseId;
}
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() {
return followRemark;
}
public void setFollowRemark(String followRemark) {
this.followRemark = followRemark;
}
public List<String> getFollowMaterialList() {
return followMaterialList;
}
public void setFollowMaterialList(List<String> followMaterialList) {
this.followMaterialList = followMaterialList;
}
public Integer getContactAutoType() {
return contactAutoType;
}
......@@ -79,4 +137,28 @@ public class ContactLogQDTO implements Serializable {
public void setContactAutoType(Integer contactAutoType) {
this.contactAutoType = contactAutoType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import cn.hutool.core.date.DateUtil;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
......@@ -43,6 +44,12 @@ public class ContactOrderSearchQDTO implements Serializable {
*/
private Date endTime;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
public String getMemberId() {
return memberId;
}
......@@ -102,4 +109,12 @@ public class ContactOrderSearchQDTO implements Serializable {
this.endTime = DateUtil.endOfDay(endTime);
}
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ import com.gic.haoban.manage.api.dto.contact.ContactLogDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogCheckQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import java.util.List;
public interface ContactLogApiService {
/**
......@@ -12,9 +14,17 @@ public interface ContactLogApiService {
* @param memberId
* @return
*/
@Deprecated
ServiceResponse<ContactLogDTO> getClerkContactTime(String memberId);
/**
* 获取每个业务最近一条有效建联记录
* @param memberId
* @return
*/
ServiceResponse<List<ContactLogDTO>> getClerkContactTimeList(String memberId);
/**
* 保存建联记录
* @param qdto
* @return
......
......@@ -93,6 +93,12 @@
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-app-performance-api</artifactId>
<version>${haoban-app-performance-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-api</artifactId>
<version>${gic-enterprise-api}</version>
<exclusions>
......
......@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactFollow;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
......@@ -50,6 +51,21 @@ public interface TabContactFollowMapper {
List<TabContactFollow> queryByIds(@Param("followIds") List<Long> followIds);
/**
* 获取时间段内跟进类型
* @param enterpriseId
* @param clerkId
* @param memberId
* @param beginTime
* @param endTime
* @return
*/
String getFollowTypes(@Param("enterpriseId") String enterpriseId,
@Param("clerkId") String clerkId,
@Param("memberId") String memberId,
@Param("beginTime") Date beginTime,
@Param("endTime") Date endTime);
/**
* 统计总行数
*
* @param tabContactFollow 查询条件
......
......@@ -35,7 +35,7 @@ public interface TabContactLogMapper {
* @param clerkId
* @return
*/
TabContactLog queryLastLog(@Param("memberId")String memberId, @Param("clerkId")String clerkId, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
List<TabContactLog> queryLastLog(@Param("memberId")String memberId, @Param("clerkId")String clerkId, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
/**
* 统计总行数
......
......@@ -48,6 +48,22 @@ public class TabContactFollow implements Serializable {
* 跟进时间
*/
private Date followTime;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 企业id
*/
......@@ -137,6 +153,30 @@ public class TabContactFollow implements Serializable {
this.followTime = followTime;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public String getEnterpriseId() {
return enterpriseId;
}
......
......@@ -59,6 +59,31 @@ public class TabContactLog implements Serializable {
* 成为潜客时间
*/
private Date potentialTime;
/**
* 来源日志id
*/
private Long sourceLogId;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 业务冗余数据
*/
private String bizData;
/**
* 跟进记录组
*/
private String followTypes;
/**
* 企业id
*/
......@@ -172,6 +197,46 @@ public class TabContactLog implements Serializable {
this.potentialTime = potentialTime;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getBizData() {
return bizData;
}
public void setBizData(String bizData) {
this.bizData = bizData;
}
public String getFollowTypes() {
return followTypes;
}
public void setFollowTypes(String followTypes) {
this.followTypes = followTypes;
}
public String getEnterpriseId() {
return enterpriseId;
}
......
......@@ -88,6 +88,15 @@ public class TabContactOrder implements Serializable {
*/
private Integer potentialScore;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 是否删除
*/
private Integer deleteFlag;
......@@ -256,6 +265,22 @@ public class TabContactOrder implements Serializable {
this.potentialScore = potentialScore;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
......
......@@ -6,6 +6,8 @@ import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface ContactLogService {
......@@ -16,14 +18,14 @@ public interface ContactLogService {
* @param clerkDTO
* @return
*/
boolean contactCheck(String enterpriseId, String memberId, ClerkDTO clerkDTO) ;
boolean contactCheck(String enterpriseId, String memberId, ClerkDTO clerkDTO,Integer bizType) ;
/**
* 保存建联记录
*
* @param qdto
*/
TabContactLog saveContactLog(ContactLogQDTO qdto) throws BusinessException;
void saveContactLog(ContactLogQDTO qdto) throws BusinessException;
/**
* 自动建联
......@@ -32,12 +34,18 @@ public interface ContactLogService {
void autoContactLog(ContactLogQDTO qdto);
/**
* 同步建联
* @param qdto
*/
void syncContactLog(ContactLogQDTO qdto);
/**
* 清除建联状态
*
* @param memberId
* @param clearType 1 消费清除 2 换绑主导购
*/
void clearContactLog(String memberId, Integer clearType,String clerkId);
void clearContactLog(String enterpriseId,String memberId, Integer clearType,String clerkId);
/**
* 获取最近一条有效建联记录
......@@ -48,10 +56,19 @@ public interface ContactLogService {
TabContactLog getClerkContactTime(String memberId);
/**
* 根据时间获取最近一条建联记录
* 获取每个业务最近一条有效建联记录
* @param memberId
* @return
*/
List<TabContactLog> getClerkContactTimeList(String memberId);
/**
* 获取最近一条建联记录
* @param memberId
* @param clerkId
* @param beginTime
* @param endTime
* @return
*/
TabContactLog getLastByTime(String memberId, Date beginTime,Date endTime);
Map<Integer,TabContactLog> getLastByTime(String memberId, String clerkId, Date beginTime, Date endTime);
}
......@@ -103,7 +103,7 @@ public class ContactFollowServiceImpl implements ContactFollowService {
autoContactSend(followList);
}
private static void autoContactSend(List<TabContactFollow> followList) {
private void autoContactSend(List<TabContactFollow> followList) {
// 自动建联
Integer followType = followList.get(0).getFollowType();
Integer contactAutoType = ContactFollowTypeEnum.fromCode(followType).getContactAutoType();
......@@ -114,6 +114,8 @@ public class ContactFollowServiceImpl implements ContactFollowService {
contactLogQDTO.setClerkId(x.getClerkId());
contactLogQDTO.setEnterpriseId(x.getEnterpriseId());
contactLogQDTO.setContactAutoType(contactAutoType);
contactLogQDTO.setBizType(x.getSourceType());
contactLogQDTO.setSourceType(x.getSourceType());
return JSON.toJSONString(contactLogQDTO);
}).collect(Collectors.toList());
String routerName = "autoContactLogForMQ";
......
......@@ -3,11 +3,14 @@ package com.gic.haoban.manage.service.service.contact.impl;
import cn.hutool.core.date.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.gic.api.base.commons.BusinessException;
import com.gic.api.base.commons.Constant;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.StoreDTO;
......@@ -17,22 +20,27 @@ import com.gic.haoban.app.customer.dto.MemberInfoListParamsDTO;
import com.gic.haoban.app.customer.dto.contact.ContactParamDTO;
import com.gic.haoban.app.customer.dto.contact.ContactSumDTO;
import com.gic.haoban.app.customer.service.api.service.CustomerApiService;
import com.gic.haoban.app.objectives.api.service.ObjectivesManageApiService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.api.enums.contact.ContactAutoTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactFollowMapper;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactLogMapper;
import com.gic.haoban.manage.service.entity.contact.TabContactFollow;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import com.gic.haoban.manage.service.service.ESMemberInfoService;
import com.gic.haoban.manage.service.service.contact.ContactConfigService;
import com.gic.haoban.manage.service.service.contact.ContactFollowService;
import com.gic.haoban.manage.service.service.contact.ContactLogService;
import com.gic.haoban.manage.service.service.content.adaptor.EnterpriseAdaptor;
import com.gic.member.api.dto.MemberStoreClerkDTO;
import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.member.api.service.MemberService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.search.engine.api.dto.ESResponse;
import com.gic.search.engine.api.dto.dynamic.DynamicDocDTO;
import com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService;
......@@ -44,9 +52,9 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@Service("contactLogService")
public class ContactLogServiceImpl implements ContactLogService {
......@@ -56,6 +64,8 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private TabContactLogMapper contactLogMapper;
@Autowired
private TabContactFollowMapper contactFollowMapper;
@Autowired
private ContactConfigService contactConfigService;
@Autowired
private ContactFollowService contactFollowService;
......@@ -70,17 +80,24 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private CustomerApiService customerApiService;
@Autowired
private ObjectivesManageApiService objectivesManageApiService;
@Autowired
private ESDataDynamicOperationApiService esDataDynamicOperationApiService;
@Autowired
private ESMemberInfoService esMemberInfoService;
@Autowired
private EnterpriseAdaptor enterpriseAdaptor;
@Override
public boolean contactCheck(String enterpriseId,String memberId,ClerkDTO clerkDTO) {
public boolean contactCheck(String enterpriseId,String memberId,ClerkDTO clerkDTO,Integer bizType) {
if (clerkDTO == null) {
return false;
}
CustomerDTO params = new CustomerDTO();
int clerkType = clerkDTO.getClerkType();
if (clerkType > 2) {
return false;
}
String clerkId = clerkDTO.getClerkId();
String storeId = "";
if (clerkType == 0 || clerkType == 1) {
......@@ -91,6 +108,25 @@ public class ContactLogServiceImpl implements ContactLogService {
params.setStoreId(storeId);
params.setClerkId(clerkId);
params.setEnterpriseId(enterpriseId);
if (Objects.equals(bizType, ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType())) {
return checkPotential(memberId, params);
} else if (Objects.equals(bizType, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType())) {
// todo 机会人群是否能建联
} else {
boolean checkPotential = checkPotential(memberId, params);
if (checkPotential) {
return true;
}
// todo 机会人群是否能建联
}
return false;
}
private boolean checkPotential(String memberId, CustomerDTO params) {
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRightByContactBizType(params.getEnterpriseId(), ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType());
if (!hasRight) {
return false;
}
ContactParamDTO contact = new ContactParamDTO();
// 搜索信息
MemberInfoListParamsDTO memberInfoListParamsDTO = com.gic.haoban.common.utils.StringUtil.getBean("{}", MemberInfoListParamsDTO.class);
......@@ -116,13 +152,22 @@ public class ContactLogServiceImpl implements ContactLogService {
@Override
public TabContactLog saveContactLog(ContactLogQDTO qdto) throws BusinessException {
public void saveContactLog(ContactLogQDTO qdto) throws BusinessException {
logger.info("保存建联记录:{}", JSON.toJSONString(qdto));
String enterpriseId = qdto.getEnterpriseId();
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRightByContactBizType(qdto.getEnterpriseId(), qdto.getBizType());
if (!hasRight) {
logger.info("无服务权限");
throw new BusinessException("-1", "无服务权限");
}
String storeId = qdto.getStoreId();
String clerkId = qdto.getClerkId();
String memberId = qdto.getMemberId();
Integer contactAutoType = qdto.getContactAutoType();
Integer followType = qdto.getFollowType();
Integer bizType = qdto.getBizType();
Integer sourceType = qdto.getSourceType();
Long sourceLogId = qdto.getSourceLogId();
DateTime date = DateUtil.date();
MemberStoreClerkDTO memberStoreClerk = memberService.getMemberStoreClerk(memberId);
if (memberStoreClerk == null) {
......@@ -137,7 +182,7 @@ public class ContactLogServiceImpl implements ContactLogService {
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
// 自动建联校验
if (contactAutoType != null) {
boolean contactCheck = contactCheck(enterpriseId, memberId, clerkDTO);
boolean contactCheck = contactCheck(enterpriseId, memberId, clerkDTO, bizType);
logger.info("非潜客未建联或建联未转化:{}",contactCheck);
if (!contactCheck) {
throw new BusinessException("-1", "非潜客未建联或建联未转化,无法建联");
......@@ -147,11 +192,13 @@ public class ContactLogServiceImpl implements ContactLogService {
Integer contactCycle = 1;
// 建联周期 14天内同周期/14天以上周期+1
Integer contactCycleFirst = Constant.FLAG_TRUE;
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, clerkId,null,null);
Map<Integer, TabContactLog> contactLogMap = getLastByTime(memberId, clerkId, null, null);
TabContactLog lastContactLog = contactLogMap.get(bizType);
Date lastContactTime = null;
if (lastContactLog != null) {
Date contactTime = lastContactLog.getContactTime();
Integer contactOrderLimitDay = getContactOrderLimitDay(contactTime);
if (DateUtil.between(date, contactTime, DateUnit.SECOND) > contactOrderLimitDay * 24 * 60 * 60) {
lastContactTime = lastContactLog.getContactTime();
Integer contactOrderLimitDay = getContactOrderLimitDay(lastContactTime);
if (DateUtil.between(date, lastContactTime, DateUnit.SECOND) > contactOrderLimitDay * 24 * 60 * 60) {
contactCycle = lastContactLog.getContactCycle() + 1;
}else {
contactCycle = lastContactLog.getContactCycle();
......@@ -159,8 +206,11 @@ public class ContactLogServiceImpl implements ContactLogService {
}
}
logger.info("建联周期:{},是否周期内首次:{}", contactCycle, contactCycleFirst);
// 获取当前建联时间和上一次建联时间之间的跟进类型
String followTypes = contactFollowMapper.getFollowTypes(enterpriseId, clerkId, memberId, lastContactTime, date);
TabContactLog contactLog = new TabContactLog();
contactLog.setFollowTypes(followTypes);
contactLog.setClerkId(clerkId);
contactLog.setStoreId(storeId);
if (clerkDTO != null) {
......@@ -175,7 +225,8 @@ public class ContactLogServiceImpl implements ContactLogService {
contactLog.setStoreCode(store.getStoreCode());
}
}
contactLog.setLogId(UniqueIdUtils.uniqueLong());
Long logId = UniqueIdUtils.uniqueLong();
contactLog.setLogId(logId);
contactLog.setMemberId(memberId);
contactLog.setContactStatus(Constant.FLAG_TRUE);
contactLog.setContactTime(date);
......@@ -183,12 +234,66 @@ public class ContactLogServiceImpl implements ContactLogService {
contactLog.setContactCycleFirst(contactCycleFirst);
// 成为潜客时间 无用暂不写
contactLog.setPotentialTime(null);
contactLog.setSourceType(sourceType);
contactLog.setBizType(bizType);
contactLog.setEnterpriseId(enterpriseId);
contactLog.setSourceLogId(sourceLogId);
contactLogMapper.insert(contactLog);
// 刷新es建联时间
Long clerkContactTime = Long.parseLong(DateUtil.format(date, DatePattern.PURE_DATETIME_PATTERN));
refreshContactTime(enterpriseId, memberId, clerkContactTime);
return contactLog;
refreshContactTime(enterpriseId, memberId, bizType, clerkContactTime);
// 建联跟进记录
String followRemark = qdto.getFollowRemark();
if (StringUtils.isNotBlank(followRemark)) {
ContactFollowQDTO followQDTO = EntityUtil.changeEntityNew(ContactFollowQDTO.class, qdto);
followQDTO.setFollowType(followType);
followQDTO.setFollowTime(date);
followQDTO.setBizId(String.valueOf(logId));
contactFollowService.saveFollow(followQDTO);
}
// 同步建联
syncContactSend(contactLog);
// 冗余机会人群数据
if (Objects.equals(bizType, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType())) {
modifyBizData(memberId, clerkId, enterpriseId, logId);
}
}
/**
* 冗余机会人群数据
* @param memberId
* @param clerkId
* @param enterpriseId
* @param logId
*/
private void modifyBizData(String memberId, String clerkId, String enterpriseId, Long logId) {
try {
ServiceResponse<List<String>> crowdTypeResponse = objectivesManageApiService.getMemberCrowdType(memberId, clerkId, enterpriseId);
List<String> result = crowdTypeResponse.getResult();
if (CollectionUtils.isNotEmpty(result)) {
TabContactLog modifyContactLog = new TabContactLog();
modifyContactLog.setLogId(logId);
modifyContactLog.setBizData(JSON.toJSONString(result));
contactLogMapper.update(modifyContactLog);
}
} catch (Exception e) {
logger.error("冗余人群数据错误!",e);
}
}
private void syncContactSend(TabContactLog contactLog) {
// 同步建联
ContactLogQDTO contactLogQDTO = EntityUtil.changeEntityNew(ContactLogQDTO.class, contactLog);
contactLogQDTO.setContactAutoType(null);
contactLogQDTO.setSourceLogId(contactLog.getLogId());
String message = JSON.toJSONString(contactLogQDTO);
String routerName = "autoContactLogForMQ";
try {
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
clientInstance.sendMessage(routerName, message);
} catch (Exception e) {
logger.error("发送错误!路由规则名称:" + routerName + ",message:" + message,e);
}
}
/**
......@@ -210,10 +315,6 @@ public class ContactLogServiceImpl implements ContactLogService {
if (qdto == null) {
return;
}
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRight(qdto.getEnterpriseId(), EnterpriseServiceEnum.POTENTIAL.getRightMenuCode());
if (!hasRight) {
return ;
}
String enterpriseId = qdto.getEnterpriseId();
Integer contactAutoType = qdto.getContactAutoType();
ContactConfigDTO contactConfig = contactConfigService.getContactConfig(enterpriseId);
......@@ -227,17 +328,9 @@ public class ContactLogServiceImpl implements ContactLogService {
}
logger.info("自动建联:{}", JSON.toJSONString(qdto));
try {
TabContactLog contactLog = saveContactLog(qdto);
// 写入自动建联跟进记录
ContactFollowQDTO followQDTO = new ContactFollowQDTO();
followQDTO.setMemberId(contactLog.getMemberId());
followQDTO.setClerkId(contactLog.getClerkId());
followQDTO.setClerkCode(contactLog.getClerkCode());
followQDTO.setFollowType(ContactFollowTypeEnum.AUTO_CONTACT.getCode());
followQDTO.setFollowRemark("因" + ContactAutoTypeEnum.fromCode(contactAutoType).getDescription() + ",系统自动标记了建联");
followQDTO.setFollowTime(DateUtil.date());
followQDTO.setEnterpriseId(enterpriseId);
contactFollowService.saveFollow(followQDTO);
qdto.setFollowType(ContactFollowTypeEnum.AUTO_CONTACT.getCode());
qdto.setFollowRemark("因" + ContactAutoTypeEnum.fromCode(contactAutoType).getDescription() + ",系统自动标记了建联");
saveContactLog(qdto);
} catch (BusinessException e) {
logger.info("自动建联异常:{}", e.getMessage());
return;
......@@ -245,37 +338,89 @@ public class ContactLogServiceImpl implements ContactLogService {
}
@Override
public void clearContactLog(String memberId,Integer clearType,String clerkId) {
logger.info("清除建联状态:{},clearType:{},clerkId:{}", memberId, clearType,clerkId);
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null,null,null);
if (lastContactLog == null) {
public void syncContactLog(ContactLogQDTO qdto) {
if (qdto == null) {
return;
}
// clearType 1 消费清除 2 换绑主导购(不清除表建联状态)
if (Objects.equals(clearType, 1)) {
TabContactLog update = new TabContactLog();
update.setLogId(lastContactLog.getLogId());
update.setContactStatus(Constant.FLAG_FALSE);
contactLogMapper.update(update);
}else if (Objects.equals(clearType, 2)) {
String lastClerkId = lastContactLog.getClerkId();
if (Objects.equals(lastClerkId, clerkId)) {
logger.info("最后一次建联和换绑导购一致则不清除建联");
return;
Integer sourceType = qdto.getSourceType();
if (Objects.isNull(sourceType)) {
return;
}
logger.info("同步建联:{}", JSON.toJSONString(qdto));
Integer bizType = qdto.getBizType();
for (ContactBizTypeEnum bizTypeEnum : ContactBizTypeEnum.values()) {
Integer syncBizType = bizTypeEnum.getType();
if (Objects.equals(bizType, syncBizType)) {
continue;
}
ContactLogQDTO syncQdto = EntityUtil.changeEntityNew(ContactLogQDTO.class, qdto);
syncQdto.setBizType(syncBizType);
syncQdto.setSourceType(sourceType);
try {
saveContactLog(syncQdto);
} catch (BusinessException e) {
logger.info("同步建联异常:{}", e.getMessage());
}
}
// 清除es建联时间 -1
refreshContactTime(lastContactLog.getEnterpriseId(), memberId, -1L);
}
private void refreshContactTime(String enterpriseId,String memberId, Long contactTime) {
@Override
public void clearContactLog(String enterpriseId,String memberId,Integer clearType,String clerkId) {
logger.info("清除建联状态:{},clearType:{},clerkId:{}", memberId, clearType,clerkId);
Map<Integer, TabContactLog> contactLogMap = getLastByTime(memberId, null, null, null);
if (contactLogMap == null || contactLogMap.isEmpty()) {
return;
}
contactLogMap.forEach((k,v)->{
// clearType 1 消费清除 2 换绑主导购(不清除表建联状态)
if (Objects.equals(clearType, 1)) {
TabContactLog update = new TabContactLog();
update.setLogId(v.getLogId());
update.setContactStatus(Constant.FLAG_FALSE);
contactLogMapper.update(update);
}else if (Objects.equals(clearType, 2)) {
String lastClerkId = v.getClerkId();
if (Objects.equals(lastClerkId, clerkId)) {
logger.info("最后一次建联和换绑导购一致则不清除建联");
return;
}
}
// 清除es建联时间
refreshContactTime(enterpriseId, memberId, k, -1L);
});
}
private void refreshContactTime(String enterpriseId, String memberId, Integer bizType, Long contactTime) {
JSONObject memberJO = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "clerkContactTime");
if (memberJO == null) {
return;
}
List<Long> clerkContactTimeList = memberJO.getObject("clerkContactTime",new TypeReference<List<Long>>(){});
if (bizType == null) {
clerkContactTimeList = Arrays.stream(ContactBizTypeEnum.values())
.map(bizTypeEnum -> bizTypeEnum.getEsClerkContactTime(contactTime))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}else {
ContactBizTypeEnum bizTypeEnum = ContactBizTypeEnum.fromType(bizType);
Long bizContactTime = bizTypeEnum.getEsClerkContactTime(contactTime);
clerkContactTimeList = clerkContactTimeList.stream().map(time -> {
if (String.valueOf(time).startsWith(bizTypeEnum.getCodePre())) {
return bizContactTime;
} else {
return time;
}
}).filter(Objects::nonNull)
.collect(Collectors.toList());
}
logger.info("刷新建联时间:{},memberId:{}", clerkContactTimeList,memberId);
DynamicDocDTO dynamicDocDTO = new DynamicDocDTO();
dynamicDocDTO.setEnterpriseId(enterpriseId);
dynamicDocDTO.setColumnCategoryCode("member");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", memberId);
jsonObject.put("memberId", memberId);
jsonObject.put("clerkContactTime", contactTime);
jsonObject.put("clerkContactTime", clerkContactTimeList);
dynamicDocDTO.setDocJson(jsonObject);
dynamicDocDTO.setRefresh(Constant.FLAG_TRUE);
ESResponse res = esDataDynamicOperationApiService.updateDataSingle(dynamicDocDTO, false);
......@@ -284,7 +429,11 @@ public class ContactLogServiceImpl implements ContactLogService {
@Override
public TabContactLog getClerkContactTime(String memberId) {
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null,null,null);
Map<Integer, TabContactLog> contactMap = getLastByTime(memberId, null, null, null);
if (contactMap == null || contactMap.isEmpty()) {
return null;
}
TabContactLog lastContactLog = contactMap.get(ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType());
if (lastContactLog == null) {
return null;
}
......@@ -310,7 +459,42 @@ public class ContactLogServiceImpl implements ContactLogService {
}
@Override
public TabContactLog getLastByTime(String memberId, Date beginTime,Date endTime) {
return contactLogMapper.queryLastLog(memberId, null,beginTime,endTime);
public List<TabContactLog> getClerkContactTimeList(String memberId) {
Map<Integer, TabContactLog> contactMap = getLastByTime(memberId, null, null, null);
if (contactMap == null || contactMap.isEmpty()) {
return null;
}
List<TabContactLog> list = new ArrayList<>();
contactMap.forEach((k,lastContactLog)->{
Integer contactStatus = lastContactLog.getContactStatus();
if (Objects.equals(contactStatus, Constant.FLAG_FALSE)) {
return;
}
String clerkId = lastContactLog.getClerkId();
Date contactTime = lastContactLog.getContactTime();
MemberStoreClerkDTO memberStoreClerk = memberService.getMemberStoreClerk(memberId);
if (memberStoreClerk == null) {
return;
}
logger.info("建联导购id:{},专属导购id:{}", clerkId, memberStoreClerk.getClerkId());
if (!Objects.equals(clerkId, memberStoreClerk.getClerkId())) {
return;
}
Integer contactOrderLimitDay = getContactOrderLimitDay(contactTime);
if (DateUtil.compare(contactTime, DateUtil.date().offset(DateField.DAY_OF_MONTH, -contactOrderLimitDay)) < 0) {
return;
}
list.add(lastContactLog);
});
return list;
}
@Override
public Map<Integer, TabContactLog> getLastByTime(String memberId, String clerkId, Date beginTime, Date endTime) {
List<TabContactLog> list = contactLogMapper.queryLastLog(memberId, clerkId, beginTime, endTime);
if (CollectionUtils.isEmpty(list)) {
return new HashMap<>();
}
return list.stream().collect(Collectors.toMap(TabContactLog::getBizType, v -> v, (e, x) -> e));
}
}
......@@ -91,44 +91,53 @@ public class ContactOrderServiceImpl implements ContactOrderService {
contactBeginTime = DateUtil.offsetDay(receiptsDate, -1);
}
TabContactLog lastContactLog = contactLogService.getLastByTime(memberId, contactBeginTime,receiptsDate);
if (lastContactLog == null) {
Map<Integer, TabContactLog> contactMap = contactLogService.getLastByTime(memberId, null, contactBeginTime, receiptsDate);
if (contactMap == null || contactMap.isEmpty()) {
return false;
}
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderId);
contactOrder.setMemberId(memberId);
contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
Double paidAmount = orderInfoResp.getPayAmount();
if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) {
paidAmount = paidAmount + (Objects.isNull(orderInfoResp.getDeliveryPaymentAmount()) ? 0.0 : orderInfoResp.getDeliveryPaymentAmount());
}
contactOrder.setPaidAmount(paidAmount);
contactOrder.setProductCount(orderInfoResp.getGoodsCount());
contactOrder.setPayTime(orderInfoResp.getReceiptsDate());
contactOrder.setReceiptsDate(orderInfoResp.getReceiptsDate());
List<OrderItemResp> orderItems = orderInfoResp.getOrderItems();
if (CollectionUtils.isNotEmpty(orderItems)) {
List<ContactOrderGoodsInfoDTO> goodsInfoDTOS = JSONObject.parseArray(JSON.toJSONString(orderItems), ContactOrderGoodsInfoDTO.class);
contactOrder.setGoodsInfo(JSON.toJSONString(goodsInfoDTOS));
}
contactOrder.setChannelCode(channelCode);
contactOrder.setChannelType(channelType);
contactOrder.setClerkId(lastContactLog.getClerkId());
contactOrder.setClerkCode(lastContactLog.getClerkCode());
contactOrder.setClerkName(lastContactLog.getClerkName());
contactOrder.setStoreId(lastContactLog.getStoreId());
contactOrder.setContactLogId(lastContactLog.getLogId());
contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
for (Map.Entry<Integer, TabContactLog> entry : contactMap.entrySet()) {
Integer key = entry.getKey();
TabContactLog lastContactLog = entry.getValue();
if (lastContactLog == null) {
continue;
}
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderId);
contactOrder.setMemberId(memberId);
contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
Double paidAmount = orderInfoResp.getPayAmount();
if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) {
paidAmount = paidAmount + (Objects.isNull(orderInfoResp.getDeliveryPaymentAmount()) ? 0.0 : orderInfoResp.getDeliveryPaymentAmount());
}
contactOrder.setPaidAmount(paidAmount);
contactOrder.setProductCount(orderInfoResp.getGoodsCount());
contactOrder.setPayTime(orderInfoResp.getReceiptsDate());
contactOrder.setReceiptsDate(orderInfoResp.getReceiptsDate());
List<OrderItemResp> orderItems = orderInfoResp.getOrderItems();
if (CollectionUtils.isNotEmpty(orderItems)) {
List<ContactOrderGoodsInfoDTO> goodsInfoDTOS = JSONObject.parseArray(JSON.toJSONString(orderItems), ContactOrderGoodsInfoDTO.class);
contactOrder.setGoodsInfo(JSON.toJSONString(goodsInfoDTOS));
}
contactOrder.setChannelCode(channelCode);
contactOrder.setChannelType(channelType);
contactOrder.setClerkId(lastContactLog.getClerkId());
contactOrder.setClerkCode(lastContactLog.getClerkCode());
contactOrder.setClerkName(lastContactLog.getClerkName());
contactOrder.setStoreId(lastContactLog.getStoreId());
contactOrder.setContactLogId(lastContactLog.getLogId());
contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setSourceType(lastContactLog.getSourceType());
contactOrder.setBizType(lastContactLog.getBizType());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
JSONObject jsonObject = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "potentialScore");
if (jsonObject != null && jsonObject.getInteger("potentialScore") != null) {
contactOrder.setPotentialScore(jsonObject.getInteger("potentialScore"));
JSONObject jsonObject = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "potentialScore");
if (jsonObject != null && jsonObject.getInteger("potentialScore") != null) {
contactOrder.setPotentialScore(jsonObject.getInteger("potentialScore"));
}
contactOrderMapper.insert(contactOrder);
}
contactOrderMapper.insert(contactOrder);
return true;
}
......
......@@ -6,6 +6,7 @@ import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.EnterpriseUsingPermissionDto;
import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO;
import com.gic.enterprise.api.service.EnterpriseUseForbidService;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
......@@ -134,6 +135,17 @@ public class EnterpriseAdaptor {
return StringUtils.equals(cache, "1");
}
public boolean checkEnterpriseHasRightByContactBizType(String enterpriseId,Integer contactBizType) {
if (Objects.equals(contactBizType, ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType())) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(EnterpriseServiceEnum.POTENTIAL.getRightMenuCode()));
} else if (Objects.equals(contactBizType, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType())) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(EnterpriseServiceEnum.OBJECTIVES.getRightMenuCode()));
} else {
return checkEnterpriseHasRights(enterpriseId, Lists.newArrayList(EnterpriseServiceEnum.POTENTIAL.getRightMenuCode()))
|| checkEnterpriseHasRights(enterpriseId, Lists.newArrayList(EnterpriseServiceEnum.OBJECTIVES.getRightMenuCode()));
}
}
public boolean checkEnterpriseHasRight(String enterpriseId,String rightMenuCode) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(rightMenuCode));
}
......
......@@ -31,12 +31,13 @@ public class RouterApiServiceImpl implements RouterApiService {
return ServiceResponse.success();
}
ClerkAddEventParam clerkAddEventParam = JSONObject.parseObject(params, ClerkAddEventParam.class);
String enterpriseId = clerkAddEventParam.getEnterpriseId();
String memberId = clerkAddEventParam.getMemberId();
Integer changeType = clerkAddEventParam.getChangeType();
String clerkId = clerkAddEventParam.getClerkId();
if (Objects.equals(changeType, 1)) {
// 换绑主导购清除建联状态
contactLogService.clearContactLog(memberId, 2, clerkId);
contactLogService.clearContactLog(enterpriseId,memberId, 2, clerkId);
}
return ServiceResponse.success();
}
......
......@@ -16,6 +16,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by wangzubo on 2022/11/1.
*/
......@@ -35,6 +38,16 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
}
@Override
public ServiceResponse<List<ContactLogDTO>> getClerkContactTimeList(String memberId) {
List<TabContactLog> list = contactLogService.getClerkContactTimeList(memberId);
if (list == null) {
return ServiceResponse.success(new ArrayList<>());
}
List<ContactLogDTO> dtos = EntityUtil.changeEntityListNew(ContactLogDTO.class, list);
return ServiceResponse.success(dtos);
}
@Override
public ServiceResponse<Void> saveContactLog(ContactLogQDTO qdto) {
try {
contactLogService.saveContactLog(qdto);
......@@ -50,7 +63,12 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
return ServiceResponse.success();
}
ContactLogQDTO contactLogQDTO = JSONObject.parseObject(message, ContactLogQDTO.class);
contactLogService.autoContactLog(contactLogQDTO);
Integer contactAutoType = contactLogQDTO.getContactAutoType();
if (contactAutoType != null) {
contactLogService.autoContactLog(contactLogQDTO);
}else {
contactLogService.syncContactLog(contactLogQDTO);
}
return ServiceResponse.success();
}
......@@ -60,7 +78,7 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
if (clerkDTO == null) {
return ServiceResponse.success(Boolean.FALSE);
}
boolean check = contactLogService.contactCheck(checkQDTO.getEnterpriseId(), checkQDTO.getMemberId(), clerkDTO);
boolean check = contactLogService.contactCheck(checkQDTO.getEnterpriseId(), checkQDTO.getMemberId(), clerkDTO,checkQDTO.getBizType());
return ServiceResponse.success(check);
}
}
......@@ -41,7 +41,7 @@ public class ContactOrderApiServiceImpl implements ContactOrderApiService {
OrderInfoResp result = serviceResponse.getResult();
boolean contactOrder = contactOrderService.saveContactOrder(result);
if (contactOrder) {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(enterpriseId,memberId, 1,"");
}
return ServiceResponse.success();
}
......
......@@ -180,6 +180,9 @@
<dubbo:reference id="customerApiService"
interface="com.gic.haoban.app.customer.service.api.service.CustomerApiService" timeout="10000"
retries="0" check="false"/>
<dubbo:reference id="objectivesManageApiService"
interface="com.gic.haoban.app.objectives.api.service.ObjectivesManageApiService" timeout="10000"
retries="0" check="false"/>
<dubbo:reference id="qywxTagSyncApiService"
interface="com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService" timeout="10000"
......
......@@ -14,6 +14,9 @@
<result column="follow_material" property="followMaterial" />
<result column="goods_info" property="goodsInfo" />
<result column="follow_time" property="followTime" />
<result column="source_type" property="sourceType" />
<result column="biz_type" property="bizType" />
<result column="biz_id" property="bizId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="delete_flag" property="deleteFlag" />
<result column="create_time" property="createTime" />
......@@ -21,10 +24,10 @@
</resultMap>
<sql id="Base_Column_List">
follow_id, member_id, clerk_id, clerk_code, follow_type,follow_remark, follow_material, goods_info, follow_time, enterprise_id, delete_flag, create_time, update_time
follow_id, member_id, clerk_id, clerk_code, follow_type,follow_remark, follow_material, goods_info, follow_time, source_type,biz_type,biz_id,enterprise_id, delete_flag, create_time, update_time
</sql>
<sql id="Alias_Base_Column_List">
t.follow_id, t.member_id, t.clerk_id, t.clerk_code, t.follow_type,t.follow_remark, t.follow_material, t.goods_info, t.follow_time, t.enterprise_id, t.delete_flag, t.create_time, t.update_time
t.follow_id, t.member_id, t.clerk_id, t.clerk_code, t.follow_type,t.follow_remark, t.follow_material, t.goods_info, t.follow_time,t.source_type,t.biz_type,t.biz_id, t.enterprise_id, t.delete_flag, t.create_time, t.update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
......@@ -44,6 +47,29 @@
</foreach>
</select>
<select id="getFollowTypes" resultType="java.lang.String">
SELECT
GROUP_CONCAT(DISTINCT follow_type)
FROM tab_contact_follow
<where>
enterprise_id = #{enterpriseId}
AND follow_type not in (5,6)
<if test="memberId != null">
AND member_id = #{memberId}
</if>
<if test="clerkId != null">
AND clerk_id = #{clerkId}
</if>
<if test="beginTime != null">
AND follow_time > #{beginTime}
</if>
<if test="endTime != null">
AND follow_time <![CDATA[<=]]> #{endTime}
</if>
</where>
group by member_id
</select>
<select id="count" resultType="long">
SELECT COUNT(*)
FROM tab_contact_follow
......@@ -109,16 +135,27 @@
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="followId">
INSERT INTO tab_contact_follow (member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, enterprise_id, delete_flag, create_time, update_time)
VALUES (#{memberId}, #{clerkId}, #{clerkCode},#{followType}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime})
INSERT INTO tab_contact_follow (member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, source_type,biz_type,biz_id,enterprise_id, delete_flag, create_time, update_time)
VALUES (#{memberId}, #{clerkId}, #{clerkCode},#{followType}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime},#{sourceType},#{bizType},#{bizId}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch">
INSERT INTO tab_contact_follow (follow_id,member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, enterprise_id)
INSERT INTO tab_contact_follow (
follow_id, member_id, clerk_id, clerk_code,
follow_type, follow_remark, follow_material,
goods_info, follow_time, source_type, biz_type, biz_id, enterprise_id
)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.followId},#{item.memberId}, #{item.clerkId}, #{item.clerkCode}, #{item.followType},#{item.followRemark}, #{item.followMaterial}, #{item.goodsInfo}, #{item.followTime}, #{item.enterpriseId})
(#{item.followId}, #{item.memberId}, #{item.clerkId}, #{item.clerkCode},
#{item.followType}, #{item.followRemark}, #{item.followMaterial},
#{item.goodsInfo}, #{item.followTime}, #{sourceType}, #{bizType}, #{bizId}, #{item.enterpriseId})
</foreach>
ON DUPLICATE KEY UPDATE
biz_type = CASE
WHEN VALUES(biz_id) IS NOT NULL THEN biz_type + VALUES(biz_type)
ELSE biz_type
END
</insert>
<update id="update">
......@@ -132,6 +169,9 @@
<if test="followMaterial != null">follow_material = #{followMaterial},</if>
<if test="goodsInfo != null">goods_info = #{goodsInfo},</if>
<if test="followTime != null">follow_time = #{followTime},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
<if test="bizId != null">biz_id = #{bizId},</if>
<if test="source_type != null">source_type = #{sourceType},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
update_time = #{updateTime}
......
......@@ -14,6 +14,11 @@
<result property="contactCycle" column="contact_cycle" jdbcType="INTEGER"/>
<result property="contactCycleFirst" column="contact_cycle_first" jdbcType="INTEGER"/>
<result property="potentialTime" column="potential_time" jdbcType="TIMESTAMP"/>
<result property="sourceType" column="source_type" jdbcType="INTEGER"/>
<result property="sourceLogId" column="source_log_id" jdbcType="BIGINT"/>
<result property="bizType" column="biz_type" jdbcType="INTEGER" />
<result property="bizData" column="biz_data" jdbcType="VARCHAR" />
<result property="followTypes" column="follow_types" jdbcType="VARCHAR" />
<result property="enterpriseId" column="enterprise_id" jdbcType="VARCHAR"/>
<result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
......@@ -39,19 +44,41 @@
</select>
<select id="queryLastLog" resultMap="TabContactLogMap">
select *
from tab_contact_log
where delete_flag = 0 and member_id = #{memberId}
SELECT t1.*
FROM tab_contact_log t1
INNER JOIN (
SELECT biz_type, MAX(contact_time) AS max_contact_time
FROM tab_contact_log
WHERE delete_flag = 0
<if test="memberId != null">
AND member_id = #{memberId}
</if>
<if test="clerkId!=null and clerkId!=''">
and clerk_id = #{clerkId}
AND clerk_id = #{clerkId}
</if>
<if test="beginTime != null">
AND contact_time >= #{beginTime}
</if>
<if test="beginTime!=null ">
and contact_time >= #{beginTime}
<if test="endTime != null">
AND contact_time <![CDATA[<=]]> #{endTime}
</if>
GROUP BY biz_type
) t2
ON t1.biz_type = t2.biz_type AND t1.contact_time = t2.max_contact_time
WHERE t1.delete_flag = 0
<if test="memberId != null">
AND t1.member_id = #{memberId}
</if>
<if test="clerkId!=null and clerkId!=''">
AND t1.clerk_id = #{clerkId}
</if>
<if test="endTime!=null ">
and contact_time <![CDATA[<=]]> #{endTime}
<if test="beginTime != null">
AND t1.contact_time >= #{beginTime}
</if>
order by contact_time desc,log_id desc limit 1
<if test="endTime != null">
AND t1.contact_time <![CDATA[<=]]> #{endTime}
</if>
ORDER BY t1.biz_type ASC,t1.contact_time desc,t1.log_id desc
</select>
<!--查询列表-->
......@@ -128,6 +155,11 @@
contact_cycle,
contact_cycle_first,
potential_time,
source_type,
source_log_id,
biz_type,
biz_data,
follow_types,
enterprise_id
)
values (
......@@ -143,6 +175,11 @@
#{contactCycle},
#{contactCycleFirst},
#{potentialTime},
#{sourceType},
#{sourceLogId},
#{bizType},
#{bizData},
#{followTypes},
#{enterpriseId})
</insert>
......@@ -183,6 +220,21 @@
<if test="potentialTime != null">
potential_time = #{potentialTime},
</if>
<if test="sourceType != null">
source_type = #{sourceType},
</if>
<if test="sourceLogId != null">
source_log_id = #{sourceLogId},
</if>
<if test="bizType != null">
biz_type = #{bizType},
</if>
<if test="bizData != null">
biz_data = #{bizData},
</if>
<if test="followTypes != null">
follow_types = #{followTypes},
</if>
<if test="enterpriseId != null and enterpriseId != ''">
enterprise_id = #{enterpriseId},
</if>
......
......@@ -24,6 +24,8 @@
<result column="contact_time" property="contactTime" />
<result column="potential_time" property="potentialTime" />
<result column="potential_score" property="potentialScore" />
<result column="source_type" property="sourceType" />
<result column="biz_type" property="bizType" />
<result column="delete_flag" property="deleteFlag" />
<result column="enterprise_id" property="enterpriseId" />
<result column="create_time" property="createTime" />
......@@ -31,7 +33,7 @@
</resultMap>
<sql id="Base_Column_List">
id, order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time, potential_score, delete_flag, enterprise_id, create_time, update_time
id, order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time, potential_score,source_type,biz_type, delete_flag, enterprise_id, create_time, update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
......@@ -45,7 +47,7 @@
SELECT
<include refid="Base_Column_List" />
FROM tab_contact_order
WHERE order_id = #{orderId} and delete_flag = 0
WHERE order_id = #{orderId} and delete_flag = 0 limit 1
</select>
<select id="queryByIds" resultMap="BaseResultMap">
......@@ -74,6 +76,9 @@
<if test="search.channelType != null">
AND channel_type = #{search.channelType}
</if>
<if test="search.bizType != null">
AND biz_type = #{search.bizType}
</if>
<if test="search.storeIdList != null and search.storeIdList.size() > 0">
AND store_id IN
<foreach item="storeId" index="index" collection="search.storeIdList" open="(" separator="," close=")">
......@@ -109,8 +114,8 @@
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time,potential_score, enterprise_id)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode},#{clerkName}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{potentialScore}, #{enterpriseId})
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time,potential_score, source_type,biz_type,enterprise_id)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode},#{clerkName}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{potentialScore}, #{sourceType},#{bizType},#{enterpriseId})
</insert>
<update id="update">
......@@ -133,6 +138,8 @@
<if test="contactTime != null">contact_time = #{contactTime},</if>
<if test="potentialTime != null">potential_time = #{potentialTime},</if>
<if test="potentialScore != null">potential_score = #{potentialScore},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
<if test="source_type != null">source_type = #{sourceType},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
update_time = #{updateTime}
......
......@@ -102,7 +102,7 @@ public class ContactTest {
@Test
public void clearContactLog() throws Exception {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(eid,memberId, 1,"");
}
@Test
......
......@@ -120,6 +120,7 @@ public class ContactController {
@RequestMapping(path = "/log")
public RestResponse<Void> saveLog(@RequestBody ContactLogQO contactLogQO) {
ContactLogQDTO logQDTO = EntityUtil.changeEntityNew(ContactLogQDTO.class, contactLogQO);
logQDTO.setSourceType(contactLogQO.getBizType());
ServiceResponse<Void> serviceResponse = contactLogApiService.saveContactLog(logQDTO);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
......
......@@ -17,6 +17,12 @@ public class ContactLogCheckQO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)null为都校验
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType;
public String getMemberId() {
return memberId;
}
......@@ -40,4 +46,12 @@ public class ContactLogCheckQO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
package com.gic.haoban.manage.web.qo.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.List;
public class ContactLogQO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -21,6 +24,21 @@ public class ContactLogQO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 跟进记录
*/
private String followRemark;
/**
* 跟进上传素材,数组格式
*/
private List<String> followMaterialList;
public String getMemberId() {
return memberId;
}
......@@ -52,4 +70,28 @@ public class ContactLogQO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getFollowRemark() {
return followRemark;
}
public void setFollowRemark(String followRemark) {
this.followRemark = followRemark;
}
public List<String> getFollowMaterialList() {
return followMaterialList;
}
public void setFollowMaterialList(List<String> followMaterialList) {
this.followMaterialList = followMaterialList;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment