diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserScriptLog.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserScriptLog.java new file mode 100644 index 0000000..cc6779a --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserScriptLog.java @@ -0,0 +1,262 @@ +package com.flossom.common.core.domain.entity; + +import com.flossom.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 发送话术记录对象 wx_user_script_log + * + * @author flossom + * @date 2023-12-20 + */ +public class WxUserScriptLog extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * $column.columnComment + */ + private Long id; + + /** + * 话术接收人 + */ + private Long wxUserId; + + /** + * 是否已读:0否,1是 + */ + private Integer isRead; + + /** + * 是否自定义话术:0否,1是 + */ + private Integer isCustom; + + /** + * 当为 is_custom = 0,选择话术模板 + */ + private Integer scriptTemplateId; + + /** + * 话术名称 + */ + private String scriptName; + + /** + * 话术标题 + */ + private String titile; + + /** + * 话术内容 + */ + private String content; + + /** + * 标签类型:1小程序标签 2企微标签 + */ + private Integer tagType; + + /** + * 跳转类型:0无跳转、1跳转内部链接、3跳转外部链接、4跳转小程序、5导向视频号、6导向视频号直播间 + */ + private Integer type; + + /** + * 跳转链接(跳转外部链接、跳转内部链接) + */ + private String link; + + /** + * 跳转链接参数(跳转内部链接) + */ + private String linkParams; + + /** + * 外链小程序appid(跳转小程序) + */ + private String redirectAppid; + + /** + * 外链小程序url(跳转小程序) + */ + private String redirectUrl; + + /** + * 视频号(导向视频号、导向视频号直播间) + */ + private String videoNo; + + /** + * 视频号feedId(导向视频号) + */ + private String feedId; + + /** + * 标签名字(xxx,xxx,xxx) + */ + private String tagNames; + + /** + * 标签ID(xxxx,xxxx,xxx) + */ + private String tagIds; + + /** + * 状态(0正常 1停用) + */ + private Integer status; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWxUserId() { + return wxUserId; + } + + public void setWxUserId(Long wxUserId) { + this.wxUserId = wxUserId; + } + + public Integer getIsRead() { + return isRead; + } + + public void setIsRead(Integer isRead) { + this.isRead = isRead; + } + + public Integer getIsCustom() { + return isCustom; + } + + public void setIsCustom(Integer isCustom) { + this.isCustom = isCustom; + } + + public Integer getScriptTemplateId() { + return scriptTemplateId; + } + + public void setScriptTemplateId(Integer scriptTemplateId) { + this.scriptTemplateId = scriptTemplateId; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getTitile() { + return titile; + } + + public void setTitile(String titile) { + this.titile = titile; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getTagType() { + return tagType; + } + + public void setTagType(Integer tagType) { + this.tagType = tagType; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getLinkParams() { + return linkParams; + } + + public void setLinkParams(String linkParams) { + this.linkParams = linkParams; + } + + public String getRedirectAppid() { + return redirectAppid; + } + + public void setRedirectAppid(String redirectAppid) { + this.redirectAppid = redirectAppid; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public String getVideoNo() { + return videoNo; + } + + public void setVideoNo(String videoNo) { + this.videoNo = videoNo; + } + + public String getFeedId() { + return feedId; + } + + public void setFeedId(String feedId) { + this.feedId = feedId; + } + + public String getTagNames() { + return tagNames; + } + + public void setTagNames(String tagNames) { + this.tagNames = tagNames; + } + + public String getTagIds() { + return tagIds; + } + + public void setTagIds(String tagIds) { + this.tagIds = tagIds; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxUserScriptReq.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxUserScriptReq.java new file mode 100644 index 0000000..5df5be5 --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxUserScriptReq.java @@ -0,0 +1,234 @@ +package com.flossom.common.core.domain.req; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * 发送话术记录 请求对象 + * + * @author flossom + * @date 2023-12-20 + */ +public class WxUserScriptReq { + + /** + * 话术接收用户id + */ + @NotNull(message = "用户列表不能为空") + List userIdList; + + /** + * 是否自定义话术:0否,1是 + */ + @NotNull(message = "请选择是否自定义话术") + @Range(min = 0, max = 1) + private Integer isCustom; + + /** + * 当为 is_custom = 0,选择话术模板 + */ + private Integer scriptTemplateId; + + /** + * 话术名称 + */ + private String scriptName; + + /** + * 话术标题 + */ + private String titile; + + /** + * 话术内容 + */ + private String content; + + /** + * 标签类型:1小程序标签 2企微标签 + */ + private Integer tagType; + + /** + * 跳转类型:0无跳转、1跳转内部链接、3跳转外部链接、4跳转小程序、5导向视频号、6导向视频号直播间 + */ + @NotNull(message = "请选择跳转类型") + @Range(min = 0, max = 6) + private Integer type; + + /** + * 跳转链接(跳转外部链接、跳转内部链接) + */ + private String link; + + /** + * 跳转链接参数(跳转内部链接) + */ + private String linkParams; + + /** + * 外链小程序appid(跳转小程序) + */ + private String redirectAppid; + + /** + * 外链小程序url(跳转小程序) + */ + private String redirectUrl; + + /** + * 视频号(导向视频号、导向视频号直播间) + */ + private String videoNo; + + /** + * 视频号feedId(导向视频号) + */ + private String feedId; + + /** + * 标签名字(xxx,xxx,xxx) + */ + private String tagNames; + + /** + * 标签ID(xxxx,xxxx,xxx) + */ + private String tagIds; + + + public List getUserIdList() { + return userIdList; + } + + public void setUserIdList(List userIdList) { + this.userIdList = userIdList; + } + + public Integer getIsCustom() { + return isCustom; + } + + public void setIsCustom(Integer isCustom) { + this.isCustom = isCustom; + } + + public Integer getScriptTemplateId() { + return scriptTemplateId; + } + + public void setScriptTemplateId(Integer scriptTemplateId) { + this.scriptTemplateId = scriptTemplateId; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getTitile() { + return titile; + } + + public void setTitile(String titile) { + this.titile = titile; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getTagType() { + return tagType; + } + + public void setTagType(Integer tagType) { + this.tagType = tagType; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getLinkParams() { + return linkParams; + } + + public void setLinkParams(String linkParams) { + this.linkParams = linkParams; + } + + public String getRedirectAppid() { + return redirectAppid; + } + + public void setRedirectAppid(String redirectAppid) { + this.redirectAppid = redirectAppid; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public String getVideoNo() { + return videoNo; + } + + public void setVideoNo(String videoNo) { + this.videoNo = videoNo; + } + + public String getFeedId() { + return feedId; + } + + public void setFeedId(String feedId) { + this.feedId = feedId; + } + + public String getTagNames() { + return tagNames; + } + + public void setTagNames(String tagNames) { + this.tagNames = tagNames; + } + + public String getTagIds() { + return tagIds; + } + + public void setTagIds(String tagIds) { + this.tagIds = tagIds; + } + +} diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java new file mode 100644 index 0000000..2ea0e9a --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java @@ -0,0 +1,62 @@ +package com.flossom.common.core.mapper; + +import com.flossom.common.core.domain.entity.WxUserScriptLog; + +import java.util.List; + + +/** + * 发送话术记录Mapper接口 + * + * @author flossom + * @date 2023-12-20 + */ +public interface WxUserScriptLogMapper { + /** + * 查询发送话术记录 + * + * @param id 发送话术记录主键 + * @return 发送话术记录 + */ + public WxUserScriptLog selectWxUserScriptLogById(Long id); + + /** + * 查询发送话术记录列表 + * + * @param wxUserScriptLog 发送话术记录 + * @return 发送话术记录集合 + */ + public List selectWxUserScriptLogList(WxUserScriptLog wxUserScriptLog); + + /** + * 新增发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + public int insertWxUserScriptLog(WxUserScriptLog wxUserScriptLog); + + /** + * 修改发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + public int updateWxUserScriptLog(WxUserScriptLog wxUserScriptLog); + + /** + * 删除发送话术记录 + * + * @param id 发送话术记录主键 + * @return 结果 + */ + public int deleteWxUserScriptLogById(Long id); + + /** + * 批量删除发送话术记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWxUserScriptLogByIds(Long[] ids); +} diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml new file mode 100644 index 0000000..bf974dc --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, wx_user_id, is_read, is_custom, script_template_id, script_name, titile, content, tag_type, type, link, link_params, redirect_appid, redirect_url, video_no, feed_id, tag_names, tag_ids, status, create_by, create_time from wx_user_script_log + + + + + + + + insert into wx_user_script_log + + wx_user_id, + is_read, + is_custom, + script_template_id, + script_name, + titile, + content, + tag_type, + type, + link, + link_params, + redirect_appid, + redirect_url, + video_no, + feed_id, + tag_names, + tag_ids, + status, + create_by, + create_time, + + + #{wxUserId}, + #{isRead}, + #{isCustom}, + #{scriptTemplateId}, + #{scriptName}, + #{titile}, + #{content}, + #{tagType}, + #{type}, + #{link}, + #{linkParams}, + #{redirectAppid}, + #{redirectUrl}, + #{videoNo}, + #{feedId}, + #{tagNames}, + #{tagIds}, + #{status}, + #{createBy}, + #{createTime}, + + + + + update wx_user_script_log + + wx_user_id = #{wxUserId}, + is_read = #{isRead}, + is_custom = #{isCustom}, + script_template_id = #{scriptTemplateId}, + script_name = #{scriptName}, + titile = #{titile}, + content = #{content}, + tag_type = #{tagType}, + type = #{type}, + link = #{link}, + link_params = #{linkParams}, + redirect_appid = #{redirectAppid}, + redirect_url = #{redirectUrl}, + video_no = #{videoNo}, + feed_id = #{feedId}, + tag_names = #{tagNames}, + tag_ids = #{tagIds}, + status = #{status}, + create_by = #{createBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from wx_user_script_log where id = #{id} + + + + delete from wx_user_script_log where id in + + #{id} + + + \ No newline at end of file diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserScriptLogController.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserScriptLogController.java new file mode 100644 index 0000000..133e6a5 --- /dev/null +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserScriptLogController.java @@ -0,0 +1,164 @@ +package com.flossom.system.controller; + +import javax.servlet.http.HttpServletResponse; + +import com.flossom.common.core.domain.R; +import com.flossom.common.core.domain.entity.WxUserScriptLog; +import com.flossom.common.core.domain.req.WxUserScriptReq; +import com.flossom.common.core.exception.ServiceException; +import com.flossom.common.core.utils.StringUtils; +import com.flossom.common.core.utils.poi.ExcelUtil; +import com.flossom.common.core.web.controller.BaseController; +import com.flossom.common.core.web.domain.AjaxResult; +import com.flossom.common.core.web.page.TableDataInfo; +import com.flossom.common.log.annotation.Log; +import com.flossom.common.log.enums.BusinessType; +import com.flossom.common.security.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import com.flossom.system.service.IWxUserScriptLogService; + +import java.util.List; + +/** + * 发送话术记录Controller + * + * @author flossom + * @date 2023-12-20 + */ +@RestController +@RequestMapping("/userScriptLog") +public class WxUserScriptLogController extends BaseController { + + @Autowired + private IWxUserScriptLogService wxUserScriptLogService; + + /** + * 查询发送话术记录列表 + */ + @RequiresPermissions("system:user_script_log:list") + @GetMapping("/list") + public TableDataInfo list(WxUserScriptLog wxUserScriptLog) { + startPage(); + List list = wxUserScriptLogService.selectWxUserScriptLogList(wxUserScriptLog); + return getDataTable(list); + } + + /** + * 导出发送话术记录列表 + */ + @RequiresPermissions("system:user_script_log:export") + @Log(title = "发送话术记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, WxUserScriptLog wxUserScriptLog) { + List list = wxUserScriptLogService.selectWxUserScriptLogList(wxUserScriptLog); + ExcelUtil util = new ExcelUtil(WxUserScriptLog.class); + util.exportExcel(response, list, "发送话术记录数据"); + } + + /** + * 获取发送话术记录详细信息 + */ + @RequiresPermissions("system:user_script_log:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return success(wxUserScriptLogService.selectWxUserScriptLogById(id)); + } + + /** + * 新增发送话术记录 + */ + @RequiresPermissions("system:user_script_log:add") + @Log(title = "发送话术记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WxUserScriptLog wxUserScriptLog) { + return toAjax(wxUserScriptLogService.insertWxUserScriptLog(wxUserScriptLog)); + } + + /** + * 修改发送话术记录 + */ + @RequiresPermissions("system:user_script_log:edit") + @Log(title = "发送话术记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WxUserScriptLog wxUserScriptLog) { + return toAjax(wxUserScriptLogService.updateWxUserScriptLog(wxUserScriptLog)); + } + + /** + * 删除发送话术记录 + */ + @RequiresPermissions("system:user_script_log:remove") + @Log(title = "发送话术记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(wxUserScriptLogService.deleteWxUserScriptLogByIds(ids)); + } + + /** + * 发送话术 + * + * @return + */ + @PostMapping("/sendScript") + public R sendScript(@RequestBody @Validated WxUserScriptReq wxUserScriptReq) { + if (wxUserScriptReq.getIsCustom() == 0) { + // 模板话术 + if (wxUserScriptReq.getScriptTemplateId() == null || wxUserScriptReq.getScriptTemplateId() == 0) { + return R.fail("请选择话术模板"); + } + } else if (wxUserScriptReq.getIsCustom() == 1) { + // 自定义话术 + if(StringUtils.isBlank(wxUserScriptReq.getTitile())){ + return R.fail("请输入话术标题"); + } + if(StringUtils.isBlank(wxUserScriptReq.getContent())){ + return R.fail("请输入话术内容"); + } + // 跳转类型 + if (wxUserScriptReq.getType() == 1) { + // 1跳转内部链接 + if (StringUtils.isBlank(wxUserScriptReq.getLink())) { + return R.fail("请输入内部链接"); + } + if (StringUtils.isBlank(wxUserScriptReq.getLinkParams())) { + return R.fail("请输入跳转参数"); + } + } + if (wxUserScriptReq.getType() == 3) { + // 03跳转外部链接 + if (StringUtils.isBlank(wxUserScriptReq.getLink())) { + return R.fail("请输入外部链接地址"); + } + } + if (wxUserScriptReq.getType() == 4) { + // 4跳转小程序 + if (StringUtils.isBlank(wxUserScriptReq.getRedirectAppid())) { + return R.fail("请输入小程序appid"); + } + if (StringUtils.isBlank(wxUserScriptReq.getRedirectUrl())) { + return R.fail("请输入小程序页面地址"); + } + } + if (wxUserScriptReq.getType() == 5) { + // 5导向视频号 + if (StringUtils.isBlank(wxUserScriptReq.getVideoNo())) { + return R.fail("请输入视频号id"); + } + if (StringUtils.isBlank(wxUserScriptReq.getFeedId())) { + return R.fail("请输入视频号feedid"); + } + } + if (wxUserScriptReq.getType() == 6) { + // 6导向视频号直播间 + if (StringUtils.isBlank(wxUserScriptReq.getVideoNo())) { + return R.fail("请输入视频号id"); + } + } + } + wxUserScriptLogService.sendScript(wxUserScriptReq); + return R.ok(); + } + +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserScriptLogService.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserScriptLogService.java new file mode 100644 index 0000000..bb735c9 --- /dev/null +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserScriptLogService.java @@ -0,0 +1,64 @@ +package com.flossom.system.service; + +import com.flossom.common.core.domain.entity.WxUserScriptLog; +import com.flossom.common.core.domain.req.WxUserScriptReq; + +import java.util.List; + +/** + * 发送话术记录Service接口 + * + * @author flossom + * @date 2023-12-20 + */ +public interface IWxUserScriptLogService { + /** + * 查询发送话术记录 + * + * @param id 发送话术记录主键 + * @return 发送话术记录 + */ + public WxUserScriptLog selectWxUserScriptLogById(Long id); + + /** + * 查询发送话术记录列表 + * + * @param wxUserScriptLog 发送话术记录 + * @return 发送话术记录集合 + */ + public List selectWxUserScriptLogList(WxUserScriptLog wxUserScriptLog); + + /** + * 新增发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + public int insertWxUserScriptLog(WxUserScriptLog wxUserScriptLog); + + /** + * 修改发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + public int updateWxUserScriptLog(WxUserScriptLog wxUserScriptLog); + + /** + * 批量删除发送话术记录 + * + * @param ids 需要删除的发送话术记录主键集合 + * @return 结果 + */ + public int deleteWxUserScriptLogByIds(Long[] ids); + + /** + * 删除发送话术记录信息 + * + * @param id 发送话术记录主键 + * @return 结果 + */ + public int deleteWxUserScriptLogById(Long id); + + void sendScript(WxUserScriptReq wxUserScriptReq); +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java new file mode 100644 index 0000000..c7f99d0 --- /dev/null +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java @@ -0,0 +1,143 @@ +package com.flossom.system.service.impl; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +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.mapper.*; +import com.flossom.common.core.utils.DateUtils; +import com.flossom.common.core.utils.StringUtils; +import com.flossom.common.security.utils.SecurityUtils; +import com.flossom.system.service.IWxUserMemberService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.flossom.system.service.IWxUserScriptLogService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 发送话术记录Service业务层处理 + * + * @author flossom + * @date 2023-12-20 + */ +@Service +public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService { + @Autowired + private WxUserScriptLogMapper wxUserScriptLogMapper; + + @Autowired + private IWxUserMemberService wxUserMemberService; + + @Autowired + private WxScriptTemplateMapper wxScriptTemplateMapper; + + /** + * 查询发送话术记录 + * + * @param id 发送话术记录主键 + * @return 发送话术记录 + */ + @Override + public WxUserScriptLog selectWxUserScriptLogById(Long id) { + return wxUserScriptLogMapper.selectWxUserScriptLogById(id); + } + + /** + * 查询发送话术记录列表 + * + * @param wxUserScriptLog 发送话术记录 + * @return 发送话术记录 + */ + @Override + public List selectWxUserScriptLogList(WxUserScriptLog wxUserScriptLog) { + return wxUserScriptLogMapper.selectWxUserScriptLogList(wxUserScriptLog); + } + + /** + * 新增发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + @Override + public int insertWxUserScriptLog(WxUserScriptLog wxUserScriptLog) { + wxUserScriptLog.setCreateTime(DateUtils.getNowDate()); + return wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog); + } + + /** + * 修改发送话术记录 + * + * @param wxUserScriptLog 发送话术记录 + * @return 结果 + */ + @Override + public int updateWxUserScriptLog(WxUserScriptLog wxUserScriptLog) { + return wxUserScriptLogMapper.updateWxUserScriptLog(wxUserScriptLog); + } + + /** + * 批量删除发送话术记录 + * + * @param ids 需要删除的发送话术记录主键 + * @return 结果 + */ + @Override + public int deleteWxUserScriptLogByIds(Long[] ids) { + return wxUserScriptLogMapper.deleteWxUserScriptLogByIds(ids); + } + + /** + * 删除发送话术记录信息 + * + * @param id 发送话术记录主键 + * @return 结果 + */ + @Override + public int deleteWxUserScriptLogById(Long id) { + return wxUserScriptLogMapper.deleteWxUserScriptLogById(id); + } + + @Override + @Transactional + public void sendScript(WxUserScriptReq wxUserScriptReq) { + List userIdList = wxUserScriptReq.getUserIdList(); + // 保存消息 + for (Long wxUserId : userIdList) { + WxUserScriptLog wxUserScriptLog = new WxUserScriptLog(); + BeanUtils.copyProperties(wxUserScriptReq, wxUserScriptLog); + wxUserScriptLog.setWxUserId(wxUserId); + wxUserScriptLog.setCreateBy(SecurityUtils.getUsername()); + wxUserScriptLog.setCreateTime(DateUtils.getNowDate()); + wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog); + } + + // 保存标签关联 + if (wxUserScriptReq.getIsCustom() == 0) { + // 模板话术 + Integer scriptTemplateId = wxUserScriptReq.getScriptTemplateId(); + WxScriptTemplate wxScriptTemplate = wxScriptTemplateMapper.selectWxScriptTemplateById(scriptTemplateId.longValue()); + if (StringUtils.isNotBlank(wxScriptTemplate.getTagIds())) { + List list = Arrays.asList(wxScriptTemplate.getTagIds().split(",")); + List tagList = list.stream().map(Integer::parseInt).collect(Collectors.toList()); + List collect = userIdList.stream().map(Long::intValue).collect(Collectors.toList()); + wxUserMemberService.batchAddMiniProgramTag(tagList, collect); + } + } + if (wxUserScriptReq.getIsCustom() == 1) { + // 自定义话术 + if (StringUtils.isNotBlank(wxUserScriptReq.getTagIds())) { + List list = Arrays.asList(wxUserScriptReq.getTagIds().split(",")); + List tagList = list.stream().map(Integer::parseInt).collect(Collectors.toList()); + List collect = userIdList.stream().map(Long::intValue).collect(Collectors.toList()); + wxUserMemberService.batchAddMiniProgramTag(tagList, collect); + } + } + + } +}