|
|
|
|
@ -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());
|
|
|
|
|
|