Commit 8959f187 by 王祖波

自动建联

parent 6e1d26f9
package com.gic.haoban.manage.api.dto.contact;
import java.io.Serializable;
import java.util.List;
public class ContactConfigDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 配置主键ID
*/
private Long configId;
/**
* 自动建联类型 10话务任务 20企微群发 30发送商品 40发送素材
*/
private List<Integer> contactAutoList;
/**
* 是否自动备注(0 否 1 是)
*/
private Integer remarkFlag;
/**
* 备注内容
*/
private List<String> remarkContentList;
/**
* 企业ID
*/
private String enterpriseId;
public Long getConfigId() {
return configId;
}
public void setConfigId(Long configId) {
this.configId = configId;
}
public Integer getRemarkFlag() {
return remarkFlag;
}
public void setRemarkFlag(Integer remarkFlag) {
this.remarkFlag = remarkFlag;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public List<Integer> getContactAutoList() {
return contactAutoList;
}
public void setContactAutoList(List<Integer> contactAutoList) {
this.contactAutoList = contactAutoList;
}
public List<String> getRemarkContentList() {
return remarkContentList;
}
public void setRemarkContentList(List<String> remarkContentList) {
this.remarkContentList = remarkContentList;
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class ContactFollowDTO implements Serializable {
private String clerkCode;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
......
package com.gic.haoban.manage.api.enums.contact;
public enum ContactAutoTypeEnum {
// 自动建联类型 10话务任务 20企微群发 30发送商品 40发送素材
CALL_TASK(10, "专属导购通过话务任务成功触达客户"),
QW_TASK(20, "专属导购通过企微群发任务成功触达了客户"),
GOODS_RECOMMEND(30, "专属导购通过\"智能选款\"或\"意向客户\"给客户发送了商品"),
MATERIAL(40, "专属导购通过\"聊天工具栏\"或\"企微群发\"给客户发送了营销素材");
private final int code;
private final String description;
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
ContactAutoTypeEnum(int code, String description) {
this.code = code;
this.description = description;
}
public static ContactAutoTypeEnum fromCode(int code) {
for (ContactAutoTypeEnum type : values()) {
if (type.code == code) {
return type;
}
}
return null;
}
}
\ No newline at end of file
......@@ -8,7 +8,9 @@ public enum ContactFollowTypeEnum {
WECHAT_SESSION(2, "企微会话","企微会话"),
PRODUCT(3, "发送商品","商品"),
WECHAT_GROUP_SEND(4, "企微群发","企微群发"),
CONTACT(5, "标记建联","标记了建联");
CONTACT(5, "标记建联","标记了建联"),
AUTO_CONTACT(6, "系统自动标记","系统自动标记"),
MATERIAL(7, "营销素材","营销素材");
private final int code;
private final String description;
......
......@@ -21,7 +21,7 @@ public class ContactFollowBatchQDTO implements Serializable {
private String clerkId;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
......
......@@ -19,7 +19,7 @@ public class ContactFollowQDTO implements Serializable {
*/
private String clerkCode;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
......
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactAutoTypeEnum;
import java.io.Serializable;
import java.util.Date;
public class ContactLogQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -22,6 +23,23 @@ public class ContactLogQDTO implements Serializable {
*/
private String enterpriseId;
/**
* 自动建联类型
* @see ContactAutoTypeEnum
*/
private Integer contactAutoType;
public ContactLogQDTO() {
}
public ContactLogQDTO(String enterpriseId,String memberId, String clerkId, String storeId, Integer contactAutoType) {
this.memberId = memberId;
this.clerkId = clerkId;
this.storeId = storeId;
this.enterpriseId = enterpriseId;
this.contactAutoType = contactAutoType;
}
public String getMemberId() {
return memberId;
}
......@@ -53,4 +71,12 @@ public class ContactLogQDTO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getContactAutoType() {
return contactAutoType;
}
public void setContactAutoType(Integer contactAutoType) {
this.contactAutoType = contactAutoType;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.service.contact;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
public interface ContactConfigApiService {
/**
* 保存建联配置
*
* @param contactConfig
*/
ServiceResponse<Void> saveContactConfig(ContactConfigDTO contactConfig);
/**
* 获取建联配置
* @param enterpriseId
* @return
*/
ServiceResponse<ContactConfigDTO> getContactConfig(String enterpriseId);
}
......@@ -20,4 +20,12 @@ public interface ContactLogApiService {
*/
ServiceResponse<Void> saveContactLog(ContactLogQDTO qdto);
/**
* 消息队列异步自动建联
* @param message
* @return
*/
ServiceResponse<Void> autoContactLogForMQ(String message);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace=".dao.TabContactConfigDao">
<resultMap type=".entity.TabContactConfig" id="TabContactConfigMap">
<result property="configId" column="config_id" jdbcType="INTEGER"/>
<result property="contactAuto" column="contact_auto" jdbcType="VARCHAR"/>
<result property="remarkFlag" column="remark_flag" jdbcType="INTEGER"/>
<result property="remarkContent" column="remark_content" 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"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="TabContactConfigMap">
select
config_idcontact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time
from tab_contact_config
where config_id = #{configId}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TabContactConfigMap">
select
config_idcontact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time
from tab_contact_config
<where>
<if test="configId != null">
and config_id = #{configId}
</if>
<if test="contactAuto != null and contactAuto != ''">
and contact_auto = #{contactAuto}
</if>
<if test="remarkFlag != null">
and remark_flag = #{remarkFlag}
</if>
<if test="remarkContent != null and remarkContent != ''">
and remark_content = #{remarkContent}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
<if test="deleteFlag != null">
and delete_flag = #{deleteFlag}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from tab_contact_config
<where>
<if test="configId != null">
and config_id = #{configId}
</if>
<if test="contactAuto != null and contactAuto != ''">
and contact_auto = #{contactAuto}
</if>
<if test="remarkFlag != null">
and remark_flag = #{remarkFlag}
</if>
<if test="remarkContent != null and remarkContent != ''">
and remark_content = #{remarkContent}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
<if test="deleteFlag != null">
and delete_flag = #{deleteFlag}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="configId" useGeneratedKeys="true">
insert into
tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
values (#{contactAuto}#{remarkFlag}#{remarkContent}#{enterpriseId}#{deleteFlag}#{createTime}#{updateTime})
</insert>
<insert id="insertBatch" keyProperty="configId" useGeneratedKeys="true">
insert into
tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.contactAuto}#{entity.remarkFlag}#{entity.remarkContent}#{entity.enterpriseId}#{entity.deleteFlag}#{entity.createTime}#{entity.updateTime})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="configId" useGeneratedKeys="true">
insert into
tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.contactAuto}#{entity.remarkFlag}#{entity.remarkContent}#{entity.enterpriseId}#{entity.deleteFlag}#{entity.createTime}#{entity.updateTime})
</foreach>
on duplicate key update
contact_auto = values(contact_auto)remark_flag = values(remark_flag)remark_content =
values(remark_content)enterprise_id = values(enterprise_id)delete_flag = values(delete_flag)create_time =
values(create_time)update_time = values(update_time)
</insert>
<!--通过主键修改数据-->
<update id="update">
update tab_contact_config
<set>
<if test="contactAuto != null and contactAuto != ''">
contact_auto = #{contactAuto},
</if>
<if test="remarkFlag != null">
remark_flag = #{remarkFlag},
</if>
<if test="remarkContent != null and remarkContent != ''">
remark_content = #{remarkContent},
</if>
<if test="enterpriseId != null and enterpriseId != ''">
enterprise_id = #{enterpriseId},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where config_id = #{configId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from tab_contact_config where config_id = #{configId}
</delete>
</mapper>
package com.gic.haoban.manage.service.dao.mapper.contact;
import com.gic.haoban.manage.service.entity.contact.TabContactConfig;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabContactConfigMapper {
/**
* 根据主键查询
*/
TabContactConfig queryById(@Param("configId") Long configId);
/**
* 根据 enterpriseId 查询配置
*/
TabContactConfig queryByEnterpriseId(@Param("enterpriseId") String enterpriseId);
/**
* 插入单条数据
*/
int insert(TabContactConfig tabContactConfig);
/**
* 批量插入
*/
int insertBatch(@Param("list") List<TabContactConfig> list);
/**
* 更新数据
*/
int update(TabContactConfig tabContactConfig);
/**
* 根据主键删除
*/
int deleteById(@Param("configId") Long configId);
}
\ No newline at end of file
package com.gic.haoban.manage.service.entity.contact;
import java.io.Serializable;
import java.util.Date;
/**
* 建联配置表(TabContactConfig)实体类
*
* @author TONGYI Lingma
* @since 2025-05-26 16:09:38
*/
public class TabContactConfig implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 配置主键ID
*/
private Long configId;
/**
* 自动建联类型 10话务任务 20企微群发 30发送商品 40发送素材
*/
private String contactAuto;
/**
* 是否自动备注(0 否 1 是)
*/
private Integer remarkFlag;
/**
* 备注内容
*/
private String remarkContent;
/**
* 企业ID
*/
private String enterpriseId;
/**
* 是否删除(0 正常 1 删除)
*/
private Integer deleteFlag;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Long getConfigId() {
return configId;
}
public void setConfigId(Long configId) {
this.configId = configId;
}
public String getContactAuto() {
return contactAuto;
}
public void setContactAuto(String contactAuto) {
this.contactAuto = contactAuto;
}
public Integer getRemarkFlag() {
return remarkFlag;
}
public void setRemarkFlag(Integer remarkFlag) {
this.remarkFlag = remarkFlag;
}
public String getRemarkContent() {
return remarkContent;
}
public void setRemarkContent(String remarkContent) {
this.remarkContent = remarkContent;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ public class TabContactFollow implements Serializable {
*/
private String clerkCode;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
......
package com.gic.haoban.manage.service.service.contact;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
public interface ContactConfigService {
/**
* 保存建联配置
*
* @param contactConfig
*/
void saveContactConfig(ContactConfigDTO contactConfig);
/**
* 获取建联配置
* @param enterpriseId
* @return
*/
ContactConfigDTO getContactConfig(String enterpriseId);
}
......@@ -14,7 +14,13 @@ public interface ContactLogService {
*
* @param qdto
*/
void saveContactLog(ContactLogQDTO qdto) throws BusinessException;
TabContactLog saveContactLog(ContactLogQDTO qdto) throws BusinessException;
/**
* 自动建联
* @param qdto
*/
void autoContactLog(ContactLogQDTO qdto);
/**
* 清除建联状态
......
package com.gic.haoban.manage.service.service.contact.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactConfigMapper;
import com.gic.haoban.manage.service.entity.contact.TabContactConfig;
import com.gic.haoban.manage.service.service.contact.ContactConfigService;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service("contactConfigService")
public class ContactConfigServiceImpl implements ContactConfigService {
private static final Logger logger = LogManager.getLogger(ContactConfigService.class);
@Autowired
private TabContactConfigMapper contactConfigMapper;
@Override
public void saveContactConfig(ContactConfigDTO contactConfig) {
logger.info("保存联系配置信息:{}", JSON.toJSONString(contactConfig));
if (contactConfig.getContactAutoList() == null) {
contactConfig.setContactAutoList(Collections.emptyList());
}
if (contactConfig.getRemarkContentList() == null) {
contactConfig.setRemarkContentList(Collections.emptyList());
}
String enterpriseId = contactConfig.getEnterpriseId();
TabContactConfig config = contactConfigMapper.queryByEnterpriseId(enterpriseId);
if (config != null) {
config.setRemarkFlag(contactConfig.getRemarkFlag());
config.setContactAuto(contactConfig.getContactAutoList().stream().map(String::valueOf).collect(Collectors.joining(",")));
config.setRemarkContent(JSON.toJSONString(contactConfig.getRemarkContentList()));
contactConfigMapper.update(config);
}else {
config = EntityUtil.changeEntityNew(TabContactConfig.class, contactConfig);
config.setConfigId(UniqueIdUtils.uniqueLong());
config.setContactAuto(contactConfig.getContactAutoList().stream().map(String::valueOf).collect(Collectors.joining(",")));
config.setRemarkContent(JSON.toJSONString(contactConfig.getRemarkContentList()));
contactConfigMapper.insert(config);
}
}
@Override
public ContactConfigDTO getContactConfig(String enterpriseId) {
TabContactConfig config = contactConfigMapper.queryByEnterpriseId(enterpriseId);
if (config == null) {
return null;
}
ContactConfigDTO contactConfigDTO = EntityUtil.changeEntityNew(ContactConfigDTO.class, config);
List<Integer> contactAutoList = Optional.ofNullable(config.getContactAuto())
.filter(StringUtils::isNotBlank)
.map(s -> Arrays.stream(s.split(",")).map(Integer::valueOf).collect(Collectors.toList()))
.orElse(Collections.emptyList());
contactConfigDTO.setContactAutoList(contactAutoList);
List<String> remarkContentList = Optional.ofNullable(config.getRemarkContent())
.filter(StringUtils::isNotBlank)
.map(x -> JSONArray.parseArray(x, String.class))
.orElse(Collections.emptyList());
contactConfigDTO.setRemarkContentList(remarkContentList);
return contactConfigDTO;
}
}
......@@ -5,25 +5,36 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.UniqueIdUtils;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.app.customer.dto.CustomerDTO;
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.base.api.common.BasePageInfo;
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.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.TabContactLog;
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.member.api.dto.MemberStoreClerkDTO;
import com.gic.member.api.dto.MemberStoreDTO;
import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.member.api.service.MemberService;
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;
import com.gic.store.goods.service.StoreGoodsService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -31,6 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Service("contactLogService")
......@@ -41,6 +53,10 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private TabContactLogMapper contactLogMapper;
@Autowired
private ContactConfigService contactConfigService;
@Autowired
private ContactFollowService contactFollowService;
@Autowired
private StoreGoodsService storeGoodsService;
@Autowired
private ClerkService clerkService;
......@@ -49,16 +65,58 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private MemberService memberService;
@Autowired
private CustomerApiService customerApiService;
@Autowired
private ESDataDynamicOperationApiService esDataDynamicOperationApiService;
public boolean contactCheck(String enterpriseId,String memberId,ClerkDTO clerkDTO) {
if (clerkDTO == null) {
return false;
}
CustomerDTO params = new CustomerDTO();
int clerkType = clerkDTO.getClerkType();
String clerkId = clerkDTO.getClerkId();
String storeId = "";
if (clerkType == 0 || clerkType == 1) {
storeId = clerkDTO.getStoreId();
}
params.setClerkType(clerkType + "");
params.setSearchParams("");
params.setStoreId(storeId);
params.setClerkId(clerkId);
params.setEnterpriseId(enterpriseId);
ContactParamDTO contact = new ContactParamDTO();
// 搜索信息
MemberInfoListParamsDTO memberInfoListParamsDTO = com.gic.haoban.common.utils.StringUtil.getBean("{}", MemberInfoListParamsDTO.class);
memberInfoListParamsDTO.setMemberId(memberId);
contact.setContactType(0);
params.setContactParamDTO(contact);
ServiceResponse<ContactSumDTO> noContactResponse = customerApiService.contactMemberSum(new BasePageInfo(), params, memberInfoListParamsDTO);
if (noContactResponse.isSuccess() && noContactResponse.getResult() != null) {
if (noContactResponse.getResult().getTotalCount() > 0) {
return true;
}
}
contact.setContactType(1);
params.setContactParamDTO(contact);
ServiceResponse<ContactSumDTO> contactResponse = customerApiService.contactMemberSum(new BasePageInfo(), params, memberInfoListParamsDTO);
if (contactResponse.isSuccess() && contactResponse.getResult() != null) {
if (contactResponse.getResult().getTotalCount() > 0) {
return true;
}
}
return false;
}
@Override
public void saveContactLog(ContactLogQDTO qdto) throws BusinessException {
public TabContactLog saveContactLog(ContactLogQDTO qdto) throws BusinessException {
logger.info("保存建联记录:{}", JSON.toJSONString(qdto));
String enterpriseId = qdto.getEnterpriseId();
String storeId = qdto.getStoreId();
String clerkId = qdto.getClerkId();
String memberId = qdto.getMemberId();
Integer contactAutoType = qdto.getContactAutoType();
DateTime date = DateUtil.date();
MemberStoreClerkDTO memberStoreClerk = memberService.getMemberStoreClerk(memberId);
if (memberStoreClerk == null) {
......@@ -70,6 +128,15 @@ public class ContactLogServiceImpl implements ContactLogService {
logger.info("非专属导购无法建联");
throw new BusinessException("-1", "非专属导购无法建联");
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
// 自动建联校验
if (contactAutoType != null) {
boolean contactCheck = contactCheck(enterpriseId, memberId, clerkDTO);
logger.info("非潜客未建联或建联未转化:{}",contactCheck);
if (!contactCheck) {
throw new BusinessException("-1", "非潜客未建联或建联未转化,无法建联");
}
}
// 是否周期内首次建联 同周期内是否有记录
Integer contactCycle = 1;
// 建联周期 14天内同周期/14天以上周期+1
......@@ -87,7 +154,6 @@ public class ContactLogServiceImpl implements ContactLogService {
logger.info("建联周期:{},是否周期内首次:{}", contactCycle, contactCycleFirst);
TabContactLog contactLog = new TabContactLog();
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
contactLog.setClerkId(clerkId);
contactLog.setStoreId(storeId);
if (clerkDTO != null) {
......@@ -113,6 +179,42 @@ public class ContactLogServiceImpl implements ContactLogService {
// 刷新es建联时间
Long clerkContactTime = Long.parseLong(DateUtil.format(date, DatePattern.PURE_DATETIME_PATTERN));
refreshContactTime(enterpriseId, memberId, clerkContactTime);
return contactLog;
}
@Override
public void autoContactLog(ContactLogQDTO qdto) {
if (qdto == null) {
return;
}
String enterpriseId = qdto.getEnterpriseId();
Integer contactAutoType = qdto.getContactAutoType();
ContactConfigDTO contactConfig = contactConfigService.getContactConfig(enterpriseId);
if (contactConfig == null) {
return;
}
List<Integer> contactAutoList = contactConfig.getContactAutoList();
if (CollectionUtils.isEmpty(contactAutoList) || !contactAutoList.contains(contactAutoType)) {
logger.info("无法自动建联:{},{}", contactAutoType, contactAutoList);
return;
}
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(contactLog.getCreateTime());
followQDTO.setEnterpriseId(enterpriseId);
contactFollowService.saveFollow(followQDTO);
} catch (BusinessException e) {
logger.info("自动建联异常:{}", e.getMessage());
return;
}
}
@Override
......
package com.gic.haoban.manage.service.service.out.impl.contact;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.api.service.contact.ContactConfigApiService;
import com.gic.haoban.manage.service.service.contact.ContactConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("contactConfigApiService")
public class ContactConfigApiServiceImpl implements ContactConfigApiService {
@Autowired
private ContactConfigService contactConfigService;
@Override
public ServiceResponse<Void> saveContactConfig(ContactConfigDTO contactConfig) {
contactConfigService.saveContactConfig(contactConfig);
return ServiceResponse.success();
}
@Override
public ServiceResponse<ContactConfigDTO> getContactConfig(String enterpriseId) {
ContactConfigDTO config = contactConfigService.getContactConfig(enterpriseId);
return ServiceResponse.success(config);
}
}
......@@ -2,12 +2,14 @@ package com.gic.haoban.manage.service.service.out.impl.contact;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Constant;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowBatchQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
......@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......
package com.gic.haoban.manage.service.service.out.impl.contact;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BusinessException;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
......@@ -8,6 +9,7 @@ import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.api.service.contact.ContactLogApiService;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import com.gic.haoban.manage.service.service.contact.ContactLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -37,4 +39,13 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> autoContactLogForMQ(String message) {
if (StringUtils.isBlank(message)) {
return ServiceResponse.success();
}
ContactLogQDTO contactLogQDTO = JSONObject.parseObject(message, ContactLogQDTO.class);
contactLogService.autoContactLog(contactLogQDTO);
return ServiceResponse.success();
}
}
......@@ -147,6 +147,7 @@
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactFollowApiService" ref="contactFollowApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactLogApiService" ref="contactLogApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactOrderApiService" ref="contactOrderApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactConfigApiService" ref="contactConfigApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.send.QwSendApiService" ref="qwSendApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.contact.TabContactConfigMapper">
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.contact.TabContactConfig">
<id column="config_id" property="configId" />
<result column="contact_auto" property="contactAuto" />
<result column="remark_flag" property="remarkFlag" />
<result column="remark_content" property="remarkContent" />
<result column="enterprise_id" property="enterpriseId" />
<result column="delete_flag" property="deleteFlag" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
config_id, contact_auto, remark_flag, remark_content, enterprise_id, delete_flag, create_time, update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM tab_contact_config
WHERE config_id = #{configId}
</select>
<select id="queryByEnterpriseId" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM tab_contact_config
WHERE enterprise_id = #{enterpriseId}
AND delete_flag = 0
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="configId">
INSERT INTO tab_contact_config (
config_id, contact_auto, remark_flag, remark_content, enterprise_id
)
VALUES (
#{configId}, #{contactAuto}, #{remarkFlag}, #{remarkContent}, #{enterpriseId}
)
</insert>
<insert id="insertBatch">
INSERT INTO tab_contact_config (
config_id, contact_auto, remark_flag, remark_content, enterprise_id, delete_flag, create_time, update_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.configId}, #{item.contactAuto}, #{item.remarkFlag}, #{item.remarkContent}, #{item.enterpriseId}, #{item.deleteFlag}, #{item.createTime}, #{item.updateTime})
</foreach>
</insert>
<update id="update">
UPDATE tab_contact_config
<set>
<if test="contactAuto != null">contact_auto = #{contactAuto},</if>
<if test="remarkFlag != null">remark_flag = #{remarkFlag},</if>
<if test="remarkContent != null">remark_content = #{remarkContent},</if>
</set>
WHERE config_id = #{configId}
</update>
<delete id="deleteById">
DELETE FROM tab_contact_config
WHERE config_id = #{configId}
</delete>
</mapper>
\ No newline at end of file
......@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
......@@ -13,6 +14,7 @@ import com.gic.haoban.manage.api.qdto.contact.ContactOrderQDTO;
import com.gic.haoban.manage.api.service.contact.ContactOrderApiService;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO;
import com.gic.haoban.manage.service.pojo.bo.potential.MemberLastInteractBO;
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.contact.ContactOrderService;
......@@ -39,6 +41,8 @@ public class ContactTest {
@Autowired
private ContactLogService contactLogService;
@Autowired
private ContactConfigService contactConfigService;
@Autowired
private ContactOrderApiService contactOrderApiService;
@Autowired
private InteractRecordService interactRecordService;
......@@ -129,4 +133,17 @@ public class ContactTest {
orderQDTO.setOnlineOrder(true);
contactOrderApiService.saveContactOrder(orderQDTO);
}
@Test
public void saveContactConfig() throws Exception {
ContactConfigDTO contactConfigDTO = new ContactConfigDTO();
contactConfigDTO.setRemarkFlag(1);
contactConfigDTO.setEnterpriseId(eid);
contactConfigDTO.setContactAutoList(Lists.newArrayList(10,20,30));
contactConfigDTO.setRemarkContentList(Lists.newArrayList("微信邀约了客户","电话邀约了客户"));
contactConfigService.saveContactConfig(contactConfigDTO);
ContactConfigDTO contactConfig = contactConfigService.getContactConfig(eid);
System.out.println(JSON.toJSONString(contactConfig));
}
}
package com.gic.haoban.manage.web.controller.contact;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.api.service.contact.ContactConfigApiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* 建联配置
*/
@RestController
@RequestMapping("/contact")
public class ContactController {
private static Logger logger = LogManager.getLogger(ContactController.class);
@Autowired
private ContactConfigApiService contactConfigApiService;
/**
* 建联配置
*
* @return RestResponse
*/
@RequestMapping("get")
@ResponseBody
public RestResponse<ContactConfigDTO> get() {
WebLoginDTO user = AuthWebRequestUtil.getLoginUser();
ServiceResponse<ContactConfigDTO> response = contactConfigApiService.getContactConfig(user.getEnterpriseId());
if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage());
}
return RestResponse.successResult(response.getResult());
}
/**
* 保存建联配置
*
* @return RestResponse
*/
@RequestMapping("save")
@ResponseBody
public RestResponse<Void> save(@RequestBody ContactConfigDTO configDTO) {
WebLoginDTO user = AuthWebRequestUtil.getLoginUser();
configDTO.setEnterpriseId(user.getEnterpriseId());
ServiceResponse<Void> response = contactConfigApiService.saveContactConfig(configDTO);
if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage());
}
return RestResponse.successResult();
}
}
......@@ -144,6 +144,7 @@
<dubbo:reference id="appOrderApiService" interface="com.gic.haoban.manage.api.service.licence.AppOrderApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference id="couponCardService" interface="com.gic.marketing.api.service.CouponCardService" timeout="100000" retries="0" check="false" />
<dubbo:reference id="qwMomentApiService" interface="com.gic.haoban.manage.api.service.moment.QwMomentApiService" timeout="100000" retries="0" check="false" />
<dubbo:reference id="contactConfigApiService" interface="com.gic.haoban.manage.api.service.contact.ContactConfigApiService" timeout="10000" retries="0" check="false" />
</beans>
......@@ -7,10 +7,12 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.manage.api.dto.contact.ContactConfigDTO;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.api.service.contact.ContactConfigApiService;
import com.gic.haoban.manage.api.service.contact.ContactFollowApiService;
import com.gic.haoban.manage.api.service.contact.ContactLogApiService;
import com.gic.haoban.manage.web.qo.contact.ContactFollowPageQO;
......@@ -40,6 +42,8 @@ public class ContactController {
private ContactFollowApiService contactFollowApiService;
@Autowired
private ContactLogApiService contactLogApiService;
@Autowired
private ContactConfigApiService contactConfigApiService;
/**
* 添加跟进记录
......@@ -124,4 +128,18 @@ public class ContactController {
return RestResponse.successResult();
}
/**
* 建联配置
* @param enterpriseId
* @return
*/
@RequestMapping(path = "/config")
public RestResponse<ContactConfigDTO> config(String enterpriseId) {
ServiceResponse<ContactConfigDTO> serviceResponse = contactConfigApiService.getContactConfig(enterpriseId);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
return RestResponse.successResult(serviceResponse.getResult());
}
}
......@@ -18,7 +18,7 @@ public class ContactFollowQO {
private String clerkId;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
......
......@@ -141,6 +141,7 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.contact.ContactFollowApiService" id="contactFollowApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.contact.ContactLogApiService" id="contactLogApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.contact.ContactOrderApiService" id="contactOrderApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.contact.ContactConfigApiService" id="contactConfigApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.content.PotentialCustomerApiService" id="potentialCustomerApiService" timeout="100000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.content.InteractRecordApiService" id="interactRecordApiService" timeout="100000" retries="0" check="false" />
......
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