Commit e5ffdfd3 by 王祖波

解决企微群发重复调用问题

parent 1c13eb18
......@@ -3,6 +3,7 @@ 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;
......@@ -32,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
......
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
......@@ -20,6 +20,7 @@ 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;
......@@ -74,6 +75,8 @@ public class ContactFollowServiceImpl implements ContactFollowService {
if (CollectionUtils.isEmpty(clerks)) {
return;
}
String enterpriseId = list.get(0).getEnterpriseId();
Integer followType = list.get(0).getFollowType();
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);
......@@ -90,14 +93,27 @@ 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 (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);
......
......@@ -105,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" />
......
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