批量发送话术,添加对应的标签

master
382696293@qq.com 2 years ago
parent f738853ae8
commit 4b04a31ad7

@ -26,6 +26,11 @@ public class WxScriptTag extends BaseEntity
@Excel(name = "标签主键")
private Long tagId;
/**
* 1 2
*/
private Integer tagType;
/** 状态0正常 1停用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private Long status;
@ -67,6 +72,14 @@ public class WxScriptTag extends BaseEntity
return status;
}
public Integer getTagType() {
return tagType;
}
public void setTagType(Integer tagType) {
this.tagType = tagType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="scriptId" column="script_id" />
<result property="tagId" column="tag_id" />
<result property="tagType" column="tag_type" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectWxScriptTagVo">
select id, script_id, tag_id, status, create_by, create_time, update_by, update_time, remark from wx_script_tag
select id, script_id, tag_id, tag_type, status, create_by, create_time, update_by, update_time, remark from wx_script_tag
</sql>
<select id="selectWxScriptTagList" parameterType="WxScriptTag" resultMap="WxScriptTagResult">
@ -39,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="scriptId != null">script_id,</if>
<if test="tagId != null">tag_id,</if>
<if test="tagType != null">tag_type,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
@ -49,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="scriptId != null">#{scriptId},</if>
<if test="tagId != null">#{tagId},</if>
<if test="tagType != null">#{tagType},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@ -63,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="scriptId != null">script_id = #{scriptId},</if>
<if test="tagId != null">tag_id = #{tagId},</if>
<if test="tagType != null">tag_type = #{tagType},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>

@ -89,6 +89,8 @@ IWxUserMemberService
List<Integer> selectUserCount();
public void batchAddWecomTag(List<Integer> tagIdList, List<Integer> userIdList);
void batchAddMiniProgramTag(List<Integer> tagId, List<Integer> userIds);
void batchDelMiniProgramTag(List<Integer> tagIdList, List<Integer> userIdList);

@ -155,6 +155,11 @@ public class WxScriptTemplateServiceImpl implements IWxScriptTemplateService {
WxScriptTag scriptTag = new WxScriptTag();
scriptTag.setScriptId(wxScriptTemplate.getId());
scriptTag.setTagId(tag.getId());
if(TagTypeStatus.MINI_PROGRAM.getCode() == wxScriptTemplate.getLevel().intValue()) {
scriptTag.setTagType(TagTypeStatus.MINI_PROGRAM.getCode());
} else {
scriptTag.setTagType(TagTypeStatus.ENTERPRISE_WECHAT.getCode());
}
scriptTag.setStatus(0l);
scriptTag.setCreateBy(SecurityUtils.getLoginUser().getUsername());
scriptTag.setCreateTime(DateUtils.getNowDate());
@ -211,6 +216,11 @@ public class WxScriptTemplateServiceImpl implements IWxScriptTemplateService {
WxScriptTag scriptTag = new WxScriptTag();
scriptTag.setScriptId(wxScriptTemplate.getId());
scriptTag.setTagId(tag.getId());
if(TagTypeStatus.MINI_PROGRAM.getCode() == Integer.valueOf(tag.getType())) {
scriptTag.setTagType(TagTypeStatus.MINI_PROGRAM.getCode());
} else {
scriptTag.setTagType(TagTypeStatus.ENTERPRISE_WECHAT.getCode());
}
scriptTag.setStatus(0l);
scriptTag.setCreateBy(SecurityUtils.getLoginUser().getUsername());
scriptTag.setCreateTime(DateUtils.getNowDate());

@ -231,6 +231,7 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
* @param tagIdList
* @param userIdList
*/
@Override
public void batchAddWecomTag(List<Integer> tagIdList, List<Integer> userIdList) {
batchAddTag(tagIdList, userIdList, TagTypeStatus.ENTERPRISE_WECHAT.getCode());
}

@ -1,15 +1,19 @@
package com.flossom.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.flossom.common.core.domain.entity.SysTag;
import com.flossom.common.core.domain.entity.WxScriptTag;
import com.flossom.common.core.domain.entity.WxScriptTemplate;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.domain.req.WxUserScriptReq;
import com.flossom.common.core.enums.IsScriptTemplateEnum;
import com.flossom.common.core.enums.Status;
import com.flossom.common.core.enums.TagTypeStatus;
import com.flossom.common.core.enums.WxUserIntegralMessageTypeEnum;
import com.flossom.common.core.mapper.*;
import com.flossom.common.core.utils.DateUtils;
@ -39,6 +43,9 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
@Autowired
private WxScriptTemplateMapper wxScriptTemplateMapper;
@Autowired
private WxScriptTagMapper wxScriptTagMapper;
/**
*
*
@ -135,12 +142,27 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
}
//1.2、 会员添加小程序标签
if (StringUtils.isNotBlank(wxScriptTemplate.getTagIds())) {
List<String> list = Arrays.asList(wxScriptTemplate.getTagIds().split(","));
List<Integer> tagList = list.stream().map(Integer::parseInt).collect(Collectors.toList());
//1.2、 会员添加标签
WxScriptTag wxScriptTag = new WxScriptTag();
wxScriptTag.setScriptId(wxScriptTemplate.getId());
List<WxScriptTag> wxScriptTagList = wxScriptTagMapper.selectWxScriptTagList(wxScriptTag);
if (wxScriptTagList != null && wxScriptTagList.size() > 0) {
// 小程序标签集合
List<Integer> miniProgramTagIdList = wxScriptTagList.stream()
.filter(scriptTag -> TagTypeStatus.MINI_PROGRAM.getCode().equals(scriptTag.getTagType()))
.map(WxScriptTag::getTagId)
.map(Long::intValue)
.collect(Collectors.toList());
// 企微标签集合
List<Integer> wecomTagIdList = wxScriptTagList.stream()
.filter(scriptTag -> TagTypeStatus.ENTERPRISE_WECHAT.getCode().equals(scriptTag.getTagType()))
.map(WxScriptTag::getTagId)
.map(Long::intValue)
.collect(Collectors.toList());
// 用户id集合
List<Integer> collect = userIdList.stream().map(Long::intValue).collect(Collectors.toList());
wxUserMemberService.batchAddMiniProgramTag(tagList, collect);
wxUserMemberService.batchAddMiniProgramTag(miniProgramTagIdList, collect);
wxUserMemberService.batchAddWecomTag(wecomTagIdList, collect);
}
}
@ -159,7 +181,7 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
wxUserScriptLog.setCreateTime(DateUtils.getNowDate());
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
}
//2、2 会员添加小程序标签
//2、2 会员添加标签
if (wxUserScriptReq.getTagIds() != null && wxUserScriptReq.getTagIds().size() > 0) {
List<Integer> tagList = wxUserScriptReq.getTagIds().stream().map(Integer::parseInt).collect(Collectors.toList());
List<Integer> collect = userIdList.stream().map(Long::intValue).collect(Collectors.toList());

Loading…
Cancel
Save