Commit 9be5cda1 by 王祖波

Merge branch 'feature-recommend2' into 'master'

Feature recommend2

See merge request !2914
parents 0ef5e146 10e50bb0
...@@ -18,6 +18,12 @@ public class ContactFollowDTO implements Serializable { ...@@ -18,6 +18,12 @@ public class ContactFollowDTO implements Serializable {
* 导购code * 导购code
*/ */
private String clerkCode; private String clerkCode;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/** /**
* 跟进记录 * 跟进记录
*/ */
...@@ -63,6 +69,14 @@ public class ContactFollowDTO implements Serializable { ...@@ -63,6 +69,14 @@ public class ContactFollowDTO implements Serializable {
this.clerkCode = clerkCode; this.clerkCode = clerkCode;
} }
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() { public String getFollowRemark() {
return followRemark; return followRemark;
} }
......
package com.gic.haoban.manage.api.enums.contact;
import org.apache.commons.lang3.StringUtils;
public enum ContactFollowTypeEnum {
PRIVATE_PHONE(1, "私人电话","私人电话"),
WECHAT_SESSION(2, "企微会话","企微会话"),
PRODUCT(3, "发送商品","商品"),
WECHAT_GROUP_SEND(4, "企微群发","企微群发"),
CONTACT(5, "标记建联","标记了建联");
private final int code;
private final String description;
private final String textMatch;
ContactFollowTypeEnum(int code, String description,String textMatch) {
this.code = code;
this.description = description;
this.textMatch = textMatch;
}
public String getTextMatch() {
return textMatch;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
public static ContactFollowTypeEnum fromCode(int code) {
for (ContactFollowTypeEnum type : values()) {
if (type.code == code) {
return type;
}
}
return null;
}
public static ContactFollowTypeEnum fromTextMatch(String textMatch) {
if (StringUtils.isBlank(textMatch)) {
return null;
}
for (ContactFollowTypeEnum type : values()) {
if (textMatch.contains(type.textMatch)) {
return type;
}
}
return null;
}
}
\ No newline at end of file
...@@ -19,6 +19,12 @@ public class ContactFollowBatchQDTO implements Serializable { ...@@ -19,6 +19,12 @@ public class ContactFollowBatchQDTO implements Serializable {
* 导购id * 导购id
*/ */
private String clerkId; private String clerkId;
/**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/** /**
* 跟进记录 * 跟进记录
*/ */
...@@ -48,6 +54,14 @@ public class ContactFollowBatchQDTO implements Serializable { ...@@ -48,6 +54,14 @@ public class ContactFollowBatchQDTO implements Serializable {
this.clerkId = clerkId; this.clerkId = clerkId;
} }
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() { public String getFollowRemark() {
return followRemark; return followRemark;
} }
......
...@@ -19,6 +19,11 @@ public class ContactFollowQDTO implements Serializable { ...@@ -19,6 +19,11 @@ public class ContactFollowQDTO implements Serializable {
*/ */
private String clerkCode; private String clerkCode;
/** /**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 跟进记录 * 跟进记录
*/ */
private String followRemark; private String followRemark;
...@@ -63,6 +68,14 @@ public class ContactFollowQDTO implements Serializable { ...@@ -63,6 +68,14 @@ public class ContactFollowQDTO implements Serializable {
this.clerkCode = clerkCode; this.clerkCode = clerkCode;
} }
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() { public String getFollowRemark() {
return followRemark; return followRemark;
} }
......
...@@ -28,6 +28,11 @@ public class TabContactFollow implements Serializable { ...@@ -28,6 +28,11 @@ public class TabContactFollow implements Serializable {
*/ */
private String clerkCode; private String clerkCode;
/** /**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 跟进记录 * 跟进记录
*/ */
private String followRemark; private String followRemark;
...@@ -92,6 +97,14 @@ public class TabContactFollow implements Serializable { ...@@ -92,6 +97,14 @@ public class TabContactFollow implements Serializable {
this.clerkCode = clerkCode; this.clerkCode = clerkCode;
} }
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() { public String getFollowRemark() {
return followRemark; return followRemark;
} }
......
...@@ -84,6 +84,10 @@ public class TabContactOrder implements Serializable { ...@@ -84,6 +84,10 @@ public class TabContactOrder implements Serializable {
*/ */
private Date potentialTime; private Date potentialTime;
/** /**
* 潜客分值
*/
private Integer potentialScore;
/**
* 是否删除 * 是否删除
*/ */
private Integer deleteFlag; private Integer deleteFlag;
...@@ -244,6 +248,14 @@ public class TabContactOrder implements Serializable { ...@@ -244,6 +248,14 @@ public class TabContactOrder implements Serializable {
this.potentialTime = potentialTime; this.potentialTime = potentialTime;
} }
public Integer getPotentialScore() {
return potentialScore;
}
public void setPotentialScore(Integer potentialScore) {
this.potentialScore = potentialScore;
}
public Integer getDeleteFlag() { public Integer getDeleteFlag() {
return deleteFlag; return deleteFlag;
} }
......
...@@ -12,6 +12,7 @@ import com.gic.commons.util.PageHelperUtils; ...@@ -12,6 +12,7 @@ import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO; import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.dto.contact.ContactFollowGoodsDTO; 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.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO; import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactFollowMapper; import com.gic.haoban.manage.service.dao.mapper.contact.TabContactFollowMapper;
...@@ -74,6 +75,13 @@ public class ContactFollowServiceImpl implements ContactFollowService { ...@@ -74,6 +75,13 @@ public class ContactFollowServiceImpl implements ContactFollowService {
if (CollectionUtils.isNotEmpty(follow.getGoodsInfoList())) { if (CollectionUtils.isNotEmpty(follow.getGoodsInfoList())) {
contactFollow.setGoodsInfo(JSON.toJSONString(follow.getGoodsInfoList())); contactFollow.setGoodsInfo(JSON.toJSONString(follow.getGoodsInfoList()));
} }
// 兼容不传followType的老版本
Integer followType = contactFollow.getFollowType();
if (followType == null) {
ContactFollowTypeEnum followTypeEnum = ContactFollowTypeEnum.fromTextMatch(contactFollow.getFollowRemark());
followType = Optional.ofNullable(followTypeEnum).map(ContactFollowTypeEnum::getCode).orElse(ContactFollowTypeEnum.CONTACT.getCode());
contactFollow.setFollowType(followType);
}
return contactFollow; return contactFollow;
}).filter(Objects::nonNull).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
contactFollowMapper.insertBatch(followList); contactFollowMapper.insertBatch(followList);
......
...@@ -143,11 +143,10 @@ public class ContactLogServiceImpl implements ContactLogService { ...@@ -143,11 +143,10 @@ public class ContactLogServiceImpl implements ContactLogService {
DynamicDocDTO dynamicDocDTO = new DynamicDocDTO(); DynamicDocDTO dynamicDocDTO = new DynamicDocDTO();
dynamicDocDTO.setEnterpriseId(enterpriseId); dynamicDocDTO.setEnterpriseId(enterpriseId);
dynamicDocDTO.setColumnCategoryCode("member"); dynamicDocDTO.setColumnCategoryCode("member");
MemberDataDTO memberDataDTO = new MemberDataDTO(); JSONObject jsonObject = new JSONObject();
memberDataDTO.setMemberId(memberId); jsonObject.put("id", memberId);
memberDataDTO.setId(memberId); jsonObject.put("memberId", memberId);
memberDataDTO.setClerkContactTime(contactTime); jsonObject.put("clerkContactTime", contactTime);
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(memberDataDTO));
dynamicDocDTO.setDocJson(jsonObject); dynamicDocDTO.setDocJson(jsonObject);
dynamicDocDTO.setRefresh(Constant.FLAG_TRUE); dynamicDocDTO.setRefresh(Constant.FLAG_TRUE);
ESResponse res = esDataDynamicOperationApiService.updateDataSingle(dynamicDocDTO, false); ESResponse res = esDataDynamicOperationApiService.updateDataSingle(dynamicDocDTO, false);
......
...@@ -60,16 +60,19 @@ public class ContactOrderServiceImpl implements ContactOrderService { ...@@ -60,16 +60,19 @@ public class ContactOrderServiceImpl implements ContactOrderService {
if (platformChannelEnum == null) { if (platformChannelEnum == null) {
return false; return false;
} }
TabContactOrder oldContactOrder = contactOrderMapper.queryByOrderId(orderInfoResp.getOrderId()); String orderId = orderInfoResp.getOrderId();
TabContactOrder oldContactOrder = contactOrderMapper.queryByOrderId(orderId);
if (oldContactOrder != null) { if (oldContactOrder != null) {
logger.info("订单已处理,订单id:{}", orderInfoResp.getOrderId()); logger.info("订单已处理,订单id:{}", orderId);
return false; return false;
} }
if (orderInfoResp.getOrderStatus() == null || orderInfoResp.getOrderStatus() != 1) { if (orderInfoResp.getOrderStatus() == null || orderInfoResp.getOrderStatus() != 1) {
logger.info("订单不是销售单"); logger.info("订单不是销售单");
return false; return false;
} }
logger.info("建联处理订单:{}", orderInfoResp.getOrderId()); String enterpriseId = orderInfoResp.getEnterpriseId();
String memberId = orderInfoResp.getMemberId();
logger.info("建联处理订单:{},memberId:{}", orderId,memberId);
Date receiptsDate = orderInfoResp.getReceiptsDate(); Date receiptsDate = orderInfoResp.getReceiptsDate();
Date contactBeginTime = null; Date contactBeginTime = null;
String channelCode = platformChannelEnum.getChannelCode(); String channelCode = platformChannelEnum.getChannelCode();
...@@ -83,14 +86,14 @@ public class ContactOrderServiceImpl implements ContactOrderService { ...@@ -83,14 +86,14 @@ public class ContactOrderServiceImpl implements ContactOrderService {
contactBeginTime = DateUtil.offsetDay(receiptsDate, -1); contactBeginTime = DateUtil.offsetDay(receiptsDate, -1);
} }
TabContactLog lastContactLog = contactLogService.getLastByTime(orderInfoResp.getMemberId(), contactBeginTime,receiptsDate); TabContactLog lastContactLog = contactLogService.getLastByTime(memberId, contactBeginTime,receiptsDate);
if (lastContactLog == null) { if (lastContactLog == null) {
return false; return false;
} }
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog)); logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder(); TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderInfoResp.getOrderId()); contactOrder.setOrderId(orderId);
contactOrder.setMemberId(orderInfoResp.getMemberId()); contactOrder.setMemberId(memberId);
contactOrder.setOrderNumber(orderInfoResp.getOrderNo()); contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
Double paidAmount = orderInfoResp.getPayAmount(); Double paidAmount = orderInfoResp.getPayAmount();
if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) { if (Objects.equals(PlatformChannelEnum.C_WECHAT_MINI.getChannelCode(), channelCode)) {
...@@ -115,6 +118,11 @@ public class ContactOrderServiceImpl implements ContactOrderService { ...@@ -115,6 +118,11 @@ public class ContactOrderServiceImpl implements ContactOrderService {
contactOrder.setContactTime(lastContactLog.getContactTime()); contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime()); contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId()); contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
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; return true;
} }
......
...@@ -33,15 +33,9 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService { ...@@ -33,15 +33,9 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
private ContactFollowService contactFollowService; private ContactFollowService contactFollowService;
@Autowired @Autowired
private ClerkService clerkService; private ClerkService clerkService;
@Autowired
private EnterpriseAdaptor enterpriseAdaptor;
@Override @Override
public ServiceResponse<Void> saveFollow(ContactFollowQDTO qdto) { public ServiceResponse<Void> saveFollow(ContactFollowQDTO qdto) {
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRight(qdto.getEnterpriseId(), EnterpriseServiceEnum.POTENTIAL.getRightMenuCode());
if (!hasRight) {
return ServiceResponse.success();
}
contactFollowService.saveFollow(qdto); contactFollowService.saveFollow(qdto);
return ServiceResponse.success(); return ServiceResponse.success();
} }
...@@ -51,10 +45,6 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService { ...@@ -51,10 +45,6 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return ServiceResponse.success(); return ServiceResponse.success();
} }
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRight(list.get(0).getEnterpriseId(), EnterpriseServiceEnum.POTENTIAL.getRightMenuCode());
if (!hasRight) {
return ServiceResponse.success();
}
contactFollowService.saveBatchFollow(list); contactFollowService.saveBatchFollow(list);
return ServiceResponse.success(); return ServiceResponse.success();
} }
...@@ -65,10 +55,6 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService { ...@@ -65,10 +55,6 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
return ServiceResponse.success(); return ServiceResponse.success();
} }
ContactFollowBatchQDTO qdto = JSONObject.parseObject(message, ContactFollowBatchQDTO.class); ContactFollowBatchQDTO qdto = JSONObject.parseObject(message, ContactFollowBatchQDTO.class);
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRight(qdto.getEnterpriseId(), EnterpriseServiceEnum.POTENTIAL.getRightMenuCode());
if (!hasRight) {
return ServiceResponse.success();
}
List<ContactFollowBatchQDTO.MemberFollow> memberList = qdto.getMemberList(); List<ContactFollowBatchQDTO.MemberFollow> memberList = qdto.getMemberList();
if (CollectionUtils.isEmpty(memberList)) { if (CollectionUtils.isEmpty(memberList)) {
return ServiceResponse.success(); return ServiceResponse.success();
......
...@@ -23,8 +23,6 @@ public class QwSendApiServiceImpl implements QwSendApiService { ...@@ -23,8 +23,6 @@ public class QwSendApiServiceImpl implements QwSendApiService {
@Autowired @Autowired
private QwSendMsgService qwSendMsgService; private QwSendMsgService qwSendMsgService;
@Autowired
private EnterpriseAdaptor enterpriseAdaptor;
@Override @Override
public ServiceResponse<Void> qwSendRefreshByMQ(String message) { public ServiceResponse<Void> qwSendRefreshByMQ(String message) {
...@@ -32,17 +30,13 @@ public class QwSendApiServiceImpl implements QwSendApiService { ...@@ -32,17 +30,13 @@ public class QwSendApiServiceImpl implements QwSendApiService {
return ServiceResponse.success(); return ServiceResponse.success();
} }
DealQwSendDTO dealQwSendDTO = JSONObject.parseObject(message, DealQwSendDTO.class); DealQwSendDTO dealQwSendDTO = JSONObject.parseObject(message, DealQwSendDTO.class);
boolean hasRight = enterpriseAdaptor.checkEnterpriseHasRight(dealQwSendDTO.getEnterpriseId(), EnterpriseServiceEnum.POTENTIAL.getRightMenuCode());
if (!hasRight) {
return ServiceResponse.success();
}
Integer refreshType = dealQwSendDTO.getRefreshType(); Integer refreshType = dealQwSendDTO.getRefreshType();
log.info("刷新企微发送记录:{}", message); log.info("刷新企微发送记录:{}", message);
if (Objects.equals(refreshType,1)) { if (Objects.equals(refreshType,1)) {
qwSendMsgService.finishQwSend(dealQwSendDTO.getFinishQwSend(),dealQwSendDTO.getTryCount()); qwSendMsgService.finishQwSend(dealQwSendDTO.getFinishQwSend(),dealQwSendDTO.getTryCount());
} else if (Objects.equals(refreshType, 2)) { } else if (Objects.equals(refreshType, 2)) {
qwSendMsgService.refreshQwSendLog(dealQwSendDTO.getQwSendMsg()); qwSendMsgService.refreshQwSendLog(dealQwSendDTO);
} }
return ServiceResponse.success(); return ServiceResponse.success();
} }
......
...@@ -20,8 +20,8 @@ public interface QwSendMsgService { ...@@ -20,8 +20,8 @@ public interface QwSendMsgService {
/** /**
* 刷新企微群结果 * 刷新企微群结果
* @param qwSendMsg * @param dealQwSendDTO
*/ */
void refreshQwSendLog(DealQwSendDTO.QwSendMsgBO qwSendMsg); void refreshQwSendLog(DealQwSendDTO dealQwSendDTO);
} }
...@@ -9,6 +9,7 @@ import com.gic.commons.util.UniqueIdUtils; ...@@ -9,6 +9,7 @@ import com.gic.commons.util.UniqueIdUtils;
import com.gic.content.api.utils.MqUtils; import com.gic.content.api.utils.MqUtils;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.dto.send.DealQwSendDTO; 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.qdto.contact.ContactFollowBatchQDTO;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService; import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.MessageApiService; import com.gic.haoban.manage.api.service.MessageApiService;
...@@ -101,11 +102,30 @@ public class QwSendMsgServiceImpl implements QwSendMsgService { ...@@ -101,11 +102,30 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
} }
@Override @Override
public void refreshQwSendLog(DealQwSendDTO.QwSendMsgBO qwSendMsg) { public void refreshQwSendLog(DealQwSendDTO dealQwSendDTO) {
DealQwSendDTO.QwSendMsgBO qwSendMsg = dealQwSendDTO.getQwSendMsg();
List<GroupSendResultBO> sendResultList = getSendResultList(qwSendMsg); List<GroupSendResultBO> sendResultList = getSendResultList(qwSendMsg);
if (CollectionUtils.isEmpty(sendResultList)) { if (CollectionUtils.isEmpty(sendResultList)) {
return; return;
} }
//判断是否已经发送
List<GroupSendResultBO> noSendList = sendResultList.stream().filter(dto -> Objects.equals(dto.getStatus(), 0))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(noSendList)) {
Integer tryCount = dealQwSendDTO.getTryCount();
if (tryCount != null && tryCount >= 10) {
log.info("查询超过次数限制:{}",qwSendMsg.getMsgId());
return;
}
if (tryCount == null) {
tryCount = 0;
}
// 重新刷新
dealQwSendDTO.setRefreshType(2);
dealQwSendDTO.setTryCount(++tryCount);
MqUtils.sendMessageToMQ("qwSendRefreshByMQ", JSON.toJSONString(dealQwSendDTO), 60);
return;
}
log.info("刷新企微群发结果:{}", qwSendMsg.getMsgId()); log.info("刷新企微群发结果:{}", qwSendMsg.getMsgId());
List<TabQwSendLog> entities; List<TabQwSendLog> entities;
List<List<GroupSendResultBO>> partition = Lists.partition(sendResultList, 1000); List<List<GroupSendResultBO>> partition = Lists.partition(sendResultList, 1000);
...@@ -162,10 +182,7 @@ public class QwSendMsgServiceImpl implements QwSendMsgService { ...@@ -162,10 +182,7 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
log.error("未查询到userid"); log.error("未查询到userid");
return Collections.emptyList(); return Collections.emptyList();
} }
List<GroupSendResultBO> sendResultList = getSendResult(qwSendMsg.getWxEnterpriseId(), qwSendMsg.getMsgId(), newWxUserId); return getSendResult(qwSendMsg.getWxEnterpriseId(), qwSendMsg.getMsgId(), newWxUserId);
//判断是否已经发送
return sendResultList.stream().filter(dto -> !Objects.equals(dto.getStatus(), 0))
.collect(Collectors.toList());
} }
public List<GroupSendResultBO> getSendResult(String wxEnterpriseId, String msgId, String userId) { public List<GroupSendResultBO> getSendResult(String wxEnterpriseId, String msgId, String userId) {
...@@ -236,6 +253,7 @@ public class QwSendMsgServiceImpl implements QwSendMsgService { ...@@ -236,6 +253,7 @@ public class QwSendMsgServiceImpl implements QwSendMsgService {
batchQDTO.setEnterpriseId(enterpriseId); batchQDTO.setEnterpriseId(enterpriseId);
batchQDTO.setMemberList(memberList); batchQDTO.setMemberList(memberList);
batchQDTO.setClerkId(clerkId); batchQDTO.setClerkId(clerkId);
batchQDTO.setFollowType(ContactFollowTypeEnum.WECHAT_GROUP_SEND.getCode());
batchQDTO.setFollowRemark("通过企微群发向客户发送了消息"); batchQDTO.setFollowRemark("通过企微群发向客户发送了消息");
MqUtils.sendMessageToMQ("saveBatchFollowForMQ", JSON.toJSONString(batchQDTO)); MqUtils.sendMessageToMQ("saveBatchFollowForMQ", JSON.toJSONString(batchQDTO));
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<result column="member_id" property="memberId" /> <result column="member_id" property="memberId" />
<result column="clerk_id" property="clerkId" /> <result column="clerk_id" property="clerkId" />
<result column="clerk_code" property="clerkCode" /> <result column="clerk_code" property="clerkCode" />
<result column="follow_type" property="followType" />
<result column="follow_remark" property="followRemark" /> <result column="follow_remark" property="followRemark" />
<result column="follow_material" property="followMaterial" /> <result column="follow_material" property="followMaterial" />
<result column="goods_info" property="goodsInfo" /> <result column="goods_info" property="goodsInfo" />
...@@ -20,10 +21,10 @@ ...@@ -20,10 +21,10 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
follow_id, member_id, clerk_id, clerk_code, 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, enterprise_id, delete_flag, create_time, update_time
</sql> </sql>
<sql id="Alias_Base_Column_List"> <sql id="Alias_Base_Column_List">
t.follow_id, t.member_id, t.clerk_id, t.clerk_code, 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.enterprise_id, t.delete_flag, t.create_time, t.update_time
</sql> </sql>
<select id="queryById" resultMap="BaseResultMap"> <select id="queryById" resultMap="BaseResultMap">
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
FROM tab_contact_follow FROM tab_contact_follow
<where> <where>
enterprise_id = #{enterpriseId} and delete_flag = 0 enterprise_id = #{enterpriseId} and delete_flag = 0 and follow_time >= now() - interval 6 month
<if test="search.clerkId != null and search.clerkId != ''"> <if test="search.clerkId != null and search.clerkId != ''">
AND clerk_id = #{search.clerkId} AND clerk_id = #{search.clerkId}
</if> </if>
...@@ -86,6 +87,7 @@ ...@@ -86,6 +87,7 @@
INNER JOIN ( SELECT clerk_id, member_id, MAX( follow_time ) AS max_follow_time FROM tab_contact_follow WHERE INNER JOIN ( SELECT clerk_id, member_id, MAX( follow_time ) AS max_follow_time FROM tab_contact_follow WHERE
enterprise_id = #{enterpriseId} enterprise_id = #{enterpriseId}
and delete_flag = 0 and delete_flag = 0
and follow_time >= now() - interval 6 month
and member_id IN and member_id IN
<foreach item="item" index="index" collection="memberIdList" open="(" separator="," close=")"> <foreach item="item" index="index" collection="memberIdList" open="(" separator="," close=")">
#{item} #{item}
...@@ -95,7 +97,7 @@ ...@@ -95,7 +97,7 @@
AND t.member_id = latest.member_id AND t.member_id = latest.member_id
AND t.follow_time = latest.max_follow_time AND t.follow_time = latest.max_follow_time
where t.enterprise_id = #{enterpriseId} where t.enterprise_id = #{enterpriseId}
and t.delete_flag = 0 and t.delete_flag = 0 and t.follow_time >= now() - interval 6 month
<if test="clerkId!=null and clerkId!=''"> <if test="clerkId!=null and clerkId!=''">
and t.clerk_id = #{clerkId} and t.clerk_id = #{clerkId}
</if> </if>
...@@ -107,15 +109,15 @@ ...@@ -107,15 +109,15 @@
</select> </select>
<insert id="insert" useGeneratedKeys="true" keyProperty="followId"> <insert id="insert" useGeneratedKeys="true" keyProperty="followId">
INSERT INTO tab_contact_follow (member_id, clerk_id, clerk_code, follow_remark, follow_material, goods_info, follow_time, enterprise_id, delete_flag, create_time, update_time) 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}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime}) VALUES (#{memberId}, #{clerkId}, #{clerkCode},#{followType}, #{followRemark}, #{followMaterial}, #{goodsInfo}, #{followTime}, #{enterpriseId}, #{deleteFlag}, #{createTime}, #{updateTime})
</insert> </insert>
<insert id="insertBatch"> <insert id="insertBatch">
INSERT INTO tab_contact_follow (follow_id,member_id, clerk_id, clerk_code, 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, enterprise_id)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.followId},#{item.memberId}, #{item.clerkId}, #{item.clerkCode}, #{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.enterpriseId})
</foreach> </foreach>
</insert> </insert>
...@@ -125,6 +127,7 @@ ...@@ -125,6 +127,7 @@
<if test="memberId != null">member_id = #{memberId},</if> <if test="memberId != null">member_id = #{memberId},</if>
<if test="clerkId != null">clerk_id = #{clerkId},</if> <if test="clerkId != null">clerk_id = #{clerkId},</if>
<if test="clerkCode != null">clerk_code = #{clerkCode},</if> <if test="clerkCode != null">clerk_code = #{clerkCode},</if>
<if test="followType != null">follow_type = #{followType},</if>
<if test="followRemark != null">follow_remark = #{followRemark},</if> <if test="followRemark != null">follow_remark = #{followRemark},</if>
<if test="followMaterial != null">follow_material = #{followMaterial},</if> <if test="followMaterial != null">follow_material = #{followMaterial},</if>
<if test="goodsInfo != null">goods_info = #{goodsInfo},</if> <if test="goodsInfo != null">goods_info = #{goodsInfo},</if>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<result column="contact_log_id" property="contactLogId" /> <result column="contact_log_id" property="contactLogId" />
<result column="contact_time" property="contactTime" /> <result column="contact_time" property="contactTime" />
<result column="potential_time" property="potentialTime" /> <result column="potential_time" property="potentialTime" />
<result column="potential_score" property="potentialScore" />
<result column="delete_flag" property="deleteFlag" /> <result column="delete_flag" property="deleteFlag" />
<result column="enterprise_id" property="enterpriseId" /> <result column="enterprise_id" property="enterpriseId" />
<result column="create_time" property="createTime" /> <result column="create_time" property="createTime" />
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <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, 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, delete_flag, enterprise_id, create_time, update_time
</sql> </sql>
<select id="queryById" resultMap="BaseResultMap"> <select id="queryById" resultMap="BaseResultMap">
...@@ -108,8 +109,8 @@ ...@@ -108,8 +109,8 @@
</select> </select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id"> <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, enterprise_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}, #{enterpriseId}) VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode},#{clerkName}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{potentialScore}, #{enterpriseId})
</insert> </insert>
<update id="update"> <update id="update">
...@@ -131,6 +132,7 @@ ...@@ -131,6 +132,7 @@
<if test="contactLogId != null">contact_log_id = #{contactLogId},</if> <if test="contactLogId != null">contact_log_id = #{contactLogId},</if>
<if test="contactTime != null">contact_time = #{contactTime},</if> <if test="contactTime != null">contact_time = #{contactTime},</if>
<if test="potentialTime != null">potential_time = #{potentialTime},</if> <if test="potentialTime != null">potential_time = #{potentialTime},</if>
<if test="potentialScore != null">potential_score = #{potentialScore},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if> <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if> <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
update_time = #{updateTime} update_time = #{updateTime}
......
...@@ -15,14 +15,18 @@ import com.gic.haoban.manage.api.service.contact.ContactFollowApiService; ...@@ -15,14 +15,18 @@ import com.gic.haoban.manage.api.service.contact.ContactFollowApiService;
import com.gic.haoban.manage.api.service.contact.ContactLogApiService; 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.ContactFollowPageQO;
import com.gic.haoban.manage.web.qo.contact.ContactFollowQO; 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.ContactLogQO;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -63,6 +67,29 @@ public class ContactController { ...@@ -63,6 +67,29 @@ public class ContactController {
} }
/** /**
* 会员最后一次跟进记录
* @param contactLastFollowQO
* @return
*/
@RequestMapping(path = "/last-follow")
public RestResponse<ContactFollowDTO> lastFollow(@RequestBody ContactLastFollowQO contactLastFollowQO) {
String memberId = contactLastFollowQO.getMemberId();
String enterpriseId = contactLastFollowQO.getEnterpriseId();
if (StringUtils.isAnyBlank(memberId,enterpriseId)) {
return RestResponse.successResult();
}
ServiceResponse<Map<String, ContactFollowDTO>> serviceResponse = contactFollowApiService.mapMemberLastFollow(enterpriseId,null, Lists.newArrayList(memberId));
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
if (serviceResponse.getResult() == null) {
return RestResponse.successResult();
}
ContactFollowDTO contactFollowDTO = serviceResponse.getResult().get(memberId);
return RestResponse.successResult(contactFollowDTO);
}
/**
* 分页查询跟进记录 * 分页查询跟进记录
* @param contactFollowPageQO * @param contactFollowPageQO
* @return * @return
......
...@@ -76,6 +76,7 @@ public class PotentialDataController { ...@@ -76,6 +76,7 @@ public class PotentialDataController {
String enterpriseId = contactOrderPageQO.getEnterpriseId(); String enterpriseId = contactOrderPageQO.getEnterpriseId();
String clerkId = contactOrderPageQO.getClerkId(); String clerkId = contactOrderPageQO.getClerkId();
String storeId = contactOrderPageQO.getStoreId(); String storeId = contactOrderPageQO.getStoreId();
String memberId = contactOrderPageQO.getMemberId();
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (StringUtils.isNotBlank(clerkId)) { if (StringUtils.isNotBlank(clerkId)) {
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId); ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
...@@ -102,6 +103,7 @@ public class PotentialDataController { ...@@ -102,6 +103,7 @@ public class PotentialDataController {
searchQDTO.setBeginTime(contactOrderPageQO.getBeginTime()); searchQDTO.setBeginTime(contactOrderPageQO.getBeginTime());
searchQDTO.setEndTime(contactOrderPageQO.getEndTime()); searchQDTO.setEndTime(contactOrderPageQO.getEndTime());
searchQDTO.setChannelType(contactOrderPageQO.getChannelType()); searchQDTO.setChannelType(contactOrderPageQO.getChannelType());
searchQDTO.setMemberId(memberId);
BasePageInfo basePageInfo = contactOrderPageQO.getBasePageInfo(); BasePageInfo basePageInfo = contactOrderPageQO.getBasePageInfo();
ServiceResponse<Page<ContactOrderDetailDTO>> serviceResponse = contactOrderApiService.pageContactOrder(enterpriseId,searchQDTO,basePageInfo); ServiceResponse<Page<ContactOrderDetailDTO>> serviceResponse = contactOrderApiService.pageContactOrder(enterpriseId,searchQDTO,basePageInfo);
if (!serviceResponse.isSuccess()) { if (!serviceResponse.isSuccess()) {
......
...@@ -194,6 +194,8 @@ public class PotentialDataAdaptor { ...@@ -194,6 +194,8 @@ public class PotentialDataAdaptor {
Integer reportType = potentialOverviewQO.getReportType(); Integer reportType = potentialOverviewQO.getReportType();
String bizDate = potentialOverviewQO.getBizDate(); String bizDate = potentialOverviewQO.getBizDate();
Integer potGroup = potentialOverviewQO.getPotGroup(); Integer potGroup = potentialOverviewQO.getPotGroup();
String clerkQuery = potentialOverviewQO.getClerkQuery();
String storeQuery = potentialOverviewQO.getStoreQuery();
Map<String, Object> inlineParams = getOverviewBaseParams(potentialOverviewQO, storeIds); Map<String, Object> inlineParams = getOverviewBaseParams(potentialOverviewQO, storeIds);
Pair<String, String> dateParam = getDateParam(reportType, bizDate); Pair<String, String> dateParam = getDateParam(reportType, bizDate);
String startDate = dateParam.getKey(); String startDate = dateParam.getKey();
...@@ -211,6 +213,12 @@ public class PotentialDataAdaptor { ...@@ -211,6 +213,12 @@ public class PotentialDataAdaptor {
if (reportType != null) { if (reportType != null) {
inlineParams.put("reportType", reportType); inlineParams.put("reportType", reportType);
} }
if (StringUtils.isNotBlank(clerkQuery)) {
inlineParams.put("clerkQuery", clerkQuery);
}
if (StringUtils.isNotBlank(storeQuery)) {
inlineParams.put("storeQuery", storeQuery);
}
return inlineParams; return inlineParams;
} }
...@@ -252,6 +260,9 @@ public class PotentialDataAdaptor { ...@@ -252,6 +260,9 @@ public class PotentialDataAdaptor {
if (reportType == null) { if (reportType == null) {
return new Pair<>("", ""); return new Pair<>("", "");
} }
if (StringUtils.isBlank(bizDate)) {
return new Pair<>("", "");
}
String endDate = bizDate; String endDate = bizDate;
String beginDate = bizDate; String beginDate = bizDate;
if (MaterialReportType.MONTH.getCode().equals(reportType)) { if (MaterialReportType.MONTH.getCode().equals(reportType)) {
......
...@@ -18,6 +18,12 @@ public class ContactFollowQO { ...@@ -18,6 +18,12 @@ public class ContactFollowQO {
private String clerkId; private String clerkId;
/** /**
* 跟进类型 1私人电话 2企微会话 3发送商品 4企微群发 5标记建联
* @see com.gic.haoban.manage.api.enums.contact.ContactFollowTypeEnum
*/
private Integer followType;
/**
* 跟进记录 * 跟进记录
*/ */
private String followRemark; private String followRemark;
...@@ -50,6 +56,14 @@ public class ContactFollowQO { ...@@ -50,6 +56,14 @@ public class ContactFollowQO {
this.clerkId = clerkId; this.clerkId = clerkId;
} }
public Integer getFollowType() {
return followType;
}
public void setFollowType(Integer followType) {
this.followType = followType;
}
public String getFollowRemark() { public String getFollowRemark() {
return followRemark; return followRemark;
} }
......
package com.gic.haoban.manage.web.qo.contact;
import lombok.Data;
/**
* Created by wangzubo on 2025/3/15.
*/
@Data
public class ContactLastFollowQO {
/**
* 会员id列表
*/
private String memberId;
/**
* 企业id
*/
private String enterpriseId;
}
...@@ -22,6 +22,11 @@ public class ContactOrderPageQO extends PageQo { ...@@ -22,6 +22,11 @@ public class ContactOrderPageQO extends PageQo {
private String storeId; private String storeId;
/** /**
* 会员id
*/
private String memberId;
/**
* 1 线上; 2 线下 * 1 线上; 2 线下
*/ */
private Integer channelType; private Integer channelType;
...@@ -64,6 +69,14 @@ public class ContactOrderPageQO extends PageQo { ...@@ -64,6 +69,14 @@ public class ContactOrderPageQO extends PageQo {
this.storeId = storeId; this.storeId = storeId;
} }
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public Integer getChannelType() { public Integer getChannelType() {
return channelType; return channelType;
} }
......
...@@ -35,6 +35,16 @@ public class PotentialStatisticsBaseQO extends BasePageInfo { ...@@ -35,6 +35,16 @@ public class PotentialStatisticsBaseQO extends BasePageInfo {
private String storeId; private String storeId;
/** /**
* 导购搜索
*/
private String clerkQuery;
/**
* 门店搜索
*/
private String storeQuery;
/**
* 门店id列表 * 门店id列表
*/ */
private List<String> storeIdList; private List<String> storeIdList;
......
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