Commit ab9f41af by 王祖波

同步建联

parent 4fedbb9c
......@@ -60,6 +60,25 @@ public class ContactLogDTO implements Serializable {
*/
private Date potentialTime;
/**
* 来源日志id
*/
private Long sourceLogId;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 跟进记录组
*/
private String followTypes;
/**
* 企业id
*/
private String enterpriseId;
......@@ -168,4 +187,35 @@ public class ContactLogDTO implements Serializable {
this.enterpriseId = enterpriseId;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getFollowTypes() {
return followTypes;
}
public void setFollowTypes(String followTypes) {
this.followTypes = followTypes;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.enums.contact;
import java.util.Objects;
public enum ContactBizTypeEnum {
// 业务类型 1潜客(0001)2机会人群(0010)
POTENTIAL_CUSTOMER("10",1,"潜客"),
OPPORTUNITY_CUSTOMER("20",2,"机会人群");
private final String codePre;
private final int type;
private final String description;
public String getCodePre() {
return codePre;
}
public int getType() {
return type;
}
public String getDescription() {
return description;
}
public Long getEsClerkContactTime(Long contactTime) {
if (Objects.equals(contactTime, -1L)) {
return null;
}
return Long.parseLong(this.getCodePre() + contactTime);
}
ContactBizTypeEnum(String codePre, int type, String description) {
this.codePre = codePre;
this.type = type;
this.description = description;
}
public static ContactBizTypeEnum fromCode(String code) {
for (ContactBizTypeEnum type : values()) {
if (Objects.equals(type.codePre,code)) {
return type;
}
}
return ContactBizTypeEnum.POTENTIAL_CUSTOMER;
}
public static ContactBizTypeEnum fromType(int type) {
for (ContactBizTypeEnum bizTypeEnum : values()) {
if (bizTypeEnum.type == type) {
return bizTypeEnum;
}
}
return ContactBizTypeEnum.POTENTIAL_CUSTOMER;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -25,6 +27,22 @@ public class ContactFollowBatchQDTO implements Serializable {
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 跟进记录
*/
......@@ -67,6 +85,30 @@ public class ContactFollowBatchQDTO implements Serializable {
this.followType = followType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getFollowRemark() {
return followRemark;
}
......
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -23,6 +25,24 @@ public class ContactFollowQDTO implements Serializable {
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 跟进记录
*/
......@@ -76,6 +96,30 @@ public class ContactFollowQDTO implements Serializable {
this.followType = followType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getFollowRemark() {
return followRemark;
}
......
......@@ -17,6 +17,12 @@ public class ContactLogCheckQDTO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)null为都校验
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType;
public String getMemberId() {
return memberId;
}
......@@ -40,4 +46,12 @@ public class ContactLogCheckQDTO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import com.gic.haoban.manage.api.enums.contact.ContactAutoTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum;
import java.io.Serializable;
import java.util.List;
public class ContactLogQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -24,11 +27,42 @@ public class ContactLogQDTO implements Serializable {
private String enterpriseId;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联 6自动建联 7营销素材
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType = ContactFollowTypeEnum.CONTACT.getCode();
/**
* 跟进记录
*/
private String followRemark;
/**
* 跟进上传素材,数组格式
*/
private List<String> followMaterialList;
/**
* 自动建联类型
* @see ContactAutoTypeEnum
*/
private Integer contactAutoType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 来源类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer sourceType;
/**
* 来源建联id
*/
private Long sourceLogId;
public ContactLogQDTO() {
}
......@@ -72,6 +106,30 @@ public class ContactLogQDTO implements Serializable {
this.enterpriseId = enterpriseId;
}
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() {
return followRemark;
}
public void setFollowRemark(String followRemark) {
this.followRemark = followRemark;
}
public List<String> getFollowMaterialList() {
return followMaterialList;
}
public void setFollowMaterialList(List<String> followMaterialList) {
this.followMaterialList = followMaterialList;
}
public Integer getContactAutoType() {
return contactAutoType;
}
......@@ -79,4 +137,28 @@ public class ContactLogQDTO implements Serializable {
public void setContactAutoType(Integer contactAutoType) {
this.contactAutoType = contactAutoType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.qdto.contact;
import cn.hutool.core.date.DateUtil;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.Date;
......@@ -43,6 +44,12 @@ public class ContactOrderSearchQDTO implements Serializable {
*/
private Date endTime;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
public String getMemberId() {
return memberId;
}
......@@ -102,4 +109,12 @@ public class ContactOrderSearchQDTO implements Serializable {
this.endTime = DateUtil.endOfDay(endTime);
}
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ import com.gic.haoban.manage.api.dto.contact.ContactLogDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogCheckQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import java.util.List;
public interface ContactLogApiService {
/**
......@@ -12,9 +14,17 @@ public interface ContactLogApiService {
* @param memberId
* @return
*/
@Deprecated
ServiceResponse<ContactLogDTO> getClerkContactTime(String memberId);
/**
* 获取每个业务最近一条有效建联记录
* @param memberId
* @return
*/
ServiceResponse<List<ContactLogDTO>> getClerkContactTimeList(String memberId);
/**
* 保存建联记录
* @param qdto
* @return
......
......@@ -93,6 +93,12 @@
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-app-performance-api</artifactId>
<version>${haoban-app-performance-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-api</artifactId>
<version>${gic-enterprise-api}</version>
<exclusions>
......
......@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactFollow;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
......@@ -50,6 +51,21 @@ public interface TabContactFollowMapper {
List<TabContactFollow> queryByIds(@Param("followIds") List<Long> followIds);
/**
* 获取时间段内跟进类型
* @param enterpriseId
* @param clerkId
* @param memberId
* @param beginTime
* @param endTime
* @return
*/
String getFollowTypes(@Param("enterpriseId") String enterpriseId,
@Param("clerkId") String clerkId,
@Param("memberId") String memberId,
@Param("beginTime") Date beginTime,
@Param("endTime") Date endTime);
/**
* 统计总行数
*
* @param tabContactFollow 查询条件
......
......@@ -35,7 +35,7 @@ public interface TabContactLogMapper {
* @param clerkId
* @return
*/
TabContactLog queryLastLog(@Param("memberId")String memberId, @Param("clerkId")String clerkId, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
List<TabContactLog> queryLastLog(@Param("memberId")String memberId, @Param("clerkId")String clerkId, @Param("beginTime")Date beginTime, @Param("endTime")Date endTime);
/**
* 统计总行数
......
......@@ -48,6 +48,22 @@ public class TabContactFollow implements Serializable {
* 跟进时间
*/
private Date followTime;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 业务id(建联日志id)
*/
private String bizId;
/**
* 企业id
*/
......@@ -137,6 +153,30 @@ public class TabContactFollow implements Serializable {
this.followTime = followTime;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public String getEnterpriseId() {
return enterpriseId;
}
......
......@@ -59,6 +59,31 @@ public class TabContactLog implements Serializable {
* 成为潜客时间
*/
private Date potentialTime;
/**
* 来源日志id
*/
private Long sourceLogId;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 业务冗余数据
*/
private String bizData;
/**
* 跟进记录组
*/
private String followTypes;
/**
* 企业id
*/
......@@ -172,6 +197,46 @@ public class TabContactLog implements Serializable {
this.potentialTime = potentialTime;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Long getSourceLogId() {
return sourceLogId;
}
public void setSourceLogId(Long sourceLogId) {
this.sourceLogId = sourceLogId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getBizData() {
return bizData;
}
public void setBizData(String bizData) {
this.bizData = bizData;
}
public String getFollowTypes() {
return followTypes;
}
public void setFollowTypes(String followTypes) {
this.followTypes = followTypes;
}
public String getEnterpriseId() {
return enterpriseId;
}
......
......@@ -88,6 +88,15 @@ public class TabContactOrder implements Serializable {
*/
private Integer potentialScore;
/**
* 来源类型 1潜客(0001)2机会人群(0010)
*/
private Integer sourceType;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
*/
private Integer bizType;
/**
* 是否删除
*/
private Integer deleteFlag;
......@@ -256,6 +265,22 @@ public class TabContactOrder implements Serializable {
this.potentialScore = potentialScore;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
......
......@@ -6,6 +6,8 @@ import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface ContactLogService {
......@@ -16,14 +18,14 @@ public interface ContactLogService {
* @param clerkDTO
* @return
*/
boolean contactCheck(String enterpriseId, String memberId, ClerkDTO clerkDTO) ;
boolean contactCheck(String enterpriseId, String memberId, ClerkDTO clerkDTO,Integer bizType) ;
/**
* 保存建联记录
*
* @param qdto
*/
TabContactLog saveContactLog(ContactLogQDTO qdto) throws BusinessException;
void saveContactLog(ContactLogQDTO qdto) throws BusinessException;
/**
* 自动建联
......@@ -32,12 +34,18 @@ public interface ContactLogService {
void autoContactLog(ContactLogQDTO qdto);
/**
* 同步建联
* @param qdto
*/
void syncContactLog(ContactLogQDTO qdto);
/**
* 清除建联状态
*
* @param memberId
* @param clearType 1 消费清除 2 换绑主导购
*/
void clearContactLog(String memberId, Integer clearType,String clerkId);
void clearContactLog(String enterpriseId,String memberId, Integer clearType,String clerkId);
/**
* 获取最近一条有效建联记录
......@@ -48,10 +56,19 @@ public interface ContactLogService {
TabContactLog getClerkContactTime(String memberId);
/**
* 根据时间获取最近一条建联记录
* 获取每个业务最近一条有效建联记录
* @param memberId
* @return
*/
List<TabContactLog> getClerkContactTimeList(String memberId);
/**
* 获取最近一条建联记录
* @param memberId
* @param clerkId
* @param beginTime
* @param endTime
* @return
*/
TabContactLog getLastByTime(String memberId, Date beginTime,Date endTime);
Map<Integer,TabContactLog> getLastByTime(String memberId, String clerkId, Date beginTime, Date endTime);
}
......@@ -103,7 +103,7 @@ public class ContactFollowServiceImpl implements ContactFollowService {
autoContactSend(followList);
}
private static void autoContactSend(List<TabContactFollow> followList) {
private void autoContactSend(List<TabContactFollow> followList) {
// 自动建联
Integer followType = followList.get(0).getFollowType();
Integer contactAutoType = ContactFollowTypeEnum.fromCode(followType).getContactAutoType();
......@@ -114,6 +114,8 @@ public class ContactFollowServiceImpl implements ContactFollowService {
contactLogQDTO.setClerkId(x.getClerkId());
contactLogQDTO.setEnterpriseId(x.getEnterpriseId());
contactLogQDTO.setContactAutoType(contactAutoType);
contactLogQDTO.setBizType(x.getSourceType());
contactLogQDTO.setSourceType(x.getSourceType());
return JSON.toJSONString(contactLogQDTO);
}).collect(Collectors.toList());
String routerName = "autoContactLogForMQ";
......
......@@ -91,44 +91,53 @@ public class ContactOrderServiceImpl implements ContactOrderService {
contactBeginTime = DateUtil.offsetDay(receiptsDate, -1);
}
TabContactLog lastContactLog = contactLogService.getLastByTime(memberId, contactBeginTime,receiptsDate);
if (lastContactLog == null) {
Map<Integer, TabContactLog> contactMap = contactLogService.getLastByTime(memberId, null, contactBeginTime, receiptsDate);
if (contactMap == null || contactMap.isEmpty()) {
return false;
}
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderId);
contactOrder.setMemberId(memberId);
contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
Double paidAmount = orderInfoResp.getPayAmount();
if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) {
paidAmount = paidAmount + (Objects.isNull(orderInfoResp.getDeliveryPaymentAmount()) ? 0.0 : orderInfoResp.getDeliveryPaymentAmount());
}
contactOrder.setPaidAmount(paidAmount);
contactOrder.setProductCount(orderInfoResp.getGoodsCount());
contactOrder.setPayTime(orderInfoResp.getReceiptsDate());
contactOrder.setReceiptsDate(orderInfoResp.getReceiptsDate());
List<OrderItemResp> orderItems = orderInfoResp.getOrderItems();
if (CollectionUtils.isNotEmpty(orderItems)) {
List<ContactOrderGoodsInfoDTO> goodsInfoDTOS = JSONObject.parseArray(JSON.toJSONString(orderItems), ContactOrderGoodsInfoDTO.class);
contactOrder.setGoodsInfo(JSON.toJSONString(goodsInfoDTOS));
}
contactOrder.setChannelCode(channelCode);
contactOrder.setChannelType(channelType);
contactOrder.setClerkId(lastContactLog.getClerkId());
contactOrder.setClerkCode(lastContactLog.getClerkCode());
contactOrder.setClerkName(lastContactLog.getClerkName());
contactOrder.setStoreId(lastContactLog.getStoreId());
contactOrder.setContactLogId(lastContactLog.getLogId());
contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
for (Map.Entry<Integer, TabContactLog> entry : contactMap.entrySet()) {
Integer key = entry.getKey();
TabContactLog lastContactLog = entry.getValue();
if (lastContactLog == null) {
continue;
}
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderId);
contactOrder.setMemberId(memberId);
contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
Double paidAmount = orderInfoResp.getPayAmount();
if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) {
paidAmount = paidAmount + (Objects.isNull(orderInfoResp.getDeliveryPaymentAmount()) ? 0.0 : orderInfoResp.getDeliveryPaymentAmount());
}
contactOrder.setPaidAmount(paidAmount);
contactOrder.setProductCount(orderInfoResp.getGoodsCount());
contactOrder.setPayTime(orderInfoResp.getReceiptsDate());
contactOrder.setReceiptsDate(orderInfoResp.getReceiptsDate());
List<OrderItemResp> orderItems = orderInfoResp.getOrderItems();
if (CollectionUtils.isNotEmpty(orderItems)) {
List<ContactOrderGoodsInfoDTO> goodsInfoDTOS = JSONObject.parseArray(JSON.toJSONString(orderItems), ContactOrderGoodsInfoDTO.class);
contactOrder.setGoodsInfo(JSON.toJSONString(goodsInfoDTOS));
}
contactOrder.setChannelCode(channelCode);
contactOrder.setChannelType(channelType);
contactOrder.setClerkId(lastContactLog.getClerkId());
contactOrder.setClerkCode(lastContactLog.getClerkCode());
contactOrder.setClerkName(lastContactLog.getClerkName());
contactOrder.setStoreId(lastContactLog.getStoreId());
contactOrder.setContactLogId(lastContactLog.getLogId());
contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setSourceType(lastContactLog.getSourceType());
contactOrder.setBizType(lastContactLog.getBizType());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
JSONObject jsonObject = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "potentialScore");
if (jsonObject != null && jsonObject.getInteger("potentialScore") != null) {
contactOrder.setPotentialScore(jsonObject.getInteger("potentialScore"));
JSONObject jsonObject = esMemberInfoService.queryDataSingle(enterpriseId, memberId, "potentialScore");
if (jsonObject != null && jsonObject.getInteger("potentialScore") != null) {
contactOrder.setPotentialScore(jsonObject.getInteger("potentialScore"));
}
contactOrderMapper.insert(contactOrder);
}
contactOrderMapper.insert(contactOrder);
return true;
}
......
......@@ -6,6 +6,7 @@ import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.EnterpriseUsingPermissionDto;
import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO;
import com.gic.enterprise.api.service.EnterpriseUseForbidService;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
......@@ -134,6 +135,17 @@ public class EnterpriseAdaptor {
return StringUtils.equals(cache, "1");
}
public boolean checkEnterpriseHasRightByContactBizType(String enterpriseId,Integer contactBizType) {
if (Objects.equals(contactBizType, ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType())) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(EnterpriseServiceEnum.POTENTIAL.getRightMenuCode()));
} else if (Objects.equals(contactBizType, ContactBizTypeEnum.OPPORTUNITY_CUSTOMER.getType())) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(EnterpriseServiceEnum.OBJECTIVES.getRightMenuCode()));
} else {
return checkEnterpriseHasRights(enterpriseId, Lists.newArrayList(EnterpriseServiceEnum.POTENTIAL.getRightMenuCode()))
|| checkEnterpriseHasRights(enterpriseId, Lists.newArrayList(EnterpriseServiceEnum.OBJECTIVES.getRightMenuCode()));
}
}
public boolean checkEnterpriseHasRight(String enterpriseId,String rightMenuCode) {
return checkEnterpriseHasRights(enterpriseId,Lists.newArrayList(rightMenuCode));
}
......
......@@ -31,12 +31,13 @@ public class RouterApiServiceImpl implements RouterApiService {
return ServiceResponse.success();
}
ClerkAddEventParam clerkAddEventParam = JSONObject.parseObject(params, ClerkAddEventParam.class);
String enterpriseId = clerkAddEventParam.getEnterpriseId();
String memberId = clerkAddEventParam.getMemberId();
Integer changeType = clerkAddEventParam.getChangeType();
String clerkId = clerkAddEventParam.getClerkId();
if (Objects.equals(changeType, 1)) {
// 换绑主导购清除建联状态
contactLogService.clearContactLog(memberId, 2, clerkId);
contactLogService.clearContactLog(enterpriseId,memberId, 2, clerkId);
}
return ServiceResponse.success();
}
......
......@@ -16,6 +16,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by wangzubo on 2022/11/1.
*/
......@@ -35,6 +38,16 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
}
@Override
public ServiceResponse<List<ContactLogDTO>> getClerkContactTimeList(String memberId) {
List<TabContactLog> list = contactLogService.getClerkContactTimeList(memberId);
if (list == null) {
return ServiceResponse.success(new ArrayList<>());
}
List<ContactLogDTO> dtos = EntityUtil.changeEntityListNew(ContactLogDTO.class, list);
return ServiceResponse.success(dtos);
}
@Override
public ServiceResponse<Void> saveContactLog(ContactLogQDTO qdto) {
try {
contactLogService.saveContactLog(qdto);
......@@ -50,7 +63,12 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
return ServiceResponse.success();
}
ContactLogQDTO contactLogQDTO = JSONObject.parseObject(message, ContactLogQDTO.class);
contactLogService.autoContactLog(contactLogQDTO);
Integer contactAutoType = contactLogQDTO.getContactAutoType();
if (contactAutoType != null) {
contactLogService.autoContactLog(contactLogQDTO);
}else {
contactLogService.syncContactLog(contactLogQDTO);
}
return ServiceResponse.success();
}
......@@ -60,7 +78,7 @@ public class ContactLogApiServiceImpl implements ContactLogApiService {
if (clerkDTO == null) {
return ServiceResponse.success(Boolean.FALSE);
}
boolean check = contactLogService.contactCheck(checkQDTO.getEnterpriseId(), checkQDTO.getMemberId(), clerkDTO);
boolean check = contactLogService.contactCheck(checkQDTO.getEnterpriseId(), checkQDTO.getMemberId(), clerkDTO,checkQDTO.getBizType());
return ServiceResponse.success(check);
}
}
......@@ -41,7 +41,7 @@ public class ContactOrderApiServiceImpl implements ContactOrderApiService {
OrderInfoResp result = serviceResponse.getResult();
boolean contactOrder = contactOrderService.saveContactOrder(result);
if (contactOrder) {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(enterpriseId,memberId, 1,"");
}
return ServiceResponse.success();
}
......
......@@ -180,6 +180,9 @@
<dubbo:reference id="customerApiService"
interface="com.gic.haoban.app.customer.service.api.service.CustomerApiService" timeout="10000"
retries="0" check="false"/>
<dubbo:reference id="objectivesManageApiService"
interface="com.gic.haoban.app.objectives.api.service.ObjectivesManageApiService" timeout="10000"
retries="0" check="false"/>
<dubbo:reference id="qywxTagSyncApiService"
interface="com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService" timeout="10000"
......
......@@ -14,6 +14,9 @@
<result column="follow_material" property="followMaterial" />
<result column="goods_info" property="goodsInfo" />
<result column="follow_time" property="followTime" />
<result column="source_type" property="sourceType" />
<result column="biz_type" property="bizType" />
<result column="biz_id" property="bizId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="delete_flag" property="deleteFlag" />
<result column="create_time" property="createTime" />
......@@ -21,10 +24,10 @@
</resultMap>
<sql id="Base_Column_List">
follow_id, member_id, clerk_id, clerk_code, follow_type,follow_remark, follow_material, goods_info, follow_time, enterprise_id, delete_flag, create_time, update_time
follow_id, member_id, clerk_id, clerk_code, follow_type,follow_remark, follow_material, goods_info, follow_time, source_type,biz_type,biz_id,enterprise_id, delete_flag, create_time, update_time
</sql>
<sql id="Alias_Base_Column_List">
t.follow_id, t.member_id, t.clerk_id, t.clerk_code, t.follow_type,t.follow_remark, t.follow_material, t.goods_info, t.follow_time, t.enterprise_id, t.delete_flag, t.create_time, t.update_time
t.follow_id, t.member_id, t.clerk_id, t.clerk_code, t.follow_type,t.follow_remark, t.follow_material, t.goods_info, t.follow_time,t.source_type,t.biz_type,t.biz_id, t.enterprise_id, t.delete_flag, t.create_time, t.update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
......@@ -44,6 +47,29 @@
</foreach>
</select>
<select id="getFollowTypes" resultType="java.lang.String">
SELECT
GROUP_CONCAT(DISTINCT follow_type)
FROM tab_contact_follow
<where>
enterprise_id = #{enterpriseId}
AND follow_type not in (5,6)
<if test="memberId != null">
AND member_id = #{memberId}
</if>
<if test="clerkId != null">
AND clerk_id = #{clerkId}
</if>
<if test="beginTime != null">
AND follow_time > #{beginTime}
</if>
<if test="endTime != null">
AND follow_time <![CDATA[<=]]> #{endTime}
</if>
</where>
group by member_id
</select>
<select id="count" resultType="long">
SELECT COUNT(*)
FROM tab_contact_follow
......@@ -109,16 +135,27 @@
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="followId">
INSERT INTO tab_contact_follow (member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, enterprise_id, delete_flag, create_time, update_time)
VALUES (#{memberId}, #{clerkId}, #{clerkCode},#{followType}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime})
INSERT INTO tab_contact_follow (member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, source_type,biz_type,biz_id,enterprise_id, delete_flag, create_time, update_time)
VALUES (#{memberId}, #{clerkId}, #{clerkCode},#{followType}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime},#{sourceType},#{bizType},#{bizId}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch">
INSERT INTO tab_contact_follow (follow_id,member_id, clerk_id, clerk_code,follow_type, follow_remark, follow_material, goods_info, follow_time, enterprise_id)
INSERT INTO tab_contact_follow (
follow_id, member_id, clerk_id, clerk_code,
follow_type, follow_remark, follow_material,
goods_info, follow_time, source_type, biz_type, biz_id, enterprise_id
)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.followId},#{item.memberId}, #{item.clerkId}, #{item.clerkCode}, #{item.followType},#{item.followRemark}, #{item.followMaterial}, #{item.goodsInfo}, #{item.followTime}, #{item.enterpriseId})
(#{item.followId}, #{item.memberId}, #{item.clerkId}, #{item.clerkCode},
#{item.followType}, #{item.followRemark}, #{item.followMaterial},
#{item.goodsInfo}, #{item.followTime}, #{sourceType}, #{bizType}, #{bizId}, #{item.enterpriseId})
</foreach>
ON DUPLICATE KEY UPDATE
biz_type = CASE
WHEN VALUES(biz_id) IS NOT NULL THEN biz_type + VALUES(biz_type)
ELSE biz_type
END
</insert>
<update id="update">
......@@ -132,6 +169,9 @@
<if test="followMaterial != null">follow_material = #{followMaterial},</if>
<if test="goodsInfo != null">goods_info = #{goodsInfo},</if>
<if test="followTime != null">follow_time = #{followTime},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
<if test="bizId != null">biz_id = #{bizId},</if>
<if test="source_type != null">source_type = #{sourceType},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
update_time = #{updateTime}
......
......@@ -14,6 +14,11 @@
<result property="contactCycle" column="contact_cycle" jdbcType="INTEGER"/>
<result property="contactCycleFirst" column="contact_cycle_first" jdbcType="INTEGER"/>
<result property="potentialTime" column="potential_time" jdbcType="TIMESTAMP"/>
<result property="sourceType" column="source_type" jdbcType="INTEGER"/>
<result property="sourceLogId" column="source_log_id" jdbcType="BIGINT"/>
<result property="bizType" column="biz_type" jdbcType="INTEGER" />
<result property="bizData" column="biz_data" jdbcType="VARCHAR" />
<result property="followTypes" column="follow_types" jdbcType="VARCHAR" />
<result property="enterpriseId" column="enterprise_id" jdbcType="VARCHAR"/>
<result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
......@@ -39,19 +44,41 @@
</select>
<select id="queryLastLog" resultMap="TabContactLogMap">
select *
from tab_contact_log
where delete_flag = 0 and member_id = #{memberId}
SELECT t1.*
FROM tab_contact_log t1
INNER JOIN (
SELECT biz_type, MAX(contact_time) AS max_contact_time
FROM tab_contact_log
WHERE delete_flag = 0
<if test="memberId != null">
AND member_id = #{memberId}
</if>
<if test="clerkId!=null and clerkId!=''">
and clerk_id = #{clerkId}
AND clerk_id = #{clerkId}
</if>
<if test="beginTime != null">
AND contact_time >= #{beginTime}
</if>
<if test="beginTime!=null ">
and contact_time >= #{beginTime}
<if test="endTime != null">
AND contact_time <![CDATA[<=]]> #{endTime}
</if>
GROUP BY biz_type
) t2
ON t1.biz_type = t2.biz_type AND t1.contact_time = t2.max_contact_time
WHERE t1.delete_flag = 0
<if test="memberId != null">
AND t1.member_id = #{memberId}
</if>
<if test="clerkId!=null and clerkId!=''">
AND t1.clerk_id = #{clerkId}
</if>
<if test="endTime!=null ">
and contact_time <![CDATA[<=]]> #{endTime}
<if test="beginTime != null">
AND t1.contact_time >= #{beginTime}
</if>
order by contact_time desc,log_id desc limit 1
<if test="endTime != null">
AND t1.contact_time <![CDATA[<=]]> #{endTime}
</if>
ORDER BY t1.biz_type ASC,t1.contact_time desc,t1.log_id desc
</select>
<!--查询列表-->
......@@ -128,6 +155,11 @@
contact_cycle,
contact_cycle_first,
potential_time,
source_type,
source_log_id,
biz_type,
biz_data,
follow_types,
enterprise_id
)
values (
......@@ -143,6 +175,11 @@
#{contactCycle},
#{contactCycleFirst},
#{potentialTime},
#{sourceType},
#{sourceLogId},
#{bizType},
#{bizData},
#{followTypes},
#{enterpriseId})
</insert>
......@@ -183,6 +220,21 @@
<if test="potentialTime != null">
potential_time = #{potentialTime},
</if>
<if test="sourceType != null">
source_type = #{sourceType},
</if>
<if test="sourceLogId != null">
source_log_id = #{sourceLogId},
</if>
<if test="bizType != null">
biz_type = #{bizType},
</if>
<if test="bizData != null">
biz_data = #{bizData},
</if>
<if test="followTypes != null">
follow_types = #{followTypes},
</if>
<if test="enterpriseId != null and enterpriseId != ''">
enterprise_id = #{enterpriseId},
</if>
......
......@@ -24,6 +24,8 @@
<result column="contact_time" property="contactTime" />
<result column="potential_time" property="potentialTime" />
<result column="potential_score" property="potentialScore" />
<result column="source_type" property="sourceType" />
<result column="biz_type" property="bizType" />
<result column="delete_flag" property="deleteFlag" />
<result column="enterprise_id" property="enterpriseId" />
<result column="create_time" property="createTime" />
......@@ -31,7 +33,7 @@
</resultMap>
<sql id="Base_Column_List">
id, order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time, potential_score, delete_flag, enterprise_id, create_time, update_time
id, order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time, potential_score,source_type,biz_type, delete_flag, enterprise_id, create_time, update_time
</sql>
<select id="queryById" resultMap="BaseResultMap">
......@@ -45,7 +47,7 @@
SELECT
<include refid="Base_Column_List" />
FROM tab_contact_order
WHERE order_id = #{orderId} and delete_flag = 0
WHERE order_id = #{orderId} and delete_flag = 0 limit 1
</select>
<select id="queryByIds" resultMap="BaseResultMap">
......@@ -74,6 +76,9 @@
<if test="search.channelType != null">
AND channel_type = #{search.channelType}
</if>
<if test="search.bizType != null">
AND biz_type = #{search.bizType}
</if>
<if test="search.storeIdList != null and search.storeIdList.size() > 0">
AND store_id IN
<foreach item="storeId" index="index" collection="search.storeIdList" open="(" separator="," close=")">
......@@ -109,8 +114,8 @@
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time,potential_score, enterprise_id)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode},#{clerkName}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{potentialScore}, #{enterpriseId})
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code,clerk_name, store_id, contact_log_id, contact_time, potential_time,potential_score, source_type,biz_type,enterprise_id)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode},#{clerkName}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{potentialScore}, #{sourceType},#{bizType},#{enterpriseId})
</insert>
<update id="update">
......@@ -133,6 +138,8 @@
<if test="contactTime != null">contact_time = #{contactTime},</if>
<if test="potentialTime != null">potential_time = #{potentialTime},</if>
<if test="potentialScore != null">potential_score = #{potentialScore},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
<if test="source_type != null">source_type = #{sourceType},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
update_time = #{updateTime}
......
......@@ -102,7 +102,7 @@ public class ContactTest {
@Test
public void clearContactLog() throws Exception {
contactLogService.clearContactLog(memberId, 1,"");
contactLogService.clearContactLog(eid,memberId, 1,"");
}
@Test
......
......@@ -120,6 +120,7 @@ public class ContactController {
@RequestMapping(path = "/log")
public RestResponse<Void> saveLog(@RequestBody ContactLogQO contactLogQO) {
ContactLogQDTO logQDTO = EntityUtil.changeEntityNew(ContactLogQDTO.class, contactLogQO);
logQDTO.setSourceType(contactLogQO.getBizType());
ServiceResponse<Void> serviceResponse = contactLogApiService.saveContactLog(logQDTO);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
......
......@@ -17,6 +17,12 @@ public class ContactLogCheckQO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)null为都校验
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType;
public String getMemberId() {
return memberId;
}
......@@ -40,4 +46,12 @@ public class ContactLogCheckQO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
\ No newline at end of file
package com.gic.haoban.manage.web.qo.contact;
import com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum;
import java.io.Serializable;
import java.util.List;
public class ContactLogQO implements Serializable {
private static final long serialVersionUID = 973688857967269973L;
......@@ -21,6 +24,21 @@ public class ContactLogQO implements Serializable {
*/
private String enterpriseId;
/**
* 业务类型 1潜客(0001)2机会人群(0010)
* @see com.gic.haoban.manage.api.enums.contact.ContactBizTypeEnum
*/
private Integer bizType = ContactBizTypeEnum.POTENTIAL_CUSTOMER.getType();
/**
* 跟进记录
*/
private String followRemark;
/**
* 跟进上传素材,数组格式
*/
private List<String> followMaterialList;
public String getMemberId() {
return memberId;
}
......@@ -52,4 +70,28 @@ public class ContactLogQO implements Serializable {
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getFollowRemark() {
return followRemark;
}
public void setFollowRemark(String followRemark) {
this.followRemark = followRemark;
}
public List<String> getFollowMaterialList() {
return followMaterialList;
}
public void setFollowMaterialList(List<String> followMaterialList) {
this.followMaterialList = followMaterialList;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment