Commit 213c70c0 by 徐高华

Merge branch 'master' into feature/xgh/202506迭代

# Conflicts:
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
parents bcfb3d40 6c34cd98
package com.gic.haoban.manage.api.constants;
import java.util.Date;
/**
* @author mozhu
* @date 2022/4/19 15:12
......@@ -25,4 +27,15 @@ public class Manage3Constants {
* 企微最大分页
*/
public static final Integer QW_LIMIT = 1000;
/**
* 建联未转化限制时间天数
*/
public static final Integer CONTACT_ORDER_LIMIT_DAY = 30;
/**
* 建联未转化时间调整发布时间
*/
public static final Date CONTACT_FIX_RELEASE_DATE = new Date("2025/06/18 23:00:00");
}
......@@ -45,8 +45,19 @@ public class MaterialDTO implements Serializable{
//appid link路径 img_url 封面图 materialTitle
private String appId;
// 小程序卡片时,小程序的头像
private String headImg ;
private static final long serialVersionUID = 1L;
public String getHeadImg() {
return headImg;
}
public void setHeadImg(String headImg) {
this.headImg = headImg;
}
public String getMediaid() {
return mediaid;
}
......
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;
......
......@@ -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.dto.send;
import com.gic.haoban.manage.api.dto.anaylsis.ClerkShareGoodsLogDTO;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created by wangzubo on 2025/3/25.
......@@ -60,6 +63,11 @@ public class DealQwSendDTO implements Serializable {
*/
private String enterpriseId;
/**
* 商品分享信息
*/
private List<ClerkShareGoodsLogDTO> shareGoodsList;
public FinishQwSendBO() {
}
......@@ -119,6 +127,14 @@ public class DealQwSendDTO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public List<ClerkShareGoodsLogDTO> getShareGoodsList() {
return shareGoodsList;
}
public void setShareGoodsList(List<ClerkShareGoodsLogDTO> shareGoodsList) {
this.shareGoodsList = shareGoodsList;
}
}
public static class QwSendMsgBO implements Serializable {
......
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
package com.gic.haoban.manage.api.enums.contact;
import cn.hutool.core.date.DateUtil;
import com.gic.haoban.manage.api.dto.contact.ContactLogDTO;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
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);
}
public static List<Long> getEsClerkContactTimeList(List<ContactLogDTO> list) {
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
list = list.stream().sorted(Comparator.comparing(ContactLogDTO::getBizType))
.collect(Collectors.toList());
List<Long> clerkContactTimeList = Lists.newArrayList();
Long maxContactTime = null;
for (ContactLogDTO contactLogDTO : list) {
Date contactTime = contactLogDTO.getContactTime();
ContactBizTypeEnum bizTypeEnum = ContactBizTypeEnum.fromType(contactLogDTO.getBizType());
Long orginalContactTimeLong = Long.parseLong(DateUtil.format(contactTime, "yyyyMMddHHmmss"));
Long contactTimeLong = bizTypeEnum.getEsClerkContactTime(orginalContactTimeLong);
clerkContactTimeList.add(contactTimeLong);
if (maxContactTime == null || orginalContactTimeLong > maxContactTime) {
maxContactTime = orginalContactTimeLong;
}
}
if (maxContactTime != null) {
clerkContactTimeList.add(maxContactTime);
}
return clerkContactTimeList;
}
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
......@@ -4,20 +4,28 @@ import org.apache.commons.lang3.StringUtils;
public enum ContactFollowTypeEnum {
PRIVATE_PHONE(1, "私人电话","私人电话"),
WECHAT_SESSION(2, "企微会话","企微会话"),
PRODUCT(3, "发送商品","商品"),
WECHAT_GROUP_SEND(4, "企微群发","企微群发"),
CONTACT(5, "标记建联","标记了建联");
// 跟进表中不会有这两个类型
SMS(-1, "短信/彩信","系统向客户发送了营销短信/彩信",null),
AI(-2, "AI电话","客户接听了AI电话",null),
PRIVATE_PHONE(1, "私人电话","私人电话",null),
WECHAT_SESSION(2, "企微会话","企微会话",null),
PRODUCT(3, "发送商品","商品",ContactAutoTypeEnum.GOODS_RECOMMEND.getCode()),
WECHAT_GROUP_SEND(4, "企微群发","企微群发",null),
CONTACT(5, "标记建联","标记了建联",null),
AUTO_CONTACT(6, "系统自动标记","系统自动标记",null),
MATERIAL(7, "营销素材","营销素材",ContactAutoTypeEnum.MATERIAL.getCode());
private final int code;
private final String description;
private final String textMatch;
private final Integer contactAutoType;
ContactFollowTypeEnum(int code, String description,String textMatch) {
ContactFollowTypeEnum(int code, String description,String textMatch,Integer contactAutoType) {
this.code = code;
this.description = description;
this.textMatch = textMatch;
this.contactAutoType = contactAutoType;
}
public String getTextMatch() {
......@@ -32,6 +40,10 @@ public enum ContactFollowTypeEnum {
return description;
}
public Integer getContactAutoType() {
return contactAutoType;
}
public static ContactFollowTypeEnum fromCode(int code) {
for (ContactFollowTypeEnum type : values()) {
if (type.code == code) {
......
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;
......@@ -21,15 +23,36 @@ 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;
/**
* 业务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;
/**
* 跟进记录
*/
private String followRemark;
/**
* 关联商品信息
*/
private List<String> goodsInfoList;
public String getEnterpriseId() {
return enterpriseId;
}
......@@ -62,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;
}
......@@ -70,6 +117,14 @@ public class ContactFollowBatchQDTO implements Serializable {
this.followRemark = followRemark;
}
public List<String> getGoodsInfoList() {
return goodsInfoList;
}
public void setGoodsInfoList(List<String> goodsInfoList) {
this.goodsInfoList = goodsInfoList;
}
public static class MemberFollow implements Serializable{
/**
......@@ -78,6 +133,11 @@ public class ContactFollowBatchQDTO implements Serializable {
private String memberId;
/**
* 外部联系人id
*/
private String externalUserId;
/**
* 跟进时间
*/
private Date followTime;
......@@ -90,6 +150,12 @@ public class ContactFollowBatchQDTO implements Serializable {
this.followTime = followTime;
}
public MemberFollow(String memberId, String externalUserId, Date followTime) {
this.memberId = memberId;
this.externalUserId = externalUserId;
this.followTime = followTime;
}
public String getMemberId() {
return memberId;
}
......@@ -98,6 +164,14 @@ public class ContactFollowBatchQDTO implements Serializable {
this.memberId = memberId;
}
public String getExternalUserId() {
return externalUserId;
}
public void setExternalUserId(String externalUserId) {
this.externalUserId = externalUserId;
}
public Date getFollowTime() {
return followTime;
}
......
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;
......@@ -19,10 +21,28 @@ 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;
/**
* 业务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;
}
......
package com.gic.haoban.manage.api.qdto.contact;
import java.io.Serializable;
public class ContactLogCheckQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
/**
* 会员id
*/
private String memberId;
/**
* 导购id
*/
private String clerkId;
/**
* 企业id
*/
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;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getEnterpriseId() {
return enterpriseId;
}
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.Date;
import java.util.List;
public class ContactLogQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -22,6 +27,64 @@ 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;
/**
* 是否同步建联
*/
private Integer syncContactType;
/**
* 同步建联时间
*/
private Date syncContactTime;
/**
* 业务类型 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() {
}
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 +116,76 @@ public class ContactLogQDTO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
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;
}
public void setContactAutoType(Integer contactAutoType) {
this.contactAutoType = contactAutoType;
}
public Integer getSyncContactType() {
return syncContactType;
}
public void setSyncContactType(Integer syncContactType) {
this.syncContactType = syncContactType;
}
public Date getSyncContactTime() {
return syncContactTime;
}
public void setSyncContactTime(Date syncContactTime) {
this.syncContactTime = syncContactTime;
}
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
......@@ -157,4 +157,10 @@ public interface HaobanTimerApiService {
* @param params
*/
void contactDataTimer(String params);
/**
* 企业微信应用过期提醒
* @param params
*/
void qywxAppOverTimer(String params) ;
}
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);
}
......@@ -2,8 +2,11 @@ package com.gic.haoban.manage.api.service.contact;
import com.gic.api.base.commons.ServiceResponse;
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 {
/**
......@@ -11,13 +14,37 @@ public interface ContactLogApiService {
* @param memberId
* @return
*/
@Deprecated
ServiceResponse<ContactLogDTO> getClerkContactTime(String memberId);
/**
* 获取每个业务最近一条有效建联记录
* @param memberId
* @return
*/
ServiceResponse<List<ContactLogDTO>> getClerkContactTimeList(String memberId);
/**
* 保存建联记录
* @param qdto
* @return
*/
ServiceResponse<Void> saveContactLog(ContactLogQDTO qdto);
/**
* 消息队列异步自动建联
* @param message
* @return
*/
ServiceResponse<Void> autoContactLogForMQ(String message);
/**
* 是否可以建联校验
* @param checkQDTO
* @return
*/
ServiceResponse<Boolean> contactCheck(ContactLogCheckQDTO checkQDTO) ;
}
<?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>
......@@ -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>
......@@ -142,6 +148,12 @@
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-marketing-pro-api</artifactId>
<version>${gic-marketing-pro-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-app-customer-api</artifactId>
<version>${haoban-app-customer-api}</version>
</dependency>
......
......@@ -10,8 +10,10 @@ import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.stats.CacheStats;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -28,9 +30,7 @@ import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
/**
* Created by wangzubo on 2024/10/27.
......@@ -42,14 +42,15 @@ public class ImageCombined {
private static final Logger logger = LoggerFactory.getLogger(ImageCombined.class);
private static final Cache<String, BufferedImage> imageCache = Caffeine.newBuilder()
.maximumWeight(200 * 1024 * 1024) // 100MB
.weigher((String key, BufferedImage image) -> image.getWidth() * image.getHeight() * 3)
.maximumWeight(300 * 1024 * 1024) // 100MB
.weigher((String key, BufferedImage image) -> image.getWidth() * image.getHeight() * 4)
.removalListener((key, value, cause) -> {
logger.info("移除缓存:{}",key);
if (value != null) {
value.flush();
}
})
.recordStats()
.expireAfterAccess(10, TimeUnit.MINUTES) // 可设置失效时间
.build();
......@@ -58,10 +59,12 @@ public class ImageCombined {
ApolloUtils.combinedMaximumPoolSize(),
60L,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(40),
new ArrayBlockingQueue<>(20),
new ThreadPoolExecutor.AbortPolicy()
);
private static final ScheduledExecutorService CACHE_STAT_SCHEDULER = Executors.newScheduledThreadPool(1);
private static void refreshThreadPool(ConfigChangeEvent changeEvent) {
if (!StringUtils.equals(changeEvent.getNamespace(), APPLICATION)) {
return;
......@@ -99,10 +102,19 @@ public class ImageCombined {
ImageIO.scanForPlugins(); // 初始化图像插件
Config config = ConfigService.getAppConfig();
config.addChangeListener(ImageCombined::refreshThreadPool);
CACHE_STAT_SCHEDULER.scheduleAtFixedRate(() -> {
CacheStats stats = imageCache.stats();
logger.info("【加载图片缓存统计】请求数: {}, 命中: {}, 未命中: {}, 命中率: {}%",
stats.requestCount(),
stats.hitCount(),
stats.missCount(),
String.format("%.2f", stats.hitRate() * 100));
}, 10, 10, TimeUnit.MINUTES);
}
public static void main(String[] args) throws Exception{
BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL);
BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL,"");
BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL));
int showStyle = 0;
......@@ -112,6 +124,7 @@ public class ImageCombined {
}
public static byte[] getCombinedImage(CombinedQDTO combinedQDTO) throws Exception{
String enterpriseId = combinedQDTO.getEnterpriseId();
String imageUrl = combinedQDTO.getImageUrl();
String qrCodeUrl = combinedQDTO.getQrCodeUrl();
Integer showStyle = combinedQDTO.getShowStyle();
......@@ -124,7 +137,7 @@ public class ImageCombined {
//压缩图片的参数
imageUrl = imageUrl + "?imageView2/2/w/1080/h/10800/format/jpg";
logger.info("加载要合成的图片开始1");
BufferedImage largeImage = loadImageWithCache(imageUrl);
BufferedImage largeImage = loadImageWithCache(imageUrl,enterpriseId);
logger.info("加载要合成的图片开始2");
BufferedImage qrCodeImage = loadImageWithReader(qrCodeUrl);
logger.info("加载要合成的图片结束");
......@@ -170,8 +183,8 @@ public class ImageCombined {
/**
* 从缓存中加载图像
*/
private static BufferedImage loadImageWithCache(String url) {
boolean useCache = ApolloUtils.combinedCache();
private static BufferedImage loadImageWithCache(String url,String enterpriseId) {
boolean useCache = ApolloUtils.combinedCache(enterpriseId);
if (!useCache) {
logger.info("非缓存加载图片:{}", url);
return loadImageWithReader(url);
......
......@@ -88,5 +88,13 @@ public interface TabHaobanAppOrderMapper {
*/
TabHaobanAppOrder queryByOrderId(@Param("orderId")String orderId);
/**
* 查询有效订单
* @param wxEnterpriseId
* @return
*/
List<TabHaobanAppOrder> listOrderForNotice(@Param("wxEnterpriseId")String wxEnterpriseId) ;
}
......@@ -96,4 +96,10 @@ public interface WxEnterpriseMapper {
List<String> listWxEnterpriseByCallbackFlag(@Param("callbackFlag")Integer callbackFlag);
List<String> getWxEnterpriseIdByName(@Param("corpName")String corpName);
/**
* 查询所有非自建的
* @return
*/
List<TabHaobanWxEnterprise> listAllNotSelf() ;
}
\ No newline at end of file
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
......@@ -3,8 +3,10 @@ package com.gic.haoban.manage.service.dao.mapper.contact;
import com.gic.haoban.manage.api.qdto.chat.GroupChatActivitySearchQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactFollow;
import com.gic.haoban.manage.service.pojo.bo.contact.listFollowCheckBO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
......@@ -31,6 +33,8 @@ public interface TabContactFollowMapper {
List<TabContactFollow> pageFollow(@Param("enterpriseId") String enterpriseId,
@Param("search") ContactFollowSearchQDTO searchQDTO);
List<String> listFollowCheck(@Param("enterpriseId") String enterpriseId,
@Param("list")List<listFollowCheckBO> list);
/**
* 通过memberId查询最后一次跟进记录
* @param enterpriseId
......@@ -50,6 +54,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);
/**
* 统计总行数
......
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;
......@@ -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,36 @@ public class TabContactLog implements Serializable {
* 成为潜客时间
*/
private Date potentialTime;
/**
* 潜客分
*/
private Integer potentialScore;
/**
* 来源日志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 +202,54 @@ public class TabContactLog implements Serializable {
this.potentialTime = potentialTime;
}
public Integer getPotentialScore() {
return potentialScore;
}
public void setPotentialScore(Integer potentialScore) {
this.potentialScore = potentialScore;
}
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,19 @@ public class TabContactOrder implements Serializable {
*/
private Integer potentialScore;
/**
* 金字塔分层信息
*/
private String groupInfo;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 是否删除
*/
private Integer deleteFlag;
......@@ -256,6 +269,30 @@ public class TabContactOrder implements Serializable {
this.potentialScore = potentialScore;
}
public String getGroupInfo() {
return groupInfo;
}
public void setGroupInfo(String groupInfo) {
this.groupInfo = groupInfo;
}
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;
}
......
package com.gic.haoban.manage.service.pojo.bo.contact;
import java.io.Serializable;
import java.util.Date;
public class listFollowCheckBO implements Serializable {
private static final long serialVersionUID = 973688857967269974L;
/**
* 会员id
*/
private String memberId;
/**
* 导购id
*/
private String clerkId;
/**
* 互动时间
*/
private Date followTime;
public listFollowCheckBO() {
}
public listFollowCheckBO(String memberId, String clerkId, Date followTime) {
this.memberId = memberId;
this.clerkId = clerkId;
this.followTime = followTime;
}
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public Date getFollowTime() {
return followTime;
}
public void setFollowTime(Date followTime) {
this.followTime = followTime;
}
}
\ No newline at end of file
......@@ -355,7 +355,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Override
public void doPlan(Long planId) {
logger.info("开始群群发发送{}", planId);
DingUtils.send("开始群群发发送,planId=" + planId + ",tranceid=" + ProviderLocalTag.tag.get().traceId, false);
//DingUtils.send("开始群群发发送,planId=" + planId + ",tranceid=" + ProviderLocalTag.tag.get().traceId, false);
TabGroupChatPlan plan = this.groupChatPlanMapper.selectById(planId);
if (null == plan) {
logger.info("计划不存在,planid={}", planId);
......@@ -524,7 +524,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Override
public void doPlanSendInfoTimer(String params) {
DingUtils.send("开始群群发统计(定时),params=" + params + ",tranceid=" + ProviderLocalTag.tag.get().traceId, false);
// DingUtils.send("开始群群发统计(定时),params=" + params + ",tranceid=" + ProviderLocalTag.tag.get().traceId, false);
Long planId = Long.parseLong(params);
List<Long> idList = this.groupChatPlanOwnerLogService.listForTimer(planId);
logger.info("定时处理群发结果,条数={}", idList.size());
......@@ -908,19 +908,26 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
Date startTime = DateUtil.addNumForSecond(sendTime,-30) ;
Date endTime = DateUtil.addNumForMinute(sendTime,2) ;
TabHaobanStaff staff = this.staffMapper.selectByPrimaryKey(staffId) ;
if(null == staff) {
return null ;
}
String wxEnterpriseId = staff.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
String wxUserId = staff.getWxUserId() ;
if(qwDTO.needOpenUserId3th()) {
wxUserId = staff.getWxOpenUseId() ;
}
Long sendTimeSec = sendTime.getTime() / 1000;
// 发送到群
List<QywxGroupMessageInfoDTO> msgList = this.queryGroupMsg(groupMsgChatType,startTime, endTime, qwDTO, wxUserId);
if(CollectionUtils.isNotEmpty(msgList)) {
if(msgList.size()==0) {
return msgList.get(0).getMsgId() ;
}else {
return msgList.get(msgList.size()-1).getMsgId() ;
return msgList.stream()
.min(Comparator.comparingLong(msg -> Math.abs(msg.getCreateTime() - sendTimeSec)))
.map(QywxGroupMessageInfoDTO::getMsgId)
.orElse(null);
}
}
return null ;
......
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);
}
package com.gic.haoban.manage.service.service.contact;
import com.gic.api.base.commons.BusinessException;
import com.gic.clerk.api.dto.ClerkDTO;
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 {
/**
* 是否可以建联判断
* @param enterpriseId
* @param memberId
* @param clerkDTO
* @return
*/
Integer contactCheck(String enterpriseId, String memberId, ClerkDTO clerkDTO,Integer bizType) ;
/**
* 保存建联记录
......@@ -17,12 +28,24 @@ public interface ContactLogService {
void saveContactLog(ContactLogQDTO qdto) throws BusinessException;
/**
* 自动建联
* @param qdto
*/
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);
/**
* 获取最近一条有效建联记录
......@@ -33,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);
}
......@@ -23,6 +23,7 @@ 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.common.utils.DateUtil;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.content.holo.HoloDataSource;
import com.gic.haoban.manage.service.pojo.bo.contact.ContactDataBO;
import com.gic.store.goods.dto.potential.PlatformPotentialCustomerOutDTO;
......@@ -178,6 +179,7 @@ public class ContactAdaptor {
ContactParamDTO contact = new ContactParamDTO();
contact.setRuleJSON(JSON.toJSONString(result));
contact.setContactType(0);
contact.setBizType(ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType());
params.setStoreId(storeId);
params.setClerkId(clerkId);
params.setClerkType(clerkTypeStr);
......
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;
}
}
package com.gic.haoban.manage.service.service.contact.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.BasePageInfo;
......@@ -8,16 +10,23 @@ 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.PageHelperUtils;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.dto.contact.ContactFollowGoodsDTO;
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.ContactFollowSearchQDTO;
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.entity.contact.TabContactFollow;
import com.gic.haoban.manage.service.pojo.bo.contact.listFollowCheckBO;
import com.gic.haoban.manage.service.service.contact.ContactFollowService;
import com.gic.marketing.api.dto.member.MemberSmsLogDTO;
import com.gic.marketing.api.service.SmsService;
import com.gic.marketing.pro.api.dto.ai.AiMemberLogListDTO;
import com.gic.marketing.pro.api.service.ai.AiMemberLogApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.store.goods.service.StoreGoodsService;
import com.gic.store.goods.vo.StoreGoodsVO;
import com.github.pagehelper.PageHelper;
......@@ -38,12 +47,18 @@ public class ContactFollowServiceImpl implements ContactFollowService {
private static final Logger logger = LogManager.getLogger(ContactFollowService.class);
private static final List<Integer> aiThirdStatus = Lists.newArrayList(0, 1, 6, 8);
@Autowired
private TabContactFollowMapper contactFollowMapper;
@Autowired
private StoreGoodsService storeGoodsService;
@Autowired
private ClerkService clerkService;
@Autowired
private AiMemberLogApiService aiMemberLogApiService;
@Autowired
private SmsService smsService;
@Override
public void saveFollow(ContactFollowQDTO qdto) {
......@@ -60,6 +75,7 @@ public class ContactFollowServiceImpl implements ContactFollowService {
if (CollectionUtils.isEmpty(clerks)) {
return;
}
String enterpriseId = list.get(0).getEnterpriseId();
Map<String, ClerkDTO> clerkMap = clerks.stream().collect(Collectors.toMap(ClerkDTO::getClerkId, Function.identity(), (v1, v2) -> v1));
List<TabContactFollow> followList = list.stream().map(follow -> {
TabContactFollow contactFollow = EntityUtil.changeEntityNew(TabContactFollow.class, follow);
......@@ -76,36 +92,197 @@ public class ContactFollowServiceImpl implements ContactFollowService {
contactFollow.setGoodsInfo(JSON.toJSONString(follow.getGoodsInfoList()));
}
// 兼容不传followType的老版本
Integer followType = contactFollow.getFollowType();
if (followType == null) {
Integer followTypeOld = contactFollow.getFollowType();
if (followTypeOld == null) {
ContactFollowTypeEnum followTypeEnum = ContactFollowTypeEnum.fromTextMatch(contactFollow.getFollowRemark());
followType = Optional.ofNullable(followTypeEnum).map(ContactFollowTypeEnum::getCode).orElse(ContactFollowTypeEnum.CONTACT.getCode());
contactFollow.setFollowType(followType);
followTypeOld = Optional.ofNullable(followTypeEnum).map(ContactFollowTypeEnum::getCode).orElse(ContactFollowTypeEnum.CONTACT.getCode());
contactFollow.setFollowType(followTypeOld);
}
return contactFollow;
}).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isEmpty(followList)) {
return;
}
Integer followType = followList.get(0).getFollowType();
logger.info("跟进类型:{}", followType);
// 解决企微群发重复调用问题
if (Objects.equals(followType, ContactFollowTypeEnum.WECHAT_GROUP_SEND.getCode())) {
logger.info("企微群发重复调用校验");
List<listFollowCheckBO> checkList = followList.stream().map(x -> new listFollowCheckBO(x.getMemberId(), x.getClerkId(), x.getFollowTime())).collect(Collectors.toList());
List<String> checkMemberIdList = contactFollowMapper.listFollowCheck(enterpriseId, checkList);
logger.info("企微群发重复调用:{}",JSON.toJSONString(checkMemberIdList));
if (CollectionUtils.isNotEmpty(checkMemberIdList)) {
followList = followList.stream().filter(x -> !checkMemberIdList.contains(x.getMemberId())).collect(Collectors.toList());
}
}
if (CollectionUtils.isEmpty(followList)) {
return;
}
contactFollowMapper.insertBatch(followList);
// 部分跟进发送自动建联
autoContactSend(followList);
}
private void autoContactSend(List<TabContactFollow> followList) {
// 自动建联
Integer followType = followList.get(0).getFollowType();
Integer contactAutoType = ContactFollowTypeEnum.fromCode(followType).getContactAutoType();
if (contactAutoType != null) {
List<String> message = followList.stream().map(x -> {
ContactLogQDTO contactLogQDTO = new ContactLogQDTO();
contactLogQDTO.setMemberId(x.getMemberId());
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";
try {
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
clientInstance.sendBatchMessages(routerName, message);
} catch (Exception e) {
logger.error("发送错误!路由规则名称:" + routerName + ",message:" + message,e);
}
message.clear();
}
}
@Override
public Page<ContactFollowDTO> pageFollow(String enterpriseId, ContactFollowSearchQDTO searchQDTO, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabContactFollow> list = contactFollowMapper.pageFollow(enterpriseId, searchQDTO);
Page<ContactFollowDTO> page = PageHelperUtils.changePageHelperToCurrentPage(list,ContactFollowDTO.class);
List<ContactFollowDTO> pageList = convertExtInfo(list);
List<ContactFollowDTO> list = queryMarketingFollowLog(enterpriseId, searchQDTO, pageInfo);
Page<ContactFollowDTO> page = new Page<>();
if (list == null || list.isEmpty()) {
page.setCurrentPage(pageInfo.getPageNum());
page.setPageSize(pageInfo.getPageSize());
page.setTotalCount(0);
page.setTotalPage(1);
page.setResult(Collections.emptyList());
return page;
}
int totalCount = 500;
int pageSize = pageInfo.getPageSize();
int pageNum = pageInfo.getPageNum();
int totalPage = (int) Math.ceil((double) totalCount / pageSize);
int fromIndex = Math.max((pageNum - 1) * pageSize, 0);
fromIndex = Math.min(fromIndex, list.size());
int toIndex = Math.min(fromIndex + pageSize, totalCount);
toIndex = Math.min(toIndex, list.size());
List<ContactFollowDTO> pageList = list.subList(fromIndex, toIndex);
page.setCurrentPage(pageNum);
page.setPageSize(pageSize);
page.setTotalCount(totalCount);
page.setTotalPage(totalPage);
page.setResult(pageList);
return page;
}
private List<ContactFollowDTO> queryMarketingFollowLog(String enterpriseId, ContactFollowSearchQDTO searchQDTO, BasePageInfo pageInfo) {
List<ContactFollowDTO> list = new ArrayList<>();
ContactFollowDTO followDTO = null;
Integer maxSize = 500;
int sizeTotal = pageInfo.getPageNum() * pageInfo.getPageSize();
sizeTotal = Math.min(sizeTotal, maxSize);
String memberId = searchQDTO.getMemberId();
Date date = DateUtil.date();
DateTime startTime = DateUtil.offsetMonth(date, -6);
BasePageInfo basePage = new BasePageInfo();
basePage.setPageNum(1);
basePage.setPageSize(sizeTotal);
ServiceResponse<Page<AiMemberLogListDTO>> aiRes = aiMemberLogApiService.pageAiMemberMarketingLog(memberId, "", aiThirdStatus,
DateUtil.formatDate(startTime), DateUtil.formatDate(date), new HashMap<>(), basePage);
if (aiRes != null && aiRes.getResult() != null && CollectionUtils.isNotEmpty(aiRes.getResult().getResult())) {
convertAiFollow(enterpriseId, aiRes.getResult().getResult(), list);
}
Page<MemberSmsLogDTO> smsPage = new Page<>();
smsPage.setCurrentPage(1);
smsPage.setPageSize(sizeTotal);
Page<MemberSmsLogDTO> smsRes = smsService.memberSmsLogPage(enterpriseId, memberId, null, DateUtil.beginOfDay(startTime).toJdkDate(), DateUtil.endOfDay(date).toJdkDate(), smsPage);
if (smsRes != null && CollectionUtils.isNotEmpty(smsRes.getResult())) {
convertSmsFollow(enterpriseId, smsRes.getResult(), list);
}
PageHelper.startPage(basePage);
List<TabContactFollow> followList = contactFollowMapper.pageFollow(enterpriseId, searchQDTO);
if (CollectionUtils.isNotEmpty(followList)) {
List<ContactFollowDTO> pageList = convertExtInfo(followList);
list.addAll(pageList);
}
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().sorted(
Comparator.comparing(ContactFollowDTO::getFollowTime, Comparator.nullsLast(Comparator.reverseOrder()))
.thenComparing(ContactFollowDTO::getFollowType, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(ContactFollowDTO::getClerkId, Comparator.nullsLast(Comparator.naturalOrder())))
.limit(maxSize)
.collect(Collectors.toList());
}
return list;
}
private void convertAiFollow(String enterpriseId, List<AiMemberLogListDTO> aiList, List<ContactFollowDTO> list) {
if (CollectionUtils.isEmpty(aiList)) {
return;
}
ContactFollowDTO followDTO;
for (AiMemberLogListDTO aiMemberLog : aiList) {
followDTO = new ContactFollowDTO();
followDTO.setMemberId(aiMemberLog.getMemberId());
followDTO.setFollowType(ContactFollowTypeEnum.AI.getCode());
followDTO.setFollowRemark(ContactFollowTypeEnum.AI.getTextMatch());
followDTO.setFollowTime(aiMemberLog.getAiTime());
followDTO.setEnterpriseId(enterpriseId);
list.add(followDTO);
}
}
private void convertSmsFollow(String enterpriseId, List<MemberSmsLogDTO> smsList, List<ContactFollowDTO> list) {
if (CollectionUtils.isEmpty(smsList)) {
return;
}
ContactFollowDTO followDTO;
for (MemberSmsLogDTO smsLog : smsList) {
followDTO = new ContactFollowDTO();
followDTO.setMemberId(smsLog.getMemberId());
followDTO.setFollowType(ContactFollowTypeEnum.SMS.getCode());
followDTO.setFollowRemark(ContactFollowTypeEnum.SMS.getTextMatch());
followDTO.setFollowTime(smsLog.getCreateDate());
followDTO.setEnterpriseId(enterpriseId);
list.add(followDTO);
}
}
@Override
public Map<String, ContactFollowDTO> mapMemberLastFollow(String enterpriseId, String clerkId,List<String> memberIdList) {
if (CollectionUtils.isEmpty(memberIdList)) {
return new HashMap<>();
}
Date date = DateUtil.date();
DateTime startTime = DateUtil.offsetMonth(date, -6);
List<TabContactFollow> list = contactFollowMapper.lastFollowByMemberId(enterpriseId, clerkId, memberIdList);
List<ContactFollowDTO> followDTOList = convertExtInfo(list);
Map<String, ContactFollowDTO> map = followDTOList.stream().collect(Collectors.toMap(ContactFollowDTO::getMemberId, v -> v,
(v1, v2) -> v1));
ServiceResponse<List<AiMemberLogListDTO>> aiRes = aiMemberLogApiService.lastAiMemberMarketingLog(memberIdList, aiThirdStatus, DateUtil.formatDate(startTime), DateUtil.formatDate(date), new HashMap<>());
if (aiRes != null && aiRes.getResult() != null) {
convertAiFollow(enterpriseId, aiRes.getResult(), followDTOList);
}
List<MemberSmsLogDTO> smsList = smsService.lastMemberSmsLog(enterpriseId, memberIdList, null, DateUtil.beginOfDay(startTime).toJdkDate(), DateUtil.endOfDay(date).toJdkDate(), new HashMap<>());
convertSmsFollow(enterpriseId, smsList, followDTOList);
Map<String, ContactFollowDTO> map = followDTOList.stream()
.sorted(Comparator
.comparing(ContactFollowDTO::getFollowTime, Comparator.nullsLast(Comparator.reverseOrder()))
.thenComparing(ContactFollowDTO::getFollowType, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(ContactFollowDTO::getClerkId, Comparator.nullsLast(Comparator.naturalOrder()))
).collect(Collectors.toMap(
ContactFollowDTO::getMemberId,
v -> v,
(v1, v2) -> v1,
LinkedHashMap::new
));
return map;
}
......
......@@ -3,35 +3,59 @@ 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;
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.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.dto.contact.ContactLogDTO;
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.MemberStoreDTO;
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;
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
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 {
......@@ -41,6 +65,12 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private TabContactLogMapper contactLogMapper;
@Autowired
private TabContactFollowMapper contactFollowMapper;
@Autowired
private ContactConfigService contactConfigService;
@Autowired
private ContactFollowService contactFollowService;
@Autowired
private StoreGoodsService storeGoodsService;
@Autowired
private ClerkService clerkService;
......@@ -49,17 +79,105 @@ public class ContactLogServiceImpl implements ContactLogService {
@Autowired
private MemberService memberService;
@Autowired
private CustomerApiService customerApiService;
@Autowired
private ObjectivesManageApiService objectivesManageApiService;
@Autowired
private ESDataDynamicOperationApiService esDataDynamicOperationApiService;
@Autowired
private ESMemberInfoService esMemberInfoService;
@Autowired
private EnterpriseAdaptor enterpriseAdaptor;
@Override
public Integer contactCheck(String enterpriseId,String memberId,ClerkDTO clerkDTO,Integer bizType) {
if (clerkDTO == null) {
return null;
}
CustomerDTO params = new CustomerDTO();
int clerkType = clerkDTO.getClerkType();
if (clerkType >= 2) {
return null;
}
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);
if (bizType!=null && !Objects.equals(bizType,-1)) {
boolean checkPotential = checkPotential(memberId, params, bizType);
return !checkPotential ? null : bizType;
} else {
boolean checkPotential = checkPotential(memberId, params, ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType());
if (checkPotential) {
return ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
}
checkPotential = checkPotential(memberId, params, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType());
if (checkPotential) {
return ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType();
}
}
return null;
}
private boolean checkPotential(String memberId, CustomerDTO params,Integer bizType) {
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRightByContactBizType(params.getEnterpriseId(), bizType);
if (!hasRight) {
return false;
}
ContactParamDTO contact = new ContactParamDTO();
// 搜索信息
MemberInfoListParamsDTO memberInfoListParamsDTO = com.gic.haoban.common.utils.StringUtil.getBean("{}", MemberInfoListParamsDTO.class);
if (Objects.equals(bizType, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType())) {
memberInfoListParamsDTO.setCrowdClerkId(params.getClerkId());
memberInfoListParamsDTO.setCrowdType(-1);
memberInfoListParamsDTO.setMemberType(4);
}
memberInfoListParamsDTO.setMemberId(memberId);
contact.setContactType(0);
contact.setBizType(bizType);
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 {
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();
DateTime date = DateUtil.date();
Integer contactAutoType = qdto.getContactAutoType();
Integer followType = qdto.getFollowType();
Integer bizType = qdto.getBizType();
Integer sourceType = qdto.getSourceType();
Long sourceLogId = qdto.getSourceLogId();
Date date = qdto.getSyncContactTime() != null ? qdto.getSyncContactTime() : DateUtil.date();
MemberStoreClerkDTO memberStoreClerk = memberService.getMemberStoreClerk(memberId);
if (memberStoreClerk == null) {
logger.info("无专属导购无法建联");
......@@ -70,14 +188,25 @@ public class ContactLogServiceImpl implements ContactLogService {
logger.info("非专属导购无法建联");
throw new BusinessException("-1", "非专属导购无法建联");
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
// 建联校验
Integer contactCheck = contactCheck(enterpriseId, memberId, clerkDTO, bizType);
logger.info("非未建联或建联未转化:{}",contactCheck);
if (contactCheck == null) {
throw new BusinessException("-1", "非未建联或建联未转化,无法建联");
}
bizType = contactCheck;
// 是否周期内首次建联 同周期内是否有记录
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();
if (DateUtil.between(date, contactTime, DateUnit.SECOND) > 14 * 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();
......@@ -85,14 +214,18 @@ public class ContactLogServiceImpl implements ContactLogService {
}
}
logger.info("建联周期:{},是否周期内首次:{}", contactCycle, contactCycleFirst);
// 获取当前建联时间和上一次建联时间之间的跟进类型
String followTypes = contactFollowMapper.getFollowTypes(enterpriseId, clerkId, memberId, lastContactTime, date);
TabContactLog contactLog = new TabContactLog();
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
contactLog.setFollowTypes(followTypes);
contactLog.setClerkId(clerkId);
contactLog.setStoreId(storeId);
if (clerkDTO != null) {
storeId = clerkDTO.getStoreId();
contactLog.setClerkCode(clerkDTO.getClerkCode());
contactLog.setClerkName(clerkDTO.getClerkName());
contactLog.setStoreId(storeId);
}
if (StringUtils.isNotBlank(storeId)) {
StoreDTO store = storeService.getStore(storeId);
......@@ -100,7 +233,13 @@ public class ContactLogServiceImpl implements ContactLogService {
contactLog.setStoreCode(store.getStoreCode());
}
}
contactLog.setLogId(UniqueIdUtils.uniqueLong());
JSONObject jsonObject = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "potentialScore");
if (jsonObject != null && jsonObject.getInteger("potentialScore") != null) {
contactLog.setPotentialScore(jsonObject.getInteger("potentialScore"));
}
Long logId = UniqueIdUtils.uniqueLong();
Long bizId = qdto.getSourceLogId() != null ? qdto.getSourceLogId() : logId;
contactLog.setLogId(logId);
contactLog.setMemberId(memberId);
contactLog.setContactStatus(Constant.FLAG_TRUE);
contactLog.setContactTime(date);
......@@ -108,45 +247,200 @@ public class ContactLogServiceImpl implements ContactLogService {
contactLog.setContactCycleFirst(contactCycleFirst);
// 成为潜客时间 无用暂不写
contactLog.setPotentialTime(null);
contactLog.setSourceType(sourceType == null ? bizType : 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);
refreshContactTime(enterpriseId, memberId);
// 建联跟进记录
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(bizId));
contactFollowService.saveFollow(followQDTO);
}
// 同步建联
if (!Objects.equals(qdto.getSyncContactType(), Constant.FLAG_TRUE)) {
syncContactSend(contactLog,followRemark);
}
// 冗余机会人群数据
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();
String jsonString = JSON.toJSONString(result);
logger.info("机会人群数据:{}", jsonString);
if (CollectionUtils.isNotEmpty(result)) {
TabContactLog modifyContactLog = new TabContactLog();
modifyContactLog.setLogId(logId);
modifyContactLog.setBizData(jsonString);
contactLogMapper.update(modifyContactLog);
}
} catch (Exception e) {
logger.error("冗余人群数据错误!",e);
}
}
private void syncContactSend(TabContactLog contactLog,String followRemark) {
// 同步建联
ContactLogQDTO contactLogQDTO = EntityUtil.changeEntityNew(ContactLogQDTO.class, contactLog);
contactLogQDTO.setSyncContactType(Constant.FLAG_TRUE);
contactLogQDTO.setSyncContactTime(contactLog.getContactTime());
contactLogQDTO.setContactAutoType(null);
contactLogQDTO.setFollowRemark(followRemark);
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);
}
}
/**
* 历史数据超过14天建联未转化的按14天周期
* @param contactTime
* @return
*/
private Integer getContactOrderLimitDay(Date contactTime) {
Integer contactOrderLimitDay = Manage3Constants.CONTACT_ORDER_LIMIT_DAY;
if (DateUtil.compare(Manage3Constants.CONTACT_FIX_RELEASE_DATE, contactTime) > 0 && DateUtil.between(Manage3Constants.CONTACT_FIX_RELEASE_DATE, contactTime, DateUnit.SECOND) > 14 * 24 * 60 * 60) {
contactOrderLimitDay = 14;
}
logger.info("建联未转化计算天数:{}",contactOrderLimitDay);
return contactOrderLimitDay;
}
@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 autoContactLog(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;
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));
for (ContactBizTypeEnum bizTypeEnum : ContactBizTypeEnum.values()) {
try {
qdto.setBizType(bizTypeEnum.getType());
qdto.setFollowType(ContactFollowTypeEnum.AUTO_CONTACT.getCode());
qdto.setFollowRemark("因" + ContactAutoTypeEnum.fromCode(contactAutoType).getDescription() + ",系统自动标记了建联");
saveContactLog(qdto);
} catch (BusinessException e) {
logger.info("自动建联异常:{}", e.getMessage());
continue;
}
return;
}
}
@Override
public void syncContactLog(ContactLogQDTO qdto) {
if (qdto == null) {
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.setSyncContactType(Constant.FLAG_TRUE);
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);
});
}
private void refreshContactTime(String enterpriseId, String memberId) {
JSONObject memberJO = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "clerkChannelContactTime");
if (memberJO == null) {
return;
}
List<Long> clerkContactTimeList = memberJO.getObject("clerkChannelContactTime",new TypeReference<List<Long>>(){});
if (clerkContactTimeList == null) {
clerkContactTimeList = new ArrayList<>();
}
List<TabContactLog> list = getClerkContactTimeList(memberId);
if (CollectionUtils.isNotEmpty(list)) {
List<ContactLogDTO> dtos = EntityUtil.changeEntityListNew(ContactLogDTO.class, list);
clerkContactTimeList = ContactBizTypeEnum.getEsClerkContactTimeList(dtos);
}else {
clerkContactTimeList = new ArrayList<>();
}
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("clerkChannelContactTime", clerkContactTimeList);
dynamicDocDTO.setDocJson(jsonObject);
dynamicDocDTO.setRefresh(Constant.FLAG_TRUE);
ESResponse res = esDataDynamicOperationApiService.updateDataSingle(dynamicDocDTO, false);
......@@ -155,7 +449,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;
}
......@@ -173,14 +471,51 @@ public class ContactLogServiceImpl implements ContactLogService {
if (!Objects.equals(clerkId, memberStoreClerk.getClerkId())) {
return null;
}
if (DateUtil.compare(contactTime, DateUtil.date().offset(DateField.DAY_OF_MONTH, -14)) < 0) {
Integer contactOrderLimitDay = getContactOrderLimitDay(contactTime);
if (DateUtil.compare(contactTime, DateUtil.date().offset(DateField.DAY_OF_MONTH, -contactOrderLimitDay)) < 0) {
return null;
}
return lastContactLog;
}
@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;
}
logger.info("获取最近一条建联记录:{}",JSON.toJSONString(contactMap));
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));
}
}
......@@ -23,6 +23,9 @@ import com.gic.haoban.manage.service.service.ESMemberInfoService;
import com.gic.haoban.manage.service.service.contact.ContactLogService;
import com.gic.haoban.manage.service.service.contact.ContactOrderService;
import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.member.tag.api.dto.MemberTagGroupDetailDTO;
import com.gic.member.tag.api.dto.MemberTagGroupSimpleDTO;
import com.gic.member.tag.api.service.MemberTagGroupApiService;
import com.gic.order.api.dto.resp.OrderInfoResp;
import com.gic.order.api.dto.resp.OrderItemResp;
import com.github.pagehelper.PageHelper;
......@@ -49,6 +52,8 @@ public class ContactOrderServiceImpl implements ContactOrderService {
@Autowired
private ESMemberInfoService esMemberInfoService;
@Autowired
private MemberTagGroupApiService memberTagGroupApiService;
@Autowired
private StoreService storeService;
@Autowired
private ClerkService clerkService;
......@@ -70,6 +75,11 @@ public class ContactOrderServiceImpl implements ContactOrderService {
logger.info("订单不是销售单");
return false;
}
long noGiveCount = orderInfoResp.getOrderItems().stream().filter(x -> !Objects.equals(x.getProType(), 2)).count();
if (noGiveCount == 0) {
logger.info("都是赠品订单:{}", orderId);
return false;
}
String enterpriseId = orderInfoResp.getEnterpriseId();
String memberId = orderInfoResp.getMemberId();
logger.info("建联处理订单:{},memberId:{}", orderId,memberId);
......@@ -86,47 +96,79 @@ 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"));
}
String groupInfo = convertGroupInfo(enterpriseId, memberId);
contactOrder.setGroupInfo(groupInfo);
contactOrderMapper.insert(contactOrder);
}
contactOrderMapper.insert(contactOrder);
return true;
}
private String convertGroupInfo(String enterpriseId, String memberId) {
JSONObject jo = new JSONObject();
try {
MemberTagGroupDetailDTO memberTagGroupDetail = memberTagGroupApiService.getMemberTagGroupDetail(enterpriseId, memberId, "1");
if (memberTagGroupDetail == null) {
return jo.toJSONString();
}
MemberTagGroupSimpleDTO allChannelMemberGradeGroup = memberTagGroupDetail.getAllChannelMemberGradeGroup();
if (allChannelMemberGradeGroup != null) {
jo.put("allChannelMemberGradeGroup", allChannelMemberGradeGroup.getGroupName());
}
MemberTagGroupSimpleDTO memberGradeGroup = memberTagGroupDetail.getMemberGradeGroup();
if (memberGradeGroup != null) {
jo.put("memberGradeGroup", memberGradeGroup.getGroupName());
}
} catch (Exception e) {
logger.info("获取金字塔分层信息异常",e);
}
return jo.toJSONString();
}
@Override
public Page<ContactOrderDetailDTO> pageContactOrder(String enterpriseId, ContactOrderSearchQDTO searchQDTO, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
......
......@@ -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));
}
......
......@@ -47,4 +47,5 @@ public interface HaobanQywxFeeOrderService {
void refund(Long feeOrderId ,String wxEnterpriseId , String orderId) ;
void qywxAppOverTimer(String params);
}
package com.gic.haoban.manage.service.service.fee.impl;
import java.util.Date;
import java.util.List;
import com.gic.commons.util.DateUtil;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanAppOrderMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeOrderAccountMapper;
import com.gic.haoban.manage.service.entity.TabHaobanAppOrder;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.util.DingUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,6 +37,10 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
private TabHaobanQywxFeeOrderMapper tabHaobanQywxFeeOrderMapper;
@Autowired
private TabHaobanQywxFeeOrderAccountMapper tabHaobanQywxFeeOrderAccountMapper ;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired
private TabHaobanAppOrderMapper tabHaobanAppOrderMapper;
/**
* 新增数据
......@@ -69,4 +81,26 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
this.tabHaobanQywxFeeOrderMapper.refund(feeOrderId);
this.tabHaobanQywxFeeOrderAccountMapper.refund(wxEnterpriseId,orderId);
}
@Override
public void qywxAppOverTimer(String params) {
// https://oapi.dingtalk.com/robot/send?access_token=62053271b8f98ac1d7e0695d98639be00ac1963e101f80e022200b5af9632ec7
List<TabHaobanWxEnterprise> enList = this.wxEnterpriseMapper.listAllNotSelf() ;
for(TabHaobanWxEnterprise wxEnterprise : enList) {
String wxEnterpriseId = wxEnterprise.getWxEnterpriseId() ;
List<TabHaobanAppOrder> orderList = this.tabHaobanAppOrderMapper.listOrderForNotice(wxEnterpriseId) ;
if(CollectionUtils.isNotEmpty(orderList)) {
TabHaobanAppOrder order = orderList.get(0) ;
Date endTime = order.getEndTime() ;
// 3天内过期
if(DateUtil.getStartTimeOfDay(endTime).getTime() - 1000*3600*24*3 <= DateUtil.getStartTimeOfDay().getTime()) {
if(DateUtil.getStartTimeOfDay(endTime).getTime()<DateUtil.getStartTimeOfDay().getTime() && DateUtil.daysBetween(DateUtil.getStartTimeOfDay(endTime),DateUtil.getStartTimeOfDay())>1) {
continue;
}
logger.info("应用即将到期={}",wxEnterpriseId);
DingUtils.send("企微企业名称:"+wxEnterprise.getCorpName()+"-"+wxEnterprise.getOpenCorpid() + "\n应用到期时间:" + DateUtil.dateToStr(endTime,"yyyy-MM-dd HH:mm:ss") , "https://oapi.dingtalk.com/robot/send?access_token=62053271b8f98ac1d7e0695d98639be00ac1963e101f80e022200b5af9632ec7",false);
}
}
}
}
}
......@@ -604,7 +604,7 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
}
List<MemberExternalUserDTO> retList = new ArrayList<>() ;
String externalUserId = null ;
Map<String,String> map = new HashMap<>() ;
//Map<String,String> map = new HashMap<>() ;
for(TabHaobanExternalClerkRelated item : list) {
MemberExternalUserDTO dto = new MemberExternalUserDTO() ;
if(null == externalUserId) {
......@@ -612,17 +612,23 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
}else if(!externalUserId.equals(item.getExternalUserId())) {
continue;
}
String staffId = item.getStaffId() ;
/*String staffId = item.getStaffId() ;
String clerkId = item.getClerkId() ;
if(null != map.get(staffId) && !map.get(staffId).equals(clerkId)) {
continue;
}
map.put(staffId,clerkId) ;
map.put(staffId,clerkId) ;*/
dto.setMemberId(memberId);
dto.setClerkId(item.getClerkId());
dto.setStoreId(item.getStoreId());
dto.setExternalStatus(item.getExternalStatus());
dto.setHalfDelTime(item.getHalfDelTime());
if(null == item.getAddTime() && null != item.getAddCreateTime()) {
item.setAddTime(Long.valueOf(item.getAddCreateTime()));
}
if(null == item.getAddTime()) {
continue;
}
dto.setAddTime(new Date(item.getAddTime()*1000));
dto.setStatusFlag(item.getStatusFlag());
if(dto.getStatusFlag()==2) {
......
......@@ -287,7 +287,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Override
public void addMemberQywxFlag(String enterpriseId, String memberId) {
List<TabHaobanExternalClerkRelated> memberList = externalClerkRelatedService.getAddTimeByMemberId(memberId, enterpriseId,"1");
List<TabHaobanExternalClerkRelated> memberList = externalClerkRelatedService.getAddTimeByMemberId(memberId, enterpriseId,null);
Date date = new Date();
Date opTime = new Date(0);
Date firstTime = new Date();
......
......@@ -32,7 +32,6 @@ import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......
......@@ -311,7 +311,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), wxUserId, takeoverUserId, list,qwDTO.isSelf(),qwDTO.getUrlHost());
if (transferCustomerResp.getErrcode() != 0) {
logger.info("离职继承-分配客户异常={}",JSONObject.toJSONString(transferCustomerResp));
DingUtils.send("离职继承分配异常"+wxUserId,true);
// DingUtils.send("离职继承分配异常"+wxUserId,true);
}
List<QywxTransferCustomerInfoDTO> customer = transferCustomerResp.getCustomer();
if (CollectionUtils.isEmpty(customer)) {
......
......@@ -15,6 +15,7 @@ import com.gic.haoban.manage.service.service.chat.GroupChatDataService;
import com.gic.haoban.manage.service.service.chat.GroupChatPlanService;
import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.contact.adaptor.ContactAdaptor;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService;
import com.gic.haoban.manage.service.util.DingUtils;
import com.gic.haoban.manage.service.util.HBQwMonitorUtils;
......@@ -62,6 +63,8 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
private GroupChatPlanService groupChatPlanService ;
@Autowired
private ContactAdaptor contactAdaptor;
@Autowired
private HaobanQywxFeeOrderService haobanQywxFeeOrderService ;
@Override
......@@ -214,4 +217,9 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
public void contactDataTimer(String params) {
contactAdaptor.contactDataTimer();
}
@Override
public void qywxAppOverTimer(String params) {
this.haobanQywxFeeOrderService.qywxAppOverTimer(params) ;
}
}
......@@ -335,24 +335,29 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId, keyword, categoryIds, materialType);
List<TabHaobanMaterial> result = page.getResult();
List<TabMiniprogramSetting> settings = miniprogramSettingService.listMiniprogram(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(result) && CollectionUtils.isNotEmpty(settings)) {
Page<MaterialDTO> retPage = PageUtil.changePageHelperToCurrentPage(page, MaterialDTO.class);
if (CollectionUtils.isNotEmpty(retPage.getResult()) && CollectionUtils.isNotEmpty(settings)) {
Map<String, TabMiniprogramSetting> settingMap = settings.stream()
.collect(Collectors.toMap(
TabMiniprogramSetting::getAppId,
Function.identity(),
(a, b) -> a
));
result.forEach(dto -> {
retPage.getResult().forEach(dto -> {
//小程序去判断逻辑
if (dto.getMaterialType() != null && dto.getMaterialType() == 6) {
TabMiniprogramSetting miniprogramSetting = settingMap.get(dto.getAppId());
dto.setMaterialDesc(miniprogramSetting == null ? "--" : miniprogramSetting.getMiniprogramName());
if(null != miniprogramSetting) {
dto.setMaterialDesc(miniprogramSetting.getMiniprogramName());
dto.setHeadImg(miniprogramSetting.getImageUrl());
}else {
dto.setMaterialContent("--");
}
}
});
}
return PageUtil.changePageHelperToCurrentPage(page, MaterialDTO.class);
return retPage ;
}
@Override
......
......@@ -11,6 +11,8 @@ import com.gic.haoban.manage.service.pojo.GicNewMemberBO;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.util.EventUtils;
import com.gic.haoban.manage.service.util.HBQwMonitorUtils;
import com.gic.member.api.dto.*;
import com.gic.member.api.service.*;
import com.gic.member.ext.api.enums.growth.GrowthRuleEnum;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -84,15 +86,6 @@ import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.hm.HmLinkService;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.dto.MemberSimpleDetailDTO;
import com.gic.member.api.dto.MemberSourceDetailDTO;
import com.gic.member.api.dto.MemberSourceShowDTO;
import com.gic.member.api.dto.QywxMemberQDTO;
import com.gic.member.api.service.MemberApiService;
import com.gic.member.api.service.MemberEntranceApiService;
import com.gic.member.api.service.MemberService;
import com.gic.member.api.service.MemberStoreService;
import com.gic.member.tag.api.dto.outapi.MemberTagSingleDTO;
import com.gic.member.tag.api.service.MemberTagOpenApiService;
import com.gic.mq.sdk.GicMQClient;
......@@ -182,7 +175,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService ;
@Autowired
private QywxErrorLogService qywxErrorLogService ;
@Autowired
private MemberTagService memberTagService ;
GicMQClient instance = GICMQClientUtil.getClientInstance();
@Override
......@@ -499,7 +494,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if(times>maxCount) {
if(!needToMq2(wxEnterpriseId)) {
log.info("加好友计数发送告警,id={}",wxEnterpriseId);
DingUtils.send("加好友mq切换,企业="+ wxEnterpriseId, false);
// DingUtils.send("加好友mq切换,企业="+ wxEnterpriseId, false);
}
log.info("加好友计数,自动到userMq2,{}",wxEnterpriseId);
this.addToMq2Mark(wxEnterpriseId);
......@@ -783,7 +778,13 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
this.saveExternalClerk(memberId, staffId, dto, staffClerkRelationDTO , 1 , 0);
// this.sendWelcome(dto, qwDTO, enterpriseId, staffId, clerkId,memberId);
//同步好友标签
this.pushTagSync(memberId, wxEnterpriseId, enterpriseId,null,dto.isFlush());
// 如果gic会员上没标签,不同步
List<MemberTagDTO> memberTags = memberTagService.listMemberClerkManualTag(enterpriseId, memberId);
if (CollectionUtils.isNotEmpty(memberTags)) {
this.pushTagSync(memberId, wxEnterpriseId, enterpriseId,null,dto.isFlush());
}else {
log.info("gic会员上无标签,不同步企微侧标签");
}
//回调给会员,更新是否为企微好友
log.info("通知会员 合并会员后更新为企微好友,memberId:{}", memberId);
// this.memberApiService.updateMemberQywxFlag(enterpriseId, memberId, 1);
......
......@@ -1098,6 +1098,10 @@ public class StaffApiServiceImpl implements StaffApiService {
String storeWidgetId = this.powerService.getStoreWidgetId(null, clerkId);
if(null != storeWidgetId) {
Page<StoreDTO> page = storeWidgetService.getStoreWidgetStore(storeWidgetId, null, clerkDTO.getEnterpriseId(), pageParam, null,null);
if(null == page || CollectionUtils.isEmpty(page.getResult())) {
storeRoleDTO.setStoreCount(0);
return storeRoleDTO;
}
storeId = page.getResult().get(0).getStoreId();
storeCount = page.getTotalCount();
}
......
......@@ -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();
}
......
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;
/**
......@@ -74,6 +77,7 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
followQDTO.setClerkCode(clerkDTO.getClerkCode());
followQDTO.setFollowRemark(clerkDTO.getClerkName() + qdto.getFollowRemark());
followQDTO.setFollowTime(x.getFollowTime());
followQDTO.setGoodsInfoList(qdto.getGoodsInfoList());
followQDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
return followQDTO;
}).collect(Collectors.toList());
......
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.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
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 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 com.gic.member.api.dto.MemberStoreClerkDTO;
import com.gic.member.api.service.MemberService;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.Objects;
/**
* Created by wangzubo on 2022/11/1.
*/
@Slf4j
@Service("contactLogApiService")
public class ContactLogApiServiceImpl implements ContactLogApiService {
@Autowired
private ContactLogService contactLogService;
@Autowired
private ClerkService clerkService;
@Autowired
private MemberService memberService;
@Override
public ServiceResponse<ContactLogDTO> getClerkContactTime(String memberId) {
......@@ -28,6 +45,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);
......@@ -37,4 +64,38 @@ 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);
Integer contactAutoType = contactLogQDTO.getContactAutoType();
if (contactAutoType != null) {
contactLogService.autoContactLog(contactLogQDTO);
}else {
contactLogService.syncContactLog(contactLogQDTO);
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<Boolean> contactCheck(ContactLogCheckQDTO checkQDTO) {
ClerkDTO clerkDTO = clerkService.getclerkById(checkQDTO.getClerkId());
if (clerkDTO == null) {
return ServiceResponse.success(Boolean.FALSE);
}
MemberStoreClerkDTO memberStoreClerk = memberService.getMemberStoreClerk(checkQDTO.getMemberId());
if (memberStoreClerk == null) {
log.info("无专属导购无法建联");
return ServiceResponse.success(Boolean.FALSE);
}
String mainClerkId = memberStoreClerk.getClerkId();
if (!Objects.equals(mainClerkId, checkQDTO.getClerkId())) {
log.info("非专属导购无法建联");
return ServiceResponse.success(Boolean.FALSE);
}
Integer contactCheck = contactLogService.contactCheck(checkQDTO.getEnterpriseId(), checkQDTO.getMemberId(), clerkDTO, checkQDTO.getBizType());
return ServiceResponse.success(contactCheck != null);
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.contact.ContactOrderDetailDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactOrderQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactOrderSearchQDTO;
......@@ -47,12 +48,12 @@ public class ContactOrderApiServiceImpl implements ContactOrderApiService {
}
OrderInfoResp result = serviceResponse.getResult();
boolean clearFlag = CollectionUtils.isNotEmpty(result.getOrderItems()) && result.getPaidAmount() > 0
&& (result.getReceiptsDate() != null && DateUtil.compare(DateUtil.offsetDay(new Date(), -14), result.getReceiptsDate()) <= 0);
&& (result.getReceiptsDate() != null && DateUtil.compare(DateUtil.offsetDay(new Date(), -Manage3Constants.CONTACT_ORDER_LIMIT_DAY), result.getReceiptsDate()) <= 0);
log.info("获取订单时间,orderId:{},单据时间:{},应收:{}", result.getOrderId(),result.getReceiptsDate(),result.getPaidAmount());
boolean contactOrder = contactOrderService.saveContactOrder(result);
log.info("clearFlag:{},contactOrder:{}", clearFlag, contactOrder);
if (clearFlag || contactOrder) {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(enterpriseId,memberId, 1,"");
}
return ServiceResponse.success();
}
......
......@@ -54,13 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -281,11 +275,12 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
log.info("当前时间处于消息禁发时间, 忽略{}", cn.hutool.core.date.DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
return ServiceResponse.success();
}
List<String> enterpriseIds = groupMessageService.hasMaterialRightEnterprise(EnterpriseAdaptor.MaterialLevel.LOW.getCode());
if (CollectionUtils.isEmpty(enterpriseIds)) {
Map<String, List<String>> map = groupMessageService.weekMonthEnterprise();
if (MapUtil.isEmpty(map)) {
log.info("开通内容权限的企业为空");
return ServiceResponse.success();
}
Set<String> enterpriseIds = map.keySet();
Date startTime = null;
// 如果是8点那次的执行 需要获取 23 ~ 8点的数据
if (checkIsTodayFirst(now)) {
......
......@@ -5,31 +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.JSONResponse;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.content.api.utils.MqUtils;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.dto.anaylsis.ClerkShareGoodsLogDTO;
import com.gic.haoban.manage.api.dto.send.DealQwSendDTO;
import com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowBatchQDTO;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.MessageApiService;
import com.gic.haoban.manage.api.service.content.MaterialShareLogApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.send.QwSendLogMapper;
import com.gic.haoban.manage.service.dao.mapper.send.QwSendMsgMapper;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.send.TabQwSendLog;
import com.gic.haoban.manage.service.entity.send.TabQwSendMsg;
import com.gic.haoban.manage.service.pojo.bo.send.FinishQwSendBO;
import com.gic.haoban.manage.service.pojo.bo.send.GroupSendResultBO;
import com.gic.haoban.manage.service.service.chat.GroupChatPlanService;
import com.gic.haoban.manage.service.service.content.impl.GroupMessageServiceImpl;
import com.gic.haoban.manage.service.service.send.QwSendMsgService;
import com.gic.member.api.constant.MemberExtKeyEnum;
import com.gic.member.api.dto.member.req.MemberExtraPropertyReq;
import com.gic.member.api.service.extra.MemberExtraPropertyApiService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
......@@ -55,6 +60,10 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
@Autowired
private MessageApiService messageApiService;
@Autowired
private MaterialShareLogApiService materialShareLogApiService;
@Autowired
private MemberExtraPropertyApiService memberExtraPropertyApiService;
@Override
public void finishQwSend(DealQwSendDTO.FinishQwSendBO finishQwSendBO,Integer tryCount) {
......@@ -83,7 +92,8 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
dealQwSendDTO.setRefreshType(2);
DealQwSendDTO.QwSendMsgBO qwSendMsgBO = EntityUtil.changeEntityByJSON(DealQwSendDTO.QwSendMsgBO.class, qwSendMsg);
dealQwSendDTO.setQwSendMsg(qwSendMsgBO);
MqUtils.sendMessageToMQ("qwSendRefreshByMQ", JSON.toJSONString(dealQwSendDTO), 60);
dealQwSendDTO.setFinishQwSend(finishQwSendBO);
MqUtils.sendMessageToMQ("qwSendRefreshByMQ", JSON.toJSONString(dealQwSendDTO), 30);
}else {
if (tryCount != null && tryCount >= 5) {
return;
......@@ -166,9 +176,9 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
if (StringUtils.isBlank(log.getMemberId())) {
return;
}
memberList.add(new ContactFollowBatchQDTO.MemberFollow(log.getMemberId(), log.getSendTime()));
memberList.add(new ContactFollowBatchQDTO.MemberFollow(log.getMemberId(), log.getExternalUserId(), log.getSendTime()));
});
saveFollowMQ(qwSendMsg.getEnterpriseId(),qwSendMsg.getClerkId(), memberList);
saveFollowMQ(qwSendMsg.getEnterpriseId(),qwSendMsg.getClerkId(), memberList,dealQwSendDTO.getFinishQwSend());
}
entities.clear();
}
......@@ -245,16 +255,62 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
return EntityUtil.changeEntityListByJSON(GroupSendResultBO.class, list);
}
private void saveFollowMQ(String enterpriseId,String clerkId,List<ContactFollowBatchQDTO.MemberFollow> memberList) {
private void saveFollowMQ(String enterpriseId,String clerkId,List<ContactFollowBatchQDTO.MemberFollow> memberList,DealQwSendDTO.FinishQwSendBO finishQwSendBO) {
if (org.apache.commons.collections.CollectionUtils.isEmpty(memberList)) {
return;
}
if (finishQwSendBO == null) {
return;
}
Integer followType = null;
String followRemark = null;
Integer bizType = finishQwSendBO.getBizType();
List<ClerkShareGoodsLogDTO> shareGoodsList = finishQwSendBO.getShareGoodsList();
List<String> goodsInfoList = null;
if (Objects.equals(bizType, 1)) {
followType = ContactFollowTypeEnum.MATERIAL.getCode();
followRemark = "向客户发送了营销素材";
} else if (Objects.equals(bizType, 2)) {
followType = ContactFollowTypeEnum.PRODUCT.getCode();
followRemark = "向客户发送了" + shareGoodsList.size() + "款商品";
goodsInfoList = shareGoodsList.stream().map(ClerkShareGoodsLogDTO::getBizId).collect(Collectors.toList());
} else {
return;
}
ContactFollowBatchQDTO batchQDTO = new ContactFollowBatchQDTO();
batchQDTO.setEnterpriseId(enterpriseId);
batchQDTO.setMemberList(memberList);
batchQDTO.setClerkId(clerkId);
batchQDTO.setFollowType(ContactFollowTypeEnum.WECHAT_GROUP_SEND.getCode());
batchQDTO.setFollowRemark("通过企微群发向客户发送了消息");
batchQDTO.setFollowType(followType);
batchQDTO.setFollowRemark(followRemark);
batchQDTO.setGoodsInfoList(goodsInfoList);
MqUtils.sendMessageToMQ("saveBatchFollowForMQ", JSON.toJSONString(batchQDTO));
if (Objects.equals(bizType, 2)) {
saveShareMaterialLog(enterpriseId, shareGoodsList, memberList);
}
}
private void saveShareMaterialLog(String enterpriseId,List<ClerkShareGoodsLogDTO> shareGoodsList,List<ContactFollowBatchQDTO.MemberFollow> memberList) {
List<ClerkShareGoodsLogDTO> list = Lists.newArrayList();
for (ContactFollowBatchQDTO.MemberFollow memberInfo : memberList) {
for (ClerkShareGoodsLogDTO goodsLogDTO : shareGoodsList) {
ClerkShareGoodsLogDTO temp = EntityUtil.changeEntityByJSON(ClerkShareGoodsLogDTO.class, goodsLogDTO);
temp.setExternalUserId(memberInfo.getExternalUserId());
temp.setMemberId(memberInfo.getMemberId());
list.add(temp);
}
//更新会员推荐时间更新
MemberExtraPropertyReq memberExtraPropertyReq = new MemberExtraPropertyReq();
memberExtraPropertyReq.setEnterpriseId(enterpriseId);
memberExtraPropertyReq.setMemberId(memberInfo.getMemberId());
memberExtraPropertyReq.setExtraKey(MemberExtKeyEnum.MEMBER_GOODS_SUGGEST_TIME.key());
memberExtraPropertyReq.setExtraValue(memberInfo.getFollowTime().getTime());
try {
memberExtraPropertyApiService.updateMemberExtraProperty(memberExtraPropertyReq);
} catch (Exception e) {
log.info("更新会员推荐时间更新异常,", e);
}
}
materialShareLogApiService.saveClerkShareRecommendLog(list);
}
}
......@@ -69,13 +69,17 @@ public class ApolloUtils {
return Integer.parseInt(combinedFontsType);
}
public static boolean combinedCache() {
public static boolean combinedCache(String enterpriseId) {
Config config = ConfigService.getAppConfig();
String combinedCache = config.getProperty("combinedCache", "");
if (StringUtils.isBlank(combinedCache)) {
return false;
}
return true;
String combinedCacheEid = config.getProperty("combinedCacheEid", "");
if (StringUtils.isBlank(combinedCacheEid)) {
return true;
}
return combinedCacheEid.contains(enterpriseId);
}
/**
......
......@@ -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"/>
......@@ -179,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"
......@@ -208,6 +212,7 @@
<dubbo:reference interface="com.gic.marketing.api.service.SmsService" id="smsService" timeout="10000" retries="0"/>
<dubbo:reference interface="com.gic.marketing.api.service.AccountOverdueSmsSendService" id="accountOverdueSmsSendService" timeout="10000" retries="0"/>
<dubbo:reference interface="com.gic.marketing.api.service.CouponReferAlarmService" id="couponReferAlarmService" retries="0" check="false"/>
<dubbo:reference interface="com.gic.marketing.pro.api.service.ai.AiMemberLogApiService" id="aiMemberLogApiService" retries="0" check="false" timeout="10000"/>
<dubbo:reference interface="com.gic.thirdparty.api.service.VoiceService" id="voiceService" timeout="10000" retries="0"/>
<dubbo:reference interface="com.gic.thirdparty.api.service.CommunicationService" id="communicationService" timeout="10000" retries="0"/>
......@@ -256,6 +261,7 @@
<dubbo:reference interface="com.gic.clerk.api.service.MenuApiService" id="menuApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.member.ext.api.service.MemberGrowthWriteApiService" id="memberGrowthWriteApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.member.api.service.integral.IntegralWriteApiService" id="integralWriteApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference id="memberExtraPropertyApiService" interface="com.gic.member.api.service.extra.MemberExtraPropertyApiService" timeout="100000" retries="0" check="false" />
<dubbo:reference id="memberTagEsApiService" interface="com.gic.member.tag.api.service.MemberTagEsApiService" timeout="100000" retries="0" check="false"/>
<dubbo:reference id="memberCrowdApiService" interface="com.gic.member.ext.api.service.MemberCrowdApiService" timeout="10000" retries="0" check="false"/>
......
......@@ -23,7 +23,9 @@
<result property="creatorName" column="creator_name" jdbcType="VARCHAR"/>
<result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List" >
id, wx_enterprise_id, order_id, order_status, order_type, user_num, duration, begin_time, end_time, pay_time, origin_price, paid_price, order_url, delete_flag, create_time, update_time, creator_id, creator_name,expire_time
</sql>
<!--查询单个-->
<select id="queryById" resultMap="TabHaobanAppOrderMap">
select
......@@ -274,5 +276,9 @@
limit 1
</select>
<select id="listOrderForNotice" resultMap="TabHaobanAppOrderMap">
select <include refid="Base_Column_List" /> from tab_haoban_app_order where wx_enterprise_id=#{wxEnterpriseId} and delete_flag = 0 and order_status = 2 and order_type in (0,2) order by end_time desc
</select>
</mapper>
......@@ -608,4 +608,9 @@
</select>
<select id="listAllNotSelf" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from tab_haoban_wx_enterprise where wx_security_type IN (1,2,3,4) AND status_flag = 1
</select>
</mapper>
\ No newline at end of file
<?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
......@@ -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
......@@ -79,6 +105,29 @@
ORDER BY follow_time DESC,follow_id DESC
</select>
<select id="listFollowCheck" resultType="java.lang.String">
SELECT
member_id
FROM tab_contact_follow
<where>
enterprise_id = #{enterpriseId}
AND delete_flag = 0
AND follow_time >= NOW() - INTERVAL 6 MONTH
<if test="list != null and list.size() > 0">
AND (
<foreach collection="list" item="item" separator=" OR ">
(
member_id = #{item.memberId}
AND follow_time = #{item.followTime}
AND clerk_id = #{item.clerkId}
AND follow_type = 4
)
</foreach>
)
</if>
</where>
</select>
<select id="lastFollowByMemberId" resultMap="BaseResultMap">
SELECT
<include refid="Alias_Base_Column_List" />
......@@ -109,16 +158,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}, #{item.sourceType}, #{item.bizType}, #{item.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 +192,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,12 @@
<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="potentialScore" column="potential_score" jdbcType="INTEGER"/>
<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 +45,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}
</if>
<if test="beginTime != null">
AND contact_time >= #{beginTime}
</if>
<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 clerk_id = #{clerkId}
AND t1.clerk_id = #{clerkId}
</if>
<if test="beginTime!=null ">
and contact_time >= #{beginTime}
<if test="beginTime != null">
AND t1.contact_time >= #{beginTime}
</if>
<if test="endTime!=null ">
and contact_time <![CDATA[<=]]> #{endTime}
<if test="endTime != null">
AND t1.contact_time <![CDATA[<=]]> #{endTime}
</if>
order by contact_time desc,log_id desc limit 1
ORDER BY t1.biz_type ASC,t1.contact_time desc,t1.log_id desc
</select>
<!--查询列表-->
......@@ -128,6 +156,12 @@
contact_cycle,
contact_cycle_first,
potential_time,
potential_score,
source_type,
source_log_id,
biz_type,
biz_data,
follow_types,
enterprise_id
)
values (
......@@ -143,6 +177,12 @@
#{contactCycle},
#{contactCycleFirst},
#{potentialTime},
#{potentialScore},
#{sourceType},
#{sourceLogId},
#{bizType},
#{bizData},
#{followTypes},
#{enterpriseId})
</insert>
......@@ -183,6 +223,24 @@
<if test="potentialTime != null">
potential_time = #{potentialTime},
</if>
<if test="potentialScore != null">
potential_score = #{potentialScore},
</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,9 @@
<result column="contact_time" property="contactTime" />
<result column="potential_time" property="potentialTime" />
<result column="potential_score" property="potentialScore" />
<result column="group_info" property="groupInfo" />
<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 +34,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,group_info,source_type,biz_type, delete_flag, enterprise_id, create_time, update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
......@@ -45,7 +48,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 +77,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 +115,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,group_info, 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},#{groupInfo}, #{sourceType},#{bizType},#{enterpriseId})
</insert>
<update id="update">
......@@ -133,6 +139,9 @@
<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="groupInfo != null">group_info = #{groupInfo},</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}
......
......@@ -35,9 +35,9 @@ public class TagSyncTest {
// com.gic.haoban.manage.service.service.out.impl.QywxTagApiServiceImpl.syncQywxTagToGicByExternalUserId
@Test
public void test1() {
String wxEnterpriseId = "b18ffdc9d0644912865a248859914d80" ;
String externalUserId = "wm59NLDQAAhf0x3cc8FLo4wxYBWZtVYw" ;
String wxUserId = "wo59NLDQAAf5VM3RJ04BBznuqq2M3K3g" ;
String wxEnterpriseId = "ca66a01b79474c40b3e7c7f93daf1a3b" ;
String externalUserId = "wm59NLDQAAdcT6u5mqXz_jeMN9CpgXuw" ;
String wxUserId = "wo59NLDQAACLAXbOdqrz-70qpl72cWcA" ;
this.qywxTagApiService.syncQywxTagToGicByExternalUserId(wxEnterpriseId,externalUserId,wxUserId,null) ;
}
......
......@@ -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;
......@@ -98,7 +102,7 @@ public class ContactTest {
@Test
public void clearContactLog() throws Exception {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(eid,memberId, 1,"");
}
@Test
......@@ -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>
......@@ -130,21 +130,12 @@ public class ClerkMaterialShareController {
log.info("saveClerkShareMaterialLog 保存导购分享推荐商品日志 clerkId:{}, recommendShareLogQO{}", recommendShareLogQO.getClerkId(), JSON.toJSONString(recommendShareLogQO));
List<ClerkShareGoodsLogDTO> list = Lists.newArrayList();
List<String> memberIdList = Lists.newArrayList();
List<String> goodsIdList = recommendShareLogQO.getGoodsIdList();
List<RecommendShareLogQO.MemberInfo> externalUserIdList = recommendShareLogQO.getMemberInfoList();
for (RecommendShareLogQO.MemberInfo memberInfo : externalUserIdList) {
for (String goodsId : goodsIdList) {
for (String goodsId : goodsIdList) {
ClerkShareGoodsLogDTO temp = new ClerkShareGoodsLogDTO();
temp.setEnterpriseId(recommendShareLogQO.getEnterpriseId());
temp.setWxEnterpriseId(recommendShareLogQO.getWxEnterpriseId());
temp.setClerkId(recommendShareLogQO.getClerkId());
temp.setExternalUserId(memberInfo.getExternalUserId());
temp.setMemberId(memberInfo.getMemberId());
if(StringUtils.isNotEmpty(memberInfo.getMemberId())){
memberIdList.add(memberInfo.getMemberId());
}
temp.setBizId(goodsId);
temp.setBizType(ShareBizType.GOODS.getCode());
temp.setStoreId(recommendShareLogQO.getStoreId());
......@@ -152,25 +143,20 @@ public class ClerkMaterialShareController {
temp.setStaffId(recommendShareLogQO.getStaffId());
temp.setWxaLinkId(recommendShareLogQO.getWxaLinkId());
list.add(temp);
}
}
ServiceResponse<Long> serviceResponse = materialShareLogApiService.saveClerkShareRecommendLog(list);
// 改为查询企微是否真正发送成功
DealQwSendDTO.FinishQwSendBO finishQwSendBO = new DealQwSendDTO.FinishQwSendBO(
recommendShareLogQO.getClerkId(),
recommendShareLogQO.getStaffId(),
DateUtil.date(),
2,
recommendShareLogQO.getWxEnterpriseId(),
recommendShareLogQO.getEnterpriseId());
finishQwSendBO.setShareGoodsList(list);
dealQwSendMsg(finishQwSendBO);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure("-701", "系统异常");
}
//更新会员推荐时间更新
if(CollectionUtils.isNotEmpty(memberIdList)){
for (String memberId : memberIdList) {
MemberExtraPropertyReq memberExtraPropertyReq = new MemberExtraPropertyReq();
memberExtraPropertyReq.setEnterpriseId(recommendShareLogQO.getEnterpriseId());
memberExtraPropertyReq.setMemberId(memberId);
memberExtraPropertyReq.setExtraKey(MemberExtKeyEnum.MEMBER_GOODS_SUGGEST_TIME.key());
memberExtraPropertyReq.setExtraValue(new Date().getTime());
memberExtraPropertyApiService.updateMemberExtraProperty(memberExtraPropertyReq);
}
}
if (StringUtils.isNotBlank(recommendShareLogQO.getWxaLinkId())) {
enterpriseWxaLinkService.updateTimeById(recommendShareLogQO.getWxaLinkId());
}
......@@ -179,7 +165,6 @@ public class ClerkMaterialShareController {
}
private void dealQwSendMsg(DealQwSendDTO.FinishQwSendBO finishQwSend) {
// 商品分享暂时不记,记录的是发送商品的类型而不是企微群发
DealQwSendDTO dealQwSendDTO = new DealQwSendDTO();
dealQwSendDTO.setEnterpriseId(finishQwSend.getEnterpriseId());
dealQwSendDTO.setRefreshType(1);
......
......@@ -74,6 +74,9 @@ public class QwMomentController {
logger.info("查询活动列表={}", JSONObject.toJSONString(qo));
PlanListWxaQDTO qdto = EntityUtil.changeEntityByJSON(PlanListWxaQDTO.class,qo) ;
ClerkDTO clerk = this.clerkService.getclerkById(qo.getClerkId()) ;
if(null == clerk) {
return RestResponse.failure("9999","导购不存在或已删除") ;
}
if(0 != clerk.getClerkType()) {
qdto.setClerkId(null);
}
......
......@@ -2,21 +2,28 @@ package com.gic.haoban.manage.web.controller.potential;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
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.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.ContactLogCheckQDTO;
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;
import com.gic.haoban.manage.web.qo.contact.ContactFollowQO;
import com.gic.haoban.manage.web.qo.contact.ContactLastFollowQO;
import com.gic.haoban.manage.web.qo.contact.ContactLogQO;
import com.gic.haoban.manage.web.qo.contact.*;
import com.gic.haoban.manage.web.utils.EsMemberInfoUtils;
import com.gic.haoban.manage.web.vo.contact.ContactLogCheckVO;
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.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -27,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -40,6 +48,33 @@ public class ContactController {
private ContactFollowApiService contactFollowApiService;
@Autowired
private ContactLogApiService contactLogApiService;
@Autowired
private ContactConfigApiService contactConfigApiService;
@Autowired
private ESDataDynamicOperationApiService esDataDynamicOperationApiService;
/**
* 更新潜客分
* @param memberId
* @return
*/
@RequestMapping(path = "/potential-score")
public RestResponse<Void> potentialScore(String enterpriseId,String memberId,Integer potentialScore) {
DynamicDocDTO dynamicDocDTO = new DynamicDocDTO();
dynamicDocDTO.setEnterpriseId(enterpriseId);
dynamicDocDTO.setColumnCategoryCode("member");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", memberId);
jsonObject.put("memberId", memberId);
jsonObject.put("potentialScore", potentialScore);
dynamicDocDTO.setDocJson(jsonObject);
dynamicDocDTO.setRefresh(Constant.FLAG_TRUE);
ESResponse res = esDataDynamicOperationApiService.updateDataSingle(dynamicDocDTO, false);
if (res != null && Objects.equals(res.getErrCode(),"0")) {
return RestResponse.successResult();
}
return RestResponse.failure(res.getErrCode(), res.getErrMsg());
}
/**
* 添加跟进记录
......@@ -117,6 +152,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());
......@@ -124,4 +160,33 @@ public class ContactController {
return RestResponse.successResult();
}
/**
* 是否可以建联校验
* @param contactLogCheckQO
* @return
*/
@RequestMapping(path = "/check")
public RestResponse<ContactLogCheckVO> check(@RequestBody ContactLogCheckQO contactLogCheckQO) {
ContactLogCheckQDTO logCheckQDTO = EntityUtil.changeEntityNew(ContactLogCheckQDTO.class, contactLogCheckQO);
ServiceResponse<Boolean> serviceResponse = contactLogApiService.contactCheck(logCheckQDTO);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
return RestResponse.successResult(new ContactLogCheckVO(serviceResponse.getResult()));
}
/**
* 建联配置
* @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;
......
package com.gic.haoban.manage.web.qo.contact;
import java.io.Serializable;
public class ContactLogCheckQO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
/**
* 会员id
*/
private String memberId;
/**
* 导购id
*/
private String clerkId;
/**
* 企业id
*/
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;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getEnterpriseId() {
return enterpriseId;
}
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
package com.gic.haoban.manage.web.vo.contact;
import lombok.Data;
import java.io.Serializable;
@Data
public class ContactLogCheckVO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
/**
* 是否可以建联
*/
private Boolean check;
public ContactLogCheckVO() {
}
public ContactLogCheckVO(Boolean check) {
this.check = check;
}
}
\ No newline at end of file
......@@ -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