发送消息

master
382696293@qq.com 2 years ago
parent 268ad8b703
commit 823f5db86c

@ -0,0 +1,27 @@
package com.flossom.common.core.enums;
/**
*
*
* @author flossom
*/
public enum IsScriptTemplateEnum {
SCRIPT_TEMPLATE(0, "话术模板"), CUSTOM_SCRIPT(1, "自定义话术");
private final Integer code;
private final String info;
IsScriptTemplateEnum(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -8,6 +8,8 @@ import com.flossom.common.core.domain.entity.SysTag;
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.WxUserIntegralMessageTypeEnum;
import com.flossom.common.core.mapper.*;
import com.flossom.common.core.utils.DateUtils;
@ -116,25 +118,32 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
@Transactional
public void sendScript(WxUserScriptReq wxUserScriptReq) {
List<Long> userIdList = wxUserScriptReq.getUserIdList();
// 保存消息
for (Long wxUserId : userIdList) {
WxUserScriptLog wxUserScriptLog = new WxUserScriptLog();
BeanUtils.copyProperties(wxUserScriptReq, wxUserScriptLog);
if (wxUserScriptReq.getTagIds() != null && wxUserScriptReq.getTagIds().size() > 0) {
wxUserScriptLog.setTagIds(wxUserScriptReq.getTagIds().stream().collect(Collectors.joining(",")));
}
wxUserScriptLog.setMessageType(WxUserIntegralMessageTypeEnum.MEMBER_MANAGEMENT.getCode());
wxUserScriptLog.setWxUserId(wxUserId);
wxUserScriptLog.setCreateBy(SecurityUtils.getUsername());
wxUserScriptLog.setCreateTime(DateUtils.getNowDate());
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
}
// 保存标签关联
if (wxUserScriptReq.getIsCustom() == 0) {
// 模板话术
// 1、话术模板
if (IsScriptTemplateEnum.SCRIPT_TEMPLATE.getCode() == wxUserScriptReq.getIsCustom()) {
// 1.1、保存消息
// 获取话术模板
Integer scriptTemplateId = wxUserScriptReq.getScriptTemplateId();
WxScriptTemplate wxScriptTemplate = wxScriptTemplateMapper.selectWxScriptTemplateById(scriptTemplateId.longValue());
for (Long wxUserId : userIdList) {
WxUserScriptLog wxUserScriptLog = new WxUserScriptLog();
BeanUtils.copyProperties(wxScriptTemplate, wxUserScriptLog);
wxUserScriptLog.setId(null);
wxUserScriptLog.setWxUserId(wxUserId);
wxUserScriptLog.setMessageType(WxUserIntegralMessageTypeEnum.MEMBER_MANAGEMENT.getCode());
wxUserScriptLog.setIsCustom(IsScriptTemplateEnum.SCRIPT_TEMPLATE.getCode());
wxUserScriptLog.setScriptTemplateId(scriptTemplateId);
wxUserScriptLog.setStatus(Status.OK.getCode());
wxUserScriptLog.setCreateBy(SecurityUtils.getUsername());
wxUserScriptLog.setCreateTime(DateUtils.getNowDate());
wxUserScriptLog.setUpdateBy(null);
wxUserScriptLog.setUpdateTime(null);
wxUserScriptLog.setRemark(null);
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());
@ -142,8 +151,23 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService {
wxUserMemberService.batchAddMiniProgramTag(tagList, collect);
}
}
if (wxUserScriptReq.getIsCustom() == 1) {
// 自定义话术
// 2、自定义话术
if (IsScriptTemplateEnum.CUSTOM_SCRIPT.getCode() == wxUserScriptReq.getIsCustom()) {
//2、1 保存消息
for (Long wxUserId : userIdList) {
WxUserScriptLog wxUserScriptLog = new WxUserScriptLog();
BeanUtils.copyProperties(wxUserScriptReq, wxUserScriptLog);
if (wxUserScriptReq.getTagIds() != null && wxUserScriptReq.getTagIds().size() > 0) {
wxUserScriptLog.setTagIds(wxUserScriptReq.getTagIds().stream().collect(Collectors.joining(",")));
}
wxUserScriptLog.setMessageType(WxUserIntegralMessageTypeEnum.MEMBER_MANAGEMENT.getCode());
wxUserScriptLog.setWxUserId(wxUserId);
wxUserScriptLog.setCreateBy(SecurityUtils.getUsername());
wxUserScriptLog.setCreateTime(DateUtils.getNowDate());
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
}
//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